2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * attr.h - attribute data structures and interfaces
29 * Copyright (c) 1998, Apple Computer, Inc. All Rights Reserved.
35 #include <sys/appleapiopts.h>
37 #ifdef __APPLE_API_UNSTABLE
39 #include <sys/types.h>
42 #include <sys/ucred.h>
45 #include <sys/mount.h>
51 #define FSOPT_NOFOLLOW 0x00000001
52 #define FSOPT_NOINMEMUPDATE 0x00000002
54 typedef u_int32_t text_encoding_t
;
56 typedef u_int32_t fsobj_type_t
;
58 typedef u_int32_t fsobj_tag_t
;
60 typedef u_int32_t fsfile_type_t
;
62 typedef u_int32_t fsvolid_t
;
64 typedef struct fsobj_id
{
66 u_int32_t fid_generation
;
69 typedef u_int32_t attrgroup_t
;
72 u_short bitmapcount
; /* number of attr. bit sets in list (should be 5) */
73 u_int16_t reserved
; /* (to maintain 4-byte alignment) */
74 attrgroup_t commonattr
; /* common attribute group */
75 attrgroup_t volattr
; /* Volume attribute group */
76 attrgroup_t dirattr
; /* directory attribute group */
77 attrgroup_t fileattr
; /* file attribute group */
78 attrgroup_t forkattr
; /* fork attribute group */
80 #define ATTR_BIT_MAP_COUNT 5
82 typedef struct attribute_set
{
83 attrgroup_t commonattr
; /* common attribute group */
84 attrgroup_t volattr
; /* Volume attribute group */
85 attrgroup_t dirattr
; /* directory attribute group */
86 attrgroup_t fileattr
; /* file attribute group */
87 attrgroup_t forkattr
; /* fork attribute group */
90 typedef struct attrreference
{
95 /* XXX PPD This is derived from HFSVolumePriv.h and should perhaps be referenced from there? */
98 u_int32_t startblock
; /* first block allocated */
99 u_int32_t blockcount
; /* number of blocks allocated */
102 typedef struct diskextent extentrecord
[8];
104 typedef u_int32_t vol_capabilities_set_t
[4];
106 #define VOL_CAPABILITIES_FORMAT 0
107 #define VOL_CAPABILITIES_INTERFACES 1
108 #define VOL_CAPABILITIES_RESERVED1 2
109 #define VOL_CAPABILITIES_RESERVED2 3
111 typedef struct vol_capabilities_attr
{
112 vol_capabilities_set_t capabilities
;
113 vol_capabilities_set_t valid
;
114 } vol_capabilities_attr_t
;
117 * VOL_CAP_FMT_PERSISTENTOBJECTIDS: When set, the volume has object IDs
118 * that are persistent (retain their values even when the volume is
119 * unmounted and remounted), and a file or directory can be looked up
120 * by ID. Volumes that support VolFS and can support Carbon File ID
121 * references should set this bit.
123 * VOL_CAP_FMT_SYMBOLICLINKS: When set, the volume supports symbolic
124 * links. The symlink(), readlink(), and lstat() calls all use this
127 * VOL_CAP_FMT_HARDLINKS: When set, the volume supports hard links.
128 * The link() call creates hard links.
130 * VOL_CAP_FMT_JOURNAL: When set, the volume is capable of supporting
131 * a journal used to speed recovery in case of unplanned shutdown
132 * (such as a power outage or crash). This bit does not necessarily
133 * mean the volume is actively using a journal for recovery.
135 * VOL_CAP_FMT_JOURNAL_ACTIVE: When set, the volume is currently using
136 * a journal for use in speeding recovery after an unplanned shutdown.
137 * This bit can be set only if VOL_CAP_FMT_JOURNAL is also set.
139 * VOL_CAP_FMT_NO_ROOT_TIMES: When set, the volume format does not
140 * store reliable times for the root directory, so you should not
141 * depend on them to detect changes, etc.
143 * VOL_CAP_FMT_SPARSE_FILES: When set, the volume supports sparse files.
144 * That is, files which can have "holes" that have never been written
145 * to, and are not allocated on disk. Sparse files may have an
146 * allocated size that is less than the file's logical length.
148 * VOL_CAP_FMT_ZERO_RUNS: For security reasons, parts of a file (runs)
149 * that have never been written to must appear to contain zeroes. When
150 * this bit is set, the volume keeps track of allocated but unwritten
151 * runs of a file so that it can substitute zeroes without actually
152 * writing zeroes to the media. This provides performance similar to
153 * sparse files, but not the space savings.
155 * VOL_CAP_FMT_CASE_SENSITIVE: When set, file and directory names are
156 * case sensitive (upper and lower case are different). When clear,
157 * an upper case character is equivalent to a lower case character,
158 * and you can't have two names that differ solely in the case of
161 * VOL_CAP_FMT_CASE_PRESERVING: When set, file and directory names
162 * preserve the difference between upper and lower case. If clear,
163 * the volume may change the case of some characters (typically
164 * making them all upper or all lower case). A volume that sets
165 * VOL_CAP_FMT_CASE_SENSITIVE should also set VOL_CAP_FMT_CASE_PRESERVING.
167 * VOL_CAP_FMT_FAST_STATFS: This bit is used as a hint to upper layers
168 * (especially Carbon) that statfs() is fast enough that its results
169 * need not be cached by those upper layers. A volume that caches
170 * the statfs information in its in-memory structures should set this bit.
171 * A volume that must always read from disk or always perform a network
172 * transaction should not set this bit.
174 #define VOL_CAP_FMT_PERSISTENTOBJECTIDS 0x00000001
175 #define VOL_CAP_FMT_SYMBOLICLINKS 0x00000002
176 #define VOL_CAP_FMT_HARDLINKS 0x00000004
177 #define VOL_CAP_FMT_JOURNAL 0x00000008
178 #define VOL_CAP_FMT_JOURNAL_ACTIVE 0x00000010
179 #define VOL_CAP_FMT_NO_ROOT_TIMES 0x00000020
180 #define VOL_CAP_FMT_SPARSE_FILES 0x00000040
181 #define VOL_CAP_FMT_ZERO_RUNS 0x00000080
182 #define VOL_CAP_FMT_CASE_SENSITIVE 0x00000100
183 #define VOL_CAP_FMT_CASE_PRESERVING 0x00000200
184 #define VOL_CAP_FMT_FAST_STATFS 0x00000400
188 * VOL_CAP_INT_SEARCHFS: When set, the volume implements the
189 * searchfs() system call (the VOP_SEARCHFS vnode operation).
191 * VOL_CAP_INT_ATTRLIST: When set, the volume implements the
192 * getattrlist() and setattrlist() system calls (VOP_GETATTRLIST
193 * and VOP_SETATTRLIST vnode operations) for the volume, files,
194 * and directories. The volume may or may not implement the
195 * readdirattr() system call. XXX Is there any minimum set
196 * of attributes that should be supported? To determine the
197 * set of supported attributes, get the ATTR_VOL_ATTRIBUTES
198 * attribute of the volume.
200 * VOL_CAP_INT_NFSEXPORT: When set, the volume implements exporting
203 * VOL_CAP_INT_READDIRATTR: When set, the volume implements the
204 * readdirattr() system call (VOP_READDIRATTR vnode operation).
206 * VOL_CAP_INT_EXCHANGEDATA: When set, the volume implements the
207 * exchangedata() system call (VOP_EXCHANGE vnode operation).
209 * VOL_CAP_INT_COPYFILE: When set, the volume implements the
210 * VOP_COPYFILE vnode operation. (XXX There should be a copyfile()
211 * system call in <unistd.h>.)
213 * VOL_CAP_INT_ALLOCATE: When set, the volume implements the
214 * VOP_ALLOCATE vnode operation, which means it implements the
215 * F_PREALLOCATE selector of fcntl(2).
217 * VOL_CAP_INT_VOL_RENAME: When set, the volume implements the
218 * ATTR_VOL_NAME attribute for both getattrlist() and setattrlist().
219 * The volume can be renamed by setting ATTR_VOL_NAME with setattrlist().
221 * VOL_CAP_INT_ADVLOCK: When set, the volume implements POSIX style
222 * byte range locks via VOP_ADVLOCK (accessible from fcntl(2)).
224 * VOL_CAP_INT_FLOCK: When set, the volume implements whole-file flock(2)
225 * style locks via VOP_ADVLOCK. This includes the O_EXLOCK and O_SHLOCK
226 * flags of the open(2) call.
229 #define VOL_CAP_INT_SEARCHFS 0x00000001
230 #define VOL_CAP_INT_ATTRLIST 0x00000002
231 #define VOL_CAP_INT_NFSEXPORT 0x00000004
232 #define VOL_CAP_INT_READDIRATTR 0x00000008
233 #define VOL_CAP_INT_EXCHANGEDATA 0x00000010
234 #define VOL_CAP_INT_COPYFILE 0x00000020
235 #define VOL_CAP_INT_ALLOCATE 0x00000040
236 #define VOL_CAP_INT_VOL_RENAME 0x00000080
237 #define VOL_CAP_INT_ADVLOCK 0x00000100
238 #define VOL_CAP_INT_FLOCK 0x00000200
240 typedef struct vol_attributes_attr
{
241 attribute_set_t validattr
;
242 attribute_set_t nativeattr
;
243 } vol_attributes_attr_t
;
245 #define DIR_MNTSTATUS_MNTPOINT 0x00000001
247 #define ATTR_CMN_NAME 0x00000001
248 #define ATTR_CMN_DEVID 0x00000002
249 #define ATTR_CMN_FSID 0x00000004
250 #define ATTR_CMN_OBJTYPE 0x00000008
251 #define ATTR_CMN_OBJTAG 0x00000010
252 #define ATTR_CMN_OBJID 0x00000020
253 #define ATTR_CMN_OBJPERMANENTID 0x00000040
254 #define ATTR_CMN_PAROBJID 0x00000080
255 #define ATTR_CMN_SCRIPT 0x00000100
256 #define ATTR_CMN_CRTIME 0x00000200
257 #define ATTR_CMN_MODTIME 0x00000400
258 #define ATTR_CMN_CHGTIME 0x00000800
259 #define ATTR_CMN_ACCTIME 0x00001000
260 #define ATTR_CMN_BKUPTIME 0x00002000
261 #define ATTR_CMN_FNDRINFO 0x00004000
262 #define ATTR_CMN_OWNERID 0x00008000
263 #define ATTR_CMN_GRPID 0x00010000
264 #define ATTR_CMN_ACCESSMASK 0x00020000
265 #define ATTR_CMN_FLAGS 0x00040000
266 #define ATTR_CMN_NAMEDATTRCOUNT 0x00080000
267 #define ATTR_CMN_NAMEDATTRLIST 0x00100000
268 #define ATTR_CMN_USERACCESS 0x00200000
270 #define ATTR_CMN_VALIDMASK 0x003FFFFF
271 #define ATTR_CMN_SETMASK 0x0007FF00
272 #define ATTR_CMN_VOLSETMASK 0x00006700
274 #define ATTR_VOL_FSTYPE 0x00000001
275 #define ATTR_VOL_SIGNATURE 0x00000002
276 #define ATTR_VOL_SIZE 0x00000004
277 #define ATTR_VOL_SPACEFREE 0x00000008
278 #define ATTR_VOL_SPACEAVAIL 0x00000010
279 #define ATTR_VOL_MINALLOCATION 0x00000020
280 #define ATTR_VOL_ALLOCATIONCLUMP 0x00000040
281 #define ATTR_VOL_IOBLOCKSIZE 0x00000080
282 #define ATTR_VOL_OBJCOUNT 0x00000100
283 #define ATTR_VOL_FILECOUNT 0x00000200
284 #define ATTR_VOL_DIRCOUNT 0x00000400
285 #define ATTR_VOL_MAXOBJCOUNT 0x00000800
286 #define ATTR_VOL_MOUNTPOINT 0x00001000
287 #define ATTR_VOL_NAME 0x00002000
288 #define ATTR_VOL_MOUNTFLAGS 0x00004000
289 #define ATTR_VOL_MOUNTEDDEVICE 0x00008000
290 #define ATTR_VOL_ENCODINGSUSED 0x00010000
291 #define ATTR_VOL_CAPABILITIES 0x00020000
292 #define ATTR_VOL_ATTRIBUTES 0x40000000
293 #define ATTR_VOL_INFO 0x80000000
295 #define ATTR_VOL_VALIDMASK 0xC003FFFF
296 #define ATTR_VOL_SETMASK 0x80002000
299 /* File/directory attributes: */
300 #define ATTR_DIR_LINKCOUNT 0x00000001
301 #define ATTR_DIR_ENTRYCOUNT 0x00000002
302 #define ATTR_DIR_MOUNTSTATUS 0x00000004
304 #define ATTR_DIR_VALIDMASK 0x00000007
305 #define ATTR_DIR_SETMASK 0x00000000
307 #define ATTR_FILE_LINKCOUNT 0x00000001
308 #define ATTR_FILE_TOTALSIZE 0x00000002
309 #define ATTR_FILE_ALLOCSIZE 0x00000004
310 #define ATTR_FILE_IOBLOCKSIZE 0x00000008
311 #define ATTR_FILE_CLUMPSIZE 0x00000010
312 #define ATTR_FILE_DEVTYPE 0x00000020
313 #define ATTR_FILE_FILETYPE 0x00000040
314 #define ATTR_FILE_FORKCOUNT 0x00000080
315 #define ATTR_FILE_FORKLIST 0x00000100
316 #define ATTR_FILE_DATALENGTH 0x00000200
317 #define ATTR_FILE_DATAALLOCSIZE 0x00000400
318 #define ATTR_FILE_DATAEXTENTS 0x00000800
319 #define ATTR_FILE_RSRCLENGTH 0x00001000
320 #define ATTR_FILE_RSRCALLOCSIZE 0x00002000
321 #define ATTR_FILE_RSRCEXTENTS 0x00004000
323 #define ATTR_FILE_VALIDMASK 0x00007FFF
324 #define ATTR_FILE_SETMASK 0x00000020
326 #define ATTR_FORK_TOTALSIZE 0x00000001
327 #define ATTR_FORK_ALLOCSIZE 0x00000002
329 #define ATTR_FORK_VALIDMASK 0x00000003
330 #define ATTR_FORK_SETMASK 0x00000000
332 #define SRCHFS_START 0x00000001
333 #define SRCHFS_MATCHPARTIALNAMES 0x00000002
334 #define SRCHFS_MATCHDIRS 0x00000004
335 #define SRCHFS_MATCHFILES 0x00000008
336 #define SRCHFS_SKIPLINKS 0x00000010
337 #define SRCHFS_SKIPINVISIBLE 0x00000020
338 #define SRCHFS_SKIPPACKAGES 0x00000040
339 #define SRCHFS_SKIPINAPPROPRIATE 0x00000080
341 #define SRCHFS_NEGATEPARAMS 0x80000000
342 #define SRCHFS_VALIDOPTIONSMASK 0x800000FF
344 struct fssearchblock
{
345 struct attrlist
*returnattrs
;
347 size_t returnbuffersize
;
349 struct timeval timelimit
;
351 size_t sizeofsearchparams1
;
353 size_t sizeofsearchparams2
;
354 struct attrlist searchattrs
;
359 u_char reserved
[556]; // sizeof( SearchState )
363 #define FST_EOF (-1) /* end-of-file offset */
365 #endif /* __APPLE_API_UNSTABLE */
366 #endif /* !_SYS_ATTR_H_ */