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