summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1996-08-14 18:10:19 +0000
committerThomas Bushnell <thomas@gnu.org>1996-08-14 18:10:19 +0000
commit2026ce0437cca8cb15149a5c488f93110f69131d (patch)
tree7bdeded20cbe0cc5222cb8aeeb773f761cc7cc79
parent332efe88b6fbf47a33cd27a4b9b22276a30c181f (diff)
*** empty log message ***
-rw-r--r--BUGS3
-rw-r--r--nfs/ChangeLog60
-rw-r--r--nfs/cache.c8
-rw-r--r--nfs/mount.c2
-rw-r--r--nfs/nfs.c40
-rw-r--r--nfs/nfs.h2
-rw-r--r--nfs/ops.c71
-rw-r--r--nfs/rpcsvc/nfs_prot.h365
-rw-r--r--nfsd/ChangeLog13
-rw-r--r--nfsd/cache.c28
-rw-r--r--nfsd/loop.c2
-rw-r--r--nfsd/nfsd.h6
-rw-r--r--nfsd/ops.c20
-rw-r--r--nfsd/xdr.c14
14 files changed, 264 insertions, 370 deletions
diff --git a/BUGS b/BUGS
index 1c58c181..dd1307ef 100644
--- a/BUGS
+++ b/BUGS
@@ -31,3 +31,6 @@ permission; this will cause a failure of vm_wire if the current
permission is later promoted.
Patch for MiG dealing when sreplyport and mach_port_poly_t are used together.
+
+Install Linux and NetBSD physical CPU reset code in place of current
+Mach version.
diff --git a/nfs/ChangeLog b/nfs/ChangeLog
index ee69f4ef..fcb44299 100644
--- a/nfs/ChangeLog
+++ b/nfs/ChangeLog
@@ -1,3 +1,63 @@
+Wed Aug 14 12:33:37 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * rpcsvc/nfs_prot.h (NFS_FHSIZE): Deleted macro.
+ (NFS2_FHSIZE, NFS3_FHSIZE, NFS3_COOKIEVERFSIZE, NFS3_CREATEVERFSIZE,
+ NFS3_WRITEVERFSIZE): New macros.
+ (enum ftype): Deleted NFFIFO. Added NF2FIFO, NF3FIFO, and an
+ alias NF2BAD for NF3FIFO.
+ (NFSPROC_NULL, NFSPROC_GETATTR, NFSPROC_SETATTR,
+ NFSPROC_LOOKUP, NFSPROC_READLINK, NFSPROC_READ,
+ NFSPROC_WRITE, NFSPROC_CREATE, NFSPROC_REMOVE,
+ NFSPROC_RENAME, NFSPROC_LINK, NFSPROC_SYMLINK, NFSPROC_MKDIR,
+ NFSPROC_RMDIR, NFSPROC_READDIR): Replace with new
+ macros that take a version arg. All users changed to use new
+ version arg.
+ (NFS_PROTOCOL_FUNC): New macro.
+ (NFS2PROC_NULL, NFS2PROC_GETATTR, NFS2PROC_SETATTR, NFS2PROC_ROOT,
+ NFS2PROC_LOOKUP, NFS2PROC_READLINK, NFS2PROC_READ,
+ NFS2PROC_WRITECACHE, NFS2PROC_WRIT, NFS2PROC_CREATE,
+ NFS2PROC_REMOVE, NFS2PROC_RENAME, NFS2PROC_LINK, NFS2PROC_SYMLINK,
+ NFS2PROC_MKDIR, NFS2PROC_RMDIR, NFS2PROC_READDIR, NFS2PROC_STATFS,
+ NFS3PROC_NULL, NFS3PROC_GETATTR, NFS3PROC_SETATTR,
+ NFS3PROC_LOOKUP, NFS3PROC_ACCESS, NFS3PROC_READLINK,
+ NFS3PROC_READ, NFS3PROC_WRITE, NFS3PROC_CREATE, NFS3PROC_MKDIR,
+ NFS3PROC_SYMLINK, NFS3PROC_MKNOD, NFS3PROC_REMOVE, NFS3PROC_RMDIR,
+ NFS3PROC_RENAME, NFS3PROC_LINK, NFS3PROC_READDIR,
+ NFS3PROC_READDIRPLUS, NFS3PROC_FSSTAT, NFS3PROC_FSINFO,
+ NFS3PROC_PATHCONF, NFS3PROC_COMMIT): New macros. All callers
+ appropriately changed.
+
+ * nfs.c (nfs_error_trans): NFS_SERVERFAULT maps to EIO;
+ NFSERR_BADTYPE maps to EOPNOTSUPP.
+
+ * rpcsvc/nfs_prot.h (nfsstat, ftype, struct nfs_fh, nfs_fh, struct
+ nfstime, nfstime, struct fattr, fattr, struct sattr, sattr,
+ filename, nfspath, struct attrstat, attrstat, struct sattrargs,
+ sattrargs, struct diropargs, diropargs, struct diropokres,
+ diropokres, struct diropres, diropres, struct readlinkres,
+ readlinkres, struct readargs, readargs, struct readokres,
+ readokres, struct readres, readres, struct writeargs, writeargs,
+ struct createargs, createargs, struct renameargs, renameargs,
+ struct linkargs, linkargs, struct symlinkargs, symlinkargs,
+ nfscookie, struct readdirargs, readdirargs, struct entry, entry,
+ struct dirlist, dirlist, struct readdirres, readdirres, struct
+ statfsokres, statfsokres, struct statfsres, statfsres): Delete
+ unused types.
+ (xdr_nfsstat, xdr_ftype, xdr_nfs_fh, xdr_nfstime, xdr_fattr,
+ xdr_sattr, xdr_filename, xdr_nfspath, xdr_attrstat, xdr_sattrargs,
+ xdr_diropargs, xdr_diropokres, xdr_diropres, xdr_readlinkres,
+ xdr_readargs, xdr_readokres, xdr_readres, xdr_writeargs,
+ xdr_createargs, xdr_renameargs, xdr_linkargs, xdr_symlinkargs,
+ xdr_nfscookie, xdr_readdirargs, xdr_entry, xdr_dirlist,
+ xdr_readdirres, xdr_statfsokres, xdr_statfsres, nfsproc_null_2,
+ nfsproc_getattr_2, nfsproc_setattr_2, nfsproc_root_2,
+ nfsproc_lookup_2, nfsproc_readlink_2, rfsproc_read_2,
+ nfsproc_writecache_2, nfsproc_write_2, nfsproc_create_2,
+ nfsproc_remove_2, nfsproc_rename_2, nfsproc_link_2,
+ nfsproc_symlink_2, nfsproc_mkdir_2, nfsproc_rmdir_2,
+ nfsproc_readdir_2, nfsproc_statfs_2): Delete unused function
+ declarations.
+
Tue Aug 13 14:57:03 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* ops.c (netfs_attempt_create_file): Sun's NFS client does not
diff --git a/nfs/cache.c b/nfs/cache.c
index 65b46575..b6577440 100644
--- a/nfs/cache.c
+++ b/nfs/cache.c
@@ -33,7 +33,7 @@ hash (void *fhandle)
unsigned int h = 0;
int i;
- for (i = 0; i < NFS_FHSIZE; i++)
+ for (i = 0; i < NFS2_FHSIZE; i++)
h += ((char *)fhandle)[i];
return h % CACHESIZE;
@@ -53,7 +53,7 @@ lookup_fhandle (void *fhandle)
spin_lock (&netfs_node_refcnt_lock);
for (np = nodehash[h]; np; np = np->nn->hnext)
{
- if (bcmp (np->nn->handle, fhandle, NFS_FHSIZE) != 0)
+ if (bcmp (np->nn->handle, fhandle, NFS2_FHSIZE) != 0)
continue;
np->references++;
@@ -63,7 +63,7 @@ lookup_fhandle (void *fhandle)
}
nn = malloc (sizeof (struct netnode));
- bcopy (fhandle, nn->handle, NFS_FHSIZE);
+ bcopy (fhandle, nn->handle, NFS2_FHSIZE);
nn->stat_updated = 0;
nn->dtrans = NOT_POSSIBLE;
nn->dead_dir = 0;
@@ -135,7 +135,7 @@ recache_handle (struct node *np, void *handle)
if (np->nn->hnext)
np->nn->hnext->nn->hprevp = np->nn->hprevp;
- bcopy (handle, np->nn->handle, NFS_FHSIZE);
+ bcopy (handle, np->nn->handle, NFS2_FHSIZE);
h = hash (handle);
np->nn->hnext = nodehash[h];
diff --git a/nfs/mount.c b/nfs/mount.c
index 687257c1..233a0298 100644
--- a/nfs/mount.c
+++ b/nfs/mount.c
@@ -177,7 +177,7 @@ mount_root (char *name, char *host)
/* Create the node for root */
np = lookup_fhandle (p);
- p += NFS_FHSIZE / sizeof (int);
+ p += NFS2_FHSIZE / sizeof (int);
free (rpcbuf);
mutex_unlock (&np->lock);
diff --git a/nfs/nfs.c b/nfs/nfs.c
index ae7e677f..f053ea41 100644
--- a/nfs/nfs.c
+++ b/nfs/nfs.c
@@ -45,9 +45,6 @@ nfs_mode_to_hurd_mode (int type, int mode)
break;
case NFREG:
- case NFNON:
- case NFBAD:
- default:
hurdmode = S_IFREG;
break;
@@ -59,8 +56,31 @@ nfs_mode_to_hurd_mode (int type, int mode)
hurdmode = S_IFSOCK;
break;
- case NFFIFO:
- hurdmode = S_IFIFO;
+ default:
+ if (protocol_version == 2)
+ switch (type)
+ {
+ case NF2NON:
+ case NF2BAD:
+ default:
+ hurdmode = S_IFREG;
+ break;
+
+ case NF2FIFO:
+ hurdmode = S_IFIFO;
+ break;
+ }
+ else
+ switch (type)
+ {
+ case NF3FIFO:
+ hurdmode = S_IFIFO;
+ break;
+
+ default:
+ hurdmode = S_IFREG;
+ break;
+ }
break;
}
@@ -86,8 +106,8 @@ hurd_mode_to_nfs_mode (mode_t mode)
int *
xdr_encode_fhandle (int *p, void *fhandle)
{
- bcopy (fhandle, p, NFS_FHSIZE);
- return p + INTSIZE (NFS_FHSIZE);
+ bcopy (fhandle, p, NFS2_FHSIZE);
+ return p + INTSIZE (NFS2_FHSIZE);
}
/* Encode uninterpreted bytes. */
@@ -423,14 +443,16 @@ nfs_error_trans (int error)
return EMLINK;
case NFSERR_NOTSUPP:
+ case NFSERR_BADTYPE:
return EOPNOTSUPP;
+ case NFSERR_SERVERFAULT:
+ return EIO;
+
case NFSERR_BADHANDLE:
case NFSERR_NOT_SYNC:
case NFSERR_BAD_COOKIE:
case NFSERR_TOOSMALL:
- case NFSERR_SERVERFAULT: /* perhaps EIO instead?? */
- case NFSERR_BADTYPE:
case NFSERR_JUKEBOX: /* ??? */
/* These indicate bugs in the client, so EGRATUITOUS is right. */
return EGRATUITOUS;
diff --git a/nfs/nfs.h b/nfs/nfs.h
index 6a384afa..1996dfce 100644
--- a/nfs/nfs.h
+++ b/nfs/nfs.h
@@ -28,7 +28,7 @@ typedef int bool_t; /* Ick. */
node. */
struct netnode
{
- char handle[NFS_FHSIZE];
+ char handle[NFS2_FHSIZE];
time_t stat_updated;
struct node *hnext, **hprevp;
diff --git a/nfs/ops.c b/nfs/ops.c
index 4c7c5170..2efeb6fd 100644
--- a/nfs/ops.c
+++ b/nfs/ops.c
@@ -86,8 +86,8 @@ netfs_validate_stat (struct node *np, struct netcred *cred)
if (mapped_time->seconds - np->nn->stat_updated < stat_timeout)
return 0;
- p = nfs_initialize_rpc (NFSPROC_GETATTR, (struct netcred *) -1,
- 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_GETATTR (protocol_version),
+ (struct netcred *) -1, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
err = conduct_rpc (&rpcbuf, &p);
@@ -112,7 +112,8 @@ netfs_attempt_chown (struct netcred *cred, struct node *np,
void *rpcbuf;
error_t err;
- p = nfs_initialize_rpc (NFSPROC_SETATTR, cred, 0, &rpcbuf, np, gid);
+ p = nfs_initialize_rpc (NFSPROC_SETATTR (protocol_version),
+ cred, 0, &rpcbuf, np, gid);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_sattr_ids (p, uid, gid);
@@ -180,7 +181,8 @@ netfs_attempt_chmod (struct netcred *cred, struct node *np,
}
}
- p = nfs_initialize_rpc (NFSPROC_SETATTR, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_SETATTR (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_sattr_mode (p, mode);
@@ -214,7 +216,8 @@ netfs_attempt_utimes (struct netcred *cred, struct node *np,
void *rpcbuf;
error_t err;
- p = nfs_initialize_rpc (NFSPROC_SETATTR, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_SETATTR (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_sattr_times (p, atime, mtime);
@@ -239,7 +242,8 @@ netfs_attempt_set_size (struct netcred *cred, struct node *np,
void *rpcbuf;
error_t err;
- p = nfs_initialize_rpc (NFSPROC_SETATTR, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_SETATTR (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_sattr_size (p, size);
@@ -264,7 +268,7 @@ netfs_attempt_statfs (struct netcred *cred, struct node *np,
void *rpcbuf;
error_t err;
- p = nfs_initialize_rpc (NFSPROC_STATFS, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFS2PROC_STATFS, cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
err = conduct_rpc (&rpcbuf, &p);
@@ -327,7 +331,8 @@ netfs_attempt_read (struct netcred *cred, struct node *np,
if (thisamt > read_size)
thisamt = read_size;
- p = nfs_initialize_rpc (NFSPROC_READ, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_READ (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
*p++ = htonl (offset);
*p++ = htonl (thisamt);
@@ -383,7 +388,8 @@ netfs_attempt_write (struct netcred *cred, struct node *np,
if (thisamt > write_size)
thisamt = write_size;
- p = nfs_initialize_rpc (NFSPROC_WRITE, cred, thisamt, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_WRITE (protocol_version),
+ cred, thisamt, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
*p++ = 0;
*p++ = htonl (offset);
@@ -418,7 +424,8 @@ verify_nonexistent (struct netcred *cred, struct node *dir,
void *rpcbuf;
error_t err;
- p = nfs_initialize_rpc (NFSPROC_LOOKUP, cred, 0, &rpcbuf, dir, -1);
+ p = nfs_initialize_rpc (NFSPROC_LOOKUP (protocol_version),
+ cred, 0, &rpcbuf, dir, -1);
p = xdr_encode_fhandle (p, &dir->nn->handle);
p = xdr_encode_string (p, name);
@@ -443,7 +450,8 @@ netfs_attempt_lookup (struct netcred *cred, struct node *np,
void *rpcbuf;
error_t err;
- p = nfs_initialize_rpc (NFSPROC_LOOKUP, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_LOOKUP (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_string (p, name);
@@ -456,7 +464,7 @@ netfs_attempt_lookup (struct netcred *cred, struct node *np,
if (!err)
{
*newnp = lookup_fhandle (p);
- p += NFS_FHSIZE / sizeof (int);
+ p += NFS2_FHSIZE / sizeof (int);
register_fresh_stat (*newnp, p);
}
else
@@ -477,7 +485,8 @@ netfs_attempt_mkdir (struct netcred *cred, struct node *np,
void *rpcbuf;
error_t err;
- p = nfs_initialize_rpc (NFSPROC_MKDIR, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_MKDIR (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_string (p, name);
p = xdr_encode_create_state (p, mode);
@@ -505,7 +514,8 @@ netfs_attempt_rmdir (struct netcred *cred, struct node *np,
/* Should we do the same sort of thing here as with attempt_unlink? */
- p = nfs_initialize_rpc (NFSPROC_RMDIR, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_RMDIR (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_string (p, name);
@@ -539,7 +549,8 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
case POSSIBLE:
case NOT_POSSIBLE:
mutex_lock (&dir->lock);
- p = nfs_initialize_rpc (NFSPROC_LINK, cred, 0, &rpcbuf, dir, -1);
+ p = nfs_initialize_rpc (NFSPROC_LINK (protocol_version),
+ cred, 0, &rpcbuf, dir, -1);
mutex_unlock (&dir->lock);
mutex_lock (&np->lock);
@@ -561,7 +572,8 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
case SYMLINK:
mutex_lock (&dir->lock);
- p = nfs_initialize_rpc (NFSPROC_SYMLINK, cred, 0, &rpcbuf, dir, -1);
+ p = nfs_initialize_rpc (NFSPROC_SYMLINK (protocol_version),
+ cred, 0, &rpcbuf, dir, -1);
p = xdr_encode_fhandle (p, &dir->nn->handle);
mutex_unlock (&dir->lock);
@@ -589,7 +601,8 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
{
/* NFSPROC_SYMLINK stupidly does not pass back an
fhandle, so we have to fetch one now. */
- p = nfs_initialize_rpc (NFSPROC_LOOKUP, cred, 0, &rpcbuf, dir, -1);
+ p = nfs_initialize_rpc (NFSPROC_LOOKUP (protocol_version),
+ cred, 0, &rpcbuf, dir, -1);
p = xdr_encode_fhandle (p, &dir->nn->handle);
p = xdr_encode_string (p, name);
@@ -605,7 +618,7 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
{
mutex_lock (&np->lock);
recache_handle (np, p);
- p += NFS_FHSIZE / sizeof (int);
+ p += NFS2_FHSIZE / sizeof (int);
register_fresh_stat (np, p);
mutex_unlock (&np->lock);
}
@@ -624,7 +637,8 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
return err;
mutex_lock (&dir->lock);
- p = nfs_initialize_rpc (NFSPROC_CREATE, cred, 0, &rpcbuf, dir, -1);
+ p = nfs_initialize_rpc (NFSPROC_CREATE (protocol_version),
+ cred, 0, &rpcbuf, dir, -1);
p = xdr_encode_fhandle (p, &dir->nn->handle);
p = xdr_encode_string (p, name);
mutex_unlock (&dir->lock);
@@ -649,7 +663,7 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
mutex_lock (&np->lock);
recache_handle (np, p);
- p += NFS_FHSIZE / sizeof (int);
+ p += NFS2_FHSIZE / sizeof (int);
register_fresh_stat (np, p);
mutex_unlock (&np->lock);
@@ -737,7 +751,8 @@ netfs_attempt_create_file (struct netcred *cred, struct node *np,
if (err)
return err;
- p = nfs_initialize_rpc (NFSPROC_CREATE, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_CREATE (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
p = xdr_encode_string (p, name);
p = xdr_encode_create_state (p, mode);
@@ -751,7 +766,7 @@ netfs_attempt_create_file (struct netcred *cred, struct node *np,
if (!err)
{
*newnp = lookup_fhandle (p);
- p += NFS_FHSIZE / sizeof (int);
+ p += NFS2_FHSIZE / sizeof (int);
register_fresh_stat (*newnp, p);
}
else
@@ -822,7 +837,8 @@ netfs_attempt_unlink (struct netcred *cred, struct node *dir,
netfs_nput (np);
mutex_lock (&dir->lock);
- p = nfs_initialize_rpc (NFSPROC_REMOVE, cred, 0, &rpcbuf, dir, -1);
+ p = nfs_initialize_rpc (NFSPROC_REMOVE (protocol_version),
+ cred, 0, &rpcbuf, dir, -1);
p = xdr_encode_fhandle (p, &dir->nn->handle);
p = xdr_encode_string (p, name);
@@ -850,7 +866,8 @@ netfs_attempt_rename (struct netcred *cred, struct node *fromdir,
return EOPNOTSUPP; /* XXX */
mutex_lock (&fromdir->lock);
- p = nfs_initialize_rpc (NFSPROC_RENAME, cred, 0, &rpcbuf, fromdir, -1);
+ p = nfs_initialize_rpc (NFSPROC_RENAME (protocol_version),
+ cred, 0, &rpcbuf, fromdir, -1);
p = xdr_encode_fhandle (p, &fromdir->nn->handle);
p = xdr_encode_string (p, fromname);
mutex_unlock (&fromdir->lock);
@@ -884,7 +901,8 @@ netfs_attempt_readlink (struct netcred *cred, struct node *np,
return 0;
}
- p = nfs_initialize_rpc (NFSPROC_READLINK, cred, 0, &rpcbuf, np, -1);
+ p = nfs_initialize_rpc (NFSPROC_READLINK (protocol_version),
+ cred, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
err = conduct_rpc (&rpcbuf, &p);
@@ -1139,7 +1157,8 @@ fetch_directory (struct netcred *cred, struct node *dir,
while (!eof)
{
/* Fetch new directory entries */
- p = nfs_initialize_rpc (NFSPROC_READDIR, cred, 0, &rpcbuf, dir, -1);
+ p = nfs_initialize_rpc (NFSPROC_READDIR (protocol_version),
+ cred, 0, &rpcbuf, dir, -1);
p = xdr_encode_fhandle (p, &dir->nn->handle);
*p++ = cookie;
*p++ = ntohl (read_size);
diff --git a/nfs/rpcsvc/nfs_prot.h b/nfs/rpcsvc/nfs_prot.h
index a5af07e0..a51f7c9f 100644
--- a/nfs/rpcsvc/nfs_prot.h
+++ b/nfs/rpcsvc/nfs_prot.h
@@ -2,9 +2,13 @@
#define NFS_MAXDATA 8192
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
-#define NFS_FHSIZE 32
+#define NFS2_FHSIZE 32
+#define NFS3_FHSIZE 64
#define NFS_COOKIESIZE 4
#define NFS_FIFO_DEV -1
+#define NFS3_COOKIEVERFSIZE 8
+#define NFS3_CREATEVERFSIZE 8
+#define NFS3_WRITEVERFSIZE 8
#define NFSMODE_FMT 0170000
#define NFSMODE_DIR 0040000
#define NFSMODE_CHR 0020000
@@ -47,310 +51,83 @@ enum nfsstat {
NFSERR_JUKEBOX = 10008, /* v3 only */
#define NFSERR_TRYLATER NFSERR_JUKEBOX
};
-typedef enum nfsstat nfsstat;
-bool_t xdr_nfsstat();
enum ftype {
- NFNON = 0,
+ NF2NON = 0, /* v2 only */
NFREG = 1,
NFDIR = 2,
NFBLK = 3,
NFCHR = 4,
NFLNK = 5,
NFSOCK = 6,
- NFBAD = 7,
- NFFIFO = 8,
+ NF3FIFO = 7, /* v3 only */
+#define NF2BAD NF3FIFO /* v2 only */
+ NF2FIFO = 8, /* v2 only */
};
-typedef enum ftype ftype;
-bool_t xdr_ftype();
-
-
-struct nfs_fh {
- char data[NFS_FHSIZE];
-};
-typedef struct nfs_fh nfs_fh;
-bool_t xdr_nfs_fh();
-
-
-struct nfstime {
- u_int seconds;
- u_int useconds;
-};
-typedef struct nfstime nfstime;
-bool_t xdr_nfstime();
-
-
-struct fattr {
- ftype type;
- u_int mode;
- u_int nlink;
- u_int uid;
- u_int gid;
- u_int size;
- u_int blocksize;
- u_int rdev;
- u_int blocks;
- u_int fsid;
- u_int fileid;
- nfstime atime;
- nfstime mtime;
- nfstime ctime;
-};
-typedef struct fattr fattr;
-bool_t xdr_fattr();
-
-
-struct sattr {
- u_int mode;
- u_int uid;
- u_int gid;
- u_int size;
- nfstime atime;
- nfstime mtime;
-};
-typedef struct sattr sattr;
-bool_t xdr_sattr();
-
-
-typedef char *filename;
-bool_t xdr_filename();
-
-
-typedef char *nfspath;
-bool_t xdr_nfspath();
-
-
-struct attrstat {
- nfsstat status;
- union {
- fattr attributes;
- } attrstat_u;
-};
-typedef struct attrstat attrstat;
-bool_t xdr_attrstat();
-
-
-struct sattrargs {
- nfs_fh file;
- sattr attributes;
-};
-typedef struct sattrargs sattrargs;
-bool_t xdr_sattrargs();
-
-
-struct diropargs {
- nfs_fh dir;
- filename name;
-};
-typedef struct diropargs diropargs;
-bool_t xdr_diropargs();
-
-
-struct diropokres {
- nfs_fh file;
- fattr attributes;
-};
-typedef struct diropokres diropokres;
-bool_t xdr_diropokres();
-
-
-struct diropres {
- nfsstat status;
- union {
- diropokres diropres;
- } diropres_u;
-};
-typedef struct diropres diropres;
-bool_t xdr_diropres();
-
-
-struct readlinkres {
- nfsstat status;
- union {
- nfspath data;
- } readlinkres_u;
-};
-typedef struct readlinkres readlinkres;
-bool_t xdr_readlinkres();
-
-
-struct readargs {
- nfs_fh file;
- u_int offset;
- u_int count;
- u_int totalcount;
-};
-typedef struct readargs readargs;
-bool_t xdr_readargs();
-
-
-struct readokres {
- fattr attributes;
- struct {
- u_int data_len;
- char *data_val;
- } data;
-};
-typedef struct readokres readokres;
-bool_t xdr_readokres();
-
-
-struct readres {
- nfsstat status;
- union {
- readokres reply;
- } readres_u;
-};
-typedef struct readres readres;
-bool_t xdr_readres();
-
-
-struct writeargs {
- nfs_fh file;
- u_int beginoffset;
- u_int offset;
- u_int totalcount;
- struct {
- u_int data_len;
- char *data_val;
- } data;
-};
-typedef struct writeargs writeargs;
-bool_t xdr_writeargs();
-
-
-struct createargs {
- diropargs where;
- sattr attributes;
-};
-typedef struct createargs createargs;
-bool_t xdr_createargs();
-
-
-struct renameargs {
- diropargs from;
- diropargs to;
-};
-typedef struct renameargs renameargs;
-bool_t xdr_renameargs();
-
-
-struct linkargs {
- nfs_fh from;
- diropargs to;
-};
-typedef struct linkargs linkargs;
-bool_t xdr_linkargs();
-
-
-struct symlinkargs {
- diropargs from;
- nfspath to;
- sattr attributes;
-};
-typedef struct symlinkargs symlinkargs;
-bool_t xdr_symlinkargs();
-
-
-typedef char nfscookie[NFS_COOKIESIZE];
-bool_t xdr_nfscookie();
-
-
-struct readdirargs {
- nfs_fh dir;
- nfscookie cookie;
- u_int count;
-};
-typedef struct readdirargs readdirargs;
-bool_t xdr_readdirargs();
-
-
-struct entry {
- u_int fileid;
- filename name;
- nfscookie cookie;
- struct entry *nextentry;
-};
-typedef struct entry entry;
-bool_t xdr_entry();
-
-
-struct dirlist {
- entry *entries;
- bool_t eof;
-};
-typedef struct dirlist dirlist;
-bool_t xdr_dirlist();
-
-
-struct readdirres {
- nfsstat status;
- union {
- dirlist reply;
- } readdirres_u;
-};
-typedef struct readdirres readdirres;
-bool_t xdr_readdirres();
-
-
-struct statfsokres {
- u_int tsize;
- u_int bsize;
- u_int blocks;
- u_int bfree;
- u_int bavail;
-};
-typedef struct statfsokres statfsokres;
-bool_t xdr_statfsokres();
-
-
-struct statfsres {
- nfsstat status;
- union {
- statfsokres reply;
- } statfsres_u;
-};
-typedef struct statfsres statfsres;
-bool_t xdr_statfsres();
-
#define NFS_PROGRAM ((u_long)100003)
#define NFS_VERSION ((u_long)2)
-#define NFSPROC_NULL ((u_long)0)
-extern void *nfsproc_null_2();
-#define NFSPROC_GETATTR ((u_long)1)
-extern attrstat *nfsproc_getattr_2();
-#define NFSPROC_SETATTR ((u_long)2)
-extern attrstat *nfsproc_setattr_2();
-#define NFSPROC_ROOT ((u_long)3)
-extern void *nfsproc_root_2();
-#define NFSPROC_LOOKUP ((u_long)4)
-extern diropres *nfsproc_lookup_2();
-#define NFSPROC_READLINK ((u_long)5)
-extern readlinkres *nfsproc_readlink_2();
-#define NFSPROC_READ ((u_long)6)
-extern readres *nfsproc_read_2();
-#define NFSPROC_WRITECACHE ((u_long)7)
-extern void *nfsproc_writecache_2();
-#define NFSPROC_WRITE ((u_long)8)
-extern attrstat *nfsproc_write_2();
-#define NFSPROC_CREATE ((u_long)9)
-extern diropres *nfsproc_create_2();
-#define NFSPROC_REMOVE ((u_long)10)
-extern nfsstat *nfsproc_remove_2();
-#define NFSPROC_RENAME ((u_long)11)
-extern nfsstat *nfsproc_rename_2();
-#define NFSPROC_LINK ((u_long)12)
-extern nfsstat *nfsproc_link_2();
-#define NFSPROC_SYMLINK ((u_long)13)
-extern nfsstat *nfsproc_symlink_2();
-#define NFSPROC_MKDIR ((u_long)14)
-extern diropres *nfsproc_mkdir_2();
-#define NFSPROC_RMDIR ((u_long)15)
-extern nfsstat *nfsproc_rmdir_2();
-#define NFSPROC_READDIR ((u_long)16)
-extern readdirres *nfsproc_readdir_2();
-#define NFSPROC_STATFS ((u_long)17)
-extern statfsres *nfsproc_statfs_2();
+
+#define NFS_PROTOCOL_FUNC(proc,vers) \
+ (vers == 2 ? NFS2PROC_ ## proc : NFS3PROC_ ## proc)
+
+#define NFSPROC_NULL(v) NFS_PROTOCOL_FUNC (NULL,v)
+#define NFSPROC_GETATTR(v) NFS_PROTOCOL_FUNC (GETATTR, v)
+#define NFSPROC_SETATTR(v) NFS_PROTOCOL_FUNC (SETATTR, v)
+#define NFSPROC_LOOKUP(v) NFS_PROTOCOL_FUNC (LOOKUP, v)
+#define NFSPROC_READLINK(v) NFS_PROTOCOL_FUNC (READLINK, v)
+#define NFSPROC_READ(v) NFS_PROTOCOL_FUNC (READ, v)
+#define NFSPROC_WRITE(v) NFS_PROTOCOL_FUNC (WRITE, v)
+#define NFSPROC_CREATE(v) NFS_PROTOCOL_FUNC (CREATE, v)
+#define NFSPROC_REMOVE(v) NFS_PROTOCOL_FUNC (REMOVE, v)
+#define NFSPROC_RENAME(v) NFS_PROTOCOL_FUNC (RENAME, v)
+#define NFSPROC_LINK(v) NFS_PROTOCOL_FUNC (LINK, v)
+#define NFSPROC_SYMLINK(v) NFS_PROTOCOL_FUNC (SYMLINK, v)
+#define NFSPROC_MKDIR(v) NFS_PROTOCOL_FUNC (MKDIR, v)
+#define NFSPROC_RMDIR(v) NFS_PROTOCOL_FUNC (RMDIR, v)
+#define NFSPROC_READDIR(v) NFS_PROTOCOL_FUNC (READDIR, v)
+
+/* Values for each protocol */
+#define NFS2PROC_NULL 0
+#define NFS2PROC_GETATTR 1
+#define NFS2PROC_SETATTR 2
+#define NFS2PROC_ROOT 3
+#define NFS2PROC_LOOKUP 4
+#define NFS2PROC_READLINK 5
+#define NFS2PROC_READ 6
+#define NFS2PROC_WRITECACHE 7
+#define NFS2PROC_WRITE 8
+#define NFS2PROC_CREATE 9
+#define NFS2PROC_REMOVE 10
+#define NFS2PROC_RENAME 11
+#define NFS2PROC_LINK 12
+#define NFS2PROC_SYMLINK 13
+#define NFS2PROC_MKDIR 14
+#define NFS2PROC_RMDIR 15
+#define NFS2PROC_READDIR 16
+#define NFS2PROC_STATFS 17
+
+#define NFS3PROC_NULL 0
+#define NFS3PROC_GETATTR 1
+#define NFS3PROC_SETATTR 2
+#define NFS3PROC_LOOKUP 3
+#define NFS3PROC_ACCESS 4
+#define NFS3PROC_READLINK 5
+#define NFS3PROC_READ 6
+#define NFS3PROC_WRITE 7
+#define NFS3PROC_CREATE 8
+#define NFS3PROC_MKDIR 9
+#define NFS3PROC_SYMLINK 10
+#define NFS3PROC_MKNOD 11
+#define NFS3PROC_REMOVE 12
+#define NFS3PROC_RMDIR 13
+#define NFS3PROC_RENAME 14
+#define NFS3PROC_LINK 15
+#define NFS3PROC_READDIR 16
+#define NFS3PROC_READDIRPLUS 17
+#define NFS3PROC_FSSTAT 18
+#define NFS3PROC_FSINFO 19
+#define NFS3PROC_PATHCONF 20
+#define NFS3PROC_COMMIT 21
diff --git a/nfsd/ChangeLog b/nfsd/ChangeLog
index 3fc876e2..744bd3b8 100644
--- a/nfsd/ChangeLog
+++ b/nfsd/ChangeLog
@@ -1,3 +1,16 @@
+Wed Aug 14 13:46:45 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * ops.c (nfstable): Renamed to nfs2table.
+ * nfsd.h (nfstable): Likewise.
+ * loop.c (server_loop): Reference nfs2table instead of nfstable.
+
+ * nfsd.h, cache.c, ops.c, xdr.c: Use new names for things that
+ have just been changed in ../nfs/rpcsvc/nfs_prot.h.
+ * xdr.c (hurd_mode_to_nfs_type): New parm VERSION; all callers
+ changed.
+ (encode_fattr): New parm VERSION; all callers changed.
+ * nfsd.h (encode_fattr): New parm VERSION.
+
Tue Aug 13 14:38:36 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* ops.c (op_create): Sun's NFS client implementation actually
diff --git a/nfsd/cache.c b/nfsd/cache.c
index 8b1ee134..29e64834 100644
--- a/nfsd/cache.c
+++ b/nfsd/cache.c
@@ -243,7 +243,7 @@ fh_hash (char *fhandle, struct idspec *i)
{
int hash = 0, n;
- for (n = 0; n < NFS_FHSIZE; n++)
+ for (n = 0; n < NFS2_FHSIZE; n++)
hash += fhandle[n];
hash += (int) i >> 6;
return hash % FHHASH_TABLE_SIZE;
@@ -260,14 +260,14 @@ lookup_cache_handle (int *p, struct cache_handle **cp, struct idspec *i)
hash = fh_hash ((char *)p, i);
mutex_lock (&fhhashlock);
for (c = fhhashtable[hash]; c; c = c->next)
- if (c->ids == i && ! bcmp (c->handle, p, NFS_FHSIZE))
+ if (c->ids == i && ! bcmp (c->handle, p, NFS2_FHSIZE))
{
if (c->references == 0)
nfreefh--;
c->references++;
mutex_unlock (&fhhashlock);
*cp = c;
- return p + NFS_FHSIZE / sizeof (int);
+ return p + NFS2_FHSIZE / sizeof (int);
}
/* Not found */
@@ -276,15 +276,15 @@ lookup_cache_handle (int *p, struct cache_handle **cp, struct idspec *i)
fsys = lookup_filesystem (*p);
if (fsys == MACH_PORT_NULL
|| fsys_getfile (fsys, i->uids, i->nuids, i->gids, i->ngids,
- (char *)(p + 1), NFS_FHSIZE - sizeof (int), &port))
+ (char *)(p + 1), NFS2_FHSIZE - sizeof (int), &port))
{
mutex_unlock (&fhhashlock);
*cp = 0;
- return p + NFS_FHSIZE / sizeof (int);
+ return p + NFS2_FHSIZE / sizeof (int);
}
c = malloc (sizeof (struct cache_handle));
- bcopy (p, c->handle, NFS_FHSIZE);
+ bcopy (p, c->handle, NFS2_FHSIZE);
cred_ref (i);
c->ids = i;
c->port = port;
@@ -298,7 +298,7 @@ lookup_cache_handle (int *p, struct cache_handle **cp, struct idspec *i)
mutex_unlock (&fhhashlock);
*cp = c;
- return p + NFS_FHSIZE / sizeof (int);
+ return p + NFS2_FHSIZE / sizeof (int);
}
void
@@ -351,12 +351,12 @@ scan_fhs ()
struct cache_handle *
create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
{
- char fhandle[NFS_FHSIZE];
+ char fhandle[NFS2_FHSIZE];
error_t err;
struct cache_handle *c;
int hash;
char *bp = fhandle + sizeof (int);
- size_t handlelen = NFS_FHSIZE - sizeof (int);
+ size_t handlelen = NFS2_FHSIZE - sizeof (int);
mach_port_t newport, ref;
/* Authenticate USERPORT so that we can call file_getfh on it. */
@@ -377,11 +377,11 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
*(int *)fhandle = fs;
err = file_getfh (newport, &bp, &handlelen);
mach_port_deallocate (mach_task_self (), newport);
- if (err || handlelen != NFS_FHSIZE - sizeof (int))
+ if (err || handlelen != NFS2_FHSIZE - sizeof (int))
return 0;
if (bp != fhandle + sizeof (int))
{
- bcopy (bp, fhandle + sizeof (int), NFS_FHSIZE - sizeof (int));
+ bcopy (bp, fhandle + sizeof (int), NFS2_FHSIZE - sizeof (int));
vm_deallocate (mach_task_self (), (vm_address_t) bp, handlelen);
}
@@ -389,7 +389,7 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
hash = fh_hash (fhandle, credc->ids);
mutex_lock (&fhhashlock);
for (c = fhhashtable[hash]; c; c = c->next)
- if (c->ids == credc->ids && ! bcmp (fhandle, c->handle, NFS_FHSIZE))
+ if (c->ids == credc->ids && ! bcmp (fhandle, c->handle, NFS2_FHSIZE))
{
/* Return this one */
if (c->references == 0)
@@ -405,7 +405,7 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
err = fsys_getfile (lookup_filesystem (fs),
credc->ids->uids, credc->ids->nuids,
credc->ids->gids, credc->ids->ngids,
- fhandle + sizeof (int), NFS_FHSIZE - sizeof (int),
+ fhandle + sizeof (int), NFS2_FHSIZE - sizeof (int),
&newport);
if (err)
{
@@ -415,7 +415,7 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
/* Create it anew */
c = malloc (sizeof (struct cache_handle));
- bcopy (fhandle, c->handle, NFS_FHSIZE);
+ bcopy (fhandle, c->handle, NFS2_FHSIZE);
cred_ref (credc->ids);
c->ids = credc->ids;
c->port = newport;
diff --git a/nfsd/loop.c b/nfsd/loop.c
index 38edae62..7d047490 100644
--- a/nfsd/loop.c
+++ b/nfsd/loop.c
@@ -101,7 +101,7 @@ server_loop (int fd)
case NFS_PROGRAM:
version = NFS_VERSION;
- table = &nfstable;
+ table = &nfs2table;
break;
case PMAPPROG:
diff --git a/nfsd/nfsd.h b/nfsd/nfsd.h
index c8ec86e2..d6d7aac9 100644
--- a/nfsd/nfsd.h
+++ b/nfsd/nfsd.h
@@ -46,7 +46,7 @@ struct idspec
struct cache_handle
{
struct cache_handle *next, **prevp;
- char handle[NFS_FHSIZE];
+ char handle[NFS2_FHSIZE];
struct idspec *ids;
file_t port;
time_t lastuse;
@@ -113,11 +113,11 @@ void scan_replies (void);
void server_loop (int);
/* ops.c */
-extern struct proctable nfstable, mounttable, pmaptable;
+extern struct proctable nfs2table, mounttable, pmaptable;
/* xdr.c */
int nfs_error_trans (error_t, int);
-int *encode_fattr (int *, struct stat *);
+int *encode_fattr (int *, struct stat *, int version);
int *decode_name (int *, char **);
int *encode_fhandle (int *, char *);
int *encode_string (int *, char *);
diff --git a/nfsd/ops.c b/nfsd/ops.c
index 4319d226..efcfa103 100644
--- a/nfsd/ops.c
+++ b/nfsd/ops.c
@@ -49,7 +49,7 @@ op_getattr (struct cache_handle *c,
err = io_stat (c->port, &st);
if (!err)
- *reply = encode_fattr (*reply, &st);
+ *reply = encode_fattr (*reply, &st, version);
return err;
}
@@ -133,7 +133,7 @@ op_setattr (struct cache_handle *c,
if (err)
return err;
- *reply = encode_fattr (*reply, &st);
+ *reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -173,7 +173,7 @@ op_lookup (struct cache_handle *c,
if (!newc)
return ESTALE;
*reply = encode_fhandle (*reply, newc->handle);
- *reply = encode_fattr (*reply, &st);
+ *reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -232,7 +232,7 @@ op_read (struct cache_handle *c,
if (err)
return err;
- *reply = encode_fattr (*reply, &st);
+ *reply = encode_fattr (*reply, &st, version);
*reply = encode_data (*reply, bp, buflen);
return 0;
}
@@ -273,7 +273,7 @@ op_write (struct cache_handle *c,
err = io_stat (c->port, &st);
if (err)
return err;
- *reply = encode_fattr (*reply, &st);
+ *reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -345,7 +345,7 @@ op_create (struct cache_handle *c,
return ESTALE;
*reply = encode_fhandle (*reply, newc->handle);
- *reply = encode_fattr (*reply, &st);
+ *reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -500,7 +500,7 @@ op_mkdir (struct cache_handle *c,
if (!newc)
return ESTALE;
*reply = encode_fhandle (*reply, newc->handle);
- *reply = encode_fattr (*reply, &st);
+ *reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -649,10 +649,10 @@ op_getport (struct cache_handle *c,
}
-struct proctable nfstable =
+struct proctable nfs2table =
{
- NFSPROC_NULL, /* first proc */
- NFSPROC_STATFS, /* last proc */
+ NFS2PROC_NULL, /* first proc */
+ NFS2PROC_STATFS, /* last proc */
{
{ op_null, 0, 0, 0},
{ op_getattr, 0, 1, 1},
diff --git a/nfsd/xdr.c b/nfsd/xdr.c
index 57ee1fdf..cb954e75 100644
--- a/nfsd/xdr.c
+++ b/nfsd/xdr.c
@@ -31,7 +31,7 @@ hurd_mode_to_nfs_mode (mode_t m)
}
static int
-hurd_mode_to_nfs_type (mode_t m)
+hurd_mode_to_nfs_type (mode_t m, int version)
{
switch (m & S_IFMT)
{
@@ -54,18 +54,18 @@ hurd_mode_to_nfs_type (mode_t m)
return NFSOCK;
case S_IFIFO:
- return NFFIFO;
+ return (version == 2 ? NF2FIFO : NF3FIFO);
default:
- return NFNON;
+ return (version == 2 ? NF2NON : NFREG);
}
}
/* Encode ST into P and return the next thing to come after it. */
int *
-encode_fattr (int *p, struct stat *st)
+encode_fattr (int *p, struct stat *st, int version)
{
- *p++ = htonl (hurd_mode_to_nfs_type (st->st_mode));
+ *p++ = htonl (hurd_mode_to_nfs_type (st->st_mode, version));
*p++ = htonl (hurd_mode_to_nfs_mode (st->st_mode));
*p++ = htonl (st->st_nlink);
*p++ = htonl (st->st_uid);
@@ -102,8 +102,8 @@ decode_name (int *p, char **name)
int *
encode_fhandle (int *p, char *handle)
{
- bcopy (handle, p, NFS_FHSIZE);
- return p + INTSIZE (NFS_FHSIZE);
+ bcopy (handle, p, NFS2_FHSIZE);
+ return p + INTSIZE (NFS2_FHSIZE);
}
/* Encode STRING into P and return the next thing to come after it. */