Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

do_nfs4_mount(): switch to vfs_parse_fs_string()

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 57e62089 b28f9eba

+11 -33
+11 -33
fs/nfs/nfs4super.c
··· 149 149 struct fs_context *root_fc; 150 150 struct vfsmount *root_mnt; 151 151 struct dentry *dentry; 152 - size_t len; 152 + char *source; 153 153 int ret; 154 - 155 - struct fs_parameter param = { 156 - .key = "source", 157 - .type = fs_value_is_string, 158 - .dirfd = -1, 159 - }; 160 - 161 - struct fs_parameter param_fsc = { 162 - .key = "fsc", 163 - .type = fs_value_is_string, 164 - .dirfd = -1, 165 - }; 166 154 167 155 if (IS_ERR(server)) 168 156 return PTR_ERR(server); ··· 169 181 root_ctx->server = server; 170 182 171 183 if (ctx->fscache_uniq) { 172 - len = strlen(ctx->fscache_uniq); 173 - param_fsc.size = len; 174 - param_fsc.string = kmemdup_nul(ctx->fscache_uniq, len, GFP_KERNEL); 175 - if (param_fsc.string == NULL) { 176 - put_fs_context(root_fc); 177 - return -ENOMEM; 178 - } 179 - ret = vfs_parse_fs_param(root_fc, &param_fsc); 180 - kfree(param_fsc.string); 184 + ret = vfs_parse_fs_string(root_fc, "fsc", ctx->fscache_uniq); 181 185 if (ret < 0) { 182 186 put_fs_context(root_fc); 183 187 return ret; ··· 177 197 } 178 198 /* We leave export_path unset as it's not used to find the root. */ 179 199 180 - len = strlen(hostname) + 5; 181 - param.string = kmalloc(len, GFP_KERNEL); 182 - if (param.string == NULL) { 200 + /* Does hostname needs to be enclosed in brackets? */ 201 + if (strchr(hostname, ':')) 202 + source = kasprintf(GFP_KERNEL, "[%s]:/", hostname); 203 + else 204 + source = kasprintf(GFP_KERNEL, "%s:/", hostname); 205 + 206 + if (!source) { 183 207 put_fs_context(root_fc); 184 208 return -ENOMEM; 185 209 } 186 - 187 - /* Does hostname needs to be enclosed in brackets? */ 188 - if (strchr(hostname, ':')) 189 - param.size = snprintf(param.string, len, "[%s]:/", hostname); 190 - else 191 - param.size = snprintf(param.string, len, "%s:/", hostname); 192 - ret = vfs_parse_fs_param(root_fc, &param); 193 - kfree(param.string); 210 + ret = vfs_parse_fs_string(root_fc, "source", source); 211 + kfree(source); 194 212 if (ret < 0) { 195 213 put_fs_context(root_fc); 196 214 return ret;