Skip to content

Commit

Permalink
vfs: Convert romfs to use the new mount API
Browse files Browse the repository at this point in the history
Convert the romfs filesystem to the new internal mount API as the old
one will be obsoleted and removed.  This allows greater flexibility in
communication of mount parameters between userspace, the VFS and the
filesystem.

See Documentation/filesystems/mount_api.txt for more information.

Signed-off-by: David Howells <[email protected]>
cc: [email protected]
cc: [email protected]
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
dhowells authored and Al Viro committed Sep 5, 2019
1 parent 43ce4c1 commit b941759
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions fs/romfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/parser.h>
#include <linux/fs_context.h>
#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/statfs.h>
Expand Down Expand Up @@ -423,18 +423,17 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
/*
* remounting must involve read-only
*/
static int romfs_remount(struct super_block *sb, int *flags, char *data)
static int romfs_reconfigure(struct fs_context *fc)
{
sync_filesystem(sb);
*flags |= SB_RDONLY;
sync_filesystem(fc->root->d_sb);
fc->sb_flags |= SB_RDONLY;
return 0;
}

static const struct super_operations romfs_super_ops = {
.alloc_inode = romfs_alloc_inode,
.free_inode = romfs_free_inode,
.statfs = romfs_statfs,
.remount_fs = romfs_remount,
};

/*
Expand All @@ -457,7 +456,7 @@ static __u32 romfs_checksum(const void *data, int size)
/*
* fill in the superblock
*/
static int romfs_fill_super(struct super_block *sb, void *data, int silent)
static int romfs_fill_super(struct super_block *sb, struct fs_context *fc)
{
struct romfs_super_block *rsb;
struct inode *root;
Expand Down Expand Up @@ -504,8 +503,8 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)

if (rsb->word0 != ROMSB_WORD0 || rsb->word1 != ROMSB_WORD1 ||
img_size < ROMFH_SIZE) {
if (!silent)
pr_warn("VFS: Can't find a romfs filesystem on dev %s.\n",
if (!(fc->sb_flags & SB_SILENT))
errorf(fc, "VFS: Can't find a romfs filesystem on dev %s.\n",
sb->s_id);
goto error_rsb_inval;
}
Expand All @@ -518,7 +517,7 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
storage = sb->s_mtd ? "MTD" : "the block layer";

len = strnlen(rsb->name, ROMFS_MAXFN);
if (!silent)
if (!(fc->sb_flags & SB_SILENT))
pr_notice("Mounting image '%*.*s' through %s\n",
(unsigned) len, (unsigned) len, rsb->name, storage);

Expand Down Expand Up @@ -548,23 +547,34 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
/*
* get a superblock for mounting
*/
static struct dentry *romfs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name,
void *data)
static int romfs_get_tree(struct fs_context *fc)
{
struct dentry *ret = ERR_PTR(-EINVAL);
int ret = -EINVAL;

#ifdef CONFIG_ROMFS_ON_MTD
ret = mount_mtd(fs_type, flags, dev_name, data, romfs_fill_super);
ret = get_tree_mtd(fc, romfs_fill_super);
#endif
#ifdef CONFIG_ROMFS_ON_BLOCK
if (ret == ERR_PTR(-EINVAL))
ret = mount_bdev(fs_type, flags, dev_name, data,
romfs_fill_super);
if (ret == -EINVAL)
ret = get_tree_bdev(fc, romfs_fill_super);
#endif
return ret;
}

static const struct fs_context_operations romfs_context_ops = {
.get_tree = romfs_get_tree,
.reconfigure = romfs_reconfigure,
};

/*
* Set up the filesystem mount context.
*/
static int romfs_init_fs_context(struct fs_context *fc)
{
fc->ops = &romfs_context_ops;
return 0;
}

/*
* destroy a romfs superblock in the appropriate manner
*/
Expand All @@ -587,7 +597,7 @@ static void romfs_kill_sb(struct super_block *sb)
static struct file_system_type romfs_fs_type = {
.owner = THIS_MODULE,
.name = "romfs",
.mount = romfs_mount,
.init_fs_context = romfs_init_fs_context,
.kill_sb = romfs_kill_sb,
.fs_flags = FS_REQUIRES_DEV,
};
Expand Down

0 comments on commit b941759

Please sign in to comment.