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 typedef u_quad_t cookie3;
43 opaque data<NFS3_FHSIZE>;
46 typedef string filename3<>;
63 typedef unsigned int mode3;
65 typedef unsigned int uid3;
67 typedef unsigned int gid3;
69 typedef u_quad_t size3;
71 typedef u_quad_t fileid3;
74 unsigned int specdata1;
75 unsigned int specdata2;
80 unsigned int nseconds;
99 union post_op_attr switch (bool attributes_follow) {
124 NFS3ERR_NAMETOOLONG = 63,
125 NFS3ERR_NOTEMPTY = 66,
129 NFS3ERR_BADHANDLE = 10001,
130 NFS3ERR_NOT_SYNC = 10002,
131 NFS3ERR_BAD_COOKIE = 10003,
132 NFS3ERR_NOTSUPP = 10004,
133 NFS3ERR_TOOSMALL = 10005,
134 NFS3ERR_SERVERFAULT = 10006,
135 NFS3ERR_BADTYPE = 10007,
136 NFS3ERR_JUKEBOX = 10008
145 typedef u_quad_t offset3;
147 typedef unsigned int count3;
155 union pre_op_attr switch (bool attributes_follow) {
175 typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
180 stable_how committed;
184 struct WRITE3resfail {
188 union WRITE3res switch (nfsstat3 status) {
192 WRITE3resfail resfail;
199 struct LOOKUP3resok {
201 post_op_attr obj_attributes;
202 post_op_attr dir_attributes;
205 struct LOOKUP3resfail {
206 post_op_attr dir_attributes;
211 union LOOKUP3res switch (nfsstat3 status) {
215 LOOKUP3resfail resfail;
224 struct COMMIT3resok {
229 struct COMMIT3resfail {
233 union COMMIT3res switch (nfsstat3 status) {
237 COMMIT3resfail resfail;
240 const ACCESS3_READ = 0x0001;
241 const ACCESS3_LOOKUP = 0x0002;
242 const ACCESS3_MODIFY = 0x0004;
243 const ACCESS3_EXTEND = 0x0008;
244 const ACCESS3_DELETE = 0x0010;
245 const ACCESS3_EXECUTE = 0x0020;
252 struct ACCESS3resok {
253 post_op_attr obj_attributes;
257 struct ACCESS3resfail {
258 post_op_attr obj_attributes;
261 union ACCESS3res switch (nfsstat3 status) {
265 ACCESS3resfail resfail;
268 struct GETATTR3args {
272 struct GETATTR3resok {
273 fattr3 obj_attributes;
276 union GETATTR3res switch (nfsstat3 status) {
287 SET_TO_SERVER_TIME = 1,
288 SET_TO_CLIENT_TIME = 2
291 union set_mode3 switch (bool set_it) {
298 union set_uid3 switch (bool set_it) {
305 union set_gid3 switch (bool set_it) {
312 union set_size3 switch (bool set_it) {
319 union set_atime switch (time_how set_it) {
320 case SET_TO_CLIENT_TIME:
326 union set_mtime switch (time_how set_it) {
327 case SET_TO_CLIENT_TIME:
349 typedef opaque createverf3[NFS3_CREATEVERFSIZE];
351 union createhow3 switch (createmode3 mode) {
353 sattr3 obj_attributes;
355 sattr3 g_obj_attributes;
365 union post_op_fh3 switch (bool handle_follows) {
372 struct CREATE3resok {
374 post_op_attr obj_attributes;
378 struct CREATE3resfail {
382 union CREATE3res switch (nfsstat3 status) {
386 CREATE3resfail resfail;
393 struct REMOVE3resok {
397 struct REMOVE3resfail {
401 union REMOVE3res switch (nfsstat3 status) {
405 REMOVE3resfail resfail;
415 post_op_attr file_attributes;
421 struct READ3resfail {
422 post_op_attr file_attributes;
425 union READ3res switch (nfsstat3 status) {
429 READ3resfail resfail;
433 const FSF3_LINK = 0x0001;
434 const FSF3_SYMLINK = 0x0002;
435 const FSF3_HOMOGENEOUS = 0x0008;
436 const FSF3_CANSETTIME = 0x0010;
442 struct FSINFO3resok {
443 post_op_attr obj_attributes;
453 unsigned int properties;
456 struct FSINFO3resfail {
457 post_op_attr obj_attributes;
460 union FSINFO3res switch (nfsstat3 status) {
464 FSINFO3resfail resfail;
472 struct FSSTAT3resok {
473 post_op_attr obj_attributes;
480 unsigned int invarsec;
483 struct FSSTAT3resfail {
484 post_op_attr obj_attributes;
487 union FSSTAT3res switch (nfsstat3 status) {
491 FSSTAT3resfail resfail;
494 struct PATHCONF3args {
498 struct PATHCONF3resok {
499 post_op_attr obj_attributes;
500 unsigned int linkmax;
501 unsigned int name_max;
503 bool chown_restricted;
504 bool case_insensitive;
505 bool case_preserving;
508 struct PATHCONF3resfail {
509 post_op_attr obj_attributes;
512 union PATHCONF3res switch (nfsstat3 status) {
514 PATHCONF3resok resok;
516 PATHCONF3resfail resfail;
519 typedef string nfspath3<>;
521 struct symlinkdata3 {
522 sattr3 symlink_attributes;
523 nfspath3 symlink_data;
526 struct SYMLINK3args {
528 symlinkdata3 symlink;
531 struct SYMLINK3resok {
533 post_op_attr obj_attributes;
537 struct SYMLINK3resfail {
541 union SYMLINK3res switch (nfsstat3 status) {
545 SYMLINK3resfail resfail;
549 struct READLINK3args {
553 struct READLINK3resok {
554 post_op_attr symlink_attributes;
558 struct READLINK3resfail {
559 post_op_attr symlink_attributes;
562 union READLINK3res switch (nfsstat3 status) {
564 READLINK3resok resok;
566 READLINK3resfail resfail;
571 sattr3 dev_attributes;
575 union mknoddata3 switch (ftype3 type) {
577 devicedata3 chr_device;
579 devicedata3 blk_device;
581 sattr3 sock_attributes;
583 sattr3 pipe_attributes;
595 post_op_attr obj_attributes;
599 struct MKNOD3resfail {
603 union MKNOD3res switch (nfsstat3 status) {
607 MKNOD3resfail resfail;
618 post_op_attr obj_attributes;
622 struct MKDIR3resfail {
626 union MKDIR3res switch (nfsstat3 status) {
630 MKDIR3resfail resfail;
641 struct RMDIR3resfail {
645 union RMDIR3res switch (nfsstat3 status) {
649 RMDIR3resfail resfail;
657 struct RENAME3resok {
658 wcc_data fromdir_wcc;
662 struct RENAME3resfail {
663 wcc_data fromdir_wcc;
667 union RENAME3res switch (nfsstat3 status) {
671 RENAME3resfail resfail;
674 struct READDIRPLUS3args {
677 cookieverf3 cookieverf;
686 post_op_attr name_attributes;
687 post_op_fh3 name_handle;
688 entryplus3 *nextentry;
691 struct dirlistplus3 {
696 struct READDIRPLUS3resok {
697 post_op_attr dir_attributes;
698 cookieverf3 cookieverf;
703 struct READDIRPLUS3resfail {
704 post_op_attr dir_attributes;
707 union READDIRPLUS3res switch (nfsstat3 status) {
709 READDIRPLUS3resok resok;
711 READDIRPLUS3resfail resfail;
714 struct READDIR3args {
717 cookieverf3 cookieverf;
734 struct READDIR3resok {
735 post_op_attr dir_attributes;
736 cookieverf3 cookieverf;
740 struct READDIR3resfail {
741 post_op_attr dir_attributes;
744 union READDIR3res switch (nfsstat3 status) {
748 READDIR3resfail resfail;
757 post_op_attr file_attributes;
758 wcc_data linkdir_wcc;
761 struct LINK3resfail {
762 post_op_attr file_attributes;
763 wcc_data linkdir_wcc;
766 union LINK3res switch (nfsstat3 status) {
770 LINK3resfail resfail;
773 union sattrguard3 switch (bool check) {
780 struct SETATTR3args {
782 sattr3 new_attributes;
786 struct SETATTR3resok {
790 struct SETATTR3resfail {
794 union SETATTR3res switch (nfsstat3 status) {
798 SETATTR3resfail resfail;
803 * We share many definitions from v3
806 typedef opaque fhandle2[FHSIZE2];
824 unsigned int blocksize;
843 const MAXNAMLEN2 = 255;
844 typedef string filename2<MAXNAMLEN2>;
846 const MAXPATHLEN2 = 1024;
847 typedef string path2<MAXPATHLEN2>;
849 const NFSMAXDATA2 = 8192;
850 typedef opaque nfsdata2<NFSMAXDATA2>;
852 const NFSCOOKIESIZE2 = 4;
853 typedef opaque nfscookie2[NFSCOOKIESIZE2];
867 struct GETATTR2args {
871 struct GETATTR2resok {
875 union GETATTR2res switch (nfsstat3 status) {
882 struct SETATTR2args {
887 struct SETATTR2resok {
891 union SETATTR2res switch (nfsstat3 status) {
902 struct LOOKUP2resok {
907 union LOOKUP2res switch (nfsstat3 status) {
914 struct READLINK2args {
918 struct READLINK2resok {
922 union READLINK2res switch (nfsstat3 status) {
924 READLINK2resok resok;
933 unsigned int totalcount;
941 union READ2res switch (nfsstat3 status) {
950 unsigned int beginoffset;
952 unsigned int totalcount;
960 union WRITE2res switch (nfsstat3 status) {
972 struct CREATE2resok {
977 union CREATE2res switch (nfsstat3 status) {
1010 struct SYMLINK2args {
1016 struct SYMLINK2res {
1025 struct MKDIR2resok {
1030 union MKDIR2res switch (nfsstat3 status) {
1045 struct READDIR2args {
1051 struct READDIR2resok {
1056 union READDIR2res switch (nfsstat3 status) {
1058 READDIR2resok resok;
1063 struct STATFS2args {
1067 struct STATFS2resok {
1070 unsigned int blocks;
1072 unsigned int bavail;
1075 union STATFS2res switch (nfsstat3 status) {
1082 program NFS_PROGRAM {
1085 NFS2_NULL(void) = 0;
1088 NFS2_GETATTR(GETATTR2args) = 1;
1091 NFS2_SETATTR(SETATTR2args) = 2;
1094 NFS2_LOOKUP(LOOKUP2args) = 4;
1097 NFS2_READLINK(READLINK2args) = 5;
1100 NFS2_READ(READ2args) = 6;
1103 NFS2_WRITE(WRITE2args) = 8;
1106 NFS2_CREATE(CREATE2args) = 9;
1109 NFS2_REMOVE(REMOVE2args) = 10;
1112 NFS2_RENAME(RENAME2args) = 11;
1115 NFS2_LINK(LINK2args) = 12;
1118 NFS2_SYMLINK(SYMLINK2args) = 13;
1121 NFS2_MKDIR(MKDIR2args) = 14;
1124 NFS2_RMDIR(RMDIR2args) = 15;
1127 NFS2_READDIR(READDIR2args) = 16;
1130 NFS2_STATFS(STATFS2args) = 17;
1135 NFS3_NULL(void) = 0;
1138 NFS3_GETATTR(GETATTR3args) = 1;
1141 NFS3_SETATTR(SETATTR3args) = 2;
1144 NFS3_LOOKUP(LOOKUP3args) = 3;
1147 NFS3_ACCESS(ACCESS3args) = 4;
1150 NFS3_READLINK(READLINK3args) = 5;
1153 NFS3_READ(READ3args) = 6;
1156 NFS3_WRITE(WRITE3args) = 7;
1159 NFS3_CREATE(CREATE3args) = 8;
1162 NFS3_MKDIR(MKDIR3args) = 9;
1165 NFS3_SYMLINK(SYMLINK3args) = 10;
1168 NFS3_MKNOD(MKNOD3args) = 11;
1171 NFS3_REMOVE(REMOVE3args) = 12;
1174 NFS3_RMDIR(RMDIR3args) = 13;
1177 NFS3_RENAME(RENAME3args) = 14;
1180 NFS3_LINK(LINK3args) = 15;
1183 NFS3_READDIR(READDIR3args) = 16;
1186 NFS3_READDIRPLUS(READDIRPLUS3args) = 17;
1189 NFS3_FSSTAT(FSSTAT3args) = 18;
1192 NFS3_FSINFO(FSINFO3args) = 19;
1195 NFS3_PATHCONF(PATHCONF3args) = 20;
1198 NFS3_COMMIT(COMMIT3args) = 21;
1204 /* NFS ACL definitions based on wireshark souces and network traces */
1205 /* NFSACL interface. Uses same port/process as NFS */
1208 NFSACL_TYPE_USER_OBJ = 0x0001,
1209 NFSACL_TYPE_USER = 0x0002,
1210 NFSACL_TYPE_GROUP_OBJ = 0x0004,
1211 NFSACL_TYPE_GROUP = 0x0008,
1212 NFSACL_TYPE_CLASS_OBJ = 0x0010,
1213 NFSACL_TYPE_CLASS = 0x0020,
1214 NFSACL_TYPE_DEFAULT = 0x1000,
1215 NFSACL_TYPE_DEFAULT_USER_OBJ = 0x1001,
1216 NFSACL_TYPE_DEFAULT_USER = 0x1002,
1217 NFSACL_TYPE_DEFAULT_GROUP_OBJ = 0x1004,
1218 NFSACL_TYPE_DEFAULT_GROUP = 0x1008,
1219 NFSACL_TYPE_DEFAULT_CLASS_OBJ = 0x1010,
1220 NFSACL_TYPE_DEFAULT_OTHER_OBJ = 0x1020
1223 const NFSACL_PERM_READ = 0x04;
1224 const NFSACL_PERM_WRITE = 0x02;
1225 const NFSACL_PERM_EXEC = 0x01;
1228 enum nfsacl_type type;
1233 const NFSACL_MASK_ACL_ENTRY = 0x0001;
1234 const NFSACL_MASK_ACL_COUNT = 0x0002;
1235 const NFSACL_MASK_ACL_DEFAULT_ENTRY = 0x0004;
1236 const NFSACL_MASK_ACL_DEFAULT_COUNT = 0x0008;
1238 struct GETACL3args {
1243 struct GETACL3resok {
1246 unsigned int ace_count;
1247 struct nfsacl_ace ace<>;
1248 unsigned int default_ace_count;
1249 struct nfsacl_ace default_ace<>;
1252 union GETACL3res switch (nfsstat3 status) {
1259 struct SETACL3args {
1262 unsigned int ace_count;
1263 struct nfsacl_ace ace<>;
1264 unsigned int default_ace_count;
1265 struct nfsacl_ace default_ace<>;
1268 struct SETACL3resok {
1272 union SETACL3res switch (nfsstat3 status) {
1279 program NFSACL_PROGRAM {
1282 NFSACL3_NULL(void) = 0;
1285 NFSACL3_GETACL(GETACL3args) = 1;
1288 NFSACL3_SETACL(SETACL3args) = 2;