xref: /freebsd/sys/fs/nfs/nfsproto.h (revision b92b9da3300655c86dcd42ea8a5ba45badd90847)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1989, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Rick Macklem at The University of Guelph.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
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 /*
60  * Calculating the maximum XDR overhead for an NFS RPC isn't easy.
61  * NFS_MAXPKTHDR is antiquated and assumes AUTH_SYS over UDP.
62  * NFS_MAXXDR should be sufficient for all NFS versions over TCP.
63  * It includes:
64  * - Maximum RPC message header. It can include 2 400byte authenticators plus
65  *   a machine name of unlimited length, although it is usually relatively
66  *   small.
67  * - XDR overheads for the NFSv4 compound. This can include Owner and
68  *   Owner_group strings, which are usually fairly small, but are allowed
69  *   to be up to 1024 bytes each.
70  * 4096 is overkill, but should always be sufficient.
71  */
72 #define	NFS_MAXPKTHDR	404
73 #define	NFS_MAXXDR	4096
74 #define	NFS_MINPACKET	20
75 #define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
76 #define	NFSV4_MINORVERSION	0	/* V4 Minor version */
77 #define	NFSV41_MINORVERSION	1	/* V4 Minor version */
78 #define	NFSV42_MINORVERSION	2	/* V4 Minor version */
79 #define	NFSV4_CBVERS		1	/* V4 CB Version */
80 #define	NFSV41_CBVERS		4	/* V4.1 CB Version */
81 #define	NFSV4_SMALLSTR	50		/* Strings small enough for stack */
82 
83 /*
84  * This value isn't a fixed value in the RFCs.
85  * It is the maximum data size supported by NFSv3 or NFSv4 over TCP for
86  * the server.  It should be set to the I/O size preferred by ZFS or
87  * MAXBSIZE, whichever is greater.
88  * ZFS currently prefers 128K.
89  * It used to be called NFS_MAXDATA, but has been renamed to clarify that
90  * it refers to server side only and doesn't conflict with the NFS_MAXDATA
91  * defined in rpcsvc/nfs_prot.h for userland.
92  * NFS_SRVMAXIO is the default setting for vfs.nfsd.srvmaxio
93  * NFS_SRVLIMITIO is the maximum setting allowed for vfs.nfsd.srvmaxio
94  */
95 #define	NFS_SRVMAXIO	(128 * 1024)
96 #define	NFS_SRVLIMITIO	(4 * 1024 * 1024)
97 
98 /* Stat numbers for rpc returns (version 2, 3 and 4) */
99 /*
100  * These numbers are hard-wired in the RFCs, so they can't be changed.
101  * The code currently assumes that the ones < 10000 are the same as
102  * sys/errno.h and that sys/errno.h will never go as high as 10000.
103  * If the value in sys/errno.h of any entry listed below is changed,
104  * the NFS code must be modified to do the mapping between them.
105  * (You can ignore NFSERR_WFLUSH, since it is never actually used.)
106  */
107 #define	NFSERR_OK		0
108 #define	NFSERR_PERM		1
109 #define	NFSERR_NOENT		2
110 #define	NFSERR_IO		5
111 #define	NFSERR_NXIO		6
112 #define	NFSERR_ACCES		13
113 #define	NFSERR_EXIST		17
114 #define	NFSERR_XDEV		18	/* Version 3, 4 only */
115 #define	NFSERR_NODEV		19
116 #define	NFSERR_NOTDIR		20
117 #define	NFSERR_ISDIR		21
118 #define	NFSERR_INVAL		22	/* Version 3, 4 only */
119 #define	NFSERR_FBIG		27
120 #define	NFSERR_NOSPC		28
121 #define	NFSERR_ROFS		30
122 #define	NFSERR_MLINK		31	/* Version 3, 4 only */
123 #define	NFSERR_NAMETOL		63
124 #define	NFSERR_NOTEMPTY		66
125 #define	NFSERR_DQUOT		69
126 #define	NFSERR_STALE		70
127 #define	NFSERR_REMOTE		71	/* Version 3 only */
128 #define	NFSERR_WFLUSH		99	/* Version 2 only */
129 #define	NFSERR_BADHANDLE	10001	/* These are Version 3, 4 only */
130 #define	NFSERR_NOT_SYNC		10002	/* Version 3 Only */
131 #define	NFSERR_BAD_COOKIE	10003
132 #define	NFSERR_NOTSUPP		10004
133 #define	NFSERR_TOOSMALL		10005
134 #define	NFSERR_SERVERFAULT	10006
135 #define	NFSERR_BADTYPE		10007
136 #define	NFSERR_DELAY		10008	/* Called NFSERR_JUKEBOX for V3 */
137 #define	NFSERR_SAME		10009	/* These are Version 4 only */
138 #define	NFSERR_DENIED		10010
139 #define	NFSERR_EXPIRED		10011
140 #define	NFSERR_LOCKED		10012
141 #define	NFSERR_GRACE		10013
142 #define	NFSERR_FHEXPIRED	10014
143 #define	NFSERR_SHAREDENIED	10015
144 #define	NFSERR_WRONGSEC		10016
145 #define	NFSERR_CLIDINUSE	10017
146 #define	NFSERR_RESOURCE		10018
147 #define	NFSERR_MOVED		10019
148 #define	NFSERR_NOFILEHANDLE	10020
149 #define	NFSERR_MINORVERMISMATCH	10021
150 #define	NFSERR_STALECLIENTID	10022
151 #define	NFSERR_STALESTATEID	10023
152 #define	NFSERR_OLDSTATEID	10024
153 #define	NFSERR_BADSTATEID	10025
154 #define	NFSERR_BADSEQID		10026
155 #define	NFSERR_NOTSAME		10027
156 #define	NFSERR_LOCKRANGE	10028
157 #define	NFSERR_SYMLINK		10029
158 #define	NFSERR_RESTOREFH	10030
159 #define	NFSERR_LEASEMOVED	10031
160 #define	NFSERR_ATTRNOTSUPP	10032
161 #define	NFSERR_NOGRACE		10033
162 #define	NFSERR_RECLAIMBAD	10034
163 #define	NFSERR_RECLAIMCONFLICT	10035
164 #define	NFSERR_BADXDR		10036
165 #define	NFSERR_LOCKSHELD	10037
166 #define	NFSERR_OPENMODE		10038
167 #define	NFSERR_BADOWNER		10039
168 #define	NFSERR_BADCHAR		10040
169 #define	NFSERR_BADNAME		10041
170 #define	NFSERR_BADRANGE		10042
171 #define	NFSERR_LOCKNOTSUPP	10043
172 #define	NFSERR_OPILLEGAL	10044
173 #define	NFSERR_DEADLOCK		10045
174 #define	NFSERR_FILEOPEN		10046
175 #define	NFSERR_ADMINREVOKED	10047
176 #define	NFSERR_CBPATHDOWN	10048
177 
178 /* NFSv4.1 specific errors. */
179 #define	NFSERR_BADIOMODE	10049
180 #define	NFSERR_BADLAYOUT	10050
181 #define	NFSERR_BADSESSIONDIGEST	10051
182 #define	NFSERR_BADSESSION	10052
183 #define	NFSERR_BADSLOT		10053
184 #define	NFSERR_COMPLETEALREADY	10054
185 #define	NFSERR_NOTBNDTOSESS	10055
186 #define	NFSERR_DELEGALREADYWANT	10056
187 #define	NFSERR_BACKCHANBUSY	10057
188 #define	NFSERR_LAYOUTTRYLATER	10058
189 #define	NFSERR_LAYOUTUNAVAIL	10059
190 #define	NFSERR_NOMATCHLAYOUT	10060
191 #define	NFSERR_RECALLCONFLICT	10061
192 #define	NFSERR_UNKNLAYOUTTYPE	10062
193 #define	NFSERR_SEQMISORDERED	10063
194 #define	NFSERR_SEQUENCEPOS	10064
195 #define	NFSERR_REQTOOBIG	10065
196 #define	NFSERR_REPTOOBIG	10066
197 #define	NFSERR_REPTOOBIGTOCACHE	10067
198 #define	NFSERR_RETRYUNCACHEDREP	10068
199 #define	NFSERR_UNSAFECOMPOUND	10069
200 #define	NFSERR_TOOMANYOPS	10070
201 #define	NFSERR_OPNOTINSESS	10071
202 #define	NFSERR_HASHALGUNSUPP	10072
203 #define	NFSERR_CLIENTIDBUSY	10074
204 #define	NFSERR_PNFSIOHOLE	10075
205 #define	NFSERR_SEQFALSERETRY	10076
206 #define	NFSERR_BADHIGHSLOT	10077
207 #define	NFSERR_DEADSESSION	10078
208 #define	NFSERR_ENCRALGUNSUPP	10079
209 #define	NFSERR_PNFSNOLAYOUT	10080
210 #define	NFSERR_NOTONLYOP	10081
211 #define	NFSERR_WRONGCRED	10082
212 #define	NFSERR_WRONGTYPE	10083
213 #define	NFSERR_DIRDELEGUNAVAIL	10084
214 #define	NFSERR_REJECTDELEG	10085
215 #define	NFSERR_RETURNCONFLICT	10086
216 #define	NFSERR_DELEGREVOKED	10087
217 
218 /* NFSv4.2 specific errors. */
219 #define	NFSERR_PARTNERNOTSUPP	10088
220 #define	NFSERR_PARTNERNOAUTH	10089
221 #define	NFSERR_UNIONNOTSUPP	10090
222 #define	NFSERR_OFFLOADDENIED	10091
223 #define	NFSERR_WRONGLFS		10092
224 #define	NFSERR_BADLABEL		10093
225 #define	NFSERR_OFFLOADNOREQS	10094
226 
227 /* NFSv4.2 Extended Attribute errors. */
228 #define	NFSERR_NOXATTR		10095
229 #define	NFSERR_XATTR2BIG	10096
230 
231 /* Maximum value of all the NFS error values. */
232 #define	NFSERR_MAXERRVAL	NFSERR_XATTR2BIG
233 
234 #define	NFSERR_STALEWRITEVERF	30001	/* Fake return for nfs_commit() */
235 #define	NFSERR_DONTREPLY	30003	/* Don't process request */
236 #define	NFSERR_RETVOID		30004	/* Return void, not error */
237 #define	NFSERR_REPLYFROMCACHE	30005	/* Reply from recent request cache */
238 #define	NFSERR_STALEDONTRECOVER	30006	/* Don't initiate recovery */
239 
240 #define	NFSERR_RPCERR		0x40000000 /* Mark an RPC layer error */
241 #define	NFSERR_AUTHERR		0x80000000 /* Mark an authentication error */
242 
243 #define	NFSERR_RPCMISMATCH	(NFSERR_RPCERR | RPC_MISMATCH)
244 #define	NFSERR_PROGUNAVAIL	(NFSERR_RPCERR | RPC_PROGUNAVAIL)
245 #define	NFSERR_PROGMISMATCH	(NFSERR_RPCERR | RPC_PROGMISMATCH)
246 #define	NFSERR_PROGNOTV4	(NFSERR_RPCERR | 0xffff)
247 #define	NFSERR_PROCUNAVAIL	(NFSERR_RPCERR | RPC_PROCUNAVAIL)
248 #define	NFSERR_GARBAGE		(NFSERR_RPCERR | RPC_GARBAGE)
249 
250 /* Sizes in bytes of various nfs rpc components */
251 #define	NFSX_UNSIGNED	4
252 #define	NFSX_HYPER	(2 * NFSX_UNSIGNED)
253 
254 /* specific to NFS Version 2 */
255 #define	NFSX_V2FH	32
256 #define	NFSX_V2FATTR	68
257 #define	NFSX_V2SATTR	32
258 #define	NFSX_V2COOKIE	4
259 #define	NFSX_V2STATFS	20
260 
261 /* specific to NFS Version 3 */
262 #define	NFSX_V3FHMAX		64	/* max. allowed by protocol */
263 #define	NFSX_V3FATTR		84
264 #define	NFSX_V3SATTR		60	/* max. all fields filled in */
265 #define	NFSX_V3SRVSATTR		(sizeof (struct nfsv3_sattr))
266 #define	NFSX_V3POSTOPATTR	(NFSX_V3FATTR + NFSX_UNSIGNED)
267 #define	NFSX_V3WCCDATA		(NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
268 #define	NFSX_V3STATFS		52
269 #define	NFSX_V3FSINFO		48
270 #define	NFSX_V3PATHCONF		24
271 
272 /* specific to NFS Version 4 */
273 #define	NFSX_V4FHMAX		128
274 #define	NFSX_V4FSID		(2 * NFSX_HYPER)
275 #define	NFSX_V4SPECDATA		(2 * NFSX_UNSIGNED)
276 #define	NFSX_V4TIME		(NFSX_HYPER + NFSX_UNSIGNED)
277 #define	NFSX_V4SETTIME		(NFSX_UNSIGNED + NFSX_V4TIME)
278 #define	NFSX_V4SESSIONID	16
279 #define	NFSX_V4DEVICEID		16
280 #define	NFSX_V4PNFSFH		(sizeof(fhandle_t) + 1)
281 #define	NFSX_V4NAMEDDIRFH	2
282 #define	NFSX_V4NAMEDATTRFH	3
283 #define	NFSX_V4FILELAYOUT	(4 * NFSX_UNSIGNED + NFSX_V4DEVICEID +	\
284 				 NFSX_HYPER + NFSM_RNDUP(NFSX_V4PNFSFH))
285 #define	NFSX_V4FLEXLAYOUT(m)	(NFSX_HYPER + 3 * NFSX_UNSIGNED +		\
286     ((m) * (NFSX_V4DEVICEID + NFSX_STATEID + NFSM_RNDUP(NFSX_V4PNFSFH) +	\
287     8 * NFSX_UNSIGNED)))
288 
289 /* sizes common to multiple NFS versions */
290 #define	NFSX_FHMAX		(NFSX_V4FHMAX)
291 #define	NFSX_MYFH		(sizeof (fhandle_t)) /* size this server uses */
292 #define	NFSX_VERF 		8
293 #define	NFSX_STATEIDOTHER	12
294 #define	NFSX_STATEID		(NFSX_UNSIGNED + NFSX_STATEIDOTHER)
295 #define	NFSX_GSSH		12
296 
297 /* variants for multiple versions */
298 #define	NFSX_STATFS(v3)		((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
299 
300 /*
301  * Beware.  NFSPROC_NULL and friends are defined in
302  * <rpcsvc/nfs_prot.h> as well and the numbers are different.
303  */
304 #ifndef	NFSPROC_NULL
305 /* nfs rpc procedure numbers (before version mapping) */
306 #define	NFSPROC_NULL		0
307 #define	NFSPROC_GETATTR		1
308 #define	NFSPROC_SETATTR		2
309 #define	NFSPROC_LOOKUP		3
310 #define	NFSPROC_ACCESS		4
311 #define	NFSPROC_READLINK	5
312 #define	NFSPROC_READ		6
313 #define	NFSPROC_WRITE		7
314 #define	NFSPROC_CREATE		8
315 #define	NFSPROC_MKDIR		9
316 #define	NFSPROC_SYMLINK		10
317 #define	NFSPROC_MKNOD		11
318 #define	NFSPROC_REMOVE		12
319 #define	NFSPROC_RMDIR		13
320 #define	NFSPROC_RENAME		14
321 #define	NFSPROC_LINK		15
322 #define	NFSPROC_READDIR		16
323 #define	NFSPROC_READDIRPLUS	17
324 #define	NFSPROC_FSSTAT		18
325 #define	NFSPROC_FSINFO		19
326 #define	NFSPROC_PATHCONF	20
327 #define	NFSPROC_COMMIT		21
328 #endif	/* NFSPROC_NULL */
329 
330 /*
331  * The lower numbers -> 21 are used by NFSv2 and v3. These define higher
332  * numbers used by NFSv4.
333  * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is
334  * one greater than the last number.
335  */
336 #ifndef	NFS_V3NPROCS
337 #define	NFS_V3NPROCS		22
338 
339 #define	NFSPROC_LOOKUPP		22
340 #define	NFSPROC_SETCLIENTID	23
341 #define	NFSPROC_SETCLIENTIDCFRM	24
342 #define	NFSPROC_LOCK		25
343 #define	NFSPROC_LOCKU		26
344 #define	NFSPROC_OPEN		27
345 #define	NFSPROC_CLOSE		28
346 #define	NFSPROC_OPENCONFIRM	29
347 #define	NFSPROC_LOCKT		30
348 #define	NFSPROC_OPENDOWNGRADE	31
349 #define	NFSPROC_RENEW		32
350 #define	NFSPROC_PUTROOTFH	33
351 #define	NFSPROC_RELEASELCKOWN	34
352 #define	NFSPROC_DELEGRETURN	35
353 #define	NFSPROC_RETDELEGREMOVE	36
354 #define	NFSPROC_RETDELEGRENAME1	37
355 #define	NFSPROC_RETDELEGRENAME2	38
356 #define	NFSPROC_GETACL		39
357 #define	NFSPROC_SETACL		40
358 
359 /*
360  * Must be defined as one higher than the last Proc# above.
361  */
362 #define	NFSV4_NPROCS		41
363 
364 /* Additional procedures for NFSv4.1. */
365 #define	NFSPROC_EXCHANGEID	41
366 #define	NFSPROC_CREATESESSION	42
367 #define	NFSPROC_DESTROYSESSION	43
368 #define	NFSPROC_DESTROYCLIENT	44
369 #define	NFSPROC_FREESTATEID	45
370 #define	NFSPROC_LAYOUTGET	46
371 #define	NFSPROC_GETDEVICEINFO	47
372 #define	NFSPROC_LAYOUTCOMMIT	48
373 #define	NFSPROC_LAYOUTRETURN	49
374 #define	NFSPROC_RECLAIMCOMPL	50
375 #define	NFSPROC_WRITEDS		51
376 #define	NFSPROC_READDS		52
377 #define	NFSPROC_COMMITDS	53
378 #define	NFSPROC_OPENLAYGET	54
379 #define	NFSPROC_CREATELAYGET	55
380 
381 /*
382  * Must be defined as one higher than the last NFSv4.1 Proc# above.
383  */
384 #define	NFSV41_NPROCS		56
385 
386 /* Additional procedures for NFSv4.2. */
387 #define	NFSPROC_IOADVISE	56
388 #define	NFSPROC_ALLOCATE	57
389 #define	NFSPROC_COPY		58
390 #define	NFSPROC_SEEK		59
391 #define	NFSPROC_SEEKDS		60
392 
393 /* and the ones for the optional Extended attribute support (RFC-8276). */
394 #define	NFSPROC_GETEXTATTR	61
395 #define	NFSPROC_SETEXTATTR	62
396 #define	NFSPROC_RMEXTATTR	63
397 #define	NFSPROC_LISTEXTATTR	64
398 
399 /* BindConnectionToSession, done by the krpc for a new connection. */
400 #define	NFSPROC_BINDCONNTOSESS	65
401 
402 /* Do a Lookup+Open for "oneopenown". */
403 #define	NFSPROC_LOOKUPOPEN	66
404 
405 /* Do an NFSv4.2 Deallocate. */
406 #define	NFSPROC_DEALLOCATE	67
407 
408 /* Do an NFSv4.2 LayoutError. */
409 #define	NFSPROC_LAYOUTERROR	68
410 
411 /* Do an NFSv4 Verify+Write. */
412 #define	NFSPROC_APPENDWRITE	69
413 
414 /* Do a NFSv4 Openattr. */
415 #define	NFSPROC_OPENATTR	70
416 
417 /* Do a NFSv4.2 Clone. */
418 #define	NFSPROC_CLONE		71
419 
420 /*
421  * Must be defined as one higher than the last NFSv4.2 Proc# above.
422  */
423 #define	NFSV42_NPROCS		72
424 
425 /* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */
426 #define	NFSV42_OLDNPROCS	69
427 
428 #endif	/* NFS_V3NPROCS */
429 
430 /*
431  * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code.
432  */
433 #ifndef	NFS_NPROCS
434 #define	NFS_NPROCS		NFSV4_NPROCS
435 #endif
436 
437 /*
438  * NFSPROC_NOOP is a fake op# that can't be the same as any V2/3/4 Procedure
439  * or Operation#. Since the NFS V4 Op #s go higher, use NFSV42_NOPS, which
440  * is one greater than the highest Op#.
441  */
442 #define	NFSPROC_NOOP		NFSV42_NOPS
443 
444 /* Actual Version 2 procedure numbers */
445 #define	NFSV2PROC_NULL		0
446 #define	NFSV2PROC_GETATTR	1
447 #define	NFSV2PROC_SETATTR	2
448 #define	NFSV2PROC_NOOP		3
449 #define	NFSV2PROC_ROOT		NFSV2PROC_NOOP	/* Obsolete */
450 #define	NFSV2PROC_LOOKUP	4
451 #define	NFSV2PROC_READLINK	5
452 #define	NFSV2PROC_READ		6
453 #define	NFSV2PROC_WRITECACHE	NFSV2PROC_NOOP	/* Obsolete */
454 #define	NFSV2PROC_WRITE		8
455 #define	NFSV2PROC_CREATE	9
456 #define	NFSV2PROC_REMOVE	10
457 #define	NFSV2PROC_RENAME	11
458 #define	NFSV2PROC_LINK		12
459 #define	NFSV2PROC_SYMLINK	13
460 #define	NFSV2PROC_MKDIR		14
461 #define	NFSV2PROC_RMDIR		15
462 #define	NFSV2PROC_READDIR	16
463 #define	NFSV2PROC_STATFS	17
464 
465 /*
466  * V4 Procedure numbers
467  */
468 #define	NFSV4PROC_COMPOUND	1
469 #define	NFSV4PROC_CBNULL	0
470 #define	NFSV4PROC_CBCOMPOUND	1
471 
472 /*
473  * Constants used by the Version 3 and 4 protocols for various RPCs
474  */
475 #define	NFSV3SATTRTIME_DONTCHANGE	0
476 #define	NFSV3SATTRTIME_TOSERVER		1
477 #define	NFSV3SATTRTIME_TOCLIENT		2
478 
479 #define	NFSV4SATTRTIME_TOSERVER		0
480 #define	NFSV4SATTRTIME_TOCLIENT		1
481 
482 #define	NFSV4LOCKT_READ			1
483 #define	NFSV4LOCKT_WRITE		2
484 #define	NFSV4LOCKT_READW		3
485 #define	NFSV4LOCKT_WRITEW		4
486 #define	NFSV4LOCKT_RELEASE		5
487 
488 #define	NFSV4OPEN_NOCREATE		0
489 #define	NFSV4OPEN_CREATE		1
490 #define	NFSV4OPEN_CLAIMNULL		0
491 #define	NFSV4OPEN_CLAIMPREVIOUS		1
492 #define	NFSV4OPEN_CLAIMDELEGATECUR	2
493 #define	NFSV4OPEN_CLAIMDELEGATEPREV	3
494 #define	NFSV4OPEN_CLAIMFH		4
495 #define	NFSV4OPEN_CLAIMDELEGATECURFH	5
496 #define	NFSV4OPEN_CLAIMDELEGATEPREVFH	6
497 #define	NFSV4OPEN_DELEGATENONE		0
498 #define	NFSV4OPEN_DELEGATEREAD		1
499 #define	NFSV4OPEN_DELEGATEWRITE		2
500 #define	NFSV4OPEN_DELEGATENONEEXT	3
501 #define	NFSV4OPEN_LIMITSIZE		1
502 #define	NFSV4OPEN_LIMITBLOCKS		2
503 
504 /*
505  * Nfs V4 ACE stuff
506  */
507 #define	NFSV4ACE_ALLOWEDTYPE		0x00000000
508 #define	NFSV4ACE_DENIEDTYPE		0x00000001
509 #define	NFSV4ACE_AUDITTYPE		0x00000002
510 #define	NFSV4ACE_ALARMTYPE		0x00000003
511 
512 #define	NFSV4ACE_SUPALLOWED		0x00000001
513 #define	NFSV4ACE_SUPDENIED		0x00000002
514 #define	NFSV4ACE_SUPAUDIT		0x00000004
515 #define	NFSV4ACE_SUPALARM		0x00000008
516 
517 #define	NFSV4ACE_SUPTYPES	(NFSV4ACE_SUPALLOWED | NFSV4ACE_SUPDENIED)
518 
519 #define	NFSV4ACE_FILEINHERIT		0x00000001
520 #define	NFSV4ACE_DIRECTORYINHERIT	0x00000002
521 #define	NFSV4ACE_NOPROPAGATEINHERIT	0x00000004
522 #define	NFSV4ACE_INHERITONLY		0x00000008
523 #define	NFSV4ACE_SUCCESSFULACCESS	0x00000010
524 #define	NFSV4ACE_FAILEDACCESS		0x00000020
525 #define	NFSV4ACE_IDENTIFIERGROUP	0x00000040
526 
527 #define	NFSV4ACE_READDATA		0x00000001
528 #define	NFSV4ACE_LISTDIRECTORY		0x00000001
529 #define	NFSV4ACE_WRITEDATA		0x00000002
530 #define	NFSV4ACE_ADDFILE		0x00000002
531 #define	NFSV4ACE_APPENDDATA		0x00000004
532 #define	NFSV4ACE_ADDSUBDIRECTORY	0x00000004
533 #define	NFSV4ACE_READNAMEDATTR		0x00000008
534 #define	NFSV4ACE_WRITENAMEDATTR		0x00000010
535 #define	NFSV4ACE_EXECUTE		0x00000020
536 #define	NFSV4ACE_SEARCH			0x00000020
537 #define	NFSV4ACE_DELETECHILD		0x00000040
538 #define	NFSV4ACE_READATTRIBUTES		0x00000080
539 #define	NFSV4ACE_WRITEATTRIBUTES	0x00000100
540 #define	NFSV4ACE_DELETE			0x00010000
541 #define	NFSV4ACE_READACL		0x00020000
542 #define	NFSV4ACE_WRITEACL		0x00040000
543 #define	NFSV4ACE_WRITEOWNER		0x00080000
544 #define	NFSV4ACE_SYNCHRONIZE		0x00100000
545 
546 /*
547  * Here are the mappings between mode bits and acl mask bits for
548  * directories and other files.
549  * (Named attributes have not been included, since named attributes are
550  *  not yet supported.)
551  * The mailing list seems to indicate that NFSV4ACE_EXECUTE refers to
552  * searching a directory, although I can't find a statement of that in
553  * the RFC.
554  */
555 #define	NFSV4ACE_ALLFILESMASK	(NFSV4ACE_READATTRIBUTES | NFSV4ACE_READACL)
556 #define	NFSV4ACE_OWNERMASK	(NFSV4ACE_WRITEATTRIBUTES | NFSV4ACE_WRITEACL)
557 #define	NFSV4ACE_DIRREADMASK	NFSV4ACE_LISTDIRECTORY
558 #define	NFSV4ACE_DIREXECUTEMASK	NFSV4ACE_EXECUTE
559 #define	NFSV4ACE_DIRWRITEMASK	(NFSV4ACE_ADDFILE | 			\
560 		NFSV4ACE_ADDSUBDIRECTORY | NFSV4ACE_DELETECHILD)
561 #define	NFSV4ACE_READMASK	NFSV4ACE_READDATA
562 #define	NFSV4ACE_WRITEMASK	(NFSV4ACE_WRITEDATA | NFSV4ACE_APPENDDATA)
563 #define	NFSV4ACE_EXECUTEMASK	NFSV4ACE_EXECUTE
564 #define	NFSV4ACE_ALLFILEBITS	(NFSV4ACE_READMASK | NFSV4ACE_WRITEMASK | \
565 	NFSV4ACE_EXECUTEMASK | NFSV4ACE_SYNCHRONIZE)
566 #define	NFSV4ACE_ALLDIRBITS	(NFSV4ACE_DIRREADMASK | 		\
567 	NFSV4ACE_DIRWRITEMASK | NFSV4ACE_DIREXECUTEMASK)
568 #define	NFSV4ACE_AUDITMASK	0x0
569 
570 /*
571  * These GENERIC masks are not used and are no longer believed to be useful.
572  */
573 #define	NFSV4ACE_GENERICREAD		0x00120081
574 #define	NFSV4ACE_GENERICWRITE		0x00160106
575 #define	NFSV4ACE_GENERICEXECUTE		0x001200a0
576 
577 #define	NFSSTATEID_PUTALLZERO		0
578 #define	NFSSTATEID_PUTALLONE		1
579 #define	NFSSTATEID_PUTSTATEID		2
580 #define	NFSSTATEID_PUTSEQIDZERO		3
581 
582 /*
583  * Bits for share access and deny.
584  */
585 #define	NFSV4OPEN_ACCESSREAD		0x00000001
586 #define	NFSV4OPEN_ACCESSWRITE		0x00000002
587 #define	NFSV4OPEN_ACCESSBOTH		0x00000003
588 #define	NFSV4OPEN_WANTDELEGMASK		0x0000ff00
589 #define	NFSV4OPEN_WANTREADDELEG		0x00000100
590 #define	NFSV4OPEN_WANTWRITEDELEG	0x00000200
591 #define	NFSV4OPEN_WANTANYDELEG		0x00000300
592 #define	NFSV4OPEN_WANTNODELEG		0x00000400
593 #define	NFSV4OPEN_WANTCANCEL		0x00000500
594 #define	NFSV4OPEN_WANTSIGNALDELEG	0x00010000
595 #define	NFSV4OPEN_WANTPUSHDELEG		0x00020000
596 
597 #define	NFSV4OPEN_DENYNONE		0x00000000
598 #define	NFSV4OPEN_DENYREAD		0x00000001
599 #define	NFSV4OPEN_DENYWRITE		0x00000002
600 #define	NFSV4OPEN_DENYBOTH		0x00000003
601 
602 /*
603  * Delegate_none_ext reply values.
604  */
605 #define	NFSV4OPEN_NOTWANTED		0
606 #define	NFSV4OPEN_CONTENTION		1
607 #define	NFSV4OPEN_RESOURCE		2
608 #define	NFSV4OPEN_NOTSUPPFTYPE		3
609 #define	NFSV4OPEN_NOTSUPPWRITEFTYPE	4
610 #define	NFSV4OPEN_NOTSUPPUPGRADE	5
611 #define	NFSV4OPEN_NOTSUPPDOWNGRADE	6
612 #define	NFSV4OPEN_CANCELLED		7
613 #define	NFSV4OPEN_ISDIR			8
614 
615 /*
616  * Open result flags
617  * (The first four are in the spec. The rest are used internally.)
618  */
619 #define	NFSV4OPEN_RESULTCONFIRM		0x00000002
620 #define	NFSV4OPEN_LOCKTYPEPOSIX		0x00000004
621 #define	NFSV4OPEN_PRESERVEUNLINKED	0x00000008
622 #define	NFSV4OPEN_MAYNOTIFYLOCK		0x00000020
623 #define	NFSV4OPEN_RFLAGS 						\
624     (NFSV4OPEN_RESULTCONFIRM | NFSV4OPEN_LOCKTYPEPOSIX |		\
625     NFSV4OPEN_PRESERVEUNLINKED | NFSV4OPEN_MAYNOTIFYLOCK)
626 #define	NFSV4OPEN_RECALL		0x00010000
627 #define	NFSV4OPEN_READDELEGATE		0x00020000
628 #define	NFSV4OPEN_WRITEDELEGATE		0x00040000
629 #define	NFSV4OPEN_WDRESOURCE		0x00080000
630 #define	NFSV4OPEN_WDCONTENTION		0x00100000
631 #define	NFSV4OPEN_WDNOTWANTED		0x00200000
632 #define	NFSV4OPEN_WDSUPPFTYPE		0x00400000
633 #define	NFSV4OPEN_WDNOTSUPPDOWNGRADE	0x00800000
634 #define	NFSV4OPEN_WDNOTSUPPUPGRADE	0x01000000
635 
636 /*
637  * NFS V4 File Handle types
638  */
639 #define	NFSV4FHTYPE_PERSISTENT		0x0
640 #define	NFSV4FHTYPE_NOEXPIREWITHOPEN	0x1
641 #define	NFSV4FHTYPE_VOLATILEANY		0x2
642 #define	NFSV4FHTYPE_VOLATILEMIGRATE	0x4
643 #define	NFSV4FHTYPE_VOLATILERENAME	0x8
644 
645 /*
646  * Maximum size of V4 opaque strings.
647  */
648 #define	NFSV4_OPAQUELIMIT	1024
649 
650 /*
651  * These are the same for V3 and V4.
652  */
653 #define	NFSACCESS_READ			0x01
654 #define	NFSACCESS_LOOKUP		0x02
655 #define	NFSACCESS_MODIFY		0x04
656 #define	NFSACCESS_EXTEND		0x08
657 #define	NFSACCESS_DELETE		0x10
658 #define	NFSACCESS_EXECUTE		0x20
659 
660 /* Additional Extended Attribute access bits RFC-8276. */
661 #define	NFSACCESS_XAREAD		0x40
662 #define	NFSACCESS_XAWRITE		0x80
663 #define	NFSACCESS_XALIST		0x100
664 
665 #define	NFSWRITE_UNSTABLE		0
666 #define	NFSWRITE_DATASYNC		1
667 #define	NFSWRITE_FILESYNC		2
668 
669 #define	NFSCREATE_UNCHECKED		0
670 #define	NFSCREATE_GUARDED		1
671 #define	NFSCREATE_EXCLUSIVE		2
672 #define	NFSCREATE_EXCLUSIVE41		3
673 
674 #define	NFSV3FSINFO_LINK		0x01
675 #define	NFSV3FSINFO_SYMLINK		0x02
676 #define	NFSV3FSINFO_HOMOGENEOUS		0x08
677 #define	NFSV3FSINFO_CANSETTIME		0x10
678 
679 /* Flags for Exchange ID */
680 #define	NFSV4EXCH_SUPPMOVEDREFER	0x00000001
681 #define	NFSV4EXCH_SUPPMOVEDMIGR	0x00000002
682 #define	NFSV4EXCH_BINDPRINCSTATEID	0x00000100
683 #define	NFSV4EXCH_USENONPNFS		0x00010000
684 #define	NFSV4EXCH_USEPNFSMDS		0x00020000
685 #define	NFSV4EXCH_USEPNFSDS		0x00040000
686 #define	NFSV4EXCH_MASKPNFS		0x00070000
687 #define	NFSV4EXCH_UPDCONFIRMEDRECA	0x40000000
688 #define	NFSV4EXCH_CONFIRMEDR		0x80000000
689 
690 /* State Protects */
691 #define	NFSV4EXCH_SP4NONE		0
692 #define	NFSV4EXCH_SP4MACHCRED		1
693 #define	NFSV4EXCH_SP4SSV		2
694 
695 /* Flags for Create Session */
696 #define	NFSV4CRSESS_PERSIST		0x00000001
697 #define	NFSV4CRSESS_CONNBACKCHAN	0x00000002
698 #define	NFSV4CRSESS_CONNRDMA		0x00000004
699 
700 /* Flags for Sequence */
701 #define	NFSV4SEQ_CBPATHDOWN		0x00000001
702 #define	NFSV4SEQ_CBGSSCONTEXPIRING	0x00000002
703 #define	NFSV4SEQ_CBGSSCONTEXPIRED	0x00000004
704 #define	NFSV4SEQ_EXPIREDALLSTATEREVOKED	0x00000008
705 #define	NFSV4SEQ_EXPIREDSOMESTATEREVOKED 0x00000010
706 #define	NFSV4SEQ_ADMINSTATEREVOKED	0x00000020
707 #define	NFSV4SEQ_RECALLABLESTATEREVOKED	0x00000040
708 #define	NFSV4SEQ_LEASEMOVED		0x00000080
709 #define	NFSV4SEQ_RESTARTRECLAIMNEEDED	0x00000100
710 #define	NFSV4SEQ_CBPATHDOWNSESSION	0x00000200
711 #define	NFSV4SEQ_BACKCHANNELFAULT	0x00000400
712 #define	NFSV4SEQ_DEVIDCHANGED		0x00000800
713 #define	NFSV4SEQ_DEVIDDELETED		0x00001000
714 
715 /* Flags for Layout. */
716 #define	NFSLAYOUTRETURN_FILE		1
717 #define	NFSLAYOUTRETURN_FSID		2
718 #define	NFSLAYOUTRETURN_ALL		3
719 
720 #define	NFSLAYOUT_NFSV4_1_FILES		0x1
721 #define	NFSLAYOUT_OSD2_OBJECTS		0x2
722 #define	NFSLAYOUT_BLOCK_VOLUME		0x3
723 #define	NFSLAYOUT_FLEXFILE		0x4
724 
725 #define	NFSLAYOUTIOMODE_READ		1
726 #define	NFSLAYOUTIOMODE_RW		2
727 #define	NFSLAYOUTIOMODE_ANY		3
728 
729 /* Flags for Get Device Info. */
730 #define	NFSDEVICEIDNOTIFY_CHANGEBIT	0x1
731 #define	NFSDEVICEIDNOTIFY_DELETEBIT	0x2
732 
733 /* Flags for File Layout. */
734 #define	NFSFLAYUTIL_DENSE		0x1
735 #define	NFSFLAYUTIL_COMMIT_THRU_MDS	0x2
736 #define	NFSFLAYUTIL_IOADVISE_THRU_MDS	0x4
737 #define	NFSFLAYUTIL_STRIPE_MASK		0xffffffc0
738 
739 /* Flags for Flex File Layout. */
740 #define	NFSFLEXFLAG_NO_LAYOUTCOMMIT	0x00000001
741 #define	NFSFLEXFLAG_NOIO_MDS		0x00000002
742 #define	NFSFLEXFLAG_NO_READIO		0x00000004
743 #define	NFSFLEXFLAG_WRITE_ONEMIRROR	0x00000008
744 
745 /* Enum values for Bind Connection to Session. */
746 #define	NFSCDFC4_FORE		0x1
747 #define	NFSCDFC4_BACK		0x2
748 #define	NFSCDFC4_FORE_OR_BOTH	0x3
749 #define	NFSCDFC4_BACK_OR_BOTH	0x7
750 #define	NFSCDFS4_FORE		0x1
751 #define	NFSCDFS4_BACK		0x2
752 #define	NFSCDFS4_BOTH		0x3
753 
754 /* Enum values for Secinfo_no_name. */
755 #define	NFSSECINFONONAME_CURFH	0
756 #define	NFSSECINFONONAME_PARENT	1
757 
758 /* Bits for CB_RECALL_ANY. */
759 #define	NFSRCA4_RDATA_DLG	0x00000001
760 #define	NFSRCA4_WDATA_DLG	0x00000002
761 #define	NFSRCA4_DIR_DLG		0x00000004
762 #define	NFSRCA4_FILE_LAYOUT	0x00000008
763 #define	NFSRCA4_BLK_LAYOUT	0x00000010
764 #define	NFSRCA4_OBJ_LAYOUT_MIN	0x00000100
765 #define	NFSRCA4_OBJ_LAYOUT_MAX	0x00000200
766 #define	NFSRCA4_FF_LAYOUT_READ	0x00010000
767 #define	NFSRCA4_FF_LAYOUT_RW	0x00020000
768 
769 #if defined(_KERNEL) || defined(KERNEL)
770 /* Conversion macros */
771 #define	vtonfsv2_mode(t,m) 						\
772 		txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : 	\
773 				MAKEIMODE((t), (m)))
774 #define	vtonfsv34_mode(m)	txdr_unsigned((m) & 07777)
775 #define	nfstov_mode(a)		(fxdr_unsigned(u_int16_t, (a))&07777)
776 #define	vtonfsv2_type(a)  (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \
777 		txdr_unsigned(newnfsv2_type[((u_int32_t)(a))]))
778 #define	vtonfsv34_type(a)  (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \
779 		txdr_unsigned(nfsv34_type[((u_int32_t)(a))]))
780 #define	nfsv2tov_type(a)	newnv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
781 #define	nfsv34tov_type(a)	nv34tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
782 #define	vtonfs_dtype(a)	(((u_int32_t)(a)) >= 9 ? IFTODT(VTTOIF(VNON)) : \
783 			 IFTODT(VTTOIF(a)))
784 
785 /* File types */
786 typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
787 	NFSOCK=6, NFFIFO=7, NFATTRDIR=8, NFNAMEDATTR=9 } nfstype;
788 
789 /* Structs for common parts of the rpc's */
790 
791 struct nfsv2_time {
792 	u_int32_t nfsv2_sec;
793 	u_int32_t nfsv2_usec;
794 };
795 typedef struct nfsv2_time	nfstime2;
796 
797 struct nfsv3_time {
798 	u_int32_t nfsv3_sec;
799 	u_int32_t nfsv3_nsec;
800 };
801 typedef struct nfsv3_time	nfstime3;
802 
803 struct nfsv4_time {
804 	u_int32_t nfsv4_highsec;
805 	u_int32_t nfsv4_sec;
806 	u_int32_t nfsv4_nsec;
807 };
808 typedef struct nfsv4_time	nfstime4;
809 
810 /*
811  * Quads are defined as arrays of 2 longs to ensure dense packing for the
812  * protocol and to facilitate xdr conversion.
813  */
814 struct nfs_uquad {
815 	u_int32_t nfsuquad[2];
816 };
817 typedef	struct nfs_uquad	nfsuint64;
818 
819 /*
820  * Used to convert between two u_longs and a u_quad_t.
821  */
822 union nfs_quadconvert {
823 	u_int32_t lval[2];
824 	u_quad_t  qval;
825 };
826 typedef union nfs_quadconvert	nfsquad_t;
827 
828 /*
829  * NFS Version 3 special file number.
830  */
831 struct nfsv3_spec {
832 	u_int32_t specdata1;
833 	u_int32_t specdata2;
834 };
835 typedef	struct nfsv3_spec	nfsv3spec;
836 
837 /*
838  * File attributes and setable attributes. These structures cover both
839  * NFS version 2 and the version 3 protocol. Note that the union is only
840  * used so that one pointer can refer to both variants. These structures
841  * go out on the wire and must be densely packed, so no quad data types
842  * are used. (all fields are longs or u_longs or structures of same)
843  * NB: You can't do sizeof(struct nfs_fattr), you must use the
844  *     NFSX_FATTR(v3) macro.
845  */
846 struct nfs_fattr {
847 	u_int32_t fa_type;
848 	u_int32_t fa_mode;
849 	u_int32_t fa_nlink;
850 	u_int32_t fa_uid;
851 	u_int32_t fa_gid;
852 	union {
853 		struct {
854 			u_int32_t nfsv2fa_size;
855 			u_int32_t nfsv2fa_blocksize;
856 			u_int32_t nfsv2fa_rdev;
857 			u_int32_t nfsv2fa_blocks;
858 			u_int32_t nfsv2fa_fsid;
859 			u_int32_t nfsv2fa_fileid;
860 			nfstime2  nfsv2fa_atime;
861 			nfstime2  nfsv2fa_mtime;
862 			nfstime2  nfsv2fa_ctime;
863 		} fa_nfsv2;
864 		struct {
865 			nfsuint64 nfsv3fa_size;
866 			nfsuint64 nfsv3fa_used;
867 			nfsv3spec nfsv3fa_rdev;
868 			nfsuint64 nfsv3fa_fsid;
869 			nfsuint64 nfsv3fa_fileid;
870 			nfstime3  nfsv3fa_atime;
871 			nfstime3  nfsv3fa_mtime;
872 			nfstime3  nfsv3fa_ctime;
873 		} fa_nfsv3;
874 	} fa_un;
875 };
876 
877 /* and some ugly defines for accessing union components */
878 #define	fa2_size		fa_un.fa_nfsv2.nfsv2fa_size
879 #define	fa2_blocksize		fa_un.fa_nfsv2.nfsv2fa_blocksize
880 #define	fa2_rdev		fa_un.fa_nfsv2.nfsv2fa_rdev
881 #define	fa2_blocks		fa_un.fa_nfsv2.nfsv2fa_blocks
882 #define	fa2_fsid		fa_un.fa_nfsv2.nfsv2fa_fsid
883 #define	fa2_fileid		fa_un.fa_nfsv2.nfsv2fa_fileid
884 #define	fa2_atime		fa_un.fa_nfsv2.nfsv2fa_atime
885 #define	fa2_mtime		fa_un.fa_nfsv2.nfsv2fa_mtime
886 #define	fa2_ctime		fa_un.fa_nfsv2.nfsv2fa_ctime
887 #define	fa3_size		fa_un.fa_nfsv3.nfsv3fa_size
888 #define	fa3_used		fa_un.fa_nfsv3.nfsv3fa_used
889 #define	fa3_rdev		fa_un.fa_nfsv3.nfsv3fa_rdev
890 #define	fa3_fsid		fa_un.fa_nfsv3.nfsv3fa_fsid
891 #define	fa3_fileid		fa_un.fa_nfsv3.nfsv3fa_fileid
892 #define	fa3_atime		fa_un.fa_nfsv3.nfsv3fa_atime
893 #define	fa3_mtime		fa_un.fa_nfsv3.nfsv3fa_mtime
894 #define	fa3_ctime		fa_un.fa_nfsv3.nfsv3fa_ctime
895 
896 #define	NFS_LINK_MAX	UINT32_MAX
897 
898 struct nfsv2_sattr {
899 	u_int32_t sa_mode;
900 	u_int32_t sa_uid;
901 	u_int32_t sa_gid;
902 	u_int32_t sa_size;
903 	nfstime2  sa_atime;
904 	nfstime2  sa_mtime;
905 };
906 
907 /*
908  * NFS Version 3 sattr structure for the new node creation case.
909  */
910 struct nfsv3_sattr {
911 	u_int32_t sa_modetrue;
912 	u_int32_t sa_mode;
913 	u_int32_t sa_uidfalse;
914 	u_int32_t sa_gidfalse;
915 	u_int32_t sa_sizefalse;
916 	u_int32_t sa_atimetype;
917 	nfstime3  sa_atime;
918 	u_int32_t sa_mtimetype;
919 	nfstime3  sa_mtime;
920 };
921 
922 /*
923  * IO Advise hint bits for NFSv4.2.
924  * Since these go on the wire as a bitmap, the NFSATTRBIT macros are
925  * used to manipulate these bits.
926  */
927 #define	NFSV4IOHINT_NORMAL		0
928 #define	NFSV4IOHINT_SEQUENTIAL		1
929 #define	NFSV4IOHINT_SEQUENTIALBACK	2
930 #define	NFSV4IOHINT_RANDOM		3
931 #define	NFSV4IOHINT_WILLNEED		4
932 #define	NFSV4IOHINT_WILLNEEDOPTUN	5
933 #define	NFSV4IOHINT_DONTNEED		6
934 #define	NFSV4IOHINT_NOREUSE		7
935 #define	NFSV4IOHINT_READ		8
936 #define	NFSV4IOHINT_WRITE		9
937 #define	NFSV4IOHINT_INITPROXIMITY	10
938 
939 #endif	/* _KERNEL */
940 
941 /*
942  * The attribute bits used for V4.
943  * NFSATTRBIT_xxx defines the attribute# (and its bit position)
944  * NFSATTRBM_xxx is a 32bit mask with the correct bit set within the
945  *	appropriate 32bit word.
946  * NFSATTRBIT_MAX is one greater than the largest NFSATTRBIT_xxx
947  */
948 #define	NFSATTRBIT_SUPPORTEDATTRS	0
949 #define	NFSATTRBIT_TYPE			1
950 #define	NFSATTRBIT_FHEXPIRETYPE		2
951 #define	NFSATTRBIT_CHANGE		3
952 #define	NFSATTRBIT_SIZE			4
953 #define	NFSATTRBIT_LINKSUPPORT		5
954 #define	NFSATTRBIT_SYMLINKSUPPORT	6
955 #define	NFSATTRBIT_NAMEDATTR		7
956 #define	NFSATTRBIT_FSID			8
957 #define	NFSATTRBIT_UNIQUEHANDLES	9
958 #define	NFSATTRBIT_LEASETIME		10
959 #define	NFSATTRBIT_RDATTRERROR		11
960 #define	NFSATTRBIT_ACL			12
961 #define	NFSATTRBIT_ACLSUPPORT		13
962 #define	NFSATTRBIT_ARCHIVE		14
963 #define	NFSATTRBIT_CANSETTIME		15
964 #define	NFSATTRBIT_CASEINSENSITIVE	16
965 #define	NFSATTRBIT_CASEPRESERVING	17
966 #define	NFSATTRBIT_CHOWNRESTRICTED	18
967 #define	NFSATTRBIT_FILEHANDLE		19
968 #define	NFSATTRBIT_FILEID		20
969 #define	NFSATTRBIT_FILESAVAIL		21
970 #define	NFSATTRBIT_FILESFREE		22
971 #define	NFSATTRBIT_FILESTOTAL		23
972 #define	NFSATTRBIT_FSLOCATIONS		24
973 #define	NFSATTRBIT_HIDDEN		25
974 #define	NFSATTRBIT_HOMOGENEOUS		26
975 #define	NFSATTRBIT_MAXFILESIZE		27
976 #define	NFSATTRBIT_MAXLINK		28
977 #define	NFSATTRBIT_MAXNAME		29
978 #define	NFSATTRBIT_MAXREAD		30
979 #define	NFSATTRBIT_MAXWRITE		31
980 #define	NFSATTRBIT_MIMETYPE		32
981 #define	NFSATTRBIT_MODE			33
982 #define	NFSATTRBIT_NOTRUNC		34
983 #define	NFSATTRBIT_NUMLINKS		35
984 #define	NFSATTRBIT_OWNER		36
985 #define	NFSATTRBIT_OWNERGROUP		37
986 #define	NFSATTRBIT_QUOTAHARD		38
987 #define	NFSATTRBIT_QUOTASOFT		39
988 #define	NFSATTRBIT_QUOTAUSED		40
989 #define	NFSATTRBIT_RAWDEV		41
990 #define	NFSATTRBIT_SPACEAVAIL		42
991 #define	NFSATTRBIT_SPACEFREE		43
992 #define	NFSATTRBIT_SPACETOTAL		44
993 #define	NFSATTRBIT_SPACEUSED		45
994 #define	NFSATTRBIT_SYSTEM		46
995 #define	NFSATTRBIT_TIMEACCESS		47
996 #define	NFSATTRBIT_TIMEACCESSSET	48
997 #define	NFSATTRBIT_TIMEBACKUP		49
998 #define	NFSATTRBIT_TIMECREATE		50
999 #define	NFSATTRBIT_TIMEDELTA		51
1000 #define	NFSATTRBIT_TIMEMETADATA		52
1001 #define	NFSATTRBIT_TIMEMODIFY		53
1002 #define	NFSATTRBIT_TIMEMODIFYSET	54
1003 #define	NFSATTRBIT_MOUNTEDONFILEID	55
1004 #define	NFSATTRBIT_DIRNOTIFDELAY	56
1005 #define	NFSATTRBIT_DIRENTNOTIFDELAY	57
1006 #define	NFSATTRBIT_DACL			58
1007 #define	NFSATTRBIT_SACL			59
1008 #define	NFSATTRBIT_CHANGEPOLICY		60
1009 #define	NFSATTRBIT_FSSTATUS		61
1010 #define	NFSATTRBIT_FSLAYOUTTYPE		62
1011 #define	NFSATTRBIT_LAYOUTHINT		63
1012 #define	NFSATTRBIT_LAYOUTTYPE		64
1013 #define	NFSATTRBIT_LAYOUTBLKSIZE	65
1014 #define	NFSATTRBIT_LAYOUTALIGNMENT	66
1015 #define	NFSATTRBIT_FSLOCATIONSINFO	67
1016 #define	NFSATTRBIT_MDSTHRESHOLD		68
1017 #define	NFSATTRBIT_RETENTIONGET		69
1018 #define	NFSATTRBIT_RETENTIONSET		70
1019 #define	NFSATTRBIT_RETENTEVTGET		71
1020 #define	NFSATTRBIT_RETENTEVTSET		72
1021 #define	NFSATTRBIT_RETENTIONHOLD	73
1022 #define	NFSATTRBIT_MODESETMASKED	74
1023 #define	NFSATTRBIT_SUPPATTREXCLCREAT	75
1024 #define	NFSATTRBIT_FSCHARSETCAP		76
1025 #define	NFSATTRBIT_CLONEBLKSIZE		77
1026 #define	NFSATTRBIT_SPACEFREED		78
1027 #define	NFSATTRBIT_CHANGEATTRTYPE	79
1028 #define	NFSATTRBIT_SECLABEL		80
1029 #define	NFSATTRBIT_MODEUMASK		81
1030 #define	NFSATTRBIT_XATTRSUPPORT		82
1031 #define	NFSATTRBIT_ACLTRUEFORM		89
1032 #define	NFSATTRBIT_ACLTRUEFORMSCOPE	90
1033 #define	NFSATTRBIT_POSIXDEFAULTACL	91
1034 #define	NFSATTRBIT_POSIXACCESSACL	92
1035 
1036 #define	NFSATTRBM_SUPPORTEDATTRS	0x00000001
1037 #define	NFSATTRBM_TYPE			0x00000002
1038 #define	NFSATTRBM_FHEXPIRETYPE		0x00000004
1039 #define	NFSATTRBM_CHANGE		0x00000008
1040 #define	NFSATTRBM_SIZE			0x00000010
1041 #define	NFSATTRBM_LINKSUPPORT		0x00000020
1042 #define	NFSATTRBM_SYMLINKSUPPORT	0x00000040
1043 #define	NFSATTRBM_NAMEDATTR		0x00000080
1044 #define	NFSATTRBM_FSID			0x00000100
1045 #define	NFSATTRBM_UNIQUEHANDLES		0x00000200
1046 #define	NFSATTRBM_LEASETIME		0x00000400
1047 #define	NFSATTRBM_RDATTRERROR		0x00000800
1048 #define	NFSATTRBM_ACL			0x00001000
1049 #define	NFSATTRBM_ACLSUPPORT		0x00002000
1050 #define	NFSATTRBM_ARCHIVE		0x00004000
1051 #define	NFSATTRBM_CANSETTIME		0x00008000
1052 #define	NFSATTRBM_CASEINSENSITIVE	0x00010000
1053 #define	NFSATTRBM_CASEPRESERVING	0x00020000
1054 #define	NFSATTRBM_CHOWNRESTRICTED	0x00040000
1055 #define	NFSATTRBM_FILEHANDLE		0x00080000
1056 #define	NFSATTRBM_FILEID		0x00100000
1057 #define	NFSATTRBM_FILESAVAIL		0x00200000
1058 #define	NFSATTRBM_FILESFREE		0x00400000
1059 #define	NFSATTRBM_FILESTOTAL		0x00800000
1060 #define	NFSATTRBM_FSLOCATIONS		0x01000000
1061 #define	NFSATTRBM_HIDDEN		0x02000000
1062 #define	NFSATTRBM_HOMOGENEOUS		0x04000000
1063 #define	NFSATTRBM_MAXFILESIZE		0x08000000
1064 #define	NFSATTRBM_MAXLINK		0x10000000
1065 #define	NFSATTRBM_MAXNAME		0x20000000
1066 #define	NFSATTRBM_MAXREAD		0x40000000
1067 #define	NFSATTRBM_MAXWRITE		0x80000000
1068 #define	NFSATTRBM_MIMETYPE		0x00000001
1069 #define	NFSATTRBM_MODE			0x00000002
1070 #define	NFSATTRBM_NOTRUNC		0x00000004
1071 #define	NFSATTRBM_NUMLINKS		0x00000008
1072 #define	NFSATTRBM_OWNER			0x00000010
1073 #define	NFSATTRBM_OWNERGROUP		0x00000020
1074 #define	NFSATTRBM_QUOTAHARD		0x00000040
1075 #define	NFSATTRBM_QUOTASOFT		0x00000080
1076 #define	NFSATTRBM_QUOTAUSED		0x00000100
1077 #define	NFSATTRBM_RAWDEV		0x00000200
1078 #define	NFSATTRBM_SPACEAVAIL		0x00000400
1079 #define	NFSATTRBM_SPACEFREE		0x00000800
1080 #define	NFSATTRBM_SPACETOTAL		0x00001000
1081 #define	NFSATTRBM_SPACEUSED		0x00002000
1082 #define	NFSATTRBM_SYSTEM		0x00004000
1083 #define	NFSATTRBM_TIMEACCESS		0x00008000
1084 #define	NFSATTRBM_TIMEACCESSSET		0x00010000
1085 #define	NFSATTRBM_TIMEBACKUP		0x00020000
1086 #define	NFSATTRBM_TIMECREATE		0x00040000
1087 #define	NFSATTRBM_TIMEDELTA		0x00080000
1088 #define	NFSATTRBM_TIMEMETADATA		0x00100000
1089 #define	NFSATTRBM_TIMEMODIFY		0x00200000
1090 #define	NFSATTRBM_TIMEMODIFYSET		0x00400000
1091 #define	NFSATTRBM_MOUNTEDONFILEID	0x00800000
1092 #define	NFSATTRBM_DIRNOTIFDELAY		0x01000000
1093 #define	NFSATTRBM_DIRENTNOTIFDELAY	0x02000000
1094 #define	NFSATTRBM_DACL			0x04000000
1095 #define	NFSATTRBM_SACL			0x08000000
1096 #define	NFSATTRBM_CHANGEPOLICY		0x10000000
1097 #define	NFSATTRBM_FSSTATUS		0x20000000
1098 #define	NFSATTRBM_FSLAYOUTTYPE		0x40000000
1099 #define	NFSATTRBM_LAYOUTHINT		0x80000000
1100 #define	NFSATTRBM_LAYOUTTYPE		0x00000001
1101 #define	NFSATTRBM_LAYOUTBLKSIZE		0x00000002
1102 #define	NFSATTRBM_LAYOUTALIGNMENT	0x00000004
1103 #define	NFSATTRBM_FSLOCATIONSINFO	0x00000008
1104 #define	NFSATTRBM_MDSTHRESHOLD		0x00000010
1105 #define	NFSATTRBM_RETENTIONGET		0x00000020
1106 #define	NFSATTRBM_RETENTIONSET		0x00000040
1107 #define	NFSATTRBM_RETENTEVTGET		0x00000080
1108 #define	NFSATTRBM_RETENTEVTSET		0x00000100
1109 #define	NFSATTRBM_RETENTIONHOLD		0x00000200
1110 #define	NFSATTRBM_MODESETMASKED		0x00000400
1111 #define	NFSATTRBM_SUPPATTREXCLCREAT	0x00000800
1112 #define	NFSATTRBM_FSCHARSETCAP		0x00001000
1113 #define	NFSATTRBM_CLONEBLKSIZE		0x00002000
1114 #define	NFSATTRBM_SPACEFREED		0x00004000
1115 #define	NFSATTRBM_CHANGEATTRTYPE	0x00008000
1116 #define	NFSATTRBM_SECLABEL		0x00010000
1117 #define	NFSATTRBM_MODEUMASK		0x00020000
1118 #define	NFSATTRBM_XATTRSUPPORT		0x00040000
1119 #define	NFSATTRBM_ACLTRUEFORM		0x02000000
1120 #define	NFSATTRBM_ACLTRUEFORMSCOPE	0x04000000
1121 #define	NFSATTRBM_POSIXDEFAULTACL	0x08000000
1122 #define	NFSATTRBM_POSIXACCESSACL	0x10000000
1123 
1124 #define	NFSATTRBIT_MAX			93
1125 
1126 /*
1127  * Sets of attributes that are supported, by words in the bitmap.
1128  */
1129 /*
1130  * NFSATTRBIT_SUPPORTED - SUPP0 - bits 0<->31
1131  *			  SUPP1 - bits 32<->63
1132  *			  SUPP2 - bits 64<->95
1133  */
1134 #define	NFSATTRBIT_SUPP0						\
1135  	(NFSATTRBM_SUPPORTEDATTRS |					\
1136  	NFSATTRBM_TYPE |						\
1137  	NFSATTRBM_FHEXPIRETYPE |					\
1138  	NFSATTRBM_CHANGE |						\
1139  	NFSATTRBM_SIZE |						\
1140  	NFSATTRBM_LINKSUPPORT |						\
1141  	NFSATTRBM_SYMLINKSUPPORT |					\
1142  	NFSATTRBM_NAMEDATTR |						\
1143  	NFSATTRBM_FSID |						\
1144  	NFSATTRBM_UNIQUEHANDLES |					\
1145  	NFSATTRBM_LEASETIME |						\
1146  	NFSATTRBM_RDATTRERROR |						\
1147  	NFSATTRBM_ACL |							\
1148  	NFSATTRBM_ACLSUPPORT |						\
1149 	NFSATTRBM_ARCHIVE |						\
1150  	NFSATTRBM_CANSETTIME |						\
1151  	NFSATTRBM_CASEINSENSITIVE |					\
1152  	NFSATTRBM_CASEPRESERVING |					\
1153  	NFSATTRBM_CHOWNRESTRICTED |					\
1154  	NFSATTRBM_FILEHANDLE |						\
1155  	NFSATTRBM_FILEID |						\
1156  	NFSATTRBM_FILESAVAIL |						\
1157  	NFSATTRBM_FILESFREE |						\
1158  	NFSATTRBM_FILESTOTAL |						\
1159 	NFSATTRBM_FSLOCATIONS |						\
1160 	NFSATTRBM_HIDDEN |						\
1161  	NFSATTRBM_HOMOGENEOUS |						\
1162  	NFSATTRBM_MAXFILESIZE |						\
1163  	NFSATTRBM_MAXLINK |						\
1164  	NFSATTRBM_MAXNAME |						\
1165  	NFSATTRBM_MAXREAD |						\
1166  	NFSATTRBM_MAXWRITE)
1167 
1168 /*
1169  * NFSATTRBIT_S1 - subset of SUPP1 - OR of the following bits:
1170  */
1171 #define	NFSATTRBIT_S1							\
1172  	(NFSATTRBM_MODE |						\
1173  	NFSATTRBM_NOTRUNC |						\
1174  	NFSATTRBM_NUMLINKS |						\
1175  	NFSATTRBM_OWNER |						\
1176  	NFSATTRBM_OWNERGROUP |						\
1177  	NFSATTRBM_RAWDEV |						\
1178  	NFSATTRBM_SPACEAVAIL |						\
1179  	NFSATTRBM_SPACEFREE |						\
1180  	NFSATTRBM_SPACETOTAL |						\
1181  	NFSATTRBM_SPACEUSED |						\
1182 	NFSATTRBM_SYSTEM |						\
1183  	NFSATTRBM_TIMEACCESS |						\
1184  	NFSATTRBM_TIMECREATE |						\
1185  	NFSATTRBM_TIMEDELTA |						\
1186  	NFSATTRBM_TIMEMETADATA |					\
1187  	NFSATTRBM_TIMEMODIFY |						\
1188  	NFSATTRBM_MOUNTEDONFILEID |					\
1189 	NFSATTRBM_QUOTAHARD |                        			\
1190     	NFSATTRBM_QUOTASOFT |                        			\
1191     	NFSATTRBM_QUOTAUSED |						\
1192 	NFSATTRBM_FSLAYOUTTYPE)
1193 
1194 #ifdef QUOTA
1195 /*
1196  * If QUOTA OR in NFSATTRBIT_QUOTAHARD, NFSATTRBIT_QUOTASOFT and
1197  * NFSATTRBIT_QUOTAUSED.
1198  */
1199 #define	NFSATTRBIT_SUPP1	(NFSATTRBIT_S1 |			\
1200 				NFSATTRBM_QUOTAHARD |			\
1201 				NFSATTRBM_QUOTASOFT |			\
1202 				NFSATTRBM_QUOTAUSED)
1203 #else
1204 #define	NFSATTRBIT_SUPP1	NFSATTRBIT_S1
1205 #endif
1206 
1207 #define	NFSATTRBIT_SUPP2						\
1208 	(NFSATTRBM_LAYOUTTYPE |						\
1209 	NFSATTRBM_LAYOUTBLKSIZE |					\
1210 	NFSATTRBM_LAYOUTALIGNMENT |					\
1211 	NFSATTRBM_SUPPATTREXCLCREAT |					\
1212 	NFSATTRBM_CLONEBLKSIZE |					\
1213 	NFSATTRBM_CHANGEATTRTYPE |					\
1214 	NFSATTRBM_XATTRSUPPORT |					\
1215 	NFSATTRBM_ACLTRUEFORM |						\
1216 	NFSATTRBM_ACLTRUEFORMSCOPE |					\
1217 	NFSATTRBM_POSIXDEFAULTACL |					\
1218 	NFSATTRBM_POSIXACCESSACL)
1219 
1220 /*
1221  * These are the set only attributes.
1222  */
1223 #define	NFSATTRBIT_SUPPSETONLY1	 (NFSATTRBM_TIMEACCESSSET |		\
1224 				 NFSATTRBM_TIMEMODIFYSET)
1225 #define	NFSATTRBIT_SUPPSETONLY2	(NFSATTRBM_MODESETMASKED |		\
1226 				 NFSATTRBM_MODEUMASK)
1227 
1228 /*
1229  * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31
1230  *			SETABLE1 - bits 32<->63
1231  *			SETABLE2 - bits 64<->95
1232  */
1233 #define	NFSATTRBIT_SETABLE0						\
1234 	(NFSATTRBM_SIZE |						\
1235 	NFSATTRBM_HIDDEN |						\
1236 	NFSATTRBM_ARCHIVE |						\
1237 	NFSATTRBM_ACL)
1238 #define	NFSATTRBIT_SETABLE1						\
1239  	(NFSATTRBM_MODE |						\
1240  	NFSATTRBM_OWNER |						\
1241  	NFSATTRBM_OWNERGROUP |						\
1242 	NFSATTRBM_SYSTEM |						\
1243  	NFSATTRBM_TIMECREATE |						\
1244  	NFSATTRBM_TIMEACCESSSET |					\
1245  	NFSATTRBM_TIMEMODIFYSET)
1246 #define	NFSATTRBIT_SETABLE2						\
1247 	(NFSATTRBM_MODESETMASKED |					\
1248 	NFSATTRBM_MODEUMASK |						\
1249 	NFSATTRBM_POSIXDEFAULTACL |					\
1250 	NFSATTRBM_POSIXACCESSACL)
1251 
1252 /*
1253  * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1.
1254  */
1255 #define	NFSATTRBIT_NFSV41_1						\
1256 	(NFSATTRBM_FSLAYOUTTYPE)
1257 #define	NFSATTRBIT_NFSV41_2						\
1258 	(NFSATTRBM_LAYOUTTYPE |						\
1259 	NFSATTRBM_LAYOUTBLKSIZE |					\
1260 	NFSATTRBM_LAYOUTALIGNMENT |					\
1261 	NFSATTRBM_MODESETMASKED |					\
1262 	NFSATTRBM_SUPPATTREXCLCREAT)
1263 
1264 /*
1265  * NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2.
1266  */
1267 #define	NFSATTRBIT_NFSV42_2						\
1268 	(NFSATTRBM_CLONEBLKSIZE |					\
1269 	NFSATTRBM_CHANGEATTRTYPE |					\
1270 	NFSATTRBM_XATTRSUPPORT |					\
1271 	NFSATTRBM_MODEUMASK |						\
1272 	NFSATTRBM_ACLTRUEFORM |						\
1273 	NFSATTRBM_ACLTRUEFORMSCOPE |					\
1274 	NFSATTRBM_POSIXDEFAULTACL |					\
1275 	NFSATTRBM_POSIXACCESSACL)
1276 
1277 /*
1278  * Set of attributes that the getattr vnode op needs.
1279  * OR of the following bits.
1280  * NFSATTRBIT_GETATTR0 - bits 0<->31
1281  */
1282 #define	NFSATTRBIT_GETATTR0						\
1283  	(NFSATTRBM_SUPPORTEDATTRS |					\
1284  	NFSATTRBM_TYPE |						\
1285  	NFSATTRBM_CHANGE |						\
1286  	NFSATTRBM_SIZE |						\
1287  	NFSATTRBM_FSID |						\
1288 	NFSATTRBM_ARCHIVE |						\
1289  	NFSATTRBM_FILEID |						\
1290 	NFSATTRBM_HIDDEN |						\
1291  	NFSATTRBM_MAXREAD)
1292 
1293 /*
1294  * NFSATTRBIT_GETATTR1 - bits 32<->63
1295  */
1296 #define	NFSATTRBIT_GETATTR1						\
1297  	(NFSATTRBM_MODE |						\
1298  	NFSATTRBM_NUMLINKS |						\
1299  	NFSATTRBM_OWNER |						\
1300  	NFSATTRBM_OWNERGROUP |						\
1301  	NFSATTRBM_RAWDEV |						\
1302  	NFSATTRBM_SPACEUSED |						\
1303 	NFSATTRBM_SYSTEM |						\
1304  	NFSATTRBM_TIMEACCESS |						\
1305 	NFSATTRBM_TIMECREATE |						\
1306  	NFSATTRBM_TIMEMETADATA |					\
1307  	NFSATTRBM_TIMEMODIFY)
1308 
1309 /*
1310  * NFSATTRBIT_GETATTR2 - bits 64<->95
1311  */
1312 #define	NFSATTRBIT_GETATTR2		0
1313 
1314 /*
1315  * Subset of the above that the Write RPC gets.
1316  * OR of the following bits.
1317  * NFSATTRBIT_WRITEGETATTR0 - bits 0<->31
1318  */
1319 #define	NFSATTRBIT_WRITEGETATTR0					\
1320  	(NFSATTRBM_SUPPORTEDATTRS |					\
1321  	NFSATTRBM_TYPE |						\
1322  	NFSATTRBM_CHANGE |						\
1323  	NFSATTRBM_SIZE |						\
1324  	NFSATTRBM_FSID |						\
1325 	NFSATTRBM_ARCHIVE |						\
1326  	NFSATTRBM_FILEID |						\
1327 	NFSATTRBM_HIDDEN |						\
1328  	NFSATTRBM_MAXREAD)
1329 
1330 /*
1331  * NFSATTRBIT_WRITEGETATTR1 - bits 32<->63
1332  */
1333 #define	NFSATTRBIT_WRITEGETATTR1					\
1334  	(NFSATTRBM_MODE |						\
1335  	NFSATTRBM_NUMLINKS |						\
1336  	NFSATTRBM_RAWDEV |						\
1337  	NFSATTRBM_SPACEUSED |						\
1338 	NFSATTRBM_SYSTEM |						\
1339  	NFSATTRBM_TIMEACCESS |						\
1340 	NFSATTRBM_TIMECREATE |						\
1341  	NFSATTRBM_TIMEMETADATA |					\
1342  	NFSATTRBM_TIMEMODIFY)
1343 
1344 /*
1345  * NFSATTRBIT_WRITEGETATTR2 - bits 64<->95
1346  */
1347 #define	NFSATTRBIT_WRITEGETATTR2	0
1348 
1349 /*
1350  * Set of attributes that the wccattr operation op needs.
1351  * OR of the following bits.
1352  * NFSATTRBIT_WCCATTR0 - bits 0<->31
1353  */
1354 #define	NFSATTRBIT_WCCATTR0	0
1355 
1356 /*
1357  * NFSATTRBIT_WCCATTR1 - bits 32<->63
1358  */
1359 #define	NFSATTRBIT_WCCATTR1						\
1360  	(NFSATTRBM_TIMEMODIFY)
1361 
1362 /*
1363  * NFSATTRBIT_WCCATTR2 - bits 64<->95
1364  */
1365 #define	NFSATTRBIT_WCCATTR2		0
1366 
1367 /*
1368  * NFSATTRBIT_CBGETATTR0 - bits 0<->31
1369  */
1370 #define	NFSATTRBIT_CBGETATTR0	(NFSATTRBM_CHANGE | NFSATTRBM_SIZE)
1371 
1372 /*
1373  * NFSATTRBIT_CBGETATTR1 - bits 32<->63
1374  */
1375 #define	NFSATTRBIT_CBGETATTR1		0x0
1376 
1377 /*
1378  * NFSATTRBIT_CBGETATTR2 - bits 64<->95
1379  */
1380 #define	NFSATTRBIT_CBGETATTR2		0x0
1381 
1382 /*
1383  * Sets of attributes that require a VFS_STATFS() call to get the
1384  * values of.
1385  * NFSATTRBIT_STATFS0 - bits 0<->31
1386  */
1387 #define	NFSATTRBIT_STATFS0						\
1388 	(NFSATTRBM_LINKSUPPORT |					\
1389 	NFSATTRBM_SYMLINKSUPPORT |					\
1390 	NFSATTRBM_CANSETTIME |						\
1391  	NFSATTRBM_FILESAVAIL |						\
1392  	NFSATTRBM_FILESFREE |						\
1393  	NFSATTRBM_FILESTOTAL |						\
1394  	NFSATTRBM_HOMOGENEOUS |						\
1395  	NFSATTRBM_MAXFILESIZE |						\
1396 	NFSATTRBM_MAXNAME |						\
1397 	NFSATTRBM_MAXREAD |						\
1398 	NFSATTRBM_MAXWRITE)
1399 
1400 /*
1401  * NFSATTRBIT_STATFS1 - bits 32<->63
1402  */
1403 #define	NFSATTRBIT_STATFS1						\
1404  	(NFSATTRBM_QUOTAHARD |						\
1405  	NFSATTRBM_QUOTASOFT |						\
1406  	NFSATTRBM_QUOTAUSED |						\
1407  	NFSATTRBM_SPACEAVAIL |						\
1408  	NFSATTRBM_SPACEFREE |						\
1409  	NFSATTRBM_SPACETOTAL |						\
1410  	NFSATTRBM_SPACEUSED |						\
1411 	NFSATTRBM_TIMEDELTA)
1412 
1413 /*
1414  * NFSATTRBIT_STATFS2 - bits 64<->95
1415  */
1416 #define	NFSATTRBIT_STATFS2		0
1417 
1418 /*
1419  * These are the bits that are needed by the nfs_statfs() call.
1420  * (The regular getattr bits are or'd in so the vnode gets the correct
1421  *  type, etc.)
1422  * NFSGETATTRBIT_STATFS0 - bits 0<->31
1423  */
1424 #define	NFSGETATTRBIT_STATFS0	(NFSATTRBIT_GETATTR0 |			\
1425 				NFSATTRBM_LINKSUPPORT |			\
1426 				NFSATTRBM_SYMLINKSUPPORT |		\
1427 				NFSATTRBM_CANSETTIME |			\
1428 				NFSATTRBM_FILESFREE |			\
1429 				NFSATTRBM_FILESTOTAL |			\
1430 				NFSATTRBM_HOMOGENEOUS |			\
1431 				NFSATTRBM_MAXFILESIZE |			\
1432 				NFSATTRBM_MAXNAME |			\
1433 				NFSATTRBM_MAXREAD |			\
1434 				NFSATTRBM_MAXWRITE)
1435 
1436 /*
1437  * NFSGETATTRBIT_STATFS1 - bits 32<->63
1438  */
1439 #define	NFSGETATTRBIT_STATFS1	(NFSATTRBIT_GETATTR1 |			\
1440 				NFSATTRBM_SPACEAVAIL |			\
1441 				NFSATTRBM_SPACEFREE |			\
1442 				NFSATTRBM_SPACETOTAL |			\
1443 				NFSATTRBM_TIMEDELTA)
1444 
1445 /*
1446  * NFSGETATTRBIT_STATFS2 - bits 64<->95
1447  */
1448 #define	NFSGETATTRBIT_STATFS2	(NFSATTRBM_CLONEBLKSIZE)
1449 
1450 /*
1451  * Set of attributes for the equivalent of an nfsv3 pathconf rpc.
1452  * NFSGETATTRBIT_PATHCONF0 - bits 0<->31
1453  */
1454 #define	NFSGETATTRBIT_PATHCONF0	(NFSATTRBIT_GETATTR0 |			\
1455 				NFSATTRBM_NAMEDATTR |			\
1456 			 	NFSATTRBM_CASEINSENSITIVE |		\
1457 			 	NFSATTRBM_CASEPRESERVING |		\
1458 			 	NFSATTRBM_CHOWNRESTRICTED |		\
1459 			 	NFSATTRBM_MAXLINK |			\
1460 			 	NFSATTRBM_MAXNAME)
1461 
1462 /*
1463  * NFSGETATTRBIT_PATHCONF1 - bits 32<->63
1464  */
1465 #define	NFSGETATTRBIT_PATHCONF1	(NFSATTRBIT_GETATTR1 |			\
1466 				NFSATTRBM_NOTRUNC)
1467 
1468 /*
1469  * NFSGETATTRBIT_PATHCONF2 - bits 64<->95
1470  */
1471 #define	NFSGETATTRBIT_PATHCONF2	(NFSATTRBM_CLONEBLKSIZE)
1472 
1473 /*
1474  * Sets of attributes required by readdir and readdirplus.
1475  * NFSATTRBIT_READDIRPLUS0	(NFSATTRBIT_GETATTR0 | NFSATTRBIT_FILEHANDLE |
1476  *				 NFSATTRBIT_RDATTRERROR)
1477  */
1478 #define	NFSATTRBIT_READDIRPLUS0	(NFSATTRBIT_GETATTR0 | NFSATTRBM_FILEHANDLE | \
1479 				NFSATTRBM_RDATTRERROR)
1480 #define	NFSATTRBIT_READDIRPLUS1	NFSATTRBIT_GETATTR1
1481 #define	NFSATTRBIT_READDIRPLUS2		0
1482 
1483 /*
1484  * Set of attributes supported by Referral vnodes.
1485  */
1486 #define	NFSATTRBIT_REFERRAL0	(NFSATTRBM_TYPE | NFSATTRBM_FSID |	\
1487 	NFSATTRBM_RDATTRERROR | NFSATTRBM_FSLOCATIONS)
1488 #define	NFSATTRBIT_REFERRAL1	NFSATTRBM_MOUNTEDONFILEID
1489 #define	NFSATTRBIT_REFERRAL2		0
1490 
1491 /* Bits for the operations bitmaps. */
1492 #define	NFSV4OPBM_ACCESS		0x00000008
1493 #define	NFSV4OPBM_CLOSE			0x00000010
1494 #define	NFSV4OPBM_COMMIT		0x00000020
1495 #define	NFSV4OPBM_CREATE		0x00000040
1496 #define	NFSV4OPBM_DELEGPURGE		0x00000080
1497 #define	NFSV4OPBM_DELEGRETURN		0x00000100
1498 #define	NFSV4OPBM_GETATTR		0x00000200
1499 #define	NFSV4OPBM_GETFH			0x00000400
1500 #define	NFSV4OPBM_LINK			0x00000800
1501 #define	NFSV4OPBM_LOCK			0x00001000
1502 #define	NFSV4OPBM_LOCKT			0x00002000
1503 #define	NFSV4OPBM_LOCKU			0x00004000
1504 #define	NFSV4OPBM_LOOKUP		0x00008000
1505 #define	NFSV4OPBM_LOOKUPP		0x00010000
1506 #define	NFSV4OPBM_NVERIFY		0x00020000
1507 #define	NFSV4OPBM_OPEN			0x00040000
1508 #define	NFSV4OPBM_OPENATTR		0x00080000
1509 #define	NFSV4OPBM_OPENCONFIRM		0x00100000
1510 #define	NFSV4OPBM_OPENDOWNGRADE		0x00200000
1511 #define	NFSV4OPBM_PUTFH			0x00400000
1512 #define	NFSV4OPBM_PUTPUBFH		0x00800000
1513 #define	NFSV4OPBM_PUTROOTFH		0x01000000
1514 #define	NFSV4OPBM_READ			0x02000000
1515 #define	NFSV4OPBM_READDIR		0x04000000
1516 #define	NFSV4OPBM_READLINK		0x08000000
1517 #define	NFSV4OPBM_REMOVE		0x10000000
1518 #define	NFSV4OPBM_RENAME		0x20000000
1519 #define	NFSV4OPBM_RENEW			0x40000000
1520 #define	NFSV4OPBM_RESTOREFH		0x80000000
1521 #define	NFSV4OPBM_SAVEFH		0x00000001
1522 #define	NFSV4OPBM_SECINFO		0x00000002
1523 #define	NFSV4OPBM_SETATTR		0x00000004
1524 #define	NFSV4OPBM_SETCLIENTID		0x00000008
1525 #define	NFSV4OPBM_SETCLIENTIDCFRM	0x00000010
1526 #define	NFSV4OPBM_VERIFY		0x00000020
1527 #define	NFSV4OPBM_WRITE			0x00000040
1528 #define	NFSV4OPBM_RELEASELCKOWN		0x00000080
1529 #define	NFSV4OPBM_BACKCHANNELCTL	0x00000100
1530 #define	NFSV4OPBM_BINDCONNTOSESS	0x00000200
1531 #define	NFSV4OPBM_EXCHANGEID		0x00000400
1532 #define	NFSV4OPBM_CREATESESSION		0x00000800
1533 #define	NFSV4OPBM_DESTROYSESSION	0x00001000
1534 #define	NFSV4OPBM_FREESTATEID		0x00002000
1535 #define	NFSV4OPBM_GETDIRDELEG		0x00004000
1536 #define	NFSV4OPBM_GETDEVINFO		0x00008000
1537 #define	NFSV4OPBM_GETDEVLIST		0x00010000
1538 #define	NFSV4OPBM_LAYOUTCOMMIT		0x00020000
1539 #define	NFSV4OPBM_LAYOUTGET		0x00040000
1540 #define	NFSV4OPBM_LAYOUTRETURN		0x00080000
1541 #define	NFSV4OPBM_SECINFONONAME		0x00100000
1542 #define	NFSV4OPBM_SEQUENCE		0x00200000
1543 #define	NFSV4OPBM_SETSSV		0x00400000
1544 #define	NFSV4OPBM_TESTSTATEID		0x00800000
1545 #define	NFSV4OPBM_WANTDELEG		0x01000000
1546 #define	NFSV4OPBM_DESTROYCLIENTID	0x02000000
1547 #define	NFSV4OPBM_RECLAIMCOMPL		0x04000000
1548 #define	NFSV4OPBM_ALLOCATE		0x08000000
1549 #define	NFSV4OPBM_COPY			0x10000000
1550 #define	NFSV4OPBM_COPYNOTIFY		0x20000000
1551 #define	NFSV4OPBM_DEALLOCATE		0x40000000
1552 #define	NFSV4OPBM_IOADVISE		0x80000000
1553 #define	NFSV4OPBM_LAYOUTERROR		0x00000001
1554 #define	NFSV4OPBM_LAYOUTSTATS		0x00000002
1555 #define	NFSV4OPBM_OFFLOADCANCEL		0x00000004
1556 #define	NFSV4OPBM_OFFLOADSTATUS		0x00000008
1557 #define	NFSV4OPBM_READPLUS		0x00000010
1558 #define	NFSV4OPBM_SEEK			0x00000020
1559 #define	NFSV4OPBM_WRITESAME		0x00000040
1560 #define	NFSV4OPBM_CLONE			0x00000080
1561 #define	NFSV4OPBM_GETXATTR		0x00000100
1562 #define	NFSV4OPBM_SETXATTR		0x00000200
1563 #define	NFSV4OPBM_LISTXATTRS		0x00000400
1564 #define	NFSV4OPBM_REMOVEXATTR		0x00000800
1565 
1566 /*
1567  * The set of must and allow operations for SP4_MACH_CRED.  These are
1568  * the operations requested by the Linux NFSv4.1/4.2 client.
1569  * The must list is also the same ones listed in the RFC.
1570  */
1571 #define	NFSOPBIT_MUST0	NFSV4OP_DELEGPURGE
1572 
1573 #define	NFSOPBIT_MUST1							\
1574 	(NFSV4OPBM_BINDCONNTOSESS |					\
1575 	NFSV4OPBM_EXCHANGEID |						\
1576 	NFSV4OPBM_CREATESESSION |					\
1577 	NFSV4OPBM_DESTROYSESSION |					\
1578 	NFSV4OPBM_DESTROYCLIENTID)
1579 
1580 #define	NFSOPBIT_MUST2		0x0
1581 
1582 #define	NFSOPBIT_CLRNOTMUST(b) do {					\
1583 	(b)->bits[0] &= NFSOPBIT_MUST0;					\
1584 	(b)->bits[1] &= NFSOPBIT_MUST1;					\
1585 	(b)->bits[2] &= NFSOPBIT_MUST2;					\
1586     } while (0)
1587 
1588 #define	NFSOPBIT_ALLOWED0						\
1589 	(NFSV4OPBM_CLOSE |						\
1590 	NFSV4OPBM_COMMIT |						\
1591 	NFSV4OPBM_DELEGRETURN |						\
1592 	NFSV4OPBM_LOCKU |						\
1593 	NFSV4OPBM_OPENDOWNGRADE)
1594 
1595 #define	NFSOPBIT_ALLOWED1						\
1596 	(NFSV4OPBM_SECINFO |						\
1597 	NFSV4OPBM_WRITE |						\
1598 	NFSV4OPBM_FREESTATEID |						\
1599 	NFSV4OPBM_LAYOUTRETURN |					\
1600 	NFSV4OPBM_SECINFONONAME |					\
1601 	NFSV4OPBM_TESTSTATEID)
1602 
1603 #define	NFSOPBIT_ALLOWED2	0x0
1604 
1605 #define	NFSOPBIT_CLRNOTALLOWED(b) do {					\
1606 	(b)->bits[0] &= NFSOPBIT_ALLOWED0;				\
1607 	(b)->bits[1] &= NFSOPBIT_ALLOWED1;				\
1608 	(b)->bits[2] &= NFSOPBIT_ALLOWED2;				\
1609     } while (0)
1610 
1611 /*
1612  * Structure for data handled by the statfs rpc. Since some fields are
1613  * u_int64_t, this cannot be used for copying data on/off the wire, due
1614  * to alignment concerns.
1615  */
1616 struct nfsstatfs {
1617 	union {
1618 		struct {
1619 			u_int32_t nfsv2sf_tsize;
1620 			u_int32_t nfsv2sf_bsize;
1621 			u_int32_t nfsv2sf_blocks;
1622 			u_int32_t nfsv2sf_bfree;
1623 			u_int32_t nfsv2sf_bavail;
1624 		} sf_nfsv2;
1625 		struct {
1626 			u_int64_t nfsv3sf_tbytes;
1627 			u_int64_t nfsv3sf_fbytes;
1628 			u_int64_t nfsv3sf_abytes;
1629 			u_int64_t nfsv3sf_tfiles;
1630 			u_int64_t nfsv3sf_ffiles;
1631 			u_int64_t nfsv3sf_afiles;
1632 			u_int32_t nfsv3sf_invarsec;
1633 		} sf_nfsv3;
1634 	} sf_un;
1635 };
1636 
1637 #define	sf_tsize	sf_un.sf_nfsv2.nfsv2sf_tsize
1638 #define	sf_bsize	sf_un.sf_nfsv2.nfsv2sf_bsize
1639 #define	sf_blocks	sf_un.sf_nfsv2.nfsv2sf_blocks
1640 #define	sf_bfree	sf_un.sf_nfsv2.nfsv2sf_bfree
1641 #define	sf_bavail	sf_un.sf_nfsv2.nfsv2sf_bavail
1642 #define	sf_tbytes	sf_un.sf_nfsv3.nfsv3sf_tbytes
1643 #define	sf_fbytes	sf_un.sf_nfsv3.nfsv3sf_fbytes
1644 #define	sf_abytes	sf_un.sf_nfsv3.nfsv3sf_abytes
1645 #define	sf_tfiles	sf_un.sf_nfsv3.nfsv3sf_tfiles
1646 #define	sf_ffiles	sf_un.sf_nfsv3.nfsv3sf_ffiles
1647 #define	sf_afiles	sf_un.sf_nfsv3.nfsv3sf_afiles
1648 #define	sf_invarsec	sf_un.sf_nfsv3.nfsv3sf_invarsec
1649 
1650 /*
1651  * Now defined using u_int64_t for the 64 bit field(s).
1652  * (Cannot be used to move data on/off the wire, due to alignment concerns.)
1653  */
1654 struct nfsfsinfo {
1655 	u_int32_t fs_rtmax;
1656 	u_int32_t fs_rtpref;
1657 	u_int32_t fs_rtmult;
1658 	u_int32_t fs_wtmax;
1659 	u_int32_t fs_wtpref;
1660 	u_int32_t fs_wtmult;
1661 	u_int32_t fs_dtpref;
1662 	u_int64_t fs_maxfilesize;
1663 	struct timespec fs_timedelta;
1664 	u_int32_t fs_properties;
1665 };
1666 
1667 /*
1668  * Bits for fs_properties
1669  */
1670 #define	NFSV3_FSFLINK		0x1
1671 #define	NFSV3_FSFSYMLINK	0x2
1672 #define	NFSV3_FSFHOMOGENEOUS	0x4
1673 #define	NFSV3_FSFCANSETTIME	0x8
1674 
1675 /*
1676  * Yikes, overload fs_rtmult as fs_maxname for V4.
1677  */
1678 #define	fs_maxname	fs_rtmult
1679 
1680 struct nfsv3_pathconf {
1681 	u_int32_t pc_linkmax;
1682 	u_int32_t pc_namemax;
1683 	u_int32_t pc_notrunc;
1684 	u_int32_t pc_chownrestricted;
1685 	u_int32_t pc_caseinsensitive;
1686 	u_int32_t pc_casepreserving;
1687 };
1688 
1689 /*
1690  * NFS V4 data structures.
1691  */
1692 struct nfsv4stateid {
1693 	u_int32_t	seqid;
1694 	u_int32_t	other[NFSX_STATEIDOTHER / NFSX_UNSIGNED];
1695 };
1696 typedef struct nfsv4stateid nfsv4stateid_t;
1697 
1698 /* Notify bits and notify bitmap size. */
1699 #define	NFSV4NOTIFY_CHANGE	1
1700 #define	NFSV4NOTIFY_DELETE	2
1701 #define	NFSV4_NOTIFYBITMAP	1	/* # of 32bit values needed for bits */
1702 
1703 /* Layoutreturn kinds. */
1704 #define	NFSV4LAYOUTRET_FILE	1
1705 #define	NFSV4LAYOUTRET_FSID	2
1706 #define	NFSV4LAYOUTRET_ALL	3
1707 
1708 /* Seek Contents. */
1709 #define	NFSV4CONTENT_DATA	0
1710 #define	NFSV4CONTENT_HOLE	1
1711 
1712 /* Options for Set Extended attribute (RFC-8276). */
1713 #define	NFSV4SXATTR_EITHER	0
1714 #define	NFSV4SXATTR_CREATE	1
1715 #define	NFSV4SXATTR_REPLACE	2
1716 
1717 /* Definitions for POSIX draft ACLs for NFSv4.2. */
1718 #define	NFSV4_ACL_MODEL_NFS4		1
1719 #define	NFSV4_ACL_MODEL_POSIX_DRAFT	2
1720 #define	NFSV4_ACL_MODEL_NONE		3
1721 
1722 #define	NFSV4_ACL_SCOPE_FILE_OBJECT	1
1723 #define	NFSV4_ACL_SCOPE_FILE_SYSTEM	2
1724 #define	NFSV4_ACL_SCOPE_SERVER		3
1725 
1726 #define	NFSV4_POSIXACL_TAG_USER_OBJ	1
1727 #define	NFSV4_POSIXACL_TAG_USER		2
1728 #define	NFSV4_POSIXACL_TAG_GROUP_OBJ	3
1729 #define	NFSV4_POSIXACL_TAG_GROUP	4
1730 #define	NFSV4_POSIXACL_TAG_MASK		5
1731 #define	NFSV4_POSIXACL_TAG_OTHER	6
1732 
1733 #define	NFSV4_POSIXACL_PERM_PERM_EXECUTE	0x00000001
1734 #define	NFSV4_POSIXACL_PERM_PERM_WRITE		0x00000002
1735 #define	NFSV4_POSIXACL_PERM_PERM_READ		0x00000004
1736 
1737 /* Values for ChangeAttrType (RFC-7862). */
1738 #define	NFSV4CHANGETYPE_MONOTONIC_INCR		0
1739 #define	NFSV4CHANGETYPE_VERS_COUNTER		1
1740 #define	NFSV4CHANGETYPE_VERS_COUNTER_NOPNFS	2
1741 #define	NFSV4CHANGETYPE_TIME_METADATA		3
1742 #define	NFSV4CHANGETYPE_UNDEFINED		4
1743 
1744 #endif	/* _NFS_NFSPROTO_H_ */
1745