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