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