mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
freevxfs: Convert freevxfs to the new mount API.
Convert the freevxfs filesystem to the new mount API. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Link: https://lore.kernel.org/r/b0d1a423-4b8e-4bc1-a021-a1078aee915f@redhat.com Tested-by: Krzysztof Błaszkowski <kb@sysmikro.com.pl> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
491681d44b
commit
b01e1a6359
@ -17,7 +17,7 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/stat.h>
|
#include <linux/stat.h>
|
||||||
#include <linux/vfs.h>
|
#include <linux/vfs.h>
|
||||||
#include <linux/mount.h>
|
#include <linux/fs_context.h>
|
||||||
|
|
||||||
#include "vxfs.h"
|
#include "vxfs.h"
|
||||||
#include "vxfs_extern.h"
|
#include "vxfs_extern.h"
|
||||||
@ -91,10 +91,10 @@ vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vxfs_remount(struct super_block *sb, int *flags, char *data)
|
static int vxfs_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,24 +120,24 @@ static const struct super_operations vxfs_super_ops = {
|
|||||||
.evict_inode = vxfs_evict_inode,
|
.evict_inode = vxfs_evict_inode,
|
||||||
.put_super = vxfs_put_super,
|
.put_super = vxfs_put_super,
|
||||||
.statfs = vxfs_statfs,
|
.statfs = vxfs_statfs,
|
||||||
.remount_fs = vxfs_remount,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
|
static int vxfs_try_sb_magic(struct super_block *sbp, struct fs_context *fc,
|
||||||
unsigned blk, __fs32 magic)
|
unsigned blk, __fs32 magic)
|
||||||
{
|
{
|
||||||
struct buffer_head *bp;
|
struct buffer_head *bp;
|
||||||
struct vxfs_sb *rsbp;
|
struct vxfs_sb *rsbp;
|
||||||
struct vxfs_sb_info *infp = VXFS_SBI(sbp);
|
struct vxfs_sb_info *infp = VXFS_SBI(sbp);
|
||||||
|
int silent = fc->sb_flags & SB_SILENT;
|
||||||
int rc = -ENOMEM;
|
int rc = -ENOMEM;
|
||||||
|
|
||||||
bp = sb_bread(sbp, blk);
|
bp = sb_bread(sbp, blk);
|
||||||
do {
|
do {
|
||||||
if (!bp || !buffer_mapped(bp)) {
|
if (!bp || !buffer_mapped(bp)) {
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
printk(KERN_WARNING
|
warnf(fc,
|
||||||
"vxfs: unable to read disk superblock at %u\n",
|
"vxfs: unable to read disk superblock at %u",
|
||||||
blk);
|
blk);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -146,9 +146,9 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
|
|||||||
rsbp = (struct vxfs_sb *)bp->b_data;
|
rsbp = (struct vxfs_sb *)bp->b_data;
|
||||||
if (rsbp->vs_magic != magic) {
|
if (rsbp->vs_magic != magic) {
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printk(KERN_NOTICE
|
infof(fc,
|
||||||
"vxfs: WRONG superblock magic %08x at %u\n",
|
"vxfs: WRONG superblock magic %08x at %u",
|
||||||
rsbp->vs_magic, blk);
|
rsbp->vs_magic, blk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,8 +169,7 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
|
|||||||
/**
|
/**
|
||||||
* vxfs_fill_super - read superblock into memory and initialize filesystem
|
* vxfs_fill_super - read superblock into memory and initialize filesystem
|
||||||
* @sbp: VFS superblock (to fill)
|
* @sbp: VFS superblock (to fill)
|
||||||
* @dp: fs private mount data
|
* @fc: filesytem context
|
||||||
* @silent: do not complain loudly when sth is wrong
|
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* We are called on the first mount of a filesystem to read the
|
* We are called on the first mount of a filesystem to read the
|
||||||
@ -182,26 +181,27 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
|
|||||||
* Locking:
|
* Locking:
|
||||||
* We are under @sbp->s_lock.
|
* We are under @sbp->s_lock.
|
||||||
*/
|
*/
|
||||||
static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
|
static int vxfs_fill_super(struct super_block *sbp, struct fs_context *fc)
|
||||||
{
|
{
|
||||||
struct vxfs_sb_info *infp;
|
struct vxfs_sb_info *infp;
|
||||||
struct vxfs_sb *rsbp;
|
struct vxfs_sb *rsbp;
|
||||||
u_long bsize;
|
u_long bsize;
|
||||||
struct inode *root;
|
struct inode *root;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
int silent = fc->sb_flags & SB_SILENT;
|
||||||
u32 j;
|
u32 j;
|
||||||
|
|
||||||
sbp->s_flags |= SB_RDONLY;
|
sbp->s_flags |= SB_RDONLY;
|
||||||
|
|
||||||
infp = kzalloc(sizeof(*infp), GFP_KERNEL);
|
infp = kzalloc(sizeof(*infp), GFP_KERNEL);
|
||||||
if (!infp) {
|
if (!infp) {
|
||||||
printk(KERN_WARNING "vxfs: unable to allocate incore superblock\n");
|
warnf(fc, "vxfs: unable to allocate incore superblock");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
bsize = sb_min_blocksize(sbp, BLOCK_SIZE);
|
bsize = sb_min_blocksize(sbp, BLOCK_SIZE);
|
||||||
if (!bsize) {
|
if (!bsize) {
|
||||||
printk(KERN_WARNING "vxfs: unable to set blocksize\n");
|
warnf(fc, "vxfs: unable to set blocksize");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,24 +210,24 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
|
|||||||
sbp->s_time_min = 0;
|
sbp->s_time_min = 0;
|
||||||
sbp->s_time_max = U32_MAX;
|
sbp->s_time_max = U32_MAX;
|
||||||
|
|
||||||
if (!vxfs_try_sb_magic(sbp, silent, 1,
|
if (!vxfs_try_sb_magic(sbp, fc, 1,
|
||||||
(__force __fs32)cpu_to_le32(VXFS_SUPER_MAGIC))) {
|
(__force __fs32)cpu_to_le32(VXFS_SUPER_MAGIC))) {
|
||||||
/* Unixware, x86 */
|
/* Unixware, x86 */
|
||||||
infp->byte_order = VXFS_BO_LE;
|
infp->byte_order = VXFS_BO_LE;
|
||||||
} else if (!vxfs_try_sb_magic(sbp, silent, 8,
|
} else if (!vxfs_try_sb_magic(sbp, fc, 8,
|
||||||
(__force __fs32)cpu_to_be32(VXFS_SUPER_MAGIC))) {
|
(__force __fs32)cpu_to_be32(VXFS_SUPER_MAGIC))) {
|
||||||
/* HP-UX, parisc */
|
/* HP-UX, parisc */
|
||||||
infp->byte_order = VXFS_BO_BE;
|
infp->byte_order = VXFS_BO_BE;
|
||||||
} else {
|
} else {
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printk(KERN_NOTICE "vxfs: can't find superblock.\n");
|
infof(fc, "vxfs: can't find superblock.");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsbp = infp->vsi_raw;
|
rsbp = infp->vsi_raw;
|
||||||
j = fs32_to_cpu(infp, rsbp->vs_version);
|
j = fs32_to_cpu(infp, rsbp->vs_version);
|
||||||
if ((j < 2 || j > 4) && !silent) {
|
if ((j < 2 || j > 4) && !silent) {
|
||||||
printk(KERN_NOTICE "vxfs: unsupported VxFS version (%d)\n", j);
|
infof(fc, "vxfs: unsupported VxFS version (%d)", j);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,17 +244,17 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
|
|||||||
|
|
||||||
j = fs32_to_cpu(infp, rsbp->vs_bsize);
|
j = fs32_to_cpu(infp, rsbp->vs_bsize);
|
||||||
if (!sb_set_blocksize(sbp, j)) {
|
if (!sb_set_blocksize(sbp, j)) {
|
||||||
printk(KERN_WARNING "vxfs: unable to set final block size\n");
|
warnf(fc, "vxfs: unable to set final block size");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vxfs_read_olt(sbp, bsize)) {
|
if (vxfs_read_olt(sbp, bsize)) {
|
||||||
printk(KERN_WARNING "vxfs: unable to read olt\n");
|
warnf(fc, "vxfs: unable to read olt");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vxfs_read_fshead(sbp)) {
|
if (vxfs_read_fshead(sbp)) {
|
||||||
printk(KERN_WARNING "vxfs: unable to read fshead\n");
|
warnf(fc, "vxfs: unable to read fshead");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
|
|||||||
}
|
}
|
||||||
sbp->s_root = d_make_root(root);
|
sbp->s_root = d_make_root(root);
|
||||||
if (!sbp->s_root) {
|
if (!sbp->s_root) {
|
||||||
printk(KERN_WARNING "vxfs: unable to get root dentry.\n");
|
warnf(fc, "vxfs: unable to get root dentry.");
|
||||||
goto out_free_ilist;
|
goto out_free_ilist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,18 +284,29 @@ out:
|
|||||||
/*
|
/*
|
||||||
* The usual module blurb.
|
* The usual module blurb.
|
||||||
*/
|
*/
|
||||||
static struct dentry *vxfs_mount(struct file_system_type *fs_type,
|
static int vxfs_get_tree(struct fs_context *fc)
|
||||||
int flags, const char *dev_name, void *data)
|
|
||||||
{
|
{
|
||||||
return mount_bdev(fs_type, flags, dev_name, data, vxfs_fill_super);
|
return get_tree_bdev(fc, vxfs_fill_super);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct fs_context_operations vxfs_context_ops = {
|
||||||
|
.get_tree = vxfs_get_tree,
|
||||||
|
.reconfigure = vxfs_reconfigure,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int vxfs_init_fs_context(struct fs_context *fc)
|
||||||
|
{
|
||||||
|
fc->ops = &vxfs_context_ops;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct file_system_type vxfs_fs_type = {
|
static struct file_system_type vxfs_fs_type = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.name = "vxfs",
|
.name = "vxfs",
|
||||||
.mount = vxfs_mount,
|
|
||||||
.kill_sb = kill_block_super,
|
.kill_sb = kill_block_super,
|
||||||
.fs_flags = FS_REQUIRES_DEV,
|
.fs_flags = FS_REQUIRES_DEV,
|
||||||
|
.init_fs_context = vxfs_init_fs_context,
|
||||||
};
|
};
|
||||||
MODULE_ALIAS_FS("vxfs"); /* makes mount -t vxfs autoload the module */
|
MODULE_ALIAS_FS("vxfs"); /* makes mount -t vxfs autoload the module */
|
||||||
MODULE_ALIAS("vxfs");
|
MODULE_ALIAS("vxfs");
|
||||||
|
Loading…
Reference in New Issue
Block a user