]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
change the calling conventions for vfs_parse_fs_string()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 28 Jun 2025 15:37:30 +0000 (11:37 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 4 Sep 2025 19:20:51 +0000 (15:20 -0400)
Absolute majority of callers are passing the 4th argument equal to
strlen() of the 3rd one.

Drop the v_size argument, add vfs_parse_fs_qstr() for the cases that
want independent length.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 files changed:
Documentation/filesystems/mount_api.rst
Documentation/filesystems/porting.rst
drivers/gpu/drm/i915/gem/i915_gemfs.c
drivers/gpu/drm/v3d/v3d_gemfs.c
fs/afs/mntpt.c
fs/fs_context.c
fs/namespace.c
fs/nfs/fs_context.c
fs/nfs/namespace.c
fs/smb/client/fs_context.c
include/linux/fs_context.h
kernel/trace/trace.c

index e149b89118c885c377a17b95adcdbcb594b34e00..c99ab1f7fea45346a92ee010cf5ef86be062036a 100644 (file)
@@ -504,10 +504,18 @@ returned.
      clear the pointer, but then becomes responsible for disposing of the
      object.
 
+   * ::
+
+       int vfs_parse_fs_qstr(struct fs_context *fc, const char *key,
+                              const struct qstr *value);
+
+     A wrapper around vfs_parse_fs_param() that copies the value string it is
+     passed.
+
    * ::
 
        int vfs_parse_fs_string(struct fs_context *fc, const char *key,
-                              const char *value, size_t v_size);
+                              const char *value);
 
      A wrapper around vfs_parse_fs_param() that copies the value string it is
      passed.
index 85f590254f07504e9fc7152a3a1abec8d55ef96b..ab48ab3f6eb21c8a71daf67d5006ab53823e3dbf 100644 (file)
@@ -1285,3 +1285,15 @@ rather than a VMA, as the VMA at this stage is not yet valid.
 The vm_area_desc provides the minimum required information for a filesystem
 to initialise state upon memory mapping of a file-backed region, and output
 parameters for the file system to set this state.
+
+---
+
+**mandatory**
+
+Calling conventions for vfs_parse_fs_string() have changed; it does *not*
+take length anymore (value ? strlen(value) : 0 is used).  If you want
+a different length, use
+
+       vfs_parse_fs_qstr(fc, key, &QSTR_LEN(value, len))
+
+instead.
index a09e2eb47175617f8609efc2d53773d217e85cf1..8f13ec4ff0d06c1fbba973fb0cbe3417db6ee7ed 100644 (file)
 #include "i915_gemfs.h"
 #include "i915_utils.h"
 
-static int add_param(struct fs_context *fc, const char *key, const char *val)
-{
-       return vfs_parse_fs_string(fc, key, val, strlen(val));
-}
-
 void i915_gemfs_init(struct drm_i915_private *i915)
 {
        struct file_system_type *type;
@@ -48,9 +43,9 @@ void i915_gemfs_init(struct drm_i915_private *i915)
        fc = fs_context_for_mount(type, SB_KERNMOUNT);
        if (IS_ERR(fc))
                goto err;
-       ret = add_param(fc, "source", "tmpfs");
+       ret = vfs_parse_fs_string(fc, "source", "tmpfs");
        if (!ret)
-               ret = add_param(fc, "huge", "within_size");
+               ret = vfs_parse_fs_string(fc, "huge", "within_size");
        if (!ret)
                gemfs = fc_mount_longterm(fc);
        put_fs_context(fc);
index 8ec6ed82b3d94105b6ebe720f548c8cd4fcd083a..c1a30166c09934b169f0d8d5074a2971c0ad36b2 100644 (file)
@@ -7,11 +7,6 @@
 
 #include "v3d_drv.h"
 
-static int add_param(struct fs_context *fc, const char *key, const char *val)
-{
-       return vfs_parse_fs_string(fc, key, val, strlen(val));
-}
-
 void v3d_gemfs_init(struct v3d_dev *v3d)
 {
        struct file_system_type *type;
@@ -38,9 +33,9 @@ void v3d_gemfs_init(struct v3d_dev *v3d)
        fc = fs_context_for_mount(type, SB_KERNMOUNT);
        if (IS_ERR(fc))
                goto err;
-       ret = add_param(fc, "source", "tmpfs");
+       ret = vfs_parse_fs_string(fc, "source", "tmpfs");
        if (!ret)
-               ret = add_param(fc, "huge", "within_size");
+               ret = vfs_parse_fs_string(fc, "huge", "within_size");
        if (!ret)
                gemfs = fc_mount_longterm(fc);
        put_fs_context(fc);
index 9434a5399f2b044f6c2e56e43d4195df6a4c4e76..1ad048e6e164573abf9311f4371d20c8be6285b7 100644 (file)
@@ -137,7 +137,8 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
 
                ret = -EINVAL;
                if (content[size - 1] == '.')
-                       ret = vfs_parse_fs_string(fc, "source", content, size - 1);
+                       ret = vfs_parse_fs_qstr(fc, "source",
+                                               &QSTR_LEN(content, size - 1));
                do_delayed_call(&cleanup);
                if (ret < 0)
                        return ret;
index 666e61753aed177ec03dd403df8828e510a91a60..93b7ebf8d92795cf9cc1c825be094dec94c8aac6 100644 (file)
@@ -161,25 +161,24 @@ int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param)
 EXPORT_SYMBOL(vfs_parse_fs_param);
 
 /**
- * vfs_parse_fs_string - Convenience function to just parse a string.
+ * vfs_parse_fs_qstr - Convenience function to just parse a string.
  * @fc: Filesystem context.
  * @key: Parameter name.
  * @value: Default value.
- * @v_size: Maximum number of bytes in the value.
  */
-int vfs_parse_fs_string(struct fs_context *fc, const char *key,
-                       const char *value, size_t v_size)
+int vfs_parse_fs_qstr(struct fs_context *fc, const char *key,
+                       const struct qstr *value)
 {
        int ret;
 
        struct fs_parameter param = {
                .key    = key,
                .type   = fs_value_is_flag,
-               .size   = v_size,
+               .size   = value ? value->len : 0,
        };
 
        if (value) {
-               param.string = kmemdup_nul(value, v_size, GFP_KERNEL);
+               param.string = kmemdup_nul(value->name, value->len, GFP_KERNEL);
                if (!param.string)
                        return -ENOMEM;
                param.type = fs_value_is_string;
@@ -189,7 +188,7 @@ int vfs_parse_fs_string(struct fs_context *fc, const char *key,
        kfree(param.string);
        return ret;
 }
-EXPORT_SYMBOL(vfs_parse_fs_string);
+EXPORT_SYMBOL(vfs_parse_fs_qstr);
 
 /**
  * vfs_parse_monolithic_sep - Parse key[=val][,key[=val]]* mount data
@@ -218,16 +217,14 @@ int vfs_parse_monolithic_sep(struct fs_context *fc, void *data,
 
        while ((key = sep(&options)) != NULL) {
                if (*key) {
-                       size_t v_len = 0;
                        char *value = strchr(key, '=');
 
                        if (value) {
                                if (unlikely(value == key))
                                        continue;
                                *value++ = 0;
-                               v_len = strlen(value);
                        }
-                       ret = vfs_parse_fs_string(fc, key, value, v_len);
+                       ret = vfs_parse_fs_string(fc, key, value);
                        if (ret < 0)
                                break;
                }
index ddfd4457d338372a6ee88f2fc54075eab25be3a8..88636124c8fe8aa315abb575ceb3f2de0f2ba830 100644 (file)
@@ -1281,8 +1281,7 @@ struct vfsmount *vfs_kern_mount(struct file_system_type *type,
                return ERR_CAST(fc);
 
        if (name)
-               ret = vfs_parse_fs_string(fc, "source",
-                                         name, strlen(name));
+               ret = vfs_parse_fs_string(fc, "source", name);
        if (!ret)
                ret = parse_monolithic_mount_data(fc, data);
        if (!ret)
@@ -3793,10 +3792,9 @@ static int do_new_mount(struct path *path, const char *fstype, int sb_flags,
        fc->oldapi = true;
 
        if (subtype)
-               err = vfs_parse_fs_string(fc, "subtype",
-                                         subtype, strlen(subtype));
+               err = vfs_parse_fs_string(fc, "subtype", subtype);
        if (!err && name)
-               err = vfs_parse_fs_string(fc, "source", name, strlen(name));
+               err = vfs_parse_fs_string(fc, "source", name);
        if (!err)
                err = parse_monolithic_mount_data(fc, data);
        if (!err && !mount_capable(fc))
index 9e94d18448ffcf2e2c114dac177f11ed66abe886..b4679b7161b0968810e13f57c889052ea015bf56 100644 (file)
@@ -1269,8 +1269,7 @@ static int nfs23_parse_monolithic(struct fs_context *fc,
                        int ret;
 
                        data->context[NFS_MAX_CONTEXT_LEN] = '\0';
-                       ret = vfs_parse_fs_string(fc, "context",
-                                                 data->context, strlen(data->context));
+                       ret = vfs_parse_fs_string(fc, "context", data->context);
                        if (ret < 0)
                                return ret;
 #else
index 7f1ec9c67ff21de7e2ce39431526b8dee75e7f49..5735c0448b4c3d5bfcd44c592a5574b9168d1e75 100644 (file)
@@ -290,7 +290,8 @@ int nfs_do_submount(struct fs_context *fc)
                nfs_errorf(fc, "NFS: Couldn't determine submount pathname");
                ret = PTR_ERR(p);
        } else {
-               ret = vfs_parse_fs_string(fc, "source", p, buffer + 4096 - p);
+               ret = vfs_parse_fs_qstr(fc, "source",
+                                       &QSTR_LEN(p, buffer + 4096 - p));
                if (!ret)
                        ret = vfs_get_tree(fc);
        }
index 072383899e8171aeff5596b55794a7e50845179a..306b76e9778391a526c211656af052b7846097f7 100644 (file)
@@ -773,16 +773,14 @@ static int smb3_fs_context_parse_monolithic(struct fs_context *fc,
                }
 
 
-               len = 0;
                value = strchr(key, '=');
                if (value) {
                        if (value == key)
                                continue;
                        *value++ = 0;
-                       len = strlen(value);
                }
 
-               ret = vfs_parse_fs_string(fc, key, value, len);
+               ret = vfs_parse_fs_string(fc, key, value);
                if (ret < 0)
                        break;
        }
index 7773eb870039c497b3ddc1fbaa605c2a7a934f51..97b514a79a49f2996d178f8518c6b91e6c9b441d 100644 (file)
@@ -134,8 +134,13 @@ extern struct fs_context *fs_context_for_submount(struct file_system_type *fs_ty
 
 extern struct fs_context *vfs_dup_fs_context(struct fs_context *fc);
 extern int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param);
-extern int vfs_parse_fs_string(struct fs_context *fc, const char *key,
-                              const char *value, size_t v_size);
+extern int vfs_parse_fs_qstr(struct fs_context *fc, const char *key,
+                               const struct qstr *value);
+static inline int vfs_parse_fs_string(struct fs_context *fc, const char *key,
+                              const char *value)
+{
+       return vfs_parse_fs_qstr(fc, key, value ? &QSTR(value) : NULL);
+}
 int vfs_parse_monolithic_sep(struct fs_context *fc, void *data,
                             char *(*sep)(char **));
 extern int generic_parse_monolithic(struct fs_context *fc, void *data);
index 4283ed4e8f592f5b3fe3213a0f831643a464f9f7..15375b45fd743b3d1f42d47f45ecb401a339349f 100644 (file)
@@ -10201,8 +10201,7 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
 
        pr_warn("NOTICE: Automounting of tracing to debugfs is deprecated and will be removed in 2030\n");
 
-       ret = vfs_parse_fs_string(fc, "source",
-                                 "tracefs", strlen("tracefs"));
+       ret = vfs_parse_fs_string(fc, "source", "tracefs");
        if (!ret)
                mnt = fc_mount(fc);
        else