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

Function vfs_mount_alloc

freebsd/kern/vfs_mount.c:489–533  ·  view source on GitHub ↗

* Allocate and initialize the mount point struct. */

Source from the content-addressed store, hash-verified

487 * Allocate and initialize the mount point struct.
488 */
489struct mount *
490vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp, const char *fspath,
491 struct ucred *cred)
492{
493 struct mount *mp;
494
495 mp = uma_zalloc(mount_zone, M_WAITOK);
496 bzero(&mp->mnt_startzero,
497 __rangeof(struct mount, mnt_startzero, mnt_endzero));
498 mp->mnt_kern_flag = 0;
499 mp->mnt_flag = 0;
500 mp->mnt_rootvnode = NULL;
501 mp->mnt_vnodecovered = NULL;
502 mp->mnt_op = NULL;
503 mp->mnt_vfc = NULL;
504 TAILQ_INIT(&mp->mnt_nvnodelist);
505 mp->mnt_nvnodelistsize = 0;
506 TAILQ_INIT(&mp->mnt_lazyvnodelist);
507 mp->mnt_lazyvnodelistsize = 0;
508 if (mp->mnt_ref != 0 || mp->mnt_lockref != 0 ||
509 mp->mnt_writeopcount != 0)
510 panic("%s: non-zero counters on new mp %p\n", __func__, mp);
511 if (mp->mnt_vfs_ops != 1)
512 panic("%s: vfs_ops should be 1 but %d found\n", __func__,
513 mp->mnt_vfs_ops);
514 (void) vfs_busy(mp, MBF_NOWAIT);
515 atomic_add_acq_int(&vfsp->vfc_refcount, 1);
516 mp->mnt_op = vfsp->vfc_vfsops;
517 mp->mnt_vfc = vfsp;
518 mp->mnt_stat.f_type = vfsp->vfc_typenum;
519 mp->mnt_gen++;
520 strlcpy(mp->mnt_stat.f_fstypename, vfsp->vfc_name, MFSNAMELEN);
521 mp->mnt_vnodecovered = vp;
522 mp->mnt_cred = crdup(cred);
523 mp->mnt_stat.f_owner = cred->cr_uid;
524 strlcpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN);
525 mp->mnt_iosize_max = DFLTPHYS;
526#ifdef MAC
527 mac_mount_init(mp);
528 mac_mount_create(cred, mp);
529#endif
530 arc4rand(&mp->mnt_hashseed, sizeof mp->mnt_hashseed, 0);
531 TAILQ_INIT(&mp->mnt_uppers);
532 return (mp);
533}
534
535/*
536 * Destroy the mount struct previously allocated by vfs_mount_alloc().

Callers 3

mount_snapshotFunction · 0.85
vfs_mountroot_devfsFunction · 0.85
vfs_domount_firstFunction · 0.85

Calls 9

bzeroFunction · 0.85
vfs_busyFunction · 0.85
crdupFunction · 0.85
mac_mount_initFunction · 0.85
mac_mount_createFunction · 0.85
panicFunction · 0.70
uma_zallocFunction · 0.50
strlcpyFunction · 0.50
arc4randFunction · 0.50

Tested by

no test coverage detected