xref: /illumos-gate/usr/src/head/rpcsvc/nfs_prot.x (revision 59d65d3175825093531e82f44269d948ed510a00)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifdef RPC_HDR
28 %/*
29 % * Definitions for uint64, int64, uint32, and int32
30 % */
31 %#include <rpc/rpc_sztypes.h>
32 %
33 #endif
34 
35 const NFS_PORT          = 2049;
36 const NFS_MAXDATA       = 8192;
37 const NFS_MAXPATHLEN    = 1024;
38 const NFS_MAXNAMLEN	= 255;
39 const NFS_FHSIZE	= 32;
40 const NFS_COOKIESIZE	= 4;
41 const NFS_FIFO_DEV	= -1;	/* size kludge for named pipes */
42 
43 /*
44  * File types
45  */
46 const NFSMODE_FMT  = 0170000;	/* type of file */
47 const NFSMODE_DIR  = 0040000;	/* directory */
48 const NFSMODE_CHR  = 0020000;	/* character special */
49 const NFSMODE_BLK  = 0060000;	/* block special */
50 const NFSMODE_REG  = 0100000;	/* regular */
51 const NFSMODE_LNK  = 0120000;	/* symbolic link */
52 const NFSMODE_SOCK = 0140000;	/* socket */
53 const NFSMODE_FIFO = 0010000;	/* fifo */
54 
55 /*
56  * Error status
57  */
58 enum nfsstat {
59 	NFS_OK= 0,		/* no error */
60 	NFSERR_PERM=1,		/* Not owner */
61 	NFSERR_NOENT=2,		/* No such file or directory */
62 	NFSERR_IO=5,		/* I/O error */
63 	NFSERR_NXIO=6,		/* No such device or address */
64 	NFSERR_ACCES=13,	/* Permission denied */
65 	NFSERR_EXIST=17,	/* File exists */
66 	NFSERR_XDEV=18,		/* Cross-device link */
67 	NFSERR_NODEV=19,	/* No such device */
68 	NFSERR_NOTDIR=20,	/* Not a directory*/
69 	NFSERR_ISDIR=21,	/* Is a directory */
70 	NFSERR_INVAL=22,	/* Invalid argument */
71 	NFSERR_FBIG=27,		/* File too large */
72 	NFSERR_NOSPC=28,	/* No space left on device */
73 	NFSERR_ROFS=30,		/* Read-only file system */
74 	NFSERR_OPNOTSUPP=45,	/* Operation not supported */
75 	NFSERR_NAMETOOLONG=63,	/* File name too long */
76 	NFSERR_NOTEMPTY=66,	/* Directory not empty */
77 	NFSERR_DQUOT=69,	/* Disc quota exceeded */
78 	NFSERR_STALE=70,	/* Stale NFS file handle */
79 	NFSERR_REMOTE=71,	/* Object is remote */
80 	NFSERR_WFLUSH=72	/* 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  * Remote file service routines
300  */
301 program NFS_PROGRAM {
302 	version NFS_VERSION {
303 		void
304 		NFSPROC_NULL(void) = 0;
305 
306 		attrstat
307 		NFSPROC_GETATTR(nfs_fh) =	1;
308 
309 		attrstat
310 		NFSPROC_SETATTR(sattrargs) = 2;
311 
312 		void
313 		NFSPROC_ROOT(void) = 3;
314 
315 		diropres
316 		NFSPROC_LOOKUP(diropargs) = 4;
317 
318 		readlinkres
319 		NFSPROC_READLINK(nfs_fh) = 5;
320 
321 		readres
322 		NFSPROC_READ(readargs) = 6;
323 
324 		void
325 		NFSPROC_WRITECACHE(void) = 7;
326 
327 		attrstat
328 		NFSPROC_WRITE(writeargs) = 8;
329 
330 		diropres
331 		NFSPROC_CREATE(createargs) = 9;
332 
333 		nfsstat
334 		NFSPROC_REMOVE(diropargs) = 10;
335 
336 		nfsstat
337 		NFSPROC_RENAME(renameargs) = 11;
338 
339 		nfsstat
340 		NFSPROC_LINK(linkargs) = 12;
341 
342 		nfsstat
343 		NFSPROC_SYMLINK(symlinkargs) = 13;
344 
345 		diropres
346 		NFSPROC_MKDIR(createargs) = 14;
347 
348 		nfsstat
349 		NFSPROC_RMDIR(diropargs) = 15;
350 
351 		readdirres
352 		NFSPROC_READDIR(readdirargs) = 16;
353 
354 		statfsres
355 		NFSPROC_STATFS(nfs_fh) = 17;
356 	} = 2;
357 } = 100003;
358 
359 /*
360  * Version 3 declarations and definitions.
361  */
362 
363 /*
364  * Sizes
365  */
366 const NFS3_FHSIZE         = 64;
367 const NFS3_COOKIEVERFSIZE = 8;
368 const NFS3_CREATEVERFSIZE = 8;
369 const NFS3_WRITEVERFSIZE  = 8;
370 
371 /*
372  * Basic data types
373  */
374 typedef string		filename3<>;
375 typedef string		nfspath3<>;
376 typedef uint64		fileid3;
377 typedef uint64		cookie3;
378 typedef opaque		cookieverf3[NFS3_COOKIEVERFSIZE];
379 typedef opaque		createverf3[NFS3_CREATEVERFSIZE];
380 typedef opaque		writeverf3[NFS3_WRITEVERFSIZE];
381 typedef uint32		uid3;
382 typedef uint32		gid3;
383 typedef uint64		size3;
384 typedef uint64		offset3;
385 typedef uint32		mode3;
386 typedef uint32		count3;
387 
388 /*
389  * Error status
390  */
391 enum nfsstat3 {
392 	NFS3_OK = 0,
393 	NFS3ERR_PERM = 1,
394 	NFS3ERR_NOENT = 2,
395 	NFS3ERR_IO = 5,
396 	NFS3ERR_NXIO = 6,
397 	NFS3ERR_ACCES = 13,
398 	NFS3ERR_EXIST = 17,
399 	NFS3ERR_XDEV = 18,
400 	NFS3ERR_NODEV = 19,
401 	NFS3ERR_NOTDIR = 20,
402 	NFS3ERR_ISDIR = 21,
403 	NFS3ERR_INVAL = 22,
404 	NFS3ERR_FBIG = 27,
405 	NFS3ERR_NOSPC = 28,
406 	NFS3ERR_ROFS = 30,
407 	NFS3ERR_MLINK = 31,
408 	NFS3ERR_NAMETOOLONG = 63,
409 	NFS3ERR_NOTEMPTY = 66,
410 	NFS3ERR_DQUOT = 69,
411 	NFS3ERR_STALE = 70,
412 	NFS3ERR_REMOTE = 71,
413 	NFS3ERR_BADHANDLE = 10001,
414 	NFS3ERR_NOT_SYNC = 10002,
415 	NFS3ERR_BAD_COOKIE = 10003,
416 	NFS3ERR_NOTSUPP = 10004,
417 	NFS3ERR_TOOSMALL = 10005,
418 	NFS3ERR_SERVERFAULT = 10006,
419 	NFS3ERR_BADTYPE = 10007,
420 	NFS3ERR_JUKEBOX = 10008
421 };
422 
423 /*
424  * File types
425  */
426 enum ftype3 {
427 	NF3REG = 1,
428 	NF3DIR = 2,
429 	NF3BLK = 3,
430 	NF3CHR = 4,
431 	NF3LNK = 5,
432 	NF3SOCK = 6,
433 	NF3FIFO = 7
434 };
435 
436 struct specdata3 {
437 	uint32	specdata1;
438 	uint32	specdata2;
439 };
440 
441 /*
442  * File access handle
443  */
444 struct nfs_fh3 {
445 	opaque data<NFS3_FHSIZE>;
446 };
447 
448 /*
449  * Timeval
450  */
451 struct nfstime3 {
452 	uint32 seconds;
453 	uint32 nseconds;
454 };
455 
456 /*
457  * File attributes
458  */
459 struct fattr3 {
460 	ftype3	  type;
461 	mode3	  mode;
462 	uint32	  nlink;
463 	uid3	  uid;
464 	gid3	  gid;
465 	size3	  size;
466 	size3	  used;
467 	specdata3 rdev;
468 	uint64	  fsid;
469 	fileid3	  fileid;
470 	nfstime3  atime;
471 	nfstime3  mtime;
472 	nfstime3  ctime;
473 };
474 
475 /*
476  * File attributes
477  */
478 union post_op_attr switch (bool attributes_follow) {
479 case TRUE:
480 	fattr3 attributes;
481 case FALSE:
482 	void;
483 };
484 
485 struct wcc_attr {
486 	size3	 size;
487 	nfstime3 mtime;
488 	nfstime3 ctime;
489 };
490 
491 union pre_op_attr switch (bool attributes_follow) {
492 case TRUE:
493 	wcc_attr attributes;
494 case FALSE:
495 	void;
496 };
497 
498 struct wcc_data {
499 	pre_op_attr  before;
500 	post_op_attr after;
501 };
502 
503 union post_op_fh3 switch (bool handle_follows) {
504 case TRUE:
505 	nfs_fh3 handle;
506 case FALSE:
507 	void;
508 };
509 
510 enum time_how {
511 	DONT_CHANGE	   = 0,
512 	SET_TO_SERVER_TIME = 1,
513 	SET_TO_CLIENT_TIME = 2
514 };
515 
516 union set_mode3 switch (bool set_it) {
517 case TRUE:
518 	mode3 mode;
519 default:
520 	void;
521 };
522 
523 union set_uid3 switch (bool set_it) {
524 case TRUE:
525 	uid3 uid;
526 default:
527 	void;
528 };
529 
530 union set_gid3 switch (bool set_it) {
531 case TRUE:
532 	gid3 gid;
533 default:
534 	void;
535 };
536 
537 union set_size3 switch (bool set_it) {
538 case TRUE:
539 	size3	size;
540 default:
541 	void;
542 };
543 
544 union set_atime switch (time_how set_it) {
545 case SET_TO_CLIENT_TIME:
546 	nfstime3 atime;
547 default:
548 	void;
549 };
550 
551 union set_mtime switch (time_how set_it) {
552 case SET_TO_CLIENT_TIME:
553 	nfstime3 mtime;
554 default:
555 	void;
556 };
557 
558 struct sattr3 {
559 	set_mode3 mode;
560 	set_uid3  uid;
561 	set_gid3  gid;
562 	set_size3 size;
563 	set_atime atime;
564 	set_mtime mtime;
565 };
566 
567 struct diropargs3 {
568 	nfs_fh3   dir;
569 	filename3 name;
570 };
571 
572 /*
573  * GETATTR: Get file attributes
574  */
575 struct GETATTR3args {
576 	nfs_fh3 object;
577 };
578 
579 struct GETATTR3resok {
580 	fattr3 obj_attributes;
581 };
582 
583 union GETATTR3res switch (nfsstat3 status) {
584 case NFS3_OK:
585 	GETATTR3resok resok;
586 default:
587 	void;
588 };
589 
590 /*
591  * SETATTR: Set file attributes
592  */
593 union sattrguard3 switch (bool check) {
594 case TRUE:
595 	nfstime3 obj_ctime;
596 case FALSE:
597 	void;
598 };
599 
600 struct SETATTR3args {
601 	nfs_fh3     object;
602 	sattr3	    new_attributes;
603 	sattrguard3 guard;
604 };
605 
606 struct SETATTR3resok {
607 	wcc_data obj_wcc;
608 };
609 
610 struct SETATTR3resfail {
611 	wcc_data obj_wcc;
612 };
613 
614 union SETATTR3res switch (nfsstat3 status) {
615 case NFS3_OK:
616 	SETATTR3resok	resok;
617 default:
618 	SETATTR3resfail	resfail;
619 };
620 
621 /*
622  * LOOKUP: Lookup filename
623  */
624 struct LOOKUP3args {
625 	diropargs3 what;
626 };
627 
628 struct LOOKUP3resok {
629 	nfs_fh3		object;
630 	post_op_attr	obj_attributes;
631 	post_op_attr	dir_attributes;
632 };
633 
634 struct LOOKUP3resfail {
635 	post_op_attr	dir_attributes;
636 };
637 
638 union LOOKUP3res switch (nfsstat3 status) {
639 case NFS3_OK:
640 	LOOKUP3resok	resok;
641 default:
642 	LOOKUP3resfail	resfail;
643 };
644 
645 /*
646  * ACCESS: Check access permission
647  */
648 const ACCESS3_READ	= 0x0001;
649 const ACCESS3_LOOKUP	= 0x0002;
650 const ACCESS3_MODIFY	= 0x0004;
651 const ACCESS3_EXTEND	= 0x0008;
652 const ACCESS3_DELETE	= 0x0010;
653 const ACCESS3_EXECUTE	= 0x0020;
654 
655 struct ACCESS3args {
656 	nfs_fh3	object;
657 	uint32	access;
658 };
659 
660 struct ACCESS3resok {
661 	post_op_attr	obj_attributes;
662 	uint32		access;
663 };
664 
665 struct ACCESS3resfail {
666 	post_op_attr	obj_attributes;
667 };
668 
669 union ACCESS3res switch (nfsstat3 status) {
670 case NFS3_OK:
671 	ACCESS3resok	resok;
672 default:
673 	ACCESS3resfail	resfail;
674 };
675 
676 /*
677  * READLINK: Read from symbolic link
678  */
679 struct READLINK3args {
680 	nfs_fh3	symlink;
681 };
682 
683 struct READLINK3resok {
684 	post_op_attr	symlink_attributes;
685 	nfspath3	data;
686 };
687 
688 struct READLINK3resfail {
689 	post_op_attr	symlink_attributes;
690 };
691 
692 union READLINK3res switch (nfsstat3 status) {
693 case NFS3_OK:
694 	READLINK3resok	 resok;
695 default:
696 	READLINK3resfail resfail;
697 };
698 
699 /*
700  * READ: Read from file
701  */
702 struct READ3args {
703 	nfs_fh3		file;
704 	offset3		offset;
705 	count3		count;
706 };
707 
708 struct READ3resok {
709 	post_op_attr	file_attributes;
710 	count3		count;
711 	bool		eof;
712 	opaque		data<>;
713 };
714 
715 struct READ3resfail {
716 	post_op_attr	file_attributes;
717 };
718 
719 union READ3res switch (nfsstat3 status) {
720 case NFS3_OK:
721 	READ3resok	resok;
722 default:
723 	READ3resfail	resfail;
724 };
725 
726 /*
727  * WRITE: Write to file
728  */
729 enum stable_how {
730 	UNSTABLE  = 0,
731 	DATA_SYNC = 1,
732 	FILE_SYNC = 2
733 };
734 
735 struct WRITE3args {
736 	nfs_fh3		file;
737 	offset3		offset;
738 	count3		count;
739 	stable_how	stable;
740 	opaque		data<>;
741 };
742 
743 struct WRITE3resok {
744 	wcc_data	file_wcc;
745 	count3		count;
746 	stable_how	committed;
747 	writeverf3	verf;
748 };
749 
750 struct WRITE3resfail {
751 	wcc_data	file_wcc;
752 };
753 
754 union WRITE3res switch (nfsstat3 status) {
755 case NFS3_OK:
756 	WRITE3resok	resok;
757 default:
758 	WRITE3resfail	resfail;
759 };
760 
761 /*
762  * CREATE: Create a file
763  */
764 enum createmode3 {
765 	UNCHECKED = 0,
766 	GUARDED	  = 1,
767 	EXCLUSIVE = 2
768 };
769 
770 union createhow3 switch (createmode3 mode) {
771 case UNCHECKED:
772 case GUARDED:
773 	sattr3		obj_attributes;
774 case EXCLUSIVE:
775 	createverf3	verf;
776 };
777 
778 struct CREATE3args {
779 	diropargs3	where;
780 	createhow3	how;
781 };
782 
783 struct CREATE3resok {
784 	post_op_fh3	obj;
785 	post_op_attr	obj_attributes;
786 	wcc_data	dir_wcc;
787 };
788 
789 struct CREATE3resfail {
790 	wcc_data	dir_wcc;
791 };
792 
793 union CREATE3res switch (nfsstat3 status) {
794 case NFS3_OK:
795 	CREATE3resok	resok;
796 default:
797 	CREATE3resfail	resfail;
798 };
799 
800 /*
801  * MKDIR: Create a directory
802  */
803 struct MKDIR3args {
804 	diropargs3	where;
805 	sattr3		attributes;
806 };
807 
808 struct MKDIR3resok {
809 	post_op_fh3	obj;
810 	post_op_attr	obj_attributes;
811 	wcc_data	dir_wcc;
812 };
813 
814 struct MKDIR3resfail {
815 	wcc_data	dir_wcc;
816 };
817 
818 union MKDIR3res switch (nfsstat3 status) {
819 case NFS3_OK:
820 	MKDIR3resok	resok;
821 default:
822 	MKDIR3resfail	resfail;
823 };
824 
825 /*
826  * SYMLINK: Create a symbolic link
827  */
828 struct symlinkdata3 {
829 	sattr3		symlink_attributes;
830 	nfspath3	symlink_data;
831 };
832 
833 struct SYMLINK3args {
834 	diropargs3	where;
835 	symlinkdata3	symlink;
836 };
837 
838 struct SYMLINK3resok {
839 	post_op_fh3	obj;
840 	post_op_attr	obj_attributes;
841 	wcc_data	dir_wcc;
842 };
843 
844 struct SYMLINK3resfail {
845 	wcc_data	dir_wcc;
846 };
847 
848 union SYMLINK3res switch (nfsstat3 status) {
849 case NFS3_OK:
850 	SYMLINK3resok	resok;
851 default:
852 	SYMLINK3resfail	resfail;
853 };
854 
855 /*
856  * MKNOD: Create a special file
857  */
858 struct devicedata3 {
859 	sattr3		dev_attributes;
860 	specdata3	spec;
861 };
862 
863 union mknoddata3 switch (ftype3 type) {
864 case NF3CHR:
865 case NF3BLK:
866 	devicedata3	device;
867 case NF3SOCK:
868 case NF3FIFO:
869 	sattr3		pipe_attributes;
870 default:
871 	void;
872 };
873 
874 struct MKNOD3args {
875 	diropargs3	where;
876 	mknoddata3	what;
877 };
878 
879 struct MKNOD3resok {
880 	post_op_fh3	obj;
881 	post_op_attr	obj_attributes;
882 	wcc_data	dir_wcc;
883 };
884 
885 struct MKNOD3resfail {
886 	wcc_data	dir_wcc;
887 };
888 
889 union MKNOD3res switch (nfsstat3 status) {
890 case NFS3_OK:
891 	MKNOD3resok	resok;
892 default:
893 	MKNOD3resfail	resfail;
894 };
895 
896 /*
897  * REMOVE: Remove a file
898  */
899 struct REMOVE3args {
900 	diropargs3	object;
901 };
902 
903 struct REMOVE3resok {
904 	wcc_data	dir_wcc;
905 };
906 
907 struct REMOVE3resfail {
908 	wcc_data	dir_wcc;
909 };
910 
911 union REMOVE3res switch (nfsstat3 status) {
912 case NFS3_OK:
913 	REMOVE3resok	resok;
914 default:
915 	REMOVE3resfail	resfail;
916 };
917 
918 /*
919  * RMDIR: Remove a directory
920  */
921 struct RMDIR3args {
922 	diropargs3 object;
923 };
924 
925 struct RMDIR3resok {
926 	wcc_data	dir_wcc;
927 };
928 
929 struct RMDIR3resfail {
930 	wcc_data	dir_wcc;
931 };
932 
933 union RMDIR3res switch (nfsstat3 status) {
934 case NFS3_OK:
935 	RMDIR3resok	resok;
936 default:
937 	RMDIR3resfail	resfail;
938 };
939 
940 /*
941  * RENAME: Rename a file or directory
942  */
943 struct RENAME3args {
944 	diropargs3	from;
945 	diropargs3	to;
946 };
947 
948 struct RENAME3resok {
949 	wcc_data	fromdir_wcc;
950 	wcc_data	todir_wcc;
951 };
952 
953 struct RENAME3resfail {
954 	wcc_data	fromdir_wcc;
955 	wcc_data	todir_wcc;
956 };
957 
958 union RENAME3res switch (nfsstat3 status) {
959 case NFS3_OK:
960 	RENAME3resok	resok;
961 default:
962 	RENAME3resfail	resfail;
963 };
964 
965 /*
966  * LINK: Create link to an object
967  */
968 struct LINK3args {
969 	nfs_fh3		file;
970 	diropargs3	link;
971 };
972 
973 struct LINK3resok {
974 	post_op_attr	file_attributes;
975 	wcc_data	linkdir_wcc;
976 };
977 
978 struct LINK3resfail {
979 	post_op_attr	file_attributes;
980 	wcc_data	linkdir_wcc;
981 };
982 
983 union LINK3res switch (nfsstat3 status) {
984 case NFS3_OK:
985 	LINK3resok	resok;
986 default:
987 	LINK3resfail	resfail;
988 };
989 
990 /*
991  * READDIR: Read from directory
992  */
993 struct READDIR3args {
994 	nfs_fh3		dir;
995 	cookie3		cookie;
996 	cookieverf3	cookieverf;
997 	count3		count;
998 };
999 
1000 struct entry3 {
1001 	fileid3		fileid;
1002 	filename3	name;
1003 	cookie3		cookie;
1004 	entry3		*nextentry;
1005 };
1006 
1007 struct dirlist3 {
1008 	entry3	*entries;
1009 	bool	eof;
1010 };
1011 
1012 struct READDIR3resok {
1013 	post_op_attr	dir_attributes;
1014 	cookieverf3	cookieverf;
1015 	dirlist3	reply;
1016 };
1017 
1018 struct READDIR3resfail {
1019 	post_op_attr	dir_attributes;
1020 };
1021 
1022 union READDIR3res switch (nfsstat3 status) {
1023 case NFS3_OK:
1024 	READDIR3resok	resok;
1025 default:
1026 	READDIR3resfail	resfail;
1027 };
1028 
1029 /*
1030  * READDIRPLUS: Extended read from a directory
1031  */
1032 struct READDIRPLUS3args {
1033 	nfs_fh3		dir;
1034 	cookie3		cookie;
1035 	cookieverf3	cookieverf;
1036 	count3		dircount;
1037 	count3		maxcount;
1038 };
1039 
1040 struct entryplus3 {
1041 	fileid3		fileid;
1042 	filename3	name;
1043 	cookie3		cookie;
1044 	post_op_attr	name_attributes;
1045 	post_op_fh3	name_handle;
1046 	entryplus3	*nextentry;
1047 };
1048 
1049 struct dirlistplus3 {
1050 	entryplus3	*entries;
1051 	bool		eof;
1052 };
1053 
1054 struct READDIRPLUS3resok {
1055 	post_op_attr	dir_attributes;
1056 	cookieverf3	cookieverf;
1057 	dirlistplus3	reply;
1058 };
1059 
1060 struct READDIRPLUS3resfail {
1061 	post_op_attr	dir_attributes;
1062 };
1063 
1064 union READDIRPLUS3res switch (nfsstat3 status) {
1065 case NFS3_OK:
1066 	READDIRPLUS3resok	resok;
1067 default:
1068 	READDIRPLUS3resfail	resfail;
1069 };
1070 
1071 /*
1072  * FSSTAT: Get dynamic file system information
1073  */
1074 struct FSSTAT3args {
1075 	nfs_fh3	fsroot;
1076 };
1077 
1078 struct FSSTAT3resok {
1079 	post_op_attr	obj_attributes;
1080 	size3		tbytes;
1081 	size3		fbytes;
1082 	size3		abytes;
1083 	size3		tfiles;
1084 	size3		ffiles;
1085 	size3		afiles;
1086 	uint32		invarsec;
1087 };
1088 
1089 struct FSSTAT3resfail {
1090 	post_op_attr	obj_attributes;
1091 };
1092 
1093 union FSSTAT3res switch (nfsstat3 status) {
1094 case NFS3_OK:
1095 	FSSTAT3resok	resok;
1096 default:
1097 	FSSTAT3resfail	resfail;
1098 };
1099 
1100 /*
1101  * FSINFO: Get static file system information
1102  */
1103 
1104 const FSF3_LINK		= 0x0001;
1105 const FSF3_SYMLINK	= 0x0002;
1106 const FSF3_HOMOGENEOUS	= 0x0008;
1107 const FSF3_CANSETTIME	= 0x0010;
1108 
1109 struct FSINFO3args {
1110 	nfs_fh3	fsroot;
1111 };
1112 
1113 struct FSINFO3resok {
1114 	post_op_attr	obj_attributes;
1115 	uint32		rtmax;
1116 	uint32		rtpref;
1117 	uint32		rtmult;
1118 	uint32		wtmax;
1119 	uint32		wtpref;
1120 	uint32		wtmult;
1121 	uint32		dtpref;
1122 	size3		maxfilesize;
1123 	nfstime3	time_delta;
1124 	uint32		properties;
1125 };
1126 
1127 struct FSINFO3resfail {
1128 	post_op_attr	obj_attributes;
1129 };
1130 
1131 union FSINFO3res switch (nfsstat3 status) {
1132 case NFS3_OK:
1133 	FSINFO3resok	resok;
1134 default:
1135 	FSINFO3resfail	resfail;
1136 };
1137 
1138 /*
1139  * PATHCONF: Retrieve POSIX information
1140  */
1141 struct PATHCONF3args {
1142 	nfs_fh3	object;
1143 };
1144 
1145 struct PATHCONF3resok {
1146 	post_op_attr	obj_attributes;
1147 	uint32		linkmax;
1148 	uint32		name_max;
1149 	bool		no_trunc;
1150 	bool		chown_restricted;
1151 	bool		case_insensitive;
1152 	bool		case_preserving;
1153 };
1154 
1155 struct PATHCONF3resfail {
1156 	post_op_attr	obj_attributes;
1157 };
1158 
1159 union PATHCONF3res switch (nfsstat3 status) {
1160 case NFS3_OK:
1161 	PATHCONF3resok	 resok;
1162 default:
1163 	PATHCONF3resfail resfail;
1164 };
1165 
1166 /*
1167  * COMMIT: Commit cached data on a server to stable storage
1168  */
1169 struct COMMIT3args {
1170 	nfs_fh3	file;
1171 	offset3	offset;
1172 	count3	count;
1173 };
1174 
1175 struct COMMIT3resok {
1176 	wcc_data	file_wcc;
1177 	writeverf3	verf;
1178 };
1179 
1180 struct COMMIT3resfail {
1181 	wcc_data	file_wcc;
1182 };
1183 
1184 union COMMIT3res switch (nfsstat3 status) {
1185 case NFS3_OK:
1186 	COMMIT3resok	resok;
1187 default:
1188 	COMMIT3resfail	resfail;
1189 };
1190 
1191 /*
1192  * Remote file service routines
1193  */
1194 program NFS3_PROGRAM {
1195 	version NFS_V3 {
1196 		void
1197 		NFSPROC3_NULL(void) = 0;
1198 
1199 		GETATTR3res
1200 		NFSPROC3_GETATTR(GETATTR3args) = 1;
1201 
1202 		SETATTR3res
1203 		NFSPROC3_SETATTR(SETATTR3args) = 2;
1204 
1205 		LOOKUP3res
1206 		NFSPROC3_LOOKUP(LOOKUP3args) = 3;
1207 
1208 		ACCESS3res
1209 		NFSPROC3_ACCESS(ACCESS3args) = 4;
1210 
1211 		READLINK3res
1212 		NFSPROC3_READLINK(READLINK3args) = 5;
1213 
1214 		READ3res
1215 		NFSPROC3_READ(READ3args) = 6;
1216 
1217 		WRITE3res
1218 		NFSPROC3_WRITE(WRITE3args) = 7;
1219 
1220 		CREATE3res
1221 		NFSPROC3_CREATE(CREATE3args) = 8;
1222 
1223 		MKDIR3res
1224 		NFSPROC3_MKDIR(MKDIR3args) = 9;
1225 
1226 		SYMLINK3res
1227 		NFSPROC3_SYMLINK(SYMLINK3args) = 10;
1228 
1229 		MKNOD3res
1230 		NFSPROC3_MKNOD(MKNOD3args) = 11;
1231 
1232 		REMOVE3res
1233 		NFSPROC3_REMOVE(REMOVE3args) = 12;
1234 
1235 		RMDIR3res
1236 		NFSPROC3_RMDIR(RMDIR3args) = 13;
1237 
1238 		RENAME3res
1239 		NFSPROC3_RENAME(RENAME3args) = 14;
1240 
1241 		LINK3res
1242 		NFSPROC3_LINK(LINK3args) = 15;
1243 
1244 		READDIR3res
1245 		NFSPROC3_READDIR(READDIR3args) = 16;
1246 
1247 		READDIRPLUS3res
1248 		NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;
1249 
1250 		FSSTAT3res
1251 		NFSPROC3_FSSTAT(FSSTAT3args) = 18;
1252 
1253 		FSINFO3res
1254 		NFSPROC3_FSINFO(FSINFO3args) = 19;
1255 
1256 		PATHCONF3res
1257 		NFSPROC3_PATHCONF(PATHCONF3args) = 20;
1258 
1259 		COMMIT3res
1260 		NFSPROC3_COMMIT(COMMIT3args) = 21;
1261 	} = 3;
1262 } = 100003;
1263