MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vfs_domount

Function vfs_domount

freebsd/kern/vfs_mount.c:1285–1374  ·  view source on GitHub ↗

* vfs_domount(): actually attempt a filesystem mount. */

Source from the content-addressed store, hash-verified

1283 * vfs_domount(): actually attempt a filesystem mount.
1284 */
1285static int
1286vfs_domount(
1287 struct thread *td, /* Calling thread. */
1288 const char *fstype, /* Filesystem type. */
1289 char *fspath, /* Mount path. */
1290 uint64_t fsflags, /* Flags common to all filesystems. */
1291 struct vfsoptlist **optlist /* Options local to the filesystem. */
1292 )
1293{
1294 struct vfsconf *vfsp;
1295 struct nameidata nd;
1296 struct vnode *vp;
1297 char *pathbuf;
1298 int error;
1299
1300 /*
1301 * Be ultra-paranoid about making sure the type and fspath
1302 * variables will fit in our mp buffers, including the
1303 * terminating NUL.
1304 */
1305 if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MNAMELEN)
1306 return (ENAMETOOLONG);
1307
1308 if (jailed(td->td_ucred) || usermount == 0) {
1309 if ((error = priv_check(td, PRIV_VFS_MOUNT)) != 0)
1310 return (error);
1311 }
1312
1313 /*
1314 * Do not allow NFS export or MNT_SUIDDIR by unprivileged users.
1315 */
1316 if (fsflags & MNT_EXPORTED) {
1317 error = priv_check(td, PRIV_VFS_MOUNT_EXPORTED);
1318 if (error)
1319 return (error);
1320 }
1321 if (fsflags & MNT_SUIDDIR) {
1322 error = priv_check(td, PRIV_VFS_MOUNT_SUIDDIR);
1323 if (error)
1324 return (error);
1325 }
1326 /*
1327 * Silently enforce MNT_NOSUID and MNT_USER for unprivileged users.
1328 */
1329 if ((fsflags & (MNT_NOSUID | MNT_USER)) != (MNT_NOSUID | MNT_USER)) {
1330 if (priv_check(td, PRIV_VFS_MOUNT_NONUSER) != 0)
1331 fsflags |= MNT_NOSUID | MNT_USER;
1332 }
1333
1334 /* Load KLDs before we lock the covered vnode to avoid reversals. */
1335 vfsp = NULL;
1336 if ((fsflags & MNT_UPDATE) == 0) {
1337 /* Don't try to load KLDs if we're mounting the root. */
1338 if (fsflags & MNT_ROOTFS)
1339 vfsp = vfs_byname(fstype);
1340 else
1341 vfsp = vfs_byname_kld(fstype, td, &error);
1342 if (vfsp == NULL)

Callers 1

vfs_donmountFunction · 0.85

Calls 12

jailedFunction · 0.85
vfs_bynameFunction · 0.85
vfs_byname_kldFunction · 0.85
nameiFunction · 0.85
NDFREEFunction · 0.85
vputFunction · 0.85
mallocFunction · 0.85
vn_path_to_global_pathFunction · 0.85
vfs_domount_firstFunction · 0.85
vfs_domount_updateFunction · 0.85
priv_checkFunction · 0.70
freeFunction · 0.70

Tested by

no test coverage detected