]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/attr.h
xnu-517.tar.gz
[apple/xnu.git] / bsd / sys / attr.h
1 /*
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26 /*
27 * attr.h - attribute data structures and interfaces
28 *
29 * Copyright (c) 1998, Apple Computer, Inc. All Rights Reserved.
30 */
31
32 #ifndef _SYS_ATTR_H_
33 #define _SYS_ATTR_H_
34
35 #include <sys/appleapiopts.h>
36
37 #ifdef __APPLE_API_UNSTABLE
38 #ifndef _SYS_TYPES_H_
39 #include <sys/types.h>
40 #endif
41 #ifndef _SYS_UCRED_H
42 #include <sys/ucred.h>
43 #endif
44 #ifndef _SYS_MOUNT_H_
45 #include <sys/mount.h>
46 #endif
47 #ifndef _SYS_TIME_H_
48 #include <sys/time.h>
49 #endif
50
51 #define FSOPT_NOFOLLOW 0x00000001
52 #define FSOPT_NOINMEMUPDATE 0x00000002
53
54 typedef u_int32_t text_encoding_t;
55
56 typedef u_int32_t fsobj_type_t;
57
58 typedef u_int32_t fsobj_tag_t;
59
60 typedef u_int32_t fsfile_type_t;
61
62 typedef u_int32_t fsvolid_t;
63
64 typedef struct fsobj_id {
65 u_int32_t fid_objno;
66 u_int32_t fid_generation;
67 } fsobj_id_t;
68
69 typedef u_int32_t attrgroup_t;
70
71 struct attrlist {
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 */
79 };
80 #define ATTR_BIT_MAP_COUNT 5
81
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 */
88 } attribute_set_t;
89
90 typedef struct attrreference {
91 long attr_dataoffset;
92 size_t attr_length;
93 } attrreference_t;
94
95 /* XXX PPD This is derived from HFSVolumePriv.h and should perhaps be referenced from there? */
96
97 struct diskextent {
98 u_int32_t startblock; /* first block allocated */
99 u_int32_t blockcount; /* number of blocks allocated */
100 };
101
102 typedef struct diskextent extentrecord[8];
103
104 typedef u_int32_t vol_capabilities_set_t[4];
105
106 #define VOL_CAPABILITIES_FORMAT 0
107 #define VOL_CAPABILITIES_INTERFACES 1
108 #define VOL_CAPABILITIES_RESERVED1 2
109 #define VOL_CAPABILITIES_RESERVED2 3
110
111 typedef struct vol_capabilities_attr {
112 vol_capabilities_set_t capabilities;
113 vol_capabilities_set_t valid;
114 } vol_capabilities_attr_t;
115
116 /*
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.
122 *
123 * VOL_CAP_FMT_SYMBOLICLINKS: When set, the volume supports symbolic
124 * links. The symlink(), readlink(), and lstat() calls all use this
125 * symbolic link.
126 *
127 * VOL_CAP_FMT_HARDLINKS: When set, the volume supports hard links.
128 * The link() call creates hard links.
129 *
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.
134 *
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.
138 *
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.
142 *
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.
147 *
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.
154 *
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
159 * the characters.
160 *
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.
166 *
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.
173 */
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
185
186
187 /*
188 * VOL_CAP_INT_SEARCHFS: When set, the volume implements the
189 * searchfs() system call (the VOP_SEARCHFS vnode operation).
190 *
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.
199 *
200 * VOL_CAP_INT_NFSEXPORT: When set, the volume implements exporting
201 * of NFS volumes.
202 *
203 * VOL_CAP_INT_READDIRATTR: When set, the volume implements the
204 * readdirattr() system call (VOP_READDIRATTR vnode operation).
205 *
206 * VOL_CAP_INT_EXCHANGEDATA: When set, the volume implements the
207 * exchangedata() system call (VOP_EXCHANGE vnode operation).
208 *
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>.)
212 *
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).
216 *
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().
220 *
221 * VOL_CAP_INT_ADVLOCK: When set, the volume implements POSIX style
222 * byte range locks via VOP_ADVLOCK (accessible from fcntl(2)).
223 *
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.
227 *
228 */
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
239
240 typedef struct vol_attributes_attr {
241 attribute_set_t validattr;
242 attribute_set_t nativeattr;
243 } vol_attributes_attr_t;
244
245 #define DIR_MNTSTATUS_MNTPOINT 0x00000001
246
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
269
270 #define ATTR_CMN_VALIDMASK 0x003FFFFF
271 #define ATTR_CMN_SETMASK 0x0007FF00
272 #define ATTR_CMN_VOLSETMASK 0x00006700
273
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
294
295 #define ATTR_VOL_VALIDMASK 0xC003FFFF
296 #define ATTR_VOL_SETMASK 0x80002000
297
298
299 /* File/directory attributes: */
300 #define ATTR_DIR_LINKCOUNT 0x00000001
301 #define ATTR_DIR_ENTRYCOUNT 0x00000002
302 #define ATTR_DIR_MOUNTSTATUS 0x00000004
303
304 #define ATTR_DIR_VALIDMASK 0x00000007
305 #define ATTR_DIR_SETMASK 0x00000000
306
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
322
323 #define ATTR_FILE_VALIDMASK 0x00007FFF
324 #define ATTR_FILE_SETMASK 0x00000020
325
326 #define ATTR_FORK_TOTALSIZE 0x00000001
327 #define ATTR_FORK_ALLOCSIZE 0x00000002
328
329 #define ATTR_FORK_VALIDMASK 0x00000003
330 #define ATTR_FORK_SETMASK 0x00000000
331
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
340
341 #define SRCHFS_NEGATEPARAMS 0x80000000
342 #define SRCHFS_VALIDOPTIONSMASK 0x800000FF
343
344 struct fssearchblock {
345 struct attrlist *returnattrs;
346 void *returnbuffer;
347 size_t returnbuffersize;
348 u_long maxmatches;
349 struct timeval timelimit;
350 void *searchparams1;
351 size_t sizeofsearchparams1;
352 void *searchparams2;
353 size_t sizeofsearchparams2;
354 struct attrlist searchattrs;
355 };
356
357
358 struct searchstate {
359 u_char reserved[556]; // sizeof( SearchState )
360 };
361
362
363 #define FST_EOF (-1) /* end-of-file offset */
364
365 #endif /* __APPLE_API_UNSTABLE */
366 #endif /* !_SYS_ATTR_H_ */