nfs_prot.x revision 1832
11832Swollman/*
21832Swollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
31832Swollman * unrestricted use provided that this legend is included on all tape
41832Swollman * media and as a part of the software program in whole or part.  Users
51832Swollman * may copy or modify Sun RPC without charge, but are not authorized
61832Swollman * to license or distribute it to anyone else except as part of a product or
71832Swollman * program developed by the user.
81832Swollman *
91832Swollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
101832Swollman * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
111832Swollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
121832Swollman *
131832Swollman * Sun RPC is provided with no support and without any obligation on the
141832Swollman * part of Sun Microsystems, Inc. to assist in its use, correction,
151832Swollman * modification or enhancement.
161832Swollman *
171832Swollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
181832Swollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
191832Swollman * OR ANY PART THEREOF.
201832Swollman *
211832Swollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue
221832Swollman * or profits or other special, indirect and consequential damages, even if
231832Swollman * Sun has been advised of the possibility of such damages.
241832Swollman *
251832Swollman * Sun Microsystems, Inc.
261832Swollman * 2550 Garcia Avenue
271832Swollman * Mountain View, California  94043
281832Swollman */
291832Swollman
301832Swollman#ifndef RPC_HDR
311832Swollman%#ifndef lint
321832Swollman%/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
331832Swollman%/*static char sccsid[] = "from: @(#)nfs_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
341832Swollman%static char rcsid[] = "$Id: nfs_prot.x,v 1.1 1993/09/14 17:42:44 jtc Exp $";
351832Swollman%#endif /* not lint */
361832Swollman#endif
371832Swollman
381832Swollmanconst NFS_PORT          = 2049;
391832Swollmanconst NFS_MAXDATA       = 8192;
401832Swollmanconst NFS_MAXPATHLEN    = 1024;
411832Swollmanconst NFS_MAXNAMLEN	= 255;
421832Swollmanconst NFS_FHSIZE	= 32;
431832Swollmanconst NFS_COOKIESIZE	= 4;
441832Swollmanconst NFS_FIFO_DEV	= -1;	/* size kludge for named pipes */
451832Swollman
461832Swollman/*
471832Swollman * File types
481832Swollman */
491832Swollmanconst NFSMODE_FMT  = 0170000;	/* type of file */
501832Swollmanconst NFSMODE_DIR  = 0040000;	/* directory */
511832Swollmanconst NFSMODE_CHR  = 0020000;	/* character special */
521832Swollmanconst NFSMODE_BLK  = 0060000;	/* block special */
531832Swollmanconst NFSMODE_REG  = 0100000;	/* regular */
541832Swollmanconst NFSMODE_LNK  = 0120000;	/* symbolic link */
551832Swollmanconst NFSMODE_SOCK = 0140000;	/* socket */
561832Swollmanconst NFSMODE_FIFO = 0010000;	/* fifo */
571832Swollman
581832Swollman/*
591832Swollman * Error status
601832Swollman */
611832Swollmanenum nfsstat {
621832Swollman	NFS_OK= 0,		/* no error */
631832Swollman	NFSERR_PERM=1,		/* Not owner */
641832Swollman	NFSERR_NOENT=2,		/* No such file or directory */
651832Swollman	NFSERR_IO=5,		/* I/O error */
661832Swollman	NFSERR_NXIO=6,		/* No such device or address */
671832Swollman	NFSERR_ACCES=13,	/* Permission denied */
681832Swollman	NFSERR_EXIST=17,	/* File exists */
691832Swollman	NFSERR_NODEV=19,	/* No such device */
701832Swollman	NFSERR_NOTDIR=20,	/* Not a directory*/
711832Swollman	NFSERR_ISDIR=21,	/* Is a directory */
721832Swollman	NFSERR_FBIG=27,		/* File too large */
731832Swollman	NFSERR_NOSPC=28,	/* No space left on device */
741832Swollman	NFSERR_ROFS=30,		/* Read-only file system */
751832Swollman	NFSERR_NAMETOOLONG=63,	/* File name too long */
761832Swollman	NFSERR_NOTEMPTY=66,	/* Directory not empty */
771832Swollman	NFSERR_DQUOT=69,	/* Disc quota exceeded */
781832Swollman	NFSERR_STALE=70,	/* Stale NFS file handle */
791832Swollman	NFSERR_WFLUSH=99	/* write cache flushed */
801832Swollman};
811832Swollman
821832Swollman/*
831832Swollman * File types
841832Swollman */
851832Swollmanenum ftype {
861832Swollman	NFNON = 0,	/* non-file */
871832Swollman	NFREG = 1,	/* regular file */
881832Swollman	NFDIR = 2,	/* directory */
891832Swollman	NFBLK = 3,	/* block special */
901832Swollman	NFCHR = 4,	/* character special */
911832Swollman	NFLNK = 5,	/* symbolic link */
921832Swollman	NFSOCK = 6,	/* unix domain sockets */
931832Swollman	NFBAD = 7,	/* unused */
941832Swollman	NFFIFO = 8 	/* named pipe */
951832Swollman};
961832Swollman
971832Swollman/*
981832Swollman * File access handle
991832Swollman */
1001832Swollmanstruct nfs_fh {
1011832Swollman	opaque data[NFS_FHSIZE];
1021832Swollman};
1031832Swollman
1041832Swollman/*
1051832Swollman * Timeval
1061832Swollman */
1071832Swollmanstruct nfstime {
1081832Swollman	unsigned seconds;
1091832Swollman	unsigned useconds;
1101832Swollman};
1111832Swollman
1121832Swollman
1131832Swollman/*
1141832Swollman * File attributes
1151832Swollman */
1161832Swollmanstruct fattr {
1171832Swollman	ftype type;		/* file type */
1181832Swollman	unsigned mode;		/* protection mode bits */
1191832Swollman	unsigned nlink;		/* # hard links */
1201832Swollman	unsigned uid;		/* owner user id */
1211832Swollman	unsigned gid;		/* owner group id */
1221832Swollman	unsigned size;		/* file size in bytes */
1231832Swollman	unsigned blocksize;	/* prefered block size */
1241832Swollman	unsigned rdev;		/* special device # */
1251832Swollman	unsigned blocks;	/* Kb of disk used by file */
1261832Swollman	unsigned fsid;		/* device # */
1271832Swollman	unsigned fileid;	/* inode # */
1281832Swollman	nfstime	atime;		/* time of last access */
1291832Swollman	nfstime	mtime;		/* time of last modification */
1301832Swollman	nfstime	ctime;		/* time of last change */
1311832Swollman};
1321832Swollman
1331832Swollman/*
1341832Swollman * File attributes which can be set
1351832Swollman */
1361832Swollmanstruct sattr {
1371832Swollman	unsigned mode;	/* protection mode bits */
1381832Swollman	unsigned uid;	/* owner user id */
1391832Swollman	unsigned gid;	/* owner group id */
1401832Swollman	unsigned size;	/* file size in bytes */
1411832Swollman	nfstime	atime;	/* time of last access */
1421832Swollman	nfstime	mtime;	/* time of last modification */
1431832Swollman};
1441832Swollman
1451832Swollman
1461832Swollmantypedef string filename<NFS_MAXNAMLEN>;
1471832Swollmantypedef string nfspath<NFS_MAXPATHLEN>;
1481832Swollman
1491832Swollman/*
1501832Swollman * Reply status with file attributes
1511832Swollman */
1521832Swollmanunion attrstat switch (nfsstat status) {
1531832Swollmancase NFS_OK:
1541832Swollman	fattr attributes;
1551832Swollmandefault:
1561832Swollman	void;
1571832Swollman};
1581832Swollman
1591832Swollmanstruct sattrargs {
1601832Swollman	nfs_fh file;
1611832Swollman	sattr attributes;
1621832Swollman};
1631832Swollman
1641832Swollman/*
1651832Swollman * Arguments for directory operations
1661832Swollman */
1671832Swollmanstruct diropargs {
1681832Swollman	nfs_fh	dir;	/* directory file handle */
1691832Swollman	filename name;		/* name (up to NFS_MAXNAMLEN bytes) */
1701832Swollman};
1711832Swollman
1721832Swollmanstruct diropokres {
1731832Swollman	nfs_fh file;
1741832Swollman	fattr attributes;
1751832Swollman};
1761832Swollman
1771832Swollman/*
1781832Swollman * Results from directory operation
1791832Swollman */
1801832Swollmanunion diropres switch (nfsstat status) {
1811832Swollmancase NFS_OK:
1821832Swollman	diropokres diropres;
1831832Swollmandefault:
1841832Swollman	void;
1851832Swollman};
1861832Swollman
1871832Swollmanunion readlinkres switch (nfsstat status) {
1881832Swollmancase NFS_OK:
1891832Swollman	nfspath data;
1901832Swollmandefault:
1911832Swollman	void;
1921832Swollman};
1931832Swollman
1941832Swollman/*
1951832Swollman * Arguments to remote read
1961832Swollman */
1971832Swollmanstruct readargs {
1981832Swollman	nfs_fh file;		/* handle for file */
1991832Swollman	unsigned offset;	/* byte offset in file */
2001832Swollman	unsigned count;		/* immediate read count */
2011832Swollman	unsigned totalcount;	/* total read count (from this offset)*/
2021832Swollman};
2031832Swollman
2041832Swollman/*
2051832Swollman * Status OK portion of remote read reply
2061832Swollman */
2071832Swollmanstruct readokres {
2081832Swollman	fattr	attributes;	/* attributes, need for pagin*/
2091832Swollman	opaque data<NFS_MAXDATA>;
2101832Swollman};
2111832Swollman
2121832Swollmanunion readres switch (nfsstat status) {
2131832Swollmancase NFS_OK:
2141832Swollman	readokres reply;
2151832Swollmandefault:
2161832Swollman	void;
2171832Swollman};
2181832Swollman
2191832Swollman/*
2201832Swollman * Arguments to remote write
2211832Swollman */
2221832Swollmanstruct writeargs {
2231832Swollman	nfs_fh	file;		/* handle for file */
2241832Swollman	unsigned beginoffset;	/* beginning byte offset in file */
2251832Swollman	unsigned offset;	/* current byte offset in file */
2261832Swollman	unsigned totalcount;	/* total write count (to this offset)*/
2271832Swollman	opaque data<NFS_MAXDATA>;
2281832Swollman};
2291832Swollman
2301832Swollmanstruct createargs {
2311832Swollman	diropargs where;
2321832Swollman	sattr attributes;
2331832Swollman};
2341832Swollman
2351832Swollmanstruct renameargs {
2361832Swollman	diropargs from;
2371832Swollman	diropargs to;
2381832Swollman};
2391832Swollman
2401832Swollmanstruct linkargs {
2411832Swollman	nfs_fh from;
2421832Swollman	diropargs to;
2431832Swollman};
2441832Swollman
2451832Swollmanstruct symlinkargs {
2461832Swollman	diropargs from;
2471832Swollman	nfspath to;
2481832Swollman	sattr attributes;
2491832Swollman};
2501832Swollman
2511832Swollman
2521832Swollmantypedef opaque nfscookie[NFS_COOKIESIZE];
2531832Swollman
2541832Swollman/*
2551832Swollman * Arguments to readdir
2561832Swollman */
2571832Swollmanstruct readdirargs {
2581832Swollman	nfs_fh dir;		/* directory handle */
2591832Swollman	nfscookie cookie;
2601832Swollman	unsigned count;		/* number of directory bytes to read */
2611832Swollman};
2621832Swollman
2631832Swollmanstruct entry {
2641832Swollman	unsigned fileid;
2651832Swollman	filename name;
2661832Swollman	nfscookie cookie;
2671832Swollman	entry *nextentry;
2681832Swollman};
2691832Swollman
2701832Swollmanstruct dirlist {
2711832Swollman	entry *entries;
2721832Swollman	bool eof;
2731832Swollman};
2741832Swollman
2751832Swollmanunion readdirres switch (nfsstat status) {
2761832Swollmancase NFS_OK:
2771832Swollman	dirlist reply;
2781832Swollmandefault:
2791832Swollman	void;
2801832Swollman};
2811832Swollman
2821832Swollmanstruct statfsokres {
2831832Swollman	unsigned tsize;	/* preferred transfer size in bytes */
2841832Swollman	unsigned bsize;	/* fundamental file system block size */
2851832Swollman	unsigned blocks;	/* total blocks in file system */
2861832Swollman	unsigned bfree;	/* free blocks in fs */
2871832Swollman	unsigned bavail;	/* free blocks avail to non-superuser */
2881832Swollman};
2891832Swollman
2901832Swollmanunion statfsres switch (nfsstat status) {
2911832Swollmancase NFS_OK:
2921832Swollman	statfsokres reply;
2931832Swollmandefault:
2941832Swollman	void;
2951832Swollman};
2961832Swollman
2971832Swollman/*
2981832Swollman * Remote file service routines
2991832Swollman */
3001832Swollmanprogram NFS_PROGRAM {
3011832Swollman	version NFS_VERSION {
3021832Swollman		void
3031832Swollman		NFSPROC_NULL(void) = 0;
3041832Swollman
3051832Swollman		attrstat
3061832Swollman		NFSPROC_GETATTR(nfs_fh) =	1;
3071832Swollman
3081832Swollman		attrstat
3091832Swollman		NFSPROC_SETATTR(sattrargs) = 2;
3101832Swollman
3111832Swollman		void
3121832Swollman		NFSPROC_ROOT(void) = 3;
3131832Swollman
3141832Swollman		diropres
3151832Swollman		NFSPROC_LOOKUP(diropargs) = 4;
3161832Swollman
3171832Swollman		readlinkres
3181832Swollman		NFSPROC_READLINK(nfs_fh) = 5;
3191832Swollman
3201832Swollman		readres
3211832Swollman		NFSPROC_READ(readargs) = 6;
3221832Swollman
3231832Swollman		void
3241832Swollman		NFSPROC_WRITECACHE(void) = 7;
3251832Swollman
3261832Swollman		attrstat
3271832Swollman		NFSPROC_WRITE(writeargs) = 8;
3281832Swollman
3291832Swollman		diropres
3301832Swollman		NFSPROC_CREATE(createargs) = 9;
3311832Swollman
3321832Swollman		nfsstat
3331832Swollman		NFSPROC_REMOVE(diropargs) = 10;
3341832Swollman
3351832Swollman		nfsstat
3361832Swollman		NFSPROC_RENAME(renameargs) = 11;
3371832Swollman
3381832Swollman		nfsstat
3391832Swollman		NFSPROC_LINK(linkargs) = 12;
3401832Swollman
3411832Swollman		nfsstat
3421832Swollman		NFSPROC_SYMLINK(symlinkargs) = 13;
3431832Swollman
3441832Swollman		diropres
3451832Swollman		NFSPROC_MKDIR(createargs) = 14;
3461832Swollman
3471832Swollman		nfsstat
3481832Swollman		NFSPROC_RMDIR(diropargs) = 15;
3491832Swollman
3501832Swollman		readdirres
3511832Swollman		NFSPROC_READDIR(readdirargs) = 16;
3521832Swollman
3531832Swollman		statfsres
3541832Swollman		NFSPROC_STATFS(nfs_fh) = 17;
3551832Swollman	} = 2;
3561832Swollman} = 100003;
3571832Swollman
358