2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 * attr.h - attribute data structures and interfaces
34 * Copyright (c) 1998, Apple Computer, Inc. All Rights Reserved.
40 #include <sys/appleapiopts.h>
42 #ifdef __APPLE_API_UNSTABLE
43 #include <sys/types.h>
44 #include <sys/ucred.h>
46 #include <sys/cdefs.h>
48 #define FSOPT_NOFOLLOW 0x00000001
49 #define FSOPT_NOINMEMUPDATE 0x00000002
50 #define FSOPT_REPORT_FULLSIZE 0x00000004
52 /* we currently aren't anywhere near this amount for a valid
53 * fssearchblock.sizeofsearchparams1 or fssearchblock.sizeofsearchparams2
54 * but we put a sanity check in to avoid abuse of the value passed in from
57 #define SEARCHFS_MAX_SEARCHPARMS 4096
59 typedef u_int32_t text_encoding_t
;
61 typedef u_int32_t fsobj_type_t
;
63 typedef u_int32_t fsobj_tag_t
;
65 typedef u_int32_t fsfile_type_t
;
67 typedef u_int32_t fsvolid_t
;
69 typedef struct fsobj_id
{
71 u_int32_t fid_generation
;
74 typedef u_int32_t attrgroup_t
;
77 u_short bitmapcount
; /* number of attr. bit sets in list (should be 5) */
78 u_int16_t reserved
; /* (to maintain 4-byte alignment) */
79 attrgroup_t commonattr
; /* common attribute group */
80 attrgroup_t volattr
; /* Volume attribute group */
81 attrgroup_t dirattr
; /* directory attribute group */
82 attrgroup_t fileattr
; /* file attribute group */
83 attrgroup_t forkattr
; /* fork attribute group */
85 #define ATTR_BIT_MAP_COUNT 5
87 typedef struct attribute_set
{
88 attrgroup_t commonattr
; /* common attribute group */
89 attrgroup_t volattr
; /* Volume attribute group */
90 attrgroup_t dirattr
; /* directory attribute group */
91 attrgroup_t fileattr
; /* file attribute group */
92 attrgroup_t forkattr
; /* fork attribute group */
95 typedef struct attrreference
{
96 int32_t attr_dataoffset
;
97 u_int32_t attr_length
;
100 /* XXX PPD This is derived from HFSVolumePriv.h and should perhaps be referenced from there? */
103 u_int32_t startblock
; /* first block allocated */
104 u_int32_t blockcount
; /* number of blocks allocated */
107 typedef struct diskextent extentrecord
[8];
109 typedef u_int32_t vol_capabilities_set_t
[4];
111 #define VOL_CAPABILITIES_FORMAT 0
112 #define VOL_CAPABILITIES_INTERFACES 1
113 #define VOL_CAPABILITIES_RESERVED1 2
114 #define VOL_CAPABILITIES_RESERVED2 3
116 typedef struct vol_capabilities_attr
{
117 vol_capabilities_set_t capabilities
;
118 vol_capabilities_set_t valid
;
119 } vol_capabilities_attr_t
;
122 * XXX this value needs to be raised - 3893388
124 #define ATTR_MAX_BUFFER 8192
127 * VOL_CAP_FMT_PERSISTENTOBJECTIDS: When set, the volume has object IDs
128 * that are persistent (retain their values even when the volume is
129 * unmounted and remounted), and a file or directory can be looked up
130 * by ID. Volumes that support VolFS and can support Carbon File ID
131 * references should set this bit.
133 * VOL_CAP_FMT_SYMBOLICLINKS: When set, the volume supports symbolic
134 * links. The symlink(), readlink(), and lstat() calls all use this
137 * VOL_CAP_FMT_HARDLINKS: When set, the volume supports hard links.
138 * The link() call creates hard links.
140 * VOL_CAP_FMT_JOURNAL: When set, the volume is capable of supporting
141 * a journal used to speed recovery in case of unplanned shutdown
142 * (such as a power outage or crash). This bit does not necessarily
143 * mean the volume is actively using a journal for recovery.
145 * VOL_CAP_FMT_JOURNAL_ACTIVE: When set, the volume is currently using
146 * a journal for use in speeding recovery after an unplanned shutdown.
147 * This bit can be set only if VOL_CAP_FMT_JOURNAL is also set.
149 * VOL_CAP_FMT_NO_ROOT_TIMES: When set, the volume format does not
150 * store reliable times for the root directory, so you should not
151 * depend on them to detect changes, etc.
153 * VOL_CAP_FMT_SPARSE_FILES: When set, the volume supports sparse files.
154 * That is, files which can have "holes" that have never been written
155 * to, and are not allocated on disk. Sparse files may have an
156 * allocated size that is less than the file's logical length.
158 * VOL_CAP_FMT_ZERO_RUNS: For security reasons, parts of a file (runs)
159 * that have never been written to must appear to contain zeroes. When
160 * this bit is set, the volume keeps track of allocated but unwritten
161 * runs of a file so that it can substitute zeroes without actually
162 * writing zeroes to the media. This provides performance similar to
163 * sparse files, but not the space savings.
165 * VOL_CAP_FMT_CASE_SENSITIVE: When set, file and directory names are
166 * case sensitive (upper and lower case are different). When clear,
167 * an upper case character is equivalent to a lower case character,
168 * and you can't have two names that differ solely in the case of
171 * VOL_CAP_FMT_CASE_PRESERVING: When set, file and directory names
172 * preserve the difference between upper and lower case. If clear,
173 * the volume may change the case of some characters (typically
174 * making them all upper or all lower case). A volume that sets
175 * VOL_CAP_FMT_CASE_SENSITIVE should also set VOL_CAP_FMT_CASE_PRESERVING.
177 * VOL_CAP_FMT_FAST_STATFS: This bit is used as a hint to upper layers
178 * (especially Carbon) that statfs() is fast enough that its results
179 * need not be cached by those upper layers. A volume that caches
180 * the statfs information in its in-memory structures should set this bit.
181 * A volume that must always read from disk or always perform a network
182 * transaction should not set this bit.
184 * VOL_CAP_FMT_2TB_FILESIZE: When set, the volume format supports file
185 * size upto 2TB. This bit does not necessarily mean that the file
186 * system does not support file size more than 2TB. This bit does
187 * not mean that the currently available space on the volume is 2TB.
189 #define VOL_CAP_FMT_PERSISTENTOBJECTIDS 0x00000001
190 #define VOL_CAP_FMT_SYMBOLICLINKS 0x00000002
191 #define VOL_CAP_FMT_HARDLINKS 0x00000004
192 #define VOL_CAP_FMT_JOURNAL 0x00000008
193 #define VOL_CAP_FMT_JOURNAL_ACTIVE 0x00000010
194 #define VOL_CAP_FMT_NO_ROOT_TIMES 0x00000020
195 #define VOL_CAP_FMT_SPARSE_FILES 0x00000040
196 #define VOL_CAP_FMT_ZERO_RUNS 0x00000080
197 #define VOL_CAP_FMT_CASE_SENSITIVE 0x00000100
198 #define VOL_CAP_FMT_CASE_PRESERVING 0x00000200
199 #define VOL_CAP_FMT_FAST_STATFS 0x00000400
200 #define VOL_CAP_FMT_2TB_FILESIZE 0x00000800
204 * VOL_CAP_INT_SEARCHFS: When set, the volume implements the
205 * searchfs() system call (the vnop_searchfs vnode operation).
207 * VOL_CAP_INT_ATTRLIST: When set, the volume implements the
208 * getattrlist() and setattrlist() system calls (vnop_getattrlist
209 * and vnop_setattrlist vnode operations) for the volume, files,
210 * and directories. The volume may or may not implement the
211 * readdirattr() system call. XXX Is there any minimum set
212 * of attributes that should be supported? To determine the
213 * set of supported attributes, get the ATTR_VOL_ATTRIBUTES
214 * attribute of the volume.
216 * VOL_CAP_INT_NFSEXPORT: When set, the volume implements exporting
219 * VOL_CAP_INT_READDIRATTR: When set, the volume implements the
220 * readdirattr() system call (vnop_readdirattr vnode operation).
222 * VOL_CAP_INT_EXCHANGEDATA: When set, the volume implements the
223 * exchangedata() system call (VNOP_EXCHANGE vnode operation).
225 * VOL_CAP_INT_COPYFILE: When set, the volume implements the
226 * VOP_COPYFILE vnode operation. (XXX There should be a copyfile()
227 * system call in <unistd.h>.)
229 * VOL_CAP_INT_ALLOCATE: When set, the volume implements the
230 * VNOP_ALLOCATE vnode operation, which means it implements the
231 * F_PREALLOCATE selector of fcntl(2).
233 * VOL_CAP_INT_VOL_RENAME: When set, the volume implements the
234 * ATTR_VOL_NAME attribute for both getattrlist() and setattrlist().
235 * The volume can be renamed by setting ATTR_VOL_NAME with setattrlist().
237 * VOL_CAP_INT_ADVLOCK: When set, the volume implements POSIX style
238 * byte range locks via vnop_advlock (accessible from fcntl(2)).
240 * VOL_CAP_INT_FLOCK: When set, the volume implements whole-file flock(2)
241 * style locks via vnop_advlock. This includes the O_EXLOCK and O_SHLOCK
242 * flags of the open(2) call.
245 #define VOL_CAP_INT_SEARCHFS 0x00000001
246 #define VOL_CAP_INT_ATTRLIST 0x00000002
247 #define VOL_CAP_INT_NFSEXPORT 0x00000004
248 #define VOL_CAP_INT_READDIRATTR 0x00000008
249 #define VOL_CAP_INT_EXCHANGEDATA 0x00000010
250 #define VOL_CAP_INT_COPYFILE 0x00000020
251 #define VOL_CAP_INT_ALLOCATE 0x00000040
252 #define VOL_CAP_INT_VOL_RENAME 0x00000080
253 #define VOL_CAP_INT_ADVLOCK 0x00000100
254 #define VOL_CAP_INT_FLOCK 0x00000200
255 #define VOL_CAP_INT_EXTENDED_SECURITY 0x00000400
256 #define VOL_CAP_INT_USERACCESS 0x00000800
258 typedef struct vol_attributes_attr
{
259 attribute_set_t validattr
;
260 attribute_set_t nativeattr
;
261 } vol_attributes_attr_t
;
263 #define ATTR_CMN_NAME 0x00000001
264 #define ATTR_CMN_DEVID 0x00000002
265 #define ATTR_CMN_FSID 0x00000004
266 #define ATTR_CMN_OBJTYPE 0x00000008
267 #define ATTR_CMN_OBJTAG 0x00000010
268 #define ATTR_CMN_OBJID 0x00000020
269 #define ATTR_CMN_OBJPERMANENTID 0x00000040
270 #define ATTR_CMN_PAROBJID 0x00000080
271 #define ATTR_CMN_SCRIPT 0x00000100
272 #define ATTR_CMN_CRTIME 0x00000200
273 #define ATTR_CMN_MODTIME 0x00000400
274 #define ATTR_CMN_CHGTIME 0x00000800
275 #define ATTR_CMN_ACCTIME 0x00001000
276 #define ATTR_CMN_BKUPTIME 0x00002000
277 #define ATTR_CMN_FNDRINFO 0x00004000
278 #define ATTR_CMN_OWNERID 0x00008000
279 #define ATTR_CMN_GRPID 0x00010000
280 #define ATTR_CMN_ACCESSMASK 0x00020000
281 #define ATTR_CMN_FLAGS 0x00040000
282 #define ATTR_CMN_USERACCESS 0x00200000
283 #define ATTR_CMN_EXTENDED_SECURITY 0x00400000
284 #define ATTR_CMN_UUID 0x00800000
285 #define ATTR_CMN_GRPUUID 0x01000000
287 #define ATTR_CMN_VALIDMASK 0x003FFFFF
288 #define ATTR_CMN_SETMASK 0x01C7FF00
289 #define ATTR_CMN_VOLSETMASK 0x00006700
291 #define ATTR_VOL_FSTYPE 0x00000001
292 #define ATTR_VOL_SIGNATURE 0x00000002
293 #define ATTR_VOL_SIZE 0x00000004
294 #define ATTR_VOL_SPACEFREE 0x00000008
295 #define ATTR_VOL_SPACEAVAIL 0x00000010
296 #define ATTR_VOL_MINALLOCATION 0x00000020
297 #define ATTR_VOL_ALLOCATIONCLUMP 0x00000040
298 #define ATTR_VOL_IOBLOCKSIZE 0x00000080
299 #define ATTR_VOL_OBJCOUNT 0x00000100
300 #define ATTR_VOL_FILECOUNT 0x00000200
301 #define ATTR_VOL_DIRCOUNT 0x00000400
302 #define ATTR_VOL_MAXOBJCOUNT 0x00000800
303 #define ATTR_VOL_MOUNTPOINT 0x00001000
304 #define ATTR_VOL_NAME 0x00002000
305 #define ATTR_VOL_MOUNTFLAGS 0x00004000
306 #define ATTR_VOL_MOUNTEDDEVICE 0x00008000
307 #define ATTR_VOL_ENCODINGSUSED 0x00010000
308 #define ATTR_VOL_CAPABILITIES 0x00020000
309 #define ATTR_VOL_ATTRIBUTES 0x40000000
310 #define ATTR_VOL_INFO 0x80000000
312 #define ATTR_VOL_VALIDMASK 0xC003FFFF
313 #define ATTR_VOL_SETMASK 0x80002000
316 /* File/directory attributes: */
317 #define ATTR_DIR_LINKCOUNT 0x00000001
318 #define ATTR_DIR_ENTRYCOUNT 0x00000002
319 #define ATTR_DIR_MOUNTSTATUS 0x00000004
320 #define DIR_MNTSTATUS_MNTPOINT 0x00000001
322 #define ATTR_DIR_VALIDMASK 0x00000007
323 #define ATTR_DIR_SETMASK 0x00000000
325 #define ATTR_FILE_LINKCOUNT 0x00000001
326 #define ATTR_FILE_TOTALSIZE 0x00000002
327 #define ATTR_FILE_ALLOCSIZE 0x00000004
328 #define ATTR_FILE_IOBLOCKSIZE 0x00000008
329 #define ATTR_FILE_DEVTYPE 0x00000020
330 #define ATTR_FILE_FORKCOUNT 0x00000080
331 #define ATTR_FILE_FORKLIST 0x00000100
332 #define ATTR_FILE_DATALENGTH 0x00000200
333 #define ATTR_FILE_DATAALLOCSIZE 0x00000400
334 #define ATTR_FILE_RSRCLENGTH 0x00001000
335 #define ATTR_FILE_RSRCALLOCSIZE 0x00002000
337 #define ATTR_FILE_VALIDMASK 0x00007FFF
338 #define ATTR_FILE_SETMASK 0x00000020
340 #define ATTR_FORK_TOTALSIZE 0x00000001
341 #define ATTR_FORK_ALLOCSIZE 0x00000002
343 #define ATTR_FORK_VALIDMASK 0x00000003
344 #define ATTR_FORK_SETMASK 0x00000000
346 /* Obsolete, implemented, not supported */
347 #define ATTR_CMN_NAMEDATTRCOUNT 0x00080000 /* not implemented */
348 #define ATTR_CMN_NAMEDATTRLIST 0x00100000 /* not implemented */
349 #define ATTR_FILE_CLUMPSIZE 0x00000010 /* obsolete */
350 #define ATTR_FILE_FILETYPE 0x00000040 /* always zero */
351 #define ATTR_FILE_DATAEXTENTS 0x00000800 /* obsolete, HFS-specific */
352 #define ATTR_FILE_RSRCEXTENTS 0x00004000 /* obsolete, HFS-specific */
357 #define SRCHFS_START 0x00000001
358 #define SRCHFS_MATCHPARTIALNAMES 0x00000002
359 #define SRCHFS_MATCHDIRS 0x00000004
360 #define SRCHFS_MATCHFILES 0x00000008
361 #define SRCHFS_SKIPLINKS 0x00000010
362 #define SRCHFS_SKIPINVISIBLE 0x00000020
363 #define SRCHFS_SKIPPACKAGES 0x00000040
364 #define SRCHFS_SKIPINAPPROPRIATE 0x00000080
366 #define SRCHFS_NEGATEPARAMS 0x80000000
367 #define SRCHFS_VALIDOPTIONSMASK 0x800000FF
369 struct fssearchblock
{
370 struct attrlist
*returnattrs
;
372 size_t returnbuffersize
;
374 struct timeval timelimit
;
376 size_t sizeofsearchparams1
;
378 size_t sizeofsearchparams2
;
379 struct attrlist searchattrs
;
383 /* LP64 version of fssearchblock. all pointers and longs
384 * grow when we're dealing with a 64-bit process.
385 * WARNING - keep in sync with fssearchblock
387 // LP64todo - should this move?
389 #if __DARWIN_ALIGN_NATURAL
390 #pragma options align=natural
393 struct user_fssearchblock
{
394 user_addr_t returnattrs
;
395 user_addr_t returnbuffer
;
396 user_size_t returnbuffersize
;
397 user_ulong_t maxmatches
;
398 struct timeval timelimit
;
399 user_addr_t searchparams1
;
400 user_size_t sizeofsearchparams1
;
401 user_addr_t searchparams2
;
402 user_size_t sizeofsearchparams2
;
403 struct attrlist searchattrs
;
406 #if __DARWIN_ALIGN_NATURAL
407 #pragma options align=reset
415 u_char reserved
[556]; // sizeof( SearchState )
419 #define FST_EOF (-1) /* end-of-file offset */
421 #endif /* __APPLE_API_UNSTABLE */
422 #endif /* !_SYS_ATTR_H_ */