summaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2023-11-19 19:03:33 +0100
committerChristian Brauner <brauner@kernel.org>2023-12-11 19:11:07 +0100
commit6971beb4ec52ad7b26f5b5eedf19d4963be7df1b (patch)
tree76d19fa7f1270323f3868de14184f89487fedf1b /fs/namespace.c
parentadd statmount(2) syscall (diff)
downloadlinux-6971beb4ec52ad7b26f5b5eedf19d4963be7df1b.tar.xz
linux-6971beb4ec52ad7b26f5b5eedf19d4963be7df1b.zip
statmount: simplify numeric option retrieval
Don't use all of this indirection which makes it really hard to follow the code which is very basic. Error handling is also not really neede here at all. Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index ae35d8b6aca8..16c2f84c6570 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -4766,15 +4766,6 @@ static void statmount_string(struct kstatmount *s, u64 mask, statmount_func_t fu
sm->mask |= mask;
}
-static void statmount_numeric(struct kstatmount *s, u64 mask, statmount_func_t func)
-{
- if (s->err || !(s->mask & mask))
- return;
-
- s->err = func(s);
- s->sm.mask |= mask;
-}
-
static u64 mnt_to_attr_flags(struct vfsmount *mnt)
{
unsigned int mnt_flags = READ_ONCE(mnt->mnt_flags);
@@ -4822,22 +4813,22 @@ static u64 mnt_to_propagation_flags(struct mount *m)
return propagation;
}
-static int statmount_sb_basic(struct kstatmount *s)
+static void statmount_sb_basic(struct kstatmount *s)
{
struct super_block *sb = s->mnt->mnt_sb;
+ s->sm.mask |= STATMOUNT_SB_BASIC;
s->sm.sb_dev_major = MAJOR(sb->s_dev);
s->sm.sb_dev_minor = MINOR(sb->s_dev);
s->sm.sb_magic = sb->s_magic;
s->sm.sb_flags = sb->s_flags & (SB_RDONLY|SB_SYNCHRONOUS|SB_DIRSYNC|SB_LAZYTIME);
-
- return 0;
}
-static int statmount_mnt_basic(struct kstatmount *s)
+static void statmount_mnt_basic(struct kstatmount *s)
{
struct mount *m = real_mount(s->mnt);
+ s->sm.mask |= STATMOUNT_MNT_BASIC;
s->sm.mnt_id = m->mnt_id_unique;
s->sm.mnt_parent_id = m->mnt_parent->mnt_id_unique;
s->sm.mnt_id_old = m->mnt_id;
@@ -4846,20 +4837,15 @@ static int statmount_mnt_basic(struct kstatmount *s)
s->sm.mnt_propagation = mnt_to_propagation_flags(m);
s->sm.mnt_peer_group = IS_MNT_SHARED(m) ? m->mnt_group_id : 0;
s->sm.mnt_master = IS_MNT_SLAVE(m) ? m->mnt_master->mnt_group_id : 0;
-
- return 0;
}
-static int statmount_propagate_from(struct kstatmount *s)
+static void statmount_propagate_from(struct kstatmount *s)
{
struct mount *m = real_mount(s->mnt);
- if (!IS_MNT_SLAVE(m))
- return 0;
-
- s->sm.propagate_from = get_dominating_id(m, &current->fs->root);
-
- return 0;
+ s->sm.mask |= STATMOUNT_PROPAGATE_FROM;
+ if (IS_MNT_SLAVE(m))
+ s->sm.propagate_from = get_dominating_id(m, &current->fs->root);
}
static int statmount_mnt_root(struct kstatmount *s)
@@ -4911,9 +4897,15 @@ static int do_statmount(struct kstatmount *s)
if (err)
return err;
- statmount_numeric(s, STATMOUNT_SB_BASIC, statmount_sb_basic);
- statmount_numeric(s, STATMOUNT_MNT_BASIC, statmount_mnt_basic);
- statmount_numeric(s, STATMOUNT_PROPAGATE_FROM, statmount_propagate_from);
+ if (s->mask & STATMOUNT_SB_BASIC)
+ statmount_sb_basic(s);
+
+ if (s->mask & STATMOUNT_MNT_BASIC)
+ statmount_mnt_basic(s);
+
+ if (s->mask & STATMOUNT_PROPAGATE_FROM)
+ statmount_propagate_from(s);
+
statmount_string(s, STATMOUNT_FS_TYPE, statmount_fs_type, &sm->fs_type);
statmount_string(s, STATMOUNT_MNT_ROOT, statmount_mnt_root, &sm->mnt_root);
statmount_string(s, STATMOUNT_MNT_POINT, statmount_mnt_point, &sm->mnt_point);