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_MAXDATA NFS_MAXBSIZE 58 #define NFS_MAXPATHLEN 1024 59 #define NFS_MAXNAMLEN 255 60 #define NFS_MAXPKTHDR 404 61 #define NFS_MAXPACKET (NFS_MAXDATA + 2048) 62 #define NFS_MINPACKET 20 63 #define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ 64 #define NFSV4_MINORVERSION 0 /* V4 Minor version */ 65 #define NFSV4_CBVERS 1 /* V4 CB Version */ 66 #define NFSV4_SMALLSTR 50 /* Strings small enough for stack */ 67 68 /* Stat numbers for rpc returns (version 2, 3 and 4) */ 69 #define NFSERR_OK 0 70 #define NFSERR_PERM 1 71 #define NFSERR_NOENT 2 72 #define NFSERR_IO 5 73 #define NFSERR_NXIO 6 74 #define NFSERR_ACCES 13 75 #define NFSERR_EXIST 17 76 #define NFSERR_XDEV 18 /* Version 3, 4 only */ 77 #define NFSERR_NODEV 19 78 #define NFSERR_NOTDIR 20 79 #define NFSERR_ISDIR 21 80 #define NFSERR_INVAL 22 /* Version 3, 4 only */ 81 #define NFSERR_FBIG 27 82 #define NFSERR_NOSPC 28 83 #define NFSERR_ROFS 30 84 #define NFSERR_MLINK 31 /* Version 3, 4 only */ 85 #define NFSERR_NAMETOL 63 86 #define NFSERR_NOTEMPTY 66 87 #define NFSERR_DQUOT 69 88 #define NFSERR_STALE 70 89 #define NFSERR_REMOTE 71 /* Version 3 only */ 90 #define NFSERR_WFLUSH 99 /* Version 2 only */ 91 #define NFSERR_BADHANDLE 10001 /* These are Version 3, 4 only */ 92 #define NFSERR_NOT_SYNC 10002 /* Version 3 Only */ 93 #define NFSERR_BAD_COOKIE 10003 94 #define NFSERR_NOTSUPP 10004 95 #define NFSERR_TOOSMALL 10005 96 #define NFSERR_SERVERFAULT 10006 97 #define NFSERR_BADTYPE 10007 98 #define NFSERR_DELAY 10008 /* Called NFSERR_JUKEBOX for V3 */ 99 #define NFSERR_SAME 10009 /* These are Version 4 only */ 100 #define NFSERR_DENIED 10010 101 #define NFSERR_EXPIRED 10011 102 #define NFSERR_LOCKED 10012 103 #define NFSERR_GRACE 10013 104 #define NFSERR_FHEXPIRED 10014 105 #define NFSERR_SHAREDENIED 10015 106 #define NFSERR_WRONGSEC 10016 107 #define NFSERR_CLIDINUSE 10017 108 #define NFSERR_RESOURCE 10018 109 #define NFSERR_MOVED 10019 110 #define NFSERR_NOFILEHANDLE 10020 111 #define NFSERR_MINORVERMISMATCH 10021 112 #define NFSERR_STALECLIENTID 10022 113 #define NFSERR_STALESTATEID 10023 114 #define NFSERR_OLDSTATEID 10024 115 #define NFSERR_BADSTATEID 10025 116 #define NFSERR_BADSEQID 10026 117 #define NFSERR_NOTSAME 10027 118 #define NFSERR_LOCKRANGE 10028 119 #define NFSERR_SYMLINK 10029 120 #define NFSERR_RESTOREFH 10030 121 #define NFSERR_LEASEMOVED 10031 122 #define NFSERR_ATTRNOTSUPP 10032 123 #define NFSERR_NOGRACE 10033 124 #define NFSERR_RECLAIMBAD 10034 125 #define NFSERR_RECLAIMCONFLICT 10035 126 #define NFSERR_BADXDR 10036 127 #define NFSERR_LOCKSHELD 10037 128 #define NFSERR_OPENMODE 10038 129 #define NFSERR_BADOWNER 10039 130 #define NFSERR_BADCHAR 10040 131 #define NFSERR_BADNAME 10041 132 #define NFSERR_BADRANGE 10042 133 #define NFSERR_LOCKNOTSUPP 10043 134 #define NFSERR_OPILLEGAL 10044 135 #define NFSERR_DEADLOCK 10045 136 #define NFSERR_FILEOPEN 10046 137 #define NFSERR_ADMINREVOKED 10047 138 #define NFSERR_CBPATHDOWN 10048 139 140 #define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */ 141 #define NFSERR_DONTREPLY 30003 /* Don't process request */ 142 #define NFSERR_RETVOID 30004 /* Return void, not error */ 143 #define NFSERR_REPLYFROMCACHE 30005 /* Reply from recent request cache */ 144 #define NFSERR_STALEDONTRECOVER 30006 /* Don't initiate recovery */ 145 146 #define NFSERR_RPCERR 0x40000000 /* Mark an RPC layer error */ 147 #define NFSERR_AUTHERR 0x80000000 /* Mark an authentication error */ 148 149 #define NFSERR_RPCMISMATCH (NFSERR_RPCERR | RPC_MISMATCH) 150 #define NFSERR_PROGUNAVAIL (NFSERR_RPCERR | RPC_PROGUNAVAIL) 151 #define NFSERR_PROGMISMATCH (NFSERR_RPCERR | RPC_PROGMISMATCH) 152 #define NFSERR_PROGNOTV4 (NFSERR_RPCERR | 0xffff) 153 #define NFSERR_PROCUNAVAIL (NFSERR_RPCERR | RPC_PROCUNAVAIL) 154 #define NFSERR_GARBAGE (NFSERR_RPCERR | RPC_GARBAGE) 155 156 /* Sizes in bytes of various nfs rpc components */ 157 #define NFSX_UNSIGNED 4 158 #define NFSX_HYPER (2 * NFSX_UNSIGNED) 159 160 /* specific to NFS Version 2 */ 161 #define NFSX_V2FH 32 162 #define NFSX_V2FATTR 68 163 #define NFSX_V2SATTR 32 164 #define NFSX_V2COOKIE 4 165 #define NFSX_V2STATFS 20 166 167 /* specific to NFS Version 3 */ 168 #define NFSX_V3FHMAX 64 /* max. allowed by protocol */ 169 #define NFSX_V3FATTR 84 170 #define NFSX_V3SATTR 60 /* max. all fields filled in */ 171 #define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr)) 172 #define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED) 173 #define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED) 174 #define NFSX_V3STATFS 52 175 #define NFSX_V3FSINFO 48 176 #define NFSX_V3PATHCONF 24 177 178 /* specific to NFS Version 4 */ 179 #define NFSX_V4FHMAX 128 180 #define NFSX_V4FSID (2 * NFSX_HYPER) 181 #define NFSX_V4SPECDATA (2 * NFSX_UNSIGNED) 182 #define NFSX_V4TIME (NFSX_HYPER + NFSX_UNSIGNED) 183 #define NFSX_V4SETTIME (NFSX_UNSIGNED + NFSX_V4TIME) 184 185 /* sizes common to multiple NFS versions */ 186 #define NFSX_FHMAX (NFSX_V4FHMAX) 187 #define NFSX_MYFH (sizeof (fhandle_t)) /* size this server uses */ 188 #define NFSX_VERF 8 189 #define NFSX_STATEIDOTHER 12 190 #define NFSX_STATEID (NFSX_UNSIGNED + NFSX_STATEIDOTHER) 191 #define NFSX_GSSH 12 192 193 /* variants for multiple versions */ 194 #define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS) 195 196 /* nfs rpc procedure numbers (before version mapping) */ 197 #define NFSPROC_NULL 0 198 #define NFSPROC_GETATTR 1 199 #define NFSPROC_SETATTR 2 200 #define NFSPROC_LOOKUP 3 201 #define NFSPROC_ACCESS 4 202 #define NFSPROC_READLINK 5 203 #define NFSPROC_READ 6 204 #define NFSPROC_WRITE 7 205 #define NFSPROC_CREATE 8 206 #define NFSPROC_MKDIR 9 207 #define NFSPROC_SYMLINK 10 208 #define NFSPROC_MKNOD 11 209 #define NFSPROC_REMOVE 12 210 #define NFSPROC_RMDIR 13 211 #define NFSPROC_RENAME 14 212 #define NFSPROC_LINK 15 213 #define NFSPROC_READDIR 16 214 #define NFSPROC_READDIRPLUS 17 215 #define NFSPROC_FSSTAT 18 216 #define NFSPROC_FSINFO 19 217 #define NFSPROC_PATHCONF 20 218 #define NFSPROC_COMMIT 21 219 220 /* 221 * These cover all the procedures for V2 and 3. The higher numbers are 222 * used to reference other V4 ops. 223 * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is 224 * one greater than the last number. 225 */ 226 #define NFS_V3NPROCS 22 227 228 #define NFSPROC_LOOKUPP 22 229 #define NFSPROC_SETCLIENTID 23 230 #define NFSPROC_SETCLIENTIDCFRM 24 231 #define NFSPROC_LOCK 25 232 #define NFSPROC_LOCKU 26 233 #define NFSPROC_OPEN 27 234 #define NFSPROC_CLOSE 28 235 #define NFSPROC_OPENCONFIRM 29 236 #define NFSPROC_LOCKT 30 237 #define NFSPROC_OPENDOWNGRADE 31 238 #define NFSPROC_RENEW 32 239 #define NFSPROC_PUTROOTFH 33 240 #define NFSPROC_RELEASELCKOWN 34 241 #define NFSPROC_DELEGRETURN 35 242 #define NFSPROC_RETDELEGREMOVE 36 243 #define NFSPROC_RETDELEGRENAME1 37 244 #define NFSPROC_RETDELEGRENAME2 38 245 #define NFSPROC_GETACL 39 246 #define NFSPROC_SETACL 40 247 248 #define NFS_NPROCS 41 249 250 /* 251 * NFSPROC_NOOP is a fake op# that can't be the same as any V2/3/4 Procedure 252 * or Operation#. Since the NFS V4 Op #s go higher, use NFSV4OP_NOPS, which 253 * is one greater than the highest Op#. 254 */ 255 #define NFSPROC_NOOP NFSV4OP_NOPS 256 257 /* Actual Version 2 procedure numbers */ 258 #define NFSV2PROC_NULL 0 259 #define NFSV2PROC_GETATTR 1 260 #define NFSV2PROC_SETATTR 2 261 #define NFSV2PROC_NOOP 3 262 #define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */ 263 #define NFSV2PROC_LOOKUP 4 264 #define NFSV2PROC_READLINK 5 265 #define NFSV2PROC_READ 6 266 #define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */ 267 #define NFSV2PROC_WRITE 8 268 #define NFSV2PROC_CREATE 9 269 #define NFSV2PROC_REMOVE 10 270 #define NFSV2PROC_RENAME 11 271 #define NFSV2PROC_LINK 12 272 #define NFSV2PROC_SYMLINK 13 273 #define NFSV2PROC_MKDIR 14 274 #define NFSV2PROC_RMDIR 15 275 #define NFSV2PROC_READDIR 16 276 #define NFSV2PROC_STATFS 17 277 278 /* 279 * V4 Procedure and suboperation numbers 280 */ 281 #define NFSV4PROC_COMPOUND 1 282 #define NFSV4PROC_CBNULL 0 283 #define NFSV4PROC_CBCOMPOUND 1 284 285 #define NFSV4OP_ACCESS 3 286 #define NFSV4OP_CLOSE 4 287 #define NFSV4OP_COMMIT 5 288 #define NFSV4OP_CREATE 6 289 #define NFSV4OP_DELEGPURGE 7 290 #define NFSV4OP_DELEGRETURN 8 291 #define NFSV4OP_GETATTR 9 292 #define NFSV4OP_GETFH 10 293 #define NFSV4OP_LINK 11 294 #define NFSV4OP_LOCK 12 295 #define NFSV4OP_LOCKT 13 296 #define NFSV4OP_LOCKU 14 297 #define NFSV4OP_LOOKUP 15 298 #define NFSV4OP_LOOKUPP 16 299 #define NFSV4OP_NVERIFY 17 300 #define NFSV4OP_OPEN 18 301 #define NFSV4OP_OPENATTR 19 302 #define NFSV4OP_OPENCONFIRM 20 303 #define NFSV4OP_OPENDOWNGRADE 21 304 #define NFSV4OP_PUTFH 22 305 #define NFSV4OP_PUTPUBFH 23 306 #define NFSV4OP_PUTROOTFH 24 307 #define NFSV4OP_READ 25 308 #define NFSV4OP_READDIR 26 309 #define NFSV4OP_READLINK 27 310 #define NFSV4OP_REMOVE 28 311 #define NFSV4OP_RENAME 29 312 #define NFSV4OP_RENEW 30 313 #define NFSV4OP_RESTOREFH 31 314 #define NFSV4OP_SAVEFH 32 315 #define NFSV4OP_SECINFO 33 316 #define NFSV4OP_SETATTR 34 317 #define NFSV4OP_SETCLIENTID 35 318 #define NFSV4OP_SETCLIENTIDCFRM 36 319 #define NFSV4OP_VERIFY 37 320 #define NFSV4OP_WRITE 38 321 #define NFSV4OP_RELEASELCKOWN 39 322 323 /* 324 * and the Callback OPs 325 */ 326 #define NFSV4OP_CBGETATTR 3 327 #define NFSV4OP_CBRECALL 4 328 329 /* 330 * NFSV4OP_NOPS is one greater than the largest V4 Op#. (Used for sizing 331 * arrays, etc.) 332 */ 333 #define NFSV4OP_NOPS 40 334 #define NFSV4OP_CBNOPS 5 335 336 /* 337 * Fake NFSV4OP_xxx used for nfsstat. Start at NFSV4OP_NOPS. 338 */ 339 #define NFSV4OP_SYMLINK (NFSV4OP_NOPS) 340 #define NFSV4OP_MKDIR (NFSV4OP_NOPS + 1) 341 #define NFSV4OP_RMDIR (NFSV4OP_NOPS + 2) 342 #define NFSV4OP_READDIRPLUS (NFSV4OP_NOPS + 3) 343 #define NFSV4OP_MKNOD (NFSV4OP_NOPS + 4) 344 #define NFSV4OP_FSSTAT (NFSV4OP_NOPS + 5) 345 #define NFSV4OP_FSINFO (NFSV4OP_NOPS + 6) 346 #define NFSV4OP_PATHCONF (NFSV4OP_NOPS + 7) 347 #define NFSV4OP_V3CREATE (NFSV4OP_NOPS + 8) 348 349 #define NFSV4OP_FAKENOPS 9 350 351 /* 352 * Constants used by the Version 3 and 4 protocols for various RPCs 353 */ 354 #define NFSV3SATTRTIME_DONTCHANGE 0 355 #define NFSV3SATTRTIME_TOSERVER 1 356 #define NFSV3SATTRTIME_TOCLIENT 2 357 358 #define NFSV4SATTRTIME_TOSERVER 0 359 #define NFSV4SATTRTIME_TOCLIENT 1 360 361 #define NFSV4LOCKT_READ 1 362 #define NFSV4LOCKT_WRITE 2 363 #define NFSV4LOCKT_READW 3 364 #define NFSV4LOCKT_WRITEW 4 365 #define NFSV4LOCKT_RELEASE 5 366 367 #define NFSV4OPEN_NOCREATE 0 368 #define NFSV4OPEN_CREATE 1 369 #define NFSV4OPEN_CLAIMNULL 0 370 #define NFSV4OPEN_CLAIMPREVIOUS 1 371 #define NFSV4OPEN_CLAIMDELEGATECUR 2 372 #define NFSV4OPEN_CLAIMDELEGATEPREV 3 373 #define NFSV4OPEN_DELEGATENONE 0 374 #define NFSV4OPEN_DELEGATEREAD 1 375 #define NFSV4OPEN_DELEGATEWRITE 2 376 #define NFSV4OPEN_LIMITSIZE 1 377 #define NFSV4OPEN_LIMITBLOCKS 2 378 379 /* 380 * Nfs V4 ACE stuff 381 */ 382 #define NFSV4ACE_ALLOWEDTYPE 0x00000000 383 #define NFSV4ACE_DENIEDTYPE 0x00000001 384 #define NFSV4ACE_AUDITTYPE 0x00000002 385 #define NFSV4ACE_ALARMTYPE 0x00000003 386 387 #define NFSV4ACE_SUPALLOWED 0x00000001 388 #define NFSV4ACE_SUPDENIED 0x00000002 389 #define NFSV4ACE_SUPAUDIT 0x00000004 390 #define NFSV4ACE_SUPALARM 0x00000008 391 392 #define NFSV4ACE_SUPTYPES (NFSV4ACE_SUPALLOWED | NFSV4ACE_SUPDENIED) 393 394 #define NFSV4ACE_FILEINHERIT 0x00000001 395 #define NFSV4ACE_DIRECTORYINHERIT 0x00000002 396 #define NFSV4ACE_NOPROPAGATEINHERIT 0x00000004 397 #define NFSV4ACE_INHERITONLY 0x00000008 398 #define NFSV4ACE_SUCCESSFULACCESS 0x00000010 399 #define NFSV4ACE_FAILEDACCESS 0x00000020 400 #define NFSV4ACE_IDENTIFIERGROUP 0x00000040 401 402 #define NFSV4ACE_READDATA 0x00000001 403 #define NFSV4ACE_LISTDIRECTORY 0x00000001 404 #define NFSV4ACE_WRITEDATA 0x00000002 405 #define NFSV4ACE_ADDFILE 0x00000002 406 #define NFSV4ACE_APPENDDATA 0x00000004 407 #define NFSV4ACE_ADDSUBDIRECTORY 0x00000004 408 #define NFSV4ACE_READNAMEDATTR 0x00000008 409 #define NFSV4ACE_WRITENAMEDATTR 0x00000010 410 #define NFSV4ACE_EXECUTE 0x00000020 411 #define NFSV4ACE_SEARCH 0x00000020 412 #define NFSV4ACE_DELETECHILD 0x00000040 413 #define NFSV4ACE_READATTRIBUTES 0x00000080 414 #define NFSV4ACE_WRITEATTRIBUTES 0x00000100 415 #define NFSV4ACE_DELETE 0x00010000 416 #define NFSV4ACE_READACL 0x00020000 417 #define NFSV4ACE_WRITEACL 0x00040000 418 #define NFSV4ACE_WRITEOWNER 0x00080000 419 #define NFSV4ACE_SYNCHRONIZE 0x00100000 420 421 /* 422 * Here are the mappings between mode bits and acl mask bits for 423 * directories and other files. 424 * (Named attributes have not been included, since named attributes are 425 * not yet supported.) 426 * The mailing list seems to indicate that NFSV4ACE_EXECUTE refers to 427 * searching a directory, although I can't find a statement of that in 428 * the RFC. 429 */ 430 #define NFSV4ACE_ALLFILESMASK (NFSV4ACE_READATTRIBUTES | NFSV4ACE_READACL) 431 #define NFSV4ACE_OWNERMASK (NFSV4ACE_WRITEATTRIBUTES | NFSV4ACE_WRITEACL) 432 #define NFSV4ACE_DIRREADMASK NFSV4ACE_LISTDIRECTORY 433 #define NFSV4ACE_DIREXECUTEMASK NFSV4ACE_EXECUTE 434 #define NFSV4ACE_DIRWRITEMASK (NFSV4ACE_ADDFILE | \ 435 NFSV4ACE_ADDSUBDIRECTORY | NFSV4ACE_DELETECHILD) 436 #define NFSV4ACE_READMASK NFSV4ACE_READDATA 437 #define NFSV4ACE_WRITEMASK (NFSV4ACE_WRITEDATA | NFSV4ACE_APPENDDATA) 438 #define NFSV4ACE_EXECUTEMASK NFSV4ACE_EXECUTE 439 #define NFSV4ACE_ALLFILEBITS (NFSV4ACE_READMASK | NFSV4ACE_WRITEMASK | \ 440 NFSV4ACE_EXECUTEMASK | NFSV4ACE_SYNCHRONIZE) 441 #define NFSV4ACE_ALLDIRBITS (NFSV4ACE_DIRREADMASK | \ 442 NFSV4ACE_DIRWRITEMASK | NFSV4ACE_DIREXECUTEMASK) 443 #define NFSV4ACE_AUDITMASK 0x0 444 445 /* 446 * These GENERIC masks are not used and are no longer believed to be useful. 447 */ 448 #define NFSV4ACE_GENERICREAD 0x00120081 449 #define NFSV4ACE_GENERICWRITE 0x00160106 450 #define NFSV4ACE_GENERICEXECUTE 0x001200a0 451 452 #define NFSSTATEID_PUTALLZERO 0 453 #define NFSSTATEID_PUTALLONE 1 454 #define NFSSTATEID_PUTSTATEID 2 455 456 /* 457 * Bits for share access and deny. 458 */ 459 #define NFSV4OPEN_ACCESSREAD 0x00000001 460 #define NFSV4OPEN_ACCESSWRITE 0x00000002 461 #define NFSV4OPEN_ACCESSBOTH 0x00000003 462 463 #define NFSV4OPEN_DENYNONE 0x00000000 464 #define NFSV4OPEN_DENYREAD 0x00000001 465 #define NFSV4OPEN_DENYWRITE 0x00000002 466 #define NFSV4OPEN_DENYBOTH 0x00000003 467 468 /* 469 * Open result flags 470 * (The first two are in the spec. The rest are used internally.) 471 */ 472 #define NFSV4OPEN_RESULTCONFIRM 0x00000002 473 #define NFSV4OPEN_LOCKTYPEPOSIX 0x00000004 474 #define NFSV4OPEN_RFLAGS \ 475 (NFSV4OPEN_RESULTCONFIRM | NFSV4OPEN_LOCKTYPEPOSIX) 476 #define NFSV4OPEN_RECALL 0x00010000 477 #define NFSV4OPEN_READDELEGATE 0x00020000 478 #define NFSV4OPEN_WRITEDELEGATE 0x00040000 479 480 /* 481 * NFS V4 File Handle types 482 */ 483 #define NFSV4FHTYPE_PERSISTENT 0x0 484 #define NFSV4FHTYPE_NOEXPIREWITHOPEN 0x1 485 #define NFSV4FHTYPE_VOLATILEANY 0x2 486 #define NFSV4FHTYPE_VOLATILEMIGRATE 0x4 487 #define NFSV4FHTYPE_VOLATILERENAME 0x8 488 489 /* 490 * Maximum size of V4 opaque strings. 491 */ 492 #define NFSV4_OPAQUELIMIT 1024 493 494 /* 495 * These are the same for V3 and V4. 496 */ 497 #define NFSACCESS_READ 0x01 498 #define NFSACCESS_LOOKUP 0x02 499 #define NFSACCESS_MODIFY 0x04 500 #define NFSACCESS_EXTEND 0x08 501 #define NFSACCESS_DELETE 0x10 502 #define NFSACCESS_EXECUTE 0x20 503 504 #define NFSWRITE_UNSTABLE 0 505 #define NFSWRITE_DATASYNC 1 506 #define NFSWRITE_FILESYNC 2 507 508 #define NFSCREATE_UNCHECKED 0 509 #define NFSCREATE_GUARDED 1 510 #define NFSCREATE_EXCLUSIVE 2 511 512 #define NFSV3FSINFO_LINK 0x01 513 #define NFSV3FSINFO_SYMLINK 0x02 514 #define NFSV3FSINFO_HOMOGENEOUS 0x08 515 #define NFSV3FSINFO_CANSETTIME 0x10 516 517 /* Conversion macros */ 518 #define vtonfsv2_mode(t,m) \ 519 txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ 520 MAKEIMODE((t), (m))) 521 #define vtonfsv34_mode(m) txdr_unsigned((m) & 07777) 522 #define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777) 523 #define vtonfsv2_type(a) (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \ 524 txdr_unsigned(newnfsv2_type[((u_int32_t)(a))])) 525 #define vtonfsv34_type(a) (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \ 526 txdr_unsigned(nfsv34_type[((u_int32_t)(a))])) 527 #define nfsv2tov_type(a) newnv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] 528 #define nfsv34tov_type(a) nv34tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] 529 #define vtonfs_dtype(a) (((u_int32_t)(a)) >= 9 ? IFTODT(VTTOIF(VNON)) : \ 530 IFTODT(VTTOIF(a))) 531 532 /* File types */ 533 typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5, 534 NFSOCK=6, NFFIFO=7, NFATTRDIR=8, NFNAMEDATTR=9 } nfstype; 535 536 /* Structs for common parts of the rpc's */ 537 538 struct nfsv2_time { 539 u_int32_t nfsv2_sec; 540 u_int32_t nfsv2_usec; 541 }; 542 typedef struct nfsv2_time nfstime2; 543 544 struct nfsv3_time { 545 u_int32_t nfsv3_sec; 546 u_int32_t nfsv3_nsec; 547 }; 548 typedef struct nfsv3_time nfstime3; 549 550 struct nfsv4_time { 551 u_int32_t nfsv4_highsec; 552 u_int32_t nfsv4_sec; 553 u_int32_t nfsv4_nsec; 554 }; 555 typedef struct nfsv4_time nfstime4; 556 557 /* 558 * Quads are defined as arrays of 2 longs to ensure dense packing for the 559 * protocol and to facilitate xdr conversion. 560 */ 561 struct nfs_uquad { 562 u_int32_t nfsuquad[2]; 563 }; 564 typedef struct nfs_uquad nfsuint64; 565 566 /* 567 * Used to convert between two u_longs and a u_quad_t. 568 */ 569 union nfs_quadconvert { 570 u_int32_t lval[2]; 571 u_quad_t qval; 572 }; 573 typedef union nfs_quadconvert nfsquad_t; 574 575 /* 576 * NFS Version 3 special file number. 577 */ 578 struct nfsv3_spec { 579 u_int32_t specdata1; 580 u_int32_t specdata2; 581 }; 582 typedef struct nfsv3_spec nfsv3spec; 583 584 /* 585 * File attributes and setable attributes. These structures cover both 586 * NFS version 2 and the version 3 protocol. Note that the union is only 587 * used so that one pointer can refer to both variants. These structures 588 * go out on the wire and must be densely packed, so no quad data types 589 * are used. (all fields are longs or u_longs or structures of same) 590 * NB: You can't do sizeof(struct nfs_fattr), you must use the 591 * NFSX_FATTR(v3) macro. 592 */ 593 struct nfs_fattr { 594 u_int32_t fa_type; 595 u_int32_t fa_mode; 596 u_int32_t fa_nlink; 597 u_int32_t fa_uid; 598 u_int32_t fa_gid; 599 union { 600 struct { 601 u_int32_t nfsv2fa_size; 602 u_int32_t nfsv2fa_blocksize; 603 u_int32_t nfsv2fa_rdev; 604 u_int32_t nfsv2fa_blocks; 605 u_int32_t nfsv2fa_fsid; 606 u_int32_t nfsv2fa_fileid; 607 nfstime2 nfsv2fa_atime; 608 nfstime2 nfsv2fa_mtime; 609 nfstime2 nfsv2fa_ctime; 610 } fa_nfsv2; 611 struct { 612 nfsuint64 nfsv3fa_size; 613 nfsuint64 nfsv3fa_used; 614 nfsv3spec nfsv3fa_rdev; 615 nfsuint64 nfsv3fa_fsid; 616 nfsuint64 nfsv3fa_fileid; 617 nfstime3 nfsv3fa_atime; 618 nfstime3 nfsv3fa_mtime; 619 nfstime3 nfsv3fa_ctime; 620 } fa_nfsv3; 621 } fa_un; 622 }; 623 624 /* and some ugly defines for accessing union components */ 625 #define fa2_size fa_un.fa_nfsv2.nfsv2fa_size 626 #define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize 627 #define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev 628 #define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks 629 #define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid 630 #define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid 631 #define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime 632 #define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime 633 #define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime 634 #define fa3_size fa_un.fa_nfsv3.nfsv3fa_size 635 #define fa3_used fa_un.fa_nfsv3.nfsv3fa_used 636 #define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev 637 #define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid 638 #define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid 639 #define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime 640 #define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime 641 #define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime 642 643 struct nfsv2_sattr { 644 u_int32_t sa_mode; 645 u_int32_t sa_uid; 646 u_int32_t sa_gid; 647 u_int32_t sa_size; 648 nfstime2 sa_atime; 649 nfstime2 sa_mtime; 650 }; 651 652 /* 653 * NFS Version 3 sattr structure for the new node creation case. 654 */ 655 struct nfsv3_sattr { 656 u_int32_t sa_modetrue; 657 u_int32_t sa_mode; 658 u_int32_t sa_uidfalse; 659 u_int32_t sa_gidfalse; 660 u_int32_t sa_sizefalse; 661 u_int32_t sa_atimetype; 662 nfstime3 sa_atime; 663 u_int32_t sa_mtimetype; 664 nfstime3 sa_mtime; 665 }; 666 667 /* 668 * The attribute bits used for V4. 669 * NFSATTRBIT_xxx defines the attribute# (and its bit position) 670 * NFSATTRBM_xxx is a 32bit mask with the correct bit set within the 671 * appropriate 32bit word. 672 * NFSATTRBIT_MAX is one greater than the largest NFSATTRBIT_xxx 673 */ 674 #define NFSATTRBIT_SUPPORTEDATTRS 0 675 #define NFSATTRBIT_TYPE 1 676 #define NFSATTRBIT_FHEXPIRETYPE 2 677 #define NFSATTRBIT_CHANGE 3 678 #define NFSATTRBIT_SIZE 4 679 #define NFSATTRBIT_LINKSUPPORT 5 680 #define NFSATTRBIT_SYMLINKSUPPORT 6 681 #define NFSATTRBIT_NAMEDATTR 7 682 #define NFSATTRBIT_FSID 8 683 #define NFSATTRBIT_UNIQUEHANDLES 9 684 #define NFSATTRBIT_LEASETIME 10 685 #define NFSATTRBIT_RDATTRERROR 11 686 #define NFSATTRBIT_ACL 12 687 #define NFSATTRBIT_ACLSUPPORT 13 688 #define NFSATTRBIT_ARCHIVE 14 689 #define NFSATTRBIT_CANSETTIME 15 690 #define NFSATTRBIT_CASEINSENSITIVE 16 691 #define NFSATTRBIT_CASEPRESERVING 17 692 #define NFSATTRBIT_CHOWNRESTRICTED 18 693 #define NFSATTRBIT_FILEHANDLE 19 694 #define NFSATTRBIT_FILEID 20 695 #define NFSATTRBIT_FILESAVAIL 21 696 #define NFSATTRBIT_FILESFREE 22 697 #define NFSATTRBIT_FILESTOTAL 23 698 #define NFSATTRBIT_FSLOCATIONS 24 699 #define NFSATTRBIT_HIDDEN 25 700 #define NFSATTRBIT_HOMOGENEOUS 26 701 #define NFSATTRBIT_MAXFILESIZE 27 702 #define NFSATTRBIT_MAXLINK 28 703 #define NFSATTRBIT_MAXNAME 29 704 #define NFSATTRBIT_MAXREAD 30 705 #define NFSATTRBIT_MAXWRITE 31 706 #define NFSATTRBIT_MIMETYPE 32 707 #define NFSATTRBIT_MODE 33 708 #define NFSATTRBIT_NOTRUNC 34 709 #define NFSATTRBIT_NUMLINKS 35 710 #define NFSATTRBIT_OWNER 36 711 #define NFSATTRBIT_OWNERGROUP 37 712 #define NFSATTRBIT_QUOTAHARD 38 713 #define NFSATTRBIT_QUOTASOFT 39 714 #define NFSATTRBIT_QUOTAUSED 40 715 #define NFSATTRBIT_RAWDEV 41 716 #define NFSATTRBIT_SPACEAVAIL 42 717 #define NFSATTRBIT_SPACEFREE 43 718 #define NFSATTRBIT_SPACETOTAL 44 719 #define NFSATTRBIT_SPACEUSED 45 720 #define NFSATTRBIT_SYSTEM 46 721 #define NFSATTRBIT_TIMEACCESS 47 722 #define NFSATTRBIT_TIMEACCESSSET 48 723 #define NFSATTRBIT_TIMEBACKUP 49 724 #define NFSATTRBIT_TIMECREATE 50 725 #define NFSATTRBIT_TIMEDELTA 51 726 #define NFSATTRBIT_TIMEMETADATA 52 727 #define NFSATTRBIT_TIMEMODIFY 53 728 #define NFSATTRBIT_TIMEMODIFYSET 54 729 #define NFSATTRBIT_MOUNTEDONFILEID 55 730 731 #define NFSATTRBM_SUPPORTEDATTRS 0x00000001 732 #define NFSATTRBM_TYPE 0x00000002 733 #define NFSATTRBM_FHEXPIRETYPE 0x00000004 734 #define NFSATTRBM_CHANGE 0x00000008 735 #define NFSATTRBM_SIZE 0x00000010 736 #define NFSATTRBM_LINKSUPPORT 0x00000020 737 #define NFSATTRBM_SYMLINKSUPPORT 0x00000040 738 #define NFSATTRBM_NAMEDATTR 0x00000080 739 #define NFSATTRBM_FSID 0x00000100 740 #define NFSATTRBM_UNIQUEHANDLES 0x00000200 741 #define NFSATTRBM_LEASETIME 0x00000400 742 #define NFSATTRBM_RDATTRERROR 0x00000800 743 #define NFSATTRBM_ACL 0x00001000 744 #define NFSATTRBM_ACLSUPPORT 0x00002000 745 #define NFSATTRBM_ARCHIVE 0x00004000 746 #define NFSATTRBM_CANSETTIME 0x00008000 747 #define NFSATTRBM_CASEINSENSITIVE 0x00010000 748 #define NFSATTRBM_CASEPRESERVING 0x00020000 749 #define NFSATTRBM_CHOWNRESTRICTED 0x00040000 750 #define NFSATTRBM_FILEHANDLE 0x00080000 751 #define NFSATTRBM_FILEID 0x00100000 752 #define NFSATTRBM_FILESAVAIL 0x00200000 753 #define NFSATTRBM_FILESFREE 0x00400000 754 #define NFSATTRBM_FILESTOTAL 0x00800000 755 #define NFSATTRBM_FSLOCATIONS 0x01000000 756 #define NFSATTRBM_HIDDEN 0x02000000 757 #define NFSATTRBM_HOMOGENEOUS 0x04000000 758 #define NFSATTRBM_MAXFILESIZE 0x08000000 759 #define NFSATTRBM_MAXLINK 0x10000000 760 #define NFSATTRBM_MAXNAME 0x20000000 761 #define NFSATTRBM_MAXREAD 0x40000000 762 #define NFSATTRBM_MAXWRITE 0x80000000 763 #define NFSATTRBM_MIMETYPE 0x00000001 764 #define NFSATTRBM_MODE 0x00000002 765 #define NFSATTRBM_NOTRUNC 0x00000004 766 #define NFSATTRBM_NUMLINKS 0x00000008 767 #define NFSATTRBM_OWNER 0x00000010 768 #define NFSATTRBM_OWNERGROUP 0x00000020 769 #define NFSATTRBM_QUOTAHARD 0x00000040 770 #define NFSATTRBM_QUOTASOFT 0x00000080 771 #define NFSATTRBM_QUOTAUSED 0x00000100 772 #define NFSATTRBM_RAWDEV 0x00000200 773 #define NFSATTRBM_SPACEAVAIL 0x00000400 774 #define NFSATTRBM_SPACEFREE 0x00000800 775 #define NFSATTRBM_SPACETOTAL 0x00001000 776 #define NFSATTRBM_SPACEUSED 0x00002000 777 #define NFSATTRBM_SYSTEM 0x00004000 778 #define NFSATTRBM_TIMEACCESS 0x00008000 779 #define NFSATTRBM_TIMEACCESSSET 0x00010000 780 #define NFSATTRBM_TIMEBACKUP 0x00020000 781 #define NFSATTRBM_TIMECREATE 0x00040000 782 #define NFSATTRBM_TIMEDELTA 0x00080000 783 #define NFSATTRBM_TIMEMETADATA 0x00100000 784 #define NFSATTRBM_TIMEMODIFY 0x00200000 785 #define NFSATTRBM_TIMEMODIFYSET 0x00400000 786 #define NFSATTRBM_MOUNTEDONFILEID 0x00800000 787 788 #define NFSATTRBIT_MAX 56 789 790 /* 791 * Sets of attributes that are supported, by words in the bitmap. 792 */ 793 /* 794 * NFSATTRBIT_SUPPORTED - SUPP0 - bits 0<->31 795 * SUPP1 - bits 32<->63 796 */ 797 #define NFSATTRBIT_SUPP0 \ 798 (NFSATTRBM_SUPPORTEDATTRS | \ 799 NFSATTRBM_TYPE | \ 800 NFSATTRBM_FHEXPIRETYPE | \ 801 NFSATTRBM_CHANGE | \ 802 NFSATTRBM_SIZE | \ 803 NFSATTRBM_LINKSUPPORT | \ 804 NFSATTRBM_SYMLINKSUPPORT | \ 805 NFSATTRBM_NAMEDATTR | \ 806 NFSATTRBM_FSID | \ 807 NFSATTRBM_UNIQUEHANDLES | \ 808 NFSATTRBM_LEASETIME | \ 809 NFSATTRBM_RDATTRERROR | \ 810 NFSATTRBM_ACL | \ 811 NFSATTRBM_ACLSUPPORT | \ 812 NFSATTRBM_CANSETTIME | \ 813 NFSATTRBM_CASEINSENSITIVE | \ 814 NFSATTRBM_CASEPRESERVING | \ 815 NFSATTRBM_CHOWNRESTRICTED | \ 816 NFSATTRBM_FILEHANDLE | \ 817 NFSATTRBM_FILEID | \ 818 NFSATTRBM_FILESAVAIL | \ 819 NFSATTRBM_FILESFREE | \ 820 NFSATTRBM_FILESTOTAL | \ 821 NFSATTRBM_FSLOCATIONS | \ 822 NFSATTRBM_HOMOGENEOUS | \ 823 NFSATTRBM_MAXFILESIZE | \ 824 NFSATTRBM_MAXLINK | \ 825 NFSATTRBM_MAXNAME | \ 826 NFSATTRBM_MAXREAD | \ 827 NFSATTRBM_MAXWRITE) 828 829 /* 830 * NFSATTRBIT_S1 - subset of SUPP1 - OR of the following bits: 831 */ 832 #define NFSATTRBIT_S1 \ 833 (NFSATTRBM_MODE | \ 834 NFSATTRBM_NOTRUNC | \ 835 NFSATTRBM_NUMLINKS | \ 836 NFSATTRBM_OWNER | \ 837 NFSATTRBM_OWNERGROUP | \ 838 NFSATTRBM_RAWDEV | \ 839 NFSATTRBM_SPACEAVAIL | \ 840 NFSATTRBM_SPACEFREE | \ 841 NFSATTRBM_SPACETOTAL | \ 842 NFSATTRBM_SPACEUSED | \ 843 NFSATTRBM_TIMEACCESS | \ 844 NFSATTRBM_TIMEDELTA | \ 845 NFSATTRBM_TIMEMETADATA | \ 846 NFSATTRBM_TIMEMODIFY | \ 847 NFSATTRBM_MOUNTEDONFILEID) 848 849 #ifdef QUOTA 850 /* 851 * If QUOTA OR in NFSATTRBIT_QUOTAHARD, NFSATTRBIT_QUOTASOFT and 852 * NFSATTRBIT_QUOTAUSED. 853 */ 854 #define NFSATTRBIT_SUPP1 (NFSATTRBIT_S1 | \ 855 NFSATTRBM_QUOTAHARD | \ 856 NFSATTRBM_QUOTASOFT | \ 857 NFSATTRBM_QUOTAUSED) 858 #else 859 #define NFSATTRBIT_SUPP1 NFSATTRBIT_S1 860 #endif 861 862 /* 863 * NFSATTRBIT_SUPPSETONLY is the OR of NFSATTRBIT_TIMEACCESSSET and 864 * NFSATTRBIT_TIMEMODIFYSET. 865 */ 866 #define NFSATTRBIT_SUPPSETONLY (NFSATTRBM_TIMEACCESSSET | \ 867 NFSATTRBM_TIMEMODIFYSET) 868 869 /* 870 * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31 871 * SETABLE1 - bits 32<->63 872 */ 873 #define NFSATTRBIT_SETABLE0 \ 874 (NFSATTRBM_SIZE | \ 875 NFSATTRBM_ACL) 876 #define NFSATTRBIT_SETABLE1 \ 877 (NFSATTRBM_MODE | \ 878 NFSATTRBM_OWNER | \ 879 NFSATTRBM_OWNERGROUP | \ 880 NFSATTRBM_TIMEACCESSSET | \ 881 NFSATTRBM_TIMEMODIFYSET) 882 883 /* 884 * Set of attributes that the getattr vnode op needs. 885 * OR of the following bits. 886 * NFSATTRBIT_GETATTR0 - bits 0<->31 887 */ 888 #define NFSATTRBIT_GETATTR0 \ 889 (NFSATTRBM_SUPPORTEDATTRS | \ 890 NFSATTRBM_TYPE | \ 891 NFSATTRBM_CHANGE | \ 892 NFSATTRBM_SIZE | \ 893 NFSATTRBM_FSID | \ 894 NFSATTRBM_FILEID | \ 895 NFSATTRBM_MAXREAD) 896 897 /* 898 * NFSATTRBIT_GETATTR1 - bits 32<->63 899 */ 900 #define NFSATTRBIT_GETATTR1 \ 901 (NFSATTRBM_MODE | \ 902 NFSATTRBM_NUMLINKS | \ 903 NFSATTRBM_OWNER | \ 904 NFSATTRBM_OWNERGROUP | \ 905 NFSATTRBM_RAWDEV | \ 906 NFSATTRBM_SPACEUSED | \ 907 NFSATTRBM_TIMEACCESS | \ 908 NFSATTRBM_TIMEMETADATA | \ 909 NFSATTRBM_TIMEMODIFY) 910 911 /* 912 * Subset of the above that the Write RPC gets. 913 * OR of the following bits. 914 * NFSATTRBIT_WRITEGETATTR0 - bits 0<->31 915 */ 916 #define NFSATTRBIT_WRITEGETATTR0 \ 917 (NFSATTRBM_CHANGE | \ 918 NFSATTRBM_SIZE | \ 919 NFSATTRBM_FSID) 920 921 /* 922 * NFSATTRBIT_WRITEGETATTR1 - bits 32<->63 923 */ 924 #define NFSATTRBIT_WRITEGETATTR1 \ 925 (NFSATTRBM_TIMEMETADATA | \ 926 NFSATTRBM_TIMEMODIFY) 927 928 /* 929 * Set of attributes that the wccattr operation op needs. 930 * OR of the following bits. 931 * NFSATTRBIT_WCCATTR0 - bits 0<->31 932 */ 933 #define NFSATTRBIT_WCCATTR0 0 934 935 /* 936 * NFSATTRBIT_WCCATTR1 - bits 32<->63 937 */ 938 #define NFSATTRBIT_WCCATTR1 \ 939 (NFSATTRBM_TIMEMODIFY) 940 941 /* 942 * NFSATTRBIT_CBGETATTR0 - bits 0<->31 943 */ 944 #define NFSATTRBIT_CBGETATTR0 (NFSATTRBM_CHANGE | NFSATTRBM_SIZE) 945 946 /* 947 * NFSATTRBIT_CBGETATTR1 - bits 32<->63 948 */ 949 #define NFSATTRBIT_CBGETATTR1 0x0 950 951 /* 952 * Sets of attributes that require a VFS_STATFS() call to get the 953 * values of. 954 * NFSATTRBIT_STATFS0 - bits 0<->31 955 */ 956 #define NFSATTRBIT_STATFS0 \ 957 (NFSATTRBM_LINKSUPPORT | \ 958 NFSATTRBM_SYMLINKSUPPORT | \ 959 NFSATTRBM_CANSETTIME | \ 960 NFSATTRBM_FILESAVAIL | \ 961 NFSATTRBM_FILESFREE | \ 962 NFSATTRBM_FILESTOTAL | \ 963 NFSATTRBM_HOMOGENEOUS | \ 964 NFSATTRBM_MAXFILESIZE | \ 965 NFSATTRBM_MAXNAME | \ 966 NFSATTRBM_MAXREAD | \ 967 NFSATTRBM_MAXWRITE) 968 969 /* 970 * NFSATTRBIT_STATFS1 - bits 32<->63 971 */ 972 #define NFSATTRBIT_STATFS1 \ 973 (NFSATTRBM_QUOTAHARD | \ 974 NFSATTRBM_QUOTASOFT | \ 975 NFSATTRBM_QUOTAUSED | \ 976 NFSATTRBM_SPACEAVAIL | \ 977 NFSATTRBM_SPACEFREE | \ 978 NFSATTRBM_SPACETOTAL | \ 979 NFSATTRBM_SPACEUSED | \ 980 NFSATTRBM_TIMEDELTA) 981 982 /* 983 * These are the bits that are needed by the nfs_statfs() call. 984 * (The regular getattr bits are or'd in so the vnode gets the correct 985 * type, etc.) 986 * NFSGETATTRBIT_STATFS0 - bits 0<->31 987 */ 988 #define NFSGETATTRBIT_STATFS0 (NFSATTRBIT_GETATTR0 | \ 989 NFSATTRBM_LINKSUPPORT | \ 990 NFSATTRBM_SYMLINKSUPPORT | \ 991 NFSATTRBM_CANSETTIME | \ 992 NFSATTRBM_FILESFREE | \ 993 NFSATTRBM_FILESTOTAL | \ 994 NFSATTRBM_HOMOGENEOUS | \ 995 NFSATTRBM_MAXFILESIZE | \ 996 NFSATTRBM_MAXNAME | \ 997 NFSATTRBM_MAXREAD | \ 998 NFSATTRBM_MAXWRITE) 999 1000 /* 1001 * NFSGETATTRBIT_STATFS1 - bits 32<->63 1002 */ 1003 #define NFSGETATTRBIT_STATFS1 (NFSATTRBIT_GETATTR1 | \ 1004 NFSATTRBM_SPACEAVAIL | \ 1005 NFSATTRBM_SPACEFREE | \ 1006 NFSATTRBM_SPACETOTAL | \ 1007 NFSATTRBM_TIMEDELTA) 1008 1009 /* 1010 * Set of attributes for the equivalent of an nfsv3 pathconf rpc. 1011 * NFSGETATTRBIT_PATHCONF0 - bits 0<->31 1012 */ 1013 #define NFSGETATTRBIT_PATHCONF0 (NFSATTRBIT_GETATTR0 | \ 1014 NFSATTRBM_CASEINSENSITIVE | \ 1015 NFSATTRBM_CASEPRESERVING | \ 1016 NFSATTRBM_CHOWNRESTRICTED | \ 1017 NFSATTRBM_MAXLINK | \ 1018 NFSATTRBM_MAXNAME) 1019 1020 /* 1021 * NFSGETATTRBIT_PATHCONF1 - bits 32<->63 1022 */ 1023 #define NFSGETATTRBIT_PATHCONF1 (NFSATTRBIT_GETATTR1 | \ 1024 NFSATTRBM_NOTRUNC) 1025 1026 /* 1027 * Sets of attributes required by readdir and readdirplus. 1028 * NFSATTRBIT_READDIRPLUS0 (NFSATTRBIT_GETATTR0 | NFSATTRBIT_FILEHANDLE | 1029 * NFSATTRBIT_RDATTRERROR) 1030 */ 1031 #define NFSATTRBIT_READDIRPLUS0 (NFSATTRBIT_GETATTR0 | NFSATTRBM_FILEHANDLE | \ 1032 NFSATTRBM_RDATTRERROR) 1033 #define NFSATTRBIT_READDIRPLUS1 NFSATTRBIT_GETATTR1 1034 1035 /* 1036 * Set of attributes supported by Referral vnodes. 1037 */ 1038 #define NFSATTRBIT_REFERRAL0 (NFSATTRBM_TYPE | NFSATTRBM_FSID | \ 1039 NFSATTRBM_RDATTRERROR | NFSATTRBM_FSLOCATIONS) 1040 #define NFSATTRBIT_REFERRAL1 NFSATTRBM_MOUNTEDONFILEID 1041 1042 /* 1043 * Structure for data handled by the statfs rpc. Since some fields are 1044 * u_int64_t, this cannot be used for copying data on/off the wire, due 1045 * to alignment concerns. 1046 */ 1047 struct nfsstatfs { 1048 union { 1049 struct { 1050 u_int32_t nfsv2sf_tsize; 1051 u_int32_t nfsv2sf_bsize; 1052 u_int32_t nfsv2sf_blocks; 1053 u_int32_t nfsv2sf_bfree; 1054 u_int32_t nfsv2sf_bavail; 1055 } sf_nfsv2; 1056 struct { 1057 u_int64_t nfsv3sf_tbytes; 1058 u_int64_t nfsv3sf_fbytes; 1059 u_int64_t nfsv3sf_abytes; 1060 u_int64_t nfsv3sf_tfiles; 1061 u_int64_t nfsv3sf_ffiles; 1062 u_int64_t nfsv3sf_afiles; 1063 u_int32_t nfsv3sf_invarsec; 1064 } sf_nfsv3; 1065 } sf_un; 1066 }; 1067 1068 #define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize 1069 #define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize 1070 #define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks 1071 #define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree 1072 #define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail 1073 #define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes 1074 #define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes 1075 #define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes 1076 #define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles 1077 #define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles 1078 #define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles 1079 #define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec 1080 1081 /* 1082 * Now defined using u_int64_t for the 64 bit field(s). 1083 * (Cannot be used to move data on/off the wire, due to alignment concerns.) 1084 */ 1085 struct nfsfsinfo { 1086 u_int32_t fs_rtmax; 1087 u_int32_t fs_rtpref; 1088 u_int32_t fs_rtmult; 1089 u_int32_t fs_wtmax; 1090 u_int32_t fs_wtpref; 1091 u_int32_t fs_wtmult; 1092 u_int32_t fs_dtpref; 1093 u_int64_t fs_maxfilesize; 1094 struct timespec fs_timedelta; 1095 u_int32_t fs_properties; 1096 }; 1097 1098 /* 1099 * Bits for fs_properties 1100 */ 1101 #define NFSV3_FSFLINK 0x1 1102 #define NFSV3_FSFSYMLINK 0x2 1103 #define NFSV3_FSFHOMOGENEOUS 0x4 1104 #define NFSV3_FSFCANSETTIME 0x8 1105 1106 /* 1107 * Yikes, overload fs_rtmult as fs_maxname for V4. 1108 */ 1109 #define fs_maxname fs_rtmult 1110 1111 struct nfsv3_pathconf { 1112 u_int32_t pc_linkmax; 1113 u_int32_t pc_namemax; 1114 u_int32_t pc_notrunc; 1115 u_int32_t pc_chownrestricted; 1116 u_int32_t pc_caseinsensitive; 1117 u_int32_t pc_casepreserving; 1118 }; 1119 1120 /* 1121 * NFS V4 data structures. 1122 */ 1123 struct nfsv4stateid { 1124 u_int32_t seqid; 1125 u_int32_t other[NFSX_STATEIDOTHER / NFSX_UNSIGNED]; 1126 }; 1127 typedef struct nfsv4stateid nfsv4stateid_t; 1128 1129 #endif /* _NFS_NFSPROTO_H_ */ 1130