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