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