aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/mount_clnt.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-07-01 12:13:27 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-10 23:40:46 -0400
commit3ea97309e6b18bce200211b3f9188e8023321adc (patch)
treea4a1f78dfd9b20df4df7dc08266b40f82205f16a /fs/nfs/mount_clnt.c
parent43780b87fa799ae65df11d89d4539d8d6a7c67eb (diff)
NFS: Remake nfsroot_mount as a permanent part of NFS client
In preparation for supporting NFSv2 and NFSv3 mount option handling in the kernel NFS client, convert mount_clnt.c to be a permanent part of the NFS client, instead of built only when CONFIG_ROOT_NFS is enabled. In addition, we also replace the "struct sockaddr_in *" argument with something more generic, to help support IPv6 at some later point. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/mount_clnt.c')
-rw-r--r--fs/nfs/mount_clnt.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index 2892ec84306..ee4899d9662 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -18,7 +18,7 @@
18#include <linux/nfs_fs.h> 18#include <linux/nfs_fs.h>
19 19
20#ifdef RPC_DEBUG 20#ifdef RPC_DEBUG
21# define NFSDBG_FACILITY NFSDBG_ROOT 21# define NFSDBG_FACILITY NFSDBG_MOUNT
22#endif 22#endif
23 23
24/* 24/*
@@ -28,7 +28,6 @@
28#define MOUNT_UMNT 3 28#define MOUNT_UMNT 3
29 */ 29 */
30 30
31static struct rpc_clnt * mnt_create(struct sockaddr_in *, int, int);
32static struct rpc_program mnt_program; 31static struct rpc_program mnt_program;
33 32
34struct mnt_fhstatus { 33struct mnt_fhstatus {
@@ -36,14 +35,21 @@ struct mnt_fhstatus {
36 struct nfs_fh * fh; 35 struct nfs_fh * fh;
37}; 36};
38 37
39/* 38/**
40 * Obtain an NFS file handle for the given host and path 39 * nfs_mount - Obtain an NFS file handle for the given host and path
40 * @addr: pointer to server's address
41 * @len: size of server's address
42 * @hostname: name of server host, or NULL
43 * @path: pointer to string containing export path to mount
44 * @version: mount version to use for this request
45 * @protocol: transport protocol to use for thie request
46 * @fh: pointer to location to place returned file handle
47 *
48 * Uses default timeout parameters specified by underlying transport.
41 */ 49 */
42int 50int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path,
43nfsroot_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh, 51 int version, int protocol, struct nfs_fh *fh)
44 int version, int protocol)
45{ 52{
46 struct rpc_clnt *mnt_clnt;
47 struct mnt_fhstatus result = { 53 struct mnt_fhstatus result = {
48 .fh = fh 54 .fh = fh
49 }; 55 };
@@ -51,12 +57,23 @@ nfsroot_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh,
51 .rpc_argp = path, 57 .rpc_argp = path,
52 .rpc_resp = &result, 58 .rpc_resp = &result,
53 }; 59 };
60 struct rpc_create_args args = {
61 .protocol = protocol,
62 .address = addr,
63 .addrsize = len,
64 .servername = hostname,
65 .program = &mnt_program,
66 .version = version,
67 .authflavor = RPC_AUTH_UNIX,
68 .flags = RPC_CLNT_CREATE_INTR,
69 };
70 struct rpc_clnt *mnt_clnt;
54 int status; 71 int status;
55 72
56 dprintk("NFS: nfs_mount(%08x:%s)\n", 73 dprintk("NFS: sending MNT request for %s:%s\n",
57 (unsigned)ntohl(addr->sin_addr.s_addr), path); 74 (hostname ? hostname : "server"), path);
58 75
59 mnt_clnt = mnt_create(addr, version, protocol); 76 mnt_clnt = rpc_create(&args);
60 if (IS_ERR(mnt_clnt)) 77 if (IS_ERR(mnt_clnt))
61 return PTR_ERR(mnt_clnt); 78 return PTR_ERR(mnt_clnt);
62 79
@@ -70,22 +87,6 @@ nfsroot_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh,
70 return status < 0? status : (result.status? -EACCES : 0); 87 return status < 0? status : (result.status? -EACCES : 0);
71} 88}
72 89
73static struct rpc_clnt *mnt_create(struct sockaddr_in *srvaddr, int version,
74 int protocol)
75{
76 struct rpc_create_args args = {
77 .protocol = protocol,
78 .address = (struct sockaddr *)srvaddr,
79 .addrsize = sizeof(*srvaddr),
80 .program = &mnt_program,
81 .version = version,
82 .authflavor = RPC_AUTH_UNIX,
83 .flags = RPC_CLNT_CREATE_INTR,
84 };
85
86 return rpc_create(&args);
87}
88
89/* 90/*
90 * XDR encode/decode functions for MOUNT 91 * XDR encode/decode functions for MOUNT
91 */ 92 */