Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/vfs_mount.c
Show First 20 Lines • Show All 837 Lines • ▼ Show 20 Lines | vfs_domount_first( | ||||
struct mount *mp; | struct mount *mp; | ||||
struct vnode *newdp; | struct vnode *newdp; | ||||
int error; | int error; | ||||
ASSERT_VOP_ELOCKED(vp, __func__); | ASSERT_VOP_ELOCKED(vp, __func__); | ||||
KASSERT((fsflags & MNT_UPDATE) == 0, ("MNT_UPDATE shouldn't be here")); | KASSERT((fsflags & MNT_UPDATE) == 0, ("MNT_UPDATE shouldn't be here")); | ||||
/* | /* | ||||
* If the jail of the calling thread lacks permission for this type of | |||||
* file system, deny immediately. | |||||
*/ | |||||
if (jailed(td->td_ucred) && !prison_allow(td->td_ucred, | |||||
vfsp->vfc_prison_flag)) { | |||||
vput(vp); | |||||
return (EPERM); | |||||
} | |||||
/* | |||||
* If the user is not root, ensure that they own the directory | * If the user is not root, ensure that they own the directory | ||||
* onto which we are attempting to mount. | * onto which we are attempting to mount. | ||||
*/ | */ | ||||
error = VOP_GETATTR(vp, &va, td->td_ucred); | error = VOP_GETATTR(vp, &va, td->td_ucred); | ||||
if (error == 0 && va.va_uid != td->td_ucred->cr_uid) | if (error == 0 && va.va_uid != td->td_ucred->cr_uid) | ||||
error = priv_check_cred(td->td_ucred, PRIV_VFS_ADMIN, 0); | error = priv_check_cred(td->td_ucred, PRIV_VFS_ADMIN, 0); | ||||
if (error == 0) | if (error == 0) | ||||
error = vinvalbuf(vp, V_SAVE, 0, 0); | error = vinvalbuf(vp, V_SAVE, 0, 0); | ||||
▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | vfs_domount( | ||||
if ((fsflags & MNT_UPDATE) == 0) { | if ((fsflags & MNT_UPDATE) == 0) { | ||||
/* Don't try to load KLDs if we're mounting the root. */ | /* Don't try to load KLDs if we're mounting the root. */ | ||||
if (fsflags & MNT_ROOTFS) | if (fsflags & MNT_ROOTFS) | ||||
vfsp = vfs_byname(fstype); | vfsp = vfs_byname(fstype); | ||||
else | else | ||||
vfsp = vfs_byname_kld(fstype, td, &error); | vfsp = vfs_byname_kld(fstype, td, &error); | ||||
if (vfsp == NULL) | if (vfsp == NULL) | ||||
return (ENODEV); | return (ENODEV); | ||||
if (jailed(td->td_ucred) && !(vfsp->vfc_flags & VFCF_JAIL)) | |||||
return (EPERM); | |||||
} | } | ||||
/* | /* | ||||
* Get vnode to be covered or mount point's vnode in case of MNT_UPDATE. | * Get vnode to be covered or mount point's vnode in case of MNT_UPDATE. | ||||
*/ | */ | ||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, | NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, | ||||
UIO_SYSSPACE, fspath, td); | UIO_SYSSPACE, fspath, td); | ||||
error = namei(&nd); | error = namei(&nd); | ||||
▲ Show 20 Lines • Show All 882 Lines • Show Last 20 Lines |