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