]> git.saurik.com Git - apple/xnu.git/blob - bsd/man/man2/getattrlist.2
f37a137aa56c7f9be6a658df0c6e8b64536a055d
[apple/xnu.git] / bsd / man / man2 / getattrlist.2
1 .\" Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
2 .\"
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.
8 .\"
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.
16 .\"
17 .\" @(#)getattrlist.2
18 .
19 .Dd February 25, 2014
20 .Dt GETATTRLIST 2
21 .Os Darwin
22 .Sh NAME
23 .Nm getattrlist ,
24 .Nm fgetattrlist ,
25 .Nm getattrlistat
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 .
33 .Ft int
34 .Fn fgetattrlist "int fd" "struct attrlist * attrList" "void * attrBuf" "size_t attrBufSize" "unsigned long options"
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
40 .Sh DESCRIPTION
41 The
42 .Fn getattrlist
43 function returns attributes (that is, metadata) of file system objects.
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 .
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
73 You can think of
74 .Fn getattrlist
75 as a seriously enhanced version of
76 .Xr stat 2 .
77 The functions return attributes about the specified file system object
78 into the buffer specified by
79 .Fa attrBuf
80 and
81 .Fa attrBufSize .
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 .
90 Not all volumes support all attributes.
91 See the discussion of
92 .Dv ATTR_VOL_ATTRIBUTES
93 for a discussion of how to determine whether a particular volume supports a
94 particular attribute.
95 .Pp
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
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.
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
111 searchable.
112 .Pp
113 .
114 .\" attrList parameter
115 .
116 The
117 .Fa attrList
118 parameter is a pointer to an
119 .Vt attrlist
120 structure, as defined by
121 .Aq Pa sys/attr.h
122 (shown below).
123 It determines what attributes are returned by the function.
124 You are responsible for filling out all fields of this structure before calling the function.
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 .
143 The fields of the
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.
150 In current systems you must set this to
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.
159 Common attributes relate to all types of file system objects.
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.
166 If you request volume attributes,
167 .Fa path
168 must reference the root of a volume.
169 In addition, you can't request volume attributes if you also request
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.
182 Fork attributes relate to the actual data in the file,
183 which can be held in multiple named contiguous ranges, or forks.
184 See below for a description of these attributes.
185 If the FSOPT_ATTR_CMN_EXTENDED option is given, this bit set is reinterpreted
186 as extended common attributes attributes, also described below.
187 .
188 .El
189 .Pp
190 .
191 Unless otherwise noted in the lists below, attributes are read-only.
192 Attributes labelled as read/write can be set using
193 .Xr setattrlist 2 .
194 .Pp
195 .
196 .\" attrBuf and attrBufSize parameters
197 .
198 The
199 .Fa attrBuf
200 and
201 .Fa attrBufSize
202 parameters specify a buffer into which the function places attribute values.
203 The format of this buffer is sufficiently complex that its description
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
213 the functions.
214 The following option bits are defined.
215 .
216 .Bl -tag -width FSOPT_PACK_INVAL_ATTRS
217 .
218 .It FSOPT_NOFOLLOW
219 If this bit is set,
220 .Fn getattrlist
221 will not follow a symlink if it occurs as
222 the last component of
223 .Fa path .
224 .
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 .
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
245 can be requested. When this option is used, forkattrs are reinterpreted as a
246 set of extended common attributes.
247 .
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 .
254 .El
255 .
256 .Sh ATTRIBUTE BUFFER
257 .
258 The data returned in the buffer described by
259 .Fa attrBuf
260 and
261 .Fa attrBufSize
262 is formatted as follows.
263 .Pp
264 .
265 .Bl -enum
266 .
267 .It
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.
272 .
273 .It
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).
277 .
278 .It
279 The attributes are placed into the attribute buffer in the order
280 that they are described below.
281 .
282 .It
283 Each attribute is aligned to a 4-byte boundary (including 64-bit data types).
284 .El
285 .Pp
286 .
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
291 .Aq Pa sys/attr.h
292 (shown below).
293 .
294 .Bd -literal
295 typedef struct attrreference {
296 int32_t attr_dataoffset;
297 u_int32_t attr_length;
298 } attrreference_t;
299 .Ed
300 .Pp
301 .
302 This structure contains a 'pointer' to the variable length attribute data.
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.
312 This offset will always be a multiple of sizeof(u_int32_t) bytes,
313 so you can safely access common data types without fear of alignment
314 exceptions.
315 .Pp
316 .
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
329 in the attribute list (including the leading length field).
330 .Pp
331 .
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
339 .Vt attrreference_t ,
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
359 ) ).
360 If this happens you must increase the size of the buffer and call
361 .Fn getattrlist
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 .
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
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.
382 .
383 .It ATTR_CMN_NAME
384 An
385 .Vt attrreference
386 structure containing the name of the file system object as
387 UTF-8 encoded, null terminated C string.
388 The attribute data length will not be greater than
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).
394 .Pp
395 .
396 .It ATTR_CMN_DEVID
397 A
398 .Vt dev_t
399 containing the device number of the device on which this
400 file system object's volume is mounted.
401 Equivalent to the
402 .Fa st_dev
403 field of the
404 .Vt stat
405 structure returned by
406 .Xr stat 2 .
407 .
408 .It ATTR_CMN_FSID
409 An
410 .Vt fsid_t
411 structure containing the file system identifier for the volume on which
412 the file system object resides.
413 Equivalent to the
414 .Fa f_fsid
415 field of the
416 .Vt statfs
417 structure returned by
418 .Xr statfs 2 .
419 .
420 .It ATTR_CMN_OBJTYPE
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
427 .Aq Pa sys/vnode.h .
428 .
429 .It ATTR_CMN_OBJTAG
430 An
431 .Vt fsobj_tag_t
432 that identifies the type of file system containing the object.
433 The values are taken from
434 .Vt enum vtagtype
435 in
436 .Aq Pa sys/vnode.h .
437 .
438 .It ATTR_CMN_OBJID
439 An
440 .Vt fsobj_id_t
441 structure that uniquely identifies the file system object within a mounted
442 volume for the duration of its mount; this identifier is not guaranteed to be
443 persistent for the volume and may change every time the volume is mounted.
444 .Pp
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
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.
457 .
458 .It ATTR_CMN_OBJPERMANENTID
459 An
460 .Vt fsobj_id_t
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.)
471 .
472 .It ATTR_CMN_PAROBJID
473 An
474 .Vt fsobj_id_t
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.
479 .Pp
480 .
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.
484 .
485 For some volume formats the computing cost for this attribute is significant;
486 developers are advised to request this attribute sparingly.
487 .
488 .It ATTR_CMN_SCRIPT
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
494 Unicode and traditional Mac OS script encodings.
495 File systems that do not have an appropriate text encoding value should return
496 kTextEncodingMacUnicode.
497 .
498 .It ATTR_CMN_CRTIME
499 (read/write) A
500 .Vt timespec
501 structure containing the time that the file system object
502 was created.
503 .
504 .It ATTR_CMN_MODTIME
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
514 .Xr stat 2 .
515 .
516 .It ATTR_CMN_CHGTIME
517 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
526 .Xr stat 2 .
527 .
528 .It ATTR_CMN_ACCTIME
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
538 .Xr stat 2 .
539 .
540 .It ATTR_CMN_BKUPTIME
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.
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.
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
559 structure).
560 .Pp
561 This attribute is not byte swapped by the file system.
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),
564 you must byte swap any multibyte fields.
565 .
566 .It ATTR_CMN_OWNERID
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
575 .Xr stat 2 .
576 .
577 .It ATTR_CMN_GRPID
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
586 .Xr stat 2 .
587 .
588 .It ATTR_CMN_ACCESSMASK
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
597 .Xr stat 2 .
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 .
603 .
604 .It ATTR_CMN_FLAGS
605 (read/write) A
606 .Vt u_int32_t
607 containing file flags.
608 Equivalent to the
609 .Fa st_flags
610 field of the
611 .Vt stat
612 structure returned by
613 .Xr stat 2 .
614 For more information about these flags, see
615 .Xr chflags 2 .
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.
629 .Pp
630 .
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.
648 .
649 .It ATTR_CMN_USERACCESS
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
655 .Dv R_OK ,
656 .Dv W_OK ,
657 and
658 .Dv X_OK ,
659 respectively.
660 See
661 .Xr access 2
662 for more details.
663 .
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 .
684 .It ATTR_CMN_FILEID
685 A
686 .Vt u_int64_t
687 that uniquely identifies the file system object within its mounted volume.
688 Equivalent to
689 .Fa st_ino
690 field of the
691 .Vt stat
692 structure returned by
693 .Xr stat 2 .
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 .
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.
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
716 its containing directory. Note that inconsistent behavior may be observed
717 when this attribute is requested on hard-linked items.
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.
723 .Pp
724 .
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
735 For reasons that are not at all obvious, you must set
736 .Dv ATTR_VOL_INFO
737 in the
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
743 A
744 .Vt u_int32_t
745 containing the file system type.
746 Equivalent to the
747 .Fa f_type
748 field of the
749 .Vt statfs
750 structure returned by
751 .Xr statfs 2 .
752 Generally not a useful value.
753 .
754 .It ATTR_VOL_SIGNATURE
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
759 distinguish between different volume formats handled by the same file system.
760 .
761 .It ATTR_VOL_SIZE
762 An
763 .Vt off_t
764 containing the total size of the volume in bytes.
765 .
766 .It ATTR_VOL_SPACEFREE
767 An
768 .Vt off_t
769 containing the free space on the volume in bytes.
770 .
771 .It ATTR_VOL_SPACEAVAIL
772 An
773 .Vt off_t
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
778 space available to the user.
779 .Pp
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
788 .Xr statfs 2 .
789 .
790 .It ATTR_VOL_MINALLOCATION
791 An
792 .Vt off_t
793 containing the minimum allocation size on the volume in bytes.
794 If you create a file containing one byte, it will consume this much space.
795 .
796 .It ATTR_VOL_ALLOCATIONCLUMP
797 An
798 .Vt off_t
799 containing the allocation clump size on the volume, in bytes.
800 As a file is extended, the file system will attempt to allocate
801 this much space each time in order to reduce fragmentation.
802 .
803 .It ATTR_VOL_IOBLOCKSIZE
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
812 .Xr statfs 2 .
813 .
814 .It ATTR_VOL_OBJCOUNT
815 A
816 .Vt u_int32_t
817 containing the number of file system objects on the volume.
818 .
819 .It ATTR_VOL_FILECOUNT
820 A
821 .Vt u_int32_t
822 containing the number of files on the volume.
823 .
824 .It ATTR_VOL_DIRCOUNT
825 A
826 .Vt u_int32_t
827 containing the number of directories on the volume.
828 .
829 .It ATTR_VOL_MAXOBJCOUNT
830 A
831 .Vt u_int32_t
832 containing the maximum number of file system objects that can be stored on the volume.
833 .
834 .It ATTR_VOL_MOUNTPOINT
835 An
836 .Vt attrreference
837 structure containing the path to the volume's mount point as a
838 UTF-8 encoded, null terminated C string.
839 The attribute data length will not be greater than
840 .Dv MAXPATHLEN .
841 Equivalent to the
842 .Fa f_mntonname
843 field of the
844 .Vt statfs
845 structure returned by
846 .Xr statfs 2 .
847 .
848 .It ATTR_VOL_NAME
849 (read/write) An
850 .Vt attrreference
851 structure containing the name of the volume as a
852 UTF-8 encoded, null terminated C string.
853 The attribute data length will not be greater than
854 .Dv NAME_MAX +
855 1.
856 .Pp
857 .
858 This attribute is only read/write if the
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
864 A
865 .Vt u_int32_t
866 containing the volume mount flags.
867 This is a copy of the value passed to the
868 .Fa flags
869 parameter of
870 .Xr mount 2
871 when the volume was mounted.
872 Equivalent to the
873 .Fa f_flags
874 field of the
875 .Vt statfs
876 structure returned by
877 .Xr statfs 2 .
878 .
879 .It ATTR_VOL_MOUNTEDDEVICE
880 An
881 .Vt attrreference
882 structure that returns the same value as the
883 .Fa f_mntfromname
884 field of the
885 .Vt statfs
886 structure returned by
887 .Xr statfs 2 .
888 For local volumes this is the path to the device on which the volume is mounted as a
889 UTF-8 encoded, null terminated C string.
890 For network volumes, this is a unique string that identifies the mount.
891 The attribute data length will not be greater than
892 .Dv MAXPATHLEN .
893 .Pp
894 .
895 .It ATTR_VOL_ENCODINGSUSED
896 An
897 .Vt unsigned long long
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
901 in DTS Technote 1150 "HFS Plus Volume Format".
902 .
903 .It ATTR_VOL_CAPABILITIES
904 A
905 .Vt vol_capabilities_attr_t
906 structure describing the optional features supported by this volume.
907 See below for a discussion of volume capabilities.
908 .
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 .
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 .
925 .It ATTR_VOL_ATTRIBUTES
926 A
927 .Vt vol_attributes_attr_t
928 structure describing the attributes supported by this volume.
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
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.
944 For file systems that do not support hard links to directories,
945 this value will be 1.
946 .
947 .It ATTR_DIR_ENTRYCOUNT
948 A
949 .Vt u_int32_t
950 containing the number of file system objects in the directory, not including
951 any synthetic items. The historical "." and ".." entries are also
952 excluded from this count.
953 .
954 .It ATTR_DIR_MOUNTSTATUS
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,
960 which indicates that there is a file system mounted on this directory.
961 .
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).
977 .El
978 .
979 .Pp
980 Requested directory attributes are not returned for file system objects that
981 are not directories.
982 .
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
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
998 .Xr stat 2 .
999 .
1000 .It ATTR_FILE_TOTALSIZE
1001 An
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
1006 An
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
1011 A
1012 .Vt u_int32_t
1013 containing the optimal block size when reading or writing this file's data.
1014 .
1015 .It ATTR_FILE_CLUMPSIZE
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.
1021 This value applies to the data fork.
1022 .
1023 .It ATTR_FILE_DEVTYPE
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
1032 .Xr stat 2 .
1033 .
1034 .It ATTR_FILE_FILETYPE
1035 A
1036 .Vt u_int32_t
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
1043 .Vt u_int32_t
1044 containing the number of forks in the file.
1045 No built-in file systems on Mac OS X currently support forks other
1046 than the data and resource fork.
1047 .
1048 .It ATTR_FILE_FORKLIST
1049 An
1050 .Vt attrreference
1051 structure containing a list of named forks of the file.
1052 No built-in file systems on Mac OS X currently support forks
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
1069 array for the data fork.
1070 The array contains eight
1071 .Vt diskextent
1072 structures which represent the first
1073 eight extents of the fork.
1074 .Pp
1075 This attributes exists for compatibility reasons.
1076 New clients should not use this attribute.
1077 Rather, they should use the
1078 .Dv F_LOG2PHYS
1079 command in
1080 .Xr fcntl 2 .
1081 .Pp
1082 .
1083 In current implementations the value may not be entirely accurate for
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
1099 array for the resource fork.
1100 The array contains eight
1101 .Vt diskextent
1102 structures which represent the first
1103 eight extents of the fork.
1104 .Pp
1105 See also
1106 .Dv ATTR_FILE_DATAEXTENTS .
1107 .
1108 .El
1109 .
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 .
1116 .Sh FORK ATTRIBUTES
1117 .
1118 Fork attributes relate to the actual data in the file,
1119 which can be held in multiple named contiguous ranges, or forks.
1120 These cannot be used if the FSOPT_ATTR_CMN_EXTENDED is given.
1121 The following fork attributes are defined.
1122 .
1123 .Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP
1124 .
1125 .It ATTR_FORK_TOTALSIZE
1126 Deprecated.
1127 An
1128 .Vt off_t
1129 containing the length of the fork in bytes (the logical size).
1130 .
1131 .It ATTR_FORK_ALLOCSIZE
1132 Deprecated.
1133 An
1134 .Vt off_t
1135 containing a count of the bytes on disk used by the fork (the physical size).
1136 .
1137 .It ATTR_FORK_RESERVED
1138 Reserved.
1139 You must set this to 0.
1140 .
1141 .El
1142 .Pp
1143 .
1144 Fork attributes are deprecated and all bits are reserved.
1145 They are not properly implemented by any current Mac OS X
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.
1149 .
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 .
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 .
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 .
1225 .El
1226 .
1227 .Sh VOLUME CAPABILITIES
1228 .
1229 .\" vol_capabilities_attr_t
1230 .
1231 Not all volumes support all features.
1232 The
1233 .Dv ATTR_VOL_CAPABILITIES
1234 attribute returns a
1235 .Vt vol_capabilities_attr_t
1236 structure (shown below) that indicates which features are supported by the volume.
1237 .
1238 .Bd -literal
1239 typedef u_int32_t vol_capabilities_set_t[4];
1240 .Pp
1241 .
1242 #define VOL_CAPABILITIES_FORMAT 0
1243 #define VOL_CAPABILITIES_INTERFACES 1
1244 #define VOL_CAPABILITIES_RESERVED1 2
1245 #define VOL_CAPABILITIES_RESERVED2 3
1246 .Pp
1247 .
1248 typedef struct vol_capabilities_attr {
1249 vol_capabilities_set_t capabilities;
1250 vol_capabilities_set_t valid;
1251 } vol_capabilities_attr_t;
1252 .Ed
1253 .Pp
1254 .
1255 The structure contains two fields,
1256 .Fa capabilities
1257 and
1258 .Fa valid .
1259 Each consists of an array of four elements.
1260 The arrays are indexed by the following values.
1261 .
1262 .Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS
1263 .
1264 .It VOL_CAPABILITIES_FORMAT
1265 This element contains information about the volume format.
1266 See
1267 .Dv VOL_CAP_FMT_PERSISTENTOBJECTIDS
1268 and so on, below.
1269 .
1270 .It VOL_CAPABILITIES_INTERFACES
1271 This element contains information about which optional functions are
1272 supported by the volume format implementation.
1273 See
1274 .Dv VOL_CAP_INT_SEARCHFS
1275 and so on, below.
1276 .
1277 .It VOL_CAPABILITIES_RESERVED1
1278 Reserved.
1279 A file system implementation should set this element to zero.
1280 A client program should ignore this element.
1281 .
1282 .It VOL_CAPABILITIES_RESERVED2
1283 Reserved.
1284 A file system implementation should set this element to zero.
1285 A client program should ignore this element.
1286 .
1287 .El
1288 .Pp
1289 .
1290 The
1291 .Fa valid
1292 field contains bit sets that indicate which flags are known to the volume format
1293 implementation.
1294 Each bit indicates whether the contents of the corresponding bit in the
1295 .Fa capabilities
1296 field is valid.
1297 .Pp
1298 .
1299 The
1300 .Fa capabilities
1301 field contains bit sets that indicate whether a particular feature is implemented
1302 by this volume format.
1303 .Pp
1304 .
1305 The following bits are defined in the first element (indexed by
1306 .Dv VOL_CAPABILITIES_FORMAT )
1307 of the
1308 .Fa capabilities
1309 and
1310 .Fa valid
1311 fields of the
1312 .Vt vol_capabilities_attr_t
1313 structure.
1314 .
1315 .Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS
1316 .
1317 .It VOL_CAP_FMT_PERSISTENTOBJECTIDS
1318 If this bit is set the volume format supports persistent object identifiers
1319 and can look up file system objects by their IDs.
1320 See
1321 .Dv ATTR_CMN_OBJPERMANENTID
1322 for details about how to obtain these identifiers.
1323 .
1324 .It VOL_CAP_FMT_SYMBOLICLINKS
1325 If this bit is set the volume format supports symbolic links.
1326 .
1327 .It VOL_CAP_FMT_HARDLINKS
1328 If this bit is set the volume format supports hard links.
1329 .
1330 .It VOL_CAP_FMT_JOURNAL
1331 If this bit is set the volume format supports a journal used to
1332 speed recovery in case of unplanned restart (such as a power outage
1333 or crash).
1334 This does not necessarily mean the volume is actively using a journal.
1335 .Pp
1336 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1337 .
1338 .It VOL_CAP_FMT_JOURNAL_ACTIVE
1339 If this bit is set the volume is currently using a journal for
1340 speedy recovery after an unplanned restart.
1341 This bit can be set only if
1342 .Dv VOL_CAP_FMT_JOURNAL
1343 is also set.
1344 .Pp
1345 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1346 .
1347 .It VOL_CAP_FMT_NO_ROOT_TIMES
1348 If this bit is set the volume format does not store reliable times for
1349 the root directory, so you should not depend on them to detect changes,
1350 identify volumes across unmount/mount, and so on.
1351 .Pp
1352 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1353 .
1354 .It VOL_CAP_FMT_SPARSE_FILES
1355 If this bit is set the volume format supports sparse files,
1356 that is, files which can have 'holes' that have never been written
1357 to, and thus do not consume space on disk.
1358 A sparse file may have an allocated size on disk that is less than its logical length (that is,
1359 .Dv ATTR_FILE_ALLOCSIZE
1360 <
1361 .Dv ATTR_FILE_TOTALSIZE ).
1362 .
1363 .Pp
1364 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1365 .
1366 .It VOL_CAP_FMT_ZERO_RUNS
1367 For security reasons, parts of a file (runs) that have never been
1368 written to must appear to contain zeroes.
1369 When this bit is set, the volume keeps track of allocated but unwritten
1370 runs of a file so that it can substitute zeroes without actually
1371 writing zeroes to the media.
1372 This provides performance similar to sparse files, but not the space savings.
1373 .Pp
1374 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1375 .
1376 .It VOL_CAP_FMT_CASE_SENSITIVE
1377 If this bit is set the volume format treats upper and lower case
1378 characters in file and directory names as different.
1379 Otherwise an upper case character is equivalent to a lower case character,
1380 and you can't have two names that differ solely in the case of
1381 the characters.
1382 .Pp
1383 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1384 .
1385 .It VOL_CAP_FMT_CASE_PRESERVING
1386 If this bit is set the volume format preserves the case of
1387 file and directory names.
1388 Otherwise the volume may change the case of some characters
1389 (typically making them all upper or all lower case).
1390 A volume that sets
1391 .Dv VOL_CAP_FMT_CASE_SENSITIVE
1392 must also set
1393 .Dv VOL_CAP_FMT_CASE_PRESERVING .
1394 .Pp
1395 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1396 .
1397 .It VOL_CAP_FMT_FAST_STATFS
1398 This bit is used as a hint to upper layers to
1399 indicate that
1400 .Xr statfs 2
1401 is fast enough that its results need not be cached by the caller.
1402 A volume format implementation that caches the
1403 .Xr statfs 2
1404 information in memory should set this bit.
1405 An implementation that must always read from disk or always perform a network
1406 transaction to satisfy
1407 .Xr statfs 2
1408 should not set this bit.
1409 .Pp
1410 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1411 .
1412 .It VOL_CAP_FMT_2TB_FILESIZE
1413 If this bit is set the volume format supports file sizes larger
1414 than 4GB, and potentially up to 2TB; it does not indicate
1415 whether the file system supports files larger than that.
1416 .Pp
1417 Introduced with Darwin 8.0 (Mac OS X version 10.4).
1418 .
1419 .It VOL_CAP_FMT_OPENDENYMODES
1420 If this bit is set, the volume format supports open deny modes
1421 (e.g., "open for read write, deny write").
1422 .
1423 .It VOL_CAP_FMT_HIDDEN_FILES
1424 If this bit is set, the volume format supports the
1425 .Dv UF_HIDDEN
1426 file flag, and the
1427 .Dv UF_HIDDEN
1428 flag is mapped to that volume's native "hidden" or "invisible"
1429 bit (e.g., the invisible bit from the Finder Info extended attribute).
1430 .
1431 .It VOL_CAP_FMT_PATH_FROM_ID
1432 If this bit is set, the volume format supports the ability to derive a pathname
1433 to the root of the file system given only the ID of an object. This also
1434 implies that object IDs on this file system are persistent and not recycled.
1435 Most file systems will not support this capability.
1436 .
1437 .It VOL_CAP_FMT_NO_VOLUME_SIZES
1438 If this bit is set the volume format does not support
1439 determining values for total data blocks, available blocks, or free blocks, as in
1440 .Fa f_blocks,
1441 .Fa f_bavail,
1442 and
1443 .Fa f_bfree
1444 in the
1445 .Fa struct statfs
1446 returned by
1447 .Xr statfs 2 .
1448 Historically, those values were set to 0xFFFFFFFF for volumes
1449 that did not support them.
1450 .Pp
1451 Introduced with Darwin 10.0 (Mac OS X version 10.6).
1452 .
1453 .It VOL_CAP_FMT_64BIT_OBJECT_IDS
1454 If this bit is set, the volume format uses object IDs that are 64-bit.
1455 This means that ATTR_CMN_FILEID and ATTR_CMN_PARENTID are the primary means of
1456 obtaining object IDs from this volume. The values returned by ATTR_CMN_OBJID,
1457 ATTR_CMN_OBJPERMANENTID, and ATTR_CMN_PAROBJID can be interpreted as 64-bit
1458 object IDs instead of fsobj_id_t.
1459 .
1460 .It VOL_CAP_FMT_NO_IMMUTABLE_FILES
1461 If this bit is set, the volume format does not support setting the UF_IMMUTABLE
1462 flag.
1463 See ATTR_CMN_FLAGS for more details.
1464 .It VOL_CAP_FMT_NO_PERMISSIONS
1465 If this bit is set, the volume format does not support setting file
1466 permissions.
1467 See ATTR_CMN_USERACCESS for more details.
1468 .It VOL_CAP_FMT_SHARED_SPACE
1469 If this bit is set, the volume format supports having multiple logical filesystems
1470 in a single "partition" which share space.
1471 .It VOL_CAP_FMT_VOL_GROUPS
1472 If this bit is set, the volume format supports having multiple logical filesystems
1473 which may be mounted and unmounted together and may present common filesystem
1474 identifier information.
1475 .
1476 .
1477 .El
1478 .Pp
1479 .
1480 The following bits are defined in the second element (indexed by
1481 .Dv VOL_CAPABILITIES_INTERFACES )
1482 of the
1483 .Fa capabilities
1484 and
1485 .Fa valid
1486 fields of the
1487 .Vt vol_capabilities_attr_t
1488 structure.
1489 .
1490 .Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS
1491 .
1492 .It VOL_CAP_INT_SEARCHFS
1493 If this bit is set the volume format implementation supports
1494 .Xr searchfs 2 .
1495 .
1496 .It VOL_CAP_INT_ATTRLIST
1497 If this bit is set the volume format implementation supports
1498 .Fn getattrlist
1499 and
1500 .Xr setattrlist 2 .
1501 .
1502 .It VOL_CAP_INT_NFSEXPORT
1503 If this bit is set the volume format implementation allows this volume to be exported via NFS.
1504 .
1505 .It VOL_CAP_INT_READDIRATTR
1506 If this bit is set the volume format implementation supports
1507 .Xr getdirentriesattr 2 .
1508 .
1509 .It VOL_CAP_INT_EXCHANGEDATA
1510 If this bit is set the volume format implementation supports
1511 .Xr exchangedata 2 .
1512 .Pp
1513 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1514 .
1515 .It VOL_CAP_INT_COPYFILE
1516 If this bit is set the volume format implementation supports the (private and undocumented)
1517 copyfile() function.
1518 (This is not the
1519 .Xr copyfile 3
1520 function.)
1521 .Pp
1522 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1523 .
1524 .It VOL_CAP_INT_ALLOCATE
1525 If this bit is set the volume format implementation supports the
1526 .Dv F_PREALLOCATE
1527 selector of
1528 .Xr fcntl 2 .
1529 .Pp
1530 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1531 .
1532 .It VOL_CAP_INT_VOL_RENAME
1533 If this bit is set the volume format implementation allows you to
1534 modify the volume name using
1535 .Xr setattrlist 2 .
1536 .Pp
1537 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1538 .
1539 .It VOL_CAP_INT_ADVLOCK
1540 If this bit is set the volume format implementation supports
1541 advisory locking, that is, the
1542 .Dv F_GETLK ,
1543 .Dv F_SETLK ,
1544 and
1545 .Dv F_SETLKW
1546 selectors to
1547 .Xr fcntl 2 .
1548 .Pp
1549 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1550 .
1551 .It VOL_CAP_INT_FLOCK
1552 If this bit is set the volume format implementation supports
1553 whole file locks.
1554 This includes
1555 .Xr flock 2
1556 and the
1557 .Dv O_EXLOCK
1558 and
1559 .Dv O_SHLOCK
1560 flags to
1561 .Xr open 2 .
1562 .Pp
1563 Introduced with Darwin 7.0 (Mac OS X version 10.3).
1564 .
1565 .It VOL_CAP_INT_EXTENDED_SECURITY
1566 If this bit is set the volume format implementation supports
1567 extended security controls (ACLs).
1568 .Pp
1569 Introduced with Darwin 8.0 (Mac OS X version 10.4).
1570 .
1571 .It VOL_CAP_INT_USERACCESS
1572 If this bit is set the volume format implementation supports the
1573 ATTR_CMN_USERACCESS attribute.
1574 .Pp
1575 Introduced with Darwin 8.0 (Mac OS X version 10.4).
1576 .
1577 .It VOL_CAP_INT_MANLOCK
1578 If this bit is set, the volume format implementation supports
1579 AFP-style mandatory byte range locks via
1580 .Xr ioctl 2 .
1581 .
1582 .It VOL_CAP_INT_EXTENDED_ATTR
1583 If this bit is set, the volume format implementation supports
1584 native extended attributes (see
1585 .Xr setxattr 2 Ns ).
1586 .
1587 .It VOL_CAP_INT_CLONE
1588 If this bit is set, the file system supports cloning files and directories.
1589 See
1590 .Xr clonefileat 2
1591 for more details.
1592 .
1593 .It VOL_CAP_INT_SNAPSHOT
1594 If this bit is set, the file system supports snapshots.
1595 See
1596 .Xr fs_snapshot_create 2
1597 for more details.
1598 .
1599 .It VOL_CAP_INT_NAMEDSTREAMS
1600 If this bit is set, the volume format implementation supports
1601 native named streams.
1602 .
1603 .It VOL_CAP_INT_RENAME_SWAP
1604 If this bit is set, the file system supports swapping file system
1605 objects. See
1606 .Xr rename 2
1607 for more details.
1608 .
1609 .It VOL_CAP_INT_RENAME_EXCL
1610 If this bit is set, the file system supports an exclusive rename
1611 operation. See
1612 .Xr rename 2
1613 for more details.
1614 .
1615 .It VOL_CAP_INT_RENAME_OPENFAIL
1616 If this bit is set, the file system may fail a rename operation
1617 of a directory if one of its descendents is open.
1618 See
1619 .Xr rename 2
1620 for more details.
1621 .
1622 .El
1623 .Pp
1624 .
1625 .\" vol_attributes_attr_t
1626 .
1627 A volume can also report which attributes it supports.
1628 This information is returned by the
1629 .Dv ATTR_VOL_ATTRIBUTES
1630 attribute, which returns a
1631 .Vt vol_attributes_attr_t
1632 structure (shown below).
1633 .
1634 .Bd -literal
1635 typedef struct attribute_set {
1636 attrgroup_t commonattr; /* common attribute group */
1637 attrgroup_t volattr; /* volume attribute group */
1638 attrgroup_t dirattr; /* directory attribute group */
1639 attrgroup_t fileattr; /* file attribute group */
1640 attrgroup_t forkattr; /* fork attribute group */
1641 } attribute_set_t;
1642 .Pp
1643 .
1644 typedef struct vol_attributes_attr {
1645 attribute_set_t validattr;
1646 attribute_set_t nativeattr;
1647 } vol_attributes_attr_t;
1648 .Ed
1649 .Pp
1650 .
1651 The
1652 .Fa validattr
1653 field consists of a number of bit sets that indicate whether an attribute is
1654 supported by the volume format implementation.
1655 The
1656 .Fa nativeattr
1657 is similar except that the bit sets indicate whether an attribute is supported
1658 natively by the volume format.
1659 An attribute is supported natively if the volume format implementation does not have to do
1660 any complex conversions to access the attribute.
1661 For example, a volume format might support persistent object identifiers, but
1662 doing so requires a complex table lookup that is not part of the core volume
1663 format.
1664 In that case, the
1665 .Dv ATTR_VOL_ATTRIBUTES
1666 attribute would return
1667 .Dv ATTR_CMN_OBJPERMANENTID
1668 set in the
1669 .Fa validattr
1670 field of the
1671 .Vt vol_attributes_attr_t ,
1672 but not in the
1673 .Fa nativeattr
1674 field.
1675 .
1676 .Sh RETURN VALUES
1677 Upon successful completion a value of 0 is returned.
1678 Otherwise, a value of -1 is returned and
1679 .Va errno
1680 is set to indicate the error.
1681 .
1682 .Sh COMPATIBILITY
1683 Not all volumes support
1684 .Fn getattrlist .
1685 The best way to test whether a volume supports this function is to
1686 simply call it and check the error result.
1687 .Fn getattrlist
1688 will return
1689 .Dv ENOTSUP
1690 if it is not supported on a particular volume.
1691 .Pp
1692 .
1693 The
1694 .Fn getattrlist
1695 function has been undocumented for more than two years.
1696 In that time a number of volume format implementations have been created without
1697 a proper specification for the behaviour of this routine.
1698 You may encounter volume format implementations with slightly different
1699 behaviour than what is described here.
1700 Your program is expected to be tolerant of this variant behaviour.
1701 .Pp
1702 .
1703 If you're implementing a volume format that supports
1704 .Fn getattrlist ,
1705 you should be careful to support the behaviour specified by this document.
1706 .
1707 .Sh ERRORS
1708 .Fn getattrlist
1709 and
1710 .Fn fgetattrlist
1711 will fail if:
1712 .Bl -tag -width Er
1713 .
1714 .It Bq Er ENOTSUP
1715 The volume does not support the query.
1716 .
1717 .It Bq Er ENOTDIR
1718 A component of the path prefix for
1719 .Fn getattrlist
1720 is not a directory.
1721 .
1722 .It Bq Er ENAMETOOLONG
1723 A component of a path name for
1724 .Fn getattrlist
1725 exceeded
1726 .Dv NAME_MAX
1727 characters, or an entire path name exceeded
1728 .Dv PATH_MAX
1729 characters.
1730 .
1731 .It Bq Er ENOENT
1732 The file system object for
1733 .Fn getattrlist
1734 does not exist.
1735 .
1736 .It Bq Er EBADF
1737 The file descriptor argument for
1738 .Fn fgetattrlist
1739 is not a valid file descriptor.
1740 .
1741 .It Bq Er EACCES
1742 Search permission is denied for a component of the path prefix for
1743 .Fn getattrlist .
1744 .
1745 .It Bq Er ELOOP
1746 Too many symbolic links were encountered in translating the pathname
1747 for
1748 .Fn getattrlist .
1749 .
1750 .It Bq Er EFAULT
1751 .Fa path ,
1752 .Fa attrList
1753 or
1754 .Em attrBuf
1755 points to an invalid address.
1756 .
1757 .It Bq Er ERANGE
1758 .Fa attrBufSize
1759 is too small to hold a u_int32_t.
1760 .
1761 .It Bq Er EINVAL
1762 The
1763 .Fa bitmapcount
1764 field of
1765 .Fa attrList
1766 is not
1767 .Dv ATTR_BIT_MAP_COUNT .
1768 .
1769 .It Bq Er EINVAL
1770 You requested an invalid attribute.
1771 .
1772 .It Bq Er EINVAL
1773 You requested an attribute that is not supported for this file system object.
1774 .
1775 .It Bq Er EINVAL
1776 You requested volume attributes and directory or file attributes.
1777 .
1778 .It Bq Er EINVAL
1779 You requested volume attributes but
1780 .Fa path
1781 does not reference the root of the volume.
1782 .
1783 .It Bq Er EROFS
1784 The volume is read-only but must be modified in order to return this attribute.
1785 .
1786 .It Bq Er EIO
1787 An I/O error occurred while reading from or writing to the file system.
1788 .El
1789 .Pp
1790 In addition to the errors returned by the
1791 .Fn getattrlist ,
1792 the
1793 .Fn getattrlistat
1794 function may fail if:
1795 .Bl -tag -width Er
1796 .It Bq Er EBADF
1797 The
1798 .Fa path
1799 argument does not specify an absolute path and the
1800 .Fa fd
1801 argument is neither
1802 .Dv AT_FDCWD
1803 nor a valid file descriptor open for searching.
1804 .It Bq Er ENOTDIR
1805 The
1806 .Fa path
1807 argument is not an absolute path and
1808 .Fa fd
1809 is neither
1810 .Dv AT_FDCWD
1811 nor a file descriptor associated with a directory.
1812 .El
1813 .Pp
1814 .
1815 .Sh CAVEATS
1816 .
1817 If you request any volume attributes, you must set
1818 .Dv ATTR_VOL_INFO
1819 in the
1820 .Fa volattr
1821 field, even though it generates no result in the attribute buffer.
1822 .Pp
1823 .
1824 The order that attributes are stored in the attribute buffer almost
1825 invariably matches the order of attribute mask bit values.
1826 For example,
1827 .Dv ATTR_CMN_NAME
1828 (0x00000001) comes before
1829 .Dv ATTR_CMN_DEVID
1830 (0x00000002) because its value is smaller.
1831 When ordering attributes, you should always use the order in which they
1832 are described above.
1833 .Pp
1834 .
1835 The
1836 .Vt timespec
1837 structure is 64-bits (two 32-bit elements) in 32-bit code, and
1838 128-bits (two 64-bit elements) in 64-bit code; however, it is aligned
1839 on a 4-byte (32-bit) boundary, even in 64-bit code.
1840 .Pp
1841 If you use a structure
1842 for the attribute data, it must be correctly packed and aligned (see
1843 examples).
1844 .Pp
1845 .
1846 Inconsistent behavior may be observed when the ATTR_CMN_FULLPATH attribute is requested on
1847 hard-linked items, particularly when the file system does not support ATTR_CMN_PARENTID
1848 natively. Callers should be aware of this when requesting the full path of a hard-linked item, especially
1849 if the full path crosses mount points.
1850 .Pp
1851 .
1852 For more caveats, see also the compatibility notes above.
1853 .
1854 .Sh EXAMPLES
1855 .
1856 The following code prints the file type and creator of a file,
1857 assuming that the volume supports the required attributes.
1858 .
1859 .Bd -literal
1860 #include <assert.h>
1861 #include <stdio.h>
1862 #include <string.h>
1863 #include <sys/attr.h>
1864 #include <sys/errno.h>
1865 #include <unistd.h>
1866 #include <sys/vnode.h>
1867 .Pp
1868 .
1869 typedef struct attrlist attrlist_t;
1870 .Pp
1871 .
1872 struct FInfoAttrBuf {
1873 u_int32_t length;
1874 fsobj_type_t objType;
1875 char finderInfo[32];
1876 } __attribute__((aligned(4), packed));
1877 typedef struct FInfoAttrBuf FInfoAttrBuf;
1878 .Pp
1879 .
1880 static int FInfoDemo(const char *path)
1881 {
1882 int err;
1883 attrlist_t attrList;
1884 FInfoAttrBuf attrBuf;
1885 .Pp
1886 .
1887 memset(&attrList, 0, sizeof(attrList));
1888 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
1889 attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
1890 .Pp
1891
1892 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0);
1893 if (err != 0) {
1894 err = errno;
1895 }
1896 .Pp
1897
1898 if (err == 0) {
1899 assert(attrBuf.length == sizeof(attrBuf));
1900 .Pp
1901
1902 printf("Finder information for %s:\en", path);
1903 switch (attrBuf.objType) {
1904 case VREG:
1905 printf("file type = '%.4s'\en", &attrBuf.finderInfo[0]);
1906 printf("file creator = '%.4s'\en", &attrBuf.finderInfo[4]);
1907 break;
1908 case VDIR:
1909 printf("directory\en");
1910 break;
1911 default:
1912 printf("other object type, %d\en", attrBuf.objType);
1913 break;
1914 }
1915 }
1916 .Pp
1917 .
1918 return err;
1919 }
1920 .Ed
1921 .Pp
1922 .
1923 The following code is an alternative implementation that uses nested structures
1924 to group the related attributes.
1925 .
1926 .Bd -literal
1927 #include <assert.h>
1928 #include <stdio.h>
1929 #include <stddef.h>
1930 #include <string.h>
1931 #include <sys/attr.h>
1932 #include <sys/errno.h>
1933 #include <unistd.h>
1934 #include <sys/vnode.h>
1935 .Pp
1936 .
1937 typedef struct attrlist attrlist_t;
1938 .Pp
1939 .
1940 struct FInfo2CommonAttrBuf {
1941 fsobj_type_t objType;
1942 char finderInfo[32];
1943 } __attribute__((aligned(4), packed));
1944 typedef struct FInfo2CommonAttrBuf FInfo2CommonAttrBuf;
1945 .Pp
1946 .
1947 struct FInfo2AttrBuf {
1948 u_int32_t length;
1949 FInfo2CommonAttrBuf common;
1950 } __attribute__((aligned(4), packed));;
1951 typedef struct FInfo2AttrBuf FInfo2AttrBuf;
1952 .Pp
1953 .
1954 static int FInfo2Demo(const char *path)
1955 {
1956 int err;
1957 attrlist_t attrList;
1958 FInfo2AttrBuf attrBuf;
1959 .Pp
1960 .
1961 memset(&attrList, 0, sizeof(attrList));
1962 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
1963 attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
1964 .Pp
1965 .
1966 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0);
1967 if (err != 0) {
1968 err = errno;
1969 }
1970 .Pp
1971 .
1972 if (err == 0) {
1973 assert(attrBuf.length == sizeof(attrBuf));
1974 .Pp
1975 .
1976 printf("Finder information for %s:\en", path);
1977 switch (attrBuf.common.objType) {
1978 case VREG:
1979 printf(
1980 "file type = '%.4s'\en",
1981 &attrBuf.common.finderInfo[0]
1982 );
1983 printf(
1984 "file creator = '%.4s'\en",
1985 &attrBuf.common.finderInfo[4]
1986 );
1987 break;
1988 case VDIR:
1989 printf("directory\en");
1990 break;
1991 default:
1992 printf(
1993 "other object type, %d\en",
1994 attrBuf.common.objType
1995 );
1996 break;
1997 }
1998 }
1999 .Pp
2000 .
2001 return err;
2002 }
2003 .Ed
2004 .Pp
2005 .
2006 The following example shows how to deal with variable length attributes.
2007 It assumes that the volume specified by
2008 .Fa path
2009 supports the necessary attributes.
2010 .
2011 .Bd -literal
2012 #include <assert.h>
2013 #include <stdio.h>
2014 #include <stddef.h>
2015 #include <string.h>
2016 #include <sys/attr.h>
2017 #include <sys/errno.h>
2018 #include <unistd.h>
2019 #include <sys/vnode.h>
2020 .Pp
2021 .
2022 typedef struct attrlist attrlist_t;
2023 .Pp
2024 .
2025 struct VolAttrBuf {
2026 u_int32_t length;
2027 u_int32_t fileCount;
2028 u_int32_t dirCount;
2029 attrreference_t mountPointRef;
2030 attrreference_t volNameRef;
2031 char mountPointSpace[MAXPATHLEN];
2032 char volNameSpace[MAXPATHLEN];
2033 } __attribute__((aligned(4), packed));
2034 typedef struct VolAttrBuf VolAttrBuf;
2035 .Pp
2036 .
2037 static int VolDemo(const char *path)
2038 {
2039 int err;
2040 attrlist_t attrList;
2041 VolAttrBuf attrBuf;
2042 .Pp
2043 .
2044 memset(&attrList, 0, sizeof(attrList));
2045 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
2046 attrList.volattr = ATTR_VOL_INFO
2047 | ATTR_VOL_FILECOUNT
2048 | ATTR_VOL_DIRCOUNT
2049 | ATTR_VOL_MOUNTPOINT
2050 | ATTR_VOL_NAME;
2051 .Pp
2052
2053 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0);
2054 if (err != 0) {
2055 err = errno;
2056 }
2057 .Pp
2058
2059 if (err == 0) {
2060 assert(attrBuf.length > offsetof(VolAttrBuf, mountPointSpace));
2061 assert(attrBuf.length <= sizeof(attrBuf));
2062 .Pp
2063
2064 printf("Volume information for %s:\en", path);
2065 printf("ATTR_VOL_FILECOUNT: %u\en", attrBuf.fileCount);
2066 printf("ATTR_VOL_DIRCOUNT: %u\en", attrBuf.dirCount);
2067 printf(
2068 "ATTR_VOL_MOUNTPOINT: %.*s\en",
2069 (int) attrBuf.mountPointRef.attr_length,
2070 ( ((char *) &attrBuf.mountPointRef)
2071 + attrBuf.mountPointRef.attr_dataoffset )
2072 );
2073 printf(
2074 "ATTR_VOL_NAME: %.*s\en",
2075 (int) attrBuf.volNameRef.attr_length,
2076 ( ((char *) &attrBuf.volNameRef)
2077 + attrBuf.volNameRef.attr_dataoffset )
2078 );
2079 }
2080 .Pp
2081 .
2082 return err;
2083 }
2084 .Ed
2085 .Pp
2086 The following sample demonstrates the need to use packing and alignment
2087 controls; without the attribute, in 64-bit code, the fields of the structure are not
2088 placed at the locations that the kernel expects.
2089 .
2090 .Bd -literal
2091 #include <stdio.h>
2092 #include <stdlib.h>
2093 #include <unistd.h>
2094 #include <string.h>
2095 #include <err.h>
2096 #include <time.h>
2097 #include <sys/attr.h>
2098 .Pp
2099 /* The alignment and packing attribute is necessary in 64-bit code */
2100 struct AttrListTimes {
2101 u_int32_t length;
2102 struct timespec st_crtime;
2103 struct timespec st_modtime;
2104 } __attribute__((aligned(4), packed));
2105 .Pp
2106 main(int argc, char **argv)
2107 {
2108 int rv;
2109 int i;
2110 .Pp
2111 for (i = 1; i < argc; i++) {
2112 struct attrlist attrList;
2113 struct AttrListTimes myStat = {0};
2114 char *path = argv[i];
2115 .Pp
2116 memset(&attrList, 0, sizeof(attrList));
2117 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
2118 attrList.commonattr = ATTR_CMN_CRTIME |
2119 ATTR_CMN_MODTIME;
2120 .Pp
2121 rv = getattrlist(path, &attrList, &myStat, sizeof(myStat), 0);
2122 .Pp
2123 if (rv == -1) {
2124 warn("getattrlist(%s)", path);
2125 continue;
2126 }
2127 printf("%s: Modification time = %s", argv[i], ctime(&myStat.st_modtime.tv_sec));
2128 }
2129 return 0;
2130 }
2131 .Ed
2132 .Pp
2133 The getLinkIDInfo() function determines if ATTR_CMNEXT_LINKID and ATTR_CMN_OBJID
2134 are valid to use on the file system specified by path.
2135 .
2136 .Bd -literal
2137 int getLinkIDInfo(const char *path, bool *cmnExtLinkIDValid, bool *cmnObjIDValid)
2138 {
2139 int result;
2140 struct statfs statfsBuf;
2141 struct attrlist attrList;
2142 struct volAttrsBuf {
2143 u_int32_t length;
2144 vol_capabilities_attr_t capabilities;
2145 vol_attributes_attr_t attributes;
2146 } __attribute__((aligned(4), packed));
2147 struct volAttrsBuf volAttrs;
2148 .Pp
2149 memset(&attrList, 0, sizeof(attrList));
2150 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
2151 attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES | ATTR_VOL_ATTRIBUTES;
2152 // get the file system's mount point path for the input path
2153 result = statfs(path, &statfsBuf);
2154 if ( result == 0 ) {
2155 // get the supported capabilities and attributes
2156 result = getattrlist(statfsBuf.f_mntonname, &attrList, &volAttrs, sizeof(volAttrs), FSOPT_ATTR_CMN_EXTENDED);
2157 if ( result == 0 ) {
2158 if ( volAttrs.attributes.validattr.forkattr & ATTR_CMNEXT_LINKID ) {
2159 // ATTR_CMNEXT_LINKID is available; do not use ATTR_CMN_OBJID
2160 *cmnExtLinkIDValid = true;
2161 *cmnObjIDValid = false;
2162 }
2163 else {
2164 // ATTR_CMNEXT_LINKID is not available
2165 cmnExtLinkIDValid = false;
2166 // ATTR_CMN_OBJID can only be used if the file system does not use 64-bit object IDs
2167 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) ) {
2168 *cmnObjIDValid = false;
2169 }
2170 else {
2171 *cmnObjIDValid = true;
2172 }
2173 }
2174 }
2175 }
2176 if ( result != 0 ) {
2177 *cmnExtLinkIDValid = *cmnObjIDValid = false;
2178 }
2179 return result;
2180 }
2181 .Ed
2182 .Pp
2183 .
2184 .Sh SEE ALSO
2185 .
2186 .Xr access 2 ,
2187 .Xr chflags 2 ,
2188 .Xr exchangedata 2 ,
2189 .Xr fcntl 2 ,
2190 .Xr getattrlistbulk 2 ,
2191 .Xr mount 2 ,
2192 .Xr searchfs 2 ,
2193 .Xr setattrlist 2 ,
2194 .Xr stat 2 ,
2195 .Xr statfs 2
2196 .
2197 .Sh HISTORY
2198 A
2199 .Fn getattrlist
2200 function call appeared in Darwin 1.3.1 (Mac OS X version 10.0).
2201 The
2202 .Fn getattrlistat
2203 function call appeared in OS X 10.10 .