diff options
author | Josef Bacik <josef@toxicpanda.com> | 2024-06-24 17:49:47 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-06-28 09:53:30 +0200 |
commit | 09b31295f833031c88419550172703d45c5401e3 (patch) | |
tree | 50bd10c7505d59a109f1bafa41f6d8ec1d1eaa5a /fs/namespace.c | |
parent | fs: keep an index of current mount namespaces (diff) | |
download | linux-09b31295f833031c88419550172703d45c5401e3.tar.xz linux-09b31295f833031c88419550172703d45c5401e3.zip |
fs: export the mount ns id via statmount
In order to allow users to iterate through children mount namespaces via
listmount we need a way for them to know what the ns id for the mount.
Add a new field to statmount called mnt_ns_id which will carry the ns id
for the given mount entry.
Co-developed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/6dabf437331fb7415d886f7c64b21cb2a50b1c66.1719243756.git.josef@toxicpanda.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index eebe9d912a71..ed2d9353e4be 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4974,6 +4974,14 @@ static int statmount_fs_type(struct kstatmount *s, struct seq_file *seq) return 0; } +static void statmount_mnt_ns_id(struct kstatmount *s) +{ + struct mnt_namespace *ns = current->nsproxy->mnt_ns; + + s->sm.mask |= STATMOUNT_MNT_NS_ID; + s->sm.mnt_ns_id = ns->seq; +} + static int statmount_string(struct kstatmount *s, u64 flag) { int ret; @@ -5070,6 +5078,9 @@ static int do_statmount(struct kstatmount *s) if (!err && s->mask & STATMOUNT_MNT_POINT) err = statmount_string(s, STATMOUNT_MNT_POINT); + if (!err && s->mask & STATMOUNT_MNT_NS_ID) + statmount_mnt_ns_id(s); + if (err) return err; |