diff options
-rw-r--r-- | fs/nfs/internal.h | 13 | ||||
-rw-r--r-- | fs/nfs/mount_clnt.c | 30 | ||||
-rw-r--r-- | fs/nfs/nfsroot.c | 17 | ||||
-rw-r--r-- | fs/nfs/super.c | 29 |
4 files changed, 49 insertions, 40 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 7a38cc7b4137..4e983961346e 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -64,8 +64,17 @@ struct nfs_parsed_mount_data { | |||
64 | }; | 64 | }; |
65 | 65 | ||
66 | /* mount_clnt.c */ | 66 | /* mount_clnt.c */ |
67 | extern int nfs_mount(struct sockaddr *, size_t, char *, char *, | 67 | struct nfs_mount_request { |
68 | int, int, struct nfs_fh *); | 68 | struct sockaddr *sap; |
69 | size_t salen; | ||
70 | char *hostname; | ||
71 | char *dirpath; | ||
72 | u32 version; | ||
73 | unsigned short protocol; | ||
74 | struct nfs_fh *fh; | ||
75 | }; | ||
76 | |||
77 | extern int nfs_mount(struct nfs_mount_request *info); | ||
69 | 78 | ||
70 | /* client.c */ | 79 | /* client.c */ |
71 | extern struct rpc_program nfs_program; | 80 | extern struct rpc_program nfs_program; |
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index 086a6830d785..7e37113d37e3 100644 --- a/fs/nfs/mount_clnt.c +++ b/fs/nfs/mount_clnt.c | |||
@@ -29,33 +29,26 @@ struct mnt_fhstatus { | |||
29 | 29 | ||
30 | /** | 30 | /** |
31 | * nfs_mount - Obtain an NFS file handle for the given host and path | 31 | * nfs_mount - Obtain an NFS file handle for the given host and path |
32 | * @addr: pointer to server's address | 32 | * @info: pointer to mount request arguments |
33 | * @len: size of server's address | ||
34 | * @hostname: name of server host, or NULL | ||
35 | * @path: pointer to string containing export path to mount | ||
36 | * @version: mount version to use for this request | ||
37 | * @protocol: transport protocol to use for thie request | ||
38 | * @fh: pointer to location to place returned file handle | ||
39 | * | 33 | * |
40 | * Uses default timeout parameters specified by underlying transport. | 34 | * Uses default timeout parameters specified by underlying transport. |
41 | */ | 35 | */ |
42 | int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path, | 36 | int nfs_mount(struct nfs_mount_request *info) |
43 | int version, int protocol, struct nfs_fh *fh) | ||
44 | { | 37 | { |
45 | struct mnt_fhstatus result = { | 38 | struct mnt_fhstatus result = { |
46 | .fh = fh | 39 | .fh = info->fh |
47 | }; | 40 | }; |
48 | struct rpc_message msg = { | 41 | struct rpc_message msg = { |
49 | .rpc_argp = path, | 42 | .rpc_argp = info->dirpath, |
50 | .rpc_resp = &result, | 43 | .rpc_resp = &result, |
51 | }; | 44 | }; |
52 | struct rpc_create_args args = { | 45 | struct rpc_create_args args = { |
53 | .protocol = protocol, | 46 | .protocol = info->protocol, |
54 | .address = addr, | 47 | .address = info->sap, |
55 | .addrsize = len, | 48 | .addrsize = info->salen, |
56 | .servername = hostname, | 49 | .servername = info->hostname, |
57 | .program = &mnt_program, | 50 | .program = &mnt_program, |
58 | .version = version, | 51 | .version = info->version, |
59 | .authflavor = RPC_AUTH_UNIX, | 52 | .authflavor = RPC_AUTH_UNIX, |
60 | .flags = 0, | 53 | .flags = 0, |
61 | }; | 54 | }; |
@@ -63,13 +56,14 @@ int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path, | |||
63 | int status; | 56 | int status; |
64 | 57 | ||
65 | dprintk("NFS: sending MNT request for %s:%s\n", | 58 | dprintk("NFS: sending MNT request for %s:%s\n", |
66 | (hostname ? hostname : "server"), path); | 59 | (info->hostname ? info->hostname : "server"), |
60 | info->dirpath); | ||
67 | 61 | ||
68 | mnt_clnt = rpc_create(&args); | 62 | mnt_clnt = rpc_create(&args); |
69 | if (IS_ERR(mnt_clnt)) | 63 | if (IS_ERR(mnt_clnt)) |
70 | goto out_clnt_err; | 64 | goto out_clnt_err; |
71 | 65 | ||
72 | if (version == NFS_MNT3_VERSION) | 66 | if (info->version == NFS_MNT3_VERSION) |
73 | msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC3_MNT]; | 67 | msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC3_MNT]; |
74 | else | 68 | else |
75 | msg.rpc_proc = &mnt_clnt->cl_procinfo[MNTPROC_MNT]; | 69 | msg.rpc_proc = &mnt_clnt->cl_procinfo[MNTPROC_MNT]; |
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index a96e5fdb38af..f015e0d62add 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c | |||
@@ -487,15 +487,20 @@ static int __init root_nfs_get_handle(void) | |||
487 | { | 487 | { |
488 | struct nfs_fh fh; | 488 | struct nfs_fh fh; |
489 | struct sockaddr_in sin; | 489 | struct sockaddr_in sin; |
490 | struct nfs_mount_request request = { | ||
491 | .sap = (struct sockaddr *)&sin, | ||
492 | .salen = sizeof(sin), | ||
493 | .dirpath = nfs_export_path, | ||
494 | .version = (nfs_data.flags & NFS_MOUNT_VER3) ? | ||
495 | NFS_MNT3_VERSION : NFS_MNT_VERSION, | ||
496 | .protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? | ||
497 | XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP, | ||
498 | .fh = &fh, | ||
499 | }; | ||
490 | int status; | 500 | int status; |
491 | int protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? | ||
492 | XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP; | ||
493 | int version = (nfs_data.flags & NFS_MOUNT_VER3) ? | ||
494 | NFS_MNT3_VERSION : NFS_MNT_VERSION; | ||
495 | 501 | ||
496 | set_sockaddr(&sin, servaddr, htons(mount_port)); | 502 | set_sockaddr(&sin, servaddr, htons(mount_port)); |
497 | status = nfs_mount((struct sockaddr *) &sin, sizeof(sin), NULL, | 503 | status = nfs_mount(&request); |
498 | nfs_export_path, version, protocol, &fh); | ||
499 | if (status < 0) | 504 | if (status < 0) |
500 | printk(KERN_ERR "Root-NFS: Server returned error %d " | 505 | printk(KERN_ERR "Root-NFS: Server returned error %d " |
501 | "while mounting %s\n", status, nfs_export_path); | 506 | "while mounting %s\n", status, nfs_export_path); |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index f48db679a1c6..2b0c8e132b54 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -1329,8 +1329,13 @@ out_security_failure: | |||
1329 | static int nfs_try_mount(struct nfs_parsed_mount_data *args, | 1329 | static int nfs_try_mount(struct nfs_parsed_mount_data *args, |
1330 | struct nfs_fh *root_fh) | 1330 | struct nfs_fh *root_fh) |
1331 | { | 1331 | { |
1332 | struct sockaddr *sap = (struct sockaddr *)&args->mount_server.address; | 1332 | struct nfs_mount_request request = { |
1333 | char *hostname; | 1333 | .sap = (struct sockaddr *) |
1334 | &args->mount_server.address, | ||
1335 | .dirpath = args->nfs_server.export_path, | ||
1336 | .protocol = args->mount_server.protocol, | ||
1337 | .fh = root_fh, | ||
1338 | }; | ||
1334 | int status; | 1339 | int status; |
1335 | 1340 | ||
1336 | if (args->mount_server.version == 0) { | 1341 | if (args->mount_server.version == 0) { |
@@ -1339,42 +1344,38 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, | |||
1339 | else | 1344 | else |
1340 | args->mount_server.version = NFS_MNT_VERSION; | 1345 | args->mount_server.version = NFS_MNT_VERSION; |
1341 | } | 1346 | } |
1347 | request.version = args->mount_server.version; | ||
1342 | 1348 | ||
1343 | if (args->mount_server.hostname) | 1349 | if (args->mount_server.hostname) |
1344 | hostname = args->mount_server.hostname; | 1350 | request.hostname = args->mount_server.hostname; |
1345 | else | 1351 | else |
1346 | hostname = args->nfs_server.hostname; | 1352 | request.hostname = args->nfs_server.hostname; |
1347 | 1353 | ||
1348 | /* | 1354 | /* |
1349 | * Construct the mount server's address. | 1355 | * Construct the mount server's address. |
1350 | */ | 1356 | */ |
1351 | if (args->mount_server.address.ss_family == AF_UNSPEC) { | 1357 | if (args->mount_server.address.ss_family == AF_UNSPEC) { |
1352 | memcpy(sap, &args->nfs_server.address, | 1358 | memcpy(request.sap, &args->nfs_server.address, |
1353 | args->nfs_server.addrlen); | 1359 | args->nfs_server.addrlen); |
1354 | args->mount_server.addrlen = args->nfs_server.addrlen; | 1360 | args->mount_server.addrlen = args->nfs_server.addrlen; |
1355 | } | 1361 | } |
1362 | request.salen = args->mount_server.addrlen; | ||
1356 | 1363 | ||
1357 | /* | 1364 | /* |
1358 | * autobind will be used if mount_server.port == 0 | 1365 | * autobind will be used if mount_server.port == 0 |
1359 | */ | 1366 | */ |
1360 | nfs_set_port(sap, args->mount_server.port); | 1367 | nfs_set_port(request.sap, args->mount_server.port); |
1361 | 1368 | ||
1362 | /* | 1369 | /* |
1363 | * Now ask the mount server to map our export path | 1370 | * Now ask the mount server to map our export path |
1364 | * to a file handle. | 1371 | * to a file handle. |
1365 | */ | 1372 | */ |
1366 | status = nfs_mount(sap, | 1373 | status = nfs_mount(&request); |
1367 | args->mount_server.addrlen, | ||
1368 | hostname, | ||
1369 | args->nfs_server.export_path, | ||
1370 | args->mount_server.version, | ||
1371 | args->mount_server.protocol, | ||
1372 | root_fh); | ||
1373 | if (status == 0) | 1374 | if (status == 0) |
1374 | return 0; | 1375 | return 0; |
1375 | 1376 | ||
1376 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n", | 1377 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n", |
1377 | hostname, status); | 1378 | request.hostname, status); |
1378 | return status; | 1379 | return status; |
1379 | } | 1380 | } |
1380 | 1381 | ||