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