mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 15:11:16 +00:00
vfs: Use sget_fc() for pseudo-filesystems
Signed-off-by: David Howells <dhowells@redhat.com> cc: linux-fsdevel@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
8d9e46d807
commit
db2c246a09
1 changed files with 10 additions and 14 deletions
28
fs/libfs.c
28
fs/libfs.c
|
@ -237,17 +237,11 @@ static const struct super_operations simple_super_operations = {
|
||||||
.statfs = simple_statfs,
|
.statfs = simple_statfs,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pseudo_fs_get_tree(struct fs_context *fc)
|
static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
|
||||||
{
|
{
|
||||||
struct pseudo_fs_context *ctx = fc->fs_private;
|
struct pseudo_fs_context *ctx = fc->fs_private;
|
||||||
struct super_block *s;
|
|
||||||
struct inode *root;
|
struct inode *root;
|
||||||
|
|
||||||
s = sget_userns(fc->fs_type, NULL, set_anon_super, SB_KERNMOUNT|SB_NOUSER,
|
|
||||||
&init_user_ns, NULL);
|
|
||||||
if (IS_ERR(s))
|
|
||||||
return PTR_ERR(s);
|
|
||||||
|
|
||||||
s->s_maxbytes = MAX_LFS_FILESIZE;
|
s->s_maxbytes = MAX_LFS_FILESIZE;
|
||||||
s->s_blocksize = PAGE_SIZE;
|
s->s_blocksize = PAGE_SIZE;
|
||||||
s->s_blocksize_bits = PAGE_SHIFT;
|
s->s_blocksize_bits = PAGE_SHIFT;
|
||||||
|
@ -257,7 +251,8 @@ static int pseudo_fs_get_tree(struct fs_context *fc)
|
||||||
s->s_time_gran = 1;
|
s->s_time_gran = 1;
|
||||||
root = new_inode(s);
|
root = new_inode(s);
|
||||||
if (!root)
|
if (!root)
|
||||||
goto Enomem;
|
return -ENOMEM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* since this is the first inode, make it number 1. New inodes created
|
* since this is the first inode, make it number 1. New inodes created
|
||||||
* after this must take care not to collide with it (by passing
|
* after this must take care not to collide with it (by passing
|
||||||
|
@ -268,15 +263,14 @@ static int pseudo_fs_get_tree(struct fs_context *fc)
|
||||||
root->i_atime = root->i_mtime = root->i_ctime = current_time(root);
|
root->i_atime = root->i_mtime = root->i_ctime = current_time(root);
|
||||||
s->s_root = d_make_root(root);
|
s->s_root = d_make_root(root);
|
||||||
if (!s->s_root)
|
if (!s->s_root)
|
||||||
goto Enomem;
|
|
||||||
s->s_d_op = ctx->dops;
|
|
||||||
s->s_flags |= SB_ACTIVE;
|
|
||||||
fc->root = dget(s->s_root);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Enomem:
|
|
||||||
deactivate_locked_super(s);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
s->s_d_op = ctx->dops;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int pseudo_fs_get_tree(struct fs_context *fc)
|
||||||
|
{
|
||||||
|
return vfs_get_super(fc, vfs_get_independent_super, pseudo_fs_fill_super);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pseudo_fs_free(struct fs_context *fc)
|
static void pseudo_fs_free(struct fs_context *fc)
|
||||||
|
@ -303,6 +297,8 @@ struct pseudo_fs_context *init_pseudo(struct fs_context *fc,
|
||||||
ctx->magic = magic;
|
ctx->magic = magic;
|
||||||
fc->fs_private = ctx;
|
fc->fs_private = ctx;
|
||||||
fc->ops = &pseudo_fs_context_ops;
|
fc->ops = &pseudo_fs_context_ops;
|
||||||
|
fc->sb_flags |= SB_NOUSER;
|
||||||
|
fc->global = true;
|
||||||
}
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue