diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-09-08 19:49:57 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-09-08 19:49:57 -0400 |
commit | 7630c852e19c7fffb85b50d98eeb5516fec7c088 (patch) | |
tree | cc22b94697a175eccf9b0f090854d93e9cf8de38 /fs/nfs | |
parent | 4cfd74fc99a41fdc161f243e1c16199656d33ab1 (diff) |
NFS: Refactor NFSv4 text-based mount option validation
Clean up: Refactor the part of nfs4_validate_mount_options() that
handles text-based options, so we can call it from the NFSv2/v3
option validation function.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/super.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 05544336f7de..599e8c5fe6ce 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -272,6 +272,8 @@ static const struct super_operations nfs_sops = { | |||
272 | }; | 272 | }; |
273 | 273 | ||
274 | #ifdef CONFIG_NFS_V4 | 274 | #ifdef CONFIG_NFS_V4 |
275 | static int nfs4_validate_text_mount_data(void *options, | ||
276 | struct nfs_parsed_mount_data *args, const char *dev_name); | ||
275 | static int nfs4_get_sb(struct file_system_type *fs_type, | 277 | static int nfs4_get_sb(struct file_system_type *fs_type, |
276 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 278 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
277 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, | 279 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, |
@@ -2262,6 +2264,37 @@ static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args) | |||
2262 | args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3); | 2264 | args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3); |
2263 | } | 2265 | } |
2264 | 2266 | ||
2267 | static int nfs4_validate_text_mount_data(void *options, | ||
2268 | struct nfs_parsed_mount_data *args, | ||
2269 | const char *dev_name) | ||
2270 | { | ||
2271 | struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; | ||
2272 | |||
2273 | nfs_set_default_port(sap, args->nfs_server.port, NFS_PORT); | ||
2274 | |||
2275 | nfs_validate_transport_protocol(args); | ||
2276 | |||
2277 | nfs4_validate_mount_flags(args); | ||
2278 | |||
2279 | if (args->auth_flavor_len > 1) { | ||
2280 | dfprintk(MOUNT, | ||
2281 | "NFS4: Too many RPC auth flavours specified\n"); | ||
2282 | return -EINVAL; | ||
2283 | } | ||
2284 | |||
2285 | if (args->client_address == NULL) { | ||
2286 | dfprintk(MOUNT, | ||
2287 | "NFS4: mount program didn't pass callback address\n"); | ||
2288 | return -EINVAL; | ||
2289 | } | ||
2290 | |||
2291 | return nfs_parse_devname(dev_name, | ||
2292 | &args->nfs_server.hostname, | ||
2293 | NFS4_MAXNAMLEN, | ||
2294 | &args->nfs_server.export_path, | ||
2295 | NFS4_MAXPATHLEN); | ||
2296 | } | ||
2297 | |||
2265 | /* | 2298 | /* |
2266 | * Validate NFSv4 mount options | 2299 | * Validate NFSv4 mount options |
2267 | */ | 2300 | */ |
@@ -2342,36 +2375,14 @@ static int nfs4_validate_mount_data(void *options, | |||
2342 | nfs_validate_transport_protocol(args); | 2375 | nfs_validate_transport_protocol(args); |
2343 | 2376 | ||
2344 | break; | 2377 | break; |
2345 | default: { | 2378 | default: |
2346 | int status; | ||
2347 | |||
2348 | if (nfs_parse_mount_options((char *)options, args) == 0) | 2379 | if (nfs_parse_mount_options((char *)options, args) == 0) |
2349 | return -EINVAL; | 2380 | return -EINVAL; |
2350 | 2381 | ||
2351 | if (!nfs_verify_server_address(sap)) | 2382 | if (!nfs_verify_server_address(sap)) |
2352 | return -EINVAL; | 2383 | return -EINVAL; |
2353 | nfs_set_default_port(sap, args->nfs_server.port, NFS_PORT); | ||
2354 | |||
2355 | nfs_validate_transport_protocol(args); | ||
2356 | |||
2357 | nfs4_validate_mount_flags(args); | ||
2358 | |||
2359 | if (args->auth_flavor_len > 1) | ||
2360 | goto out_inval_auth; | ||
2361 | |||
2362 | if (args->client_address == NULL) | ||
2363 | goto out_no_client_address; | ||
2364 | |||
2365 | status = nfs_parse_devname(dev_name, | ||
2366 | &args->nfs_server.hostname, | ||
2367 | NFS4_MAXNAMLEN, | ||
2368 | &args->nfs_server.export_path, | ||
2369 | NFS4_MAXPATHLEN); | ||
2370 | if (status < 0) | ||
2371 | return status; | ||
2372 | 2384 | ||
2373 | break; | 2385 | return nfs4_validate_text_mount_data(options, args, dev_name); |
2374 | } | ||
2375 | } | 2386 | } |
2376 | 2387 | ||
2377 | return 0; | 2388 | return 0; |
@@ -2388,10 +2399,6 @@ out_inval_auth: | |||
2388 | out_no_address: | 2399 | out_no_address: |
2389 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); | 2400 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); |
2390 | return -EINVAL; | 2401 | return -EINVAL; |
2391 | |||
2392 | out_no_client_address: | ||
2393 | dfprintk(MOUNT, "NFS4: mount program didn't pass callback address\n"); | ||
2394 | return -EINVAL; | ||
2395 | } | 2402 | } |
2396 | 2403 | ||
2397 | /* | 2404 | /* |