1 /* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. 8 * 9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 * 13 * Sun RPC is provided with no support and without any obligation on the 14 * part of Sun Microsystems, Inc. to assist in its use, correction, 15 * modification or enhancement. 16 * 17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 * OR ANY PART THEREOF. 20 * 21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 * or profits or other special, indirect and consequential damages, even if 23 * Sun has been advised of the possibility of such damages. 24 * 25 * Sun Microsystems, Inc. 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 */ 29 30 #ifndef RPC_HDR 31 %#include <sys/cdefs.h> 32 %#ifndef lint 33 %/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/ 34 %/*static char sccsid[] = "from: @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ 35 %__RCSID("$NetBSD: nfs_prot.x,v 1.5 2003/05/08 13:32:00 yamt Exp $"); 36 %#endif /* not lint */ 37 #endif 38 39 const NFS_PORT = 2049; 40 const NFS_MAXDATA = 8192; 41 const NFS_MAXPATHLEN = 1024; 42 const NFS_MAXNAMLEN = 255; 43 const NFS_FHSIZE = 32; 44 const NFS_COOKIESIZE = 4; 45 const NFS_FIFO_DEV = -1; /* size kludge for named pipes */ 46 47 /* 48 * File types 49 */ 50 const NFSMODE_FMT = 0170000; /* type of file */ 51 const NFSMODE_DIR = 0040000; /* directory */ 52 const NFSMODE_CHR = 0020000; /* character special */ 53 const NFSMODE_BLK = 0060000; /* block special */ 54 const NFSMODE_REG = 0100000; /* regular */ 55 const NFSMODE_LNK = 0120000; /* symbolic link */ 56 const NFSMODE_SOCK = 0140000; /* socket */ 57 const NFSMODE_FIFO = 0010000; /* fifo */ 58 59 /* 60 * Error status 61 */ 62 enum nfsstat { 63 NFS_OK= 0, /* no error */ 64 NFSERR_PERM=1, /* Not owner */ 65 NFSERR_NOENT=2, /* No such file or directory */ 66 NFSERR_IO=5, /* I/O error */ 67 NFSERR_NXIO=6, /* No such device or address */ 68 NFSERR_ACCES=13, /* Permission denied */ 69 NFSERR_EXIST=17, /* File exists */ 70 NFSERR_NODEV=19, /* No such device */ 71 NFSERR_NOTDIR=20, /* Not a directory*/ 72 NFSERR_ISDIR=21, /* Is a directory */ 73 NFSERR_FBIG=27, /* File too large */ 74 NFSERR_NOSPC=28, /* No space left on device */ 75 NFSERR_ROFS=30, /* Read-only file system */ 76 NFSERR_NAMETOOLONG=63, /* File name too long */ 77 NFSERR_NOTEMPTY=66, /* Directory not empty */ 78 NFSERR_DQUOT=69, /* Disc quota exceeded */ 79 NFSERR_STALE=70, /* Stale NFS file handle */ 80 NFSERR_WFLUSH=99 /* write cache flushed */ 81 }; 82 83 /* 84 * File types 85 */ 86 enum ftype { 87 NFNON = 0, /* non-file */ 88 NFREG = 1, /* regular file */ 89 NFDIR = 2, /* directory */ 90 NFBLK = 3, /* block special */ 91 NFCHR = 4, /* character special */ 92 NFLNK = 5, /* symbolic link */ 93 NFSOCK = 6, /* unix domain sockets */ 94 NFBAD = 7, /* unused */ 95 NFFIFO = 8 /* named pipe */ 96 }; 97 98 /* 99 * File access handle 100 */ 101 struct nfs_fh { 102 opaque data[NFS_FHSIZE]; 103 }; 104 105 /* 106 * Timeval 107 */ 108 struct nfstime { 109 unsigned seconds; 110 unsigned useconds; 111 }; 112 113 114 /* 115 * File attributes 116 */ 117 struct fattr { 118 ftype type; /* file type */ 119 unsigned mode; /* protection mode bits */ 120 unsigned nlink; /* # hard links */ 121 unsigned uid; /* owner user id */ 122 unsigned gid; /* owner group id */ 123 unsigned size; /* file size in bytes */ 124 unsigned blocksize; /* prefered block size */ 125 unsigned rdev; /* special device # */ 126 unsigned blocks; /* Kb of disk used by file */ 127 unsigned fsid; /* device # */ 128 unsigned fileid; /* inode # */ 129 nfstime atime; /* time of last access */ 130 nfstime mtime; /* time of last modification */ 131 nfstime ctime; /* time of last change */ 132 }; 133 134 /* 135 * File attributes which can be set 136 */ 137 struct sattr { 138 unsigned mode; /* protection mode bits */ 139 unsigned uid; /* owner user id */ 140 unsigned gid; /* owner group id */ 141 unsigned size; /* file size in bytes */ 142 nfstime atime; /* time of last access */ 143 nfstime mtime; /* time of last modification */ 144 }; 145 146 147 typedef string filename<NFS_MAXNAMLEN>; 148 typedef string nfspath<NFS_MAXPATHLEN>; 149 150 /* 151 * Reply status with file attributes 152 */ 153 union attrstat switch (nfsstat status) { 154 case NFS_OK: 155 fattr attributes; 156 default: 157 void; 158 }; 159 160 struct sattrargs { 161 nfs_fh file; 162 sattr attributes; 163 }; 164 165 /* 166 * Arguments for directory operations 167 */ 168 struct diropargs { 169 nfs_fh dir; /* directory file handle */ 170 filename name; /* name (up to NFS_MAXNAMLEN bytes) */ 171 }; 172 173 struct diropokres { 174 nfs_fh file; 175 fattr attributes; 176 }; 177 178 /* 179 * Results from directory operation 180 */ 181 union diropres switch (nfsstat status) { 182 case NFS_OK: 183 diropokres diropres; 184 default: 185 void; 186 }; 187 188 union readlinkres switch (nfsstat status) { 189 case NFS_OK: 190 nfspath data; 191 default: 192 void; 193 }; 194 195 /* 196 * Arguments to remote read 197 */ 198 struct readargs { 199 nfs_fh file; /* handle for file */ 200 unsigned offset; /* byte offset in file */ 201 unsigned count; /* immediate read count */ 202 unsigned totalcount; /* total read count (from this offset)*/ 203 }; 204 205 /* 206 * Status OK portion of remote read reply 207 */ 208 struct readokres { 209 fattr attributes; /* attributes, need for pagin*/ 210 opaque data<NFS_MAXDATA>; 211 }; 212 213 union readres switch (nfsstat status) { 214 case NFS_OK: 215 readokres reply; 216 default: 217 void; 218 }; 219 220 /* 221 * Arguments to remote write 222 */ 223 struct writeargs { 224 nfs_fh file; /* handle for file */ 225 unsigned beginoffset; /* beginning byte offset in file */ 226 unsigned offset; /* current byte offset in file */ 227 unsigned totalcount; /* total write count (to this offset)*/ 228 opaque data<NFS_MAXDATA>; 229 }; 230 231 struct createargs { 232 diropargs where; 233 sattr attributes; 234 }; 235 236 struct renameargs { 237 diropargs from; 238 diropargs to; 239 }; 240 241 struct linkargs { 242 nfs_fh from; 243 diropargs to; 244 }; 245 246 struct symlinkargs { 247 diropargs from; 248 nfspath to; 249 sattr attributes; 250 }; 251 252 253 typedef opaque nfscookie[NFS_COOKIESIZE]; 254 255 /* 256 * Arguments to readdir 257 */ 258 struct readdirargs { 259 nfs_fh dir; /* directory handle */ 260 nfscookie cookie; 261 unsigned count; /* number of directory bytes to read */ 262 }; 263 264 struct entry { 265 unsigned fileid; 266 filename name; 267 nfscookie cookie; 268 entry *nextentry; 269 }; 270 271 struct dirlist { 272 entry *entries; 273 bool eof; 274 }; 275 276 union readdirres switch (nfsstat status) { 277 case NFS_OK: 278 dirlist reply; 279 default: 280 void; 281 }; 282 283 struct statfsokres { 284 unsigned tsize; /* preferred transfer size in bytes */ 285 unsigned bsize; /* fundamental file system block size */ 286 unsigned blocks; /* total blocks in file system */ 287 unsigned bfree; /* free blocks in fs */ 288 unsigned bavail; /* free blocks avail to non-superuser */ 289 }; 290 291 union statfsres switch (nfsstat status) { 292 case NFS_OK: 293 statfsokres reply; 294 default: 295 void; 296 }; 297 298 /* 299 * NFSv3 constants and types 300 */ 301 const NFS3_FHSIZE = 64; /* maximum size in bytes of a file handle */ 302 const NFS3_COOKIEVERFSIZE = 8; /* size of a cookie verifier for READDIR */ 303 const NFS3_CREATEVERFSIZE = 8; /* size of the verifier used for CREATE */ 304 const NFS3_WRITEVERFSIZE = 8; /* size of the verifier used for WRITE */ 305 306 typedef u_int64_t uint64; /* XXX */ 307 typedef int64_t int64; /* XXX */ 308 typedef unsigned long uint32; 309 typedef long int32; 310 typedef string filename3<>; 311 typedef string nfspath3<>; 312 typedef uint64 fileid3; 313 typedef uint64 cookie3; 314 typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; 315 typedef opaque createverf3[NFS3_CREATEVERFSIZE]; 316 typedef opaque writeverf3[NFS3_WRITEVERFSIZE]; 317 typedef uint32 uid3; 318 typedef uint32 gid3; 319 typedef uint64 size3; 320 typedef uint64 offset3; 321 typedef uint32 mode3; 322 typedef uint32 count3; 323 324 /* 325 * Error status (v3) 326 */ 327 enum nfsstat3 { 328 NFS3_OK = 0, 329 NFS3ERR_PERM = 1, 330 NFS3ERR_NOENT = 2, 331 NFS3ERR_IO = 5, 332 NFS3ERR_NXIO = 6, 333 NFS3ERR_ACCES = 13, 334 NFS3ERR_EXIST = 17, 335 NFS3ERR_XDEV = 18, 336 NFS3ERR_NODEV = 19, 337 NFS3ERR_NOTDIR = 20, 338 NFS3ERR_ISDIR = 21, 339 NFS3ERR_INVAL = 22, 340 NFS3ERR_FBIG = 27, 341 NFS3ERR_NOSPC = 28, 342 NFS3ERR_ROFS = 30, 343 NFS3ERR_MLINK = 31, 344 NFS3ERR_NAMETOOLONG = 63, 345 NFS3ERR_NOTEMPTY = 66, 346 NFS3ERR_DQUOT = 69, 347 NFS3ERR_STALE = 70, 348 NFS3ERR_REMOTE = 71, 349 NFS3ERR_BADHANDLE = 10001, 350 NFS3ERR_NOT_SYNC = 10002, 351 NFS3ERR_BAD_COOKIE = 10003, 352 NFS3ERR_NOTSUPP = 10004, 353 NFS3ERR_TOOSMALL = 10005, 354 NFS3ERR_SERVERFAULT = 10006, 355 NFS3ERR_BADTYPE = 10007, 356 NFS3ERR_JUKEBOX = 10008 357 }; 358 359 /* 360 * File types (v3) 361 */ 362 enum ftype3 { 363 NF3REG = 1, /* regular file */ 364 NF3DIR = 2, /* directory */ 365 NF3BLK = 3, /* block special */ 366 NF3CHR = 4, /* character special */ 367 NF3LNK = 5, /* symbolic link */ 368 NF3SOCK = 6, /* unix domain sockets */ 369 NF3FIFO = 7 /* named pipe */ 370 }; 371 372 struct specdata3 { 373 uint32 specdata1; 374 uint32 specdata2; 375 }; 376 377 /* 378 * File access handle (v3) 379 */ 380 struct nfs_fh3 { 381 opaque data<NFS3_FHSIZE>; 382 }; 383 384 /* 385 * Timeval (v3) 386 */ 387 struct nfstime3 { 388 uint32 seconds; 389 uint32 nseconds; 390 }; 391 392 393 /* 394 * File attributes (v3) 395 */ 396 struct fattr3 { 397 ftype3 type; /* file type */ 398 mode3 mode; /* protection mode bits */ 399 uint32 nlink; /* # hard links */ 400 uid3 uid; /* owner user id */ 401 gid3 gid; /* owner group id */ 402 size3 size; /* file size in bytes */ 403 size3 used; /* prefered block size */ 404 specdata3 rdev; /* special device # */ 405 uint64 fsid; /* device # */ 406 fileid3 fileid; /* inode # */ 407 nfstime3 atime; /* time of last access */ 408 nfstime3 mtime; /* time of last modification */ 409 nfstime3 ctime; /* time of last change */ 410 }; 411 412 union post_op_attr switch (bool attributes_follow) { 413 case TRUE: 414 fattr3 attributes; 415 case FALSE: 416 void; 417 }; 418 419 struct wcc_attr { 420 size3 size; 421 nfstime3 mtime; 422 nfstime3 ctime; 423 }; 424 425 union pre_op_attr switch (bool attributes_follow) { 426 case TRUE: 427 wcc_attr attributes; 428 case FALSE: 429 void; 430 }; 431 432 struct wcc_data { 433 pre_op_attr before; 434 post_op_attr after; 435 }; 436 437 union post_op_fh3 switch (bool handle_follows) { 438 case TRUE: 439 nfs_fh3 handle; 440 case FALSE: 441 void; 442 }; 443 444 /* 445 * File attributes which can be set (v3) 446 */ 447 enum time_how { 448 DONT_CHANGE = 0, 449 SET_TO_SERVER_TIME = 1, 450 SET_TO_CLIENT_TIME = 2 451 }; 452 453 union set_mode3 switch (bool set_it) { 454 case TRUE: 455 mode3 mode; 456 default: 457 void; 458 }; 459 460 union set_uid3 switch (bool set_it) { 461 case TRUE: 462 uid3 uid; 463 default: 464 void; 465 }; 466 467 union set_gid3 switch (bool set_it) { 468 case TRUE: 469 gid3 gid; 470 default: 471 void; 472 }; 473 474 union set_size3 switch (bool set_it) { 475 case TRUE: 476 size3 size; 477 default: 478 void; 479 }; 480 481 union set_atime switch (time_how set_it) { 482 case SET_TO_CLIENT_TIME: 483 nfstime3 atime; 484 default: 485 void; 486 }; 487 488 union set_mtime switch (time_how set_it) { 489 case SET_TO_CLIENT_TIME: 490 nfstime3 mtime; 491 default: 492 void; 493 }; 494 495 struct sattr3 { 496 set_mode3 mode; 497 set_uid3 uid; 498 set_gid3 gid; 499 set_size3 size; 500 set_atime atime; 501 set_mtime mtime; 502 }; 503 504 /* 505 * Arguments for directory operations (v3) 506 */ 507 struct diropargs3 { 508 nfs_fh3 dir; /* directory file handle */ 509 filename3 name; /* name (up to NFS_MAXNAMLEN bytes) */ 510 }; 511 512 /* 513 * Arguments to getattr (v3). 514 */ 515 struct GETATTR3args { 516 nfs_fh3 object; 517 }; 518 519 struct GETATTR3resok { 520 fattr3 obj_attributes; 521 }; 522 523 union GETATTR3res switch (nfsstat3 status) { 524 case NFS3_OK: 525 GETATTR3resok resok; 526 default: 527 void; 528 }; 529 530 /* 531 * Arguments to setattr (v3). 532 */ 533 union sattrguard3 switch (bool check) { 534 case TRUE: 535 nfstime3 obj_ctime; 536 case FALSE: 537 void; 538 }; 539 540 struct SETATTR3args { 541 nfs_fh3 object; 542 sattr3 new_attributes; 543 sattrguard3 guard; 544 }; 545 546 struct SETATTR3resok { 547 wcc_data obj_wcc; 548 }; 549 550 struct SETATTR3resfail { 551 wcc_data obj_wcc; 552 }; 553 554 union SETATTR3res switch (nfsstat3 status) { 555 case NFS3_OK: 556 SETATTR3resok resok; 557 default: 558 SETATTR3resfail resfail; 559 }; 560 561 /* 562 * Arguments to lookup (v3). 563 */ 564 struct LOOKUP3args { 565 diropargs3 what; 566 }; 567 568 struct LOOKUP3resok { 569 nfs_fh3 object; 570 post_op_attr obj_attributes; 571 post_op_attr dir_attributes; 572 }; 573 574 struct LOOKUP3resfail { 575 post_op_attr dir_attributes; 576 }; 577 578 union LOOKUP3res switch (nfsstat3 status) { 579 case NFS3_OK: 580 LOOKUP3resok resok; 581 default: 582 LOOKUP3resfail resfail; 583 }; 584 585 /* 586 * Arguments to access (v3). 587 */ 588 const ACCESS3_READ = 0x0001; 589 const ACCESS3_LOOKUP = 0x0002; 590 const ACCESS3_MODIFY = 0x0004; 591 const ACCESS3_EXTEND = 0x0008; 592 const ACCESS3_DELETE = 0x0010; 593 const ACCESS3_EXECUTE = 0x0020; 594 595 struct ACCESS3args { 596 nfs_fh3 object; 597 uint32 access; 598 }; 599 600 struct ACCESS3resok { 601 post_op_attr obj_attributes; 602 uint32 access; 603 }; 604 605 struct ACCESS3resfail { 606 post_op_attr obj_attributes; 607 }; 608 609 union ACCESS3res switch (nfsstat3 status) { 610 case NFS3_OK: 611 ACCESS3resok resok; 612 default: 613 ACCESS3resfail resfail; 614 }; 615 616 /* 617 * Arguments to readlink (v3). 618 */ 619 struct READLINK3args { 620 nfs_fh3 symlink; 621 }; 622 623 struct READLINK3resok { 624 post_op_attr symlink_attributes; 625 nfspath3 data; 626 }; 627 628 struct READLINK3resfail { 629 post_op_attr symlink_attributes; 630 }; 631 632 union READLINK3res switch (nfsstat3 status) { 633 case NFS3_OK: 634 READLINK3resok resok; 635 default: 636 READLINK3resfail resfail; 637 }; 638 639 /* 640 * Arguments to read (v3). 641 */ 642 struct READ3args { 643 nfs_fh3 file; 644 offset3 offset; 645 count3 count; 646 }; 647 648 struct READ3resok { 649 post_op_attr file_attributes; 650 count3 count; 651 bool eof; 652 opaque data<>; 653 }; 654 655 struct READ3resfail { 656 post_op_attr file_attributes; 657 }; 658 659 /* XXX: solaris 2.6 uses ``nfsstat'' here */ 660 union READ3res switch (nfsstat3 status) { 661 case NFS3_OK: 662 READ3resok resok; 663 default: 664 READ3resfail resfail; 665 }; 666 667 /* 668 * Arguments to write (v3). 669 */ 670 enum stable_how { 671 UNSTABLE = 0, 672 DATA_SYNC = 1, 673 FILE_SYNC = 2 674 }; 675 676 struct WRITE3args { 677 nfs_fh3 file; 678 offset3 offset; 679 count3 count; 680 stable_how stable; 681 opaque data<>; 682 }; 683 684 struct WRITE3resok { 685 wcc_data file_wcc; 686 count3 count; 687 stable_how committed; 688 writeverf3 verf; 689 }; 690 691 struct WRITE3resfail { 692 wcc_data file_wcc; 693 }; 694 695 union WRITE3res switch (nfsstat3 status) { 696 case NFS3_OK: 697 WRITE3resok resok; 698 default: 699 WRITE3resfail resfail; 700 }; 701 702 /* 703 * Arguments to create (v3). 704 */ 705 enum createmode3 { 706 UNCHECKED = 0, 707 GUARDED = 1, 708 EXCLUSIVE = 2 709 }; 710 711 union createhow3 switch (createmode3 mode) { 712 case UNCHECKED: 713 case GUARDED: 714 sattr3 obj_attributes; 715 case EXCLUSIVE: 716 createverf3 verf; 717 }; 718 719 struct CREATE3args { 720 diropargs3 where; 721 createhow3 how; 722 }; 723 724 struct CREATE3resok { 725 post_op_fh3 obj; 726 post_op_attr obj_attributes; 727 wcc_data dir_wcc; 728 }; 729 730 struct CREATE3resfail { 731 wcc_data dir_wcc; 732 }; 733 734 union CREATE3res switch (nfsstat3 status) { 735 case NFS3_OK: 736 CREATE3resok resok; 737 default: 738 CREATE3resfail resfail; 739 }; 740 741 /* 742 * Arguments to mkdir (v3). 743 */ 744 struct MKDIR3args { 745 diropargs3 where; 746 sattr3 attributes; 747 }; 748 749 struct MKDIR3resok { 750 post_op_fh3 obj; 751 post_op_attr obj_attributes; 752 wcc_data dir_wcc; 753 }; 754 755 struct MKDIR3resfail { 756 wcc_data dir_wcc; 757 }; 758 759 union MKDIR3res switch (nfsstat3 status) { 760 case NFS3_OK: 761 MKDIR3resok resok; 762 default: 763 MKDIR3resfail resfail; 764 }; 765 766 /* 767 * Arguments to symlink (v3). 768 */ 769 struct symlinkdata3 { 770 sattr3 symlink_attributes; 771 nfspath3 symlink_data; 772 }; 773 774 struct SYMLINK3args { 775 diropargs3 where; 776 symlinkdata3 symlink; 777 }; 778 779 struct SYMLINK3resok { 780 post_op_fh3 obj; 781 post_op_attr obj_attributes; 782 wcc_data dir_wcc; 783 }; 784 785 struct SYMLINK3resfail { 786 wcc_data dir_wcc; 787 }; 788 789 union SYMLINK3res switch (nfsstat3 status) { 790 case NFS3_OK: 791 SYMLINK3resok resok; 792 default: 793 SYMLINK3resfail resfail; 794 }; 795 796 /* 797 * Arguments to mknod (v3). 798 */ 799 struct devicedata3 { 800 sattr3 dev_attributes; 801 specdata3 spec; 802 }; 803 804 union mknoddata3 switch (ftype3 type) { 805 case NF3CHR: 806 case NF3BLK: 807 devicedata3 device; 808 case NF3SOCK: 809 case NF3FIFO: 810 sattr3 pipe_attributes; 811 default: 812 void; 813 }; 814 815 struct MKNOD3args { 816 diropargs3 where; 817 mknoddata3 what; 818 }; 819 820 struct MKNOD3resok { 821 post_op_fh3 obj; 822 post_op_attr obj_attributes; 823 wcc_data dir_wcc; 824 }; 825 826 struct MKNOD3resfail { 827 wcc_data dir_wcc; 828 }; 829 830 union MKNOD3res switch (nfsstat3 status) { 831 case NFS3_OK: 832 MKNOD3resok resok; 833 default: 834 MKNOD3resfail resfail; 835 }; 836 837 /* 838 * Arguments to remove (v3). 839 */ 840 struct REMOVE3args { 841 diropargs3 object; 842 }; 843 844 struct REMOVE3resok { 845 wcc_data dir_wcc; 846 }; 847 848 struct REMOVE3resfail { 849 wcc_data dir_wcc; 850 }; 851 852 union REMOVE3res switch (nfsstat3 status) { 853 case NFS3_OK: 854 REMOVE3resok resok; 855 default: 856 REMOVE3resfail resfail; 857 }; 858 859 /* 860 * Arguments to rmdir (v3). 861 */ 862 struct RMDIR3args { 863 diropargs3 object; 864 }; 865 866 struct RMDIR3resok { 867 wcc_data dir_wcc; 868 }; 869 870 struct RMDIR3resfail { 871 wcc_data dir_wcc; 872 }; 873 874 union RMDIR3res switch (nfsstat3 status) { 875 case NFS3_OK: 876 RMDIR3resok resok; 877 default: 878 RMDIR3resfail resfail; 879 }; 880 881 /* 882 * Arguments to rename (v3). 883 */ 884 struct RENAME3args { 885 diropargs3 from; 886 diropargs3 to; 887 }; 888 889 struct RENAME3resok { 890 wcc_data fromdir_wcc; 891 wcc_data todir_wcc; 892 }; 893 894 struct RENAME3resfail { 895 wcc_data fromdir_wcc; 896 wcc_data todir_wcc; 897 }; 898 899 union RENAME3res switch (nfsstat3 status) { 900 case NFS3_OK: 901 RENAME3resok resok; 902 default: 903 RENAME3resfail resfail; 904 }; 905 906 /* 907 * Arguments to link (v3). 908 */ 909 struct LINK3args { 910 nfs_fh3 file; 911 diropargs3 link; 912 }; 913 914 struct LINK3resok { 915 post_op_attr file_attributes; 916 wcc_data linkdir_wcc; 917 }; 918 919 struct LINK3resfail { 920 post_op_attr file_attributes; 921 wcc_data linkdir_wcc; 922 }; 923 924 union LINK3res switch (nfsstat3 status) { 925 case NFS3_OK: 926 LINK3resok resok; 927 default: 928 LINK3resfail resfail; 929 }; 930 931 /* 932 * Arguments to readdir (v3). 933 */ 934 struct READDIR3args { 935 nfs_fh3 dir; 936 cookie3 cookie; 937 cookieverf3 cookieverf; 938 count3 count; 939 }; 940 941 struct entry3 { 942 fileid3 fileid; 943 filename3 name; 944 cookie3 cookie; 945 entry3 *nextentry; 946 }; 947 948 struct dirlist3 { 949 entry3 *entries; 950 bool eof; 951 }; 952 953 struct READDIR3resok { 954 post_op_attr dir_attributes; 955 cookieverf3 cookieverf; 956 dirlist3 reply; 957 }; 958 959 struct READDIR3resfail { 960 post_op_attr dir_attributes; 961 }; 962 963 union READDIR3res switch (nfsstat3 status) { 964 case NFS3_OK: 965 READDIR3resok resok; 966 default: 967 READDIR3resfail resfail; 968 }; 969 970 /* 971 * Arguments to readdirplus (v3). 972 */ 973 struct READDIRPLUS3args { 974 nfs_fh3 dir; 975 cookie3 cookie; 976 cookieverf3 cookieverf; 977 count3 dircount; 978 count3 maxcount; 979 }; 980 981 struct entryplus3 { 982 fileid3 fileid; 983 filename3 name; 984 cookie3 cookie; 985 post_op_attr name_attributes; 986 post_op_fh3 name_handle; 987 entryplus3 *nextentry; 988 }; 989 990 struct dirlistplus3 { 991 entryplus3 *entries; 992 bool eof; 993 }; 994 995 struct READDIRPLUS3resok { 996 post_op_attr dir_attributes; 997 cookieverf3 cookieverf; 998 dirlistplus3 reply; 999 }; 1000 1001 struct READDIRPLUS3resfail { 1002 post_op_attr dir_attributes; 1003 }; 1004 1005 union READDIRPLUS3res switch (nfsstat3 status) { 1006 case NFS3_OK: 1007 READDIRPLUS3resok resok; 1008 default: 1009 READDIRPLUS3resfail resfail; 1010 }; 1011 1012 /* 1013 * Arguments to fsstat (v3). 1014 */ 1015 struct FSSTAT3args { 1016 nfs_fh3 fsroot; 1017 }; 1018 1019 struct FSSTAT3resok { 1020 post_op_attr obj_attributes; 1021 size3 tbytes; 1022 size3 fbytes; 1023 size3 abytes; 1024 size3 tfiles; 1025 size3 ffiles; 1026 size3 afiles; 1027 uint32 invarsec; 1028 }; 1029 1030 struct FSSTAT3resfail { 1031 post_op_attr obj_attributes; 1032 }; 1033 1034 union FSSTAT3res switch (nfsstat3 status) { 1035 case NFS3_OK: 1036 FSSTAT3resok resok; 1037 default: 1038 FSSTAT3resfail resfail; 1039 }; 1040 1041 /* 1042 * Arguments to fsinfo (v3). 1043 */ 1044 const FSF3_LINK = 0x0001; 1045 const FSF3_SYMLINK = 0x0002; 1046 const FSF3_HOMOGENEOUS = 0x0008; 1047 const FSF3_CANSETTIME = 0x0010; 1048 1049 struct FSINFO3args { 1050 nfs_fh3 fsroot; 1051 }; 1052 1053 struct FSINFO3resok { 1054 post_op_attr obj_attributes; 1055 uint32 rtmax; 1056 uint32 rtpref; 1057 uint32 rtmult; 1058 uint32 wtmax; 1059 uint32 wtpref; 1060 uint32 wtmult; 1061 uint32 dtpref; 1062 size3 maxfilesize; 1063 nfstime3 time_delta; 1064 uint32 properties; 1065 }; 1066 1067 struct FSINFO3resfail { 1068 post_op_attr obj_attributes; 1069 }; 1070 1071 union FSINFO3res switch (nfsstat3 status) { 1072 case NFS3_OK: 1073 FSINFO3resok resok; 1074 default: 1075 FSINFO3resfail resfail; 1076 }; 1077 1078 /* 1079 * Arguments to pathconf (v3). 1080 */ 1081 struct PATHCONF3args { 1082 nfs_fh3 object; 1083 }; 1084 1085 struct PATHCONF3resok { 1086 post_op_attr obj_attributes; 1087 uint32 linkmax; 1088 uint32 name_max; 1089 bool no_trunc; 1090 bool chown_restricted; 1091 bool case_insensitive; 1092 bool case_preserving; 1093 }; 1094 1095 struct PATHCONF3resfail { 1096 post_op_attr obj_attributes; 1097 }; 1098 1099 union PATHCONF3res switch (nfsstat3 status) { 1100 case NFS3_OK: 1101 PATHCONF3resok resok; 1102 default: 1103 PATHCONF3resfail resfail; 1104 }; 1105 1106 /* 1107 * Arguments to commit (v3). 1108 */ 1109 struct COMMIT3args { 1110 nfs_fh3 file; 1111 offset3 offset; 1112 count3 count; 1113 }; 1114 1115 struct COMMIT3resok { 1116 wcc_data file_wcc; 1117 writeverf3 verf; 1118 }; 1119 1120 struct COMMIT3resfail { 1121 wcc_data file_wcc; 1122 }; 1123 1124 union COMMIT3res switch (nfsstat3 status) { 1125 case NFS3_OK: 1126 COMMIT3resok resok; 1127 default: 1128 COMMIT3resfail resfail; 1129 }; 1130 1131 /* 1132 * Remote file service routines 1133 */ 1134 program NFS_PROGRAM { 1135 version NFS_VERSION { 1136 void 1137 NFSPROC_NULL(void) = 0; 1138 1139 attrstat 1140 NFSPROC_GETATTR(nfs_fh) = 1; 1141 1142 attrstat 1143 NFSPROC_SETATTR(sattrargs) = 2; 1144 1145 void 1146 NFSPROC_ROOT(void) = 3; 1147 1148 diropres 1149 NFSPROC_LOOKUP(diropargs) = 4; 1150 1151 readlinkres 1152 NFSPROC_READLINK(nfs_fh) = 5; 1153 1154 readres 1155 NFSPROC_READ(readargs) = 6; 1156 1157 void 1158 NFSPROC_WRITECACHE(void) = 7; 1159 1160 attrstat 1161 NFSPROC_WRITE(writeargs) = 8; 1162 1163 diropres 1164 NFSPROC_CREATE(createargs) = 9; 1165 1166 nfsstat 1167 NFSPROC_REMOVE(diropargs) = 10; 1168 1169 nfsstat 1170 NFSPROC_RENAME(renameargs) = 11; 1171 1172 nfsstat 1173 NFSPROC_LINK(linkargs) = 12; 1174 1175 nfsstat 1176 NFSPROC_SYMLINK(symlinkargs) = 13; 1177 1178 diropres 1179 NFSPROC_MKDIR(createargs) = 14; 1180 1181 nfsstat 1182 NFSPROC_RMDIR(diropargs) = 15; 1183 1184 readdirres 1185 NFSPROC_READDIR(readdirargs) = 16; 1186 1187 statfsres 1188 NFSPROC_STATFS(nfs_fh) = 17; 1189 } = 2; 1190 version NFS_V3 { 1191 void 1192 NFSPROC3_NULL(void) = 0; 1193 1194 GETATTR3res 1195 NFSPROC3_GETATTR(GETATTR3args) = 1; 1196 1197 SETATTR3res 1198 NFSPROC3_SETATTR(SETATTR3args) = 2; 1199 1200 LOOKUP3res 1201 NFSPROC3_LOOKUP(LOOKUP3args) = 3; 1202 1203 ACCESS3res 1204 NFSPROC3_ACCESS(ACCESS3args) = 4; 1205 1206 READLINK3res 1207 NFSPROC3_READLINK(READLINK3args) = 5; 1208 1209 READ3res 1210 NFSPROC3_READ(READ3args) = 6; 1211 1212 WRITE3res 1213 NFSPROC3_WRITE(WRITE3args) = 7; 1214 1215 CREATE3res 1216 NFSPROC3_CREATE(CREATE3args) = 8; 1217 1218 MKDIR3res 1219 NFSPROC3_MKDIR(MKDIR3args) = 9; 1220 1221 SYMLINK3res 1222 NFSPROC3_SYMLINK(SYMLINK3args) = 10; 1223 1224 MKNOD3res 1225 NFSPROC3_MKNOD(MKNOD3args) = 11; 1226 1227 REMOVE3res 1228 NFSPROC3_REMOVE(REMOVE3args) = 12; 1229 1230 RMDIR3res 1231 NFSPROC3_RMDIR(RMDIR3args) = 13; 1232 1233 RENAME3res 1234 NFSPROC3_RENAME(RENAME3args) = 14; 1235 1236 LINK3res 1237 NFSPROC3_LINK(LINK3args) = 15; 1238 1239 READDIR3res 1240 NFSPROC3_READDIR(READDIR3args) = 16; 1241 1242 READDIRPLUS3res 1243 NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17; 1244 1245 FSSTAT3res 1246 NFSPROC3_FSSTAT(FSSTAT3args) = 18; 1247 1248 FSINFO3res 1249 NFSPROC3_FSINFO(FSINFO3args) = 19; 1250 1251 PATHCONF3res 1252 NFSPROC3_PATHCONF(PATHCONF3args) = 20; 1253 1254 COMMIT3res 1255 NFSPROC3_COMMIT(COMMIT3args) = 21; 1256 } = 3; 1257 } = 100003; 1258 1259