Home | History | Annotate | Line # | Download | only in librpcsvc
nfs_prot.x revision 1.2
      1  1.1      jtc /*
      2  1.1      jtc  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
      3  1.1      jtc  * unrestricted use provided that this legend is included on all tape
      4  1.1      jtc  * media and as a part of the software program in whole or part.  Users
      5  1.1      jtc  * may copy or modify Sun RPC without charge, but are not authorized
      6  1.1      jtc  * to license or distribute it to anyone else except as part of a product or
      7  1.1      jtc  * program developed by the user.
      8  1.1      jtc  *
      9  1.1      jtc  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
     10  1.1      jtc  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
     11  1.1      jtc  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
     12  1.1      jtc  *
     13  1.1      jtc  * Sun RPC is provided with no support and without any obligation on the
     14  1.1      jtc  * part of Sun Microsystems, Inc. to assist in its use, correction,
     15  1.1      jtc  * modification or enhancement.
     16  1.1      jtc  *
     17  1.1      jtc  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
     18  1.1      jtc  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
     19  1.1      jtc  * OR ANY PART THEREOF.
     20  1.1      jtc  *
     21  1.1      jtc  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
     22  1.1      jtc  * or profits or other special, indirect and consequential damages, even if
     23  1.1      jtc  * Sun has been advised of the possibility of such damages.
     24  1.1      jtc  *
     25  1.1      jtc  * Sun Microsystems, Inc.
     26  1.1      jtc  * 2550 Garcia Avenue
     27  1.1      jtc  * Mountain View, California  94043
     28  1.1      jtc  */
     29  1.1      jtc 
     30  1.1      jtc #ifndef RPC_HDR
     31  1.1      jtc %#ifndef lint
     32  1.1      jtc %/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
     33  1.1      jtc %/*static char sccsid[] = "from: @(#)nfs_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
     34  1.2  thorpej %static char rcsid[] = "$NetBSD: nfs_prot.x,v 1.2 1996/09/26 23:45:23 thorpej Exp $";
     35  1.1      jtc %#endif /* not lint */
     36  1.1      jtc #endif
     37  1.1      jtc 
     38  1.1      jtc const NFS_PORT          = 2049;
     39  1.1      jtc const NFS_MAXDATA       = 8192;
     40  1.1      jtc const NFS_MAXPATHLEN    = 1024;
     41  1.1      jtc const NFS_MAXNAMLEN	= 255;
     42  1.1      jtc const NFS_FHSIZE	= 32;
     43  1.1      jtc const NFS_COOKIESIZE	= 4;
     44  1.1      jtc const NFS_FIFO_DEV	= -1;	/* size kludge for named pipes */
     45  1.1      jtc 
     46  1.1      jtc /*
     47  1.1      jtc  * File types
     48  1.1      jtc  */
     49  1.1      jtc const NFSMODE_FMT  = 0170000;	/* type of file */
     50  1.1      jtc const NFSMODE_DIR  = 0040000;	/* directory */
     51  1.1      jtc const NFSMODE_CHR  = 0020000;	/* character special */
     52  1.1      jtc const NFSMODE_BLK  = 0060000;	/* block special */
     53  1.1      jtc const NFSMODE_REG  = 0100000;	/* regular */
     54  1.1      jtc const NFSMODE_LNK  = 0120000;	/* symbolic link */
     55  1.1      jtc const NFSMODE_SOCK = 0140000;	/* socket */
     56  1.1      jtc const NFSMODE_FIFO = 0010000;	/* fifo */
     57  1.1      jtc 
     58  1.1      jtc /*
     59  1.1      jtc  * Error status
     60  1.1      jtc  */
     61  1.1      jtc enum nfsstat {
     62  1.1      jtc 	NFS_OK= 0,		/* no error */
     63  1.1      jtc 	NFSERR_PERM=1,		/* Not owner */
     64  1.1      jtc 	NFSERR_NOENT=2,		/* No such file or directory */
     65  1.1      jtc 	NFSERR_IO=5,		/* I/O error */
     66  1.1      jtc 	NFSERR_NXIO=6,		/* No such device or address */
     67  1.1      jtc 	NFSERR_ACCES=13,	/* Permission denied */
     68  1.1      jtc 	NFSERR_EXIST=17,	/* File exists */
     69  1.1      jtc 	NFSERR_NODEV=19,	/* No such device */
     70  1.1      jtc 	NFSERR_NOTDIR=20,	/* Not a directory*/
     71  1.1      jtc 	NFSERR_ISDIR=21,	/* Is a directory */
     72  1.1      jtc 	NFSERR_FBIG=27,		/* File too large */
     73  1.1      jtc 	NFSERR_NOSPC=28,	/* No space left on device */
     74  1.1      jtc 	NFSERR_ROFS=30,		/* Read-only file system */
     75  1.1      jtc 	NFSERR_NAMETOOLONG=63,	/* File name too long */
     76  1.1      jtc 	NFSERR_NOTEMPTY=66,	/* Directory not empty */
     77  1.1      jtc 	NFSERR_DQUOT=69,	/* Disc quota exceeded */
     78  1.1      jtc 	NFSERR_STALE=70,	/* Stale NFS file handle */
     79  1.1      jtc 	NFSERR_WFLUSH=99	/* write cache flushed */
     80  1.1      jtc };
     81  1.1      jtc 
     82  1.1      jtc /*
     83  1.1      jtc  * File types
     84  1.1      jtc  */
     85  1.1      jtc enum ftype {
     86  1.1      jtc 	NFNON = 0,	/* non-file */
     87  1.1      jtc 	NFREG = 1,	/* regular file */
     88  1.1      jtc 	NFDIR = 2,	/* directory */
     89  1.1      jtc 	NFBLK = 3,	/* block special */
     90  1.1      jtc 	NFCHR = 4,	/* character special */
     91  1.1      jtc 	NFLNK = 5,	/* symbolic link */
     92  1.1      jtc 	NFSOCK = 6,	/* unix domain sockets */
     93  1.1      jtc 	NFBAD = 7,	/* unused */
     94  1.1      jtc 	NFFIFO = 8 	/* named pipe */
     95  1.1      jtc };
     96  1.1      jtc 
     97  1.1      jtc /*
     98  1.1      jtc  * File access handle
     99  1.1      jtc  */
    100  1.1      jtc struct nfs_fh {
    101  1.1      jtc 	opaque data[NFS_FHSIZE];
    102  1.1      jtc };
    103  1.1      jtc 
    104  1.1      jtc /*
    105  1.1      jtc  * Timeval
    106  1.1      jtc  */
    107  1.1      jtc struct nfstime {
    108  1.1      jtc 	unsigned seconds;
    109  1.1      jtc 	unsigned useconds;
    110  1.1      jtc };
    111  1.1      jtc 
    112  1.1      jtc 
    113  1.1      jtc /*
    114  1.1      jtc  * File attributes
    115  1.1      jtc  */
    116  1.1      jtc struct fattr {
    117  1.1      jtc 	ftype type;		/* file type */
    118  1.1      jtc 	unsigned mode;		/* protection mode bits */
    119  1.1      jtc 	unsigned nlink;		/* # hard links */
    120  1.1      jtc 	unsigned uid;		/* owner user id */
    121  1.1      jtc 	unsigned gid;		/* owner group id */
    122  1.1      jtc 	unsigned size;		/* file size in bytes */
    123  1.1      jtc 	unsigned blocksize;	/* prefered block size */
    124  1.1      jtc 	unsigned rdev;		/* special device # */
    125  1.1      jtc 	unsigned blocks;	/* Kb of disk used by file */
    126  1.1      jtc 	unsigned fsid;		/* device # */
    127  1.1      jtc 	unsigned fileid;	/* inode # */
    128  1.1      jtc 	nfstime	atime;		/* time of last access */
    129  1.1      jtc 	nfstime	mtime;		/* time of last modification */
    130  1.1      jtc 	nfstime	ctime;		/* time of last change */
    131  1.1      jtc };
    132  1.1      jtc 
    133  1.1      jtc /*
    134  1.1      jtc  * File attributes which can be set
    135  1.1      jtc  */
    136  1.1      jtc struct sattr {
    137  1.1      jtc 	unsigned mode;	/* protection mode bits */
    138  1.1      jtc 	unsigned uid;	/* owner user id */
    139  1.1      jtc 	unsigned gid;	/* owner group id */
    140  1.1      jtc 	unsigned size;	/* file size in bytes */
    141  1.1      jtc 	nfstime	atime;	/* time of last access */
    142  1.1      jtc 	nfstime	mtime;	/* time of last modification */
    143  1.1      jtc };
    144  1.1      jtc 
    145  1.1      jtc 
    146  1.1      jtc typedef string filename<NFS_MAXNAMLEN>;
    147  1.1      jtc typedef string nfspath<NFS_MAXPATHLEN>;
    148  1.1      jtc 
    149  1.1      jtc /*
    150  1.1      jtc  * Reply status with file attributes
    151  1.1      jtc  */
    152  1.1      jtc union attrstat switch (nfsstat status) {
    153  1.1      jtc case NFS_OK:
    154  1.1      jtc 	fattr attributes;
    155  1.1      jtc default:
    156  1.1      jtc 	void;
    157  1.1      jtc };
    158  1.1      jtc 
    159  1.1      jtc struct sattrargs {
    160  1.1      jtc 	nfs_fh file;
    161  1.1      jtc 	sattr attributes;
    162  1.1      jtc };
    163  1.1      jtc 
    164  1.1      jtc /*
    165  1.1      jtc  * Arguments for directory operations
    166  1.1      jtc  */
    167  1.1      jtc struct diropargs {
    168  1.1      jtc 	nfs_fh	dir;	/* directory file handle */
    169  1.1      jtc 	filename name;		/* name (up to NFS_MAXNAMLEN bytes) */
    170  1.1      jtc };
    171  1.1      jtc 
    172  1.1      jtc struct diropokres {
    173  1.1      jtc 	nfs_fh file;
    174  1.1      jtc 	fattr attributes;
    175  1.1      jtc };
    176  1.1      jtc 
    177  1.1      jtc /*
    178  1.1      jtc  * Results from directory operation
    179  1.1      jtc  */
    180  1.1      jtc union diropres switch (nfsstat status) {
    181  1.1      jtc case NFS_OK:
    182  1.1      jtc 	diropokres diropres;
    183  1.1      jtc default:
    184  1.1      jtc 	void;
    185  1.1      jtc };
    186  1.1      jtc 
    187  1.1      jtc union readlinkres switch (nfsstat status) {
    188  1.1      jtc case NFS_OK:
    189  1.1      jtc 	nfspath data;
    190  1.1      jtc default:
    191  1.1      jtc 	void;
    192  1.1      jtc };
    193  1.1      jtc 
    194  1.1      jtc /*
    195  1.1      jtc  * Arguments to remote read
    196  1.1      jtc  */
    197  1.1      jtc struct readargs {
    198  1.1      jtc 	nfs_fh file;		/* handle for file */
    199  1.1      jtc 	unsigned offset;	/* byte offset in file */
    200  1.1      jtc 	unsigned count;		/* immediate read count */
    201  1.1      jtc 	unsigned totalcount;	/* total read count (from this offset)*/
    202  1.1      jtc };
    203  1.1      jtc 
    204  1.1      jtc /*
    205  1.1      jtc  * Status OK portion of remote read reply
    206  1.1      jtc  */
    207  1.1      jtc struct readokres {
    208  1.1      jtc 	fattr	attributes;	/* attributes, need for pagin*/
    209  1.1      jtc 	opaque data<NFS_MAXDATA>;
    210  1.1      jtc };
    211  1.1      jtc 
    212  1.1      jtc union readres switch (nfsstat status) {
    213  1.1      jtc case NFS_OK:
    214  1.1      jtc 	readokres reply;
    215  1.1      jtc default:
    216  1.1      jtc 	void;
    217  1.1      jtc };
    218  1.1      jtc 
    219  1.1      jtc /*
    220  1.1      jtc  * Arguments to remote write
    221  1.1      jtc  */
    222  1.1      jtc struct writeargs {
    223  1.1      jtc 	nfs_fh	file;		/* handle for file */
    224  1.1      jtc 	unsigned beginoffset;	/* beginning byte offset in file */
    225  1.1      jtc 	unsigned offset;	/* current byte offset in file */
    226  1.1      jtc 	unsigned totalcount;	/* total write count (to this offset)*/
    227  1.1      jtc 	opaque data<NFS_MAXDATA>;
    228  1.1      jtc };
    229  1.1      jtc 
    230  1.1      jtc struct createargs {
    231  1.1      jtc 	diropargs where;
    232  1.1      jtc 	sattr attributes;
    233  1.1      jtc };
    234  1.1      jtc 
    235  1.1      jtc struct renameargs {
    236  1.1      jtc 	diropargs from;
    237  1.1      jtc 	diropargs to;
    238  1.1      jtc };
    239  1.1      jtc 
    240  1.1      jtc struct linkargs {
    241  1.1      jtc 	nfs_fh from;
    242  1.1      jtc 	diropargs to;
    243  1.1      jtc };
    244  1.1      jtc 
    245  1.1      jtc struct symlinkargs {
    246  1.1      jtc 	diropargs from;
    247  1.1      jtc 	nfspath to;
    248  1.1      jtc 	sattr attributes;
    249  1.1      jtc };
    250  1.1      jtc 
    251  1.1      jtc 
    252  1.1      jtc typedef opaque nfscookie[NFS_COOKIESIZE];
    253  1.1      jtc 
    254  1.1      jtc /*
    255  1.1      jtc  * Arguments to readdir
    256  1.1      jtc  */
    257  1.1      jtc struct readdirargs {
    258  1.1      jtc 	nfs_fh dir;		/* directory handle */
    259  1.1      jtc 	nfscookie cookie;
    260  1.1      jtc 	unsigned count;		/* number of directory bytes to read */
    261  1.1      jtc };
    262  1.1      jtc 
    263  1.1      jtc struct entry {
    264  1.1      jtc 	unsigned fileid;
    265  1.1      jtc 	filename name;
    266  1.1      jtc 	nfscookie cookie;
    267  1.1      jtc 	entry *nextentry;
    268  1.1      jtc };
    269  1.1      jtc 
    270  1.1      jtc struct dirlist {
    271  1.1      jtc 	entry *entries;
    272  1.1      jtc 	bool eof;
    273  1.1      jtc };
    274  1.1      jtc 
    275  1.1      jtc union readdirres switch (nfsstat status) {
    276  1.1      jtc case NFS_OK:
    277  1.1      jtc 	dirlist reply;
    278  1.1      jtc default:
    279  1.1      jtc 	void;
    280  1.1      jtc };
    281  1.1      jtc 
    282  1.1      jtc struct statfsokres {
    283  1.1      jtc 	unsigned tsize;	/* preferred transfer size in bytes */
    284  1.1      jtc 	unsigned bsize;	/* fundamental file system block size */
    285  1.1      jtc 	unsigned blocks;	/* total blocks in file system */
    286  1.1      jtc 	unsigned bfree;	/* free blocks in fs */
    287  1.1      jtc 	unsigned bavail;	/* free blocks avail to non-superuser */
    288  1.1      jtc };
    289  1.1      jtc 
    290  1.1      jtc union statfsres switch (nfsstat status) {
    291  1.1      jtc case NFS_OK:
    292  1.1      jtc 	statfsokres reply;
    293  1.1      jtc default:
    294  1.1      jtc 	void;
    295  1.1      jtc };
    296  1.1      jtc 
    297  1.1      jtc /*
    298  1.1      jtc  * Remote file service routines
    299  1.1      jtc  */
    300  1.1      jtc program NFS_PROGRAM {
    301  1.1      jtc 	version NFS_VERSION {
    302  1.1      jtc 		void
    303  1.1      jtc 		NFSPROC_NULL(void) = 0;
    304  1.1      jtc 
    305  1.1      jtc 		attrstat
    306  1.1      jtc 		NFSPROC_GETATTR(nfs_fh) =	1;
    307  1.1      jtc 
    308  1.1      jtc 		attrstat
    309  1.1      jtc 		NFSPROC_SETATTR(sattrargs) = 2;
    310  1.1      jtc 
    311  1.1      jtc 		void
    312  1.1      jtc 		NFSPROC_ROOT(void) = 3;
    313  1.1      jtc 
    314  1.1      jtc 		diropres
    315  1.1      jtc 		NFSPROC_LOOKUP(diropargs) = 4;
    316  1.1      jtc 
    317  1.1      jtc 		readlinkres
    318  1.1      jtc 		NFSPROC_READLINK(nfs_fh) = 5;
    319  1.1      jtc 
    320  1.1      jtc 		readres
    321  1.1      jtc 		NFSPROC_READ(readargs) = 6;
    322  1.1      jtc 
    323  1.1      jtc 		void
    324  1.1      jtc 		NFSPROC_WRITECACHE(void) = 7;
    325  1.1      jtc 
    326  1.1      jtc 		attrstat
    327  1.1      jtc 		NFSPROC_WRITE(writeargs) = 8;
    328  1.1      jtc 
    329  1.1      jtc 		diropres
    330  1.1      jtc 		NFSPROC_CREATE(createargs) = 9;
    331  1.1      jtc 
    332  1.1      jtc 		nfsstat
    333  1.1      jtc 		NFSPROC_REMOVE(diropargs) = 10;
    334  1.1      jtc 
    335  1.1      jtc 		nfsstat
    336  1.1      jtc 		NFSPROC_RENAME(renameargs) = 11;
    337  1.1      jtc 
    338  1.1      jtc 		nfsstat
    339  1.1      jtc 		NFSPROC_LINK(linkargs) = 12;
    340  1.1      jtc 
    341  1.1      jtc 		nfsstat
    342  1.1      jtc 		NFSPROC_SYMLINK(symlinkargs) = 13;
    343  1.1      jtc 
    344  1.1      jtc 		diropres
    345  1.1      jtc 		NFSPROC_MKDIR(createargs) = 14;
    346  1.1      jtc 
    347  1.1      jtc 		nfsstat
    348  1.1      jtc 		NFSPROC_RMDIR(diropargs) = 15;
    349  1.1      jtc 
    350  1.1      jtc 		readdirres
    351  1.1      jtc 		NFSPROC_READDIR(readdirargs) = 16;
    352  1.1      jtc 
    353  1.1      jtc 		statfsres
    354  1.1      jtc 		NFSPROC_STATFS(nfs_fh) = 17;
    355  1.1      jtc 	} = 2;
    356  1.1      jtc } = 100003;
    357  1.1      jtc 
    358