diff options
Diffstat (limited to 'nfs')
-rw-r--r-- | nfs/ChangeLog | 60 | ||||
-rw-r--r-- | nfs/cache.c | 8 | ||||
-rw-r--r-- | nfs/mount.c | 2 | ||||
-rw-r--r-- | nfs/nfs.c | 40 | ||||
-rw-r--r-- | nfs/nfs.h | 2 | ||||
-rw-r--r-- | nfs/ops.c | 71 | ||||
-rw-r--r-- | nfs/rpcsvc/nfs_prot.h | 365 |
7 files changed, 213 insertions, 335 deletions
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); @@ -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; @@ -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; @@ -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 |