diff options
| author | Chuck Lever <cel@citi.umich.edu> | 2002-11-07 00:43:25 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@penguin.transmeta.com> | 2002-11-07 00:43:25 -0800 |
| commit | 20eb6a8b29f845a0a1dd893a91cac35ac3cc3b45 (patch) | |
| tree | 1559f5bb854c03de013835f226ed7c6cc7399c71 | |
| parent | 249502cc3933acc27173384e48a29a6ff00ada5b (diff) | |
[PATCH] allow nfsroot to mount with TCP
nfsroot needs to pass the network protocol (UDP/TCP) into the mount
functions in order to support mounting root partitions via NFS over TCP.
| -rw-r--r-- | fs/nfs/mount_clnt.c | 31 | ||||
| -rw-r--r-- | fs/nfs/nfsroot.c | 12 | ||||
| -rw-r--r-- | include/linux/nfs_fs.h | 4 |
3 files changed, 20 insertions, 27 deletions
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index 0d33648d9376..3a26b06a491b 100644 --- a/fs/nfs/mount_clnt.c +++ b/fs/nfs/mount_clnt.c @@ -29,10 +29,9 @@ #define MOUNT_UMNT 3 */ -static int nfs_gen_mount(struct sockaddr_in *, - char *, struct nfs_fh *, int); -static struct rpc_clnt * mnt_create(char *, struct sockaddr_in *, int); -extern struct rpc_program mnt_program; +static struct rpc_clnt * mnt_create(char *, struct sockaddr_in *, + int, int); +struct rpc_program mnt_program; struct mnt_fhstatus { unsigned int status; @@ -43,19 +42,8 @@ struct mnt_fhstatus { * Obtain an NFS file handle for the given host and path */ int -nfs_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh) -{ - return nfs_gen_mount(addr, path, fh, NFS_MNT_VERSION); -} - -int -nfs3_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh) -{ - return nfs_gen_mount(addr, path, fh, NFS_MNT3_VERSION); -} - -static int -nfs_gen_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh, int version) +nfsroot_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh, + int version, int protocol) { struct rpc_clnt *mnt_clnt; struct mnt_fhstatus result = { @@ -69,21 +57,22 @@ nfs_gen_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh, int versi (unsigned)ntohl(addr->sin_addr.s_addr), path); sprintf(hostname, "%u.%u.%u.%u", NIPQUAD(addr->sin_addr.s_addr)); - if (!(mnt_clnt = mnt_create(hostname, addr, version))) + if (!(mnt_clnt = mnt_create(hostname, addr, version, protocol))) return -EACCES; - call = (version == 3) ? MOUNTPROC3_MNT : MNTPROC_MNT; + call = (version == NFS_MNT3_VERSION) ? MOUNTPROC3_MNT : MNTPROC_MNT; status = rpc_call(mnt_clnt, call, path, &result, 0); return status < 0? status : (result.status? -EACCES : 0); } static struct rpc_clnt * -mnt_create(char *hostname, struct sockaddr_in *srvaddr, int version) +mnt_create(char *hostname, struct sockaddr_in *srvaddr, int version, + int protocol) { struct rpc_xprt *xprt; struct rpc_clnt *clnt; - if (!(xprt = xprt_create_proto(IPPROTO_UDP, srvaddr, NULL))) + if (!(xprt = xprt_create_proto(protocol, srvaddr, NULL))) return NULL; clnt = rpc_create_client(xprt, hostname, diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 8a5171ac14a4..0e9370848f49 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c @@ -64,6 +64,8 @@ * Trond Myklebust : Add in preliminary support for NFSv3 and TCP. * Fix bug in root_nfs_addr(). nfs_data.namlen * is NOT for the length of the hostname. + * Hua Qin : Support for mounting root file system via + * NFS over TCP. */ #include <linux/config.h> @@ -440,12 +442,14 @@ static int __init root_nfs_get_handle(void) { struct sockaddr_in sin; int status; + int protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? + IPPROTO_TCP : IPPROTO_UDP; + int version = (nfs_data.flags & NFS_MOUNT_VER3) ? + NFS_MNT3_VERSION : NFS_MNT_VERSION; set_sockaddr(&sin, servaddr, mount_port); - if (nfs_data.flags & NFS_MOUNT_VER3) - status = nfs3_mount(&sin, nfs_path, &nfs_data.root); - else - status = nfs_mount(&sin, nfs_path, &nfs_data.root); + status = nfsroot_mount(&sin, nfs_path, &nfs_data.root, + version, protocol); if (status < 0) printk(KERN_ERR "Root-NFS: Server returned error %d " "while mounting %s\n", status, nfs_path); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 9f6bce1ccfe4..989a9015cdd5 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -398,8 +398,8 @@ extern void nfs_readdata_release(struct rpc_task *); * linux/fs/mount_clnt.c * (Used only by nfsroot module) */ -extern int nfs_mount(struct sockaddr_in *, char *, struct nfs_fh *); -extern int nfs3_mount(struct sockaddr_in *, char *, struct nfs_fh *); +extern int nfsroot_mount(struct sockaddr_in *, char *, struct nfs_fh *, + int, int); /* * inline functions |
