1 /* 2 * Copyright (c) 2010 IETF Trust and the persons identified 3 * as the document authors. All rights reserved. 4 * 5 * The document authors are identified in RFC 3530 and 6 * RFC 5661. 7 * 8 * Redistribution and use in source and binary forms, with 9 * or without modification, are permitted provided that the 10 * following conditions are met: 11 * 12 * - Redistributions of source code must retain the above 13 * copyright notice, this list of conditions and the 14 * following disclaimer. 15 * 16 * - Redistributions in binary form must reproduce the above 17 * copyright notice, this list of conditions and the 18 * following disclaimer in the documentation and/or other 19 * materials provided with the distribution. 20 * 21 * - Neither the name of Internet Society, IETF or IETF 22 * Trust, nor the names of specific contributors, may be 23 * used to endorse or promote products derived from this 24 * software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 27 * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 28 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 31 * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 34 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 39 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 40 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 */ 42 43 pragma header nfs4; 44 45 /* 46 * Basic typedefs for RFC 1832 data type definitions 47 */ 48 typedef int int32_t; 49 typedef unsigned int uint32_t; 50 typedef hyper int64_t; 51 typedef unsigned hyper uint64_t; 52 53 const NFS4_VERIFIER_SIZE = 8; 54 const NFS4_FHSIZE = 128; 55 56 enum nfsstat4 { 57 NFS4_OK = 0, /* everything is okay */ 58 NFS4ERR_PERM = 1, /* caller not privileged */ 59 NFS4ERR_NOENT = 2, /* no such file/directory */ 60 NFS4ERR_IO = 5, /* hard I/O error */ 61 NFS4ERR_NXIO = 6, /* no such device */ 62 NFS4ERR_ACCESS = 13, /* access denied */ 63 NFS4ERR_EXIST = 17, /* file already exists */ 64 NFS4ERR_XDEV = 18, /* different filesystems */ 65 66 /* 67 * Please do not allocate value 19; it was used in NFSv3 68 * and we do not want a value in NFSv3 to have a different 69 * meaning in NFSv4.x. 70 */ 71 72 NFS4ERR_NOTDIR = 20, /* should be a directory */ 73 NFS4ERR_ISDIR = 21, /* should not be directory */ 74 NFS4ERR_INVAL = 22, /* invalid argument */ 75 NFS4ERR_FBIG = 27, /* file exceeds server max */ 76 NFS4ERR_NOSPC = 28, /* no space on filesystem */ 77 NFS4ERR_ROFS = 30, /* read-only filesystem */ 78 NFS4ERR_MLINK = 31, /* too many hard links */ 79 NFS4ERR_NAMETOOLONG = 63, /* name exceeds server max */ 80 NFS4ERR_NOTEMPTY = 66, /* directory not empty */ 81 NFS4ERR_DQUOT = 69, /* hard quota limit reached*/ 82 NFS4ERR_STALE = 70, /* file no longer exists */ 83 NFS4ERR_BADHANDLE = 10001,/* Illegal filehandle */ 84 NFS4ERR_BAD_COOKIE = 10003,/* READDIR cookie is stale */ 85 NFS4ERR_NOTSUPP = 10004,/* operation not supported */ 86 NFS4ERR_TOOSMALL = 10005,/* response limit exceeded */ 87 NFS4ERR_SERVERFAULT = 10006,/* undefined server error */ 88 NFS4ERR_BADTYPE = 10007,/* type invalid for CREATE */ 89 NFS4ERR_DELAY = 10008,/* file "busy" - retry */ 90 NFS4ERR_SAME = 10009,/* nverify says attrs same */ 91 NFS4ERR_DENIED = 10010,/* lock unavailable */ 92 NFS4ERR_EXPIRED = 10011,/* lock lease expired */ 93 NFS4ERR_LOCKED = 10012,/* I/O failed due to lock */ 94 NFS4ERR_GRACE = 10013,/* in grace period */ 95 NFS4ERR_FHEXPIRED = 10014,/* filehandle expired */ 96 NFS4ERR_SHARE_DENIED = 10015,/* share reserve denied */ 97 NFS4ERR_WRONGSEC = 10016,/* wrong security flavor */ 98 NFS4ERR_CLID_INUSE = 10017,/* clientid in use */ 99 100 /* NFS4ERR_RESOURCE is not a valid error in NFSv4.1 */ 101 NFS4ERR_RESOURCE = 10018,/* resource exhaustion */ 102 103 NFS4ERR_MOVED = 10019,/* filesystem relocated */ 104 NFS4ERR_NOFILEHANDLE = 10020,/* current FH is not set */ 105 NFS4ERR_MINOR_VERS_MISMATCH= 10021,/* minor vers not supp */ 106 NFS4ERR_STALE_CLIENTID = 10022,/* server has rebooted */ 107 NFS4ERR_STALE_STATEID = 10023,/* server has rebooted */ 108 NFS4ERR_OLD_STATEID = 10024,/* state is out of sync */ 109 NFS4ERR_BAD_STATEID = 10025,/* incorrect stateid */ 110 NFS4ERR_BAD_SEQID = 10026,/* request is out of seq. */ 111 NFS4ERR_NOT_SAME = 10027,/* verify - attrs not same */ 112 NFS4ERR_LOCK_RANGE = 10028,/* overlapping lock range */ 113 NFS4ERR_SYMLINK = 10029,/* should be file/directory*/ 114 NFS4ERR_RESTOREFH = 10030,/* no saved filehandle */ 115 NFS4ERR_LEASE_MOVED = 10031,/* some filesystem moved */ 116 NFS4ERR_ATTRNOTSUPP = 10032,/* recommended attr not sup*/ 117 NFS4ERR_NO_GRACE = 10033,/* reclaim outside of grace*/ 118 NFS4ERR_RECLAIM_BAD = 10034,/* reclaim error at server */ 119 NFS4ERR_RECLAIM_CONFLICT= 10035,/* conflict on reclaim */ 120 NFS4ERR_BADXDR = 10036,/* XDR decode failed */ 121 NFS4ERR_LOCKS_HELD = 10037,/* file locks held at CLOSE*/ 122 NFS4ERR_OPENMODE = 10038,/* conflict in OPEN and I/O*/ 123 NFS4ERR_BADOWNER = 10039,/* owner translation bad */ 124 NFS4ERR_BADCHAR = 10040,/* utf-8 char not supported*/ 125 NFS4ERR_BADNAME = 10041,/* name not supported */ 126 NFS4ERR_BAD_RANGE = 10042,/* lock range not supported*/ 127 NFS4ERR_LOCK_NOTSUPP = 10043,/* no atomic up/downgrade */ 128 NFS4ERR_OP_ILLEGAL = 10044,/* undefined operation */ 129 NFS4ERR_DEADLOCK = 10045,/* file locking deadlock */ 130 NFS4ERR_FILE_OPEN = 10046,/* open file blocks op. */ 131 NFS4ERR_ADMIN_REVOKED = 10047,/* lockowner state revoked */ 132 NFS4ERR_CB_PATH_DOWN = 10048,/* callback path down */ 133 134 /* NFSv4.1 errors start here. */ 135 136 NFS4ERR_BADIOMODE = 10049, 137 NFS4ERR_BADLAYOUT = 10050, 138 NFS4ERR_BAD_SESSION_DIGEST = 10051, 139 NFS4ERR_BADSESSION = 10052, 140 NFS4ERR_BADSLOT = 10053, 141 NFS4ERR_COMPLETE_ALREADY = 10054, 142 NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055, 143 NFS4ERR_DELEG_ALREADY_WANTED = 10056, 144 NFS4ERR_BACK_CHAN_BUSY = 10057,/*backchan reqs outstanding*/ 145 NFS4ERR_LAYOUTTRYLATER = 10058, 146 NFS4ERR_LAYOUTUNAVAILABLE = 10059, 147 NFS4ERR_NOMATCHING_LAYOUT = 10060, 148 NFS4ERR_RECALLCONFLICT = 10061, 149 NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062, 150 NFS4ERR_SEQ_MISORDERED = 10063,/* unexpected seq.ID in req*/ 151 NFS4ERR_SEQUENCE_POS = 10064,/* [CB_]SEQ. op not 1st op */ 152 NFS4ERR_REQ_TOO_BIG = 10065,/* request too big */ 153 NFS4ERR_REP_TOO_BIG = 10066,/* reply too big */ 154 NFS4ERR_REP_TOO_BIG_TO_CACHE =10067,/* rep. not all cached*/ 155 NFS4ERR_RETRY_UNCACHED_REP =10068,/* retry & rep. uncached*/ 156 NFS4ERR_UNSAFE_COMPOUND =10069,/* retry/recovery too hard */ 157 NFS4ERR_TOO_MANY_OPS = 10070,/*too many ops in [CB_]COMP*/ 158 NFS4ERR_OP_NOT_IN_SESSION =10071,/* op needs [CB_]SEQ. op */ 159 NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp. */ 160 /* Error 10073 is unused. */ 161 NFS4ERR_CLIENTID_BUSY = 10074,/* clientid has state */ 162 NFS4ERR_PNFS_IO_HOLE = 10075,/* IO to _SPARSE file hole */ 163 NFS4ERR_SEQ_FALSE_RETRY= 10076,/* Retry != original req. */ 164 NFS4ERR_BAD_HIGH_SLOT = 10077,/* req has bad highest_slot*/ 165 NFS4ERR_DEADSESSION = 10078,/*new req sent to dead sess*/ 166 NFS4ERR_ENCR_ALG_UNSUPP= 10079,/* encr alg. not supp. */ 167 NFS4ERR_PNFS_NO_LAYOUT = 10080,/* I/O without a layout */ 168 NFS4ERR_NOT_ONLY_OP = 10081,/* addl ops not allowed */ 169 NFS4ERR_WRONG_CRED = 10082,/* op done by wrong cred */ 170 NFS4ERR_WRONG_TYPE = 10083,/* op on wrong type object */ 171 NFS4ERR_DIRDELEG_UNAVAIL=10084,/* delegation not avail. */ 172 NFS4ERR_REJECT_DELEG = 10085,/* cb rejected delegation */ 173 NFS4ERR_RETURNCONFLICT = 10086,/* layout get before return*/ 174 NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */ 175 NFS4ERR_PARTNER_NOTSUPP = 10088, 176 NFS4ERR_PARTNER_NO_AUTH = 10089, 177 NFS4ERR_UNION_NOTSUPP = 10090, 178 NFS4ERR_OFFLOAD_DENIED = 10091, 179 NFS4ERR_WRONG_LFS = 10092, 180 NFS4ERR_BADLABEL = 10093, 181 NFS4ERR_OFFLOAD_NO_REQS = 10094, 182 NFS4ERR_NOXATTR = 10095, 183 NFS4ERR_XATTR2BIG = 10096 184 }; 185 186 /* 187 * Basic data types 188 */ 189 typedef opaque attrlist4<>; 190 typedef uint32_t bitmap4<>; 191 typedef opaque verifier4[NFS4_VERIFIER_SIZE]; 192 typedef uint64_t nfs_cookie4; 193 typedef opaque nfs_fh4<NFS4_FHSIZE>; 194 195 typedef opaque utf8string<>; 196 typedef utf8string utf8str_cis; 197 typedef utf8string utf8str_cs; 198 typedef utf8string utf8str_mixed; 199 200 typedef utf8str_cs component4; 201 typedef utf8str_cs linktext4; 202 typedef component4 pathname4<>; 203 204 /* 205 * Timeval 206 */ 207 struct nfstime4 { 208 int64_t seconds; 209 uint32_t nseconds; 210 }; 211 212 /* 213 * File attribute container 214 */ 215 struct fattr4 { 216 bitmap4 attrmask; 217 attrlist4 attr_vals; 218 }; 219 220 /* 221 * Stateid 222 */ 223 struct stateid4 { 224 uint32_t seqid; 225 opaque other[12]; 226 }; 227 228 /* 229 * The following content was extracted from draft-ietf-nfsv4-delstid 230 */ 231 232 typedef bool fattr4_offline; 233 234 235 const FATTR4_OFFLINE = 83; 236 237 238 struct open_arguments4 { 239 bitmap4 oa_share_access; 240 bitmap4 oa_share_deny; 241 bitmap4 oa_share_access_want; 242 bitmap4 oa_open_claim; 243 bitmap4 oa_create_mode; 244 }; 245 246 247 enum open_args_share_access4 { 248 OPEN_ARGS_SHARE_ACCESS_READ = 1, 249 OPEN_ARGS_SHARE_ACCESS_WRITE = 2, 250 OPEN_ARGS_SHARE_ACCESS_BOTH = 3 251 }; 252 253 254 enum open_args_share_deny4 { 255 OPEN_ARGS_SHARE_DENY_NONE = 0, 256 OPEN_ARGS_SHARE_DENY_READ = 1, 257 OPEN_ARGS_SHARE_DENY_WRITE = 2, 258 OPEN_ARGS_SHARE_DENY_BOTH = 3 259 }; 260 261 262 enum open_args_share_access_want4 { 263 OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG = 3, 264 OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG = 4, 265 OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL = 5, 266 OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL 267 = 17, 268 OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED 269 = 18, 270 OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 20, 271 OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 21 272 }; 273 274 275 enum open_args_open_claim4 { 276 OPEN_ARGS_OPEN_CLAIM_NULL = 0, 277 OPEN_ARGS_OPEN_CLAIM_PREVIOUS = 1, 278 OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR = 2, 279 OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV = 3, 280 OPEN_ARGS_OPEN_CLAIM_FH = 4, 281 OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH = 5, 282 OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH = 6 283 }; 284 285 286 enum open_args_createmode4 { 287 OPEN_ARGS_CREATEMODE_UNCHECKED4 = 0, 288 OPEN_ARGS_CREATE_MODE_GUARDED = 1, 289 OPEN_ARGS_CREATEMODE_EXCLUSIVE4 = 2, 290 OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 = 3 291 }; 292 293 294 typedef open_arguments4 fattr4_open_arguments; 295 pragma public fattr4_open_arguments; 296 297 298 %/* 299 % * Determine what OPEN supports. 300 % */ 301 const FATTR4_OPEN_ARGUMENTS = 86; 302 303 304 305 306 const OPEN4_RESULT_NO_OPEN_STATEID = 0x00000010; 307 308 309 /* 310 * attributes for the delegation times being 311 * cached and served by the "client" 312 */ 313 typedef nfstime4 fattr4_time_deleg_access; 314 typedef nfstime4 fattr4_time_deleg_modify; 315 pragma public fattr4_time_deleg_access; 316 pragma public fattr4_time_deleg_modify; 317 318 319 %/* 320 % * New RECOMMENDED Attribute for 321 % * delegation caching of times 322 % */ 323 const FATTR4_TIME_DELEG_ACCESS = 84; 324 const FATTR4_TIME_DELEG_MODIFY = 85; 325 326 327 328 /* new flags for share_access field of OPEN4args */ 329 const OPEN4_SHARE_ACCESS_WANT_DELEG_MASK = 0xFF00; 330 const OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE = 0x0000; 331 const OPEN4_SHARE_ACCESS_WANT_READ_DELEG = 0x0100; 332 const OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG = 0x0200; 333 const OPEN4_SHARE_ACCESS_WANT_ANY_DELEG = 0x0300; 334 const OPEN4_SHARE_ACCESS_WANT_NO_DELEG = 0x0400; 335 const OPEN4_SHARE_ACCESS_WANT_CANCEL = 0x0500; 336 337 const OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL = 0x10000; 338 const OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED = 0x20000; 339 const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000; 340 const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 0x200000; 341 342 enum open_delegation_type4 { 343 OPEN_DELEGATE_NONE = 0, 344 OPEN_DELEGATE_READ = 1, 345 OPEN_DELEGATE_WRITE = 2, 346 OPEN_DELEGATE_NONE_EXT = 3, /* new to v4.1 */ 347 OPEN_DELEGATE_READ_ATTRS_DELEG = 4, 348 OPEN_DELEGATE_WRITE_ATTRS_DELEG = 5 349 }; 350 351 352 /* 353 * The following content was extracted from draft-ietf-nfsv4-posix-acls 354 */ 355 356 enum aclmodel4 { 357 ACL_MODEL_NFS4 = 1, 358 ACL_MODEL_POSIX_DRAFT = 2, 359 ACL_MODEL_NONE = 3 360 }; 361 pragma public aclmodel4; 362 363 enum aclscope4 { 364 ACL_SCOPE_FILE_OBJECT = 1, 365 ACL_SCOPE_FILE_SYSTEM = 2, 366 ACL_SCOPE_SERVER = 3 367 }; 368 pragma public aclscope4; 369 370 enum posixacetag4 { 371 POSIXACE4_TAG_USER_OBJ = 1, 372 POSIXACE4_TAG_USER = 2, 373 POSIXACE4_TAG_GROUP_OBJ = 3, 374 POSIXACE4_TAG_GROUP = 4, 375 POSIXACE4_TAG_MASK = 5, 376 POSIXACE4_TAG_OTHER = 6 377 }; 378 pragma public posixacetag4; 379 380 typedef uint32_t posixaceperm4; 381 pragma public posixaceperm4; 382 383 /* Bit definitions for posixaceperm4. */ 384 const POSIXACE4_PERM_EXECUTE = 0x00000001; 385 const POSIXACE4_PERM_WRITE = 0x00000002; 386 const POSIXACE4_PERM_READ = 0x00000004; 387 388 struct posixace4 { 389 posixacetag4 tag; 390 posixaceperm4 perm; 391 utf8str_mixed who; 392 }; 393 394 typedef aclmodel4 fattr4_acl_trueform; 395 typedef aclscope4 fattr4_acl_trueform_scope; 396 typedef posixace4 fattr4_posix_default_acl<>; 397 typedef posixace4 fattr4_posix_access_acl<>; 398 399 %/* 400 % * New for POSIX ACL extension 401 % */ 402 const FATTR4_ACL_TRUEFORM = 89; 403 const FATTR4_ACL_TRUEFORM_SCOPE = 90; 404 const FATTR4_POSIX_DEFAULT_ACL = 91; 405 const FATTR4_POSIX_ACCESS_ACL = 92; 406 407 /* 408 * Directory notification types. 409 */ 410 enum notify_type4 { 411 NOTIFY4_CHANGE_CHILD_ATTRS = 0, 412 NOTIFY4_CHANGE_DIR_ATTRS = 1, 413 NOTIFY4_REMOVE_ENTRY = 2, 414 NOTIFY4_ADD_ENTRY = 3, 415 NOTIFY4_RENAME_ENTRY = 4, 416 NOTIFY4_CHANGE_COOKIE_VERIFIER = 5, 417 /* Proposed in RFC8881bis */ 418 NOTIFY4_GFLAG_EXTEND = 6, 419 NOTIFY4_AUFLAG_VALID = 7, 420 NOTIFY4_AUFLAG_USER = 8, 421 NOTIFY4_AUFLAG_GROUP = 9, 422 NOTIFY4_AUFLAG_OTHER = 10, 423 NOTIFY4_CHANGE_AUTH = 11, 424 NOTIFY4_CFLAG_ORDER = 12, 425 NOTIFY4_AUFLAG_GANOW = 13, 426 NOTIFY4_AUFLAG_GALATER = 14, 427 NOTIFY4_CHANGE_GA = 15, 428 NOTIFY4_CHANGE_AMASK = 16 429 }; 430 431 /* Changed entry information. */ 432 struct notify_entry4 { 433 component4 ne_file; 434 fattr4 ne_attrs; 435 }; 436 437 /* Previous entry information */ 438 struct prev_entry4 { 439 notify_entry4 pe_prev_entry; 440 /* what READDIR returned for this entry */ 441 nfs_cookie4 pe_prev_entry_cookie; 442 }; 443 444 struct notify_remove4 { 445 notify_entry4 nrm_old_entry; 446 nfs_cookie4 nrm_old_entry_cookie; 447 }; 448 pragma public notify_remove4; 449 450 struct notify_add4 { 451 /* 452 * Information on object 453 * possibly renamed over. 454 */ 455 notify_remove4 nad_old_entry<1>; 456 notify_entry4 nad_new_entry; 457 /* what READDIR would have returned for this entry */ 458 nfs_cookie4 nad_new_entry_cookie<1>; 459 prev_entry4 nad_prev_entry<1>; 460 bool nad_last_entry; 461 }; 462 pragma public notify_add4; 463 464 struct notify_attr4 { 465 notify_entry4 na_changed_entry; 466 }; 467 pragma public notify_attr4; 468 469 struct notify_rename4 { 470 notify_remove4 nrn_old_entry; 471 notify_add4 nrn_new_entry; 472 }; 473 pragma public notify_rename4; 474 475 struct notify_verifier4 { 476 verifier4 nv_old_cookieverf; 477 verifier4 nv_new_cookieverf; 478 }; 479 480 /* 481 * Objects of type notify_<>4 and 482 * notify_device_<>4 are encoded in this. 483 */ 484 typedef opaque notifylist4<>; 485 486 struct notify4 { 487 /* composed from notify_type4 or notify_deviceid_type4 */ 488 bitmap4 notify_mask; 489 notifylist4 notify_vals; 490 }; 491 492 struct CB_NOTIFY4args { 493 stateid4 cna_stateid; 494 nfs_fh4 cna_fh; 495 notify4 cna_changes<>; 496 }; 497 pragma public CB_NOTIFY4args; 498 499 struct CB_NOTIFY4res { 500 nfsstat4 cnr_status; 501 }; 502