Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_syscalls.c
Show First 20 Lines • Show All 1,579 Lines • ▼ Show 20 Lines | |||||
can_hardlink(struct vnode *vp, struct ucred *cred) | can_hardlink(struct vnode *vp, struct ucred *cred) | ||||
{ | { | ||||
struct vattr va; | struct vattr va; | ||||
int error; | int error; | ||||
if (!hardlink_check_uid && !hardlink_check_gid) | if (!hardlink_check_uid && !hardlink_check_gid) | ||||
return (0); | return (0); | ||||
error = VOP_GETATTR(vp, &va, cred); | error = VOP_GETATTR(vp, 0, &va, cred); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
if (hardlink_check_uid && cred->cr_uid != va.va_uid) { | if (hardlink_check_uid && cred->cr_uid != va.va_uid) { | ||||
error = priv_check_cred(cred, PRIV_VFS_LINK); | error = priv_check_cred(cred, PRIV_VFS_LINK); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | if ((error = namei(&nd)) != 0) { | ||||
if (error == EINVAL) | if (error == EINVAL) | ||||
error = EPERM; | error = EPERM; | ||||
goto fdout; | goto fdout; | ||||
} | } | ||||
vp = nd.ni_vp; | vp = nd.ni_vp; | ||||
if (vp->v_type == VDIR && oldinum == 0) { | if (vp->v_type == VDIR && oldinum == 0) { | ||||
error = EPERM; /* POSIX */ | error = EPERM; /* POSIX */ | ||||
} else if (oldinum != 0 && | } else if (oldinum != 0 && | ||||
((error = VOP_STAT(vp, &sb, td->td_ucred, NOCRED)) == 0) && | ((error = VOP_STAT(vp, &sb, 0, td->td_ucred, NOCRED)) == 0) && | ||||
sb.st_ino != oldinum) { | sb.st_ino != oldinum) { | ||||
error = EIDRM; /* Identifier removed */ | error = EIDRM; /* Identifier removed */ | ||||
} else if (fp != NULL && fp->f_vnode != vp) { | } else if (fp != NULL && fp->f_vnode != vp) { | ||||
if (VN_IS_DOOMED(fp->f_vnode)) | if (VN_IS_DOOMED(fp->f_vnode)) | ||||
error = EBADF; | error = EBADF; | ||||
else | else | ||||
error = EDEADLK; | error = EDEADLK; | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | NDINIT_ATRIGHTS(&nd, LOOKUP, at2cnpflags(flag, AT_RESOLVE_BENEATH | | ||||
AUDITVNODE1, pathseg, path, fd, &cap_fstat_rights); | AUDITVNODE1, pathseg, path, fd, &cap_fstat_rights); | ||||
if ((error = namei(&nd)) != 0) { | if ((error = namei(&nd)) != 0) { | ||||
if (error == ENOTDIR && | if (error == ENOTDIR && | ||||
(nd.ni_resflags & NIRES_EMPTYPATH) != 0) | (nd.ni_resflags & NIRES_EMPTYPATH) != 0) | ||||
error = kern_fstat(td, fd, sbp); | error = kern_fstat(td, fd, sbp); | ||||
return (error); | return (error); | ||||
} | } | ||||
error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED); | error = VOP_STAT(nd.ni_vp, sbp, 0, td->td_ucred, NOCRED); | ||||
NDFREE_PNBUF(&nd); | NDFREE_PNBUF(&nd); | ||||
vput(nd.ni_vp); | vput(nd.ni_vp); | ||||
#ifdef __STAT_TIME_T_EXT | #ifdef __STAT_TIME_T_EXT | ||||
sbp->st_atim_ext = 0; | sbp->st_atim_ext = 0; | ||||
sbp->st_mtim_ext = 0; | sbp->st_mtim_ext = 0; | ||||
sbp->st_ctim_ext = 0; | sbp->st_ctim_ext = 0; | ||||
sbp->st_btim_ext = 0; | sbp->st_btim_ext = 0; | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 732 Lines • ▼ Show 20 Lines | setutimes(struct thread *td, struct vnode *vp, const struct timespec *ts, | ||||
setbirthtime = false; | setbirthtime = false; | ||||
vattr.va_birthtime.tv_sec = VNOVAL; | vattr.va_birthtime.tv_sec = VNOVAL; | ||||
vattr.va_birthtime.tv_nsec = 0; | vattr.va_birthtime.tv_nsec = 0; | ||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0) | if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0) | ||||
return (error); | return (error); | ||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); | vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); | ||||
if (numtimes < 3 && VOP_GETATTR(vp, &vattr, td->td_ucred) == 0 && | if (numtimes < 3 && VOP_GETATTR(vp, 0, &vattr, td->td_ucred) == 0 && | ||||
timespeccmp(&ts[1], &vattr.va_birthtime, < )) | timespeccmp(&ts[1], &vattr.va_birthtime, < )) | ||||
setbirthtime = true; | setbirthtime = true; | ||||
VATTR_NULL(&vattr); | VATTR_NULL(&vattr); | ||||
vattr.va_atime = ts[0]; | vattr.va_atime = ts[0]; | ||||
vattr.va_mtime = ts[1]; | vattr.va_mtime = ts[1]; | ||||
if (setbirthtime) | if (setbirthtime) | ||||
vattr.va_birthtime = ts[1]; | vattr.va_birthtime = ts[1]; | ||||
if (numtimes > 2) | if (numtimes > 2) | ||||
▲ Show 20 Lines • Show All 1,063 Lines • ▼ Show 20 Lines | if (vp->v_type != VCHR || vp->v_rdev == NULL) { | ||||
error = EINVAL; | error = EINVAL; | ||||
goto out; | goto out; | ||||
} | } | ||||
#ifdef MAC | #ifdef MAC | ||||
error = mac_vnode_check_revoke(td->td_ucred, vp); | error = mac_vnode_check_revoke(td->td_ucred, vp); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
#endif | #endif | ||||
error = VOP_GETATTR(vp, &vattr, td->td_ucred); | error = VOP_GETATTR(vp, 0, &vattr, td->td_ucred); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
if (td->td_ucred->cr_uid != vattr.va_uid) { | if (td->td_ucred->cr_uid != vattr.va_uid) { | ||||
error = priv_check(td, PRIV_VFS_ADMIN); | error = priv_check(td, PRIV_VFS_ADMIN); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
} | } | ||||
if (devfs_usecount(vp) > 0) | if (devfs_usecount(vp) > 0) | ||||
▲ Show 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | kern_fhstat(struct thread *td, struct fhandle fh, struct stat *sb) | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL) | if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL) | ||||
return (ESTALE); | return (ESTALE); | ||||
error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp); | error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp); | ||||
vfs_unbusy(mp); | vfs_unbusy(mp); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
error = VOP_STAT(vp, sb, td->td_ucred, NOCRED); | error = VOP_STAT(vp, sb, 0, td->td_ucred, NOCRED); | ||||
vput(vp); | vput(vp); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* Implement fstatfs() for (NFS) file handles. | * Implement fstatfs() for (NFS) file handles. | ||||
*/ | */ | ||||
#ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
▲ Show 20 Lines • Show All 342 Lines • Show Last 20 Lines |