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