Deleted Added
full compact
vfs_extattr.c (3167) vfs_extattr.c (3308)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
39 * $Id: vfs_syscalls.c,v 1.8 1994/09/22 19:37:56 wollman Exp $
39 * $Id: vfs_syscalls.c,v 1.9 1994/09/28 16:45:11 dfr Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/filedesc.h>
46#include <sys/kernel.h>
47#include <sys/file.h>
48#include <sys/stat.h>
49#include <sys/vnode.h>
50#include <sys/mount.h>
51#include <sys/proc.h>
52#include <sys/uio.h>
53#include <sys/malloc.h>
54#include <sys/dirent.h>
55
56#include <vm/vm.h>
57#include <sys/sysctl.h>
58
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/filedesc.h>
46#include <sys/kernel.h>
47#include <sys/file.h>
48#include <sys/stat.h>
49#include <sys/vnode.h>
50#include <sys/mount.h>
51#include <sys/proc.h>
52#include <sys/uio.h>
53#include <sys/malloc.h>
54#include <sys/dirent.h>
55
56#include <vm/vm.h>
57#include <sys/sysctl.h>
58
59void cvtstat __P((struct stat *, struct ostat *));
60static int change_dir __P((struct nameidata *ndp, struct proc *p));
61
62/*
63 * Virtual File System System Calls
64 */
65
66/*
67 * Mount a file system.

--- 14 unchanged lines hidden (view full) ---

82 register struct vnode *vp;
83 register struct mount *mp;
84 int error, flag = 0;
85 struct nameidata nd;
86
87 /*
88 * Must be super user
89 */
59static int change_dir __P((struct nameidata *ndp, struct proc *p));
60
61/*
62 * Virtual File System System Calls
63 */
64
65/*
66 * Mount a file system.

--- 14 unchanged lines hidden (view full) ---

81 register struct vnode *vp;
82 register struct mount *mp;
83 int error, flag = 0;
84 struct nameidata nd;
85
86 /*
87 * Must be super user
88 */
90 if (error = suser(p->p_ucred, &p->p_acflag))
89 error = suser(p->p_ucred, &p->p_acflag);
90 if (error)
91 return (error);
92 /*
93 * Get vnode to be covered
94 */
95 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
91 return (error);
92 /*
93 * Get vnode to be covered
94 */
95 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
96 if (error = namei(&nd))
96 namei(&nd);
97 if (error)
97 return (error);
98 vp = nd.ni_vp;
99 if (uap->flags & MNT_UPDATE) {
100 if ((vp->v_flag & VROOT) == 0) {
101 vput(vp);
102 return (EINVAL);
103 }
104 mp = vp->v_mount;

--- 7 unchanged lines hidden (view full) ---

112 vput(vp);
113 return (EOPNOTSUPP); /* Needs translation */
114 }
115 mp->mnt_flag |=
116 uap->flags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE);
117 VOP_UNLOCK(vp);
118 goto update;
119 }
98 return (error);
99 vp = nd.ni_vp;
100 if (uap->flags & MNT_UPDATE) {
101 if ((vp->v_flag & VROOT) == 0) {
102 vput(vp);
103 return (EINVAL);
104 }
105 mp = vp->v_mount;

--- 7 unchanged lines hidden (view full) ---

113 vput(vp);
114 return (EOPNOTSUPP); /* Needs translation */
115 }
116 mp->mnt_flag |=
117 uap->flags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE);
118 VOP_UNLOCK(vp);
119 goto update;
120 }
120 if (error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0))
121 error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0);
122 if (error)
121 return (error);
122 if (vp->v_type != VDIR) {
123 vput(vp);
124 return (ENOTDIR);
125 }
126 if ((u_long)uap->type > MOUNT_MAXTYPE || vfssw[uap->type] == NULL) {
127 vput(vp);
128 return (ENODEV);
129 }
130
131 /*
132 * Allocate and initialize the file system.
133 */
134 mp = (struct mount *)malloc((u_long)sizeof(struct mount),
135 M_MOUNT, M_WAITOK);
136 bzero((char *)mp, (u_long)sizeof(struct mount));
137 mp->mnt_op = vfssw[uap->type];
138 mp->mnt_vfc = vfsconf[uap->type];
123 return (error);
124 if (vp->v_type != VDIR) {
125 vput(vp);
126 return (ENOTDIR);
127 }
128 if ((u_long)uap->type > MOUNT_MAXTYPE || vfssw[uap->type] == NULL) {
129 vput(vp);
130 return (ENODEV);
131 }
132
133 /*
134 * Allocate and initialize the file system.
135 */
136 mp = (struct mount *)malloc((u_long)sizeof(struct mount),
137 M_MOUNT, M_WAITOK);
138 bzero((char *)mp, (u_long)sizeof(struct mount));
139 mp->mnt_op = vfssw[uap->type];
140 mp->mnt_vfc = vfsconf[uap->type];
139 if (error = vfs_lock(mp)) {
141 error = vfs_lock(mp);
142 if (error) {
140 free((caddr_t)mp, M_MOUNT);
141 vput(vp);
142 return (error);
143 }
144 if (vp->v_mountedhere != NULL) {
145 vfs_unlock(mp);
146 free((caddr_t)mp, M_MOUNT);
147 vput(vp);

--- 66 unchanged lines hidden (view full) ---

214 int *retval;
215{
216 register struct vnode *vp;
217 struct mount *mp;
218 int error;
219 struct nameidata nd;
220
221 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
143 free((caddr_t)mp, M_MOUNT);
144 vput(vp);
145 return (error);
146 }
147 if (vp->v_mountedhere != NULL) {
148 vfs_unlock(mp);
149 free((caddr_t)mp, M_MOUNT);
150 vput(vp);

--- 66 unchanged lines hidden (view full) ---

217 int *retval;
218{
219 register struct vnode *vp;
220 struct mount *mp;
221 int error;
222 struct nameidata nd;
223
224 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
222 if (error = namei(&nd))
225 error = namei(&nd);
226 if (error)
223 return (error);
224 vp = nd.ni_vp;
225
226 /*
227 * Unless this is a user mount, then must
228 * have suser privilege.
229 */
230 if (((vp->v_mount->mnt_flag & MNT_USER) == 0) &&

--- 32 unchanged lines hidden (view full) ---

263{
264 struct vnode *coveredvp;
265 int error;
266
267 coveredvp = mp->mnt_vnodecovered;
268 if (vfs_busy(mp))
269 return (EBUSY);
270 mp->mnt_flag |= MNT_UNMOUNT;
227 return (error);
228 vp = nd.ni_vp;
229
230 /*
231 * Unless this is a user mount, then must
232 * have suser privilege.
233 */
234 if (((vp->v_mount->mnt_flag & MNT_USER) == 0) &&

--- 32 unchanged lines hidden (view full) ---

267{
268 struct vnode *coveredvp;
269 int error;
270
271 coveredvp = mp->mnt_vnodecovered;
272 if (vfs_busy(mp))
273 return (EBUSY);
274 mp->mnt_flag |= MNT_UNMOUNT;
271 if (error = vfs_lock(mp))
275 error = vfs_lock(mp);
276 if (error)
272 return (error);
273
274 mp->mnt_flag &=~ MNT_ASYNC;
275 vnode_pager_umount(mp); /* release cached vnodes */
276 cache_purgevfs(mp); /* remove cache entries for this file sys */
277 if ((error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0 ||
278 (flags & MNT_FORCE))
279 error = VFS_UNMOUNT(mp, flags, p);

--- 74 unchanged lines hidden (view full) ---

354 register struct quotactl_args *uap;
355 int *retval;
356{
357 register struct mount *mp;
358 int error;
359 struct nameidata nd;
360
361 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
277 return (error);
278
279 mp->mnt_flag &=~ MNT_ASYNC;
280 vnode_pager_umount(mp); /* release cached vnodes */
281 cache_purgevfs(mp); /* remove cache entries for this file sys */
282 if ((error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0 ||
283 (flags & MNT_FORCE))
284 error = VFS_UNMOUNT(mp, flags, p);

--- 74 unchanged lines hidden (view full) ---

359 register struct quotactl_args *uap;
360 int *retval;
361{
362 register struct mount *mp;
363 int error;
364 struct nameidata nd;
365
366 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
362 if (error = namei(&nd))
367 error = namei(&nd);
368 if (error)
363 return (error);
364 mp = nd.ni_vp->v_mount;
365 vrele(nd.ni_vp);
366 return (VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg, p));
367}
368
369/*
370 * Get filesystem statistics.

--- 10 unchanged lines hidden (view full) ---

381 int *retval;
382{
383 register struct mount *mp;
384 register struct statfs *sp;
385 int error;
386 struct nameidata nd;
387
388 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
369 return (error);
370 mp = nd.ni_vp->v_mount;
371 vrele(nd.ni_vp);
372 return (VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg, p));
373}
374
375/*
376 * Get filesystem statistics.

--- 10 unchanged lines hidden (view full) ---

387 int *retval;
388{
389 register struct mount *mp;
390 register struct statfs *sp;
391 int error;
392 struct nameidata nd;
393
394 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
389 if (error = namei(&nd))
395 error = namei(&nd);
396 if (error)
390 return (error);
391 mp = nd.ni_vp->v_mount;
392 sp = &mp->mnt_stat;
393 vrele(nd.ni_vp);
397 return (error);
398 mp = nd.ni_vp->v_mount;
399 sp = &mp->mnt_stat;
400 vrele(nd.ni_vp);
394 if (error = VFS_STATFS(mp, sp, p))
401 error = VFS_STATFS(mp, sp, p);
402 if (error)
395 return (error);
396 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
397 return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
398}
399
400/*
401 * Get filesystem statistics.
402 */

--- 8 unchanged lines hidden (view full) ---

411 register struct fstatfs_args *uap;
412 int *retval;
413{
414 struct file *fp;
415 struct mount *mp;
416 register struct statfs *sp;
417 int error;
418
403 return (error);
404 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
405 return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
406}
407
408/*
409 * Get filesystem statistics.
410 */

--- 8 unchanged lines hidden (view full) ---

419 register struct fstatfs_args *uap;
420 int *retval;
421{
422 struct file *fp;
423 struct mount *mp;
424 register struct statfs *sp;
425 int error;
426
419 if (error = getvnode(p->p_fd, uap->fd, &fp))
427 error = getvnode(p->p_fd, uap->fd, &fp);
428 if (error)
420 return (error);
421 mp = ((struct vnode *)fp->f_data)->v_mount;
422 sp = &mp->mnt_stat;
429 return (error);
430 mp = ((struct vnode *)fp->f_data)->v_mount;
431 sp = &mp->mnt_stat;
423 if (error = VFS_STATFS(mp, sp, p))
432 error = VFS_STATFS(mp, sp, p);
433 if (error)
424 return (error);
425 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
426 return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
427}
428
429/*
430 * Get statistics on all filesystems.
431 */

--- 55 unchanged lines hidden (view full) ---

487 struct fchdir_args *uap;
488 int *retval;
489{
490 register struct filedesc *fdp = p->p_fd;
491 register struct vnode *vp;
492 struct file *fp;
493 int error;
494
434 return (error);
435 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
436 return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
437}
438
439/*
440 * Get statistics on all filesystems.
441 */

--- 55 unchanged lines hidden (view full) ---

497 struct fchdir_args *uap;
498 int *retval;
499{
500 register struct filedesc *fdp = p->p_fd;
501 register struct vnode *vp;
502 struct file *fp;
503 int error;
504
495 if (error = getvnode(fdp, uap->fd, &fp))
505 error = getvnode(fdp, uap->fd, &fp);
506 if (error)
496 return (error);
497 vp = (struct vnode *)fp->f_data;
498 VOP_LOCK(vp);
499 if (vp->v_type != VDIR)
500 error = ENOTDIR;
501 else
502 error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
503 VOP_UNLOCK(vp);

--- 18 unchanged lines hidden (view full) ---

522 struct chdir_args *uap;
523 int *retval;
524{
525 register struct filedesc *fdp = p->p_fd;
526 int error;
527 struct nameidata nd;
528
529 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
507 return (error);
508 vp = (struct vnode *)fp->f_data;
509 VOP_LOCK(vp);
510 if (vp->v_type != VDIR)
511 error = ENOTDIR;
512 else
513 error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
514 VOP_UNLOCK(vp);

--- 18 unchanged lines hidden (view full) ---

533 struct chdir_args *uap;
534 int *retval;
535{
536 register struct filedesc *fdp = p->p_fd;
537 int error;
538 struct nameidata nd;
539
540 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
530 if (error = change_dir(&nd, p))
541 error = change_dir(&nd, p);
542 if (error)
531 return (error);
532 vrele(fdp->fd_cdir);
533 fdp->fd_cdir = nd.ni_vp;
534 return (0);
535}
536
537/*
538 * Change notion of root (``/'') directory.

--- 7 unchanged lines hidden (view full) ---

546 struct proc *p;
547 struct chroot_args *uap;
548 int *retval;
549{
550 register struct filedesc *fdp = p->p_fd;
551 int error;
552 struct nameidata nd;
553
543 return (error);
544 vrele(fdp->fd_cdir);
545 fdp->fd_cdir = nd.ni_vp;
546 return (0);
547}
548
549/*
550 * Change notion of root (``/'') directory.

--- 7 unchanged lines hidden (view full) ---

558 struct proc *p;
559 struct chroot_args *uap;
560 int *retval;
561{
562 register struct filedesc *fdp = p->p_fd;
563 int error;
564 struct nameidata nd;
565
554 if (error = suser(p->p_ucred, &p->p_acflag))
566 error = suser(p->p_ucred, &p->p_acflag);
567 if (error)
555 return (error);
556 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
568 return (error);
569 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
557 if (error = change_dir(&nd, p))
570 error = change_dir(&nd, p);
571 if (error)
558 return (error);
559 if (fdp->fd_rdir != NULL)
560 vrele(fdp->fd_rdir);
561 fdp->fd_rdir = nd.ni_vp;
562 return (0);
563}
564
565/*
566 * Common routine for chroot and chdir.
567 */
568static int
569change_dir(ndp, p)
570 register struct nameidata *ndp;
571 struct proc *p;
572{
573 struct vnode *vp;
574 int error;
575
572 return (error);
573 if (fdp->fd_rdir != NULL)
574 vrele(fdp->fd_rdir);
575 fdp->fd_rdir = nd.ni_vp;
576 return (0);
577}
578
579/*
580 * Common routine for chroot and chdir.
581 */
582static int
583change_dir(ndp, p)
584 register struct nameidata *ndp;
585 struct proc *p;
586{
587 struct vnode *vp;
588 int error;
589
576 if (error = namei(ndp))
590 error = namei(ndp);
591 if (error)
577 return (error);
578 vp = ndp->ni_vp;
579 if (vp->v_type != VDIR)
580 error = ENOTDIR;
581 else
582 error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
583 VOP_UNLOCK(vp);
584 if (error)

--- 21 unchanged lines hidden (view full) ---

606 register struct vnode *vp;
607 int flags, cmode;
608 struct file *nfp;
609 int type, indx, error;
610 struct flock lf;
611 struct nameidata nd;
612 extern struct fileops vnops;
613
592 return (error);
593 vp = ndp->ni_vp;
594 if (vp->v_type != VDIR)
595 error = ENOTDIR;
596 else
597 error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
598 VOP_UNLOCK(vp);
599 if (error)

--- 21 unchanged lines hidden (view full) ---

621 register struct vnode *vp;
622 int flags, cmode;
623 struct file *nfp;
624 int type, indx, error;
625 struct flock lf;
626 struct nameidata nd;
627 extern struct fileops vnops;
628
614 if (error = falloc(p, &nfp, &indx))
629 error = falloc(p, &nfp, &indx);
630 if (error)
615 return (error);
616 fp = nfp;
617 flags = FFLAGS(uap->flags);
618 cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
619 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
620 p->p_dupfd = -indx - 1; /* XXX check for fdopen */
631 return (error);
632 fp = nfp;
633 flags = FFLAGS(uap->flags);
634 cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
635 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
636 p->p_dupfd = -indx - 1; /* XXX check for fdopen */
621 if (error = vn_open(&nd, flags, cmode)) {
637 error = vn_open(&nd, flags, cmode);
638 if (error) {
622 ffree(fp);
623 if ((error == ENODEV || error == ENXIO) &&
624 p->p_dupfd >= 0 && /* XXX from fdopen */
625 (error =
626 dupfdopen(fdp, indx, p->p_dupfd, flags, error)) == 0) {
627 *retval = indx;
628 return (0);
629 }

--- 15 unchanged lines hidden (view full) ---

645 if (flags & O_EXLOCK)
646 lf.l_type = F_WRLCK;
647 else
648 lf.l_type = F_RDLCK;
649 type = F_FLOCK;
650 if ((flags & FNONBLOCK) == 0)
651 type |= F_WAIT;
652 VOP_UNLOCK(vp);
639 ffree(fp);
640 if ((error == ENODEV || error == ENXIO) &&
641 p->p_dupfd >= 0 && /* XXX from fdopen */
642 (error =
643 dupfdopen(fdp, indx, p->p_dupfd, flags, error)) == 0) {
644 *retval = indx;
645 return (0);
646 }

--- 15 unchanged lines hidden (view full) ---

662 if (flags & O_EXLOCK)
663 lf.l_type = F_WRLCK;
664 else
665 lf.l_type = F_RDLCK;
666 type = F_FLOCK;
667 if ((flags & FNONBLOCK) == 0)
668 type |= F_WAIT;
669 VOP_UNLOCK(vp);
653 if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
670 error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type);
671 if (error) {
654 (void) vn_close(vp, fp->f_flag, fp->f_cred, p);
655 ffree(fp);
656 fdp->fd_ofiles[indx] = NULL;
657 return (error);
658 }
659 VOP_LOCK(vp);
660 fp->f_flag |= FHASLOCK;
661 }

--- 40 unchanged lines hidden (view full) ---

702 register struct mknod_args *uap;
703 int *retval;
704{
705 register struct vnode *vp;
706 struct vattr vattr;
707 int error;
708 struct nameidata nd;
709
672 (void) vn_close(vp, fp->f_flag, fp->f_cred, p);
673 ffree(fp);
674 fdp->fd_ofiles[indx] = NULL;
675 return (error);
676 }
677 VOP_LOCK(vp);
678 fp->f_flag |= FHASLOCK;
679 }

--- 40 unchanged lines hidden (view full) ---

720 register struct mknod_args *uap;
721 int *retval;
722{
723 register struct vnode *vp;
724 struct vattr vattr;
725 int error;
726 struct nameidata nd;
727
710 if (error = suser(p->p_ucred, &p->p_acflag))
728 error = suser(p->p_ucred, &p->p_acflag);
729 if (error)
711 return (error);
712 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
730 return (error);
731 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
713 if (error = namei(&nd))
732 error = namei(&nd);
733 if (error)
714 return (error);
715 vp = nd.ni_vp;
716 if (vp != NULL)
717 error = EEXIST;
718 else {
719 VATTR_NULL(&vattr);
720 vattr.va_mode = (uap->mode & ALLPERMS) &~ p->p_fd->fd_cmask;
721 vattr.va_rdev = uap->dev;

--- 42 unchanged lines hidden (view full) ---

764 register struct mkfifo_args *uap;
765 int *retval;
766{
767 struct vattr vattr;
768 int error;
769 struct nameidata nd;
770
771 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
734 return (error);
735 vp = nd.ni_vp;
736 if (vp != NULL)
737 error = EEXIST;
738 else {
739 VATTR_NULL(&vattr);
740 vattr.va_mode = (uap->mode & ALLPERMS) &~ p->p_fd->fd_cmask;
741 vattr.va_rdev = uap->dev;

--- 42 unchanged lines hidden (view full) ---

784 register struct mkfifo_args *uap;
785 int *retval;
786{
787 struct vattr vattr;
788 int error;
789 struct nameidata nd;
790
791 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
772 if (error = namei(&nd))
792 error = namei(&nd);
793 if (error)
773 return (error);
774 if (nd.ni_vp != NULL) {
775 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
776 if (nd.ni_dvp == nd.ni_vp)
777 vrele(nd.ni_dvp);
778 else
779 vput(nd.ni_dvp);
780 vrele(nd.ni_vp);

--- 20 unchanged lines hidden (view full) ---

801 register struct link_args *uap;
802 int *retval;
803{
804 register struct vnode *vp;
805 struct nameidata nd;
806 int error;
807
808 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
794 return (error);
795 if (nd.ni_vp != NULL) {
796 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
797 if (nd.ni_dvp == nd.ni_vp)
798 vrele(nd.ni_dvp);
799 else
800 vput(nd.ni_dvp);
801 vrele(nd.ni_vp);

--- 20 unchanged lines hidden (view full) ---

822 register struct link_args *uap;
823 int *retval;
824{
825 register struct vnode *vp;
826 struct nameidata nd;
827 int error;
828
829 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
809 if (error = namei(&nd))
830 error = namei(&nd);
831 if (error)
810 return (error);
811 vp = nd.ni_vp;
812 if (vp->v_type != VDIR ||
813 (error = suser(p->p_ucred, &p->p_acflag)) == 0) {
814 nd.ni_cnd.cn_nameiop = CREATE;
815 nd.ni_cnd.cn_flags = LOCKPARENT;
816 nd.ni_dirp = uap->link;
832 return (error);
833 vp = nd.ni_vp;
834 if (vp->v_type != VDIR ||
835 (error = suser(p->p_ucred, &p->p_acflag)) == 0) {
836 nd.ni_cnd.cn_nameiop = CREATE;
837 nd.ni_cnd.cn_flags = LOCKPARENT;
838 nd.ni_dirp = uap->link;
817 if ((error = namei(&nd)) == 0) {
839 error = namei(&nd);
840 if (!error) {
818 if (nd.ni_vp != NULL)
819 error = EEXIST;
820 if (!error) {
821 LEASE_CHECK(nd.ni_dvp,
822 p, p->p_ucred, LEASE_WRITE);
823 LEASE_CHECK(vp,
824 p, p->p_ucred, LEASE_WRITE);
825 error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);

--- 27 unchanged lines hidden (view full) ---

853 int *retval;
854{
855 struct vattr vattr;
856 char *path;
857 int error;
858 struct nameidata nd;
859
860 MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
841 if (nd.ni_vp != NULL)
842 error = EEXIST;
843 if (!error) {
844 LEASE_CHECK(nd.ni_dvp,
845 p, p->p_ucred, LEASE_WRITE);
846 LEASE_CHECK(vp,
847 p, p->p_ucred, LEASE_WRITE);
848 error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);

--- 27 unchanged lines hidden (view full) ---

876 int *retval;
877{
878 struct vattr vattr;
879 char *path;
880 int error;
881 struct nameidata nd;
882
883 MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
861 if (error = copyinstr(uap->path, path, MAXPATHLEN, NULL))
884 error = copyinstr(uap->path, path, MAXPATHLEN, NULL);
885 if (error)
862 goto out;
863 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
886 goto out;
887 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
864 if (error = namei(&nd))
888 error = namei(&nd);
889 if (error)
865 goto out;
866 if (nd.ni_vp) {
867 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
868 if (nd.ni_dvp == nd.ni_vp)
869 vrele(nd.ni_dvp);
870 else
871 vput(nd.ni_dvp);
872 vrele(nd.ni_vp);

--- 22 unchanged lines hidden (view full) ---

895 struct unlink_args *uap;
896 int *retval;
897{
898 register struct vnode *vp;
899 int error;
900 struct nameidata nd;
901
902 NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
890 goto out;
891 if (nd.ni_vp) {
892 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
893 if (nd.ni_dvp == nd.ni_vp)
894 vrele(nd.ni_dvp);
895 else
896 vput(nd.ni_dvp);
897 vrele(nd.ni_vp);

--- 22 unchanged lines hidden (view full) ---

920 struct unlink_args *uap;
921 int *retval;
922{
923 register struct vnode *vp;
924 int error;
925 struct nameidata nd;
926
927 NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
903 if (error = namei(&nd))
928 error = namei(&nd);
929 if (error)
904 return (error);
905 vp = nd.ni_vp;
906 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
907 VOP_LOCK(vp);
908
909 if (vp->v_type != VDIR ||
910 (error = suser(p->p_ucred, &p->p_acflag)) == 0) {
911 /*

--- 45 unchanged lines hidden (view full) ---

957 return (EBADF);
958 if (fp->f_type != DTYPE_VNODE)
959 return (ESPIPE);
960 switch (uap->whence) {
961 case L_INCR:
962 fp->f_offset += uap->offset;
963 break;
964 case L_XTND:
930 return (error);
931 vp = nd.ni_vp;
932 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
933 VOP_LOCK(vp);
934
935 if (vp->v_type != VDIR ||
936 (error = suser(p->p_ucred, &p->p_acflag)) == 0) {
937 /*

--- 45 unchanged lines hidden (view full) ---

983 return (EBADF);
984 if (fp->f_type != DTYPE_VNODE)
985 return (ESPIPE);
986 switch (uap->whence) {
987 case L_INCR:
988 fp->f_offset += uap->offset;
989 break;
990 case L_XTND:
965 if (error =
966 VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
991 error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
992 if (error)
967 return (error);
968 fp->f_offset = uap->offset + vattr.va_size;
969 break;
970 case L_SET:
971 fp->f_offset = uap->offset;
972 break;
973 default:
974 return (EINVAL);

--- 48 unchanged lines hidden (view full) ---

1023 int error, flags, t_gid, t_uid;
1024 struct nameidata nd;
1025
1026 t_uid = cred->cr_uid;
1027 t_gid = cred->cr_groups[0];
1028 cred->cr_uid = p->p_cred->p_ruid;
1029 cred->cr_groups[0] = p->p_cred->p_rgid;
1030 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
993 return (error);
994 fp->f_offset = uap->offset + vattr.va_size;
995 break;
996 case L_SET:
997 fp->f_offset = uap->offset;
998 break;
999 default:
1000 return (EINVAL);

--- 48 unchanged lines hidden (view full) ---

1049 int error, flags, t_gid, t_uid;
1050 struct nameidata nd;
1051
1052 t_uid = cred->cr_uid;
1053 t_gid = cred->cr_groups[0];
1054 cred->cr_uid = p->p_cred->p_ruid;
1055 cred->cr_groups[0] = p->p_cred->p_rgid;
1056 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1031 if (error = namei(&nd))
1057 error = namei(&nd);
1058 if (error)
1032 goto out1;
1033 vp = nd.ni_vp;
1034
1035 /* Flags == 0 means only check for existence. */
1036 if (uap->flags) {
1037 flags = 0;
1038 if (uap->flags & R_OK)
1039 flags |= VREAD;

--- 27 unchanged lines hidden (view full) ---

1067 int *retval;
1068{
1069 struct stat sb;
1070 struct ostat osb;
1071 int error;
1072 struct nameidata nd;
1073
1074 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1059 goto out1;
1060 vp = nd.ni_vp;
1061
1062 /* Flags == 0 means only check for existence. */
1063 if (uap->flags) {
1064 flags = 0;
1065 if (uap->flags & R_OK)
1066 flags |= VREAD;

--- 27 unchanged lines hidden (view full) ---

1094 int *retval;
1095{
1096 struct stat sb;
1097 struct ostat osb;
1098 int error;
1099 struct nameidata nd;
1100
1101 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1075 if (error = namei(&nd))
1102 error = namei(&nd);
1103 if (error)
1076 return (error);
1077 error = vn_stat(nd.ni_vp, &sb, p);
1078 vput(nd.ni_vp);
1079 if (error)
1080 return (error);
1081 cvtstat(&sb, &osb);
1082 error = copyout((caddr_t)&osb, (caddr_t)uap->ub, sizeof (osb));
1083 return (error);

--- 16 unchanged lines hidden (view full) ---

1100 struct vnode *vp, *dvp;
1101 struct stat sb, sb1;
1102 struct ostat osb;
1103 int error;
1104 struct nameidata nd;
1105
1106 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
1107 uap->path, p);
1104 return (error);
1105 error = vn_stat(nd.ni_vp, &sb, p);
1106 vput(nd.ni_vp);
1107 if (error)
1108 return (error);
1109 cvtstat(&sb, &osb);
1110 error = copyout((caddr_t)&osb, (caddr_t)uap->ub, sizeof (osb));
1111 return (error);

--- 16 unchanged lines hidden (view full) ---

1128 struct vnode *vp, *dvp;
1129 struct stat sb, sb1;
1130 struct ostat osb;
1131 int error;
1132 struct nameidata nd;
1133
1134 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
1135 uap->path, p);
1108 if (error = namei(&nd))
1136 error = namei(&nd);
1137 if (error)
1109 return (error);
1110 /*
1111 * For symbolic links, always return the attributes of its
1112 * containing directory, except for mode, size, and links.
1113 */
1114 vp = nd.ni_vp;
1115 dvp = nd.ni_dvp;
1116 if (vp->v_type != VLNK) {

--- 71 unchanged lines hidden (view full) ---

1188 register struct stat_args *uap;
1189 int *retval;
1190{
1191 struct stat sb;
1192 int error;
1193 struct nameidata nd;
1194
1195 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1138 return (error);
1139 /*
1140 * For symbolic links, always return the attributes of its
1141 * containing directory, except for mode, size, and links.
1142 */
1143 vp = nd.ni_vp;
1144 dvp = nd.ni_dvp;
1145 if (vp->v_type != VLNK) {

--- 71 unchanged lines hidden (view full) ---

1217 register struct stat_args *uap;
1218 int *retval;
1219{
1220 struct stat sb;
1221 int error;
1222 struct nameidata nd;
1223
1224 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1196 if (error = namei(&nd))
1225 error = namei(&nd);
1226 if (error)
1197 return (error);
1198 error = vn_stat(nd.ni_vp, &sb, p);
1199 vput(nd.ni_vp);
1200 if (error)
1201 return (error);
1202 error = copyout((caddr_t)&sb, (caddr_t)uap->ub, sizeof (sb));
1203 return (error);
1204}

--- 14 unchanged lines hidden (view full) ---

1219{
1220 int error;
1221 struct vnode *vp, *dvp;
1222 struct stat sb, sb1;
1223 struct nameidata nd;
1224
1225 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
1226 uap->path, p);
1227 return (error);
1228 error = vn_stat(nd.ni_vp, &sb, p);
1229 vput(nd.ni_vp);
1230 if (error)
1231 return (error);
1232 error = copyout((caddr_t)&sb, (caddr_t)uap->ub, sizeof (sb));
1233 return (error);
1234}

--- 14 unchanged lines hidden (view full) ---

1249{
1250 int error;
1251 struct vnode *vp, *dvp;
1252 struct stat sb, sb1;
1253 struct nameidata nd;
1254
1255 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
1256 uap->path, p);
1227 if (error = namei(&nd))
1257 error = namei(&nd);
1258 if (error)
1228 return (error);
1229 /*
1230 * For symbolic links, always return the attributes of its
1231 * containing directory, except for mode, size, and links.
1232 */
1233 vp = nd.ni_vp;
1234 dvp = nd.ni_dvp;
1235 if (vp->v_type != VLNK) {

--- 39 unchanged lines hidden (view full) ---

1275 struct proc *p;
1276 register struct pathconf_args *uap;
1277 int *retval;
1278{
1279 int error;
1280 struct nameidata nd;
1281
1282 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1259 return (error);
1260 /*
1261 * For symbolic links, always return the attributes of its
1262 * containing directory, except for mode, size, and links.
1263 */
1264 vp = nd.ni_vp;
1265 dvp = nd.ni_dvp;
1266 if (vp->v_type != VLNK) {

--- 39 unchanged lines hidden (view full) ---

1306 struct proc *p;
1307 register struct pathconf_args *uap;
1308 int *retval;
1309{
1310 int error;
1311 struct nameidata nd;
1312
1313 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1283 if (error = namei(&nd))
1314 error = namei(&nd);
1315 if (error)
1284 return (error);
1285 error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
1286 vput(nd.ni_vp);
1287 return (error);
1288}
1289
1290/*
1291 * Return target name of a symbolic link.

--- 12 unchanged lines hidden (view full) ---

1304{
1305 register struct vnode *vp;
1306 struct iovec aiov;
1307 struct uio auio;
1308 int error;
1309 struct nameidata nd;
1310
1311 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1316 return (error);
1317 error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
1318 vput(nd.ni_vp);
1319 return (error);
1320}
1321
1322/*
1323 * Return target name of a symbolic link.

--- 12 unchanged lines hidden (view full) ---

1336{
1337 register struct vnode *vp;
1338 struct iovec aiov;
1339 struct uio auio;
1340 int error;
1341 struct nameidata nd;
1342
1343 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1312 if (error = namei(&nd))
1344 error = namei(&nd);
1345 if (error)
1313 return (error);
1314 vp = nd.ni_vp;
1315 if (vp->v_type != VLNK)
1316 error = EINVAL;
1317 else {
1318 aiov.iov_base = uap->buf;
1319 aiov.iov_len = uap->count;
1320 auio.uio_iov = &aiov;

--- 25 unchanged lines hidden (view full) ---

1346 int *retval;
1347{
1348 register struct vnode *vp;
1349 struct vattr vattr;
1350 int error;
1351 struct nameidata nd;
1352
1353 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1346 return (error);
1347 vp = nd.ni_vp;
1348 if (vp->v_type != VLNK)
1349 error = EINVAL;
1350 else {
1351 aiov.iov_base = uap->buf;
1352 aiov.iov_len = uap->count;
1353 auio.uio_iov = &aiov;

--- 25 unchanged lines hidden (view full) ---

1379 int *retval;
1380{
1381 register struct vnode *vp;
1382 struct vattr vattr;
1383 int error;
1384 struct nameidata nd;
1385
1386 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1354 if (error = namei(&nd))
1387 error = namei(&nd);
1388 if (error)
1355 return (error);
1356 vp = nd.ni_vp;
1357 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1358 VOP_LOCK(vp);
1359 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1360 error = EROFS;
1361 else {
1362 VATTR_NULL(&vattr);

--- 18 unchanged lines hidden (view full) ---

1381 register struct fchflags_args *uap;
1382 int *retval;
1383{
1384 struct vattr vattr;
1385 struct vnode *vp;
1386 struct file *fp;
1387 int error;
1388
1389 return (error);
1390 vp = nd.ni_vp;
1391 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1392 VOP_LOCK(vp);
1393 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1394 error = EROFS;
1395 else {
1396 VATTR_NULL(&vattr);

--- 18 unchanged lines hidden (view full) ---

1415 register struct fchflags_args *uap;
1416 int *retval;
1417{
1418 struct vattr vattr;
1419 struct vnode *vp;
1420 struct file *fp;
1421 int error;
1422
1389 if (error = getvnode(p->p_fd, uap->fd, &fp))
1423 error = getvnode(p->p_fd, uap->fd, &fp);
1424 if (error)
1390 return (error);
1391 vp = (struct vnode *)fp->f_data;
1392 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1393 VOP_LOCK(vp);
1394 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1395 error = EROFS;
1396 else {
1397 VATTR_NULL(&vattr);

--- 19 unchanged lines hidden (view full) ---

1417 int *retval;
1418{
1419 register struct vnode *vp;
1420 struct vattr vattr;
1421 int error;
1422 struct nameidata nd;
1423
1424 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1425 return (error);
1426 vp = (struct vnode *)fp->f_data;
1427 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1428 VOP_LOCK(vp);
1429 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1430 error = EROFS;
1431 else {
1432 VATTR_NULL(&vattr);

--- 19 unchanged lines hidden (view full) ---

1452 int *retval;
1453{
1454 register struct vnode *vp;
1455 struct vattr vattr;
1456 int error;
1457 struct nameidata nd;
1458
1459 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1425 if (error = namei(&nd))
1460 error = namei(&nd);
1461 if (error)
1426 return (error);
1427 vp = nd.ni_vp;
1428 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1429 VOP_LOCK(vp);
1430 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1431 error = EROFS;
1432 else {
1433 VATTR_NULL(&vattr);

--- 18 unchanged lines hidden (view full) ---

1452 register struct fchmod_args *uap;
1453 int *retval;
1454{
1455 struct vattr vattr;
1456 struct vnode *vp;
1457 struct file *fp;
1458 int error;
1459
1462 return (error);
1463 vp = nd.ni_vp;
1464 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1465 VOP_LOCK(vp);
1466 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1467 error = EROFS;
1468 else {
1469 VATTR_NULL(&vattr);

--- 18 unchanged lines hidden (view full) ---

1488 register struct fchmod_args *uap;
1489 int *retval;
1490{
1491 struct vattr vattr;
1492 struct vnode *vp;
1493 struct file *fp;
1494 int error;
1495
1460 if (error = getvnode(p->p_fd, uap->fd, &fp))
1496 error = getvnode(p->p_fd, uap->fd, &fp);
1497 if (error)
1461 return (error);
1462 vp = (struct vnode *)fp->f_data;
1463 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1464 VOP_LOCK(vp);
1465 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1466 error = EROFS;
1467 else {
1468 VATTR_NULL(&vattr);

--- 20 unchanged lines hidden (view full) ---

1489 int *retval;
1490{
1491 register struct vnode *vp;
1492 struct vattr vattr;
1493 int error;
1494 struct nameidata nd;
1495
1496 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1498 return (error);
1499 vp = (struct vnode *)fp->f_data;
1500 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1501 VOP_LOCK(vp);
1502 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1503 error = EROFS;
1504 else {
1505 VATTR_NULL(&vattr);

--- 20 unchanged lines hidden (view full) ---

1526 int *retval;
1527{
1528 register struct vnode *vp;
1529 struct vattr vattr;
1530 int error;
1531 struct nameidata nd;
1532
1533 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1497 if (error = namei(&nd))
1534 error = namei(&nd);
1535 if (error)
1498 return (error);
1499 vp = nd.ni_vp;
1500 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1501 VOP_LOCK(vp);
1502 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1503 error = EROFS;
1504 else {
1505 VATTR_NULL(&vattr);

--- 20 unchanged lines hidden (view full) ---

1526 register struct fchown_args *uap;
1527 int *retval;
1528{
1529 struct vattr vattr;
1530 struct vnode *vp;
1531 struct file *fp;
1532 int error;
1533
1536 return (error);
1537 vp = nd.ni_vp;
1538 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1539 VOP_LOCK(vp);
1540 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1541 error = EROFS;
1542 else {
1543 VATTR_NULL(&vattr);

--- 20 unchanged lines hidden (view full) ---

1564 register struct fchown_args *uap;
1565 int *retval;
1566{
1567 struct vattr vattr;
1568 struct vnode *vp;
1569 struct file *fp;
1570 int error;
1571
1534 if (error = getvnode(p->p_fd, uap->fd, &fp))
1572 error = getvnode(p->p_fd, uap->fd, &fp);
1573 if (error)
1535 return (error);
1536 vp = (struct vnode *)fp->f_data;
1537 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1538 VOP_LOCK(vp);
1539 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1540 error = EROFS;
1541 else {
1542 VATTR_NULL(&vattr);

--- 25 unchanged lines hidden (view full) ---

1568 int error;
1569 struct nameidata nd;
1570
1571 VATTR_NULL(&vattr);
1572 if (uap->tptr == NULL) {
1573 microtime(&tv[0]);
1574 tv[1] = tv[0];
1575 vattr.va_vaflags |= VA_UTIMES_NULL;
1574 return (error);
1575 vp = (struct vnode *)fp->f_data;
1576 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1577 VOP_LOCK(vp);
1578 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1579 error = EROFS;
1580 else {
1581 VATTR_NULL(&vattr);

--- 25 unchanged lines hidden (view full) ---

1607 int error;
1608 struct nameidata nd;
1609
1610 VATTR_NULL(&vattr);
1611 if (uap->tptr == NULL) {
1612 microtime(&tv[0]);
1613 tv[1] = tv[0];
1614 vattr.va_vaflags |= VA_UTIMES_NULL;
1576 } else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
1577 return (error);
1615 } else {
1616 error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
1617 if (error)
1618 return (error);
1619 }
1578 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1620 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1579 if (error = namei(&nd))
1621 error = namei(&nd);
1622 if (error)
1580 return (error);
1581 vp = nd.ni_vp;
1582 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1583 VOP_LOCK(vp);
1584 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1585 error = EROFS;
1586 else {
1587 vattr.va_atime.ts_sec = tv[0].tv_sec;

--- 24 unchanged lines hidden (view full) ---

1612 register struct vnode *vp;
1613 struct vattr vattr;
1614 int error;
1615 struct nameidata nd;
1616
1617 if (uap->length < 0)
1618 return(EINVAL);
1619 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1623 return (error);
1624 vp = nd.ni_vp;
1625 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1626 VOP_LOCK(vp);
1627 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1628 error = EROFS;
1629 else {
1630 vattr.va_atime.ts_sec = tv[0].tv_sec;

--- 24 unchanged lines hidden (view full) ---

1655 register struct vnode *vp;
1656 struct vattr vattr;
1657 int error;
1658 struct nameidata nd;
1659
1660 if (uap->length < 0)
1661 return(EINVAL);
1662 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
1620 if (error = namei(&nd))
1663 error = namei(&nd);
1664 if (error)
1621 return (error);
1622 vp = nd.ni_vp;
1623 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1624 VOP_LOCK(vp);
1625 if (vp->v_type == VDIR)
1626 error = EISDIR;
1627 else if ((error = vn_writechk(vp)) == 0 &&
1628 (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) {

--- 22 unchanged lines hidden (view full) ---

1651{
1652 struct vattr vattr;
1653 struct vnode *vp;
1654 struct file *fp;
1655 int error;
1656
1657 if (uap->length < 0)
1658 return(EINVAL);
1665 return (error);
1666 vp = nd.ni_vp;
1667 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1668 VOP_LOCK(vp);
1669 if (vp->v_type == VDIR)
1670 error = EISDIR;
1671 else if ((error = vn_writechk(vp)) == 0 &&
1672 (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) {

--- 22 unchanged lines hidden (view full) ---

1695{
1696 struct vattr vattr;
1697 struct vnode *vp;
1698 struct file *fp;
1699 int error;
1700
1701 if (uap->length < 0)
1702 return(EINVAL);
1659 if (error = getvnode(p->p_fd, uap->fd, &fp))
1703 error = getvnode(p->p_fd, uap->fd, &fp);
1704 if (error)
1660 return (error);
1661 if ((fp->f_flag & FWRITE) == 0)
1662 return (EINVAL);
1663 vp = (struct vnode *)fp->f_data;
1664 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1665 VOP_LOCK(vp);
1666 if (vp->v_type == VDIR)
1667 error = EISDIR;

--- 62 unchanged lines hidden (view full) ---

1730 struct proc *p;
1731 struct fsync_args *uap;
1732 int *retval;
1733{
1734 register struct vnode *vp;
1735 struct file *fp;
1736 int error;
1737
1705 return (error);
1706 if ((fp->f_flag & FWRITE) == 0)
1707 return (EINVAL);
1708 vp = (struct vnode *)fp->f_data;
1709 LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
1710 VOP_LOCK(vp);
1711 if (vp->v_type == VDIR)
1712 error = EISDIR;

--- 62 unchanged lines hidden (view full) ---

1775 struct proc *p;
1776 struct fsync_args *uap;
1777 int *retval;
1778{
1779 register struct vnode *vp;
1780 struct file *fp;
1781 int error;
1782
1738 if (error = getvnode(p->p_fd, uap->fd, &fp))
1783 error = getvnode(p->p_fd, uap->fd, &fp);
1784 if (error)
1739 return (error);
1740 vp = (struct vnode *)fp->f_data;
1741 VOP_LOCK(vp);
1742 error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p);
1743 VOP_UNLOCK(vp);
1744 return (error);
1745}
1746

--- 13 unchanged lines hidden (view full) ---

1760 int *retval;
1761{
1762 register struct vnode *tvp, *fvp, *tdvp;
1763 struct nameidata fromnd, tond;
1764 int error;
1765
1766 NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
1767 uap->from, p);
1785 return (error);
1786 vp = (struct vnode *)fp->f_data;
1787 VOP_LOCK(vp);
1788 error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p);
1789 VOP_UNLOCK(vp);
1790 return (error);
1791}
1792

--- 13 unchanged lines hidden (view full) ---

1806 int *retval;
1807{
1808 register struct vnode *tvp, *fvp, *tdvp;
1809 struct nameidata fromnd, tond;
1810 int error;
1811
1812 NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
1813 uap->from, p);
1768 if (error = namei(&fromnd))
1814 error = namei(&fromnd);
1815 if (error)
1769 return (error);
1770 fvp = fromnd.ni_vp;
1771 NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
1772 UIO_USERSPACE, uap->to, p);
1816 return (error);
1817 fvp = fromnd.ni_vp;
1818 NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
1819 UIO_USERSPACE, uap->to, p);
1773 if (error = namei(&tond)) {
1820 error = namei(&tond);
1821 if (error) {
1774 VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
1775 vrele(fromnd.ni_dvp);
1776 vrele(fvp);
1777 goto out1;
1778 }
1779 tdvp = tond.ni_dvp;
1780 tvp = tond.ni_vp;
1781 if (tvp != NULL) {

--- 64 unchanged lines hidden (view full) ---

1846 int *retval;
1847{
1848 register struct vnode *vp;
1849 struct vattr vattr;
1850 int error;
1851 struct nameidata nd;
1852
1853 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
1822 VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
1823 vrele(fromnd.ni_dvp);
1824 vrele(fvp);
1825 goto out1;
1826 }
1827 tdvp = tond.ni_dvp;
1828 tvp = tond.ni_vp;
1829 if (tvp != NULL) {

--- 64 unchanged lines hidden (view full) ---

1894 int *retval;
1895{
1896 register struct vnode *vp;
1897 struct vattr vattr;
1898 int error;
1899 struct nameidata nd;
1900
1901 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
1854 if (error = namei(&nd))
1902 error = namei(&nd);
1903 if (error)
1855 return (error);
1856 vp = nd.ni_vp;
1857 if (vp != NULL) {
1858 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
1859 if (nd.ni_dvp == vp)
1860 vrele(nd.ni_dvp);
1861 else
1862 vput(nd.ni_dvp);

--- 23 unchanged lines hidden (view full) ---

1886 struct rmdir_args *uap;
1887 int *retval;
1888{
1889 register struct vnode *vp;
1890 int error;
1891 struct nameidata nd;
1892
1893 NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1904 return (error);
1905 vp = nd.ni_vp;
1906 if (vp != NULL) {
1907 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
1908 if (nd.ni_dvp == vp)
1909 vrele(nd.ni_dvp);
1910 else
1911 vput(nd.ni_dvp);

--- 23 unchanged lines hidden (view full) ---

1935 struct rmdir_args *uap;
1936 int *retval;
1937{
1938 register struct vnode *vp;
1939 int error;
1940 struct nameidata nd;
1941
1942 NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
1894 if (error = namei(&nd))
1943 error = namei(&nd);
1944 if (error)
1895 return (error);
1896 vp = nd.ni_vp;
1897 if (vp->v_type != VDIR) {
1898 error = ENOTDIR;
1899 goto out;
1900 }
1901 /*
1902 * No rmdir "." please.

--- 43 unchanged lines hidden (view full) ---

1946 struct file *fp;
1947 struct uio auio, kuio;
1948 struct iovec aiov, kiov;
1949 struct dirent *dp, *edp;
1950 caddr_t dirbuf;
1951 int error, readcnt;
1952 long loff;
1953
1945 return (error);
1946 vp = nd.ni_vp;
1947 if (vp->v_type != VDIR) {
1948 error = ENOTDIR;
1949 goto out;
1950 }
1951 /*
1952 * No rmdir "." please.

--- 43 unchanged lines hidden (view full) ---

1996 struct file *fp;
1997 struct uio auio, kuio;
1998 struct iovec aiov, kiov;
1999 struct dirent *dp, *edp;
2000 caddr_t dirbuf;
2001 int error, readcnt;
2002 long loff;
2003
1954 if (error = getvnode(p->p_fd, uap->fd, &fp))
2004 error = getvnode(p->p_fd, uap->fd, &fp);
2005 if (error)
1955 return (error);
1956 if ((fp->f_flag & FREAD) == 0)
1957 return (EBADF);
1958 vp = (struct vnode *)fp->f_data;
1959 if (vp->v_type != VDIR)
1960 return (EINVAL);
1961 aiov.iov_base = uap->buf;
1962 aiov.iov_len = uap->count;

--- 80 unchanged lines hidden (view full) ---

2043{
2044 register struct vnode *vp;
2045 struct file *fp;
2046 struct uio auio;
2047 struct iovec aiov;
2048 long loff;
2049 int error;
2050
2006 return (error);
2007 if ((fp->f_flag & FREAD) == 0)
2008 return (EBADF);
2009 vp = (struct vnode *)fp->f_data;
2010 if (vp->v_type != VDIR)
2011 return (EINVAL);
2012 aiov.iov_base = uap->buf;
2013 aiov.iov_len = uap->count;

--- 80 unchanged lines hidden (view full) ---

2094{
2095 register struct vnode *vp;
2096 struct file *fp;
2097 struct uio auio;
2098 struct iovec aiov;
2099 long loff;
2100 int error;
2101
2051 if (error = getvnode(p->p_fd, uap->fd, &fp))
2102 error = getvnode(p->p_fd, uap->fd, &fp);
2103 if (error)
2052 return (error);
2053 if ((fp->f_flag & FREAD) == 0)
2054 return (EBADF);
2055 vp = (struct vnode *)fp->f_data;
2056unionread:
2057 if (vp->v_type != VDIR)
2058 return (EINVAL);
2059 aiov.iov_base = uap->buf;

--- 93 unchanged lines hidden (view full) ---

2153 int *retval;
2154{
2155 register struct vnode *vp;
2156 struct vattr vattr;
2157 int error;
2158 struct nameidata nd;
2159
2160 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
2104 return (error);
2105 if ((fp->f_flag & FREAD) == 0)
2106 return (EBADF);
2107 vp = (struct vnode *)fp->f_data;
2108unionread:
2109 if (vp->v_type != VDIR)
2110 return (EINVAL);
2111 aiov.iov_base = uap->buf;

--- 93 unchanged lines hidden (view full) ---

2205 int *retval;
2206{
2207 register struct vnode *vp;
2208 struct vattr vattr;
2209 int error;
2210 struct nameidata nd;
2211
2212 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
2161 if (error = namei(&nd))
2213 error = namei(&nd);
2214 if (error)
2162 return (error);
2163 vp = nd.ni_vp;
2164 if (vp->v_type != VCHR && vp->v_type != VBLK) {
2165 error = EINVAL;
2166 goto out;
2167 }
2215 return (error);
2216 vp = nd.ni_vp;
2217 if (vp->v_type != VCHR && vp->v_type != VBLK) {
2218 error = EINVAL;
2219 goto out;
2220 }
2168 if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
2221 error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
2222 if (error)
2169 goto out;
2170 if (p->p_ucred->cr_uid != vattr.va_uid &&
2171 (error = suser(p->p_ucred, &p->p_acflag)))
2172 goto out;
2173 if (vp->v_usecount > 1 || (vp->v_flag & VALIASED))
2174 vgoneall(vp);
2175out:
2176 vrele(vp);

--- 22 unchanged lines hidden ---
2223 goto out;
2224 if (p->p_ucred->cr_uid != vattr.va_uid &&
2225 (error = suser(p->p_ucred, &p->p_acflag)))
2226 goto out;
2227 if (vp->v_usecount > 1 || (vp->v_flag & VALIASED))
2228 vgoneall(vp);
2229out:
2230 vrele(vp);

--- 22 unchanged lines hidden ---