| 1 | /* |
| 2 | Copyright (c) 2014, Ronnie Sahlberg |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are met: |
| 7 | |
| 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. |
| 13 | |
| 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. |
| 24 | |
| 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. |
| 28 | */ |
| 29 | |
| 30 | /* |
| 31 | * NFS v3 Definitions |
| 32 | */ |
| 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; |
| 37 | |
| 38 | typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; |
| 39 | |
| 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*/ |
| 46 | |
| 47 | typedef U_INT64_PLATTFORM_TYPE uint64; |
| 48 | |
| 49 | typedef uint64 cookie3; |
| 50 | |
| 51 | struct nfs_fh3 { |
| 52 | opaque data<NFS3_FHSIZE>; |
| 53 | }; |
| 54 | |
| 55 | typedef string filename3<>; |
| 56 | |
| 57 | struct diropargs3 { |
| 58 | nfs_fh3 dir; |
| 59 | filename3 name; |
| 60 | }; |
| 61 | |
| 62 | enum ftype3 { |
| 63 | NF3REG = 1, |
| 64 | NF3DIR = 2, |
| 65 | NF3BLK = 3, |
| 66 | NF3CHR = 4, |
| 67 | NF3LNK = 5, |
| 68 | NF3SOCK = 6, |
| 69 | NF3FIFO = 7 |
| 70 | }; |
| 71 | |
| 72 | typedef unsigned int mode3; |
| 73 | |
| 74 | typedef unsigned int uid3; |
| 75 | |
| 76 | typedef unsigned int gid3; |
| 77 | |
| 78 | typedef uint64 size3; |
| 79 | |
| 80 | typedef uint64 fileid3; |
| 81 | |
| 82 | struct specdata3 { |
| 83 | unsigned int specdata1; |
| 84 | unsigned int specdata2; |
| 85 | }; |
| 86 | |
| 87 | struct nfstime3 { |
| 88 | unsigned int seconds; |
| 89 | unsigned int nseconds; |
| 90 | }; |
| 91 | |
| 92 | struct fattr3 { |
| 93 | ftype3 type; |
| 94 | mode3 mode; |
| 95 | unsigned int nlink; |
| 96 | uid3 uid; |
| 97 | gid3 gid; |
| 98 | size3 size; |
| 99 | size3 used; |
| 100 | specdata3 rdev; |
| 101 | uint64 fsid; |
| 102 | fileid3 fileid; |
| 103 | nfstime3 atime; |
| 104 | nfstime3 mtime; |
| 105 | nfstime3 ctime; |
| 106 | }; |
| 107 | |
| 108 | union post_op_attr switch (bool attributes_follow) { |
| 109 | case TRUE: |
| 110 | fattr3 attributes; |
| 111 | case FALSE: |
| 112 | void; |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | enum nfsstat3 { |
| 117 | NFS3_OK = 0, |
| 118 | NFS3ERR_PERM = 1, |
| 119 | NFS3ERR_NOENT = 2, |
| 120 | NFS3ERR_IO = 5, |
| 121 | NFS3ERR_NXIO = 6, |
| 122 | NFS3ERR_ACCES = 13, |
| 123 | NFS3ERR_EXIST = 17, |
| 124 | NFS3ERR_XDEV = 18, |
| 125 | NFS3ERR_NODEV = 19, |
| 126 | NFS3ERR_NOTDIR = 20, |
| 127 | NFS3ERR_ISDIR = 21, |
| 128 | NFS3ERR_INVAL = 22, |
| 129 | NFS3ERR_FBIG = 27, |
| 130 | NFS3ERR_NOSPC = 28, |
| 131 | NFS3ERR_ROFS = 30, |
| 132 | NFS3ERR_MLINK = 31, |
| 133 | NFS3ERR_NAMETOOLONG = 63, |
| 134 | NFS3ERR_NOTEMPTY = 66, |
| 135 | NFS3ERR_DQUOT = 69, |
| 136 | NFS3ERR_STALE = 70, |
| 137 | NFS3ERR_REMOTE = 71, |
| 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 |
| 146 | }; |
| 147 | |
| 148 | enum stable_how { |
| 149 | UNSTABLE = 0, |
| 150 | DATA_SYNC = 1, |
| 151 | FILE_SYNC = 2 |
| 152 | }; |
| 153 | |
| 154 | typedef uint64 offset3; |
| 155 | |
| 156 | typedef unsigned int count3; |
| 157 | |
| 158 | struct wcc_attr { |
| 159 | size3 size; |
| 160 | nfstime3 mtime; |
| 161 | nfstime3 ctime; |
| 162 | }; |
| 163 | |
| 164 | union pre_op_attr switch (bool attributes_follow) { |
| 165 | case TRUE: |
| 166 | wcc_attr attributes; |
| 167 | case FALSE: |
| 168 | void; |
| 169 | }; |
| 170 | |
| 171 | struct wcc_data { |
| 172 | pre_op_attr before; |
| 173 | post_op_attr after; |
| 174 | }; |
| 175 | |
| 176 | struct WRITE3args { |
| 177 | nfs_fh3 file; |
| 178 | offset3 offset; |
| 179 | count3 count; |
| 180 | stable_how stable; |
| 181 | opaque data<>; |
| 182 | }; |
| 183 | |
| 184 | typedef opaque writeverf3[NFS3_WRITEVERFSIZE]; |
| 185 | |
| 186 | struct WRITE3resok { |
| 187 | wcc_data file_wcc; |
| 188 | count3 count; |
| 189 | stable_how committed; |
| 190 | writeverf3 verf; |
| 191 | }; |
| 192 | |
| 193 | struct WRITE3resfail { |
| 194 | wcc_data file_wcc; |
| 195 | }; |
| 196 | |
| 197 | union WRITE3res switch (nfsstat3 status) { |
| 198 | case NFS3_OK: |
| 199 | WRITE3resok resok; |
| 200 | default: |
| 201 | WRITE3resfail resfail; |
| 202 | }; |
| 203 | |
| 204 | struct LOOKUP3args { |
| 205 | diropargs3 what; |
| 206 | }; |
| 207 | |
| 208 | struct LOOKUP3resok { |
| 209 | nfs_fh3 object; |
| 210 | post_op_attr obj_attributes; |
| 211 | post_op_attr dir_attributes; |
| 212 | }; |
| 213 | |
| 214 | struct LOOKUP3resfail { |
| 215 | post_op_attr dir_attributes; |
| 216 | }; |
| 217 | |
| 218 | |
| 219 | |
| 220 | union LOOKUP3res switch (nfsstat3 status) { |
| 221 | case NFS3_OK: |
| 222 | LOOKUP3resok resok; |
| 223 | default: |
| 224 | LOOKUP3resfail resfail; |
| 225 | }; |
| 226 | |
| 227 | struct COMMIT3args { |
| 228 | nfs_fh3 file; |
| 229 | offset3 offset; |
| 230 | count3 count; |
| 231 | }; |
| 232 | |
| 233 | struct COMMIT3resok { |
| 234 | wcc_data file_wcc; |
| 235 | writeverf3 verf; |
| 236 | }; |
| 237 | |
| 238 | struct COMMIT3resfail { |
| 239 | wcc_data file_wcc; |
| 240 | }; |
| 241 | |
| 242 | union COMMIT3res switch (nfsstat3 status) { |
| 243 | case NFS3_OK: |
| 244 | COMMIT3resok resok; |
| 245 | default: |
| 246 | COMMIT3resfail resfail; |
| 247 | }; |
| 248 | |
| 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; |
| 255 | |
| 256 | struct ACCESS3args { |
| 257 | nfs_fh3 object; |
| 258 | unsigned int access; |
| 259 | }; |
| 260 | |
| 261 | struct ACCESS3resok { |
| 262 | post_op_attr obj_attributes; |
| 263 | unsigned int access; |
| 264 | }; |
| 265 | |
| 266 | struct ACCESS3resfail { |
| 267 | post_op_attr obj_attributes; |
| 268 | }; |
| 269 | |
| 270 | union ACCESS3res switch (nfsstat3 status) { |
| 271 | case NFS3_OK: |
| 272 | ACCESS3resok resok; |
| 273 | default: |
| 274 | ACCESS3resfail resfail; |
| 275 | }; |
| 276 | |
| 277 | struct GETATTR3args { |
| 278 | nfs_fh3 object; |
| 279 | }; |
| 280 | |
| 281 | struct GETATTR3resok { |
| 282 | fattr3 obj_attributes; |
| 283 | }; |
| 284 | |
| 285 | union GETATTR3res switch (nfsstat3 status) { |
| 286 | case NFS3_OK: |
| 287 | GETATTR3resok resok; |
| 288 | default: |
| 289 | void; |
| 290 | }; |
| 291 | |
| 292 | |
| 293 | |
| 294 | enum time_how { |
| 295 | DONT_CHANGE = 0, |
| 296 | SET_TO_SERVER_TIME = 1, |
| 297 | SET_TO_CLIENT_TIME = 2 |
| 298 | }; |
| 299 | |
| 300 | union set_mode3 switch (bool set_it) { |
| 301 | case TRUE: |
| 302 | mode3 mode; |
| 303 | default: |
| 304 | void; |
| 305 | }; |
| 306 | |
| 307 | union set_uid3 switch (bool set_it) { |
| 308 | case TRUE: |
| 309 | uid3 uid; |
| 310 | default: |
| 311 | void; |
| 312 | }; |
| 313 | |
| 314 | union set_gid3 switch (bool set_it) { |
| 315 | case TRUE: |
| 316 | gid3 gid; |
| 317 | default: |
| 318 | void; |
| 319 | }; |
| 320 | |
| 321 | union set_size3 switch (bool set_it) { |
| 322 | case TRUE: |
| 323 | size3 size; |
| 324 | default: |
| 325 | void; |
| 326 | }; |
| 327 | |
| 328 | union set_atime switch (time_how set_it) { |
| 329 | case SET_TO_CLIENT_TIME: |
| 330 | nfstime3 atime; |
| 331 | default: |
| 332 | void; |
| 333 | }; |
| 334 | |
| 335 | union set_mtime switch (time_how set_it) { |
| 336 | case SET_TO_CLIENT_TIME: |
| 337 | nfstime3 mtime; |
| 338 | default: |
| 339 | void; |
| 340 | }; |
| 341 | |
| 342 | struct sattr3 { |
| 343 | set_mode3 mode; |
| 344 | set_uid3 uid; |
| 345 | set_gid3 gid; |
| 346 | set_size3 size; |
| 347 | set_atime atime; |
| 348 | set_mtime mtime; |
| 349 | }; |
| 350 | |
| 351 | enum createmode3 { |
| 352 | UNCHECKED = 0, |
| 353 | GUARDED = 1, |
| 354 | EXCLUSIVE = 2 |
| 355 | }; |
| 356 | |
| 357 | |
| 358 | typedef opaque createverf3[NFS3_CREATEVERFSIZE]; |
| 359 | |
| 360 | union createhow3 switch (createmode3 mode) { |
| 361 | case UNCHECKED: |
| 362 | sattr3 obj_attributes; |
| 363 | case GUARDED: |
| 364 | sattr3 g_obj_attributes; |
| 365 | case EXCLUSIVE: |
| 366 | createverf3 verf; |
| 367 | }; |
| 368 | |
| 369 | struct CREATE3args { |
| 370 | diropargs3 where; |
| 371 | createhow3 how; |
| 372 | }; |
| 373 | |
| 374 | union post_op_fh3 switch (bool handle_follows) { |
| 375 | case TRUE: |
| 376 | nfs_fh3 handle; |
| 377 | case FALSE: |
| 378 | void; |
| 379 | }; |
| 380 | |
| 381 | struct CREATE3resok { |
| 382 | post_op_fh3 obj; |
| 383 | post_op_attr obj_attributes; |
| 384 | wcc_data dir_wcc; |
| 385 | }; |
| 386 | |
| 387 | struct CREATE3resfail { |
| 388 | wcc_data dir_wcc; |
| 389 | }; |
| 390 | |
| 391 | union CREATE3res switch (nfsstat3 status) { |
| 392 | case NFS3_OK: |
| 393 | CREATE3resok resok; |
| 394 | default: |
| 395 | CREATE3resfail resfail; |
| 396 | }; |
| 397 | |
| 398 | struct REMOVE3args { |
| 399 | diropargs3 object; |
| 400 | }; |
| 401 | |
| 402 | struct REMOVE3resok { |
| 403 | wcc_data dir_wcc; |
| 404 | }; |
| 405 | |
| 406 | struct REMOVE3resfail { |
| 407 | wcc_data dir_wcc; |
| 408 | }; |
| 409 | |
| 410 | union REMOVE3res switch (nfsstat3 status) { |
| 411 | case NFS3_OK: |
| 412 | REMOVE3resok resok; |
| 413 | default: |
| 414 | REMOVE3resfail resfail; |
| 415 | }; |
| 416 | |
| 417 | struct READ3args { |
| 418 | nfs_fh3 file; |
| 419 | offset3 offset; |
| 420 | count3 count; |
| 421 | }; |
| 422 | |
| 423 | struct READ3resok { |
| 424 | post_op_attr file_attributes; |
| 425 | count3 count; |
| 426 | bool eof; |
| 427 | opaque data<>; |
| 428 | }; |
| 429 | |
| 430 | struct READ3resfail { |
| 431 | post_op_attr file_attributes; |
| 432 | }; |
| 433 | |
| 434 | union READ3res switch (nfsstat3 status) { |
| 435 | case NFS3_OK: |
| 436 | READ3resok resok; |
| 437 | default: |
| 438 | READ3resfail resfail; |
| 439 | }; |
| 440 | |
| 441 | |
| 442 | const FSF3_LINK = 0x0001; |
| 443 | const FSF3_SYMLINK = 0x0002; |
| 444 | const FSF3_HOMOGENEOUS = 0x0008; |
| 445 | const FSF3_CANSETTIME = 0x0010; |
| 446 | |
| 447 | struct FSINFO3args { |
| 448 | nfs_fh3 fsroot; |
| 449 | }; |
| 450 | |
| 451 | struct FSINFO3resok { |
| 452 | post_op_attr obj_attributes; |
| 453 | unsigned int rtmax; |
| 454 | unsigned int rtpref; |
| 455 | unsigned int rtmult; |
| 456 | unsigned int wtmax; |
| 457 | unsigned int wtpref; |
| 458 | unsigned int wtmult; |
| 459 | unsigned int dtpref; |
| 460 | size3 maxfilesize; |
| 461 | nfstime3 time_delta; |
| 462 | unsigned int properties; |
| 463 | }; |
| 464 | |
| 465 | struct FSINFO3resfail { |
| 466 | post_op_attr obj_attributes; |
| 467 | }; |
| 468 | |
| 469 | union FSINFO3res switch (nfsstat3 status) { |
| 470 | case NFS3_OK: |
| 471 | FSINFO3resok resok; |
| 472 | default: |
| 473 | FSINFO3resfail resfail; |
| 474 | }; |
| 475 | |
| 476 | |
| 477 | struct FSSTAT3args { |
| 478 | nfs_fh3 fsroot; |
| 479 | }; |
| 480 | |
| 481 | struct FSSTAT3resok { |
| 482 | post_op_attr obj_attributes; |
| 483 | size3 tbytes; |
| 484 | size3 fbytes; |
| 485 | size3 abytes; |
| 486 | size3 tfiles; |
| 487 | size3 ffiles; |
| 488 | size3 afiles; |
| 489 | unsigned int invarsec; |
| 490 | }; |
| 491 | |
| 492 | struct FSSTAT3resfail { |
| 493 | post_op_attr obj_attributes; |
| 494 | }; |
| 495 | |
| 496 | union FSSTAT3res switch (nfsstat3 status) { |
| 497 | case NFS3_OK: |
| 498 | FSSTAT3resok resok; |
| 499 | default: |
| 500 | FSSTAT3resfail resfail; |
| 501 | }; |
| 502 | |
| 503 | struct PATHCONF3args { |
| 504 | nfs_fh3 object; |
| 505 | }; |
| 506 | |
| 507 | struct PATHCONF3resok { |
| 508 | post_op_attr obj_attributes; |
| 509 | unsigned int linkmax; |
| 510 | unsigned int name_max; |
| 511 | bool no_trunc; |
| 512 | bool chown_restricted; |
| 513 | bool case_insensitive; |
| 514 | bool case_preserving; |
| 515 | }; |
| 516 | |
| 517 | struct PATHCONF3resfail { |
| 518 | post_op_attr obj_attributes; |
| 519 | }; |
| 520 | |
| 521 | union PATHCONF3res switch (nfsstat3 status) { |
| 522 | case NFS3_OK: |
| 523 | PATHCONF3resok resok; |
| 524 | default: |
| 525 | PATHCONF3resfail resfail; |
| 526 | }; |
| 527 | |
| 528 | typedef string nfspath3<>; |
| 529 | |
| 530 | struct symlinkdata3 { |
| 531 | sattr3 symlink_attributes; |
| 532 | nfspath3 symlink_data; |
| 533 | }; |
| 534 | |
| 535 | struct SYMLINK3args { |
| 536 | diropargs3 where; |
| 537 | symlinkdata3 symlink; |
| 538 | }; |
| 539 | |
| 540 | struct SYMLINK3resok { |
| 541 | post_op_fh3 obj; |
| 542 | post_op_attr obj_attributes; |
| 543 | wcc_data dir_wcc; |
| 544 | }; |
| 545 | |
| 546 | struct SYMLINK3resfail { |
| 547 | wcc_data dir_wcc; |
| 548 | }; |
| 549 | |
| 550 | union SYMLINK3res switch (nfsstat3 status) { |
| 551 | case NFS3_OK: |
| 552 | SYMLINK3resok resok; |
| 553 | default: |
| 554 | SYMLINK3resfail resfail; |
| 555 | }; |
| 556 | |
| 557 | |
| 558 | struct READLINK3args { |
| 559 | nfs_fh3 symlink; |
| 560 | }; |
| 561 | |
| 562 | struct READLINK3resok { |
| 563 | post_op_attr symlink_attributes; |
| 564 | nfspath3 data; |
| 565 | }; |
| 566 | |
| 567 | struct READLINK3resfail { |
| 568 | post_op_attr symlink_attributes; |
| 569 | }; |
| 570 | |
| 571 | union READLINK3res switch (nfsstat3 status) { |
| 572 | case NFS3_OK: |
| 573 | READLINK3resok resok; |
| 574 | default: |
| 575 | READLINK3resfail resfail; |
| 576 | }; |
| 577 | |
| 578 | |
| 579 | struct devicedata3 { |
| 580 | sattr3 dev_attributes; |
| 581 | specdata3 spec; |
| 582 | }; |
| 583 | |
| 584 | union mknoddata3 switch (ftype3 type) { |
| 585 | case NF3CHR: |
| 586 | devicedata3 chr_device; |
| 587 | case NF3BLK: |
| 588 | devicedata3 blk_device; |
| 589 | case NF3SOCK: |
| 590 | sattr3 sock_attributes; |
| 591 | case NF3FIFO: |
| 592 | sattr3 pipe_attributes; |
| 593 | default: |
| 594 | void; |
| 595 | }; |
| 596 | |
| 597 | struct MKNOD3args { |
| 598 | diropargs3 where; |
| 599 | mknoddata3 what; |
| 600 | }; |
| 601 | |
| 602 | struct MKNOD3resok { |
| 603 | post_op_fh3 obj; |
| 604 | post_op_attr obj_attributes; |
| 605 | wcc_data dir_wcc; |
| 606 | }; |
| 607 | |
| 608 | struct MKNOD3resfail { |
| 609 | wcc_data dir_wcc; |
| 610 | }; |
| 611 | |
| 612 | union MKNOD3res switch (nfsstat3 status) { |
| 613 | case NFS3_OK: |
| 614 | MKNOD3resok resok; |
| 615 | default: |
| 616 | MKNOD3resfail resfail; |
| 617 | }; |
| 618 | |
| 619 | |
| 620 | struct MKDIR3args { |
| 621 | diropargs3 where; |
| 622 | sattr3 attributes; |
| 623 | }; |
| 624 | |
| 625 | struct MKDIR3resok { |
| 626 | post_op_fh3 obj; |
| 627 | post_op_attr obj_attributes; |
| 628 | wcc_data dir_wcc; |
| 629 | }; |
| 630 | |
| 631 | struct MKDIR3resfail { |
| 632 | wcc_data dir_wcc; |
| 633 | }; |
| 634 | |
| 635 | union MKDIR3res switch (nfsstat3 status) { |
| 636 | case NFS3_OK: |
| 637 | MKDIR3resok resok; |
| 638 | default: |
| 639 | MKDIR3resfail resfail; |
| 640 | }; |
| 641 | |
| 642 | struct RMDIR3args { |
| 643 | diropargs3 object; |
| 644 | }; |
| 645 | |
| 646 | struct RMDIR3resok { |
| 647 | wcc_data dir_wcc; |
| 648 | }; |
| 649 | |
| 650 | struct RMDIR3resfail { |
| 651 | wcc_data dir_wcc; |
| 652 | }; |
| 653 | |
| 654 | union RMDIR3res switch (nfsstat3 status) { |
| 655 | case NFS3_OK: |
| 656 | RMDIR3resok resok; |
| 657 | default: |
| 658 | RMDIR3resfail resfail; |
| 659 | }; |
| 660 | |
| 661 | struct RENAME3args { |
| 662 | diropargs3 from; |
| 663 | diropargs3 to; |
| 664 | }; |
| 665 | |
| 666 | struct RENAME3resok { |
| 667 | wcc_data fromdir_wcc; |
| 668 | wcc_data todir_wcc; |
| 669 | }; |
| 670 | |
| 671 | struct RENAME3resfail { |
| 672 | wcc_data fromdir_wcc; |
| 673 | wcc_data todir_wcc; |
| 674 | }; |
| 675 | |
| 676 | union RENAME3res switch (nfsstat3 status) { |
| 677 | case NFS3_OK: |
| 678 | RENAME3resok resok; |
| 679 | default: |
| 680 | RENAME3resfail resfail; |
| 681 | }; |
| 682 | |
| 683 | struct READDIRPLUS3args { |
| 684 | nfs_fh3 dir; |
| 685 | cookie3 cookie; |
| 686 | cookieverf3 cookieverf; |
| 687 | count3 dircount; |
| 688 | count3 maxcount; |
| 689 | }; |
| 690 | |
| 691 | struct entryplus3 { |
| 692 | fileid3 fileid; |
| 693 | filename3 name; |
| 694 | cookie3 cookie; |
| 695 | post_op_attr name_attributes; |
| 696 | post_op_fh3 name_handle; |
| 697 | entryplus3 *nextentry; |
| 698 | }; |
| 699 | |
| 700 | struct dirlistplus3 { |
| 701 | entryplus3 *entries; |
| 702 | bool eof; |
| 703 | }; |
| 704 | |
| 705 | struct READDIRPLUS3resok { |
| 706 | post_op_attr dir_attributes; |
| 707 | cookieverf3 cookieverf; |
| 708 | dirlistplus3 reply; |
| 709 | }; |
| 710 | |
| 711 | |
| 712 | struct READDIRPLUS3resfail { |
| 713 | post_op_attr dir_attributes; |
| 714 | }; |
| 715 | |
| 716 | union READDIRPLUS3res switch (nfsstat3 status) { |
| 717 | case NFS3_OK: |
| 718 | READDIRPLUS3resok resok; |
| 719 | default: |
| 720 | READDIRPLUS3resfail resfail; |
| 721 | }; |
| 722 | |
| 723 | struct READDIR3args { |
| 724 | nfs_fh3 dir; |
| 725 | cookie3 cookie; |
| 726 | cookieverf3 cookieverf; |
| 727 | count3 count; |
| 728 | }; |
| 729 | |
| 730 | |
| 731 | struct entry3 { |
| 732 | fileid3 fileid; |
| 733 | filename3 name; |
| 734 | cookie3 cookie; |
| 735 | entry3 *nextentry; |
| 736 | }; |
| 737 | |
| 738 | struct dirlist3 { |
| 739 | entry3 *entries; |
| 740 | bool eof; |
| 741 | }; |
| 742 | |
| 743 | struct READDIR3resok { |
| 744 | post_op_attr dir_attributes; |
| 745 | cookieverf3 cookieverf; |
| 746 | dirlist3 reply; |
| 747 | }; |
| 748 | |
| 749 | struct READDIR3resfail { |
| 750 | post_op_attr dir_attributes; |
| 751 | }; |
| 752 | |
| 753 | union READDIR3res switch (nfsstat3 status) { |
| 754 | case NFS3_OK: |
| 755 | READDIR3resok resok; |
| 756 | default: |
| 757 | READDIR3resfail resfail; |
| 758 | }; |
| 759 | |
| 760 | struct LINK3args { |
| 761 | nfs_fh3 file; |
| 762 | diropargs3 link; |
| 763 | }; |
| 764 | |
| 765 | struct LINK3resok { |
| 766 | post_op_attr file_attributes; |
| 767 | wcc_data linkdir_wcc; |
| 768 | }; |
| 769 | |
| 770 | struct LINK3resfail { |
| 771 | post_op_attr file_attributes; |
| 772 | wcc_data linkdir_wcc; |
| 773 | }; |
| 774 | |
| 775 | union LINK3res switch (nfsstat3 status) { |
| 776 | case NFS3_OK: |
| 777 | LINK3resok resok; |
| 778 | default: |
| 779 | LINK3resfail resfail; |
| 780 | }; |
| 781 | |
| 782 | union sattrguard3 switch (bool check) { |
| 783 | case TRUE: |
| 784 | nfstime3 obj_ctime; |
| 785 | case FALSE: |
| 786 | void; |
| 787 | }; |
| 788 | |
| 789 | struct SETATTR3args { |
| 790 | nfs_fh3 object; |
| 791 | sattr3 new_attributes; |
| 792 | sattrguard3 guard; |
| 793 | }; |
| 794 | |
| 795 | struct SETATTR3resok { |
| 796 | wcc_data obj_wcc; |
| 797 | }; |
| 798 | |
| 799 | struct SETATTR3resfail { |
| 800 | wcc_data obj_wcc; |
| 801 | }; |
| 802 | |
| 803 | union SETATTR3res switch (nfsstat3 status) { |
| 804 | case NFS3_OK: |
| 805 | SETATTR3resok resok; |
| 806 | default: |
| 807 | SETATTR3resfail resfail; |
| 808 | }; |
| 809 | |
| 810 | /* |
| 811 | * NFS v2 Definitions |
| 812 | * We share many definitions from v3 |
| 813 | */ |
| 814 | const FHSIZE2 = 32; |
| 815 | typedef opaque fhandle2[FHSIZE2]; |
| 816 | |
| 817 | enum ftype2 { |
| 818 | NF2NON = 0, |
| 819 | NF2REG = 1, |
| 820 | NF2DIR = 2, |
| 821 | NF2BLK = 3, |
| 822 | NF2CHR = 4, |
| 823 | NF2LNK = 5 |
| 824 | }; |
| 825 | |
| 826 | struct fattr2 { |
| 827 | ftype2 type; |
| 828 | unsigned int mode; |
| 829 | unsigned int nlink; |
| 830 | unsigned int uid; |
| 831 | unsigned int gid; |
| 832 | unsigned int size; |
| 833 | unsigned int blocksize; |
| 834 | unsigned int rdev; |
| 835 | unsigned int blocks; |
| 836 | unsigned int fsid; |
| 837 | unsigned int fileid; |
| 838 | nfstime3 atime; |
| 839 | nfstime3 mtime; |
| 840 | nfstime3 ctime; |
| 841 | }; |
| 842 | |
| 843 | struct sattr2 { |
| 844 | unsigned int mode; |
| 845 | unsigned int uid; |
| 846 | unsigned int gid; |
| 847 | unsigned int size; |
| 848 | nfstime3 atime; |
| 849 | nfstime3 mtime; |
| 850 | }; |
| 851 | |
| 852 | const MAXNAMLEN2 = 255; |
| 853 | typedef string filename2<MAXNAMLEN2>; |
| 854 | |
| 855 | const MAXPATHLEN2 = 1024; |
| 856 | typedef string path2<MAXPATHLEN2>; |
| 857 | |
| 858 | const NFSMAXDATA2 = 8192; |
| 859 | typedef opaque nfsdata2<NFSMAXDATA2>; |
| 860 | |
| 861 | const NFSCOOKIESIZE2 = 4; |
| 862 | typedef opaque nfscookie2[NFSCOOKIESIZE2]; |
| 863 | |
| 864 | struct entry2 { |
| 865 | unsigned int fileid; |
| 866 | filename2 name; |
| 867 | nfscookie2 cookie; |
| 868 | entry2 *nextentry; |
| 869 | }; |
| 870 | |
| 871 | struct diropargs2 { |
| 872 | fhandle2 dir; |
| 873 | filename2 name; |
| 874 | }; |
| 875 | |
| 876 | struct GETATTR2args { |
| 877 | fhandle2 fhandle; |
| 878 | }; |
| 879 | |
| 880 | struct GETATTR2resok { |
| 881 | fattr2 attributes; |
| 882 | }; |
| 883 | |
| 884 | union GETATTR2res switch (nfsstat3 status) { |
| 885 | case NFS3_OK: |
| 886 | GETATTR2resok resok; |
| 887 | default: |
| 888 | void; |
| 889 | }; |
| 890 | |
| 891 | struct SETATTR2args { |
| 892 | fhandle2 fhandle; |
| 893 | sattr2 attributes; |
| 894 | }; |
| 895 | |
| 896 | struct SETATTR2resok { |
| 897 | fattr2 attributes; |
| 898 | }; |
| 899 | |
| 900 | union SETATTR2res switch (nfsstat3 status) { |
| 901 | case NFS3_OK: |
| 902 | SETATTR2resok resok; |
| 903 | default: |
| 904 | void; |
| 905 | }; |
| 906 | |
| 907 | struct LOOKUP2args { |
| 908 | diropargs2 what; |
| 909 | }; |
| 910 | |
| 911 | struct LOOKUP2resok { |
| 912 | fhandle2 file; |
| 913 | fattr2 attributes; |
| 914 | }; |
| 915 | |
| 916 | union LOOKUP2res switch (nfsstat3 status) { |
| 917 | case NFS3_OK: |
| 918 | LOOKUP2resok resok; |
| 919 | default: |
| 920 | void; |
| 921 | }; |
| 922 | |
| 923 | struct READLINK2args { |
| 924 | fhandle2 file; |
| 925 | }; |
| 926 | |
| 927 | struct READLINK2resok { |
| 928 | path2 data; |
| 929 | }; |
| 930 | |
| 931 | union READLINK2res switch (nfsstat3 status) { |
| 932 | case NFS3_OK: |
| 933 | READLINK2resok resok; |
| 934 | default: |
| 935 | void; |
| 936 | }; |
| 937 | |
| 938 | struct READ2args { |
| 939 | fhandle2 file; |
| 940 | unsigned int offset; |
| 941 | unsigned int count; |
| 942 | unsigned int totalcount; |
| 943 | }; |
| 944 | |
| 945 | struct READ2resok { |
| 946 | fattr2 attributes; |
| 947 | nfsdata2 data; |
| 948 | }; |
| 949 | |
| 950 | union READ2res switch (nfsstat3 status) { |
| 951 | case NFS3_OK: |
| 952 | READ2resok resok; |
| 953 | default: |
| 954 | void; |
| 955 | }; |
| 956 | |
| 957 | struct WRITE2args { |
| 958 | fhandle2 file; |
| 959 | unsigned int beginoffset; |
| 960 | unsigned int offset; |
| 961 | unsigned int totalcount; |
| 962 | nfsdata2 data; |
| 963 | }; |
| 964 | |
| 965 | struct WRITE2resok { |
| 966 | fattr2 attributes; |
| 967 | }; |
| 968 | |
| 969 | union WRITE2res switch (nfsstat3 status) { |
| 970 | case NFS3_OK: |
| 971 | WRITE2resok resok; |
| 972 | default: |
| 973 | void; |
| 974 | }; |
| 975 | |
| 976 | struct CREATE2args { |
| 977 | diropargs2 where; |
| 978 | sattr2 attributes; |
| 979 | }; |
| 980 | |
| 981 | struct CREATE2resok { |
| 982 | fhandle2 file; |
| 983 | fattr2 attributes; |
| 984 | }; |
| 985 | |
| 986 | union CREATE2res switch (nfsstat3 status) { |
| 987 | case NFS3_OK: |
| 988 | CREATE2resok resok; |
| 989 | default: |
| 990 | void; |
| 991 | }; |
| 992 | |
| 993 | struct REMOVE2args { |
| 994 | diropargs2 what; |
| 995 | }; |
| 996 | |
| 997 | struct REMOVE2res { |
| 998 | nfsstat3 status; |
| 999 | }; |
| 1000 | |
| 1001 | struct RENAME2args { |
| 1002 | diropargs2 from; |
| 1003 | diropargs2 to; |
| 1004 | }; |
| 1005 | |
| 1006 | struct RENAME2res { |
| 1007 | nfsstat3 status; |
| 1008 | }; |
| 1009 | |
| 1010 | struct LINK2args { |
| 1011 | fhandle2 from; |
| 1012 | diropargs2 to; |
| 1013 | }; |
| 1014 | |
| 1015 | struct LINK2res { |
| 1016 | nfsstat3 status; |
| 1017 | }; |
| 1018 | |
| 1019 | struct SYMLINK2args { |
| 1020 | diropargs2 from; |
| 1021 | path2 to; |
| 1022 | sattr2 attributes; |
| 1023 | }; |
| 1024 | |
| 1025 | struct SYMLINK2res { |
| 1026 | nfsstat3 status; |
| 1027 | }; |
| 1028 | |
| 1029 | struct MKDIR2args { |
| 1030 | diropargs2 where; |
| 1031 | sattr2 attributes; |
| 1032 | }; |
| 1033 | |
| 1034 | struct MKDIR2resok { |
| 1035 | fhandle2 file; |
| 1036 | fattr2 attributes; |
| 1037 | }; |
| 1038 | |
| 1039 | union MKDIR2res switch (nfsstat3 status) { |
| 1040 | case NFS3_OK: |
| 1041 | MKDIR2resok resok; |
| 1042 | default: |
| 1043 | void; |
| 1044 | }; |
| 1045 | |
| 1046 | struct RMDIR2args { |
| 1047 | diropargs2 what; |
| 1048 | }; |
| 1049 | |
| 1050 | struct RMDIR2res { |
| 1051 | nfsstat3 status; |
| 1052 | }; |
| 1053 | |
| 1054 | struct READDIR2args { |
| 1055 | fhandle2 dir; |
| 1056 | nfscookie2 cookie; |
| 1057 | unsigned int count; |
| 1058 | }; |
| 1059 | |
| 1060 | struct READDIR2resok { |
| 1061 | entry2 *entries; |
| 1062 | bool eof; |
| 1063 | }; |
| 1064 | |
| 1065 | union READDIR2res switch (nfsstat3 status) { |
| 1066 | case NFS3_OK: |
| 1067 | READDIR2resok resok; |
| 1068 | default: |
| 1069 | void; |
| 1070 | }; |
| 1071 | |
| 1072 | struct STATFS2args { |
| 1073 | fhandle2 dir; |
| 1074 | }; |
| 1075 | |
| 1076 | struct STATFS2resok { |
| 1077 | unsigned int tsize; |
| 1078 | unsigned int bsize; |
| 1079 | unsigned int blocks; |
| 1080 | unsigned int bfree; |
| 1081 | unsigned int bavail; |
| 1082 | }; |
| 1083 | |
| 1084 | union STATFS2res switch (nfsstat3 status) { |
| 1085 | case NFS3_OK: |
| 1086 | STATFS2resok resok; |
| 1087 | default: |
| 1088 | void; |
| 1089 | }; |
| 1090 | |
| 1091 | program NFS_PROGRAM { |
| 1092 | version NFS_V2 { |
| 1093 | void |
| 1094 | NFS2_NULL(void) = 0; |
| 1095 | |
| 1096 | GETATTR2res |
| 1097 | NFS2_GETATTR(GETATTR2args) = 1; |
| 1098 | |
| 1099 | SETATTR2res |
| 1100 | NFS2_SETATTR(SETATTR2args) = 2; |
| 1101 | |
| 1102 | LOOKUP2res |
| 1103 | NFS2_LOOKUP(LOOKUP2args) = 4; |
| 1104 | |
| 1105 | READLINK2res |
| 1106 | NFS2_READLINK(READLINK2args) = 5; |
| 1107 | |
| 1108 | READ2res |
| 1109 | NFS2_READ(READ2args) = 6; |
| 1110 | |
| 1111 | WRITE2res |
| 1112 | NFS2_WRITE(WRITE2args) = 8; |
| 1113 | |
| 1114 | CREATE2res |
| 1115 | NFS2_CREATE(CREATE2args) = 9; |
| 1116 | |
| 1117 | REMOVE2res |
| 1118 | NFS2_REMOVE(REMOVE2args) = 10; |
| 1119 | |
| 1120 | RENAME2res |
| 1121 | NFS2_RENAME(RENAME2args) = 11; |
| 1122 | |
| 1123 | LINK2res |
| 1124 | NFS2_LINK(LINK2args) = 12; |
| 1125 | |
| 1126 | SYMLINK2res |
| 1127 | NFS2_SYMLINK(SYMLINK2args) = 13; |
| 1128 | |
| 1129 | MKDIR2res |
| 1130 | NFS2_MKDIR(MKDIR2args) = 14; |
| 1131 | |
| 1132 | RMDIR2res |
| 1133 | NFS2_RMDIR(RMDIR2args) = 15; |
| 1134 | |
| 1135 | READDIR2res |
| 1136 | NFS2_READDIR(READDIR2args) = 16; |
| 1137 | |
| 1138 | STATFS2res |
| 1139 | NFS2_STATFS(STATFS2args) = 17; |
| 1140 | } = 2; |
| 1141 | |
| 1142 | version NFS_V3 { |
| 1143 | void |
| 1144 | NFS3_NULL(void) = 0; |
| 1145 | |
| 1146 | GETATTR3res |
| 1147 | NFS3_GETATTR(GETATTR3args) = 1; |
| 1148 | |
| 1149 | SETATTR3res |
| 1150 | NFS3_SETATTR(SETATTR3args) = 2; |
| 1151 | |
| 1152 | LOOKUP3res |
| 1153 | NFS3_LOOKUP(LOOKUP3args) = 3; |
| 1154 | |
| 1155 | ACCESS3res |
| 1156 | NFS3_ACCESS(ACCESS3args) = 4; |
| 1157 | |
| 1158 | READLINK3res |
| 1159 | NFS3_READLINK(READLINK3args) = 5; |
| 1160 | |
| 1161 | READ3res |
| 1162 | NFS3_READ(READ3args) = 6; |
| 1163 | |
| 1164 | WRITE3res |
| 1165 | NFS3_WRITE(WRITE3args) = 7; |
| 1166 | |
| 1167 | CREATE3res |
| 1168 | NFS3_CREATE(CREATE3args) = 8; |
| 1169 | |
| 1170 | MKDIR3res |
| 1171 | NFS3_MKDIR(MKDIR3args) = 9; |
| 1172 | |
| 1173 | SYMLINK3res |
| 1174 | NFS3_SYMLINK(SYMLINK3args) = 10; |
| 1175 | |
| 1176 | MKNOD3res |
| 1177 | NFS3_MKNOD(MKNOD3args) = 11; |
| 1178 | |
| 1179 | REMOVE3res |
| 1180 | NFS3_REMOVE(REMOVE3args) = 12; |
| 1181 | |
| 1182 | RMDIR3res |
| 1183 | NFS3_RMDIR(RMDIR3args) = 13; |
| 1184 | |
| 1185 | RENAME3res |
| 1186 | NFS3_RENAME(RENAME3args) = 14; |
| 1187 | |
| 1188 | LINK3res |
| 1189 | NFS3_LINK(LINK3args) = 15; |
| 1190 | |
| 1191 | READDIR3res |
| 1192 | NFS3_READDIR(READDIR3args) = 16; |
| 1193 | |
| 1194 | READDIRPLUS3res |
| 1195 | NFS3_READDIRPLUS(READDIRPLUS3args) = 17; |
| 1196 | |
| 1197 | FSSTAT3res |
| 1198 | NFS3_FSSTAT(FSSTAT3args) = 18; |
| 1199 | |
| 1200 | FSINFO3res |
| 1201 | NFS3_FSINFO(FSINFO3args) = 19; |
| 1202 | |
| 1203 | PATHCONF3res |
| 1204 | NFS3_PATHCONF(PATHCONF3args) = 20; |
| 1205 | |
| 1206 | COMMIT3res |
| 1207 | NFS3_COMMIT(COMMIT3args) = 21; |
| 1208 | } = 3; |
| 1209 | } = 100003; |
| 1210 | |
| 1211 | |
| 1212 | |
| 1213 | /* NFS ACL definitions based on wireshark souces and network traces */ |
| 1214 | /* NFSACL interface. Uses same port/process as NFS */ |
| 1215 | |
| 1216 | enum nfsacl_type { |
| 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 |
| 1230 | }; |
| 1231 | |
| 1232 | const NFSACL_PERM_READ = 0x04; |
| 1233 | const NFSACL_PERM_WRITE = 0x02; |
| 1234 | const NFSACL_PERM_EXEC = 0x01; |
| 1235 | |
| 1236 | struct nfsacl_ace { |
| 1237 | enum nfsacl_type type; |
| 1238 | unsigned int id; |
| 1239 | unsigned int perm; |
| 1240 | }; |
| 1241 | |
| 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; |
| 1246 | |
| 1247 | struct GETACL3args { |
| 1248 | nfs_fh3 dir; |
| 1249 | unsigned int mask; |
| 1250 | }; |
| 1251 | |
| 1252 | struct GETACL3resok { |
| 1253 | post_op_attr attr; |
| 1254 | unsigned int mask; |
| 1255 | unsigned int ace_count; |
| 1256 | struct nfsacl_ace ace<>; |
| 1257 | unsigned int default_ace_count; |
| 1258 | struct nfsacl_ace default_ace<>; |
| 1259 | }; |
| 1260 | |
| 1261 | union GETACL3res switch (nfsstat3 status) { |
| 1262 | case NFS3_OK: |
| 1263 | GETACL3resok resok; |
| 1264 | default: |
| 1265 | void; |
| 1266 | }; |
| 1267 | |
| 1268 | struct SETACL3args { |
| 1269 | nfs_fh3 dir; |
| 1270 | unsigned int mask; |
| 1271 | unsigned int ace_count; |
| 1272 | struct nfsacl_ace ace<>; |
| 1273 | unsigned int default_ace_count; |
| 1274 | struct nfsacl_ace default_ace<>; |
| 1275 | }; |
| 1276 | |
| 1277 | struct SETACL3resok { |
| 1278 | post_op_attr attr; |
| 1279 | }; |
| 1280 | |
| 1281 | union SETACL3res switch (nfsstat3 status) { |
| 1282 | case NFS3_OK: |
| 1283 | SETACL3resok resok; |
| 1284 | default: |
| 1285 | void; |
| 1286 | }; |
| 1287 | |
| 1288 | program NFSACL_PROGRAM { |
| 1289 | version NFSACL_V3 { |
| 1290 | void |
| 1291 | NFSACL3_NULL(void) = 0; |
| 1292 | |
| 1293 | GETACL3res |
| 1294 | NFSACL3_GETACL(GETACL3args) = 1; |
| 1295 | |
| 1296 | SETACL3res |
| 1297 | NFSACL3_SETACL(SETACL3args) = 2; |
| 1298 | } = 3; |
| 1299 | } = 100227; |