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