Commit 103fb219 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'vfs-6.10.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs mount API conversions from Christian Brauner:
 "This converts qnx6, minix, debugfs, tracefs, freevxfs, and openpromfs
  to the new mount api, further reducing the number of filesystems
  relying on the legacy mount api"

* tag 'vfs-6.10.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
  minix: convert minix to use the new mount api
  vfs: Convert tracefs to use the new mount API
  vfs: Convert debugfs to use the new mount API
  openpromfs: finish conversion to the new mount API
  freevxfs: Convert freevxfs to the new mount API.
  qnx6: convert qnx6 to use the new mount api
parents 1b0aabcc 7cd7bfe5
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mount.h> #include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kobject.h> #include <linux/kobject.h>
...@@ -23,7 +24,6 @@ ...@@ -23,7 +24,6 @@
#include <linux/fsnotify.h> #include <linux/fsnotify.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/parser.h>
#include <linux/magic.h> #include <linux/magic.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/security.h> #include <linux/security.h>
...@@ -77,7 +77,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb) ...@@ -77,7 +77,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb)
return inode; return inode;
} }
struct debugfs_mount_opts { struct debugfs_fs_info {
kuid_t uid; kuid_t uid;
kgid_t gid; kgid_t gid;
umode_t mode; umode_t mode;
...@@ -89,58 +89,42 @@ enum { ...@@ -89,58 +89,42 @@ enum {
Opt_uid, Opt_uid,
Opt_gid, Opt_gid,
Opt_mode, Opt_mode,
Opt_err
}; };
static const match_table_t tokens = { static const struct fs_parameter_spec debugfs_param_specs[] = {
{Opt_uid, "uid=%u"}, fsparam_u32 ("gid", Opt_gid),
{Opt_gid, "gid=%u"}, fsparam_u32oct ("mode", Opt_mode),
{Opt_mode, "mode=%o"}, fsparam_u32 ("uid", Opt_uid),
{Opt_err, NULL} {}
}; };
struct debugfs_fs_info { static int debugfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
struct debugfs_mount_opts mount_opts;
};
static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
{ {
substring_t args[MAX_OPT_ARGS]; struct debugfs_fs_info *opts = fc->s_fs_info;
int option; struct fs_parse_result result;
int token;
kuid_t uid; kuid_t uid;
kgid_t gid; kgid_t gid;
char *p; int opt;
opts->opts = 0;
opts->mode = DEBUGFS_DEFAULT_MODE;
while ((p = strsep(&data, ",")) != NULL) { opt = fs_parse(fc, debugfs_param_specs, param, &result);
if (!*p) if (opt < 0)
continue; return opt;
token = match_token(p, tokens, args); switch (opt) {
switch (token) {
case Opt_uid: case Opt_uid:
if (match_int(&args[0], &option)) uid = make_kuid(current_user_ns(), result.uint_32);
return -EINVAL;
uid = make_kuid(current_user_ns(), option);
if (!uid_valid(uid)) if (!uid_valid(uid))
return -EINVAL; return invalf(fc, "Unknown uid");
opts->uid = uid; opts->uid = uid;
break; break;
case Opt_gid: case Opt_gid:
if (match_int(&args[0], &option)) gid = make_kgid(current_user_ns(), result.uint_32);
return -EINVAL;
gid = make_kgid(current_user_ns(), option);
if (!gid_valid(gid)) if (!gid_valid(gid))
return -EINVAL; return invalf(fc, "Unknown gid");
opts->gid = gid; opts->gid = gid;
break; break;
case Opt_mode: case Opt_mode:
if (match_octal(&args[0], &option)) opts->mode = result.uint_32 & S_IALLUGO;
return -EINVAL;
opts->mode = option & S_IALLUGO;
break; break;
/* /*
* We might like to report bad mount options here; * We might like to report bad mount options here;
...@@ -148,8 +132,7 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts) ...@@ -148,8 +132,7 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
*/ */
} }
opts->opts |= BIT(token); opts->opts |= BIT(opt);
}
return 0; return 0;
} }
...@@ -158,23 +141,22 @@ static void _debugfs_apply_options(struct super_block *sb, bool remount) ...@@ -158,23 +141,22 @@ static void _debugfs_apply_options(struct super_block *sb, bool remount)
{ {
struct debugfs_fs_info *fsi = sb->s_fs_info; struct debugfs_fs_info *fsi = sb->s_fs_info;
struct inode *inode = d_inode(sb->s_root); struct inode *inode = d_inode(sb->s_root);
struct debugfs_mount_opts *opts = &fsi->mount_opts;
/* /*
* On remount, only reset mode/uid/gid if they were provided as mount * On remount, only reset mode/uid/gid if they were provided as mount
* options. * options.
*/ */
if (!remount || opts->opts & BIT(Opt_mode)) { if (!remount || fsi->opts & BIT(Opt_mode)) {
inode->i_mode &= ~S_IALLUGO; inode->i_mode &= ~S_IALLUGO;
inode->i_mode |= opts->mode; inode->i_mode |= fsi->mode;
} }
if (!remount || opts->opts & BIT(Opt_uid)) if (!remount || fsi->opts & BIT(Opt_uid))
inode->i_uid = opts->uid; inode->i_uid = fsi->uid;
if (!remount || opts->opts & BIT(Opt_gid)) if (!remount || fsi->opts & BIT(Opt_gid))
inode->i_gid = opts->gid; inode->i_gid = fsi->gid;
} }
static void debugfs_apply_options(struct super_block *sb) static void debugfs_apply_options(struct super_block *sb)
...@@ -187,35 +169,33 @@ static void debugfs_apply_options_remount(struct super_block *sb) ...@@ -187,35 +169,33 @@ static void debugfs_apply_options_remount(struct super_block *sb)
_debugfs_apply_options(sb, true); _debugfs_apply_options(sb, true);
} }
static int debugfs_remount(struct super_block *sb, int *flags, char *data) static int debugfs_reconfigure(struct fs_context *fc)
{ {
int err; struct super_block *sb = fc->root->d_sb;
struct debugfs_fs_info *fsi = sb->s_fs_info; struct debugfs_fs_info *sb_opts = sb->s_fs_info;
struct debugfs_fs_info *new_opts = fc->s_fs_info;
sync_filesystem(sb); sync_filesystem(sb);
err = debugfs_parse_options(data, &fsi->mount_opts);
if (err)
goto fail;
/* structure copy of new mount options to sb */
*sb_opts = *new_opts;
debugfs_apply_options_remount(sb); debugfs_apply_options_remount(sb);
fail: return 0;
return err;
} }
static int debugfs_show_options(struct seq_file *m, struct dentry *root) static int debugfs_show_options(struct seq_file *m, struct dentry *root)
{ {
struct debugfs_fs_info *fsi = root->d_sb->s_fs_info; struct debugfs_fs_info *fsi = root->d_sb->s_fs_info;
struct debugfs_mount_opts *opts = &fsi->mount_opts;
if (!uid_eq(opts->uid, GLOBAL_ROOT_UID)) if (!uid_eq(fsi->uid, GLOBAL_ROOT_UID))
seq_printf(m, ",uid=%u", seq_printf(m, ",uid=%u",
from_kuid_munged(&init_user_ns, opts->uid)); from_kuid_munged(&init_user_ns, fsi->uid));
if (!gid_eq(opts->gid, GLOBAL_ROOT_GID)) if (!gid_eq(fsi->gid, GLOBAL_ROOT_GID))
seq_printf(m, ",gid=%u", seq_printf(m, ",gid=%u",
from_kgid_munged(&init_user_ns, opts->gid)); from_kgid_munged(&init_user_ns, fsi->gid));
if (opts->mode != DEBUGFS_DEFAULT_MODE) if (fsi->mode != DEBUGFS_DEFAULT_MODE)
seq_printf(m, ",mode=%o", opts->mode); seq_printf(m, ",mode=%o", fsi->mode);
return 0; return 0;
} }
...@@ -229,7 +209,6 @@ static void debugfs_free_inode(struct inode *inode) ...@@ -229,7 +209,6 @@ static void debugfs_free_inode(struct inode *inode)
static const struct super_operations debugfs_super_operations = { static const struct super_operations debugfs_super_operations = {
.statfs = simple_statfs, .statfs = simple_statfs,
.remount_fs = debugfs_remount,
.show_options = debugfs_show_options, .show_options = debugfs_show_options,
.free_inode = debugfs_free_inode, .free_inode = debugfs_free_inode,
}; };
...@@ -263,26 +242,14 @@ static const struct dentry_operations debugfs_dops = { ...@@ -263,26 +242,14 @@ static const struct dentry_operations debugfs_dops = {
.d_automount = debugfs_automount, .d_automount = debugfs_automount,
}; };
static int debug_fill_super(struct super_block *sb, void *data, int silent) static int debugfs_fill_super(struct super_block *sb, struct fs_context *fc)
{ {
static const struct tree_descr debug_files[] = {{""}}; static const struct tree_descr debug_files[] = {{""}};
struct debugfs_fs_info *fsi;
int err; int err;
fsi = kzalloc(sizeof(struct debugfs_fs_info), GFP_KERNEL);
sb->s_fs_info = fsi;
if (!fsi) {
err = -ENOMEM;
goto fail;
}
err = debugfs_parse_options(data, &fsi->mount_opts);
if (err)
goto fail;
err = simple_fill_super(sb, DEBUGFS_MAGIC, debug_files); err = simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
if (err) if (err)
goto fail; return err;
sb->s_op = &debugfs_super_operations; sb->s_op = &debugfs_super_operations;
sb->s_d_op = &debugfs_dops; sb->s_d_op = &debugfs_dops;
...@@ -290,27 +257,48 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent) ...@@ -290,27 +257,48 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent)
debugfs_apply_options(sb); debugfs_apply_options(sb);
return 0; return 0;
fail:
kfree(fsi);
sb->s_fs_info = NULL;
return err;
} }
static struct dentry *debug_mount(struct file_system_type *fs_type, static int debugfs_get_tree(struct fs_context *fc)
int flags, const char *dev_name,
void *data)
{ {
if (!(debugfs_allow & DEBUGFS_ALLOW_API)) if (!(debugfs_allow & DEBUGFS_ALLOW_API))
return ERR_PTR(-EPERM); return -EPERM;
return get_tree_single(fc, debugfs_fill_super);
}
static void debugfs_free_fc(struct fs_context *fc)
{
kfree(fc->s_fs_info);
}
return mount_single(fs_type, flags, data, debug_fill_super); static const struct fs_context_operations debugfs_context_ops = {
.free = debugfs_free_fc,
.parse_param = debugfs_parse_param,
.get_tree = debugfs_get_tree,
.reconfigure = debugfs_reconfigure,
};
static int debugfs_init_fs_context(struct fs_context *fc)
{
struct debugfs_fs_info *fsi;
fsi = kzalloc(sizeof(struct debugfs_fs_info), GFP_KERNEL);
if (!fsi)
return -ENOMEM;
fsi->mode = DEBUGFS_DEFAULT_MODE;
fc->s_fs_info = fsi;
fc->ops = &debugfs_context_ops;
return 0;
} }
static struct file_system_type debug_fs_type = { static struct file_system_type debug_fs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "debugfs", .name = "debugfs",
.mount = debug_mount, .init_fs_context = debugfs_init_fs_context,
.parameters = debugfs_param_specs,
.kill_sb = kill_litter_super, .kill_sb = kill_litter_super,
}; };
MODULE_ALIAS_FS("debugfs"); MODULE_ALIAS_FS("debugfs");
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/mount.h> #include <linux/fs_context.h>
#include "vxfs.h" #include "vxfs.h"
#include "vxfs_extern.h" #include "vxfs_extern.h"
...@@ -91,10 +91,10 @@ vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp) ...@@ -91,10 +91,10 @@ vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp)
return 0; return 0;
} }
static int vxfs_remount(struct super_block *sb, int *flags, char *data) static int vxfs_reconfigure(struct fs_context *fc)
{ {
sync_filesystem(sb); sync_filesystem(fc->root->d_sb);
*flags |= SB_RDONLY; fc->sb_flags |= SB_RDONLY;
return 0; return 0;
} }
...@@ -120,23 +120,23 @@ static const struct super_operations vxfs_super_ops = { ...@@ -120,23 +120,23 @@ static const struct super_operations vxfs_super_ops = {
.evict_inode = vxfs_evict_inode, .evict_inode = vxfs_evict_inode,
.put_super = vxfs_put_super, .put_super = vxfs_put_super,
.statfs = vxfs_statfs, .statfs = vxfs_statfs,
.remount_fs = vxfs_remount,
}; };
static int vxfs_try_sb_magic(struct super_block *sbp, int silent, static int vxfs_try_sb_magic(struct super_block *sbp, struct fs_context *fc,
unsigned blk, __fs32 magic) unsigned blk, __fs32 magic)
{ {
struct buffer_head *bp; struct buffer_head *bp;
struct vxfs_sb *rsbp; struct vxfs_sb *rsbp;
struct vxfs_sb_info *infp = VXFS_SBI(sbp); struct vxfs_sb_info *infp = VXFS_SBI(sbp);
int silent = fc->sb_flags & SB_SILENT;
int rc = -ENOMEM; int rc = -ENOMEM;
bp = sb_bread(sbp, blk); bp = sb_bread(sbp, blk);
do { do {
if (!bp || !buffer_mapped(bp)) { if (!bp || !buffer_mapped(bp)) {
if (!silent) { if (!silent) {
printk(KERN_WARNING warnf(fc,
"vxfs: unable to read disk superblock at %u\n", "vxfs: unable to read disk superblock at %u",
blk); blk);
} }
break; break;
...@@ -146,8 +146,8 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent, ...@@ -146,8 +146,8 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
rsbp = (struct vxfs_sb *)bp->b_data; rsbp = (struct vxfs_sb *)bp->b_data;
if (rsbp->vs_magic != magic) { if (rsbp->vs_magic != magic) {
if (!silent) if (!silent)
printk(KERN_NOTICE infof(fc,
"vxfs: WRONG superblock magic %08x at %u\n", "vxfs: WRONG superblock magic %08x at %u",
rsbp->vs_magic, blk); rsbp->vs_magic, blk);
break; break;
} }
...@@ -169,8 +169,7 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent, ...@@ -169,8 +169,7 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
/** /**
* vxfs_fill_super - read superblock into memory and initialize filesystem * vxfs_fill_super - read superblock into memory and initialize filesystem
* @sbp: VFS superblock (to fill) * @sbp: VFS superblock (to fill)
* @dp: fs private mount data * @fc: filesytem context
* @silent: do not complain loudly when sth is wrong
* *
* Description: * Description:
* We are called on the first mount of a filesystem to read the * We are called on the first mount of a filesystem to read the
...@@ -182,26 +181,27 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent, ...@@ -182,26 +181,27 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
* Locking: * Locking:
* We are under @sbp->s_lock. * We are under @sbp->s_lock.
*/ */
static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) static int vxfs_fill_super(struct super_block *sbp, struct fs_context *fc)
{ {
struct vxfs_sb_info *infp; struct vxfs_sb_info *infp;
struct vxfs_sb *rsbp; struct vxfs_sb *rsbp;
u_long bsize; u_long bsize;
struct inode *root; struct inode *root;
int ret = -EINVAL; int ret = -EINVAL;
int silent = fc->sb_flags & SB_SILENT;
u32 j; u32 j;
sbp->s_flags |= SB_RDONLY; sbp->s_flags |= SB_RDONLY;
infp = kzalloc(sizeof(*infp), GFP_KERNEL); infp = kzalloc(sizeof(*infp), GFP_KERNEL);
if (!infp) { if (!infp) {
printk(KERN_WARNING "vxfs: unable to allocate incore superblock\n"); warnf(fc, "vxfs: unable to allocate incore superblock");
return -ENOMEM; return -ENOMEM;
} }
bsize = sb_min_blocksize(sbp, BLOCK_SIZE); bsize = sb_min_blocksize(sbp, BLOCK_SIZE);
if (!bsize) { if (!bsize) {
printk(KERN_WARNING "vxfs: unable to set blocksize\n"); warnf(fc, "vxfs: unable to set blocksize");
goto out; goto out;
} }
...@@ -210,24 +210,24 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) ...@@ -210,24 +210,24 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
sbp->s_time_min = 0; sbp->s_time_min = 0;
sbp->s_time_max = U32_MAX; sbp->s_time_max = U32_MAX;
if (!vxfs_try_sb_magic(sbp, silent, 1, if (!vxfs_try_sb_magic(sbp, fc, 1,
(__force __fs32)cpu_to_le32(VXFS_SUPER_MAGIC))) { (__force __fs32)cpu_to_le32(VXFS_SUPER_MAGIC))) {
/* Unixware, x86 */ /* Unixware, x86 */
infp->byte_order = VXFS_BO_LE; infp->byte_order = VXFS_BO_LE;
} else if (!vxfs_try_sb_magic(sbp, silent, 8, } else if (!vxfs_try_sb_magic(sbp, fc, 8,
(__force __fs32)cpu_to_be32(VXFS_SUPER_MAGIC))) { (__force __fs32)cpu_to_be32(VXFS_SUPER_MAGIC))) {
/* HP-UX, parisc */ /* HP-UX, parisc */
infp->byte_order = VXFS_BO_BE; infp->byte_order = VXFS_BO_BE;
} else { } else {
if (!silent) if (!silent)
printk(KERN_NOTICE "vxfs: can't find superblock.\n"); infof(fc, "vxfs: can't find superblock.");
goto out; goto out;
} }
rsbp = infp->vsi_raw; rsbp = infp->vsi_raw;
j = fs32_to_cpu(infp, rsbp->vs_version); j = fs32_to_cpu(infp, rsbp->vs_version);
if ((j < 2 || j > 4) && !silent) { if ((j < 2 || j > 4) && !silent) {
printk(KERN_NOTICE "vxfs: unsupported VxFS version (%d)\n", j); infof(fc, "vxfs: unsupported VxFS version (%d)", j);
goto out; goto out;
} }
...@@ -244,17 +244,17 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) ...@@ -244,17 +244,17 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
j = fs32_to_cpu(infp, rsbp->vs_bsize); j = fs32_to_cpu(infp, rsbp->vs_bsize);
if (!sb_set_blocksize(sbp, j)) { if (!sb_set_blocksize(sbp, j)) {
printk(KERN_WARNING "vxfs: unable to set final block size\n"); warnf(fc, "vxfs: unable to set final block size");
goto out; goto out;
} }
if (vxfs_read_olt(sbp, bsize)) { if (vxfs_read_olt(sbp, bsize)) {
printk(KERN_WARNING "vxfs: unable to read olt\n"); warnf(fc, "vxfs: unable to read olt");
goto out; goto out;
} }
if (vxfs_read_fshead(sbp)) { if (vxfs_read_fshead(sbp)) {
printk(KERN_WARNING "vxfs: unable to read fshead\n"); warnf(fc, "vxfs: unable to read fshead");
goto out; goto out;
} }
...@@ -265,7 +265,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) ...@@ -265,7 +265,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
} }
sbp->s_root = d_make_root(root); sbp->s_root = d_make_root(root);
if (!sbp->s_root) { if (!sbp->s_root) {
printk(KERN_WARNING "vxfs: unable to get root dentry.\n"); warnf(fc, "vxfs: unable to get root dentry.");
goto out_free_ilist; goto out_free_ilist;
} }
...@@ -284,18 +284,29 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) ...@@ -284,18 +284,29 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
/* /*
* The usual module blurb. * The usual module blurb.
*/ */
static struct dentry *vxfs_mount(struct file_system_type *fs_type, static int vxfs_get_tree(struct fs_context *fc)
int flags, const char *dev_name, void *data)
{ {
return mount_bdev(fs_type, flags, dev_name, data, vxfs_fill_super); return get_tree_bdev(fc, vxfs_fill_super);
}
static const struct fs_context_operations vxfs_context_ops = {
.get_tree = vxfs_get_tree,
.reconfigure = vxfs_reconfigure,
};
static int vxfs_init_fs_context(struct fs_context *fc)
{
fc->ops = &vxfs_context_ops;
return 0;
} }
static struct file_system_type vxfs_fs_type = { static struct file_system_type vxfs_fs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "vxfs", .name = "vxfs",
.mount = vxfs_mount,
.kill_sb = kill_block_super, .kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV, .fs_flags = FS_REQUIRES_DEV,
.init_fs_context = vxfs_init_fs_context,
}; };
MODULE_ALIAS_FS("vxfs"); /* makes mount -t vxfs autoload the module */ MODULE_ALIAS_FS("vxfs"); /* makes mount -t vxfs autoload the module */
MODULE_ALIAS("vxfs"); MODULE_ALIAS("vxfs");
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
#include <linux/mpage.h> #include <linux/mpage.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/writeback.h> #include <linux/writeback.h>
#include <linux/fs_context.h>
static int minix_write_inode(struct inode *inode, static int minix_write_inode(struct inode *inode,
struct writeback_control *wbc); struct writeback_control *wbc);
static int minix_statfs(struct dentry *dentry, struct kstatfs *buf); static int minix_statfs(struct dentry *dentry, struct kstatfs *buf);
static int minix_remount (struct super_block * sb, int * flags, char * data);
static void minix_evict_inode(struct inode *inode) static void minix_evict_inode(struct inode *inode)
{ {
...@@ -111,19 +111,19 @@ static const struct super_operations minix_sops = { ...@@ -111,19 +111,19 @@ static const struct super_operations minix_sops = {
.evict_inode = minix_evict_inode, .evict_inode = minix_evict_inode,
.put_super = minix_put_super, .put_super = minix_put_super,
.statfs = minix_statfs, .statfs = minix_statfs,
.remount_fs = minix_remount,
}; };
static int minix_remount (struct super_block * sb, int * flags, char * data) static int minix_reconfigure(struct fs_context *fc)
{ {
struct minix_sb_info * sbi = minix_sb(sb);
struct minix_super_block * ms; struct minix_super_block * ms;
struct super_block *sb = fc->root->d_sb;
struct minix_sb_info * sbi = sb->s_fs_info;
sync_filesystem(sb); sync_filesystem(sb);
ms = sbi->s_ms; ms = sbi->s_ms;
if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb)) if ((bool)(fc->sb_flags & SB_RDONLY) == sb_rdonly(sb))
return 0; return 0;
if (*flags & SB_RDONLY) { if (fc->sb_flags & SB_RDONLY) {
if (ms->s_state & MINIX_VALID_FS || if (ms->s_state & MINIX_VALID_FS ||
!(sbi->s_mount_state & MINIX_VALID_FS)) !(sbi->s_mount_state & MINIX_VALID_FS))
return 0; return 0;
...@@ -170,7 +170,7 @@ static bool minix_check_superblock(struct super_block *sb) ...@@ -170,7 +170,7 @@ static bool minix_check_superblock(struct super_block *sb)
return true; return true;
} }
static int minix_fill_super(struct super_block *s, void *data, int silent) static int minix_fill_super(struct super_block *s, struct fs_context *fc)
{ {
struct buffer_head *bh; struct buffer_head *bh;
struct buffer_head **map; struct buffer_head **map;
...@@ -180,6 +180,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -180,6 +180,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
struct inode *root_inode; struct inode *root_inode;
struct minix_sb_info *sbi; struct minix_sb_info *sbi;
int ret = -EINVAL; int ret = -EINVAL;
int silent = fc->sb_flags & SB_SILENT;
sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL); sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
if (!sbi) if (!sbi)
...@@ -371,6 +372,23 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -371,6 +372,23 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
return ret; return ret;
} }
static int minix_get_tree(struct fs_context *fc)
{
return get_tree_bdev(fc, minix_fill_super);
}
static const struct fs_context_operations minix_context_ops = {
.get_tree = minix_get_tree,
.reconfigure = minix_reconfigure,
};
static int minix_init_fs_context(struct fs_context *fc)
{
fc->ops = &minix_context_ops;
return 0;
}
static int minix_statfs(struct dentry *dentry, struct kstatfs *buf) static int minix_statfs(struct dentry *dentry, struct kstatfs *buf)
{ {
struct super_block *sb = dentry->d_sb; struct super_block *sb = dentry->d_sb;
...@@ -680,18 +698,12 @@ void minix_truncate(struct inode * inode) ...@@ -680,18 +698,12 @@ void minix_truncate(struct inode * inode)
V2_minix_truncate(inode); V2_minix_truncate(inode);
} }
static struct dentry *minix_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
return mount_bdev(fs_type, flags, dev_name, data, minix_fill_super);
}
static struct file_system_type minix_fs_type = { static struct file_system_type minix_fs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "minix", .name = "minix",
.mount = minix_mount,
.kill_sb = kill_block_super, .kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV, .fs_flags = FS_REQUIRES_DEV,
.init_fs_context = minix_init_fs_context,
}; };
MODULE_ALIAS_FS("minix"); MODULE_ALIAS_FS("minix");
......
...@@ -355,10 +355,10 @@ static struct inode *openprom_iget(struct super_block *sb, ino_t ino) ...@@ -355,10 +355,10 @@ static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
return inode; return inode;
} }
static int openprom_remount(struct super_block *sb, int *flags, char *data) static int openpromfs_reconfigure(struct fs_context *fc)
{ {
sync_filesystem(sb); sync_filesystem(fc->root->d_sb);
*flags |= SB_NOATIME; fc->sb_flags |= SB_NOATIME;
return 0; return 0;
} }
...@@ -366,7 +366,6 @@ static const struct super_operations openprom_sops = { ...@@ -366,7 +366,6 @@ static const struct super_operations openprom_sops = {
.alloc_inode = openprom_alloc_inode, .alloc_inode = openprom_alloc_inode,
.free_inode = openprom_free_inode, .free_inode = openprom_free_inode,
.statfs = simple_statfs, .statfs = simple_statfs,
.remount_fs = openprom_remount,
}; };
static int openprom_fill_super(struct super_block *s, struct fs_context *fc) static int openprom_fill_super(struct super_block *s, struct fs_context *fc)
...@@ -415,6 +414,7 @@ static int openpromfs_get_tree(struct fs_context *fc) ...@@ -415,6 +414,7 @@ static int openpromfs_get_tree(struct fs_context *fc)
static const struct fs_context_operations openpromfs_context_ops = { static const struct fs_context_operations openpromfs_context_ops = {
.get_tree = openpromfs_get_tree, .get_tree = openpromfs_get_tree,
.reconfigure = openpromfs_reconfigure,
}; };
static int openpromfs_init_fs_context(struct fs_context *fc) static int openpromfs_init_fs_context(struct fs_context *fc)
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/writeback.h> #include <linux/writeback.h>
#include <linux/statfs.h> #include <linux/statfs.h>
#include <linux/parser.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/mount.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/mpage.h> #include <linux/mpage.h>
#include <linux/fs_parser.h>
#include <linux/fs_context.h>
#include "qnx6.h" #include "qnx6.h"
static const struct super_operations qnx6_sops; static const struct super_operations qnx6_sops;
...@@ -31,7 +31,7 @@ static const struct super_operations qnx6_sops; ...@@ -31,7 +31,7 @@ static const struct super_operations qnx6_sops;
static void qnx6_put_super(struct super_block *sb); static void qnx6_put_super(struct super_block *sb);
static struct inode *qnx6_alloc_inode(struct super_block *sb); static struct inode *qnx6_alloc_inode(struct super_block *sb);
static void qnx6_free_inode(struct inode *inode); static void qnx6_free_inode(struct inode *inode);
static int qnx6_remount(struct super_block *sb, int *flags, char *data); static int qnx6_reconfigure(struct fs_context *fc);
static int qnx6_statfs(struct dentry *dentry, struct kstatfs *buf); static int qnx6_statfs(struct dentry *dentry, struct kstatfs *buf);
static int qnx6_show_options(struct seq_file *seq, struct dentry *root); static int qnx6_show_options(struct seq_file *seq, struct dentry *root);
...@@ -40,7 +40,6 @@ static const struct super_operations qnx6_sops = { ...@@ -40,7 +40,6 @@ static const struct super_operations qnx6_sops = {
.free_inode = qnx6_free_inode, .free_inode = qnx6_free_inode,
.put_super = qnx6_put_super, .put_super = qnx6_put_super,
.statfs = qnx6_statfs, .statfs = qnx6_statfs,
.remount_fs = qnx6_remount,
.show_options = qnx6_show_options, .show_options = qnx6_show_options,
}; };
...@@ -54,10 +53,12 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root) ...@@ -54,10 +53,12 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root)
return 0; return 0;
} }
static int qnx6_remount(struct super_block *sb, int *flags, char *data) static int qnx6_reconfigure(struct fs_context *fc)
{ {
struct super_block *sb = fc->root->d_sb;
sync_filesystem(sb); sync_filesystem(sb);
*flags |= SB_RDONLY; fc->sb_flags |= SB_RDONLY;
return 0; return 0;
} }
...@@ -218,39 +219,36 @@ void qnx6_superblock_debug(struct qnx6_super_block *sb, struct super_block *s) ...@@ -218,39 +219,36 @@ void qnx6_superblock_debug(struct qnx6_super_block *sb, struct super_block *s)
#endif #endif
enum { enum {
Opt_mmifs, Opt_mmifs
Opt_err
}; };
static const match_table_t tokens = { struct qnx6_context {
{Opt_mmifs, "mmi_fs"}, unsigned long s_mount_opts;
{Opt_err, NULL}
}; };
static int qnx6_parse_options(char *options, struct super_block *sb) static const struct fs_parameter_spec qnx6_param_spec[] = {
{ fsparam_flag ("mmi_fs", Opt_mmifs),
char *p; {}
struct qnx6_sb_info *sbi = QNX6_SB(sb); };
substring_t args[MAX_OPT_ARGS];
if (!options) static int qnx6_parse_param(struct fs_context *fc, struct fs_parameter *param)
return 1; {
struct qnx6_context *ctx = fc->fs_private;
struct fs_parse_result result;
int opt;
while ((p = strsep(&options, ",")) != NULL) { opt = fs_parse(fc, qnx6_param_spec, param, &result);
int token; if (opt < 0)
if (!*p) return opt;
continue;
token = match_token(p, tokens, args); switch (opt) {
switch (token) {
case Opt_mmifs: case Opt_mmifs:
set_opt(sbi->s_mount_opt, MMI_FS); ctx->s_mount_opts |= QNX6_MOUNT_MMI_FS;
break; break;
default: default:
return 0; return -EINVAL;
}
} }
return 1; return 0;
} }
static struct buffer_head *qnx6_check_first_superblock(struct super_block *s, static struct buffer_head *qnx6_check_first_superblock(struct super_block *s,
...@@ -293,22 +291,25 @@ static struct buffer_head *qnx6_check_first_superblock(struct super_block *s, ...@@ -293,22 +291,25 @@ static struct buffer_head *qnx6_check_first_superblock(struct super_block *s,
static struct inode *qnx6_private_inode(struct super_block *s, static struct inode *qnx6_private_inode(struct super_block *s,
struct qnx6_root_node *p); struct qnx6_root_node *p);
static int qnx6_fill_super(struct super_block *s, void *data, int silent) static int qnx6_fill_super(struct super_block *s, struct fs_context *fc)
{ {
struct buffer_head *bh1 = NULL, *bh2 = NULL; struct buffer_head *bh1 = NULL, *bh2 = NULL;
struct qnx6_super_block *sb1 = NULL, *sb2 = NULL; struct qnx6_super_block *sb1 = NULL, *sb2 = NULL;
struct qnx6_sb_info *sbi; struct qnx6_sb_info *sbi;
struct qnx6_context *ctx = fc->fs_private;
struct inode *root; struct inode *root;
const char *errmsg; const char *errmsg;
struct qnx6_sb_info *qs; struct qnx6_sb_info *qs;
int ret = -EINVAL; int ret = -EINVAL;
u64 offset; u64 offset;
int bootblock_offset = QNX6_BOOTBLOCK_SIZE; int bootblock_offset = QNX6_BOOTBLOCK_SIZE;
int silent = fc->sb_flags & SB_SILENT;
qs = kzalloc(sizeof(struct qnx6_sb_info), GFP_KERNEL); qs = kzalloc(sizeof(struct qnx6_sb_info), GFP_KERNEL);
if (!qs) if (!qs)
return -ENOMEM; return -ENOMEM;
s->s_fs_info = qs; s->s_fs_info = qs;
qs->s_mount_opt = ctx->s_mount_opts;
/* Superblock always is 512 Byte long */ /* Superblock always is 512 Byte long */
if (!sb_set_blocksize(s, QNX6_SUPERBLOCK_SIZE)) { if (!sb_set_blocksize(s, QNX6_SUPERBLOCK_SIZE)) {
...@@ -316,12 +317,7 @@ static int qnx6_fill_super(struct super_block *s, void *data, int silent) ...@@ -316,12 +317,7 @@ static int qnx6_fill_super(struct super_block *s, void *data, int silent)
goto outnobh; goto outnobh;
} }
/* parse the mount-options */ if (qs->s_mount_opt == QNX6_MOUNT_MMI_FS) {
if (!qnx6_parse_options((char *) data, s)) {
pr_err("invalid mount options.\n");
goto outnobh;
}
if (test_opt(s, MMI_FS)) {
sb1 = qnx6_mmi_fill_super(s, silent); sb1 = qnx6_mmi_fill_super(s, silent);
if (sb1) if (sb1)
goto mmi_success; goto mmi_success;
...@@ -632,18 +628,43 @@ static void destroy_inodecache(void) ...@@ -632,18 +628,43 @@ static void destroy_inodecache(void)
kmem_cache_destroy(qnx6_inode_cachep); kmem_cache_destroy(qnx6_inode_cachep);
} }
static struct dentry *qnx6_mount(struct file_system_type *fs_type, static int qnx6_get_tree(struct fs_context *fc)
int flags, const char *dev_name, void *data)
{ {
return mount_bdev(fs_type, flags, dev_name, data, qnx6_fill_super); return get_tree_bdev(fc, qnx6_fill_super);
}
static void qnx6_free_fc(struct fs_context *fc)
{
kfree(fc->fs_private);
}
static const struct fs_context_operations qnx6_context_ops = {
.parse_param = qnx6_parse_param,
.get_tree = qnx6_get_tree,
.reconfigure = qnx6_reconfigure,
.free = qnx6_free_fc,
};
static int qnx6_init_fs_context(struct fs_context *fc)
{
struct qnx6_context *ctx;
ctx = kzalloc(sizeof(struct qnx6_context), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
fc->ops = &qnx6_context_ops;
fc->fs_private = ctx;
return 0;
} }
static struct file_system_type qnx6_fs_type = { static struct file_system_type qnx6_fs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "qnx6", .name = "qnx6",
.mount = qnx6_mount,
.kill_sb = kill_block_super, .kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV, .fs_flags = FS_REQUIRES_DEV,
.init_fs_context = qnx6_init_fs_context,
.parameters = qnx6_param_spec,
}; };
MODULE_ALIAS_FS("qnx6"); MODULE_ALIAS_FS("qnx6");
......
...@@ -11,14 +11,14 @@ ...@@ -11,14 +11,14 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mount.h> #include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/tracefs.h> #include <linux/tracefs.h>
#include <linux/fsnotify.h> #include <linux/fsnotify.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/parser.h>
#include <linux/magic.h> #include <linux/magic.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "internal.h" #include "internal.h"
...@@ -281,7 +281,7 @@ struct inode *tracefs_get_inode(struct super_block *sb) ...@@ -281,7 +281,7 @@ struct inode *tracefs_get_inode(struct super_block *sb)
return inode; return inode;
} }
struct tracefs_mount_opts { struct tracefs_fs_info {
kuid_t uid; kuid_t uid;
kgid_t gid; kgid_t gid;
umode_t mode; umode_t mode;
...@@ -293,58 +293,42 @@ enum { ...@@ -293,58 +293,42 @@ enum {
Opt_uid, Opt_uid,
Opt_gid, Opt_gid,
Opt_mode, Opt_mode,
Opt_err
}; };
static const match_table_t tokens = { static const struct fs_parameter_spec tracefs_param_specs[] = {
{Opt_uid, "uid=%u"}, fsparam_u32 ("gid", Opt_gid),
{Opt_gid, "gid=%u"}, fsparam_u32oct ("mode", Opt_mode),
{Opt_mode, "mode=%o"}, fsparam_u32 ("uid", Opt_uid),
{Opt_err, NULL} {}
}; };
struct tracefs_fs_info { static int tracefs_parse_param(struct fs_context *fc, struct fs_parameter *param)
struct tracefs_mount_opts mount_opts;
};
static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
{ {
substring_t args[MAX_OPT_ARGS]; struct tracefs_fs_info *opts = fc->s_fs_info;
int option; struct fs_parse_result result;
int token;
kuid_t uid; kuid_t uid;
kgid_t gid; kgid_t gid;
char *p; int opt;
opts->opts = 0;
opts->mode = TRACEFS_DEFAULT_MODE;
while ((p = strsep(&data, ",")) != NULL) { opt = fs_parse(fc, tracefs_param_specs, param, &result);
if (!*p) if (opt < 0)
continue; return opt;
token = match_token(p, tokens, args); switch (opt) {
switch (token) {
case Opt_uid: case Opt_uid:
if (match_int(&args[0], &option)) uid = make_kuid(current_user_ns(), result.uint_32);
return -EINVAL;
uid = make_kuid(current_user_ns(), option);
if (!uid_valid(uid)) if (!uid_valid(uid))
return -EINVAL; return invalf(fc, "Unknown uid");
opts->uid = uid; opts->uid = uid;
break; break;
case Opt_gid: case Opt_gid:
if (match_int(&args[0], &option)) gid = make_kgid(current_user_ns(), result.uint_32);
return -EINVAL;
gid = make_kgid(current_user_ns(), option);
if (!gid_valid(gid)) if (!gid_valid(gid))
return -EINVAL; return invalf(fc, "Unknown gid");
opts->gid = gid; opts->gid = gid;
break; break;
case Opt_mode: case Opt_mode:
if (match_octal(&args[0], &option)) opts->mode = result.uint_32 & S_IALLUGO;
return -EINVAL;
opts->mode = option & S_IALLUGO;
break; break;
/* /*
* We might like to report bad mount options here; * We might like to report bad mount options here;
...@@ -352,8 +336,7 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts) ...@@ -352,8 +336,7 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
*/ */
} }
opts->opts |= BIT(token); opts->opts |= BIT(opt);
}
return 0; return 0;
} }
...@@ -362,7 +345,6 @@ static int tracefs_apply_options(struct super_block *sb, bool remount) ...@@ -362,7 +345,6 @@ static int tracefs_apply_options(struct super_block *sb, bool remount)
{ {
struct tracefs_fs_info *fsi = sb->s_fs_info; struct tracefs_fs_info *fsi = sb->s_fs_info;
struct inode *inode = d_inode(sb->s_root); struct inode *inode = d_inode(sb->s_root);
struct tracefs_mount_opts *opts = &fsi->mount_opts;
struct tracefs_inode *ti; struct tracefs_inode *ti;
bool update_uid, update_gid; bool update_uid, update_gid;
umode_t tmp_mode; umode_t tmp_mode;
...@@ -372,22 +354,22 @@ static int tracefs_apply_options(struct super_block *sb, bool remount) ...@@ -372,22 +354,22 @@ static int tracefs_apply_options(struct super_block *sb, bool remount)
* options. * options.
*/ */
if (!remount || opts->opts & BIT(Opt_mode)) { if (!remount || fsi->opts & BIT(Opt_mode)) {
tmp_mode = READ_ONCE(inode->i_mode) & ~S_IALLUGO; tmp_mode = READ_ONCE(inode->i_mode) & ~S_IALLUGO;
tmp_mode |= opts->mode; tmp_mode |= fsi->mode;
WRITE_ONCE(inode->i_mode, tmp_mode); WRITE_ONCE(inode->i_mode, tmp_mode);
} }
if (!remount || opts->opts & BIT(Opt_uid)) if (!remount || fsi->opts & BIT(Opt_uid))
inode->i_uid = opts->uid; inode->i_uid = fsi->uid;
if (!remount || opts->opts & BIT(Opt_gid)) if (!remount || fsi->opts & BIT(Opt_gid))
inode->i_gid = opts->gid; inode->i_gid = fsi->gid;
if (remount && (opts->opts & BIT(Opt_uid) || opts->opts & BIT(Opt_gid))) { if (remount && (fsi->opts & BIT(Opt_uid) || fsi->opts & BIT(Opt_gid))) {
update_uid = opts->opts & BIT(Opt_uid); update_uid = fsi->opts & BIT(Opt_uid);
update_gid = opts->opts & BIT(Opt_gid); update_gid = fsi->opts & BIT(Opt_gid);
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(ti, &tracefs_inodes, list) { list_for_each_entry_rcu(ti, &tracefs_inodes, list) {
...@@ -406,35 +388,31 @@ static int tracefs_apply_options(struct super_block *sb, bool remount) ...@@ -406,35 +388,31 @@ static int tracefs_apply_options(struct super_block *sb, bool remount)
return 0; return 0;
} }
static int tracefs_remount(struct super_block *sb, int *flags, char *data) static int tracefs_reconfigure(struct fs_context *fc)
{ {
int err; struct super_block *sb = fc->root->d_sb;
struct tracefs_fs_info *fsi = sb->s_fs_info; struct tracefs_fs_info *sb_opts = sb->s_fs_info;
struct tracefs_fs_info *new_opts = fc->s_fs_info;
sync_filesystem(sb); sync_filesystem(sb);
err = tracefs_parse_options(data, &fsi->mount_opts); /* structure copy of new mount options to sb */
if (err) *sb_opts = *new_opts;
goto fail;
tracefs_apply_options(sb, true);
fail: return tracefs_apply_options(sb, true);
return err;
} }
static int tracefs_show_options(struct seq_file *m, struct dentry *root) static int tracefs_show_options(struct seq_file *m, struct dentry *root)
{ {
struct tracefs_fs_info *fsi = root->d_sb->s_fs_info; struct tracefs_fs_info *fsi = root->d_sb->s_fs_info;
struct tracefs_mount_opts *opts = &fsi->mount_opts;
if (!uid_eq(opts->uid, GLOBAL_ROOT_UID)) if (!uid_eq(fsi->uid, GLOBAL_ROOT_UID))
seq_printf(m, ",uid=%u", seq_printf(m, ",uid=%u",
from_kuid_munged(&init_user_ns, opts->uid)); from_kuid_munged(&init_user_ns, fsi->uid));
if (!gid_eq(opts->gid, GLOBAL_ROOT_GID)) if (!gid_eq(fsi->gid, GLOBAL_ROOT_GID))
seq_printf(m, ",gid=%u", seq_printf(m, ",gid=%u",
from_kgid_munged(&init_user_ns, opts->gid)); from_kgid_munged(&init_user_ns, fsi->gid));
if (opts->mode != TRACEFS_DEFAULT_MODE) if (fsi->mode != TRACEFS_DEFAULT_MODE)
seq_printf(m, ",mode=%o", opts->mode); seq_printf(m, ",mode=%o", fsi->mode);
return 0; return 0;
} }
...@@ -444,7 +422,6 @@ static const struct super_operations tracefs_super_operations = { ...@@ -444,7 +422,6 @@ static const struct super_operations tracefs_super_operations = {
.free_inode = tracefs_free_inode, .free_inode = tracefs_free_inode,
.drop_inode = generic_delete_inode, .drop_inode = generic_delete_inode,
.statfs = simple_statfs, .statfs = simple_statfs,
.remount_fs = tracefs_remount,
.show_options = tracefs_show_options, .show_options = tracefs_show_options,
}; };
...@@ -489,26 +466,14 @@ static const struct dentry_operations tracefs_dentry_operations = { ...@@ -489,26 +466,14 @@ static const struct dentry_operations tracefs_dentry_operations = {
.d_release = tracefs_d_release, .d_release = tracefs_d_release,
}; };
static int trace_fill_super(struct super_block *sb, void *data, int silent) static int tracefs_fill_super(struct super_block *sb, struct fs_context *fc)
{ {
static const struct tree_descr trace_files[] = {{""}}; static const struct tree_descr trace_files[] = {{""}};
struct tracefs_fs_info *fsi;
int err; int err;
fsi = kzalloc(sizeof(struct tracefs_fs_info), GFP_KERNEL);
sb->s_fs_info = fsi;
if (!fsi) {
err = -ENOMEM;
goto fail;
}
err = tracefs_parse_options(data, &fsi->mount_opts);
if (err)
goto fail;
err = simple_fill_super(sb, TRACEFS_MAGIC, trace_files); err = simple_fill_super(sb, TRACEFS_MAGIC, trace_files);
if (err) if (err)
goto fail; return err;
sb->s_op = &tracefs_super_operations; sb->s_op = &tracefs_super_operations;
sb->s_d_op = &tracefs_dentry_operations; sb->s_d_op = &tracefs_dentry_operations;
...@@ -516,24 +481,45 @@ static int trace_fill_super(struct super_block *sb, void *data, int silent) ...@@ -516,24 +481,45 @@ static int trace_fill_super(struct super_block *sb, void *data, int silent)
tracefs_apply_options(sb, false); tracefs_apply_options(sb, false);
return 0; return 0;
}
fail: static int tracefs_get_tree(struct fs_context *fc)
kfree(fsi); {
sb->s_fs_info = NULL; return get_tree_single(fc, tracefs_fill_super);
return err;
} }
static struct dentry *trace_mount(struct file_system_type *fs_type, static void tracefs_free_fc(struct fs_context *fc)
int flags, const char *dev_name,
void *data)
{ {
return mount_single(fs_type, flags, data, trace_fill_super); kfree(fc->s_fs_info);
}
static const struct fs_context_operations tracefs_context_ops = {
.free = tracefs_free_fc,
.parse_param = tracefs_parse_param,
.get_tree = tracefs_get_tree,
.reconfigure = tracefs_reconfigure,
};
static int tracefs_init_fs_context(struct fs_context *fc)
{
struct tracefs_fs_info *fsi;
fsi = kzalloc(sizeof(struct tracefs_fs_info), GFP_KERNEL);
if (!fsi)
return -ENOMEM;
fsi->mode = TRACEFS_DEFAULT_MODE;
fc->s_fs_info = fsi;
fc->ops = &tracefs_context_ops;
return 0;
} }
static struct file_system_type trace_fs_type = { static struct file_system_type trace_fs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "tracefs", .name = "tracefs",
.mount = trace_mount, .init_fs_context = tracefs_init_fs_context,
.parameters = tracefs_param_specs,
.kill_sb = kill_litter_super, .kill_sb = kill_litter_super,
}; };
MODULE_ALIAS_FS("tracefs"); MODULE_ALIAS_FS("tracefs");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment