can_move_mount_beneath(9)
π can_move_mount_beneath(9) β like, the Kernel API Manual page, bestie
okay so this is a page straight out of the Kernel API Manual and it's literally about checking whether we can mount beneath the top mount. yes, beneath. under. the vibes are immaculate and the locking is intense π«Ά
β¨ SYNOPSIS β¨
int can_move_mount_beneath (const struct mount *mnt_from , const struct
mount *mnt_to , struct pinned_mountpoint *mp );
π ARGUMENTS π
mnt_fromβ the mount we're trying to move. main character of the operation π«mnt_toβ the mount we want to mount under. yes bestie, under.mpβ the mountpoint ofmnt_to. it's giving "where exactly are we doing this".
πΈ DESCRIPTION πΈ
so like, this function runs a whole vibe check on the situation before anything gets moved. three checks, no cap:
- Make sure that
mnt_fromcan take over the lock ofmnt_to. and heads up β a mount of a mount namespace file is left out of a copy of the tree, so it literally can't. sorry to that mount π - Ensure that nothing has been mounted on top of
mnt_frombefore we grabbednamespace_semβ because otherwise we'd be creating pointless shadow mounts and honestly? nobody has time for that. - Prevent mounting beneath a mount if the propagation relationship between the source mount, parent mount, and top mount would lead to nonsensical mount trees. like, we are NOT letting the tree become a mess. periodt π₯
π CONTEXT π
this function expects namespace_lock to be held. so hold it. fr fr.
β RETURN β
- on success:
0β¨ - on error: a negative error code π
π¦ SEE ALSO π¦
kernel file ./fs/namespace.c, plus the whole friend group:
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)do_lock_mount(9)path_overmounted(9)mnt_set_expiry(9)mnt_allow_writers(9)
bestie reminder: namespace_lock held or this whole thing is a no π
and that's the page!! sign-off szn: this one lives in ./fs, dated October 2026, and it's page can_move_mount_beneath(9) of the Kernel API Manual. go mount responsibly, ily πππ
π¦ 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