Commit b9417599 authored by David Howells's avatar David Howells Committed by Al Viro

vfs: Convert romfs to use the new mount API

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: default avatarDavid Howells <dhowells@redhat.com>
cc: linux-mtd@lists.infradead.org
cc: linux-block@vger.kernel.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 43ce4c1f
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/parser.h> #include <linux/fs_context.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/statfs.h> #include <linux/statfs.h>
...@@ -423,10 +423,10 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -423,10 +423,10 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
/* /*
* remounting must involve read-only * 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); sync_filesystem(fc->root->d_sb);
*flags |= SB_RDONLY; fc->sb_flags |= SB_RDONLY;
return 0; return 0;
} }
...@@ -434,7 +434,6 @@ static const struct super_operations romfs_super_ops = { ...@@ -434,7 +434,6 @@ static const struct super_operations romfs_super_ops = {
.alloc_inode = romfs_alloc_inode, .alloc_inode = romfs_alloc_inode,
.free_inode = romfs_free_inode, .free_inode = romfs_free_inode,
.statfs = romfs_statfs, .statfs = romfs_statfs,
.remount_fs = romfs_remount,
}; };
/* /*
...@@ -457,7 +456,7 @@ static __u32 romfs_checksum(const void *data, int size) ...@@ -457,7 +456,7 @@ static __u32 romfs_checksum(const void *data, int size)
/* /*
* fill in the superblock * 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 romfs_super_block *rsb;
struct inode *root; struct inode *root;
...@@ -504,8 +503,8 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -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 || if (rsb->word0 != ROMSB_WORD0 || rsb->word1 != ROMSB_WORD1 ||
img_size < ROMFH_SIZE) { img_size < ROMFH_SIZE) {
if (!silent) if (!(fc->sb_flags & SB_SILENT))
pr_warn("VFS: Can't find a romfs filesystem on dev %s.\n", errorf(fc, "VFS: Can't find a romfs filesystem on dev %s.\n",
sb->s_id); sb->s_id);
goto error_rsb_inval; goto error_rsb_inval;
} }
...@@ -518,7 +517,7 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -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"; storage = sb->s_mtd ? "MTD" : "the block layer";
len = strnlen(rsb->name, ROMFS_MAXFN); len = strnlen(rsb->name, ROMFS_MAXFN);
if (!silent) if (!(fc->sb_flags & SB_SILENT))
pr_notice("Mounting image '%*.*s' through %s\n", pr_notice("Mounting image '%*.*s' through %s\n",
(unsigned) len, (unsigned) len, rsb->name, storage); (unsigned) len, (unsigned) len, rsb->name, storage);
...@@ -548,23 +547,34 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -548,23 +547,34 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
/* /*
* get a superblock for mounting * get a superblock for mounting
*/ */
static struct dentry *romfs_mount(struct file_system_type *fs_type, static int romfs_get_tree(struct fs_context *fc)
int flags, const char *dev_name,
void *data)
{ {
struct dentry *ret = ERR_PTR(-EINVAL); int ret = -EINVAL;
#ifdef CONFIG_ROMFS_ON_MTD #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 #endif
#ifdef CONFIG_ROMFS_ON_BLOCK #ifdef CONFIG_ROMFS_ON_BLOCK
if (ret == ERR_PTR(-EINVAL)) if (ret == -EINVAL)
ret = mount_bdev(fs_type, flags, dev_name, data, ret = get_tree_bdev(fc, romfs_fill_super);
romfs_fill_super);
#endif #endif
return ret; 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 * destroy a romfs superblock in the appropriate manner
*/ */
...@@ -587,7 +597,7 @@ static void romfs_kill_sb(struct super_block *sb) ...@@ -587,7 +597,7 @@ static void romfs_kill_sb(struct super_block *sb)
static struct file_system_type romfs_fs_type = { static struct file_system_type romfs_fs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "romfs", .name = "romfs",
.mount = romfs_mount, .init_fs_context = romfs_init_fs_context,
.kill_sb = romfs_kill_sb, .kill_sb = romfs_kill_sb,
.fs_flags = FS_REQUIRES_DEV, .fs_flags = FS_REQUIRES_DEV,
}; };
......
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