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