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