xref: /freebsd/sys/nfs/nfsproto.h (revision 61ba55bcf70f2340f9c943c9571113b3fd8eda69)
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  *	@(#)nfsproto.h  8.2 (Berkeley) 3/30/95
35  */
36 
37 #ifndef _NFS_NFSPROTO_H_
38 #define _NFS_NFSPROTO_H_
39 
40 /*
41  * nfs definitions as per the Version 2 and 3 specs
42  */
43 
44 /*
45  * Constants as defined in the Sun NFS Version 2 and 3 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_VER2	2
54 #define	NFS_VER3	3
55 #define NFS_VER4	4
56 
57 #define NFS_V2MAXDATA	8192
58 #define	NFS_MAXDGRAMDATA 16384
59 #define	NFS_MAXDATA	32768
60 #define	NFS_MAXPATHLEN	1024
61 #define	NFS_MAXNAMLEN	255
62 #define	NFS_MAXPKTHDR	404	/* XXXv4 this needs to be adjust for v4 */
63 #define NFS_MAXPACKET	(NFS_MAXPKTHDR + NFS_MAXDATA)
64 #define	NFS_MINPACKET	20
65 #define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
66 
67 /* Stat numbers for rpc returns (version 2, 3 and 4) */
68 #define	NFS_OK			0
69 #define	NFSERR_PERM		1
70 #define	NFSERR_NOENT		2
71 #define	NFSERR_IO		5
72 #define	NFSERR_NXIO		6
73 #define	NFSERR_ACCES		13
74 #define	NFSERR_EXIST		17
75 #define	NFSERR_XDEV		18	/* Version 3 only */
76 #define	NFSERR_NODEV		19
77 #define	NFSERR_NOTDIR		20
78 #define	NFSERR_ISDIR		21
79 #define	NFSERR_INVAL		22	/* Version 3 only */
80 #define	NFSERR_FBIG		27
81 #define	NFSERR_NOSPC		28
82 #define	NFSERR_ROFS		30
83 #define	NFSERR_MLINK		31	/* Version 3 only */
84 #define	NFSERR_NAMETOL		63
85 #define	NFSERR_NOTEMPTY		66
86 #define	NFSERR_DQUOT		69
87 #define	NFSERR_STALE		70
88 #define	NFSERR_REMOTE		71	/* Version 3 only */
89 #define	NFSERR_WFLUSH		99	/* Version 2 only */
90 #define	NFSERR_BADHANDLE	10001	/* The rest Version 3, 4 only */
91 #define	NFSERR_NOT_SYNC		10002
92 #define	NFSERR_BAD_COOKIE	10003
93 #define	NFSERR_NOTSUPP		10004
94 #define	NFSERR_TOOSMALL		10005
95 #define	NFSERR_SERVERFAULT	10006
96 #define	NFSERR_BADTYPE		10007
97 #define	NFSERR_JUKEBOX		10008
98 #define NFSERR_TRYLATER		NFSERR_JUKEBOX
99 #define	NFSERR_SAME		10009   /* The rest 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_SHARDE_DENIED	10015
106 #define	NFSERR_WRONGSEC		10016
107 #define	NFSERR_CLID_INUSE	10017
108 #define	NFSERR_RESOURCE		10018
109 #define	NFSERR_MOVED		10019
110 #define	NFSERR_NOFILEHANDLE	10020
111 #define	NFSERR_MINOR_VERS_MISMATCH 10021
112 #define	NFSERR_STALE_CLIENTID	10022
113 #define	NFSERR_STALE_STATEID	10023
114 #define	NFSERR_OLD_STATEID	10024
115 #define	NFSERR_BAD_STATEID	10025
116 #define	NFSERR_BAD_SEQID	10026
117 #define	NFSERR_NOT_SAME		10027
118 #define	NFSERR_LOCK_RANGE	10028
119 #define	NFSERR_SYMLINK		10029
120 #define	NFSERR_READDIR_NOSPC	10030
121 #define	NFSERR_LEASE_MOVED	10031
122 #define	NFSERR_ATTRNOTSUPP	10032
123 #define	NFSERR_NO_GRACE		10033
124 #define	NFSERR_RECLAIM_BAD	10034
125 #define	NFSERR_RECLAIM_CONFLICT	10035
126 #define	NFSERR_BADXDR		10036
127 #define	NFSERR_LOCKS_HELD	10037
128 #define	NFSERR_OPENMODE		10038
129 #define	NFSERR_BADOWNER		10039
130 #define	NFSERR_BADCHAR		10040
131 #define	NFSERR_BADNAME		10041
132 #define	NFSERR_BAD_RANGE	10042
133 #define	NFSERR_LOCK_NOTSUPP	10043
134 #define	NFSERR_OP_ILLEGAL	10044
135 #define	NFSERR_DEADLOCK		10045
136 #define	NFSERR_FILE_OPEN	10046
137 #define	NFSERR_STALEWRITEVERF	30001	/* Fake return for nfs_commit() */
138 
139 #define NFSERR_RETVOID		0x20000000 /* Return void, not error */
140 #define NFSERR_AUTHERR		0x40000000 /* Mark an authentication error */
141 #define NFSERR_RETERR		0x80000000 /* Mark an error return for V3 */
142 
143 /* Sizes in bytes of various nfs rpc components */
144 #define	NFSX_UNSIGNED	4
145 
146 /* specific to NFS Version 2 */
147 #define	NFSX_V2FH	32
148 #define	NFSX_V2FATTR	68
149 #define	NFSX_V2SATTR	32
150 #define	NFSX_V2COOKIE	4
151 #define NFSX_V2STATFS	20
152 
153 /* specific to NFS Version 3 */
154 #define NFSX_V3FH		(sizeof (fhandle_t)) /* size this server uses */
155 #define	NFSX_V3FHMAX		64	/* max. allowed by protocol */
156 #define NFSX_V3FATTR		84
157 #define NFSX_V3SATTR		60	/* max. all fields filled in */
158 #define NFSX_V3SRVSATTR		(sizeof (struct nfsv3_sattr))
159 #define NFSX_V3POSTOPATTR	(NFSX_V3FATTR + NFSX_UNSIGNED)
160 #define NFSX_V3WCCDATA		(NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
161 #define NFSX_V3COOKIEVERF 	8
162 #define NFSX_V3WRITEVERF 	8
163 #define NFSX_V3CREATEVERF	8
164 #define NFSX_V3STATFS		52
165 #define NFSX_V3FSINFO		48
166 #define NFSX_V3PATHCONF		24
167 
168 /* specific to NFS Version 4 */
169 #define NFSX_V4VERF		8
170 #define NFSX_V4FH		128
171 #define NFSX_V4STATEID		16
172 
173 /* variants for both versions */
174 #define NFSX_FH(v3)		((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
175 					NFSX_V2FH)
176 #define NFSX_SRVFH(v3)		((v3) ? NFSX_V3FH : NFSX_V2FH)
177 #define	NFSX_FATTR(v3)		((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
178 #define NFSX_PREOPATTR(v3)	((v3) ? (7 * NFSX_UNSIGNED) : 0)
179 #define NFSX_POSTOPATTR(v3)	((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
180 #define NFSX_POSTOPORFATTR(v3)	((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
181 					NFSX_V2FATTR)
182 #define NFSX_WCCDATA(v3)	((v3) ? NFSX_V3WCCDATA : 0)
183 #define NFSX_WCCORFATTR(v3)	((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
184 #define	NFSX_SATTR(v3)		((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
185 #define	NFSX_COOKIEVERF(v3)	((v3) ? NFSX_V3COOKIEVERF : 0)
186 #define	NFSX_WRITEVERF(v3)	((v3) ? NFSX_V3WRITEVERF : 0)
187 #define NFSX_READDIR(v3)	((v3) ? (5 * NFSX_UNSIGNED) : \
188 					(2 * NFSX_UNSIGNED))
189 #define	NFSX_STATFS(v3)		((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
190 
191 /* nfs rpc procedure numbers (before version mapping) */
192 #define	NFSPROC_NULL		0
193 #define	NFSPROC_GETATTR		1
194 #define	NFSPROC_SETATTR		2
195 #define	NFSPROC_LOOKUP		3
196 #define	NFSPROC_ACCESS		4
197 #define	NFSPROC_READLINK	5
198 #define	NFSPROC_READ		6
199 #define	NFSPROC_WRITE		7
200 #define	NFSPROC_CREATE		8
201 #define	NFSPROC_MKDIR		9
202 #define	NFSPROC_SYMLINK		10
203 #define	NFSPROC_MKNOD		11
204 #define	NFSPROC_REMOVE		12
205 #define	NFSPROC_RMDIR		13
206 #define	NFSPROC_RENAME		14
207 #define	NFSPROC_LINK		15
208 #define	NFSPROC_READDIR		16
209 #define	NFSPROC_READDIRPLUS	17
210 #define	NFSPROC_FSSTAT		18
211 #define	NFSPROC_FSINFO		19
212 #define	NFSPROC_PATHCONF	20
213 #define	NFSPROC_COMMIT		21
214 #define NFSPROC_NOOP		22
215 #define	NFS_NPROCS		23
216 
217 /* Actual Version 2 procedure numbers */
218 #define	NFSV2PROC_NULL		0
219 #define	NFSV2PROC_GETATTR	1
220 #define	NFSV2PROC_SETATTR	2
221 #define	NFSV2PROC_NOOP		3
222 #define	NFSV2PROC_ROOT		NFSV2PROC_NOOP	/* Obsolete */
223 #define	NFSV2PROC_LOOKUP	4
224 #define	NFSV2PROC_READLINK	5
225 #define	NFSV2PROC_READ		6
226 #define	NFSV2PROC_WRITECACHE	NFSV2PROC_NOOP	/* Obsolete */
227 #define	NFSV2PROC_WRITE		8
228 #define	NFSV2PROC_CREATE	9
229 #define	NFSV2PROC_REMOVE	10
230 #define	NFSV2PROC_RENAME	11
231 #define	NFSV2PROC_LINK		12
232 #define	NFSV2PROC_SYMLINK	13
233 #define	NFSV2PROC_MKDIR		14
234 #define	NFSV2PROC_RMDIR		15
235 #define	NFSV2PROC_READDIR	16
236 #define	NFSV2PROC_STATFS	17
237 
238 /* Version 4 procedure numbers */
239 #define NFSV4PROC_NULL         0
240 #define NFSV4PROC_COMPOUND     1
241 
242 /* Version 4 operation numbers */
243 #define NFSV4OP_ACCESS		3
244 #define NFSV4OP_CLOSE		4
245 #define NFSV4OP_COMMIT		5
246 #define NFSV4OP_CREATE		6
247 #define NFSV4OP_DELEGPURGE	7
248 #define NFSV4OP_DELEGRETURN	8
249 #define NFSV4OP_GETATTR		9
250 #define NFSV4OP_GETFH		10
251 #define NFSV4OP_LINK		11
252 #define NFSV4OP_LOCK		12
253 #define NFSV4OP_LOCKT		13
254 #define NFSV4OP_LOCKU		14
255 #define NFSV4OP_LOOKUP		15
256 #define NFSV4OP_LOOKUPP		16
257 #define NFSV4OP_NVERIFY		17
258 #define NFSV4OP_OPEN		18
259 #define NFSV4OP_OPENATTR	19
260 #define NFSV4OP_OPEN_CONFIRM	20
261 #define NFSV4OP_OPEN_DOWNGRADE	21
262 #define NFSV4OP_PUTFH		22
263 #define NFSV4OP_PUTPUBFH	23
264 #define NFSV4OP_PUTROOTFH	24
265 #define NFSV4OP_READ		25
266 #define NFSV4OP_READDIR		26
267 #define NFSV4OP_READLINK	27
268 #define NFSV4OP_REMOVE		28
269 #define NFSV4OP_RENAME		29
270 #define NFSV4OP_RENEW		30
271 #define NFSV4OP_RESTOREFH	31
272 #define NFSV4OP_SAVEFH		32
273 #define NFSV4OP_SECINFO		33
274 #define NFSV4OP_SETATTR		34
275 #define NFSV4OP_SETCLIENTID	35
276 #define NFSV4OP_SETCLIENTID_CONFIRM 36
277 #define NFSV4OP_VERIFY		37
278 #define NFSV4OP_WRITE		38
279 
280 /*
281  * Constants used by the Version 3 protocol for various RPCs
282  */
283 #define NFSV3SATTRTIME_DONTCHANGE	0
284 #define NFSV3SATTRTIME_TOSERVER		1
285 #define NFSV3SATTRTIME_TOCLIENT		2
286 
287 #define NFSV3ACCESS_READ		0x01
288 #define NFSV3ACCESS_LOOKUP		0x02
289 #define NFSV3ACCESS_MODIFY		0x04
290 #define NFSV3ACCESS_EXTEND		0x08
291 #define NFSV3ACCESS_DELETE		0x10
292 #define NFSV3ACCESS_EXECUTE		0x20
293 
294 #define NFSV3WRITE_UNSTABLE		0
295 #define NFSV3WRITE_DATASYNC		1
296 #define NFSV3WRITE_FILESYNC		2
297 
298 #define NFSV3CREATE_UNCHECKED		0
299 #define NFSV3CREATE_GUARDED		1
300 #define NFSV3CREATE_EXCLUSIVE		2
301 
302 #define NFSV3FSINFO_LINK		0x01
303 #define NFSV3FSINFO_SYMLINK		0x02
304 #define NFSV3FSINFO_HOMOGENEOUS		0x08
305 #define NFSV3FSINFO_CANSETTIME		0x10
306 
307 /*
308  * Constants used by the Version 4 protocol for various RPCs
309  */
310 
311 #define NFSV4ACCESS_READ		0x01
312 #define NFSV4ACCESS_LOOKUP		0x02
313 #define NFSV4ACCESS_MODIFY		0x04
314 #define NFSV4ACCESS_EXTEND		0x08
315 #define NFSV4ACCESS_DELETE		0x10
316 #define NFSV4ACCESS_EXECUTE		0x20
317 
318 #define NFSV4OPENRES_MLOCK		0x01
319 #define NFSV4OPENRES_CONFIRM		0x02
320 
321 #define NFSV4OPENSHARE_ACCESS_READ	0x01
322 #define NFSV4OPENSHARE_ACCESS_WRITE	0x02
323 #define NFSV4OPENSHARE_ACCESS_BOTH	0x03
324 #define NFSV4OPENSHARE_DENY_NONE	0x00
325 #define NFSV4OPENSHARE_DENY_READ	0x01
326 #define NFSV4OPENSHARE_DENY_WRITE	0x02
327 #define NFSV4OPENSHARE_DENY_BOTH	0x03
328 
329 /* File types */
330 typedef enum {
331 	NFNON=0,
332 	NFREG=1,
333 	NFDIR=2,
334 	NFBLK=3,
335 	NFCHR=4,
336 	NFLNK=5,
337 	NFSOCK=6,
338 	NFFIFO=7,
339 	NFATTRDIR = 8,
340 	NFNAMEDATTR = 9,
341 	NFBAD = 10,
342 } nfstype;
343 
344 /* NFSv4 claim type */
345 typedef enum {
346 	NCLNULL = 0,
347 	NCLPREV = 1,
348 	NCLDELEGCUR = 2,
349 	NCLDELEGPREV = 3,
350 } nfsv4cltype;
351 
352 /* Other NFSv4 types */
353 typedef enum {
354 	NSHUNSTABLE = 0,
355 	NSHDATASYNC = 1,
356 	NSHFILESYNC = 2,
357 } nfsv4stablehow;
358 
359 typedef enum { OTNOCREATE = 0, OTCREATE = 1 } nfsv4opentype;
360 typedef enum { CMUNCHECKED = 0, CMGUARDED = 1, CMEXCLUSIVE = 2 } nfsv4createmode;
361 typedef enum { THSERVERTIME = 0, THCLIENTTIME = 1 } nfsv4timehow;
362 typedef enum { ODNONE = 0, ODREAD = 1, ODWRITE = 2 } nfsv4opendelegtype;
363 
364 /* Structs for common parts of the rpc's */
365 
366 /*
367  * File Handle (32 bytes for version 2), variable up to 64 for version 3.
368  * File Handles of up to NFS_SMALLFH in size are stored directly in the
369  * nfs node, whereas larger ones are malloc'd. (This never happens when
370  * NFS_SMALLFH is set to 64.)
371  * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
372  */
373 #ifndef NFS_SMALLFH
374 #define NFS_SMALLFH	128
375 #endif
376 union nfsfh {
377 	fhandle_t	fh_generic;
378 	u_char		fh_bytes[NFS_SMALLFH];
379 };
380 typedef union nfsfh nfsfh_t;
381 
382 struct nfsv2_time {
383 	u_int32_t	nfsv2_sec;
384 	u_int32_t	nfsv2_usec;
385 };
386 typedef struct nfsv2_time	nfstime2;
387 
388 struct nfsv3_time {
389 	u_int32_t	nfsv3_sec;
390 	u_int32_t	nfsv3_nsec;
391 };
392 typedef struct nfsv3_time	nfstime3;
393 
394 /*
395  * Quads are defined as arrays of 2 longs to ensure dense packing for the
396  * protocol and to facilitate xdr conversion.
397  */
398 struct nfs_uquad {
399 	u_int32_t	nfsuquad[2];
400 };
401 typedef	struct nfs_uquad	nfsuint64;
402 
403 /*
404  * Used to convert between two u_longs and a u_quad_t.
405  */
406 union nfs_quadconvert {
407 	u_int32_t	lval[2];
408 	u_quad_t	qval;
409 };
410 typedef union nfs_quadconvert	nfsquad_t;
411 
412 /*
413  * NFS Version 3 special file number.
414  */
415 struct nfsv3_spec {
416 	u_int32_t	specdata1;
417 	u_int32_t	specdata2;
418 };
419 typedef	struct nfsv3_spec	nfsv3spec;
420 
421 /*
422  * NFS Version 4 bitmap.
423  */
424 struct nfsv4_bitmap {
425 	uint32_t	bmlen;
426 	uint32_t	*bmval;
427 };
428 typedef struct nfsv4_bitmap nfsv4bitmap;
429 
430 struct nfsv4_changeinfo {
431 	u_int		ciatomic;
432 	uint64_t	cibefore;
433 	uint64_t	ciafter;
434 };
435 typedef struct nfsv4_changeinfo nfsv4changeinfo;
436 
437 /*
438  * File attributes and setable attributes. These structures cover both
439  * NFS version 2 and the version 3 protocol. Note that the union is only
440  * used so that one pointer can refer to both variants. These structures
441  * go out on the wire and must be densely packed, so no quad data types
442  * are used. (all fields are longs or u_longs or structures of same)
443  * NB: You can't do sizeof(struct nfs_fattr), you must use the
444  *     NFSX_FATTR(v3) macro.
445  */
446 struct nfs_fattr {
447 	u_int32_t	fa_type;
448 	u_int32_t	fa_mode;
449 	u_int32_t	fa_nlink;
450 	u_int32_t	fa_uid;
451 	u_int32_t	fa_gid;
452 	union {
453 		struct {
454 			u_int32_t	nfsv2fa_size;
455 			u_int32_t	nfsv2fa_blocksize;
456 			u_int32_t	nfsv2fa_rdev;
457 			u_int32_t	nfsv2fa_blocks;
458 			u_int32_t	nfsv2fa_fsid;
459 			u_int32_t	nfsv2fa_fileid;
460 			nfstime2	nfsv2fa_atime;
461 			nfstime2	nfsv2fa_mtime;
462 			nfstime2	nfsv2fa_ctime;
463 		} fa_nfsv2;
464 		struct {
465 			nfsuint64	nfsv3fa_size;
466 			nfsuint64	nfsv3fa_used;
467 			nfsv3spec	nfsv3fa_rdev;
468 			nfsuint64	nfsv3fa_fsid;
469 			nfsuint64	nfsv3fa_fileid;
470 			nfstime3	nfsv3fa_atime;
471 			nfstime3	nfsv3fa_mtime;
472 			nfstime3	nfsv3fa_ctime;
473 		} fa_nfsv3;
474 	} fa_un;
475 };
476 
477 /* and some ugly defines for accessing union components */
478 #define	fa2_size		fa_un.fa_nfsv2.nfsv2fa_size
479 #define	fa2_blocksize		fa_un.fa_nfsv2.nfsv2fa_blocksize
480 #define	fa2_rdev		fa_un.fa_nfsv2.nfsv2fa_rdev
481 #define	fa2_blocks		fa_un.fa_nfsv2.nfsv2fa_blocks
482 #define	fa2_fsid		fa_un.fa_nfsv2.nfsv2fa_fsid
483 #define	fa2_fileid		fa_un.fa_nfsv2.nfsv2fa_fileid
484 #define	fa2_atime		fa_un.fa_nfsv2.nfsv2fa_atime
485 #define	fa2_mtime		fa_un.fa_nfsv2.nfsv2fa_mtime
486 #define	fa2_ctime		fa_un.fa_nfsv2.nfsv2fa_ctime
487 #define	fa3_size		fa_un.fa_nfsv3.nfsv3fa_size
488 #define	fa3_used		fa_un.fa_nfsv3.nfsv3fa_used
489 #define	fa3_rdev		fa_un.fa_nfsv3.nfsv3fa_rdev
490 #define	fa3_fsid		fa_un.fa_nfsv3.nfsv3fa_fsid
491 #define	fa3_fileid		fa_un.fa_nfsv3.nfsv3fa_fileid
492 #define	fa3_atime		fa_un.fa_nfsv3.nfsv3fa_atime
493 #define	fa3_mtime		fa_un.fa_nfsv3.nfsv3fa_mtime
494 #define	fa3_ctime		fa_un.fa_nfsv3.nfsv3fa_ctime
495 
496 struct nfsv4_fattr {
497 	u_int		fa4_valid;
498 	nfstype		fa4_type;
499 	off_t		fa4_size;
500 	uint64_t	fa4_fsid_major;
501 	uint64_t	fa4_fsid_minor;
502 	uint64_t	fa4_fileid;
503 	mode_t		fa4_mode;
504 	nlink_t		fa4_nlink;
505 	uid_t		fa4_uid;
506 	gid_t		fa4_gid;
507 	uint32_t	fa4_rdev_major;
508 	uint32_t	fa4_rdev_minor;
509 	struct timespec	fa4_atime;
510 	struct timespec	fa4_btime;
511 	struct timespec	fa4_ctime;
512 	struct timespec	fa4_mtime;
513 	uint64_t	fa4_maxread;
514 	uint64_t	fa4_maxwrite;
515 	uint64_t	fa4_ffree;
516 	uint64_t	fa4_ftotal;
517 	uint32_t	fa4_maxname;
518 	uint64_t	fa4_savail;
519 	uint64_t	fa4_sfree;
520 	uint64_t	fa4_stotal;
521 	uint64_t	fa4_changeid;
522 	uint32_t	fa4_lease_time;
523 	uint64_t	fa4_maxfilesize;
524 };
525 
526 /* Flags for fa4_valid */
527 #define FA4V_SIZE	0x00000001
528 #define FA4V_FSID	0x00000002
529 #define FA4V_FILEID	0x00000004
530 #define FA4V_MODE	0x00000008
531 #define FA4V_NLINK	0x00000010
532 #define FA4V_UID	0x00000020
533 #define FA4V_GID	0x00000040
534 #define FA4V_RDEV	0x00000080
535 #define FA4V_ATIME	0x00000100
536 #define FA4V_BTIME	0x00000200
537 #define FA4V_CTIME	0x00000400
538 #define FA4V_MTIME	0x00000800
539 #define FA4V_MAXREAD	0x00001000
540 #define FA4V_MAXWRITE	0x00002000
541 #define FA4V_TYPE	0x00004000
542 #define FA4V_FFREE	0x00008000
543 #define FA4V_FTOTAL	0x00010000
544 #define FA4V_MAXNAME	0x00020000
545 #define FA4V_SAVAIL	0x00040000
546 #define FA4V_SFREE	0x00080000
547 #define FA4V_STOTAL	0x00100000
548 #define FA4V_CHANGEID	0x00200000
549 #define FA4V_LEASE_TIME	0x00400000
550 #define FA4V_MAXFILESIZE 0x00800000
551 #define FA4V_ACL	0x01000000
552 
553 /* Offsets into bitmask */
554 #define FA4_SUPPORTED_ATTRS	0
555 #define FA4_TYPE		1
556 #define FA4_FH_EXPIRE_TYPE	2
557 #define FA4_CHANGE		3
558 #define FA4_SIZE		4
559 #define FA4_LINK_SUPPORT	5
560 #define FA4_SYMLINK_SUPPORT	6
561 #define FA4_NAMED_ATTR		7
562 #define FA4_FSID		8
563 #define FA4_UNIQUE_HANDLES	9
564 #define FA4_LEASE_TIME		10
565 #define FA4_RDATTR_ERROR	11
566 #define FA4_ACL			12
567 #define FA4_ACLSUPPORT		13
568 #define FA4_ARCHIVE		14
569 #define FA4_CANSETTIME		15
570 #define FA4_CASE_INSENSITIVE	16
571 #define FA4_CASE_PRESERVING	17
572 #define FA4_CHOWN_RESTRICTED	18
573 #define FA4_FILEHANDLE		19
574 #define FA4_FILEID		20
575 #define FA4_FILES_AVAIL		21
576 #define FA4_FILES_FREE		22
577 #define FA4_FILES_TOTAL		23
578 #define FA4_FS_LOCATIONS	24
579 #define FA4_HIDDEN		25
580 #define FA4_HOMOGENEOUS		26
581 #define FA4_MAXFILESIZE		27
582 #define FA4_MAXLINK		28
583 #define FA4_MAXNAME		29
584 #define FA4_MAXREAD		30
585 #define FA4_MAXWRITE		31
586 #define FA4_MIMETYPE		32
587 #define FA4_MODE		33
588 #define FA4_NO_TRUNC		34
589 #define FA4_NUMLINKS		35
590 #define FA4_OWNER		36
591 #define FA4_OWNER_GROUP		37
592 #define FA4_QUOTA_HARD		38
593 #define FA4_QUOTA_SOFT		39
594 #define FA4_QUOTA_USED		40
595 #define FA4_RAWDEV		41
596 #define FA4_SPACE_AVAIL		42
597 #define FA4_SPACE_FREE		43
598 #define FA4_SPACE_TOTAL		44
599 #define FA4_SPACE_USED		45
600 #define FA4_SYSTEM		46
601 #define FA4_TIME_ACCESS		47
602 #define FA4_TIME_ACCESS_SET	48
603 #define FA4_TIME_BACKUP		49
604 #define FA4_TIME_CREATE		50
605 #define FA4_TIME_DELTA		51
606 #define FA4_TIME_METADATA	52
607 #define FA4_TIME_MODIFY		53
608 #define FA4_TIME_MODIFY_SET	54
609 #define FA4_ATTR_MAX		55
610 
611 /* Macros for v4 fattr manipulation */
612 #define FA4_SET(n, p)	((p)[(n)/32] |= (1 << ((n) % 32)))
613 #define FA4_CLR(n, p)	((p)[(n)/32] &= ~(1 << ((n) % 32)))
614 #define FA4_ISSET(n, p)	((p)[(n)/32] & (1 << ((n) % 32)))
615 #define FA4_ZERO(p)	bzero((p), 8)
616 #define FA4_SKIP(p)	((p) += 2)
617 
618 struct nfsv2_sattr {
619 	u_int32_t	sa_mode;
620 	u_int32_t	sa_uid;
621 	u_int32_t	sa_gid;
622 	u_int32_t	sa_size;
623 	nfstime2	sa_atime;
624 	nfstime2	sa_mtime;
625 };
626 
627 /*
628  * NFS Version 3 sattr structure for the new node creation case.
629  */
630 struct nfsv3_sattr {
631 	u_int32_t	sa_modetrue;
632 	u_int32_t	sa_mode;
633 	u_int32_t	sa_uidfalse;
634 	u_int32_t	sa_gidfalse;
635 	u_int32_t	sa_sizefalse;
636 	u_int32_t	sa_atimetype;
637 	nfstime3	sa_atime;
638 	u_int32_t	sa_mtimetype;
639 	nfstime3	sa_mtime;
640 };
641 
642 struct nfs_statfs {
643 	union {
644 		struct {
645 			u_int32_t	nfsv2sf_tsize;
646 			u_int32_t	nfsv2sf_bsize;
647 			u_int32_t	nfsv2sf_blocks;
648 			u_int32_t	nfsv2sf_bfree;
649 			u_int32_t	nfsv2sf_bavail;
650 		} sf_nfsv2;
651 		struct {
652 			nfsuint64	nfsv3sf_tbytes;
653 			nfsuint64	nfsv3sf_fbytes;
654 			nfsuint64	nfsv3sf_abytes;
655 			nfsuint64	nfsv3sf_tfiles;
656 			nfsuint64	nfsv3sf_ffiles;
657 			nfsuint64	nfsv3sf_afiles;
658 			u_int32_t	nfsv3sf_invarsec;
659 		} sf_nfsv3;
660 	} sf_un;
661 };
662 
663 #define sf_tsize	sf_un.sf_nfsv2.nfsv2sf_tsize
664 #define sf_bsize	sf_un.sf_nfsv2.nfsv2sf_bsize
665 #define sf_blocks	sf_un.sf_nfsv2.nfsv2sf_blocks
666 #define sf_bfree	sf_un.sf_nfsv2.nfsv2sf_bfree
667 #define sf_bavail	sf_un.sf_nfsv2.nfsv2sf_bavail
668 #define sf_tbytes	sf_un.sf_nfsv3.nfsv3sf_tbytes
669 #define sf_fbytes	sf_un.sf_nfsv3.nfsv3sf_fbytes
670 #define sf_abytes	sf_un.sf_nfsv3.nfsv3sf_abytes
671 #define sf_tfiles	sf_un.sf_nfsv3.nfsv3sf_tfiles
672 #define sf_ffiles	sf_un.sf_nfsv3.nfsv3sf_ffiles
673 #define sf_afiles	sf_un.sf_nfsv3.nfsv3sf_afiles
674 #define sf_invarsec	sf_un.sf_nfsv3.nfsv3sf_invarsec
675 
676 struct nfsv3_fsinfo {
677 	u_int32_t	fs_rtmax;
678 	u_int32_t	fs_rtpref;
679 	u_int32_t	fs_rtmult;
680 	u_int32_t	fs_wtmax;
681 	u_int32_t	fs_wtpref;
682 	u_int32_t	fs_wtmult;
683 	u_int32_t	fs_dtpref;
684 	nfsuint64	fs_maxfilesize;
685 	nfstime3	fs_timedelta;
686 	u_int32_t	fs_properties;
687 };
688 
689 struct nfsv3_pathconf {
690 	u_int32_t	pc_linkmax;
691 	u_int32_t	pc_namemax;
692 	u_int32_t	pc_notrunc;
693 	u_int32_t	pc_chownrestricted;
694 	u_int32_t	pc_caseinsensitive;
695 	u_int32_t	pc_casepreserving;
696 };
697 
698 #endif
699