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