diff options
| author | Doug Rabson <dfr@FreeBSD.org> | 1997-05-14 08:19:35 +0000 |
|---|---|---|
| committer | Doug Rabson <dfr@FreeBSD.org> | 1997-05-14 08:19:35 +0000 |
| commit | 7877839a2284d0e299b306b069ff12c2aaaad5fb (patch) | |
| tree | 4bdc3ad79d5dc9b6724b63916234bf5f8a25e963 | |
| parent | a53a472ff45ef555aba613ffd352246bc46a2c48 (diff) | |
Notes
29 files changed, 1621 insertions, 1711 deletions
diff --git a/include/rpcsvc/mount.x b/include/rpcsvc/mount.x index 758b47cfbdd1..0a744c56931d 100644 --- a/include/rpcsvc/mount.x +++ b/include/rpcsvc/mount.x @@ -35,13 +35,16 @@ %#ifndef lint %/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/ %/*static char sccsid[] = "from: @(#)mount.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: mount.x,v 1.1 1993/09/14 17:42:43 jtc Exp $"; +%static char rcsid[] = "$Id: mount.x,v 1.1 1994/08/04 19:01:46 wollman Exp $"; %#endif /* not lint */ #endif const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ const MNTNAMLEN = 255; /* maximum bytes in a name argument */ const FHSIZE = 32; /* size in bytes of a file handle */ +#ifdef WANT_NFS3 +const FHSIZE3 = 64; /* size in bytes of a file handle (v3) */ +#endif /* * The fhandle is the file handle that the server passes to the client. @@ -50,6 +53,9 @@ const FHSIZE = 32; /* size in bytes of a file handle */ * server needs to distinguish an individual file. */ typedef opaque fhandle[FHSIZE]; +#ifdef WANT_NFS3 +typedef opaque fhandle3<FHSIZE3>; +#endif /* * If a status of zero is returned, the call completed successfully, and @@ -63,6 +69,36 @@ default: void; }; +#ifdef WANT_NFS3 +/* + * Status codes returned by the version 3 mount call. + */ +enum mountstat3 { + MNT3_OK = 0, /* no error */ + MNT3ERR_PERM = 1, /* Not owner */ + MNT3ERR_NOENT = 2, /* No such file or directory */ + MNT3ERR_IO = 5, /* I/O error */ + MNT3ERR_ACCES = 13, /* Permission denied */ + MNT3ERR_NOTDIR = 20, /* Not a directory */ + MNT3ERR_INVAL = 22, /* Invalid argument */ + MNT3ERR_NAMETOOLONG = 63, /* Filename too long */ + MNT3ERR_NOTSUPP = 10004, /* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */ +}; + +struct mountres3_ok { + fhandle3 fhandle; + int auth_flavors<>; +}; + +union mountres3 switch (mountstat3 fhs_status) { +case 0: + mountres3_ok mountinfo; +default: + void; +}; +#endif + /* * The type dirpath is the pathname of a directory */ @@ -105,8 +141,10 @@ struct exportnode { program MOUNTPROG { /* * Version one of the mount protocol communicates with version two - * of the NFS protocol. The only connecting point is the fhandle - * structure, which is the same for both protocols. + * of the NFS protocol. Version three communicates with + * version three of the NFS protocol. The only connecting + * point is the fhandle structure, which is the same for both + * protocols. */ version MOUNTVERS { /* @@ -162,4 +200,57 @@ program MOUNTPROG { exports MOUNTPROC_EXPORTALL(void) = 6; } = 1; +#ifdef WANT_NFS3 + version MOUNTVERS3 { + /* + * Does no work. It is made available in all RPC services + * to allow server reponse testing and timing + */ + void + MOUNTPROC_NULL(void) = 0; + + /* + * If mountres3.fhs_status is MNT3_OK, then + * mountres3.mountinfo contains the file handle for + * the directory and a list of acceptable + * authentication flavors. This file handle may only + * be used in the NFS version 3 protocol. This + * procedure also results in the server adding a new + * entry to its mount list recording that this client + * has mounted the directory. AUTH_UNIX authentication + * or better is required. + */ + mountres3 + MOUNTPROC_MNT(dirpath) = 1; + + /* + * Returns the list of remotely mounted filesystems. The + * mountlist contains one entry for each hostname and + * directory pair. + */ + mountlist + MOUNTPROC_DUMP(void) = 2; + + /* + * Removes the mount list entry for the directory + * Unix authentication required. + */ + void + MOUNTPROC_UMNT(dirpath) = 3; + + /* + * Removes all of the mount list entries for this client + * Unix authentication required. + */ + void + MOUNTPROC_UMNTALL(void) = 4; + + /* + * Returns a list of all the exported filesystems, and which + * machines are allowed to import it. + */ + exports + MOUNTPROC_EXPORT(void) = 5; + } = 3; +#endif } = 100005; diff --git a/include/rpcsvc/nfs_prot.x b/include/rpcsvc/nfs_prot.x index 74d46ba5300b..7b98dbd5fac9 100644 --- a/include/rpcsvc/nfs_prot.x +++ b/include/rpcsvc/nfs_prot.x @@ -31,7 +31,7 @@ %#ifndef lint %/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/ %/*static char sccsid[] = "from: @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: nfs_prot.x,v 1.1 1993/09/14 17:42:44 jtc Exp $"; +%static char rcsid[] = "$Id: nfs_prot.x,v 1.1 1994/08/04 19:01:47 wollman Exp $"; %#endif /* not lint */ #endif @@ -294,6 +294,842 @@ default: void; }; +#ifdef WANT_NFS3 + +/* + * NFSv3 constants and types + */ +const NFS3_FHSIZE = 64; /* maximum size in bytes of a file handle */ +const NFS3_COOKIEVERFSIZE = 8; /* size of a cookie verifier for READDIR */ +const NFS3_CREATEVERFSIZE = 8; /* size of the verifier used for CREATE */ +const NFS3_WRITEVERFSIZE = 8; /* size of the verifier used for WRITE */ + +typedef unsigned hyper uint64; +typedef hyper int64; +typedef unsigned long uint32; +typedef long int32; +typedef string filename3<>; +typedef string nfspath3<>; +typedef uint64 fileid3; +typedef uint64 cookie3; +typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; +typedef opaque createverf3[NFS3_CREATEVERFSIZE]; +typedef opaque writeverf3[NFS3_WRITEVERFSIZE]; +typedef uint32 uid3; +typedef uint32 gid3; +typedef uint64 size3; +typedef uint64 offset3; +typedef uint32 mode3; +typedef uint32 count3; + +/* + * Error status (v3) + */ +enum nfsstat3 { + NFS3_OK = 0, + NFS3ERR_PERM = 1, + NFS3ERR_NOENT = 2, + NFS3ERR_IO = 5, + NFS3ERR_NXIO = 6, + NFS3ERR_ACCES = 13, + NFS3ERR_EXIST = 17, + NFS3ERR_XDEV = 18, + NFS3ERR_NODEV = 19, + NFS3ERR_NOTDIR = 20, + NFS3ERR_ISDIR = 21, + NFS3ERR_INVAL = 22, + NFS3ERR_FBIG = 27, + NFS3ERR_NOSPC = 28, + NFS3ERR_ROFS = 30, + NFS3ERR_MLINK = 31, + NFS3ERR_NAMETOOLONG = 63, + NFS3ERR_NOTEMPTY = 66, + NFS3ERR_DQUOT = 69, + NFS3ERR_STALE = 70, + NFS3ERR_REMOTE = 71, + NFS3ERR_BADHANDLE = 10001, + NFS3ERR_NOT_SYNC = 10002, + NFS3ERR_BAD_COOKIE = 10003, + NFS3ERR_NOTSUPP = 10004, + NFS3ERR_TOOSMALL = 10005, + NFS3ERR_SERVERFAULT = 10006, + NFS3ERR_BADTYPE = 10007, + NFS3ERR_JUKEBOX = 10008 +}; + +/* + * File types (v3) + */ +enum ftype3 { + NF3REG = 1, /* regular file */ + NF3DIR = 2, /* directory */ + NF3BLK = 3, /* block special */ + NF3CHR = 4, /* character special */ + NF3LNK = 5, /* symbolic link */ + NF3SOCK = 6, /* unix domain sockets */ + NF3FIFO = 7 /* named pipe */ +}; + +struct specdata3 { + uint32 specdata1; + uint32 specdata2; +}; + +/* + * File access handle (v3) + */ +struct nfs_fh3 { + opaque data<NFS3_FHSIZE>; +}; + +/* + * Timeval (v3) + */ +struct nfstime3 { + uint32 seconds; + uint32 nseconds; +}; + + +/* + * File attributes (v3) + */ +struct fattr3 { + ftype3 type; /* file type */ + mode3 mode; /* protection mode bits */ + uint32 nlink; /* # hard links */ + uid3 uid; /* owner user id */ + gid3 gid; /* owner group id */ + size3 size; /* file size in bytes */ + size3 used; /* prefered block size */ + specdata3 rdev; /* special device # */ + uint64 fsid; /* device # */ + fileid3 fileid; /* inode # */ + nfstime3 atime; /* time of last access */ + nfstime3 mtime; /* time of last modification */ + nfstime3 ctime; /* time of last change */ +}; + +union post_op_attr switch (bool attributes_follow) { +case TRUE: + fattr3 attributes; +case FALSE: + void; +}; + +struct wcc_attr { + size3 size; + nfstime3 mtime; + nfstime3 ctime; +}; + +union pre_op_attr switch (bool attributes_follow) { +case TRUE: + wcc_attr attributes; +case FALSE: + void; +}; + +struct wcc_data { + pre_op_attr before; + post_op_attr after; +}; + +union post_op_fh3 switch (bool handle_follows) { +case TRUE: + nfs_fh3 handle; +case FALSE: + void; +}; + +/* + * File attributes which can be set (v3) + */ +enum time_how { + DONT_CHANGE = 0, + SET_TO_SERVER_TIME = 1, + SET_TO_CLIENT_TIME = 2 +}; + +union set_mode3 switch (bool set_it) { +case TRUE: + mode3 mode; +default: + void; +}; + +union set_uid3 switch (bool set_it) { +case TRUE: + uid3 mode; +default: + void; +}; + +union set_gid3 switch (bool set_it) { +case TRUE: + gid3 mode; +default: + void; +}; + +union set_size3 switch (bool set_it) { +case TRUE: + size3 mode; +default: + void; +}; + +union set_atime switch (time_how set_it) { +case SET_TO_CLIENT_TIME: + atime mode; +default: + void; +}; + +union set_mtime switch (time_how set_it) { +case SET_TO_CLIENT_TIME: + mtime mode; +default: + void; +}; + +struct sattr3 { + set_mode3 mode; + set_uid3 uid; + set_gid3 gid; + set_size3 size; + set_atime atime; + set_mtime mtime; +}; + +/* + * Arguments for directory operations (v3) + */ +struct diropargs3 { + nfs_fh3 dir; /* directory file handle */ + filename3 name; /* name (up to NFS_MAXNAMLEN bytes) */ +}; + +/* + * Arguments to getattr (v3). + */ +struct GETATTR3args { + nfs_fh3 object; +}; + +struct GETATTR3resok { + fattr3 obj_attributes; +}; + +union GETATTR3res switch (nfsstat3 status) { +case NFS3_OK: + GETATTR3resok resok; +default: + void; +}; + +/* + * Arguments to setattr (v3). + */ +union sattrguard3 switch (bool check) { +case TRUE: + nfstime3 obj_ctime; +case FALSE: + void; +}; + +struct SETATTR3args { + nfs_fh3 object; + sattr3 new_attributes; + sattrguard3 guard; +}; + +struct SETATTR3resok { + wcc_data obj_wcc; +}; + +struct SETATTR3resfail { + wcc_data obj_wcc; +}; + +union SETATTR3res switch (nfsstat3 status) { +case NFS3_OK: + SETATTR3resok resok; +default: + SETATTR3resfail resfail; +}; + +/* + * Arguments to lookup (v3). + */ +struct LOOKUP3args { + diropargs3 what; +}; + +struct LOOKUP3resok { + nfs_fh3 object; + post_op_attr obj_attributes; + post_op_attr dir_attributes; +}; + +struct LOOKUP3resfail { + post_op_attr dir_attributes; +}; + +union LOOKUP3res switch (nfsstat3 status) { +case NFS3_OK: + LOOKUP3resok resok; +default: + LOOKUP3resfail resfail; +}; + +/* + * Arguments to access (v3). + */ +const ACCESS3_READ = 0x0001; +const ACCESS3_LOOKUP = 0x0002; +const ACCESS3_MODIFY = 0x0004; +const ACCESS3_EXTEND = 0x0008; +const ACCESS3_DELETE = 0x0010; +const ACCESS3_EXECUTE = 0x0020; + +struct ACCESS3args { + nfs_fh3 object; + uint32 access; +}; + +struct ACCESS3resok { + post_op_attr obj_attributes; + uint32 access; +}; + +struct ACCESS3resfail { + post_op_attr obj_attributes; +}; + +union ACCESS3res switch (nfsstat3 status) { +case NFS3_OK: + ACCESS3resok resok; +default: + ACCESS3resfail resfail; +}; + +/* + * Arguments to readlink (v3). + */ +struct READLINK3args { + nfs_fh3 symlink; +}; + +struct READLINK3resok { + post_op_attr symlink_attributes; + nfspath3 data; +}; + +struct READLINK3resfail { + post_op_attr symlink_attributes; +}; + +union READLINK3res switch (nfsstat3 status) { +case NFS3_OK: + READLINK3resok resok; +default: + READLINK3resfail resfail; +}; + +/* + * Arguments to read (v3). + */ +struct READ3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; + +struct READ3resok { + post_op_attr file_attributes; + count3 count; + bool eof; + opaque data<>; +}; + +struct READ3resfail { + post_op_attr file_attributes; +}; + +union READ3res switch (nfsstat3 status) { +case NFS3_OK: + READ3resok resok; +default: + READ3resfail resfail; +}; + +/* + * Arguments to write (v3). + */ +enum stable_how { + UNSTABLE = 0, + DATA_SYNC = 1, + FILE_SYNC = 2 +}; + +struct WRITE3args { + nfs_fh3 file; + offset3 offset; + count3 count; + stable_how stable; + opaque data<>; +}; + +struct WRITE3resok { + wcc_data file_wcc; + count3 count; + stable_how comitted; + writeverf3 verf; +}; + +struct WRITE3resfail { + wcc_data file_wcc; +}; + +union WRITE3res switch (nfsstat3 status) { +case NFS3_OK: + WRITE3resok resok; +default: + WRITE3resfail resfail; +}; + +/* + * Arguments to create (v3). + */ +enum createmode3 { + UNCHECKED = 0, + GUARDED = 1, + EXCLUSIVE = 2 +}; + +union createhow3 switch (createmode3 mode) { +case UNCHECKED: +case GUARDED: + sattr3 obj_attributes; +case EXCLUSIVE: + createverf3 verf; +}; + +struct CREATE3args { + diropargs3 where; + createhow3 how; +}; + +struct CREATE3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct CREATE3resfail { + wcc_data dir_wcc; +}; + +union CREATE3res switch (nfsstat3 status) { +case NFS3_OK: + CREATE3resok resok; +default: + CREATE3resfail resfail; +}; + +/* + * Arguments to mkdir (v3). + */ +struct MKDIR3args { + diropargs3 where; + sattr3 attributes; +}; + +struct MKDIR3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct MKDIR3resfail { + wcc_data dir_wcc; +}; + +union MKDIR3res switch (nfsstat3 status) { +case NFS3_OK: + MKDIR3resok resok; +default: + MKDIR3resfail resfail; +}; + +/* + * Arguments to symlink (v3). + */ +struct symlinkdata3 { + sattr3 symlink_attributes; + nfspath3 symlink_data; +}; + +struct SYMLINK3args { + diropargs3 where; + symlinkdata3 symlink; +}; + +struct SYMLINK3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct SYMLINK3resfail { + wcc_data dir_wcc; +}; + +union SYMLINK3res switch (nfsstat3 status) { +case NFS3_OK: + SYMLINK3resok resok; +default: + SYMLINK3resfail resfail; +}; + +/* + * Arguments to mknod (v3). + */ +struct devicedata3 { + sattr3 dev_attributes; + specdata3 spec; +}; + +union mknoddata3 switch (ftype3 type) { +case NF3CHR: +case NF3BLK: + devicedata3 device; +case NF3SOCK: +case NF3FIFO: + sattr3 pipe_attributes; +default: + void; +}; + +struct MKNOD3args { + diropargs3 where; + mknoddata3 what; +}; + +struct MKNOD3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct MKNOD3resfail { + wcc_data dir_wcc; +}; + +union MKNOD3res switch (nfsstat3 status) { +case NFS3_OK: + MKNOD3resok resok; +default: + MKNOD3resfail resfail; +}; + +/* + * Arguments to remove (v3). + */ +struct REMOVE3args { + diropargs3 object; +}; + +struct REMOVE3resok { + wcc_data dir_wcc; +}; + +struct REMOVE3resfail { + wcc_data dir_wcc; +}; + +union REMOVE3res switch (nfsstat3 status) { +case NFS3_OK: + REMOVE3resok resok; +default: + REMOVE3resfail resfail; +}; + +/* + * Arguments to rmdir (v3). + */ +struct RMDIR3args { + diropargs3 object; +}; + +struct RMDIR3resok { + wcc_data dir_wcc; +}; + +struct RMDIR3resfail { + wcc_data dir_wcc; +}; + +union RMDIR3res switch (nfsstat3 status) { +case NFS3_OK: + RMDIR3resok resok; +default: + RMDIR3resfail resfail; +}; + +/* + * Arguments to rename (v3). + */ +struct RENAME3args { + diropargs3 from; + diropargs3 to; +}; + +struct RENAME3resok { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; + +struct RENAME3resfail { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; + +union RENAME3res switch (nfsstat3 status) { +case NFS3_OK: + RENAME3resok resok; +default: + RENAME3resfail resfail; +}; + +/* + * Arguments to link (v3). + */ +struct LINK3args { + nfs_fh3 file; + diropargs3 link; +}; + +struct LINK3resok { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; + +struct LINK3resfail { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; + +union LINK3res switch (nfsstat3 status) { +case NFS3_OK: + LINK3resok resok; +default: + LINK3resfail resfail; +}; + +/* + * Arguments to readdir (v3). + */ +struct READDIR3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 count; +}; + +struct entry3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + entry3 *nextentry; +}; + +struct dirlist3 { + entry3 *entries; + bool eof; +}; + +struct READDIR3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlist3 reply; +}; + +struct READDIR3resfail { + post_op_attr dir_attributes; +}; + +union READDIR3res switch (nfsstat3 status) { +case NFS3_OK: + READDIR3resok resok; +default: + READDIR3resfail resfail; +}; + +/* + * Arguments to readdirplus (v3). + */ +struct READDIRPLUS3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 dircount; + count3 maxcount; +}; + +struct entryplus3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + post_op_attr name_attributes; + post_op_fh3 name_handle; + entryplus3 *nextentry; +}; + +struct dirlistplus3 { + entryplus3 *entries; + bool eof; +}; + +struct READDIRPLUS3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlistplus3 reply; +}; + +struct READDIRPLUS3resfail { + post_op_attr dir_attributes; +}; + +union READDIRPLUS3res switch (nfsstat3 status) { +case NFS3_OK: + READDIRPLUS3resok resok; +default: + READDIRPLUS3resfail resfail; +}; + +/* + * Arguments to fsstat (v3). + */ +struct FSSTAT3args { + nfs_fh3 fsroot; +}; + +struct FSSTAT3resok { + post_op_attr obj_attributes; + size3 tbytes; + size3 fbytes; + size3 abytes; + size3 tfiles; + size3 ffiles; + size3 afiles; + uint32 invarsec; +}; + +struct FSSTAT3resfail { + post_op_attr obj_attributes; +}; + +union FSSTAT3res switch (nfsstat3 status) { +case NFS3_OK: + FSSTAT3resok resok; +default: + FSSTAT3resfail resfail; +}; + +/* + * Arguments to fsinfo (v3). + */ +const FSF3_LINK = 0x0001; +const FSF3_SYMLINK = 0x0002; +const FSF3_HOMOGENEOUS = 0x0008; +const FSF3_CANSETTIME = 0x0010; + +struct FSINFO3args { + nfs_fh3 fsroot; +}; + +struct FSINFO3resok { + post_op_attr obj_attributes; + uint32 rtmax; + uint32 rtpref; + uint32 rtmult; + uint32 wtmax; + uint32 wtpref; + uint32 wtmult; + uint32 dtpref; + size3 maxfilesize; + nfstime3 time_delta; + uint32 properties; +}; + +struct FSINFO3resfail { + post_op_attr obj_attributes; +}; + +union FSINFO3res switch (nfsstat3 status) { +case NFS3_OK: + FSINFO3resok resok; +default: + FSINFO3resfail resfail; +}; + +/* + * Arguments to pathconf (v3). + */ +struct PATHCONF3args { + nfs_fh3 object; +}; + +struct PATHCONF3resok { + post_op_attr obj_attributes; + uint32 linkmax; + uint32 name_max; + bool no_trunc; + bool chown_restricted; + bool case_insensitive; + bool case_preserving; +}; + +struct PATHCONF3resfail { + post_op_attr obj_attributes; +}; + +union PATHCONF3res switch (nfsstat3 status) { +case NFS3_OK: + FSINFO3resok resok; +default: + FSINFO3resfail resfail; +}; + +/* + * Arguments to commit (v3). + */ +struct COMMIT3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; + +struct COMMIT3resok { + wcc_data file_wcc; + writeverf3 verf; +}; + +struct COMMIT3resfail { + wcc_data file_wcc; +}; + +union COMMIT3res switch (nfsstat3 status) { +case NFS3_OK: + FSINFO3resok resok; +default: + FSINFO3resfail resfail; +}; + +#endif /* WANT_NFS3 */ + /* * Remote file service routines */ @@ -353,5 +1189,75 @@ program NFS_PROGRAM { statfsres NFSPROC_STATFS(nfs_fh) = 17; } = 2; +#ifdef WANT_NFS3 + version NFS_V3 { + void + NFSPROC3_NULL(void) = 0; + + GETATTR3res + NFSPROC3_GETATTR(GETATTR3args) = 1; + + SETATTR3res + NFSPROC3_SETATTR(SETATTR3args) = 2; + + LOOKUP3res + NFSPROC3_LOOKUP(LOOKUP3args) = 3; + + ACCESS3res + NFSPROC3_ACCESS(ACCESS3args) = 4; + + READLINK3res + NFSPROC3_READLINK(READLINK3args) = 5; + + READ3res + NFSPROC3_READ(READ3args) = 6; + + WRITE3res + NFSPROC3_WRITE(WRITE3args) = 7; + + CREATE3res + NFSPROC3_CREATE(CREATE3args) = 8; + + MKDIR3res + NFSPROC3_MKDIR(MKDIR3args) = 9; + + SYMLINK3res + NFSPROC3_SYMLINK(SYMLINK3args) = 10; + + MKNOD3res + NFSPROC3_MKNOD(MKNOD3args) = 11; + + REMOVE3res + NFSPROC3_REMOVE(REMOVE3args) = 12; + + RMDIR3res + NFSPROC3_RMDIR(RMDIR3args) = 13; + + RENAME3res + NFSPROC3_RENAME(RENAME3args) = 14; + + LINK3res + NFSPROC3_LINK(LINK3args) = 15; + + READDIR3res + NFSPROC3_READDIR(READDIR3args) = 16; + + READDIRPLUS3res + NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17; + + FSSTAT3res + NFSPROC3_FSSTAT(FSSTAT3args) = 18; + + FSINFO3res + NFSPROC3_FSINFO(FSINFO3args) = 19; + + PATHCONF3res + NFSPROC3_PATHCONF(PATHCONF3args) = 20; + + COMMIT3res + NFSPROC3_COMMIT(COMMIT3args) = 21; + + } = 3; +#endif } = 100003; diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8 index 5048d4af2729..20f505d3bd87 100644 --- a/sbin/mount_nfs/mount_nfs.8 +++ b/sbin/mount_nfs/mount_nfs.8 @@ -31,7 +31,7 @@ .\" .\" @(#)mount_nfs.8 8.2 (Berkeley) 3/27/94 .\" -.\" $Id$ +.\" $Id: mount_nfs.8,v 1.5 1996/10/22 21:56:58 joerg Exp $ .\"" .Dd March 27, 1994 .Dt MOUNT_NFS 8 @@ -41,7 +41,7 @@ .Nd mount nfs file systems .Sh SYNOPSIS .Nm mount_nfs -.Op Fl 3KPTUbcdilqs +.Op Fl 23KPTUbcdilqs .Op Fl D Ar deadthresh .Op Fl I Ar readdirsize .Op Fl L Ar leaseterm @@ -72,8 +72,11 @@ Appendix I. .Pp The options are: .Bl -tag -width indent +.It Fl 2 +Use the NFS Version 2 protocol (the default is to try version 3 first +then version 2). .It Fl 3 -Use the NFS Version 3 protocol (Version 2 is the default). +Use the NFS Version 3 protocol. .It Fl D Used with NQNFS to set the .Dq "dead server threshold" @@ -200,6 +203,9 @@ Same as .It kerb Same as .Fl K . +.It nfsv2 +Same as +.Fl 2 . .It nfsv3 Same as .Fl 3 . diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 659e26b43ba5..ef099d5b0cf0 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -45,7 +45,7 @@ static char copyright[] = static char sccsid[] = "@(#)mount_nfs.c 8.3 (Berkeley) 3/27/94"; */ static const char rcsid[] = - "$Id: mount_nfs.c,v 1.13 1996/05/13 17:43:06 wollman Exp $"; + "$Id: mount_nfs.c,v 1.14 1996/09/14 02:58:13 bde Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -106,6 +106,7 @@ static const char rcsid[] = #define ALTF_SOFT 0x800 #define ALTF_TCP 0x1000 #define ALTF_PORT 0x2000 +#define ALTF_NFSV2 0x4000 struct mntopt mopts[] = { MOPT_STDOPTS, @@ -129,6 +130,7 @@ struct mntopt mopts[] = { { "soft", 0, ALTF_SOFT, 1 }, { "tcp", 0, ALTF_TCP, 1 }, { "port=", 0, ALTF_PORT, 1 }, + { "nfsv2", 0, ALTF_NFSV2, 1 }, { NULL } }; #else @@ -147,7 +149,7 @@ struct nfs_args nfsdefargs = { 0, (u_char *)0, 0, - 0, + NFSMNT_RESVPORT, NFS_WSIZE, NFS_RSIZE, NFS_READDIRSIZE, @@ -175,6 +177,11 @@ int opflags = 0; int nfsproto = IPPROTO_UDP; int mnttcp_ok = 1; u_short port_no = 0; +enum { + ANY, + V2, + V3 +} mountmode = ANY; #ifdef NFSKERB char inst[INST_SZ]; @@ -200,6 +207,44 @@ void usage __P((void)) __dead2; int xdr_dir __P((XDR *, char *)); int xdr_fh __P((XDR *, struct nfhret *)); +/* + * Used to set mount flags with getmntopts. Call with dir=TRUE to + * initialise altflags from the current mount flags. Call with + * dir=FALSE to update mount flags with the new value of altflags after + * the call to getmntopts. + */ +static void +setflags(int* altflags, int* nfsflags, int dir) +{ +#define F2(af, nf) \ + if (dir) { \ + if (*nfsflags & NFSMNT_##nf) \ + *altflags |= ALTF_##af; \ + else \ + *altflags &= ~ALTF_##af; \ + } else { \ + if (*altflags & ALTF_##af) \ + *nfsflags |= NFSMNT_##nf; \ + else \ + *nfsflags &= ~NFSMNT_##nf; \ + } +#define F(f) F2(f,f) + + F(NOCONN); + F(DUMBTIMR); + F2(INTR, INT); +#ifdef NFSKERB + F(KERB); +#endif + F(RDIRPLUS); + F(RESVPORT); + F(NQNFS); + F(SOFT); + +#undef F +#undef F2 +} + int main(argc, argv) int argc; @@ -230,10 +275,13 @@ main(argc, argv) nfsargs = nfsdefargs; nfsargsp = &nfsargs; while ((c = getopt(argc, argv, - "3a:bcdD:g:I:iKL:lm:o:PpqR:r:sTt:w:x:U")) != EOF) + "23a:bcdD:g:I:iKL:lm:o:PpqR:r:sTt:w:x:U")) != EOF) switch (c) { + case '2': + mountmode = V2; + break; case '3': - nfsargsp->flags |= NFSMNT_NFSV3; + mountmode = V3; break; case 'a': num = strtol(optarg, &p, 10); @@ -301,42 +349,37 @@ main(argc, argv) #endif case 'o': #ifdef __FreeBSD__ + altflags = 0; + setflags(&altflags, &nfsargsp->flags, TRUE); + if (mountmode == V2) + altflags |= ALTF_NFSV2; + else if (mountmode == V3) + altflags |= ALTF_NFSV3; getmntopts(optarg, mopts, &mntflags, &altflags); + setflags(&altflags, &nfsargsp->flags, FALSE); + /* + * Handle altflags which don't map directly to + * mount flags. + */ if(altflags & ALTF_BG) opflags |= BGRND; - if(altflags & ALTF_NOCONN) - nfsargsp->flags |= NFSMNT_NOCONN; - if(altflags & ALTF_DUMBTIMR) - nfsargsp->flags |= NFSMNT_DUMBTIMR; - if(altflags & ALTF_INTR) - nfsargsp->flags |= NFSMNT_INT; -#ifdef NFSKERB - if(altflags & ALTF_KERB) - nfsargsp->flags |= NFSMNT_KERB; -#endif - if(altflags & ALTF_NFSV3) - nfsargsp->flags |= NFSMNT_NFSV3; - if(altflags & ALTF_RDIRPLUS) - nfsargsp->flags |= NFSMNT_RDIRPLUS; if(altflags & ALTF_MNTUDP) mnttcp_ok = 0; - if(altflags & ALTF_RESVPORT) - nfsargsp->flags |= NFSMNT_RESVPORT; #ifdef ISO if(altflags & ALTF_SEQPACKET) nfsargsp->sotype = SOCK_SEQPACKET; #endif - if(altflags & ALTF_NQNFS) - nfsargsp->flags |= (NFSMNT_NQNFS|NFSMNT_NFSV3); - if(altflags & ALTF_SOFT) - nfsargsp->flags |= NFSMNT_SOFT; if(altflags & ALTF_TCP) { nfsargsp->sotype = SOCK_STREAM; nfsproto = IPPROTO_TCP; } if(altflags & ALTF_PORT) port_no = atoi(strstr(optarg, "port=") + 5); - altflags = 0; + mountmode = ANY; + if(altflags & ALTF_NFSV2) + mountmode = V2; + if(altflags & ALTF_NFSV3) + mountmode = V3; #else getmntopts(optarg, mopts, &mntflags); #endif @@ -350,7 +393,8 @@ main(argc, argv) break; #endif case 'q': - nfsargsp->flags |= (NFSMNT_NQNFS | NFSMNT_NFSV3); + mountmode = V3; + nfsargsp->flags |= NFSMNT_NQNFS; break; case 'R': num = strtol(optarg, &p, 10); @@ -524,6 +568,52 @@ main(argc, argv) kverf.verf.t2 = kout.t2; kverf.verf.w2 = kout.w2; nfssvc_flag = NFSSVC_MNTD | NFSSVC_GOTAUTH; +/* + * Return RPC_SUCCESS if server responds. + */ +enum clnt_stat +pingnfsserver(addr, version, sotype) + struct sockaddr_in *addr; + int version; + int sotype; +{ + struct sockaddr_in sin; + int tport; + CLIENT *clp; + int so = RPC_ANYSOCK; + enum clnt_stat stat; + struct timeval pertry, try; + + sin = *addr; + + if ((tport = port_no ? port_no : + pmap_getport(&sin, RPCPROG_NFS, version, nfsproto)) == 0) { + return rpc_createerr.cf_stat; + } + + sin.sin_port = htons(tport); + + pertry.tv_sec = 10; + pertry.tv_usec = 0; + if (sotype == SOCK_STREAM) + clp = clnttcp_create(&sin, RPCPROG_NFS, version, + &so, 0, 0); + else + clp = clntudp_create(&sin, RPCPROG_NFS, version, + pertry, &so); + if (clp == NULL) + return rpc_createerr.cf_stat; + + try.tv_sec = 10; + try.tv_usec = 0; + stat = clnt_call(clp, NFSPROC_NULL, + xdr_void, NULL, xdr_void, NULL, try); + + clnt_destroy(clp); + + return stat; +} + } setreuid(0, 0); #endif /* NFSKERB */ @@ -547,7 +637,7 @@ getnfsargs(spec, nfsargsp) #endif struct timeval pertry, try; enum clnt_stat clnt_stat; - int so = RPC_ANYSOCK, i, nfsvers, mntvers; + int so = RPC_ANYSOCK, i, nfsvers, mntvers, orgcnt; char *hostp, *delimp; #ifdef NFSKERB char *cp; @@ -629,14 +719,32 @@ getnfsargs(spec, nfsargsp) } #endif /* NFSKERB */ - if (nfsargsp->flags & NFSMNT_NFSV3) { + orgcnt = retrycnt; +tryagain: + if (mountmode == ANY || mountmode == V3) { nfsvers = 3; mntvers = 3; + nfsargsp->flags |= NFSMNT_NFSV3; } else { nfsvers = 2; mntvers = 1; + nfsargsp->flags &= ~NFSMNT_NFSV3; } nfhret.stat = EACCES; /* Mark not yet successful */ + /* + * First ping the nfs server to see if it supports + * the version of the protocol we want to use. + */ + clnt_stat = pingnfsserver(&saddr, nfsvers, + nfsargsp->sotype); + if (clnt_stat == RPC_PROGVERSMISMATCH) { + if (mountmode == ANY) { + mountmode = V2; + goto tryagain; + } else { + errx(1, "Can't contact NFS server"); + } + } while (retrycnt > 0) { saddr.sin_family = AF_INET; saddr.sin_port = htons(PMAPPORT); @@ -670,6 +778,15 @@ getnfsargs(spec, nfsargsp) clnt_stat = clnt_call(clp, RPCMNT_MOUNT, xdr_dir, spec, xdr_fh, &nfhret, try); if (clnt_stat != RPC_SUCCESS) { + if (clnt_stat == RPC_PROGVERSMISMATCH) { + if (mountmode == ANY) { + mountmode = V2; + goto tryagain; + } else { + errx(1, "%s", + clnt_sperror(clp, "MNT RPC")); + } + } if ((opflags & ISBGRND) == 0) warnx("%s", clnt_sperror(clp, "bad MNT RPC")); @@ -780,7 +897,7 @@ void usage() { (void)fprintf(stderr, "\ -usage: mount_nfs [-3KPTUbcdilqs] [-D deadthresh] [-I readdirsize]\n\ +usage: mount_nfs [-23KPTUbcdilqs] [-D deadthresh] [-I readdirsize]\n\ [-L leaseterm] [-R retrycnt] [-a maxreadahead] [-g maxgroups]\n\ [-m realm] [-o options] [-r readsize] [-t timeout] [-w writesize]\n\ [-x retrans] rhost:path node\n"); diff --git a/sbin/mountd/mountd.8 b/sbin/mountd/mountd.8 index 8277da87cd91..fb4ca6f23418 100644 --- a/sbin/mountd/mountd.8 +++ b/sbin/mountd/mountd.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)mountd.8 8.4 (Berkeley) 4/28/95 -.\" $Id: mountd.8,v 1.5.2.1 1997/03/12 15:07:15 mpp Exp $ +.\" $Id: mountd.8,v 1.5.2.2 1997/04/09 20:31:32 guido Exp $ .\" .Dd April 28, 1995 .Dt MOUNTD 8 @@ -42,7 +42,7 @@ mount requests .Sh SYNOPSIS .Nm /sbin/mountd -.Op Fl nr +.Op Fl 2nr .Op Ar exportsfile .Sh DESCRIPTION .Xr Mountd @@ -61,6 +61,11 @@ Appendix I. Options and operands available for .Nm mountd : .Bl -tag -width Ds +.It Fl 2 +The +.Fl 2 +option allows the administrator to force clients to use only the +version 2 NFS protocol to mount filesystems from this server. .It Fl n The .Fl n diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index cfe591715345..717117f03377 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -43,7 +43,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "From: @(#)mountd.c 8.8 (Berkeley) 2/20/94";*/ static const char rcsid[] = - "$Id: mountd.c,v 1.11.2.4 1997/04/23 11:04:58 msmith Exp $"; + "$Id: mountd.c,v 1.11.2.5 1997/04/30 18:41:22 pst Exp $"; #endif /*not lint*/ #include <sys/param.h> @@ -217,6 +217,7 @@ struct ucred def_anon = { 1, { (gid_t) -2 } }; +int force_v2 = 0; int resvport_only = 1; int dir_only = 1; int opt_flags; @@ -267,8 +268,11 @@ main(argc, argv) } #endif /* __FreeBSD__ */ - while ((c = getopt(argc, argv, "dnr")) != EOF) + while ((c = getopt(argc, argv, "2dnr")) != EOF) switch (c) { + case '2': + force_v2 = 1; + break; case 'n': resvport_only = 0; break; @@ -333,10 +337,14 @@ main(argc, argv) } pmap_unset(RPCPROG_MNT, 1); pmap_unset(RPCPROG_MNT, 3); + if (!force_v2) + if (!svc_register(udptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_UDP) || + !svc_register(tcptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_TCP)) { + syslog(LOG_ERR, "Can't register mount"); + exit(1); + } if (!svc_register(udptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_UDP) || - !svc_register(udptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_UDP) || - !svc_register(tcptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_TCP) || - !svc_register(tcptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_TCP)) { + !svc_register(tcptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_TCP)) { syslog(LOG_ERR, "Can't register mount"); exit(1); } diff --git a/sys/gnu/ext2fs/ext2_lookup.c b/sys/gnu/ext2fs/ext2_lookup.c index baeaa52775ff..b781fda58896 100644 --- a/sys/gnu/ext2fs/ext2_lookup.c +++ b/sys/gnu/ext2fs/ext2_lookup.c @@ -156,6 +156,7 @@ ext2_readdir(ap) int count, error; struct ext2_dir_entry *edp, *dp; + int ncookies; struct dirent dstdp; struct uio auio; struct iovec aiov; @@ -183,6 +184,7 @@ printf("ext2_readdir called uio->uio_offset %d uio->uio_resid %d count %d \n", if (error == 0) { readcnt = count - auio.uio_resid; edp = (struct ext2_dir_entry *)&dirbuf[readcnt]; + ncookies = 0; for (dp = (struct ext2_dir_entry *)dirbuf; !error && uio->uio_resid > 0 && dp < edp; ) { ext2_dirconv2ffs(dp, &dstdp); @@ -194,6 +196,8 @@ printf("ext2_readdir called uio->uio_offset %d uio->uio_resid %d count %d \n", error = uiomove((caddr_t)&dstdp, dstdp.d_reclen, uio); + if (!error) + ncookies++; } else break; } else { @@ -203,8 +207,30 @@ printf("ext2_readdir called uio->uio_offset %d uio->uio_resid %d count %d \n", } /* we need to correct uio_offset */ uio->uio_offset = startoffset + (caddr_t)dp - dirbuf; + + if (!error && ap->a_ncookies != NULL) { + u_int *cookies; + u_int *cookiep; + off_t off; + + if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1) + panic("ext2fs_readdir: unexpected uio from NFS server"); + MALLOC(cookies, u_int *, ncookies * sizeof(u_long), M_TEMP, + M_WAITOK); + off = startoffset; + for (dp = (struct ext2_dir_entry *)dirbuf, cookiep = cookies; + dp < edp; + dp = (struct ext2_dir_entry *)((caddr_t) dp + dp->rec_len)) { + off += dp->rec_len; + *cookiep++ = (u_int) off; + } + *ap->a_ncookies = ncookies; + *ap->a_cookies = cookies; + } } FREE(dirbuf, M_TEMP); + if (ap->a_eofflag) + *ap->a_eofflag = VTOI(ap->a_vp)->i_size <= uio->uio_offset; return (error); } diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index 863f5b087197..423d4c600c5b 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -45,7 +45,7 @@ * * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93 * - * $Id: ibcs2_misc.c,v 1.12 1996/12/05 03:14:14 nate Exp $ + * $Id: ibcs2_misc.c,v 1.10.2.1 1996/12/12 19:39:18 jkh Exp $ */ /* @@ -71,6 +71,7 @@ #include <sys/resourcevar.h> #include <sys/socket.h> #include <sys/stat.h> +#include <sys/dirent.h> #include <sys/time.h> #include <sys/times.h> #include <sys/vnode.h> @@ -79,8 +80,6 @@ #include <sys/utsname.h> #include <sys/unistd.h> -#include <ufs/ufs/dir.h> - #include <netinet/in.h> #include <sys/sysproto.h> @@ -337,8 +336,10 @@ ibcs2_getdents(p, uap, retval) struct iovec aiov; struct ibcs2_dirent idb; off_t off; /* true file offset */ - int buflen, error, eofflag, blockoff; -#define BSD_DIRENT(cp) ((struct direct *)(cp)) + int buflen, error, eofflag; + u_int *cookies = NULL, *cookiep; + int ncookies; +#define BSD_DIRENT(cp) ((struct dirent *)(cp)) #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short)) if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -350,8 +351,8 @@ ibcs2_getdents(p, uap, retval) return (EINVAL); off = fp->f_offset; - blockoff = off % DIRBLKSIZ; - buflen = max(DIRBLKSIZ, SCARG(uap, nbytes) + blockoff); +#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */ + buflen = max(DIRBLKSIZ, SCARG(uap, nbytes)); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); VOP_LOCK(vp); @@ -364,29 +365,59 @@ again: auio.uio_segflg = UIO_SYSSPACE; auio.uio_procp = p; auio.uio_resid = buflen; - auio.uio_offset = off - (off_t)blockoff; + auio.uio_offset = off; + + if (cookies) { + free(cookies, M_TEMP); + cookies = NULL; + } + /* * First we read into the malloc'ed buffer, then * we massage it into user space, one record at a time. */ - if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, NULL)) + if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) goto out; inp = buf; - inp += blockoff; outp = SCARG(uap, buf); resid = SCARG(uap, nbytes); - if ((len = buflen - auio.uio_resid - blockoff) == 0) + if ((len = buflen - auio.uio_resid) <= 0) goto eof; + + cookiep = cookies; + + if (cookies) { + /* + * When using cookies, the vfs has the option of reading from + * a different offset than that supplied (UFS truncates the + * offset to a block boundary to make sure that it never reads + * partway through a directory entry, even if the directory + * has been compacted). + */ + while (len > 0 && ncookies > 0 && *cookiep <= off) { + len -= BSD_DIRENT(inp)->d_reclen; + inp += BSD_DIRENT(inp)->d_reclen; + cookiep++; + ncookies--; + } + } + for (; len > 0; len -= reclen) { + if (cookiep && ncookies == 0) + break; reclen = BSD_DIRENT(inp)->d_reclen; if (reclen & 3) { printf("ibcs2_getdents: reclen=%d\n", reclen); error = EFAULT; goto out; } - if (BSD_DIRENT(inp)->d_ino == 0) { + if (BSD_DIRENT(inp)->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ - off += reclen; + if (cookiep) { + off = *cookiep++; + ncookies--; + } else + off += reclen; continue; } if (reclen > len || resid < IBCS2_RECLEN(reclen)) { @@ -399,7 +430,7 @@ again: * we have to worry about touching user memory outside of * the copyout() call). */ - idb.d_ino = (ibcs2_ino_t)BSD_DIRENT(inp)->d_ino; + idb.d_ino = (ibcs2_ino_t)BSD_DIRENT(inp)->d_fileno; idb.d_off = (ibcs2_off_t)off; idb.d_reclen = (u_short)IBCS2_RECLEN(reclen); if ((error = copyout((caddr_t)&idb, outp, 10)) != 0 || @@ -407,7 +438,11 @@ again: BSD_DIRENT(inp)->d_namlen + 1)) != 0) goto out; /* advance past this real entry */ - off += reclen; + if (cookiep) { + off = *cookiep++; + ncookies--; + } else + off += reclen; inp += reclen; /* advance output past iBCS2-shaped entry */ outp += IBCS2_RECLEN(reclen); @@ -420,6 +455,8 @@ again: eof: *retval = SCARG(uap, nbytes) - resid; out: + if (cookies) + free(cookies, M_TEMP); VOP_UNLOCK(vp); free(buf, M_TEMP); return (error); @@ -444,7 +481,9 @@ ibcs2_read(p, uap, retval) char name[14]; } idb; off_t off; /* true file offset */ - int buflen, error, eofflag, size, blockoff; + int buflen, error, eofflag, size; + u_int *cookies = NULL, *cookiep; + int ncookies; if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) { if (error == EINVAL) @@ -461,8 +500,7 @@ ibcs2_read(p, uap, retval) DPRINTF(("ibcs2_read: read directory\n")); off = fp->f_offset; - blockoff = off % DIRBLKSIZ; - buflen = max(DIRBLKSIZ, SCARG(uap, nbytes) + blockoff); + buflen = max(DIRBLKSIZ, SCARG(uap, nbytes)); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); VOP_LOCK(vp); @@ -475,31 +513,61 @@ again: auio.uio_segflg = UIO_SYSSPACE; auio.uio_procp = p; auio.uio_resid = buflen; - auio.uio_offset = off - (off_t)blockoff; + auio.uio_offset = off; + + if (cookies) { + free(cookies, M_TEMP); + cookies = NULL; + } + /* * First we read into the malloc'ed buffer, then * we massage it into user space, one record at a time. */ - if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, 0, 0)) { + if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) { DPRINTF(("VOP_READDIR failed: %d\n", error)); goto out; } inp = buf; - inp += blockoff; outp = SCARG(uap, buf); resid = SCARG(uap, nbytes); - if ((len = buflen - auio.uio_resid - blockoff) == 0) + if ((len = buflen - auio.uio_resid) <= 0) goto eof; + + cookiep = cookies; + + if (cookies) { + /* + * When using cookies, the vfs has the option of reading from + * a different offset than that supplied (UFS truncates the + * offset to a block boundary to make sure that it never reads + * partway through a directory entry, even if the directory + * has been compacted). + */ + while (len > 0 && ncookies > 0 && *cookiep <= off) { + len -= BSD_DIRENT(inp)->d_reclen; + inp += BSD_DIRENT(inp)->d_reclen; + cookiep++; + ncookies--; + } + } + for (; len > 0 && resid > 0; len -= reclen) { + if (cookiep && ncookies == 0) + break; reclen = BSD_DIRENT(inp)->d_reclen; if (reclen & 3) { printf("ibcs2_read: reclen=%d\n", reclen); error = EFAULT; goto out; } - if (BSD_DIRENT(inp)->d_ino == 0) { + if (BSD_DIRENT(inp)->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ - off += reclen; + if (cookiep) { + off = *cookiep++; + ncookies--; + } else + off += reclen; continue; } if (reclen > len || resid < sizeof(struct ibcs2_direct)) { @@ -515,14 +583,18 @@ again: * TODO: if length(filename) > 14, then break filename into * multiple entries and set inode = 0xffff except last */ - idb.ino = (BSD_DIRENT(inp)->d_ino > 0xfffe) ? 0xfffe : - BSD_DIRENT(inp)->d_ino; + idb.ino = (BSD_DIRENT(inp)->d_fileno > 0xfffe) ? 0xfffe : + BSD_DIRENT(inp)->d_fileno; (void)copystr(BSD_DIRENT(inp)->d_name, idb.name, 14, &size); bzero(idb.name + size, 14 - size); if (error = copyout(&idb, outp, sizeof(struct ibcs2_direct))) goto out; /* advance past this real entry */ - off += reclen; + if (cookiep) { + off = *cookiep++; + ncookies--; + } else + off += reclen; inp += reclen; /* advance output past iBCS2-shaped entry */ outp += sizeof(struct ibcs2_direct); @@ -535,6 +607,8 @@ again: eof: *retval = SCARG(uap, nbytes) - resid; out: + if (cookies) + free(cookies, M_TEMP); VOP_UNLOCK(vp); free(buf, M_TEMP); return (error); diff --git a/sys/i386/linux/linux_file.c b/sys/i386/linux/linux_file.c index bf28b2c552cf..357e587c124b 100644 --- a/sys/i386/linux/linux_file.c +++ b/sys/i386/linux/linux_file.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_file.c,v 1.6 1996/03/02 19:37:53 peter Exp $ + * $Id: linux_file.c,v 1.7 1996/03/10 22:27:51 peter Exp $ */ #include <sys/param.h> @@ -36,17 +36,12 @@ #include <sys/filedesc.h> #include <sys/proc.h> #include <sys/ioctl.h> -#include <sys/stat.h> #include <sys/vnode.h> #include <sys/malloc.h> -#include <sys/exec.h> #include <sys/dirent.h> -#include <sys/sysproto.h> #include <sys/conf.h> #include <sys/tty.h> -#include <ufs/ufs/dir.h> - #include <i386/linux/linux.h> #include <i386/linux/linux_proto.h> #include <i386/linux/linux_util.h> @@ -415,7 +410,9 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args, int *retval) struct vattr va; off_t off; struct linux_dirent linux_dirent; - int buflen, error, eofflag, nbytes, justone, blockoff; + int buflen, error, eofflag, nbytes, justone; + u_int *cookies = NULL, *cookiep; + int ncookies; #ifdef DEBUG printf("Linux-emul(%d): getdents(%d, *, %d)\n", @@ -446,8 +443,8 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args, int *retval) justone = 0; off = fp->f_offset; - blockoff = off % DIRBLKSIZ; - buflen = max(DIRBLKSIZ, nbytes + blockoff); +#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */ + buflen = max(DIRBLKSIZ, nbytes); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); VOP_LOCK(vp); @@ -460,23 +457,47 @@ again: auio.uio_segflg = UIO_SYSSPACE; auio.uio_procp = p; auio.uio_resid = buflen; - auio.uio_offset = off - (off_t)blockoff; + auio.uio_offset = off; + + if (cookies) { + free(cookies, M_TEMP); + cookies = NULL; + } - error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, (int *) NULL, - (u_int **) NULL); + error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies); if (error) { goto out; } inp = buf; - inp += blockoff; outp = (caddr_t) args->dent; resid = nbytes; - if ((len = buflen - auio.uio_resid - blockoff) == 0) { + if ((len = buflen - auio.uio_resid) <= 0) { goto eof; } + cookiep = cookies; + + if (cookies) { + /* + * When using cookies, the vfs has the option of reading from + * a different offset than that supplied (UFS truncates the + * offset to a block boundary to make sure that it never reads + * partway through a directory entry, even if the directory + * has been compacted). + */ + while (len > 0 && ncookies > 0 && *cookiep <= off) { + bdp = (struct dirent *) inp; + len -= bdp->d_reclen; + inp += bdp->d_reclen; + cookiep++; + ncookies--; + } + } + while (len > 0) { + if (cookiep && ncookies == 0) + break; bdp = (struct dirent *) inp; reclen = bdp->d_reclen; if (reclen & 3) { @@ -487,7 +508,11 @@ again: if (bdp->d_fileno == 0) { inp += reclen; - off += reclen; + if (cookiep) { + off = *cookiep++; + ncookies--; + } else + off += reclen; len -= reclen; continue; } @@ -512,7 +537,11 @@ again: goto out; } inp += reclen; - off += reclen; + if (cookiep) { + off = *cookiep++; + ncookies--; + } else + off += reclen; outp += linuxreclen; resid -= linuxreclen; len -= reclen; @@ -529,6 +558,8 @@ again: eof: *retval = nbytes - resid; + if (cookies) + free(cookies, M_TEMP); out: VOP_UNLOCK(vp); free(buf, M_TEMP); diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index d45663ad6a37..0563a2fe6d85 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94 - * $Id: vfs_cluster.c,v 1.38 1996/10/06 07:50:04 dyson Exp $ + * $Id: vfs_cluster.c,v 1.38.2.1 1996/12/15 09:54:11 davidg Exp $ */ #include <sys/param.h> @@ -425,7 +425,8 @@ cluster_callback(bp) if (error) { tbp->b_flags |= B_ERROR; tbp->b_error = error; - } + } else + tbp->b_dirtyoff = tbp->b_dirtyend = 0; biodone(tbp); } relpbuf(bp); diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h index 36e3d5ca2219..c22c9987aed6 100644 --- a/sys/nfs/nfs.h +++ b/sys/nfs/nfs.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs.h 8.1 (Berkeley) 6/10/93 - * $Id: nfs.h,v 1.18.2.1 1996/11/09 21:10:44 phk Exp $ + * $Id: nfs.h,v 1.18.2.2 1997/03/27 20:04:00 guido Exp $ */ #ifndef _NFS_NFS_H_ @@ -597,6 +597,23 @@ int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq)); +#ifdef NFS_DEBUG + +extern int nfs_debug; +#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ +#define NFS_DEBUG_WG 2 /* server write gathering */ +#define NFS_DEBUG_RC 4 /* server request caching */ + +#define NFS_DPF(cat, args) \ + do { \ + if (nfs_debug & NFS_DEBUG_##cat) printf args; \ + } while (0) + +#else + +#define NFS_DPF(cat, args) + +#endif #endif /* KERNEL */ diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index 37a7a00d6c7a..2f86141a87ae 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_bio.c 8.5 (Berkeley) 1/4/94 - * $Id: nfs_bio.c,v 1.28.2.2 1996/11/12 09:09:27 phk Exp $ + * $Id: nfs_bio.c,v 1.28.2.3 1997/03/04 17:59:41 dfr Exp $ */ #include <sys/param.h> @@ -305,6 +305,10 @@ again: break; case VDIR: nfsstats.biocache_readdirs++; + if (np->n_direofoffset + && uio->uio_offset >= np->n_direofoffset) { + return (0); + } lbn = uio->uio_offset / NFS_DIRBLKSIZ; on = uio->uio_offset & (NFS_DIRBLKSIZ - 1); bp = nfs_getcacheblk(vp, lbn, NFS_DIRBLKSIZ, p); @@ -327,6 +331,9 @@ again: * offset cookies. */ for (i = 0; i <= lbn && !error; i++) { + if (np->n_direofoffset + && (i * NFS_DIRBLKSIZ) >= np->n_direofoffset) + return (0); bp = nfs_getcacheblk(vp, i, NFS_DIRBLKSIZ, p); if (!bp) return (EINTR); @@ -511,6 +518,7 @@ nfs_write(ap) again: if (uio->uio_offset + n > np->n_size) { np->n_size = uio->uio_offset + n; + np->n_flag |= NMODIFIED; vnode_pager_setsize(vp, (u_long)np->n_size); } bufsize = biosize; @@ -756,6 +764,7 @@ again: nmp->nm_bufqiods++; wakeup((caddr_t)&nfs_iodwant[i]); gotiod = TRUE; + break; } /* @@ -971,9 +980,12 @@ nfs_doio(bp, cr, p) iomode = NFSV3WRITE_FILESYNC; bp->b_flags |= B_WRITEINPROG; error = nfs_writerpc(vp, uiop, cr, &iomode, &must_commit); - if (!error && iomode == NFSV3WRITE_UNSTABLE) - bp->b_flags |= B_NEEDCOMMIT | B_CLUSTEROK; - else + if (!error && iomode == NFSV3WRITE_UNSTABLE) { + bp->b_flags |= B_NEEDCOMMIT; + if (bp->b_dirtyoff == 0 + && bp->b_dirtyend == bp->b_bufsize) + bp->b_flags |= B_CLUSTEROK; + } else bp->b_flags &= ~B_NEEDCOMMIT; bp->b_flags &= ~B_WRITEINPROG; diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c index be3155ca6477..57472319d038 100644 --- a/sys/nfs/nfs_node.c +++ b/sys/nfs/nfs_node.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_node.c 8.2 (Berkeley) 12/30/93 - * $Id: nfs_node.c,v 1.12 1995/10/29 15:32:50 phk Exp $ + * $Id: nfs_node.c,v 1.13 1996/06/12 03:37:46 davidg Exp $ */ #include <sys/param.h> @@ -196,11 +196,11 @@ nfs_inactive(ap) np = VTONFS(ap->a_vp); if (prtactive && ap->a_vp->v_usecount != 0) vprint("nfs_inactive: pushing active", ap->a_vp); - if (ap->a_vp->v_type != VDIR) + if (ap->a_vp->v_type != VDIR) { sp = np->n_sillyrename; - else + np->n_sillyrename = (struct sillyrename *)0; + } else sp = (struct sillyrename *)0; - np->n_sillyrename = (struct sillyrename *)0; if (sp) { /* * Remove the silly file that was rename'd earlier diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 9f2010e922e0..4a579e4636e5 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94 - * $Id: nfs_serv.c,v 1.33 1996/09/05 07:58:04 davidg Exp $ + * $Id: nfs_serv.c,v 1.34 1996/09/19 18:20:56 nate Exp $ */ /* @@ -97,6 +97,7 @@ extern enum vtype nv3tov_type[8]; extern struct nfsstats nfsstats; int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000; +int nfsrvw_procrastinate_v3 = 0; int nfs_async; SYSCTL_INT(_vfs_nfs, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0, ""); @@ -930,7 +931,8 @@ nfsrv_writegather(ndp, slp, procp, mrq) nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; cur_usec = (u_quad_t)time.tv_sec * 1000000 + (u_quad_t)time.tv_usec; - nfsd->nd_time = cur_usec + nfsrvw_procrastinate; + nfsd->nd_time = cur_usec + + (v3 ? nfsrvw_procrastinate_v3 : nfsrvw_procrastinate); /* * Now, get the write header.. @@ -1000,6 +1002,7 @@ nfsmout: owp = wp; wp = wp->nd_tq.le_next; } + NFS_DPF(WG, ("Q%03x", nfsd->nd_retxid & 0xfff)); if (owp) { LIST_INSERT_AFTER(owp, nfsd, nd_tq); } else { @@ -1051,6 +1054,7 @@ loop1: break; if (nfsd->nd_mreq) continue; + NFS_DPF(WG, ("P%03x", nfsd->nd_retxid & 0xfff)); LIST_REMOVE(nfsd, nd_tq); LIST_REMOVE(nfsd, nd_hash); splx(s); @@ -1127,6 +1131,7 @@ loop1: */ swp = nfsd; do { + NFS_DPF(WG, ("R%03x", nfsd->nd_retxid & 0xfff)); if (error) { nfsm_writereply(NFSX_WCCDATA(v3), v3); if (v3) { @@ -1186,6 +1191,7 @@ loop1: s = splsoftclock(); for (nfsd = slp->ns_tq.lh_first; nfsd; nfsd = nfsd->nd_tq.le_next) if (nfsd->nd_mreq) { + NFS_DPF(WG, ("X%03x", nfsd->nd_retxid & 0xfff)); LIST_REMOVE(nfsd, nd_tq); *mrq = nfsd->nd_mreq; *ndp = nfsd; @@ -1210,7 +1216,10 @@ nfsrvw_coalesce(owp, nfsd) { register int overlap; register struct mbuf *mp; + struct nfsrv_descript *p; + NFS_DPF(WG, ("C%03x-%03x", + nfsd->nd_retxid & 0xfff, owp->nd_retxid & 0xfff)); LIST_REMOVE(nfsd, nd_hash); LIST_REMOVE(nfsd, nd_tq); if (owp->nd_eoff < nfsd->nd_eoff) { @@ -1233,6 +1242,16 @@ nfsrvw_coalesce(owp, nfsd) owp->nd_stable == NFSV3WRITE_UNSTABLE) owp->nd_stable = NFSV3WRITE_DATASYNC; LIST_INSERT_HEAD(&owp->nd_coalesce, nfsd, nd_tq); + + /* + * If nfsd had anything else coalesced into it, transfer them + * to owp, otherwise their replies will never get sent. + */ + for (p = nfsd->nd_coalesce.lh_first; p; + p = nfsd->nd_coalesce.lh_first) { + LIST_REMOVE(p, nd_tq); + LIST_INSERT_HEAD(&owp->nd_coalesce, p, nd_tq); + } } /* diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 6cafa8af98ac..93d716a3f8f1 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_socket.c 8.3 (Berkeley) 1/12/94 - * $Id: nfs_socket.c,v 1.17 1996/07/11 16:32:45 wollman Exp $ + * $Id: nfs_socket.c,v 1.18 1996/10/11 10:15:33 dfr Exp $ */ /* @@ -270,8 +270,8 @@ nfs_connect(nmp, rep) so->so_snd.sb_timeo = 0; } if (nmp->nm_sotype == SOCK_DGRAM) { - sndreserve = nmp->nm_wsize + NFS_MAXPKTHDR; - rcvreserve = nmp->nm_rsize + NFS_MAXPKTHDR; + sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2; + rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR) * 2; } else if (nmp->nm_sotype == SOCK_SEQPACKET) { sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2; rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR) * 2; diff --git a/sys/nfs/nfs_srvcache.c b/sys/nfs/nfs_srvcache.c index 44aaf83933ad..ae44d4c942fa 100644 --- a/sys/nfs/nfs_srvcache.c +++ b/sys/nfs/nfs_srvcache.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_srvcache.c 8.1 (Berkeley) 6/10/93 - * $Id: nfs_srvcache.c,v 1.7 1995/12/17 21:12:27 phk Exp $ + * $Id: nfs_srvcache.c,v 1.8 1996/01/13 23:27:55 phk Exp $ */ #ifndef NFS_NOSERVER @@ -184,6 +184,7 @@ loop: rp = rp->rc_hash.le_next) { if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc && netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) { + NFS_DPF(RC, ("H%03x", rp->rc_xid & 0xfff)); if ((rp->rc_flag & RC_LOCKED) != 0) { rp->rc_flag |= RC_WANTED; (void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 0); @@ -224,6 +225,7 @@ loop: } } nfsstats.srvcache_misses++; + NFS_DPF(RC, ("M%03x", nd->nd_retxid & 0xfff)); if (numnfsrvcache < desirednfsrvcache) { rp = (struct nfsrvcache *)malloc((u_long)sizeof *rp, M_NFSD, M_WAITOK); @@ -289,6 +291,7 @@ loop: rp = rp->rc_hash.le_next) { if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc && netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) { + NFS_DPF(RC, ("U%03x", rp->rc_xid & 0xfff)); if ((rp->rc_flag & RC_LOCKED) != 0) { rp->rc_flag |= RC_WANTED; (void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 0); @@ -319,6 +322,7 @@ loop: return; } } + NFS_DPF(RC, ("L%03x", nd->nd_retxid & 0xfff)); } /* diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 451727e7e0ef..68dbe3b1be0e 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_syscalls.c 8.3 (Berkeley) 1/4/94 - * $Id: nfs_syscalls.c,v 1.14.2.2 1996/11/12 09:09:30 phk Exp $ + * $Id: nfs_syscalls.c,v 1.14.2.3 1997/03/27 20:04:04 guido Exp $ */ #include <sys/param.h> @@ -86,6 +86,7 @@ extern int nqsrv_writeslack; extern int nfsrtton; extern struct nfsstats nfsstats; extern int nfsrvw_procrastinate; +extern int nfsrvw_procrastinate_v3; struct nfssvc_sock *nfs_udpsock, *nfs_cltpsock; static int nuidhash_max = NFS_MAXUIDHASH; @@ -111,6 +112,8 @@ static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); static int nfs_privport = 0; SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay, CTLFLAG_RW, &nfsrvw_procrastinate, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay_v3, CTLFLAG_RW, &nfsrvw_procrastinate_v3, 0, ""); /* * NFS server system calls @@ -455,6 +458,7 @@ nfssvc_nfsd(nsd, argp, p) struct nfsrv_descript *nd = NULL; struct mbuf *mreq; int error = 0, cacherep, s, sotype, writes_todo; + int procrastinate; u_quad_t cur_usec; #ifndef nolint @@ -606,7 +610,8 @@ nfssvc_nfsd(nsd, argp, p) sin = mtod(nam, struct sockaddr_in *); port = ntohs(sin->sin_port); - if (port >= IPPORT_RESERVED) { + if (port >= IPPORT_RESERVED && + nd->nd_procnum != NFSPROC_NULL) { nd->nd_procnum = NFSPROC_NOOP; nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK); cacherep = RC_DOIT; @@ -624,8 +629,12 @@ nfssvc_nfsd(nsd, argp, p) do { switch (cacherep) { case RC_DOIT: + if (nd && (nd->nd_flag & ND_NFSV3)) + procrastinate = nfsrvw_procrastinate_v3; + else + procrastinate = nfsrvw_procrastinate; if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && - nfsrvw_procrastinate > 0 && !notstarted)) + procrastinate > 0 && !notstarted)) error = nfsrv_writegather(&nd, slp, nfsd->nfsd_procp, &mreq); else diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index 06bb7ba74fc2..767f34f9109a 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vfsops.c 8.3 (Berkeley) 1/4/94 - * $Id: nfs_vfsops.c,v 1.30.2.2 1997/05/11 18:01:24 tegge Exp $ + * $Id: nfs_vfsops.c,v 1.30.2.3 1997/05/12 18:56:19 tegge Exp $ */ #include <sys/param.h> @@ -333,12 +333,9 @@ nfs_fsinfo(nmp, vp, cred, p) } pref = fxdr_unsigned(u_long, fsp->fs_dtpref); if (pref < nmp->nm_readdirsize) - nmp->nm_readdirsize = (pref + NFS_DIRBLKSIZ - 1) & - ~(NFS_DIRBLKSIZ - 1); + nmp->nm_readdirsize = pref; if (max < nmp->nm_readdirsize) { - nmp->nm_readdirsize = max & ~(NFS_DIRBLKSIZ - 1); - if (nmp->nm_readdirsize == 0) - nmp->nm_readdirsize = max; + nmp->nm_readdirsize = max; } nmp->nm_flag |= NFSMNT_GOTFSINFO; } @@ -713,13 +710,11 @@ mountnfs(argp, mp, nam, pth, hst, vpp) if ((argp->flags & NFSMNT_READDIRSIZE) && argp->readdirsize > 0) { nmp->nm_readdirsize = argp->readdirsize; - /* Round down to multiple of blocksize */ - nmp->nm_readdirsize &= ~(NFS_DIRBLKSIZ - 1); - if (nmp->nm_readdirsize < NFS_DIRBLKSIZ) - nmp->nm_readdirsize = NFS_DIRBLKSIZ; } if (nmp->nm_readdirsize > maxio) nmp->nm_readdirsize = maxio; + if (nmp->nm_readdirsize > nmp->nm_rsize) + nmp->nm_readdirsize = nmp->nm_rsize; if ((argp->flags & NFSMNT_MAXGRPS) && argp->maxgrouplist >= 0 && argp->maxgrouplist <= NFS_MAXGRPS) diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index c779a99503f9..5e7aa4c3c061 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94 - * $Id: nfs_vnops.c,v 1.36.2.2 1997/01/07 06:18:27 wpaul Exp $ + * $Id: nfs_vnops.c,v 1.36.2.3 1997/03/04 17:59:42 dfr Exp $ */ /* @@ -422,8 +422,49 @@ nfs_access(ap) } nfsm_reqdone; return (error); - } else - return (nfsspec_access(ap)); + } else { + if (error = nfsspec_access(ap)) + return (error); + + /* + * Attempt to prevent a mapped root from accessing a file + * which it shouldn't. We try to read a byte from the file + * if the user is root and the file is not zero length. + * After calling nfsspec_access, we should have the correct + * file size cached. + */ + if (ap->a_cred->cr_uid == 0 && (ap->a_mode & VREAD) + && VTONFS(vp)->n_size > 0) { + struct iovec aiov; + struct uio auio; + char buf[1]; + + aiov.iov_base = buf; + aiov.iov_len = 1; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_offset = 0; + auio.uio_resid = 1; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_rw = UIO_READ; + auio.uio_procp = ap->a_p; + + if (vp->v_type == VREG) + error = nfs_readrpc(vp, &auio, ap->a_cred); + else if (vp->v_type == VDIR) { + char* buf; + buf = malloc(NFS_DIRBLKSIZ, M_TEMP, M_WAITOK); + aiov.iov_base = buf; + aiov.iov_len = auio.uio_resid = NFS_DIRBLKSIZ; + error = nfs_readdirrpc(vp, &auio, ap->a_cred); + free(buf, M_TEMP); + } else if (vp->v_type = VLNK) + error = nfs_readlinkrpc(vp, &auio, ap->a_cred); + else + error = EACCES; + } + return (error); + } } /* @@ -826,6 +867,7 @@ nfs_lookup(ap) struct nfsnode *np; int lockparent, wantparent, error = 0, attrflag, fhsize; int v3 = NFS_ISV3(dvp); + struct proc *p = cnp->cn_proc; if ((flags & ISLASTCN) && (dvp->v_mount->mnt_flag & MNT_RDONLY) && (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) @@ -841,6 +883,9 @@ nfs_lookup(ap) struct vattr vattr; int vpid; + if (error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p)) + return (error); + newvp = *vpp; vpid = newvp->v_id; /* diff --git a/sys/nfs/nfsmount.h b/sys/nfs/nfsmount.h index a1c3b385f8a0..cca2b2db772b 100644 --- a/sys/nfs/nfsmount.h +++ b/sys/nfs/nfsmount.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfsmount.h 8.1 (Berkeley) 6/10/93 - * $Id: nfsmount.h,v 1.7 1995/12/17 21:12:36 phk Exp $ + * $Id: nfsmount.h,v 1.7.4.1 1996/11/09 21:11:17 phk Exp $ */ #ifndef _NFS_NFSMOUNT_H_ @@ -94,22 +94,6 @@ struct nfsmount { */ #define VFSTONFS(mp) ((struct nfsmount *)((mp)->mnt_data)) -#ifdef NFS_DEBUG - -extern int nfs_debug; -#define NFS_DEBUG_ASYNCIO 1 - -#define NFS_DPF(cat, args) \ - do { \ - if (nfs_debug & NFS_DEBUG_##cat) printf args; \ - } while (0) - -#else - -#define NFS_DPF(cat, args) - -#endif - #endif /* KERNEL */ #endif diff --git a/usr.sbin/amd/amd/Makefile b/usr.sbin/amd/amd/Makefile index 07b9f1e37d61..705338c760d6 100644 --- a/usr.sbin/amd/amd/Makefile +++ b/usr.sbin/amd/amd/Makefile @@ -14,6 +14,7 @@ SRCS= afs_ops.c am_ops.c clock.c util.c xutil.c \ amq_subr.c umount_fs.c host_ops.c nfsx_ops.c \ ufs_ops.c ifs_ops.c amd.c get_args.c restart.c wire.c OBJS+= vers.${PROG}.o +CFLAGS+=-I${.OBJDIR} CFLAGS+=-I${.CURDIR}/../rpcx CFLAGS+=-I${.CURDIR}/../config CFLAGS+=-I${.CURDIR}/../include @@ -24,9 +25,32 @@ CFLAGS+=${CONFIG} LDADD= ${XLIBDIR} ${RESOLV} CLEANFILES+=vers.${PROG}.c vers.${PROG}.o version.amd +CLEANFILES+=mount.h mount_xdr.c nfs_prot.h nfs_prot_xdr.c nfs_prot_svc.c +RPCCOM = rpcgen +MOUNT_X= /usr/include/rpcsvc/mount.x +NFS_PROT_X= /usr/include/rpcsvc/nfs_prot.x vers.${PROG}.c: ${SRCS:.c=.o} @d=${.CURDIR}/ sh ${.CURDIR}/../config/newvers.sh ${PROG} ${MACHINE} ${OS} + +afs_ops.o host_ops.o nfs_ops.o srvr_nfs.o: mount.h + +mount.h: ${MOUNT_X} + ${RPCCOM} -h -DWANT_NFS3 ${MOUNT_X} -o ${.TARGET} + +mount_xdr.c: mount.h ${MOUNT_X} + ${RPCCOM} -c -DWANT_NFS3 ${MOUNT_X} -o ${.TARGET} + +${OBJS} beforedepend: nfs_prot.h + +nfs_prot.h: ${NFS_PROT_X} + ${RPCCOM} -h ${NFS_PROT_X} -o ${.TARGET} + +nfs_prot_xdr.c: ${NFS_PROT_X} + ${RPCCOM} -c ${NFS_PROT_X} -o ${.TARGET} + +nfs_prot_svc.c: ${NFS_PROT_X} + ${RPCCOM} -m ${NFS_PROT_X} -o ${.TARGET} .PATH: ${.CURDIR}/../rpcx ${.CURDIR}/../config .include "Makefile.config" .include "../../Makefile.inc" diff --git a/usr.sbin/amd/amd/nfs_ops.c b/usr.sbin/amd/amd/nfs_ops.c index eed5b71de19d..19ba9d843e24 100644 --- a/usr.sbin/amd/amd/nfs_ops.c +++ b/usr.sbin/amd/amd/nfs_ops.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: nfs_ops.c,v 1.3 1995/05/30 03:45:52 rgrimes Exp $ + * $FreeBSD$ */ #ifndef lint @@ -57,6 +57,7 @@ typedef nfs_fh fhandle_t; #endif /* NFS_HDR */ #include <sys/mount.h> #include "mount.h" +#include "mountres.h" /* * Network file system @@ -65,7 +66,10 @@ typedef nfs_fh fhandle_t; /* * Convert from nfsstat to UN*X error code */ -#define unx_error(e) ((int)(e)) +#define unx_error(e) ((e) < 10000 ? (int)(e) \ + : ((e) == MNT3ERR_NOTSUPP ? EOPNOTSUPP \ + : ((e) == MNT3ERR_SERVERFAULT ? EIO \ + : EINVAL))) /* * The NFS layer maintains a cache of file handles. @@ -97,7 +101,7 @@ struct fh_cache { int fh_error; /* Valid data? */ int fh_id; /* Unique id */ int fh_cid; /* Callout id */ - struct fhstatus fh_handle; /* Handle on filesystem */ + mountres fh_mountres; /* Result of mount rpc */ struct sockaddr_in fh_sin; /* Address of mountd */ fserver *fh_fs; /* Server holding filesystem */ char *fh_path; /* Filesystem on host */ @@ -116,7 +120,7 @@ static int fh_id = 0; extern qelem fh_head; qelem fh_head = { &fh_head, &fh_head }; -static int call_mountd P((fh_cache*, unsigned long, fwd_fun, voidp)); +static int call_mountd P((fh_cache*, unsigned long, unsigned long, fwd_fun, voidp)); AUTH *nfs_auth; @@ -165,10 +169,24 @@ int done; { fh_cache *fp = find_nfs_fhandle_cache(idv, done); if (fp) { - fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &fp->fh_handle, xdr_fhstatus); + if (fp->fh_mountres.mr_version == MOUNTVERS3) { + fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &fp->fh_mountres.mr_mountres3, xdr_mountres3); + if (fp->fh_error) { + /* + * Fall back to version 1 protocol. + */ +#ifdef DEBUG + dlog("mount version 3 refused, retrying with version 1"); +#endif + fp->fh_id = FHID_ALLOC(); + fp->fh_mountres.mr_version = MOUNTVERS; + call_mountd(fp, MOUNTPROC_MNT, MOUNTVERS, got_nfs_fh, fp->fh_wchan); + } + } else + fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &fp->fh_mountres.mr_fhstatus, xdr_fhstatus); if (!fp->fh_error) { #ifdef DEBUG - dlog("got filehandle for %s:%s", fp->fh_fs->fs_host, fp->fh_path); + dlog("got filehandle for %s:%s, version=%d", fp->fh_fs->fs_host, fp->fh_path, fp->fh_mountres.mr_version); #endif /* DEBUG */ /* * Wakeup anything sleeping on this filehandle @@ -205,6 +223,8 @@ fh_cache *fp; dlog("Discarding filehandle for %s:%s", fp->fh_fs->fs_host, fp->fh_path); #endif /* DEBUG */ free_srvr(fp->fh_fs); + if (fp->fh_mountres.mr_version == MOUNTVERS3) + xdr_free(xdr_mountres3, (char *) &fp->fh_mountres.mr_mountres3); free((voidp) fp->fh_path); free((voidp) fp); } @@ -212,11 +232,12 @@ fh_cache *fp; /* * Determine the file handle for a node */ -static int prime_nfs_fhandle_cache P((char *path, fserver *fs, struct fhstatus *fhbuf, voidp wchan)); -static int prime_nfs_fhandle_cache(path, fs, fhbuf, wchan) +static int prime_nfs_fhandle_cache P((char *path, fserver *fs, int forcev2, struct mountres *mrbuf, voidp wchan)); +static int prime_nfs_fhandle_cache(path, fs, forcev2, mrbuf, wchan) char *path; fserver *fs; -struct fhstatus *fhbuf; +int forcev2; +struct mountres *mrbuf; voidp wchan; { fh_cache *fp, *fp_save = 0; @@ -234,11 +255,14 @@ voidp wchan; if (fs == fp->fh_fs && strcmp(path, fp->fh_path) == 0) { switch (fp->fh_error) { case 0: - error = fp->fh_error = unx_error(fp->fh_handle.fhs_status); + if (fp->fh_mountres.mr_version == MOUNTVERS) + error = fp->fh_error = unx_error(fp->fh_mountres.mr_fhstatus.fhs_status); + else + error = fp->fh_error = unx_error(fp->fh_mountres.mr_mountres3.fhs_status); if (error == 0) { - if (fhbuf) - bcopy((voidp) &fp->fh_handle, (voidp) fhbuf, - sizeof(fp->fh_handle)); + if (mrbuf) + bcopy((voidp) &fp->fh_mountres, (voidp) mrbuf, + sizeof(fp->fh_mountres)); if (fp->fh_cid) untimeout(fp->fh_cid); fp->fh_cid = timeout(FH_TTL, discard_fh, (voidp) fp); @@ -308,6 +332,21 @@ voidp wchan; fp->fh_wchan = wchan; fp->fh_error = -1; fp->fh_cid = timeout(FH_TTL, discard_fh, (voidp) fp); + if (forcev2) { + /* + * Force an NFSv2 mount. + */ +#ifdef DEBUG + dlog("forcing v2 mount"); +#endif + fp->fh_mountres.mr_version = MOUNTVERS; + } else { + /* + * Attempt v3 first. + */ + fp->fh_mountres.mr_version = MOUNTVERS3; + fp->fh_mountres.mr_mountres3.mountres3_u.mountinfo.fhandle.fhandle3_val = NULL; + } /* * If the address has changed then don't try to re-use the @@ -320,7 +359,7 @@ voidp wchan; fp->fh_fs = dup_srvr(fs); fp->fh_path = strdup(path); - error = call_mountd(fp, MOUNTPROC_MNT, got_nfs_fh, wchan); + error = call_mountd(fp, MOUNTPROC_MNT, fp->fh_mountres.mr_version, got_nfs_fh, wchan); if (error) { /* * Local error - cache for a short period @@ -355,10 +394,11 @@ int make_nfs_auth P((void)) return 0; } -static int call_mountd P((fh_cache *fp, u_long proc, fwd_fun f, voidp wchan)); -static int call_mountd(fp, proc, f, wchan) +static int call_mountd P((fh_cache *fp, u_long proc, u_long version, fwd_fun f, voidp wchan)); +static int call_mountd(fp, proc, version, f, wchan) fh_cache *fp; u_long proc; +u_long version; fwd_fun f; voidp wchan; { @@ -381,7 +421,7 @@ voidp wchan; fp->fh_sin.sin_port = port; } - rpc_msg_init(&mnt_msg, MOUNTPROG, MOUNTVERS, (unsigned long) 0); + rpc_msg_init(&mnt_msg, MOUNTPROG, version, (unsigned long) 0); len = make_rpc_packet(iobuf, sizeof(iobuf), proc, &mnt_msg, (voidp) &fp->fh_path, xdr_nfspath, nfs_auth); @@ -439,6 +479,24 @@ am_opts *fo; return xmtab; } +static int forcev2(mf) +mntfs *mf; +{ + struct mntent mnt; + + mnt.mnt_dir = mf->mf_mount; + mnt.mnt_fsname = mf->mf_info; + mnt.mnt_type = MTAB_TYPE_NFS; + mnt.mnt_opts = mf->mf_mopts; + mnt.mnt_freq = 0; + mnt.mnt_passno = 0; + + if (hasmntopt(&mnt, "nfsv2") != NULL) + return TRUE; + else + return FALSE; +} + /* * Initialise am structure for nfs */ @@ -447,17 +505,17 @@ mntfs *mf; { if (!mf->mf_private) { int error; - struct fhstatus fhs; + struct mountres mr; char *colon = strchr(mf->mf_info, ':'); if (colon == 0) return ENOENT; - error = prime_nfs_fhandle_cache(colon+1, mf->mf_server, &fhs, (voidp) mf); + error = prime_nfs_fhandle_cache(colon+1, mf->mf_server, forcev2(mf), &mr, (voidp) mf); if (!error) { - mf->mf_private = (voidp) ALLOC(fhstatus); + mf->mf_private = (voidp) ALLOC(mountres); mf->mf_prfree = (void (*)()) free; - bcopy((voidp) &fhs, mf->mf_private, sizeof(fhs)); + bcopy((voidp) &mr, mf->mf_private, sizeof(mr)); } return error; } @@ -465,9 +523,9 @@ mntfs *mf; return 0; } -int mount_nfs_fh P((struct fhstatus *fhp, char *dir, char *fs_name, char *opts, mntfs *mf)); -int mount_nfs_fh(fhp, dir, fs_name, opts, mf) -struct fhstatus *fhp; +int mount_nfs_fh P((struct mountres *mrp, char *dir, char *fs_name, char *opts, mntfs *mf)); +int mount_nfs_fh(mrp, dir, fs_name, opts, mf) +struct mountres *mrp; char *dir; char *fs_name; char *opts; @@ -528,10 +586,14 @@ mntfs *mf; /* * set mount args */ - NFS_FH_DREF(nfs_args.fh, (NFS_FH_TYPE) fhp->fhstatus_u.fhs_fhandle); -#ifdef NFSv3 - nfs_args.fhsize = FHSIZE; -#endif + if (mrp->mr_version == MOUNTVERS) { + NFS_FH_DREF(nfs_args.fh, (NFS_FH_TYPE) mrp->mr_fhstatus.fhstatus_u.fhs_fhandle); + nfs_args.fhsize = FHSIZE; + } else { + NFS_FH_DREF(nfs_args.fh, (NFS_FH_TYPE) mrp->mr_mountres3.mountres3_u.mountinfo.fhandle.fhandle3_val); + nfs_args.fhsize = mrp->mr_mountres3.mountres3_u.mountinfo.fhandle.fhandle3_len; + nfs_args.flags |= NFSMNT_NFSV3; + } #ifdef ULTRIX_HACK nfs_args.optstr = mnt.mnt_opts; @@ -682,7 +744,7 @@ mntfs *mf; #ifdef DEBUG dlog("locating fhandle for %s", fs_name); #endif /* DEBUG */ - error = prime_nfs_fhandle_cache(colon+1, mf->mf_server, &fhs, (voidp) 0); + error = prime_nfs_fhandle_cache(colon+1, mf->mf_server, forcev2(mf), &fhs, (voidp) 0); if (error) return error; @@ -694,7 +756,7 @@ mntfs *mf; return EINVAL; } - return mount_nfs_fh((struct fhstatus *) mf->mf_private, dir, fs_name, opts, mf); + return mount_nfs_fh((struct mountres *) mf->mf_private, dir, fs_name, opts, mf); } static int nfs_fmount(mf) @@ -767,7 +829,7 @@ am_node *mp; f.fh_id = 0; f.fh_error = 0; (void) prime_nfs_fhandle_cache(colon+1, mf->mf_server, (struct fhstatus *) 0, (voidp) mf); - (void) call_mountd(&f, MOUNTPROC_UMNT, (fwd_fun) 0, (voidp) 0); + (void) call_mountd(&f, MOUNTPROC_UMNT, MOUNTVERS, (fwd_fun) 0, (voidp) 0); *colon = ':'; } #endif /* INFORM_MOUNTD */ diff --git a/usr.sbin/amd/amq/Makefile b/usr.sbin/amd/amq/Makefile index f0618aef194d..c3f87a38e772 100644 --- a/usr.sbin/amd/amq/Makefile +++ b/usr.sbin/amd/amq/Makefile @@ -3,6 +3,7 @@ PROG = amq MAN8 = amq.8 SRCS = amq.c amq_clnt.c amq_xdr.c misc_rpc.c +CFLAGS+=-I${.OBJDIR} CFLAGS+=-I${.CURDIR}/../include CFLAGS+=-I${.CURDIR}/../rpcx CFLAGS+=-I${.CURDIR}/../config @@ -10,6 +11,14 @@ CFLAGS+=-DARCH_REP=\"${MACHINE}\" CFLAGS+=-DOS_REP=\"bsd44\" CFLAGS+=-DOS_HDR=\"os-bsd44.h\" .PATH: ${.CURDIR}/../rpcx ${.CURDIR}/../amd +CLEANFILES+=nfs_prot.h +RPCCOM = rpcgen +NFS_PROT_X= /usr/include/rpcsvc/nfs_prot.x + +nfs_prot.h: ${NFS_PROT_X} + ${RPCCOM} -h ${NFS_PROT_X} -o ${.TARGET} + +${OBJS} beforedepend: nfs_prot.h .include "../../Makefile.inc" .include <bsd.prog.mk> diff --git a/usr.sbin/amd/mk-amd-map/Makefile b/usr.sbin/amd/mk-amd-map/Makefile index 52c2a4941837..c1cc6b14a08e 100644 --- a/usr.sbin/amd/mk-amd-map/Makefile +++ b/usr.sbin/amd/mk-amd-map/Makefile @@ -1,11 +1,20 @@ # @(#)Makefile 8.1 (Berkeley) 6/28/93 PROG= mk-amd-map +CFLAGS+=-I${.OBJDIR} CFLAGS+=-I${.CURDIR}/../include CFLAGS+=-I${.CURDIR}/../rpcx CFLAGS+=-I${.CURDIR}/../config CFLAGS+=-DOS_HDR=\"os-bsd44.h\" MAN8= mk-amd-map.8 +CLEANFILES+=nfs_prot.h +RPCCOM = rpcgen +NFS_PROT_X= /usr/include/rpcsvc/nfs_prot.x + +nfs_prot.h: ${NFS_PROT_X} + ${RPCCOM} -h ${NFS_PROT_X} -o ${.TARGET} + +${OBJS} beforedepend: nfs_prot.h .include "../../Makefile.inc" .include <bsd.prog.mk> diff --git a/usr.sbin/amd/rpcx/mount.h b/usr.sbin/amd/rpcx/mount.h deleted file mode 100644 index d30b0c3809dd..000000000000 --- a/usr.sbin/amd/rpcx/mount.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 1990 Jan-Simon Pendry - * Copyright (c) 1990 Imperial College of Science, Technology & Medicine - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry at Imperial College, London. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mount.h 8.1 (Berkeley) 6/6/93 - * - * $Id: mount.h,v 5.2.2.1 1992/02/09 15:09:27 jsp beta $ - * - */ - -#define MNTPATHLEN 1024 -#define MNTNAMLEN 255 -#define FHSIZE 32 - -typedef char fhandle[FHSIZE]; -bool_t xdr_fhandle(); - - -struct fhstatus { - u_int fhs_status; - union { - fhandle fhs_fhandle; - } fhstatus_u; -}; -typedef struct fhstatus fhstatus; -bool_t xdr_fhstatus(); - - -typedef char *dirpath; -bool_t xdr_dirpath(); - - -typedef char *name; -bool_t xdr_name(); - - -typedef struct mountbody *mountlist; -bool_t xdr_mountlist(); - - -struct mountbody { - name ml_hostname; - dirpath ml_directory; - mountlist ml_next; -}; -typedef struct mountbody mountbody; -bool_t xdr_mountbody(); - - -typedef struct groupnode *groups; -bool_t xdr_groups(); - - -struct groupnode { - name gr_name; - groups gr_next; -}; -typedef struct groupnode groupnode; -bool_t xdr_groupnode(); - - -typedef struct exportnode *exports; -bool_t xdr_exports(); - - -struct exportnode { - dirpath ex_dir; - groups ex_groups; - exports ex_next; -}; -typedef struct exportnode exportnode; -bool_t xdr_exportnode(); - - -#define MOUNTPROG ((u_long)100005) -#define MOUNTVERS ((u_long)1) -#define MOUNTPROC_NULL ((u_long)0) -extern voidp mountproc_null_1(); -#define MOUNTPROC_MNT ((u_long)1) -extern fhstatus *mountproc_mnt_1(); -#define MOUNTPROC_DUMP ((u_long)2) -extern mountlist *mountproc_dump_1(); -#define MOUNTPROC_UMNT ((u_long)3) -extern voidp mountproc_umnt_1(); -#define MOUNTPROC_UMNTALL ((u_long)4) -extern voidp mountproc_umntall_1(); -#define MOUNTPROC_EXPORT ((u_long)5) -extern exports *mountproc_export_1(); -#define MOUNTPROC_EXPORTALL ((u_long)6) -extern exports *mountproc_exportall_1(); - diff --git a/usr.sbin/amd/rpcx/mount_xdr.c b/usr.sbin/amd/rpcx/mount_xdr.c deleted file mode 100644 index f8d8f57f0fca..000000000000 --- a/usr.sbin/amd/rpcx/mount_xdr.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 1989 Jan-Simon Pendry - * Copyright (c) 1989 Imperial College of Science, Technology & Medicine - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry at Imperial College, London. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mount_xdr.c 8.1 (Berkeley) 6/6/93 - * - * $Id: mount_xdr.c,v 5.2.2.1 1992/02/09 15:09:28 jsp beta $ - * - */ - -#include "am.h" -#include "mount.h" - - -bool_t -xdr_fhandle(xdrs, objp) - XDR *xdrs; - fhandle objp; -{ - if (!xdr_opaque(xdrs, objp, FHSIZE)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_fhstatus(xdrs, objp) - XDR *xdrs; - fhstatus *objp; -{ - if (!xdr_u_int(xdrs, &objp->fhs_status)) { - return (FALSE); - } - switch (objp->fhs_status) { - case 0: - if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - - - -bool_t -xdr_dirpath(xdrs, objp) - XDR *xdrs; - dirpath *objp; -{ - if (!xdr_string(xdrs, objp, MNTPATHLEN)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_name(xdrs, objp) - XDR *xdrs; - name *objp; -{ - if (!xdr_string(xdrs, objp, MNTNAMLEN)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_mountlist(xdrs, objp) - XDR *xdrs; - mountlist *objp; -{ - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct mountbody), xdr_mountbody)) { - return (FALSE); - } - return (TRUE); -} - - - -bool_t -xdr_mountbody(xdrs, objp) - XDR *xdrs; - mountbody *objp; -{ - if (!xdr_name(xdrs, &objp->ml_hostname)) { - return (FALSE); - } - if (!xdr_dirpath(xdrs, &objp->ml_directory)) { - return (FALSE); - } - if (!xdr_mountlist(xdrs, &objp->ml_next)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_groups(xdrs, objp) - XDR *xdrs; - groups *objp; -{ - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct groupnode), xdr_groupnode)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_groupnode(xdrs, objp) - XDR *xdrs; - groupnode *objp; -{ - if (!xdr_name(xdrs, &objp->gr_name)) { - return (FALSE); - } - if (!xdr_groups(xdrs, &objp->gr_next)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_exports(xdrs, objp) - XDR *xdrs; - exports *objp; -{ - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct exportnode), xdr_exportnode)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_exportnode(xdrs, objp) - XDR *xdrs; - exportnode *objp; -{ - if (!xdr_dirpath(xdrs, &objp->ex_dir)) { - return (FALSE); - } - if (!xdr_groups(xdrs, &objp->ex_groups)) { - return (FALSE); - } - if (!xdr_exports(xdrs, &objp->ex_next)) { - return (FALSE); - } - return (TRUE); -} - - diff --git a/usr.sbin/amd/rpcx/nfs_prot.h b/usr.sbin/amd/rpcx/nfs_prot.h deleted file mode 100644 index 62a75f7993fa..000000000000 --- a/usr.sbin/amd/rpcx/nfs_prot.h +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) 1990 Jan-Simon Pendry - * Copyright (c) 1990 Imperial College of Science, Technology & Medicine - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry at Imperial College, London. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nfs_prot.h 8.1 (Berkeley) 6/6/93 - * - * $Id: nfs_prot.h,v 5.2.2.1 1992/02/09 15:09:29 jsp beta $ - * - */ - -#define xdr_nfsstat xdr_enum -#define xdr_ftype xdr_enum - -#define NFS_PORT 2049 -#define NFS_MAXDATA 8192 -#define NFS_MAXPATHLEN 1024 -#define NFS_MAXNAMLEN 255 -#define NFS_FHSIZE 32 -#define NFS_COOKIESIZE 4 -#define NFS_FIFO_DEV -1 -#define NFSMODE_FMT 0170000 -#define NFSMODE_DIR 0040000 -#define NFSMODE_CHR 0020000 -#define NFSMODE_BLK 0060000 -#define NFSMODE_REG 0100000 -#define NFSMODE_LNK 0120000 -#define NFSMODE_SOCK 0140000 -#define NFSMODE_FIFO 0010000 - -enum nfsstat { - NFS_OK = 0, - NFSERR_PERM = 1, - NFSERR_NOENT = 2, - NFSERR_IO = 5, - NFSERR_NXIO = 6, - NFSERR_ACCES = 13, - NFSERR_EXIST = 17, - NFSERR_NODEV = 19, - NFSERR_NOTDIR = 20, - NFSERR_ISDIR = 21, - NFSERR_FBIG = 27, - NFSERR_NOSPC = 28, - NFSERR_ROFS = 30, - NFSERR_NAMETOOLONG = 63, - NFSERR_NOTEMPTY = 66, - NFSERR_DQUOT = 69, - NFSERR_STALE = 70, - NFSERR_WFLUSH = 99 -}; -typedef enum nfsstat nfsstat; -bool_t xdr_nfsstat(); - - -enum ftype { - NFNON = 0, - NFREG = 1, - NFDIR = 2, - NFBLK = 3, - NFCHR = 4, - NFLNK = 5, - NFSOCK = 6, - NFBAD = 7, - NFFIFO = 8 -}; -typedef enum ftype ftype; -/* static 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; -/* static 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; -/* static 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; -/* static bool_t xdr_sattr(); */ - - -typedef char *filename; -/* static 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]; -/* static 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; -/* static bool_t xdr_entry(); */ - - -struct dirlist { - entry *entries; - bool_t eof; -}; -typedef struct dirlist dirlist; -/* static 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 voidp 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 voidp 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 voidp 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(); - diff --git a/usr.sbin/amd/rpcx/nfs_prot_svc.c b/usr.sbin/amd/rpcx/nfs_prot_svc.c deleted file mode 100644 index 21e47e339962..000000000000 --- a/usr.sbin/amd/rpcx/nfs_prot_svc.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 1989 Jan-Simon Pendry - * Copyright (c) 1989 Imperial College of Science, Technology & Medicine - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry at Imperial College, London. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nfs_prot_svc.c 8.1 (Berkeley) 6/6/93 - * - * $Id: nfs_prot_svc.c,v 5.2.2.1 1992/02/09 15:09:30 jsp beta $ - * - */ - -#include "am.h" - -void nfs_program_2(rqstp, transp) -struct svc_req *rqstp; -SVCXPRT *transp; -{ - union { - nfs_fh nfsproc_getattr_2_arg; - sattrargs nfsproc_setattr_2_arg; - diropargs nfsproc_lookup_2_arg; - nfs_fh nfsproc_readlink_2_arg; - readargs nfsproc_read_2_arg; - writeargs nfsproc_write_2_arg; - createargs nfsproc_create_2_arg; - diropargs nfsproc_remove_2_arg; - renameargs nfsproc_rename_2_arg; - linkargs nfsproc_link_2_arg; - symlinkargs nfsproc_symlink_2_arg; - createargs nfsproc_mkdir_2_arg; - diropargs nfsproc_rmdir_2_arg; - readdirargs nfsproc_readdir_2_arg; - nfs_fh nfsproc_statfs_2_arg; - } argument; - char *result; - bool_t (*xdr_argument)(), (*xdr_result)(); - char *(*local)(); - - switch (rqstp->rq_proc) { - case NFSPROC_NULL: - xdr_argument = xdr_void; - xdr_result = xdr_void; - local = (char *(*)()) nfsproc_null_2; - break; - - case NFSPROC_GETATTR: - xdr_argument = xdr_nfs_fh; - xdr_result = xdr_attrstat; - local = (char *(*)()) nfsproc_getattr_2; - break; - - case NFSPROC_SETATTR: - xdr_argument = xdr_sattrargs; - xdr_result = xdr_attrstat; - local = (char *(*)()) nfsproc_setattr_2; - break; - - case NFSPROC_ROOT: - xdr_argument = xdr_void; - xdr_result = xdr_void; - local = (char *(*)()) nfsproc_root_2; - break; - - case NFSPROC_LOOKUP: - xdr_argument = xdr_diropargs; - xdr_result = xdr_diropres; - local = (char *(*)()) nfsproc_lookup_2; - break; - - case NFSPROC_READLINK: - xdr_argument = xdr_nfs_fh; - xdr_result = xdr_readlinkres; - local = (char *(*)()) nfsproc_readlink_2; - break; - - case NFSPROC_READ: - xdr_argument = xdr_readargs; - xdr_result = xdr_readres; - local = (char *(*)()) nfsproc_read_2; - break; - - case NFSPROC_WRITECACHE: - xdr_argument = xdr_void; - xdr_result = xdr_void; - local = (char *(*)()) nfsproc_writecache_2; - break; - - case NFSPROC_WRITE: - xdr_argument = xdr_writeargs; - xdr_result = xdr_attrstat; - local = (char *(*)()) nfsproc_write_2; - break; - - case NFSPROC_CREATE: - xdr_argument = xdr_createargs; - xdr_result = xdr_diropres; - local = (char *(*)()) nfsproc_create_2; - break; - - case NFSPROC_REMOVE: - xdr_argument = xdr_diropargs; - xdr_result = xdr_nfsstat; - local = (char *(*)()) nfsproc_remove_2; - break; - - case NFSPROC_RENAME: - xdr_argument = xdr_renameargs; - xdr_result = xdr_nfsstat; - local = (char *(*)()) nfsproc_rename_2; - break; - - case NFSPROC_LINK: - xdr_argument = xdr_linkargs; - xdr_result = xdr_nfsstat; - local = (char *(*)()) nfsproc_link_2; - break; - - case NFSPROC_SYMLINK: - xdr_argument = xdr_symlinkargs; - xdr_result = xdr_nfsstat; - local = (char *(*)()) nfsproc_symlink_2; - break; - - case NFSPROC_MKDIR: - xdr_argument = xdr_createargs; - xdr_result = xdr_diropres; - local = (char *(*)()) nfsproc_mkdir_2; - break; - - case NFSPROC_RMDIR: - xdr_argument = xdr_diropargs; - xdr_result = xdr_nfsstat; - local = (char *(*)()) nfsproc_rmdir_2; - break; - - case NFSPROC_READDIR: - xdr_argument = xdr_readdirargs; - xdr_result = xdr_readdirres; - local = (char *(*)()) nfsproc_readdir_2; - break; - - case NFSPROC_STATFS: - xdr_argument = xdr_nfs_fh; - xdr_result = xdr_statfsres; - local = (char *(*)()) nfsproc_statfs_2; - break; - - default: - svcerr_noproc(transp); - return; - } - bzero((char *)&argument, sizeof(argument)); - if (!svc_getargs(transp, xdr_argument, &argument)) { - svcerr_decode(transp); - return; - } - result = (*local)(&argument, rqstp); - if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { - svcerr_systemerr(transp); - } - if (!svc_freeargs(transp, xdr_argument, &argument)) { - plog(XLOG_FATAL, "unable to free rpc arguments in nfs_program_1"); - going_down(1); - } -} - diff --git a/usr.sbin/amd/rpcx/nfs_prot_xdr.c b/usr.sbin/amd/rpcx/nfs_prot_xdr.c deleted file mode 100644 index 1786d01bd642..000000000000 --- a/usr.sbin/amd/rpcx/nfs_prot_xdr.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * Copyright (c) 1989 Jan-Simon Pendry - * Copyright (c) 1989 Imperial College of Science, Technology & Medicine - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry at Imperial College, London. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nfs_prot_xdr.c 8.1 (Berkeley) 6/6/93 - * - * $Id: nfs_prot_xdr.c,v 5.2.2.1 1992/02/09 15:09:32 jsp beta $ - * - */ - -#include "am.h" - - -#ifndef xdr_nfsstat -bool_t -xdr_nfsstat(xdrs, objp) - XDR *xdrs; - nfsstat *objp; -{ - if (!xdr_enum(xdrs, (enum_t *)objp)) { - return (FALSE); - } - return (TRUE); -} -#endif /* xdr_nfsstat */ - - - -#ifndef xdr_ftype -static bool_t -xdr_ftype(xdrs, objp) - XDR *xdrs; - ftype *objp; -{ - if (!xdr_enum(xdrs, (enum_t *)objp)) { - return (FALSE); - } - return (TRUE); -} -#endif /* xdr_ftype */ - - - -bool_t -xdr_nfs_fh(xdrs, objp) - XDR *xdrs; - nfs_fh *objp; -{ - if (!xdr_opaque(xdrs, objp->data, NFS_FHSIZE)) { - return (FALSE); - } - return (TRUE); -} - - - - -static bool_t -xdr_nfstime(xdrs, objp) - XDR *xdrs; - nfstime *objp; -{ - if (!xdr_u_int(xdrs, &objp->seconds)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->useconds)) { - return (FALSE); - } - return (TRUE); -} - - - - -static bool_t -xdr_fattr(xdrs, objp) - XDR *xdrs; - fattr *objp; -{ - if (!xdr_ftype(xdrs, &objp->type)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->nlink)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocksize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->rdev)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fsid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fileid)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->ctime)) { - return (FALSE); - } - return (TRUE); -} - - - - -static bool_t -xdr_sattr(xdrs, objp) - XDR *xdrs; - sattr *objp; -{ - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } - return (TRUE); -} - - - - -static bool_t -xdr_filename(xdrs, objp) - XDR *xdrs; - filename *objp; -{ - if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_nfspath(xdrs, objp) - XDR *xdrs; - nfspath *objp; -{ - if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_attrstat(xdrs, objp) - XDR *xdrs; - attrstat *objp; -{ - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case NFS_OK: - if (!xdr_fattr(xdrs, &objp->attrstat_u.attributes)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - - - -bool_t -xdr_sattrargs(xdrs, objp) - XDR *xdrs; - sattrargs *objp; -{ - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_sattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_diropargs(xdrs, objp) - XDR *xdrs; - diropargs *objp; -{ - if (!xdr_nfs_fh(xdrs, &objp->dir)) { - return (FALSE); - } - if (!xdr_filename(xdrs, &objp->name)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_diropokres(xdrs, objp) - XDR *xdrs; - diropokres *objp; -{ - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_fattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_diropres(xdrs, objp) - XDR *xdrs; - diropres *objp; -{ - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case NFS_OK: - if (!xdr_diropokres(xdrs, &objp->diropres_u.diropres)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - - - -bool_t -xdr_readlinkres(xdrs, objp) - XDR *xdrs; - readlinkres *objp; -{ - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case NFS_OK: - if (!xdr_nfspath(xdrs, &objp->readlinkres_u.data)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - - - -bool_t -xdr_readargs(xdrs, objp) - XDR *xdrs; - readargs *objp; -{ - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->offset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->count)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->totalcount)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_readokres(xdrs, objp) - XDR *xdrs; - readokres *objp; -{ - if (!xdr_fattr(xdrs, &objp->attributes)) { - return (FALSE); - } - if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_readres(xdrs, objp) - XDR *xdrs; - readres *objp; -{ - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case NFS_OK: - if (!xdr_readokres(xdrs, &objp->readres_u.reply)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - - - -bool_t -xdr_writeargs(xdrs, objp) - XDR *xdrs; - writeargs *objp; -{ - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->beginoffset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->offset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->totalcount)) { - return (FALSE); - } - if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_createargs(xdrs, objp) - XDR *xdrs; - createargs *objp; -{ - if (!xdr_diropargs(xdrs, &objp->where)) { - return (FALSE); - } - if (!xdr_sattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_renameargs(xdrs, objp) - XDR *xdrs; - renameargs *objp; -{ - if (!xdr_diropargs(xdrs, &objp->from)) { - return (FALSE); - } - if (!xdr_diropargs(xdrs, &objp->to)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_linkargs(xdrs, objp) - XDR *xdrs; - linkargs *objp; -{ - if (!xdr_nfs_fh(xdrs, &objp->from)) { - return (FALSE); - } - if (!xdr_diropargs(xdrs, &objp->to)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_symlinkargs(xdrs, objp) - XDR *xdrs; - symlinkargs *objp; -{ - if (!xdr_diropargs(xdrs, &objp->from)) { - return (FALSE); - } - if (!xdr_nfspath(xdrs, &objp->to)) { - return (FALSE); - } - if (!xdr_sattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); -} - - - - -static bool_t -xdr_nfscookie(xdrs, objp) - XDR *xdrs; - nfscookie objp; -{ - if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_readdirargs(xdrs, objp) - XDR *xdrs; - readdirargs *objp; -{ - if (!xdr_nfs_fh(xdrs, &objp->dir)) { - return (FALSE); - } - if (!xdr_nfscookie(xdrs, objp->cookie)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->count)) { - return (FALSE); - } - return (TRUE); -} - - - - -static bool_t -xdr_entry(xdrs, objp) - XDR *xdrs; - entry *objp; -{ - if (!xdr_u_int(xdrs, &objp->fileid)) { - return (FALSE); - } - if (!xdr_filename(xdrs, &objp->name)) { - return (FALSE); - } - if (!xdr_nfscookie(xdrs, objp->cookie)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof(entry), xdr_entry)) { - return (FALSE); - } - return (TRUE); -} - - - - -static bool_t -xdr_dirlist(xdrs, objp) - XDR *xdrs; - dirlist *objp; -{ - if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof(entry), xdr_entry)) { - return (FALSE); - } - if (!xdr_bool(xdrs, &objp->eof)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_readdirres(xdrs, objp) - XDR *xdrs; - readdirres *objp; -{ - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case NFS_OK: - if (!xdr_dirlist(xdrs, &objp->readdirres_u.reply)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - - - -bool_t -xdr_statfsokres(xdrs, objp) - XDR *xdrs; - statfsokres *objp; -{ - if (!xdr_u_int(xdrs, &objp->tsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bfree)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bavail)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_statfsres(xdrs, objp) - XDR *xdrs; - statfsres *objp; -{ - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case NFS_OK: - if (!xdr_statfsokres(xdrs, &objp->statfsres_u.reply)) { - return (FALSE); - } - break; - } - return (TRUE); -} |
