xref: /illumos-gate/usr/src/head/rpcsvc/nfs4_prot.x (revision bb65110f7220d348d063c325407fdf3f616f4ee8)
1 /*
2  * This file was machine generated for [RFC7862].
3  *
4  * Last updated Sun Mar 13 10:58:40 PDT 2016
5  */
6 
7 /*
8  * Copyright (c) 2016 IETF Trust and the persons identified
9  * as the authors.  All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with
12  * or without modification, are permitted provided that the
13  * following conditions are met:
14  *
15  * - Redistributions of source code must retain the above
16  *   copyright notice, this list of conditions and the
17  *   following disclaimer.
18  *
19  * - Redistributions in binary form must reproduce the above
20  *   copyright notice, this list of conditions and the
21  *   following disclaimer in the documentation and/or other
22  *   materials provided with the distribution.
23  *
24  * - Neither the name of Internet Society, IETF or IETF
25  *   Trust, nor the names of specific contributors, may be
26  *   used to endorse or promote products derived from this
27  *   software without specific prior written permission.
28  *
29  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
30  *   AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
31  *   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
34  *   EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
35  *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36  *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37  *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38  *   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41  *   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42  *   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
43  *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 
45  */
46 
47 /*
48  * This code was derived from RFC 7863.
49  */
50 
51 /*
52  *      nfsv42.x
53  */
54 
55 %#ifndef _AUTH_SYS_DEFINE_FOR_NFSv42
56 %#define _AUTH_SYS_DEFINE_FOR_NFSv42
57 %#include <rpc/auth_sys.h>
58 %typedef struct authsys_parms authsys_parms;
59 %#endif /* _AUTH_SYS_DEFINE_FOR_NFSv42 */
60 
61 /*
62  * Basic typedefs for RFC 1832 data type definitions
63  */
64 
65 /*
66  * typedef int                  int32_t;
67  * typedef unsigned int         uint32_t;
68  * typedef hyper                int64_t;
69  * typedef unsigned hyper       uint64_t;
70  */
71 
72 /*
73  * Sizes
74  */
75 const NFS4_FHSIZE               = 128;
76 const NFS4_VERIFIER_SIZE        = 8;
77 const NFS4_OTHER_SIZE           = 12;
78 const NFS4_OPAQUE_LIMIT         = 1024;
79 const NFS4_SESSIONID_SIZE       = 16;
80 
81 const NFS4_INT64_MAX            = 0x7fffffffffffffff;
82 const NFS4_UINT64_MAX           = 0xffffffffffffffff;
83 const NFS4_INT32_MAX            = 0x7fffffff;
84 const NFS4_UINT32_MAX           = 0xffffffff;
85 
86 const NFS4_MAXFILELEN           = 0xffffffffffffffff;
87 const NFS4_MAXFILEOFF           = 0xfffffffffffffffe;
88 
89 
90 /*
91  * File types
92  */
93 enum nfs_ftype4 {
94         NF4REG       = 1,  /* Regular File */
95         NF4DIR       = 2,  /* Directory */
96         NF4BLK       = 3,  /* Special File -- block device */
97         NF4CHR       = 4,  /* Special File -- character device */
98         NF4LNK       = 5,  /* Symbolic Link */
99         NF4SOCK      = 6,  /* Special File -- socket */
100         NF4FIFO      = 7,  /* Special File -- fifo */
101         NF4ATTRDIR   = 8,  /* Attribute Directory */
102         NF4NAMEDATTR = 9   /* Named Attribute */
103 };
104 
105 /*
106  * Error status
107  */
108 enum nfsstat4 {
109  NFS4_OK                = 0,     /* everything is okay        */
110  NFS4ERR_PERM           = 1,     /* caller not privileged     */
111  NFS4ERR_NOENT          = 2,     /* no such file/directory    */
112  NFS4ERR_IO             = 5,     /* hard I/O error            */
113  NFS4ERR_NXIO           = 6,     /* no such device            */
114  NFS4ERR_ACCESS         = 13,    /* access denied             */
115  NFS4ERR_EXIST          = 17,    /* file already exists       */
116  NFS4ERR_XDEV           = 18,    /* different file systems    */
117 
118 /*
119  * Please do not allocate value 19; it was used in NFSv3,
120  * and we do not want a value in NFSv3 to have a different
121  * meaning in NFSv4.x.
122  */
123 
124  NFS4ERR_NOTDIR         = 20,    /* should be a directory     */
125  NFS4ERR_ISDIR          = 21,    /* should not be a directory */
126  NFS4ERR_INVAL          = 22,    /* invalid argument          */
127  NFS4ERR_FBIG           = 27,    /* file exceeds server max   */
128  NFS4ERR_NOSPC          = 28,    /* no space on file system   */
129  NFS4ERR_ROFS           = 30,    /* read-only file system     */
130  NFS4ERR_MLINK          = 31,    /* too many hard links       */
131  NFS4ERR_NAMETOOLONG    = 63,    /* name exceeds server max   */
132  NFS4ERR_NOTEMPTY       = 66,    /* directory not empty       */
133  NFS4ERR_DQUOT          = 69,    /* hard quota limit reached  */
134  NFS4ERR_STALE          = 70,    /* file no longer exists     */
135  NFS4ERR_BADHANDLE      = 10001, /* illegal filehandle        */
136  NFS4ERR_BAD_COOKIE     = 10003, /* READDIR cookie is stale   */
137  NFS4ERR_NOTSUPP        = 10004, /* operation not supported   */
138  NFS4ERR_TOOSMALL       = 10005, /* response limit exceeded   */
139  NFS4ERR_SERVERFAULT    = 10006, /* undefined server error    */
140  NFS4ERR_BADTYPE        = 10007, /* type invalid for CREATE   */
141  NFS4ERR_DELAY          = 10008, /* file "busy" -- retry      */
142  NFS4ERR_SAME           = 10009, /* nverify says attrs same   */
143  NFS4ERR_DENIED         = 10010, /* lock unavailable          */
144  NFS4ERR_EXPIRED        = 10011, /* lock lease expired        */
145  NFS4ERR_LOCKED         = 10012, /* I/O failed due to lock    */
146  NFS4ERR_GRACE          = 10013, /* in grace period           */
147  NFS4ERR_FHEXPIRED      = 10014, /* filehandle expired        */
148  NFS4ERR_SHARE_DENIED   = 10015, /* share reserve denied      */
149  NFS4ERR_WRONGSEC       = 10016, /* wrong security flavor     */
150  NFS4ERR_CLID_INUSE     = 10017, /* client ID in use          */
151 
152  /* NFS4ERR_RESOURCE is not a valid error in NFSv4.1. */
153  NFS4ERR_RESOURCE       = 10018, /* resource exhaustion       */
154 
155  NFS4ERR_MOVED          = 10019, /* file system relocated     */
156  NFS4ERR_NOFILEHANDLE   = 10020, /* current FH is not set     */
157  NFS4ERR_MINOR_VERS_MISMATCH= 10021, /* minor vers not supp   */
158  NFS4ERR_STALE_CLIENTID = 10022, /* server has rebooted       */
159  NFS4ERR_STALE_STATEID  = 10023, /* server has rebooted       */
160  NFS4ERR_OLD_STATEID    = 10024, /* state is out of sync      */
161  NFS4ERR_BAD_STATEID    = 10025, /* incorrect stateid         */
162  NFS4ERR_BAD_SEQID      = 10026, /* request is out of seq.    */
163  NFS4ERR_NOT_SAME       = 10027, /* verify -- attrs not same  */
164  NFS4ERR_LOCK_RANGE     = 10028, /* overlapping lock range    */
165  NFS4ERR_SYMLINK        = 10029, /* should be file/directory  */
166  NFS4ERR_RESTOREFH      = 10030, /* no saved filehandle       */
167  NFS4ERR_LEASE_MOVED    = 10031, /* some file system moved    */
168  NFS4ERR_ATTRNOTSUPP    = 10032, /* recommended attr not supp */
169  NFS4ERR_NO_GRACE       = 10033, /* reclaim outside of grace  */
170  NFS4ERR_RECLAIM_BAD    = 10034, /* reclaim error at server   */
171  NFS4ERR_RECLAIM_CONFLICT= 10035, /* conflict on reclaim      */
172  NFS4ERR_BADXDR         = 10036, /* XDR decode failed         */
173  NFS4ERR_LOCKS_HELD     = 10037, /* file locks held at CLOSE  */
174  NFS4ERR_OPENMODE       = 10038, /* conflict in OPEN and I/O  */
175  NFS4ERR_BADOWNER       = 10039, /* owner translation bad     */
176  NFS4ERR_BADCHAR        = 10040, /* UTF-8 char not supported  */
177  NFS4ERR_BADNAME        = 10041, /* name not supported        */
178  NFS4ERR_BAD_RANGE      = 10042, /* lock range not supported  */
179  NFS4ERR_LOCK_NOTSUPP   = 10043, /* no atomic up/downgrade    */
180  NFS4ERR_OP_ILLEGAL     = 10044, /* undefined operation       */
181  NFS4ERR_DEADLOCK       = 10045, /* file-locking deadlock     */
182  NFS4ERR_FILE_OPEN      = 10046, /* open file blocks op       */
183  NFS4ERR_ADMIN_REVOKED  = 10047, /* lock-owner state revoked  */
184  NFS4ERR_CB_PATH_DOWN   = 10048, /* callback path down        */
185 
186  /* NFSv4.1 errors start here. */
187 
188  NFS4ERR_BADIOMODE      = 10049,
189  NFS4ERR_BADLAYOUT      = 10050,
190  NFS4ERR_BAD_SESSION_DIGEST = 10051,
191  NFS4ERR_BADSESSION     = 10052,
192  NFS4ERR_BADSLOT        = 10053,
193  NFS4ERR_COMPLETE_ALREADY = 10054,
194  NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
195  NFS4ERR_DELEG_ALREADY_WANTED = 10056,
196  NFS4ERR_BACK_CHAN_BUSY = 10057, /* backchan reqs outstanding */
197  NFS4ERR_LAYOUTTRYLATER = 10058,
198  NFS4ERR_LAYOUTUNAVAILABLE = 10059,
199  NFS4ERR_NOMATCHING_LAYOUT = 10060,
200  NFS4ERR_RECALLCONFLICT = 10061,
201  NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062,
202  NFS4ERR_SEQ_MISORDERED = 10063, /* unexpected seq. ID in req */
203  NFS4ERR_SEQUENCE_POS   = 10064, /* [CB_]SEQ. op not 1st op   */
204  NFS4ERR_REQ_TOO_BIG    = 10065, /* request too big           */
205  NFS4ERR_REP_TOO_BIG    = 10066, /* reply too big             */
206  NFS4ERR_REP_TOO_BIG_TO_CACHE =10067, /* rep. not all cached  */
207  NFS4ERR_RETRY_UNCACHED_REP =10068, /* retry + rep. uncached  */
208  NFS4ERR_UNSAFE_COMPOUND =10069, /* retry/recovery too hard   */
209  NFS4ERR_TOO_MANY_OPS   = 10070, /* too many ops in [CB_]COMP */
210  NFS4ERR_OP_NOT_IN_SESSION =10071, /* op needs [CB_]SEQ. op   */
211  NFS4ERR_HASH_ALG_UNSUPP = 10072,  /* hash alg. not supp      */
212                                    /* Error 10073 is unused.  */
213  NFS4ERR_CLIENTID_BUSY  = 10074, /* client ID has state       */
214  NFS4ERR_PNFS_IO_HOLE   = 10075, /* IO to _SPARSE file hole   */
215  NFS4ERR_SEQ_FALSE_RETRY= 10076, /* retry != original req     */
216  NFS4ERR_BAD_HIGH_SLOT  = 10077, /* req has bad highest_slot  */
217  NFS4ERR_DEADSESSION    = 10078, /* new req sent to dead sess */
218  NFS4ERR_ENCR_ALG_UNSUPP= 10079, /* encr alg. not supp        */
219  NFS4ERR_PNFS_NO_LAYOUT = 10080, /* I/O without a layout      */
220  NFS4ERR_NOT_ONLY_OP    = 10081, /* addl ops not allowed      */
221  NFS4ERR_WRONG_CRED     = 10082, /* op done by wrong cred     */
222  NFS4ERR_WRONG_TYPE     = 10083, /* op on wrong type object   */
223  NFS4ERR_DIRDELEG_UNAVAIL=10084, /* delegation not avail.     */
224  NFS4ERR_REJECT_DELEG   = 10085, /* cb rejected delegation    */
225  NFS4ERR_RETURNCONFLICT = 10086, /* layout get before return  */
226  NFS4ERR_DELEG_REVOKED  = 10087, /* deleg./layout revoked     */
227 
228  /* NFSv4.2 errors start here. */
229 
230  NFS4ERR_PARTNER_NOTSUPP= 10088, /* s2s not supported         */
231  NFS4ERR_PARTNER_NO_AUTH= 10089, /* s2s not authorized        */
232  NFS4ERR_UNION_NOTSUPP  = 10090, /* arm of union not supp     */
233  NFS4ERR_OFFLOAD_DENIED = 10091, /* dest not allowing copy    */
234  NFS4ERR_WRONG_LFS      = 10092, /* LFS not supported         */
235  NFS4ERR_BADLABEL       = 10093, /* incorrect label           */
236  NFS4ERR_OFFLOAD_NO_REQS= 10094  /* dest not meeting reqs     */
237 };
238 
239 /*
240  * Basic data types
241  */
242 typedef opaque  attrlist4<>;
243 typedef uint32_t        bitmap4<>;
244 typedef uint64_t        changeid4;
245 typedef uint64_t        clientid4;
246 typedef uint32_t        count4;
247 typedef uint64_t        length4;
248 typedef uint32_t        mode4;
249 typedef uint64_t        nfs_cookie4;
250 typedef opaque  nfs_fh4<NFS4_FHSIZE>;
251 typedef uint64_t        offset4;
252 typedef uint32_t        qop4;
253 typedef opaque  sec_oid4<>;
254 typedef uint32_t        sequenceid4;
255 typedef uint32_t        seqid4;
256 typedef opaque  sessionid4[NFS4_SESSIONID_SIZE];
257 typedef uint32_t        slotid4;
258 typedef opaque  utf8string<>;
259 typedef utf8string      utf8str_cis;
260 typedef utf8string      utf8str_cs;
261 typedef utf8string      utf8str_mixed;
262 typedef utf8str_cs      component4;
263 typedef opaque  linktext4<>;
264 typedef utf8string      ascii_REQUIRED4;
265 typedef component4      pathname4<>;
266 typedef opaque  verifier4[NFS4_VERIFIER_SIZE];
267 typedef string  secret4<>;
268 typedef uint32_t        policy4;
269 
270 /*
271  * Timeval
272  */
273 struct nfstime4 {
274         int64_t         seconds;
275         uint32_t        nseconds;
276 };
277 
278 enum time_how4 {
279         SET_TO_SERVER_TIME4 = 0,
280         SET_TO_CLIENT_TIME4 = 1
281 };
282 
283 union settime4 switch (time_how4 set_it) {
284  case SET_TO_CLIENT_TIME4:
285          nfstime4       time;
286  default:
287          void;
288 };
289 
290 
291 typedef uint32_t nfs_lease4;
292 
293 /*
294  * File attribute definitions
295  */
296 
297 /*
298  * File System ID (FSID) structure for major/minor
299  */
300 struct fsid4 {
301         uint64_t        major;
302         uint64_t        minor;
303 };
304 
305 /*
306  * File system locations attribute
307  * for relocation/migration and
308  * related attributes
309  */
310 struct change_policy4 {
311         uint64_t        cp_major;
312         uint64_t        cp_minor;
313 };
314 
315 struct fs_location4 {
316         utf8str_cis     server<>;
317         pathname4       rootpath;
318 };
319 
320 struct fs_locations4 {
321         pathname4       fs_root;
322         fs_location4    locations<>;
323 };
324 
325 /*
326  * Various Access Control Entry (ACE) definitions
327  */
328 
329 /*
330  * Mask that indicates which ACEs are supported.
331  * Values for the fattr4_aclsupport attribute.
332  */
333 const ACL4_SUPPORT_ALLOW_ACL    = 0x00000001;
334 const ACL4_SUPPORT_DENY_ACL     = 0x00000002;
335 const ACL4_SUPPORT_AUDIT_ACL    = 0x00000004;
336 const ACL4_SUPPORT_ALARM_ACL    = 0x00000008;
337 
338 
339 typedef uint32_t        acetype4;
340 
341 
342 /*
343  * acetype4 values.  Others can be added as needed.
344  */
345 const ACE4_ACCESS_ALLOWED_ACE_TYPE      = 0x00000000;
346 const ACE4_ACCESS_DENIED_ACE_TYPE       = 0x00000001;
347 const ACE4_SYSTEM_AUDIT_ACE_TYPE        = 0x00000002;
348 const ACE4_SYSTEM_ALARM_ACE_TYPE        = 0x00000003;
349 
350 
351 
352 /*
353  * ACE flag
354  */
355 typedef uint32_t aceflag4;
356 
357 
358 /*
359  * ACE flag values
360  */
361 const ACE4_FILE_INHERIT_ACE             = 0x00000001;
362 const ACE4_DIRECTORY_INHERIT_ACE        = 0x00000002;
363 const ACE4_NO_PROPAGATE_INHERIT_ACE     = 0x00000004;
364 const ACE4_INHERIT_ONLY_ACE             = 0x00000008;
365 const ACE4_SUCCESSFUL_ACCESS_ACE_FLAG   = 0x00000010;
366 const ACE4_FAILED_ACCESS_ACE_FLAG       = 0x00000020;
367 const ACE4_IDENTIFIER_GROUP             = 0x00000040;
368 const ACE4_INHERITED_ACE                = 0x00000080;
369 
370 
371 
372 /*
373  * ACE mask
374  */
375 typedef uint32_t        acemask4;
376 
377 
378 /*
379  * ACE mask values
380  */
381 const ACE4_READ_DATA            = 0x00000001;
382 const ACE4_LIST_DIRECTORY       = 0x00000001;
383 const ACE4_WRITE_DATA           = 0x00000002;
384 const ACE4_ADD_FILE             = 0x00000002;
385 const ACE4_APPEND_DATA          = 0x00000004;
386 const ACE4_ADD_SUBDIRECTORY     = 0x00000004;
387 const ACE4_READ_NAMED_ATTRS     = 0x00000008;
388 const ACE4_WRITE_NAMED_ATTRS    = 0x00000010;
389 const ACE4_EXECUTE              = 0x00000020;
390 const ACE4_DELETE_CHILD         = 0x00000040;
391 const ACE4_READ_ATTRIBUTES      = 0x00000080;
392 const ACE4_WRITE_ATTRIBUTES     = 0x00000100;
393 const ACE4_WRITE_RETENTION      = 0x00000200;
394 const ACE4_WRITE_RETENTION_HOLD = 0x00000400;
395 
396 const ACE4_DELETE               = 0x00010000;
397 const ACE4_READ_ACL             = 0x00020000;
398 const ACE4_WRITE_ACL            = 0x00040000;
399 const ACE4_WRITE_OWNER          = 0x00080000;
400 const ACE4_SYNCHRONIZE          = 0x00100000;
401 
402 
403 /*
404  * ACE4_GENERIC_READ -- defined as a combination of
405  *      ACE4_READ_ACL |
406  *      ACE4_READ_DATA |
407  *      ACE4_READ_ATTRIBUTES |
408  *      ACE4_SYNCHRONIZE
409  */
410 
411 const ACE4_GENERIC_READ = 0x00120081;
412 
413 /*
414  * ACE4_GENERIC_WRITE -- defined as a combination of
415  *      ACE4_READ_ACL |
416  *      ACE4_WRITE_DATA |
417  *      ACE4_WRITE_ATTRIBUTES |
418  *      ACE4_WRITE_ACL |
419  *      ACE4_APPEND_DATA |
420  *      ACE4_SYNCHRONIZE
421  */
422 const ACE4_GENERIC_WRITE = 0x00160106;
423 
424 
425 /*
426  * ACE4_GENERIC_EXECUTE -- defined as a combination of
427  *      ACE4_READ_ACL |
428  *      ACE4_READ_ATTRIBUTES |
429  *      ACE4_EXECUTE |
430  *      ACE4_SYNCHRONIZE
431  */
432 const ACE4_GENERIC_EXECUTE = 0x001200A0;
433 
434 
435 /*
436  * ACE definition
437  */
438 struct nfsace4 {
439         acetype4        type;
440         aceflag4        flag;
441         acemask4        access_mask;
442         utf8str_mixed   who;
443 };
444 
445 
446 /*
447  * Access Control List (ACL) flag
448  */
449 
450 typedef uint32_t aclflag4;
451 
452 /*
453  * ACL flag values
454  */
455 const ACL4_AUTO_INHERIT         = 0x00000001;
456 const ACL4_PROTECTED            = 0x00000002;
457 const ACL4_DEFAULTED            = 0x00000004;
458 
459 
460 /*
461  * Version 4.1 ACL definition
462  */
463 struct nfsacl41 {
464         aclflag4        na41_flag;
465         nfsace4         na41_aces<>;
466 };
467 
468 
469 /*
470  * Field definitions for the fattr4_mode
471  * and fattr4_mode_set_masked attributes
472  */
473 const MODE4_SUID = 0x800;  /* set user id on execution */
474 const MODE4_SGID = 0x400;  /* set group id on execution */
475 const MODE4_SVTX = 0x200;  /* save text even after use */
476 const MODE4_RUSR = 0x100;  /* read permission: owner */
477 const MODE4_WUSR = 0x080;  /* write permission: owner */
478 const MODE4_XUSR = 0x040;  /* execute permission: owner */
479 const MODE4_RGRP = 0x020;  /* read permission: group */
480 const MODE4_WGRP = 0x010;  /* write permission: group */
481 const MODE4_XGRP = 0x008;  /* execute permission: group */
482 const MODE4_ROTH = 0x004;  /* read permission: other */
483 const MODE4_WOTH = 0x002;  /* write permission: other */
484 const MODE4_XOTH = 0x001;  /* execute permission: other */
485 
486 
487 /*
488  * Masked mode for the mode_set_masked attribute
489  */
490 struct mode_masked4 {
491  mode4  mm_value_to_set; /* Values of bits
492                             to set or reset
493                             in mode */
494 
495  mode4  mm_mask_bits;    /* Mask of bits to
496                             set or reset
497                             in mode */
498 };
499 
500 /*
501  * Special data/attribute associated with
502  * file types NF4BLK and NF4CHR
503  */
504 struct specdata4 {
505  uint32_t specdata1; /* Major device number */
506  uint32_t specdata2; /* Minor device number */
507 };
508 
509 /*
510  * Values for fattr4_fh_expire_type
511  */
512 const FH4_PERSISTENT          = 0x00000000;
513 const FH4_NOEXPIRE_WITH_OPEN  = 0x00000001;
514 const FH4_VOLATILE_ANY        = 0x00000002;
515 const FH4_VOL_MIGRATION       = 0x00000004;
516 const FH4_VOL_RENAME          = 0x00000008;
517 
518 
519 struct netaddr4 {
520         /* See struct rpcb in RFC 1833. */
521         string na_r_netid<>;    /* Network id */
522         string na_r_addr<>;     /* Universal address */
523 };
524 
525 
526 /*
527  * Data structures new to NFSv4.1
528  */
529 
530 struct nfs_impl_id4 {
531         utf8str_cis   nii_domain;
532         utf8str_cs    nii_name;
533         nfstime4      nii_date;
534 };
535 
536 
537 /*
538  * Stateid
539  */
540 struct stateid4 {
541         uint32_t        seqid;
542         opaque          other[NFS4_OTHER_SIZE];
543 };
544 
545 enum layouttype4 {
546         LAYOUT4_NFSV4_1_FILES   = 0x1,
547         LAYOUT4_OSD2_OBJECTS    = 0x2,
548         LAYOUT4_BLOCK_VOLUME    = 0x3
549 };
550 
551 struct layout_content4 {
552         layouttype4 loc_type;
553         opaque      loc_body<>;
554 };
555 
556 
557 %/*
558 % * LAYOUT4_OSD2_OBJECTS loc_body description
559 % * is in a separate .x file.
560 % */
561 %
562 %/*
563 % * LAYOUT4_BLOCK_VOLUME loc_body description
564 % * is in a separate .x file.
565 % */
566 
567 struct layouthint4 {
568         layouttype4             loh_type;
569         opaque                  loh_body<>;
570 };
571 
572 enum layoutiomode4 {
573         LAYOUTIOMODE4_READ      = 1,
574         LAYOUTIOMODE4_RW        = 2,
575         LAYOUTIOMODE4_ANY       = 3
576 };
577 
578 struct layout4 {
579         offset4                 lo_offset;
580         length4                 lo_length;
581         layoutiomode4           lo_iomode;
582         layout_content4         lo_content;
583 };
584 
585 const NFS4_DEVICEID4_SIZE = 16;
586 
587 typedef opaque  deviceid4[NFS4_DEVICEID4_SIZE];
588 
589 struct device_addr4 {
590         layouttype4             da_layout_type;
591         opaque                  da_addr_body<>;
592 };
593 
594 
595 struct layoutupdate4 {
596         layouttype4             lou_type;
597         opaque                  lou_body<>;
598 };
599 
600 %
601 /* Constants used for LAYOUTRETURN and CB_LAYOUTRECALL */
602 const LAYOUT4_RET_REC_FILE              = 1;
603 const LAYOUT4_RET_REC_FSID              = 2;
604 const LAYOUT4_RET_REC_ALL               = 3;
605 %
606 enum layoutreturn_type4 {
607         LAYOUTRETURN4_FILE = LAYOUT4_RET_REC_FILE,
608         LAYOUTRETURN4_FSID = LAYOUT4_RET_REC_FSID,
609         LAYOUTRETURN4_ALL  = LAYOUT4_RET_REC_ALL
610 };
611 
612 struct layoutreturn_file4 {
613         offset4         lrf_offset;
614         length4         lrf_length;
615         stateid4        lrf_stateid;
616 %       /* layouttype4 specific data */
617         opaque          lrf_body<>;
618 };
619 
620 union layoutreturn4 switch (layoutreturn_type4 lr_returntype) {
621         case LAYOUTRETURN4_FILE:
622                 layoutreturn_file4      lr_layout;
623         default:
624                 void;
625 };
626 %
627 
628 enum fs4_status_type {
629         STATUS4_FIXED     = 1,
630         STATUS4_UPDATED   = 2,
631         STATUS4_VERSIONED = 3,
632         STATUS4_WRITABLE  = 4,
633         STATUS4_REFERRAL  = 5
634 };
635 
636 struct fs4_status {
637         bool            fss_absent;
638         fs4_status_type fss_type;
639         utf8str_cs      fss_source;
640         utf8str_cs      fss_current;
641         int32_t         fss_age;
642         nfstime4        fss_version;
643 };
644 
645 
646 const TH4_READ_SIZE     = 0;
647 const TH4_WRITE_SIZE    = 1;
648 const TH4_READ_IOSIZE   = 2;
649 const TH4_WRITE_IOSIZE  = 3;
650 
651 typedef length4 threshold4_read_size;
652 typedef length4 threshold4_write_size;
653 typedef length4 threshold4_read_iosize;
654 typedef length4 threshold4_write_iosize;
655 
656 struct threshold_item4 {
657         layouttype4     thi_layout_type;
658         bitmap4         thi_hintset;
659         opaque          thi_hintlist<>;
660 };
661 
662 struct mdsthreshold4 {
663         threshold_item4 mth_hints<>;
664 };
665 
666 const RET4_DURATION_INFINITE    = 0xffffffffffffffff;
667 struct retention_get4 {
668         uint64_t        rg_duration;
669         nfstime4        rg_begin_time<1>;
670 };
671 
672 struct retention_set4 {
673         bool            rs_enable;
674         uint64_t        rs_duration<1>;
675 };
676 
677 const FSCHARSET_CAP4_CONTAINS_NON_UTF8  = 0x1;
678 const FSCHARSET_CAP4_ALLOWS_ONLY_UTF8   = 0x2;
679 
680 typedef uint32_t        fs_charset_cap4;
681 
682 
683 /*
684  * Data structures new to NFSv4.2
685  */
686 
687 enum netloc_type4 {
688         NL4_NAME        = 1,
689         NL4_URL         = 2,
690         NL4_NETADDR     = 3
691 };
692 union netloc4 switch (netloc_type4 nl_type) {
693         case NL4_NAME:          utf8str_cis nl_name;
694         case NL4_URL:           utf8str_cis nl_url;
695         case NL4_NETADDR:       netaddr4    nl_addr;
696 };
697 
698 enum change_attr_type4 {
699            NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR         = 0,
700            NFS4_CHANGE_TYPE_IS_VERSION_COUNTER        = 1,
701            NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS = 2,
702            NFS4_CHANGE_TYPE_IS_TIME_METADATA          = 3,
703            NFS4_CHANGE_TYPE_IS_UNDEFINED              = 4
704 };
705 
706 struct labelformat_spec4 {
707         policy4 lfs_lfs;
708         policy4 lfs_pi;
709 };
710 
711 struct sec_label4 {
712         labelformat_spec4       slai_lfs;
713         opaque                  slai_data<>;
714 };
715 
716 
717 struct copy_from_auth_priv {
718         secret4             cfap_shared_secret;
719         netloc4             cfap_destination;
720         /* The NFSv4 user name that the user principal maps to */
721         utf8str_mixed       cfap_username;
722 };
723 
724 struct copy_to_auth_priv {
725         /* Equal to cfap_shared_secret */
726         secret4              ctap_shared_secret;
727         netloc4              ctap_source<>;
728         /* The NFSv4 user name that the user principal maps to */
729         utf8str_mixed        ctap_username;
730 };
731 
732 struct copy_confirm_auth_priv {
733         /* Equal to GSS_GetMIC() of cfap_shared_secret */
734         opaque              ccap_shared_secret_mic<>;
735         /* The NFSv4 user name that the user principal maps to */
736         utf8str_mixed       ccap_username;
737 };
738 
739 
740 struct app_data_block4 {
741         offset4         adb_offset;
742         length4         adb_block_size;
743         length4         adb_block_count;
744         length4         adb_reloff_blocknum;
745         count4          adb_block_num;
746         length4         adb_reloff_pattern;
747         opaque          adb_pattern<>;
748 };
749 
750 
751 struct data4 {
752         offset4         d_offset;
753         opaque          d_data<>;
754 };
755 
756 struct data_info4 {
757         offset4         di_offset;
758         length4         di_length;
759 };
760 
761 
762 enum data_content4 {
763         NFS4_CONTENT_DATA = 0,
764         NFS4_CONTENT_HOLE = 1
765 };
766 
767 
768 
769 enum stable_how4 {
770         UNSTABLE4       = 0,
771         DATA_SYNC4      = 1,
772         FILE_SYNC4      = 2
773 };
774 
775 
776 
777 struct write_response4 {
778         stateid4        wr_callback_id<1>;
779         length4         wr_count;
780         stable_how4     wr_committed;
781         verifier4       wr_writeverf;
782 };
783 
784 
785 /*
786  * NFSv4.1 attributes
787  */
788 typedef bitmap4         fattr4_supported_attrs;
789 typedef nfs_ftype4      fattr4_type;
790 typedef uint32_t        fattr4_fh_expire_type;
791 typedef changeid4       fattr4_change;
792 typedef uint64_t        fattr4_size;
793 typedef bool            fattr4_link_support;
794 typedef bool            fattr4_symlink_support;
795 typedef bool            fattr4_named_attr;
796 typedef fsid4           fattr4_fsid;
797 typedef bool            fattr4_unique_handles;
798 typedef nfs_lease4      fattr4_lease_time;
799 typedef nfsstat4        fattr4_rdattr_error;
800 typedef nfsace4         fattr4_acl<>;
801 typedef uint32_t        fattr4_aclsupport;
802 typedef bool            fattr4_archive;
803 typedef bool            fattr4_cansettime;
804 typedef bool            fattr4_case_insensitive;
805 typedef bool            fattr4_case_preserving;
806 typedef bool            fattr4_chown_restricted;
807 typedef uint64_t        fattr4_fileid;
808 typedef uint64_t        fattr4_files_avail;
809 typedef nfs_fh4         fattr4_filehandle;
810 typedef uint64_t        fattr4_files_free;
811 typedef uint64_t        fattr4_files_total;
812 typedef fs_locations4   fattr4_fs_locations;
813 typedef bool            fattr4_hidden;
814 typedef bool            fattr4_homogeneous;
815 typedef uint64_t        fattr4_maxfilesize;
816 typedef uint32_t        fattr4_maxlink;
817 typedef uint32_t        fattr4_maxname;
818 typedef uint64_t        fattr4_maxread;
819 typedef uint64_t        fattr4_maxwrite;
820 typedef ascii_REQUIRED4 fattr4_mimetype;
821 typedef mode4           fattr4_mode;
822 typedef mode_masked4    fattr4_mode_set_masked;
823 typedef uint64_t        fattr4_mounted_on_fileid;
824 typedef bool            fattr4_no_trunc;
825 typedef uint32_t        fattr4_numlinks;
826 typedef utf8str_mixed   fattr4_owner;
827 typedef utf8str_mixed   fattr4_owner_group;
828 typedef uint64_t        fattr4_quota_avail_hard;
829 typedef uint64_t        fattr4_quota_avail_soft;
830 typedef uint64_t        fattr4_quota_used;
831 typedef specdata4       fattr4_rawdev;
832 typedef uint64_t        fattr4_space_avail;
833 typedef length4         fattr4_space_free;
834 typedef uint64_t        fattr4_space_total;
835 typedef uint64_t        fattr4_space_used;
836 typedef bool            fattr4_system;
837 typedef nfstime4        fattr4_time_access;
838 typedef settime4        fattr4_time_access_set;
839 typedef nfstime4        fattr4_time_backup;
840 typedef nfstime4        fattr4_time_create;
841 typedef nfstime4        fattr4_time_delta;
842 typedef nfstime4        fattr4_time_metadata;
843 typedef nfstime4        fattr4_time_modify;
844 typedef settime4        fattr4_time_modify_set;
845 /*
846  * Attributes new to NFSv4.1
847  */
848 typedef bitmap4         fattr4_suppattr_exclcreat;
849 typedef nfstime4        fattr4_dir_notif_delay;
850 typedef nfstime4        fattr4_dirent_notif_delay;
851 typedef layouttype4     fattr4_fs_layout_types<>;
852 typedef fs4_status      fattr4_fs_status;
853 typedef fs_charset_cap4 fattr4_fs_charset_cap;
854 typedef uint32_t        fattr4_layout_alignment;
855 typedef uint32_t        fattr4_layout_blksize;
856 typedef layouthint4     fattr4_layout_hint;
857 typedef layouttype4     fattr4_layout_types<>;
858 typedef mdsthreshold4   fattr4_mdsthreshold;
859 typedef retention_get4  fattr4_retention_get;
860 typedef retention_set4  fattr4_retention_set;
861 typedef retention_get4  fattr4_retentevt_get;
862 typedef retention_set4  fattr4_retentevt_set;
863 typedef uint64_t        fattr4_retention_hold;
864 typedef nfsacl41        fattr4_dacl;
865 typedef nfsacl41        fattr4_sacl;
866 typedef change_policy4  fattr4_change_policy;
867 /*
868  * Attributes new to NFSv4.2
869  */
870 typedef uint64_t        fattr4_space_freed;
871 typedef change_attr_type4
872                 fattr4_change_attr_type;
873 typedef sec_label4      fattr4_sec_label;
874 typedef uint32_t        fattr4_clone_blksize;
875 
876 %/*
877 % * REQUIRED attributes
878 % */
879 const FATTR4_SUPPORTED_ATTRS    = 0;
880 const FATTR4_TYPE               = 1;
881 const FATTR4_FH_EXPIRE_TYPE     = 2;
882 const FATTR4_CHANGE             = 3;
883 const FATTR4_SIZE               = 4;
884 const FATTR4_LINK_SUPPORT       = 5;
885 const FATTR4_SYMLINK_SUPPORT    = 6;
886 const FATTR4_NAMED_ATTR         = 7;
887 const FATTR4_FSID               = 8;
888 const FATTR4_UNIQUE_HANDLES     = 9;
889 const FATTR4_LEASE_TIME         = 10;
890 const FATTR4_RDATTR_ERROR       = 11;
891 const FATTR4_FILEHANDLE         = 19;
892 
893 %/*
894 % * New to NFSv4.1
895 % */
896 const FATTR4_SUPPATTR_EXCLCREAT = 75;
897 
898 %/*
899 % * RECOMMENDED attributes
900 % */
901 const FATTR4_ACL                = 12;
902 const FATTR4_ACLSUPPORT         = 13;
903 const FATTR4_ARCHIVE            = 14;
904 const FATTR4_CANSETTIME         = 15;
905 const FATTR4_CASE_INSENSITIVE   = 16;
906 const FATTR4_CASE_PRESERVING    = 17;
907 const FATTR4_CHOWN_RESTRICTED   = 18;
908 const FATTR4_FILEID             = 20;
909 const FATTR4_FILES_AVAIL        = 21;
910 const FATTR4_FILES_FREE         = 22;
911 const FATTR4_FILES_TOTAL        = 23;
912 const FATTR4_FS_LOCATIONS       = 24;
913 const FATTR4_HIDDEN             = 25;
914 const FATTR4_HOMOGENEOUS        = 26;
915 const FATTR4_MAXFILESIZE        = 27;
916 const FATTR4_MAXLINK            = 28;
917 const FATTR4_MAXNAME            = 29;
918 const FATTR4_MAXREAD            = 30;
919 const FATTR4_MAXWRITE           = 31;
920 const FATTR4_MIMETYPE           = 32;
921 const FATTR4_MODE               = 33;
922 const FATTR4_NO_TRUNC           = 34;
923 const FATTR4_NUMLINKS           = 35;
924 const FATTR4_OWNER              = 36;
925 const FATTR4_OWNER_GROUP        = 37;
926 const FATTR4_QUOTA_AVAIL_HARD   = 38;
927 const FATTR4_QUOTA_AVAIL_SOFT   = 39;
928 const FATTR4_QUOTA_USED         = 40;
929 const FATTR4_RAWDEV             = 41;
930 const FATTR4_SPACE_AVAIL        = 42;
931 const FATTR4_SPACE_FREE         = 43;
932 const FATTR4_SPACE_TOTAL        = 44;
933 const FATTR4_SPACE_USED         = 45;
934 const FATTR4_SYSTEM             = 46;
935 const FATTR4_TIME_ACCESS        = 47;
936 const FATTR4_TIME_ACCESS_SET    = 48;
937 const FATTR4_TIME_BACKUP        = 49;
938 const FATTR4_TIME_CREATE        = 50;
939 const FATTR4_TIME_DELTA         = 51;
940 const FATTR4_TIME_METADATA      = 52;
941 const FATTR4_TIME_MODIFY        = 53;
942 const FATTR4_TIME_MODIFY_SET    = 54;
943 const FATTR4_MOUNTED_ON_FILEID  = 55;
944 
945 %/*
946 % * New to NFSv4.1
947 % */
948 const FATTR4_DIR_NOTIF_DELAY    = 56;
949 const FATTR4_DIRENT_NOTIF_DELAY = 57;
950 const FATTR4_DACL               = 58;
951 const FATTR4_SACL               = 59;
952 const FATTR4_CHANGE_POLICY      = 60;
953 const FATTR4_FS_STATUS          = 61;
954 const FATTR4_FS_LAYOUT_TYPES    = 62;
955 const FATTR4_LAYOUT_HINT        = 63;
956 const FATTR4_LAYOUT_TYPES       = 64;
957 const FATTR4_LAYOUT_BLKSIZE     = 65;
958 const FATTR4_LAYOUT_ALIGNMENT   = 66;
959 const FATTR4_FS_LOCATIONS_INFO  = 67;
960 const FATTR4_MDSTHRESHOLD       = 68;
961 const FATTR4_RETENTION_GET      = 69;
962 const FATTR4_RETENTION_SET      = 70;
963 const FATTR4_RETENTEVT_GET      = 71;
964 const FATTR4_RETENTEVT_SET      = 72;
965 const FATTR4_RETENTION_HOLD     = 73;
966 const FATTR4_MODE_SET_MASKED    = 74;
967 const FATTR4_FS_CHARSET_CAP     = 76;
968 
969 %/*
970 % * New to NFSv4.2
971 % */
972 const FATTR4_CLONE_BLKSIZE      = 77;
973 const FATTR4_SPACE_FREED        = 78;
974 const FATTR4_CHANGE_ATTR_TYPE   = 79;
975 const FATTR4_SEC_LABEL          = 80;
976 
977 /*
978  * File attribute container
979  */
980 struct fattr4 {
981         bitmap4         attrmask;
982         attrlist4       attr_vals;
983 };
984 
985 /*
986  * Change info for the client
987  */
988 struct change_info4 {
989         bool            atomic;
990         changeid4       before;
991         changeid4       after;
992 };
993 
994 typedef netaddr4 clientaddr4;
995 
996 /*
997  * Callback program info as provided by the client
998  */
999 struct cb_client4 {
1000         uint32_t        cb_program;
1001         netaddr4        cb_location;
1002 };
1003 
1004 /*
1005  * NFSv4.0 long-hand client ID
1006  */
1007 struct nfs_client_id4 {
1008         verifier4       verifier;
1009         opaque          id<NFS4_OPAQUE_LIMIT>;
1010 };
1011 
1012 /*
1013  * NFSv4.1 client owner (aka long-hand client ID)
1014  */
1015 struct client_owner4 {
1016         verifier4       co_verifier;
1017         opaque          co_ownerid<NFS4_OPAQUE_LIMIT>;
1018 };
1019 
1020 
1021 /*
1022  * NFSv4.1 server owner
1023  */
1024 struct server_owner4 {
1025  uint64_t       so_minor_id;
1026  opaque         so_major_id<NFS4_OPAQUE_LIMIT>;
1027 };
1028 
1029 
1030 struct state_owner4 {
1031         clientid4       clientid;
1032         opaque          owner<NFS4_OPAQUE_LIMIT>;
1033 };
1034 
1035 typedef state_owner4 open_owner4;
1036 typedef state_owner4 lock_owner4;
1037 
1038 
1039 enum nfs_lock_type4 {
1040         READ_LT         = 1,
1041         WRITE_LT        = 2,
1042         READW_LT        = 3,    /* Blocking read */
1043         WRITEW_LT       = 4     /* Blocking write */
1044 };
1045 
1046 
1047 %
1048 %/* Input for computing subkeys */
1049 enum ssv_subkey4 {
1050         SSV4_SUBKEY_MIC_I2T     = 1,
1051         SSV4_SUBKEY_MIC_T2I     = 2,
1052         SSV4_SUBKEY_SEAL_I2T    = 3,
1053         SSV4_SUBKEY_SEAL_T2I    = 4
1054 };
1055 %
1056 
1057 %
1058 %/* Input for computing smt_hmac */
1059 struct ssv_mic_plain_tkn4 {
1060   uint32_t        smpt_ssv_seq;
1061   opaque          smpt_orig_plain<>;
1062 };
1063 %
1064 
1065 %
1066 %/*
1067 % * Secret State Verifier Generic Security Service (SSV GSS)
1068 % * PerMsgToken token
1069 % */
1070 struct ssv_mic_tkn4 {
1071   uint32_t        smt_ssv_seq;
1072   opaque          smt_hmac<>;
1073 };
1074 %
1075 
1076 %
1077 %/* Input for computing ssct_encr_data and ssct_hmac */
1078 struct ssv_seal_plain_tkn4 {
1079   opaque          sspt_confounder<>;
1080   uint32_t        sspt_ssv_seq;
1081   opaque          sspt_orig_plain<>;
1082   opaque          sspt_pad<>;
1083 };
1084 %
1085 
1086 %
1087 %/* SSV GSS SealedMessage token */
1088 struct ssv_seal_cipher_tkn4 {
1089   uint32_t      ssct_ssv_seq;
1090   opaque        ssct_iv<>;
1091   opaque        ssct_encr_data<>;
1092   opaque        ssct_hmac<>;
1093 };
1094 %
1095 
1096 /*
1097  * Defines an individual server replica
1098  */
1099 struct fs_locations_server4 {
1100        int32_t          fls_currency;
1101        opaque           fls_info<>;
1102        utf8str_cis      fls_server;
1103 };
1104 
1105 /*
1106  * Byte indices of items within
1107  * fls_info: flag fields, class numbers,
1108  * bytes indicating ranks and orders
1109  */
1110 const FSLI4BX_GFLAGS            = 0;
1111 const FSLI4BX_TFLAGS            = 1;
1112 
1113 const FSLI4BX_CLSIMUL           = 2;
1114 const FSLI4BX_CLHANDLE          = 3;
1115 const FSLI4BX_CLFILEID          = 4;
1116 const FSLI4BX_CLWRITEVER        = 5;
1117 const FSLI4BX_CLCHANGE          = 6;
1118 const FSLI4BX_CLREADDIR         = 7;
1119 
1120 const FSLI4BX_READRANK          = 8;
1121 const FSLI4BX_WRITERANK         = 9;
1122 const FSLI4BX_READORDER         = 10;
1123 const FSLI4BX_WRITEORDER        = 11;
1124 
1125 /*
1126  * Bits defined within the general flag byte
1127  */
1128 const FSLI4GF_WRITABLE          = 0x01;
1129 const FSLI4GF_CUR_REQ           = 0x02;
1130 const FSLI4GF_ABSENT            = 0x04;
1131 const FSLI4GF_GOING             = 0x08;
1132 const FSLI4GF_SPLIT             = 0x10;
1133 
1134 /*
1135  * Bits defined within the transport flag byte
1136  */
1137 const FSLI4TF_RDMA              = 0x01;
1138 
1139 /*
1140  * Defines a set of replicas sharing
1141  * a common value of the root path
1142  * within the corresponding
1143  * single-server namespaces
1144  */
1145 struct fs_locations_item4 {
1146        fs_locations_server4     fli_entries<>;
1147        pathname4                fli_rootpath;
1148 };
1149 
1150 /*
1151  * Defines the overall structure of
1152  * the fs_locations_info attribute
1153  */
1154 struct fs_locations_info4 {
1155        uint32_t                 fli_flags;
1156        int32_t                  fli_valid_for;
1157        pathname4                fli_fs_root;
1158        fs_locations_item4       fli_items<>;
1159 };
1160 
1161 /*
1162  * Flag bits in fli_flags
1163  */
1164 const FSLI4IF_VAR_SUB           = 0x00000001;
1165 
1166 typedef fs_locations_info4 fattr4_fs_locations_info;
1167 
1168 const NFL4_UFLG_MASK                    = 0x0000003F;
1169 const NFL4_UFLG_DENSE                   = 0x00000001;
1170 const NFL4_UFLG_COMMIT_THRU_MDS         = 0x00000002;
1171 const NFL42_UFLG_IO_ADVISE_THRU_MDS     = 0x00000004;
1172 const NFL4_UFLG_STRIPE_UNIT_SIZE_MASK   = 0xFFFFFFC0;
1173 
1174 typedef uint32_t nfl_util4;
1175 
1176 %
1177 
1178 enum filelayout_hint_care4 {
1179         NFLH4_CARE_DENSE        = NFL4_UFLG_DENSE,
1180 
1181         NFLH4_CARE_COMMIT_THRU_MDS
1182                                 = NFL4_UFLG_COMMIT_THRU_MDS,
1183 
1184         NFL42_CARE_IO_ADVISE_THRU_MDS
1185                                 = NFL42_UFLG_IO_ADVISE_THRU_MDS,
1186 
1187         NFLH4_CARE_STRIPE_UNIT_SIZE
1188                                 = 0x00000040,
1189 
1190         NFLH4_CARE_STRIPE_COUNT = 0x00000080
1191 };
1192 %
1193 %/*
1194 % * Encoded in the loh_body field of data type layouthint4:
1195 % */
1196 %
1197 struct nfsv4_1_file_layouthint4 {
1198         uint32_t        nflh_care;
1199         nfl_util4       nflh_util;
1200         count4          nflh_stripe_count;
1201 };
1202 
1203 %
1204 
1205 %
1206 typedef netaddr4 multipath_list4<>;
1207 %
1208 %/*
1209 % * Encoded in the da_addr_body field of data type device_addr4:
1210 % */
1211 struct nfsv4_1_file_layout_ds_addr4 {
1212         uint32_t        nflda_stripe_indices<>;
1213         multipath_list4 nflda_multipath_ds_list<>;
1214 };
1215 
1216 %
1217 
1218 %
1219 %/*
1220 % * Encoded in the loc_body field of data type layout_content4:
1221 % */
1222 struct nfsv4_1_file_layout4 {
1223          deviceid4      nfl_deviceid;
1224          nfl_util4      nfl_util;
1225          uint32_t       nfl_first_stripe_index;
1226          offset4        nfl_pattern_offset;
1227          nfs_fh4        nfl_fh_list<>;
1228 };
1229 
1230 %
1231 
1232 
1233 /*
1234  * Operation arrays (the opnum first)
1235  */
1236 
1237 enum nfs_opnum4 {
1238  OP_ACCESS               = 3,
1239  OP_CLOSE                = 4,
1240  OP_COMMIT               = 5,
1241  OP_CREATE               = 6,
1242  OP_DELEGPURGE           = 7,
1243  OP_DELEGRETURN          = 8,
1244  OP_GETATTR              = 9,
1245  OP_GETFH                = 10,
1246  OP_LINK                 = 11,
1247  OP_LOCK                 = 12,
1248  OP_LOCKT                = 13,
1249  OP_LOCKU                = 14,
1250  OP_LOOKUP               = 15,
1251  OP_LOOKUPP              = 16,
1252  OP_NVERIFY              = 17,
1253  OP_OPEN                 = 18,
1254  OP_OPENATTR             = 19,
1255  OP_OPEN_CONFIRM         = 20, /* Mandatory not-to-implement */
1256  OP_OPEN_DOWNGRADE       = 21,
1257  OP_PUTFH                = 22,
1258  OP_PUTPUBFH             = 23,
1259  OP_PUTROOTFH            = 24,
1260  OP_READ                 = 25,
1261  OP_READDIR              = 26,
1262  OP_READLINK             = 27,
1263  OP_REMOVE               = 28,
1264  OP_RENAME               = 29,
1265  OP_RENEW                = 30, /* Mandatory not-to-implement */
1266  OP_RESTOREFH            = 31,
1267  OP_SAVEFH               = 32,
1268  OP_SECINFO              = 33,
1269  OP_SETATTR              = 34,
1270  OP_SETCLIENTID          = 35, /* Mandatory not-to-implement */
1271  OP_SETCLIENTID_CONFIRM  = 36, /* Mandatory not-to-implement */
1272  OP_VERIFY               = 37,
1273  OP_WRITE                = 38,
1274  OP_RELEASE_LOCKOWNER    = 39, /* Mandatory not-to-implement */
1275 %
1276 %/* New operations for NFSv4.1 */
1277 %
1278  OP_BACKCHANNEL_CTL      = 40,
1279  OP_BIND_CONN_TO_SESSION = 41,
1280  OP_EXCHANGE_ID          = 42,
1281  OP_CREATE_SESSION       = 43,
1282  OP_DESTROY_SESSION      = 44,
1283  OP_FREE_STATEID         = 45,
1284  OP_GET_DIR_DELEGATION   = 46,
1285  OP_GETDEVICEINFO        = 47,
1286  OP_GETDEVICELIST        = 48,
1287  OP_LAYOUTCOMMIT         = 49,
1288  OP_LAYOUTGET            = 50,
1289  OP_LAYOUTRETURN         = 51,
1290  OP_SECINFO_NO_NAME      = 52,
1291  OP_SEQUENCE             = 53,
1292  OP_SET_SSV              = 54,
1293  OP_TEST_STATEID         = 55,
1294  OP_WANT_DELEGATION      = 56,
1295  OP_DESTROY_CLIENTID     = 57,
1296  OP_RECLAIM_COMPLETE     = 58,
1297 %
1298 %/* New operations for NFSv4.2 */
1299 %
1300  OP_ALLOCATE             = 59,
1301  OP_COPY                 = 60,
1302  OP_COPY_NOTIFY          = 61,
1303  OP_DEALLOCATE           = 62,
1304  OP_IO_ADVISE            = 63,
1305  OP_LAYOUTERROR          = 64,
1306  OP_LAYOUTSTATS          = 65,
1307  OP_OFFLOAD_CANCEL       = 66,
1308  OP_OFFLOAD_STATUS       = 67,
1309  OP_READ_PLUS            = 68,
1310  OP_SEEK                 = 69,
1311  OP_WRITE_SAME           = 70,
1312  OP_CLONE                = 71,
1313  OP_ILLEGAL              = 10044
1314 };
1315 
1316 
1317 
1318 const ACCESS4_READ       = 0x00000001;
1319 const ACCESS4_LOOKUP     = 0x00000002;
1320 const ACCESS4_MODIFY     = 0x00000004;
1321 const ACCESS4_EXTEND     = 0x00000008;
1322 const ACCESS4_DELETE     = 0x00000010;
1323 const ACCESS4_EXECUTE    = 0x00000020;
1324 
1325 struct ACCESS4args {
1326         /* CURRENT_FH: object */
1327         uint32_t        access;
1328 };
1329 
1330 struct ACCESS4resok {
1331         uint32_t        supported;
1332         uint32_t        access;
1333 };
1334 
1335 union ACCESS4res switch (nfsstat4 status) {
1336  case NFS4_OK:
1337          ACCESS4resok    resok4;
1338  default:
1339          void;
1340 };
1341 
1342 struct CLONE4args {
1343         /* SAVED_FH: source file */
1344         /* CURRENT_FH: destination file */
1345         stateid4        cl_src_stateid;
1346         stateid4        cl_dst_stateid;
1347         offset4         cl_src_offset;
1348         offset4         cl_dst_offset;
1349         length4         cl_count;
1350 };
1351 
1352 struct CLONE4res {
1353         nfsstat4        cl_status;
1354 };
1355 struct CLOSE4args {
1356         /* CURRENT_FH: object */
1357         seqid4          seqid;
1358         stateid4        open_stateid;
1359 };
1360 
1361 union CLOSE4res switch (nfsstat4 status) {
1362  case NFS4_OK:
1363          stateid4       open_stateid;
1364  default:
1365          void;
1366 };
1367 
1368 struct COMMIT4args {
1369         /* CURRENT_FH: file */
1370         offset4         offset;
1371         count4          count;
1372 };
1373 
1374 struct COMMIT4resok {
1375         verifier4       writeverf;
1376 };
1377 
1378 union COMMIT4res switch (nfsstat4 status) {
1379  case NFS4_OK:
1380          COMMIT4resok   resok4;
1381  default:
1382          void;
1383 };
1384 
1385 union createtype4 switch (nfs_ftype4 type) {
1386  case NF4LNK:
1387          linktext4 linkdata;
1388  case NF4BLK:
1389  case NF4CHR:
1390          specdata4 devdata;
1391  case NF4SOCK:
1392  case NF4FIFO:
1393  case NF4DIR:
1394          void;
1395  default:
1396          void;  /* Server should return NFS4ERR_BADTYPE. */
1397 };
1398 
1399 struct CREATE4args {
1400         /* CURRENT_FH: directory for creation */
1401         createtype4     objtype;
1402         component4      objname;
1403         fattr4          createattrs;
1404 };
1405 
1406 struct CREATE4resok {
1407         change_info4    cinfo;
1408         bitmap4         attrset;        /* Attributes set */
1409 };
1410 
1411 union CREATE4res switch (nfsstat4 status) {
1412  case NFS4_OK:
1413          /* New CURRENTFH: created object */
1414          CREATE4resok resok4;
1415  default:
1416          void;
1417 };
1418 
1419 struct DELEGPURGE4args {
1420         clientid4       clientid;
1421 };
1422 
1423 struct DELEGPURGE4res {
1424         nfsstat4        status;
1425 };
1426 
1427 struct DELEGRETURN4args {
1428         /* CURRENT_FH: delegated object */
1429         stateid4        deleg_stateid;
1430 };
1431 
1432 struct DELEGRETURN4res {
1433         nfsstat4        status;
1434 };
1435 
1436 struct GETATTR4args {
1437         /* CURRENT_FH: object */
1438         bitmap4         attr_request;
1439 };
1440 
1441 struct GETATTR4resok {
1442         fattr4          obj_attributes;
1443 };
1444 
1445 union GETATTR4res switch (nfsstat4 status) {
1446  case NFS4_OK:
1447          GETATTR4resok  resok4;
1448  default:
1449          void;
1450 };
1451 
1452 struct GETFH4resok {
1453         nfs_fh4         object;
1454 };
1455 
1456 union GETFH4res switch (nfsstat4 status) {
1457  case NFS4_OK:
1458          GETFH4resok     resok4;
1459  default:
1460          void;
1461 };
1462 
1463 struct LINK4args {
1464         /* SAVED_FH: source object */
1465         /* CURRENT_FH: target directory */
1466         component4      newname;
1467 };
1468 
1469 struct LINK4resok {
1470         change_info4    cinfo;
1471 };
1472 
1473 union LINK4res switch (nfsstat4 status) {
1474  case NFS4_OK:
1475          LINK4resok resok4;
1476  default:
1477          void;
1478 };
1479 
1480 /*
1481  * For LOCK, transition from open_stateid and lock_owner
1482  * to a lock stateid.
1483  */
1484 struct open_to_lock_owner4 {
1485         seqid4          open_seqid;
1486         stateid4        open_stateid;
1487         seqid4          lock_seqid;
1488         lock_owner4     lock_owner;
1489 };
1490 
1491 /*
1492  * For LOCK, existing lock stateid continues to request new
1493  * file lock for the same lock_owner and open_stateid.
1494  */
1495 struct exist_lock_owner4 {
1496         stateid4        lock_stateid;
1497         seqid4          lock_seqid;
1498 };
1499 
1500 union locker4 switch (bool new_lock_owner) {
1501  case TRUE:
1502         open_to_lock_owner4     open_owner;
1503  case FALSE:
1504         exist_lock_owner4       lock_owner;
1505 };
1506 
1507 /*
1508  * LOCK/LOCKT/LOCKU: Record lock management
1509  */
1510 struct LOCK4args {
1511         /* CURRENT_FH: file */
1512         nfs_lock_type4  locktype;
1513         bool            reclaim;
1514         offset4         offset;
1515         length4         length;
1516         locker4         locker;
1517 };
1518 
1519 struct LOCK4denied {
1520         offset4         offset;
1521         length4         length;
1522         nfs_lock_type4  locktype;
1523         lock_owner4     owner;
1524 };
1525 
1526 struct LOCK4resok {
1527         stateid4        lock_stateid;
1528 };
1529 
1530 union LOCK4res switch (nfsstat4 status) {
1531  case NFS4_OK:
1532          LOCK4resok     resok4;
1533  case NFS4ERR_DENIED:
1534          LOCK4denied    denied;
1535  default:
1536          void;
1537 };
1538 
1539 struct LOCKT4args {
1540         /* CURRENT_FH: file */
1541         nfs_lock_type4  locktype;
1542         offset4         offset;
1543         length4         length;
1544         lock_owner4     owner;
1545 };
1546 
1547 union LOCKT4res switch (nfsstat4 status) {
1548  case NFS4ERR_DENIED:
1549          LOCK4denied    denied;
1550  case NFS4_OK:
1551          void;
1552  default:
1553          void;
1554 };
1555 
1556 struct LOCKU4args {
1557         /* CURRENT_FH: file */
1558         nfs_lock_type4  locktype;
1559         seqid4          seqid;
1560         stateid4        lock_stateid;
1561         offset4         offset;
1562         length4         length;
1563 };
1564 
1565 union LOCKU4res switch (nfsstat4 status) {
1566  case NFS4_OK:
1567          stateid4       lock_stateid;
1568  default:
1569          void;
1570 };
1571 
1572 struct LOOKUP4args {
1573         /* CURRENT_FH: directory */
1574         component4      objname;
1575 };
1576 
1577 struct LOOKUP4res {
1578         /* New CURRENT_FH: object */
1579         nfsstat4        status;
1580 };
1581 
1582 struct LOOKUPP4res {
1583         /* New CURRENT_FH: parent directory */
1584         nfsstat4        status;
1585 };
1586 
1587 struct NVERIFY4args {
1588         /* CURRENT_FH: object */
1589         fattr4          obj_attributes;
1590 };
1591 
1592 struct NVERIFY4res {
1593         nfsstat4        status;
1594 };
1595 
1596 /*
1597  * Various definitions for OPEN
1598  */
1599 enum createmode4 {
1600         UNCHECKED4      = 0,
1601         GUARDED4        = 1,
1602         /* Deprecated in NFSv4.1 */
1603         EXCLUSIVE4      = 2,
1604         /*
1605          * New to NFSv4.1.  If session is persistent,
1606          * GUARDED4 MUST be used.  Otherwise, use
1607          * EXCLUSIVE4_1 instead of EXCLUSIVE4.
1608          */
1609         EXCLUSIVE4_1    = 3
1610 };
1611 
1612 struct creatverfattr {
1613          verifier4      cva_verf;
1614          fattr4         cva_attrs;
1615 };
1616 
1617 union createhow4 switch (createmode4 mode) {
1618  case UNCHECKED4:
1619  case GUARDED4:
1620          fattr4         createattrs;
1621  case EXCLUSIVE4:
1622          verifier4      createverf;
1623  case EXCLUSIVE4_1:
1624          creatverfattr  ch_createboth;
1625 };
1626 
1627 enum opentype4 {
1628         OPEN4_NOCREATE  = 0,
1629         OPEN4_CREATE    = 1
1630 };
1631 
1632 union openflag4 switch (opentype4 opentype) {
1633  case OPEN4_CREATE:
1634          createhow4     how;
1635  default:
1636          void;
1637 };
1638 
1639 /* Next definitions used for OPEN delegation */
1640 enum limit_by4 {
1641         NFS_LIMIT_SIZE          = 1,
1642         NFS_LIMIT_BLOCKS        = 2
1643         /* Others as needed */
1644 };
1645 
1646 struct nfs_modified_limit4 {
1647         uint32_t        num_blocks;
1648         uint32_t        bytes_per_block;
1649 };
1650 
1651 union nfs_space_limit4 switch (limit_by4 limitby) {
1652  /* Limit specified as file size */
1653  case NFS_LIMIT_SIZE:
1654          uint64_t               filesize;
1655  /* Limit specified by number of blocks */
1656  case NFS_LIMIT_BLOCKS:
1657          nfs_modified_limit4    mod_blocks;
1658 };
1659 
1660 /*
1661  * Share Access and Deny constants for open argument
1662  */
1663 const OPEN4_SHARE_ACCESS_READ   = 0x00000001;
1664 const OPEN4_SHARE_ACCESS_WRITE  = 0x00000002;
1665 const OPEN4_SHARE_ACCESS_BOTH   = 0x00000003;
1666 
1667 const OPEN4_SHARE_DENY_NONE     = 0x00000000;
1668 const OPEN4_SHARE_DENY_READ     = 0x00000001;
1669 const OPEN4_SHARE_DENY_WRITE    = 0x00000002;
1670 const OPEN4_SHARE_DENY_BOTH     = 0x00000003;
1671 
1672 
1673 /* New flags for share_access field of OPEN4args */
1674 const OPEN4_SHARE_ACCESS_WANT_DELEG_MASK        = 0xFF00;
1675 const OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE     = 0x0000;
1676 const OPEN4_SHARE_ACCESS_WANT_READ_DELEG        = 0x0100;
1677 const OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG       = 0x0200;
1678 const OPEN4_SHARE_ACCESS_WANT_ANY_DELEG         = 0x0300;
1679 const OPEN4_SHARE_ACCESS_WANT_NO_DELEG          = 0x0400;
1680 const OPEN4_SHARE_ACCESS_WANT_CANCEL            = 0x0500;
1681 
1682 const
1683  OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL
1684  = 0x10000;
1685 
1686 const
1687  OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED
1688  = 0x20000;
1689 
1690 enum open_delegation_type4 {
1691         OPEN_DELEGATE_NONE      = 0,
1692         OPEN_DELEGATE_READ      = 1,
1693         OPEN_DELEGATE_WRITE     = 2,
1694         OPEN_DELEGATE_NONE_EXT  = 3 /* New to NFSv4.1 */
1695 };
1696 
1697 enum open_claim_type4 {
1698         /*
1699          * Not a reclaim
1700          */
1701         CLAIM_NULL              = 0,
1702 
1703         CLAIM_PREVIOUS          = 1,
1704         CLAIM_DELEGATE_CUR      = 2,
1705         CLAIM_DELEGATE_PREV     = 3,
1706 
1707         /*
1708          * Not a reclaim
1709          *
1710          * Like CLAIM_NULL, but object identified
1711          * by the current filehandle
1712          */
1713         CLAIM_FH                = 4, /* New to NFSv4.1 */
1714 
1715         /*
1716          * Like CLAIM_DELEGATE_CUR, but object identified
1717          * by current filehandle
1718          */
1719         CLAIM_DELEG_CUR_FH      = 5, /* New to NFSv4.1 */
1720 
1721         /*
1722          * Like CLAIM_DELEGATE_PREV, but object identified
1723          * by current filehandle
1724          */
1725         CLAIM_DELEG_PREV_FH     = 6 /* New to NFSv4.1 */
1726 };
1727 
1728 struct open_claim_delegate_cur4 {
1729         stateid4        delegate_stateid;
1730         component4      file;
1731 };
1732 
1733 union open_claim4 switch (open_claim_type4 claim) {
1734  /*
1735   * No special rights to file.
1736   * Ordinary OPEN of the specified file.
1737   */
1738  case CLAIM_NULL:
1739         /* CURRENT_FH: directory */
1740         component4      file;
1741  /*
1742   * Right to the file established by an
1743   * open previous to server reboot.  File
1744   * identified by filehandle obtained at
1745   * that time rather than by name.
1746   */
1747  case CLAIM_PREVIOUS:
1748         /* CURRENT_FH: file being reclaimed */
1749         open_delegation_type4   delegate_type;
1750 
1751  /*
1752   * Right to file based on a delegation
1753   * granted by the server.  File is
1754   * specified by name.
1755   */
1756  case CLAIM_DELEGATE_CUR:
1757         /* CURRENT_FH: directory */
1758         open_claim_delegate_cur4        delegate_cur_info;
1759 
1760  /*
1761   * Right to file based on a delegation
1762   * granted to a previous boot instance
1763   * of the client.  File is specified by name.
1764   */
1765  case CLAIM_DELEGATE_PREV:
1766          /* CURRENT_FH: directory */
1767         component4      file_delegate_prev;
1768 
1769  /*
1770   * Like CLAIM_NULL.  No special rights
1771   * to file.  Ordinary OPEN of the
1772   * specified file by current filehandle.
1773   */
1774  case CLAIM_FH: /* New to NFSv4.1 */
1775         /* CURRENT_FH: regular file to open */
1776         void;
1777 
1778  /*
1779   * Like CLAIM_DELEGATE_PREV.  Right to file based on a
1780   * delegation granted to a previous boot
1781   * instance of the client.  File is identified
1782   * by filehandle.
1783   */
1784  case CLAIM_DELEG_PREV_FH: /* New to NFSv4.1 */
1785         /* CURRENT_FH: file being opened */
1786         void;
1787 
1788  /*
1789   * Like CLAIM_DELEGATE_CUR.  Right to file based on
1790   * a delegation granted by the server.
1791   * File is identified by filehandle.
1792   */
1793  case CLAIM_DELEG_CUR_FH: /* New to NFSv4.1 */
1794          /* CURRENT_FH: file being opened */
1795          stateid4       oc_delegate_stateid;
1796 
1797 };
1798 
1799 /*
1800  * OPEN: Open a file, potentially receiving an open delegation.
1801  */
1802 struct OPEN4args {
1803         seqid4          seqid;
1804         uint32_t        share_access;
1805         uint32_t        share_deny;
1806         open_owner4     owner;
1807         openflag4       openhow;
1808         open_claim4     claim;
1809 };
1810 
1811 struct open_read_delegation4 {
1812  stateid4 stateid;    /* Stateid for delegation */
1813  bool     recall;     /* Pre-recalled flag for
1814                          delegations obtained
1815                          by reclaim (CLAIM_PREVIOUS) */
1816 
1817  nfsace4 permissions; /* Defines users who don't
1818                          need an ACCESS call to
1819                          open for read */
1820 };
1821 
1822 struct open_write_delegation4 {
1823  stateid4 stateid;      /* Stateid for delegation */
1824  bool     recall;       /* Pre-recalled flag for
1825                            delegations obtained
1826                            by reclaim
1827                            (CLAIM_PREVIOUS) */
1828 
1829  nfs_space_limit4
1830            space_limit; /* Defines condition that
1831                            the client must check to
1832                            determine whether the
1833                            file needs to be flushed
1834                            to the server on close */
1835 
1836  nfsace4   permissions; /* Defines users who don't
1837                            need an ACCESS call as
1838                            part of a delegated
1839                            open */
1840 };
1841 
1842 
1843 enum why_no_delegation4 { /* New to NFSv4.1 */
1844         WND4_NOT_WANTED                 = 0,
1845         WND4_CONTENTION                 = 1,
1846         WND4_RESOURCE                   = 2,
1847         WND4_NOT_SUPP_FTYPE             = 3,
1848         WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
1849         WND4_NOT_SUPP_UPGRADE           = 5,
1850         WND4_NOT_SUPP_DOWNGRADE         = 6,
1851         WND4_CANCELLED                  = 7,
1852         WND4_IS_DIR                     = 8
1853 };
1854 
1855 union open_none_delegation4 /* New to NFSv4.1 */
1856  switch (why_no_delegation4 ond_why) {
1857          case WND4_CONTENTION:
1858                  bool ond_server_will_push_deleg;
1859          case WND4_RESOURCE:
1860                  bool ond_server_will_signal_avail;
1861          default:
1862                  void;
1863 };
1864 
1865 union open_delegation4
1866  switch (open_delegation_type4 delegation_type) {
1867          case OPEN_DELEGATE_NONE:
1868                  void;
1869          case OPEN_DELEGATE_READ:
1870                  open_read_delegation4 read;
1871          case OPEN_DELEGATE_WRITE:
1872                  open_write_delegation4 write;
1873          case OPEN_DELEGATE_NONE_EXT: /* New to NFSv4.1 */
1874                  open_none_delegation4 od_whynone;
1875 };
1876 
1877 /*
1878  * Result flags
1879  */
1880 
1881 /* Client must confirm open. */
1882 const OPEN4_RESULT_CONFIRM      = 0x00000002;
1883 /* Type of file-locking behavior at the server */
1884 const OPEN4_RESULT_LOCKTYPE_POSIX = 0x00000004;
1885 /* Server will preserve file if removed while open. */
1886 const OPEN4_RESULT_PRESERVE_UNLINKED = 0x00000008;
1887 
1888 /*
1889  * Server may use CB_NOTIFY_LOCK on locks
1890  * derived from this open.
1891  */
1892 const OPEN4_RESULT_MAY_NOTIFY_LOCK = 0x00000020;
1893 
1894 struct OPEN4resok {
1895  stateid4         stateid;      /* Stateid for open */
1896  change_info4     cinfo;        /* Directory change info */
1897  uint32_t         rflags;       /* Result flags */
1898  bitmap4          attrset;      /* Attribute set for create */
1899  open_delegation4 delegation;   /* Info on any open
1900                                    delegation */
1901 };
1902 
1903 union OPEN4res switch (nfsstat4 status) {
1904  case NFS4_OK:
1905          /* New CURRENT_FH: opened file */
1906          OPEN4resok      resok4;
1907  default:
1908          void;
1909 };
1910 
1911 struct OPENATTR4args {
1912         /* CURRENT_FH: object */
1913         bool    createdir;
1914 };
1915 
1916 struct OPENATTR4res {
1917         /*
1918          * If status is NFS4_OK,
1919          *   New CURRENT_FH: named attribute
1920          *                   directory
1921          */
1922         nfsstat4        status;
1923 };
1924 
1925 /* Obsolete in NFSv4.1 */
1926 struct OPEN_CONFIRM4args {
1927         /* CURRENT_FH: opened file */
1928         stateid4        open_stateid;
1929         seqid4          seqid;
1930 };
1931 
1932 struct OPEN_CONFIRM4resok {
1933         stateid4        open_stateid;
1934 };
1935 
1936 union OPEN_CONFIRM4res switch (nfsstat4 status) {
1937  case NFS4_OK:
1938          OPEN_CONFIRM4resok     resok4;
1939  default:
1940          void;
1941 };
1942 
1943 struct OPEN_DOWNGRADE4args {
1944         /* CURRENT_FH: opened file */
1945         stateid4        open_stateid;
1946         seqid4          seqid;
1947         uint32_t        share_access;
1948         uint32_t        share_deny;
1949 };
1950 
1951 struct OPEN_DOWNGRADE4resok {
1952         stateid4        open_stateid;
1953 };
1954 
1955 union OPEN_DOWNGRADE4res switch (nfsstat4 status) {
1956  case NFS4_OK:
1957          OPEN_DOWNGRADE4resok    resok4;
1958  default:
1959          void;
1960 };
1961 
1962 struct PUTFH4args {
1963         nfs_fh4         object;
1964 };
1965 
1966 struct PUTFH4res {
1967         /*
1968          * If status is NFS4_OK,
1969          *   New CURRENT_FH: argument to PUTFH
1970          */
1971         nfsstat4        status;
1972 };
1973 
1974 struct PUTPUBFH4res {
1975         /*
1976          * If status is NFS4_OK,
1977          *   New CURRENT_FH: public fh
1978          */
1979         nfsstat4        status;
1980 };
1981 
1982 struct PUTROOTFH4res {
1983         /*
1984          * If status is NFS4_OK,
1985          *   New CURRENT_FH: root fh
1986          */
1987         nfsstat4        status;
1988 };
1989 
1990 struct READ4args {
1991         /* CURRENT_FH: file */
1992         stateid4        stateid;
1993         offset4         offset;
1994         count4          count;
1995 };
1996 
1997 struct READ4resok {
1998         bool            eof;
1999         opaque          data<>;
2000 };
2001 
2002 union READ4res switch (nfsstat4 status) {
2003  case NFS4_OK:
2004          READ4resok     resok4;
2005  default:
2006          void;
2007 };
2008 
2009 struct READDIR4args {
2010         /* CURRENT_FH: directory */
2011         nfs_cookie4     cookie;
2012         verifier4       cookieverf;
2013         count4          dircount;
2014         count4          maxcount;
2015         bitmap4         attr_request;
2016 };
2017 
2018 struct entry4 {
2019         nfs_cookie4     cookie;
2020         component4      name;
2021         fattr4          attrs;
2022         entry4          *nextentry;
2023 };
2024 
2025 struct dirlist4 {
2026         entry4          *entries;
2027         bool            eof;
2028 };
2029 
2030 struct READDIR4resok {
2031         verifier4       cookieverf;
2032         dirlist4        reply;
2033 };
2034 
2035 
2036 union READDIR4res switch (nfsstat4 status) {
2037  case NFS4_OK:
2038          READDIR4resok  resok4;
2039  default:
2040          void;
2041 };
2042 
2043 
2044 struct READLINK4resok {
2045         linktext4       link;
2046 };
2047 
2048 union READLINK4res switch (nfsstat4 status) {
2049  case NFS4_OK:
2050          READLINK4resok resok4;
2051  default:
2052          void;
2053 };
2054 
2055 struct REMOVE4args {
2056         /* CURRENT_FH: directory */
2057         component4      target;
2058 };
2059 
2060 struct REMOVE4resok {
2061         change_info4    cinfo;
2062 };
2063 
2064 union REMOVE4res switch (nfsstat4 status) {
2065  case NFS4_OK:
2066          REMOVE4resok   resok4;
2067  default:
2068          void;
2069 };
2070 
2071 struct RENAME4args {
2072         /* SAVED_FH: source directory */
2073         component4      oldname;
2074         /* CURRENT_FH: target directory */
2075         component4      newname;
2076 };
2077 
2078 struct RENAME4resok {
2079         change_info4    source_cinfo;
2080         change_info4    target_cinfo;
2081 };
2082 
2083 union RENAME4res switch (nfsstat4 status) {
2084  case NFS4_OK:
2085          RENAME4resok    resok4;
2086  default:
2087          void;
2088 };
2089 
2090 /* Obsolete in NFSv4.1 */
2091 struct RENEW4args {
2092         clientid4       clientid;
2093 };
2094 
2095 struct RENEW4res {
2096         nfsstat4        status;
2097 };
2098 
2099 struct RESTOREFH4res {
2100         /*
2101          * If status is NFS4_OK,
2102          *   New CURRENT_FH: value of saved fh
2103          */
2104         nfsstat4        status;
2105 };
2106 
2107 struct SAVEFH4res {
2108         /*
2109          * If status is NFS4_OK,
2110          *   New SAVED_FH: value of current fh
2111          */
2112         nfsstat4        status;
2113 };
2114 
2115 struct SECINFO4args {
2116         /* CURRENT_FH: directory */
2117         component4      name;
2118 };
2119 
2120 /*
2121  * From RFC 2203
2122  */
2123 enum rpc_gss_svc_t {
2124         RPC_GSS_SVC_NONE        = 1,
2125         RPC_GSS_SVC_INTEGRITY   = 2,
2126         RPC_GSS_SVC_PRIVACY     = 3
2127 };
2128 
2129 struct rpcsec_gss_info {
2130         sec_oid4        oid;
2131         qop4            qop;
2132         rpc_gss_svc_t   service;
2133 };
2134 
2135 /* RPCSEC_GSS has a value of "6".  See RFC 2203. */
2136 union secinfo4 switch (uint32_t flavor) {
2137  case RPCSEC_GSS:
2138          rpcsec_gss_info        flavor_info;
2139  default:
2140          void;
2141 };
2142 
2143 typedef secinfo4 SECINFO4resok<>;
2144 
2145 union SECINFO4res switch (nfsstat4 status) {
2146  case NFS4_OK:
2147          /* CURRENTFH: consumed */
2148          SECINFO4resok resok4;
2149  default:
2150          void;
2151 };
2152 
2153 struct SETATTR4args {
2154         /* CURRENT_FH: target object */
2155         stateid4        stateid;
2156         fattr4          obj_attributes;
2157 };
2158 
2159 struct SETATTR4res {
2160         nfsstat4        status;
2161         bitmap4         attrsset;
2162 };
2163 
2164 /* Obsolete in NFSv4.1 */
2165 struct SETCLIENTID4args {
2166         nfs_client_id4  client;
2167         cb_client4      callback;
2168         uint32_t        callback_ident;
2169 };
2170 
2171 struct SETCLIENTID4resok {
2172         clientid4       clientid;
2173         verifier4       setclientid_confirm;
2174 };
2175 
2176 union SETCLIENTID4res switch (nfsstat4 status) {
2177  case NFS4_OK:
2178          SETCLIENTID4resok      resok4;
2179  case NFS4ERR_CLID_INUSE:
2180          clientaddr4    client_using;
2181  default:
2182          void;
2183 };
2184 
2185 /* Obsolete in NFSv4.1 */
2186 struct SETCLIENTID_CONFIRM4args {
2187         clientid4       clientid;
2188         verifier4       setclientid_confirm;
2189 };
2190 
2191 struct SETCLIENTID_CONFIRM4res {
2192         nfsstat4        status;
2193 };
2194 
2195 struct VERIFY4args {
2196         /* CURRENT_FH: object */
2197         fattr4          obj_attributes;
2198 };
2199 
2200 struct VERIFY4res {
2201         nfsstat4        status;
2202 };
2203 
2204 struct WRITE4args {
2205         /* CURRENT_FH: file */
2206         stateid4        stateid;
2207         offset4         offset;
2208         stable_how4     stable;
2209         opaque          data<>;
2210 };
2211 
2212 struct WRITE4resok {
2213         count4          count;
2214         stable_how4     committed;
2215         verifier4       writeverf;
2216 };
2217 
2218 union WRITE4res switch (nfsstat4 status) {
2219  case NFS4_OK:
2220          WRITE4resok    resok4;
2221  default:
2222          void;
2223 };
2224 
2225 /* Obsolete in NFSv4.1 */
2226 struct RELEASE_LOCKOWNER4args {
2227         lock_owner4     lock_owner;
2228 };
2229 
2230 struct RELEASE_LOCKOWNER4res {
2231         nfsstat4        status;
2232 };
2233 
2234 struct ILLEGAL4res {
2235         nfsstat4        status;
2236 };
2237 
2238 typedef opaque gsshandle4_t<>;
2239 
2240 struct gss_cb_handles4 {
2241         rpc_gss_svc_t           gcbp_service; /* RFC 2203 */
2242         gsshandle4_t            gcbp_handle_from_server;
2243         gsshandle4_t            gcbp_handle_from_client;
2244 };
2245 
2246 union callback_sec_parms4 switch (uint32_t cb_secflavor) {
2247  case AUTH_NONE:
2248          void;
2249  case AUTH_SYS:
2250          authsys_parms   cbsp_sys_cred; /* RFC 5531 */
2251  case RPCSEC_GSS:
2252          gss_cb_handles4 cbsp_gss_handles;
2253 };
2254 
2255 struct BACKCHANNEL_CTL4args {
2256         uint32_t                bca_cb_program;
2257         callback_sec_parms4     bca_sec_parms<>;
2258 };
2259 
2260 struct BACKCHANNEL_CTL4res {
2261         nfsstat4                bcr_status;
2262 };
2263 
2264 enum channel_dir_from_client4 {
2265  CDFC4_FORE             = 0x1,
2266  CDFC4_BACK             = 0x2,
2267  CDFC4_FORE_OR_BOTH     = 0x3,
2268  CDFC4_BACK_OR_BOTH     = 0x7
2269 };
2270 
2271 struct BIND_CONN_TO_SESSION4args {
2272  sessionid4     bctsa_sessid;
2273 
2274  channel_dir_from_client4
2275                 bctsa_dir;
2276 
2277  bool           bctsa_use_conn_in_rdma_mode;
2278 };
2279 
2280 enum channel_dir_from_server4 {
2281  CDFS4_FORE     = 0x1,
2282  CDFS4_BACK     = 0x2,
2283  CDFS4_BOTH     = 0x3
2284 };
2285 
2286 struct BIND_CONN_TO_SESSION4resok {
2287  sessionid4     bctsr_sessid;
2288 
2289  channel_dir_from_server4
2290                 bctsr_dir;
2291 
2292  bool           bctsr_use_conn_in_rdma_mode;
2293 };
2294 
2295 union BIND_CONN_TO_SESSION4res
2296  switch (nfsstat4 bctsr_status) {
2297          case NFS4_OK:
2298                  BIND_CONN_TO_SESSION4resok  bctsr_resok4;
2299          default:
2300                  void;
2301 };
2302 
2303 const EXCHGID4_FLAG_SUPP_MOVED_REFER    = 0x00000001;
2304 const EXCHGID4_FLAG_SUPP_MOVED_MIGR     = 0x00000002;
2305 const EXCHGID4_FLAG_SUPP_FENCE_OPS      = 0x00000004;
2306 
2307 const EXCHGID4_FLAG_BIND_PRINC_STATEID  = 0x00000100;
2308 
2309 const EXCHGID4_FLAG_USE_NON_PNFS        = 0x00010000;
2310 const EXCHGID4_FLAG_USE_PNFS_MDS        = 0x00020000;
2311 const EXCHGID4_FLAG_USE_PNFS_DS         = 0x00040000;
2312 
2313 const EXCHGID4_FLAG_MASK_PNFS           = 0x00070000;
2314 
2315 const EXCHGID4_FLAG_UPD_CONFIRMED_REC_A = 0x40000000;
2316 const EXCHGID4_FLAG_CONFIRMED_R         = 0x80000000;
2317 
2318 struct state_protect_ops4 {
2319         bitmap4 spo_must_enforce;
2320         bitmap4 spo_must_allow;
2321 };
2322 
2323 struct ssv_sp_parms4 {
2324         state_protect_ops4      ssp_ops;
2325         sec_oid4                ssp_hash_algs<>;
2326         sec_oid4                ssp_encr_algs<>;
2327         uint32_t                ssp_window;
2328         uint32_t                ssp_num_gss_handles;
2329 };
2330 
2331 enum state_protect_how4 {
2332         SP4_NONE      = 0,
2333         SP4_MACH_CRED = 1,
2334         SP4_SSV       = 2
2335 };
2336 
2337 union state_protect4_a switch (state_protect_how4 spa_how) {
2338         case SP4_NONE:
2339                 void;
2340         case SP4_MACH_CRED:
2341                 state_protect_ops4      spa_mach_ops;
2342         case SP4_SSV:
2343                 ssv_sp_parms4           spa_ssv_parms;
2344 };
2345 
2346 struct EXCHANGE_ID4args {
2347         client_owner4           eia_clientowner;
2348         uint32_t                eia_flags;
2349         state_protect4_a        eia_state_protect;
2350         nfs_impl_id4            eia_client_impl_id<1>;
2351 };
2352 
2353 struct ssv_prot_info4 {
2354  state_protect_ops4     spi_ops;
2355  uint32_t               spi_hash_alg;
2356  uint32_t               spi_encr_alg;
2357  uint32_t               spi_ssv_len;
2358  uint32_t               spi_window;
2359  gsshandle4_t           spi_handles<>;
2360 };
2361 
2362 union state_protect4_r switch (state_protect_how4 spr_how) {
2363  case SP4_NONE:
2364          void;
2365  case SP4_MACH_CRED:
2366          state_protect_ops4     spr_mach_ops;
2367  case SP4_SSV:
2368          ssv_prot_info4         spr_ssv_info;
2369 };
2370 
2371 struct EXCHANGE_ID4resok {
2372  clientid4        eir_clientid;
2373  sequenceid4      eir_sequenceid;
2374  uint32_t         eir_flags;
2375  state_protect4_r eir_state_protect;
2376  server_owner4    eir_server_owner;
2377  opaque           eir_server_scope<NFS4_OPAQUE_LIMIT>;
2378  nfs_impl_id4     eir_server_impl_id<1>;
2379 };
2380 
2381 union EXCHANGE_ID4res switch (nfsstat4 eir_status) {
2382  case NFS4_OK:
2383          EXCHANGE_ID4resok      eir_resok4;
2384 
2385  default:
2386          void;
2387 };
2388 
2389 struct channel_attrs4 {
2390         count4                  ca_headerpadsize;
2391         count4                  ca_maxrequestsize;
2392         count4                  ca_maxresponsesize;
2393         count4                  ca_maxresponsesize_cached;
2394         count4                  ca_maxoperations;
2395         count4                  ca_maxrequests;
2396         uint32_t                ca_rdma_ird<1>;
2397 };
2398 
2399 const CREATE_SESSION4_FLAG_PERSIST              = 0x00000001;
2400 const CREATE_SESSION4_FLAG_CONN_BACK_CHAN       = 0x00000002;
2401 const CREATE_SESSION4_FLAG_CONN_RDMA            = 0x00000004;
2402 
2403 struct CREATE_SESSION4args {
2404         clientid4               csa_clientid;
2405         sequenceid4             csa_sequence;
2406 
2407         uint32_t                csa_flags;
2408 
2409         channel_attrs4          csa_fore_chan_attrs;
2410         channel_attrs4          csa_back_chan_attrs;
2411 
2412         uint32_t                csa_cb_program;
2413         callback_sec_parms4     csa_sec_parms<>;
2414 };
2415 
2416 struct CREATE_SESSION4resok {
2417         sessionid4              csr_sessionid;
2418         sequenceid4             csr_sequence;
2419 
2420         uint32_t                csr_flags;
2421 
2422         channel_attrs4          csr_fore_chan_attrs;
2423         channel_attrs4          csr_back_chan_attrs;
2424 };
2425 
2426 union CREATE_SESSION4res switch (nfsstat4 csr_status) {
2427  case NFS4_OK:
2428          CREATE_SESSION4resok   csr_resok4;
2429  default:
2430          void;
2431 };
2432 
2433 struct DESTROY_SESSION4args {
2434         sessionid4      dsa_sessionid;
2435 };
2436 
2437 struct DESTROY_SESSION4res {
2438         nfsstat4        dsr_status;
2439 };
2440 
2441 struct FREE_STATEID4args {
2442         stateid4        fsa_stateid;
2443 };
2444 
2445 struct FREE_STATEID4res {
2446         nfsstat4        fsr_status;
2447 };
2448 
2449 
2450 typedef nfstime4 attr_notice4;
2451 
2452 struct GET_DIR_DELEGATION4args {
2453         /* CURRENT_FH: delegated directory */
2454         bool            gdda_signal_deleg_avail;
2455         bitmap4         gdda_notification_types;
2456         attr_notice4    gdda_child_attr_delay;
2457         attr_notice4    gdda_dir_attr_delay;
2458         bitmap4         gdda_child_attributes;
2459         bitmap4         gdda_dir_attributes;
2460 };
2461 struct GET_DIR_DELEGATION4resok {
2462         verifier4       gddr_cookieverf;
2463         /* Stateid for get_dir_delegation */
2464         stateid4        gddr_stateid;
2465         /* Which notifications can the server support? */
2466         bitmap4         gddr_notification;
2467         bitmap4         gddr_child_attributes;
2468         bitmap4         gddr_dir_attributes;
2469 };
2470 
2471 enum gddrnf4_status {
2472         GDD4_OK         = 0,
2473         GDD4_UNAVAIL    = 1
2474 };
2475 
2476 union GET_DIR_DELEGATION4res_non_fatal
2477  switch (gddrnf4_status gddrnf_status) {
2478          case GDD4_OK:
2479               GET_DIR_DELEGATION4resok      gddrnf_resok4;
2480          case GDD4_UNAVAIL:
2481           bool                gddrnf_will_signal_deleg_avail;
2482 };
2483 
2484 union GET_DIR_DELEGATION4res
2485  switch (nfsstat4 gddr_status) {
2486          case NFS4_OK:
2487           GET_DIR_DELEGATION4res_non_fatal   gddr_res_non_fatal4;
2488          default:
2489                  void;
2490 };
2491 
2492 struct GETDEVICEINFO4args {
2493         deviceid4       gdia_device_id;
2494         layouttype4     gdia_layout_type;
2495         count4          gdia_maxcount;
2496         bitmap4         gdia_notify_types;
2497 };
2498 
2499 struct GETDEVICEINFO4resok {
2500         device_addr4    gdir_device_addr;
2501         bitmap4         gdir_notification;
2502 };
2503 
2504 union GETDEVICEINFO4res switch (nfsstat4 gdir_status) {
2505  case NFS4_OK:
2506          GETDEVICEINFO4resok     gdir_resok4;
2507  case NFS4ERR_TOOSMALL:
2508          count4                  gdir_mincount;
2509  default:
2510          void;
2511 };
2512 
2513 struct GETDEVICELIST4args {
2514         /* CURRENT_FH: object belonging to the file system */
2515         layouttype4     gdla_layout_type;
2516 
2517         /* Number of device IDs to return */
2518         count4          gdla_maxdevices;
2519 
2520         nfs_cookie4     gdla_cookie;
2521         verifier4       gdla_cookieverf;
2522 };
2523 
2524 struct GETDEVICELIST4resok {
2525         nfs_cookie4             gdlr_cookie;
2526         verifier4               gdlr_cookieverf;
2527         deviceid4               gdlr_deviceid_list<>;
2528         bool                    gdlr_eof;
2529 };
2530 
2531 union GETDEVICELIST4res switch (nfsstat4 gdlr_status) {
2532  case NFS4_OK:
2533          GETDEVICELIST4resok     gdlr_resok4;
2534  default:
2535          void;
2536 };
2537 
2538 union newtime4 switch (bool nt_timechanged) {
2539  case TRUE:
2540          nfstime4           nt_time;
2541  case FALSE:
2542          void;
2543 };
2544 
2545 union newoffset4 switch (bool no_newoffset) {
2546  case TRUE:
2547          offset4           no_offset;
2548  case FALSE:
2549          void;
2550 };
2551 
2552 struct LAYOUTCOMMIT4args {
2553         /* CURRENT_FH: file */
2554         offset4                 loca_offset;
2555         length4                 loca_length;
2556         bool                    loca_reclaim;
2557         stateid4                loca_stateid;
2558         newoffset4              loca_last_write_offset;
2559         newtime4                loca_time_modify;
2560         layoutupdate4           loca_layoutupdate;
2561 };
2562 union newsize4 switch (bool ns_sizechanged) {
2563  case TRUE:
2564          length4         ns_size;
2565  case FALSE:
2566          void;
2567 };
2568 
2569 struct LAYOUTCOMMIT4resok {
2570         newsize4                locr_newsize;
2571 };
2572 
2573 union LAYOUTCOMMIT4res switch (nfsstat4 locr_status) {
2574  case NFS4_OK:
2575          LAYOUTCOMMIT4resok      locr_resok4;
2576  default:
2577          void;
2578 };
2579 
2580 struct LAYOUTGET4args {
2581         /* CURRENT_FH: file */
2582         bool                    loga_signal_layout_avail;
2583         layouttype4             loga_layout_type;
2584         layoutiomode4           loga_iomode;
2585         offset4                 loga_offset;
2586         length4                 loga_length;
2587         length4                 loga_minlength;
2588         stateid4                loga_stateid;
2589         count4                  loga_maxcount;
2590 };
2591 struct LAYOUTGET4resok {
2592         bool               logr_return_on_close;
2593         stateid4           logr_stateid;
2594         layout4            logr_layout<>;
2595 };
2596 
2597 union LAYOUTGET4res switch (nfsstat4 logr_status) {
2598  case NFS4_OK:
2599          LAYOUTGET4resok     logr_resok4;
2600  case NFS4ERR_LAYOUTTRYLATER:
2601          bool                logr_will_signal_layout_avail;
2602  default:
2603          void;
2604 };
2605 
2606 
2607 struct LAYOUTRETURN4args {
2608         /* CURRENT_FH: file */
2609         bool                    lora_reclaim;
2610         layouttype4             lora_layout_type;
2611         layoutiomode4           lora_iomode;
2612         layoutreturn4           lora_layoutreturn;
2613 };
2614 
2615 
2616 union layoutreturn_stateid switch (bool lrs_present) {
2617  case TRUE:
2618          stateid4                lrs_stateid;
2619  case FALSE:
2620          void;
2621 };
2622 
2623 union LAYOUTRETURN4res switch (nfsstat4 lorr_status) {
2624  case NFS4_OK:
2625          layoutreturn_stateid    lorr_stateid;
2626  default:
2627          void;
2628 };
2629 
2630 enum secinfo_style4 {
2631         SECINFO_STYLE4_CURRENT_FH       = 0,
2632         SECINFO_STYLE4_PARENT           = 1
2633 };
2634 
2635 /* CURRENT_FH: object or child directory */
2636 typedef secinfo_style4 SECINFO_NO_NAME4args;
2637 
2638 /* CURRENTFH: consumed if status is NFS4_OK */
2639 typedef SECINFO4res SECINFO_NO_NAME4res;
2640 
2641 struct SEQUENCE4args {
2642         sessionid4     sa_sessionid;
2643         sequenceid4    sa_sequenceid;
2644         slotid4        sa_slotid;
2645         slotid4        sa_highest_slotid;
2646         bool           sa_cachethis;
2647 };
2648 
2649 const SEQ4_STATUS_CB_PATH_DOWN                  = 0x00000001;
2650 const SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING      = 0x00000002;
2651 const SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED       = 0x00000004;
2652 const SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED     = 0x00000008;
2653 const SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED    = 0x00000010;
2654 const SEQ4_STATUS_ADMIN_STATE_REVOKED           = 0x00000020;
2655 const SEQ4_STATUS_RECALLABLE_STATE_REVOKED      = 0x00000040;
2656 const SEQ4_STATUS_LEASE_MOVED                   = 0x00000080;
2657 const SEQ4_STATUS_RESTART_RECLAIM_NEEDED        = 0x00000100;
2658 const SEQ4_STATUS_CB_PATH_DOWN_SESSION          = 0x00000200;
2659 const SEQ4_STATUS_BACKCHANNEL_FAULT             = 0x00000400;
2660 const SEQ4_STATUS_DEVID_CHANGED                 = 0x00000800;
2661 const SEQ4_STATUS_DEVID_DELETED                 = 0x00001000;
2662 
2663 struct SEQUENCE4resok {
2664         sessionid4      sr_sessionid;
2665         sequenceid4     sr_sequenceid;
2666         slotid4         sr_slotid;
2667         slotid4         sr_highest_slotid;
2668         slotid4         sr_target_highest_slotid;
2669         uint32_t        sr_status_flags;
2670 };
2671 
2672 union SEQUENCE4res switch (nfsstat4 sr_status) {
2673  case NFS4_OK:
2674          SEQUENCE4resok  sr_resok4;
2675  default:
2676          void;
2677 };
2678 
2679 struct ssa_digest_input4 {
2680         SEQUENCE4args sdi_seqargs;
2681 };
2682 
2683 struct SET_SSV4args {
2684         opaque          ssa_ssv<>;
2685         opaque          ssa_digest<>;
2686 };
2687 
2688 struct ssr_digest_input4 {
2689         SEQUENCE4res sdi_seqres;
2690 };
2691 
2692 struct SET_SSV4resok {
2693         opaque          ssr_digest<>;
2694 };
2695 
2696 union SET_SSV4res switch (nfsstat4 ssr_status) {
2697  case NFS4_OK:
2698          SET_SSV4resok   ssr_resok4;
2699  default:
2700          void;
2701 };
2702 
2703 struct TEST_STATEID4args {
2704         stateid4        ts_stateids<>;
2705 };
2706 
2707 struct TEST_STATEID4resok {
2708         nfsstat4        tsr_status_codes<>;
2709 };
2710 
2711 union TEST_STATEID4res switch (nfsstat4 tsr_status) {
2712  case NFS4_OK:
2713          TEST_STATEID4resok tsr_resok4;
2714  default:
2715          void;
2716 };
2717 
2718 union deleg_claim4 switch (open_claim_type4 dc_claim) {
2719 /*
2720  * No special rights to object.  Ordinary delegation
2721  * request of the specified object.  Object identified
2722  * by filehandle.
2723  */
2724  case CLAIM_FH: /* New to NFSv4.1 */
2725          /* CURRENT_FH: object being delegated */
2726           void;
2727 
2728 /*
2729  * Right to file based on a delegation granted
2730  * to a previous boot instance of the client.
2731  * File is specified by filehandle.
2732  */
2733  case CLAIM_DELEG_PREV_FH: /* New to NFSv4.1 */
2734          /* CURRENT_FH: object being delegated */
2735           void;
2736 
2737 /*
2738  * Right to the file established by an open previous
2739  * to server reboot.  File identified by filehandle.
2740  * Used during server reclaim grace period.
2741  */
2742  case CLAIM_PREVIOUS:
2743          /* CURRENT_FH: object being reclaimed */
2744           open_delegation_type4   dc_delegate_type;
2745 };
2746 
2747 struct WANT_DELEGATION4args {
2748         uint32_t        wda_want;
2749         deleg_claim4    wda_claim;
2750 };
2751 
2752 union WANT_DELEGATION4res switch (nfsstat4 wdr_status) {
2753  case NFS4_OK:
2754          open_delegation4 wdr_resok4;
2755  default:
2756          void;
2757 };
2758 
2759 struct DESTROY_CLIENTID4args {
2760         clientid4       dca_clientid;
2761 };
2762 
2763 struct DESTROY_CLIENTID4res {
2764         nfsstat4        dcr_status;
2765 };
2766 
2767 struct RECLAIM_COMPLETE4args {
2768         /*
2769          * If rca_one_fs TRUE,
2770          *
2771          *    CURRENT_FH: object in
2772          *    file system for which the
2773          *    reclaim is complete.
2774          */
2775         bool            rca_one_fs;
2776 };
2777 
2778 struct RECLAIM_COMPLETE4res {
2779         nfsstat4        rcr_status;
2780 };
2781 
2782 struct COPY4args {
2783         /* SAVED_FH: source file */
2784         /* CURRENT_FH: destination file */
2785         stateid4        ca_src_stateid;
2786         stateid4        ca_dst_stateid;
2787         offset4         ca_src_offset;
2788         offset4         ca_dst_offset;
2789         length4         ca_count;
2790         bool            ca_consecutive;
2791         bool            ca_synchronous;
2792         netloc4         ca_source_server<>;
2793 };
2794 
2795 
2796 struct copy_requirements4 {
2797         bool            cr_consecutive;
2798         bool            cr_synchronous;
2799 };
2800 
2801 struct COPY4resok {
2802         write_response4         cr_response;
2803         copy_requirements4      cr_requirements;
2804 };
2805 
2806 union COPY4res switch (nfsstat4 cr_status) {
2807  case NFS4_OK:
2808          COPY4resok              cr_resok4;
2809  case NFS4ERR_OFFLOAD_NO_REQS:
2810          copy_requirements4      cr_requirements;
2811  default:
2812          void;
2813 };
2814 
2815 struct COPY_NOTIFY4args {
2816         /* CURRENT_FH: source file */
2817         stateid4        cna_src_stateid;
2818         netloc4         cna_destination_server;
2819 };
2820 
2821 struct COPY_NOTIFY4resok {
2822         nfstime4        cnr_lease_time;
2823         stateid4        cnr_stateid;
2824         netloc4         cnr_source_server<>;
2825 };
2826 
2827 union COPY_NOTIFY4res switch (nfsstat4 cnr_status) {
2828  case NFS4_OK:
2829          COPY_NOTIFY4resok       resok4;
2830  default:
2831          void;
2832 };
2833 
2834 struct OFFLOAD_CANCEL4args {
2835         /* CURRENT_FH: file to cancel */
2836         stateid4        oca_stateid;
2837 };
2838 
2839 struct OFFLOAD_CANCEL4res {
2840         nfsstat4        ocr_status;
2841 };
2842 
2843 
2844 struct OFFLOAD_STATUS4args {
2845         /* CURRENT_FH: destination file */
2846         stateid4        osa_stateid;
2847 };
2848 
2849 struct OFFLOAD_STATUS4resok {
2850         length4         osr_count;
2851         nfsstat4        osr_complete<1>;
2852 };
2853 
2854 union OFFLOAD_STATUS4res switch (nfsstat4 osr_status) {
2855  case NFS4_OK:
2856          OFFLOAD_STATUS4resok            osr_resok4;
2857  default:
2858          void;
2859 };
2860 
2861 struct ALLOCATE4args {
2862         /* CURRENT_FH: file */
2863         stateid4        aa_stateid;
2864         offset4         aa_offset;
2865         length4         aa_length;
2866 };
2867 struct ALLOCATE4res {
2868         nfsstat4        ar_status;
2869 };
2870 
2871 struct DEALLOCATE4args {
2872         /* CURRENT_FH: file */
2873         stateid4        da_stateid;
2874         offset4         da_offset;
2875         length4         da_length;
2876 };
2877 
2878 
2879 struct DEALLOCATE4res {
2880         nfsstat4        dr_status;
2881 };
2882 enum IO_ADVISE_type4 {
2883         IO_ADVISE4_NORMAL                       = 0,
2884         IO_ADVISE4_SEQUENTIAL                   = 1,
2885         IO_ADVISE4_SEQUENTIAL_BACKWARDS         = 2,
2886         IO_ADVISE4_RANDOM                       = 3,
2887         IO_ADVISE4_WILLNEED                     = 4,
2888         IO_ADVISE4_WILLNEED_OPPORTUNISTIC       = 5,
2889         IO_ADVISE4_DONTNEED                     = 6,
2890         IO_ADVISE4_NOREUSE                      = 7,
2891         IO_ADVISE4_READ                         = 8,
2892         IO_ADVISE4_WRITE                        = 9,
2893         IO_ADVISE4_INIT_PROXIMITY               = 10
2894 };
2895 
2896 struct IO_ADVISE4args {
2897         /* CURRENT_FH: file */
2898         stateid4        iaa_stateid;
2899         offset4         iaa_offset;
2900         length4         iaa_count;
2901         bitmap4         iaa_hints;
2902 };
2903 
2904 struct IO_ADVISE4resok {
2905         bitmap4 ior_hints;
2906 };
2907 
2908 union IO_ADVISE4res switch (nfsstat4 ior_status) {
2909  case NFS4_OK:
2910          IO_ADVISE4resok resok4;
2911  default:
2912          void;
2913 };
2914 
2915 
2916 struct device_error4 {
2917         deviceid4       de_deviceid;
2918         nfsstat4        de_status;
2919         nfs_opnum4      de_opnum;
2920 };
2921 
2922 
2923 struct LAYOUTERROR4args {
2924         /* CURRENT_FH: file */
2925         offset4                 lea_offset;
2926         length4                 lea_length;
2927         stateid4                lea_stateid;
2928         device_error4           lea_errors<>;
2929 };
2930 
2931 struct LAYOUTERROR4res {
2932         nfsstat4        ler_status;
2933 };
2934 
2935 struct io_info4 {
2936         uint64_t        ii_count;
2937         uint64_t        ii_bytes;
2938 };
2939 
2940 struct LAYOUTSTATS4args {
2941         /* CURRENT_FH: file */
2942         offset4                 lsa_offset;
2943         length4                 lsa_length;
2944         stateid4                lsa_stateid;
2945         io_info4                lsa_read;
2946         io_info4                lsa_write;
2947         deviceid4               lsa_deviceid;
2948         layoutupdate4           lsa_layoutupdate;
2949 };
2950 
2951 struct LAYOUTSTATS4res {
2952         nfsstat4        lsr_status;
2953 };
2954 
2955 struct READ_PLUS4args {
2956         /* CURRENT_FH: file */
2957         stateid4        rpa_stateid;
2958         offset4         rpa_offset;
2959         count4          rpa_count;
2960 };
2961 union read_plus_content switch (data_content4 rpc_content) {
2962  case NFS4_CONTENT_DATA:
2963          data4           rpc_data;
2964  case NFS4_CONTENT_HOLE:
2965          data_info4      rpc_hole;
2966  default:
2967          void;
2968 };
2969 
2970 /*
2971  * Allow a return of an array of contents.
2972  */
2973 struct read_plus_res4 {
2974         bool                    rpr_eof;
2975         read_plus_content       rpr_contents<>;
2976 };
2977 
2978 union READ_PLUS4res switch (nfsstat4 rp_status) {
2979  case NFS4_OK:
2980          read_plus_res4  rp_resok4;
2981  default:
2982          void;
2983 };
2984 
2985 struct SEEK4args {
2986         /* CURRENT_FH: file */
2987         stateid4        sa_stateid;
2988         offset4         sa_offset;
2989         data_content4   sa_what;
2990 };
2991 struct seek_res4 {
2992         bool            sr_eof;
2993         offset4         sr_offset;
2994 };
2995 union SEEK4res switch (nfsstat4 sa_status) {
2996  case NFS4_OK:
2997          seek_res4       resok4;
2998  default:
2999          void;
3000 };
3001 
3002 struct WRITE_SAME4args {
3003         /* CURRENT_FH: file */
3004         stateid4        wsa_stateid;
3005         stable_how4     wsa_stable;
3006         app_data_block4 wsa_adb;
3007 };
3008 
3009 
3010 union WRITE_SAME4res switch (nfsstat4 wsr_status) {
3011  case NFS4_OK:
3012          write_response4         resok4;
3013  default:
3014          void;
3015 };
3016 
3017 
3018 /*
3019  * Operation arrays (the rest)
3020  */
3021 
3022 union nfs_argop4 switch (nfs_opnum4 argop) {
3023  case OP_ACCESS:         ACCESS4args opaccess;
3024  case OP_CLOSE:          CLOSE4args opclose;
3025  case OP_COMMIT:         COMMIT4args opcommit;
3026  case OP_CREATE:         CREATE4args opcreate;
3027  case OP_DELEGPURGE:     DELEGPURGE4args opdelegpurge;
3028  case OP_DELEGRETURN:    DELEGRETURN4args opdelegreturn;
3029  case OP_GETATTR:        GETATTR4args opgetattr;
3030  case OP_GETFH:          void;
3031  case OP_LINK:           LINK4args oplink;
3032  case OP_LOCK:           LOCK4args oplock;
3033  case OP_LOCKT:          LOCKT4args oplockt;
3034  case OP_LOCKU:          LOCKU4args oplocku;
3035  case OP_LOOKUP:         LOOKUP4args oplookup;
3036  case OP_LOOKUPP:        void;
3037  case OP_NVERIFY:        NVERIFY4args opnverify;
3038  case OP_OPEN:           OPEN4args opopen;
3039  case OP_OPENATTR:       OPENATTR4args opopenattr;
3040 
3041  /* Not for NFSv4.1 */
3042  case OP_OPEN_CONFIRM:   OPEN_CONFIRM4args opopen_confirm;
3043 
3044  case OP_OPEN_DOWNGRADE: OPEN_DOWNGRADE4args opopen_downgrade;
3045 
3046  case OP_PUTFH:          PUTFH4args opputfh;
3047  case OP_PUTPUBFH:       void;
3048  case OP_PUTROOTFH:      void;
3049  case OP_READ:           READ4args opread;
3050  case OP_READDIR:        READDIR4args opreaddir;
3051  case OP_READLINK:       void;
3052  case OP_REMOVE:         REMOVE4args opremove;
3053  case OP_RENAME:         RENAME4args oprename;
3054 
3055  /* Not for NFSv4.1 */
3056  case OP_RENEW:          RENEW4args oprenew;
3057 
3058  case OP_RESTOREFH:      void;
3059  case OP_SAVEFH:         void;
3060  case OP_SECINFO:        SECINFO4args opsecinfo;
3061  case OP_SETATTR:        SETATTR4args opsetattr;
3062 
3063  /* Not for NFSv4.1 */
3064  case OP_SETCLIENTID:    SETCLIENTID4args opsetclientid;
3065 
3066  /* Not for NFSv4.1 */
3067  case OP_SETCLIENTID_CONFIRM:
3068                          SETCLIENTID_CONFIRM4args
3069                                  opsetclientid_confirm;
3070 
3071  case OP_VERIFY:         VERIFY4args opverify;
3072  case OP_WRITE:          WRITE4args opwrite;
3073 
3074  /* Not for NFSv4.1 */
3075  case OP_RELEASE_LOCKOWNER:
3076                          RELEASE_LOCKOWNER4args
3077                                  oprelease_lockowner;
3078 
3079  /* Operations new to NFSv4.1 */
3080  case OP_BACKCHANNEL_CTL:
3081                          BACKCHANNEL_CTL4args opbackchannel_ctl;
3082 
3083  case OP_BIND_CONN_TO_SESSION:
3084                          BIND_CONN_TO_SESSION4args
3085                                  opbind_conn_to_session;
3086 
3087  case OP_EXCHANGE_ID:    EXCHANGE_ID4args opexchange_id;
3088 
3089  case OP_CREATE_SESSION: CREATE_SESSION4args opcreate_session;
3090 
3091  case OP_DESTROY_SESSION:
3092                          DESTROY_SESSION4args opdestroy_session;
3093 
3094  case OP_FREE_STATEID:   FREE_STATEID4args opfree_stateid;
3095 
3096  case OP_GET_DIR_DELEGATION:
3097                          GET_DIR_DELEGATION4args
3098                                  opget_dir_delegation;
3099 
3100  case OP_GETDEVICEINFO:  GETDEVICEINFO4args opgetdeviceinfo;
3101  case OP_GETDEVICELIST:  GETDEVICELIST4args opgetdevicelist;
3102  case OP_LAYOUTCOMMIT:   LAYOUTCOMMIT4args oplayoutcommit;
3103  case OP_LAYOUTGET:      LAYOUTGET4args oplayoutget;
3104  case OP_LAYOUTRETURN:   LAYOUTRETURN4args oplayoutreturn;
3105 
3106  case OP_SECINFO_NO_NAME:
3107                          SECINFO_NO_NAME4args opsecinfo_no_name;
3108 
3109  case OP_SEQUENCE:       SEQUENCE4args opsequence;
3110  case OP_SET_SSV:        SET_SSV4args opset_ssv;
3111  case OP_TEST_STATEID:   TEST_STATEID4args optest_stateid;
3112 
3113  case OP_WANT_DELEGATION:
3114                          WANT_DELEGATION4args opwant_delegation;
3115 
3116  case OP_DESTROY_CLIENTID:
3117                          DESTROY_CLIENTID4args
3118                                  opdestroy_clientid;
3119 
3120  case OP_RECLAIM_COMPLETE:
3121                          RECLAIM_COMPLETE4args
3122                                  opreclaim_complete;
3123 
3124  /* Operations new to NFSv4.2 */
3125  case OP_ALLOCATE:       ALLOCATE4args opallocate;
3126  case OP_COPY:           COPY4args opcopy;
3127  case OP_COPY_NOTIFY:    COPY_NOTIFY4args opoffload_notify;
3128  case OP_DEALLOCATE:     DEALLOCATE4args opdeallocate;
3129  case OP_IO_ADVISE:      IO_ADVISE4args opio_advise;
3130  case OP_LAYOUTERROR:    LAYOUTERROR4args oplayouterror;
3131  case OP_LAYOUTSTATS:    LAYOUTSTATS4args oplayoutstats;
3132  case OP_OFFLOAD_CANCEL: OFFLOAD_CANCEL4args opoffload_cancel;
3133  case OP_OFFLOAD_STATUS: OFFLOAD_STATUS4args opoffload_status;
3134  case OP_READ_PLUS:      READ_PLUS4args opread_plus;
3135  case OP_SEEK:           SEEK4args opseek;
3136  case OP_WRITE_SAME:     WRITE_SAME4args opwrite_same;
3137  case OP_CLONE:          CLONE4args opclone;
3138 
3139  /* Operations not new to NFSv4.1 */
3140  case OP_ILLEGAL:        void;
3141 };
3142 
3143 union nfs_resop4 switch (nfs_opnum4 resop) {
3144  case OP_ACCESS:         ACCESS4res opaccess;
3145  case OP_CLOSE:          CLOSE4res opclose;
3146  case OP_COMMIT:         COMMIT4res opcommit;
3147  case OP_CREATE:         CREATE4res opcreate;
3148  case OP_DELEGPURGE:     DELEGPURGE4res opdelegpurge;
3149  case OP_DELEGRETURN:    DELEGRETURN4res opdelegreturn;
3150  case OP_GETATTR:        GETATTR4res opgetattr;
3151  case OP_GETFH:          GETFH4res opgetfh;
3152  case OP_LINK:           LINK4res oplink;
3153  case OP_LOCK:           LOCK4res oplock;
3154  case OP_LOCKT:          LOCKT4res oplockt;
3155  case OP_LOCKU:          LOCKU4res oplocku;
3156  case OP_LOOKUP:         LOOKUP4res oplookup;
3157  case OP_LOOKUPP:        LOOKUPP4res oplookupp;
3158  case OP_NVERIFY:        NVERIFY4res opnverify;
3159  case OP_OPEN:           OPEN4res opopen;
3160  case OP_OPENATTR:       OPENATTR4res opopenattr;
3161  /* Not for NFSv4.1 */
3162  case OP_OPEN_CONFIRM:   OPEN_CONFIRM4res opopen_confirm;
3163 
3164  case OP_OPEN_DOWNGRADE: OPEN_DOWNGRADE4res opopen_downgrade;
3165 
3166  case OP_PUTFH:          PUTFH4res opputfh;
3167  case OP_PUTPUBFH:       PUTPUBFH4res opputpubfh;
3168  case OP_PUTROOTFH:      PUTROOTFH4res opputrootfh;
3169  case OP_READ:           READ4res opread;
3170  case OP_READDIR:        READDIR4res opreaddir;
3171  case OP_READLINK:       READLINK4res opreadlink;
3172  case OP_REMOVE:         REMOVE4res opremove;
3173  case OP_RENAME:         RENAME4res oprename;
3174  /* Not for NFSv4.1 */
3175  case OP_RENEW:          RENEW4res oprenew;
3176  case OP_RESTOREFH:      RESTOREFH4res oprestorefh;
3177  case OP_SAVEFH:         SAVEFH4res opsavefh;
3178  case OP_SECINFO:        SECINFO4res opsecinfo;
3179  case OP_SETATTR:        SETATTR4res opsetattr;
3180  /* Not for NFSv4.1 */
3181  case OP_SETCLIENTID:    SETCLIENTID4res opsetclientid;
3182 
3183  /* Not for NFSv4.1 */
3184  case OP_SETCLIENTID_CONFIRM:
3185                          SETCLIENTID_CONFIRM4res
3186                                  opsetclientid_confirm;
3187  case OP_VERIFY:         VERIFY4res opverify;
3188  case OP_WRITE:          WRITE4res opwrite;
3189 
3190  /* Not for NFSv4.1 */
3191  case OP_RELEASE_LOCKOWNER:
3192                          RELEASE_LOCKOWNER4res
3193                                  oprelease_lockowner;
3194 
3195  /* Operations new to NFSv4.1 */
3196  case OP_BACKCHANNEL_CTL:
3197                          BACKCHANNEL_CTL4res opbackchannel_ctl;
3198 
3199  case OP_BIND_CONN_TO_SESSION:
3200                          BIND_CONN_TO_SESSION4res
3201                                  opbind_conn_to_session;
3202 
3203  case OP_EXCHANGE_ID:    EXCHANGE_ID4res opexchange_id;
3204 
3205  case OP_CREATE_SESSION: CREATE_SESSION4res opcreate_session;
3206 
3207  case OP_DESTROY_SESSION:
3208                          DESTROY_SESSION4res opdestroy_session;
3209 
3210  case OP_FREE_STATEID:   FREE_STATEID4res opfree_stateid;
3211 
3212  case OP_GET_DIR_DELEGATION:
3213                          GET_DIR_DELEGATION4res
3214                                  opget_dir_delegation;
3215 
3216  case OP_GETDEVICEINFO:  GETDEVICEINFO4res opgetdeviceinfo;
3217  case OP_GETDEVICELIST:  GETDEVICELIST4res opgetdevicelist;
3218  case OP_LAYOUTCOMMIT:   LAYOUTCOMMIT4res oplayoutcommit;
3219  case OP_LAYOUTGET:      LAYOUTGET4res oplayoutget;
3220  case OP_LAYOUTRETURN:   LAYOUTRETURN4res oplayoutreturn;
3221 
3222  case OP_SECINFO_NO_NAME:
3223                          SECINFO_NO_NAME4res opsecinfo_no_name;
3224 
3225  case OP_SEQUENCE:       SEQUENCE4res opsequence;
3226  case OP_SET_SSV:        SET_SSV4res opset_ssv;
3227  case OP_TEST_STATEID:   TEST_STATEID4res optest_stateid;
3228 
3229  case OP_WANT_DELEGATION:
3230                          WANT_DELEGATION4res opwant_delegation;
3231 
3232  case OP_DESTROY_CLIENTID:
3233                          DESTROY_CLIENTID4res
3234                                  opdestroy_clientid;
3235 
3236  case OP_RECLAIM_COMPLETE:
3237                          RECLAIM_COMPLETE4res
3238                                  opreclaim_complete;
3239 
3240  /* Operations new to NFSv4.2 */
3241  case OP_ALLOCATE:       ALLOCATE4res opallocate;
3242  case OP_COPY:           COPY4res opcopy;
3243  case OP_COPY_NOTIFY:    COPY_NOTIFY4res opcopy_notify;
3244  case OP_DEALLOCATE:     DEALLOCATE4res opdeallocate;
3245  case OP_IO_ADVISE:      IO_ADVISE4res opio_advise;
3246  case OP_LAYOUTERROR:    LAYOUTERROR4res oplayouterror;
3247  case OP_LAYOUTSTATS:    LAYOUTSTATS4res oplayoutstats;
3248  case OP_OFFLOAD_CANCEL: OFFLOAD_CANCEL4res opoffload_cancel;
3249  case OP_OFFLOAD_STATUS: OFFLOAD_STATUS4res opoffload_status;
3250  case OP_READ_PLUS:      READ_PLUS4res opread_plus;
3251  case OP_SEEK:           SEEK4res opseek;
3252  case OP_WRITE_SAME:     WRITE_SAME4res opwrite_same;
3253  case OP_CLONE:          CLONE4res opclone;
3254 
3255  /* Operations not new to NFSv4.1 */
3256  case OP_ILLEGAL:        ILLEGAL4res opillegal;
3257 };
3258 
3259 struct COMPOUND4args {
3260         utf8str_cs       tag;
3261         uint32_t         minorversion;
3262         nfs_argop4       argarray<>;
3263 };
3264 
3265 struct COMPOUND4res {
3266         nfsstat4         status;
3267         utf8str_cs       tag;
3268         nfs_resop4       resarray<>;
3269 };
3270 
3271 
3272 /*
3273  * Remote file service routines
3274  */
3275 program NFS4_PROGRAM {
3276         version NFS_V4 {
3277                 void
3278                          NFSPROC4_NULL(void) = 0;
3279 
3280                 COMPOUND4res
3281                          NFSPROC4_COMPOUND(COMPOUND4args) = 1;
3282 
3283         } = 4;
3284 } = 100003;
3285 
3286 /*
3287  * NFS4 callback procedure definitions and program
3288  */
3289 struct CB_GETATTR4args {
3290         nfs_fh4 fh;
3291         bitmap4 attr_request;
3292 };
3293 
3294 struct CB_GETATTR4resok {
3295         fattr4  obj_attributes;
3296 };
3297 
3298 union CB_GETATTR4res switch (nfsstat4 status) {
3299  case NFS4_OK:
3300          CB_GETATTR4resok       resok4;
3301  default:
3302          void;
3303 };
3304 
3305 struct CB_RECALL4args {
3306         stateid4        stateid;
3307         bool            truncate;
3308         nfs_fh4         fh;
3309 };
3310 
3311 struct CB_RECALL4res {
3312         nfsstat4        status;
3313 };
3314 
3315 /*
3316  * CB_ILLEGAL: Response for illegal operation numbers
3317  */
3318 struct CB_ILLEGAL4res {
3319         nfsstat4        status;
3320 };
3321 
3322 /*
3323  * NFSv4.1 callback arguments and results
3324  */
3325 
3326 enum layoutrecall_type4 {
3327         LAYOUTRECALL4_FILE = LAYOUT4_RET_REC_FILE,
3328         LAYOUTRECALL4_FSID = LAYOUT4_RET_REC_FSID,
3329         LAYOUTRECALL4_ALL  = LAYOUT4_RET_REC_ALL
3330 };
3331 
3332 struct layoutrecall_file4 {
3333         nfs_fh4         lor_fh;
3334         offset4         lor_offset;
3335         length4         lor_length;
3336         stateid4        lor_stateid;
3337 };
3338 
3339 union layoutrecall4 switch (layoutrecall_type4 lor_recalltype) {
3340  case LAYOUTRECALL4_FILE:
3341          layoutrecall_file4 lor_layout;
3342  case LAYOUTRECALL4_FSID:
3343          fsid4              lor_fsid;
3344  case LAYOUTRECALL4_ALL:
3345          void;
3346 };
3347 
3348 struct CB_LAYOUTRECALL4args {
3349         layouttype4             clora_type;
3350         layoutiomode4           clora_iomode;
3351         bool                    clora_changed;
3352         layoutrecall4           clora_recall;
3353 };
3354 struct CB_LAYOUTRECALL4res {
3355         nfsstat4        clorr_status;
3356 };
3357 
3358 /*
3359  * Directory notification types
3360  */
3361 enum notify_type4 {
3362         NOTIFY4_CHANGE_CHILD_ATTRS     = 0,
3363         NOTIFY4_CHANGE_DIR_ATTRS       = 1,
3364         NOTIFY4_REMOVE_ENTRY           = 2,
3365         NOTIFY4_ADD_ENTRY              = 3,
3366         NOTIFY4_RENAME_ENTRY           = 4,
3367         NOTIFY4_CHANGE_COOKIE_VERIFIER = 5
3368 };
3369 
3370 /* Changed entry information */
3371 struct notify_entry4 {
3372         component4      ne_file;
3373         fattr4          ne_attrs;
3374 };
3375 
3376 /* Previous entry information */
3377 struct prev_entry4 {
3378         notify_entry4   pe_prev_entry;
3379         /* What READDIR returned for this entry */
3380         nfs_cookie4     pe_prev_entry_cookie;
3381 };
3382 
3383 struct notify_remove4 {
3384         notify_entry4   nrm_old_entry;
3385         nfs_cookie4     nrm_old_entry_cookie;
3386 };
3387 
3388 struct notify_add4 {
3389         /*
3390          * During a rename, contains
3391          * the object that was deleted.
3392          */
3393         notify_remove4      nad_old_entry<1>;
3394         notify_entry4       nad_new_entry;
3395         /* What READDIR would have returned for this entry */
3396         nfs_cookie4         nad_new_entry_cookie<1>;
3397         prev_entry4         nad_prev_entry<1>;
3398         bool                nad_last_entry;
3399 };
3400 
3401 struct notify_attr4 {
3402         notify_entry4   na_changed_entry;
3403 };
3404 
3405 struct notify_rename4 {
3406         notify_remove4  nrn_old_entry;
3407         notify_add4     nrn_new_entry;
3408 };
3409 
3410 struct notify_verifier4 {
3411         verifier4       nv_old_cookieverf;
3412         verifier4       nv_new_cookieverf;
3413 };
3414 
3415 /*
3416  * Objects of type notify_<>4 and
3417  * notify_device_<>4 are encoded in this.
3418  */
3419 typedef opaque notifylist4<>;
3420 
3421 struct notify4 {
3422         /* Composed from notify_type4 or notify_deviceid_type4 */
3423         bitmap4         notify_mask;
3424         notifylist4     notify_vals;
3425 };
3426 
3427 struct CB_NOTIFY4args {
3428         stateid4    cna_stateid;
3429         nfs_fh4     cna_fh;
3430         notify4     cna_changes<>;
3431 };
3432 
3433 struct CB_NOTIFY4res {
3434         nfsstat4    cnr_status;
3435 };
3436 
3437 struct CB_PUSH_DELEG4args {
3438         nfs_fh4          cpda_fh;
3439         open_delegation4 cpda_delegation;
3440 
3441 };
3442 
3443 struct CB_PUSH_DELEG4res {
3444         nfsstat4 cpdr_status;
3445 };
3446 
3447 const RCA4_TYPE_MASK_RDATA_DLG          = 0;
3448 const RCA4_TYPE_MASK_WDATA_DLG          = 1;
3449 const RCA4_TYPE_MASK_DIR_DLG            = 2;
3450 const RCA4_TYPE_MASK_FILE_LAYOUT        = 3;
3451 const RCA4_TYPE_MASK_BLK_LAYOUT         = 4;
3452 const RCA4_TYPE_MASK_OBJ_LAYOUT_MIN     = 8;
3453 const RCA4_TYPE_MASK_OBJ_LAYOUT_MAX     = 9;
3454 const RCA4_TYPE_MASK_OTHER_LAYOUT_MIN   = 12;
3455 const RCA4_TYPE_MASK_OTHER_LAYOUT_MAX   = 15;
3456 
3457 struct CB_RECALL_ANY4args      {
3458        uint32_t         craa_objects_to_keep;
3459        bitmap4          craa_type_mask;
3460 };
3461 
3462 struct CB_RECALL_ANY4res {
3463         nfsstat4        crar_status;
3464 };
3465 
3466 typedef CB_RECALL_ANY4args CB_RECALLABLE_OBJ_AVAIL4args;
3467 
3468 struct CB_RECALLABLE_OBJ_AVAIL4res {
3469         nfsstat4        croa_status;
3470 };
3471 
3472 struct CB_RECALL_SLOT4args {
3473         slotid4       rsa_target_highest_slotid;
3474 };
3475 
3476 struct CB_RECALL_SLOT4res {
3477         nfsstat4   rsr_status;
3478 };
3479 
3480 struct referring_call4 {
3481         sequenceid4     rc_sequenceid;
3482         slotid4         rc_slotid;
3483 };
3484 
3485 struct referring_call_list4 {
3486         sessionid4      rcl_sessionid;
3487         referring_call4 rcl_referring_calls<>;
3488 };
3489 
3490 struct CB_SEQUENCE4args {
3491         sessionid4           csa_sessionid;
3492         sequenceid4          csa_sequenceid;
3493         slotid4              csa_slotid;
3494         slotid4              csa_highest_slotid;
3495         bool                 csa_cachethis;
3496         referring_call_list4 csa_referring_call_lists<>;
3497 };
3498 
3499 struct CB_SEQUENCE4resok {
3500         sessionid4         csr_sessionid;
3501         sequenceid4        csr_sequenceid;
3502         slotid4            csr_slotid;
3503         slotid4            csr_highest_slotid;
3504         slotid4            csr_target_highest_slotid;
3505 };
3506 
3507 union CB_SEQUENCE4res switch (nfsstat4 csr_status) {
3508  case NFS4_OK:
3509          CB_SEQUENCE4resok   csr_resok4;
3510  default:
3511          void;
3512 };
3513 
3514 struct CB_WANTS_CANCELLED4args {
3515         bool cwca_contended_wants_cancelled;
3516         bool cwca_resourced_wants_cancelled;
3517 };
3518 
3519 struct CB_WANTS_CANCELLED4res {
3520         nfsstat4        cwcr_status;
3521 };
3522 
3523 struct CB_NOTIFY_LOCK4args {
3524     nfs_fh4     cnla_fh;
3525     lock_owner4 cnla_lock_owner;
3526 };
3527 
3528 struct CB_NOTIFY_LOCK4res {
3529         nfsstat4        cnlr_status;
3530 };
3531 
3532 /*
3533  * Device notification types
3534  */
3535 enum notify_deviceid_type4 {
3536         NOTIFY_DEVICEID4_CHANGE = 1,
3537         NOTIFY_DEVICEID4_DELETE = 2
3538 };
3539 
3540 /* For NOTIFY4_DEVICEID4_DELETE */
3541 struct notify_deviceid_delete4 {
3542         layouttype4     ndd_layouttype;
3543         deviceid4       ndd_deviceid;
3544 };
3545 
3546 /* For NOTIFY4_DEVICEID4_CHANGE */
3547 struct notify_deviceid_change4 {
3548         layouttype4     ndc_layouttype;
3549         deviceid4       ndc_deviceid;
3550         bool            ndc_immediate;
3551 };
3552 
3553 struct CB_NOTIFY_DEVICEID4args {
3554         notify4 cnda_changes<>;
3555 };
3556 
3557 struct CB_NOTIFY_DEVICEID4res {
3558         nfsstat4        cndr_status;
3559 };
3560 
3561 union offload_info4 switch (nfsstat4 coa_status) {
3562  case NFS4_OK:
3563          write_response4 coa_resok4;
3564  default:
3565          length4         coa_bytes_copied;
3566 };
3567 struct CB_OFFLOAD4args {
3568         nfs_fh4         coa_fh;
3569         stateid4        coa_stateid;
3570         offload_info4   coa_offload_info;
3571 };
3572 struct CB_OFFLOAD4res {
3573         nfsstat4        cor_status;
3574 };
3575 /*
3576  * Various definitions for CB_COMPOUND
3577  */
3578 %
3579 enum nfs_cb_opnum4 {
3580         OP_CB_GETATTR                   = 3,
3581         OP_CB_RECALL                    = 4,
3582 %/* Callback operations new to NFSv4.1 */
3583         OP_CB_LAYOUTRECALL              = 5,
3584         OP_CB_NOTIFY                    = 6,
3585         OP_CB_PUSH_DELEG                = 7,
3586         OP_CB_RECALL_ANY                = 8,
3587         OP_CB_RECALLABLE_OBJ_AVAIL      = 9,
3588         OP_CB_RECALL_SLOT               = 10,
3589         OP_CB_SEQUENCE                  = 11,
3590         OP_CB_WANTS_CANCELLED           = 12,
3591         OP_CB_NOTIFY_LOCK               = 13,
3592         OP_CB_NOTIFY_DEVICEID           = 14,
3593 %/* Callback operations new to NFSv4.2 */
3594         OP_CB_OFFLOAD                   = 15,
3595 
3596         OP_CB_ILLEGAL                   = 10044
3597 };
3598 
3599 union nfs_cb_argop4 switch (nfs_cb_opnum4 argop) {
3600  case OP_CB_GETATTR:
3601       CB_GETATTR4args           opcbgetattr;
3602 
3603  /* New NFSv4.1 operations */
3604  case OP_CB_RECALL:
3605       CB_RECALL4args            opcbrecall;
3606  case OP_CB_LAYOUTRECALL:
3607       CB_LAYOUTRECALL4args      opcblayoutrecall;
3608  case OP_CB_NOTIFY:
3609       CB_NOTIFY4args            opcbnotify;
3610  case OP_CB_PUSH_DELEG:
3611       CB_PUSH_DELEG4args        opcbpush_deleg;
3612  case OP_CB_RECALL_ANY:
3613       CB_RECALL_ANY4args        opcbrecall_any;
3614  case OP_CB_RECALLABLE_OBJ_AVAIL:
3615       CB_RECALLABLE_OBJ_AVAIL4args opcbrecallable_obj_avail;
3616  case OP_CB_RECALL_SLOT:
3617       CB_RECALL_SLOT4args       opcbrecall_slot;
3618  case OP_CB_SEQUENCE:
3619       CB_SEQUENCE4args          opcbsequence;
3620  case OP_CB_WANTS_CANCELLED:
3621       CB_WANTS_CANCELLED4args   opcbwants_cancelled;
3622  case OP_CB_NOTIFY_LOCK:
3623       CB_NOTIFY_LOCK4args       opcbnotify_lock;
3624  case OP_CB_NOTIFY_DEVICEID:
3625       CB_NOTIFY_DEVICEID4args   opcbnotify_deviceid;
3626 
3627  /* New NFSv4.2 operations */
3628  case OP_CB_OFFLOAD:
3629       CB_OFFLOAD4args           opcboffload;
3630 
3631  case OP_CB_ILLEGAL:            void;
3632 };
3633 
3634 union nfs_cb_resop4 switch (nfs_cb_opnum4 resop) {
3635  case OP_CB_GETATTR:    CB_GETATTR4res  opcbgetattr;
3636  case OP_CB_RECALL:     CB_RECALL4res   opcbrecall;
3637 
3638  /* New NFSv4.1 operations */
3639  case OP_CB_LAYOUTRECALL:
3640                         CB_LAYOUTRECALL4res
3641                                         opcblayoutrecall;
3642 
3643  case OP_CB_NOTIFY:     CB_NOTIFY4res   opcbnotify;
3644 
3645  case OP_CB_PUSH_DELEG: CB_PUSH_DELEG4res
3646                                         opcbpush_deleg;
3647 
3648  case OP_CB_RECALL_ANY: CB_RECALL_ANY4res
3649                                         opcbrecall_any;
3650 
3651  case OP_CB_RECALLABLE_OBJ_AVAIL:
3652                         CB_RECALLABLE_OBJ_AVAIL4res
3653                                 opcbrecallable_obj_avail;
3654 
3655  case OP_CB_RECALL_SLOT:
3656                         CB_RECALL_SLOT4res
3657                                         opcbrecall_slot;
3658 
3659  case OP_CB_SEQUENCE:   CB_SEQUENCE4res opcbsequence;
3660 
3661  case OP_CB_WANTS_CANCELLED:
3662                         CB_WANTS_CANCELLED4res
3663                                 opcbwants_cancelled;
3664 
3665  case OP_CB_NOTIFY_LOCK:
3666                         CB_NOTIFY_LOCK4res
3667                                         opcbnotify_lock;
3668 
3669  case OP_CB_NOTIFY_DEVICEID:
3670                         CB_NOTIFY_DEVICEID4res
3671                                         opcbnotify_deviceid;
3672 
3673  /* New NFSv4.2 operations */
3674  case OP_CB_OFFLOAD:    CB_OFFLOAD4res  opcboffload;
3675 
3676  /* Not new operation */
3677  case OP_CB_ILLEGAL:    CB_ILLEGAL4res  opcbillegal;
3678 };
3679 
3680 
3681 struct CB_COMPOUND4args {
3682         utf8str_cs      tag;
3683         uint32_t        minorversion;
3684         uint32_t        callback_ident;
3685         nfs_cb_argop4   argarray<>;
3686 };
3687 
3688 struct CB_COMPOUND4res {
3689         nfsstat4 status;
3690         utf8str_cs      tag;
3691         nfs_cb_resop4   resarray<>;
3692 };
3693 
3694 
3695 
3696 /*
3697  * Program number is in the transient range, since the client
3698  * will assign the exact transient program number and provide
3699  * that to the server via the CREATE_SESSION or
3700  * BACKCHANNEL_CTL operations.
3701  */
3702 program NFS4_CALLBACK {
3703         version NFS_CB {
3704                 void
3705                         CB_NULL(void) = 0;
3706                 CB_COMPOUND4res
3707                         CB_COMPOUND(CB_COMPOUND4args) = 1;
3708         } = 1;
3709 } = 0x40000000;
3710