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