2 * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
30 * Copyright (c) 1989, 1993
31 * The Regents of the University of California. All rights reserved.
33 * This code is derived from software contributed to Berkeley by
34 * Rick Macklem at The University of Guelph.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the University of
47 * California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
65 * FreeBSD-Id: nfsproto.h,v 1.3 1997/02/22 09:42:50 peter Exp $
68 #ifndef _NFS_NFSPROTO_H_
69 #define _NFS_NFSPROTO_H_
71 #include <sys/appleapiopts.h>
73 #ifdef __APPLE_API_PRIVATE
76 * NFS definitions per the various NFS protocol specs:
77 * Version 2 (RFC 1094), Version 3 (RFC 1813), and Version 4 (RFC 3530)
78 * and various protocol-related implementation definitions.
81 /* Only define these if nfs_prot.h hasn't been included */
85 #define NFS_PROG 100003
89 #define NFS_V2MAXDATA 8192
90 #define NFS_MAXDGRAMDATA 16384
91 #define NFS_PREFDGRAMDATA 8192
92 #define NFS_MAXDATA (8 * 64 * PAGE_SIZE) /* Same as NFS_MAXBSIZE from nfsnode.h */
93 #define NFS_MAXPATHLEN 1024
94 #define NFS_MAXNAMLEN 255
95 #define NFS_MAXPACKET (16 * 1024 * 1024)
96 #define NFS_UDPSOCKBUF (224 * 1024)
97 #define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
99 #define NFSRV_MAXDATA NFS_MAXDATA
100 #define NFSRV_TCPSOCKBUF (2 * NFSRV_MAXDATA)
102 #define NFS4_CALLBACK_PROG 0x4E465343 /* "NFSC" */
103 #define NFS4_CALLBACK_PROG_VERSION 1
105 /* Stat numbers for NFS RPC returns */
107 #define NFSERR_PERM 1
108 #define NFSERR_NOENT 2
110 #define NFSERR_NXIO 6
111 #define NFSERR_ACCES 13
112 #define NFSERR_EXIST 17
113 #define NFSERR_XDEV 18 /* Version 3 only */
114 #define NFSERR_NODEV 19
115 #define NFSERR_NOTDIR 20
116 #define NFSERR_ISDIR 21
117 #define NFSERR_INVAL 22 /* Version 3 only */
118 #define NFSERR_FBIG 27
119 #define NFSERR_NOSPC 28
120 #define NFSERR_ROFS 30
121 #define NFSERR_MLINK 31 /* Version 3 only */
122 #define NFSERR_NAMETOL 63
123 #define NFSERR_NOTEMPTY 66
124 #define NFSERR_DQUOT 69
125 #define NFSERR_STALE 70
126 #define NFSERR_REMOTE 71 /* Version 3 only */
127 #define NFSERR_WFLUSH 99 /* Version 2 only */
128 #define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
129 #define NFSERR_NOT_SYNC 10002
130 #define NFSERR_BAD_COOKIE 10003
131 #define NFSERR_NOTSUPP 10004
132 #define NFSERR_TOOSMALL 10005
133 #define NFSERR_SERVERFAULT 10006
134 #define NFSERR_BADTYPE 10007
135 #define NFSERR_JUKEBOX 10008
136 #define NFSERR_TRYLATER NFSERR_JUKEBOX
137 #define NFSERR_DELAY NFSERR_JUKEBOX
138 #define NFSERR_SAME 10009 /* The rest Version 4 only */
139 #define NFSERR_DENIED 10010
140 #define NFSERR_EXPIRED 10011
141 #define NFSERR_LOCKED 10012
142 #define NFSERR_GRACE 10013
143 #define NFSERR_FHEXPIRED 10014
144 #define NFSERR_SHARE_DENIED 10015
145 #define NFSERR_WRONGSEC 10016
146 #define NFSERR_CLID_INUSE 10017
147 #define NFSERR_RESOURCE 10018
148 #define NFSERR_MOVED 10019
149 #define NFSERR_NOFILEHANDLE 10020
150 #define NFSERR_MINOR_VERS_MISMATCH 10021
151 #define NFSERR_STALE_CLIENTID 10022
152 #define NFSERR_STALE_STATEID 10023
153 #define NFSERR_OLD_STATEID 10024
154 #define NFSERR_BAD_STATEID 10025
155 #define NFSERR_BAD_SEQID 10026
156 #define NFSERR_NOT_SAME 10027
157 #define NFSERR_LOCK_RANGE 10028
158 #define NFSERR_SYMLINK 10029
159 #define NFSERR_RESTOREFH 10030
160 #define NFSERR_LEASE_MOVED 10031
161 #define NFSERR_ATTRNOTSUPP 10032
162 #define NFSERR_NO_GRACE 10033
163 #define NFSERR_RECLAIM_BAD 10034
164 #define NFSERR_RECLAIM_CONFLICT 10035
165 #define NFSERR_BADXDR 10036
166 #define NFSERR_LOCKS_HELD 10037
167 #define NFSERR_OPENMODE 10038
168 #define NFSERR_BADOWNER 10039
169 #define NFSERR_BADCHAR 10040
170 #define NFSERR_BADNAME 10041
171 #define NFSERR_BAD_RANGE 10042
172 #define NFSERR_LOCK_NOTSUPP 10043
173 #define NFSERR_OP_ILLEGAL 10044
174 #define NFSERR_DEADLOCK 10045
175 #define NFSERR_FILE_OPEN 10046
176 #define NFSERR_ADMIN_REVOKED 10047
177 #define NFSERR_CB_PATH_DOWN 10048
179 #define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
180 #define NFSERR_DIRBUFDROPPED 30002 /* Fake return for nfs*_readdir_rpc() */
183 * For gss we would like to return EAUTH when we don't have or can't get credentials,
184 * but some callers don't know what to do with it, so we define our own version
185 * of EAUTH to be EACCES
187 #define NFSERR_EAUTH EACCES
189 #define NFSERR_RETVOID 0x20000000 /* Return void, not error */
190 #define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
191 #define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
193 #endif /* !NFS_PROGRAM */
195 /* Sizes in bytes of various nfs rpc components */
196 #define NFSX_UNSIGNED 4
198 /* specific to NFS Version 2 */
200 #define NFSX_V2FATTR 68
201 #define NFSX_V2SATTR 32
202 #define NFSX_V2COOKIE 4
203 #define NFSX_V2STATFS 20
205 /* specific to NFS Version 3 */
206 #define NFSX_V3FHMAX 64 /* max. allowed by protocol */
207 #define NFSX_V3FATTR 84
208 #define NFSX_V3SATTR 60 /* max. all fields filled in */
209 #define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
210 #define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
211 #define NFSX_V3COOKIEVERF 8
212 #define NFSX_V3WRITEVERF 8
213 #define NFSX_V3CREATEVERF 8
214 #define NFSX_V3STATFS 52
215 #define NFSX_V3FSINFO 48
216 #define NFSX_V3PATHCONF 24
218 /* specific to NFS Version 4 */
219 #define NFS4_FHSIZE 128
220 #define NFS4_VERIFIER_SIZE 8
221 #define NFS4_OPAQUE_LIMIT 1024
223 /* variants for multiple versions */
224 #define NFSX_FH(V) (((V) == NFS_VER2) ? NFSX_V2FH : (NFSX_UNSIGNED + \
225 (((V) == NFS_VER3) ? NFSX_V3FHMAX : NFS4_FHSIZE)))
226 #define NFSX_SRVFH(V, FH) (((V) == NFS_VER2) ? NFSX_V2FH : (FH)->nfh_len)
227 #define NFSX_FATTR(V) (((V) == NFS_VER3) ? NFSX_V3FATTR : NFSX_V2FATTR)
228 #define NFSX_PREOPATTR(V) (((V) == NFS_VER3) ? (7 * NFSX_UNSIGNED) : 0)
229 #define NFSX_POSTOPATTR(V) (((V) == NFS_VER3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
230 #define NFSX_POSTOPORFATTR(V) (((V) == NFS_VER3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : NFSX_V2FATTR)
231 #define NFSX_WCCDATA(V) (((V) == NFS_VER3) ? NFSX_V3WCCDATA : 0)
232 #define NFSX_WCCORFATTR(V) (((V) == NFS_VER3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
233 #define NFSX_SATTR(V) (((V) == NFS_VER3) ? NFSX_V3SATTR : NFSX_V2SATTR)
234 #define NFSX_COOKIEVERF(V) (((V) == NFS_VER3) ? NFSX_V3COOKIEVERF : 0)
235 #define NFSX_WRITEVERF(V) (((V) == NFS_VER3) ? NFSX_V3WRITEVERF : 0)
236 #define NFSX_READDIR(V) (((V) == NFS_VER3) ? (5 * NFSX_UNSIGNED) : \
238 #define NFSX_STATFS(V) (((V) == NFS_VER3) ? NFSX_V3STATFS : NFSX_V2STATFS)
240 /* Only define these if nfs_prot.h hasn't been included */
243 /* nfs rpc procedure numbers (before version mapping) */
244 #define NFSPROC_NULL 0
245 #define NFSPROC_GETATTR 1
246 #define NFSPROC_SETATTR 2
247 #define NFSPROC_LOOKUP 3
248 #define NFSPROC_ACCESS 4
249 #define NFSPROC_READLINK 5
250 #define NFSPROC_READ 6
251 #define NFSPROC_WRITE 7
252 #define NFSPROC_CREATE 8
253 #define NFSPROC_MKDIR 9
254 #define NFSPROC_SYMLINK 10
255 #define NFSPROC_MKNOD 11
256 #define NFSPROC_REMOVE 12
257 #define NFSPROC_RMDIR 13
258 #define NFSPROC_RENAME 14
259 #define NFSPROC_LINK 15
260 #define NFSPROC_READDIR 16
261 #define NFSPROC_READDIRPLUS 17
262 #define NFSPROC_FSSTAT 18
263 #define NFSPROC_FSINFO 19
264 #define NFSPROC_PATHCONF 20
265 #define NFSPROC_COMMIT 21
267 #endif /* !NFS_PROGRAM */
269 #define NFSPROC_NOOP 22
270 #define NFS_NPROCS 23
272 /* Actual Version 2 procedure numbers */
273 #define NFSV2PROC_NULL 0
274 #define NFSV2PROC_GETATTR 1
275 #define NFSV2PROC_SETATTR 2
276 #define NFSV2PROC_NOOP 3
277 #define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
278 #define NFSV2PROC_LOOKUP 4
279 #define NFSV2PROC_READLINK 5
280 #define NFSV2PROC_READ 6
281 #define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
282 #define NFSV2PROC_WRITE 8
283 #define NFSV2PROC_CREATE 9
284 #define NFSV2PROC_REMOVE 10
285 #define NFSV2PROC_RENAME 11
286 #define NFSV2PROC_LINK 12
287 #define NFSV2PROC_SYMLINK 13
288 #define NFSV2PROC_MKDIR 14
289 #define NFSV2PROC_RMDIR 15
290 #define NFSV2PROC_READDIR 16
291 #define NFSV2PROC_STATFS 17
294 * Constants used by the Version 3 protocol for various RPCs
297 #define NFSV3FSINFO_LINK 0x01
298 #define NFSV3FSINFO_SYMLINK 0x02
299 #define NFSV3FSINFO_HOMOGENEOUS 0x08
300 #define NFSV3FSINFO_CANSETTIME 0x10
302 /* time setting constants */
303 #define NFS_TIME_DONT_CHANGE 0
304 #define NFS_TIME_SET_TO_SERVER 1
305 #define NFS_TIME_SET_TO_CLIENT 2
306 #define NFS4_TIME_SET_TO_SERVER 0
307 #define NFS4_TIME_SET_TO_CLIENT 1
309 /* access() constants */
310 #define NFS_ACCESS_READ 0x01
311 #define NFS_ACCESS_LOOKUP 0x02
312 #define NFS_ACCESS_MODIFY 0x04
313 #define NFS_ACCESS_EXTEND 0x08
314 #define NFS_ACCESS_DELETE 0x10
315 #define NFS_ACCESS_EXECUTE 0x20
316 #define NFS_ACCESS_ALL (NFS_ACCESS_READ | NFS_ACCESS_MODIFY \
317 | NFS_ACCESS_EXTEND | NFS_ACCESS_EXECUTE \
318 | NFS_ACCESS_DELETE | NFS_ACCESS_LOOKUP)
320 /* NFS WRITE how constants */
321 #define NFS_WRITE_UNSTABLE 0
322 #define NFS_WRITE_DATASYNC 1
323 #define NFS_WRITE_FILESYNC 2
325 /* NFS CREATE types */
326 #define NFS_CREATE_UNCHECKED 0
327 #define NFS_CREATE_GUARDED 1
328 #define NFS_CREATE_EXCLUSIVE 2
330 /* Only define these if nfs_prot.h hasn't been included */
332 /* NFS object types */
333 typedef enum { NFNON
=0, NFREG
=1, NFDIR
=2, NFBLK
=3, NFCHR
=4, NFLNK
=5,
334 NFSOCK
=6, NFFIFO
=7, NFATTRDIR
=8, NFNAMEDATTR
=9 } nfstype
;
335 #endif /* !NFS_PROGRAM */
338 * File Handle (32 bytes for version 2), variable up to 64 for version 3
339 * and variable up to 128 bytes for version 4.
340 * File Handles of up to NFS_SMALLFH in size are stored directly in the
341 * nfs node, whereas larger ones are malloc'd. (This never happens when
342 * NFS_SMALLFH is set to the largest size.)
343 * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
346 #define NFS_SMALLFH 64
350 * NFS attribute management stuff
352 #define NFS_ATTR_BITMAP_LEN 2
353 #define NFS_BITMAP_SET(B, I) (((uint32_t *)(B))[(I)/32] |= 1U<<((I)%32))
354 #define NFS_BITMAP_CLR(B, I) (((uint32_t *)(B))[(I)/32] &= ~(1U<<((I)%32)))
355 #define NFS_BITMAP_ISSET(B, I) (((uint32_t *)(B))[(I)/32] & (1U<<((I)%32)))
356 #define NFS_BITMAP_COPY_ATTR(FROM, TO, WHICH, ATTR) \
358 if (NFS_BITMAP_ISSET(((FROM)->nva_bitmap), (NFS_FATTR_##WHICH))) { \
359 (TO)->nva_##ATTR = (FROM)->nva_##ATTR; \
360 NFS_BITMAP_SET(((TO)->nva_bitmap), (NFS_FATTR_##WHICH)); \
363 #define NFS_BITMAP_COPY_TIME(FROM, TO, WHICH, ATTR) \
365 if (NFS_BITMAP_ISSET(((FROM)->nva_bitmap), (NFS_FATTR_TIME_##WHICH))) { \
366 (TO)->nva_timesec[NFSTIME_##ATTR] = (FROM)->nva_timesec[NFSTIME_##ATTR]; \
367 (TO)->nva_timensec[NFSTIME_##ATTR] = (FROM)->nva_timensec[NFSTIME_##ATTR]; \
368 NFS_BITMAP_SET(((TO)->nva_bitmap), (NFS_FATTR_TIME_##WHICH)); \
371 #define NFS_BITMAP_ZERO(B, L) \
374 for (__i=0; __i < (L); __i++) \
375 ((uint32_t*)(B))[__i] = 0; \
378 extern uint32_t nfs_fs_attr_bitmap
[NFS_ATTR_BITMAP_LEN
];
379 extern uint32_t nfs_object_attr_bitmap
[NFS_ATTR_BITMAP_LEN
];
380 extern uint32_t nfs_getattr_bitmap
[NFS_ATTR_BITMAP_LEN
];
381 extern uint32_t nfs4_getattr_write_bitmap
[NFS_ATTR_BITMAP_LEN
];
383 #define NFS_CLEAR_ATTRIBUTES(A) NFS_BITMAP_ZERO((A), NFS_ATTR_BITMAP_LEN)
384 #define NFS_COPY_ATTRIBUTES(SRC, DST) \
387 for (__i=0; __i < NFS_ATTR_BITMAP_LEN; __i++) \
388 ((uint32_t*)(DST))[__i] = ((uint32_t*)(SRC))[__i]; \
392 #define NFS_FATTR_SUPPORTED_ATTRS 0
393 #define NFS_FATTR_TYPE 1
394 #define NFS_FATTR_FH_EXPIRE_TYPE 2
395 #define NFS_FATTR_CHANGE 3
396 #define NFS_FATTR_SIZE 4
397 #define NFS_FATTR_LINK_SUPPORT 5
398 #define NFS_FATTR_SYMLINK_SUPPORT 6
399 #define NFS_FATTR_NAMED_ATTR 7
400 #define NFS_FATTR_FSID 8
401 #define NFS_FATTR_UNIQUE_HANDLES 9
402 #define NFS_FATTR_LEASE_TIME 10
403 #define NFS_FATTR_RDATTR_ERROR 11
404 #define NFS_FATTR_FILEHANDLE 19
405 #define NFS_FATTR_ACL 12
406 #define NFS_FATTR_ACLSUPPORT 13
407 #define NFS_FATTR_ARCHIVE 14
408 #define NFS_FATTR_CANSETTIME 15
409 #define NFS_FATTR_CASE_INSENSITIVE 16
410 #define NFS_FATTR_CASE_PRESERVING 17
411 #define NFS_FATTR_CHOWN_RESTRICTED 18
412 #define NFS_FATTR_FILEID 20
413 #define NFS_FATTR_FILES_AVAIL 21
414 #define NFS_FATTR_FILES_FREE 22
415 #define NFS_FATTR_FILES_TOTAL 23
416 #define NFS_FATTR_FS_LOCATIONS 24
417 #define NFS_FATTR_HIDDEN 25
418 #define NFS_FATTR_HOMOGENEOUS 26
419 #define NFS_FATTR_MAXFILESIZE 27
420 #define NFS_FATTR_MAXLINK 28
421 #define NFS_FATTR_MAXNAME 29
422 #define NFS_FATTR_MAXREAD 30
423 #define NFS_FATTR_MAXWRITE 31
424 #define NFS_FATTR_MIMETYPE 32
425 #define NFS_FATTR_MODE 33
426 #define NFS_FATTR_NO_TRUNC 34
427 #define NFS_FATTR_NUMLINKS 35
428 #define NFS_FATTR_OWNER 36
429 #define NFS_FATTR_OWNER_GROUP 37
430 #define NFS_FATTR_QUOTA_AVAIL_HARD 38
431 #define NFS_FATTR_QUOTA_AVAIL_SOFT 39
432 #define NFS_FATTR_QUOTA_USED 40
433 #define NFS_FATTR_RAWDEV 41
434 #define NFS_FATTR_SPACE_AVAIL 42
435 #define NFS_FATTR_SPACE_FREE 43
436 #define NFS_FATTR_SPACE_TOTAL 44
437 #define NFS_FATTR_SPACE_USED 45
438 #define NFS_FATTR_SYSTEM 46
439 #define NFS_FATTR_TIME_ACCESS 47
440 #define NFS_FATTR_TIME_ACCESS_SET 48
441 #define NFS_FATTR_TIME_BACKUP 49
442 #define NFS_FATTR_TIME_CREATE 50
443 #define NFS_FATTR_TIME_DELTA 51
444 #define NFS_FATTR_TIME_METADATA 52
445 #define NFS_FATTR_TIME_MODIFY 53
446 #define NFS_FATTR_TIME_MODIFY_SET 54
447 #define NFS_FATTR_MOUNTED_ON_FILEID 55
449 #define NFS4_ALL_ATTRIBUTES(A) \
452 NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
453 NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
454 NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
455 NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
456 NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
457 NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
458 NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
459 NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
460 NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
461 NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
462 NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
463 NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
464 NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
466 NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
467 NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
468 NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
469 NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
470 NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
471 NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
472 NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
473 NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
474 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
475 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
476 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
477 NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
478 NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
479 NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
480 NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
481 NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
482 NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
483 NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
484 NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
485 NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
486 NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
487 NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
488 NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
489 NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
490 NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
491 NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); \
492 NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); \
493 NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); \
494 NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
495 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
496 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
497 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
498 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
499 NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
500 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
501 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); \
502 NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
503 NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
504 NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
505 NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
506 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
507 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); \
508 NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
511 #define NFS4_PER_OBJECT_ATTRIBUTES(A) \
514 NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
515 NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
516 NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
517 NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
518 NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
519 NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
520 NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
522 NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
523 NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
524 NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
525 NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
526 NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
527 NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
528 NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
529 NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
530 NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
531 NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
532 NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
533 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
534 NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
535 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
536 NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
537 NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
538 NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
539 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
540 NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
543 #define NFS4_PER_FS_ATTRIBUTES(A) \
546 NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
547 NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
548 NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
549 NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
550 NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
551 NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
553 NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
554 NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
555 NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
556 NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
557 NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
558 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
559 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
560 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
561 NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
562 NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
563 NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
564 NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
565 NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
566 NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
567 NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
568 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
569 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
570 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
571 NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
574 #define NFS4_DEFAULT_ATTRIBUTES(A) \
577 NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
578 NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
579 NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
580 NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
581 NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
582 NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
583 NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
584 NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
585 NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
586 NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
587 NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
588 /* NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); */ \
589 /* NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); */ \
591 /* NFS_BITMAP_SET((A), NFS_FATTR_ACL); */ \
592 NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
593 NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
594 /* NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); */ \
595 NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
596 NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
597 NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
598 NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
599 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
600 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
601 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
602 /* NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); */ \
603 NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
604 NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
605 NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
606 NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
607 NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
608 NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
609 NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
610 /* NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); */ \
611 NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
612 NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
613 NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
614 NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
615 NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
616 /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); */ \
617 /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); */ \
618 /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); */ \
619 NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
620 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
621 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
622 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
623 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
624 /* NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); */ \
625 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
626 /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); */ \
627 NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
628 NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
629 /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); */ \
630 NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
631 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
632 /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); */ \
633 NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
637 * NFSv4 WRITE RPCs contain partial GETATTR requests - only type, change, size, metadatatime and modifytime are requested.
638 * In such cases, we do not update the time stamp - but the requested attributes.
640 #define NFS4_DEFAULT_WRITE_ATTRIBUTES(A) \
643 NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
644 NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
645 NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
647 NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
648 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
651 /* attributes requested when we want to do a "statfs" */
652 #define NFS4_STATFS_ATTRIBUTES(A) \
655 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
656 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
657 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
658 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
659 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
660 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
667 #define NFS_OPEN_NOCREATE 0
668 #define NFS_OPEN_CREATE 1
669 /* delegation space limit */
670 #define NFS_LIMIT_SIZE 1
671 #define NFS_LIMIT_BLOCKS 2
672 /* access/deny modes */
673 #define NFS_OPEN_SHARE_ACCESS_NONE 0x00000000
674 #define NFS_OPEN_SHARE_ACCESS_READ 0x00000001
675 #define NFS_OPEN_SHARE_ACCESS_WRITE 0x00000002
676 #define NFS_OPEN_SHARE_ACCESS_BOTH 0x00000003
677 #define NFS_OPEN_SHARE_DENY_NONE 0x00000000
678 #define NFS_OPEN_SHARE_DENY_READ 0x00000001
679 #define NFS_OPEN_SHARE_DENY_WRITE 0x00000002
680 #define NFS_OPEN_SHARE_DENY_BOTH 0x00000003
681 /* delegation types */
682 #define NFS_OPEN_DELEGATE_NONE 0
683 #define NFS_OPEN_DELEGATE_READ 1
684 #define NFS_OPEN_DELEGATE_WRITE 2
685 /* delegation claim types */
686 #define NFS_CLAIM_NULL 0
687 #define NFS_CLAIM_PREVIOUS 1
688 #define NFS_CLAIM_DELEGATE_CUR 2
689 #define NFS_CLAIM_DELEGATE_PREV 3
690 /* open result flags */
691 #define NFS_OPEN_RESULT_CONFIRM 0x00000002
692 #define NFS_OPEN_RESULT_LOCKTYPE_POSIX 0x00000004
694 #define NFS_LOCK_TYPE_READ 1
695 #define NFS_LOCK_TYPE_WRITE 2
696 #define NFS_LOCK_TYPE_READW 3 /* "blocking" */
697 #define NFS_LOCK_TYPE_WRITEW 4 /* "blocking" */
699 /* NFSv4 RPC procedures */
700 #define NFSPROC4_NULL 0
701 #define NFSPROC4_COMPOUND 1
702 #define NFSPROC4_CB_NULL 0
703 #define NFSPROC4_CB_COMPOUND 1
706 #define NFS_OP_ACCESS 3
707 #define NFS_OP_CLOSE 4
708 #define NFS_OP_COMMIT 5
709 #define NFS_OP_CREATE 6
710 #define NFS_OP_DELEGPURGE 7
711 #define NFS_OP_DELEGRETURN 8
712 #define NFS_OP_GETATTR 9
713 #define NFS_OP_GETFH 10
714 #define NFS_OP_LINK 11
715 #define NFS_OP_LOCK 12
716 #define NFS_OP_LOCKT 13
717 #define NFS_OP_LOCKU 14
718 #define NFS_OP_LOOKUP 15
719 #define NFS_OP_LOOKUPP 16
720 #define NFS_OP_NVERIFY 17
721 #define NFS_OP_OPEN 18
722 #define NFS_OP_OPENATTR 19
723 #define NFS_OP_OPEN_CONFIRM 20
724 #define NFS_OP_OPEN_DOWNGRADE 21
725 #define NFS_OP_PUTFH 22
726 #define NFS_OP_PUTPUBFH 23
727 #define NFS_OP_PUTROOTFH 24
728 #define NFS_OP_READ 25
729 #define NFS_OP_READDIR 26
730 #define NFS_OP_READLINK 27
731 #define NFS_OP_REMOVE 28
732 #define NFS_OP_RENAME 29
733 #define NFS_OP_RENEW 30
734 #define NFS_OP_RESTOREFH 31
735 #define NFS_OP_SAVEFH 32
736 #define NFS_OP_SECINFO 33
737 #define NFS_OP_SETATTR 34
738 #define NFS_OP_SETCLIENTID 35
739 #define NFS_OP_SETCLIENTID_CONFIRM 36
740 #define NFS_OP_VERIFY 37
741 #define NFS_OP_WRITE 38
742 #define NFS_OP_RELEASE_LOCKOWNER 39
743 #define NFS_OP_ILLEGAL 10044
744 /* NFSv4 callback opcodes */
745 #define NFS_OP_CB_GETATTR 3
746 #define NFS_OP_CB_RECALL 4
747 #define NFS_OP_CB_ILLEGAL 10044
749 /* NFSv4 file handle type flags */
750 #define NFS_FH_PERSISTENT 0x00000000
751 #define NFS_FH_NOEXPIRE_WITH_OPEN 0x00000001
752 #define NFS_FH_VOLATILE_ANY 0x00000002
753 #define NFS_FH_VOL_MIGRATION 0x00000004
754 #define NFS_FH_VOL_RENAME 0x00000008
757 * NFSv4 ACL constants
759 /* ACE support mask bits */
760 #define NFS_ACL_SUPPORT_ALLOW_ACL 0x00000001
761 #define NFS_ACL_SUPPORT_DENY_ACL 0x00000002
762 #define NFS_ACL_SUPPORT_AUDIT_ACL 0x00000004
763 #define NFS_ACL_SUPPORT_ALARM_ACL 0x00000008
765 #define NFS_ACE_ACCESS_ALLOWED_ACE_TYPE 0x00000000
766 #define NFS_ACE_ACCESS_DENIED_ACE_TYPE 0x00000001
767 #define NFS_ACE_SYSTEM_AUDIT_ACE_TYPE 0x00000002
768 #define NFS_ACE_SYSTEM_ALARM_ACE_TYPE 0x00000003
770 #define NFS_ACE_FILE_INHERIT_ACE 0x00000001
771 #define NFS_ACE_DIRECTORY_INHERIT_ACE 0x00000002
772 #define NFS_ACE_NO_PROPAGATE_INHERIT_ACE 0x00000004
773 #define NFS_ACE_INHERIT_ONLY_ACE 0x00000008
774 #define NFS_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
775 #define NFS_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020
776 #define NFS_ACE_IDENTIFIER_GROUP 0x00000040
777 #define NFS_ACE_INHERITED_ACE 0x00000080
779 #define NFS_ACE_READ_DATA 0x00000001
780 #define NFS_ACE_LIST_DIRECTORY 0x00000001
781 #define NFS_ACE_WRITE_DATA 0x00000002
782 #define NFS_ACE_ADD_FILE 0x00000002
783 #define NFS_ACE_APPEND_DATA 0x00000004
784 #define NFS_ACE_ADD_SUBDIRECTORY 0x00000004
785 #define NFS_ACE_READ_NAMED_ATTRS 0x00000008
786 #define NFS_ACE_WRITE_NAMED_ATTRS 0x00000010
787 #define NFS_ACE_EXECUTE 0x00000020
788 #define NFS_ACE_DELETE_CHILD 0x00000040
789 #define NFS_ACE_READ_ATTRIBUTES 0x00000080
790 #define NFS_ACE_WRITE_ATTRIBUTES 0x00000100
791 #define NFS_ACE_DELETE 0x00010000
792 #define NFS_ACE_READ_ACL 0x00020000
793 #define NFS_ACE_WRITE_ACL 0x00040000
794 #define NFS_ACE_WRITE_OWNER 0x00080000
795 #define NFS_ACE_SYNCHRONIZE 0x00100000
796 #define NFS_ACE_GENERIC_READ 0x00120081
797 #define NFS_ACE_GENERIC_WRITE 0x00160106
798 #define NFS_ACE_GENERIC_EXECUTE 0x001200A0
802 * Quads are defined as arrays of 2 32-bit values to ensure dense packing
803 * for the protocol and to facilitate xdr conversion.
806 u_int32_t nfsuquad
[2];
808 typedef struct nfs_uquad nfsuint64
;
811 * Used to convert between two u_int32_ts and a u_quad_t.
813 union nfs_quadconvert
{
817 typedef union nfs_quadconvert nfsquad_t
;
820 * special data/attribute associated with NFBLK/NFCHR
822 struct nfs_specdata
{
823 uint32_t specdata1
; /* major device number */
824 uint32_t specdata2
; /* minor device number */
826 typedef struct nfs_specdata nfs_specdata
;
829 * an "fsid" large enough to hold an NFSv4 fsid.
835 typedef struct nfs_fsid nfs_fsid
;
838 * NFSv4 stateid structure
844 typedef struct nfs_stateid nfs_stateid
;
846 #endif /* __APPLE_API_PRIVATE */
847 #endif /* _NFS_NFSPROTO_H_ */