Add proper per-file copyright notices/licenses and top-level license.
[bluesky.git] / TBBT / trace_play / sfs_c_nfs.h
1 #ifndef __sfs_c_nfs_h
2 #define __sfs_c_nfs_h
3
4 /*
5  *   Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
6  *      All rights reserved.
7  *              Standard Performance Evaluation Corporation (SPEC)
8  *              6585 Merchant Place, Suite 100
9  *              Warrenton, VA 20187
10  *
11  *      This product contains benchmarks acquired from several sources who
12  *      understand and agree with SPEC's goal of creating fair and objective
13  *      benchmarks to measure computer performance.
14  *
15  *      This copyright notice is placed here only to protect SPEC in the
16  *      event the source is misused in any manner that is contrary to the
17  *      spirit, the goals and the intent of SPEC.
18  *
19  *      The source code is provided to the user or company under the license
20  *      agreement for the SPEC Benchmark Suite for this product.
21  */
22
23 /*****************************************************************
24  *                                                               *
25  *      Copyright 1991,1992  Legato Systems, Inc.                *
26  *      Copyright 1991,1992  Auspex Systems, Inc.                *
27  *      Copyright 1991,1992  Data General Corporation            *
28  *      Copyright 1991,1992  Digital Equipment Corporation       *
29  *      Copyright 1991,1992  Interphase Corporation              *
30  *      Copyright 1991,1992  Sun Microsystems, Inc.              *
31  *                                                               *
32  *****************************************************************/
33
34 /*
35  * @(#)sfs_c_nfs.h      2.1     97/10/23
36  *
37  * -------------------------- sfs_c_nfs.h -------------------------
38  *
39  *      Literals and types for the NFS protocol, Version 2.
40  *
41  *.Revision_History
42  *
43  *      Richard Bean    17-May-90       Created.
44  */
45
46
47 /*
48  * for RPC calls
49  */
50 /* #define NFS_PORT     2049 */
51 #define NFS_PROGRAM     ((uint32_t)100003)
52 #define NFS_VERSION     ((uint32_t)2)
53 #define NFS_V3          ((uint32_t)3)
54
55 /*
56  * fixed sizes
57  */
58 #define NFS_MAXDATA     8192
59 //#define NFS_MAXDATA   16384
60 #define NFS_MAXPATHLEN  1024
61 #define NFS_MAXNAMLEN   255
62 #define NFS_COOKIESIZE  4
63 #define NFS_FHSIZE      32
64
65
66 #if !defined(AIX)
67 typedef struct {
68         char    data[NFS_FHSIZE];
69 } fhandle_t;
70 #endif  /* AIX  */
71
72 /*
73  * Definition of "standard" mount parameters
74  */
75 #define MOUNTPROG       100005
76 #define MOUNTVERS       1
77 #define MOUNTPROC_MNT   1
78
79 struct fhstatus {
80         int fhs_status;
81         fhandle_t fhs_fh;
82 };
83
84 typedef fhandle_t nfs_fh;
85
86 /*
87  * fattr modes
88  */
89 /*
90  * The mode mask is used to mask off server vendor specific mode bits
91  * from the mode field.  This allows clients from different vendors to
92  * validate servers from different vendors.
93  */
94 #define NFSMODE_MASK 0177777
95 #define NFSMODE_FMT 0170000
96 #define NFSMODE_DIR 0040000
97 #define NFSMODE_CHR 0020000
98 #define NFSMODE_BLK 0060000
99 #define NFSMODE_REG 0100000
100 #define NFSMODE_LNK 0120000
101 #define NFSMODE_SOCK 0140000
102 #define NFSMODE_FIFO 0010000
103
104
105 /*
106  * NFS Procedures
107  */
108 #define NFSPROC_NULL            0
109 #define NFSPROC_GETATTR         1
110 #define NFSPROC_SETATTR         2
111 #define NFSPROC_ROOT            3
112 #define NFSPROC_LOOKUP          4
113 #define NFSPROC_READLINK        5
114 #define NFSPROC_READ            6
115 #define NFSPROC_WRITECACHE      7
116 #define NFSPROC_WRITE           8
117 #define NFSPROC_CREATE          9
118 #define NFSPROC_REMOVE          10
119 #define NFSPROC_RENAME          11
120 #define NFSPROC_LINK            12
121 #define NFSPROC_SYMLINK         13
122 #define NFSPROC_MKDIR           14
123 #define NFSPROC_RMDIR           15
124 #define NFSPROC_READDIR         16
125 #define NFSPROC_STATFS          17
126 #define NFS_PROCEDURE_COUNT     (NFSPROC_STATFS + 1)
127
128
129 /*
130  * call and return types
131  */
132 enum nfsstat {
133         NFS_OK =                0,
134         NFSERR_PERM =           1,
135         NFSERR_NOENT =          2,
136         NFSERR_IO =             5,
137         NFSERR_NXIO =           6,
138         NFSERR_ACCES =          13,
139         NFSERR_EXIST =          17,
140         NFSERR_XDEV =           18,
141         NFSERR_NODEV =          19,
142         NFSERR_NOTDIR =         20,
143         NFSERR_ISDIR =          21,
144         NFSERR_INVAL =          22,
145         NFSERR_FBIG =           27,
146         NFSERR_NOSPC =          28,
147         NFSERR_ROFS =           30,
148         NFSERR_OPNOTSUPP =      45,
149         NFSERR_NAMETOOLONG =    63,
150         NFSERR_NOTEMPTY =       66,
151         NFSERR_DQUOT =          69,
152         NFSERR_STALE =          70,
153         NFSERR_REMOTE =         71,
154         NFSERR_WFLUSH =         99
155 };
156 typedef enum nfsstat nfsstat;
157
158
159 enum ftype {
160         NFNON = 0,
161         NFREG = 1,
162         NFDIR = 2,
163         NFBLK = 3,
164         NFCHR = 4,
165         NFLNK = 5,
166         NFSOCK = 6,
167         NFBAD = 7,
168         NFFIFO = 8
169 };
170 typedef enum ftype ftype;
171 #define NUM_TYPES 5
172
173
174 struct nfstime {
175         unsigned int seconds;
176         unsigned int useconds;
177 };
178 typedef struct nfstime nfstime;
179
180
181 struct fattr {
182         ftype type;
183         unsigned int mode;
184         unsigned int nlink;
185         unsigned int uid;
186         unsigned int gid;
187         unsigned int size;
188         unsigned int blocksize;
189         unsigned int rdev;
190         unsigned int blocks;
191         unsigned int fsid;
192         unsigned int fileid;
193         nfstime atime;
194         nfstime mtime;
195         nfstime ctime;
196 };
197 typedef struct fattr fattr;
198
199
200 struct sattr {
201         unsigned int mode;
202         unsigned int uid;
203         unsigned int gid;
204         unsigned int size;
205         nfstime atime;
206         nfstime mtime;
207 };
208 typedef struct sattr sattr;
209
210
211 typedef char *filename;
212
213
214 typedef char *nfspath;
215
216
217 struct attrstat {
218         nfsstat status;
219         union {
220                 fattr attributes;
221         } attrstat_u;
222 };
223 typedef struct attrstat attrstat;
224
225
226 struct sattrargs {
227         nfs_fh file;
228         sattr attributes;
229 };
230 typedef struct sattrargs sattrargs;
231
232
233 struct diropargs {
234         nfs_fh dir;
235         filename name;
236 };
237 typedef struct diropargs diropargs;
238
239
240 struct diropokres {
241         nfs_fh file;
242         fattr attributes;
243 };
244 typedef struct diropokres diropokres;
245
246
247 struct diropres {
248         nfsstat status;
249         union {
250                 diropokres diropres;
251         } diropres_u;
252 };
253 typedef struct diropres diropres;
254
255
256 struct readlinkres {
257         nfsstat status;
258         struct {
259                 nfspath data;
260                 int len;        /* for convenience only, not in the protocol */
261         } readlinkres_u;
262 };
263 typedef struct readlinkres readlinkres;
264
265
266 struct readargs {
267         nfs_fh file;
268         unsigned int offset;
269         unsigned int count;
270         unsigned int totalcount;        /* unused field, but in the protocol */
271 };
272 typedef struct readargs readargs;
273
274
275 struct readokres {
276         fattr attributes;
277         struct {
278                 unsigned int data_len;
279                 char *data_val;
280         } data;
281 };
282 typedef struct readokres readokres;
283
284
285 struct readres {
286         nfsstat status;
287         union {
288                 readokres reply;
289         } readres_u;
290 };
291 typedef struct readres readres;
292
293
294 struct writeargs {
295         nfs_fh file;
296         unsigned int beginoffset;       /* unused field, but in the protocol */
297         unsigned int offset;
298         unsigned int totalcount;        /* unused field, but in the protocol */
299         struct {
300                 unsigned int data_len;
301                 char *data_val;
302         } data;
303 };
304 typedef struct writeargs writeargs;
305
306
307 struct createargs {
308         diropargs where;
309         sattr attributes;
310 };
311 typedef struct createargs createargs;
312
313
314 struct renameargs {
315         diropargs from;
316         diropargs to;
317 };
318 typedef struct renameargs renameargs;
319
320
321 struct linkargs {
322         nfs_fh from;
323         diropargs to;
324 };
325 typedef struct linkargs linkargs;
326
327
328 struct symlinkargs {
329         diropargs from;
330         nfspath to;
331         sattr attributes;
332 };
333 typedef struct symlinkargs symlinkargs;
334
335
336 struct mkdirargs {
337         diropargs where;
338         sattr attributes;
339 };
340 typedef struct mkdirargs mkdirargs;
341
342
343 typedef char nfscookie[NFS_COOKIESIZE];
344
345
346 struct readdirargs {
347         nfs_fh dir;
348         nfscookie cookie;
349         unsigned int count;
350 };
351 typedef struct readdirargs readdirargs;
352
353
354 struct entry {
355         bool_t valid;   /* bool for entry is present */
356         unsigned int fileid;
357         uint16_t name_len;
358         filename name;
359         nfscookie cookie;
360 };
361 typedef struct entry entry;
362
363
364 struct dirlist {
365         int max_entries;        /* for convenience only, not in the protocol */
366         entry *entries;         /* a stream of consecutive entry's */
367         bool_t eof;
368 };
369 typedef struct dirlist dirlist;
370
371
372 struct readdirres {
373         nfsstat status;
374         union {
375                 dirlist reply;
376         } readdirres_u;
377 };
378 typedef struct readdirres readdirres;
379
380
381 struct statfsokres {
382         unsigned int tsize;
383         unsigned int bsize;
384         unsigned int blocks;
385         unsigned int bfree;
386         unsigned int bavail;
387 };
388 typedef struct statfsokres statfsokres;
389
390
391 struct statfsres {
392         nfsstat status;
393         union {
394                 statfsokres reply;
395         } statfsres_u;
396 };
397 typedef struct statfsres statfsres;
398
399
400 /*
401  *      Literals and types for the NFS protocol, Version 3.
402  */
403
404
405 /*
406  * for RPC calls
407  */
408
409 /*
410  * fixed sizes
411  */
412 #define NFS3_FHSIZE     64
413 #define NFS3_COOKIEVERFSIZE     8
414 #define NFS3_CREATEVERFSIZE     8
415 #define NFS3_WRITEVERFSIZE      8
416
417 #define nfs3nametoolong ((char *)-1)
418
419 /*
420  * Not all systems have a built in long long type so we define a
421  * special version for sfs to use.
422  */
423 typedef union {
424         struct {
425                 uint32_t _u;
426                 uint32_t _l;
427         } _p;
428         char _f[8];
429 } nfs_uint64_t;
430
431 typedef char *filename3;
432
433 typedef char *nfspath3;
434
435 typedef char cookieverf3[NFS3_COOKIEVERFSIZE];
436
437 typedef char createverf3[NFS3_CREATEVERFSIZE];
438
439 typedef char writeverf3[NFS3_WRITEVERFSIZE];
440
441 struct nfs_fh3 {
442         unsigned int fh3_length;
443         union nfs_fh3_u {
444                 struct {
445                         char _u[NFS_FHSIZE];
446                         char _l[NFS_FHSIZE];
447                 } _p;
448                 char data[NFS3_FHSIZE];
449         } fh3_u;
450 };
451 #define fh3_fsid        fh3_u.nfs_fh3_i.fh3_i.fh_fsid
452 #define fh3_len         fh3_u.nfs_fh3_i.fh3_i.fh_len /* fid length */
453 #define fh3_data        fh3_u.nfs_fh3_i.fh3_i.fh_data /* fid bytes */
454 #define fh3_xlen        fh3_u.nfs_fh3_i.fh3_i.fh_xlen
455 #define fh3_xdata       fh3_u.nfs_fh3_i.fh3_i.fh_xdata
456 typedef struct nfs_fh3 nfs_fh3;
457
458 struct diropargs3 {
459         nfs_fh3 dir;
460         filename3 name;
461 };
462 typedef struct diropargs3 diropargs3;
463
464 struct nfstime3 {
465         uint32_t seconds;
466         uint32_t nseconds;
467 };
468 typedef struct nfstime3 nfstime3;
469
470 struct specdata3 {
471         uint32_t specdata1;
472         uint32_t specdata2;
473 };
474 typedef struct specdata3 specdata3;
475
476
477 /*
478  * call and return types
479  */
480 enum nfsstat3 {
481         NFS3_OK = 0,
482         NFS3ERR_PERM = 1,
483         NFS3ERR_NOENT = 2,
484         NFS3ERR_IO = 5,
485         NFS3ERR_NXIO = 6,
486         NFS3ERR_ACCES = 13,
487         NFS3ERR_EXIST = 17,
488         NFS3ERR_XDEV = 18,
489         NFS3ERR_NODEV = 19,
490         NFS3ERR_NOTDIR = 20,
491         NFS3ERR_ISDIR = 21,
492         NFS3ERR_INVAL = 22,
493         NFS3ERR_FBIG = 27,
494         NFS3ERR_NOSPC = 28,
495         NFS3ERR_ROFS = 30,
496         NFS3ERR_MLINK = 31,
497         NFS3ERR_NAMETOOLONG = 63,
498         NFS3ERR_NOTEMPTY = 66,
499         NFS3ERR_DQUOT = 69,
500         NFS3ERR_STALE = 70,
501         NFS3ERR_REMOTE = 71,
502         NFS3ERR_BADHANDLE = 10001,
503         NFS3ERR_NOT_SYNC = 10002,
504         NFS3ERR_BAD_COOKIE = 10003,
505         NFS3ERR_NOTSUPP = 10004,
506         NFS3ERR_TOOSMALL = 10005,
507         NFS3ERR_SERVERFAULT = 10006,
508         NFS3ERR_BADTYPE = 10007,
509         NFS3ERR_JUKEBOX = 10008,
510         NFS3ERR_RFS_TIMEOUT = 10009,                    // RFS
511         NFS3ERR_RFS_MISS = 10010                // RFS reply missed in trace
512 };
513 typedef enum nfsstat3 nfsstat3;
514
515 enum ftype3 {
516         NF3NON = 0,
517         NF3REG = 1,
518         NF3DIR = 2,
519         NF3BLK = 3,
520         NF3CHR = 4,
521         NF3LNK = 5,
522         NF3SOCK = 6,
523         NF3FIFO = 7
524 };
525 typedef enum ftype3 ftype3;
526 #define NUM_TYPES 5
527
528
529 struct fattr3 {
530         ftype3          type;
531         uint32_t                mode;
532         uint32_t                nlink;
533         uint32_t                uid;
534         uint32_t                gid;
535         nfs_uint64_t    size;
536         nfs_uint64_t    used;
537         specdata3       rdev;
538         nfs_uint64_t    fsid;
539         nfs_uint64_t    fileid;
540         nfstime3        atime;
541         nfstime3        mtime;
542         nfstime3        ctime;
543 };
544 typedef struct fattr3 fattr3;
545
546 struct post_op_attr {
547         bool_t  attributes;
548         fattr3  attr;
549 };
550 typedef struct post_op_attr post_op_attr;
551
552 struct wcc_attr {
553         nfs_uint64_t    size;
554         nfstime3        mtime;
555         nfstime3        ctime;
556 };
557 typedef struct wcc_attr wcc_attr;
558
559 struct pre_op_attr {
560         bool_t          attributes;
561         wcc_attr        attr;
562 };
563 typedef struct pre_op_attr pre_op_attr;
564
565 struct wcc_data {
566         pre_op_attr     before;
567         post_op_attr    after;
568 };
569 typedef struct wcc_data wcc_data;
570
571 struct post_op_fh3 {
572         bool_t  handle_follows;
573         nfs_fh3 handle;
574 };
575 typedef struct post_op_fh3 post_op_fh3;
576
577 enum time_how {
578         DONT_CHANGE = 0,
579         SET_TO_SERVER_TIME = 1,
580         SET_TO_CLIENT_TIME = 2
581 };
582 typedef enum time_how time_how;
583
584 struct set_mode3 {
585         bool_t set_it;
586         uint32_t mode;
587 };
588 typedef struct set_mode3 set_mode3;
589
590 struct set_uid3 {
591         bool_t set_it;
592         uint32_t uid;
593 };
594 typedef struct set_uid3 set_uid3;
595  
596 struct set_gid3 {
597         bool_t set_it;
598         uint32_t gid;
599 };
600 typedef struct set_gid3 set_gid3;
601  
602 struct set_size3 {
603         bool_t          set_it;
604         nfs_uint64_t    size;
605 };
606 typedef struct set_size3 set_size3;
607  
608 struct set_atime {
609         time_how set_it;
610         nfstime3 atime;
611 };
612 typedef struct set_atime set_atime;
613  
614 struct set_mtime {
615         time_how set_it;
616         nfstime3 mtime;
617 };
618 typedef struct set_mtime set_mtime;
619  
620 struct sattr3 {
621         set_mode3       mode;
622         set_uid3        uid;
623         set_gid3        gid;
624         set_size3       size;
625         set_atime       atime;
626         set_mtime       mtime;
627 };
628 typedef struct sattr3 sattr3;
629
630
631 #define resok   res_u.ok
632 #define resfail res_u.fail
633
634 struct GETATTR3args {
635         nfs_fh3 object;
636 };
637 typedef struct GETATTR3args GETATTR3args;
638
639 struct GETATTR3resok {
640         fattr3 obj_attributes;
641 };
642 typedef struct GETATTR3resok GETATTR3resok;
643
644 struct GETATTR3res {
645         nfsstat3 status;
646         union {
647                 GETATTR3resok ok;
648         } res_u;
649 };
650 typedef struct GETATTR3res GETATTR3res;
651
652 struct sattrguard3 {
653         bool_t          check;
654         nfstime3        obj_ctime;
655 };
656 typedef struct sattrguard3 sattrguard3;
657
658 struct SETATTR3args {
659         nfs_fh3         object;
660         sattr3          new_attributes;
661         sattrguard3     guard;
662 };
663 typedef struct SETATTR3args SETATTR3args;
664
665 struct SETATTR3resok {
666         wcc_data obj_wcc;
667 };
668 typedef struct SETATTR3resok SETATTR3resok;
669
670 struct SETATTR3resfail {
671         wcc_data obj_wcc;
672 };
673 typedef struct SETATTR3resfail SETATTR3resfail;
674
675 struct SETATTR3res {
676         nfsstat3 status;
677         union {
678                 SETATTR3resok   ok;
679                 SETATTR3resfail fail;
680         } res_u;
681 };
682 typedef struct SETATTR3res SETATTR3res;
683
684 struct LOOKUP3args {
685         diropargs3 what;
686 };
687 typedef struct LOOKUP3args LOOKUP3args;
688
689 struct LOOKUP3resok {
690         nfs_fh3         object;
691         post_op_attr    obj_attributes;
692         post_op_attr    dir_attributes;
693 };
694 typedef struct LOOKUP3resok LOOKUP3resok;
695
696 struct LOOKUP3resfail {
697         post_op_attr dir_attributes;
698 };
699 typedef struct LOOKUP3resfail LOOKUP3resfail;
700
701 struct LOOKUP3res {
702         nfsstat3 status;
703         union {
704                 LOOKUP3resok    ok;
705                 LOOKUP3resfail  fail;
706         } res_u;
707 };
708 typedef struct LOOKUP3res LOOKUP3res;
709
710 struct ACCESS3args {
711         nfs_fh3 object;
712         uint32_t        access;
713 };
714 typedef struct ACCESS3args ACCESS3args;
715 #define ACCESS3_READ    0x1
716 #define ACCESS3_LOOKUP  0x2
717 #define ACCESS3_MODIFY  0x4
718 #define ACCESS3_EXTEND  0x8
719 #define ACCESS3_DELETE  0x10
720 #define ACCESS3_EXECUTE 0x20
721
722 struct ACCESS3resok {
723         post_op_attr obj_attributes;
724         uint32_t access;
725 };
726 typedef struct ACCESS3resok ACCESS3resok;
727
728 struct ACCESS3resfail {
729         post_op_attr obj_attributes;
730 };
731 typedef struct ACCESS3resfail ACCESS3resfail;
732
733 struct ACCESS3res {
734         nfsstat3 status;
735         union {
736                 ACCESS3resok    ok;
737                 ACCESS3resfail  fail;
738         } res_u;
739 };
740 typedef struct ACCESS3res ACCESS3res;
741
742 struct READLINK3args {
743         nfs_fh3 symlink;
744 };
745 typedef struct READLINK3args READLINK3args;
746
747 struct READLINK3resok {
748         post_op_attr    symlink_attributes;
749         nfspath3        data;
750 };
751 typedef struct READLINK3resok READLINK3resok;
752
753 struct READLINK3resfail {
754         post_op_attr symlink_attributes;
755 };
756 typedef struct READLINK3resfail READLINK3resfail;
757
758 struct READLINK3res {
759         nfsstat3 status;
760         union {
761                 READLINK3resok          ok;
762                 READLINK3resfail        fail;
763         } res_u;
764 };
765 typedef struct READLINK3res READLINK3res;
766
767 struct READ3args {
768         nfs_fh3         file;
769         nfs_uint64_t    offset;
770         uint32_t                count;
771 };
772 typedef struct READ3args READ3args;
773
774 struct READ3resok {
775         post_op_attr file_attributes;
776         uint32_t count;
777         bool_t eof;
778         struct {
779                 unsigned int data_len;
780                 char *data_val;
781         } data;
782         unsigned int size;
783 };
784 typedef struct READ3resok READ3resok;
785
786 struct READ3resfail {
787         post_op_attr file_attributes;
788 };
789 typedef struct READ3resfail READ3resfail;
790
791 struct READ3res {
792         nfsstat3 status;
793         union {
794                 READ3resok ok;
795                 READ3resfail fail;
796         } res_u;
797 };
798 typedef struct READ3res READ3res;
799
800 enum stable_how {
801         UNSTABLE = 0,
802         DATA_SYNC = 1,
803         FILE_SYNC = 2
804 };
805 typedef enum stable_how stable_how;
806
807 struct WRITE3args {
808         nfs_fh3 file;
809         nfs_uint64_t offset;
810         uint32_t count;
811         stable_how stable;
812         struct {
813                 unsigned int data_len;
814                 char *data_val;
815         } data;
816 };
817 typedef struct WRITE3args WRITE3args;
818
819 struct WRITE3resok {
820         wcc_data file_wcc;
821         uint32_t count;
822         stable_how committed;
823         writeverf3 verf;
824 };
825 typedef struct WRITE3resok WRITE3resok;
826
827 struct WRITE3resfail {
828         wcc_data file_wcc;
829 };
830 typedef struct WRITE3resfail WRITE3resfail;
831
832 struct WRITE3res {
833         nfsstat3 status;
834         union {
835                 WRITE3resok ok;
836                 WRITE3resfail fail;
837         } res_u;
838 };
839 typedef struct WRITE3res WRITE3res;
840
841 enum createmode3 {
842         UNCHECKED = 0,
843         GUARDED = 1,
844         EXCLUSIVE = 2
845 };
846 typedef enum createmode3 createmode3;
847
848 struct createhow3 {
849         createmode3 mode;
850         union {
851                 sattr3 obj_attributes;
852                 createverf3 verf;
853         } createhow3_u;
854 };
855 typedef struct createhow3 createhow3;
856
857 struct CREATE3args {
858         diropargs3 where;
859         createhow3 how;
860 };
861 typedef struct CREATE3args CREATE3args;
862
863 struct CREATE3resok {
864         post_op_fh3 obj;
865         post_op_attr obj_attributes;
866         wcc_data dir_wcc;
867 };
868 typedef struct CREATE3resok CREATE3resok;
869
870 struct CREATE3resfail {
871         wcc_data dir_wcc;
872 };
873 typedef struct CREATE3resfail CREATE3resfail;
874
875 struct CREATE3res {
876         nfsstat3 status;
877         union {
878                 CREATE3resok ok;
879                 CREATE3resfail fail;
880         } res_u;
881 };
882 typedef struct CREATE3res CREATE3res;
883
884 struct MKDIR3args {
885         diropargs3 where;
886         sattr3 attributes;
887 };
888 typedef struct MKDIR3args MKDIR3args;
889
890 struct MKDIR3resok {
891         post_op_fh3 obj;
892         post_op_attr obj_attributes;
893         wcc_data dir_wcc;
894 };
895 typedef struct MKDIR3resok MKDIR3resok;
896
897 struct MKDIR3resfail {
898         wcc_data dir_wcc;
899 };
900 typedef struct MKDIR3resfail MKDIR3resfail;
901
902 struct MKDIR3res {
903         nfsstat3 status;
904         union {
905                 MKDIR3resok ok;
906                 MKDIR3resfail fail;
907         } res_u;
908 };
909 typedef struct MKDIR3res MKDIR3res;
910
911 struct symlinkdata3 {
912         sattr3 symlink_attributes;
913         nfspath3 symlink_data;
914 };
915 typedef struct symlinkdata3 symlinkdata3;
916
917 struct SYMLINK3args {
918         diropargs3 where;
919         symlinkdata3 symlink;
920 };
921 typedef struct SYMLINK3args SYMLINK3args;
922
923 struct SYMLINK3resok {
924         post_op_fh3 obj;
925         post_op_attr obj_attributes;
926         wcc_data dir_wcc;
927 };
928 typedef struct SYMLINK3resok SYMLINK3resok;
929
930 struct SYMLINK3resfail {
931         wcc_data dir_wcc;
932 };
933 typedef struct SYMLINK3resfail SYMLINK3resfail;
934
935 struct SYMLINK3res {
936         nfsstat3 status;
937         union {
938                 SYMLINK3resok ok;
939                 SYMLINK3resfail fail;
940         } res_u;
941 };
942 typedef struct SYMLINK3res SYMLINK3res;
943
944 struct devicedata3 {
945         sattr3 dev_attributes;
946         specdata3 spec;
947 };
948 typedef struct devicedata3 devicedata3;
949
950 struct mknoddata3 {
951         ftype3 type;
952         union {
953                 devicedata3 device;
954                 sattr3 pipe_attributes;
955         } mknoddata3_u;
956 };
957 typedef struct mknoddata3 mknoddata3;
958
959 struct MKNOD3args {
960         diropargs3 where;
961         mknoddata3 what;
962 };
963 typedef struct MKNOD3args MKNOD3args;
964
965 struct MKNOD3resok {
966         post_op_fh3 obj;
967         post_op_attr obj_attributes;
968         wcc_data dir_wcc;
969 };
970 typedef struct MKNOD3resok MKNOD3resok;
971
972 struct MKNOD3resfail {
973         wcc_data dir_wcc;
974 };
975 typedef struct MKNOD3resfail MKNOD3resfail;
976
977 struct MKNOD3res {
978         nfsstat3 status;
979         union {
980                 MKNOD3resok ok;
981                 MKNOD3resfail fail;
982         } res_u;
983 };
984 typedef struct MKNOD3res MKNOD3res;
985
986 struct REMOVE3args {
987         diropargs3 object;
988 };
989 typedef struct REMOVE3args REMOVE3args;
990
991 struct REMOVE3resok {
992         wcc_data dir_wcc;
993 };
994 typedef struct REMOVE3resok REMOVE3resok;
995
996 struct REMOVE3resfail {
997         wcc_data dir_wcc;
998 };
999 typedef struct REMOVE3resfail REMOVE3resfail;
1000
1001 struct REMOVE3res {
1002         nfsstat3 status;
1003         union {
1004                 REMOVE3resok ok;
1005                 REMOVE3resfail fail;
1006         } res_u;
1007 };
1008 typedef struct REMOVE3res REMOVE3res;
1009
1010 struct RMDIR3args {
1011         diropargs3 object;
1012 };
1013 typedef struct RMDIR3args RMDIR3args;
1014
1015 struct RMDIR3resok {
1016         wcc_data dir_wcc;
1017 };
1018 typedef struct RMDIR3resok RMDIR3resok;
1019
1020 struct RMDIR3resfail {
1021         wcc_data dir_wcc;
1022 };
1023 typedef struct RMDIR3resfail RMDIR3resfail;
1024
1025 struct RMDIR3res {
1026         nfsstat3 status;
1027         union {
1028                 RMDIR3resok ok;
1029                 RMDIR3resfail fail;
1030         } res_u;
1031 };
1032 typedef struct RMDIR3res RMDIR3res;
1033
1034 struct RENAME3args {
1035         diropargs3 from;
1036         diropargs3 to;
1037 };
1038 typedef struct RENAME3args RENAME3args;
1039
1040 struct RENAME3resok {
1041         wcc_data fromdir_wcc;
1042         wcc_data todir_wcc;
1043 };
1044 typedef struct RENAME3resok RENAME3resok;
1045
1046 struct RENAME3resfail {
1047         wcc_data fromdir_wcc;
1048         wcc_data todir_wcc;
1049 };
1050 typedef struct RENAME3resfail RENAME3resfail;
1051
1052 struct RENAME3res {
1053         nfsstat3 status;
1054         union {
1055                 RENAME3resok ok;
1056                 RENAME3resfail fail;
1057         } res_u;
1058 };
1059 typedef struct RENAME3res RENAME3res;
1060
1061 struct LINK3args {
1062         nfs_fh3 file;
1063         diropargs3 link;
1064 };
1065 typedef struct LINK3args LINK3args;
1066
1067 struct LINK3resok {
1068         post_op_attr file_attributes;
1069         wcc_data linkdir_wcc;
1070 };
1071 typedef struct LINK3resok LINK3resok;
1072
1073 struct LINK3resfail {
1074         post_op_attr file_attributes;
1075         wcc_data linkdir_wcc;
1076 };
1077 typedef struct LINK3resfail LINK3resfail;
1078
1079 struct LINK3res {
1080         nfsstat3 status;
1081         union {
1082                 LINK3resok ok;
1083                 LINK3resfail fail;
1084         } res_u;
1085 };
1086 typedef struct LINK3res LINK3res;
1087
1088 struct READDIR3args {
1089         nfs_fh3 dir;
1090         nfs_uint64_t cookie;
1091         cookieverf3 cookieverf;
1092         uint32_t count;
1093 };
1094 typedef struct READDIR3args READDIR3args;
1095
1096 struct entry3 {
1097         nfs_uint64_t fileid;
1098         char name[SFS_MAXNAMLEN];
1099         nfs_uint64_t cookie;
1100 };
1101 typedef struct entry3 entry3;
1102
1103 struct dirlist3 {
1104         entry3 *entries;
1105         bool_t eof;
1106 };
1107 typedef struct dirlist3 dirlist3;
1108
1109 struct READDIR3resok {
1110         post_op_attr dir_attributes;
1111         cookieverf3 cookieverf;
1112         dirlist3 reply;
1113         unsigned int size;
1114         unsigned int count;
1115         nfs_uint64_t cookie;
1116 };
1117 typedef struct READDIR3resok READDIR3resok;
1118
1119 struct READDIR3resfail {
1120         post_op_attr dir_attributes;
1121 };
1122 typedef struct READDIR3resfail READDIR3resfail;
1123
1124 struct READDIR3res {
1125         nfsstat3 status;
1126         union {
1127                 READDIR3resok ok;
1128                 READDIR3resfail fail;
1129         } res_u;
1130 };
1131 typedef struct READDIR3res READDIR3res;
1132
1133 struct READDIRPLUS3args {
1134         nfs_fh3 dir;
1135         nfs_uint64_t cookie;
1136         cookieverf3 cookieverf;
1137         uint32_t dircount;
1138         uint32_t maxcount;
1139 };
1140 typedef struct READDIRPLUS3args READDIRPLUS3args;
1141
1142 struct entryplus3 {
1143         nfs_uint64_t fileid;
1144         char name[SFS_MAXNAMLEN];
1145         nfs_uint64_t cookie;
1146         post_op_attr name_attributes;
1147         post_op_fh3 name_handle;
1148 };
1149 typedef struct entryplus3 entryplus3;
1150
1151 struct dirlistplus3 {
1152         entryplus3 *entries;
1153         bool_t eof;
1154 };
1155 typedef struct dirlistplus3 dirlistplus3;
1156
1157 struct READDIRPLUS3resok {
1158         post_op_attr dir_attributes;
1159         cookieverf3 cookieverf;
1160         dirlistplus3 reply;
1161         unsigned int size;
1162         unsigned int count;
1163         unsigned int maxcount;
1164         post_op_attr *attributes;
1165         post_op_fh3 *handles;
1166 };
1167 typedef struct READDIRPLUS3resok READDIRPLUS3resok;
1168
1169 struct READDIRPLUS3resfail {
1170         post_op_attr dir_attributes;
1171 };
1172 typedef struct READDIRPLUS3resfail READDIRPLUS3resfail;
1173
1174 struct READDIRPLUS3res {
1175         nfsstat3 status;
1176         union {
1177                 READDIRPLUS3resok ok;
1178                 READDIRPLUS3resfail fail;
1179         } res_u;
1180 };
1181 typedef struct READDIRPLUS3res READDIRPLUS3res;
1182
1183 struct FSSTAT3args {
1184         nfs_fh3 fsroot;
1185 };
1186 typedef struct FSSTAT3args FSSTAT3args;
1187
1188 struct FSSTAT3resok {
1189         post_op_attr obj_attributes;
1190         nfs_uint64_t tbytes;
1191         nfs_uint64_t fbytes;
1192         nfs_uint64_t abytes;
1193         nfs_uint64_t tfiles;
1194         nfs_uint64_t ffiles;
1195         nfs_uint64_t afiles;
1196         uint32_t invarsec;
1197 };
1198 typedef struct FSSTAT3resok FSSTAT3resok;
1199
1200 struct FSSTAT3resfail {
1201         post_op_attr obj_attributes;
1202 };
1203 typedef struct FSSTAT3resfail FSSTAT3resfail;
1204
1205 struct FSSTAT3res {
1206         nfsstat3 status;
1207         union {
1208                 FSSTAT3resok ok;
1209                 FSSTAT3resfail fail;
1210         } res_u;
1211 };
1212 typedef struct FSSTAT3res FSSTAT3res;
1213
1214 struct FSINFO3args {
1215         nfs_fh3 fsroot;
1216 };
1217 typedef struct FSINFO3args FSINFO3args;
1218
1219 struct FSINFO3resok {
1220         post_op_attr obj_attributes;
1221         uint32_t rtmax;
1222         uint32_t rtpref;
1223         uint32_t rtmult;
1224         uint32_t wtmax;
1225         uint32_t wtpref;
1226         uint32_t wtmult;
1227         uint32_t dtpref;
1228         nfs_uint64_t maxfilesize;
1229         nfstime3 time_delta;
1230         uint32_t properties;
1231 };
1232 typedef struct FSINFO3resok FSINFO3resok;
1233
1234 struct FSINFO3resfail {
1235         post_op_attr obj_attributes;
1236 };
1237 typedef struct FSINFO3resfail FSINFO3resfail;
1238 #define FSF3_LINK 0x1
1239 #define FSF3_SYMLINK 0x2
1240 #define FSF3_HOMOGENEOUS 0x8
1241 #define FSF3_CANSETTIME 0x10
1242
1243 struct FSINFO3res {
1244         nfsstat3 status;
1245         union {
1246                 FSINFO3resok ok;
1247                 FSINFO3resfail fail;
1248         } res_u;
1249 };
1250 typedef struct FSINFO3res FSINFO3res;
1251
1252 struct PATHCONF3args {
1253         nfs_fh3 object;
1254 };
1255 typedef struct PATHCONF3args PATHCONF3args;
1256
1257 struct PATHCONF3resok {
1258         post_op_attr obj_attributes;
1259         uint32_t link_max;
1260         uint32_t name_max;
1261         bool_t no_trunc;
1262         bool_t chown_restricted;
1263         bool_t case_insensitive;
1264         bool_t case_preserving;
1265 };
1266 typedef struct PATHCONF3resok PATHCONF3resok;
1267
1268 struct PATHCONF3resfail {
1269         post_op_attr obj_attributes;
1270 };
1271 typedef struct PATHCONF3resfail PATHCONF3resfail;
1272
1273 struct PATHCONF3res {
1274         nfsstat3 status;
1275         union {
1276                 PATHCONF3resok ok;
1277                 PATHCONF3resfail fail;
1278         } res_u;
1279 };
1280 typedef struct PATHCONF3res PATHCONF3res;
1281
1282 struct COMMIT3args {
1283         nfs_fh3 file;
1284         nfs_uint64_t offset;
1285         uint32_t count;
1286 };
1287 typedef struct COMMIT3args COMMIT3args;
1288
1289 struct COMMIT3resok {
1290         wcc_data file_wcc;
1291         writeverf3 verf;
1292 };
1293 typedef struct COMMIT3resok COMMIT3resok;
1294
1295 struct COMMIT3resfail {
1296         wcc_data file_wcc;
1297 };
1298 typedef struct COMMIT3resfail COMMIT3resfail;
1299
1300 struct COMMIT3res {
1301         nfsstat3 status;
1302         union {
1303                 COMMIT3resok ok;
1304                 COMMIT3resfail fail;
1305         } res_u;
1306 };
1307 typedef struct COMMIT3res COMMIT3res;
1308
1309 /*
1310  * NFS Procedures
1311  */
1312 #define NFSPROC3_NULL           0
1313 #define NFSPROC3_GETATTR        1
1314 #define NFSPROC3_SETATTR        2
1315 #define NFSPROC3_LOOKUP         3
1316 #define NFSPROC3_ACCESS         4
1317 #define NFSPROC3_READLINK       5
1318 #define NFSPROC3_READ           6
1319 #define NFSPROC3_WRITE          7
1320 #define NFSPROC3_CREATE         8
1321 #define NFSPROC3_MKDIR          9
1322 #define NFSPROC3_SYMLINK        10
1323 #define NFSPROC3_MKNOD          11
1324 #define NFSPROC3_REMOVE         12
1325 #define NFSPROC3_RMDIR          13
1326 #define NFSPROC3_RENAME         14
1327 #define NFSPROC3_LINK           15
1328 #define NFSPROC3_READDIR        16
1329 #define NFSPROC3_READDIRPLUS    17
1330 #define NFSPROC3_FSSTAT         18
1331 #define NFSPROC3_FSINFO         19
1332 #define NFSPROC3_PATHCONF       20
1333 #define NFSPROC3_COMMIT         21
1334 #define NFS3_PROCEDURE_COUNT    (NFSPROC3_COMMIT + 1)
1335
1336
1337 /*
1338  *      mount.h definitions
1339  */
1340 #define MOUNTVER3       ((uint32_t)3)
1341 #define MNTPATHLEN 1024
1342 #define MNTNAMLEN 255
1343
1344 #define MOUNTPROC_NULL ((uint32_t)(0))
1345 #define MOUNTPROC_DUMP ((uint32_t)(2))
1346 #define MOUNTPROC_UMNT ((uint32_t)(3))
1347 #define MOUNTPROC_UMNTALL ((uint32_t)(4))
1348 #define MOUNTPROC_EXPORT ((uint32_t)(5))
1349 #define MOUNTPROC_EXPORTALL ((uint32_t)(6))
1350 #define MOUNTPROC_PATHCONF ((uint32_t)(7))
1351
1352 struct fhandle3 {
1353         unsigned int    fhandle3_len;
1354         char    *fhandle3_val;
1355 };
1356 typedef struct fhandle3 fhandle3;
1357
1358 enum mntstat3 {
1359         MNT_OK = 0,
1360         MNT3ERR_PERM = 1,
1361         MNT3ERR_NOENT = 2,
1362         MNT3ERR_IO = 5,
1363         MNT3ERR_ACCES = 13,
1364         MNT3ERR_NOTDIR = 20,
1365         MNT3ERR_INVAL = 22,
1366         MNT3ERR_NAMETOOLONG = 63,
1367         MNT3ERR_NOTSUPP = 10004,
1368         MNT3ERR_SERVERFAULT = 10006
1369 };
1370 typedef enum mntstat3 mntstat3;
1371
1372 struct mntres3_ok {
1373         fhandle3 fhandle;
1374         struct {
1375                 unsigned int auth_flavors_len;
1376                 int *auth_flavors_val;
1377         } auth_flavors;
1378 };
1379 typedef struct mntres3_ok mntres3_ok;
1380
1381 struct mountres3 {
1382         mntstat3 fhs_status;
1383         union {
1384                 mntres3_ok mntinfo;
1385         } mntres3_u;
1386 };
1387 typedef struct mountres3 mountres3;
1388
1389 typedef char *dirpath;
1390
1391
1392 /*
1393  * External XDR functions
1394  */
1395
1396 /*
1397  * Mount protocol
1398  */
1399 extern bool_t xdr_path(XDR *, char **);
1400 extern bool_t xdr_fhstatus(XDR *, struct fhstatus *);
1401 extern bool_t xdr_dirpath(XDR *, dirpath *);
1402 extern bool_t xdr_mntres3(XDR *, mountres3 *);
1403
1404 /*
1405  * V2
1406  */
1407 extern bool_t xdr_create(XDR *, char *);
1408 extern bool_t xdr_getattr(XDR *xdrs, char *);
1409 extern bool_t xdr_link(XDR *xdrs, char *);
1410 extern bool_t xdr_lookup(XDR *xdrs, char *);
1411 extern bool_t xdr_mkdir(XDR *xdrs, char *);
1412 extern bool_t xdr_read(XDR *xdrs, char *);
1413 extern bool_t xdr_readdir(XDR *xdrs,  char *);
1414 extern bool_t xdr_readlink(XDR *xdrs, char *);
1415 extern bool_t xdr_remove(XDR *xdrs, char *);
1416 extern bool_t xdr_rename(XDR *xdrs, char *);
1417 extern bool_t xdr_rmdir(XDR *xdrs, char *);
1418 extern bool_t xdr_setattr(XDR *xdrs, char *);
1419 extern bool_t xdr_statfs(XDR *xdrs, char *);
1420 extern bool_t xdr_symlink(XDR *xdrs, char *);
1421 extern bool_t xdr_write(XDR *xdrs, char *);
1422
1423 /*
1424  * V3
1425  */
1426 extern bool_t xdr_GETATTR3args(XDR *, GETATTR3args *);
1427 extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res *);
1428 extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args *);
1429 extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res *);
1430 extern bool_t xdr_LOOKUP3args(XDR *, LOOKUP3args *);
1431 extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res *);
1432 extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args *);
1433 extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res *);
1434 extern bool_t xdr_READLINK3args(XDR *, READLINK3args *);
1435 extern bool_t xdr_READLINK3res(XDR *, READLINK3res *);
1436 extern bool_t xdr_READ3args(XDR *, READ3args *);
1437 extern bool_t xdr_READ3res(XDR *, READ3res *);
1438 extern bool_t xdr_WRITE3args(XDR *, WRITE3args *);
1439 extern bool_t xdr_WRITE3res(XDR *, WRITE3res *);
1440 extern bool_t xdr_CREATE3args(XDR *, CREATE3args *);
1441 extern bool_t xdr_CREATE3res(XDR *, CREATE3res *);
1442 extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args *);
1443 extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res *);
1444 extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args *);
1445 extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res *);
1446 extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args *);
1447 extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res *);
1448 extern bool_t xdr_REMOVE3args(XDR *, REMOVE3args *);
1449 extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res *);
1450 extern bool_t xdr_RMDIR3args(XDR *, RMDIR3args *);
1451 extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res *);
1452 extern bool_t xdr_RENAME3args(XDR *, RENAME3args *);
1453 extern bool_t xdr_RENAME3res(XDR *, RENAME3res *);
1454 extern bool_t xdr_LINK3args(XDR *, LINK3args *);
1455 extern bool_t xdr_LINK3res(XDR *, LINK3res *);
1456 extern bool_t xdr_READDIR3args(XDR *, READDIR3args *);
1457 extern bool_t xdr_READDIR3res(XDR *, READDIR3res *);
1458 extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args *);
1459 extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res *);
1460 extern bool_t xdr_FSSTAT3args(XDR *, FSSTAT3args *);
1461 extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res *);
1462 extern bool_t xdr_FSINFO3args(XDR *, FSINFO3args *);
1463 extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res *);
1464 extern bool_t xdr_PATHCONF3args(XDR *, PATHCONF3args *);
1465 extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res *);
1466 extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args *);
1467 extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res *);
1468
1469
1470 #endif  /* __sfs_c_nfs_h */