Skip to content

Commit 325cca8

Browse files
committed
fs: add kflags member to struct mount_kattr
Instead of using a boolean use a flag so we can add new flags in following patches. Link: https://lore.kernel.org/r/20250128-work-mnt_idmap-update-v2-v1-4-c25feb0d2eb3@kernel.org Reviewed-by: "Seth Forshee (DigitalOcean)" <sforshee@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent c4a1682 commit 325cca8

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

fs/namespace.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,16 @@ LIST_HEAD(notify_list); /* protected by namespace_sem */
8787
static struct rb_root mnt_ns_tree = RB_ROOT; /* protected by mnt_ns_tree_lock */
8888
static LIST_HEAD(mnt_ns_list); /* protected by mnt_ns_tree_lock */
8989

90+
enum mount_kattr_flags_t {
91+
MOUNT_KATTR_RECURSE = (1 << 0),
92+
};
93+
9094
struct mount_kattr {
9195
unsigned int attr_set;
9296
unsigned int attr_clr;
9397
unsigned int propagation;
9498
unsigned int lookup_flags;
95-
bool recurse;
99+
enum mount_kattr_flags_t kflags;
96100
struct user_namespace *mnt_userns;
97101
struct mnt_idmap *mnt_idmap;
98102
};
@@ -4672,7 +4676,7 @@ static int mount_setattr_prepare(struct mount_kattr *kattr, struct mount *mnt)
46724676
break;
46734677
}
46744678

4675-
if (!kattr->recurse)
4679+
if (!(kattr->kflags & MOUNT_KATTR_RECURSE))
46764680
return 0;
46774681
}
46784682

@@ -4733,7 +4737,7 @@ static void mount_setattr_commit(struct mount_kattr *kattr, struct mount *mnt)
47334737

47344738
if (kattr->propagation)
47354739
change_mnt_propagation(m, kattr->propagation);
4736-
if (!kattr->recurse)
4740+
if (!(kattr->kflags & MOUNT_KATTR_RECURSE))
47374741
break;
47384742
}
47394743
touch_mnt_namespace(mnt->mnt_ns);
@@ -4763,7 +4767,7 @@ static int do_mount_setattr(struct path *path, struct mount_kattr *kattr)
47634767
*/
47644768
namespace_lock();
47654769
if (kattr->propagation == MS_SHARED) {
4766-
err = invent_group_ids(mnt, kattr->recurse);
4770+
err = invent_group_ids(mnt, kattr->kflags & MOUNT_KATTR_RECURSE);
47674771
if (err) {
47684772
namespace_unlock();
47694773
return err;
@@ -4979,9 +4983,11 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,
49794983

49804984
kattr = (struct mount_kattr) {
49814985
.lookup_flags = lookup_flags,
4982-
.recurse = !!(flags & AT_RECURSIVE),
49834986
};
49844987

4988+
if (flags & AT_RECURSIVE)
4989+
kattr.kflags |= MOUNT_KATTR_RECURSE;
4990+
49854991
err = copy_mount_setattr(uattr, usize, &kattr);
49864992
if (err)
49874993
return err;
@@ -5011,9 +5017,10 @@ SYSCALL_DEFINE5(open_tree_attr, int, dfd, const char __user *, filename,
50115017

50125018
if (uattr) {
50135019
int ret;
5014-
struct mount_kattr kattr = {
5015-
.recurse = !!(flags & AT_RECURSIVE),
5016-
};
5020+
struct mount_kattr kattr = {};
5021+
5022+
if (flags & AT_RECURSIVE)
5023+
kattr.kflags |= MOUNT_KATTR_RECURSE;
50175024

50185025
ret = copy_mount_setattr(uattr, usize, &kattr);
50195026
if (ret)

0 commit comments

Comments
 (0)