]>
Commit | Line | Data |
---|---|---|
91447636 | 1 | .\" Copyright (c) 2003 Apple Computer, Inc. All rights reserved. |
2d21ac55 | 2 | .\" |
91447636 A |
3 | .\" The contents of this file constitute Original Code as defined in and |
4 | .\" are subject to the Apple Public Source License Version 1.1 (the | |
5 | .\" "License"). You may not use this file except in compliance with the | |
6 | .\" License. Please obtain a copy of the License at | |
7 | .\" http://www.apple.com/publicsource and read it before using this file. | |
2d21ac55 | 8 | .\" |
91447636 A |
9 | .\" This Original Code and all software distributed under the License are |
10 | .\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
11 | .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
12 | .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
13 | .\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
14 | .\" License for the specific language governing rights and limitations | |
15 | .\" under the License. | |
2d21ac55 | 16 | .\" |
91447636 A |
17 | .\" @(#)getattrlist.2 |
18 | . | |
fe8ab488 | 19 | .Dd February 25, 2014 |
91447636 A |
20 | .Dt GETATTRLIST 2 |
21 | .Os Darwin | |
22 | .Sh NAME | |
b0d623f7 | 23 | .Nm getattrlist , |
fe8ab488 A |
24 | .Nm fgetattrlist , |
25 | .Nm getattrlistat | |
91447636 A |
26 | .Nd get file system attributes |
27 | .Sh SYNOPSIS | |
28 | .Fd #include <sys/attr.h> | |
29 | .Fd #include <unistd.h> | |
30 | .Ft int | |
31 | .Fn getattrlist "const char* path" "struct attrlist * attrList" "void * attrBuf" "size_t attrBufSize" "unsigned long options" | |
32 | . | |
b0d623f7 A |
33 | .Ft int |
34 | .Fn fgetattrlist "int fd" "struct attrlist * attrList" "void * attrBuf" "size_t attrBufSize" "unsigned long options" | |
fe8ab488 A |
35 | .Ft int |
36 | .Fo getattrlistat | |
37 | .Fa "int fd" "const char *path" "struct attrlist * attrList" "void * attrBuf" | |
38 | .Fa "size_t attrBufSize" "unsigned long options" | |
39 | .Fc | |
91447636 A |
40 | .Sh DESCRIPTION |
41 | The | |
42 | .Fn getattrlist | |
43 | function returns attributes (that is, metadata) of file system objects. | |
b0d623f7 A |
44 | .Fn getattrlist |
45 | works on the file system object named by | |
46 | .Fa path , | |
47 | while | |
48 | .Fn fgetattrlist | |
49 | works on the provided file descriptor | |
50 | .Fa fd . | |
fe8ab488 A |
51 | .Pp |
52 | The | |
53 | .Fn getattrlistat | |
54 | system call is equivalent to | |
55 | .Fn getattrlist | |
56 | except in the case where | |
57 | .Fa path | |
58 | specifies a relative path. | |
59 | In this case the attributes are returned for the file system object named by | |
60 | path relative to the directory associated with the file descriptor | |
61 | .Fa fd | |
62 | instead of the current working directory. | |
63 | If | |
64 | .Fn getattrlistat | |
65 | is passed the special value | |
66 | .Dv AT_FDCWD | |
67 | in the | |
68 | .Fa fd | |
69 | parameter, the current working directory is used and the behavior is | |
70 | identical to a call to | |
71 | .Fn getattrlist . | |
72 | .Pp | |
2d21ac55 | 73 | You can think of |
91447636 A |
74 | .Fn getattrlist |
75 | as a seriously enhanced version of | |
76 | .Xr stat 2 . | |
b0d623f7 A |
77 | The functions return attributes about the specified file system object |
78 | into the buffer specified by | |
91447636 A |
79 | .Fa attrBuf |
80 | and | |
81 | .Fa attrBufSize . | |
2d21ac55 A |
82 | The |
83 | .Fa attrList | |
84 | parameter determines what attributes are returned. | |
85 | The | |
86 | .Fa options | |
87 | parameter lets you control specific aspects of the function's behavior. | |
88 | .Pp | |
89 | . | |
91447636 | 90 | Not all volumes support all attributes. |
2d21ac55 A |
91 | See the discussion of |
92 | .Dv ATTR_VOL_ATTRIBUTES | |
93 | for a discussion of how to determine whether a particular volume supports a | |
91447636 A |
94 | particular attribute. |
95 | .Pp | |
2d21ac55 A |
96 | Furthermore, you should only request the attributes that you need. |
97 | Some attributes are expensive to calculate on some volume formats. | |
98 | For example, | |
99 | .Dv ATTR_DIR_ENTRYCOUNT | |
91447636 A |
100 | is usually expensive to calculate on non-HFS [Plus] volumes. |
101 | If you don't need a particular attribute, you should not ask for it. | |
102 | .Pp | |
103 | . | |
104 | .\" path parameter | |
105 | . | |
106 | The | |
107 | .Fa path | |
108 | parameter must reference a valid file system object. | |
2d21ac55 A |
109 | Read, write or execute permission of the object itself is not required, but |
110 | all directories listed in the path name leading to the object must be | |
91447636 A |
111 | searchable. |
112 | .Pp | |
113 | . | |
114 | .\" attrList parameter | |
115 | . | |
116 | The | |
117 | .Fa attrList | |
2d21ac55 A |
118 | parameter is a pointer to an |
119 | .Vt attrlist | |
91447636 A |
120 | structure, as defined by |
121 | .Aq Pa sys/attr.h | |
122 | (shown below). | |
123 | It determines what attributes are returned by the function. | |
2d21ac55 | 124 | You are responsible for filling out all fields of this structure before calling the function. |
91447636 A |
125 | .Bd -literal |
126 | typedef u_int32_t attrgroup_t; | |
127 | .Pp | |
128 | struct attrlist { | |
129 | u_short bitmapcount; /* number of attr. bit sets in list */ | |
130 | u_int16_t reserved; /* (to maintain 4-byte alignment) */ | |
131 | attrgroup_t commonattr; /* common attribute group */ | |
132 | attrgroup_t volattr; /* volume attribute group */ | |
133 | attrgroup_t dirattr; /* directory attribute group */ | |
134 | attrgroup_t fileattr; /* file attribute group */ | |
135 | attrgroup_t forkattr; /* fork attribute group */ | |
136 | }; | |
137 | #define ATTR_BIT_MAP_COUNT 5 | |
138 | .Ed | |
139 | .Pp | |
140 | . | |
141 | .\" attrlist elements | |
142 | . | |
2d21ac55 | 143 | The fields of the |
91447636 A |
144 | .Vt attrlist |
145 | structure are defined as follows. | |
146 | .Bl -tag -width XXXbitmapcount | |
147 | . | |
148 | .It bitmapcount | |
149 | Number of attribute bit sets in the structure. | |
2d21ac55 | 150 | In current systems you must set this to |
91447636 A |
151 | .Dv ATTR_BIT_MAP_COUNT . |
152 | . | |
153 | .It reserved | |
154 | Reserved. | |
155 | You must set this to 0. | |
156 | . | |
157 | .It commonattr | |
158 | A bit set that specifies the common attributes that you require. | |
2d21ac55 | 159 | Common attributes relate to all types of file system objects. |
91447636 A |
160 | See below for a description of these attributes. |
161 | . | |
162 | .It volattr | |
163 | A bit set that specifies the volume attributes that you require. | |
164 | Volume attributes relate to volumes (that is, mounted file systems). | |
165 | See below for a description of these attributes. | |
2d21ac55 | 166 | If you request volume attributes, |
91447636 A |
167 | .Fa path |
168 | must reference the root of a volume. | |
2d21ac55 | 169 | In addition, you can't request volume attributes if you also request |
91447636 A |
170 | file or directory attributes. |
171 | . | |
172 | .It dirattr | |
173 | A bit set that specifies the directory attributes that you require. | |
174 | See below for a description of these attributes. | |
175 | . | |
176 | .It fileattr | |
177 | A bit set that specifies the file attributes that you require. | |
178 | See below for a description of these attributes. | |
179 | . | |
180 | .It forkattr | |
181 | A bit set that specifies the fork attributes that you require. | |
2d21ac55 | 182 | Fork attributes relate to the actual data in the file, |
91447636 A |
183 | which can be held in multiple named contiguous ranges, or forks. |
184 | See below for a description of these attributes. | |
813fb2f6 A |
185 | If the FSOPT_ATTR_CMN_EXTENDED option is given, this bit set is reinterpreted |
186 | as extended common attributes attributes, also described below. | |
91447636 A |
187 | . |
188 | .El | |
189 | .Pp | |
190 | . | |
2d21ac55 A |
191 | Unless otherwise noted in the lists below, attributes are read-only. |
192 | Attributes labelled as read/write can be set using | |
91447636 A |
193 | .Xr setattrlist 2 . |
194 | .Pp | |
195 | . | |
196 | .\" attrBuf and attrBufSize parameters | |
197 | . | |
198 | The | |
199 | .Fa attrBuf | |
2d21ac55 | 200 | and |
91447636 | 201 | .Fa attrBufSize |
2d21ac55 A |
202 | parameters specify a buffer into which the function places attribute values. |
203 | The format of this buffer is sufficiently complex that its description | |
91447636 A |
204 | requires a separate section (see below). |
205 | The initial contents of this buffer are ignored. | |
206 | .Pp | |
207 | . | |
208 | .\" option parameter | |
209 | . | |
210 | The | |
211 | .Fa options | |
212 | parameter is a bit set that controls the behaviour of | |
b0d623f7 | 213 | the functions. |
91447636 A |
214 | The following option bits are defined. |
215 | . | |
b0d623f7 | 216 | .Bl -tag -width FSOPT_PACK_INVAL_ATTRS |
91447636 A |
217 | . |
218 | .It FSOPT_NOFOLLOW | |
2d21ac55 A |
219 | If this bit is set, |
220 | .Fn getattrlist | |
221 | will not follow a symlink if it occurs as | |
91447636 A |
222 | the last component of |
223 | .Fa path . | |
224 | . | |
b0d623f7 A |
225 | .It FSOPT_REPORT_FULLSIZE |
226 | The size of the attributes reported (in the first | |
227 | .Vt u_int32_t | |
228 | field in the attribute buffer) will be the size needed to hold all the | |
229 | requested attributes; if not set, only the attributes actually returned | |
230 | will be reported. This allows the caller to determine if any truncation | |
231 | occurred. | |
232 | . | |
233 | .It FSOPT_PACK_INVAL_ATTRS | |
234 | If this is bit is set, then all requested attributes, even ones that are | |
235 | not supported by the object or file system, will be returned. Default values | |
236 | will be used for the invalid ones. Requires that | |
237 | .Dv ATTR_CMN_RETURNED_ATTRS | |
238 | be requested. | |
239 | . | |
fe8ab488 A |
240 | .It FSOPT_ATTR_CMN_EXTENDED |
241 | If this is bit is set, then | |
242 | .Dv ATTR_CMN_GEN_COUNT | |
243 | and | |
244 | .Dv ATTR_CMN_DOCUMENT_ID | |
813fb2f6 A |
245 | can be requested. When this option is used, forkattrs are reinterpreted as a |
246 | set of extended common attributes. | |
fe8ab488 | 247 | . |
91447636 A |
248 | .El |
249 | . | |
250 | .Sh ATTRIBUTE BUFFER | |
251 | . | |
2d21ac55 A |
252 | The data returned in the buffer described by |
253 | .Fa attrBuf | |
254 | and | |
255 | .Fa attrBufSize | |
91447636 A |
256 | is formatted as follows. |
257 | .Pp | |
258 | . | |
259 | .Bl -enum | |
260 | . | |
261 | .It | |
2d21ac55 A |
262 | The first element of the buffer is a |
263 | .Vt u_int32_t | |
264 | that contains the overall length, in bytes, of the attributes returned. | |
265 | This size includes the length field itself. | |
91447636 A |
266 | . |
267 | .It | |
2d21ac55 A |
268 | Following the length field is a list of attributes. |
269 | Each attribute is represented by a field of its type, | |
270 | where the type is given as part of the attribute description (below). | |
91447636 A |
271 | . |
272 | .It | |
2d21ac55 | 273 | The attributes are placed into the attribute buffer in the order |
91447636 A |
274 | that they are described below. |
275 | . | |
b0d623f7 A |
276 | .It |
277 | Each attribute is aligned to a 4-byte boundary (including 64-bit data types). | |
91447636 A |
278 | .El |
279 | .Pp | |
280 | . | |
2d21ac55 A |
281 | If the attribute is of variable length, it is represented |
282 | in the list by an | |
283 | .Vt attrreference | |
284 | structure, as defined by | |
91447636 A |
285 | .Aq Pa sys/attr.h |
286 | (shown below). | |
287 | . | |
288 | .Bd -literal | |
289 | typedef struct attrreference { | |
b0d623f7 A |
290 | int32_t attr_dataoffset; |
291 | u_int32_t attr_length; | |
91447636 A |
292 | } attrreference_t; |
293 | .Ed | |
294 | .Pp | |
295 | . | |
296 | This structure contains a 'pointer' to the variable length attribute data. | |
2d21ac55 A |
297 | The |
298 | .Fa attr_length | |
299 | field is the length of the attribute data (in bytes). | |
300 | The | |
301 | .Fa attr_dataoffset | |
302 | field is the offset in bytes from the | |
303 | .Vt attrreference | |
304 | structure | |
305 | to the attribute data. | |
b0d623f7 | 306 | This offset will always be a multiple of sizeof(u_int32_t) bytes, |
2d21ac55 | 307 | so you can safely access common data types without fear of alignment |
91447636 A |
308 | exceptions. |
309 | .Pp | |
310 | . | |
2d21ac55 A |
311 | The |
312 | .Fn getattrlist | |
313 | function will silently truncate attribute data if | |
314 | .Fa attrBufSize | |
315 | is too small. | |
316 | The length field at the front of the attribute list always represents | |
317 | the length of the data actually copied into the attribute buffer. | |
318 | If the data is truncated, there is no easy way to determine the | |
319 | buffer size that's required to get all of the requested attributes. | |
320 | You should always pass an | |
321 | .Fa attrBufSize | |
322 | that is large enough to accommodate the known size of the attributes | |
91447636 A |
323 | in the attribute list (including the leading length field). |
324 | .Pp | |
325 | . | |
2d21ac55 A |
326 | Because the returned attributes are simply truncated if the buffer is |
327 | too small, it's possible for a variable length attribute to reference | |
328 | data beyond the end of the attribute buffer. That is, it's possible | |
329 | for the attribute data to start beyond the end of the attribute buffer | |
330 | (that is, if | |
331 | .Fa attrRef | |
332 | is a pointer to the | |
91447636 | 333 | .Vt attrreference_t , |
2d21ac55 A |
334 | ( ( (char *) |
335 | .Fa attrRef | |
336 | ) + | |
337 | .Fa attr_dataoffset | |
338 | ) > ( ( (char *) | |
339 | .Fa attrBuf | |
340 | ) + | |
341 | .Fa attrSize | |
342 | ) ) or, indeed, for the attribute data to extend beyond the end of the attribute buffer (that is, | |
343 | ( ( (char *) | |
344 | .Fa attrRef | |
345 | ) + | |
346 | .Fa attr_dataoffset | |
347 | + | |
348 | .Fa attr_datalength | |
349 | ) > ( ( (char *) | |
350 | .Fa attrBuf | |
351 | ) + | |
352 | .Fa attrSize | |
91447636 | 353 | ) ). |
2d21ac55 A |
354 | If this happens you must increase the size of the buffer and call |
355 | .Fn getattrlist | |
91447636 A |
356 | to get an accurate copy of the attribute. |
357 | . | |
358 | .Sh COMMON ATTRIBUTES | |
359 | . | |
360 | Common attributes relate to all types of file system objects. | |
361 | The following common attributes are defined. | |
362 | . | |
363 | .Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP | |
364 | . | |
b0d623f7 A |
365 | .It ATTR_CMN_RETURNED_ATTRS |
366 | An | |
367 | .Vt attribute_set_t | |
368 | structure which is used to report which of the requested attributes | |
369 | were actually returned. This attribute, when requested, will always | |
370 | be the first attribute returned. By default, unsupported attributes | |
371 | will be skipped (i.e. not packed into the output buffer). This behavior | |
fe8ab488 A |
372 | can be over-ridden using the FSOPT_PACK_INVAL_ATTRS option flag. Both |
373 | .Xr getattrlist 2 and | |
374 | .Xr getatttrlistbulk 2 support this attribute while | |
375 | .Xr searchfs 2 does not. | |
b0d623f7 | 376 | . |
91447636 | 377 | .It ATTR_CMN_NAME |
2d21ac55 A |
378 | An |
379 | .Vt attrreference | |
380 | structure containing the name of the file system object as | |
91447636 | 381 | UTF-8 encoded, null terminated C string. |
2d21ac55 | 382 | The attribute data length will not be greater than |
6d2010ae A |
383 | .Dv NAME_MAX |
384 | + 1 characters, which is | |
385 | .Dv NAME_MAX | |
386 | * 3 + 1 bytes (as one UTF-8-encoded character may | |
387 | take up to three bytes). | |
91447636 A |
388 | .Pp |
389 | . | |
390 | .It ATTR_CMN_DEVID | |
2d21ac55 A |
391 | A |
392 | .Vt dev_t | |
393 | containing the device number of the device on which this | |
91447636 | 394 | file system object's volume is mounted. |
2d21ac55 A |
395 | Equivalent to the |
396 | .Fa st_dev | |
397 | field of the | |
398 | .Vt stat | |
399 | structure returned by | |
91447636 A |
400 | .Xr stat 2 . |
401 | . | |
402 | .It ATTR_CMN_FSID | |
2d21ac55 A |
403 | An |
404 | .Vt fsid_t | |
405 | structure containing the file system identifier for the volume on which | |
91447636 | 406 | the file system object resides. |
2d21ac55 A |
407 | Equivalent to the |
408 | .Fa f_fsid | |
409 | field of the | |
410 | .Vt statfs | |
411 | structure returned by | |
91447636 A |
412 | .Xr statfs 2 . |
413 | . | |
91447636 | 414 | .It ATTR_CMN_OBJTYPE |
2d21ac55 A |
415 | An |
416 | .Vt fsobj_type_t | |
417 | that identifies the type of file system object. | |
418 | The values are taken from | |
419 | .Vt enum vtype | |
420 | in | |
91447636 A |
421 | .Aq Pa sys/vnode.h . |
422 | . | |
423 | .It ATTR_CMN_OBJTAG | |
2d21ac55 A |
424 | An |
425 | .Vt fsobj_tag_t | |
91447636 | 426 | that identifies the type of file system containing the object. |
2d21ac55 A |
427 | The values are taken from |
428 | .Vt enum vtagtype | |
91447636 A |
429 | in |
430 | .Aq Pa sys/vnode.h . | |
431 | . | |
432 | .It ATTR_CMN_OBJID | |
2d21ac55 A |
433 | An |
434 | .Vt fsobj_id_t | |
fe8ab488 A |
435 | structure that uniquely identifies the file system object within a mounted |
436 | volume for the duration of it's mount; this identifier is not guaranteed to be | |
437 | persistent for the volume and may change every time the volume is mounted. | |
39037602 A |
438 | If the VOL_CAP_FMT_64BIT_OBJECT_IDS capability is set, this is instead a 64-bit |
439 | object identifier. | |
91447636 | 440 | .Pp |
fe8ab488 A |
441 | On HFS+ volumes, the ATTR_CMN_OBJID of a file system object is distinct from |
442 | the ATTR_CMN_OBJID of any hard link to that file system object. Although the | |
443 | ATTR_CMN_OBJID of a file system object may appear similar (in whole | |
444 | or in part) to it's ATTR_CMN_FILEID (see description of ATTR_CMN_FILEID below), | |
445 | \fBno relation between the two attributes should ever be implied.\fP | |
91447636 A |
446 | . |
447 | .It ATTR_CMN_OBJPERMANENTID | |
2d21ac55 A |
448 | An |
449 | .Vt fsobj_id_t | |
fe8ab488 A |
450 | structure that uniquely and persistently identifies the file system object |
451 | within its volume; persistence implies that this attribute is unaffected by | |
452 | mount/unmount operations on the volume. | |
39037602 A |
453 | If the VOL_CAP_FMT_64BIT_OBJECT_IDS capability is set, this is instead a 64-bit |
454 | object identifier. | |
fe8ab488 A |
455 | .Pp |
456 | Some file systems can not return this attribute when the volume is mounted | |
457 | read-only and will fail the request with error | |
458 | .Dv EROFS. | |
459 | .br | |
460 | (e.g. original HFS modifies on disk structures to generate persistent | |
461 | identifiers, and hence cannot do so if the volume is mounted read only.) | |
91447636 A |
462 | . |
463 | .It ATTR_CMN_PAROBJID | |
2d21ac55 A |
464 | An |
465 | .Vt fsobj_id_t | |
fe8ab488 A |
466 | structure that uniquely identifies the parent directory of the file system |
467 | object within a mounted volume, for the duration of the volume mount; this | |
468 | identifier is not guaranteed to be persistent for the volume and may change | |
469 | every time the volume is mounted. | |
39037602 A |
470 | If the VOL_CAP_FMT_64BIT_OBJECT_IDS capability is set, this is instead a 64-bit |
471 | object identifier. | |
91447636 A |
472 | .Pp |
473 | . | |
fe8ab488 A |
474 | If a file system object is hard linked from multiple directories, the parent |
475 | directory returned for this attribute is non deterministic; it can be any one | |
476 | of the parent directories of this object. | |
91447636 | 477 | . |
fe8ab488 A |
478 | For some volume formats the computing cost for this attribute is significant; |
479 | developers are advised to request this attribute sparingly. | |
91447636 A |
480 | . |
481 | .It ATTR_CMN_SCRIPT | |
2d21ac55 A |
482 | (read/write) A |
483 | .Vt text_encoding_t | |
484 | containing a text encoding hint for | |
485 | the file system object's name. | |
486 | It is included to facilitate the lossless round trip conversion of names between | |
91447636 | 487 | Unicode and traditional Mac OS script encodings. |
2d21ac55 A |
488 | File systems that do not have an appropriate text encoding value should return |
489 | kTextEncodingMacUnicode. | |
91447636 A |
490 | . |
491 | .It ATTR_CMN_CRTIME | |
2d21ac55 A |
492 | (read/write) A |
493 | .Vt timespec | |
494 | structure containing the time that the file system object | |
495 | was created. | |
91447636 A |
496 | . |
497 | .It ATTR_CMN_MODTIME | |
2d21ac55 A |
498 | (read/write) A |
499 | .Vt timespec | |
500 | structure containing the time that the file system object | |
501 | was last modified. | |
502 | Equivalent to the | |
503 | .Fa st_mtimespec | |
504 | field of the | |
505 | .Vt stat | |
506 | structure returned by | |
91447636 A |
507 | .Xr stat 2 . |
508 | . | |
509 | .It ATTR_CMN_CHGTIME | |
39037602 | 510 | A |
2d21ac55 A |
511 | .Vt timespec |
512 | structure containing the time that the file system object's | |
513 | attributes were last modified. | |
514 | Equivalent to the | |
515 | .Fa st_ctimespec | |
516 | field of the | |
517 | .Vt stat | |
518 | structure returned by | |
91447636 A |
519 | .Xr stat 2 . |
520 | . | |
521 | .It ATTR_CMN_ACCTIME | |
2d21ac55 A |
522 | (read/write) A |
523 | .Vt timespec | |
524 | structure containing the time that the file system object | |
525 | was last accessed. | |
526 | Equivalent to the | |
527 | .Fa st_atimespec | |
528 | field of the | |
529 | .Vt stat | |
530 | structure returned by | |
91447636 A |
531 | .Xr stat 2 . |
532 | . | |
533 | .It ATTR_CMN_BKUPTIME | |
2d21ac55 A |
534 | (read/write) A |
535 | .Vt timespec | |
536 | structure containing the time that the file system object was | |
537 | last backed up. | |
538 | This value is for use by backup utilities. | |
91447636 A |
539 | The file system stores but does not interpret the value. |
540 | . | |
541 | .It ATTR_CMN_FNDRINFO | |
542 | (read/write) 32 bytes of data for use by the Finder. | |
2d21ac55 A |
543 | Equivalent to the concatenation of a |
544 | .Vt FileInfo | |
545 | structure and an | |
546 | .Vt ExtendedFileInfo | |
547 | structure | |
548 | (or, for directories, a | |
549 | .Vt FolderInfo | |
550 | structure and an | |
551 | .Vt ExtendedFolderInfo | |
91447636 | 552 | structure). |
91447636 A |
553 | .Pp |
554 | This attribute is not byte swapped by the file system. | |
2d21ac55 A |
555 | The value of multibyte fields on disk is always big endian. |
556 | When running on a little endian system (such as Darwin on x86), | |
91447636 A |
557 | you must byte swap any multibyte fields. |
558 | . | |
559 | .It ATTR_CMN_OWNERID | |
2d21ac55 A |
560 | (read/write) A |
561 | .Vt uid_t | |
562 | containing the owner of the file system object. | |
563 | Equivalent to the | |
564 | .Fa st_uid | |
565 | field of the | |
566 | .Vt stat | |
567 | structure returned by | |
91447636 A |
568 | .Xr stat 2 . |
569 | . | |
570 | .It ATTR_CMN_GRPID | |
2d21ac55 A |
571 | (read/write) A |
572 | .Vt gid_t | |
573 | containing the group of the file system object. | |
574 | Equivalent to the | |
575 | .Fa st_gid | |
576 | field of the | |
577 | .Vt stat | |
578 | structure returned by | |
91447636 A |
579 | .Xr stat 2 . |
580 | . | |
581 | .It ATTR_CMN_ACCESSMASK | |
2d21ac55 A |
582 | (read/write) A |
583 | .Vt u_int32_t | |
584 | containing the access permissions of the file system object. | |
585 | Equivalent to the | |
586 | .Fa st_mode | |
587 | field of the | |
588 | .Vt stat | |
589 | structure returned by | |
91447636 | 590 | .Xr stat 2 . |
6d2010ae A |
591 | Only the permission bits of |
592 | .Fa st_mode | |
593 | are valid; other bits should be ignored, | |
594 | e.g., by masking with | |
595 | .Dv ~S_IFMT . | |
91447636 | 596 | . |
91447636 | 597 | .It ATTR_CMN_FLAGS |
2d21ac55 A |
598 | (read/write) A |
599 | .Vt u_int32_t | |
91447636 | 600 | containing file flags. |
2d21ac55 A |
601 | Equivalent to the |
602 | .Fa st_flags | |
603 | field of the | |
604 | .Vt stat | |
605 | structure returned by | |
91447636 | 606 | .Xr stat 2 . |
2d21ac55 | 607 | For more information about these flags, see |
91447636 | 608 | .Xr chflags 2 . |
fe8ab488 A |
609 | . |
610 | .It ATTR_CMN_GEN_COUNT | |
611 | A | |
612 | .Vt u_int32_t | |
613 | containing a non zero monotonically increasing generation | |
614 | count for this file system object. The generation count tracks | |
615 | the number of times the data in a file system object has been | |
616 | modified. No meaning can be implied from its value. The | |
617 | value of the generation count for a file system object can | |
618 | be compared against a previous value of the same file system | |
619 | object for equality; i.e. an unchanged generation | |
620 | count indicates identical data. Requesting this attribute requires the | |
621 | FSOPT_ATTR_CMN_EXTENDED option flag. | |
91447636 A |
622 | .Pp |
623 | . | |
fe8ab488 A |
624 | A generation count value of 0 is invalid and cannot be used to |
625 | determine data change. | |
626 | .Pp | |
627 | The generation count is invalid while a file is mmap'ed. An invalid | |
628 | generation count value of 0 will be returned for mmap'ed files. | |
629 | . | |
630 | .It ATTR_CMN_DOCUMENT_ID | |
631 | A | |
632 | .Vt u_int32_t | |
633 | containing the document id. The document id is a value assigned | |
634 | by the kernel to a document (which can be a file or directory) | |
635 | and is used to track the data regardless of where it gets moved. | |
636 | The document id survives safe saves; i.e it is sticky to the path it | |
637 | was assigned to. Requesting this attribute requires the | |
638 | FSOPT_ATTR_CMN_EXTENDED option flag. | |
639 | .Pp | |
640 | A document id of 0 is invalid. | |
91447636 A |
641 | . |
642 | .It ATTR_CMN_USERACCESS | |
2d21ac55 A |
643 | A |
644 | .Vt u_int32_t | |
645 | containing the effective permissions of the current user | |
646 | (the calling process's effective UID) for this file system object. | |
647 | You can test for read, write, and execute permission using | |
91447636 A |
648 | .Dv R_OK , |
649 | .Dv W_OK , | |
650 | and | |
2d21ac55 A |
651 | .Dv X_OK , |
652 | respectively. | |
653 | See | |
654 | .Xr access 2 | |
91447636 A |
655 | for more details. |
656 | . | |
b0d623f7 A |
657 | .It ATTR_CMN_EXTENDED_SECURITY |
658 | A variable-length object (thus an | |
659 | .Vt attrreference | |
660 | structure) containing a | |
661 | .Vt kauth_filesec | |
662 | structure, of which only the ACL entry is used. | |
663 | . | |
664 | .It ATTR_CMN_UUID | |
665 | A | |
666 | .Vt guid_t | |
667 | of the owner of the file system object. Analoguous to | |
668 | .Dv ATTR_CMN_OWNERID . | |
669 | . | |
670 | .It ATTR_CMN_GRPUUID | |
671 | A | |
672 | .Vt guid_t | |
673 | of the group to which the file system object belongs. | |
674 | Analoguous to | |
675 | .Dv ATTR_CMN_GRPID . | |
676 | . | |
2d21ac55 A |
677 | .It ATTR_CMN_FILEID |
678 | A | |
679 | .Vt u_int64_t | |
fe8ab488 A |
680 | that uniquely identifies the file system object within it's mounted volume. |
681 | Equivalent to | |
682 | .Fa st_ino | |
683 | field of the | |
684 | .Vt stat | |
685 | structure returned by | |
686 | .Xr stat 2 . | |
2d21ac55 A |
687 | . |
688 | .It ATTR_CMN_PARENTID | |
689 | A | |
690 | .Vt u_int64_t | |
691 | that identifies the parent directory of the file system object. | |
692 | . | |
b0d623f7 A |
693 | .It ATTR_CMN_FULLPATH |
694 | An | |
695 | .Vt attrreference | |
696 | structure containing the full path (resolving all symlinks) to | |
697 | the file system object as | |
698 | a UTF-8 encoded, null terminated C string. | |
699 | The attribute data length will not be greater than | |
700 | .Dv PATH_MAX. | |
701 | Inconsistent behavior may be observed when this attribute is requested on | |
702 | hard-linked items, particularly when the file system does not support ATTR_CMN_PARENTID | |
703 | natively. Callers should be aware of this when requesting the full path of a hard-linked item. | |
6d2010ae A |
704 | . |
705 | .It ATTR_CMN_ADDEDTIME | |
706 | A | |
707 | .Vt timespec | |
708 | that contains the time that the file system object was created or renamed into | |
316670eb | 709 | its containing directory. Note that inconsistent behavior may be observed |
6d2010ae | 710 | when this attribute is requested on hard-linked items. |
fe8ab488 A |
711 | . |
712 | .It ATTR_CMN_DATA_PROTECT_FLAGS | |
713 | A | |
714 | .Vt u_int32_t | |
715 | that contains the file or directory's data protection class. | |
b0d623f7 A |
716 | .Pp |
717 | . | |
91447636 A |
718 | .El |
719 | . | |
720 | .Sh VOLUME ATTRIBUTES | |
721 | . | |
722 | Volume attributes relate to volumes (that is, mounted file systems). | |
723 | The following volume attributes are defined. | |
724 | . | |
725 | .Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP | |
726 | . | |
727 | .It ATTR_VOL_INFO | |
2d21ac55 A |
728 | For reasons that are not at all obvious, you must set |
729 | .Dv ATTR_VOL_INFO | |
730 | in the | |
91447636 A |
731 | .Fa volattr |
732 | field if you request any other volume attributes. | |
733 | This does not result in any attribute data being added to the attribute buffer. | |
734 | . | |
735 | .It ATTR_VOL_FSTYPE | |
2d21ac55 A |
736 | A |
737 | .Vt u_int32_t | |
91447636 | 738 | containing the file system type. |
2d21ac55 A |
739 | Equivalent to the |
740 | .Fa f_type | |
741 | field of the | |
742 | .Vt statfs | |
743 | structure returned by | |
91447636 A |
744 | .Xr statfs 2 . |
745 | Generally not a useful value. | |
746 | . | |
747 | .It ATTR_VOL_SIGNATURE | |
2d21ac55 A |
748 | A |
749 | .Vt u_int32_t | |
750 | containing the volume signature word. | |
751 | This value is unique within a given file system type and lets you | |
91447636 | 752 | distinguish between different volume formats handled by the same file system. |
91447636 A |
753 | . |
754 | .It ATTR_VOL_SIZE | |
2d21ac55 | 755 | An |
91447636 A |
756 | .Vt off_t |
757 | containing the total size of the volume in bytes. | |
758 | . | |
759 | .It ATTR_VOL_SPACEFREE | |
2d21ac55 | 760 | An |
91447636 A |
761 | .Vt off_t |
762 | containing the free space on the volume in bytes. | |
763 | . | |
764 | .It ATTR_VOL_SPACEAVAIL | |
2d21ac55 | 765 | An |
91447636 | 766 | .Vt off_t |
2d21ac55 A |
767 | containing the space, in bytes, on the volume available to non-privileged processes. |
768 | This is the free space minus the amount of space reserved by the system to prevent critical | |
769 | disk exhaustion errors. | |
770 | Non-privileged programs, like a disk management tool, should use this value to display the | |
91447636 A |
771 | space available to the user. |
772 | .Pp | |
2d21ac55 A |
773 | .Dv ATTR_VOL_SPACEAVAIL |
774 | is to | |
775 | .Dv ATTR_VOL_SPACEFREE | |
776 | as | |
777 | .Fa f_bavail | |
778 | is to | |
779 | .Fa f_bfree | |
780 | in | |
91447636 A |
781 | .Xr statfs 2 . |
782 | . | |
783 | .It ATTR_VOL_MINALLOCATION | |
2d21ac55 | 784 | An |
91447636 | 785 | .Vt off_t |
2d21ac55 | 786 | containing the minimum allocation size on the volume in bytes. |
91447636 A |
787 | If you create a file containing one byte, it will consume this much space. |
788 | . | |
789 | .It ATTR_VOL_ALLOCATIONCLUMP | |
2d21ac55 | 790 | An |
91447636 | 791 | .Vt off_t |
2d21ac55 A |
792 | containing the allocation clump size on the volume, in bytes. |
793 | As a file is extended, the file system will attempt to allocate | |
91447636 A |
794 | this much space each time in order to reduce fragmentation. |
795 | . | |
796 | .It ATTR_VOL_IOBLOCKSIZE | |
2d21ac55 A |
797 | A |
798 | .Vt u_int32_t | |
799 | containing the optimal block size when reading or writing data. | |
800 | Equivalent to the | |
801 | .Fa f_iosize | |
802 | field of the | |
803 | .Vt statfs | |
804 | structure returned by | |
91447636 A |
805 | .Xr statfs 2 . |
806 | . | |
807 | .It ATTR_VOL_OBJCOUNT | |
2d21ac55 A |
808 | A |
809 | .Vt u_int32_t | |
91447636 A |
810 | containing the number of file system objects on the volume. |
811 | . | |
812 | .It ATTR_VOL_FILECOUNT | |
2d21ac55 A |
813 | A |
814 | .Vt u_int32_t | |
91447636 A |
815 | containing the number of files on the volume. |
816 | . | |
817 | .It ATTR_VOL_DIRCOUNT | |
2d21ac55 A |
818 | A |
819 | .Vt u_int32_t | |
91447636 A |
820 | containing the number of directories on the volume. |
821 | . | |
822 | .It ATTR_VOL_MAXOBJCOUNT | |
2d21ac55 A |
823 | A |
824 | .Vt u_int32_t | |
91447636 A |
825 | containing the maximum number of file system objects that can be stored on the volume. |
826 | . | |
827 | .It ATTR_VOL_MOUNTPOINT | |
2d21ac55 | 828 | An |
91447636 | 829 | .Vt attrreference |
2d21ac55 | 830 | structure containing the path to the volume's mount point as a |
91447636 | 831 | UTF-8 encoded, null terminated C string. |
2d21ac55 | 832 | The attribute data length will not be greater than |
91447636 | 833 | .Dv MAXPATHLEN . |
2d21ac55 A |
834 | Equivalent to the |
835 | .Fa f_mntonname | |
836 | field of the | |
837 | .Vt statfs | |
838 | structure returned by | |
91447636 A |
839 | .Xr statfs 2 . |
840 | . | |
841 | .It ATTR_VOL_NAME | |
2d21ac55 | 842 | (read/write) An |
91447636 | 843 | .Vt attrreference |
2d21ac55 | 844 | structure containing the name of the volume as a |
91447636 | 845 | UTF-8 encoded, null terminated C string. |
2d21ac55 | 846 | The attribute data length will not be greater than |
91447636 A |
847 | .Dv NAME_MAX + |
848 | 1. | |
849 | .Pp | |
850 | . | |
2d21ac55 | 851 | This attribute is only read/write if the |
91447636 A |
852 | .Dv VOL_CAP_INT_VOL_RENAME |
853 | bit is set in the volume capabilities (see below). | |
854 | .Pp | |
855 | . | |
856 | .It ATTR_VOL_MOUNTFLAGS | |
2d21ac55 A |
857 | A |
858 | .Vt u_int32_t | |
859 | containing the volume mount flags. | |
860 | This is a copy of the value passed to the | |
91447636 | 861 | .Fa flags |
2d21ac55 | 862 | parameter of |
91447636 A |
863 | .Xr mount 2 |
864 | when the volume was mounted. | |
2d21ac55 A |
865 | Equivalent to the |
866 | .Fa f_flags | |
867 | field of the | |
868 | .Vt statfs | |
869 | structure returned by | |
91447636 A |
870 | .Xr statfs 2 . |
871 | . | |
872 | .It ATTR_VOL_MOUNTEDDEVICE | |
2d21ac55 | 873 | An |
91447636 | 874 | .Vt attrreference |
2d21ac55 A |
875 | structure that returns the same value as the |
876 | .Fa f_mntfromname | |
877 | field of the | |
878 | .Vt statfs | |
879 | structure returned by | |
91447636 | 880 | .Xr statfs 2 . |
2d21ac55 | 881 | For local volumes this is the path to the device on which the volume is mounted as a |
91447636 A |
882 | UTF-8 encoded, null terminated C string. |
883 | For network volumes, this is a unique string that identifies the mount. | |
2d21ac55 | 884 | The attribute data length will not be greater than |
91447636 A |
885 | .Dv MAXPATHLEN . |
886 | .Pp | |
887 | . | |
888 | .It ATTR_VOL_ENCODINGSUSED | |
2d21ac55 | 889 | An |
91447636 | 890 | .Vt unsigned long long |
2d21ac55 A |
891 | containing a bitmap of the text encodings used on this volume. |
892 | For more information about this, see the discussion of | |
893 | .Fa encodingsBitmap | |
91447636 A |
894 | in DTS Technote 1150 "HFS Plus Volume Format". |
895 | . | |
896 | .It ATTR_VOL_CAPABILITIES | |
897 | A | |
898 | .Vt vol_capabilities_attr_t | |
2d21ac55 | 899 | structure describing the optional features supported by this volume. |
91447636 A |
900 | See below for a discussion of volume capabilities. |
901 | . | |
b0d623f7 A |
902 | .It ATTR_VOL_UUID |
903 | A | |
904 | .Vt uuid_t | |
905 | containing the file system UUID. Typically this will be a | |
906 | version 5 UUID. | |
907 | . | |
813fb2f6 A |
908 | .It ATTR_VOL_QUOTA_SIZE |
909 | An | |
910 | .Vt off_t | |
911 | containing the maximum size of the volume in bytes. | |
912 | . | |
913 | .It ATTR_VOL_RESERVED_SIZE | |
914 | An | |
915 | .Vt off_t | |
916 | containing the minimum size of the volume in bytes. | |
917 | . | |
91447636 A |
918 | .It ATTR_VOL_ATTRIBUTES |
919 | A | |
920 | .Vt vol_attributes_attr_t | |
2d21ac55 | 921 | structure describing the attributes supported by this volume. |
91447636 A |
922 | This structure is discussed below, along with volume capabilities. |
923 | . | |
924 | .El | |
925 | . | |
926 | .Sh DIRECTORY ATTRIBUTES | |
927 | . | |
928 | The following directory attributes are defined. | |
929 | . | |
930 | .Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP | |
931 | . | |
932 | .It ATTR_DIR_LINKCOUNT | |
2d21ac55 A |
933 | A |
934 | .Vt u_int32_t | |
935 | containing the number of hard links to the directory; | |
936 | this does not include the historical "." and ".." entries. | |
b0d623f7 | 937 | For file systems that do not support hard links to directories, |
2d21ac55 | 938 | this value will be 1. |
91447636 A |
939 | . |
940 | .It ATTR_DIR_ENTRYCOUNT | |
2d21ac55 A |
941 | A |
942 | .Vt u_int32_t | |
943 | containing the number of file system objects in the directory, not including | |
b0d623f7 A |
944 | any synthetic items. The historical "." and ".." entries are also |
945 | excluded from this count. | |
91447636 A |
946 | . |
947 | .It ATTR_DIR_MOUNTSTATUS | |
2d21ac55 A |
948 | A |
949 | .Vt u_int32_t | |
950 | containing flags describing what's mounted on the directory. | |
951 | Currently the only flag defined is | |
952 | .Dv DIR_MNTSTATUS_MNTPOINT, | |
91447636 | 953 | which indicates that there is a file system mounted on this directory. |
91447636 | 954 | . |
813fb2f6 A |
955 | .It ATTR_DIR_ALLOCSIZE |
956 | An | |
957 | .Vt off_t | |
958 | containing the number of bytes on disk used by the directory | |
959 | (the physical size). | |
960 | . | |
961 | .It ATTR_DIR_IOBLOCKSIZE | |
962 | A | |
963 | .Vt u_int32_t | |
964 | containing the optimal block size when reading or writing data. | |
965 | . | |
966 | .It ATTR_DIR_DATALENGTH | |
967 | An | |
968 | .Vt off_t | |
969 | containing the length of the directory in bytes (the logical size). | |
91447636 A |
970 | .El |
971 | . | |
b0d623f7 A |
972 | .Pp |
973 | Requested directory attributes are not returned for file system objects that | |
974 | are not directories. | |
975 | . | |
91447636 A |
976 | .Sh FILE ATTRIBUTES |
977 | . | |
978 | The following file attributes are defined. | |
979 | . | |
980 | .Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP | |
981 | . | |
982 | .It ATTR_FILE_LINKCOUNT | |
2d21ac55 A |
983 | A |
984 | .Vt u_int32_t | |
985 | containing the number of hard links to this file. | |
986 | Equivalent to the | |
987 | .Fa st_nlink | |
988 | field of the | |
989 | .Vt stat | |
990 | structure returned by | |
91447636 A |
991 | .Xr stat 2 . |
992 | . | |
993 | .It ATTR_FILE_TOTALSIZE | |
2d21ac55 | 994 | An |
91447636 A |
995 | .Vt off_t |
996 | containing the total number of bytes in all forks of the file (the logical size). | |
997 | . | |
998 | .It ATTR_FILE_ALLOCSIZE | |
2d21ac55 | 999 | An |
91447636 A |
1000 | .Vt off_t |
1001 | containing a count of the bytes on disk used by all of the file's forks (the physical size). | |
1002 | . | |
1003 | .It ATTR_FILE_IOBLOCKSIZE | |
2d21ac55 A |
1004 | A |
1005 | .Vt u_int32_t | |
1006 | containing the optimal block size when reading or writing this file's data. | |
91447636 A |
1007 | . |
1008 | .It ATTR_FILE_CLUMPSIZE | |
2d21ac55 A |
1009 | A |
1010 | .Vt u_int32_t | |
1011 | containing the allocation clump size for this file, in bytes. | |
1012 | As the file is extended, the file system will attempt to allocate | |
1013 | this much space each time in order to reduce fragmentation. | |
91447636 A |
1014 | This value applies to the data fork. |
1015 | . | |
1016 | .It ATTR_FILE_DEVTYPE | |
2d21ac55 A |
1017 | (read/write) A |
1018 | .Vt u_int32_t | |
1019 | containing the device type for a special device file. | |
1020 | Equivalent to the | |
1021 | .Fa st_rdev | |
1022 | field of the | |
1023 | .Vt stat | |
1024 | structure returned by | |
91447636 A |
1025 | .Xr stat 2 . |
1026 | . | |
1027 | .It ATTR_FILE_FILETYPE | |
1028 | A | |
2d21ac55 | 1029 | .Vt u_int32_t |
91447636 A |
1030 | that whose value is reserved. |
1031 | Clients should ignore its value. | |
1032 | New volume format implementations should not support this attribute. | |
1033 | . | |
1034 | .It ATTR_FILE_FORKCOUNT | |
1035 | A | |
2d21ac55 | 1036 | .Vt u_int32_t |
91447636 | 1037 | containing the number of forks in the file. |
2d21ac55 | 1038 | No built-in file systems on Mac OS X currently support forks other |
91447636 A |
1039 | than the data and resource fork. |
1040 | . | |
1041 | .It ATTR_FILE_FORKLIST | |
2d21ac55 | 1042 | An |
91447636 A |
1043 | .Vt attrreference |
1044 | structure containing a list of named forks of the file. | |
2d21ac55 | 1045 | No built-in file systems on Mac OS X currently support forks |
91447636 A |
1046 | other than the data and resource fork. |
1047 | Because of this, the structure of this attribute's value is not yet defined. | |
1048 | . | |
1049 | .It ATTR_FILE_DATALENGTH | |
1050 | An | |
1051 | .Vt off_t | |
1052 | containing the length of the data fork in bytes (the logical size). | |
1053 | . | |
1054 | .It ATTR_FILE_DATAALLOCSIZE | |
1055 | An | |
1056 | .Vt off_t | |
1057 | containing a count of the bytes on disk used by the data fork (the physical size). | |
1058 | . | |
1059 | .It ATTR_FILE_DATAEXTENTS | |
1060 | An | |
1061 | .Vt extentrecord | |
2d21ac55 A |
1062 | array for the data fork. |
1063 | The array contains eight | |
1064 | .Vt diskextent | |
1065 | structures which represent the first | |
91447636 A |
1066 | eight extents of the fork. |
1067 | .Pp | |
2d21ac55 | 1068 | This attributes exists for compatibility reasons. |
91447636 | 1069 | New clients should not use this attribute. |
2d21ac55 A |
1070 | Rather, they should use the |
1071 | .Dv F_LOG2PHYS | |
1072 | command in | |
91447636 A |
1073 | .Xr fcntl 2 . |
1074 | .Pp | |
1075 | . | |
2d21ac55 | 1076 | In current implementations the value may not be entirely accurate for |
91447636 A |
1077 | a variety of reasons. |
1078 | . | |
1079 | .It ATTR_FILE_RSRCLENGTH | |
1080 | An | |
1081 | .Vt off_t | |
1082 | containing the length of the resource fork in bytes (the logical size). | |
1083 | . | |
1084 | .It ATTR_FILE_RSRCALLOCSIZE | |
1085 | An | |
1086 | .Vt off_t | |
1087 | containing a count of the bytes on disk used by the resource fork (the physical size). | |
1088 | . | |
1089 | .It ATTR_FILE_RSRCEXTENTS | |
1090 | An | |
1091 | .Vt extentrecord | |
2d21ac55 A |
1092 | array for the resource fork. |
1093 | The array contains eight | |
1094 | .Vt diskextent | |
1095 | structures which represent the first | |
91447636 A |
1096 | eight extents of the fork. |
1097 | .Pp | |
2d21ac55 | 1098 | See also |
91447636 A |
1099 | .Dv ATTR_FILE_DATAEXTENTS . |
1100 | . | |
1101 | .El | |
1102 | . | |
b0d623f7 A |
1103 | .Pp |
1104 | File attributes are used for any file system object that is not a directory, | |
1105 | not just ordinary files. | |
1106 | Requested file attributes are not returned for file system objects that | |
1107 | are directories. | |
1108 | . | |
91447636 A |
1109 | .Sh FORK ATTRIBUTES |
1110 | . | |
2d21ac55 | 1111 | Fork attributes relate to the actual data in the file, |
91447636 | 1112 | which can be held in multiple named contiguous ranges, or forks. |
813fb2f6 | 1113 | These cannot be used if the FSOPT_ATTR_CMN_EXTENDED is given. |
91447636 A |
1114 | The following fork attributes are defined. |
1115 | . | |
1116 | .Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP | |
1117 | . | |
1118 | .It ATTR_FORK_TOTALSIZE | |
39037602 | 1119 | Deprecated. |
91447636 A |
1120 | An |
1121 | .Vt off_t | |
1122 | containing the length of the fork in bytes (the logical size). | |
1123 | . | |
1124 | .It ATTR_FORK_ALLOCSIZE | |
39037602 | 1125 | Deprecated. |
91447636 A |
1126 | An |
1127 | .Vt off_t | |
1128 | containing a count of the bytes on disk used by the fork (the physical size). | |
1129 | . | |
39037602 A |
1130 | .It ATTR_FORK_RESERVED |
1131 | Reserved. | |
1132 | You must set this to 0. | |
1133 | . | |
91447636 A |
1134 | .El |
1135 | .Pp | |
1136 | . | |
39037602 A |
1137 | Fork attributes are deprecated and all bits are reserved. |
1138 | They are not properly implemented by any current Mac OS X | |
2d21ac55 A |
1139 | volume format implementation. |
1140 | We strongly recommend that client programs do not request fork attributes. | |
1141 | If you are implementing a volume format, you should not support these attributes. | |
91447636 | 1142 | . |
813fb2f6 A |
1143 | .Sh COMMON EXTENDED ATTRIBUTES |
1144 | . | |
1145 | Common extended attributes are like common attributes except that they are set | |
1146 | in the forkattr field and can only be used if the FSOPT_ATTR_CMN_EXTENDED | |
1147 | option is given. Use of these attributes is mutually exclusive with the above | |
1148 | fork attributes. | |
1149 | . | |
1150 | .Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP | |
1151 | . | |
1152 | .It ATTR_CMNEXT_RELPATH | |
1153 | An | |
1154 | .Vt attrreference | |
1155 | structure containing the mount-relative path of | |
1156 | the file system object as | |
1157 | a UTF-8 encoded, null terminated C string. | |
1158 | The attribute data length will not be greater than | |
1159 | .Dv PATH_MAX. | |
1160 | Inconsistent behavior may be observed when this attribute is requested on | |
1161 | hard-linked items, particularly when the file system does not support | |
1162 | ATTR_CMN_PARENTID natively. Callers should be aware of this when requesting the | |
1163 | relative path of a hard-linked item. | |
1164 | . | |
1165 | .It ATTR_CMNEXT_PRIVATESIZE | |
1166 | An | |
1167 | .Vt off_t | |
1168 | containing the number of bytes that are \fBnot\fP trapped inside a clone | |
1169 | or snapshot, and which would be freed immediately if the file were deleted. | |
1170 | . | |
1171 | .El | |
1172 | . | |
91447636 A |
1173 | .Sh VOLUME CAPABILITIES |
1174 | . | |
1175 | .\" vol_capabilities_attr_t | |
1176 | . | |
2d21ac55 A |
1177 | Not all volumes support all features. |
1178 | The | |
1179 | .Dv ATTR_VOL_CAPABILITIES | |
1180 | attribute returns a | |
1181 | .Vt vol_capabilities_attr_t | |
91447636 A |
1182 | structure (shown below) that indicates which features are supported by the volume. |
1183 | . | |
1184 | .Bd -literal | |
1185 | typedef u_int32_t vol_capabilities_set_t[4]; | |
1186 | .Pp | |
1187 | . | |
1188 | #define VOL_CAPABILITIES_FORMAT 0 | |
1189 | #define VOL_CAPABILITIES_INTERFACES 1 | |
1190 | #define VOL_CAPABILITIES_RESERVED1 2 | |
1191 | #define VOL_CAPABILITIES_RESERVED2 3 | |
1192 | .Pp | |
1193 | . | |
1194 | typedef struct vol_capabilities_attr { | |
1195 | vol_capabilities_set_t capabilities; | |
1196 | vol_capabilities_set_t valid; | |
1197 | } vol_capabilities_attr_t; | |
1198 | .Ed | |
1199 | .Pp | |
1200 | . | |
2d21ac55 A |
1201 | The structure contains two fields, |
1202 | .Fa capabilities | |
1203 | and | |
91447636 | 1204 | .Fa valid . |
2d21ac55 | 1205 | Each consists of an array of four elements. |
91447636 A |
1206 | The arrays are indexed by the following values. |
1207 | . | |
1208 | .Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS | |
1209 | . | |
1210 | .It VOL_CAPABILITIES_FORMAT | |
2d21ac55 A |
1211 | This element contains information about the volume format. |
1212 | See | |
1213 | .Dv VOL_CAP_FMT_PERSISTENTOBJECTIDS | |
91447636 A |
1214 | and so on, below. |
1215 | . | |
1216 | .It VOL_CAPABILITIES_INTERFACES | |
2d21ac55 | 1217 | This element contains information about which optional functions are |
91447636 | 1218 | supported by the volume format implementation. |
2d21ac55 A |
1219 | See |
1220 | .Dv VOL_CAP_INT_SEARCHFS | |
91447636 A |
1221 | and so on, below. |
1222 | . | |
1223 | .It VOL_CAPABILITIES_RESERVED1 | |
2d21ac55 A |
1224 | Reserved. |
1225 | A file system implementation should set this element to zero. | |
91447636 A |
1226 | A client program should ignore this element. |
1227 | . | |
1228 | .It VOL_CAPABILITIES_RESERVED2 | |
2d21ac55 A |
1229 | Reserved. |
1230 | A file system implementation should set this element to zero. | |
91447636 A |
1231 | A client program should ignore this element. |
1232 | . | |
1233 | .El | |
1234 | .Pp | |
1235 | . | |
2d21ac55 A |
1236 | The |
1237 | .Fa valid | |
1238 | field contains bit sets that indicate which flags are known to the volume format | |
1239 | implementation. | |
1240 | Each bit indicates whether the contents of the corresponding bit in the | |
1241 | .Fa capabilities | |
91447636 A |
1242 | field is valid. |
1243 | .Pp | |
1244 | . | |
2d21ac55 A |
1245 | The |
1246 | .Fa capabilities | |
1247 | field contains bit sets that indicate whether a particular feature is implemented | |
1248 | by this volume format. | |
91447636 A |
1249 | .Pp |
1250 | . | |
2d21ac55 A |
1251 | The following bits are defined in the first element (indexed by |
1252 | .Dv VOL_CAPABILITIES_FORMAT ) | |
1253 | of the | |
1254 | .Fa capabilities | |
1255 | and | |
1256 | .Fa valid | |
1257 | fields of the | |
1258 | .Vt vol_capabilities_attr_t | |
91447636 A |
1259 | structure. |
1260 | . | |
1261 | .Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS | |
1262 | . | |
1263 | .It VOL_CAP_FMT_PERSISTENTOBJECTIDS | |
2d21ac55 | 1264 | If this bit is set the volume format supports persistent object identifiers |
91447636 | 1265 | and can look up file system objects by their IDs. |
2d21ac55 A |
1266 | See |
1267 | .Dv ATTR_CMN_OBJPERMANENTID | |
91447636 A |
1268 | for details about how to obtain these identifiers. |
1269 | . | |
1270 | .It VOL_CAP_FMT_SYMBOLICLINKS | |
2d21ac55 | 1271 | If this bit is set the volume format supports symbolic links. |
91447636 A |
1272 | . |
1273 | .It VOL_CAP_FMT_HARDLINKS | |
2d21ac55 | 1274 | If this bit is set the volume format supports hard links. |
91447636 A |
1275 | . |
1276 | .It VOL_CAP_FMT_JOURNAL | |
2d21ac55 A |
1277 | If this bit is set the volume format supports a journal used to |
1278 | speed recovery in case of unplanned restart (such as a power outage | |
91447636 A |
1279 | or crash). |
1280 | This does not necessarily mean the volume is actively using a journal. | |
1281 | .Pp | |
1282 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1283 | . | |
1284 | .It VOL_CAP_FMT_JOURNAL_ACTIVE | |
2d21ac55 | 1285 | If this bit is set the volume is currently using a journal for |
91447636 | 1286 | speedy recovery after an unplanned restart. |
2d21ac55 | 1287 | This bit can be set only if |
91447636 A |
1288 | .Dv VOL_CAP_FMT_JOURNAL |
1289 | is also set. | |
1290 | .Pp | |
1291 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1292 | . | |
1293 | .It VOL_CAP_FMT_NO_ROOT_TIMES | |
2d21ac55 A |
1294 | If this bit is set the volume format does not store reliable times for |
1295 | the root directory, so you should not depend on them to detect changes, | |
91447636 A |
1296 | identify volumes across unmount/mount, and so on. |
1297 | .Pp | |
1298 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1299 | . | |
1300 | .It VOL_CAP_FMT_SPARSE_FILES | |
1301 | If this bit is set the volume format supports sparse files, | |
1302 | that is, files which can have 'holes' that have never been written | |
2d21ac55 | 1303 | to, and thus do not consume space on disk. |
91447636 | 1304 | A sparse file may have an allocated size on disk that is less than its logical length (that is, |
2d21ac55 | 1305 | .Dv ATTR_FILE_ALLOCSIZE |
91447636 A |
1306 | < |
1307 | .Dv ATTR_FILE_TOTALSIZE ). | |
1308 | . | |
1309 | .Pp | |
1310 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1311 | . | |
1312 | .It VOL_CAP_FMT_ZERO_RUNS | |
2d21ac55 A |
1313 | For security reasons, parts of a file (runs) that have never been |
1314 | written to must appear to contain zeroes. | |
91447636 A |
1315 | When this bit is set, the volume keeps track of allocated but unwritten |
1316 | runs of a file so that it can substitute zeroes without actually | |
2d21ac55 | 1317 | writing zeroes to the media. |
91447636 A |
1318 | This provides performance similar to sparse files, but not the space savings. |
1319 | .Pp | |
1320 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1321 | . | |
1322 | .It VOL_CAP_FMT_CASE_SENSITIVE | |
2d21ac55 A |
1323 | If this bit is set the volume format treats upper and lower case |
1324 | characters in file and directory names as different. | |
1325 | Otherwise an upper case character is equivalent to a lower case character, | |
91447636 A |
1326 | and you can't have two names that differ solely in the case of |
1327 | the characters. | |
1328 | .Pp | |
1329 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1330 | . | |
1331 | .It VOL_CAP_FMT_CASE_PRESERVING | |
2d21ac55 A |
1332 | If this bit is set the volume format preserves the case of |
1333 | file and directory names. | |
1334 | Otherwise the volume may change the case of some characters | |
91447636 | 1335 | (typically making them all upper or all lower case). |
2d21ac55 | 1336 | A volume that sets |
91447636 | 1337 | .Dv VOL_CAP_FMT_CASE_SENSITIVE |
2d21ac55 | 1338 | must also set |
91447636 A |
1339 | .Dv VOL_CAP_FMT_CASE_PRESERVING . |
1340 | .Pp | |
1341 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1342 | . | |
1343 | .It VOL_CAP_FMT_FAST_STATFS | |
fe8ab488 | 1344 | This bit is used as a hint to upper layers to |
2d21ac55 A |
1345 | indicate that |
1346 | .Xr statfs 2 | |
1347 | is fast enough that its results need not be cached by the caller. | |
1348 | A volume format implementation that caches the | |
91447636 | 1349 | .Xr statfs 2 |
91447636 | 1350 | information in memory should set this bit. |
2d21ac55 A |
1351 | An implementation that must always read from disk or always perform a network |
1352 | transaction to satisfy | |
91447636 A |
1353 | .Xr statfs 2 |
1354 | should not set this bit. | |
1355 | .Pp | |
1356 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1357 | . | |
1358 | .It VOL_CAP_FMT_2TB_FILESIZE | |
b0d623f7 A |
1359 | If this bit is set the volume format supports file sizes larger |
1360 | than 4GB, and potentially up to 2TB; it does not indicate | |
1361 | whether the file system supports files larger than that. | |
91447636 A |
1362 | .Pp |
1363 | Introduced with Darwin 8.0 (Mac OS X version 10.4). | |
1364 | . | |
b0d623f7 A |
1365 | .It VOL_CAP_FMT_OPENDENYMODES |
1366 | If this bit is set, the volume format supports open deny modes | |
1367 | (e.g., "open for read write, deny write"). | |
1368 | . | |
1369 | .It VOL_CAP_FMT_HIDDEN_FILES | |
1370 | If this bit is set, the volume format supports the | |
1371 | .Dv UF_HIDDEN | |
1372 | file flag, and the | |
1373 | .Dv UF_HIDDEN | |
1374 | flag is mapped to that volume's native "hidden" or "invisible" | |
1375 | bit (e.g., the invisible bit from the Finder Info extended attribute). | |
1376 | . | |
1377 | .It VOL_CAP_FMT_PATH_FROM_ID | |
1378 | If this bit is set, the volume format supports the ability to derive a pathname | |
1379 | to the root of the file system given only the ID of an object. This also | |
1380 | implies that object IDs on this file system are persistent and not recycled. | |
1381 | Most file systems will not support this capability. | |
1382 | . | |
1383 | .It VOL_CAP_FMT_NO_VOLUME_SIZES | |
1384 | If this bit is set the volume format does not support | |
1385 | determining values for total data blocks, available blocks, or free blocks, as in | |
1386 | .Fa f_blocks, | |
1387 | .Fa f_bavail, | |
1388 | and | |
1389 | .Fa f_bfree | |
1390 | in the | |
1391 | .Fa struct statfs | |
1392 | returned by | |
1393 | .Xr statfs 2 . | |
1394 | Historically, those values were set to 0xFFFFFFFF for volumes | |
1395 | that did not support them. | |
1396 | .Pp | |
1397 | Introduced with Darwin 10.0 (Mac OS X version 10.6). | |
1398 | . | |
6d2010ae A |
1399 | .It VOL_CAP_FMT_64BIT_OBJECT_IDS |
1400 | If this bit is set, the volume format uses object IDs that are 64-bit. | |
39037602 A |
1401 | This means that ATTR_CMN_FILEID and ATTR_CMN_PARENTID are the primary means of |
1402 | obtaining object IDs from this volume. The values returned by ATTR_CMN_OBJID, | |
1403 | ATTR_CMN_OBJPERMANENTID, and ATTR_CMN_PAROBJID can be interpreted as 64-bit | |
1404 | object IDs instead of fsobj_id_t. | |
6d2010ae | 1405 | . |
813fb2f6 A |
1406 | .It VOL_CAP_FMT_NO_IMMUTABLE_FILES |
1407 | If this bit is set, the volume format does not support setting the UF_IMMUTABLE | |
1408 | flag. | |
1409 | See ATTR_CMN_FLAGS for more details. | |
1410 | .It VOL_CAP_FMT_NO_PERMISSIONS | |
1411 | If this bit is set, the volume format does not support setting file | |
1412 | permissions. | |
1413 | See ATTR_CMN_USERACCESS for more details. | |
1414 | . | |
91447636 A |
1415 | .El |
1416 | .Pp | |
1417 | . | |
2d21ac55 A |
1418 | The following bits are defined in the second element (indexed by |
1419 | .Dv VOL_CAPABILITIES_INTERFACES ) | |
1420 | of the | |
1421 | .Fa capabilities | |
1422 | and | |
1423 | .Fa valid | |
1424 | fields of the | |
1425 | .Vt vol_capabilities_attr_t | |
91447636 A |
1426 | structure. |
1427 | . | |
1428 | .Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS | |
1429 | . | |
1430 | .It VOL_CAP_INT_SEARCHFS | |
2d21ac55 | 1431 | If this bit is set the volume format implementation supports |
91447636 A |
1432 | .Xr searchfs 2 . |
1433 | . | |
1434 | .It VOL_CAP_INT_ATTRLIST | |
2d21ac55 A |
1435 | If this bit is set the volume format implementation supports |
1436 | .Fn getattrlist | |
1437 | and | |
91447636 A |
1438 | .Xr setattrlist 2 . |
1439 | . | |
1440 | .It VOL_CAP_INT_NFSEXPORT | |
2d21ac55 | 1441 | If this bit is set the volume format implementation allows this volume to be exported via NFS. |
91447636 A |
1442 | . |
1443 | .It VOL_CAP_INT_READDIRATTR | |
2d21ac55 | 1444 | If this bit is set the volume format implementation supports |
91447636 A |
1445 | .Xr getdirentriesattr 2 . |
1446 | . | |
1447 | .It VOL_CAP_INT_EXCHANGEDATA | |
2d21ac55 | 1448 | If this bit is set the volume format implementation supports |
91447636 A |
1449 | .Xr exchangedata 2 . |
1450 | .Pp | |
1451 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1452 | . | |
1453 | .It VOL_CAP_INT_COPYFILE | |
1454 | If this bit is set the volume format implementation supports the (private and undocumented) | |
1455 | copyfile() function. | |
b0d623f7 A |
1456 | (This is not the |
1457 | .Xr copyfile 3 | |
1458 | function.) | |
91447636 A |
1459 | .Pp |
1460 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1461 | . | |
1462 | .It VOL_CAP_INT_ALLOCATE | |
2d21ac55 A |
1463 | If this bit is set the volume format implementation supports the |
1464 | .Dv F_PREALLOCATE | |
1465 | selector of | |
91447636 A |
1466 | .Xr fcntl 2 . |
1467 | .Pp | |
1468 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1469 | . | |
1470 | .It VOL_CAP_INT_VOL_RENAME | |
2d21ac55 A |
1471 | If this bit is set the volume format implementation allows you to |
1472 | modify the volume name using | |
91447636 A |
1473 | .Xr setattrlist 2 . |
1474 | .Pp | |
1475 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1476 | . | |
1477 | .It VOL_CAP_INT_ADVLOCK | |
2d21ac55 A |
1478 | If this bit is set the volume format implementation supports |
1479 | advisory locking, that is, the | |
91447636 | 1480 | .Dv F_GETLK , |
2d21ac55 A |
1481 | .Dv F_SETLK , |
1482 | and | |
1483 | .Dv F_SETLKW | |
1484 | selectors to | |
91447636 A |
1485 | .Xr fcntl 2 . |
1486 | .Pp | |
1487 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1488 | . | |
1489 | .It VOL_CAP_INT_FLOCK | |
2d21ac55 A |
1490 | If this bit is set the volume format implementation supports |
1491 | whole file locks. | |
1492 | This includes | |
1493 | .Xr flock 2 | |
1494 | and the | |
1495 | .Dv O_EXLOCK | |
1496 | and | |
1497 | .Dv O_SHLOCK | |
1498 | flags to | |
91447636 A |
1499 | .Xr open 2 . |
1500 | .Pp | |
1501 | Introduced with Darwin 7.0 (Mac OS X version 10.3). | |
1502 | . | |
2d21ac55 A |
1503 | .It VOL_CAP_INT_EXTENDED_SECURITY |
1504 | If this bit is set the volume format implementation supports | |
1505 | extended security controls (ACLs). | |
1506 | .Pp | |
1507 | Introduced with Darwin 8.0 (Mac OS X version 10.4). | |
1508 | . | |
1509 | .It VOL_CAP_INT_USERACCESS | |
1510 | If this bit is set the volume format implementation supports the | |
1511 | ATTR_CMN_USERACCESS attribute. | |
1512 | .Pp | |
1513 | Introduced with Darwin 8.0 (Mac OS X version 10.4). | |
1514 | . | |
b0d623f7 A |
1515 | .It VOL_CAP_INT_MANLOCK |
1516 | If this bit is set, the volume format implementation supports | |
1517 | AFP-style mandatory byte range locks via | |
1518 | .Xr ioctl 2 . | |
1519 | . | |
1520 | .It VOL_CAP_INT_EXTENDED_ATTR | |
1521 | If this bit is set, the volume format implementation supports | |
1522 | native extended attributes (see | |
39037602 | 1523 | .Xr setxattr 2 Ns ). |
b0d623f7 | 1524 | . |
813fb2f6 A |
1525 | .It VOL_CAP_INT_CLONE |
1526 | If this bit is set, the file system supports cloning files and directories. | |
1527 | See | |
1528 | .Xr clonefileat 2 | |
1529 | for more details. | |
1530 | . | |
b0d623f7 A |
1531 | .It VOL_CAP_INT_NAMEDSTREAMS |
1532 | If this bit is set, the volume format implementation supports | |
1533 | native named streams. | |
1534 | . | |
39037602 A |
1535 | .It VOL_CAP_INT_RENAME_SWAP |
1536 | If this bit is set, the file system supports swapping file system | |
1537 | objects. See | |
1538 | .Xr rename 2 | |
1539 | for more details. | |
1540 | . | |
1541 | .It VOL_CAP_INT_RENAME_EXCL | |
1542 | If this bit is set, the file system supports an exclusive rename | |
1543 | operation. See | |
1544 | .Xr rename 2 | |
1545 | for more details. | |
1546 | . | |
91447636 A |
1547 | .El |
1548 | .Pp | |
1549 | . | |
1550 | .\" vol_attributes_attr_t | |
1551 | . | |
2d21ac55 | 1552 | A volume can also report which attributes it supports. |
91447636 | 1553 | This information is returned by the |
2d21ac55 A |
1554 | .Dv ATTR_VOL_ATTRIBUTES |
1555 | attribute, which returns a | |
1556 | .Vt vol_attributes_attr_t | |
91447636 A |
1557 | structure (shown below). |
1558 | . | |
1559 | .Bd -literal | |
1560 | typedef struct attribute_set { | |
1561 | attrgroup_t commonattr; /* common attribute group */ | |
1562 | attrgroup_t volattr; /* volume attribute group */ | |
1563 | attrgroup_t dirattr; /* directory attribute group */ | |
1564 | attrgroup_t fileattr; /* file attribute group */ | |
1565 | attrgroup_t forkattr; /* fork attribute group */ | |
1566 | } attribute_set_t; | |
1567 | .Pp | |
1568 | . | |
1569 | typedef struct vol_attributes_attr { | |
1570 | attribute_set_t validattr; | |
1571 | attribute_set_t nativeattr; | |
1572 | } vol_attributes_attr_t; | |
1573 | .Ed | |
1574 | .Pp | |
1575 | . | |
2d21ac55 A |
1576 | The |
1577 | .Fa validattr | |
1578 | field consists of a number of bit sets that indicate whether an attribute is | |
1579 | supported by the volume format implementation. | |
1580 | The | |
1581 | .Fa nativeattr | |
1582 | is similar except that the bit sets indicate whether an attribute is supported | |
1583 | natively by the volume format. | |
1584 | An attribute is supported natively if the volume format implementation does not have to do | |
1585 | any complex conversions to access the attribute. | |
1586 | For example, a volume format might support persistent object identifiers, but | |
1587 | doing so requires a complex table lookup that is not part of the core volume | |
1588 | format. | |
1589 | In that case, the | |
1590 | .Dv ATTR_VOL_ATTRIBUTES | |
1591 | attribute would return | |
1592 | .Dv ATTR_CMN_OBJPERMANENTID | |
1593 | set in the | |
1594 | .Fa validattr | |
1595 | field of the | |
91447636 | 1596 | .Vt vol_attributes_attr_t , |
2d21ac55 A |
1597 | but not in the |
1598 | .Fa nativeattr | |
91447636 A |
1599 | field. |
1600 | . | |
1601 | .Sh RETURN VALUES | |
1602 | Upon successful completion a value of 0 is returned. | |
1603 | Otherwise, a value of -1 is returned and | |
1604 | .Va errno | |
1605 | is set to indicate the error. | |
1606 | . | |
1607 | .Sh COMPATIBILITY | |
2d21ac55 | 1608 | Not all volumes support |
91447636 | 1609 | .Fn getattrlist . |
2d21ac55 | 1610 | The best way to test whether a volume supports this function is to |
91447636 | 1611 | simply call it and check the error result. |
2d21ac55 A |
1612 | .Fn getattrlist |
1613 | will return | |
91447636 A |
1614 | .Dv ENOTSUP |
1615 | if it is not supported on a particular volume. | |
1616 | .Pp | |
1617 | . | |
2d21ac55 A |
1618 | The |
1619 | .Fn getattrlist | |
1620 | function has been undocumented for more than two years. | |
1621 | In that time a number of volume format implementations have been created without | |
1622 | a proper specification for the behaviour of this routine. | |
1623 | You may encounter volume format implementations with slightly different | |
1624 | behaviour than what is described here. | |
91447636 A |
1625 | Your program is expected to be tolerant of this variant behaviour. |
1626 | .Pp | |
1627 | . | |
2d21ac55 | 1628 | If you're implementing a volume format that supports |
91447636 A |
1629 | .Fn getattrlist , |
1630 | you should be careful to support the behaviour specified by this document. | |
1631 | . | |
1632 | .Sh ERRORS | |
1633 | .Fn getattrlist | |
b0d623f7 A |
1634 | and |
1635 | .Fn fgetattrlist | |
91447636 A |
1636 | will fail if: |
1637 | .Bl -tag -width Er | |
1638 | . | |
1639 | .It Bq Er ENOTSUP | |
b0d623f7 | 1640 | The volume does not support the query. |
91447636 A |
1641 | . |
1642 | .It Bq Er ENOTDIR | |
b0d623f7 A |
1643 | A component of the path prefix for |
1644 | .Fn getattrlist | |
1645 | is not a directory. | |
91447636 A |
1646 | . |
1647 | .It Bq Er ENAMETOOLONG | |
b0d623f7 A |
1648 | A component of a path name for |
1649 | .Fn getattrlist | |
1650 | exceeded | |
91447636 | 1651 | .Dv NAME_MAX |
2d21ac55 | 1652 | characters, or an entire path name exceeded |
91447636 A |
1653 | .Dv PATH_MAX |
1654 | characters. | |
1655 | . | |
1656 | .It Bq Er ENOENT | |
b0d623f7 A |
1657 | The file system object for |
1658 | .Fn getattrlist | |
1659 | does not exist. | |
1660 | . | |
1661 | .It Bq Er EBADF | |
1662 | The file descriptor argument for | |
1663 | .Fn fgetattrlist | |
1664 | is not a valid file descriptor. | |
91447636 A |
1665 | . |
1666 | .It Bq Er EACCES | |
b0d623f7 A |
1667 | Search permission is denied for a component of the path prefix for |
1668 | .Fn getattrlist . | |
91447636 A |
1669 | . |
1670 | .It Bq Er ELOOP | |
b0d623f7 A |
1671 | Too many symbolic links were encountered in translating the pathname |
1672 | for | |
1673 | .Fn getattrlist . | |
91447636 A |
1674 | . |
1675 | .It Bq Er EFAULT | |
1676 | .Fa path , | |
1677 | .Fa attrList | |
1678 | or | |
1679 | .Em attrBuf | |
1680 | points to an invalid address. | |
1681 | . | |
1682 | .It Bq Er EINVAL | |
2d21ac55 A |
1683 | The |
1684 | .Fa bitmapcount | |
1685 | field of | |
1686 | .Fa attrList | |
1687 | is not | |
91447636 A |
1688 | .Dv ATTR_BIT_MAP_COUNT . |
1689 | . | |
1690 | .It Bq Er EINVAL | |
1691 | You requested an invalid attribute. | |
1692 | . | |
1693 | .It Bq Er EINVAL | |
1694 | You requested an attribute that is not supported for this file system object. | |
1695 | . | |
1696 | .It Bq Er EINVAL | |
1697 | You requested volume attributes and directory or file attributes. | |
1698 | . | |
1699 | .It Bq Er EINVAL | |
2d21ac55 A |
1700 | You requested volume attributes but |
1701 | .Fa path | |
91447636 A |
1702 | does not reference the root of the volume. |
1703 | . | |
1704 | .It Bq Er EROFS | |
1705 | The volume is read-only but must be modified in order to return this attribute. | |
1706 | . | |
1707 | .It Bq Er EIO | |
1708 | An I/O error occurred while reading from or writing to the file system. | |
1709 | .El | |
1710 | .Pp | |
fe8ab488 A |
1711 | In addition to the errors returned by the |
1712 | .Fn getattrlist , | |
1713 | the | |
1714 | .Fn getattrlistat | |
1715 | function may fail if: | |
1716 | .Bl -tag -width Er | |
1717 | .It Bq Er EBADF | |
1718 | The | |
1719 | .Fa path | |
1720 | argument does not specify an absolute path and the | |
1721 | .Fa fd | |
1722 | argument is neither | |
1723 | .Dv AT_FDCWD | |
1724 | nor a valid file descriptor open for searching. | |
1725 | .It Bq Er ENOTDIR | |
1726 | The | |
1727 | .Fa path | |
1728 | argument is not an absolute path and | |
1729 | .Fa fd | |
1730 | is neither | |
1731 | .Dv AT_FDCWD | |
1732 | nor a file descriptor associated with a directory. | |
1733 | .El | |
1734 | .Pp | |
91447636 A |
1735 | . |
1736 | .Sh CAVEATS | |
1737 | . | |
2d21ac55 A |
1738 | If you request any volume attributes, you must set |
1739 | .Dv ATTR_VOL_INFO | |
1740 | in the | |
91447636 A |
1741 | .Fa volattr |
1742 | field, even though it generates no result in the attribute buffer. | |
1743 | .Pp | |
1744 | . | |
2d21ac55 | 1745 | The order that attributes are stored in the attribute buffer almost |
91447636 | 1746 | invariably matches the order of attribute mask bit values. |
2d21ac55 A |
1747 | For example, |
1748 | .Dv ATTR_CMN_NAME | |
1749 | (0x00000001) comes before | |
1750 | .Dv ATTR_CMN_DEVID | |
91447636 | 1751 | (0x00000002) because its value is smaller. |
2d21ac55 | 1752 | When ordering attributes, you should always use the order in which they |
91447636 A |
1753 | are described above. |
1754 | .Pp | |
1755 | . | |
b0d623f7 A |
1756 | The |
1757 | .Vt timespec | |
1758 | structure is 64-bits (two 32-bit elements) in 32-bit code, and | |
1759 | 128-bits (two 64-bit elements) in 64-bit code; however, it is aligned | |
1760 | on a 4-byte (32-bit) boundary, even in 64-bit code. | |
1761 | .Pp | |
6d2010ae A |
1762 | If you use a structure |
1763 | for the attribute data, it must be correctly packed and aligned (see | |
1764 | examples). | |
1765 | .Pp | |
b0d623f7 A |
1766 | . |
1767 | Inconsistent behavior may be observed when the ATTR_CMN_FULLPATH attribute is requested on | |
1768 | hard-linked items, particularly when the file system does not support ATTR_CMN_PARENTID | |
1769 | natively. Callers should be aware of this when requesting the full path of a hard-linked item, especially | |
1770 | if the full path crosses mount points. | |
1771 | .Pp | |
1772 | . | |
91447636 A |
1773 | For more caveats, see also the compatibility notes above. |
1774 | . | |
1775 | .Sh EXAMPLES | |
1776 | . | |
2d21ac55 | 1777 | The following code prints the file type and creator of a file, |
91447636 A |
1778 | assuming that the volume supports the required attributes. |
1779 | . | |
1780 | .Bd -literal | |
1781 | #include <assert.h> | |
1782 | #include <stdio.h> | |
1783 | #include <string.h> | |
1784 | #include <sys/attr.h> | |
1785 | #include <sys/errno.h> | |
1786 | #include <unistd.h> | |
1787 | #include <sys/vnode.h> | |
1788 | .Pp | |
1789 | . | |
1790 | typedef struct attrlist attrlist_t; | |
1791 | .Pp | |
1792 | . | |
1793 | struct FInfoAttrBuf { | |
2d21ac55 | 1794 | u_int32_t length; |
91447636 A |
1795 | fsobj_type_t objType; |
1796 | char finderInfo[32]; | |
6d2010ae | 1797 | } __attribute__((aligned(4), packed)); |
91447636 A |
1798 | typedef struct FInfoAttrBuf FInfoAttrBuf; |
1799 | .Pp | |
1800 | . | |
1801 | static int FInfoDemo(const char *path) | |
1802 | { | |
1803 | int err; | |
1804 | attrlist_t attrList; | |
1805 | FInfoAttrBuf attrBuf; | |
1806 | .Pp | |
1807 | . | |
1808 | memset(&attrList, 0, sizeof(attrList)); | |
1809 | attrList.bitmapcount = ATTR_BIT_MAP_COUNT; | |
1810 | attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO; | |
1811 | .Pp | |
2d21ac55 | 1812 | |
91447636 A |
1813 | err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0); |
1814 | if (err != 0) { | |
1815 | err = errno; | |
1816 | } | |
1817 | .Pp | |
2d21ac55 | 1818 | |
91447636 A |
1819 | if (err == 0) { |
1820 | assert(attrBuf.length == sizeof(attrBuf)); | |
1821 | .Pp | |
2d21ac55 | 1822 | |
91447636 A |
1823 | printf("Finder information for %s:\en", path); |
1824 | switch (attrBuf.objType) { | |
1825 | case VREG: | |
1826 | printf("file type = '%.4s'\en", &attrBuf.finderInfo[0]); | |
1827 | printf("file creator = '%.4s'\en", &attrBuf.finderInfo[4]); | |
1828 | break; | |
1829 | case VDIR: | |
1830 | printf("directory\en"); | |
1831 | break; | |
1832 | default: | |
1833 | printf("other object type, %d\en", attrBuf.objType); | |
1834 | break; | |
1835 | } | |
1836 | } | |
1837 | .Pp | |
1838 | . | |
1839 | return err; | |
1840 | } | |
1841 | .Ed | |
1842 | .Pp | |
1843 | . | |
2d21ac55 | 1844 | The following code is an alternative implementation that uses nested structures |
91447636 A |
1845 | to group the related attributes. |
1846 | . | |
1847 | .Bd -literal | |
1848 | #include <assert.h> | |
1849 | #include <stdio.h> | |
1850 | #include <stddef.h> | |
1851 | #include <string.h> | |
1852 | #include <sys/attr.h> | |
1853 | #include <sys/errno.h> | |
1854 | #include <unistd.h> | |
1855 | #include <sys/vnode.h> | |
1856 | .Pp | |
1857 | . | |
1858 | typedef struct attrlist attrlist_t; | |
1859 | .Pp | |
1860 | . | |
1861 | struct FInfo2CommonAttrBuf { | |
1862 | fsobj_type_t objType; | |
1863 | char finderInfo[32]; | |
6d2010ae | 1864 | } __attribute__((aligned(4), packed)); |
91447636 A |
1865 | typedef struct FInfo2CommonAttrBuf FInfo2CommonAttrBuf; |
1866 | .Pp | |
1867 | . | |
1868 | struct FInfo2AttrBuf { | |
2d21ac55 | 1869 | u_int32_t length; |
91447636 | 1870 | FInfo2CommonAttrBuf common; |
6d2010ae | 1871 | } __attribute__((aligned(4), packed));; |
91447636 A |
1872 | typedef struct FInfo2AttrBuf FInfo2AttrBuf; |
1873 | .Pp | |
1874 | . | |
1875 | static int FInfo2Demo(const char *path) | |
1876 | { | |
1877 | int err; | |
1878 | attrlist_t attrList; | |
1879 | FInfo2AttrBuf attrBuf; | |
1880 | .Pp | |
1881 | . | |
1882 | memset(&attrList, 0, sizeof(attrList)); | |
1883 | attrList.bitmapcount = ATTR_BIT_MAP_COUNT; | |
1884 | attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO; | |
1885 | .Pp | |
1886 | . | |
1887 | err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0); | |
1888 | if (err != 0) { | |
1889 | err = errno; | |
1890 | } | |
1891 | .Pp | |
1892 | . | |
1893 | if (err == 0) { | |
1894 | assert(attrBuf.length == sizeof(attrBuf)); | |
1895 | .Pp | |
1896 | . | |
1897 | printf("Finder information for %s:\en", path); | |
1898 | switch (attrBuf.common.objType) { | |
1899 | case VREG: | |
1900 | printf( | |
2d21ac55 | 1901 | "file type = '%.4s'\en", |
91447636 A |
1902 | &attrBuf.common.finderInfo[0] |
1903 | ); | |
1904 | printf( | |
2d21ac55 | 1905 | "file creator = '%.4s'\en", |
91447636 A |
1906 | &attrBuf.common.finderInfo[4] |
1907 | ); | |
1908 | break; | |
1909 | case VDIR: | |
1910 | printf("directory\en"); | |
1911 | break; | |
1912 | default: | |
1913 | printf( | |
2d21ac55 | 1914 | "other object type, %d\en", |
91447636 A |
1915 | attrBuf.common.objType |
1916 | ); | |
1917 | break; | |
1918 | } | |
1919 | } | |
1920 | .Pp | |
1921 | . | |
1922 | return err; | |
1923 | } | |
1924 | .Ed | |
1925 | .Pp | |
1926 | . | |
2d21ac55 A |
1927 | The following example shows how to deal with variable length attributes. |
1928 | It assumes that the volume specified by | |
1929 | .Fa path | |
91447636 A |
1930 | supports the necessary attributes. |
1931 | . | |
1932 | .Bd -literal | |
1933 | #include <assert.h> | |
1934 | #include <stdio.h> | |
1935 | #include <stddef.h> | |
1936 | #include <string.h> | |
1937 | #include <sys/attr.h> | |
1938 | #include <sys/errno.h> | |
1939 | #include <unistd.h> | |
1940 | #include <sys/vnode.h> | |
1941 | .Pp | |
1942 | . | |
1943 | typedef struct attrlist attrlist_t; | |
1944 | .Pp | |
1945 | . | |
1946 | struct VolAttrBuf { | |
2d21ac55 A |
1947 | u_int32_t length; |
1948 | u_int32_t fileCount; | |
1949 | u_int32_t dirCount; | |
91447636 A |
1950 | attrreference_t mountPointRef; |
1951 | attrreference_t volNameRef; | |
1952 | char mountPointSpace[MAXPATHLEN]; | |
1953 | char volNameSpace[MAXPATHLEN]; | |
6d2010ae | 1954 | } __attribute__((aligned(4), packed)); |
91447636 A |
1955 | typedef struct VolAttrBuf VolAttrBuf; |
1956 | .Pp | |
1957 | . | |
1958 | static int VolDemo(const char *path) | |
1959 | { | |
1960 | int err; | |
1961 | attrlist_t attrList; | |
1962 | VolAttrBuf attrBuf; | |
1963 | .Pp | |
1964 | . | |
1965 | memset(&attrList, 0, sizeof(attrList)); | |
1966 | attrList.bitmapcount = ATTR_BIT_MAP_COUNT; | |
2d21ac55 A |
1967 | attrList.volattr = ATTR_VOL_INFO |
1968 | | ATTR_VOL_FILECOUNT | |
1969 | | ATTR_VOL_DIRCOUNT | |
1970 | | ATTR_VOL_MOUNTPOINT | |
91447636 A |
1971 | | ATTR_VOL_NAME; |
1972 | .Pp | |
2d21ac55 | 1973 | |
91447636 A |
1974 | err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0); |
1975 | if (err != 0) { | |
1976 | err = errno; | |
1977 | } | |
1978 | .Pp | |
2d21ac55 | 1979 | |
91447636 A |
1980 | if (err == 0) { |
1981 | assert(attrBuf.length > offsetof(VolAttrBuf, mountPointSpace)); | |
1982 | assert(attrBuf.length <= sizeof(attrBuf)); | |
1983 | .Pp | |
2d21ac55 | 1984 | |
91447636 | 1985 | printf("Volume information for %s:\en", path); |
b0d623f7 A |
1986 | printf("ATTR_VOL_FILECOUNT: %u\en", attrBuf.fileCount); |
1987 | printf("ATTR_VOL_DIRCOUNT: %u\en", attrBuf.dirCount); | |
91447636 | 1988 | printf( |
2d21ac55 | 1989 | "ATTR_VOL_MOUNTPOINT: %.*s\en", |
91447636 | 1990 | (int) attrBuf.mountPointRef.attr_length, |
2d21ac55 | 1991 | ( ((char *) &attrBuf.mountPointRef) |
91447636 A |
1992 | + attrBuf.mountPointRef.attr_dataoffset ) |
1993 | ); | |
1994 | printf( | |
2d21ac55 | 1995 | "ATTR_VOL_NAME: %.*s\en", |
91447636 | 1996 | (int) attrBuf.volNameRef.attr_length, |
2d21ac55 | 1997 | ( ((char *) &attrBuf.volNameRef) |
91447636 A |
1998 | + attrBuf.volNameRef.attr_dataoffset ) |
1999 | ); | |
2000 | } | |
2001 | .Pp | |
2002 | . | |
2003 | return err; | |
2004 | } | |
2005 | .Ed | |
2006 | .Pp | |
6d2010ae A |
2007 | The following sample demonstrates the need to use packing and alignment |
2008 | controls; without the attribute, in 64-bit code, the fields of the structure are not | |
2009 | placed at the locations that the kernel expects. | |
2010 | . | |
2011 | .Bd -literal | |
2012 | #include <stdio.h> | |
2013 | #include <stdlib.h> | |
2014 | #include <unistd.h> | |
2015 | #include <string.h> | |
2016 | #include <err.h> | |
2017 | #include <time.h> | |
2018 | #include <sys/attr.h> | |
2019 | .Pp | |
2020 | /* The alignment and packing attribute is necessary in 64-bit code */ | |
2021 | struct AttrListTimes { | |
2022 | u_int32_t length; | |
2023 | struct timespec st_crtime; | |
2024 | struct timespec st_modtime; | |
2025 | } __attribute__((aligned(4), packed)); | |
2026 | .Pp | |
2027 | main(int argc, char **argv) | |
2028 | { | |
2029 | int rv; | |
2030 | int i; | |
2031 | .Pp | |
2032 | for (i = 1; i < argc; i++) { | |
2033 | struct attrlist attrList; | |
2034 | struct AttrListTimes myStat = {0}; | |
2035 | char *path = argv[i]; | |
2036 | .Pp | |
2037 | memset(&attrList, 0, sizeof(attrList)); | |
2038 | attrList.bitmapcount = ATTR_BIT_MAP_COUNT; | |
2039 | attrList.commonattr = ATTR_CMN_CRTIME | | |
2040 | ATTR_CMN_MODTIME; | |
2041 | .Pp | |
2042 | rv = getattrlist(path, &attrList, &myStat, sizeof(myStat), 0); | |
2043 | .Pp | |
2044 | if (rv == -1) { | |
2045 | warn("getattrlist(%s)", path); | |
2046 | continue; | |
2047 | } | |
2048 | printf("%s: Modification time = %s", argv[i], ctime(&myStat.st_modtime.tv_sec)); | |
2049 | } | |
2050 | return 0; | |
2051 | } | |
2052 | .Ed | |
2053 | .Pp | |
91447636 A |
2054 | . |
2055 | .Sh SEE ALSO | |
2056 | . | |
2057 | .Xr access 2 , | |
2058 | .Xr chflags 2 , | |
2059 | .Xr exchangedata 2 , | |
2060 | .Xr fcntl 2 , | |
fe8ab488 | 2061 | .Xr getattrlistbulk 2 , |
91447636 A |
2062 | .Xr mount 2 , |
2063 | .Xr searchfs 2 , | |
2064 | .Xr setattrlist 2 , | |
2065 | .Xr stat 2 , | |
2066 | .Xr statfs 2 | |
2067 | . | |
2068 | .Sh HISTORY | |
2d21ac55 | 2069 | A |
91447636 A |
2070 | .Fn getattrlist |
2071 | function call appeared in Darwin 1.3.1 (Mac OS X version 10.0). | |
fe8ab488 A |
2072 | The |
2073 | .Fn getattrlistat | |
2074 | function call appeared in OS X 10.10 . |