vfs_extattr.c (43141) | vfs_extattr.c (43301) |
---|---|
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.112 1999/01/05 18:49:55 eivind Exp $ | 39 * $Id: vfs_syscalls.c,v 1.113 1999/01/24 06:28:37 bde Exp $ |
40 */ 41 42/* For 4.3 integer FS ID compatibility */ 43#include "opt_compat.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/sysent.h> --- 70 unchanged lines hidden (view full) --- 118 if (usermount == 0 && (error = suser(p->p_ucred, &p->p_acflag))) 119 return (error); 120 121 /* 122 * Get vnode to be covered 123 */ 124 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 125 SCARG(uap, path), p); | 40 */ 41 42/* For 4.3 integer FS ID compatibility */ 43#include "opt_compat.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/sysent.h> --- 70 unchanged lines hidden (view full) --- 118 if (usermount == 0 && (error = suser(p->p_ucred, &p->p_acflag))) 119 return (error); 120 121 /* 122 * Get vnode to be covered 123 */ 124 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 125 SCARG(uap, path), p); |
126 if (error = namei(&nd)) | 126 if ((error = namei(&nd)) != 0) |
127 return (error); 128 vp = nd.ni_vp; 129 if (SCARG(uap, flags) & MNT_UPDATE) { 130 if ((vp->v_flag & VROOT) == 0) { 131 vput(vp); 132 return (EINVAL); 133 } 134 mp = vp->v_mount; --- 53 unchanged lines hidden (view full) --- 188 */ 189 if (p->p_ucred->cr_uid != 0) { 190 if (SCARG(uap, flags) & MNT_EXPORTED) { 191 vput(vp); 192 return (EPERM); 193 } 194 SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV; 195 } | 127 return (error); 128 vp = nd.ni_vp; 129 if (SCARG(uap, flags) & MNT_UPDATE) { 130 if ((vp->v_flag & VROOT) == 0) { 131 vput(vp); 132 return (EINVAL); 133 } 134 mp = vp->v_mount; --- 53 unchanged lines hidden (view full) --- 188 */ 189 if (p->p_ucred->cr_uid != 0) { 190 if (SCARG(uap, flags) & MNT_EXPORTED) { 191 vput(vp); 192 return (EPERM); 193 } 194 SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV; 195 } |
196 if (error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0)) | 196 if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) |
197 return (error); 198 if (vp->v_type != VDIR) { 199 vput(vp); 200 return (ENOTDIR); 201 } 202#ifdef COMPAT_43 203 /* 204 * Historically filesystem types were identified by number. If we --- 7 unchanged lines hidden (view full) --- 212 break; 213 if (vfsp == NULL) { 214 vput(vp); 215 return (ENODEV); 216 } 217 strncpy(fstypename, vfsp->vfc_name, MFSNAMELEN); 218 } else 219#endif /* COMPAT_43 */ | 197 return (error); 198 if (vp->v_type != VDIR) { 199 vput(vp); 200 return (ENOTDIR); 201 } 202#ifdef COMPAT_43 203 /* 204 * Historically filesystem types were identified by number. If we --- 7 unchanged lines hidden (view full) --- 212 break; 213 if (vfsp == NULL) { 214 vput(vp); 215 return (ENODEV); 216 } 217 strncpy(fstypename, vfsp->vfc_name, MFSNAMELEN); 218 } else 219#endif /* COMPAT_43 */ |
220 if (error = copyinstr(SCARG(uap, type), fstypename, MFSNAMELEN, NULL)) { | 220 if ((error = copyinstr(SCARG(uap, type), fstypename, MFSNAMELEN, NULL)) != 0) { |
221 vput(vp); 222 return (error); 223 } 224 for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) 225 if (!strcmp(vfsp->vfc_name, fstypename)) 226 break; 227 if (vfsp == NULL) { 228 linker_file_t lf; 229 230 /* Refuse to load modules if securelevel raised */ 231 if (securelevel > 0) { 232 vput(vp); 233 return EPERM; 234 } 235 /* Only load modules for root (very important!) */ | 221 vput(vp); 222 return (error); 223 } 224 for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) 225 if (!strcmp(vfsp->vfc_name, fstypename)) 226 break; 227 if (vfsp == NULL) { 228 linker_file_t lf; 229 230 /* Refuse to load modules if securelevel raised */ 231 if (securelevel > 0) { 232 vput(vp); 233 return EPERM; 234 } 235 /* Only load modules for root (very important!) */ |
236 if (error = suser(p->p_ucred, &p->p_acflag)) { | 236 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) { |
237 vput(vp); 238 return error; 239 } 240 error = linker_load_file(fstypename, &lf); 241 if (error || lf == NULL) { 242 vput(vp); 243 if (lf == NULL) 244 error = ENODEV; --- 92 unchanged lines hidden (view full) --- 337 simple_lock(&mountlist_slock); 338 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); 339 simple_unlock(&mountlist_slock); 340 checkdirs(vp); 341 VOP_UNLOCK(vp, 0, p); 342 if ((mp->mnt_flag & MNT_RDONLY) == 0) 343 error = vfs_allocate_syncvnode(mp); 344 vfs_unbusy(mp, p); | 237 vput(vp); 238 return error; 239 } 240 error = linker_load_file(fstypename, &lf); 241 if (error || lf == NULL) { 242 vput(vp); 243 if (lf == NULL) 244 error = ENODEV; --- 92 unchanged lines hidden (view full) --- 337 simple_lock(&mountlist_slock); 338 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); 339 simple_unlock(&mountlist_slock); 340 checkdirs(vp); 341 VOP_UNLOCK(vp, 0, p); 342 if ((mp->mnt_flag & MNT_RDONLY) == 0) 343 error = vfs_allocate_syncvnode(mp); 344 vfs_unbusy(mp, p); |
345 if (error = VFS_START(mp, 0, p)) | 345 if ((error = VFS_START(mp, 0, p)) != 0) |
346 vrele(vp); 347 } else { 348 simple_lock(&vp->v_interlock); 349 vp->v_flag &= ~VMOUNT; 350 simple_unlock(&vp->v_interlock); 351 mp->mnt_vfc->vfc_refcount--; 352 vfs_unbusy(mp, p); 353 free((caddr_t)mp, M_MOUNT); --- 63 unchanged lines hidden (view full) --- 417{ 418 register struct vnode *vp; 419 struct mount *mp; 420 int error; 421 struct nameidata nd; 422 423 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 424 SCARG(uap, path), p); | 346 vrele(vp); 347 } else { 348 simple_lock(&vp->v_interlock); 349 vp->v_flag &= ~VMOUNT; 350 simple_unlock(&vp->v_interlock); 351 mp->mnt_vfc->vfc_refcount--; 352 vfs_unbusy(mp, p); 353 free((caddr_t)mp, M_MOUNT); --- 63 unchanged lines hidden (view full) --- 417{ 418 register struct vnode *vp; 419 struct mount *mp; 420 int error; 421 struct nameidata nd; 422 423 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 424 SCARG(uap, path), p); |
425 if (error = namei(&nd)) | 425 if ((error = namei(&nd)) != 0) |
426 return (error); 427 vp = nd.ni_vp; 428 mp = vp->v_mount; 429 430 /* 431 * Only root, or the user that did the original mount is 432 * permitted to unmount this filesystem. 433 */ --- 156 unchanged lines hidden (view full) --- 590 syscallarg(caddr_t) arg; 591 } */ *uap; 592{ 593 register struct mount *mp; 594 int error; 595 struct nameidata nd; 596 597 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 426 return (error); 427 vp = nd.ni_vp; 428 mp = vp->v_mount; 429 430 /* 431 * Only root, or the user that did the original mount is 432 * permitted to unmount this filesystem. 433 */ --- 156 unchanged lines hidden (view full) --- 590 syscallarg(caddr_t) arg; 591 } */ *uap; 592{ 593 register struct mount *mp; 594 int error; 595 struct nameidata nd; 596 597 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
598 if (error = namei(&nd)) | 598 if ((error = namei(&nd)) != 0) |
599 return (error); 600 mp = nd.ni_vp->v_mount; 601 vrele(nd.ni_vp); 602 return (VFS_QUOTACTL(mp, SCARG(uap, cmd), SCARG(uap, uid), 603 SCARG(uap, arg), p)); 604} 605 606/* --- 16 unchanged lines hidden (view full) --- 623{ 624 register struct mount *mp; 625 register struct statfs *sp; 626 int error; 627 struct nameidata nd; 628 struct statfs sb; 629 630 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 599 return (error); 600 mp = nd.ni_vp->v_mount; 601 vrele(nd.ni_vp); 602 return (VFS_QUOTACTL(mp, SCARG(uap, cmd), SCARG(uap, uid), 603 SCARG(uap, arg), p)); 604} 605 606/* --- 16 unchanged lines hidden (view full) --- 623{ 624 register struct mount *mp; 625 register struct statfs *sp; 626 int error; 627 struct nameidata nd; 628 struct statfs sb; 629 630 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
631 if (error = namei(&nd)) | 631 if ((error = namei(&nd)) != 0) |
632 return (error); 633 mp = nd.ni_vp->v_mount; 634 sp = &mp->mnt_stat; 635 vrele(nd.ni_vp); 636 error = VFS_STATFS(mp, sp, p); 637 if (error) 638 return (error); 639 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; --- 24 unchanged lines hidden (view full) --- 664 } */ *uap; 665{ 666 struct file *fp; 667 struct mount *mp; 668 register struct statfs *sp; 669 int error; 670 struct statfs sb; 671 | 632 return (error); 633 mp = nd.ni_vp->v_mount; 634 sp = &mp->mnt_stat; 635 vrele(nd.ni_vp); 636 error = VFS_STATFS(mp, sp, p); 637 if (error) 638 return (error); 639 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; --- 24 unchanged lines hidden (view full) --- 664 } */ *uap; 665{ 666 struct file *fp; 667 struct mount *mp; 668 register struct statfs *sp; 669 int error; 670 struct statfs sb; 671 |
672 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 672 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
673 return (error); 674 mp = ((struct vnode *)fp->f_data)->v_mount; 675 sp = &mp->mnt_stat; 676 error = VFS_STATFS(mp, sp, p); 677 if (error) 678 return (error); 679 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; 680 if (p->p_ucred->cr_uid != 0) { --- 90 unchanged lines hidden (view full) --- 771 } */ *uap; 772{ 773 register struct filedesc *fdp = p->p_fd; 774 struct vnode *vp, *tdp; 775 struct mount *mp; 776 struct file *fp; 777 int error; 778 | 673 return (error); 674 mp = ((struct vnode *)fp->f_data)->v_mount; 675 sp = &mp->mnt_stat; 676 error = VFS_STATFS(mp, sp, p); 677 if (error) 678 return (error); 679 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; 680 if (p->p_ucred->cr_uid != 0) { --- 90 unchanged lines hidden (view full) --- 771 } */ *uap; 772{ 773 register struct filedesc *fdp = p->p_fd; 774 struct vnode *vp, *tdp; 775 struct mount *mp; 776 struct file *fp; 777 int error; 778 |
779 if (error = getvnode(fdp, SCARG(uap, fd), &fp)) | 779 if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0) |
780 return (error); 781 vp = (struct vnode *)fp->f_data; 782 VREF(vp); 783 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 784 if (vp->v_type != VDIR) 785 error = ENOTDIR; 786 else 787 error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); --- 34 unchanged lines hidden (view full) --- 822 } */ *uap; 823{ 824 register struct filedesc *fdp = p->p_fd; 825 int error; 826 struct nameidata nd; 827 828 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 829 SCARG(uap, path), p); | 780 return (error); 781 vp = (struct vnode *)fp->f_data; 782 VREF(vp); 783 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 784 if (vp->v_type != VDIR) 785 error = ENOTDIR; 786 else 787 error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); --- 34 unchanged lines hidden (view full) --- 822 } */ *uap; 823{ 824 register struct filedesc *fdp = p->p_fd; 825 int error; 826 struct nameidata nd; 827 828 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 829 SCARG(uap, path), p); |
830 if (error = change_dir(&nd, p)) | 830 if ((error = change_dir(&nd, p)) != 0) |
831 return (error); 832 vrele(fdp->fd_cdir); 833 fdp->fd_cdir = nd.ni_vp; 834 return (0); 835} 836 837/* 838 * Change notion of root (``/'') directory. --- 15 unchanged lines hidden (view full) --- 854 int error; 855 struct nameidata nd; 856 857 error = suser(p->p_ucred, &p->p_acflag); 858 if (error) 859 return (error); 860 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 861 SCARG(uap, path), p); | 831 return (error); 832 vrele(fdp->fd_cdir); 833 fdp->fd_cdir = nd.ni_vp; 834 return (0); 835} 836 837/* 838 * Change notion of root (``/'') directory. --- 15 unchanged lines hidden (view full) --- 854 int error; 855 struct nameidata nd; 856 857 error = suser(p->p_ucred, &p->p_acflag); 858 if (error) 859 return (error); 860 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 861 SCARG(uap, path), p); |
862 if (error = change_dir(&nd, p)) | 862 if ((error = change_dir(&nd, p)) != 0) |
863 return (error); 864 vrele(fdp->fd_rdir); 865 fdp->fd_rdir = nd.ni_vp; 866 return (0); 867} 868 869/* 870 * Common routine for chroot and chdir. --- 90 unchanged lines hidden (view full) --- 961 if (flags & O_EXLOCK) 962 lf.l_type = F_WRLCK; 963 else 964 lf.l_type = F_RDLCK; 965 type = F_FLOCK; 966 if ((flags & FNONBLOCK) == 0) 967 type |= F_WAIT; 968 VOP_UNLOCK(vp, 0, p); | 863 return (error); 864 vrele(fdp->fd_rdir); 865 fdp->fd_rdir = nd.ni_vp; 866 return (0); 867} 868 869/* 870 * Common routine for chroot and chdir. --- 90 unchanged lines hidden (view full) --- 961 if (flags & O_EXLOCK) 962 lf.l_type = F_WRLCK; 963 else 964 lf.l_type = F_RDLCK; 965 type = F_FLOCK; 966 if ((flags & FNONBLOCK) == 0) 967 type |= F_WAIT; 968 VOP_UNLOCK(vp, 0, p); |
969 if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) { | 969 if ((error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) != 0) { |
970 (void) vn_close(vp, fp->f_flag, fp->f_cred, p); 971 ffree(fp); 972 fdp->fd_ofiles[indx] = NULL; 973 return (error); 974 } 975 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 976 fp->f_flag |= FHASLOCK; 977 } --- 60 unchanged lines hidden (view full) --- 1038 int error; 1039 int whiteout = 0; 1040 struct nameidata nd; 1041 1042 error = suser(p->p_ucred, &p->p_acflag); 1043 if (error) 1044 return (error); 1045 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); | 970 (void) vn_close(vp, fp->f_flag, fp->f_cred, p); 971 ffree(fp); 972 fdp->fd_ofiles[indx] = NULL; 973 return (error); 974 } 975 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 976 fp->f_flag |= FHASLOCK; 977 } --- 60 unchanged lines hidden (view full) --- 1038 int error; 1039 int whiteout = 0; 1040 struct nameidata nd; 1041 1042 error = suser(p->p_ucred, &p->p_acflag); 1043 if (error) 1044 return (error); 1045 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); |
1046 if (error = namei(&nd)) | 1046 if ((error = namei(&nd)) != 0) |
1047 return (error); 1048 vp = nd.ni_vp; 1049 if (vp != NULL) 1050 error = EEXIST; 1051 else { 1052 VATTR_NULL(&vattr); 1053 vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask; 1054 vattr.va_rdev = SCARG(uap, dev); --- 61 unchanged lines hidden (view full) --- 1116 syscallarg(int) mode; 1117 } */ *uap; 1118{ 1119 struct vattr vattr; 1120 int error; 1121 struct nameidata nd; 1122 1123 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); | 1047 return (error); 1048 vp = nd.ni_vp; 1049 if (vp != NULL) 1050 error = EEXIST; 1051 else { 1052 VATTR_NULL(&vattr); 1053 vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask; 1054 vattr.va_rdev = SCARG(uap, dev); --- 61 unchanged lines hidden (view full) --- 1116 syscallarg(int) mode; 1117 } */ *uap; 1118{ 1119 struct vattr vattr; 1120 int error; 1121 struct nameidata nd; 1122 1123 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); |
1124 if (error = namei(&nd)) | 1124 if ((error = namei(&nd)) != 0) |
1125 return (error); 1126 if (nd.ni_vp != NULL) { 1127 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 1128 if (nd.ni_dvp == nd.ni_vp) 1129 vrele(nd.ni_dvp); 1130 else 1131 vput(nd.ni_dvp); 1132 vrele(nd.ni_vp); --- 26 unchanged lines hidden (view full) --- 1159 syscallarg(char *) link; 1160 } */ *uap; 1161{ 1162 register struct vnode *vp; 1163 struct nameidata nd; 1164 int error; 1165 1166 NDINIT(&nd, LOOKUP, FOLLOW|NOOBJ, UIO_USERSPACE, SCARG(uap, path), p); | 1125 return (error); 1126 if (nd.ni_vp != NULL) { 1127 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 1128 if (nd.ni_dvp == nd.ni_vp) 1129 vrele(nd.ni_dvp); 1130 else 1131 vput(nd.ni_dvp); 1132 vrele(nd.ni_vp); --- 26 unchanged lines hidden (view full) --- 1159 syscallarg(char *) link; 1160 } */ *uap; 1161{ 1162 register struct vnode *vp; 1163 struct nameidata nd; 1164 int error; 1165 1166 NDINIT(&nd, LOOKUP, FOLLOW|NOOBJ, UIO_USERSPACE, SCARG(uap, path), p); |
1167 if (error = namei(&nd)) | 1167 if ((error = namei(&nd)) != 0) |
1168 return (error); 1169 vp = nd.ni_vp; 1170 if (vp->v_type == VDIR) 1171 error = EPERM; /* POSIX */ 1172 else { 1173 NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); 1174 error = namei(&nd); 1175 if (!error) { --- 39 unchanged lines hidden (view full) --- 1215 } */ *uap; 1216{ 1217 struct vattr vattr; 1218 char *path; 1219 int error; 1220 struct nameidata nd; 1221 1222 path = zalloc(namei_zone); | 1168 return (error); 1169 vp = nd.ni_vp; 1170 if (vp->v_type == VDIR) 1171 error = EPERM; /* POSIX */ 1172 else { 1173 NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); 1174 error = namei(&nd); 1175 if (!error) { --- 39 unchanged lines hidden (view full) --- 1215 } */ *uap; 1216{ 1217 struct vattr vattr; 1218 char *path; 1219 int error; 1220 struct nameidata nd; 1221 1222 path = zalloc(namei_zone); |
1223 if (error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL)) | 1223 if ((error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL)) != 0) |
1224 goto out; 1225 NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); | 1224 goto out; 1225 NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); |
1226 if (error = namei(&nd)) | 1226 if ((error = namei(&nd)) != 0) |
1227 goto out; 1228 if (nd.ni_vp) { 1229 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 1230 if (nd.ni_dvp == nd.ni_vp) 1231 vrele(nd.ni_dvp); 1232 else 1233 vput(nd.ni_dvp); 1234 vrele(nd.ni_vp); --- 39 unchanged lines hidden (view full) --- 1274 else 1275 vput(nd.ni_dvp); 1276 if (nd.ni_vp) 1277 vrele(nd.ni_vp); 1278 return (EEXIST); 1279 } 1280 1281 VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); | 1227 goto out; 1228 if (nd.ni_vp) { 1229 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 1230 if (nd.ni_dvp == nd.ni_vp) 1231 vrele(nd.ni_dvp); 1232 else 1233 vput(nd.ni_dvp); 1234 vrele(nd.ni_vp); --- 39 unchanged lines hidden (view full) --- 1274 else 1275 vput(nd.ni_dvp); 1276 if (nd.ni_vp) 1277 vrele(nd.ni_vp); 1278 return (EEXIST); 1279 } 1280 1281 VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); |
1282 if (error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE)) | 1282 if ((error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE)) != 0) |
1283 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 1284 vput(nd.ni_dvp); 1285 ASSERT_VOP_UNLOCKED(nd.ni_dvp, "undelete"); 1286 ASSERT_VOP_UNLOCKED(nd.ni_vp, "undelete"); 1287 return (error); 1288} 1289 1290/* --- 12 unchanged lines hidden (view full) --- 1303 syscallarg(char *) path; 1304 } */ *uap; 1305{ 1306 register struct vnode *vp; 1307 int error; 1308 struct nameidata nd; 1309 1310 NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); | 1283 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 1284 vput(nd.ni_dvp); 1285 ASSERT_VOP_UNLOCKED(nd.ni_dvp, "undelete"); 1286 ASSERT_VOP_UNLOCKED(nd.ni_vp, "undelete"); 1287 return (error); 1288} 1289 1290/* --- 12 unchanged lines hidden (view full) --- 1303 syscallarg(char *) path; 1304 } */ *uap; 1305{ 1306 register struct vnode *vp; 1307 int error; 1308 struct nameidata nd; 1309 1310 NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); |
1311 if (error = namei(&nd)) | 1311 if ((error = namei(&nd)) != 0) |
1312 return (error); 1313 vp = nd.ni_vp; 1314 VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); 1315 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 1316 1317 if (vp->v_type == VDIR) 1318 error = EPERM; /* POSIX */ 1319 else { --- 134 unchanged lines hidden (view full) --- 1454 struct nameidata nd; 1455 1456 t_uid = cred->cr_uid; 1457 t_gid = cred->cr_groups[0]; 1458 cred->cr_uid = p->p_cred->p_ruid; 1459 cred->cr_groups[0] = p->p_cred->p_rgid; 1460 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1461 SCARG(uap, path), p); | 1312 return (error); 1313 vp = nd.ni_vp; 1314 VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); 1315 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 1316 1317 if (vp->v_type == VDIR) 1318 error = EPERM; /* POSIX */ 1319 else { --- 134 unchanged lines hidden (view full) --- 1454 struct nameidata nd; 1455 1456 t_uid = cred->cr_uid; 1457 t_gid = cred->cr_groups[0]; 1458 cred->cr_uid = p->p_cred->p_ruid; 1459 cred->cr_groups[0] = p->p_cred->p_rgid; 1460 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1461 SCARG(uap, path), p); |
1462 if (error = namei(&nd)) | 1462 if ((error = namei(&nd)) != 0) |
1463 goto out1; 1464 vp = nd.ni_vp; 1465 1466 /* Flags == 0 means only check for existence. */ 1467 if (SCARG(uap, flags)) { 1468 flags = 0; 1469 if (SCARG(uap, flags) & R_OK) 1470 flags |= VREAD; --- 32 unchanged lines hidden (view full) --- 1503{ 1504 struct stat sb; 1505 struct ostat osb; 1506 int error; 1507 struct nameidata nd; 1508 1509 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1510 SCARG(uap, path), p); | 1463 goto out1; 1464 vp = nd.ni_vp; 1465 1466 /* Flags == 0 means only check for existence. */ 1467 if (SCARG(uap, flags)) { 1468 flags = 0; 1469 if (SCARG(uap, flags) & R_OK) 1470 flags |= VREAD; --- 32 unchanged lines hidden (view full) --- 1503{ 1504 struct stat sb; 1505 struct ostat osb; 1506 int error; 1507 struct nameidata nd; 1508 1509 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1510 SCARG(uap, path), p); |
1511 if (error = namei(&nd)) | 1511 if ((error = namei(&nd)) != 0) |
1512 return (error); 1513 error = vn_stat(nd.ni_vp, &sb, p); 1514 vput(nd.ni_vp); 1515 if (error) 1516 return (error); 1517 cvtstat(&sb, &osb); 1518 error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); 1519 return (error); --- 20 unchanged lines hidden (view full) --- 1540 struct vnode *vp; 1541 struct stat sb; 1542 struct ostat osb; 1543 int error; 1544 struct nameidata nd; 1545 1546 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1547 SCARG(uap, path), p); | 1512 return (error); 1513 error = vn_stat(nd.ni_vp, &sb, p); 1514 vput(nd.ni_vp); 1515 if (error) 1516 return (error); 1517 cvtstat(&sb, &osb); 1518 error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); 1519 return (error); --- 20 unchanged lines hidden (view full) --- 1540 struct vnode *vp; 1541 struct stat sb; 1542 struct ostat osb; 1543 int error; 1544 struct nameidata nd; 1545 1546 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1547 SCARG(uap, path), p); |
1548 if (error = namei(&nd)) | 1548 if ((error = namei(&nd)) != 0) |
1549 return (error); 1550 vp = nd.ni_vp; 1551 error = vn_stat(vp, &sb, p); 1552 vput(vp); 1553 if (error) 1554 return (error); 1555 cvtstat(&sb, &osb); 1556 error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); --- 49 unchanged lines hidden (view full) --- 1606 } */ *uap; 1607{ 1608 struct stat sb; 1609 int error; 1610 struct nameidata nd; 1611 1612 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1613 SCARG(uap, path), p); | 1549 return (error); 1550 vp = nd.ni_vp; 1551 error = vn_stat(vp, &sb, p); 1552 vput(vp); 1553 if (error) 1554 return (error); 1555 cvtstat(&sb, &osb); 1556 error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); --- 49 unchanged lines hidden (view full) --- 1606 } */ *uap; 1607{ 1608 struct stat sb; 1609 int error; 1610 struct nameidata nd; 1611 1612 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1613 SCARG(uap, path), p); |
1614 if (error = namei(&nd)) | 1614 if ((error = namei(&nd)) != 0) |
1615 return (error); 1616 error = vn_stat(nd.ni_vp, &sb, p); 1617 vput(nd.ni_vp); 1618 if (error) 1619 return (error); 1620 error = copyout((caddr_t)&sb, (caddr_t)SCARG(uap, ub), sizeof (sb)); 1621 return (error); 1622} --- 18 unchanged lines hidden (view full) --- 1641{ 1642 int error; 1643 struct vnode *vp; 1644 struct stat sb; 1645 struct nameidata nd; 1646 1647 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1648 SCARG(uap, path), p); | 1615 return (error); 1616 error = vn_stat(nd.ni_vp, &sb, p); 1617 vput(nd.ni_vp); 1618 if (error) 1619 return (error); 1620 error = copyout((caddr_t)&sb, (caddr_t)SCARG(uap, ub), sizeof (sb)); 1621 return (error); 1622} --- 18 unchanged lines hidden (view full) --- 1641{ 1642 int error; 1643 struct vnode *vp; 1644 struct stat sb; 1645 struct nameidata nd; 1646 1647 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1648 SCARG(uap, path), p); |
1649 if (error = namei(&nd)) | 1649 if ((error = namei(&nd)) != 0) |
1650 return (error); 1651 vp = nd.ni_vp; 1652 error = vn_stat(vp, &sb, p); 1653 vput(vp); 1654 if (error) 1655 return (error); 1656 error = copyout((caddr_t)&sb, (caddr_t)SCARG(uap, ub), sizeof (sb)); 1657 return (error); --- 38 unchanged lines hidden (view full) --- 1696{ 1697 struct stat sb; 1698 struct nstat nsb; 1699 int error; 1700 struct nameidata nd; 1701 1702 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1703 SCARG(uap, path), p); | 1650 return (error); 1651 vp = nd.ni_vp; 1652 error = vn_stat(vp, &sb, p); 1653 vput(vp); 1654 if (error) 1655 return (error); 1656 error = copyout((caddr_t)&sb, (caddr_t)SCARG(uap, ub), sizeof (sb)); 1657 return (error); --- 38 unchanged lines hidden (view full) --- 1696{ 1697 struct stat sb; 1698 struct nstat nsb; 1699 int error; 1700 struct nameidata nd; 1701 1702 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1703 SCARG(uap, path), p); |
1704 if (error = namei(&nd)) | 1704 if ((error = namei(&nd)) != 0) |
1705 return (error); 1706 error = vn_stat(nd.ni_vp, &sb, p); 1707 vput(nd.ni_vp); 1708 if (error) 1709 return (error); 1710 cvtnstat(&sb, &nsb); 1711 error = copyout((caddr_t)&nsb, (caddr_t)SCARG(uap, ub), sizeof (nsb)); 1712 return (error); --- 20 unchanged lines hidden (view full) --- 1733 int error; 1734 struct vnode *vp; 1735 struct stat sb; 1736 struct nstat nsb; 1737 struct nameidata nd; 1738 1739 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1740 SCARG(uap, path), p); | 1705 return (error); 1706 error = vn_stat(nd.ni_vp, &sb, p); 1707 vput(nd.ni_vp); 1708 if (error) 1709 return (error); 1710 cvtnstat(&sb, &nsb); 1711 error = copyout((caddr_t)&nsb, (caddr_t)SCARG(uap, ub), sizeof (nsb)); 1712 return (error); --- 20 unchanged lines hidden (view full) --- 1733 int error; 1734 struct vnode *vp; 1735 struct stat sb; 1736 struct nstat nsb; 1737 struct nameidata nd; 1738 1739 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1740 SCARG(uap, path), p); |
1741 if (error = namei(&nd)) | 1741 if ((error = namei(&nd)) != 0) |
1742 return (error); 1743 vp = nd.ni_vp; 1744 error = vn_stat(vp, &sb, p); 1745 vput(vp); 1746 if (error) 1747 return (error); 1748 cvtnstat(&sb, &nsb); 1749 error = copyout((caddr_t)&nsb, (caddr_t)SCARG(uap, ub), sizeof (nsb)); --- 18 unchanged lines hidden (view full) --- 1768 syscallarg(int) name; 1769 } */ *uap; 1770{ 1771 int error; 1772 struct nameidata nd; 1773 1774 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1775 SCARG(uap, path), p); | 1742 return (error); 1743 vp = nd.ni_vp; 1744 error = vn_stat(vp, &sb, p); 1745 vput(vp); 1746 if (error) 1747 return (error); 1748 cvtnstat(&sb, &nsb); 1749 error = copyout((caddr_t)&nsb, (caddr_t)SCARG(uap, ub), sizeof (nsb)); --- 18 unchanged lines hidden (view full) --- 1768 syscallarg(int) name; 1769 } */ *uap; 1770{ 1771 int error; 1772 struct nameidata nd; 1773 1774 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1775 SCARG(uap, path), p); |
1776 if (error = namei(&nd)) | 1776 if ((error = namei(&nd)) != 0) |
1777 return (error); 1778 error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), p->p_retval); 1779 vput(nd.ni_vp); 1780 return (error); 1781} 1782 1783/* 1784 * Return target name of a symbolic link. --- 18 unchanged lines hidden (view full) --- 1803 register struct vnode *vp; 1804 struct iovec aiov; 1805 struct uio auio; 1806 int error; 1807 struct nameidata nd; 1808 1809 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1810 SCARG(uap, path), p); | 1777 return (error); 1778 error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), p->p_retval); 1779 vput(nd.ni_vp); 1780 return (error); 1781} 1782 1783/* 1784 * Return target name of a symbolic link. --- 18 unchanged lines hidden (view full) --- 1803 register struct vnode *vp; 1804 struct iovec aiov; 1805 struct uio auio; 1806 int error; 1807 struct nameidata nd; 1808 1809 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, 1810 SCARG(uap, path), p); |
1811 if (error = namei(&nd)) | 1811 if ((error = namei(&nd)) != 0) |
1812 return (error); 1813 vp = nd.ni_vp; 1814 if (vp->v_type != VLNK) 1815 error = EINVAL; 1816 else { 1817 aiov.iov_base = SCARG(uap, buf); 1818 aiov.iov_len = SCARG(uap, count); 1819 auio.uio_iov = &aiov; --- 45 unchanged lines hidden (view full) --- 1865 syscallarg(char *) path; 1866 syscallarg(int) flags; 1867 } */ *uap; 1868{ 1869 int error; 1870 struct nameidata nd; 1871 1872 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 1812 return (error); 1813 vp = nd.ni_vp; 1814 if (vp->v_type != VLNK) 1815 error = EINVAL; 1816 else { 1817 aiov.iov_base = SCARG(uap, buf); 1818 aiov.iov_len = SCARG(uap, count); 1819 auio.uio_iov = &aiov; --- 45 unchanged lines hidden (view full) --- 1865 syscallarg(char *) path; 1866 syscallarg(int) flags; 1867 } */ *uap; 1868{ 1869 int error; 1870 struct nameidata nd; 1871 1872 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
1873 if (error = namei(&nd)) | 1873 if ((error = namei(&nd)) != 0) |
1874 return (error); 1875 error = setfflags(p, nd.ni_vp, SCARG(uap, flags)); 1876 vrele(nd.ni_vp); 1877 return error; 1878} 1879 1880/* 1881 * Change flags of a file given a file descriptor. --- 11 unchanged lines hidden (view full) --- 1893 register struct fchflags_args /* { 1894 syscallarg(int) fd; 1895 syscallarg(int) flags; 1896 } */ *uap; 1897{ 1898 struct file *fp; 1899 int error; 1900 | 1874 return (error); 1875 error = setfflags(p, nd.ni_vp, SCARG(uap, flags)); 1876 vrele(nd.ni_vp); 1877 return error; 1878} 1879 1880/* 1881 * Change flags of a file given a file descriptor. --- 11 unchanged lines hidden (view full) --- 1893 register struct fchflags_args /* { 1894 syscallarg(int) fd; 1895 syscallarg(int) flags; 1896 } */ *uap; 1897{ 1898 struct file *fp; 1899 int error; 1900 |
1901 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 1901 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
1902 return (error); 1903 return setfflags(p, (struct vnode *) fp->f_data, SCARG(uap, flags)); 1904} 1905 1906static int 1907setfmode(p, vp, mode) 1908 struct proc *p; 1909 struct vnode *vp; --- 28 unchanged lines hidden (view full) --- 1938 syscallarg(char *) path; 1939 syscallarg(int) mode; 1940 } */ *uap; 1941{ 1942 int error; 1943 struct nameidata nd; 1944 1945 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 1902 return (error); 1903 return setfflags(p, (struct vnode *) fp->f_data, SCARG(uap, flags)); 1904} 1905 1906static int 1907setfmode(p, vp, mode) 1908 struct proc *p; 1909 struct vnode *vp; --- 28 unchanged lines hidden (view full) --- 1938 syscallarg(char *) path; 1939 syscallarg(int) mode; 1940 } */ *uap; 1941{ 1942 int error; 1943 struct nameidata nd; 1944 1945 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
1946 if (error = namei(&nd)) | 1946 if ((error = namei(&nd)) != 0) |
1947 return (error); 1948 error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); 1949 vrele(nd.ni_vp); 1950 return error; 1951} 1952 1953/* 1954 * Change mode of a file given path name (don't follow links.) --- 12 unchanged lines hidden (view full) --- 1967 syscallarg(char *) path; 1968 syscallarg(int) mode; 1969 } */ *uap; 1970{ 1971 int error; 1972 struct nameidata nd; 1973 1974 NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 1947 return (error); 1948 error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); 1949 vrele(nd.ni_vp); 1950 return error; 1951} 1952 1953/* 1954 * Change mode of a file given path name (don't follow links.) --- 12 unchanged lines hidden (view full) --- 1967 syscallarg(char *) path; 1968 syscallarg(int) mode; 1969 } */ *uap; 1970{ 1971 int error; 1972 struct nameidata nd; 1973 1974 NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
1975 if (error = namei(&nd)) | 1975 if ((error = namei(&nd)) != 0) |
1976 return (error); 1977 error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); 1978 vrele(nd.ni_vp); 1979 return error; 1980} 1981 1982/* 1983 * Change mode of a file given a file descriptor. --- 11 unchanged lines hidden (view full) --- 1995 register struct fchmod_args /* { 1996 syscallarg(int) fd; 1997 syscallarg(int) mode; 1998 } */ *uap; 1999{ 2000 struct file *fp; 2001 int error; 2002 | 1976 return (error); 1977 error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); 1978 vrele(nd.ni_vp); 1979 return error; 1980} 1981 1982/* 1983 * Change mode of a file given a file descriptor. --- 11 unchanged lines hidden (view full) --- 1995 register struct fchmod_args /* { 1996 syscallarg(int) fd; 1997 syscallarg(int) mode; 1998 } */ *uap; 1999{ 2000 struct file *fp; 2001 int error; 2002 |
2003 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 2003 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
2004 return (error); 2005 return setfmode(p, (struct vnode *)fp->f_data, SCARG(uap, mode)); 2006} 2007 2008static int 2009setfown(p, vp, uid, gid) 2010 struct proc *p; 2011 struct vnode *vp; --- 32 unchanged lines hidden (view full) --- 2044 syscallarg(int) uid; 2045 syscallarg(int) gid; 2046 } */ *uap; 2047{ 2048 int error; 2049 struct nameidata nd; 2050 2051 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 2004 return (error); 2005 return setfmode(p, (struct vnode *)fp->f_data, SCARG(uap, mode)); 2006} 2007 2008static int 2009setfown(p, vp, uid, gid) 2010 struct proc *p; 2011 struct vnode *vp; --- 32 unchanged lines hidden (view full) --- 2044 syscallarg(int) uid; 2045 syscallarg(int) gid; 2046 } */ *uap; 2047{ 2048 int error; 2049 struct nameidata nd; 2050 2051 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
2052 if (error = namei(&nd)) | 2052 if ((error = namei(&nd)) != 0) |
2053 return (error); 2054 error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); 2055 vrele(nd.ni_vp); 2056 2057 return (error); 2058} 2059 2060/* --- 15 unchanged lines hidden (view full) --- 2076 syscallarg(int) uid; 2077 syscallarg(int) gid; 2078 } */ *uap; 2079{ 2080 int error; 2081 struct nameidata nd; 2082 2083 NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 2053 return (error); 2054 error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); 2055 vrele(nd.ni_vp); 2056 2057 return (error); 2058} 2059 2060/* --- 15 unchanged lines hidden (view full) --- 2076 syscallarg(int) uid; 2077 syscallarg(int) gid; 2078 } */ *uap; 2079{ 2080 int error; 2081 struct nameidata nd; 2082 2083 NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
2084 if (error = namei(&nd)) | 2084 if ((error = namei(&nd)) != 0) |
2085 return (error); 2086 error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); 2087 vrele(nd.ni_vp); 2088 return (error); 2089} 2090 2091/* 2092 * Set ownership given a file descriptor. --- 13 unchanged lines hidden (view full) --- 2106 syscallarg(int) fd; 2107 syscallarg(int) uid; 2108 syscallarg(int) gid; 2109 } */ *uap; 2110{ 2111 struct file *fp; 2112 int error; 2113 | 2085 return (error); 2086 error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); 2087 vrele(nd.ni_vp); 2088 return (error); 2089} 2090 2091/* 2092 * Set ownership given a file descriptor. --- 13 unchanged lines hidden (view full) --- 2106 syscallarg(int) fd; 2107 syscallarg(int) uid; 2108 syscallarg(int) gid; 2109 } */ *uap; 2110{ 2111 struct file *fp; 2112 int error; 2113 |
2114 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 2114 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
2115 return (error); 2116 return setfown(p, (struct vnode *)fp->f_data, 2117 SCARG(uap, uid), SCARG(uap, gid)); 2118} 2119 2120static int 2121setutimes(p, vp, tv, nullflag) 2122 struct proc *p; --- 41 unchanged lines hidden (view full) --- 2164 struct nameidata nd; 2165 int nullflag; 2166 2167 nullflag = 0; 2168 if (SCARG(uap, tptr) == NULL) { 2169 microtime(&tv[0]); 2170 tv[1] = tv[0]; 2171 nullflag = 1; | 2115 return (error); 2116 return setfown(p, (struct vnode *)fp->f_data, 2117 SCARG(uap, uid), SCARG(uap, gid)); 2118} 2119 2120static int 2121setutimes(p, vp, tv, nullflag) 2122 struct proc *p; --- 41 unchanged lines hidden (view full) --- 2164 struct nameidata nd; 2165 int nullflag; 2166 2167 nullflag = 0; 2168 if (SCARG(uap, tptr) == NULL) { 2169 microtime(&tv[0]); 2170 tv[1] = tv[0]; 2171 nullflag = 1; |
2172 } else if (error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv, 2173 sizeof (tv))) | 2172 } else if ((error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv, 2173 sizeof (tv))) != 0) |
2174 return (error); 2175 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 2174 return (error); 2175 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
2176 if (error = namei(&nd)) | 2176 if ((error = namei(&nd)) != 0) |
2177 return (error); 2178 error = setutimes(p, nd.ni_vp, tv, nullflag); 2179 vrele(nd.ni_vp); 2180 return (error); 2181} 2182 2183/* 2184 * Set the access and modification times of a file. --- 18 unchanged lines hidden (view full) --- 2203 struct nameidata nd; 2204 int nullflag; 2205 2206 nullflag = 0; 2207 if (SCARG(uap, tptr) == NULL) { 2208 microtime(&tv[0]); 2209 tv[1] = tv[0]; 2210 nullflag = 1; | 2177 return (error); 2178 error = setutimes(p, nd.ni_vp, tv, nullflag); 2179 vrele(nd.ni_vp); 2180 return (error); 2181} 2182 2183/* 2184 * Set the access and modification times of a file. --- 18 unchanged lines hidden (view full) --- 2203 struct nameidata nd; 2204 int nullflag; 2205 2206 nullflag = 0; 2207 if (SCARG(uap, tptr) == NULL) { 2208 microtime(&tv[0]); 2209 tv[1] = tv[0]; 2210 nullflag = 1; |
2211 } else if (error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv, 2212 sizeof (tv))) | 2211 } else if ((error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv, 2212 sizeof (tv))) != 0) |
2213 return (error); 2214 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 2213 return (error); 2214 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
2215 if (error = namei(&nd)) | 2215 if ((error = namei(&nd)) != 0) |
2216 return (error); 2217 2218 error = setutimes(p, nd.ni_vp, tv, nullflag); 2219 vrele(nd.ni_vp); 2220 return (error); 2221} 2222 2223/* --- 19 unchanged lines hidden (view full) --- 2243 int error; 2244 int nullflag; 2245 2246 nullflag = 0; 2247 if (SCARG(uap, tptr) == NULL) { 2248 microtime(&tv[0]); 2249 tv[1] = tv[0]; 2250 nullflag = 1; | 2216 return (error); 2217 2218 error = setutimes(p, nd.ni_vp, tv, nullflag); 2219 vrele(nd.ni_vp); 2220 return (error); 2221} 2222 2223/* --- 19 unchanged lines hidden (view full) --- 2243 int error; 2244 int nullflag; 2245 2246 nullflag = 0; 2247 if (SCARG(uap, tptr) == NULL) { 2248 microtime(&tv[0]); 2249 tv[1] = tv[0]; 2250 nullflag = 1; |
2251 } else if (error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv, 2252 sizeof (tv))) | 2251 } else if ((error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv, 2252 sizeof (tv))) != 0) |
2253 return (error); 2254 | 2253 return (error); 2254 |
2255 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 2255 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
2256 return (error); 2257 return setutimes(p, (struct vnode *)fp->f_data, tv, nullflag); 2258} 2259 2260/* 2261 * Truncate a file given its path name. 2262 */ 2263#ifndef _SYS_SYSPROTO_H_ --- 16 unchanged lines hidden (view full) --- 2280 register struct vnode *vp; 2281 struct vattr vattr; 2282 int error; 2283 struct nameidata nd; 2284 2285 if (uap->length < 0) 2286 return(EINVAL); 2287 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 2256 return (error); 2257 return setutimes(p, (struct vnode *)fp->f_data, tv, nullflag); 2258} 2259 2260/* 2261 * Truncate a file given its path name. 2262 */ 2263#ifndef _SYS_SYSPROTO_H_ --- 16 unchanged lines hidden (view full) --- 2280 register struct vnode *vp; 2281 struct vattr vattr; 2282 int error; 2283 struct nameidata nd; 2284 2285 if (uap->length < 0) 2286 return(EINVAL); 2287 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
2288 if (error = namei(&nd)) | 2288 if ((error = namei(&nd)) != 0) |
2289 return (error); 2290 vp = nd.ni_vp; 2291 VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); 2292 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 2293 if (vp->v_type == VDIR) 2294 error = EISDIR; 2295 else if ((error = vn_writechk(vp)) == 0 && 2296 (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) { --- 27 unchanged lines hidden (view full) --- 2324{ 2325 struct vattr vattr; 2326 struct vnode *vp; 2327 struct file *fp; 2328 int error; 2329 2330 if (uap->length < 0) 2331 return(EINVAL); | 2289 return (error); 2290 vp = nd.ni_vp; 2291 VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); 2292 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 2293 if (vp->v_type == VDIR) 2294 error = EISDIR; 2295 else if ((error = vn_writechk(vp)) == 0 && 2296 (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) { --- 27 unchanged lines hidden (view full) --- 2324{ 2325 struct vattr vattr; 2326 struct vnode *vp; 2327 struct file *fp; 2328 int error; 2329 2330 if (uap->length < 0) 2331 return(EINVAL); |
2332 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 2332 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
2333 return (error); 2334 if ((fp->f_flag & FWRITE) == 0) 2335 return (EINVAL); 2336 vp = (struct vnode *)fp->f_data; 2337 VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); 2338 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 2339 if (vp->v_type == VDIR) 2340 error = EISDIR; --- 81 unchanged lines hidden (view full) --- 2422 struct fsync_args /* { 2423 syscallarg(int) fd; 2424 } */ *uap; 2425{ 2426 register struct vnode *vp; 2427 struct file *fp; 2428 int error; 2429 | 2333 return (error); 2334 if ((fp->f_flag & FWRITE) == 0) 2335 return (EINVAL); 2336 vp = (struct vnode *)fp->f_data; 2337 VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); 2338 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 2339 if (vp->v_type == VDIR) 2340 error = EISDIR; --- 81 unchanged lines hidden (view full) --- 2422 struct fsync_args /* { 2423 syscallarg(int) fd; 2424 } */ *uap; 2425{ 2426 register struct vnode *vp; 2427 struct file *fp; 2428 int error; 2429 |
2430 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 2430 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
2431 return (error); 2432 vp = (struct vnode *)fp->f_data; 2433 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 2434 if (vp->v_object) 2435 vm_object_page_clean(vp->v_object, 0, 0, 0); 2436 if ((error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p)) == 0 && 2437 vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) && 2438 bioops.io_fsync) --- 22 unchanged lines hidden (view full) --- 2461 } */ *uap; 2462{ 2463 register struct vnode *tvp, *fvp, *tdvp; 2464 struct nameidata fromnd, tond; 2465 int error; 2466 2467 NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE, 2468 SCARG(uap, from), p); | 2431 return (error); 2432 vp = (struct vnode *)fp->f_data; 2433 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); 2434 if (vp->v_object) 2435 vm_object_page_clean(vp->v_object, 0, 0, 0); 2436 if ((error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p)) == 0 && 2437 vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) && 2438 bioops.io_fsync) --- 22 unchanged lines hidden (view full) --- 2461 } */ *uap; 2462{ 2463 register struct vnode *tvp, *fvp, *tdvp; 2464 struct nameidata fromnd, tond; 2465 int error; 2466 2467 NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE, 2468 SCARG(uap, from), p); |
2469 if (error = namei(&fromnd)) | 2469 if ((error = namei(&fromnd)) != 0) |
2470 return (error); 2471 fvp = fromnd.ni_vp; 2472 NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | NOOBJ, 2473 UIO_USERSPACE, SCARG(uap, to), p); 2474 if (fromnd.ni_vp->v_type == VDIR) 2475 tond.ni_cnd.cn_flags |= WILLBEDIR; | 2470 return (error); 2471 fvp = fromnd.ni_vp; 2472 NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | NOOBJ, 2473 UIO_USERSPACE, SCARG(uap, to), p); 2474 if (fromnd.ni_vp->v_type == VDIR) 2475 tond.ni_cnd.cn_flags |= WILLBEDIR; |
2476 if (error = namei(&tond)) { | 2476 if ((error = namei(&tond)) != 0) { |
2477 /* Translate error code for rename("dir1", "dir2/."). */ 2478 if (error == EISDIR && fvp->v_type == VDIR) 2479 error = EINVAL; 2480 VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); 2481 vrele(fromnd.ni_dvp); 2482 vrele(fvp); 2483 goto out1; 2484 } --- 78 unchanged lines hidden (view full) --- 2563{ 2564 register struct vnode *vp; 2565 struct vattr vattr; 2566 int error; 2567 struct nameidata nd; 2568 2569 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); 2570 nd.ni_cnd.cn_flags |= WILLBEDIR; | 2477 /* Translate error code for rename("dir1", "dir2/."). */ 2478 if (error == EISDIR && fvp->v_type == VDIR) 2479 error = EINVAL; 2480 VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); 2481 vrele(fromnd.ni_dvp); 2482 vrele(fvp); 2483 goto out1; 2484 } --- 78 unchanged lines hidden (view full) --- 2563{ 2564 register struct vnode *vp; 2565 struct vattr vattr; 2566 int error; 2567 struct nameidata nd; 2568 2569 NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); 2570 nd.ni_cnd.cn_flags |= WILLBEDIR; |
2571 if (error = namei(&nd)) | 2571 if ((error = namei(&nd)) != 0) |
2572 return (error); 2573 vp = nd.ni_vp; 2574 if (vp != NULL) { 2575 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 2576 if (nd.ni_dvp == vp) 2577 vrele(nd.ni_dvp); 2578 else 2579 vput(nd.ni_dvp); --- 30 unchanged lines hidden (view full) --- 2610 } */ *uap; 2611{ 2612 register struct vnode *vp; 2613 int error; 2614 struct nameidata nd; 2615 2616 NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, 2617 SCARG(uap, path), p); | 2572 return (error); 2573 vp = nd.ni_vp; 2574 if (vp != NULL) { 2575 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 2576 if (nd.ni_dvp == vp) 2577 vrele(nd.ni_dvp); 2578 else 2579 vput(nd.ni_dvp); --- 30 unchanged lines hidden (view full) --- 2610 } */ *uap; 2611{ 2612 register struct vnode *vp; 2613 int error; 2614 struct nameidata nd; 2615 2616 NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, 2617 SCARG(uap, path), p); |
2618 if (error = namei(&nd)) | 2618 if ((error = namei(&nd)) != 0) |
2619 return (error); 2620 vp = nd.ni_vp; 2621 if (vp->v_type != VDIR) { 2622 error = ENOTDIR; 2623 goto out; 2624 } 2625 /* 2626 * No rmdir "." please. --- 52 unchanged lines hidden (view full) --- 2679 struct file *fp; 2680 struct uio auio, kuio; 2681 struct iovec aiov, kiov; 2682 struct dirent *dp, *edp; 2683 caddr_t dirbuf; 2684 int error, eofflag, readcnt; 2685 long loff; 2686 | 2619 return (error); 2620 vp = nd.ni_vp; 2621 if (vp->v_type != VDIR) { 2622 error = ENOTDIR; 2623 goto out; 2624 } 2625 /* 2626 * No rmdir "." please. --- 52 unchanged lines hidden (view full) --- 2679 struct file *fp; 2680 struct uio auio, kuio; 2681 struct iovec aiov, kiov; 2682 struct dirent *dp, *edp; 2683 caddr_t dirbuf; 2684 int error, eofflag, readcnt; 2685 long loff; 2686 |
2687 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 2687 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
2688 return (error); 2689 if ((fp->f_flag & FREAD) == 0) 2690 return (EBADF); 2691 vp = (struct vnode *)fp->f_data; 2692unionread: 2693 if (vp->v_type != VDIR) 2694 return (EINVAL); 2695 aiov.iov_base = SCARG(uap, buf); --- 97 unchanged lines hidden (view full) --- 2793{ 2794 struct vnode *vp; 2795 struct file *fp; 2796 struct uio auio; 2797 struct iovec aiov; 2798 long loff; 2799 int error, eofflag; 2800 | 2688 return (error); 2689 if ((fp->f_flag & FREAD) == 0) 2690 return (EBADF); 2691 vp = (struct vnode *)fp->f_data; 2692unionread: 2693 if (vp->v_type != VDIR) 2694 return (EINVAL); 2695 aiov.iov_base = SCARG(uap, buf); --- 97 unchanged lines hidden (view full) --- 2793{ 2794 struct vnode *vp; 2795 struct file *fp; 2796 struct uio auio; 2797 struct iovec aiov; 2798 long loff; 2799 int error, eofflag; 2800 |
2801 if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) | 2801 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) |
2802 return (error); 2803 if ((fp->f_flag & FREAD) == 0) 2804 return (EBADF); 2805 vp = (struct vnode *)fp->f_data; 2806unionread: 2807 if (vp->v_type != VDIR) 2808 return (EINVAL); 2809 aiov.iov_base = SCARG(uap, buf); --- 91 unchanged lines hidden (view full) --- 2901 } */ *uap; 2902{ 2903 register struct vnode *vp; 2904 struct vattr vattr; 2905 int error; 2906 struct nameidata nd; 2907 2908 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); | 2802 return (error); 2803 if ((fp->f_flag & FREAD) == 0) 2804 return (EBADF); 2805 vp = (struct vnode *)fp->f_data; 2806unionread: 2807 if (vp->v_type != VDIR) 2808 return (EINVAL); 2809 aiov.iov_base = SCARG(uap, buf); --- 91 unchanged lines hidden (view full) --- 2901 } */ *uap; 2902{ 2903 register struct vnode *vp; 2904 struct vattr vattr; 2905 int error; 2906 struct nameidata nd; 2907 2908 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); |
2909 if (error = namei(&nd)) | 2909 if ((error = namei(&nd)) != 0) |
2910 return (error); 2911 vp = nd.ni_vp; 2912 if (vp->v_type != VCHR && vp->v_type != VBLK) { 2913 error = EINVAL; 2914 goto out; 2915 } | 2910 return (error); 2911 vp = nd.ni_vp; 2912 if (vp->v_type != VCHR && vp->v_type != VBLK) { 2913 error = EINVAL; 2914 goto out; 2915 } |
2916 if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) | 2916 if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) |
2917 goto out; 2918 if (p->p_ucred->cr_uid != vattr.va_uid && 2919 (error = suser(p->p_ucred, &p->p_acflag))) 2920 goto out; 2921 if (vp->v_usecount > 1 || (vp->v_flag & VALIASED)) 2922 VOP_REVOKE(vp, REVOKEALL); 2923out: 2924 vrele(vp); --- 114 unchanged lines hidden --- | 2917 goto out; 2918 if (p->p_ucred->cr_uid != vattr.va_uid && 2919 (error = suser(p->p_ucred, &p->p_acflag))) 2920 goto out; 2921 if (vp->v_usecount > 1 || (vp->v_flag & VALIASED)) 2922 VOP_REVOKE(vp, REVOKEALL); 2923out: 2924 vrele(vp); --- 114 unchanged lines hidden --- |