aboutsummaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/super.c')
-rw-r--r--fs/super.c96
1 files changed, 16 insertions, 80 deletions
diff --git a/fs/super.c b/fs/super.c
index 4bae0ef6110..e8486490826 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -910,29 +910,18 @@ struct dentry *mount_single(struct file_system_type *fs_type,
910} 910}
911EXPORT_SYMBOL(mount_single); 911EXPORT_SYMBOL(mount_single);
912 912
913struct vfsmount * 913struct dentry *
914vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) 914mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
915{ 915{
916 struct vfsmount *mnt;
917 struct dentry *root; 916 struct dentry *root;
917 struct super_block *sb;
918 char *secdata = NULL; 918 char *secdata = NULL;
919 int error; 919 int error = -ENOMEM;
920
921 if (!type)
922 return ERR_PTR(-ENODEV);
923
924 error = -ENOMEM;
925 mnt = alloc_vfsmnt(name);
926 if (!mnt)
927 goto out;
928
929 if (flags & MS_KERNMOUNT)
930 mnt->mnt_flags = MNT_INTERNAL;
931 920
932 if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { 921 if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) {
933 secdata = alloc_secdata(); 922 secdata = alloc_secdata();
934 if (!secdata) 923 if (!secdata)
935 goto out_mnt; 924 goto out;
936 925
937 error = security_sb_copy_data(data, secdata); 926 error = security_sb_copy_data(data, secdata);
938 if (error) 927 if (error)
@@ -944,13 +933,12 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
944 error = PTR_ERR(root); 933 error = PTR_ERR(root);
945 goto out_free_secdata; 934 goto out_free_secdata;
946 } 935 }
947 mnt->mnt_root = root; 936 sb = root->d_sb;
948 mnt->mnt_sb = root->d_sb; 937 BUG_ON(!sb);
949 BUG_ON(!mnt->mnt_sb); 938 WARN_ON(!sb->s_bdi);
950 WARN_ON(!mnt->mnt_sb->s_bdi); 939 sb->s_flags |= MS_BORN;
951 mnt->mnt_sb->s_flags |= MS_BORN;
952 940
953 error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata); 941 error = security_sb_kern_mount(sb, flags, secdata);
954 if (error) 942 if (error)
955 goto out_sb; 943 goto out_sb;
956 944
@@ -961,27 +949,21 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
961 * violate this rule. This warning should be either removed or 949 * violate this rule. This warning should be either removed or
962 * converted to a BUG() in 2.6.34. 950 * converted to a BUG() in 2.6.34.
963 */ 951 */
964 WARN((mnt->mnt_sb->s_maxbytes < 0), "%s set sb->s_maxbytes to " 952 WARN((sb->s_maxbytes < 0), "%s set sb->s_maxbytes to "
965 "negative value (%lld)\n", type->name, mnt->mnt_sb->s_maxbytes); 953 "negative value (%lld)\n", type->name, sb->s_maxbytes);
966 954
967 mnt->mnt_mountpoint = mnt->mnt_root; 955 up_write(&sb->s_umount);
968 mnt->mnt_parent = mnt;
969 up_write(&mnt->mnt_sb->s_umount);
970 free_secdata(secdata); 956 free_secdata(secdata);
971 return mnt; 957 return root;
972out_sb: 958out_sb:
973 dput(mnt->mnt_root); 959 dput(root);
974 deactivate_locked_super(mnt->mnt_sb); 960 deactivate_locked_super(sb);
975out_free_secdata: 961out_free_secdata:
976 free_secdata(secdata); 962 free_secdata(secdata);
977out_mnt:
978 free_vfsmnt(mnt);
979out: 963out:
980 return ERR_PTR(error); 964 return ERR_PTR(error);
981} 965}
982 966
983EXPORT_SYMBOL_GPL(vfs_kern_mount);
984
985/** 967/**
986 * freeze_super - lock the filesystem and force it into a consistent state 968 * freeze_super - lock the filesystem and force it into a consistent state
987 * @sb: the super to lock 969 * @sb: the super to lock
@@ -1071,49 +1053,3 @@ out:
1071 return 0; 1053 return 0;
1072} 1054}
1073EXPORT_SYMBOL(thaw_super); 1055EXPORT_SYMBOL(thaw_super);
1074
1075static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype)
1076{
1077 int err;
1078 const char *subtype = strchr(fstype, '.');
1079 if (subtype) {
1080 subtype++;
1081 err = -EINVAL;
1082 if (!subtype[0])
1083 goto err;
1084 } else
1085 subtype = "";
1086
1087 mnt->mnt_sb->s_subtype = kstrdup(subtype, GFP_KERNEL);
1088 err = -ENOMEM;
1089 if (!mnt->mnt_sb->s_subtype)
1090 goto err;
1091 return mnt;
1092
1093 err:
1094 mntput(mnt);
1095 return ERR_PTR(err);
1096}
1097
1098struct vfsmount *
1099do_kern_mount(const char *fstype, int flags, const char *name, void *data)
1100{
1101 struct file_system_type *type = get_fs_type(fstype);
1102 struct vfsmount *mnt;
1103 if (!type)
1104 return ERR_PTR(-ENODEV);
1105 mnt = vfs_kern_mount(type, flags, name, data);
1106 if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) &&
1107 !mnt->mnt_sb->s_subtype)
1108 mnt = fs_set_subtype(mnt, fstype);
1109 put_filesystem(type);
1110 return mnt;
1111}
1112EXPORT_SYMBOL_GPL(do_kern_mount);
1113
1114struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
1115{
1116 return vfs_kern_mount(type, MS_KERNMOUNT, type->name, data);
1117}
1118
1119EXPORT_SYMBOL_GPL(kern_mount_data);