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