svr4_stat.c (46112) | svr4_stat.c (49264) |
---|---|
1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 * 28 * $Id$ |
|
27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/namei.h> 32#include <sys/proc.h> 33#include <sys/file.h> 34#include <sys/stat.h> --- 120 unchanged lines hidden (view full) --- 155 strcpy(st4->st_fstype, "unknown"); 156} 157 158int 159svr4_sys_stat(p, uap) 160 struct proc *p; 161 struct svr4_sys_stat_args *uap; 162{ | 29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/namei.h> 34#include <sys/proc.h> 35#include <sys/file.h> 36#include <sys/stat.h> --- 120 unchanged lines hidden (view full) --- 157 strcpy(st4->st_fstype, "unknown"); 158} 159 160int 161svr4_sys_stat(p, uap) 162 struct proc *p; 163 struct svr4_sys_stat_args *uap; 164{ |
163 int *retval; 164#ifdef SVR4_NO_OSTAT 165 struct svr4_sys_xstat_args cup; 166 167 retval = &(p->p_retval[0]); 168 SCARG(&cup, two) = 2; 169 SCARG(&cup, path) = SCARG(uap, path); 170 SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub); 171 return svr4_sys_xstat(p, &cup, retval); 172#else | |
173 struct stat st; 174 struct svr4_stat svr4_st; 175 struct stat_args cup; 176 int error; 177 caddr_t sg = stackgap_init(); 178 | 165 struct stat st; 166 struct svr4_stat svr4_st; 167 struct stat_args cup; 168 int error; 169 caddr_t sg = stackgap_init(); 170 |
179 retval = p->p_retval; | |
180 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 181 182 SCARG(&cup, path) = SCARG(uap, path); 183 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 184 185 186 if ((error = stat(p, &cup)) != 0) 187 return error; --- 5 unchanged lines hidden (view full) --- 193 194 if (S_ISSOCK(st.st_mode)) 195 (void) svr4_add_socket(p, SCARG(uap, path), &st); 196 197 if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) 198 return error; 199 200 return 0; | 171 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 172 173 SCARG(&cup, path) = SCARG(uap, path); 174 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 175 176 177 if ((error = stat(p, &cup)) != 0) 178 return error; --- 5 unchanged lines hidden (view full) --- 184 185 if (S_ISSOCK(st.st_mode)) 186 (void) svr4_add_socket(p, SCARG(uap, path), &st); 187 188 if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) 189 return error; 190 191 return 0; |
201#endif | |
202} 203 204 205int 206svr4_sys_lstat(p, uap) 207 register struct proc *p; 208 struct svr4_sys_lstat_args *uap; 209{ | 192} 193 194 195int 196svr4_sys_lstat(p, uap) 197 register struct proc *p; 198 struct svr4_sys_lstat_args *uap; 199{ |
210 int *retval; | |
211 struct stat st; 212 struct svr4_stat svr4_st; 213 struct lstat_args cup; 214 int error; | 200 struct stat st; 201 struct svr4_stat svr4_st; 202 struct lstat_args cup; 203 int error; |
215 caddr_t sg = stackgap_init(); | 204 caddr_t sg = stackgap_init(); |
216 | 205 |
217 retval = p->p_retval; | |
218 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 219 220 SCARG(&cup, path) = SCARG(uap, path); 221 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 222 223 if ((error = lstat(p, &cup)) != 0) 224 return error; 225 --- 15 unchanged lines hidden (view full) --- 241int 242svr4_sys_fstat(p, uap) 243 register struct proc *p; 244 struct svr4_sys_fstat_args *uap; 245{ 246 struct stat st; 247 struct svr4_stat svr4_st; 248 struct fstat_args cup; | 206 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 207 208 SCARG(&cup, path) = SCARG(uap, path); 209 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 210 211 if ((error = lstat(p, &cup)) != 0) 212 return error; 213 --- 15 unchanged lines hidden (view full) --- 229int 230svr4_sys_fstat(p, uap) 231 register struct proc *p; 232 struct svr4_sys_fstat_args *uap; 233{ 234 struct stat st; 235 struct svr4_stat svr4_st; 236 struct fstat_args cup; |
249 int error, *retval; 250 caddr_t sg = stackgap_init(); | 237 int error; 238 caddr_t sg = stackgap_init(); |
251 | 239 |
252 retval = p->p_retval; | |
253 SCARG(&cup, fd) = SCARG(uap, fd); 254 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); 255 256 if ((error = fstat(p, &cup)) != 0) 257 return error; 258 259 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) 260 return error; --- 10 unchanged lines hidden (view full) --- 271int 272svr4_sys_xstat(p, uap) 273 register struct proc *p; 274 struct svr4_sys_xstat_args *uap; 275{ 276 struct stat st; 277 struct svr4_xstat svr4_st; 278 struct stat_args cup; | 240 SCARG(&cup, fd) = SCARG(uap, fd); 241 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); 242 243 if ((error = fstat(p, &cup)) != 0) 244 return error; 245 246 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) 247 return error; --- 10 unchanged lines hidden (view full) --- 258int 259svr4_sys_xstat(p, uap) 260 register struct proc *p; 261 struct svr4_sys_xstat_args *uap; 262{ 263 struct stat st; 264 struct svr4_xstat svr4_st; 265 struct stat_args cup; |
279 int error, *retval; | 266 int error; |
280 281 caddr_t sg = stackgap_init(); 282 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 283 | 267 268 caddr_t sg = stackgap_init(); 269 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 270 |
284 retval = p->p_retval; | |
285 SCARG(&cup, path) = SCARG(uap, path); 286 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 287 288 if ((error = stat(p, &cup)) != 0) 289 return error; 290 291 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) 292 return error; --- 11 unchanged lines hidden (view full) --- 304 return 0; 305} 306 307int 308svr4_sys_lxstat(p, uap) 309 register struct proc *p; 310 struct svr4_sys_lxstat_args *uap; 311{ | 271 SCARG(&cup, path) = SCARG(uap, path); 272 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 273 274 if ((error = stat(p, &cup)) != 0) 275 return error; 276 277 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) 278 return error; --- 11 unchanged lines hidden (view full) --- 290 return 0; 291} 292 293int 294svr4_sys_lxstat(p, uap) 295 register struct proc *p; 296 struct svr4_sys_lxstat_args *uap; 297{ |
312 int *retval; | |
313 struct stat st; 314 struct svr4_xstat svr4_st; 315 struct lstat_args cup; 316 int error; 317 caddr_t sg = stackgap_init(); 318 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 319 | 298 struct stat st; 299 struct svr4_xstat svr4_st; 300 struct lstat_args cup; 301 int error; 302 caddr_t sg = stackgap_init(); 303 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 304 |
320 retval = p->p_retval; 321 | |
322 SCARG(&cup, path) = SCARG(uap, path); 323 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 324 325 if ((error = lstat(p, &cup)) != 0) 326 return error; 327 328 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) 329 return error; --- 11 unchanged lines hidden (view full) --- 341} 342 343 344int 345svr4_sys_fxstat(p, uap) 346 register struct proc *p; 347 struct svr4_sys_fxstat_args *uap; 348{ | 305 SCARG(&cup, path) = SCARG(uap, path); 306 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 307 308 if ((error = lstat(p, &cup)) != 0) 309 return error; 310 311 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) 312 return error; --- 11 unchanged lines hidden (view full) --- 324} 325 326 327int 328svr4_sys_fxstat(p, uap) 329 register struct proc *p; 330 struct svr4_sys_fxstat_args *uap; 331{ |
349 int *retval; | |
350 struct stat st; 351 struct svr4_xstat svr4_st; 352 struct fstat_args cup; 353 int error; 354 355 caddr_t sg = stackgap_init(); 356 | 332 struct stat st; 333 struct svr4_xstat svr4_st; 334 struct fstat_args cup; 335 int error; 336 337 caddr_t sg = stackgap_init(); 338 |
357 retval = p->p_retval; | |
358 SCARG(&cup, fd) = SCARG(uap, fd); 359 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); 360 361 if ((error = fstat(p, &cup)) != 0) 362 return error; 363 364 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) 365 return error; --- 9 unchanged lines hidden (view full) --- 375int 376svr4_sys_stat64(p, uap) 377 register struct proc *p; 378 struct svr4_sys_stat64_args *uap; 379{ 380 struct stat st; 381 struct svr4_stat64 svr4_st; 382 struct stat_args cup; | 339 SCARG(&cup, fd) = SCARG(uap, fd); 340 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); 341 342 if ((error = fstat(p, &cup)) != 0) 343 return error; 344 345 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) 346 return error; --- 9 unchanged lines hidden (view full) --- 356int 357svr4_sys_stat64(p, uap) 358 register struct proc *p; 359 struct svr4_sys_stat64_args *uap; 360{ 361 struct stat st; 362 struct svr4_stat64 svr4_st; 363 struct stat_args cup; |
383 int error, *retval; 384 caddr_t sg = stackgap_init(); | 364 int error; 365 caddr_t sg = stackgap_init(); |
385 | 366 |
386 retval = p->p_retval; | |
387 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 388 389 SCARG(&cup, path) = SCARG(uap, path); 390 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 391 392 if ((error = stat(p, &cup)) != 0) 393 return error; 394 --- 15 unchanged lines hidden (view full) --- 410int 411svr4_sys_lstat64(p, uap) 412 register struct proc *p; 413 struct svr4_sys_lstat64_args *uap; 414{ 415 struct stat st; 416 struct svr4_stat64 svr4_st; 417 struct stat_args cup; | 367 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 368 369 SCARG(&cup, path) = SCARG(uap, path); 370 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 371 372 if ((error = stat(p, &cup)) != 0) 373 return error; 374 --- 15 unchanged lines hidden (view full) --- 390int 391svr4_sys_lstat64(p, uap) 392 register struct proc *p; 393 struct svr4_sys_lstat64_args *uap; 394{ 395 struct stat st; 396 struct svr4_stat64 svr4_st; 397 struct stat_args cup; |
418 int error, *retval; 419 caddr_t sg = stackgap_init(); | 398 int error; 399 caddr_t sg = stackgap_init(); |
420 | 400 |
421 retval = p->p_retval; 422 | |
423 CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path)); 424 425 SCARG(&cup, path) = SCARG(uap, path); 426 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 427 428 if ((error = lstat(p, (struct lstat_args *)&cup)) != 0) 429 return error; 430 --- 15 unchanged lines hidden (view full) --- 446int 447svr4_sys_fstat64(p, uap) 448 register struct proc *p; 449 struct svr4_sys_fstat64_args *uap; 450{ 451 struct stat st; 452 struct svr4_stat64 svr4_st; 453 struct fstat_args cup; | 401 CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path)); 402 403 SCARG(&cup, path) = SCARG(uap, path); 404 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); 405 406 if ((error = lstat(p, (struct lstat_args *)&cup)) != 0) 407 return error; 408 --- 15 unchanged lines hidden (view full) --- 424int 425svr4_sys_fstat64(p, uap) 426 register struct proc *p; 427 struct svr4_sys_fstat64_args *uap; 428{ 429 struct stat st; 430 struct svr4_stat64 svr4_st; 431 struct fstat_args cup; |
454 int error, *retval; | 432 int error; |
455 caddr_t sg = stackgap_init(); 456 | 433 caddr_t sg = stackgap_init(); 434 |
457 retval = p->p_retval; 458 | |
459 SCARG(&cup, fd) = SCARG(uap, fd); 460 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); 461 462 if ((error = fstat(p, &cup)) != 0) 463 return error; 464 465 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) 466 return error; --- 58 unchanged lines hidden (view full) --- 525 sizeof(struct svr4_utsname)); 526} 527 528int 529svr4_sys_systeminfo(p, uap) 530 struct proc *p; 531 struct svr4_sys_systeminfo_args *uap; 532{ | 435 SCARG(&cup, fd) = SCARG(uap, fd); 436 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); 437 438 if ((error = fstat(p, &cup)) != 0) 439 return error; 440 441 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) 442 return error; --- 58 unchanged lines hidden (view full) --- 501 sizeof(struct svr4_utsname)); 502} 503 504int 505svr4_sys_systeminfo(p, uap) 506 struct proc *p; 507 struct svr4_sys_systeminfo_args *uap; 508{ |
533 char *str = NULL; 534 int error = 0, *retval = p->p_retval; 535 size_t len = 0; 536 char buf[1]; /* XXX NetBSD uses 256, but that seems like awfully 537 excessive kstack usage for an empty string... */ 538 u_int rlen = SCARG(uap, len); | 509 char *str = NULL; 510 int error = 0; 511 register_t *retval = p->p_retval; 512 size_t len = 0; 513 char buf[1]; /* XXX NetBSD uses 256, but that seems 514 like awfully excessive kstack usage 515 for an empty string... */ 516 u_int rlen = SCARG(uap, len); |
539 540 switch (SCARG(uap, what)) { 541 case SVR4_SI_SYSNAME: 542 str = ostype; 543 break; 544 545 case SVR4_SI_HOSTNAME: 546 str = hostname; --- 209 unchanged lines hidden (view full) --- 756} 757 758 759int 760svr4_sys_pathconf(p, uap) 761 register struct proc *p; 762 struct svr4_sys_pathconf_args *uap; 763{ | 517 518 switch (SCARG(uap, what)) { 519 case SVR4_SI_SYSNAME: 520 str = ostype; 521 break; 522 523 case SVR4_SI_HOSTNAME: 524 str = hostname; --- 209 unchanged lines hidden (view full) --- 734} 735 736 737int 738svr4_sys_pathconf(p, uap) 739 register struct proc *p; 740 struct svr4_sys_pathconf_args *uap; 741{ |
764 caddr_t sg = stackgap_init(); 765 int *retval = p->p_retval; | 742 caddr_t sg = stackgap_init(); 743 register_t *retval = p->p_retval; |
766 767 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 768 769 SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name)); 770 771 switch (SCARG(uap, name)) { 772 case -1: 773 *retval = -1; --- 7 unchanged lines hidden (view full) --- 781} 782 783 784int 785svr4_sys_fpathconf(p, uap) 786 register struct proc *p; 787 struct svr4_sys_fpathconf_args *uap; 788{ | 744 745 CHECKALTEXIST(p, &sg, SCARG(uap, path)); 746 747 SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name)); 748 749 switch (SCARG(uap, name)) { 750 case -1: 751 *retval = -1; --- 7 unchanged lines hidden (view full) --- 759} 760 761 762int 763svr4_sys_fpathconf(p, uap) 764 register struct proc *p; 765 struct svr4_sys_fpathconf_args *uap; 766{ |
789 int *retval = p->p_retval; | 767 register_t *retval = p->p_retval; |
790 791 SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name)); 792 793 switch (SCARG(uap, name)) { 794 case -1: 795 *retval = -1; 796 return EINVAL; 797 case 0: 798 *retval = 0; 799 return 0; 800 default: 801 return fpathconf(p, (struct fpathconf_args *)uap); 802 } 803} | 768 769 SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name)); 770 771 switch (SCARG(uap, name)) { 772 case -1: 773 *retval = -1; 774 return EINVAL; 775 case 0: 776 *retval = 0; 777 return 0; 778 default: 779 return fpathconf(p, (struct fpathconf_args *)uap); 780 } 781} |