Commit 702ff7f9 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (2/8) ->get_sb() switchover

get_sb_bdev() et.al. get a new argument (fill_super) and become
exported.
parent 143845d1
...@@ -641,8 +641,9 @@ struct super_block *get_anon_super(struct file_system_type *type, ...@@ -641,8 +641,9 @@ struct super_block *get_anon_super(struct file_system_type *type,
return s; return s;
} }
static struct super_block *get_sb_bdev(struct file_system_type *fs_type, struct super_block *get_sb_bdev(struct file_system_type *fs_type,
int flags, char *dev_name, void * data) int flags, char *dev_name, void * data,
int (*fill_super)(struct super_block *, void *, int))
{ {
struct inode *inode; struct inode *inode;
struct block_device *bdev; struct block_device *bdev;
...@@ -698,7 +699,7 @@ static struct super_block *get_sb_bdev(struct file_system_type *fs_type, ...@@ -698,7 +699,7 @@ static struct super_block *get_sb_bdev(struct file_system_type *fs_type,
list_for_each(p, &super_blocks) { list_for_each(p, &super_blocks) {
struct super_block *old = sb_entry(p); struct super_block *old = sb_entry(p);
if (!kdev_same(old->s_dev, dev)) if (old->s_bdev != bdev)
continue; continue;
if (old->s_type != fs_type || if (old->s_type != fs_type ||
((flags ^ old->s_flags) & MS_RDONLY)) { ((flags ^ old->s_flags) & MS_RDONLY)) {
...@@ -718,8 +719,8 @@ static struct super_block *get_sb_bdev(struct file_system_type *fs_type, ...@@ -718,8 +719,8 @@ static struct super_block *get_sb_bdev(struct file_system_type *fs_type,
s->s_flags = flags; s->s_flags = flags;
insert_super(s, fs_type); insert_super(s, fs_type);
strncpy(s->s_id, bdevname(dev), sizeof(s->s_id)); strncpy(s->s_id, bdevname(dev), sizeof(s->s_id));
error = -EINVAL; error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) if (error)
goto failed; goto failed;
s->s_flags |= MS_ACTIVE; s->s_flags |= MS_ACTIVE;
path_release(&nd); path_release(&nd);
...@@ -736,19 +737,23 @@ static struct super_block *get_sb_bdev(struct file_system_type *fs_type, ...@@ -736,19 +737,23 @@ static struct super_block *get_sb_bdev(struct file_system_type *fs_type,
return ERR_PTR(error); return ERR_PTR(error);
} }
static struct super_block *get_sb_nodev(struct file_system_type *fs_type, struct super_block *get_sb_nodev(struct file_system_type *fs_type,
int flags, char *dev_name, void *data) int flags, void *data,
int (*fill_super)(struct super_block *, void *, int))
{ {
int error;
struct super_block *s = get_anon_super(fs_type, NULL, NULL); struct super_block *s = get_anon_super(fs_type, NULL, NULL);
if (IS_ERR(s)) if (IS_ERR(s))
return s; return s;
s->s_flags = flags; s->s_flags = flags;
if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) {
error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
if (error) {
deactivate_super(s); deactivate_super(s);
remove_super(s); remove_super(s);
return ERR_PTR(-EINVAL); return ERR_PTR(error);
} }
s->s_flags |= MS_ACTIVE; s->s_flags |= MS_ACTIVE;
return s; return s;
...@@ -759,19 +764,22 @@ static int compare_single(struct super_block *s, void *p) ...@@ -759,19 +764,22 @@ static int compare_single(struct super_block *s, void *p)
return 1; return 1;
} }
static struct super_block *get_sb_single(struct file_system_type *fs_type, struct super_block *get_sb_single(struct file_system_type *fs_type,
int flags, char *dev_name, void *data) int flags, void *data,
int (*fill_super)(struct super_block *, void *, int))
{ {
int error;
struct super_block *s = get_anon_super(fs_type, compare_single, NULL); struct super_block *s = get_anon_super(fs_type, compare_single, NULL);
if (IS_ERR(s)) if (IS_ERR(s))
return s; return s;
if (!s->s_root) { if (!s->s_root) {
s->s_flags = flags; s->s_flags = flags;
if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) { error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
if (error) {
deactivate_super(s); deactivate_super(s);
remove_super(s); remove_super(s);
return ERR_PTR(-EINVAL); return ERR_PTR(error);
} }
s->s_flags |= MS_ACTIVE; s->s_flags |= MS_ACTIVE;
} }
...@@ -779,6 +787,27 @@ static struct super_block *get_sb_single(struct file_system_type *fs_type, ...@@ -779,6 +787,27 @@ static struct super_block *get_sb_single(struct file_system_type *fs_type,
return s; return s;
} }
/* Will go away */
static int fill_super(struct super_block *sb, void *data, int verbose)
{
return sb->s_type->read_super(sb, data, verbose) ? 0 : -EINVAL;
}
static struct super_block *__get_sb_bdev(struct file_system_type *fs_type,
int flags, char *dev_name, void * data)
{
return get_sb_bdev(fs_type, flags, dev_name, data, fill_super);
}
static struct super_block *__get_sb_nodev(struct file_system_type *fs_type,
int flags, char *dev_name, void * data)
{
return get_sb_nodev(fs_type, flags, data, fill_super);
}
static struct super_block *__get_sb_single(struct file_system_type *fs_type,
int flags, char *dev_name, void * data)
{
return get_sb_nodev(fs_type, flags, data, fill_super);
}
struct vfsmount * struct vfsmount *
do_kern_mount(const char *fstype, int flags, char *name, void *data) do_kern_mount(const char *fstype, int flags, char *name, void *data)
{ {
...@@ -795,11 +824,11 @@ do_kern_mount(const char *fstype, int flags, char *name, void *data) ...@@ -795,11 +824,11 @@ do_kern_mount(const char *fstype, int flags, char *name, void *data)
if (type->get_sb) if (type->get_sb)
sb = type->get_sb(type, flags, name, data); sb = type->get_sb(type, flags, name, data);
else if (type->fs_flags & FS_REQUIRES_DEV) else if (type->fs_flags & FS_REQUIRES_DEV)
sb = get_sb_bdev(type, flags, name, data); sb = __get_sb_bdev(type, flags, name, data);
else if (type->fs_flags & FS_SINGLE) else if (type->fs_flags & FS_SINGLE)
sb = get_sb_single(type, flags, name, data); sb = __get_sb_single(type, flags, name, data);
else else
sb = get_sb_nodev(type, flags, name, data); sb = __get_sb_nodev(type, flags, name, data);
if (IS_ERR(sb)) if (IS_ERR(sb))
goto out_mnt; goto out_mnt;
if (type->fs_flags & FS_NOMOUNT) if (type->fs_flags & FS_NOMOUNT)
......
...@@ -946,6 +946,16 @@ struct file_system_type { ...@@ -946,6 +946,16 @@ struct file_system_type {
struct list_head fs_supers; struct list_head fs_supers;
}; };
struct super_block *get_sb_bdev(struct file_system_type *fs_type,
int flags, char *dev_name, void * data,
int (*fill_super)(struct super_block *, void *, int));
struct super_block *get_sb_single(struct file_system_type *fs_type,
int flags, void *data,
int (*fill_super)(struct super_block *, void *, int));
struct super_block *get_sb_nodev(struct file_system_type *fs_type,
int flags, void *data,
int (*fill_super)(struct super_block *, void *, int));
#define DECLARE_FSTYPE(var,type,read,flags) \ #define DECLARE_FSTYPE(var,type,read,flags) \
struct file_system_type var = { \ struct file_system_type var = { \
name: type, \ name: type, \
......
...@@ -275,6 +275,9 @@ EXPORT_SYMBOL(lock_may_write); ...@@ -275,6 +275,9 @@ EXPORT_SYMBOL(lock_may_write);
EXPORT_SYMBOL(dcache_readdir); EXPORT_SYMBOL(dcache_readdir);
EXPORT_SYMBOL(fd_install); EXPORT_SYMBOL(fd_install);
EXPORT_SYMBOL(put_unused_fd); EXPORT_SYMBOL(put_unused_fd);
EXPORT_SYMBOL(get_sb_bdev);
EXPORT_SYMBOL(get_sb_nodev);
EXPORT_SYMBOL(get_sb_single);
/* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */ /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */
EXPORT_SYMBOL(default_llseek); EXPORT_SYMBOL(default_llseek);
......
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