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