diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-17 22:08:28 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-17 22:10:41 -0400 |
commit | 9d412a43c3b26e1e549319e5eec26f0829f9f74d (patch) | |
tree | b6522b693564fed172e9f8aee2e42aa2fdd95c8a /fs/super.c | |
parent | fbe0aa1f3d16fac5b641c0c1697371dcbe45b569 (diff) | |
download | linux-stable-9d412a43c3b26e1e549319e5eec26f0829f9f74d.tar.gz linux-stable-9d412a43c3b26e1e549319e5eec26f0829f9f74d.tar.bz2 linux-stable-9d412a43c3b26e1e549319e5eec26f0829f9f74d.zip |
vfs: split off vfsmount-related parts of vfs_kern_mount()
new function: mount_fs(). Does all work done by vfs_kern_mount()
except the allocation and filling of vfsmount; returns root dentry
or ERR_PTR().
vfs_kern_mount() switched to using it and taken to fs/namespace.c,
along with its wrappers.
alloc_vfsmnt()/free_vfsmnt() made static.
functions in namespace.c slightly reordered.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 96 |
1 files changed, 16 insertions, 80 deletions
diff --git a/fs/super.c b/fs/super.c index 4bae0ef6110e..e84864908264 100644 --- a/fs/super.c +++ b/fs/super.c @@ -910,29 +910,18 @@ struct dentry *mount_single(struct file_system_type *fs_type, } EXPORT_SYMBOL(mount_single); -struct vfsmount * -vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) +struct dentry * +mount_fs(struct file_system_type *type, int flags, const char *name, void *data) { - struct vfsmount *mnt; struct dentry *root; + struct super_block *sb; char *secdata = NULL; - int error; - - if (!type) - return ERR_PTR(-ENODEV); - - error = -ENOMEM; - mnt = alloc_vfsmnt(name); - if (!mnt) - goto out; - - if (flags & MS_KERNMOUNT) - mnt->mnt_flags = MNT_INTERNAL; + int error = -ENOMEM; if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { secdata = alloc_secdata(); if (!secdata) - goto out_mnt; + goto out; error = security_sb_copy_data(data, secdata); if (error) @@ -944,13 +933,12 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void error = PTR_ERR(root); goto out_free_secdata; } - mnt->mnt_root = root; - mnt->mnt_sb = root->d_sb; - BUG_ON(!mnt->mnt_sb); - WARN_ON(!mnt->mnt_sb->s_bdi); - mnt->mnt_sb->s_flags |= MS_BORN; + sb = root->d_sb; + BUG_ON(!sb); + WARN_ON(!sb->s_bdi); + sb->s_flags |= MS_BORN; - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata); + error = security_sb_kern_mount(sb, flags, secdata); if (error) goto out_sb; @@ -961,27 +949,21 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void * violate this rule. This warning should be either removed or * converted to a BUG() in 2.6.34. */ - WARN((mnt->mnt_sb->s_maxbytes < 0), "%s set sb->s_maxbytes to " - "negative value (%lld)\n", type->name, mnt->mnt_sb->s_maxbytes); + WARN((sb->s_maxbytes < 0), "%s set sb->s_maxbytes to " + "negative value (%lld)\n", type->name, sb->s_maxbytes); - mnt->mnt_mountpoint = mnt->mnt_root; - mnt->mnt_parent = mnt; - up_write(&mnt->mnt_sb->s_umount); + up_write(&sb->s_umount); free_secdata(secdata); - return mnt; + return root; out_sb: - dput(mnt->mnt_root); - deactivate_locked_super(mnt->mnt_sb); + dput(root); + deactivate_locked_super(sb); out_free_secdata: free_secdata(secdata); -out_mnt: - free_vfsmnt(mnt); out: return ERR_PTR(error); } -EXPORT_SYMBOL_GPL(vfs_kern_mount); - /** * freeze_super - lock the filesystem and force it into a consistent state * @sb: the super to lock @@ -1071,49 +1053,3 @@ out: return 0; } EXPORT_SYMBOL(thaw_super); - -static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype) -{ - int err; - const char *subtype = strchr(fstype, '.'); - if (subtype) { - subtype++; - err = -EINVAL; - if (!subtype[0]) - goto err; - } else - subtype = ""; - - mnt->mnt_sb->s_subtype = kstrdup(subtype, GFP_KERNEL); - err = -ENOMEM; - if (!mnt->mnt_sb->s_subtype) - goto err; - return mnt; - - err: - mntput(mnt); - return ERR_PTR(err); -} - -struct vfsmount * -do_kern_mount(const char *fstype, int flags, const char *name, void *data) -{ - struct file_system_type *type = get_fs_type(fstype); - struct vfsmount *mnt; - if (!type) - return ERR_PTR(-ENODEV); - mnt = vfs_kern_mount(type, flags, name, data); - if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) && - !mnt->mnt_sb->s_subtype) - mnt = fs_set_subtype(mnt, fstype); - put_filesystem(type); - return mnt; -} -EXPORT_SYMBOL_GPL(do_kern_mount); - -struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) -{ - return vfs_kern_mount(type, MS_KERNMOUNT, type->name, data); -} - -EXPORT_SYMBOL_GPL(kern_mount_data); |