attach_recursive_mnt(9)
π attach_recursive_mnt(9) β Kernel API Manual, bestie edition β¨
okay so this is attach_recursive_mnt(9) from the Kernel API Manual, and it's genuinely one of those "attach a source mount tree" functions that looks scary but is so slay once you get it π
π NAME
attach_recursive_mnt β attach a source mount tree πΈ
β¨ SYNOPSIS
int attach_recursive_mnt (struct mount *source_mnt , const struct
pinned_mountpoint *dest );
π«Ά ARGUMENTS
source_mntβ the mount tree you wanna attach, bestie πdestβ the context for mounting at the place where the tree should go β¨
π NOTE
so this next part is literally the vibe check table π β it explains the semantics when a source mount of a given type is attached to a destination mount of a given type. read it carefully, no skipping π
---------------------------------------------------------------------------
| BIND MOUNT OPERATION
|
|**************************************************************************
| source-->| shared | private | slave |
unbindable | | dest | | |
| | | | | | |
| | | v | | |
| |
|**************************************************************************
| shared | shared (++) | shared (+) | shared(+++)| invalid
| | | | | |
| |non-shared| shared (+) | private | slave (*) |
invalid |
***************************************************************************
A bind operation clones the source mount and mounts the clone on the destination mount. that's the whole bit π«
Here's the legend, bestie π:
- (++) β the cloned mount is propagated to all the mounts in the propagation tree of the destination mount, and the cloned mount is added to the peer group of the source mount π₯
- (+) β the cloned mount is created under the destination mount and is marked as shared. the cloned mount is added to the peer group of the source mount β¨
- (+++) β the mount is propagated to all the mounts in the propagation tree of the destination mount, and the cloned mount is made slave of the same master as that of the source mount. the cloned mount is marked as 'shared and slave' π
- (*) β the cloned mount is made a slave of the same master as that of the source mount π
and now the move side of things π¦:
---------------------------------------------------------------------------
| MOVE MOUNT OPERATION
|
|**************************************************************************
| source-->| shared | private | slave |
unbindable | | dest | | |
| | | | | | |
| | | v | | |
| |
|**************************************************************************
| shared | shared (+) | shared (+) | shared(+++) | invalid
| | | | | |
| |non-shared| shared (+*) | private | slave (*) |
unbindable |
***************************************************************************
Legend for the move table, periodt π :
- (+) β the mount is moved to the destination. and is then propagated to all the mounts in the propagation tree of the destination mount π
- (+*) β the mount is moved to the destination. that's it, that's the whole thing π
- (+++) β the mount is moved to the destination and is then propagated to all the mounts belonging to the destination mount's propagation tree. the mount is marked as 'shared and slave' π
- (*) β the mount continues to be a slave at the new location π§
if the source mount is a tree, the operations explained above is applied to each mount in the tree π β like, every single one, no cap.
fr fr warning π: must be called without spinlocks held, since this function can sleep in allocations. do nottt hold those spinlocks, bestie, it will not end well π
π CONTEXT
The function expects namespace_lock to be held. that's non-negotiable, it's giving very "you must have the lock" energy π
β RETURN
If source_mnt was successfully attached, 0 is returned π. Otherwise a negative error code is returned π.
π SEE ALSO
Kernel file ./fs/namespace.c β and 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)do_lock_mount(9)path_overmounted(9)can_move_mount_beneath(9)mnt_set_expiry(9)mnt_allow_writers(9)
kay that's the whole page, you ate that π«Ά go attach some mount trees responsibly, mwah π
source: ./fs β version vibes from October 2026, attach_recursive_mnt(9) β¨ periodt π
π¦ 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