[PATCH] pass NFS protocol version from "mount" command 2.2.x/2.3.x

Joseph H. Buehler (jhpb@sarto.gaithersburg.md.us)
Sat, 24 Jul 1999 20:21:55 -0400


This is a multi-part message in MIME format.
--------------64C94FD2369111AA0C110C92
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The attached patch is required so that the kernel
can talk to NFS servers running a version of NFS
besides 2. It does not look as though version 3
support is complete in the kernel, but this patch
(or something similar) will be required eventually.

Unlike 2.0.x, 2.2.x and 2.3.x validate
the version passed from "mount", so I have also
added version 100 in the kernel, so I can test
NFS version 2 server implementations without
interfering with standard NFS servers.

Tested under 2.2.5 (RedHat 6.0). Applies cleanly
against 2.2.10 and 2.3.11, should be no problems.

I have a companion patch to "mount" that I will send
to its maintainer once this patch makes it into the
kernel.

Please cc me on replies, I am not on the list.

Joe Buehler
--------------64C94FD2369111AA0C110C92
Content-Type: text/plain; charset=us-ascii;
name="linux-2.2.5.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="linux-2.2.5.patch"

--- linux-2.2.5/include/linux/nfs_mount.h.~1~ Mon Apr 7 14:35:31 1997
+++ linux-2.2.5/include/linux/nfs_mount.h Sat Jul 24 19:29:50 1999
@@ -16,7 +16,7 @@
* mount-to-kernel version compatibility. Some of these aren't used yet
* but here they are anyway.
*/
-#define NFS_MOUNT_VERSION 3
+#define NFS_MOUNT_VERSION 4

struct nfs_mount_data {
int version; /* 1 */
@@ -35,6 +35,7 @@
char hostname[256]; /* 1 */
int namlen; /* 2 */
unsigned int bsize; /* 3 */
+ int nfsvers; /* 4 */
};

/* bits in the flags field */
@@ -49,5 +50,6 @@
#define NFS_MOUNT_VER3 0x0080 /* 3 */
#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
#define NFS_MOUNT_NONLM 0x0200 /* 3 */
-
+#define NFS_MOUNT_NFSVERS 0x0400 /* 4 */
+
#endif
--- linux-2.2.5/fs/nfs/inode.c.~1~ Wed Mar 3 14:17:02 1999
+++ linux-2.2.5/fs/nfs/inode.c Sat Jul 24 18:29:30 1999
@@ -209,12 +209,16 @@
goto out_miss_args;

if (data->version != NFS_MOUNT_VERSION) {
- printk("nfs warning: mount version %s than kernel\n",
- data->version < NFS_MOUNT_VERSION ? "older" : "newer");
+ printk("nfs warning: mount version (%d) %s than kernel (%d)\n",
+ data->version,
+ data->version < NFS_MOUNT_VERSION ? "older" : "newer",
+ NFS_MOUNT_VERSION);
if (data->version < 2)
data->namlen = 0;
if (data->version < 3)
data->bsize = 0;
+ if (data->version < 4)
+ data->nfsvers = 0;
}

/* We now require that the mount process passes the remote address */
@@ -265,7 +269,7 @@
authflavor = RPC_AUTH_KRB;

clnt = rpc_create_client(xprt, server->hostname, &nfs_program,
- NFS_VERSION, authflavor);
+ data->nfsvers ? data->nfsvers : NFS_VERSION, authflavor);
if (clnt == NULL)
goto out_no_client;

--- linux-2.2.5/fs/nfs/nfs2xdr.c.~1~ Sat Mar 6 17:21:13 1999
+++ linux-2.2.5/fs/nfs/nfs2xdr.c Sat Jul 24 15:55:58 1999
@@ -674,10 +674,17 @@
nfs_procedures
};

+static struct rpc_version nfs_version100 = {
+ 100,
+ sizeof(nfs_procedures)/sizeof(nfs_procedures[0]),
+ nfs_procedures
+};
+
static struct rpc_version * nfs_version[] = {
NULL,
NULL,
- &nfs_version2
+ &nfs_version2,
+ &nfs_version100
};

struct rpc_program nfs_program = {
--- linux-2.2.5/net/sunrpc/clnt.c.~1~ Tue Oct 6 12:39:44 1998
+++ linux-2.2.5/net/sunrpc/clnt.c Sat Jul 24 19:30:34 1999
@@ -72,14 +72,20 @@
{
struct rpc_version *version;
struct rpc_clnt *clnt = NULL;
+ int i;

dprintk("RPC: creating %s client for %s (xprt %p)\n",
program->name, servname, xprt);

if (!xprt)
goto out;
- if (vers >= program->nrvers || !(version = program->version[vers]))
+ for (i=0; i<program->nrvers; ++i)
+ if ((version = program->version[i]) && vers == version->number)
+ break;
+ if (i >= program->nrvers)
goto out;
+
+ dprintk("RPC: program %d version %d\n", program->number, version->number);

clnt = (struct rpc_clnt *) rpc_allocate(0, sizeof(*clnt));
if (!clnt)

--------------64C94FD2369111AA0C110C92--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/