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