fs: add kflags member to struct mount_kattr
authorChristian Brauner <brauner@kernel.org>
Tue, 28 Jan 2025 10:33:42 +0000 (11:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 12 Feb 2025 11:12:28 +0000 (12:12 +0100)
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>
fs/namespace.c

index ac4ad74..a6d3f20 100644 (file)
@@ -87,12 +87,16 @@ LIST_HEAD(notify_list); /* protected by namespace_sem */
 static struct rb_root mnt_ns_tree = RB_ROOT; /* protected by mnt_ns_tree_lock */
 static LIST_HEAD(mnt_ns_list); /* protected by mnt_ns_tree_lock */
 
+enum mount_kattr_flags_t {
+       MOUNT_KATTR_RECURSE             = (1 << 0),
+};
+
 struct mount_kattr {
        unsigned int attr_set;
        unsigned int attr_clr;
        unsigned int propagation;
        unsigned int lookup_flags;
-       bool recurse;
+       enum mount_kattr_flags_t kflags;
        struct user_namespace *mnt_userns;
        struct mnt_idmap *mnt_idmap;
 };
@@ -4672,7 +4676,7 @@ static int mount_setattr_prepare(struct mount_kattr *kattr, struct mount *mnt)
                                break;
                }
 
-               if (!kattr->recurse)
+               if (!(kattr->kflags & MOUNT_KATTR_RECURSE))
                        return 0;
        }
 
@@ -4733,7 +4737,7 @@ static void mount_setattr_commit(struct mount_kattr *kattr, struct mount *mnt)
 
                if (kattr->propagation)
                        change_mnt_propagation(m, kattr->propagation);
-               if (!kattr->recurse)
+               if (!(kattr->kflags & MOUNT_KATTR_RECURSE))
                        break;
        }
        touch_mnt_namespace(mnt->mnt_ns);
@@ -4763,7 +4767,7 @@ static int do_mount_setattr(struct path *path, struct mount_kattr *kattr)
                 */
                namespace_lock();
                if (kattr->propagation == MS_SHARED) {
-                       err = invent_group_ids(mnt, kattr->recurse);
+                       err = invent_group_ids(mnt, kattr->kflags & MOUNT_KATTR_RECURSE);
                        if (err) {
                                namespace_unlock();
                                return err;
@@ -4979,9 +4983,11 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,
 
        kattr = (struct mount_kattr) {
                .lookup_flags   = lookup_flags,
-               .recurse        = !!(flags & AT_RECURSIVE),
        };
 
+       if (flags & AT_RECURSIVE)
+               kattr.kflags |= MOUNT_KATTR_RECURSE;
+
        err = copy_mount_setattr(uattr, usize, &kattr);
        if (err)
                return err;
@@ -5011,9 +5017,10 @@ SYSCALL_DEFINE5(open_tree_attr, int, dfd, const char __user *, filename,
 
        if (uattr) {
                int ret;
-               struct mount_kattr kattr = {
-                       .recurse = !!(flags & AT_RECURSIVE),
-               };
+               struct mount_kattr kattr = {};
+
+               if (flags & AT_RECURSIVE)
+                       kattr.kflags |= MOUNT_KATTR_RECURSE;
 
                ret = copy_mount_setattr(uattr, usize, &kattr);
                if (ret)