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