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