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