2.0.3x kernel patch for alternate NFS servers (Re: mount-2.8a)

Joseph H. Buehler (jhpb@sarto.gaithersburg.md.us)
05 Aug 1998 21:29:14 -0400


Andries.Brouwer@cwi.nl writes:

> PS: the past week or so, four or five people asked whether I
> would put their patches in mount.c. If these changes go together
> with changes in the kernel, and the official kernel does not
> have them yet, then I won't put them in mount.c.
> If I didnt use your favourite patch and this is not the reason,
> you are welcome to send it again.

Alan,

Would you please put the following patch into 2.0.3x? I run an NFS
daemon for accessing my tape drive on a non-standard RPC
program/version so it does not interfere with standard NFS usage.

Once this is in the kernel I will submit the corresponding mount patch
to Andries again.

Joe Buehler

This is a patch to the linux kernel to enable it to mount NFS servers
running on non-standard RPC program/version numbers.

It has been tested with 2.0.33 and 2.0.34.

--- /usr/src/linux/fs/nfs/inode.c.orig Sat Nov 30 05:21:21 1996
+++ /usr/src/linux/fs/nfs/inode.c Wed Mar 11 18:30:54 1998
@@ -163,6 +163,13 @@
server->acdirmin = data->acdirmin*HZ;
server->acdirmax = data->acdirmax*HZ;
strcpy(server->hostname, data->hostname);
+ if (data->flags & NFS_MOUNT_NFSVERS) {
+ server->nfsvers = data->nfsvers ? data->nfsvers : NFS_NFS_VERSION;
+ server->nfsprog = data->nfsprog ? data->nfsprog : NFS_NFS_PROGRAM;
+ } else {
+ server->nfsvers = NFS_NFS_VERSION;
+ server->nfsprog = NFS_NFS_PROGRAM;
+ }

/* Start of JSP NFS patch */
/* Check if passed address in data->addr */
--- /usr/src/linux/fs/nfs/proc.c.orig Wed Jul 3 06:52:09 1996
+++ /usr/src/linux/fs/nfs/proc.c Tue Mar 10 20:07:45 1998
@@ -64,7 +64,7 @@
/* Mapping from NFS error code to "errno" error code. */
#define errno_NFSERR_IO EIO

-static int *nfs_rpc_header(int *p, int procedure, int ruid);
+static int *nfs_rpc_header(int *p, int procedure, int ruid, struct nfs_server *server);
static int *nfs_rpc_verify(int *p);
static int nfs_stat_to_errno(int stat);

@@ -231,7 +231,7 @@
if (!(p0 = nfs_rpc_alloc(server->rsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_GETATTR, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_GETATTR, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
if ((status = nfs_rpc_call(server, p0, p, server->rsize)) < 0) {
nfs_rpc_free(p0);
@@ -267,7 +267,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_SETATTR, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_SETATTR, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
p = xdr_encode_sattr(p, sattr);
if ((status = nfs_rpc_call(server, p0, p, server->wsize)) < 0) {
@@ -308,7 +308,7 @@
if (!(p0 = nfs_rpc_alloc(server->rsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_LOOKUP, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_LOOKUP, ruid, server);
p = xdr_encode_fhandle(p, dir);
p = xdr_encode_string(p, name);
if ((status = nfs_rpc_call(server, p0, p, server->rsize)) < 0) {
@@ -345,7 +345,7 @@
if (!(*p0 = nfs_rpc_alloc(server->rsize)))
return -EIO;
retry:
- p = nfs_rpc_header(*p0, NFSPROC_READLINK, ruid);
+ p = nfs_rpc_header(*p0, NFSPROC_READLINK, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
if ((status = nfs_rpc_call(server, *p0, p, server->rsize)) < 0)
return status;
@@ -382,7 +382,7 @@
if (!(p0 = nfs_rpc_alloc(server->rsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_READ, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_READ, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
*p++ = htonl(offset);
*p++ = htonl(count);
@@ -428,7 +428,7 @@
if (!(p0 = nfs_rpc_alloc(NFS_SLACK_SPACE)))
return -EIO;

- p = nfs_rpc_header(p0, NFSPROC_READ, 0);
+ p = nfs_rpc_header(p0, NFSPROC_READ, 0, server);
p = xdr_encode_fhandle(p, fh);
*p++ = htonl(offset);
*p++ = htonl(count);
@@ -505,7 +505,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_WRITE, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_WRITE, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
*p++ = htonl(offset); /* traditional, could be any value */
*p++ = htonl(offset);
@@ -548,7 +548,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_CREATE, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_CREATE, ruid, server);
p = xdr_encode_fhandle(p, dir);
p = xdr_encode_string(p, name);
p = xdr_encode_sattr(p, sattr);
@@ -586,7 +586,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_REMOVE, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_REMOVE, ruid, server);
p = xdr_encode_fhandle(p, dir);
p = xdr_encode_string(p, name);
if ((status = nfs_rpc_call(server, p0, p, server->wsize)) < 0) {
@@ -630,7 +630,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_RENAME, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_RENAME, ruid, server);
p = xdr_encode_fhandle(p, old_dir);
p = xdr_encode_string(p, old_name);
p = xdr_encode_fhandle(p, new_dir);
@@ -668,7 +668,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_LINK, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_LINK, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
p = xdr_encode_fhandle(p, dir);
p = xdr_encode_string(p, name);
@@ -705,7 +705,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_SYMLINK, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_SYMLINK, ruid, server);
p = xdr_encode_fhandle(p, dir);
p = xdr_encode_string(p, name);
p = xdr_encode_string(p, path);
@@ -744,7 +744,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_MKDIR, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_MKDIR, ruid, server);
p = xdr_encode_fhandle(p, dir);
p = xdr_encode_string(p, name);
p = xdr_encode_sattr(p, sattr);
@@ -782,7 +782,7 @@
if (!(p0 = nfs_rpc_alloc(server->wsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_RMDIR, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_RMDIR, ruid, server);
p = xdr_encode_fhandle(p, dir);
p = xdr_encode_string(p, name);
if ((status = nfs_rpc_call(server, p0, p, server->wsize)) < 0) {
@@ -822,7 +822,7 @@
if (!(p0 = nfs_rpc_alloc(server->rsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_READDIR, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_READDIR, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
*p++ = htonl(cookie);
*p++ = htonl(size);
@@ -874,7 +874,7 @@
if (!(p0 = nfs_rpc_alloc(server->rsize)))
return -EIO;
retry:
- p = nfs_rpc_header(p0, NFSPROC_STATFS, ruid);
+ p = nfs_rpc_header(p0, NFSPROC_STATFS, ruid, server);
p = xdr_encode_fhandle(p, fhandle);
if ((status = nfs_rpc_call(server, p0, p, server->rsize)) < 0) {
nfs_rpc_free(p0);
@@ -938,11 +938,11 @@
}


-static int *nfs_rpc_header(int *p, int procedure, int ruid)
+static int *nfs_rpc_header(int *p, int procedure, int ruid, struct nfs_server *server)
{
- return rpc_header(p, procedure, NFS_PROGRAM, NFS_VERSION,
- (ruid ? current->uid : current->fsuid),
- current->egid, current->groups);
+ return rpc_header(p, procedure, server->nfsprog, server->nfsvers,
+ (ruid ? current->uid : current->fsuid),
+ current->egid, current->groups);
}


--- /usr/src/linux/include/linux/nfs_fs_sb.h.orig Thu Jun 6 14:23:00 1996
+++ /usr/src/linux/include/linux/nfs_fs_sb.h Sat Apr 18 15:44:37 1998
@@ -20,6 +20,8 @@
int acdirmin;
int acdirmax;
char hostname[256];
+ int nfsvers;
+ int nfsprog;
};

/*
--- /usr/src/linux/include/linux/nfs_mount.h.orig Tue Nov 14 09:03:57 1995
+++ /usr/src/linux/include/linux/nfs_mount.h Sat Apr 18 15:44:37 1998
@@ -46,6 +46,10 @@
int acdirmax; /* 1 */
struct sockaddr_in addr; /* 1 */
char hostname[256]; /* 1 */
+ int namlen; /* 2 */
+ unsigned int bsize; /* 3 */
+ int nfsvers; /* 1++ */
+ int nfsprog; /* 1++ */
};

/* bits in the flags field */
@@ -56,5 +60,6 @@
#define NFS_MOUNT_POSIX 0x0008 /* 1 */
#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
#define NFS_MOUNT_NOAC 0x0020 /* 1 */
-
+#define NFS_MOUNT_NFSVERS 0x4000 /* 1++ */
+
#endif

-
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.altern.org/andrebalsa/doc/lkml-faq.html