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 /* we currently aren't anywhere near this amount for a valid
52 * fssearchblock.sizeofsearchparams1 or fssearchblock.sizeofsearchparams2
53 * but we put a sanity check in to avoid abuse of the value passed in from
56 #define SEARCHFS_MAX_SEARCHPARMS 4096
58 typedef u_int32_t text_encoding_t
;
60 typedef u_int32_t fsobj_type_t
;
62 typedef u_int32_t fsobj_tag_t
;
64 typedef u_int32_t fsfile_type_t
;
66 typedef u_int32_t fsvolid_t
;
68 typedef struct fsobj_id
{
70 u_int32_t fid_generation
;
73 typedef u_int32_t attrgroup_t
;
76 u_short bitmapcount
; /* number of attr. bit sets in list (should be 5) */
77 u_int16_t reserved
; /* (to maintain 4-byte alignment) */
78 attrgroup_t commonattr
; /* common attribute group */
79 attrgroup_t volattr
; /* Volume attribute group */
80 attrgroup_t dirattr
; /* directory attribute group */
81 attrgroup_t fileattr
; /* file attribute group */
82 attrgroup_t forkattr
; /* fork attribute group */
84 #define ATTR_BIT_MAP_COUNT 5
86 typedef struct attribute_set
{
87 attrgroup_t commonattr
; /* common attribute group */
88 attrgroup_t volattr
; /* Volume attribute group */
89 attrgroup_t dirattr
; /* directory attribute group */
90 attrgroup_t fileattr
; /* file attribute group */
91 attrgroup_t forkattr
; /* fork attribute group */
94 typedef struct attrreference
{
99 /* XXX PPD This is derived from HFSVolumePriv.h and should perhaps be referenced from there? */
102 u_int32_t startblock
; /* first block allocated */
103 u_int32_t blockcount
; /* number of blocks allocated */
106 typedef struct diskextent extentrecord
[8];
108 typedef u_int32_t vol_capabilities_set_t
[4];
110 #define VOL_CAPABILITIES_FORMAT 0
111 #define VOL_CAPABILITIES_INTERFACES 1
112 #define VOL_CAPABILITIES_RESERVED1 2
113 #define VOL_CAPABILITIES_RESERVED2 3
115 typedef struct vol_capabilities_attr
{
116 vol_capabilities_set_t capabilities
;
117 vol_capabilities_set_t valid
;
118 } vol_capabilities_attr_t
;
121 * VOL_CAP_FMT_PERSISTENTOBJECTIDS: When set, the volume has object IDs
122 * that are persistent (retain their values even when the volume is
123 * unmounted and remounted), and a file or directory can be looked up
124 * by ID. Volumes that support VolFS and can support Carbon File ID
125 * references should set this bit.
127 * VOL_CAP_FMT_SYMBOLICLINKS: When set, the volume supports symbolic
128 * links. The symlink(), readlink(), and lstat() calls all use this
131 * VOL_CAP_FMT_HARDLINKS: When set, the volume supports hard links.
132 * The link() call creates hard links.
134 * VOL_CAP_FMT_JOURNAL: When set, the volume is capable of supporting
135 * a journal used to speed recovery in case of unplanned shutdown
136 * (such as a power outage or crash). This bit does not necessarily
137 * mean the volume is actively using a journal for recovery.
139 * VOL_CAP_FMT_JOURNAL_ACTIVE: When set, the volume is currently using
140 * a journal for use in speeding recovery after an unplanned shutdown.
141 * This bit can be set only if VOL_CAP_FMT_JOURNAL is also set.
143 * VOL_CAP_FMT_NO_ROOT_TIMES: When set, the volume format does not
144 * store reliable times for the root directory, so you should not
145 * depend on them to detect changes, etc.
147 * VOL_CAP_FMT_SPARSE_FILES: When set, the volume supports sparse files.
148 * That is, files which can have "holes" that have never been written
149 * to, and are not allocated on disk. Sparse files may have an
150 * allocated size that is less than the file's logical length.
152 * VOL_CAP_FMT_ZERO_RUNS: For security reasons, parts of a file (runs)
153 * that have never been written to must appear to contain zeroes. When
154 * this bit is set, the volume keeps track of allocated but unwritten
155 * runs of a file so that it can substitute zeroes without actually
156 * writing zeroes to the media. This provides performance similar to
157 * sparse files, but not the space savings.
159 * VOL_CAP_FMT_CASE_SENSITIVE: When set, file and directory names are
160 * case sensitive (upper and lower case are different). When clear,
161 * an upper case character is equivalent to a lower case character,
162 * and you can't have two names that differ solely in the case of
165 * VOL_CAP_FMT_CASE_PRESERVING: When set, file and directory names
166 * preserve the difference between upper and lower case. If clear,
167 * the volume may change the case of some characters (typically
168 * making them all upper or all lower case). A volume that sets
169 * VOL_CAP_FMT_CASE_SENSITIVE should also set VOL_CAP_FMT_CASE_PRESERVING.
171 * VOL_CAP_FMT_FAST_STATFS: This bit is used as a hint to upper layers
172 * (especially Carbon) that statfs() is fast enough that its results
173 * need not be cached by those upper layers. A volume that caches
174 * the statfs information in its in-memory structures should set this bit.
175 * A volume that must always read from disk or always perform a network
176 * transaction should not set this bit.
178 #define VOL_CAP_FMT_PERSISTENTOBJECTIDS 0x00000001
179 #define VOL_CAP_FMT_SYMBOLICLINKS 0x00000002
180 #define VOL_CAP_FMT_HARDLINKS 0x00000004
181 #define VOL_CAP_FMT_JOURNAL 0x00000008
182 #define VOL_CAP_FMT_JOURNAL_ACTIVE 0x00000010
183 #define VOL_CAP_FMT_NO_ROOT_TIMES 0x00000020
184 #define VOL_CAP_FMT_SPARSE_FILES 0x00000040
185 #define VOL_CAP_FMT_ZERO_RUNS 0x00000080
186 #define VOL_CAP_FMT_CASE_SENSITIVE 0x00000100
187 #define VOL_CAP_FMT_CASE_PRESERVING 0x00000200
188 #define VOL_CAP_FMT_FAST_STATFS 0x00000400
192 * VOL_CAP_INT_SEARCHFS: When set, the volume implements the
193 * searchfs() system call (the VOP_SEARCHFS vnode operation).
195 * VOL_CAP_INT_ATTRLIST: When set, the volume implements the
196 * getattrlist() and setattrlist() system calls (VOP_GETATTRLIST
197 * and VOP_SETATTRLIST vnode operations) for the volume, files,
198 * and directories. The volume may or may not implement the
199 * readdirattr() system call. XXX Is there any minimum set
200 * of attributes that should be supported? To determine the
201 * set of supported attributes, get the ATTR_VOL_ATTRIBUTES
202 * attribute of the volume.
204 * VOL_CAP_INT_NFSEXPORT: When set, the volume implements exporting
207 * VOL_CAP_INT_READDIRATTR: When set, the volume implements the
208 * readdirattr() system call (VOP_READDIRATTR vnode operation).
210 * VOL_CAP_INT_EXCHANGEDATA: When set, the volume implements the
211 * exchangedata() system call (VOP_EXCHANGE vnode operation).
213 * VOL_CAP_INT_COPYFILE: When set, the volume implements the
214 * VOP_COPYFILE vnode operation. (XXX There should be a copyfile()
215 * system call in <unistd.h>.)
217 * VOL_CAP_INT_ALLOCATE: When set, the volume implements the
218 * VOP_ALLOCATE vnode operation, which means it implements the
219 * F_PREALLOCATE selector of fcntl(2).
221 * VOL_CAP_INT_VOL_RENAME: When set, the volume implements the
222 * ATTR_VOL_NAME attribute for both getattrlist() and setattrlist().
223 * The volume can be renamed by setting ATTR_VOL_NAME with setattrlist().
225 * VOL_CAP_INT_ADVLOCK: When set, the volume implements POSIX style
226 * byte range locks via VOP_ADVLOCK (accessible from fcntl(2)).
228 * VOL_CAP_INT_FLOCK: When set, the volume implements whole-file flock(2)
229 * style locks via VOP_ADVLOCK. This includes the O_EXLOCK and O_SHLOCK
230 * flags of the open(2) call.
233 #define VOL_CAP_INT_SEARCHFS 0x00000001
234 #define VOL_CAP_INT_ATTRLIST 0x00000002
235 #define VOL_CAP_INT_NFSEXPORT 0x00000004
236 #define VOL_CAP_INT_READDIRATTR 0x00000008
237 #define VOL_CAP_INT_EXCHANGEDATA 0x00000010
238 #define VOL_CAP_INT_COPYFILE 0x00000020
239 #define VOL_CAP_INT_ALLOCATE 0x00000040
240 #define VOL_CAP_INT_VOL_RENAME 0x00000080
241 #define VOL_CAP_INT_ADVLOCK 0x00000100
242 #define VOL_CAP_INT_FLOCK 0x00000200
244 typedef struct vol_attributes_attr
{
245 attribute_set_t validattr
;
246 attribute_set_t nativeattr
;
247 } vol_attributes_attr_t
;
249 #define DIR_MNTSTATUS_MNTPOINT 0x00000001
251 #define ATTR_CMN_NAME 0x00000001
252 #define ATTR_CMN_DEVID 0x00000002
253 #define ATTR_CMN_FSID 0x00000004
254 #define ATTR_CMN_OBJTYPE 0x00000008
255 #define ATTR_CMN_OBJTAG 0x00000010
256 #define ATTR_CMN_OBJID 0x00000020
257 #define ATTR_CMN_OBJPERMANENTID 0x00000040
258 #define ATTR_CMN_PAROBJID 0x00000080
259 #define ATTR_CMN_SCRIPT 0x00000100
260 #define ATTR_CMN_CRTIME 0x00000200
261 #define ATTR_CMN_MODTIME 0x00000400
262 #define ATTR_CMN_CHGTIME 0x00000800
263 #define ATTR_CMN_ACCTIME 0x00001000
264 #define ATTR_CMN_BKUPTIME 0x00002000
265 #define ATTR_CMN_FNDRINFO 0x00004000
266 #define ATTR_CMN_OWNERID 0x00008000
267 #define ATTR_CMN_GRPID 0x00010000
268 #define ATTR_CMN_ACCESSMASK 0x00020000
269 #define ATTR_CMN_FLAGS 0x00040000
270 #define ATTR_CMN_NAMEDATTRCOUNT 0x00080000
271 #define ATTR_CMN_NAMEDATTRLIST 0x00100000
272 #define ATTR_CMN_USERACCESS 0x00200000
274 #define ATTR_CMN_VALIDMASK 0x003FFFFF
275 #define ATTR_CMN_SETMASK 0x0007FF00
276 #define ATTR_CMN_VOLSETMASK 0x00006700
278 #define ATTR_VOL_FSTYPE 0x00000001
279 #define ATTR_VOL_SIGNATURE 0x00000002
280 #define ATTR_VOL_SIZE 0x00000004
281 #define ATTR_VOL_SPACEFREE 0x00000008
282 #define ATTR_VOL_SPACEAVAIL 0x00000010
283 #define ATTR_VOL_MINALLOCATION 0x00000020
284 #define ATTR_VOL_ALLOCATIONCLUMP 0x00000040
285 #define ATTR_VOL_IOBLOCKSIZE 0x00000080
286 #define ATTR_VOL_OBJCOUNT 0x00000100
287 #define ATTR_VOL_FILECOUNT 0x00000200
288 #define ATTR_VOL_DIRCOUNT 0x00000400
289 #define ATTR_VOL_MAXOBJCOUNT 0x00000800
290 #define ATTR_VOL_MOUNTPOINT 0x00001000
291 #define ATTR_VOL_NAME 0x00002000
292 #define ATTR_VOL_MOUNTFLAGS 0x00004000
293 #define ATTR_VOL_MOUNTEDDEVICE 0x00008000
294 #define ATTR_VOL_ENCODINGSUSED 0x00010000
295 #define ATTR_VOL_CAPABILITIES 0x00020000
296 #define ATTR_VOL_ATTRIBUTES 0x40000000
297 #define ATTR_VOL_INFO 0x80000000
299 #define ATTR_VOL_VALIDMASK 0xC003FFFF
300 #define ATTR_VOL_SETMASK 0x80002000
303 /* File/directory attributes: */
304 #define ATTR_DIR_LINKCOUNT 0x00000001
305 #define ATTR_DIR_ENTRYCOUNT 0x00000002
306 #define ATTR_DIR_MOUNTSTATUS 0x00000004
308 #define ATTR_DIR_VALIDMASK 0x00000007
309 #define ATTR_DIR_SETMASK 0x00000000
311 #define ATTR_FILE_LINKCOUNT 0x00000001
312 #define ATTR_FILE_TOTALSIZE 0x00000002
313 #define ATTR_FILE_ALLOCSIZE 0x00000004
314 #define ATTR_FILE_IOBLOCKSIZE 0x00000008
315 #define ATTR_FILE_CLUMPSIZE 0x00000010
316 #define ATTR_FILE_DEVTYPE 0x00000020
317 #define ATTR_FILE_FILETYPE 0x00000040
318 #define ATTR_FILE_FORKCOUNT 0x00000080
319 #define ATTR_FILE_FORKLIST 0x00000100
320 #define ATTR_FILE_DATALENGTH 0x00000200
321 #define ATTR_FILE_DATAALLOCSIZE 0x00000400
322 #define ATTR_FILE_DATAEXTENTS 0x00000800
323 #define ATTR_FILE_RSRCLENGTH 0x00001000
324 #define ATTR_FILE_RSRCALLOCSIZE 0x00002000
325 #define ATTR_FILE_RSRCEXTENTS 0x00004000
327 #define ATTR_FILE_VALIDMASK 0x00007FFF
328 #define ATTR_FILE_SETMASK 0x00000020
330 #define ATTR_FORK_TOTALSIZE 0x00000001
331 #define ATTR_FORK_ALLOCSIZE 0x00000002
333 #define ATTR_FORK_VALIDMASK 0x00000003
334 #define ATTR_FORK_SETMASK 0x00000000
336 #define SRCHFS_START 0x00000001
337 #define SRCHFS_MATCHPARTIALNAMES 0x00000002
338 #define SRCHFS_MATCHDIRS 0x00000004
339 #define SRCHFS_MATCHFILES 0x00000008
340 #define SRCHFS_SKIPLINKS 0x00000010
341 #define SRCHFS_SKIPINVISIBLE 0x00000020
342 #define SRCHFS_SKIPPACKAGES 0x00000040
343 #define SRCHFS_SKIPINAPPROPRIATE 0x00000080
345 #define SRCHFS_NEGATEPARAMS 0x80000000
346 #define SRCHFS_VALIDOPTIONSMASK 0x800000FF
348 struct fssearchblock
{
349 struct attrlist
*returnattrs
;
351 size_t returnbuffersize
;
353 struct timeval timelimit
;
355 size_t sizeofsearchparams1
;
357 size_t sizeofsearchparams2
;
358 struct attrlist searchattrs
;
363 u_char reserved
[556]; // sizeof( SearchState )
367 #define FST_EOF (-1) /* end-of-file offset */
369 #endif /* __APPLE_API_UNSTABLE */
370 #endif /* !_SYS_ATTR_H_ */