@@ -684,27 +684,6 @@ static int legacy_validate(struct fs_context *fc)
ctx->secdata);
}
-/*
- * Determine the superblock subtype.
- */
-static int legacy_set_subtype(struct fs_context *fc)
-{
- const char *subtype = strchr(fc->fs_type->name, '.');
-
- if (subtype) {
- subtype++;
- if (!subtype[0])
- return -EINVAL;
- } else {
- subtype = "";
- }
-
- fc->subtype = kstrdup(subtype, GFP_KERNEL);
- if (!fc->subtype)
- return -ENOMEM;
- return 0;
-}
-
/*
* Get a mountable root with the legacy mount command.
*/
@@ -713,7 +692,6 @@ static int legacy_get_tree(struct fs_context *fc)
struct legacy_fs_context *ctx = fc->fs_private;
struct super_block *sb;
struct dentry *root;
- int ret;
root = fc->fs_type->mount(fc->fs_type, fc->sb_flags,
fc->source, ctx->legacy_data,
@@ -724,20 +702,8 @@ static int legacy_get_tree(struct fs_context *fc)
sb = root->d_sb;
BUG_ON(!sb);
- if ((fc->fs_type->fs_flags & FS_HAS_SUBTYPE) &&
- !fc->subtype) {
- ret = legacy_set_subtype(fc);
- if (ret < 0)
- goto err_sb;
- }
-
fc->root = root;
return 0;
-
-err_sb:
- dput(root);
- deactivate_locked_super(sb);
- return ret;
}
/*
@@ -2617,6 +2617,7 @@ static int do_new_mount(struct path *mountpoint, const char *fstype,
{
struct file_system_type *fs_type;
struct fs_context *fc;
+ const char *subtype = NULL;
int err;
if (!fstype)
@@ -2627,6 +2628,19 @@ static int do_new_mount(struct path *mountpoint, const char *fstype,
if (!fs_type)
goto out;
+ if (fs_type->fs_flags & FS_HAS_SUBTYPE) {
+ subtype = strchr(fstype, '.');
+ if (subtype) {
+ subtype++;
+ if (!subtype[0]) {
+ put_filesystem(fs_type);
+ return -EINVAL;
+ }
+ } else {
+ subtype = "";
+ }
+ }
+
fc = vfs_new_fs_context(fs_type, NULL, sb_flags, sb_flags,
FS_CONTEXT_FOR_USER_MOUNT);
put_filesystem(fs_type);
@@ -2635,6 +2649,13 @@ static int do_new_mount(struct path *mountpoint, const char *fstype,
goto out;
}
+ if (subtype) {
+ fc->subtype = kstrdup(subtype, GFP_KERNEL);
+ err = -ENOMEM;
+ if (!fc->subtype)
+ goto out;
+ }
+
if (name) {
err = vfs_parse_fs_string(fc, "source", name, strlen(name));
if (err < 0)
Subtype was initilized at the wrong place from the wrong source (fstype->fs_type->name, which does not ever contain a subtype). Set subtype from do_new_mount(), where it actually does something. Verified with fuse. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> --- fs/fs_context.c | 34 ---------------------------------- fs/namespace.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 34 deletions(-)