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