1/*
2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part.  Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
8 *
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12 *
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
16 *
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
20 *
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
24 *
25 * Sun Microsystems, Inc.
26 * 2550 Garcia Avenue
27 * Mountain View, California  94043
28 */
29
30#ifndef RPC_HDR
31%#ifndef lint
32%/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
33%/*static char sccsid[] = "from: @(#)nfs_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
34%#endif /* not lint */
35%#include <sys/cdefs.h>
36%__FBSDID("$FreeBSD$");
37#endif
38
39const NFS_PORT          = 2049;
40const NFS_MAXDATA       = 8192;
41const NFS_MAXPATHLEN    = 1024;
42const NFS_MAXNAMLEN	= 255;
43const NFS_FHSIZE	= 32;
44const NFS_COOKIESIZE	= 4;
45const NFS_FIFO_DEV	= -1;	/* size kludge for named pipes */
46
47/*
48 * File types
49 */
50const NFSMODE_FMT  = 0170000;	/* type of file */
51const NFSMODE_DIR  = 0040000;	/* directory */
52const NFSMODE_CHR  = 0020000;	/* character special */
53const NFSMODE_BLK  = 0060000;	/* block special */
54const NFSMODE_REG  = 0100000;	/* regular */
55const NFSMODE_LNK  = 0120000;	/* symbolic link */
56const NFSMODE_SOCK = 0140000;	/* socket */
57const NFSMODE_FIFO = 0010000;	/* fifo */
58
59/*
60 * Error status
61 */
62enum nfsstat {
63	NFS_OK= 0,		/* no error */
64	NFSERR_PERM=1,		/* Not owner */
65	NFSERR_NOENT=2,		/* No such file or directory */
66	NFSERR_IO=5,		/* I/O error */
67	NFSERR_NXIO=6,		/* No such device or address */
68	NFSERR_ACCES=13,	/* Permission denied */
69	NFSERR_EXIST=17,	/* File exists */
70	NFSERR_NODEV=19,	/* No such device */
71	NFSERR_NOTDIR=20,	/* Not a directory*/
72	NFSERR_ISDIR=21,	/* Is a directory */
73	NFSERR_FBIG=27,		/* File too large */
74	NFSERR_NOSPC=28,	/* No space left on device */
75	NFSERR_ROFS=30,		/* Read-only file system */
76	NFSERR_NAMETOOLONG=63,	/* File name too long */
77	NFSERR_NOTEMPTY=66,	/* Directory not empty */
78	NFSERR_DQUOT=69,	/* Disc quota exceeded */
79	NFSERR_STALE=70,	/* Stale NFS file handle */
80	NFSERR_WFLUSH=99	/* write cache flushed */
81};
82
83/*
84 * File types
85 */
86enum ftype {
87	NFNON = 0,	/* non-file */
88	NFREG = 1,	/* regular file */
89	NFDIR = 2,	/* directory */
90	NFBLK = 3,	/* block special */
91	NFCHR = 4,	/* character special */
92	NFLNK = 5,	/* symbolic link */
93	NFSOCK = 6,	/* unix domain sockets */
94	NFBAD = 7,	/* unused */
95	NFFIFO = 8 	/* named pipe */
96};
97
98/*
99 * File access handle
100 */
101struct nfs_fh {
102	opaque data[NFS_FHSIZE];
103};
104
105/*
106 * Timeval
107 */
108struct nfstime {
109	unsigned seconds;
110	unsigned useconds;
111};
112
113
114/*
115 * File attributes
116 */
117struct fattr {
118	ftype type;		/* file type */
119	unsigned mode;		/* protection mode bits */
120	unsigned nlink;		/* # hard links */
121	unsigned uid;		/* owner user id */
122	unsigned gid;		/* owner group id */
123	unsigned size;		/* file size in bytes */
124	unsigned blocksize;	/* prefered block size */
125	unsigned rdev;		/* special device # */
126	unsigned blocks;	/* Kb of disk used by file */
127	unsigned fsid;		/* device # */
128	unsigned fileid;	/* inode # */
129	nfstime	atime;		/* time of last access */
130	nfstime	mtime;		/* time of last modification */
131	nfstime	ctime;		/* time of last change */
132};
133
134/*
135 * File attributes which can be set
136 */
137struct sattr {
138	unsigned mode;	/* protection mode bits */
139	unsigned uid;	/* owner user id */
140	unsigned gid;	/* owner group id */
141	unsigned size;	/* file size in bytes */
142	nfstime	atime;	/* time of last access */
143	nfstime	mtime;	/* time of last modification */
144};
145
146
147typedef string filename<NFS_MAXNAMLEN>;
148typedef string nfspath<NFS_MAXPATHLEN>;
149
150/*
151 * Reply status with file attributes
152 */
153union attrstat switch (nfsstat status) {
154case NFS_OK:
155	fattr attributes;
156default:
157	void;
158};
159
160struct sattrargs {
161	nfs_fh file;
162	sattr attributes;
163};
164
165/*
166 * Arguments for directory operations
167 */
168struct diropargs {
169	nfs_fh	dir;	/* directory file handle */
170	filename name;		/* name (up to NFS_MAXNAMLEN bytes) */
171};
172
173struct diropokres {
174	nfs_fh file;
175	fattr attributes;
176};
177
178/*
179 * Results from directory operation
180 */
181union diropres switch (nfsstat status) {
182case NFS_OK:
183	diropokres diropres;
184default:
185	void;
186};
187
188union readlinkres switch (nfsstat status) {
189case NFS_OK:
190	nfspath data;
191default:
192	void;
193};
194
195/*
196 * Arguments to remote read
197 */
198struct readargs {
199	nfs_fh file;		/* handle for file */
200	unsigned offset;	/* byte offset in file */
201	unsigned count;		/* immediate read count */
202	unsigned totalcount;	/* total read count (from this offset)*/
203};
204
205/*
206 * Status OK portion of remote read reply
207 */
208struct readokres {
209	fattr	attributes;	/* attributes, need for pagin*/
210	opaque data<NFS_MAXDATA>;
211};
212
213union readres switch (nfsstat status) {
214case NFS_OK:
215	readokres reply;
216default:
217	void;
218};
219
220/*
221 * Arguments to remote write
222 */
223struct writeargs {
224	nfs_fh	file;		/* handle for file */
225	unsigned beginoffset;	/* beginning byte offset in file */
226	unsigned offset;	/* current byte offset in file */
227	unsigned totalcount;	/* total write count (to this offset)*/
228	opaque data<NFS_MAXDATA>;
229};
230
231struct createargs {
232	diropargs where;
233	sattr attributes;
234};
235
236struct renameargs {
237	diropargs from;
238	diropargs to;
239};
240
241struct linkargs {
242	nfs_fh from;
243	diropargs to;
244};
245
246struct symlinkargs {
247	diropargs from;
248	nfspath to;
249	sattr attributes;
250};
251
252
253typedef opaque nfscookie[NFS_COOKIESIZE];
254
255/*
256 * Arguments to readdir
257 */
258struct readdirargs {
259	nfs_fh dir;		/* directory handle */
260	nfscookie cookie;
261	unsigned count;		/* number of directory bytes to read */
262};
263
264struct entry {
265	unsigned fileid;
266	filename name;
267	nfscookie cookie;
268	entry *nextentry;
269};
270
271struct dirlist {
272	entry *entries;
273	bool eof;
274};
275
276union readdirres switch (nfsstat status) {
277case NFS_OK:
278	dirlist reply;
279default:
280	void;
281};
282
283struct statfsokres {
284	unsigned tsize;	/* preferred transfer size in bytes */
285	unsigned bsize;	/* fundamental file system block size */
286	unsigned blocks;	/* total blocks in file system */
287	unsigned bfree;	/* free blocks in fs */
288	unsigned bavail;	/* free blocks avail to non-superuser */
289};
290
291union statfsres switch (nfsstat status) {
292case NFS_OK:
293	statfsokres reply;
294default:
295	void;
296};
297
298#ifdef WANT_NFS3
299
300/*
301 * NFSv3 constants and types
302 */
303const NFS3_FHSIZE	= 64;	/* maximum size in bytes of a file handle */
304const NFS3_COOKIEVERFSIZE = 8;	/* size of a cookie verifier for READDIR */
305const NFS3_CREATEVERFSIZE = 8;	/* size of the verifier used for CREATE */
306const NFS3_WRITEVERFSIZE = 8;	/* size of the verifier used for WRITE */
307
308typedef unsigned hyper uint64;
309typedef hyper int64;
310typedef unsigned long uint32;
311typedef long int32;
312typedef string filename3<>;
313typedef string nfspath3<>;
314typedef uint64 fileid3;
315typedef uint64 cookie3;
316typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
317typedef opaque createverf3[NFS3_CREATEVERFSIZE];
318typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
319typedef uint32 uid3;
320typedef uint32 gid3;
321typedef uint64 size3;
322typedef uint64 offset3;
323typedef uint32 mode3;
324typedef uint32 count3;
325
326/*
327 * Error status (v3)
328 */
329enum nfsstat3 {
330	NFS3_OK	= 0,
331	NFS3ERR_PERM		= 1,
332	NFS3ERR_NOENT		= 2,
333	NFS3ERR_IO		= 5,
334	NFS3ERR_NXIO		= 6,
335	NFS3ERR_ACCES		= 13,
336	NFS3ERR_EXIST		= 17,
337	NFS3ERR_XDEV		= 18,
338	NFS3ERR_NODEV		= 19,
339	NFS3ERR_NOTDIR		= 20,
340	NFS3ERR_ISDIR		= 21,
341	NFS3ERR_INVAL		= 22,
342	NFS3ERR_FBIG		= 27,
343	NFS3ERR_NOSPC		= 28,
344	NFS3ERR_ROFS		= 30,
345	NFS3ERR_MLINK		= 31,
346	NFS3ERR_NAMETOOLONG	= 63,
347	NFS3ERR_NOTEMPTY	= 66,
348	NFS3ERR_DQUOT		= 69,
349	NFS3ERR_STALE		= 70,
350	NFS3ERR_REMOTE		= 71,
351	NFS3ERR_BADHANDLE	= 10001,
352	NFS3ERR_NOT_SYNC	= 10002,
353	NFS3ERR_BAD_COOKIE	= 10003,
354	NFS3ERR_NOTSUPP		= 10004,
355	NFS3ERR_TOOSMALL	= 10005,
356	NFS3ERR_SERVERFAULT	= 10006,
357	NFS3ERR_BADTYPE		= 10007,
358	NFS3ERR_JUKEBOX		= 10008
359};
360
361/*
362 * File types (v3)
363 */
364enum ftype3 {
365	NF3REG	= 1,		/* regular file */
366	NF3DIR	= 2,		/* directory */
367	NF3BLK	= 3,		/* block special */
368	NF3CHR	= 4,		/* character special */
369	NF3LNK	= 5,		/* symbolic link */
370	NF3SOCK	= 6,		/* unix domain sockets */
371	NF3FIFO	= 7		/* named pipe */
372};
373
374struct specdata3 {
375	uint32	specdata1;
376	uint32	specdata2;
377};
378
379/*
380 * File access handle (v3)
381 */
382struct nfs_fh3 {
383	opaque data<NFS3_FHSIZE>;
384};
385
386/*
387 * Timeval (v3)
388 */
389struct nfstime3 {
390	uint32	seconds;
391	uint32	nseconds;
392};
393
394
395/*
396 * File attributes (v3)
397 */
398struct fattr3 {
399	ftype3	type;		/* file type */
400	mode3	mode;		/* protection mode bits */
401	uint32	nlink;		/* # hard links */
402	uid3	uid;		/* owner user id */
403	gid3	gid;		/* owner group id */
404	size3	size;		/* file size in bytes */
405	size3	used;		/* prefered block size */
406	specdata3 rdev;		/* special device # */
407	uint64 fsid;		/* device # */
408	fileid3	fileid;		/* inode # */
409	nfstime3 atime;		/* time of last access */
410	nfstime3 mtime;		/* time of last modification */
411	nfstime3 ctime;		/* time of last change */
412};
413
414union post_op_attr switch (bool attributes_follow) {
415case TRUE:
416	fattr3	attributes;
417case FALSE:
418	void;
419};
420
421struct wcc_attr {
422	size3	size;
423	nfstime3 mtime;
424	nfstime3 ctime;
425};
426
427union pre_op_attr switch (bool attributes_follow) {
428case TRUE:
429	wcc_attr attributes;
430case FALSE:
431	void;
432};
433
434struct wcc_data {
435	pre_op_attr before;
436	post_op_attr after;
437};
438
439union post_op_fh3 switch (bool handle_follows) {
440case TRUE:
441	nfs_fh3	handle;
442case FALSE:
443	void;
444};
445
446/*
447 * File attributes which can be set (v3)
448 */
449enum time_how {
450	DONT_CHANGE		= 0,
451	SET_TO_SERVER_TIME	= 1,
452	SET_TO_CLIENT_TIME	= 2
453};
454
455union set_mode3 switch (bool set_it) {
456case TRUE:
457	mode3	mode;
458default:
459	void;
460};
461
462union set_uid3 switch (bool set_it) {
463case TRUE:
464	uid3	uid;
465default:
466	void;
467};
468
469union set_gid3 switch (bool set_it) {
470case TRUE:
471	gid3	gid;
472default:
473	void;
474};
475
476union set_size3 switch (bool set_it) {
477case TRUE:
478	size3	size;
479default:
480	void;
481};
482
483union set_atime switch (time_how set_it) {
484case SET_TO_CLIENT_TIME:
485	nfstime3	atime;
486default:
487	void;
488};
489
490union set_mtime switch (time_how set_it) {
491case SET_TO_CLIENT_TIME:
492	nfstime3	mtime;
493default:
494	void;
495};
496
497struct sattr3 {
498	set_mode3	mode;
499	set_uid3	uid;
500	set_gid3	gid;
501	set_size3	size;
502	set_atime	atime;
503	set_mtime	mtime;
504};
505
506/*
507 * Arguments for directory operations (v3)
508 */
509struct diropargs3 {
510	nfs_fh3	dir;		/* directory file handle */
511	filename3 name;		/* name (up to NFS_MAXNAMLEN bytes) */
512};
513
514/*
515 * Arguments to getattr (v3).
516 */
517struct GETATTR3args {
518	nfs_fh3		object;
519};
520
521struct GETATTR3resok {
522	fattr3		obj_attributes;
523};
524
525union GETATTR3res switch (nfsstat3 status) {
526case NFS3_OK:
527	GETATTR3resok	resok;
528default:
529	void;
530};
531
532/*
533 * Arguments to setattr (v3).
534 */
535union sattrguard3 switch (bool check) {
536case TRUE:
537	nfstime3	obj_ctime;
538case FALSE:
539	void;
540};
541
542struct SETATTR3args {
543	nfs_fh3		object;
544	sattr3		new_attributes;
545	sattrguard3	guard;
546};
547
548struct SETATTR3resok {
549	wcc_data	obj_wcc;
550};
551
552struct SETATTR3resfail {
553	wcc_data	obj_wcc;
554};
555
556union SETATTR3res switch (nfsstat3 status) {
557case NFS3_OK:
558	SETATTR3resok	resok;
559default:
560	SETATTR3resfail	resfail;
561};
562
563/*
564 * Arguments to lookup (v3).
565 */
566struct LOOKUP3args {
567	diropargs3	what;
568};
569
570struct LOOKUP3resok {
571	nfs_fh3		object;
572	post_op_attr	obj_attributes;
573	post_op_attr	dir_attributes;
574};
575
576struct LOOKUP3resfail {
577	post_op_attr	dir_attributes;
578};
579
580union LOOKUP3res switch (nfsstat3 status) {
581case NFS3_OK:
582	LOOKUP3resok	resok;
583default:
584	LOOKUP3resfail	resfail;
585};
586
587/*
588 * Arguments to access (v3).
589 */
590const ACCESS3_READ	= 0x0001;
591const ACCESS3_LOOKUP	= 0x0002;
592const ACCESS3_MODIFY	= 0x0004;
593const ACCESS3_EXTEND	= 0x0008;
594const ACCESS3_DELETE	= 0x0010;
595const ACCESS3_EXECUTE	= 0x0020;
596
597struct ACCESS3args {
598	nfs_fh3		object;
599	uint32		access;
600};
601
602struct ACCESS3resok {
603	post_op_attr	obj_attributes;
604	uint32		access;
605};
606
607struct ACCESS3resfail {
608	post_op_attr	obj_attributes;
609};
610
611union ACCESS3res switch (nfsstat3 status) {
612case NFS3_OK:
613	ACCESS3resok	resok;
614default:
615	ACCESS3resfail	resfail;
616};
617
618/*
619 * Arguments to readlink (v3).
620 */
621struct READLINK3args {
622	nfs_fh3		symlink;
623};
624
625struct READLINK3resok {
626	post_op_attr	symlink_attributes;
627	nfspath3	data;
628};
629
630struct READLINK3resfail {
631	post_op_attr	symlink_attributes;
632};
633
634union READLINK3res switch (nfsstat3 status) {
635case NFS3_OK:
636	READLINK3resok	resok;
637default:
638	READLINK3resfail resfail;
639};
640
641/*
642 * Arguments to read (v3).
643 */
644struct READ3args {
645	nfs_fh3		file;
646	offset3		offset;
647	count3		count;
648};
649
650struct READ3resok {
651	post_op_attr	file_attributes;
652	count3		count;
653	bool		eof;
654	opaque		data<>;
655};
656
657struct READ3resfail {
658	post_op_attr	file_attributes;
659};
660
661/* XXX: solaris 2.6 uses ``nfsstat'' here */
662union READ3res switch (nfsstat3 status) {
663case NFS3_OK:
664	READ3resok	resok;
665default:
666	READ3resfail	resfail;
667};
668
669/*
670 * Arguments to write (v3).
671 */
672enum stable_how {
673	UNSTABLE	= 0,
674	DATA_SYNC	= 1,
675	FILE_SYNC	= 2
676};
677
678struct WRITE3args {
679	nfs_fh3		file;
680	offset3		offset;
681	count3		count;
682	stable_how	stable;
683	opaque		data<>;
684};
685
686struct WRITE3resok {
687	wcc_data	file_wcc;
688	count3		count;
689	stable_how	committed;
690	writeverf3	verf;
691};
692
693struct WRITE3resfail {
694	wcc_data	file_wcc;
695};
696
697union WRITE3res switch (nfsstat3 status) {
698case NFS3_OK:
699	WRITE3resok	resok;
700default:
701	WRITE3resfail	resfail;
702};
703
704/*
705 * Arguments to create (v3).
706 */
707enum createmode3 {
708	UNCHECKED	= 0,
709	GUARDED		= 1,
710	EXCLUSIVE	= 2
711};
712
713union createhow3 switch (createmode3 mode) {
714case UNCHECKED:
715case GUARDED:
716	sattr3		obj_attributes;
717case EXCLUSIVE:
718	createverf3	verf;
719};
720
721struct CREATE3args {
722	diropargs3	where;
723	createhow3	how;
724};
725
726struct CREATE3resok {
727	post_op_fh3	obj;
728	post_op_attr	obj_attributes;
729	wcc_data	dir_wcc;
730};
731
732struct CREATE3resfail {
733	wcc_data	dir_wcc;
734};
735
736union CREATE3res switch (nfsstat3 status) {
737case NFS3_OK:
738	CREATE3resok	resok;
739default:
740	CREATE3resfail	resfail;
741};
742
743/*
744 * Arguments to mkdir (v3).
745 */
746struct MKDIR3args {
747	diropargs3	where;
748	sattr3		attributes;
749};
750
751struct MKDIR3resok {
752	post_op_fh3	obj;
753	post_op_attr	obj_attributes;
754	wcc_data	dir_wcc;
755};
756
757struct MKDIR3resfail {
758	wcc_data	dir_wcc;
759};
760
761union MKDIR3res switch (nfsstat3 status) {
762case NFS3_OK:
763	MKDIR3resok	resok;
764default:
765	MKDIR3resfail	resfail;
766};
767
768/*
769 * Arguments to symlink (v3).
770 */
771struct symlinkdata3 {
772	sattr3		symlink_attributes;
773	nfspath3	symlink_data;
774};
775
776struct SYMLINK3args {
777	diropargs3	where;
778	symlinkdata3	symlink;
779};
780
781struct SYMLINK3resok {
782	post_op_fh3	obj;
783	post_op_attr	obj_attributes;
784	wcc_data	dir_wcc;
785};
786
787struct SYMLINK3resfail {
788	wcc_data	dir_wcc;
789};
790
791union SYMLINK3res switch (nfsstat3 status) {
792case NFS3_OK:
793	SYMLINK3resok	resok;
794default:
795	SYMLINK3resfail	resfail;
796};
797
798/*
799 * Arguments to mknod (v3).
800 */
801struct devicedata3 {
802	sattr3		dev_attributes;
803	specdata3	spec;
804};
805
806union mknoddata3 switch (ftype3 type) {
807case NF3CHR:
808case NF3BLK:
809	devicedata3	device;
810case NF3SOCK:
811case NF3FIFO:
812	sattr3		pipe_attributes;
813default:
814	void;
815};
816
817struct MKNOD3args {
818	diropargs3	where;
819	mknoddata3	what;
820};
821
822struct MKNOD3resok {
823	post_op_fh3	obj;
824	post_op_attr	obj_attributes;
825	wcc_data	dir_wcc;
826};
827
828struct MKNOD3resfail {
829	wcc_data	dir_wcc;
830};
831
832union MKNOD3res switch (nfsstat3 status) {
833case NFS3_OK:
834	MKNOD3resok	resok;
835default:
836	MKNOD3resfail	resfail;
837};
838
839/*
840 * Arguments to remove (v3).
841 */
842struct REMOVE3args {
843	diropargs3	object;
844};
845
846struct REMOVE3resok {
847	wcc_data	dir_wcc;
848};
849
850struct REMOVE3resfail {
851	wcc_data	dir_wcc;
852};
853
854union REMOVE3res switch (nfsstat3 status) {
855case NFS3_OK:
856	REMOVE3resok	resok;
857default:
858	REMOVE3resfail	resfail;
859};
860
861/*
862 * Arguments to rmdir (v3).
863 */
864struct RMDIR3args {
865	diropargs3	object;
866};
867
868struct RMDIR3resok {
869	wcc_data	dir_wcc;
870};
871
872struct RMDIR3resfail {
873	wcc_data	dir_wcc;
874};
875
876union RMDIR3res switch (nfsstat3 status) {
877case NFS3_OK:
878	RMDIR3resok	resok;
879default:
880	RMDIR3resfail	resfail;
881};
882
883/*
884 * Arguments to rename (v3).
885 */
886struct RENAME3args {
887	diropargs3	from;
888	diropargs3	to;
889};
890
891struct RENAME3resok {
892	wcc_data	fromdir_wcc;
893	wcc_data	todir_wcc;
894};
895
896struct RENAME3resfail {
897	wcc_data	fromdir_wcc;
898	wcc_data	todir_wcc;
899};
900
901union RENAME3res switch (nfsstat3 status) {
902case NFS3_OK:
903	RENAME3resok	resok;
904default:
905	RENAME3resfail	resfail;
906};
907
908/*
909 * Arguments to link (v3).
910 */
911struct LINK3args {
912	nfs_fh3		file;
913	diropargs3	link;
914};
915
916struct LINK3resok {
917	post_op_attr	file_attributes;
918	wcc_data	linkdir_wcc;
919};
920
921struct LINK3resfail {
922	post_op_attr	file_attributes;
923	wcc_data	linkdir_wcc;
924};
925
926union LINK3res switch (nfsstat3 status) {
927case NFS3_OK:
928	LINK3resok	resok;
929default:
930	LINK3resfail	resfail;
931};
932
933/*
934 * Arguments to readdir (v3).
935 */
936struct READDIR3args {
937	nfs_fh3		dir;
938	cookie3		cookie;
939	cookieverf3	cookieverf;
940	count3		count;
941};
942
943struct entry3 {
944	fileid3		fileid;
945	filename3	name;
946	cookie3		cookie;
947	entry3		*nextentry;
948};
949
950struct dirlist3 {
951	entry3		*entries;
952	bool		eof;
953};
954
955struct READDIR3resok {
956	post_op_attr	dir_attributes;
957	cookieverf3	cookieverf;
958	dirlist3	reply;
959};
960
961struct READDIR3resfail {
962	post_op_attr	dir_attributes;
963};
964
965union READDIR3res switch (nfsstat3 status) {
966case NFS3_OK:
967	READDIR3resok	resok;
968default:
969	READDIR3resfail	resfail;
970};
971
972/*
973 * Arguments to readdirplus (v3).
974 */
975struct READDIRPLUS3args {
976	nfs_fh3		dir;
977	cookie3		cookie;
978	cookieverf3	cookieverf;
979	count3		dircount;
980	count3		maxcount;
981};
982
983struct entryplus3 {
984	fileid3		fileid;
985	filename3	name;
986	cookie3		cookie;
987	post_op_attr	name_attributes;
988	post_op_fh3	name_handle;
989	entryplus3	*nextentry;
990};
991
992struct dirlistplus3 {
993	entryplus3	*entries;
994	bool		eof;
995};
996
997struct READDIRPLUS3resok {
998	post_op_attr	dir_attributes;
999	cookieverf3	cookieverf;
1000	dirlistplus3	reply;
1001};
1002
1003struct READDIRPLUS3resfail {
1004	post_op_attr	dir_attributes;
1005};
1006
1007union READDIRPLUS3res switch (nfsstat3 status) {
1008case NFS3_OK:
1009	READDIRPLUS3resok	resok;
1010default:
1011	READDIRPLUS3resfail	resfail;
1012};
1013
1014/*
1015 * Arguments to fsstat (v3).
1016 */
1017struct FSSTAT3args {
1018	nfs_fh3		fsroot;
1019};
1020
1021struct FSSTAT3resok {
1022	post_op_attr	obj_attributes;
1023	size3		tbytes;
1024	size3		fbytes;
1025	size3		abytes;
1026	size3		tfiles;
1027	size3		ffiles;
1028	size3		afiles;
1029	uint32		invarsec;
1030};
1031
1032struct FSSTAT3resfail {
1033	post_op_attr	obj_attributes;
1034};
1035
1036union FSSTAT3res switch (nfsstat3 status) {
1037case NFS3_OK:
1038	FSSTAT3resok	resok;
1039default:
1040	FSSTAT3resfail	resfail;
1041};
1042
1043/*
1044 * Arguments to fsinfo (v3).
1045 */
1046const FSF3_LINK		= 0x0001;
1047const FSF3_SYMLINK	= 0x0002;
1048const FSF3_HOMOGENEOUS	= 0x0008;
1049const FSF3_CANSETTIME	= 0x0010;
1050
1051struct FSINFO3args {
1052	nfs_fh3		fsroot;
1053};
1054
1055struct FSINFO3resok {
1056	post_op_attr	obj_attributes;
1057	uint32		rtmax;
1058	uint32		rtpref;
1059	uint32		rtmult;
1060	uint32		wtmax;
1061	uint32		wtpref;
1062	uint32		wtmult;
1063	uint32		dtpref;
1064	size3		maxfilesize;
1065	nfstime3	time_delta;
1066	uint32		properties;
1067};
1068
1069struct FSINFO3resfail {
1070	post_op_attr	obj_attributes;
1071};
1072
1073union FSINFO3res switch (nfsstat3 status) {
1074case NFS3_OK:
1075	FSINFO3resok	resok;
1076default:
1077	FSINFO3resfail	resfail;
1078};
1079
1080/*
1081 * Arguments to pathconf (v3).
1082 */
1083struct PATHCONF3args {
1084	nfs_fh3		object;
1085};
1086
1087struct PATHCONF3resok {
1088	post_op_attr	obj_attributes;
1089	uint32		linkmax;
1090	uint32		name_max;
1091	bool		no_trunc;
1092	bool		chown_restricted;
1093	bool		case_insensitive;
1094	bool		case_preserving;
1095};
1096
1097struct PATHCONF3resfail {
1098	post_op_attr	obj_attributes;
1099};
1100
1101union PATHCONF3res switch (nfsstat3 status) {
1102case NFS3_OK:
1103	PATHCONF3resok	resok;
1104default:
1105	PATHCONF3resfail	resfail;
1106};
1107
1108/*
1109 * Arguments to commit (v3).
1110 */
1111struct COMMIT3args {
1112	nfs_fh3		file;
1113	offset3		offset;
1114	count3		count;
1115};
1116
1117struct COMMIT3resok {
1118	wcc_data	file_wcc;
1119	writeverf3	verf;
1120};
1121
1122struct COMMIT3resfail {
1123	wcc_data	file_wcc;
1124};
1125
1126union COMMIT3res switch (nfsstat3 status) {
1127case NFS3_OK:
1128	COMMIT3resok	resok;
1129default:
1130	COMMIT3resfail	resfail;
1131};
1132
1133#endif /* WANT_NFS3 */
1134
1135/*
1136 * Remote file service routines
1137 */
1138program NFS_PROGRAM {
1139	version NFS_VERSION {
1140		void
1141		NFSPROC_NULL(void) = 0;
1142
1143		attrstat
1144		NFSPROC_GETATTR(nfs_fh) =	1;
1145
1146		attrstat
1147		NFSPROC_SETATTR(sattrargs) = 2;
1148
1149		void
1150		NFSPROC_ROOT(void) = 3;
1151
1152		diropres
1153		NFSPROC_LOOKUP(diropargs) = 4;
1154
1155		readlinkres
1156		NFSPROC_READLINK(nfs_fh) = 5;
1157
1158		readres
1159		NFSPROC_READ(readargs) = 6;
1160
1161		void
1162		NFSPROC_WRITECACHE(void) = 7;
1163
1164		attrstat
1165		NFSPROC_WRITE(writeargs) = 8;
1166
1167		diropres
1168		NFSPROC_CREATE(createargs) = 9;
1169
1170		nfsstat
1171		NFSPROC_REMOVE(diropargs) = 10;
1172
1173		nfsstat
1174		NFSPROC_RENAME(renameargs) = 11;
1175
1176		nfsstat
1177		NFSPROC_LINK(linkargs) = 12;
1178
1179		nfsstat
1180		NFSPROC_SYMLINK(symlinkargs) = 13;
1181
1182		diropres
1183		NFSPROC_MKDIR(createargs) = 14;
1184
1185		nfsstat
1186		NFSPROC_RMDIR(diropargs) = 15;
1187
1188		readdirres
1189		NFSPROC_READDIR(readdirargs) = 16;
1190
1191		statfsres
1192		NFSPROC_STATFS(nfs_fh) = 17;
1193	} = 2;
1194} = 100003;
1195#ifdef WANT_NFS3
1196program NFS3_PROGRAM {
1197	version NFS_V3 {
1198		void
1199		NFSPROC3_NULL(void)			= 0;
1200
1201		GETATTR3res
1202		NFSPROC3_GETATTR(GETATTR3args)		= 1;
1203
1204		SETATTR3res
1205		NFSPROC3_SETATTR(SETATTR3args)		= 2;
1206
1207		LOOKUP3res
1208		NFSPROC3_LOOKUP(LOOKUP3args)		= 3;
1209
1210		ACCESS3res
1211		NFSPROC3_ACCESS(ACCESS3args)		= 4;
1212
1213		READLINK3res
1214		NFSPROC3_READLINK(READLINK3args)	= 5;
1215
1216		READ3res
1217		NFSPROC3_READ(READ3args)		= 6;
1218
1219		WRITE3res
1220		NFSPROC3_WRITE(WRITE3args)		= 7;
1221
1222		CREATE3res
1223		NFSPROC3_CREATE(CREATE3args)		= 8;
1224
1225		MKDIR3res
1226		NFSPROC3_MKDIR(MKDIR3args)		= 9;
1227
1228		SYMLINK3res
1229		NFSPROC3_SYMLINK(SYMLINK3args)		= 10;
1230
1231		MKNOD3res
1232		NFSPROC3_MKNOD(MKNOD3args)		= 11;
1233
1234		REMOVE3res
1235		NFSPROC3_REMOVE(REMOVE3args)		= 12;
1236
1237		RMDIR3res
1238		NFSPROC3_RMDIR(RMDIR3args)		= 13;
1239
1240		RENAME3res
1241		NFSPROC3_RENAME(RENAME3args)		= 14;
1242
1243		LINK3res
1244		NFSPROC3_LINK(LINK3args)		= 15;
1245
1246		READDIR3res
1247		NFSPROC3_READDIR(READDIR3args)		= 16;
1248
1249		READDIRPLUS3res
1250		NFSPROC3_READDIRPLUS(READDIRPLUS3args)	= 17;
1251
1252		FSSTAT3res
1253		NFSPROC3_FSSTAT(FSSTAT3args)		= 18;
1254
1255		FSINFO3res
1256		NFSPROC3_FSINFO(FSINFO3args)		= 19;
1257
1258		PATHCONF3res
1259		NFSPROC3_PATHCONF(PATHCONF3args)	= 20;
1260
1261		COMMIT3res
1262		NFSPROC3_COMMIT(COMMIT3args)		= 21;
1263	} = 3;
1264} = 100003;
1265#endif
1266
1267