Commit 8f8d8d11 authored by David Howells's avatar David Howells Committed by Al Viro

vfs: Convert hypfs to use the new mount API

Convert the hypfs 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: Martin Schwidefsky <schwidefsky@de.ibm.com>
cc: Heiko Carstens <heiko.carstens@de.ibm.com>
cc: linux-s390@vger.kernel.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b54c64f7
...@@ -12,17 +12,17 @@ ...@@ -12,17 +12,17 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/parser.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/mount.h>
#include <linux/uio.h> #include <linux/uio.h>
#include <asm/ebcdic.h> #include <asm/ebcdic.h>
#include "hypfs.h" #include "hypfs.h"
...@@ -207,52 +207,44 @@ static int hypfs_release(struct inode *inode, struct file *filp) ...@@ -207,52 +207,44 @@ static int hypfs_release(struct inode *inode, struct file *filp)
return 0; return 0;
} }
enum { opt_uid, opt_gid, opt_err }; enum { Opt_uid, Opt_gid, };
static const match_table_t hypfs_tokens = { static const struct fs_parameter_spec hypfs_param_specs[] = {
{opt_uid, "uid=%u"}, fsparam_u32("gid", Opt_gid),
{opt_gid, "gid=%u"}, fsparam_u32("uid", Opt_uid),
{opt_err, NULL} {}
}; };
static int hypfs_parse_options(char *options, struct super_block *sb) static const struct fs_parameter_description hypfs_fs_parameters = {
.name = "hypfs",
.specs = hypfs_param_specs,
};
static int hypfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{ {
char *str; struct hypfs_sb_info *hypfs_info = fc->s_fs_info;
substring_t args[MAX_OPT_ARGS]; struct fs_parse_result result;
kuid_t uid; kuid_t uid;
kgid_t gid; kgid_t gid;
int opt;
if (!options)
return 0; opt = fs_parse(fc, &hypfs_fs_parameters, param, &result);
while ((str = strsep(&options, ",")) != NULL) { if (opt < 0)
int token, option; return opt;
struct hypfs_sb_info *hypfs_info = sb->s_fs_info;
switch (opt) {
if (!*str) case Opt_uid:
continue; uid = make_kuid(current_user_ns(), result.uint_32);
token = match_token(str, hypfs_tokens, args); if (!uid_valid(uid))
switch (token) { return invalf(fc, "Unknown uid");
case opt_uid: hypfs_info->uid = uid;
if (match_int(&args[0], &option)) break;
return -EINVAL; case Opt_gid:
uid = make_kuid(current_user_ns(), option); gid = make_kgid(current_user_ns(), result.uint_32);
if (!uid_valid(uid)) if (!gid_valid(gid))
return -EINVAL; return invalf(fc, "Unknown gid");
hypfs_info->uid = uid; hypfs_info->gid = gid;
break; break;
case opt_gid:
if (match_int(&args[0], &option))
return -EINVAL;
gid = make_kgid(current_user_ns(), option);
if (!gid_valid(gid))
return -EINVAL;
hypfs_info->gid = gid;
break;
case opt_err:
default:
pr_err("%s is not a valid mount option\n", str);
return -EINVAL;
}
} }
return 0; return 0;
} }
...@@ -266,26 +258,18 @@ static int hypfs_show_options(struct seq_file *s, struct dentry *root) ...@@ -266,26 +258,18 @@ static int hypfs_show_options(struct seq_file *s, struct dentry *root)
return 0; return 0;
} }
static int hypfs_fill_super(struct super_block *sb, void *data, int silent) static int hypfs_fill_super(struct super_block *sb, struct fs_context *fc)
{ {
struct hypfs_sb_info *sbi = sb->s_fs_info;
struct inode *root_inode; struct inode *root_inode;
struct dentry *root_dentry, *update_file; struct dentry *root_dentry, *update_file;
int rc = 0; int rc;
struct hypfs_sb_info *sbi;
sbi = kzalloc(sizeof(struct hypfs_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
mutex_init(&sbi->lock);
sbi->uid = current_uid();
sbi->gid = current_gid();
sb->s_fs_info = sbi;
sb->s_blocksize = PAGE_SIZE; sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT; sb->s_blocksize_bits = PAGE_SHIFT;
sb->s_magic = HYPFS_MAGIC; sb->s_magic = HYPFS_MAGIC;
sb->s_op = &hypfs_s_ops; sb->s_op = &hypfs_s_ops;
if (hypfs_parse_options(data, sb))
return -EINVAL;
root_inode = hypfs_make_inode(sb, S_IFDIR | 0755); root_inode = hypfs_make_inode(sb, S_IFDIR | 0755);
if (!root_inode) if (!root_inode)
return -ENOMEM; return -ENOMEM;
...@@ -309,10 +293,37 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -309,10 +293,37 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent)
return 0; return 0;
} }
static struct dentry *hypfs_mount(struct file_system_type *fst, int flags, static int hypfs_get_tree(struct fs_context *fc)
const char *devname, void *data) {
return get_tree_single(fc, hypfs_fill_super);
}
static void hypfs_free_fc(struct fs_context *fc)
{ {
return mount_single(fst, flags, data, hypfs_fill_super); kfree(fc->s_fs_info);
}
static const struct fs_context_operations hypfs_context_ops = {
.free = hypfs_free_fc,
.parse_param = hypfs_parse_param,
.get_tree = hypfs_get_tree,
};
static int hypfs_init_fs_context(struct fs_context *fc)
{
struct hypfs_sb_info *sbi;
sbi = kzalloc(sizeof(struct hypfs_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
mutex_init(&sbi->lock);
sbi->uid = current_uid();
sbi->gid = current_gid();
fc->s_fs_info = sbi;
fc->ops = &hypfs_context_ops;
return 0;
} }
static void hypfs_kill_super(struct super_block *sb) static void hypfs_kill_super(struct super_block *sb)
...@@ -443,7 +454,8 @@ static const struct file_operations hypfs_file_ops = { ...@@ -443,7 +454,8 @@ static const struct file_operations hypfs_file_ops = {
static struct file_system_type hypfs_type = { static struct file_system_type hypfs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "s390_hypfs", .name = "s390_hypfs",
.mount = hypfs_mount, .init_fs_context = hypfs_init_fs_context,
.parameters = &hypfs_fs_parameters,
.kill_sb = hypfs_kill_super .kill_sb = hypfs_kill_super
}; };
......
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