1 /*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 4. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * $FreeBSD$ 33 */ 34 35 #ifndef _NFS_NFSPROTO_H_ 36 #define _NFS_NFSPROTO_H_ 37 38 /* 39 * nfs definitions as per the Version 2, 3 and 4 specs 40 */ 41 42 /* 43 * Constants as defined in the NFS Version 2, 3 and 4 specs. 44 * "NFS: Network File System Protocol Specification" RFC1094 45 * and in the "NFS: Network File System Version 3 Protocol 46 * Specification" 47 */ 48 49 #define NFS_PORT 2049 50 #define NFS_PROG 100003 51 #define NFS_CALLBCKPROG 0x40000000 /* V4 only */ 52 #define NFS_VER2 2 53 #define NFS_VER3 3 54 #define NFS_VER4 4 55 #define NFS_V2MAXDATA 8192 56 #define NFS_MAXDGRAMDATA 16384 57 #define NFS_MAXPATHLEN 1024 58 #define NFS_MAXNAMLEN 255 59 #define NFS_MAXPKTHDR 404 60 #define NFS_MAXPACKET (NFS_SRVMAXIO + 2048) 61 #define NFS_MINPACKET 20 62 #define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ 63 #define NFSV4_MINORVERSION 0 /* V4 Minor version */ 64 #define NFSV41_MINORVERSION 1 /* V4 Minor version */ 65 #define NFSV4_CBVERS 1 /* V4 CB Version */ 66 #define NFSV41_CBVERS 4 /* V4.1 CB Version */ 67 #define NFSV4_SMALLSTR 50 /* Strings small enough for stack */ 68 69 /* 70 * This value isn't a fixed value in the RFCs. 71 * It is the maximum data size supported by NFSv3 or NFSv4 over TCP for 72 * the server. It should be set to the I/O size preferred by ZFS or 73 * MAXBSIZE, whichever is greater. 74 * ZFS currently prefers 128K. 75 * It used to be called NFS_MAXDATA, but has been renamed to clarify that 76 * it refers to server side only and doesn't conflict with the NFS_MAXDATA 77 * defined in rpcsvc/nfs_prot.h for userland. 78 */ 79 #define NFS_SRVMAXIO (128 * 1024) 80 81 /* Stat numbers for rpc returns (version 2, 3 and 4) */ 82 /* 83 * These numbers are hard-wired in the RFCs, so they can't be changed. 84 * The code currently assumes that the ones < 10000 are the same as 85 * sys/errno.h and that sys/errno.h will never go as high as 10000. 86 * If the value in sys/errno.h of any entry listed below is changed, 87 * the NFS code must be modified to do the mapping between them. 88 * (You can ignore NFSERR_WFLUSH, since it is never actually used.) 89 */ 90 #define NFSERR_OK 0 91 #define NFSERR_PERM 1 92 #define NFSERR_NOENT 2 93 #define NFSERR_IO 5 94 #define NFSERR_NXIO 6 95 #define NFSERR_ACCES 13 96 #define NFSERR_EXIST 17 97 #define NFSERR_XDEV 18 /* Version 3, 4 only */ 98 #define NFSERR_NODEV 19 99 #define NFSERR_NOTDIR 20 100 #define NFSERR_ISDIR 21 101 #define NFSERR_INVAL 22 /* Version 3, 4 only */ 102 #define NFSERR_FBIG 27 103 #define NFSERR_NOSPC 28 104 #define NFSERR_ROFS 30 105 #define NFSERR_MLINK 31 /* Version 3, 4 only */ 106 #define NFSERR_NAMETOL 63 107 #define NFSERR_NOTEMPTY 66 108 #define NFSERR_DQUOT 69 109 #define NFSERR_STALE 70 110 #define NFSERR_REMOTE 71 /* Version 3 only */ 111 #define NFSERR_WFLUSH 99 /* Version 2 only */ 112 #define NFSERR_BADHANDLE 10001 /* These are Version 3, 4 only */ 113 #define NFSERR_NOT_SYNC 10002 /* Version 3 Only */ 114 #define NFSERR_BAD_COOKIE 10003 115 #define NFSERR_NOTSUPP 10004 116 #define NFSERR_TOOSMALL 10005 117 #define NFSERR_SERVERFAULT 10006 118 #define NFSERR_BADTYPE 10007 119 #define NFSERR_DELAY 10008 /* Called NFSERR_JUKEBOX for V3 */ 120 #define NFSERR_SAME 10009 /* These are Version 4 only */ 121 #define NFSERR_DENIED 10010 122 #define NFSERR_EXPIRED 10011 123 #define NFSERR_LOCKED 10012 124 #define NFSERR_GRACE 10013 125 #define NFSERR_FHEXPIRED 10014 126 #define NFSERR_SHAREDENIED 10015 127 #define NFSERR_WRONGSEC 10016 128 #define NFSERR_CLIDINUSE 10017 129 #define NFSERR_RESOURCE 10018 130 #define NFSERR_MOVED 10019 131 #define NFSERR_NOFILEHANDLE 10020 132 #define NFSERR_MINORVERMISMATCH 10021 133 #define NFSERR_STALECLIENTID 10022 134 #define NFSERR_STALESTATEID 10023 135 #define NFSERR_OLDSTATEID 10024 136 #define NFSERR_BADSTATEID 10025 137 #define NFSERR_BADSEQID 10026 138 #define NFSERR_NOTSAME 10027 139 #define NFSERR_LOCKRANGE 10028 140 #define NFSERR_SYMLINK 10029 141 #define NFSERR_RESTOREFH 10030 142 #define NFSERR_LEASEMOVED 10031 143 #define NFSERR_ATTRNOTSUPP 10032 144 #define NFSERR_NOGRACE 10033 145 #define NFSERR_RECLAIMBAD 10034 146 #define NFSERR_RECLAIMCONFLICT 10035 147 #define NFSERR_BADXDR 10036 148 #define NFSERR_LOCKSHELD 10037 149 #define NFSERR_OPENMODE 10038 150 #define NFSERR_BADOWNER 10039 151 #define NFSERR_BADCHAR 10040 152 #define NFSERR_BADNAME 10041 153 #define NFSERR_BADRANGE 10042 154 #define NFSERR_LOCKNOTSUPP 10043 155 #define NFSERR_OPILLEGAL 10044 156 #define NFSERR_DEADLOCK 10045 157 #define NFSERR_FILEOPEN 10046 158 #define NFSERR_ADMINREVOKED 10047 159 #define NFSERR_CBPATHDOWN 10048 160 161 /* NFSv4.1 specific errors. */ 162 #define NFSERR_BADIOMODE 10049 163 #define NFSERR_BADLAYOUT 10050 164 #define NFSERR_BADSESSIONDIGEST 10051 165 #define NFSERR_BADSESSION 10052 166 #define NFSERR_BADSLOT 10053 167 #define NFSERR_COMPLETEALREADY 10054 168 #define NFSERR_NOTBNDTOSESS 10055 169 #define NFSERR_DELEGALREADYWANT 10056 170 #define NFSERR_BACKCHANBUSY 10057 171 #define NFSERR_LAYOUTTRYLATER 10058 172 #define NFSERR_LAYOUTUNAVAIL 10059 173 #define NFSERR_NOMATCHLAYOUT 10060 174 #define NFSERR_RECALLCONFLICT 10061 175 #define NFSERR_UNKNLAYOUTTYPE 10062 176 #define NFSERR_SEQMISORDERED 10063 177 #define NFSERR_SEQUENCEPOS 10064 178 #define NFSERR_REQTOOBIG 10065 179 #define NFSERR_REPTOOBIG 10066 180 #define NFSERR_REPTOOBIGTOCACHE 10067 181 #define NFSERR_RETRYUNCACHEDREP 10068 182 #define NFSERR_UNSAFECOMPOUND 10069 183 #define NFSERR_TOOMANYOPS 10070 184 #define NFSERR_OPNOTINSESS 10071 185 #define NFSERR_HASHALGUNSUPP 10072 186 #define NFSERR_CLIENTIDBUSY 10074 187 #define NFSERR_PNFSIOHOLE 10075 188 #define NFSERR_SEQFALSERETRY 10076 189 #define NFSERR_BADHIGHSLOT 10077 190 #define NFSERR_DEADSESSION 10078 191 #define NFSERR_ENCRALGUNSUPP 10079 192 #define NFSERR_PNFSNOLAYOUT 10080 193 #define NFSERR_NOTONLYOP 10081 194 #define NFSERR_WRONGCRED 10082 195 #define NFSERR_WRONGTYPE 10083 196 #define NFSERR_DIRDELEGUNAVAIL 10084 197 #define NFSERR_REJECTDELEG 10085 198 #define NFSERR_RETURNCONFLICT 10086 199 #define NFSERR_DELEGREVOKED 10087 200 201 #define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */ 202 #define NFSERR_DONTREPLY 30003 /* Don't process request */ 203 #define NFSERR_RETVOID 30004 /* Return void, not error */ 204 #define NFSERR_REPLYFROMCACHE 30005 /* Reply from recent request cache */ 205 #define NFSERR_STALEDONTRECOVER 30006 /* Don't initiate recovery */ 206 207 #define NFSERR_RPCERR 0x40000000 /* Mark an RPC layer error */ 208 #define NFSERR_AUTHERR 0x80000000 /* Mark an authentication error */ 209 210 #define NFSERR_RPCMISMATCH (NFSERR_RPCERR | RPC_MISMATCH) 211 #define NFSERR_PROGUNAVAIL (NFSERR_RPCERR | RPC_PROGUNAVAIL) 212 #define NFSERR_PROGMISMATCH (NFSERR_RPCERR | RPC_PROGMISMATCH) 213 #define NFSERR_PROGNOTV4 (NFSERR_RPCERR | 0xffff) 214 #define NFSERR_PROCUNAVAIL (NFSERR_RPCERR | RPC_PROCUNAVAIL) 215 #define NFSERR_GARBAGE (NFSERR_RPCERR | RPC_GARBAGE) 216 217 /* Sizes in bytes of various nfs rpc components */ 218 #define NFSX_UNSIGNED 4 219 #define NFSX_HYPER (2 * NFSX_UNSIGNED) 220 221 /* specific to NFS Version 2 */ 222 #define NFSX_V2FH 32 223 #define NFSX_V2FATTR 68 224 #define NFSX_V2SATTR 32 225 #define NFSX_V2COOKIE 4 226 #define NFSX_V2STATFS 20 227 228 /* specific to NFS Version 3 */ 229 #define NFSX_V3FHMAX 64 /* max. allowed by protocol */ 230 #define NFSX_V3FATTR 84 231 #define NFSX_V3SATTR 60 /* max. all fields filled in */ 232 #define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr)) 233 #define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED) 234 #define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED) 235 #define NFSX_V3STATFS 52 236 #define NFSX_V3FSINFO 48 237 #define NFSX_V3PATHCONF 24 238 239 /* specific to NFS Version 4 */ 240 #define NFSX_V4FHMAX 128 241 #define NFSX_V4FSID (2 * NFSX_HYPER) 242 #define NFSX_V4SPECDATA (2 * NFSX_UNSIGNED) 243 #define NFSX_V4TIME (NFSX_HYPER + NFSX_UNSIGNED) 244 #define NFSX_V4SETTIME (NFSX_UNSIGNED + NFSX_V4TIME) 245 #define NFSX_V4SESSIONID 16 246 #define NFSX_V4DEVICEID 16 247 248 /* sizes common to multiple NFS versions */ 249 #define NFSX_FHMAX (NFSX_V4FHMAX) 250 #define NFSX_MYFH (sizeof (fhandle_t)) /* size this server uses */ 251 #define NFSX_VERF 8 252 #define NFSX_STATEIDOTHER 12 253 #define NFSX_STATEID (NFSX_UNSIGNED + NFSX_STATEIDOTHER) 254 #define NFSX_GSSH 12 255 256 /* variants for multiple versions */ 257 #define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS) 258 259 /* nfs rpc procedure numbers (before version mapping) */ 260 #define NFSPROC_NULL 0 261 #define NFSPROC_GETATTR 1 262 #define NFSPROC_SETATTR 2 263 #define NFSPROC_LOOKUP 3 264 #define NFSPROC_ACCESS 4 265 #define NFSPROC_READLINK 5 266 #define NFSPROC_READ 6 267 #define NFSPROC_WRITE 7 268 #define NFSPROC_CREATE 8 269 #define NFSPROC_MKDIR 9 270 #define NFSPROC_SYMLINK 10 271 #define NFSPROC_MKNOD 11 272 #define NFSPROC_REMOVE 12 273 #define NFSPROC_RMDIR 13 274 #define NFSPROC_RENAME 14 275 #define NFSPROC_LINK 15 276 #define NFSPROC_READDIR 16 277 #define NFSPROC_READDIRPLUS 17 278 #define NFSPROC_FSSTAT 18 279 #define NFSPROC_FSINFO 19 280 #define NFSPROC_PATHCONF 20 281 #define NFSPROC_COMMIT 21 282 283 /* 284 * The lower numbers -> 21 are used by NFSv2 and v3. These define higher 285 * numbers used by NFSv4. 286 * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is 287 * one greater than the last number. 288 */ 289 #ifndef NFS_V3NPROCS 290 #define NFS_V3NPROCS 22 291 292 #define NFSPROC_LOOKUPP 22 293 #define NFSPROC_SETCLIENTID 23 294 #define NFSPROC_SETCLIENTIDCFRM 24 295 #define NFSPROC_LOCK 25 296 #define NFSPROC_LOCKU 26 297 #define NFSPROC_OPEN 27 298 #define NFSPROC_CLOSE 28 299 #define NFSPROC_OPENCONFIRM 29 300 #define NFSPROC_LOCKT 30 301 #define NFSPROC_OPENDOWNGRADE 31 302 #define NFSPROC_RENEW 32 303 #define NFSPROC_PUTROOTFH 33 304 #define NFSPROC_RELEASELCKOWN 34 305 #define NFSPROC_DELEGRETURN 35 306 #define NFSPROC_RETDELEGREMOVE 36 307 #define NFSPROC_RETDELEGRENAME1 37 308 #define NFSPROC_RETDELEGRENAME2 38 309 #define NFSPROC_GETACL 39 310 #define NFSPROC_SETACL 40 311 312 /* 313 * Must be defined as one higher than the last Proc# above. 314 */ 315 #define NFSV4_NPROCS 41 316 317 /* Additional procedures for NFSv4.1. */ 318 #define NFSPROC_EXCHANGEID 41 319 #define NFSPROC_CREATESESSION 42 320 #define NFSPROC_DESTROYSESSION 43 321 #define NFSPROC_DESTROYCLIENT 44 322 #define NFSPROC_FREESTATEID 45 323 #define NFSPROC_LAYOUTGET 46 324 #define NFSPROC_GETDEVICEINFO 47 325 #define NFSPROC_LAYOUTCOMMIT 48 326 #define NFSPROC_LAYOUTRETURN 49 327 #define NFSPROC_RECLAIMCOMPL 50 328 #define NFSPROC_WRITEDS 51 329 #define NFSPROC_READDS 52 330 #define NFSPROC_COMMITDS 53 331 332 /* 333 * Must be defined as one higher than the last NFSv4.1 Proc# above. 334 */ 335 #define NFSV41_NPROCS 54 336 337 #endif /* NFS_V3NPROCS */ 338 339 /* 340 * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code. 341 */ 342 #ifndef NFS_NPROCS 343 #define NFS_NPROCS NFSV4_NPROCS 344 #endif 345 346 /* 347 * NFSPROC_NOOP is a fake op# that can't be the same as any V2/3/4 Procedure 348 * or Operation#. Since the NFS V4 Op #s go higher, use NFSV42_NOPS, which 349 * is one greater than the highest Op#. 350 */ 351 #define NFSPROC_NOOP NFSV42_NOPS 352 353 /* Actual Version 2 procedure numbers */ 354 #define NFSV2PROC_NULL 0 355 #define NFSV2PROC_GETATTR 1 356 #define NFSV2PROC_SETATTR 2 357 #define NFSV2PROC_NOOP 3 358 #define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */ 359 #define NFSV2PROC_LOOKUP 4 360 #define NFSV2PROC_READLINK 5 361 #define NFSV2PROC_READ 6 362 #define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */ 363 #define NFSV2PROC_WRITE 8 364 #define NFSV2PROC_CREATE 9 365 #define NFSV2PROC_REMOVE 10 366 #define NFSV2PROC_RENAME 11 367 #define NFSV2PROC_LINK 12 368 #define NFSV2PROC_SYMLINK 13 369 #define NFSV2PROC_MKDIR 14 370 #define NFSV2PROC_RMDIR 15 371 #define NFSV2PROC_READDIR 16 372 #define NFSV2PROC_STATFS 17 373 374 /* 375 * V4 Procedure numbers 376 */ 377 #define NFSV4PROC_COMPOUND 1 378 #define NFSV4PROC_CBNULL 0 379 #define NFSV4PROC_CBCOMPOUND 1 380 381 /* 382 * Constants used by the Version 3 and 4 protocols for various RPCs 383 */ 384 #define NFSV3SATTRTIME_DONTCHANGE 0 385 #define NFSV3SATTRTIME_TOSERVER 1 386 #define NFSV3SATTRTIME_TOCLIENT 2 387 388 #define NFSV4SATTRTIME_TOSERVER 0 389 #define NFSV4SATTRTIME_TOCLIENT 1 390 391 #define NFSV4LOCKT_READ 1 392 #define NFSV4LOCKT_WRITE 2 393 #define NFSV4LOCKT_READW 3 394 #define NFSV4LOCKT_WRITEW 4 395 #define NFSV4LOCKT_RELEASE 5 396 397 #define NFSV4OPEN_NOCREATE 0 398 #define NFSV4OPEN_CREATE 1 399 #define NFSV4OPEN_CLAIMNULL 0 400 #define NFSV4OPEN_CLAIMPREVIOUS 1 401 #define NFSV4OPEN_CLAIMDELEGATECUR 2 402 #define NFSV4OPEN_CLAIMDELEGATEPREV 3 403 #define NFSV4OPEN_CLAIMFH 4 404 #define NFSV4OPEN_CLAIMDELEGATECURFH 5 405 #define NFSV4OPEN_CLAIMDELEGATEPREVFH 6 406 #define NFSV4OPEN_DELEGATENONE 0 407 #define NFSV4OPEN_DELEGATEREAD 1 408 #define NFSV4OPEN_DELEGATEWRITE 2 409 #define NFSV4OPEN_DELEGATENONEEXT 3 410 #define NFSV4OPEN_LIMITSIZE 1 411 #define NFSV4OPEN_LIMITBLOCKS 2 412 413 /* 414 * Nfs V4 ACE stuff 415 */ 416 #define NFSV4ACE_ALLOWEDTYPE 0x00000000 417 #define NFSV4ACE_DENIEDTYPE 0x00000001 418 #define NFSV4ACE_AUDITTYPE 0x00000002 419 #define NFSV4ACE_ALARMTYPE 0x00000003 420 421 #define NFSV4ACE_SUPALLOWED 0x00000001 422 #define NFSV4ACE_SUPDENIED 0x00000002 423 #define NFSV4ACE_SUPAUDIT 0x00000004 424 #define NFSV4ACE_SUPALARM 0x00000008 425 426 #define NFSV4ACE_SUPTYPES (NFSV4ACE_SUPALLOWED | NFSV4ACE_SUPDENIED) 427 428 #define NFSV4ACE_FILEINHERIT 0x00000001 429 #define NFSV4ACE_DIRECTORYINHERIT 0x00000002 430 #define NFSV4ACE_NOPROPAGATEINHERIT 0x00000004 431 #define NFSV4ACE_INHERITONLY 0x00000008 432 #define NFSV4ACE_SUCCESSFULACCESS 0x00000010 433 #define NFSV4ACE_FAILEDACCESS 0x00000020 434 #define NFSV4ACE_IDENTIFIERGROUP 0x00000040 435 436 #define NFSV4ACE_READDATA 0x00000001 437 #define NFSV4ACE_LISTDIRECTORY 0x00000001 438 #define NFSV4ACE_WRITEDATA 0x00000002 439 #define NFSV4ACE_ADDFILE 0x00000002 440 #define NFSV4ACE_APPENDDATA 0x00000004 441 #define NFSV4ACE_ADDSUBDIRECTORY 0x00000004 442 #define NFSV4ACE_READNAMEDATTR 0x00000008 443 #define NFSV4ACE_WRITENAMEDATTR 0x00000010 444 #define NFSV4ACE_EXECUTE 0x00000020 445 #define NFSV4ACE_SEARCH 0x00000020 446 #define NFSV4ACE_DELETECHILD 0x00000040 447 #define NFSV4ACE_READATTRIBUTES 0x00000080 448 #define NFSV4ACE_WRITEATTRIBUTES 0x00000100 449 #define NFSV4ACE_DELETE 0x00010000 450 #define NFSV4ACE_READACL 0x00020000 451 #define NFSV4ACE_WRITEACL 0x00040000 452 #define NFSV4ACE_WRITEOWNER 0x00080000 453 #define NFSV4ACE_SYNCHRONIZE 0x00100000 454 455 /* 456 * Here are the mappings between mode bits and acl mask bits for 457 * directories and other files. 458 * (Named attributes have not been included, since named attributes are 459 * not yet supported.) 460 * The mailing list seems to indicate that NFSV4ACE_EXECUTE refers to 461 * searching a directory, although I can't find a statement of that in 462 * the RFC. 463 */ 464 #define NFSV4ACE_ALLFILESMASK (NFSV4ACE_READATTRIBUTES | NFSV4ACE_READACL) 465 #define NFSV4ACE_OWNERMASK (NFSV4ACE_WRITEATTRIBUTES | NFSV4ACE_WRITEACL) 466 #define NFSV4ACE_DIRREADMASK NFSV4ACE_LISTDIRECTORY 467 #define NFSV4ACE_DIREXECUTEMASK NFSV4ACE_EXECUTE 468 #define NFSV4ACE_DIRWRITEMASK (NFSV4ACE_ADDFILE | \ 469 NFSV4ACE_ADDSUBDIRECTORY | NFSV4ACE_DELETECHILD) 470 #define NFSV4ACE_READMASK NFSV4ACE_READDATA 471 #define NFSV4ACE_WRITEMASK (NFSV4ACE_WRITEDATA | NFSV4ACE_APPENDDATA) 472 #define NFSV4ACE_EXECUTEMASK NFSV4ACE_EXECUTE 473 #define NFSV4ACE_ALLFILEBITS (NFSV4ACE_READMASK | NFSV4ACE_WRITEMASK | \ 474 NFSV4ACE_EXECUTEMASK | NFSV4ACE_SYNCHRONIZE) 475 #define NFSV4ACE_ALLDIRBITS (NFSV4ACE_DIRREADMASK | \ 476 NFSV4ACE_DIRWRITEMASK | NFSV4ACE_DIREXECUTEMASK) 477 #define NFSV4ACE_AUDITMASK 0x0 478 479 /* 480 * These GENERIC masks are not used and are no longer believed to be useful. 481 */ 482 #define NFSV4ACE_GENERICREAD 0x00120081 483 #define NFSV4ACE_GENERICWRITE 0x00160106 484 #define NFSV4ACE_GENERICEXECUTE 0x001200a0 485 486 #define NFSSTATEID_PUTALLZERO 0 487 #define NFSSTATEID_PUTALLONE 1 488 #define NFSSTATEID_PUTSTATEID 2 489 #define NFSSTATEID_PUTSEQIDZERO 3 490 491 /* 492 * Bits for share access and deny. 493 */ 494 #define NFSV4OPEN_ACCESSREAD 0x00000001 495 #define NFSV4OPEN_ACCESSWRITE 0x00000002 496 #define NFSV4OPEN_ACCESSBOTH 0x00000003 497 #define NFSV4OPEN_WANTDELEGMASK 0x0000ff00 498 #define NFSV4OPEN_WANTREADDELEG 0x00000100 499 #define NFSV4OPEN_WANTWRITEDELEG 0x00000200 500 #define NFSV4OPEN_WANTANYDELEG 0x00000300 501 #define NFSV4OPEN_WANTNODELEG 0x00000400 502 #define NFSV4OPEN_WANTCANCEL 0x00000500 503 #define NFSV4OPEN_WANTSIGNALDELEG 0x00010000 504 #define NFSV4OPEN_WANTPUSHDELEG 0x00020000 505 506 #define NFSV4OPEN_DENYNONE 0x00000000 507 #define NFSV4OPEN_DENYREAD 0x00000001 508 #define NFSV4OPEN_DENYWRITE 0x00000002 509 #define NFSV4OPEN_DENYBOTH 0x00000003 510 511 /* 512 * Delegate_none_ext reply values. 513 */ 514 #define NFSV4OPEN_NOTWANTED 0 515 #define NFSV4OPEN_CONTENTION 1 516 #define NFSV4OPEN_RESOURCE 2 517 #define NFSV4OPEN_NOTSUPPFTYPE 3 518 #define NFSV4OPEN_NOTSUPPWRITEFTYPE 4 519 #define NFSV4OPEN_NOTSUPPUPGRADE 5 520 #define NFSV4OPEN_NOTSUPPDOWNGRADE 6 521 #define NFSV4OPEN_CANCELLED 7 522 #define NFSV4OPEN_ISDIR 8 523 524 /* 525 * Open result flags 526 * (The first four are in the spec. The rest are used internally.) 527 */ 528 #define NFSV4OPEN_RESULTCONFIRM 0x00000002 529 #define NFSV4OPEN_LOCKTYPEPOSIX 0x00000004 530 #define NFSV4OPEN_PRESERVEUNLINKED 0x00000008 531 #define NFSV4OPEN_MAYNOTIFYLOCK 0x00000020 532 #define NFSV4OPEN_RFLAGS \ 533 (NFSV4OPEN_RESULTCONFIRM | NFSV4OPEN_LOCKTYPEPOSIX | \ 534 NFSV4OPEN_PRESERVEUNLINKED | NFSV4OPEN_MAYNOTIFYLOCK) 535 #define NFSV4OPEN_RECALL 0x00010000 536 #define NFSV4OPEN_READDELEGATE 0x00020000 537 #define NFSV4OPEN_WRITEDELEGATE 0x00040000 538 #define NFSV4OPEN_WDRESOURCE 0x00080000 539 #define NFSV4OPEN_WDCONTENTION 0x00100000 540 #define NFSV4OPEN_WDNOTWANTED 0x00200000 541 542 /* 543 * NFS V4 File Handle types 544 */ 545 #define NFSV4FHTYPE_PERSISTENT 0x0 546 #define NFSV4FHTYPE_NOEXPIREWITHOPEN 0x1 547 #define NFSV4FHTYPE_VOLATILEANY 0x2 548 #define NFSV4FHTYPE_VOLATILEMIGRATE 0x4 549 #define NFSV4FHTYPE_VOLATILERENAME 0x8 550 551 /* 552 * Maximum size of V4 opaque strings. 553 */ 554 #define NFSV4_OPAQUELIMIT 1024 555 556 /* 557 * These are the same for V3 and V4. 558 */ 559 #define NFSACCESS_READ 0x01 560 #define NFSACCESS_LOOKUP 0x02 561 #define NFSACCESS_MODIFY 0x04 562 #define NFSACCESS_EXTEND 0x08 563 #define NFSACCESS_DELETE 0x10 564 #define NFSACCESS_EXECUTE 0x20 565 566 #define NFSWRITE_UNSTABLE 0 567 #define NFSWRITE_DATASYNC 1 568 #define NFSWRITE_FILESYNC 2 569 570 #define NFSCREATE_UNCHECKED 0 571 #define NFSCREATE_GUARDED 1 572 #define NFSCREATE_EXCLUSIVE 2 573 #define NFSCREATE_EXCLUSIVE41 3 574 575 #define NFSV3FSINFO_LINK 0x01 576 #define NFSV3FSINFO_SYMLINK 0x02 577 #define NFSV3FSINFO_HOMOGENEOUS 0x08 578 #define NFSV3FSINFO_CANSETTIME 0x10 579 580 /* Flags for Exchange ID */ 581 #define NFSV4EXCH_SUPPMOVEDREFER 0x00000001 582 #define NFSV4EXCH_SUPPMOVEDMIGR 0x00000002 583 #define NFSV4EXCH_BINDPRINCSTATEID 0x00000100 584 #define NFSV4EXCH_USENONPNFS 0x00010000 585 #define NFSV4EXCH_USEPNFSMDS 0x00020000 586 #define NFSV4EXCH_USEPNFSDS 0x00040000 587 #define NFSV4EXCH_MASKPNFS 0x00070000 588 #define NFSV4EXCH_UPDCONFIRMEDRECA 0x40000000 589 #define NFSV4EXCH_CONFIRMEDR 0x80000000 590 591 /* State Protects */ 592 #define NFSV4EXCH_SP4NONE 0 593 #define NFSV4EXCH_SP4MACHCRED 1 594 #define NFSV4EXCH_SP4SSV 2 595 596 /* Flags for Create Session */ 597 #define NFSV4CRSESS_PERSIST 0x00000001 598 #define NFSV4CRSESS_CONNBACKCHAN 0x00000002 599 #define NFSV4CRSESS_CONNRDMA 0x00000004 600 601 /* Flags for Sequence */ 602 #define NFSV4SEQ_CBPATHDOWN 0x00000001 603 #define NFSV4SEQ_CBGSSCONTEXPIRING 0x00000002 604 #define NFSV4SEQ_CBGSSCONTEXPIRED 0x00000004 605 #define NFSV4SEQ_EXPIREDALLSTATEREVOKED 0x00000008 606 #define NFSV4SEQ_EXPIREDSOMESTATEREVOKED 0x00000010 607 #define NFSV4SEQ_ADMINSTATEREVOKED 0x00000020 608 #define NFSV4SEQ_RECALLABLESTATEREVOKED 0x00000040 609 #define NFSV4SEQ_LEASEMOVED 0x00000080 610 #define NFSV4SEQ_RESTARTRECLAIMNEEDED 0x00000100 611 #define NFSV4SEQ_CBPATHDOWNSESSION 0x00000200 612 #define NFSV4SEQ_BACKCHANNELFAULT 0x00000400 613 #define NFSV4SEQ_DEVIDCHANGED 0x00000800 614 #define NFSV4SEQ_DEVIDDELETED 0x00001000 615 616 /* Flags for Layout. */ 617 #define NFSLAYOUTRETURN_FILE 1 618 #define NFSLAYOUTRETURN_FSID 2 619 #define NFSLAYOUTRETURN_ALL 3 620 621 #define NFSLAYOUT_NFSV4_1_FILES 0x1 622 #define NFSLAYOUT_OSD2_OBJECTS 0x2 623 #define NFSLAYOUT_BLOCK_VOLUME 0x3 624 625 #define NFSLAYOUTIOMODE_READ 1 626 #define NFSLAYOUTIOMODE_RW 2 627 #define NFSLAYOUTIOMODE_ANY 3 628 629 /* Flags for Get Device Info. */ 630 #define NFSDEVICEIDNOTIFY_CHANGEBIT 0x1 631 #define NFSDEVICEIDNOTIFY_DELETEBIT 0x2 632 633 /* Flags for File Layout. */ 634 #define NFSFLAYUTIL_DENSE 0x1 635 #define NFSFLAYUTIL_COMMIT_THRU_MDS 0x2 636 637 /* Conversion macros */ 638 #define vtonfsv2_mode(t,m) \ 639 txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ 640 MAKEIMODE((t), (m))) 641 #define vtonfsv34_mode(m) txdr_unsigned((m) & 07777) 642 #define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777) 643 #define vtonfsv2_type(a) (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \ 644 txdr_unsigned(newnfsv2_type[((u_int32_t)(a))])) 645 #define vtonfsv34_type(a) (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \ 646 txdr_unsigned(nfsv34_type[((u_int32_t)(a))])) 647 #define nfsv2tov_type(a) newnv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] 648 #define nfsv34tov_type(a) nv34tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] 649 #define vtonfs_dtype(a) (((u_int32_t)(a)) >= 9 ? IFTODT(VTTOIF(VNON)) : \ 650 IFTODT(VTTOIF(a))) 651 652 /* File types */ 653 typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5, 654 NFSOCK=6, NFFIFO=7, NFATTRDIR=8, NFNAMEDATTR=9 } nfstype; 655 656 /* Structs for common parts of the rpc's */ 657 658 struct nfsv2_time { 659 u_int32_t nfsv2_sec; 660 u_int32_t nfsv2_usec; 661 }; 662 typedef struct nfsv2_time nfstime2; 663 664 struct nfsv3_time { 665 u_int32_t nfsv3_sec; 666 u_int32_t nfsv3_nsec; 667 }; 668 typedef struct nfsv3_time nfstime3; 669 670 struct nfsv4_time { 671 u_int32_t nfsv4_highsec; 672 u_int32_t nfsv4_sec; 673 u_int32_t nfsv4_nsec; 674 }; 675 typedef struct nfsv4_time nfstime4; 676 677 /* 678 * Quads are defined as arrays of 2 longs to ensure dense packing for the 679 * protocol and to facilitate xdr conversion. 680 */ 681 struct nfs_uquad { 682 u_int32_t nfsuquad[2]; 683 }; 684 typedef struct nfs_uquad nfsuint64; 685 686 /* 687 * Used to convert between two u_longs and a u_quad_t. 688 */ 689 union nfs_quadconvert { 690 u_int32_t lval[2]; 691 u_quad_t qval; 692 }; 693 typedef union nfs_quadconvert nfsquad_t; 694 695 /* 696 * NFS Version 3 special file number. 697 */ 698 struct nfsv3_spec { 699 u_int32_t specdata1; 700 u_int32_t specdata2; 701 }; 702 typedef struct nfsv3_spec nfsv3spec; 703 704 /* 705 * File attributes and setable attributes. These structures cover both 706 * NFS version 2 and the version 3 protocol. Note that the union is only 707 * used so that one pointer can refer to both variants. These structures 708 * go out on the wire and must be densely packed, so no quad data types 709 * are used. (all fields are longs or u_longs or structures of same) 710 * NB: You can't do sizeof(struct nfs_fattr), you must use the 711 * NFSX_FATTR(v3) macro. 712 */ 713 struct nfs_fattr { 714 u_int32_t fa_type; 715 u_int32_t fa_mode; 716 u_int32_t fa_nlink; 717 u_int32_t fa_uid; 718 u_int32_t fa_gid; 719 union { 720 struct { 721 u_int32_t nfsv2fa_size; 722 u_int32_t nfsv2fa_blocksize; 723 u_int32_t nfsv2fa_rdev; 724 u_int32_t nfsv2fa_blocks; 725 u_int32_t nfsv2fa_fsid; 726 u_int32_t nfsv2fa_fileid; 727 nfstime2 nfsv2fa_atime; 728 nfstime2 nfsv2fa_mtime; 729 nfstime2 nfsv2fa_ctime; 730 } fa_nfsv2; 731 struct { 732 nfsuint64 nfsv3fa_size; 733 nfsuint64 nfsv3fa_used; 734 nfsv3spec nfsv3fa_rdev; 735 nfsuint64 nfsv3fa_fsid; 736 nfsuint64 nfsv3fa_fileid; 737 nfstime3 nfsv3fa_atime; 738 nfstime3 nfsv3fa_mtime; 739 nfstime3 nfsv3fa_ctime; 740 } fa_nfsv3; 741 } fa_un; 742 }; 743 744 /* and some ugly defines for accessing union components */ 745 #define fa2_size fa_un.fa_nfsv2.nfsv2fa_size 746 #define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize 747 #define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev 748 #define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks 749 #define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid 750 #define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid 751 #define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime 752 #define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime 753 #define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime 754 #define fa3_size fa_un.fa_nfsv3.nfsv3fa_size 755 #define fa3_used fa_un.fa_nfsv3.nfsv3fa_used 756 #define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev 757 #define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid 758 #define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid 759 #define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime 760 #define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime 761 #define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime 762 763 struct nfsv2_sattr { 764 u_int32_t sa_mode; 765 u_int32_t sa_uid; 766 u_int32_t sa_gid; 767 u_int32_t sa_size; 768 nfstime2 sa_atime; 769 nfstime2 sa_mtime; 770 }; 771 772 /* 773 * NFS Version 3 sattr structure for the new node creation case. 774 */ 775 struct nfsv3_sattr { 776 u_int32_t sa_modetrue; 777 u_int32_t sa_mode; 778 u_int32_t sa_uidfalse; 779 u_int32_t sa_gidfalse; 780 u_int32_t sa_sizefalse; 781 u_int32_t sa_atimetype; 782 nfstime3 sa_atime; 783 u_int32_t sa_mtimetype; 784 nfstime3 sa_mtime; 785 }; 786 787 /* 788 * The attribute bits used for V4. 789 * NFSATTRBIT_xxx defines the attribute# (and its bit position) 790 * NFSATTRBM_xxx is a 32bit mask with the correct bit set within the 791 * appropriate 32bit word. 792 * NFSATTRBIT_MAX is one greater than the largest NFSATTRBIT_xxx 793 */ 794 #define NFSATTRBIT_SUPPORTEDATTRS 0 795 #define NFSATTRBIT_TYPE 1 796 #define NFSATTRBIT_FHEXPIRETYPE 2 797 #define NFSATTRBIT_CHANGE 3 798 #define NFSATTRBIT_SIZE 4 799 #define NFSATTRBIT_LINKSUPPORT 5 800 #define NFSATTRBIT_SYMLINKSUPPORT 6 801 #define NFSATTRBIT_NAMEDATTR 7 802 #define NFSATTRBIT_FSID 8 803 #define NFSATTRBIT_UNIQUEHANDLES 9 804 #define NFSATTRBIT_LEASETIME 10 805 #define NFSATTRBIT_RDATTRERROR 11 806 #define NFSATTRBIT_ACL 12 807 #define NFSATTRBIT_ACLSUPPORT 13 808 #define NFSATTRBIT_ARCHIVE 14 809 #define NFSATTRBIT_CANSETTIME 15 810 #define NFSATTRBIT_CASEINSENSITIVE 16 811 #define NFSATTRBIT_CASEPRESERVING 17 812 #define NFSATTRBIT_CHOWNRESTRICTED 18 813 #define NFSATTRBIT_FILEHANDLE 19 814 #define NFSATTRBIT_FILEID 20 815 #define NFSATTRBIT_FILESAVAIL 21 816 #define NFSATTRBIT_FILESFREE 22 817 #define NFSATTRBIT_FILESTOTAL 23 818 #define NFSATTRBIT_FSLOCATIONS 24 819 #define NFSATTRBIT_HIDDEN 25 820 #define NFSATTRBIT_HOMOGENEOUS 26 821 #define NFSATTRBIT_MAXFILESIZE 27 822 #define NFSATTRBIT_MAXLINK 28 823 #define NFSATTRBIT_MAXNAME 29 824 #define NFSATTRBIT_MAXREAD 30 825 #define NFSATTRBIT_MAXWRITE 31 826 #define NFSATTRBIT_MIMETYPE 32 827 #define NFSATTRBIT_MODE 33 828 #define NFSATTRBIT_NOTRUNC 34 829 #define NFSATTRBIT_NUMLINKS 35 830 #define NFSATTRBIT_OWNER 36 831 #define NFSATTRBIT_OWNERGROUP 37 832 #define NFSATTRBIT_QUOTAHARD 38 833 #define NFSATTRBIT_QUOTASOFT 39 834 #define NFSATTRBIT_QUOTAUSED 40 835 #define NFSATTRBIT_RAWDEV 41 836 #define NFSATTRBIT_SPACEAVAIL 42 837 #define NFSATTRBIT_SPACEFREE 43 838 #define NFSATTRBIT_SPACETOTAL 44 839 #define NFSATTRBIT_SPACEUSED 45 840 #define NFSATTRBIT_SYSTEM 46 841 #define NFSATTRBIT_TIMEACCESS 47 842 #define NFSATTRBIT_TIMEACCESSSET 48 843 #define NFSATTRBIT_TIMEBACKUP 49 844 #define NFSATTRBIT_TIMECREATE 50 845 #define NFSATTRBIT_TIMEDELTA 51 846 #define NFSATTRBIT_TIMEMETADATA 52 847 #define NFSATTRBIT_TIMEMODIFY 53 848 #define NFSATTRBIT_TIMEMODIFYSET 54 849 #define NFSATTRBIT_MOUNTEDONFILEID 55 850 #define NFSATTRBIT_DIRNOTIFDELAY 56 851 #define NFSATTRBIT_DIRENTNOTIFDELAY 57 852 #define NFSATTRBIT_DACL 58 853 #define NFSATTRBIT_SACL 59 854 #define NFSATTRBIT_CHANGEPOLICY 60 855 #define NFSATTRBIT_FSSTATUS 61 856 #define NFSATTRBIT_FSLAYOUTTYPE 62 857 #define NFSATTRBIT_LAYOUTHINT 63 858 #define NFSATTRBIT_LAYOUTTYPE 64 859 #define NFSATTRBIT_LAYOUTBLKSIZE 65 860 #define NFSATTRBIT_LAYOUTALIGNMENT 66 861 #define NFSATTRBIT_FSLOCATIONSINFO 67 862 #define NFSATTRBIT_MDSTHRESHOLD 68 863 #define NFSATTRBIT_RETENTIONGET 69 864 #define NFSATTRBIT_RETENTIONSET 70 865 #define NFSATTRBIT_RETENTEVTGET 71 866 #define NFSATTRBIT_RETENTEVTSET 72 867 #define NFSATTRBIT_RETENTIONHOLD 73 868 #define NFSATTRBIT_MODESETMASKED 74 869 #define NFSATTRBIT_SUPPATTREXCLCREAT 75 870 #define NFSATTRBIT_FSCHARSETCAP 76 871 872 #define NFSATTRBM_SUPPORTEDATTRS 0x00000001 873 #define NFSATTRBM_TYPE 0x00000002 874 #define NFSATTRBM_FHEXPIRETYPE 0x00000004 875 #define NFSATTRBM_CHANGE 0x00000008 876 #define NFSATTRBM_SIZE 0x00000010 877 #define NFSATTRBM_LINKSUPPORT 0x00000020 878 #define NFSATTRBM_SYMLINKSUPPORT 0x00000040 879 #define NFSATTRBM_NAMEDATTR 0x00000080 880 #define NFSATTRBM_FSID 0x00000100 881 #define NFSATTRBM_UNIQUEHANDLES 0x00000200 882 #define NFSATTRBM_LEASETIME 0x00000400 883 #define NFSATTRBM_RDATTRERROR 0x00000800 884 #define NFSATTRBM_ACL 0x00001000 885 #define NFSATTRBM_ACLSUPPORT 0x00002000 886 #define NFSATTRBM_ARCHIVE 0x00004000 887 #define NFSATTRBM_CANSETTIME 0x00008000 888 #define NFSATTRBM_CASEINSENSITIVE 0x00010000 889 #define NFSATTRBM_CASEPRESERVING 0x00020000 890 #define NFSATTRBM_CHOWNRESTRICTED 0x00040000 891 #define NFSATTRBM_FILEHANDLE 0x00080000 892 #define NFSATTRBM_FILEID 0x00100000 893 #define NFSATTRBM_FILESAVAIL 0x00200000 894 #define NFSATTRBM_FILESFREE 0x00400000 895 #define NFSATTRBM_FILESTOTAL 0x00800000 896 #define NFSATTRBM_FSLOCATIONS 0x01000000 897 #define NFSATTRBM_HIDDEN 0x02000000 898 #define NFSATTRBM_HOMOGENEOUS 0x04000000 899 #define NFSATTRBM_MAXFILESIZE 0x08000000 900 #define NFSATTRBM_MAXLINK 0x10000000 901 #define NFSATTRBM_MAXNAME 0x20000000 902 #define NFSATTRBM_MAXREAD 0x40000000 903 #define NFSATTRBM_MAXWRITE 0x80000000 904 #define NFSATTRBM_MIMETYPE 0x00000001 905 #define NFSATTRBM_MODE 0x00000002 906 #define NFSATTRBM_NOTRUNC 0x00000004 907 #define NFSATTRBM_NUMLINKS 0x00000008 908 #define NFSATTRBM_OWNER 0x00000010 909 #define NFSATTRBM_OWNERGROUP 0x00000020 910 #define NFSATTRBM_QUOTAHARD 0x00000040 911 #define NFSATTRBM_QUOTASOFT 0x00000080 912 #define NFSATTRBM_QUOTAUSED 0x00000100 913 #define NFSATTRBM_RAWDEV 0x00000200 914 #define NFSATTRBM_SPACEAVAIL 0x00000400 915 #define NFSATTRBM_SPACEFREE 0x00000800 916 #define NFSATTRBM_SPACETOTAL 0x00001000 917 #define NFSATTRBM_SPACEUSED 0x00002000 918 #define NFSATTRBM_SYSTEM 0x00004000 919 #define NFSATTRBM_TIMEACCESS 0x00008000 920 #define NFSATTRBM_TIMEACCESSSET 0x00010000 921 #define NFSATTRBM_TIMEBACKUP 0x00020000 922 #define NFSATTRBM_TIMECREATE 0x00040000 923 #define NFSATTRBM_TIMEDELTA 0x00080000 924 #define NFSATTRBM_TIMEMETADATA 0x00100000 925 #define NFSATTRBM_TIMEMODIFY 0x00200000 926 #define NFSATTRBM_TIMEMODIFYSET 0x00400000 927 #define NFSATTRBM_MOUNTEDONFILEID 0x00800000 928 #define NFSATTRBM_DIRNOTIFDELAY 0x01000000 929 #define NFSATTRBM_DIRENTNOTIFDELAY 0x02000000 930 #define NFSATTRBM_DACL 0x04000000 931 #define NFSATTRBM_SACL 0x08000000 932 #define NFSATTRBM_CHANGEPOLICY 0x10000000 933 #define NFSATTRBM_FSSTATUS 0x20000000 934 #define NFSATTRBM_FSLAYOUTTYPE 0x40000000 935 #define NFSATTRBM_LAYOUTHINT 0x80000000 936 #define NFSATTRBM_LAYOUTTYPE 0x00000001 937 #define NFSATTRBM_LAYOUTBLKSIZE 0x00000002 938 #define NFSATTRBM_LAYOUTALIGNMENT 0x00000004 939 #define NFSATTRBM_FSLOCATIONSINFO 0x00000008 940 #define NFSATTRBM_MDSTHRESHOLD 0x00000010 941 #define NFSATTRBM_RETENTIONGET 0x00000020 942 #define NFSATTRBM_RETENTIONSET 0x00000040 943 #define NFSATTRBM_RETENTEVTGET 0x00000080 944 #define NFSATTRBM_RETENTEVTSET 0x00000100 945 #define NFSATTRBM_RETENTIONHOLD 0x00000200 946 #define NFSATTRBM_MODESETMASKED 0x00000400 947 #define NFSATTRBM_SUPPATTREXCLCREAT 0x00000800 948 #define NFSATTRBM_FSCHARSETCAP 0x00001000 949 950 #define NFSATTRBIT_MAX 77 951 952 /* 953 * Sets of attributes that are supported, by words in the bitmap. 954 */ 955 /* 956 * NFSATTRBIT_SUPPORTED - SUPP0 - bits 0<->31 957 * SUPP1 - bits 32<->63 958 * SUPP2 - bits 64<->95 959 */ 960 #define NFSATTRBIT_SUPP0 \ 961 (NFSATTRBM_SUPPORTEDATTRS | \ 962 NFSATTRBM_TYPE | \ 963 NFSATTRBM_FHEXPIRETYPE | \ 964 NFSATTRBM_CHANGE | \ 965 NFSATTRBM_SIZE | \ 966 NFSATTRBM_LINKSUPPORT | \ 967 NFSATTRBM_SYMLINKSUPPORT | \ 968 NFSATTRBM_NAMEDATTR | \ 969 NFSATTRBM_FSID | \ 970 NFSATTRBM_UNIQUEHANDLES | \ 971 NFSATTRBM_LEASETIME | \ 972 NFSATTRBM_RDATTRERROR | \ 973 NFSATTRBM_ACL | \ 974 NFSATTRBM_ACLSUPPORT | \ 975 NFSATTRBM_CANSETTIME | \ 976 NFSATTRBM_CASEINSENSITIVE | \ 977 NFSATTRBM_CASEPRESERVING | \ 978 NFSATTRBM_CHOWNRESTRICTED | \ 979 NFSATTRBM_FILEHANDLE | \ 980 NFSATTRBM_FILEID | \ 981 NFSATTRBM_FILESAVAIL | \ 982 NFSATTRBM_FILESFREE | \ 983 NFSATTRBM_FILESTOTAL | \ 984 NFSATTRBM_FSLOCATIONS | \ 985 NFSATTRBM_HOMOGENEOUS | \ 986 NFSATTRBM_MAXFILESIZE | \ 987 NFSATTRBM_MAXLINK | \ 988 NFSATTRBM_MAXNAME | \ 989 NFSATTRBM_MAXREAD | \ 990 NFSATTRBM_MAXWRITE) 991 992 /* 993 * NFSATTRBIT_S1 - subset of SUPP1 - OR of the following bits: 994 */ 995 #define NFSATTRBIT_S1 \ 996 (NFSATTRBM_MODE | \ 997 NFSATTRBM_NOTRUNC | \ 998 NFSATTRBM_NUMLINKS | \ 999 NFSATTRBM_OWNER | \ 1000 NFSATTRBM_OWNERGROUP | \ 1001 NFSATTRBM_RAWDEV | \ 1002 NFSATTRBM_SPACEAVAIL | \ 1003 NFSATTRBM_SPACEFREE | \ 1004 NFSATTRBM_SPACETOTAL | \ 1005 NFSATTRBM_SPACEUSED | \ 1006 NFSATTRBM_TIMEACCESS | \ 1007 NFSATTRBM_TIMEDELTA | \ 1008 NFSATTRBM_TIMEMETADATA | \ 1009 NFSATTRBM_TIMEMODIFY | \ 1010 NFSATTRBM_MOUNTEDONFILEID | \ 1011 NFSATTRBM_QUOTAHARD | \ 1012 NFSATTRBM_QUOTASOFT | \ 1013 NFSATTRBM_QUOTAUSED) 1014 1015 1016 #ifdef QUOTA 1017 /* 1018 * If QUOTA OR in NFSATTRBIT_QUOTAHARD, NFSATTRBIT_QUOTASOFT and 1019 * NFSATTRBIT_QUOTAUSED. 1020 */ 1021 #define NFSATTRBIT_SUPP1 (NFSATTRBIT_S1 | \ 1022 NFSATTRBM_QUOTAHARD | \ 1023 NFSATTRBM_QUOTASOFT | \ 1024 NFSATTRBM_QUOTAUSED) 1025 #else 1026 #define NFSATTRBIT_SUPP1 NFSATTRBIT_S1 1027 #endif 1028 1029 #define NFSATTRBIT_SUPP2 NFSATTRBM_SUPPATTREXCLCREAT 1030 1031 /* 1032 * NFSATTRBIT_SUPPSETONLY is the OR of NFSATTRBIT_TIMEACCESSSET and 1033 * NFSATTRBIT_TIMEMODIFYSET. 1034 */ 1035 #define NFSATTRBIT_SUPPSETONLY (NFSATTRBM_TIMEACCESSSET | \ 1036 NFSATTRBM_TIMEMODIFYSET) 1037 1038 /* 1039 * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31 1040 * SETABLE1 - bits 32<->63 1041 * SETABLE2 - bits 64<->95 1042 */ 1043 #define NFSATTRBIT_SETABLE0 \ 1044 (NFSATTRBM_SIZE | \ 1045 NFSATTRBM_ACL) 1046 #define NFSATTRBIT_SETABLE1 \ 1047 (NFSATTRBM_MODE | \ 1048 NFSATTRBM_OWNER | \ 1049 NFSATTRBM_OWNERGROUP | \ 1050 NFSATTRBM_TIMEACCESSSET | \ 1051 NFSATTRBM_TIMEMODIFYSET) 1052 #define NFSATTRBIT_SETABLE2 0 1053 1054 /* 1055 * Set of attributes that the getattr vnode op needs. 1056 * OR of the following bits. 1057 * NFSATTRBIT_GETATTR0 - bits 0<->31 1058 */ 1059 #define NFSATTRBIT_GETATTR0 \ 1060 (NFSATTRBM_SUPPORTEDATTRS | \ 1061 NFSATTRBM_TYPE | \ 1062 NFSATTRBM_CHANGE | \ 1063 NFSATTRBM_SIZE | \ 1064 NFSATTRBM_FSID | \ 1065 NFSATTRBM_FILEID | \ 1066 NFSATTRBM_MAXREAD) 1067 1068 /* 1069 * NFSATTRBIT_GETATTR1 - bits 32<->63 1070 */ 1071 #define NFSATTRBIT_GETATTR1 \ 1072 (NFSATTRBM_MODE | \ 1073 NFSATTRBM_NUMLINKS | \ 1074 NFSATTRBM_OWNER | \ 1075 NFSATTRBM_OWNERGROUP | \ 1076 NFSATTRBM_RAWDEV | \ 1077 NFSATTRBM_SPACEUSED | \ 1078 NFSATTRBM_TIMEACCESS | \ 1079 NFSATTRBM_TIMEMETADATA | \ 1080 NFSATTRBM_TIMEMODIFY) 1081 1082 /* 1083 * NFSATTRBIT_GETATTR2 - bits 64<->95 1084 */ 1085 #define NFSATTRBIT_GETATTR2 0 1086 1087 /* 1088 * Subset of the above that the Write RPC gets. 1089 * OR of the following bits. 1090 * NFSATTRBIT_WRITEGETATTR0 - bits 0<->31 1091 */ 1092 #define NFSATTRBIT_WRITEGETATTR0 \ 1093 (NFSATTRBM_SUPPORTEDATTRS | \ 1094 NFSATTRBM_TYPE | \ 1095 NFSATTRBM_CHANGE | \ 1096 NFSATTRBM_SIZE | \ 1097 NFSATTRBM_FSID | \ 1098 NFSATTRBM_FILEID | \ 1099 NFSATTRBM_MAXREAD) 1100 1101 /* 1102 * NFSATTRBIT_WRITEGETATTR1 - bits 32<->63 1103 */ 1104 #define NFSATTRBIT_WRITEGETATTR1 \ 1105 (NFSATTRBM_MODE | \ 1106 NFSATTRBM_NUMLINKS | \ 1107 NFSATTRBM_RAWDEV | \ 1108 NFSATTRBM_SPACEUSED | \ 1109 NFSATTRBM_TIMEACCESS | \ 1110 NFSATTRBM_TIMEMETADATA | \ 1111 NFSATTRBM_TIMEMODIFY) 1112 1113 /* 1114 * NFSATTRBIT_WRITEGETATTR2 - bits 64<->95 1115 */ 1116 #define NFSATTRBIT_WRITEGETATTR2 0 1117 1118 /* 1119 * Set of attributes that the wccattr operation op needs. 1120 * OR of the following bits. 1121 * NFSATTRBIT_WCCATTR0 - bits 0<->31 1122 */ 1123 #define NFSATTRBIT_WCCATTR0 0 1124 1125 /* 1126 * NFSATTRBIT_WCCATTR1 - bits 32<->63 1127 */ 1128 #define NFSATTRBIT_WCCATTR1 \ 1129 (NFSATTRBM_TIMEMODIFY) 1130 1131 /* 1132 * NFSATTRBIT_WCCATTR2 - bits 64<->95 1133 */ 1134 #define NFSATTRBIT_WCCATTR2 0 1135 1136 /* 1137 * NFSATTRBIT_CBGETATTR0 - bits 0<->31 1138 */ 1139 #define NFSATTRBIT_CBGETATTR0 (NFSATTRBM_CHANGE | NFSATTRBM_SIZE) 1140 1141 /* 1142 * NFSATTRBIT_CBGETATTR1 - bits 32<->63 1143 */ 1144 #define NFSATTRBIT_CBGETATTR1 0x0 1145 1146 /* 1147 * NFSATTRBIT_CBGETATTR2 - bits 64<->95 1148 */ 1149 #define NFSATTRBIT_CBGETATTR2 0x0 1150 1151 /* 1152 * Sets of attributes that require a VFS_STATFS() call to get the 1153 * values of. 1154 * NFSATTRBIT_STATFS0 - bits 0<->31 1155 */ 1156 #define NFSATTRBIT_STATFS0 \ 1157 (NFSATTRBM_LINKSUPPORT | \ 1158 NFSATTRBM_SYMLINKSUPPORT | \ 1159 NFSATTRBM_CANSETTIME | \ 1160 NFSATTRBM_FILESAVAIL | \ 1161 NFSATTRBM_FILESFREE | \ 1162 NFSATTRBM_FILESTOTAL | \ 1163 NFSATTRBM_HOMOGENEOUS | \ 1164 NFSATTRBM_MAXFILESIZE | \ 1165 NFSATTRBM_MAXNAME | \ 1166 NFSATTRBM_MAXREAD | \ 1167 NFSATTRBM_MAXWRITE) 1168 1169 /* 1170 * NFSATTRBIT_STATFS1 - bits 32<->63 1171 */ 1172 #define NFSATTRBIT_STATFS1 \ 1173 (NFSATTRBM_QUOTAHARD | \ 1174 NFSATTRBM_QUOTASOFT | \ 1175 NFSATTRBM_QUOTAUSED | \ 1176 NFSATTRBM_SPACEAVAIL | \ 1177 NFSATTRBM_SPACEFREE | \ 1178 NFSATTRBM_SPACETOTAL | \ 1179 NFSATTRBM_SPACEUSED | \ 1180 NFSATTRBM_TIMEDELTA) 1181 1182 /* 1183 * NFSATTRBIT_STATFS2 - bits 64<->95 1184 */ 1185 #define NFSATTRBIT_STATFS2 0 1186 1187 /* 1188 * These are the bits that are needed by the nfs_statfs() call. 1189 * (The regular getattr bits are or'd in so the vnode gets the correct 1190 * type, etc.) 1191 * NFSGETATTRBIT_STATFS0 - bits 0<->31 1192 */ 1193 #define NFSGETATTRBIT_STATFS0 (NFSATTRBIT_GETATTR0 | \ 1194 NFSATTRBM_LINKSUPPORT | \ 1195 NFSATTRBM_SYMLINKSUPPORT | \ 1196 NFSATTRBM_CANSETTIME | \ 1197 NFSATTRBM_FILESFREE | \ 1198 NFSATTRBM_FILESTOTAL | \ 1199 NFSATTRBM_HOMOGENEOUS | \ 1200 NFSATTRBM_MAXFILESIZE | \ 1201 NFSATTRBM_MAXNAME | \ 1202 NFSATTRBM_MAXREAD | \ 1203 NFSATTRBM_MAXWRITE) 1204 1205 /* 1206 * NFSGETATTRBIT_STATFS1 - bits 32<->63 1207 */ 1208 #define NFSGETATTRBIT_STATFS1 (NFSATTRBIT_GETATTR1 | \ 1209 NFSATTRBM_SPACEAVAIL | \ 1210 NFSATTRBM_SPACEFREE | \ 1211 NFSATTRBM_SPACETOTAL | \ 1212 NFSATTRBM_TIMEDELTA) 1213 1214 /* 1215 * NFSGETATTRBIT_STATFS2 - bits 64<->95 1216 */ 1217 #define NFSGETATTRBIT_STATFS2 0 1218 1219 /* 1220 * Set of attributes for the equivalent of an nfsv3 pathconf rpc. 1221 * NFSGETATTRBIT_PATHCONF0 - bits 0<->31 1222 */ 1223 #define NFSGETATTRBIT_PATHCONF0 (NFSATTRBIT_GETATTR0 | \ 1224 NFSATTRBM_CASEINSENSITIVE | \ 1225 NFSATTRBM_CASEPRESERVING | \ 1226 NFSATTRBM_CHOWNRESTRICTED | \ 1227 NFSATTRBM_MAXLINK | \ 1228 NFSATTRBM_MAXNAME) 1229 1230 /* 1231 * NFSGETATTRBIT_PATHCONF1 - bits 32<->63 1232 */ 1233 #define NFSGETATTRBIT_PATHCONF1 (NFSATTRBIT_GETATTR1 | \ 1234 NFSATTRBM_NOTRUNC) 1235 1236 /* 1237 * NFSGETATTRBIT_PATHCONF2 - bits 64<->95 1238 */ 1239 #define NFSGETATTRBIT_PATHCONF2 0 1240 1241 /* 1242 * Sets of attributes required by readdir and readdirplus. 1243 * NFSATTRBIT_READDIRPLUS0 (NFSATTRBIT_GETATTR0 | NFSATTRBIT_FILEHANDLE | 1244 * NFSATTRBIT_RDATTRERROR) 1245 */ 1246 #define NFSATTRBIT_READDIRPLUS0 (NFSATTRBIT_GETATTR0 | NFSATTRBM_FILEHANDLE | \ 1247 NFSATTRBM_RDATTRERROR) 1248 #define NFSATTRBIT_READDIRPLUS1 NFSATTRBIT_GETATTR1 1249 #define NFSATTRBIT_READDIRPLUS2 0 1250 1251 /* 1252 * Set of attributes supported by Referral vnodes. 1253 */ 1254 #define NFSATTRBIT_REFERRAL0 (NFSATTRBM_TYPE | NFSATTRBM_FSID | \ 1255 NFSATTRBM_RDATTRERROR | NFSATTRBM_FSLOCATIONS) 1256 #define NFSATTRBIT_REFERRAL1 NFSATTRBM_MOUNTEDONFILEID 1257 #define NFSATTRBIT_REFERRAL2 0 1258 1259 /* 1260 * Structure for data handled by the statfs rpc. Since some fields are 1261 * u_int64_t, this cannot be used for copying data on/off the wire, due 1262 * to alignment concerns. 1263 */ 1264 struct nfsstatfs { 1265 union { 1266 struct { 1267 u_int32_t nfsv2sf_tsize; 1268 u_int32_t nfsv2sf_bsize; 1269 u_int32_t nfsv2sf_blocks; 1270 u_int32_t nfsv2sf_bfree; 1271 u_int32_t nfsv2sf_bavail; 1272 } sf_nfsv2; 1273 struct { 1274 u_int64_t nfsv3sf_tbytes; 1275 u_int64_t nfsv3sf_fbytes; 1276 u_int64_t nfsv3sf_abytes; 1277 u_int64_t nfsv3sf_tfiles; 1278 u_int64_t nfsv3sf_ffiles; 1279 u_int64_t nfsv3sf_afiles; 1280 u_int32_t nfsv3sf_invarsec; 1281 } sf_nfsv3; 1282 } sf_un; 1283 }; 1284 1285 #define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize 1286 #define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize 1287 #define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks 1288 #define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree 1289 #define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail 1290 #define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes 1291 #define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes 1292 #define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes 1293 #define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles 1294 #define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles 1295 #define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles 1296 #define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec 1297 1298 /* 1299 * Now defined using u_int64_t for the 64 bit field(s). 1300 * (Cannot be used to move data on/off the wire, due to alignment concerns.) 1301 */ 1302 struct nfsfsinfo { 1303 u_int32_t fs_rtmax; 1304 u_int32_t fs_rtpref; 1305 u_int32_t fs_rtmult; 1306 u_int32_t fs_wtmax; 1307 u_int32_t fs_wtpref; 1308 u_int32_t fs_wtmult; 1309 u_int32_t fs_dtpref; 1310 u_int64_t fs_maxfilesize; 1311 struct timespec fs_timedelta; 1312 u_int32_t fs_properties; 1313 }; 1314 1315 /* 1316 * Bits for fs_properties 1317 */ 1318 #define NFSV3_FSFLINK 0x1 1319 #define NFSV3_FSFSYMLINK 0x2 1320 #define NFSV3_FSFHOMOGENEOUS 0x4 1321 #define NFSV3_FSFCANSETTIME 0x8 1322 1323 /* 1324 * Yikes, overload fs_rtmult as fs_maxname for V4. 1325 */ 1326 #define fs_maxname fs_rtmult 1327 1328 struct nfsv3_pathconf { 1329 u_int32_t pc_linkmax; 1330 u_int32_t pc_namemax; 1331 u_int32_t pc_notrunc; 1332 u_int32_t pc_chownrestricted; 1333 u_int32_t pc_caseinsensitive; 1334 u_int32_t pc_casepreserving; 1335 }; 1336 1337 /* 1338 * NFS V4 data structures. 1339 */ 1340 struct nfsv4stateid { 1341 u_int32_t seqid; 1342 u_int32_t other[NFSX_STATEIDOTHER / NFSX_UNSIGNED]; 1343 }; 1344 typedef struct nfsv4stateid nfsv4stateid_t; 1345 1346 #endif /* _NFS_NFSPROTO_H_ */ 1347