nfs.x: some rpcgen's can not handle multiple union choices for the same arm.
[deb_libnfs.git] / nfs / nfs.x
1 /* NFS part from rfc 1813, NFSACL part is from wireshark sources */
2
3 const NFS3_FHSIZE = 64; /* Maximum bytes in a V3 file handle */
4 const NFS3_WRITEVERFSIZE = 8;
5 const NFS3_CREATEVERFSIZE = 8;
6 const NFS3_COOKIEVERFSIZE = 8;
7
8 typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
9
10
11 /*unsigned hyper can be overridden by giving rpcgen -DU_INT64_PLATTFORM_TYPE="foo" - for plattforms
12 where rpcgen doesn't know anything about hyper
13 default to unsigned hyper as of rfc 1813 */
14 #ifndef U_INT64_PLATTFORM_TYPE
15 #define U_INT64_PLATTFORM_TYPE unsigned hyper
16 #endif/*U_INT64_PLATTFORM_TYPE*/
17
18 typedef U_INT64_PLATTFORM_TYPE uint64;
19 typedef uint64 cookie3;
20
21 struct nfs_fh3 {
22 opaque data<NFS3_FHSIZE>;
23 };
24
25 typedef string filename3<>;
26
27 struct diropargs3 {
28 nfs_fh3 dir;
29 filename3 name;
30 };
31
32 enum ftype3 {
33 NF3REG = 1,
34 NF3DIR = 2,
35 NF3BLK = 3,
36 NF3CHR = 4,
37 NF3LNK = 5,
38 NF3SOCK = 6,
39 NF3FIFO = 7
40 };
41
42 typedef unsigned long uint32;
43
44 typedef long int32;
45
46 typedef uint32 mode3;
47
48 typedef uint32 uid3;
49
50 typedef uint32 gid3;
51
52 typedef uint64 size3;
53
54 typedef uint64 fileid3;
55
56 struct specdata3 {
57 uint32 specdata1;
58 uint32 specdata2;
59 };
60
61 struct nfstime3 {
62 uint32 seconds;
63 uint32 nseconds;
64 };
65
66 struct fattr3 {
67 ftype3 type;
68 mode3 mode;
69 uint32 nlink;
70 uid3 uid;
71 gid3 gid;
72 size3 size;
73 size3 used;
74 specdata3 rdev;
75 uint64 fsid;
76 fileid3 fileid;
77 nfstime3 atime;
78 nfstime3 mtime;
79 nfstime3 ctime;
80 };
81
82 union post_op_attr switch (bool attributes_follow) {
83 case TRUE:
84 fattr3 attributes;
85 case FALSE:
86 void;
87 };
88
89
90 enum nfsstat3 {
91 NFS3_OK = 0,
92 NFS3ERR_PERM = 1,
93 NFS3ERR_NOENT = 2,
94 NFS3ERR_IO = 5,
95 NFS3ERR_NXIO = 6,
96 NFS3ERR_ACCES = 13,
97 NFS3ERR_EXIST = 17,
98 NFS3ERR_XDEV = 18,
99 NFS3ERR_NODEV = 19,
100 NFS3ERR_NOTDIR = 20,
101 NFS3ERR_ISDIR = 21,
102 NFS3ERR_INVAL = 22,
103 NFS3ERR_FBIG = 27,
104 NFS3ERR_NOSPC = 28,
105 NFS3ERR_ROFS = 30,
106 NFS3ERR_MLINK = 31,
107 NFS3ERR_NAMETOOLONG = 63,
108 NFS3ERR_NOTEMPTY = 66,
109 NFS3ERR_DQUOT = 69,
110 NFS3ERR_STALE = 70,
111 NFS3ERR_REMOTE = 71,
112 NFS3ERR_BADHANDLE = 10001,
113 NFS3ERR_NOT_SYNC = 10002,
114 NFS3ERR_BAD_COOKIE = 10003,
115 NFS3ERR_NOTSUPP = 10004,
116 NFS3ERR_TOOSMALL = 10005,
117 NFS3ERR_SERVERFAULT = 10006,
118 NFS3ERR_BADTYPE = 10007,
119 NFS3ERR_JUKEBOX = 10008
120 };
121
122 enum stable_how {
123 UNSTABLE = 0,
124 DATA_SYNC = 1,
125 FILE_SYNC = 2
126 };
127
128 typedef uint64 offset3;
129
130 typedef uint32 count3;
131
132 struct wcc_attr {
133 size3 size;
134 nfstime3 mtime;
135 nfstime3 ctime;
136 };
137
138 union pre_op_attr switch (bool attributes_follow) {
139 case TRUE:
140 wcc_attr attributes;
141 case FALSE:
142 void;
143 };
144
145 struct wcc_data {
146 pre_op_attr before;
147 post_op_attr after;
148 };
149
150 struct WRITE3args {
151 nfs_fh3 file;
152 offset3 offset;
153 count3 count;
154 stable_how stable;
155 opaque data<>;
156 };
157
158 typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
159
160 struct WRITE3resok {
161 wcc_data file_wcc;
162 count3 count;
163 stable_how committed;
164 writeverf3 verf;
165 };
166
167 struct WRITE3resfail {
168 wcc_data file_wcc;
169 };
170
171 union WRITE3res switch (nfsstat3 status) {
172 case NFS3_OK:
173 WRITE3resok resok;
174 default:
175 WRITE3resfail resfail;
176 };
177
178 struct LOOKUP3args {
179 diropargs3 what;
180 };
181
182 struct LOOKUP3resok {
183 nfs_fh3 object;
184 post_op_attr obj_attributes;
185 post_op_attr dir_attributes;
186 };
187
188 struct LOOKUP3resfail {
189 post_op_attr dir_attributes;
190 };
191
192
193
194 union LOOKUP3res switch (nfsstat3 status) {
195 case NFS3_OK:
196 LOOKUP3resok resok;
197 default:
198 LOOKUP3resfail resfail;
199 };
200
201 struct COMMIT3args {
202 nfs_fh3 file;
203 offset3 offset;
204 count3 count;
205 };
206
207 struct COMMIT3resok {
208 wcc_data file_wcc;
209 writeverf3 verf;
210 };
211
212 struct COMMIT3resfail {
213 wcc_data file_wcc;
214 };
215
216 union COMMIT3res switch (nfsstat3 status) {
217 case NFS3_OK:
218 COMMIT3resok resok;
219 default:
220 COMMIT3resfail resfail;
221 };
222
223 const ACCESS3_READ = 0x0001;
224 const ACCESS3_LOOKUP = 0x0002;
225 const ACCESS3_MODIFY = 0x0004;
226 const ACCESS3_EXTEND = 0x0008;
227 const ACCESS3_DELETE = 0x0010;
228 const ACCESS3_EXECUTE = 0x0020;
229
230 struct ACCESS3args {
231 nfs_fh3 object;
232 uint32 access;
233 };
234
235 struct ACCESS3resok {
236 post_op_attr obj_attributes;
237 uint32 access;
238 };
239
240 struct ACCESS3resfail {
241 post_op_attr obj_attributes;
242 };
243
244 union ACCESS3res switch (nfsstat3 status) {
245 case NFS3_OK:
246 ACCESS3resok resok;
247 default:
248 ACCESS3resfail resfail;
249 };
250
251 struct GETATTR3args {
252 nfs_fh3 object;
253 };
254
255 struct GETATTR3resok {
256 fattr3 obj_attributes;
257 };
258
259 union GETATTR3res switch (nfsstat3 status) {
260 case NFS3_OK:
261 GETATTR3resok resok;
262 default:
263 void;
264 };
265
266
267
268 enum time_how {
269 DONT_CHANGE = 0,
270 SET_TO_SERVER_TIME = 1,
271 SET_TO_CLIENT_TIME = 2
272 };
273
274 union set_mode3 switch (bool set_it) {
275 case TRUE:
276 mode3 mode;
277 default:
278 void;
279 };
280
281 union set_uid3 switch (bool set_it) {
282 case TRUE:
283 uid3 uid;
284 default:
285 void;
286 };
287
288 union set_gid3 switch (bool set_it) {
289 case TRUE:
290 gid3 gid;
291 default:
292 void;
293 };
294
295 union set_size3 switch (bool set_it) {
296 case TRUE:
297 size3 size;
298 default:
299 void;
300 };
301
302 union set_atime switch (time_how set_it) {
303 case SET_TO_CLIENT_TIME:
304 nfstime3 atime;
305 default:
306 void;
307 };
308
309 union set_mtime switch (time_how set_it) {
310 case SET_TO_CLIENT_TIME:
311 nfstime3 mtime;
312 default:
313 void;
314 };
315
316 struct sattr3 {
317 set_mode3 mode;
318 set_uid3 uid;
319 set_gid3 gid;
320 set_size3 size;
321 set_atime atime;
322 set_mtime mtime;
323 };
324
325 enum createmode3 {
326 UNCHECKED = 0,
327 GUARDED = 1,
328 EXCLUSIVE = 2
329 };
330
331
332 typedef opaque createverf3[NFS3_CREATEVERFSIZE];
333
334 union createhow3 switch (createmode3 mode) {
335 case UNCHECKED:
336 sattr3 obj_attributes;
337 case GUARDED:
338 sattr3 g_obj_attributes;
339 case EXCLUSIVE:
340 createverf3 verf;
341 };
342
343 struct CREATE3args {
344 diropargs3 where;
345 createhow3 how;
346 };
347
348 union post_op_fh3 switch (bool handle_follows) {
349 case TRUE:
350 nfs_fh3 handle;
351 case FALSE:
352 void;
353 };
354
355 struct CREATE3resok {
356 post_op_fh3 obj;
357 post_op_attr obj_attributes;
358 wcc_data dir_wcc;
359 };
360
361 struct CREATE3resfail {
362 wcc_data dir_wcc;
363 };
364
365 union CREATE3res switch (nfsstat3 status) {
366 case NFS3_OK:
367 CREATE3resok resok;
368 default:
369 CREATE3resfail resfail;
370 };
371
372 struct REMOVE3args {
373 diropargs3 object;
374 };
375
376 struct REMOVE3resok {
377 wcc_data dir_wcc;
378 };
379
380 struct REMOVE3resfail {
381 wcc_data dir_wcc;
382 };
383
384 union REMOVE3res switch (nfsstat3 status) {
385 case NFS3_OK:
386 REMOVE3resok resok;
387 default:
388 REMOVE3resfail resfail;
389 };
390
391 struct READ3args {
392 nfs_fh3 file;
393 offset3 offset;
394 count3 count;
395 };
396
397 struct READ3resok {
398 post_op_attr file_attributes;
399 count3 count;
400 bool eof;
401 opaque data<>;
402 };
403
404 struct READ3resfail {
405 post_op_attr file_attributes;
406 };
407
408 union READ3res switch (nfsstat3 status) {
409 case NFS3_OK:
410 READ3resok resok;
411 default:
412 READ3resfail resfail;
413 };
414
415
416 const FSF3_LINK = 0x0001;
417 const FSF3_SYMLINK = 0x0002;
418 const FSF3_HOMOGENEOUS = 0x0008;
419 const FSF3_CANSETTIME = 0x0010;
420
421 struct FSINFO3args {
422 nfs_fh3 fsroot;
423 };
424
425 struct FSINFO3resok {
426 post_op_attr obj_attributes;
427 uint32 rtmax;
428 uint32 rtpref;
429 uint32 rtmult;
430 uint32 wtmax;
431 uint32 wtpref;
432 uint32 wtmult;
433 uint32 dtpref;
434 size3 maxfilesize;
435 nfstime3 time_delta;
436 uint32 properties;
437 };
438
439 struct FSINFO3resfail {
440 post_op_attr obj_attributes;
441 };
442
443 union FSINFO3res switch (nfsstat3 status) {
444 case NFS3_OK:
445 FSINFO3resok resok;
446 default:
447 FSINFO3resfail resfail;
448 };
449
450
451 struct FSSTAT3args {
452 nfs_fh3 fsroot;
453 };
454
455 struct FSSTAT3resok {
456 post_op_attr obj_attributes;
457 size3 tbytes;
458 size3 fbytes;
459 size3 abytes;
460 size3 tfiles;
461 size3 ffiles;
462 size3 afiles;
463 uint32 invarsec;
464 };
465
466 struct FSSTAT3resfail {
467 post_op_attr obj_attributes;
468 };
469
470 union FSSTAT3res switch (nfsstat3 status) {
471 case NFS3_OK:
472 FSSTAT3resok resok;
473 default:
474 FSSTAT3resfail resfail;
475 };
476
477 struct PATHCONF3args {
478 nfs_fh3 object;
479 };
480
481 struct PATHCONF3resok {
482 post_op_attr obj_attributes;
483 uint32 linkmax;
484 uint32 name_max;
485 bool no_trunc;
486 bool chown_restricted;
487 bool case_insensitive;
488 bool case_preserving;
489 };
490
491 struct PATHCONF3resfail {
492 post_op_attr obj_attributes;
493 };
494
495 union PATHCONF3res switch (nfsstat3 status) {
496 case NFS3_OK:
497 PATHCONF3resok resok;
498 default:
499 PATHCONF3resfail resfail;
500 };
501
502 typedef string nfspath3<>;
503
504 struct symlinkdata3 {
505 sattr3 symlink_attributes;
506 nfspath3 symlink_data;
507 };
508
509 struct SYMLINK3args {
510 diropargs3 where;
511 symlinkdata3 symlink;
512 };
513
514 struct SYMLINK3resok {
515 post_op_fh3 obj;
516 post_op_attr obj_attributes;
517 wcc_data dir_wcc;
518 };
519
520 struct SYMLINK3resfail {
521 wcc_data dir_wcc;
522 };
523
524 union SYMLINK3res switch (nfsstat3 status) {
525 case NFS3_OK:
526 SYMLINK3resok resok;
527 default:
528 SYMLINK3resfail resfail;
529 };
530
531
532 struct READLINK3args {
533 nfs_fh3 symlink;
534 };
535
536 struct READLINK3resok {
537 post_op_attr symlink_attributes;
538 nfspath3 data;
539 };
540
541 struct READLINK3resfail {
542 post_op_attr symlink_attributes;
543 };
544
545 union READLINK3res switch (nfsstat3 status) {
546 case NFS3_OK:
547 READLINK3resok resok;
548 default:
549 READLINK3resfail resfail;
550 };
551
552
553 struct devicedata3 {
554 sattr3 dev_attributes;
555 specdata3 spec;
556 };
557
558 union mknoddata3 switch (ftype3 type) {
559 case NF3CHR:
560 devicedata3 chr_device;
561 case NF3BLK:
562 devicedata3 blk_device;
563 case NF3SOCK:
564 sattr3 sock_attributes;
565 case NF3FIFO:
566 sattr3 pipe_attributes;
567 default:
568 void;
569 };
570
571 struct MKNOD3args {
572 diropargs3 where;
573 mknoddata3 what;
574 };
575
576 struct MKNOD3resok {
577 post_op_fh3 obj;
578 post_op_attr obj_attributes;
579 wcc_data dir_wcc;
580 };
581
582 struct MKNOD3resfail {
583 wcc_data dir_wcc;
584 };
585
586 union MKNOD3res switch (nfsstat3 status) {
587 case NFS3_OK:
588 MKNOD3resok resok;
589 default:
590 MKNOD3resfail resfail;
591 };
592
593
594 struct MKDIR3args {
595 diropargs3 where;
596 sattr3 attributes;
597 };
598
599 struct MKDIR3resok {
600 post_op_fh3 obj;
601 post_op_attr obj_attributes;
602 wcc_data dir_wcc;
603 };
604
605 struct MKDIR3resfail {
606 wcc_data dir_wcc;
607 };
608
609 union MKDIR3res switch (nfsstat3 status) {
610 case NFS3_OK:
611 MKDIR3resok resok;
612 default:
613 MKDIR3resfail resfail;
614 };
615
616 struct RMDIR3args {
617 diropargs3 object;
618 };
619
620 struct RMDIR3resok {
621 wcc_data dir_wcc;
622 };
623
624 struct RMDIR3resfail {
625 wcc_data dir_wcc;
626 };
627
628 union RMDIR3res switch (nfsstat3 status) {
629 case NFS3_OK:
630 RMDIR3resok resok;
631 default:
632 RMDIR3resfail resfail;
633 };
634
635 struct RENAME3args {
636 diropargs3 from;
637 diropargs3 to;
638 };
639
640 struct RENAME3resok {
641 wcc_data fromdir_wcc;
642 wcc_data todir_wcc;
643 };
644
645 struct RENAME3resfail {
646 wcc_data fromdir_wcc;
647 wcc_data todir_wcc;
648 };
649
650 union RENAME3res switch (nfsstat3 status) {
651 case NFS3_OK:
652 RENAME3resok resok;
653 default:
654 RENAME3resfail resfail;
655 };
656
657 struct READDIRPLUS3args {
658 nfs_fh3 dir;
659 cookie3 cookie;
660 cookieverf3 cookieverf;
661 count3 dircount;
662 count3 maxcount;
663 };
664
665 struct entryplus3 {
666 fileid3 fileid;
667 filename3 name;
668 cookie3 cookie;
669 post_op_attr name_attributes;
670 post_op_fh3 name_handle;
671 entryplus3 *nextentry;
672 };
673
674 struct dirlistplus3 {
675 entryplus3 *entries;
676 bool eof;
677 };
678
679 struct READDIRPLUS3resok {
680 post_op_attr dir_attributes;
681 cookieverf3 cookieverf;
682 dirlistplus3 reply;
683 };
684
685
686 struct READDIRPLUS3resfail {
687 post_op_attr dir_attributes;
688 };
689
690 union READDIRPLUS3res switch (nfsstat3 status) {
691 case NFS3_OK:
692 READDIRPLUS3resok resok;
693 default:
694 READDIRPLUS3resfail resfail;
695 };
696
697 struct READDIR3args {
698 nfs_fh3 dir;
699 cookie3 cookie;
700 cookieverf3 cookieverf;
701 count3 count;
702 };
703
704
705 struct entry3 {
706 fileid3 fileid;
707 filename3 name;
708 cookie3 cookie;
709 entry3 *nextentry;
710 };
711
712 struct dirlist3 {
713 entry3 *entries;
714 bool eof;
715 };
716
717 struct READDIR3resok {
718 post_op_attr dir_attributes;
719 cookieverf3 cookieverf;
720 dirlist3 reply;
721 };
722
723 struct READDIR3resfail {
724 post_op_attr dir_attributes;
725 };
726
727 union READDIR3res switch (nfsstat3 status) {
728 case NFS3_OK:
729 READDIR3resok resok;
730 default:
731 READDIR3resfail resfail;
732 };
733
734 struct LINK3args {
735 nfs_fh3 file;
736 diropargs3 link;
737 };
738
739 struct LINK3resok {
740 post_op_attr file_attributes;
741 wcc_data linkdir_wcc;
742 };
743
744 struct LINK3resfail {
745 post_op_attr file_attributes;
746 wcc_data linkdir_wcc;
747 };
748
749 union LINK3res switch (nfsstat3 status) {
750 case NFS3_OK:
751 LINK3resok resok;
752 default:
753 LINK3resfail resfail;
754 };
755
756 union sattrguard3 switch (bool check) {
757 case TRUE:
758 nfstime3 obj_ctime;
759 case FALSE:
760 void;
761 };
762
763 struct SETATTR3args {
764 nfs_fh3 object;
765 sattr3 new_attributes;
766 sattrguard3 guard;
767 };
768
769 struct SETATTR3resok {
770 wcc_data obj_wcc;
771 };
772
773 struct SETATTR3resfail {
774 wcc_data obj_wcc;
775 };
776
777 union SETATTR3res switch (nfsstat3 status) {
778 case NFS3_OK:
779 SETATTR3resok resok;
780 default:
781 SETATTR3resfail resfail;
782 };
783
784 program NFS_PROGRAM {
785 version NFS_V3 {
786 void
787 NFS3_NULL(void) = 0;
788
789 GETATTR3res
790 NFS3_GETATTR(GETATTR3args) = 1;
791
792 SETATTR3res
793 NFS3_SETATTR(SETATTR3args) = 2;
794
795 LOOKUP3res
796 NFS3_LOOKUP(LOOKUP3args) = 3;
797
798 ACCESS3res
799 NFS3_ACCESS(ACCESS3args) = 4;
800
801 READLINK3res
802 NFS3_READLINK(READLINK3args) = 5;
803
804 READ3res
805 NFS3_READ(READ3args) = 6;
806
807 WRITE3res
808 NFS3_WRITE(WRITE3args) = 7;
809
810 CREATE3res
811 NFS3_CREATE(CREATE3args) = 8;
812
813 MKDIR3res
814 NFS3_MKDIR(MKDIR3args) = 9;
815
816 SYMLINK3res
817 NFS3_SYMLINK(SYMLINK3args) = 10;
818
819 /* MKNOD3res NFSPROC3_MKNOD(MKNOD3args) = 11;*/
820
821 REMOVE3res
822 NFS3_REMOVE(REMOVE3args) = 12;
823
824 RMDIR3res
825 NFS3_RMDIR(RMDIR3args) = 13;
826
827 RENAME3res
828 NFS3_RENAME(RENAME3args) = 14;
829
830 LINK3res
831 NFS3_LINK(LINK3args) = 15;
832
833 READDIR3res
834 NFS3_READDIR(READDIR3args) = 16;
835
836 READDIRPLUS3res
837 NFS3_READDIRPLUS(READDIRPLUS3args) = 17;
838
839 FSSTAT3res
840 NFS3_FSSTAT(FSSTAT3args) = 18;
841
842 FSINFO3res
843 NFS3_FSINFO(FSINFO3args) = 19;
844
845 PATHCONF3res
846 NFS3_PATHCONF(PATHCONF3args) = 20;
847
848 COMMIT3res
849 NFS3_COMMIT(COMMIT3args) = 21;
850 } = 3;
851 } = 100003;
852
853
854
855 /* NFS ACL definitions based on wireshark souces and network traces */
856 /* NFSACL interface. Uses same port/process as NFS */
857
858 enum nfsacl_type {
859 NFSACL_TYPE_USER_OBJ = 0x0001,
860 NFSACL_TYPE_USER = 0x0002,
861 NFSACL_TYPE_GROUP_OBJ = 0x0004,
862 NFSACL_TYPE_GROUP = 0x0008,
863 NFSACL_TYPE_CLASS_OBJ = 0x0010,
864 NFSACL_TYPE_CLASS = 0x0020,
865 NFSACL_TYPE_DEFAULT = 0x1000,
866 NFSACL_TYPE_DEFAULT_USER_OBJ = 0x1001,
867 NFSACL_TYPE_DEFAULT_USER = 0x1002,
868 NFSACL_TYPE_DEFAULT_GROUP_OBJ = 0x1004,
869 NFSACL_TYPE_DEFAULT_GROUP = 0x1008,
870 NFSACL_TYPE_DEFAULT_CLASS_OBJ = 0x1010,
871 NFSACL_TYPE_DEFAULT_OTHER_OBJ = 0x1020
872 };
873
874 const NFSACL_PERM_READ = 0x04;
875 const NFSACL_PERM_WRITE = 0x02;
876 const NFSACL_PERM_EXEC = 0x01;
877
878 struct nfsacl_ace {
879 enum nfsacl_type type;
880 uint32_t id;
881 uint32_t perm;
882 };
883
884 const NFSACL_MASK_ACL_ENTRY = 0x0001;
885 const NFSACL_MASK_ACL_COUNT = 0x0002;
886 const NFSACL_MASK_ACL_DEFAULT_ENTRY = 0x0004;
887 const NFSACL_MASK_ACL_DEFAULT_COUNT = 0x0008;
888
889 struct GETACL3args {
890 nfs_fh3 dir;
891 uint32 mask;
892 };
893
894 struct GETACL3resok {
895 post_op_attr attr;
896 uint32_t mask;
897 uint32_t ace_count;
898 struct nfsacl_ace ace<>;
899 uint32_t default_ace_count;
900 struct nfsacl_ace default_ace<>;
901 };
902
903 union GETACL3res switch (nfsstat3 status) {
904 case NFS3_OK:
905 GETACL3resok resok;
906 default:
907 void;
908 };
909
910 program NFSACL_PROGRAM {
911 version NFSACL_V3 {
912 void
913 NFSACL3_NULL(void) = 0;
914
915 GETACL3res
916 NFSACL3_GETACL(GETACL3args) = 1;
917 } = 3;
918 } = 100227;