Commit 7d945a3a authored by Al Viro's avatar Al Viro

logfs get_sb, part 3

take logfs_get_sb_device() calls to logfs_get_sb() itself
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 0d85c799
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/slab.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1)) #define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1))
...@@ -321,27 +320,23 @@ static const struct logfs_device_ops bd_devops = { ...@@ -321,27 +320,23 @@ static const struct logfs_device_ops bd_devops = {
.put_device = bdev_put_device, .put_device = bdev_put_device,
}; };
int logfs_get_sb_bdev(struct logfs_super *p, int logfs_get_sb_bdev(struct logfs_super *p, struct file_system_type *type,
struct file_system_type *type, int flags, const char *devname)
const char *devname, struct vfsmount *mnt)
{ {
struct block_device *bdev; struct block_device *bdev;
bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, type); bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, type);
if (IS_ERR(bdev)) { if (IS_ERR(bdev))
kfree(p);
return PTR_ERR(bdev); return PTR_ERR(bdev);
}
if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
int mtdnr = MINOR(bdev->bd_dev); int mtdnr = MINOR(bdev->bd_dev);
close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE); close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE);
return logfs_get_sb_mtd(p, type, flags, mtdnr, mnt); return logfs_get_sb_mtd(p, mtdnr);
} }
p->s_bdev = bdev; p->s_bdev = bdev;
p->s_mtd = NULL; p->s_mtd = NULL;
p->s_devops = &bd_devops; p->s_devops = &bd_devops;
return 0;
return logfs_get_sb_device(p, type, flags, mnt);
} }
...@@ -265,18 +265,14 @@ static const struct logfs_device_ops mtd_devops = { ...@@ -265,18 +265,14 @@ static const struct logfs_device_ops mtd_devops = {
.put_device = mtd_put_device, .put_device = mtd_put_device,
}; };
int logfs_get_sb_mtd(struct logfs_super *s, int logfs_get_sb_mtd(struct logfs_super *s, int mtdnr)
struct file_system_type *type, int flags,
int mtdnr, struct vfsmount *mnt)
{ {
struct mtd_info *mtd = get_mtd_device(NULL, mtdnr); struct mtd_info *mtd = get_mtd_device(NULL, mtdnr);
if (IS_ERR(mtd)) { if (IS_ERR(mtd))
kfree(s);
return PTR_ERR(mtd); return PTR_ERR(mtd);
}
s->s_bdev = NULL; s->s_bdev = NULL;
s->s_mtd = mtd; s->s_mtd = mtd;
s->s_devops = &mtd_devops; s->s_devops = &mtd_devops;
return logfs_get_sb_device(s, type, flags, mnt); return 0;
} }
...@@ -472,29 +472,23 @@ void logfs_compr_exit(void); ...@@ -472,29 +472,23 @@ void logfs_compr_exit(void);
/* dev_bdev.c */ /* dev_bdev.c */
#ifdef CONFIG_BLOCK #ifdef CONFIG_BLOCK
int logfs_get_sb_bdev(struct logfs_super *s, int logfs_get_sb_bdev(struct logfs_super *s,
struct file_system_type *type, int flags, struct file_system_type *type,
const char *devname, struct vfsmount *mnt); const char *devname);
#else #else
static inline int logfs_get_sb_bdev(struct logfs_super *s, static inline int logfs_get_sb_bdev(struct logfs_super *s,
struct file_system_type *type, int flags, struct file_system_type *type,
const char *devname, struct vfsmount *mnt) const char *devname)
{ {
kfree(s);
return -ENODEV; return -ENODEV;
} }
#endif #endif
/* dev_mtd.c */ /* dev_mtd.c */
#ifdef CONFIG_MTD #ifdef CONFIG_MTD
int logfs_get_sb_mtd(struct logfs_super *s, int logfs_get_sb_mtd(struct logfs_super *s, int mtdnr)
struct file_system_type *type, int flags,
int mtdnr, struct vfsmount *mnt);
#else #else
static inline int logfs_get_sb_mtd(struct logfs_super *s, static inline int logfs_get_sb_mtd(struct logfs_super *s, int mtdnr)
struct file_system_type *type, int flags,
int mtdnr, struct vfsmount *mnt)
{ {
kfree(s);
return -ENODEV; return -ENODEV;
} }
#endif #endif
......
...@@ -596,26 +596,31 @@ static int logfs_get_sb(struct file_system_type *type, int flags, ...@@ -596,26 +596,31 @@ static int logfs_get_sb(struct file_system_type *type, int flags,
{ {
ulong mtdnr; ulong mtdnr;
struct logfs_super *super; struct logfs_super *super;
int err;
super = kzalloc(sizeof(*super), GFP_KERNEL); super = kzalloc(sizeof(*super), GFP_KERNEL);
if (!super) if (!super)
return -ENOMEM; return -ENOMEM;
if (!devname) if (!devname)
return logfs_get_sb_bdev(super, type, flags, devname, mnt); err = logfs_get_sb_bdev(super, type, devname);
if (strncmp(devname, "mtd", 3)) else if (strncmp(devname, "mtd", 3))
return logfs_get_sb_bdev(super, type, flags, devname, mnt); err = logfs_get_sb_bdev(super, type, devname);
else {
{
char *garbage; char *garbage;
mtdnr = simple_strtoul(devname+3, &garbage, 0); mtdnr = simple_strtoul(devname+3, &garbage, 0);
if (*garbage) { if (*garbage)
kfree(super); err = -EINVAL;
return -EINVAL; else
} err = logfs_get_sb_mtd(super, mtdnr);
}
if (err) {
kfree(super);
return err;
} }
return logfs_get_sb_mtd(super, type, flags, mtdnr, mnt); return logfs_get_sb_device(super, type, flags, mnt);
} }
static struct file_system_type logfs_fs_type = { static struct file_system_type logfs_fs_type = {
......
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