diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-07-01 12:13:27 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-07-10 23:40:46 -0400 |
commit | 3ea97309e6b18bce200211b3f9188e8023321adc (patch) | |
tree | a4a1f78dfd9b20df4df7dc08266b40f82205f16a /fs | |
parent | 43780b87fa799ae65df11d89d4539d8d6a7c67eb (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')
-rw-r--r-- | fs/nfs/Makefile | 4 | ||||
-rw-r--r-- | fs/nfs/mount_clnt.c | 55 | ||||
-rw-r--r-- | fs/nfs/nfsroot.c | 3 |
3 files changed, 32 insertions, 30 deletions
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index f4580b44eef4..b55cb236cf74 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile | |||
@@ -6,8 +6,8 @@ obj-$(CONFIG_NFS_FS) += nfs.o | |||
6 | 6 | ||
7 | nfs-y := client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \ | 7 | nfs-y := client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \ |
8 | pagelist.o proc.o read.o symlink.o unlink.o \ | 8 | pagelist.o proc.o read.o symlink.o unlink.o \ |
9 | write.o namespace.o | 9 | write.o namespace.o mount_clnt.o |
10 | nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o | 10 | nfs-$(CONFIG_ROOT_NFS) += nfsroot.o |
11 | nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o | 11 | nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o |
12 | nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o | 12 | nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o |
13 | nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ | 13 | nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ |
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index 2892ec843066..ee4899d96629 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 | ||
31 | static struct rpc_clnt * mnt_create(struct sockaddr_in *, int, int); | ||
32 | static struct rpc_program mnt_program; | 31 | static struct rpc_program mnt_program; |
33 | 32 | ||
34 | struct mnt_fhstatus { | 33 | struct 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 | */ |
42 | int | 50 | int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path, |
43 | nfsroot_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 | ||
73 | static 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 | */ |
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index f0db4703b1c9..3490322d1145 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c | |||
@@ -496,7 +496,8 @@ static int __init root_nfs_get_handle(void) | |||
496 | NFS_MNT3_VERSION : NFS_MNT_VERSION; | 496 | NFS_MNT3_VERSION : NFS_MNT_VERSION; |
497 | 497 | ||
498 | set_sockaddr(&sin, servaddr, htons(mount_port)); | 498 | set_sockaddr(&sin, servaddr, htons(mount_port)); |
499 | status = nfsroot_mount(&sin, nfs_path, &fh, version, protocol); | 499 | status = nfs_mount((struct sockaddr *) &sin, sizeof(sin), NULL, |
500 | nfs_path, version, protocol, &fh); | ||
500 | if (status < 0) | 501 | if (status < 0) |
501 | printk(KERN_ERR "Root-NFS: Server returned error %d " | 502 | printk(KERN_ERR "Root-NFS: Server returned error %d " |
502 | "while mounting %s\n", status, nfs_path); | 503 | "while mounting %s\n", status, nfs_path); |