2 Copyright (c) 2014, Ronnie Sahlberg
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 1. Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 The views and conclusions contained in the software and documentation are those
26 of the authors and should not be interpreted as representing official policies,
27 either expressed or implied, of the FreeBSD Project.
33 const NFS3_FHSIZE = 64; /* Maximum bytes in a V3 file handle */
34 const NFS3_WRITEVERFSIZE = 8;
35 const NFS3_CREATEVERFSIZE = 8;
36 const NFS3_COOKIEVERFSIZE = 8;
38 typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
40 /*unsigned hyper can be overridden by giving rpcgen -DU_INT64_PLATTFORM_TYPE="
41 where rpcgen doesn't know anything about hyper
42 default to unsigned hyper as of rfc 1813 */
43 #ifndef U_INT64_PLATTFORM_TYPE
44 #define U_INT64_PLATTFORM_TYPE unsigned hyper
45 #endif/*U_INT64_PLATTFORM_TYPE*/
47 typedef U_INT64_PLATTFORM_TYPE uint64;
49 typedef uint64 cookie3;
52 opaque data<NFS3_FHSIZE>;
55 typedef string filename3<>;
72 typedef unsigned int mode3;
74 typedef unsigned int uid3;
76 typedef unsigned int gid3;
80 typedef uint64 fileid3;
83 unsigned int specdata1;
84 unsigned int specdata2;
89 unsigned int nseconds;
108 union post_op_attr switch (bool attributes_follow) {
133 NFS3ERR_NAMETOOLONG = 63,
134 NFS3ERR_NOTEMPTY = 66,
138 NFS3ERR_BADHANDLE = 10001,
139 NFS3ERR_NOT_SYNC = 10002,
140 NFS3ERR_BAD_COOKIE = 10003,
141 NFS3ERR_NOTSUPP = 10004,
142 NFS3ERR_TOOSMALL = 10005,
143 NFS3ERR_SERVERFAULT = 10006,
144 NFS3ERR_BADTYPE = 10007,
145 NFS3ERR_JUKEBOX = 10008
154 typedef uint64 offset3;
156 typedef unsigned int count3;
164 union pre_op_attr switch (bool attributes_follow) {
184 typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
189 stable_how committed;
193 struct WRITE3resfail {
197 union WRITE3res switch (nfsstat3 status) {
201 WRITE3resfail resfail;
208 struct LOOKUP3resok {
210 post_op_attr obj_attributes;
211 post_op_attr dir_attributes;
214 struct LOOKUP3resfail {
215 post_op_attr dir_attributes;
220 union LOOKUP3res switch (nfsstat3 status) {
224 LOOKUP3resfail resfail;
233 struct COMMIT3resok {
238 struct COMMIT3resfail {
242 union COMMIT3res switch (nfsstat3 status) {
246 COMMIT3resfail resfail;
249 const ACCESS3_READ = 0x0001;
250 const ACCESS3_LOOKUP = 0x0002;
251 const ACCESS3_MODIFY = 0x0004;
252 const ACCESS3_EXTEND = 0x0008;
253 const ACCESS3_DELETE = 0x0010;
254 const ACCESS3_EXECUTE = 0x0020;
261 struct ACCESS3resok {
262 post_op_attr obj_attributes;
266 struct ACCESS3resfail {
267 post_op_attr obj_attributes;
270 union ACCESS3res switch (nfsstat3 status) {
274 ACCESS3resfail resfail;
277 struct GETATTR3args {
281 struct GETATTR3resok {
282 fattr3 obj_attributes;
285 union GETATTR3res switch (nfsstat3 status) {
296 SET_TO_SERVER_TIME = 1,
297 SET_TO_CLIENT_TIME = 2
300 union set_mode3 switch (bool set_it) {
307 union set_uid3 switch (bool set_it) {
314 union set_gid3 switch (bool set_it) {
321 union set_size3 switch (bool set_it) {
328 union set_atime switch (time_how set_it) {
329 case SET_TO_CLIENT_TIME:
335 union set_mtime switch (time_how set_it) {
336 case SET_TO_CLIENT_TIME:
358 typedef opaque createverf3[NFS3_CREATEVERFSIZE];
360 union createhow3 switch (createmode3 mode) {
362 sattr3 obj_attributes;
364 sattr3 g_obj_attributes;
374 union post_op_fh3 switch (bool handle_follows) {
381 struct CREATE3resok {
383 post_op_attr obj_attributes;
387 struct CREATE3resfail {
391 union CREATE3res switch (nfsstat3 status) {
395 CREATE3resfail resfail;
402 struct REMOVE3resok {
406 struct REMOVE3resfail {
410 union REMOVE3res switch (nfsstat3 status) {
414 REMOVE3resfail resfail;
424 post_op_attr file_attributes;
430 struct READ3resfail {
431 post_op_attr file_attributes;
434 union READ3res switch (nfsstat3 status) {
438 READ3resfail resfail;
442 const FSF3_LINK = 0x0001;
443 const FSF3_SYMLINK = 0x0002;
444 const FSF3_HOMOGENEOUS = 0x0008;
445 const FSF3_CANSETTIME = 0x0010;
451 struct FSINFO3resok {
452 post_op_attr obj_attributes;
462 unsigned int properties;
465 struct FSINFO3resfail {
466 post_op_attr obj_attributes;
469 union FSINFO3res switch (nfsstat3 status) {
473 FSINFO3resfail resfail;
481 struct FSSTAT3resok {
482 post_op_attr obj_attributes;
489 unsigned int invarsec;
492 struct FSSTAT3resfail {
493 post_op_attr obj_attributes;
496 union FSSTAT3res switch (nfsstat3 status) {
500 FSSTAT3resfail resfail;
503 struct PATHCONF3args {
507 struct PATHCONF3resok {
508 post_op_attr obj_attributes;
509 unsigned int linkmax;
510 unsigned int name_max;
512 bool chown_restricted;
513 bool case_insensitive;
514 bool case_preserving;
517 struct PATHCONF3resfail {
518 post_op_attr obj_attributes;
521 union PATHCONF3res switch (nfsstat3 status) {
523 PATHCONF3resok resok;
525 PATHCONF3resfail resfail;
528 typedef string nfspath3<>;
530 struct symlinkdata3 {
531 sattr3 symlink_attributes;
532 nfspath3 symlink_data;
535 struct SYMLINK3args {
537 symlinkdata3 symlink;
540 struct SYMLINK3resok {
542 post_op_attr obj_attributes;
546 struct SYMLINK3resfail {
550 union SYMLINK3res switch (nfsstat3 status) {
554 SYMLINK3resfail resfail;
558 struct READLINK3args {
562 struct READLINK3resok {
563 post_op_attr symlink_attributes;
567 struct READLINK3resfail {
568 post_op_attr symlink_attributes;
571 union READLINK3res switch (nfsstat3 status) {
573 READLINK3resok resok;
575 READLINK3resfail resfail;
580 sattr3 dev_attributes;
584 union mknoddata3 switch (ftype3 type) {
586 devicedata3 chr_device;
588 devicedata3 blk_device;
590 sattr3 sock_attributes;
592 sattr3 pipe_attributes;
604 post_op_attr obj_attributes;
608 struct MKNOD3resfail {
612 union MKNOD3res switch (nfsstat3 status) {
616 MKNOD3resfail resfail;
627 post_op_attr obj_attributes;
631 struct MKDIR3resfail {
635 union MKDIR3res switch (nfsstat3 status) {
639 MKDIR3resfail resfail;
650 struct RMDIR3resfail {
654 union RMDIR3res switch (nfsstat3 status) {
658 RMDIR3resfail resfail;
666 struct RENAME3resok {
667 wcc_data fromdir_wcc;
671 struct RENAME3resfail {
672 wcc_data fromdir_wcc;
676 union RENAME3res switch (nfsstat3 status) {
680 RENAME3resfail resfail;
683 struct READDIRPLUS3args {
686 cookieverf3 cookieverf;
695 post_op_attr name_attributes;
696 post_op_fh3 name_handle;
697 entryplus3 *nextentry;
700 struct dirlistplus3 {
705 struct READDIRPLUS3resok {
706 post_op_attr dir_attributes;
707 cookieverf3 cookieverf;
712 struct READDIRPLUS3resfail {
713 post_op_attr dir_attributes;
716 union READDIRPLUS3res switch (nfsstat3 status) {
718 READDIRPLUS3resok resok;
720 READDIRPLUS3resfail resfail;
723 struct READDIR3args {
726 cookieverf3 cookieverf;
743 struct READDIR3resok {
744 post_op_attr dir_attributes;
745 cookieverf3 cookieverf;
749 struct READDIR3resfail {
750 post_op_attr dir_attributes;
753 union READDIR3res switch (nfsstat3 status) {
757 READDIR3resfail resfail;
766 post_op_attr file_attributes;
767 wcc_data linkdir_wcc;
770 struct LINK3resfail {
771 post_op_attr file_attributes;
772 wcc_data linkdir_wcc;
775 union LINK3res switch (nfsstat3 status) {
779 LINK3resfail resfail;
782 union sattrguard3 switch (bool check) {
789 struct SETATTR3args {
791 sattr3 new_attributes;
795 struct SETATTR3resok {
799 struct SETATTR3resfail {
803 union SETATTR3res switch (nfsstat3 status) {
807 SETATTR3resfail resfail;
812 * We share many definitions from v3
815 typedef opaque fhandle2[FHSIZE2];
833 unsigned int blocksize;
852 const MAXNAMLEN2 = 255;
853 typedef string filename2<MAXNAMLEN2>;
855 const MAXPATHLEN2 = 1024;
856 typedef string path2<MAXPATHLEN2>;
858 const NFSMAXDATA2 = 8192;
859 typedef opaque nfsdata2<NFSMAXDATA2>;
861 const NFSCOOKIESIZE2 = 4;
862 typedef opaque nfscookie2[NFSCOOKIESIZE2];
876 struct GETATTR2args {
880 struct GETATTR2resok {
884 union GETATTR2res switch (nfsstat3 status) {
891 struct SETATTR2args {
896 struct SETATTR2resok {
900 union SETATTR2res switch (nfsstat3 status) {
911 struct LOOKUP2resok {
916 union LOOKUP2res switch (nfsstat3 status) {
923 struct READLINK2args {
927 struct READLINK2resok {
931 union READLINK2res switch (nfsstat3 status) {
933 READLINK2resok resok;
942 unsigned int totalcount;
950 union READ2res switch (nfsstat3 status) {
959 unsigned int beginoffset;
961 unsigned int totalcount;
969 union WRITE2res switch (nfsstat3 status) {
981 struct CREATE2resok {
986 union CREATE2res switch (nfsstat3 status) {
1001 struct RENAME2args {
1019 struct SYMLINK2args {
1025 struct SYMLINK2res {
1034 struct MKDIR2resok {
1039 union MKDIR2res switch (nfsstat3 status) {
1054 struct READDIR2args {
1060 struct READDIR2resok {
1065 union READDIR2res switch (nfsstat3 status) {
1067 READDIR2resok resok;
1072 struct STATFS2args {
1076 struct STATFS2resok {
1079 unsigned int blocks;
1081 unsigned int bavail;
1084 union STATFS2res switch (nfsstat3 status) {
1091 program NFS_PROGRAM {
1094 NFS2_NULL(void) = 0;
1097 NFS2_GETATTR(GETATTR2args) = 1;
1100 NFS2_SETATTR(SETATTR2args) = 2;
1103 NFS2_LOOKUP(LOOKUP2args) = 4;
1106 NFS2_READLINK(READLINK2args) = 5;
1109 NFS2_READ(READ2args) = 6;
1112 NFS2_WRITE(WRITE2args) = 8;
1115 NFS2_CREATE(CREATE2args) = 9;
1118 NFS2_REMOVE(REMOVE2args) = 10;
1121 NFS2_RENAME(RENAME2args) = 11;
1124 NFS2_LINK(LINK2args) = 12;
1127 NFS2_SYMLINK(SYMLINK2args) = 13;
1130 NFS2_MKDIR(MKDIR2args) = 14;
1133 NFS2_RMDIR(RMDIR2args) = 15;
1136 NFS2_READDIR(READDIR2args) = 16;
1139 NFS2_STATFS(STATFS2args) = 17;
1144 NFS3_NULL(void) = 0;
1147 NFS3_GETATTR(GETATTR3args) = 1;
1150 NFS3_SETATTR(SETATTR3args) = 2;
1153 NFS3_LOOKUP(LOOKUP3args) = 3;
1156 NFS3_ACCESS(ACCESS3args) = 4;
1159 NFS3_READLINK(READLINK3args) = 5;
1162 NFS3_READ(READ3args) = 6;
1165 NFS3_WRITE(WRITE3args) = 7;
1168 NFS3_CREATE(CREATE3args) = 8;
1171 NFS3_MKDIR(MKDIR3args) = 9;
1174 NFS3_SYMLINK(SYMLINK3args) = 10;
1177 NFS3_MKNOD(MKNOD3args) = 11;
1180 NFS3_REMOVE(REMOVE3args) = 12;
1183 NFS3_RMDIR(RMDIR3args) = 13;
1186 NFS3_RENAME(RENAME3args) = 14;
1189 NFS3_LINK(LINK3args) = 15;
1192 NFS3_READDIR(READDIR3args) = 16;
1195 NFS3_READDIRPLUS(READDIRPLUS3args) = 17;
1198 NFS3_FSSTAT(FSSTAT3args) = 18;
1201 NFS3_FSINFO(FSINFO3args) = 19;
1204 NFS3_PATHCONF(PATHCONF3args) = 20;
1207 NFS3_COMMIT(COMMIT3args) = 21;
1213 /* NFS ACL definitions based on wireshark souces and network traces */
1214 /* NFSACL interface. Uses same port/process as NFS */
1217 NFSACL_TYPE_USER_OBJ = 0x0001,
1218 NFSACL_TYPE_USER = 0x0002,
1219 NFSACL_TYPE_GROUP_OBJ = 0x0004,
1220 NFSACL_TYPE_GROUP = 0x0008,
1221 NFSACL_TYPE_CLASS_OBJ = 0x0010,
1222 NFSACL_TYPE_CLASS = 0x0020,
1223 NFSACL_TYPE_DEFAULT = 0x1000,
1224 NFSACL_TYPE_DEFAULT_USER_OBJ = 0x1001,
1225 NFSACL_TYPE_DEFAULT_USER = 0x1002,
1226 NFSACL_TYPE_DEFAULT_GROUP_OBJ = 0x1004,
1227 NFSACL_TYPE_DEFAULT_GROUP = 0x1008,
1228 NFSACL_TYPE_DEFAULT_CLASS_OBJ = 0x1010,
1229 NFSACL_TYPE_DEFAULT_OTHER_OBJ = 0x1020
1232 const NFSACL_PERM_READ = 0x04;
1233 const NFSACL_PERM_WRITE = 0x02;
1234 const NFSACL_PERM_EXEC = 0x01;
1237 enum nfsacl_type type;
1242 const NFSACL_MASK_ACL_ENTRY = 0x0001;
1243 const NFSACL_MASK_ACL_COUNT = 0x0002;
1244 const NFSACL_MASK_ACL_DEFAULT_ENTRY = 0x0004;
1245 const NFSACL_MASK_ACL_DEFAULT_COUNT = 0x0008;
1247 struct GETACL3args {
1252 struct GETACL3resok {
1255 unsigned int ace_count;
1256 struct nfsacl_ace ace<>;
1257 unsigned int default_ace_count;
1258 struct nfsacl_ace default_ace<>;
1261 union GETACL3res switch (nfsstat3 status) {
1268 struct SETACL3args {
1271 unsigned int ace_count;
1272 struct nfsacl_ace ace<>;
1273 unsigned int default_ace_count;
1274 struct nfsacl_ace default_ace<>;
1277 struct SETACL3resok {
1281 union SETACL3res switch (nfsstat3 status) {
1288 program NFSACL_PROGRAM {
1291 NFSACL3_NULL(void) = 0;
1294 NFSACL3_GETACL(GETACL3args) = 1;
1297 NFSACL3_SETACL(SETACL3args) = 2;