diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2025-06-08 23:25:36 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2025-06-29 18:13:41 -0400 |
| commit | 05da054d43770e229dfb0e185c15452eed14364c (patch) | |
| tree | e99c8dd4d3e780ffe309be758bb5c53356f05c00 /fs/mount.h | |
| parent | e031251cb249f824ad67cb0b2fc18b68d5792b8d (diff) | |
new predicate: anon_ns_root(mount)
checks if mount is the root of an anonymouns namespace.
Switch open-coded equivalents to using it.
For mounts that belong to anon namespace !mnt_has_parent(mount)
is the same as mount == ns->root, and intent is more obvious in
the latter form.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/mount.h')
| -rw-r--r-- | fs/mount.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/mount.h b/fs/mount.h index f10776003643..f20e6ed845fe 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -161,6 +161,13 @@ static inline bool is_anon_ns(struct mnt_namespace *ns) return ns->seq == 0; } +static inline bool anon_ns_root(const struct mount *m) +{ + struct mnt_namespace *ns = READ_ONCE(m->mnt_ns); + + return !IS_ERR_OR_NULL(ns) && is_anon_ns(ns) && m == ns->root; +} + static inline bool mnt_ns_attached(const struct mount *mnt) { return !RB_EMPTY_NODE(&mnt->mnt_node); |