xref: /titanic_52/usr/src/head/rpcsvc/nfs4_prot.x (revision f42c2f535d941f602630ea3db3eaf6e956bd4138)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  *  Copyright (C) The Internet Society (1998-2003).
23  *  All Rights Reserved.
24  */
25 
26 /*
27  *	nfs4_prot.x
28  */
29 
30 /*
31  * Basic typedefs for RFC 1832 data type definitions
32  */
33 
34 /*
35  * typedef int		int32_t;
36  * typedef unsigned int	uint32_t;
37  * typedef hyper		int64_t;
38  * typedef unsigned hyper	uint64_t;
39  */
40 
41 /*
42  * Sizes
43  */
44 const NFS4_FHSIZE		= 128;
45 const NFS4_VERIFIER_SIZE	= 8;
46 const NFS4_OPAQUE_LIMIT		= 1024;
47 
48 /*
49  * File types
50  */
51 enum nfs_ftype4 {
52 	NF4REG		= 1,	/* Regular File */
53 	NF4DIR		= 2,	/* Directory */
54 	NF4BLK		= 3,	/* Special File - block device */
55 	NF4CHR		= 4,	/* Special File - character device */
56 	NF4LNK		= 5,	/* Symbolic Link */
57 	NF4SOCK		= 6,	/* Special File - socket */
58 	NF4FIFO		= 7,	/* Special File - fifo */
59 	NF4ATTRDIR	= 8,	/* Attribute Directory */
60 	NF4NAMEDATTR	= 9	/* Named Attribute */
61 };
62 
63 /*
64  * Error status
65  */
66 enum nfsstat4 {
67 	NFS4_OK			= 0,    /* everything is okay      */
68 	NFS4ERR_PERM		= 1,    /* caller not privileged   */
69 	NFS4ERR_NOENT		= 2,    /* no such file/directory  */
70 	NFS4ERR_IO		= 5,    /* hard I/O error          */
71 	NFS4ERR_NXIO		= 6,    /* no such device          */
72 	NFS4ERR_ACCESS		= 13,   /* access denied           */
73 	NFS4ERR_EXIST		= 17,   /* file already exists     */
74 	NFS4ERR_XDEV		= 18,   /* different filesystems   */
75 	/* Unused/reserved        19 */
76 	NFS4ERR_NOTDIR		= 20,   /* should be a directory   */
77 	NFS4ERR_ISDIR		= 21,   /* should not be directory */
78 	NFS4ERR_INVAL		= 22,   /* invalid argument        */
79 	NFS4ERR_FBIG		= 27,   /* file exceeds server max */
80 	NFS4ERR_NOSPC		= 28,   /* no space on filesystem  */
81 	NFS4ERR_ROFS		= 30,   /* read-only filesystem    */
82 	NFS4ERR_MLINK		= 31,   /* too many hard links     */
83 	NFS4ERR_NAMETOOLONG	= 63,   /* name exceeds server max */
84 	NFS4ERR_NOTEMPTY	= 66,   /* directory not empty     */
85 	NFS4ERR_DQUOT		= 69,   /* hard quota limit reached*/
86 	NFS4ERR_STALE		= 70,   /* file no longer exists   */
87 	NFS4ERR_BADHANDLE	= 10001,/* Illegal filehandle      */
88 	NFS4ERR_BAD_COOKIE	= 10003,/* READDIR cookie is stale */
89 	NFS4ERR_NOTSUPP		= 10004,/* operation not supported */
90 	NFS4ERR_TOOSMALL	= 10005,/* response limit exceeded */
91 	NFS4ERR_SERVERFAULT	= 10006,/* undefined server error  */
92 	NFS4ERR_BADTYPE		= 10007,/* type invalid for CREATE */
93 	NFS4ERR_DELAY		= 10008,/* file "busy" - retry     */
94 	NFS4ERR_SAME		= 10009,/* nverify says attrs same */
95 	NFS4ERR_DENIED		= 10010,/* lock unavailable	   */
96 	NFS4ERR_EXPIRED		= 10011,/* lock lease expired	   */
97 	NFS4ERR_LOCKED		= 10012,/* I/O failed due to lock  */
98 	NFS4ERR_GRACE		= 10013,/* in grace period	   */
99 	NFS4ERR_FHEXPIRED	= 10014,/* filehandle expired	   */
100 	NFS4ERR_SHARE_DENIED	= 10015,/* share reserve denied	   */
101 	NFS4ERR_WRONGSEC	= 10016,/* wrong security flavor   */
102 	NFS4ERR_CLID_INUSE	= 10017,/* clientid in use	   */
103 	NFS4ERR_RESOURCE	= 10018,/* resource exhaustion	   */
104 	NFS4ERR_MOVED		= 10019,/* filesystem relocated	   */
105 	NFS4ERR_NOFILEHANDLE	= 10020,/* current FH is not set   */
106 	NFS4ERR_MINOR_VERS_MISMATCH = 10021,/* minor vers not supp */
107 	NFS4ERR_STALE_CLIENTID	= 10022,/* server has rebooted     */
108 	NFS4ERR_STALE_STATEID	= 10023,/* server has rebooted     */
109 	NFS4ERR_OLD_STATEID	= 10024,/* state is out of sync    */
110 	NFS4ERR_BAD_STATEID	= 10025,/* incorrect stateid       */
111 	NFS4ERR_BAD_SEQID	= 10026,/* request is out of seq.  */
112 	NFS4ERR_NOT_SAME	= 10027,/* verify - attrs not same */
113 	NFS4ERR_LOCK_RANGE	= 10028,/* lock range not supported*/
114 	NFS4ERR_SYMLINK		= 10029,/* should be file/directory*/
115 	NFS4ERR_RESTOREFH	= 10030,/* no saved filehandle     */
116 	NFS4ERR_LEASE_MOVED	= 10031,/* some filesystem moved   */
117 	NFS4ERR_ATTRNOTSUPP	= 10032,/* recommended attr not sup*/
118 	NFS4ERR_NO_GRACE	= 10033,/* reclaim outside of grace*/
119 	NFS4ERR_RECLAIM_BAD	= 10034,/* reclaim error at server */
120 	NFS4ERR_RECLAIM_CONFLICT = 10035,/* conflict on reclaim    */
121 	NFS4ERR_BADXDR		= 10036,/* XDR decode failed       */
122 	NFS4ERR_LOCKS_HELD	= 10037,/* file locks held at CLOSE*/
123 	NFS4ERR_OPENMODE	= 10038,/* conflict in OPEN and I/O*/
124 	NFS4ERR_BADOWNER	= 10039,/* owner translation bad   */
125 	NFS4ERR_BADCHAR		= 10040,/* utf-8 char not supported*/
126 	NFS4ERR_BADNAME		= 10041,/* name not supported      */
127 	NFS4ERR_BAD_RANGE	= 10042,/* lock range not supported*/
128 	NFS4ERR_LOCK_NOTSUPP	= 10043,/* no atomic up/downgrade  */
129 	NFS4ERR_OP_ILLEGAL	= 10044,/* undefined operation     */
130 	NFS4ERR_DEADLOCK	= 10045,/* file locking deadlock   */
131 	NFS4ERR_FILE_OPEN	= 10046,/* open file blocks op.    */
132 	NFS4ERR_ADMIN_REVOKED	= 10047,/* lockowner state revoked */
133 	NFS4ERR_CB_PATH_DOWN    = 10048 /* callback path down      */
134 };
135 
136 /*
137  * Basic data types
138  */
139 typedef uint32_t	bitmap4<>;
140 typedef uint64_t	offset4;
141 typedef uint32_t	count4;
142 typedef	uint64_t	length4;
143 typedef uint64_t	clientid4;
144 typedef uint32_t	seqid4;
145 typedef opaque		utf8string<>;
146 typedef utf8string	utf8str_cis;
147 typedef utf8string	utf8str_cs;
148 typedef utf8string	utf8str_mixed;
149 typedef utf8str_cs	component4;
150 typedef	component4	pathname4<>;
151 typedef uint64_t	nfs_lockid4;
152 typedef	uint64_t	nfs_cookie4;
153 typedef	utf8str_cs	linktext4;
154 typedef opaque		sec_oid4<>;
155 typedef uint32_t	qop4;
156 typedef	uint32_t	mode4;
157 typedef	uint64_t	changeid4;
158 typedef opaque		verifier4[NFS4_VERIFIER_SIZE];
159 
160 /*
161  * Timeval
162  */
163 struct nfstime4 {
164 	int64_t		seconds;
165 	uint32_t	nseconds;
166 };
167 
168 enum time_how4 {
169 	SET_TO_SERVER_TIME4 = 0,
170 	SET_TO_CLIENT_TIME4 = 1
171 };
172 
173 union settime4 switch (time_how4 set_it) {
174  case SET_TO_CLIENT_TIME4:
175 	 nfstime4	time;
176  default:
177 	 void;
178 };
179 
180 /*
181  * File access handle
182  */
183 typedef	opaque	nfs_fh4<NFS4_FHSIZE>;
184 
185 
186 /*
187  * File attribute definitions
188  */
189 
190 /*
191  * FSID structure for major/minor
192  */
193 struct fsid4 {
194 	uint64_t	major;
195 	uint64_t	minor;
196 };
197 
198 /*
199  * Filesystem locations attribute for relocation/migration
200  */
201 struct fs_location4 {
202 	utf8str_cis	server<>;
203 	pathname4	rootpath;
204 };
205 
206 struct fs_locations4 {
207 	pathname4	fs_root;
208 	fs_location4	locations<>;
209 };
210 
211 struct nfs_fsl_info {
212 	uint_t			netbuf_len;
213 	uint_t			netnm_len;
214 	uint_t			knconf_len;
215 	string			netname<MAXNETNAMELEN>;
216 	struct netbuf		*addr;
217 	struct knetconfig	*knconf;
218 };
219 
220 
221 /*
222  * Various Access Control Entry definitions
223  */
224 
225 /*
226  * Mask that indicates which Access Control Entries are supported.
227  * Values for the fattr4_aclsupport attribute.
228  */
229 const ACL4_SUPPORT_ALLOW_ACL	= 0x00000001;
230 const ACL4_SUPPORT_DENY_ACL	= 0x00000002;
231 const ACL4_SUPPORT_AUDIT_ACL	= 0x00000004;
232 const ACL4_SUPPORT_ALARM_ACL	= 0x00000008;
233 
234 
235 typedef	uint32_t	acetype4;
236 
237 /*
238  * acetype4 values, others can be added as needed.
239  */
240 const ACE4_ACCESS_ALLOWED_ACE_TYPE	= 0x00000000;
241 const ACE4_ACCESS_DENIED_ACE_TYPE	= 0x00000001;
242 const ACE4_SYSTEM_AUDIT_ACE_TYPE	= 0x00000002;
243 const ACE4_SYSTEM_ALARM_ACE_TYPE	= 0x00000003;
244 
245 
246 /*
247  * ACE flag
248  */
249 typedef uint32_t aceflag4;
250 
251 /*
252  * ACE flag values
253  */
254 const ACE4_FILE_INHERIT_ACE		= 0x00000001;
255 const ACE4_DIRECTORY_INHERIT_ACE	= 0x00000002;
256 const ACE4_NO_PROPAGATE_INHERIT_ACE	= 0x00000004;
257 const ACE4_INHERIT_ONLY_ACE		= 0x00000008;
258 const ACE4_SUCCESSFUL_ACCESS_ACE_FLAG	= 0x00000010;
259 const ACE4_FAILED_ACCESS_ACE_FLAG	= 0x00000020;
260 const ACE4_IDENTIFIER_GROUP		= 0x00000040;
261 
262 
263 /*
264  * ACE mask
265  */
266 typedef uint32_t	acemask4;
267 
268 /*
269  * ACE mask values
270  */
271 const ACE4_READ_DATA		= 0x00000001;
272 const ACE4_LIST_DIRECTORY	= 0x00000001;
273 const ACE4_WRITE_DATA		= 0x00000002;
274 const ACE4_ADD_FILE		= 0x00000002;
275 const ACE4_APPEND_DATA		= 0x00000004;
276 const ACE4_ADD_SUBDIRECTORY	= 0x00000004;
277 const ACE4_READ_NAMED_ATTRS	= 0x00000008;
278 const ACE4_WRITE_NAMED_ATTRS	= 0x00000010;
279 const ACE4_EXECUTE		= 0x00000020;
280 const ACE4_DELETE_CHILD		= 0x00000040;
281 const ACE4_READ_ATTRIBUTES	= 0x00000080;
282 const ACE4_WRITE_ATTRIBUTES	= 0x00000100;
283 
284 const ACE4_DELETE		= 0x00010000;
285 const ACE4_READ_ACL		= 0x00020000;
286 const ACE4_WRITE_ACL		= 0x00040000;
287 const ACE4_WRITE_OWNER		= 0x00080000;
288 const ACE4_SYNCHRONIZE		= 0x00100000;
289 
290 /*
291  * ACE4_GENERIC_READ -- defined as combination of
292  *	ACE4_READ_ACL |
293  *	ACE4_READ_DATA |
294  *	ACE4_READ_ATTRIBUTES |
295  *	ACE4_SYNCHRONIZE
296  */
297 
298 const ACE4_GENERIC_READ	= 0x00120081;
299 
300 /*
301  * ACE4_GENERIC_WRITE -- defined as combination of
302  *	ACE4_READ_ACL |
303  *	ACE4_WRITE_DATA |
304  *	ACE4_WRITE_ATTRIBUTES |
305  *	ACE4_WRITE_ACL |
306  *	ACE4_APPEND_DATA |
307  *	ACE4_SYNCHRONIZE
308  */
309 const ACE4_GENERIC_WRITE = 0x00160106;
310 
311 
312 /*
313  * ACE4_GENERIC_EXECUTE -- defined as combination of
314  *	ACE4_READ_ACL
315  *	ACE4_READ_ATTRIBUTES
316  *	ACE4_EXECUTE
317  *	ACE4_SYNCHRONIZE
318  */
319 const ACE4_GENERIC_EXECUTE = 0x001200A0;
320 
321 
322 /*
323  * Access Control Entry definition
324  */
325 struct nfsace4 {
326 	acetype4	type;
327 	aceflag4	flag;
328 	acemask4	access_mask;
329 	utf8str_mixed	who;
330 };
331 
332 /*
333  * Field definitions for the fattr4_mode attribute
334  */
335 const MODE4_SUID = 0x800;  /* set user id on execution */
336 const MODE4_SGID = 0x400;  /* set group id on execution */
337 const MODE4_SVTX = 0x200;  /* save text even after use */
338 const MODE4_RUSR = 0x100;  /* read permission: owner */
339 const MODE4_WUSR = 0x080;  /* write permission: owner */
340 const MODE4_XUSR = 0x040;  /* execute permission: owner */
341 const MODE4_RGRP = 0x020;  /* read permission: group */
342 const MODE4_WGRP = 0x010;  /* write permission: group */
343 const MODE4_XGRP = 0x008;  /* execute permission: group */
344 const MODE4_ROTH = 0x004;  /* read permission: other */
345 const MODE4_WOTH = 0x002;  /* write permission: other */
346 const MODE4_XOTH = 0x001;  /* execute permission: other */
347 
348 /*
349  * Special data/attribute associated with
350  * file types NF4BLK and NF4CHR.
351  */
352 struct specdata4 {
353 	uint32_t	specdata1;	/* major device number */
354 	uint32_t	specdata2;	/* minor device number */
355 };
356 
357 /*
358  * Values for fattr4_fh_expire_type
359  */
360 const	FH4_PERSISTENT		= 0x00000000;
361 const	FH4_NOEXPIRE_WITH_OPEN	= 0x00000001;
362 const	FH4_VOLATILE_ANY	= 0x00000002;
363 const	FH4_VOL_MIGRATION	= 0x00000004;
364 const	FH4_VOL_RENAME		= 0x00000008;
365 
366 
367 typedef bitmap4		fattr4_supported_attrs;
368 typedef nfs_ftype4	fattr4_type;
369 typedef	uint32_t	fattr4_fh_expire_type;
370 typedef	changeid4	fattr4_change;
371 typedef uint64_t	fattr4_size;
372 typedef	bool		fattr4_link_support;
373 typedef	bool		fattr4_symlink_support;
374 typedef bool		fattr4_named_attr;
375 typedef fsid4		fattr4_fsid;
376 typedef	bool		fattr4_unique_handles;
377 typedef uint32_t	fattr4_lease_time;
378 typedef	nfsstat4	fattr4_rdattr_error;
379 
380 typedef nfsace4		fattr4_acl<>;
381 typedef uint32_t	fattr4_aclsupport;
382 typedef	bool		fattr4_archive;
383 typedef	bool		fattr4_cansettime;
384 typedef	bool		fattr4_case_insensitive;
385 typedef	bool		fattr4_case_preserving;
386 typedef	bool		fattr4_chown_restricted;
387 typedef uint64_t	fattr4_fileid;
388 typedef uint64_t	fattr4_files_avail;
389 typedef nfs_fh4		fattr4_filehandle;
390 typedef uint64_t	fattr4_files_free;
391 typedef uint64_t	fattr4_files_total;
392 typedef fs_locations4	fattr4_fs_locations;
393 typedef bool		fattr4_hidden;
394 typedef bool		fattr4_homogeneous;
395 typedef uint64_t	fattr4_maxfilesize;
396 typedef uint32_t	fattr4_maxlink;
397 typedef uint32_t	fattr4_maxname;
398 typedef uint64_t	fattr4_maxread;
399 typedef uint64_t	fattr4_maxwrite;
400 typedef	utf8str_cs	fattr4_mimetype;
401 typedef mode4		fattr4_mode;
402 typedef uint64_t	fattr4_mounted_on_fileid;
403 typedef	bool		fattr4_no_trunc;
404 typedef	uint32_t	fattr4_numlinks;
405 typedef	utf8str_mixed	fattr4_owner;
406 typedef	utf8str_mixed	fattr4_owner_group;
407 typedef uint64_t	fattr4_quota_avail_hard;
408 typedef uint64_t	fattr4_quota_avail_soft;
409 typedef uint64_t	fattr4_quota_used;
410 typedef specdata4	fattr4_rawdev;
411 typedef uint64_t	fattr4_space_avail;
412 typedef uint64_t	fattr4_space_free;
413 typedef uint64_t	fattr4_space_total;
414 typedef uint64_t	fattr4_space_used;
415 typedef bool		fattr4_system;
416 typedef nfstime4	fattr4_time_access;
417 typedef settime4	fattr4_time_access_set;
418 typedef nfstime4	fattr4_time_backup;
419 typedef nfstime4	fattr4_time_create;
420 typedef nfstime4	fattr4_time_delta;
421 typedef nfstime4	fattr4_time_metadata;
422 typedef nfstime4	fattr4_time_modify;
423 typedef settime4	fattr4_time_modify_set;
424 
425 
426 /*
427  * Mandatory Attributes
428  */
429 const FATTR4_SUPPORTED_ATTRS	= 0;
430 const FATTR4_TYPE		= 1;
431 const FATTR4_FH_EXPIRE_TYPE	= 2;
432 const FATTR4_CHANGE		= 3;
433 const FATTR4_SIZE		= 4;
434 const FATTR4_LINK_SUPPORT	= 5;
435 const FATTR4_SYMLINK_SUPPORT	= 6;
436 const FATTR4_NAMED_ATTR		= 7;
437 const FATTR4_FSID		= 8;
438 const FATTR4_UNIQUE_HANDLES	= 9;
439 const FATTR4_LEASE_TIME		= 10;
440 const FATTR4_RDATTR_ERROR	= 11;
441 const FATTR4_FILEHANDLE		= 19;
442 
443 /*
444  * Recommended Attributes
445  */
446 const FATTR4_ACL		= 12;
447 const FATTR4_ACLSUPPORT		= 13;
448 const FATTR4_ARCHIVE		= 14;
449 const FATTR4_CANSETTIME		= 15;
450 const FATTR4_CASE_INSENSITIVE	= 16;
451 const FATTR4_CASE_PRESERVING	= 17;
452 const FATTR4_CHOWN_RESTRICTED	= 18;
453 const FATTR4_FILEID		= 20;
454 const FATTR4_FILES_AVAIL	= 21;
455 const FATTR4_FILES_FREE		= 22;
456 const FATTR4_FILES_TOTAL	= 23;
457 const FATTR4_FS_LOCATIONS	= 24;
458 const FATTR4_HIDDEN		= 25;
459 const FATTR4_HOMOGENEOUS	= 26;
460 const FATTR4_MAXFILESIZE	= 27;
461 const FATTR4_MAXLINK		= 28;
462 const FATTR4_MAXNAME		= 29;
463 const FATTR4_MAXREAD		= 30;
464 const FATTR4_MAXWRITE		= 31;
465 const FATTR4_MIMETYPE		= 32;
466 const FATTR4_MODE		= 33;
467 const FATTR4_NO_TRUNC		= 34;
468 const FATTR4_NUMLINKS		= 35;
469 const FATTR4_OWNER		= 36;
470 const FATTR4_OWNER_GROUP	= 37;
471 const FATTR4_QUOTA_AVAIL_HARD	= 38;
472 const FATTR4_QUOTA_AVAIL_SOFT	= 39;
473 const FATTR4_QUOTA_USED		= 40;
474 const FATTR4_RAWDEV		= 41;
475 const FATTR4_SPACE_AVAIL	= 42;
476 const FATTR4_SPACE_FREE		= 43;
477 const FATTR4_SPACE_TOTAL	= 44;
478 const FATTR4_SPACE_USED		= 45;
479 const FATTR4_SYSTEM		= 46;
480 const FATTR4_TIME_ACCESS	= 47;
481 const FATTR4_TIME_ACCESS_SET	= 48;
482 const FATTR4_TIME_BACKUP	= 49;
483 const FATTR4_TIME_CREATE	= 50;
484 const FATTR4_TIME_DELTA		= 51;
485 const FATTR4_TIME_METADATA	= 52;
486 const FATTR4_TIME_MODIFY	= 53;
487 const FATTR4_TIME_MODIFY_SET	= 54;
488 const FATTR4_MOUNTED_ON_FILEID	= 55;
489 
490 typedef	opaque	attrlist4<>;
491 
492 /*
493  * File attribute container
494  */
495 struct fattr4 {
496 	bitmap4		attrmask;
497 	attrlist4	attr_vals;
498 };
499 
500 /*
501  * Change info for the client
502  */
503 struct change_info4 {
504 	bool		atomic;
505 	changeid4	before;
506 	changeid4	after;
507 };
508 
509 struct clientaddr4 {
510 	/* see struct rpcb in RFC 1833 */
511 	string r_netid<>;		/* network id */
512 	string r_addr<>;		/* universal address */
513 };
514 
515 /*
516  * Callback program info as provided by the client
517  */
518 struct cb_client4 {
519 	uint32_t	cb_program;
520 	clientaddr4	cb_location;
521 };
522 
523 /*
524  * Stateid
525  */
526 struct stateid4 {
527 	uint32_t	seqid;
528 	opaque		other[12];
529 };
530 
531 /*
532  * Client ID
533  */
534 struct nfs_client_id4 {
535 	verifier4	verifier;
536 	opaque		id<NFS4_OPAQUE_LIMIT>;
537 };
538 
539 struct open_owner4 {
540 	clientid4	clientid;
541 	opaque		owner<NFS4_OPAQUE_LIMIT>;
542 };
543 
544 struct lock_owner4 {
545 	clientid4	clientid;
546 	opaque		owner<NFS4_OPAQUE_LIMIT>;
547 };
548 
549 enum nfs_lock_type4 {
550 	READ_LT		= 1,
551 	WRITE_LT	= 2,
552 	READW_LT	= 3,	/* blocking read */
553 	WRITEW_LT	= 4	/* blocking write */
554 };
555 
556 /*
557  * ACCESS: Check access permission
558  */
559 const ACCESS4_READ	= 0x00000001;
560 const ACCESS4_LOOKUP	= 0x00000002;
561 const ACCESS4_MODIFY	= 0x00000004;
562 const ACCESS4_EXTEND	= 0x00000008;
563 const ACCESS4_DELETE	= 0x00000010;
564 const ACCESS4_EXECUTE	= 0x00000020;
565 
566 struct ACCESS4args {
567 	/* CURRENT_FH: object */
568 	uint32_t	access;
569 };
570 
571 struct ACCESS4resok {
572 	uint32_t	supported;
573 	uint32_t	access;
574 };
575 
576 union ACCESS4res switch (nfsstat4 status) {
577  case NFS4_OK:
578 	 ACCESS4resok	resok4;
579  default:
580 	 void;
581 };
582 
583 /*
584  * CLOSE: Close a file and release share reservations
585  */
586 struct CLOSE4args {
587 	/* CURRENT_FH: object */
588 	seqid4		seqid;
589 	stateid4	open_stateid;
590 };
591 
592 union CLOSE4res switch (nfsstat4 status) {
593  case NFS4_OK:
594 	 stateid4	open_stateid;
595  default:
596 	 void;
597 };
598 
599 /*
600  * COMMIT: Commit cached data on server to stable storage
601  */
602 struct COMMIT4args {
603 	/* CURRENT_FH: file */
604 	offset4		offset;
605 	count4		count;
606 };
607 
608 struct COMMIT4resok {
609 	verifier4	writeverf;
610 };
611 
612 
613 union COMMIT4res switch (nfsstat4 status) {
614  case NFS4_OK:
615 	 COMMIT4resok	resok4;
616  default:
617 	 void;
618 };
619 
620 /*
621  * CREATE: Create a non-regular file
622  */
623 union createtype4 switch (nfs_ftype4 type) {
624  case NF4LNK:
625 	 linktext4	linkdata;
626  case NF4BLK:
627  case NF4CHR:
628 	 specdata4	devdata;
629  case NF4SOCK:
630  case NF4FIFO:
631  case NF4DIR:
632 	 void;
633  default:
634 	 void;		/* server should return NFS4ERR_BADTYPE */
635 };
636 
637 struct CREATE4args {
638 	/* CURRENT_FH: directory for creation */
639 	createtype4	objtype;
640 	component4	objname;
641 	fattr4		createattrs;
642 };
643 
644 struct CREATE4resok {
645 	change_info4	cinfo;
646 	bitmap4		attrset;	/* attributes set */
647 };
648 
649 union CREATE4res switch (nfsstat4 status) {
650  case NFS4_OK:
651 	 CREATE4resok resok4;
652  default:
653 	 void;
654 };
655 
656 /*
657  * DELEGPURGE: Purge Delegations Awaiting Recovery
658  */
659 struct DELEGPURGE4args {
660 	clientid4	clientid;
661 };
662 
663 struct DELEGPURGE4res {
664 	nfsstat4	status;
665 };
666 
667 /*
668  * DELEGRETURN: Return a delegation
669  */
670 struct DELEGRETURN4args {
671 	/* CURRENT_FH: delegated file */
672 	stateid4	deleg_stateid;
673 };
674 
675 struct DELEGRETURN4res {
676 	nfsstat4	status;
677 };
678 
679 /*
680  * GETATTR: Get file attributes
681  */
682 struct GETATTR4args {
683 	/* CURRENT_FH: directory or file */
684 	bitmap4		attr_request;
685 };
686 
687 struct GETATTR4resok {
688 	fattr4		obj_attributes;
689 };
690 
691 union GETATTR4res switch (nfsstat4 status) {
692  case NFS4_OK:
693 	 GETATTR4resok	resok4;
694  default:
695 	 void;
696 };
697 
698 /*
699  * GETFH: Get current filehandle
700  */
701 struct GETFH4resok {
702 	nfs_fh4		object;
703 };
704 
705 union GETFH4res switch (nfsstat4 status) {
706  case NFS4_OK:
707 	GETFH4resok	resok4;
708  default:
709 	void;
710 };
711 
712 /*
713  * LINK: Create link to an object
714  */
715 struct LINK4args {
716 	/* SAVED_FH: source object */
717 	/* CURRENT_FH: target directory */
718 	component4	newname;
719 };
720 
721 struct LINK4resok {
722 	change_info4	cinfo;
723 };
724 
725 union LINK4res switch (nfsstat4 status) {
726  case NFS4_OK:
727 	 LINK4resok resok4;
728  default:
729 	 void;
730 };
731 
732 /*
733  * For LOCK, transition from open_owner to new lock_owner
734  */
735 struct open_to_lock_owner4 {
736 	seqid4		open_seqid;
737 	stateid4	open_stateid;
738 	seqid4		lock_seqid;
739 	lock_owner4	lock_owner;
740 };
741 
742 /*
743  * For LOCK, existing lock_owner continues to request file locks
744  */
745 struct exist_lock_owner4 {
746 	stateid4	lock_stateid;
747 	seqid4		lock_seqid;
748 };
749 
750 union locker4 switch (bool new_lock_owner) {
751  case TRUE:
752 	open_to_lock_owner4	open_owner;
753  case FALSE:
754 	exist_lock_owner4	lock_owner;
755 };
756 
757 /*
758  * LOCK/LOCKT/LOCKU: Record lock management
759  */
760 struct LOCK4args {
761 	/* CURRENT_FH: file */
762 	nfs_lock_type4	locktype;
763 	bool		reclaim;
764 	offset4		offset;
765 	length4		length;
766 	locker4		locker;
767 };
768 
769 struct LOCK4denied {
770 	offset4		offset;
771 	length4		length;
772 	nfs_lock_type4	locktype;
773 	lock_owner4	owner;
774 };
775 
776 struct LOCK4resok {
777 	stateid4	lock_stateid;
778 };
779 
780 union LOCK4res switch (nfsstat4 status) {
781  case NFS4_OK:
782 	 LOCK4resok	resok4;
783  case NFS4ERR_DENIED:
784 	 LOCK4denied	denied;
785  default:
786 	 void;
787 };
788 
789 struct LOCKT4args {
790 	/* CURRENT_FH: file */
791 	nfs_lock_type4	locktype;
792 	offset4		offset;
793 	length4		length;
794 	lock_owner4	owner;
795 };
796 
797 union LOCKT4res switch (nfsstat4 status) {
798  case NFS4ERR_DENIED:
799 	 LOCK4denied	denied;
800  case NFS4_OK:
801 	 void;
802  default:
803 	 void;
804 };
805 
806 struct LOCKU4args {
807 	/* CURRENT_FH: file */
808 	nfs_lock_type4	locktype;
809 	seqid4		seqid;
810 	stateid4	lock_stateid;
811 	offset4		offset;
812 	length4		length;
813 };
814 
815 union LOCKU4res switch (nfsstat4 status) {
816  case	NFS4_OK:
817 	 stateid4	lock_stateid;
818  default:
819 	 void;
820 };
821 
822 /*
823  * LOOKUP: Lookup filename
824  */
825 struct LOOKUP4args {
826 	/* CURRENT_FH: directory */
827 	component4	objname;
828 };
829 
830 struct LOOKUP4res {
831 	/* CURRENT_FH: object */
832 	nfsstat4	status;
833 };
834 
835 /*
836  * LOOKUPP: Lookup parent directory
837  */
838 struct LOOKUPP4res {
839 	/* CURRENT_FH: directory */
840 	nfsstat4	status;
841 };
842 
843 /*
844  * NVERIFY: Verify attributes different
845  */
846 struct NVERIFY4args {
847 	/* CURRENT_FH: object */
848 	fattr4		obj_attributes;
849 };
850 
851 struct NVERIFY4res {
852 	nfsstat4	status;
853 };
854 
855 /*
856  * Various definitions for OPEN
857  */
858 enum createmode4 {
859 	UNCHECKED4	= 0,
860 	GUARDED4	= 1,
861 	EXCLUSIVE4	= 2
862 };
863 
864 union createhow4 switch (createmode4 mode) {
865  case UNCHECKED4:
866  case GUARDED4:
867 	 fattr4		createattrs;
868  case EXCLUSIVE4:
869 	 verifier4	createverf;
870 };
871 
872 enum opentype4 {
873 	OPEN4_NOCREATE	= 0,
874 	OPEN4_CREATE	= 1
875 };
876 
877 union openflag4 switch (opentype4 opentype) {
878  case OPEN4_CREATE:
879 	 createhow4	how;
880  default:
881 	 void;
882 };
883 
884 /* Next definitions used for OPEN delegation */
885 enum limit_by4 {
886 	NFS_LIMIT_SIZE		= 1,
887 	NFS_LIMIT_BLOCKS	= 2
888 	/* others as needed */
889 };
890 
891 struct nfs_modified_limit4 {
892 	uint32_t	num_blocks;
893 	uint32_t	bytes_per_block;
894 };
895 
896 union nfs_space_limit4 switch (limit_by4 limitby) {
897  /* limit specified as file size */
898  case NFS_LIMIT_SIZE:
899 	 uint64_t		filesize;
900  /* limit specified by number of blocks */
901  case NFS_LIMIT_BLOCKS:
902 	 nfs_modified_limit4	mod_blocks;
903 } ;
904 
905 /*
906  * Share Access and Deny constants for open argument
907  */
908 const OPEN4_SHARE_ACCESS_READ	= 0x00000001;
909 const OPEN4_SHARE_ACCESS_WRITE	= 0x00000002;
910 const OPEN4_SHARE_ACCESS_BOTH	= 0x00000003;
911 
912 const OPEN4_SHARE_DENY_NONE	= 0x00000000;
913 const OPEN4_SHARE_DENY_READ	= 0x00000001;
914 const OPEN4_SHARE_DENY_WRITE	= 0x00000002;
915 const OPEN4_SHARE_DENY_BOTH	= 0x00000003;
916 
917 enum open_delegation_type4 {
918 	OPEN_DELEGATE_NONE	= 0,
919 	OPEN_DELEGATE_READ	= 1,
920 	OPEN_DELEGATE_WRITE	= 2
921 };
922 
923 enum open_claim_type4 {
924 	CLAIM_NULL		= 0,
925 	CLAIM_PREVIOUS		= 1,
926 	CLAIM_DELEGATE_CUR	= 2,
927 	CLAIM_DELEGATE_PREV	= 3
928 };
929 
930 struct open_claim_delegate_cur4 {
931 	stateid4	delegate_stateid;
932 	component4	file;
933 };
934 
935 union open_claim4 switch (open_claim_type4 claim) {
936  /*
937   * No special rights to file. Ordinary OPEN of the specified file.
938   */
939  case CLAIM_NULL:
940 	/* CURRENT_FH: directory */
941 	component4	file;
942 
943  /*
944   * Right to the file established by an open previous to server
945   * reboot.  File identified by filehandle obtained at that time
946   * rather than by name.
947   */
948  case CLAIM_PREVIOUS:
949 	/* CURRENT_FH: file being reclaimed */
950 	open_delegation_type4	delegate_type;
951 
952  /*
953   * Right to file based on a delegation granted by the server.
954   * File is specified by name.
955   */
956  case CLAIM_DELEGATE_CUR:
957 	/* CURRENT_FH: directory */
958 	open_claim_delegate_cur4	delegate_cur_info;
959 
960  /* Right to file based on a delegation granted to a previous boot
961   * instance of the client.  File is specified by name.
962   */
963  case CLAIM_DELEGATE_PREV:
964 	 /* CURRENT_FH: directory */
965 	component4	file_delegate_prev;
966 };
967 
968 /*
969  * OPEN: Open a file, potentially receiving an open delegation
970  */
971 struct OPEN4args {
972 	seqid4		seqid;
973 	uint32_t	share_access;
974 	uint32_t	share_deny;
975 	open_owner4	owner;
976 	openflag4	openhow;
977 	open_claim4	claim;
978 };
979 
980 struct open_read_delegation4 {
981 	stateid4	stateid;	/* Stateid for delegation*/
982 	bool		recall;		/* Pre-recalled flag for
983 					   delegations obtained
984 					   by reclaim
985 					   (CLAIM_PREVIOUS) */
986 	nfsace4		permissions;	/* Defines users who don't
987 					   need an ACCESS call to
988 					   open for read */
989 };
990 
991 struct open_write_delegation4 {
992 	stateid4	stateid;	/* Stateid for delegation */
993 	bool		recall;		/* Pre-recalled flag for
994 					   delegations obtained
995 					   by reclaim
996 					   (CLAIM_PREVIOUS) */
997 	nfs_space_limit4 space_limit;	/* Defines condition that
998 					   the client must check to
999 					   determine whether the
1000 					   file needs to be flushed
1001 					   to the server on close.
1002 					   */
1003 	nfsace4		permissions;	/* Defines users who don't
1004 					   need an ACCESS call as
1005 					   part of a delegated
1006 					   open. */
1007 };
1008 
1009 union open_delegation4
1010 switch (open_delegation_type4 delegation_type) {
1011 	case OPEN_DELEGATE_NONE:
1012 		void;
1013 	case OPEN_DELEGATE_READ:
1014 		open_read_delegation4 read;
1015 	case OPEN_DELEGATE_WRITE:
1016 		open_write_delegation4 write;
1017 };
1018 
1019 /*
1020  * Result flags
1021  */
1022 /* Client must confirm open */
1023 const OPEN4_RESULT_CONFIRM	= 0x00000002;
1024 /* Type of file locking behavior at the server */
1025 const OPEN4_RESULT_LOCKTYPE_POSIX = 0x00000004;
1026 
1027 struct OPEN4resok {
1028 	stateid4	stateid;	/* Stateid for open */
1029 	change_info4	cinfo;		/* Directory Change Info */
1030 	uint32_t	rflags;		/* Result flags */
1031 	bitmap4		attrset;	/* attribute set for create*/
1032 	open_delegation4 delegation;	/* Info on any open
1033 					   delegation */
1034 };
1035 
1036 union OPEN4res switch (nfsstat4 status) {
1037  case NFS4_OK:
1038 	/* CURRENT_FH: opened file */
1039 	OPEN4resok	resok4;
1040  default:
1041 	void;
1042 };
1043 
1044 /*
1045  * OPENATTR: open named attributes directory
1046  */
1047 struct OPENATTR4args {
1048 	/* CURRENT_FH: object */
1049 	bool	createdir;
1050 };
1051 
1052 struct OPENATTR4res {
1053 	/* CURRENT_FH: named attr directory */
1054 	nfsstat4	status;
1055 };
1056 
1057 /*
1058  * OPEN_CONFIRM: confirm the open
1059  */
1060 struct OPEN_CONFIRM4args {
1061 	/* CURRENT_FH: opened file */
1062 	stateid4	open_stateid;
1063 	seqid4		seqid;
1064 };
1065 
1066 struct OPEN_CONFIRM4resok {
1067 	stateid4	open_stateid;
1068 };
1069 
1070 union OPEN_CONFIRM4res switch (nfsstat4 status) {
1071  case NFS4_OK:
1072 	 OPEN_CONFIRM4resok	resok4;
1073  default:
1074 	 void;
1075 };
1076 
1077 /*
1078  * OPEN_DOWNGRADE: downgrade the access/deny for a file
1079  */
1080 struct OPEN_DOWNGRADE4args {
1081 	/* CURRENT_FH: opened file */
1082 	stateid4	open_stateid;
1083 	seqid4		seqid;
1084 	uint32_t	share_access;
1085 	uint32_t	share_deny;
1086 };
1087 
1088 struct OPEN_DOWNGRADE4resok {
1089 	stateid4	open_stateid;
1090 };
1091 
1092 union OPEN_DOWNGRADE4res switch(nfsstat4 status) {
1093  case NFS4_OK:
1094 	OPEN_DOWNGRADE4resok	resok4;
1095  default:
1096 	 void;
1097 };
1098 
1099 /*
1100  * PUTFH: Set current filehandle
1101  */
1102 struct PUTFH4args {
1103 	nfs_fh4		object;
1104 };
1105 
1106 struct PUTFH4res {
1107 	/* CURRENT_FH: */
1108 	nfsstat4	status;
1109 };
1110 
1111 /*
1112  * PUTPUBFH: Set public filehandle
1113  */
1114 struct PUTPUBFH4res {
1115 	/* CURRENT_FH: public fh */
1116 	nfsstat4	status;
1117 };
1118 
1119 /*
1120  * PUTROOTFH: Set root filehandle
1121  */
1122 struct PUTROOTFH4res {
1123 	/* CURRENT_FH: root fh */
1124 	nfsstat4	status;
1125 };
1126 
1127 /*
1128  * READ: Read from file
1129  */
1130 struct READ4args {
1131 	/* CURRENT_FH: file */
1132 	stateid4	stateid;
1133 	offset4		offset;
1134 	count4		count;
1135 };
1136 
1137 struct READ4resok {
1138 	bool		eof;
1139 	opaque		data<>;
1140 };
1141 
1142 union READ4res switch (nfsstat4 status) {
1143  case NFS4_OK:
1144 	 READ4resok	resok4;
1145  default:
1146 	 void;
1147 };
1148 
1149 /*
1150  * READDIR: Read directory
1151  */
1152 struct READDIR4args {
1153 	/* CURRENT_FH: directory */
1154 	nfs_cookie4	cookie;
1155 	verifier4	cookieverf;
1156 	count4		dircount;
1157 	count4		maxcount;
1158 	bitmap4		attr_request;
1159 };
1160 
1161 struct entry4 {
1162 	nfs_cookie4	cookie;
1163 	component4	name;
1164 	fattr4		attrs;
1165 	entry4		*nextentry;
1166 };
1167 
1168 struct dirlist4 {
1169 	entry4		*entries;
1170 	bool		eof;
1171 };
1172 
1173 struct READDIR4resok {
1174 	verifier4	cookieverf;
1175 	dirlist4	reply;
1176 };
1177 
1178 
1179 union READDIR4res switch (nfsstat4 status) {
1180  case NFS4_OK:
1181 	 READDIR4resok	resok4;
1182  default:
1183 	 void;
1184 };
1185 
1186 
1187 /*
1188  * READLINK: Read symbolic link
1189  */
1190 struct READLINK4resok {
1191 	linktext4	link;
1192 };
1193 
1194 union READLINK4res switch (nfsstat4 status) {
1195  case NFS4_OK:
1196 	 READLINK4resok	resok4;
1197  default:
1198 	 void;
1199 };
1200 
1201 /*
1202  * REMOVE: Remove filesystem object
1203  */
1204 struct REMOVE4args {
1205 	/* CURRENT_FH: directory */
1206 	component4	target;
1207 };
1208 
1209 struct REMOVE4resok {
1210 	change_info4	cinfo;
1211 };
1212 
1213 union REMOVE4res switch (nfsstat4 status) {
1214  case NFS4_OK:
1215 	 REMOVE4resok	resok4;
1216  default:
1217 	 void;
1218 };
1219 
1220 /*
1221  * RENAME: Rename directory entry
1222  */
1223 struct RENAME4args {
1224 	/* SAVED_FH: source directory */
1225 	component4	oldname;
1226 	/* CURRENT_FH: target directory */
1227 	component4	newname;
1228 };
1229 
1230 struct RENAME4resok {
1231 	change_info4	source_cinfo;
1232 	change_info4	target_cinfo;
1233 };
1234 
1235 union RENAME4res switch (nfsstat4 status) {
1236  case NFS4_OK:
1237 	RENAME4resok	resok4;
1238  default:
1239 	void;
1240 };
1241 
1242 /*
1243  * RENEW: Renew a Lease
1244  */
1245 struct RENEW4args {
1246 	clientid4	clientid;
1247 };
1248 
1249 struct RENEW4res {
1250 	nfsstat4	status;
1251 };
1252 
1253 /*
1254  * RESTOREFH: Restore saved filehandle
1255  */
1256 
1257 struct RESTOREFH4res {
1258 	/* CURRENT_FH: value of saved fh */
1259 	nfsstat4	status;
1260 };
1261 
1262 /*
1263  * SAVEFH: Save current filehandle
1264  */
1265 struct SAVEFH4res {
1266 	/* SAVED_FH: value of current fh */
1267 	nfsstat4	status;
1268 };
1269 
1270 /*
1271  * SECINFO: Obtain Available Security Mechanisms
1272  */
1273 struct SECINFO4args {
1274 	/* CURRENT_FH: directory */
1275 	component4	name;
1276 };
1277 
1278 /*
1279  * From RFC 2203
1280  */
1281 enum rpc_gss_svc_t {
1282 	RPC_GSS_SVC_NONE	= 1,
1283 	RPC_GSS_SVC_INTEGRITY	= 2,
1284 	RPC_GSS_SVC_PRIVACY	= 3
1285 };
1286 
1287 struct rpcsec_gss_info {
1288 	sec_oid4	oid;
1289 	qop4		qop;
1290 	rpc_gss_svc_t	service;
1291 };
1292 
1293 /* RPCSEC_GSS has a value of '6' - See RFC 2203 */
1294 union secinfo4 switch (uint32_t flavor) {
1295  case RPCSEC_GSS:
1296 	 rpcsec_gss_info	flavor_info;
1297  default:
1298 	 void;
1299 };
1300 
1301 typedef secinfo4 SECINFO4resok<>;
1302 
1303 union SECINFO4res switch (nfsstat4 status) {
1304  case NFS4_OK:
1305 	 SECINFO4resok resok4;
1306  default:
1307 	 void;
1308 };
1309 
1310 /*
1311  * SETATTR: Set attributes
1312  */
1313 struct SETATTR4args {
1314 	/* CURRENT_FH: target object */
1315 	stateid4	stateid;
1316 	fattr4		obj_attributes;
1317 };
1318 
1319 struct SETATTR4res {
1320 	nfsstat4	status;
1321 	bitmap4		attrsset;
1322 };
1323 
1324 /*
1325  * SETCLIENTID
1326  */
1327 struct SETCLIENTID4args {
1328 	nfs_client_id4	client;
1329 	cb_client4	callback;
1330 	uint32_t	callback_ident;
1331 };
1332 
1333 struct SETCLIENTID4resok {
1334 	clientid4	clientid;
1335 	verifier4	setclientid_confirm;
1336 };
1337 
1338 union SETCLIENTID4res switch (nfsstat4 status) {
1339  case NFS4_OK:
1340 	 SETCLIENTID4resok	resok4;
1341  case NFS4ERR_CLID_INUSE:
1342 	 clientaddr4	client_using;
1343  default:
1344 	 void;
1345 };
1346 
1347 struct SETCLIENTID_CONFIRM4args {
1348 	clientid4	clientid;
1349 	verifier4	setclientid_confirm;
1350 };
1351 
1352 struct SETCLIENTID_CONFIRM4res {
1353 	nfsstat4	status;
1354 };
1355 
1356 /*
1357  * VERIFY: Verify attributes same
1358  */
1359 struct VERIFY4args {
1360 	/* CURRENT_FH: object */
1361 	fattr4		obj_attributes;
1362 };
1363 
1364 struct VERIFY4res {
1365 	nfsstat4	status;
1366 };
1367 
1368 /*
1369  * WRITE: Write to file
1370  */
1371 enum stable_how4 {
1372 	UNSTABLE4	= 0,
1373 	DATA_SYNC4	= 1,
1374 	FILE_SYNC4	= 2
1375 };
1376 
1377 struct WRITE4args {
1378 	/* CURRENT_FH: file */
1379 	stateid4	stateid;
1380 	offset4		offset;
1381 	stable_how4	stable;
1382 	opaque		data<>;
1383 };
1384 
1385 struct WRITE4resok {
1386 	count4		count;
1387 	stable_how4	committed;
1388 	verifier4	writeverf;
1389 };
1390 
1391 union WRITE4res switch (nfsstat4 status) {
1392  case NFS4_OK:
1393 	 WRITE4resok	resok4;
1394  default:
1395 	 void;
1396 };
1397 
1398 /*
1399  * RELEASE_LOCKOWNER: Notify server to release lockowner
1400  */
1401 struct RELEASE_LOCKOWNER4args {
1402 	lock_owner4	lock_owner;
1403 };
1404 
1405 struct RELEASE_LOCKOWNER4res {
1406 	nfsstat4	status;
1407 };
1408 
1409 /*
1410  * ILLEGAL: Response for illegal operation numbers
1411  */
1412 struct ILLEGAL4res {
1413 	nfsstat4        status;
1414 };
1415 
1416 /*
1417  * Operation arrays
1418  */
1419 
1420 enum nfs_opnum4 {
1421 	OP_ACCESS		= 3,
1422 	OP_CLOSE		= 4,
1423 	OP_COMMIT		= 5,
1424 	OP_CREATE		= 6,
1425 	OP_DELEGPURGE		= 7,
1426 	OP_DELEGRETURN		= 8,
1427 	OP_GETATTR		= 9,
1428 	OP_GETFH		= 10,
1429 	OP_LINK			= 11,
1430 	OP_LOCK			= 12,
1431 	OP_LOCKT		= 13,
1432 	OP_LOCKU		= 14,
1433 	OP_LOOKUP		= 15,
1434 	OP_LOOKUPP		= 16,
1435 	OP_NVERIFY		= 17,
1436 	OP_OPEN			= 18,
1437 	OP_OPENATTR		= 19,
1438 	OP_OPEN_CONFIRM		= 20,
1439 	OP_OPEN_DOWNGRADE	= 21,
1440 	OP_PUTFH		= 22,
1441 	OP_PUTPUBFH		= 23,
1442 	OP_PUTROOTFH		= 24,
1443 	OP_READ			= 25,
1444 	OP_READDIR		= 26,
1445 	OP_READLINK		= 27,
1446 	OP_REMOVE		= 28,
1447 	OP_RENAME		= 29,
1448 	OP_RENEW		= 30,
1449 	OP_RESTOREFH		= 31,
1450 	OP_SAVEFH		= 32,
1451 	OP_SECINFO		= 33,
1452 	OP_SETATTR		= 34,
1453 	OP_SETCLIENTID		= 35,
1454 	OP_SETCLIENTID_CONFIRM	= 36,
1455 	OP_VERIFY		= 37,
1456 	OP_WRITE		= 38,
1457 	OP_RELEASE_LOCKOWNER	= 39,
1458 	OP_ILLEGAL		= 10044
1459 };
1460 
1461 union nfs_argop4 switch (nfs_opnum4 argop) {
1462  case OP_ACCESS:	ACCESS4args opaccess;
1463  case OP_CLOSE:		CLOSE4args opclose;
1464  case OP_COMMIT:	COMMIT4args opcommit;
1465  case OP_CREATE:	CREATE4args opcreate;
1466  case OP_DELEGPURGE:	DELEGPURGE4args opdelegpurge;
1467  case OP_DELEGRETURN:	DELEGRETURN4args opdelegreturn;
1468  case OP_GETATTR:	GETATTR4args opgetattr;
1469  case OP_GETFH:		void;
1470  case OP_LINK:		LINK4args oplink;
1471  case OP_LOCK:		LOCK4args oplock;
1472  case OP_LOCKT:		LOCKT4args oplockt;
1473  case OP_LOCKU:		LOCKU4args oplocku;
1474  case OP_LOOKUP:	LOOKUP4args oplookup;
1475  case OP_LOOKUPP:	void;
1476  case OP_NVERIFY:	NVERIFY4args opnverify;
1477  case OP_OPEN:		OPEN4args opopen;
1478  case OP_OPENATTR:	OPENATTR4args opopenattr;
1479  case OP_OPEN_CONFIRM:	OPEN_CONFIRM4args opopen_confirm;
1480  case OP_OPEN_DOWNGRADE:	OPEN_DOWNGRADE4args opopen_downgrade;
1481  case OP_PUTFH:		PUTFH4args opputfh;
1482  case OP_PUTPUBFH:	void;
1483  case OP_PUTROOTFH:	void;
1484  case OP_READ:		READ4args opread;
1485  case OP_READDIR:	READDIR4args opreaddir;
1486  case OP_READLINK:	void;
1487  case OP_REMOVE:	REMOVE4args opremove;
1488  case OP_RENAME:	RENAME4args oprename;
1489  case OP_RENEW:		RENEW4args oprenew;
1490  case OP_RESTOREFH:	void;
1491  case OP_SAVEFH:	void;
1492  case OP_SECINFO:	SECINFO4args opsecinfo;
1493  case OP_SETATTR:	SETATTR4args opsetattr;
1494  case OP_SETCLIENTID:	SETCLIENTID4args opsetclientid;
1495  case OP_SETCLIENTID_CONFIRM:	SETCLIENTID_CONFIRM4args
1496 					opsetclientid_confirm;
1497  case OP_VERIFY:	VERIFY4args opverify;
1498  case OP_WRITE:		WRITE4args opwrite;
1499  case OP_RELEASE_LOCKOWNER:	RELEASE_LOCKOWNER4args
1500 				    oprelease_lockowner;
1501  case OP_ILLEGAL:	void;
1502 };
1503 
1504 union nfs_resop4 switch (nfs_opnum4 resop){
1505  case OP_ACCESS:	ACCESS4res opaccess;
1506  case OP_CLOSE:		CLOSE4res opclose;
1507  case OP_COMMIT:	COMMIT4res opcommit;
1508  case OP_CREATE:	CREATE4res opcreate;
1509  case OP_DELEGPURGE:	DELEGPURGE4res opdelegpurge;
1510  case OP_DELEGRETURN:	DELEGRETURN4res opdelegreturn;
1511  case OP_GETATTR:	GETATTR4res opgetattr;
1512  case OP_GETFH:		GETFH4res opgetfh;
1513  case OP_LINK:		LINK4res oplink;
1514  case OP_LOCK:		LOCK4res oplock;
1515  case OP_LOCKT:		LOCKT4res oplockt;
1516  case OP_LOCKU:		LOCKU4res oplocku;
1517  case OP_LOOKUP:	LOOKUP4res oplookup;
1518  case OP_LOOKUPP:	LOOKUPP4res oplookupp;
1519  case OP_NVERIFY:	NVERIFY4res opnverify;
1520  case OP_OPEN:		OPEN4res opopen;
1521  case OP_OPENATTR:	OPENATTR4res opopenattr;
1522  case OP_OPEN_CONFIRM:	OPEN_CONFIRM4res opopen_confirm;
1523  case OP_OPEN_DOWNGRADE:	OPEN_DOWNGRADE4res opopen_downgrade;
1524  case OP_PUTFH:		PUTFH4res opputfh;
1525  case OP_PUTPUBFH:	PUTPUBFH4res opputpubfh;
1526  case OP_PUTROOTFH:	PUTROOTFH4res opputrootfh;
1527  case OP_READ:		READ4res opread;
1528  case OP_READDIR:	READDIR4res opreaddir;
1529  case OP_READLINK:	READLINK4res opreadlink;
1530  case OP_REMOVE:	REMOVE4res opremove;
1531  case OP_RENAME:	RENAME4res oprename;
1532  case OP_RENEW:		RENEW4res oprenew;
1533  case OP_RESTOREFH:	RESTOREFH4res oprestorefh;
1534  case OP_SAVEFH:	SAVEFH4res opsavefh;
1535  case OP_SECINFO:	SECINFO4res opsecinfo;
1536  case OP_SETATTR:	SETATTR4res opsetattr;
1537  case OP_SETCLIENTID:	SETCLIENTID4res opsetclientid;
1538  case OP_SETCLIENTID_CONFIRM:	SETCLIENTID_CONFIRM4res
1539 					opsetclientid_confirm;
1540  case OP_VERIFY:	VERIFY4res opverify;
1541  case OP_WRITE:		WRITE4res opwrite;
1542  case OP_RELEASE_LOCKOWNER:	RELEASE_LOCKOWNER4res
1543 				    oprelease_lockowner;
1544  case OP_ILLEGAL:	ILLEGAL4res opillegal;
1545 };
1546 
1547 struct COMPOUND4args {
1548 	utf8str_cs	tag;
1549 	uint32_t	minorversion;
1550 	nfs_argop4	argarray<>;
1551 };
1552 
1553 struct COMPOUND4res {
1554 	nfsstat4 status;
1555 	utf8str_cs	tag;
1556 	nfs_resop4	resarray<>;
1557 };
1558 
1559 /*
1560  * Remote file service routines
1561  */
1562 program NFS4_PROGRAM {
1563 	version NFS_V4 {
1564 		void
1565 			NFSPROC4_NULL(void) = 0;
1566 
1567 		COMPOUND4res
1568 			NFSPROC4_COMPOUND(COMPOUND4args) = 1;
1569 
1570 	} = 4;
1571 } = 100003;
1572 
1573 
1574 
1575 /*
1576  * NFS4 Callback Procedure Definitions and Program
1577  */
1578 
1579 /*
1580  * CB_GETATTR: Get Current Attributes
1581  */
1582 struct CB_GETATTR4args {
1583 	nfs_fh4	fh;
1584 	bitmap4	attr_request;
1585 };
1586 
1587 struct CB_GETATTR4resok {
1588 	fattr4	obj_attributes;
1589 };
1590 
1591 union CB_GETATTR4res switch (nfsstat4 status) {
1592  case NFS4_OK:
1593 	 CB_GETATTR4resok	resok4;
1594  default:
1595 	 void;
1596 };
1597 
1598 /*
1599  * CB_RECALL: Recall an Open Delegation
1600  */
1601 struct CB_RECALL4args {
1602 	stateid4	stateid;
1603 	bool		truncate;
1604 	nfs_fh4		fh;
1605 };
1606 
1607 struct CB_RECALL4res {
1608 	nfsstat4	status;
1609 };
1610 
1611 /*
1612  * CB_ILLEGAL: Response for illegal operation numbers
1613  */
1614 struct CB_ILLEGAL4res {
1615 	nfsstat4        status;
1616 };
1617 
1618 /*
1619  * Various definitions for CB_COMPOUND
1620  */
1621 enum nfs_cb_opnum4 {
1622 	OP_CB_GETATTR		= 3,
1623 	OP_CB_RECALL		= 4,
1624 	OP_CB_ILLEGAL		= 10044
1625 };
1626 
1627 union nfs_cb_argop4 switch (unsigned argop) {
1628  case OP_CB_GETATTR:	CB_GETATTR4args opcbgetattr;
1629  case OP_CB_RECALL:	CB_RECALL4args	opcbrecall;
1630  case OP_CB_ILLEGAL:	void;
1631 };
1632 
1633 union nfs_cb_resop4 switch (unsigned resop){
1634  case OP_CB_GETATTR:	CB_GETATTR4res	opcbgetattr;
1635  case OP_CB_RECALL:	CB_RECALL4res	opcbrecall;
1636  case OP_CB_ILLEGAL:	CB_ILLEGAL4res	opcbillegal;
1637 };
1638 
1639 struct CB_COMPOUND4args {
1640 	utf8str_cs	tag;
1641 	uint32_t	minorversion;
1642 	uint32_t	callback_ident;
1643 	nfs_cb_argop4	argarray<>;
1644 };
1645 
1646 struct CB_COMPOUND4res {
1647 	nfsstat4 status;
1648 	utf8str_cs	tag;
1649 	nfs_cb_resop4	resarray<>;
1650 };
1651 
1652 
1653 /*
1654  * Program number is in the transient range since the client
1655  * will assign the exact transient program number and provide
1656  * that to the server via the SETCLIENTID operation.
1657  */
1658 program NFS4_CALLBACK {
1659 	version NFS_CB {
1660 		void
1661 			CB_NULL(void) = 0;
1662 		CB_COMPOUND4res
1663 			CB_COMPOUND(CB_COMPOUND4args) = 1;
1664 	} = 1;
1665 } = 0x40000000;
1666