do_lock_mount(9)
okay bestie, we're talking about do_lock_mount(9) from the Kernel API Manual β it's the function that gets the whole environment locked and ready before something gets mounted. Very main character energy, honestly. π
π NAME π
do_lock_mount β acquire environment for mounting.
β¨ SYNOPSIS β¨
void do_lock_mount (const struct path *path , struct pinned_mountpoint
*res , bool beneath );
πΈ ARGUMENTS πΈ
pathβ the target path, aka where we're trying to mount something.resβ the context to set up; the caller hands this over and the function fills it in.beneathβ aboolsaying whether the intention is to mount beneathpath.
π DESCRIPTION π
To mount something at a given location, we need:
namespace_semlocked exclusive- the inode of the dentry we are mounting on locked exclusive
- the
struct mountpointfor that dentry - the
struct mountwe are mounting on
Results are stored in the caller-supplied context (pinned_mountpoint). On success, res->parent and res->mp point to the parent and the mountpoint respectively, and res->node is inserted into the ->m_list of the mountpoint β which makes sure the mountpoint won't disappear. π«Ά
On failure, res->parent is set to ERR_PTR(-E...), res->mp is left NULL, and res->node is empty. In case of success, do_lock_mount returns with locks acquired (in the proper order β inode lock nests outside of namespace_sem). No cap, the order matters.
A request to mount on an overmounted location is treated as "mount on top of whatever's overmounting it"; a request to mount beneath a location is "mount immediately beneath the topmost mount at that place".
In all cases the location must not have been unmounted, and the chosen mountpoint must be allowed to be mounted on. For the "beneath" case we also require the location to be at the root of a mount that has something mounted on top of it (i.e. has an overmount). That's not a vibe suggestion, bestie β those are the rules. π
π¦ SEE ALSO π¦
Kernel file ./fs/namespace.c, plus these absolute icons:
mnt_get_write_access(9)mnt_want_write(9)mnt_get_write_access_file(9)mnt_want_write_file(9)mnt_put_write_access(9)mnt_drop_write(9)mnt_hold_writers(9)mnt_unhold_writers(9)__lookup_mnt(9)lookup_mnt(9)attach_mnt(9)vfs_create_mount(9)path_is_mountpoint(9)may_umount_tree(9)may_umount(9)clone_private_mount(9)attach_recursive_mnt(9)path_overmounted(9)can_move_mount_beneath(9)mnt_set_expiry(9)mnt_allow_writers(9)
That's the whole page, bestie β source/version is ./fs, dated October 2026, and the function is do_lock_mount(9). Slay. πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms