svr4_misc.c (84783) | svr4_misc.c (89306) |
---|---|
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: --- 11 unchanged lines hidden (view full) --- 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 * | 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: --- 11 unchanged lines hidden (view full) --- 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 * $FreeBSD: head/sys/compat/svr4/svr4_misc.c 84783 2001-10-10 23:06:54Z ps $ | 28 * $FreeBSD: head/sys/compat/svr4/svr4_misc.c 89306 2002-01-13 11:58:06Z alfred $ |
29 */ 30 31/* 32 * SVR4 compatibility module. 33 * 34 * SVR4 system calls that are implemented differently in BSD are 35 * handled here. 36 */ --- 221 unchanged lines hidden (view full) --- 258 int ncookies; 259 260 DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n", 261 td->td_proc->p_pid, SCARG(uap, fd), SCARG(uap, nbytes))); 262 if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) { 263 return (error); 264 } 265 | 29 */ 30 31/* 32 * SVR4 compatibility module. 33 * 34 * SVR4 system calls that are implemented differently in BSD are 35 * handled here. 36 */ --- 221 unchanged lines hidden (view full) --- 258 int ncookies; 259 260 DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n", 261 td->td_proc->p_pid, SCARG(uap, fd), SCARG(uap, nbytes))); 262 if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) { 263 return (error); 264 } 265 |
266 if ((fp->f_flag & FREAD) == 0) | 266 if ((fp->f_flag & FREAD) == 0) { 267 fdrop(fp, td); |
267 return (EBADF); | 268 return (EBADF); |
269 } |
|
268 269 vp = (struct vnode *) fp->f_data; 270 | 270 271 vp = (struct vnode *) fp->f_data; 272 |
271 if (vp->v_type != VDIR) | 273 if (vp->v_type != VDIR) { 274 fdrop(fp, td); |
272 return (EINVAL); | 275 return (EINVAL); |
276 } |
|
273 274 if ((error = VOP_GETATTR(vp, &va, td->td_proc->p_ucred, td))) { | 277 278 if ((error = VOP_GETATTR(vp, &va, td->td_proc->p_ucred, td))) { |
279 fdrop(fp, td); |
|
275 return error; 276 } 277 278 nbytes = SCARG(uap, nbytes); 279 if (nbytes == 1) { 280 nbytes = sizeof (struct svr4_dirent64); 281 justone = 1; 282 } --- 112 unchanged lines hidden (view full) --- 395 fp->f_offset = off; 396 397 if (justone) 398 nbytes = resid + svr4reclen; 399 400eof: 401 td->td_retval[0] = nbytes - resid; 402out: | 280 return error; 281 } 282 283 nbytes = SCARG(uap, nbytes); 284 if (nbytes == 1) { 285 nbytes = sizeof (struct svr4_dirent64); 286 justone = 1; 287 } --- 112 unchanged lines hidden (view full) --- 400 fp->f_offset = off; 401 402 if (justone) 403 nbytes = resid + svr4reclen; 404 405eof: 406 td->td_retval[0] = nbytes - resid; 407out: |
408 VOP_UNLOCK(vp, 0, td); 409 fdrop(fp, td); |
|
403 if (cookies) 404 free(cookies, M_TEMP); | 410 if (cookies) 411 free(cookies, M_TEMP); |
405 VOP_UNLOCK(vp, 0, td); | |
406 free(buf, M_TEMP); 407 return error; 408} 409 410 411int 412svr4_sys_getdents(td, uap) 413 struct thread *td; --- 12 unchanged lines hidden (view full) --- 426 off_t off; /* true file offset */ 427 int buflen, error, eofflag; 428 u_long *cookiebuf = NULL, *cookie; 429 int ncookies = 0, *retval = td->td_retval; 430 431 if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) 432 return (error); 433 | 412 free(buf, M_TEMP); 413 return error; 414} 415 416 417int 418svr4_sys_getdents(td, uap) 419 struct thread *td; --- 12 unchanged lines hidden (view full) --- 432 off_t off; /* true file offset */ 433 int buflen, error, eofflag; 434 u_long *cookiebuf = NULL, *cookie; 435 int ncookies = 0, *retval = td->td_retval; 436 437 if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) 438 return (error); 439 |
434 if ((fp->f_flag & FREAD) == 0) | 440 if ((fp->f_flag & FREAD) == 0) { 441 fdrop(fp, td); |
435 return (EBADF); | 442 return (EBADF); |
443 } |
|
436 437 vp = (struct vnode *)fp->f_data; | 444 445 vp = (struct vnode *)fp->f_data; |
438 if (vp->v_type != VDIR) | 446 if (vp->v_type != VDIR) { 447 fdrop(fp, td); |
439 return (EINVAL); | 448 return (EINVAL); |
449 } |
|
440 441 buflen = min(MAXBSIZE, SCARG(uap, nbytes)); 442 buf = malloc(buflen, M_TEMP, M_WAITOK); 443 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 444 off = fp->f_offset; 445again: 446 aiov.iov_base = buf; 447 aiov.iov_len = buflen; --- 5 unchanged lines hidden (view full) --- 453 auio.uio_resid = buflen; 454 auio.uio_offset = off; 455 /* 456 * First we read into the malloc'ed buffer, then 457 * we massage it into user space, one record at a time. 458 */ 459 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, 460 &cookiebuf); | 450 451 buflen = min(MAXBSIZE, SCARG(uap, nbytes)); 452 buf = malloc(buflen, M_TEMP, M_WAITOK); 453 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 454 off = fp->f_offset; 455again: 456 aiov.iov_base = buf; 457 aiov.iov_len = buflen; --- 5 unchanged lines hidden (view full) --- 463 auio.uio_resid = buflen; 464 auio.uio_offset = off; 465 /* 466 * First we read into the malloc'ed buffer, then 467 * we massage it into user space, one record at a time. 468 */ 469 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, 470 &cookiebuf); |
461 if (error) | 471 if (error) { |
462 goto out; | 472 goto out; |
473 } |
|
463 464 inp = buf; 465 outp = SCARG(uap, buf); 466 resid = SCARG(uap, nbytes); 467 if ((len = buflen - auio.uio_resid) == 0) 468 goto eof; 469 470 for (cookie = cookiebuf; len > 0; len -= reclen) { --- 39 unchanged lines hidden (view full) --- 510 if (outp == SCARG(uap, buf)) 511 goto again; 512 fp->f_offset = off; /* update the vnode offset */ 513 514eof: 515 *retval = SCARG(uap, nbytes) - resid; 516out: 517 VOP_UNLOCK(vp, 0, td); | 474 475 inp = buf; 476 outp = SCARG(uap, buf); 477 resid = SCARG(uap, nbytes); 478 if ((len = buflen - auio.uio_resid) == 0) 479 goto eof; 480 481 for (cookie = cookiebuf; len > 0; len -= reclen) { --- 39 unchanged lines hidden (view full) --- 521 if (outp == SCARG(uap, buf)) 522 goto again; 523 fp->f_offset = off; /* update the vnode offset */ 524 525eof: 526 *retval = SCARG(uap, nbytes) - resid; 527out: 528 VOP_UNLOCK(vp, 0, td); |
529 fdrop(fp, td); |
|
518 if (cookiebuf) 519 free(cookiebuf, M_TEMP); 520 free(buf, M_TEMP); 521 return error; 522} 523 524 525int --- 76 unchanged lines hidden (view full) --- 602 vp = (struct vnode *) fp->f_data; 603 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 604 if (vp->v_type != VDIR) 605 error = ENOTDIR; 606 else 607 error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); 608 VOP_UNLOCK(vp, 0, td); 609 if (error) | 530 if (cookiebuf) 531 free(cookiebuf, M_TEMP); 532 free(buf, M_TEMP); 533 return error; 534} 535 536 537int --- 76 unchanged lines hidden (view full) --- 614 vp = (struct vnode *) fp->f_data; 615 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 616 if (vp->v_type != VDIR) 617 error = ENOTDIR; 618 else 619 error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); 620 VOP_UNLOCK(vp, 0, td); 621 if (error) |
622 fdrop(fp, td); |
|
610 return error; | 623 return error; |
624 } |
|
611 VREF(vp); | 625 VREF(vp); |
612 if (fdp->fd_rdir != NULL) 613 vrele(fdp->fd_rdir); | 626 FILEDESC_LOCK(fdp); 627 vpold = fdp->fd_rdir; |
614 fdp->fd_rdir = vp; | 628 fdp->fd_rdir = vp; |
629 FILEDESC_UNLOCK(fdp); 630 if (vpold != NULL) 631 vrele(vpold); 632 fdrop(fp, td); |
|
615 return 0; 616} 617 618 619static int 620svr4_mknod(td, retval, path, mode, dev) 621 struct thread *td; 622 register_t *retval; --- 593 unchanged lines hidden (view full) --- 1216 DPRINTF(("waitsys(%d, %d, %p, %x)\n", 1217 SCARG(uap, grp), SCARG(uap, id), 1218 SCARG(uap, info), SCARG(uap, options))); 1219 1220loop: 1221 nfound = 0; 1222 sx_slock(&proctree_lock); 1223 LIST_FOREACH(q, &td->td_proc->p_children, p_sibling) { | 633 return 0; 634} 635 636 637static int 638svr4_mknod(td, retval, path, mode, dev) 639 struct thread *td; 640 register_t *retval; --- 593 unchanged lines hidden (view full) --- 1234 DPRINTF(("waitsys(%d, %d, %p, %x)\n", 1235 SCARG(uap, grp), SCARG(uap, id), 1236 SCARG(uap, info), SCARG(uap, options))); 1237 1238loop: 1239 nfound = 0; 1240 sx_slock(&proctree_lock); 1241 LIST_FOREACH(q, &td->td_proc->p_children, p_sibling) { |
1242 PROC_LOCK(q); |
|
1224 if (SCARG(uap, id) != WAIT_ANY && 1225 q->p_pid != SCARG(uap, id) && 1226 q->p_pgid != -SCARG(uap, id)) { | 1243 if (SCARG(uap, id) != WAIT_ANY && 1244 q->p_pid != SCARG(uap, id) && 1245 q->p_pgid != -SCARG(uap, id)) { |
1246 PROC_UNLOCK(q); |
|
1227 DPRINTF(("pid %d pgid %d != %d\n", q->p_pid, 1228 q->p_pgid, SCARG(uap, id))); 1229 continue; 1230 } 1231 nfound++; | 1247 DPRINTF(("pid %d pgid %d != %d\n", q->p_pid, 1248 q->p_pgid, SCARG(uap, id))); 1249 continue; 1250 } 1251 nfound++; |
1232 PROC_LOCK(q); | |
1233 mtx_lock_spin(&sched_lock); 1234 if (q->p_stat == SZOMB && 1235 ((SCARG(uap, options) & (SVR4_WEXITED|SVR4_WTRAPPED)))) { 1236 mtx_unlock_spin(&sched_lock); 1237 PROC_UNLOCK(q); 1238 sx_sunlock(&proctree_lock); 1239 *retval = 0; 1240 DPRINTF(("found %d\n", q->p_pid)); --- 475 unchanged lines hidden --- | 1252 mtx_lock_spin(&sched_lock); 1253 if (q->p_stat == SZOMB && 1254 ((SCARG(uap, options) & (SVR4_WEXITED|SVR4_WTRAPPED)))) { 1255 mtx_unlock_spin(&sched_lock); 1256 PROC_UNLOCK(q); 1257 sx_sunlock(&proctree_lock); 1258 *retval = 0; 1259 DPRINTF(("found %d\n", q->p_pid)); --- 475 unchanged lines hidden --- |