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
93 #ifdef XNU_TARGET_OS_IOS
94 #define NFS_MAXDATA (32 * PAGE_SIZE) /* Same as NFS_MAXBSIZE from nfsnode.h */
95 #else /* TARGET_OS_IOS */
96 #define NFS_MAXDATA (64*1024)
97 #endif /* TARGET_OS_IOS */
99 #define NFSRV_MAXDATA (64*1024) // XXX not ready for >64K
100 #define NFS_MAXPATHLEN 1024
101 #define NFS_MAXNAMLEN 255
102 #define NFS_MAXPACKET (16*1024*1024)
103 #define NFS_UDPSOCKBUF (224*1024)
104 #define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
106 #define NFS4_CALLBACK_PROG 0x4E465343 /* "NFSC" */
107 #define NFS4_CALLBACK_PROG_VERSION 1
109 /* Stat numbers for NFS RPC returns */
111 #define NFSERR_PERM 1
112 #define NFSERR_NOENT 2
114 #define NFSERR_NXIO 6
115 #define NFSERR_ACCES 13
116 #define NFSERR_EXIST 17
117 #define NFSERR_XDEV 18 /* Version 3 only */
118 #define NFSERR_NODEV 19
119 #define NFSERR_NOTDIR 20
120 #define NFSERR_ISDIR 21
121 #define NFSERR_INVAL 22 /* Version 3 only */
122 #define NFSERR_FBIG 27
123 #define NFSERR_NOSPC 28
124 #define NFSERR_ROFS 30
125 #define NFSERR_MLINK 31 /* Version 3 only */
126 #define NFSERR_NAMETOL 63
127 #define NFSERR_NOTEMPTY 66
128 #define NFSERR_DQUOT 69
129 #define NFSERR_STALE 70
130 #define NFSERR_REMOTE 71 /* Version 3 only */
131 #define NFSERR_WFLUSH 99 /* Version 2 only */
132 #define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
133 #define NFSERR_NOT_SYNC 10002
134 #define NFSERR_BAD_COOKIE 10003
135 #define NFSERR_NOTSUPP 10004
136 #define NFSERR_TOOSMALL 10005
137 #define NFSERR_SERVERFAULT 10006
138 #define NFSERR_BADTYPE 10007
139 #define NFSERR_JUKEBOX 10008
140 #define NFSERR_TRYLATER NFSERR_JUKEBOX
141 #define NFSERR_DELAY NFSERR_JUKEBOX
142 #define NFSERR_SAME 10009 /* The rest Version 4 only */
143 #define NFSERR_DENIED 10010
144 #define NFSERR_EXPIRED 10011
145 #define NFSERR_LOCKED 10012
146 #define NFSERR_GRACE 10013
147 #define NFSERR_FHEXPIRED 10014
148 #define NFSERR_SHARE_DENIED 10015
149 #define NFSERR_WRONGSEC 10016
150 #define NFSERR_CLID_INUSE 10017
151 #define NFSERR_RESOURCE 10018
152 #define NFSERR_MOVED 10019
153 #define NFSERR_NOFILEHANDLE 10020
154 #define NFSERR_MINOR_VERS_MISMATCH 10021
155 #define NFSERR_STALE_CLIENTID 10022
156 #define NFSERR_STALE_STATEID 10023
157 #define NFSERR_OLD_STATEID 10024
158 #define NFSERR_BAD_STATEID 10025
159 #define NFSERR_BAD_SEQID 10026
160 #define NFSERR_NOT_SAME 10027
161 #define NFSERR_LOCK_RANGE 10028
162 #define NFSERR_SYMLINK 10029
163 #define NFSERR_RESTOREFH 10030
164 #define NFSERR_LEASE_MOVED 10031
165 #define NFSERR_ATTRNOTSUPP 10032
166 #define NFSERR_NO_GRACE 10033
167 #define NFSERR_RECLAIM_BAD 10034
168 #define NFSERR_RECLAIM_CONFLICT 10035
169 #define NFSERR_BADXDR 10036
170 #define NFSERR_LOCKS_HELD 10037
171 #define NFSERR_OPENMODE 10038
172 #define NFSERR_BADOWNER 10039
173 #define NFSERR_BADCHAR 10040
174 #define NFSERR_BADNAME 10041
175 #define NFSERR_BAD_RANGE 10042
176 #define NFSERR_LOCK_NOTSUPP 10043
177 #define NFSERR_OP_ILLEGAL 10044
178 #define NFSERR_DEADLOCK 10045
179 #define NFSERR_FILE_OPEN 10046
180 #define NFSERR_ADMIN_REVOKED 10047
181 #define NFSERR_CB_PATH_DOWN 10048
183 #define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
184 #define NFSERR_DIRBUFDROPPED 30002 /* Fake return for nfs*_readdir_rpc() */
187 * For gss we would like to return EAUTH when we don't have or can't get credentials,
188 * but some callers don't know what to do with it, so we define our own version
189 * of EAUTH to be EACCES
191 #define NFSERR_EAUTH EACCES
193 #define NFSERR_RETVOID 0x20000000 /* Return void, not error */
194 #define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
195 #define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
197 #endif /* !NFS_PROGRAM */
199 /* Sizes in bytes of various nfs rpc components */
200 #define NFSX_UNSIGNED 4
202 /* specific to NFS Version 2 */
204 #define NFSX_V2FATTR 68
205 #define NFSX_V2SATTR 32
206 #define NFSX_V2COOKIE 4
207 #define NFSX_V2STATFS 20
209 /* specific to NFS Version 3 */
210 #define NFSX_V3FHMAX 64 /* max. allowed by protocol */
211 #define NFSX_V3FATTR 84
212 #define NFSX_V3SATTR 60 /* max. all fields filled in */
213 #define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
214 #define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
215 #define NFSX_V3COOKIEVERF 8
216 #define NFSX_V3WRITEVERF 8
217 #define NFSX_V3CREATEVERF 8
218 #define NFSX_V3STATFS 52
219 #define NFSX_V3FSINFO 48
220 #define NFSX_V3PATHCONF 24
222 /* specific to NFS Version 4 */
223 #define NFS4_FHSIZE 128
224 #define NFS4_VERIFIER_SIZE 8
225 #define NFS4_OPAQUE_LIMIT 1024
227 /* variants for multiple versions */
228 #define NFSX_FH(V) (((V) == NFS_VER2) ? NFSX_V2FH : (NFSX_UNSIGNED + \
229 (((V) == NFS_VER3) ? NFSX_V3FHMAX : NFS4_FHSIZE)))
230 #define NFSX_SRVFH(V, FH) (((V) == NFS_VER2) ? NFSX_V2FH : (FH)->nfh_len)
231 #define NFSX_FATTR(V) (((V) == NFS_VER3) ? NFSX_V3FATTR : NFSX_V2FATTR)
232 #define NFSX_PREOPATTR(V) (((V) == NFS_VER3) ? (7 * NFSX_UNSIGNED) : 0)
233 #define NFSX_POSTOPATTR(V) (((V) == NFS_VER3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
234 #define NFSX_POSTOPORFATTR(V) (((V) == NFS_VER3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : NFSX_V2FATTR)
235 #define NFSX_WCCDATA(V) (((V) == NFS_VER3) ? NFSX_V3WCCDATA : 0)
236 #define NFSX_WCCORFATTR(V) (((V) == NFS_VER3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
237 #define NFSX_SATTR(V) (((V) == NFS_VER3) ? NFSX_V3SATTR : NFSX_V2SATTR)
238 #define NFSX_COOKIEVERF(V) (((V) == NFS_VER3) ? NFSX_V3COOKIEVERF : 0)
239 #define NFSX_WRITEVERF(V) (((V) == NFS_VER3) ? NFSX_V3WRITEVERF : 0)
240 #define NFSX_READDIR(V) (((V) == NFS_VER3) ? (5 * NFSX_UNSIGNED) : \
242 #define NFSX_STATFS(V) (((V) == NFS_VER3) ? NFSX_V3STATFS : NFSX_V2STATFS)
244 /* Only define these if nfs_prot.h hasn't been included */
247 /* nfs rpc procedure numbers (before version mapping) */
248 #define NFSPROC_NULL 0
249 #define NFSPROC_GETATTR 1
250 #define NFSPROC_SETATTR 2
251 #define NFSPROC_LOOKUP 3
252 #define NFSPROC_ACCESS 4
253 #define NFSPROC_READLINK 5
254 #define NFSPROC_READ 6
255 #define NFSPROC_WRITE 7
256 #define NFSPROC_CREATE 8
257 #define NFSPROC_MKDIR 9
258 #define NFSPROC_SYMLINK 10
259 #define NFSPROC_MKNOD 11
260 #define NFSPROC_REMOVE 12
261 #define NFSPROC_RMDIR 13
262 #define NFSPROC_RENAME 14
263 #define NFSPROC_LINK 15
264 #define NFSPROC_READDIR 16
265 #define NFSPROC_READDIRPLUS 17
266 #define NFSPROC_FSSTAT 18
267 #define NFSPROC_FSINFO 19
268 #define NFSPROC_PATHCONF 20
269 #define NFSPROC_COMMIT 21
271 #endif /* !NFS_PROGRAM */
273 #define NFSPROC_NOOP 22
274 #define NFS_NPROCS 23
276 /* Actual Version 2 procedure numbers */
277 #define NFSV2PROC_NULL 0
278 #define NFSV2PROC_GETATTR 1
279 #define NFSV2PROC_SETATTR 2
280 #define NFSV2PROC_NOOP 3
281 #define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
282 #define NFSV2PROC_LOOKUP 4
283 #define NFSV2PROC_READLINK 5
284 #define NFSV2PROC_READ 6
285 #define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
286 #define NFSV2PROC_WRITE 8
287 #define NFSV2PROC_CREATE 9
288 #define NFSV2PROC_REMOVE 10
289 #define NFSV2PROC_RENAME 11
290 #define NFSV2PROC_LINK 12
291 #define NFSV2PROC_SYMLINK 13
292 #define NFSV2PROC_MKDIR 14
293 #define NFSV2PROC_RMDIR 15
294 #define NFSV2PROC_READDIR 16
295 #define NFSV2PROC_STATFS 17
298 * Constants used by the Version 3 protocol for various RPCs
301 #define NFSV3FSINFO_LINK 0x01
302 #define NFSV3FSINFO_SYMLINK 0x02
303 #define NFSV3FSINFO_HOMOGENEOUS 0x08
304 #define NFSV3FSINFO_CANSETTIME 0x10
306 /* time setting constants */
307 #define NFS_TIME_DONT_CHANGE 0
308 #define NFS_TIME_SET_TO_SERVER 1
309 #define NFS_TIME_SET_TO_CLIENT 2
310 #define NFS4_TIME_SET_TO_SERVER 0
311 #define NFS4_TIME_SET_TO_CLIENT 1
313 /* access() constants */
314 #define NFS_ACCESS_READ 0x01
315 #define NFS_ACCESS_LOOKUP 0x02
316 #define NFS_ACCESS_MODIFY 0x04
317 #define NFS_ACCESS_EXTEND 0x08
318 #define NFS_ACCESS_DELETE 0x10
319 #define NFS_ACCESS_EXECUTE 0x20
320 #define NFS_ACCESS_ALL (NFS_ACCESS_READ | NFS_ACCESS_MODIFY \
321 | NFS_ACCESS_EXTEND | NFS_ACCESS_EXECUTE \
322 | NFS_ACCESS_DELETE | NFS_ACCESS_LOOKUP)
324 /* NFS WRITE how constants */
325 #define NFS_WRITE_UNSTABLE 0
326 #define NFS_WRITE_DATASYNC 1
327 #define NFS_WRITE_FILESYNC 2
329 /* NFS CREATE types */
330 #define NFS_CREATE_UNCHECKED 0
331 #define NFS_CREATE_GUARDED 1
332 #define NFS_CREATE_EXCLUSIVE 2
334 /* Only define these if nfs_prot.h hasn't been included */
336 /* NFS object types */
337 typedef enum { NFNON
=0, NFREG
=1, NFDIR
=2, NFBLK
=3, NFCHR
=4, NFLNK
=5,
338 NFSOCK
=6, NFFIFO
=7, NFATTRDIR
=8, NFNAMEDATTR
=9 } nfstype
;
339 #endif /* !NFS_PROGRAM */
342 * File Handle (32 bytes for version 2), variable up to 64 for version 3
343 * and variable up to 128 bytes for version 4.
344 * File Handles of up to NFS_SMALLFH in size are stored directly in the
345 * nfs node, whereas larger ones are malloc'd. (This never happens when
346 * NFS_SMALLFH is set to the largest size.)
347 * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
350 #define NFS_SMALLFH 64
354 * NFS attribute management stuff
356 #define NFS_ATTR_BITMAP_LEN 2
357 #define NFS_BITMAP_SET(B, I) (((uint32_t *)(B))[(I)/32] |= 1U<<((I)%32))
358 #define NFS_BITMAP_CLR(B, I) (((uint32_t *)(B))[(I)/32] &= ~(1U<<((I)%32)))
359 #define NFS_BITMAP_ISSET(B, I) (((uint32_t *)(B))[(I)/32] & (1U<<((I)%32)))
360 #define NFS_BITMAP_ZERO(B, L) \
363 for (__i=0; __i < (L); __i++) \
364 ((uint32_t*)(B))[__i] = 0; \
367 extern uint32_t nfs_fs_attr_bitmap
[NFS_ATTR_BITMAP_LEN
];
368 extern uint32_t nfs_object_attr_bitmap
[NFS_ATTR_BITMAP_LEN
];
369 extern uint32_t nfs_getattr_bitmap
[NFS_ATTR_BITMAP_LEN
];
371 #define NFS_CLEAR_ATTRIBUTES(A) NFS_BITMAP_ZERO((A), NFS_ATTR_BITMAP_LEN)
372 #define NFS_COPY_ATTRIBUTES(SRC, DST) \
375 for (__i=0; __i < NFS_ATTR_BITMAP_LEN; __i++) \
376 ((uint32_t*)(DST))[__i] = ((uint32_t*)(SRC))[__i]; \
380 #define NFS_FATTR_SUPPORTED_ATTRS 0
381 #define NFS_FATTR_TYPE 1
382 #define NFS_FATTR_FH_EXPIRE_TYPE 2
383 #define NFS_FATTR_CHANGE 3
384 #define NFS_FATTR_SIZE 4
385 #define NFS_FATTR_LINK_SUPPORT 5
386 #define NFS_FATTR_SYMLINK_SUPPORT 6
387 #define NFS_FATTR_NAMED_ATTR 7
388 #define NFS_FATTR_FSID 8
389 #define NFS_FATTR_UNIQUE_HANDLES 9
390 #define NFS_FATTR_LEASE_TIME 10
391 #define NFS_FATTR_RDATTR_ERROR 11
392 #define NFS_FATTR_FILEHANDLE 19
393 #define NFS_FATTR_ACL 12
394 #define NFS_FATTR_ACLSUPPORT 13
395 #define NFS_FATTR_ARCHIVE 14
396 #define NFS_FATTR_CANSETTIME 15
397 #define NFS_FATTR_CASE_INSENSITIVE 16
398 #define NFS_FATTR_CASE_PRESERVING 17
399 #define NFS_FATTR_CHOWN_RESTRICTED 18
400 #define NFS_FATTR_FILEID 20
401 #define NFS_FATTR_FILES_AVAIL 21
402 #define NFS_FATTR_FILES_FREE 22
403 #define NFS_FATTR_FILES_TOTAL 23
404 #define NFS_FATTR_FS_LOCATIONS 24
405 #define NFS_FATTR_HIDDEN 25
406 #define NFS_FATTR_HOMOGENEOUS 26
407 #define NFS_FATTR_MAXFILESIZE 27
408 #define NFS_FATTR_MAXLINK 28
409 #define NFS_FATTR_MAXNAME 29
410 #define NFS_FATTR_MAXREAD 30
411 #define NFS_FATTR_MAXWRITE 31
412 #define NFS_FATTR_MIMETYPE 32
413 #define NFS_FATTR_MODE 33
414 #define NFS_FATTR_NO_TRUNC 34
415 #define NFS_FATTR_NUMLINKS 35
416 #define NFS_FATTR_OWNER 36
417 #define NFS_FATTR_OWNER_GROUP 37
418 #define NFS_FATTR_QUOTA_AVAIL_HARD 38
419 #define NFS_FATTR_QUOTA_AVAIL_SOFT 39
420 #define NFS_FATTR_QUOTA_USED 40
421 #define NFS_FATTR_RAWDEV 41
422 #define NFS_FATTR_SPACE_AVAIL 42
423 #define NFS_FATTR_SPACE_FREE 43
424 #define NFS_FATTR_SPACE_TOTAL 44
425 #define NFS_FATTR_SPACE_USED 45
426 #define NFS_FATTR_SYSTEM 46
427 #define NFS_FATTR_TIME_ACCESS 47
428 #define NFS_FATTR_TIME_ACCESS_SET 48
429 #define NFS_FATTR_TIME_BACKUP 49
430 #define NFS_FATTR_TIME_CREATE 50
431 #define NFS_FATTR_TIME_DELTA 51
432 #define NFS_FATTR_TIME_METADATA 52
433 #define NFS_FATTR_TIME_MODIFY 53
434 #define NFS_FATTR_TIME_MODIFY_SET 54
435 #define NFS_FATTR_MOUNTED_ON_FILEID 55
437 #define NFS4_ALL_ATTRIBUTES(A) \
440 NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
441 NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
442 NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
443 NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
444 NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
445 NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
446 NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
447 NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
448 NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
449 NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
450 NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
451 NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
452 NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
454 NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
455 NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
456 NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
457 NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
458 NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
459 NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
460 NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
461 NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
462 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
463 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
464 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
465 NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
466 NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
467 NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
468 NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
469 NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
470 NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
471 NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
472 NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
473 NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
474 NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
475 NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
476 NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
477 NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
478 NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
479 NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); \
480 NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); \
481 NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); \
482 NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
483 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
484 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
485 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
486 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
487 NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
488 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
489 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); \
490 NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
491 NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
492 NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
493 NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
494 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
495 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); \
496 NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
499 #define NFS4_PER_OBJECT_ATTRIBUTES(A) \
502 NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
503 NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
504 NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
505 NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
506 NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
507 NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
508 NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
510 NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
511 NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
512 NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
513 NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
514 NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
515 NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
516 NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
517 NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
518 NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
519 NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
520 NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
521 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
522 NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
523 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
524 NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
525 NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
526 NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
527 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
528 NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
531 #define NFS4_PER_FS_ATTRIBUTES(A) \
534 NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
535 NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
536 NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
537 NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
538 NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
539 NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
541 NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
542 NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
543 NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
544 NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
545 NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
546 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
547 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
548 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
549 NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
550 NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
551 NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
552 NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
553 NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
554 NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
555 NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
556 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
557 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
558 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
559 NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
562 #define NFS4_DEFAULT_ATTRIBUTES(A) \
565 NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
566 NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
567 NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
568 NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
569 NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
570 NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
571 NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
572 NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
573 NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
574 NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
575 NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
576 /* NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); */ \
577 /* NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); */ \
579 /* NFS_BITMAP_SET((A), NFS_FATTR_ACL); */ \
580 NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
581 NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
582 /* NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); */ \
583 NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
584 NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
585 NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
586 NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
587 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
588 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
589 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
590 /* NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); */ \
591 NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
592 NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
593 NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
594 NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
595 NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
596 NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
597 NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
598 /* NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); */ \
599 NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
600 NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
601 NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
602 NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
603 NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
604 /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); */ \
605 /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); */ \
606 /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); */ \
607 NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
608 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
609 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
610 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
611 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
612 /* NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); */ \
613 NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
614 /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); */ \
615 NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
616 NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
617 /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); */ \
618 NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
619 NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
620 /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); */ \
621 NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
624 /* attributes requested when we want to do a "statfs" */
625 #define NFS4_STATFS_ATTRIBUTES(A) \
628 NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
629 NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
630 NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
631 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
632 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
633 NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
640 #define NFS_OPEN_NOCREATE 0
641 #define NFS_OPEN_CREATE 1
642 /* delegation space limit */
643 #define NFS_LIMIT_SIZE 1
644 #define NFS_LIMIT_BLOCKS 2
645 /* access/deny modes */
646 #define NFS_OPEN_SHARE_ACCESS_NONE 0x00000000
647 #define NFS_OPEN_SHARE_ACCESS_READ 0x00000001
648 #define NFS_OPEN_SHARE_ACCESS_WRITE 0x00000002
649 #define NFS_OPEN_SHARE_ACCESS_BOTH 0x00000003
650 #define NFS_OPEN_SHARE_DENY_NONE 0x00000000
651 #define NFS_OPEN_SHARE_DENY_READ 0x00000001
652 #define NFS_OPEN_SHARE_DENY_WRITE 0x00000002
653 #define NFS_OPEN_SHARE_DENY_BOTH 0x00000003
654 /* delegation types */
655 #define NFS_OPEN_DELEGATE_NONE 0
656 #define NFS_OPEN_DELEGATE_READ 1
657 #define NFS_OPEN_DELEGATE_WRITE 2
658 /* delegation claim types */
659 #define NFS_CLAIM_NULL 0
660 #define NFS_CLAIM_PREVIOUS 1
661 #define NFS_CLAIM_DELEGATE_CUR 2
662 #define NFS_CLAIM_DELEGATE_PREV 3
663 /* open result flags */
664 #define NFS_OPEN_RESULT_CONFIRM 0x00000002
665 #define NFS_OPEN_RESULT_LOCKTYPE_POSIX 0x00000004
667 #define NFS_LOCK_TYPE_READ 1
668 #define NFS_LOCK_TYPE_WRITE 2
669 #define NFS_LOCK_TYPE_READW 3 /* "blocking" */
670 #define NFS_LOCK_TYPE_WRITEW 4 /* "blocking" */
672 /* NFSv4 RPC procedures */
673 #define NFSPROC4_NULL 0
674 #define NFSPROC4_COMPOUND 1
675 #define NFSPROC4_CB_NULL 0
676 #define NFSPROC4_CB_COMPOUND 1
679 #define NFS_OP_ACCESS 3
680 #define NFS_OP_CLOSE 4
681 #define NFS_OP_COMMIT 5
682 #define NFS_OP_CREATE 6
683 #define NFS_OP_DELEGPURGE 7
684 #define NFS_OP_DELEGRETURN 8
685 #define NFS_OP_GETATTR 9
686 #define NFS_OP_GETFH 10
687 #define NFS_OP_LINK 11
688 #define NFS_OP_LOCK 12
689 #define NFS_OP_LOCKT 13
690 #define NFS_OP_LOCKU 14
691 #define NFS_OP_LOOKUP 15
692 #define NFS_OP_LOOKUPP 16
693 #define NFS_OP_NVERIFY 17
694 #define NFS_OP_OPEN 18
695 #define NFS_OP_OPENATTR 19
696 #define NFS_OP_OPEN_CONFIRM 20
697 #define NFS_OP_OPEN_DOWNGRADE 21
698 #define NFS_OP_PUTFH 22
699 #define NFS_OP_PUTPUBFH 23
700 #define NFS_OP_PUTROOTFH 24
701 #define NFS_OP_READ 25
702 #define NFS_OP_READDIR 26
703 #define NFS_OP_READLINK 27
704 #define NFS_OP_REMOVE 28
705 #define NFS_OP_RENAME 29
706 #define NFS_OP_RENEW 30
707 #define NFS_OP_RESTOREFH 31
708 #define NFS_OP_SAVEFH 32
709 #define NFS_OP_SECINFO 33
710 #define NFS_OP_SETATTR 34
711 #define NFS_OP_SETCLIENTID 35
712 #define NFS_OP_SETCLIENTID_CONFIRM 36
713 #define NFS_OP_VERIFY 37
714 #define NFS_OP_WRITE 38
715 #define NFS_OP_RELEASE_LOCKOWNER 39
716 #define NFS_OP_ILLEGAL 10044
717 /* NFSv4 callback opcodes */
718 #define NFS_OP_CB_GETATTR 3
719 #define NFS_OP_CB_RECALL 4
720 #define NFS_OP_CB_ILLEGAL 10044
722 /* NFSv4 file handle type flags */
723 #define NFS_FH_PERSISTENT 0x00000000
724 #define NFS_FH_NOEXPIRE_WITH_OPEN 0x00000001
725 #define NFS_FH_VOLATILE_ANY 0x00000002
726 #define NFS_FH_VOL_MIGRATION 0x00000004
727 #define NFS_FH_VOL_RENAME 0x00000008
730 * NFSv4 ACL constants
732 /* ACE support mask bits */
733 #define NFS_ACL_SUPPORT_ALLOW_ACL 0x00000001
734 #define NFS_ACL_SUPPORT_DENY_ACL 0x00000002
735 #define NFS_ACL_SUPPORT_AUDIT_ACL 0x00000004
736 #define NFS_ACL_SUPPORT_ALARM_ACL 0x00000008
738 #define NFS_ACE_ACCESS_ALLOWED_ACE_TYPE 0x00000000
739 #define NFS_ACE_ACCESS_DENIED_ACE_TYPE 0x00000001
740 #define NFS_ACE_SYSTEM_AUDIT_ACE_TYPE 0x00000002
741 #define NFS_ACE_SYSTEM_ALARM_ACE_TYPE 0x00000003
743 #define NFS_ACE_FILE_INHERIT_ACE 0x00000001
744 #define NFS_ACE_DIRECTORY_INHERIT_ACE 0x00000002
745 #define NFS_ACE_NO_PROPAGATE_INHERIT_ACE 0x00000004
746 #define NFS_ACE_INHERIT_ONLY_ACE 0x00000008
747 #define NFS_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
748 #define NFS_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020
749 #define NFS_ACE_IDENTIFIER_GROUP 0x00000040
750 #define NFS_ACE_INHERITED_ACE 0x00000080
752 #define NFS_ACE_READ_DATA 0x00000001
753 #define NFS_ACE_LIST_DIRECTORY 0x00000001
754 #define NFS_ACE_WRITE_DATA 0x00000002
755 #define NFS_ACE_ADD_FILE 0x00000002
756 #define NFS_ACE_APPEND_DATA 0x00000004
757 #define NFS_ACE_ADD_SUBDIRECTORY 0x00000004
758 #define NFS_ACE_READ_NAMED_ATTRS 0x00000008
759 #define NFS_ACE_WRITE_NAMED_ATTRS 0x00000010
760 #define NFS_ACE_EXECUTE 0x00000020
761 #define NFS_ACE_DELETE_CHILD 0x00000040
762 #define NFS_ACE_READ_ATTRIBUTES 0x00000080
763 #define NFS_ACE_WRITE_ATTRIBUTES 0x00000100
764 #define NFS_ACE_DELETE 0x00010000
765 #define NFS_ACE_READ_ACL 0x00020000
766 #define NFS_ACE_WRITE_ACL 0x00040000
767 #define NFS_ACE_WRITE_OWNER 0x00080000
768 #define NFS_ACE_SYNCHRONIZE 0x00100000
769 #define NFS_ACE_GENERIC_READ 0x00120081
770 #define NFS_ACE_GENERIC_WRITE 0x00160106
771 #define NFS_ACE_GENERIC_EXECUTE 0x001200A0
775 * Quads are defined as arrays of 2 32-bit values to ensure dense packing
776 * for the protocol and to facilitate xdr conversion.
779 u_int32_t nfsuquad
[2];
781 typedef struct nfs_uquad nfsuint64
;
784 * Used to convert between two u_int32_ts and a u_quad_t.
786 union nfs_quadconvert
{
790 typedef union nfs_quadconvert nfsquad_t
;
793 * special data/attribute associated with NFBLK/NFCHR
795 struct nfs_specdata
{
796 uint32_t specdata1
; /* major device number */
797 uint32_t specdata2
; /* minor device number */
799 typedef struct nfs_specdata nfs_specdata
;
802 * an "fsid" large enough to hold an NFSv4 fsid.
808 typedef struct nfs_fsid nfs_fsid
;
811 * NFSv4 stateid structure
817 typedef struct nfs_stateid nfs_stateid
;
819 #endif /* __APPLE_API_PRIVATE */
820 #endif /* _NFS_NFSPROTO_H_ */