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