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 31, 2024 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_MOUNTEXTFLAGS 934A 935.Vt u_int32_t 936containing the volume extended mount flags. 937Equivalent to the 938.Fa f_flags_ext 939field of the 940.Vt statfs 941structure returned by 942.Xr statfs 2 . 943. 944.It ATTR_VOL_QUOTA_SIZE 945An 946.Vt off_t 947containing the maximum size of the volume in bytes. 948. 949.It ATTR_VOL_RESERVED_SIZE 950An 951.Vt off_t 952containing the minimum size of the volume in bytes. 953. 954.It ATTR_VOL_ATTRIBUTES 955A 956.Vt vol_attributes_attr_t 957structure describing the attributes supported by this volume. 958This structure is discussed below, along with volume capabilities. 959. 960.It ATTR_VOL_FSTYPENAME 961An 962.Vt attrreference 963structure containing the file system type name as a 964UTF-8 encoded, null terminated C string. 965The attribute data length will not be greater than 966.Dv MFSTYPENAMELEN . 967. 968.It ATTR_VOL_FSSUBTYPE 969A 970.Vt u_int32_t 971containing the file system sub-type. 972Equivalent to the 973.Fa f_fssubtype 974field of the 975.Vt statfs 976structure returned by 977.Xr statfs 2 . 978. 979.El 980. 981.Sh DIRECTORY ATTRIBUTES 982. 983The following directory attributes are defined. 984. 985.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP 986. 987.It ATTR_DIR_LINKCOUNT 988A 989.Vt u_int32_t 990containing the number of hard links to the directory; 991this does not include the historical "." and ".." entries. 992For file systems that do not support hard links to directories, 993this value will be 1. 994. 995.It ATTR_DIR_ENTRYCOUNT 996A 997.Vt u_int32_t 998containing the number of file system objects in the directory, not including 999any synthetic items. The historical "." and ".." entries are also 1000excluded from this count. 1001. 1002.It ATTR_DIR_MOUNTSTATUS 1003A 1004.Vt u_int32_t 1005containing flags describing what's mounted on the directory. 1006Currently the only flag defined is 1007.Dv DIR_MNTSTATUS_MNTPOINT, 1008which indicates that there is a file system mounted on this directory. 1009. 1010.It ATTR_DIR_ALLOCSIZE 1011An 1012.Vt off_t 1013containing the number of bytes on disk used by the directory 1014(the physical size). 1015. 1016.It ATTR_DIR_IOBLOCKSIZE 1017A 1018.Vt u_int32_t 1019containing the optimal block size when reading or writing data. 1020. 1021.It ATTR_DIR_DATALENGTH 1022An 1023.Vt off_t 1024containing the length of the directory in bytes (the logical size). 1025.El 1026. 1027.Pp 1028Requested directory attributes are not returned for file system objects that 1029are not directories. 1030. 1031.Sh FILE ATTRIBUTES 1032. 1033The following file attributes are defined. 1034. 1035.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP 1036. 1037.It ATTR_FILE_LINKCOUNT 1038A 1039.Vt u_int32_t 1040containing the number of hard links to this file. 1041Equivalent to the 1042.Fa st_nlink 1043field of the 1044.Vt stat 1045structure returned by 1046.Xr stat 2 . 1047. 1048.It ATTR_FILE_TOTALSIZE 1049An 1050.Vt off_t 1051containing the total number of bytes in all forks of the file (the logical size). 1052. 1053.It ATTR_FILE_ALLOCSIZE 1054An 1055.Vt off_t 1056containing a count of the bytes on disk used by all of the file's forks (the physical size). 1057. 1058.It ATTR_FILE_IOBLOCKSIZE 1059A 1060.Vt u_int32_t 1061containing the optimal block size when reading or writing this file's data. 1062. 1063.It ATTR_FILE_CLUMPSIZE 1064A 1065.Vt u_int32_t 1066containing the allocation clump size for this file, in bytes. 1067As the file is extended, the file system will attempt to allocate 1068this much space each time in order to reduce fragmentation. 1069This value applies to the data fork. 1070. 1071.It ATTR_FILE_DEVTYPE 1072(read/write) A 1073.Vt u_int32_t 1074containing the device type for a special device file. 1075Equivalent to the 1076.Fa st_rdev 1077field of the 1078.Vt stat 1079structure returned by 1080.Xr stat 2 . 1081. 1082.It ATTR_FILE_FILETYPE 1083A 1084.Vt u_int32_t 1085that whose value is reserved. 1086Clients should ignore its value. 1087New volume format implementations should not support this attribute. 1088. 1089.It ATTR_FILE_FORKCOUNT 1090A 1091.Vt u_int32_t 1092containing the number of forks in the file. 1093No built-in file systems on Mac OS X currently support forks other 1094than the data and resource fork. 1095. 1096.It ATTR_FILE_FORKLIST 1097An 1098.Vt attrreference 1099structure containing a list of named forks of the file. 1100No built-in file systems on Mac OS X currently support forks 1101other than the data and resource fork. 1102Because of this, the structure of this attribute's value is not yet defined. 1103. 1104.It ATTR_FILE_DATALENGTH 1105An 1106.Vt off_t 1107containing the length of the data fork in bytes (the logical size). 1108. 1109.It ATTR_FILE_DATAALLOCSIZE 1110An 1111.Vt off_t 1112containing a count of the bytes on disk used by the data fork (the physical size). 1113. 1114.It ATTR_FILE_DATAEXTENTS 1115An 1116.Vt extentrecord 1117array for the data fork. 1118The array contains eight 1119.Vt diskextent 1120structures which represent the first 1121eight extents of the fork. 1122.Pp 1123This attributes exists for compatibility reasons. 1124New clients should not use this attribute. 1125Rather, they should use the 1126.Dv F_LOG2PHYS 1127command in 1128.Xr fcntl 2 . 1129.Pp 1130. 1131In current implementations the value may not be entirely accurate for 1132a variety of reasons. 1133. 1134.It ATTR_FILE_RSRCLENGTH 1135An 1136.Vt off_t 1137containing the length of the resource fork in bytes (the logical size). 1138. 1139.It ATTR_FILE_RSRCALLOCSIZE 1140An 1141.Vt off_t 1142containing a count of the bytes on disk used by the resource fork (the physical size). 1143. 1144.It ATTR_FILE_RSRCEXTENTS 1145An 1146.Vt extentrecord 1147array for the resource fork. 1148The array contains eight 1149.Vt diskextent 1150structures which represent the first 1151eight extents of the fork. 1152.Pp 1153See also 1154.Dv ATTR_FILE_DATAEXTENTS . 1155. 1156.El 1157. 1158.Pp 1159File attributes are used for any file system object that is not a directory, 1160not just ordinary files. 1161Requested file attributes are not returned for file system objects that 1162are directories. 1163. 1164.Sh FORK ATTRIBUTES 1165. 1166Fork attributes relate to the actual data in the file, 1167which can be held in multiple named contiguous ranges, or forks. 1168These cannot be used if the FSOPT_ATTR_CMN_EXTENDED is given. 1169The following fork attributes are defined. 1170. 1171.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP 1172. 1173.It ATTR_FORK_TOTALSIZE 1174Deprecated. 1175An 1176.Vt off_t 1177containing the length of the fork in bytes (the logical size). 1178. 1179.It ATTR_FORK_ALLOCSIZE 1180Deprecated. 1181An 1182.Vt off_t 1183containing a count of the bytes on disk used by the fork (the physical size). 1184. 1185.It ATTR_FORK_RESERVED 1186Reserved. 1187You must set this to 0. 1188. 1189.El 1190.Pp 1191. 1192Fork attributes are deprecated and all bits are reserved. 1193They are not properly implemented by any current Mac OS X 1194volume format implementation. 1195We strongly recommend that client programs do not request fork attributes. 1196If you are implementing a volume format, you should not support these attributes. 1197. 1198.Sh COMMON EXTENDED ATTRIBUTES 1199. 1200Common extended attributes are like common attributes except that they are set 1201in the forkattr field and can only be used if the FSOPT_ATTR_CMN_EXTENDED 1202option is given. Use of these attributes is mutually exclusive with the above 1203fork attributes. 1204. 1205.Bl -tag -width ATTR_CMNEXT_RECURSIVE_GENCOUNT 1206. 1207.It ATTR_CMNEXT_RELPATH 1208An 1209.Vt attrreference 1210structure containing the mount-relative path of 1211the file system object as 1212a UTF-8 encoded, null terminated C string. 1213The attribute data length will not be greater than 1214.Dv PATH_MAX. 1215Inconsistent behavior may be observed when this attribute is requested on 1216hard-linked items, particularly when the file system does not support 1217ATTR_CMN_PARENTID natively. Callers should be aware of this when requesting the 1218relative path of a hard-linked item. 1219. 1220.It ATTR_CMNEXT_PRIVATESIZE 1221An 1222.Vt off_t 1223containing the number of bytes that are \fBnot\fP trapped inside a clone 1224or snapshot, and which would be freed immediately if the file were deleted. 1225. 1226.It ATTR_CMNEXT_LINKID 1227A 1228.Vt u_int64_t 1229that uniquely identifies the file system object within a mounted volume for the 1230duration of its mount. 1231.Pp 1232On HFS+ and APFS volumes, the ATTR_CMNEXT_LINKID of a file system 1233object is distinct from the ATTR_CMNEXT_LINKID of any hard link to that file 1234system object. Although the ATTR_CMNEXT_LINKID of a file system object may appear 1235similar (in whole or in part) to its ATTR_CMN_FILEID (see description of 1236ATTR_CMN_FILEID above), \fBno relation between the two attributes should ever be implied.\fP 1237. 1238.It ATTR_CMNEXT_NOFIRMLINKPATH 1239An 1240.Vt attrreference 1241structure containing a path that does not have firmlinks of 1242the file system object as 1243a UTF-8 encoded, null terminated C string. 1244The attribute data length will not be greater than 1245.Dv PATH_MAX. 1246Inconsistent behavior may be observed when this attribute is requested on 1247hard-linked items, particularly when the file system does not support 1248ATTR_CMN_PARENTID natively. Callers should be aware of this when requesting the 1249canonical path of a hard-linked item. 1250.It ATTR_CMNEXT_REALDEVID 1251A 1252.Vt dev_t 1253containing the real device number of the device on which this 1254file system object's volume is mounted. 1255Equivalent to the 1256.Fa st_dev 1257field of the 1258.Vt stat 1259structure returned by 1260.Xr stat 2 . 1261. 1262.It ATTR_CMNEXT_REALFSID 1263An 1264.Vt fsid_t 1265structure containing the real file system identifier for the volume on which 1266the file system object resides. 1267Equivalent to the 1268.Fa f_fsid 1269field of the 1270.Vt statfs 1271structure returned by 1272.Xr statfs 2 . 1273. 1274.It ATTR_CMNEXT_CLONEID 1275A 1276.Vt u_int64_t 1277that uniquely identifies the data stream associated with the file 1278system object. Useful for finding which files are pure clones of each 1279other (as they will have the same clone-id). 1280. 1281.It ATTR_CMNEXT_EXT_FLAGS 1282A 1283.Vt u_int64_t 1284that contains additional flags with information about the file. The 1285flags are: 1286. 1287.Bl -tag -width EF_SHARES_ALL_BLOCKS 1288. 1289.It EF_MAY_SHARE_BLOCKS 1290If this bit is set then the file may share blocks with another file 1291(i.e. it may be a clone of another file). 1292. 1293.It EF_NO_XATTRS 1294If this bit is set then the file has no extended attributes. Useful 1295for avoiding a call to listxattr(). 1296. 1297.It EF_IS_SYNC_ROOT 1298If this bit is set the directory is a "sync root". This bit will 1299never be set for regular files. 1300. 1301.It EF_IS_PURGEABLE 1302If this bit is set the item is a "purgeable" item that can be deleted 1303by the file system when asked to free space. 1304. 1305.It EF_IS_SPARSE 1306If this bit is set the item has sparse regions. 1307. 1308.It EF_IS_SYNTHETIC 1309If this bit is set the item is a synthetic directory/symlink. 1310. 1311.It EF_SHARES_ALL_BLOCKS 1312If this bit is set then the file shares all of its blocks with another 1313file (i.e. it is a full clone of another file). For compatibility reasons, 1314EF_SHARES_ALL_BLOCKS means EF_MAY_SHARE_BLOCKS as well. 1315. 1316.El 1317. 1318.It ATTR_CMNEXT_RECURSIVE_GENCOUNT 1319A 1320.Vt u_int64_t 1321that represents the recursive generation count of a directory that has 1322been marked as maintain-dir-stats in an apfs file system. This 1323gencount is updated any time any child is modified (as part of the 1324contract that a maintain-dir-stats directory manages). If the 1325directory is not marked maintain-dir-stats, a zero is returned. 1326. 1327.It ATTR_CMNEXT_ATTRIBUTION_TAG 1328An optional 1329.Vt u_int64_t 1330id that represents the bundle id (owner) assoicated with the file 1331(zero means the file isn't attributed yet) 1332. 1333.It ATTR_CMNEXT_CLONE_REFCNT 1334A 1335.Vt u_int32_t 1336that represents the number of full clones 1337(each shares all of its blocks with this file). 1338. 1339.El 1340.Pp 1341. 1342.Sh VOLUME CAPABILITIES 1343. 1344.\" vol_capabilities_attr_t 1345. 1346Not all volumes support all features. 1347The 1348.Dv ATTR_VOL_CAPABILITIES 1349attribute returns a 1350.Vt vol_capabilities_attr_t 1351structure (shown below) that indicates which features are supported by the volume. 1352. 1353.Bd -literal 1354typedef u_int32_t vol_capabilities_set_t[4]; 1355.Pp 1356. 1357#define VOL_CAPABILITIES_FORMAT 0 1358#define VOL_CAPABILITIES_INTERFACES 1 1359#define VOL_CAPABILITIES_RESERVED1 2 1360#define VOL_CAPABILITIES_RESERVED2 3 1361.Pp 1362. 1363typedef struct vol_capabilities_attr { 1364 vol_capabilities_set_t capabilities; 1365 vol_capabilities_set_t valid; 1366} vol_capabilities_attr_t; 1367.Ed 1368.Pp 1369. 1370The structure contains two fields, 1371.Fa capabilities 1372and 1373.Fa valid . 1374Each consists of an array of four elements. 1375The arrays are indexed by the following values. 1376. 1377.Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS 1378. 1379.It VOL_CAPABILITIES_FORMAT 1380This element contains information about the volume format. 1381See 1382.Dv VOL_CAP_FMT_PERSISTENTOBJECTIDS 1383and so on, below. 1384. 1385.It VOL_CAPABILITIES_INTERFACES 1386This element contains information about which optional functions are 1387supported by the volume format implementation. 1388See 1389.Dv VOL_CAP_INT_SEARCHFS 1390and so on, below. 1391. 1392.It VOL_CAPABILITIES_RESERVED1 1393Reserved. 1394A file system implementation should set this element to zero. 1395A client program should ignore this element. 1396. 1397.It VOL_CAPABILITIES_RESERVED2 1398Reserved. 1399A file system implementation should set this element to zero. 1400A client program should ignore this element. 1401. 1402.El 1403.Pp 1404. 1405The 1406.Fa valid 1407field contains bit sets that indicate which flags are known to the volume format 1408implementation. 1409Each bit indicates whether the contents of the corresponding bit in the 1410.Fa capabilities 1411field is valid. 1412.Pp 1413. 1414The 1415.Fa capabilities 1416field contains bit sets that indicate whether a particular feature is implemented 1417by this volume format. 1418.Pp 1419. 1420The following bits are defined in the first element (indexed by 1421.Dv VOL_CAPABILITIES_FORMAT ) 1422of the 1423.Fa capabilities 1424and 1425.Fa valid 1426fields of the 1427.Vt vol_capabilities_attr_t 1428structure. 1429. 1430.Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS 1431. 1432.It VOL_CAP_FMT_PERSISTENTOBJECTIDS 1433If this bit is set the volume format supports persistent object identifiers 1434and can look up file system objects by their IDs. 1435See 1436.Dv ATTR_CMN_OBJPERMANENTID 1437for details about how to obtain these identifiers. 1438. 1439.It VOL_CAP_FMT_SYMBOLICLINKS 1440If this bit is set the volume format supports symbolic links. 1441. 1442.It VOL_CAP_FMT_HARDLINKS 1443If this bit is set the volume format supports hard links. 1444. 1445.It VOL_CAP_FMT_JOURNAL 1446If this bit is set the volume format supports a journal used to 1447speed recovery in case of unplanned restart (such as a power outage 1448or crash). 1449This does not necessarily mean the volume is actively using a journal. 1450.Pp 1451Introduced with Darwin 7.0 (Mac OS X version 10.3). 1452. 1453.It VOL_CAP_FMT_JOURNAL_ACTIVE 1454If this bit is set the volume is currently using a journal for 1455speedy recovery after an unplanned restart. 1456This bit can be set only if 1457.Dv VOL_CAP_FMT_JOURNAL 1458is also set. 1459.Pp 1460Introduced with Darwin 7.0 (Mac OS X version 10.3). 1461. 1462.It VOL_CAP_FMT_NO_ROOT_TIMES 1463If this bit is set the volume format does not store reliable times for 1464the root directory, so you should not depend on them to detect changes, 1465identify volumes across unmount/mount, and so on. 1466.Pp 1467Introduced with Darwin 7.0 (Mac OS X version 10.3). 1468. 1469.It VOL_CAP_FMT_SPARSE_FILES 1470If this bit is set the volume format supports sparse files, 1471that is, files which can have 'holes' that have never been written 1472to, and thus do not consume space on disk. 1473A sparse file may have an allocated size on disk that is less than its logical length (that is, 1474.Dv ATTR_FILE_ALLOCSIZE 1475< 1476.Dv ATTR_FILE_TOTALSIZE ). 1477. 1478.Pp 1479Introduced with Darwin 7.0 (Mac OS X version 10.3). 1480. 1481.It VOL_CAP_FMT_ZERO_RUNS 1482For security reasons, parts of a file (runs) that have never been 1483written to must appear to contain zeroes. 1484When this bit is set, the volume keeps track of allocated but unwritten 1485runs of a file so that it can substitute zeroes without actually 1486writing zeroes to the media. 1487This provides performance similar to sparse files, but not the space savings. 1488.Pp 1489Introduced with Darwin 7.0 (Mac OS X version 10.3). 1490. 1491.It VOL_CAP_FMT_CASE_SENSITIVE 1492If this bit is set the volume format treats upper and lower case 1493characters in file and directory names as different. 1494Otherwise an upper case character is equivalent to a lower case character, 1495and you can't have two names that differ solely in the case of 1496the characters. 1497.Pp 1498Introduced with Darwin 7.0 (Mac OS X version 10.3). 1499. 1500.It VOL_CAP_FMT_CASE_PRESERVING 1501If this bit is set the volume format preserves the case of 1502file and directory names. 1503Otherwise the volume may change the case of some characters 1504(typically making them all upper or all lower case). 1505A volume that sets 1506.Dv VOL_CAP_FMT_CASE_SENSITIVE 1507must also set 1508.Dv VOL_CAP_FMT_CASE_PRESERVING . 1509.Pp 1510Introduced with Darwin 7.0 (Mac OS X version 10.3). 1511. 1512.It VOL_CAP_FMT_FAST_STATFS 1513This bit is used as a hint to upper layers to 1514indicate that 1515.Xr statfs 2 1516is fast enough that its results need not be cached by the caller. 1517A volume format implementation that caches the 1518.Xr statfs 2 1519information in memory should set this bit. 1520An implementation that must always read from disk or always perform a network 1521transaction to satisfy 1522.Xr statfs 2 1523should not set this bit. 1524.Pp 1525Introduced with Darwin 7.0 (Mac OS X version 10.3). 1526. 1527.It VOL_CAP_FMT_2TB_FILESIZE 1528If this bit is set the volume format supports file sizes larger 1529than 4GB, and potentially up to 2TB; it does not indicate 1530whether the file system supports files larger than that. 1531.Pp 1532Introduced with Darwin 8.0 (Mac OS X version 10.4). 1533. 1534.It VOL_CAP_FMT_OPENDENYMODES 1535If this bit is set, the volume format supports open deny modes 1536(e.g., "open for read write, deny write"). 1537. 1538.It VOL_CAP_FMT_HIDDEN_FILES 1539If this bit is set, the volume format supports the 1540.Dv UF_HIDDEN 1541file flag, and the 1542.Dv UF_HIDDEN 1543flag is mapped to that volume's native "hidden" or "invisible" 1544bit (e.g., the invisible bit from the Finder Info extended attribute). 1545. 1546.It VOL_CAP_FMT_PATH_FROM_ID 1547If this bit is set, the volume format supports the ability to derive a pathname 1548to the root of the file system given only the ID of an object. This also 1549implies that object IDs on this file system are persistent and not recycled. 1550Most file systems will not support this capability. 1551. 1552.It VOL_CAP_FMT_NO_VOLUME_SIZES 1553If this bit is set the volume format does not support 1554determining values for total data blocks, available blocks, or free blocks, as in 1555.Fa f_blocks, 1556.Fa f_bavail, 1557and 1558.Fa f_bfree 1559in the 1560.Fa struct statfs 1561returned by 1562.Xr statfs 2 . 1563Historically, those values were set to 0xFFFFFFFF for volumes 1564that did not support them. 1565.Pp 1566Introduced with Darwin 10.0 (Mac OS X version 10.6). 1567. 1568.It VOL_CAP_FMT_64BIT_OBJECT_IDS 1569If this bit is set, the volume format uses object IDs that are 64-bit. 1570This means that ATTR_CMN_FILEID and ATTR_CMN_PARENTID are the primary means of 1571obtaining object IDs from this volume. The values returned by ATTR_CMN_OBJID, 1572ATTR_CMN_OBJPERMANENTID, and ATTR_CMN_PAROBJID can be interpreted as 64-bit 1573object IDs instead of fsobj_id_t. 1574. 1575.It VOL_CAP_FMT_DOCUMENT_ID 1576If this bit is set, the volume format supports document IDs 1577(an ID which persists across object ID changes) for document revisions. 1578.It VOL_CAP_FMT_NO_IMMUTABLE_FILES 1579If this bit is set, the volume format does not support setting the UF_IMMUTABLE 1580flag. 1581See ATTR_CMN_FLAGS for more details. 1582.It VOL_CAP_FMT_NO_PERMISSIONS 1583If this bit is set, the volume format does not support setting file 1584permissions. 1585See ATTR_CMN_USERACCESS for more details. 1586.It VOL_CAP_FMT_SHARED_SPACE 1587If this bit is set, the volume format supports having multiple logical filesystems 1588in a single "partition" which share space. 1589.It VOL_CAP_FMT_VOL_GROUPS 1590If this bit is set, the volume format supports having multiple logical filesystems 1591which may be mounted and unmounted together and may present common filesystem 1592identifier information. 1593.It VOL_CAP_FMT_SEALED 1594If this bit is set, the volume is cryptographically sealed and any modifications 1595may render the volume unusable. 1596.It VOL_CAP_FMT_CLONE_MAPPING 1597If this bit is set, the volume format supports full clone tracking. 1598See ATTR_CMNEXT_CLONE_REFCNT and ATTR_CMNEXT_CLONEID for more details. 1599Other features like extended directory statistics, for fast directory sizing, 1600and attribution tags may be supported as well. 1601See VOL_CAP_INT_ATTRIBUTION_TAG for more details related to tagging. 1602. 1603. 1604.El 1605.Pp 1606. 1607The following bits are defined in the second element (indexed by 1608.Dv VOL_CAPABILITIES_INTERFACES ) 1609of the 1610.Fa capabilities 1611and 1612.Fa valid 1613fields of the 1614.Vt vol_capabilities_attr_t 1615structure. 1616. 1617.Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS 1618. 1619.It VOL_CAP_INT_SEARCHFS 1620If this bit is set the volume format implementation supports 1621.Xr searchfs 2 . 1622. 1623.It VOL_CAP_INT_ATTRLIST 1624If this bit is set the volume format implementation supports 1625.Fn getattrlist 1626and 1627.Xr setattrlist 2 . 1628. 1629.It VOL_CAP_INT_NFSEXPORT 1630If this bit is set the volume format implementation allows this volume to be exported via NFS. 1631. 1632.It VOL_CAP_INT_READDIRATTR 1633If this bit is set the volume format implementation supports 1634.Xr getdirentriesattr 2 . 1635. 1636.It VOL_CAP_INT_EXCHANGEDATA 1637If this bit is set the volume format implementation supports 1638.Xr exchangedata 2 . 1639.Pp 1640Introduced with Darwin 7.0 (Mac OS X version 10.3). 1641. 1642.It VOL_CAP_INT_COPYFILE 1643If this bit is set the volume format implementation supports the (private and undocumented) 1644copyfile() function. 1645(This is not the 1646.Xr copyfile 3 1647function.) 1648.Pp 1649Introduced with Darwin 7.0 (Mac OS X version 10.3). 1650. 1651.It VOL_CAP_INT_ALLOCATE 1652If this bit is set the volume format implementation supports the 1653.Dv F_PREALLOCATE 1654selector of 1655.Xr fcntl 2 . 1656.Pp 1657Introduced with Darwin 7.0 (Mac OS X version 10.3). 1658. 1659.It VOL_CAP_INT_VOL_RENAME 1660If this bit is set the volume format implementation allows you to 1661modify the volume name using 1662.Xr setattrlist 2 . 1663.Pp 1664Introduced with Darwin 7.0 (Mac OS X version 10.3). 1665. 1666.It VOL_CAP_INT_ADVLOCK 1667If this bit is set the volume format implementation supports 1668advisory locking, that is, the 1669.Dv F_GETLK , 1670.Dv F_SETLK , 1671and 1672.Dv F_SETLKW 1673selectors to 1674.Xr fcntl 2 . 1675.Pp 1676Introduced with Darwin 7.0 (Mac OS X version 10.3). 1677. 1678.It VOL_CAP_INT_FLOCK 1679If this bit is set the volume format implementation supports 1680whole file locks. 1681This includes 1682.Xr flock 2 1683and the 1684.Dv O_EXLOCK 1685and 1686.Dv O_SHLOCK 1687flags to 1688.Xr open 2 . 1689.Pp 1690Introduced with Darwin 7.0 (Mac OS X version 10.3). 1691. 1692.It VOL_CAP_INT_EXTENDED_SECURITY 1693If this bit is set the volume format implementation supports 1694extended security controls (ACLs). 1695.Pp 1696Introduced with Darwin 8.0 (Mac OS X version 10.4). 1697. 1698.It VOL_CAP_INT_USERACCESS 1699If this bit is set the volume format implementation supports the 1700ATTR_CMN_USERACCESS attribute. 1701.Pp 1702Introduced with Darwin 8.0 (Mac OS X version 10.4). 1703. 1704.It VOL_CAP_INT_MANLOCK 1705If this bit is set, the volume format implementation supports 1706AFP-style mandatory byte range locks via 1707.Xr ioctl 2 . 1708. 1709.It VOL_CAP_INT_EXTENDED_ATTR 1710If this bit is set, the volume format implementation supports 1711native extended attributes (see 1712.Xr setxattr 2 Ns ). 1713. 1714.It VOL_CAP_INT_CLONE 1715If this bit is set, the file system supports cloning files and directories. 1716See 1717.Xr clonefileat 2 1718for more details. 1719. 1720.It VOL_CAP_INT_SNAPSHOT 1721If this bit is set, the file system supports snapshots. 1722See 1723.Xr fs_snapshot_create 2 1724for more details. 1725. 1726.It VOL_CAP_INT_NAMEDSTREAMS 1727If this bit is set, the volume format implementation supports 1728native named streams. 1729. 1730.It VOL_CAP_INT_RENAME_SWAP 1731If this bit is set, the file system supports swapping file system 1732objects. See 1733.Xr rename 2 1734for more details. 1735. 1736.It VOL_CAP_INT_RENAME_EXCL 1737If this bit is set, the file system supports an exclusive rename 1738operation. See 1739.Xr rename 2 1740for more details. 1741. 1742.It VOL_CAP_INT_RENAME_OPENFAIL 1743If this bit is set, the file system may fail a rename operation 1744of a directory if one of its descendents is open. 1745See 1746.Xr rename 2 1747for more details. 1748. 1749.It VOL_CAP_INT_ATTRIBUTION_TAG 1750If this bit is set, the file system supports establishing an owner relationship between 1751a file (excluding small files) and a process on the first read/write/truncate/clone operation. 1752See ATTR_CMNEXT_ATTRIBUTION_TAG for more details. 1753. 1754.It VOL_CAP_INT_PUNCHHOLE 1755If this bit is set, the file system supports the 1756.Dv F_PUNCHOLE operation. 1757See 1758.Xr fcntl 2 1759for more details. 1760. 1761.El 1762.Pp 1763. 1764.\" vol_attributes_attr_t 1765. 1766A volume can also report which attributes it supports. 1767This information is returned by the 1768.Dv ATTR_VOL_ATTRIBUTES 1769attribute, which returns a 1770.Vt vol_attributes_attr_t 1771structure (shown below). 1772. 1773.Bd -literal 1774typedef struct attribute_set { 1775 attrgroup_t commonattr; /* common attribute group */ 1776 attrgroup_t volattr; /* volume attribute group */ 1777 attrgroup_t dirattr; /* directory attribute group */ 1778 attrgroup_t fileattr; /* file attribute group */ 1779 attrgroup_t forkattr; /* fork attribute group */ 1780} attribute_set_t; 1781.Pp 1782. 1783typedef struct vol_attributes_attr { 1784 attribute_set_t validattr; 1785 attribute_set_t nativeattr; 1786} vol_attributes_attr_t; 1787.Ed 1788.Pp 1789. 1790The 1791.Fa validattr 1792field consists of a number of bit sets that indicate whether an attribute is 1793supported by the volume format implementation. 1794The 1795.Fa nativeattr 1796is similar except that the bit sets indicate whether an attribute is supported 1797natively by the volume format. 1798An attribute is supported natively if the volume format implementation does not have to do 1799any complex conversions to access the attribute. 1800For example, a volume format might support persistent object identifiers, but 1801doing so requires a complex table lookup that is not part of the core volume 1802format. 1803In that case, the 1804.Dv ATTR_VOL_ATTRIBUTES 1805attribute would return 1806.Dv ATTR_CMN_OBJPERMANENTID 1807set in the 1808.Fa validattr 1809field of the 1810.Vt vol_attributes_attr_t , 1811but not in the 1812.Fa nativeattr 1813field. 1814. 1815.Sh RETURN VALUES 1816Upon successful completion a value of 0 is returned. 1817Otherwise, a value of -1 is returned and 1818.Va errno 1819is set to indicate the error. 1820. 1821.Sh COMPATIBILITY 1822Not all volumes support 1823.Fn getattrlist . 1824The best way to test whether a volume supports this function is to 1825simply call it and check the error result. 1826.Fn getattrlist 1827will return 1828.Dv ENOTSUP 1829if it is not supported on a particular volume. 1830.Pp 1831. 1832The 1833.Fn getattrlist 1834function has been undocumented for more than two years. 1835In that time a number of volume format implementations have been created without 1836a proper specification for the behaviour of this routine. 1837You may encounter volume format implementations with slightly different 1838behaviour than what is described here. 1839Your program is expected to be tolerant of this variant behaviour. 1840.Pp 1841. 1842If you're implementing a volume format that supports 1843.Fn getattrlist , 1844you should be careful to support the behaviour specified by this document. 1845. 1846.Sh ERRORS 1847.Fn getattrlist 1848and 1849.Fn fgetattrlist 1850will fail if: 1851.Bl -tag -width Er 1852. 1853.It Bq Er ENOTSUP 1854The volume does not support the query. 1855. 1856.It Bq Er ENOTDIR 1857A component of the path prefix for 1858.Fn getattrlist 1859is not a directory. 1860. 1861.It Bq Er ENAMETOOLONG 1862A component of a path name for 1863.Fn getattrlist 1864exceeded 1865.Dv NAME_MAX 1866characters, or an entire path name exceeded 1867.Dv PATH_MAX 1868characters. 1869. 1870.It Bq Er ENOENT 1871The file system object for 1872.Fn getattrlist 1873does not exist. 1874. 1875.It Bq Er EBADF 1876The file descriptor argument for 1877.Fn fgetattrlist 1878is not a valid file descriptor. 1879. 1880.It Bq Er EACCES 1881Search permission is denied for a component of the path prefix for 1882.Fn getattrlist . 1883. 1884.It Bq Er ELOOP 1885Too many symbolic links were encountered in translating the pathname 1886for 1887.Fn getattrlist . 1888. 1889.It Bq Er ELOOP 1890FSOPT_NOFOLLOW_ANY was passed and a symbolic link was encountered in 1891translating the pathname for 1892.Fn getattrlist . 1893. 1894.It Bq Er EFAULT 1895.Fa path , 1896.Fa attrList 1897or 1898.Em attrBuf 1899points to an invalid address. 1900. 1901.It Bq Er ERANGE 1902.Fa attrBufSize 1903is too small to hold a u_int32_t. 1904. 1905.It Bq Er EINVAL 1906The 1907.Fa bitmapcount 1908field of 1909.Fa attrList 1910is not 1911.Dv ATTR_BIT_MAP_COUNT . 1912. 1913.It Bq Er EINVAL 1914You requested an invalid attribute. 1915. 1916.It Bq Er EINVAL 1917You requested an attribute that is not supported for this file system object. 1918. 1919.It Bq Er EINVAL 1920You requested volume attributes and directory or file attributes. 1921. 1922.It Bq Er EINVAL 1923You requested volume attributes but 1924.Fa path 1925does not reference the root of the volume. 1926. 1927.It Bq Er EROFS 1928The volume is read-only but must be modified in order to return this attribute. 1929. 1930.It Bq Er EIO 1931An I/O error occurred while reading from or writing to the file system. 1932.El 1933.Pp 1934In addition to the errors returned by the 1935.Fn getattrlist , 1936the 1937.Fn getattrlistat 1938function may fail if: 1939.Bl -tag -width Er 1940.It Bq Er EBADF 1941The 1942.Fa path 1943argument does not specify an absolute path and the 1944.Fa fd 1945argument is neither 1946.Dv AT_FDCWD 1947nor a valid file descriptor open for searching. 1948.It Bq Er ENOTDIR 1949The 1950.Fa path 1951argument is not an absolute path and 1952.Fa fd 1953is neither 1954.Dv AT_FDCWD 1955nor a file descriptor associated with a directory. 1956.El 1957.Pp 1958. 1959.Sh CAVEATS 1960. 1961If you request any volume attributes, you must set 1962.Dv ATTR_VOL_INFO 1963in the 1964.Fa volattr 1965field, even though it generates no result in the attribute buffer. 1966.Pp 1967. 1968The order that attributes are stored in the attribute buffer almost 1969invariably matches the order of attribute mask bit values. 1970For example, 1971.Dv ATTR_CMN_NAME 1972(0x00000001) comes before 1973.Dv ATTR_CMN_DEVID 1974(0x00000002) because its value is smaller. 1975When ordering attributes, you should always use the order in which they 1976are described above. 1977.Pp 1978. 1979The 1980.Vt timespec 1981structure is 64-bits (two 32-bit elements) in 32-bit code, and 1982128-bits (two 64-bit elements) in 64-bit code; however, it is aligned 1983on a 4-byte (32-bit) boundary, even in 64-bit code. 1984.Pp 1985If you use a structure 1986for the attribute data, it must be correctly packed and aligned (see 1987examples). 1988.Pp 1989. 1990Inconsistent behavior may be observed when the ATTR_CMN_FULLPATH attribute is requested on 1991hard-linked items, particularly when the file system does not support ATTR_CMN_PARENTID 1992natively. Callers should be aware of this when requesting the full path of a hard-linked item, especially 1993if the full path crosses mount points. 1994.Pp 1995. 1996For more caveats, see also the compatibility notes above. 1997. 1998.Sh EXAMPLES 1999. 2000The following code prints the file type and creator of a file, 2001assuming that the volume supports the required attributes. 2002. 2003.Bd -literal 2004#include <assert.h> 2005#include <stdio.h> 2006#include <string.h> 2007#include <sys/attr.h> 2008#include <sys/errno.h> 2009#include <unistd.h> 2010#include <sys/vnode.h> 2011.Pp 2012. 2013typedef struct attrlist attrlist_t; 2014.Pp 2015. 2016struct FInfoAttrBuf { 2017 u_int32_t length; 2018 fsobj_type_t objType; 2019 char finderInfo[32]; 2020} __attribute__((aligned(4), packed)); 2021typedef struct FInfoAttrBuf FInfoAttrBuf; 2022.Pp 2023. 2024static int FInfoDemo(const char *path) 2025{ 2026 int err; 2027 attrlist_t attrList; 2028 FInfoAttrBuf attrBuf; 2029.Pp 2030. 2031 memset(&attrList, 0, sizeof(attrList)); 2032 attrList.bitmapcount = ATTR_BIT_MAP_COUNT; 2033 attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO; 2034.Pp 2035 2036 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0); 2037 if (err != 0) { 2038 err = errno; 2039 } 2040.Pp 2041 2042 if (err == 0) { 2043 assert(attrBuf.length == sizeof(attrBuf)); 2044.Pp 2045 2046 printf("Finder information for %s:\en", path); 2047 switch (attrBuf.objType) { 2048 case VREG: 2049 printf("file type = '%.4s'\en", &attrBuf.finderInfo[0]); 2050 printf("file creator = '%.4s'\en", &attrBuf.finderInfo[4]); 2051 break; 2052 case VDIR: 2053 printf("directory\en"); 2054 break; 2055 default: 2056 printf("other object type, %d\en", attrBuf.objType); 2057 break; 2058 } 2059 } 2060.Pp 2061. 2062 return err; 2063} 2064.Ed 2065.Pp 2066. 2067The following code is an alternative implementation that uses nested structures 2068to group the related attributes. 2069. 2070.Bd -literal 2071#include <assert.h> 2072#include <stdio.h> 2073#include <stddef.h> 2074#include <string.h> 2075#include <sys/attr.h> 2076#include <sys/errno.h> 2077#include <unistd.h> 2078#include <sys/vnode.h> 2079.Pp 2080. 2081typedef struct attrlist attrlist_t; 2082.Pp 2083. 2084struct FInfo2CommonAttrBuf { 2085 fsobj_type_t objType; 2086 char finderInfo[32]; 2087} __attribute__((aligned(4), packed)); 2088typedef struct FInfo2CommonAttrBuf FInfo2CommonAttrBuf; 2089.Pp 2090. 2091struct FInfo2AttrBuf { 2092 u_int32_t length; 2093 FInfo2CommonAttrBuf common; 2094} __attribute__((aligned(4), packed));; 2095typedef struct FInfo2AttrBuf FInfo2AttrBuf; 2096.Pp 2097. 2098static int FInfo2Demo(const char *path) 2099{ 2100 int err; 2101 attrlist_t attrList; 2102 FInfo2AttrBuf attrBuf; 2103.Pp 2104. 2105 memset(&attrList, 0, sizeof(attrList)); 2106 attrList.bitmapcount = ATTR_BIT_MAP_COUNT; 2107 attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO; 2108.Pp 2109. 2110 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0); 2111 if (err != 0) { 2112 err = errno; 2113 } 2114.Pp 2115. 2116 if (err == 0) { 2117 assert(attrBuf.length == sizeof(attrBuf)); 2118.Pp 2119. 2120 printf("Finder information for %s:\en", path); 2121 switch (attrBuf.common.objType) { 2122 case VREG: 2123 printf( 2124 "file type = '%.4s'\en", 2125 &attrBuf.common.finderInfo[0] 2126 ); 2127 printf( 2128 "file creator = '%.4s'\en", 2129 &attrBuf.common.finderInfo[4] 2130 ); 2131 break; 2132 case VDIR: 2133 printf("directory\en"); 2134 break; 2135 default: 2136 printf( 2137 "other object type, %d\en", 2138 attrBuf.common.objType 2139 ); 2140 break; 2141 } 2142 } 2143.Pp 2144. 2145 return err; 2146} 2147.Ed 2148.Pp 2149. 2150The following example shows how to deal with variable length attributes. 2151It assumes that the volume specified by 2152.Fa path 2153supports the necessary attributes. 2154. 2155.Bd -literal 2156#include <assert.h> 2157#include <stdio.h> 2158#include <stddef.h> 2159#include <string.h> 2160#include <sys/attr.h> 2161#include <sys/errno.h> 2162#include <unistd.h> 2163#include <sys/vnode.h> 2164.Pp 2165. 2166typedef struct attrlist attrlist_t; 2167.Pp 2168. 2169struct VolAttrBuf { 2170 u_int32_t length; 2171 u_int32_t fileCount; 2172 u_int32_t dirCount; 2173 attrreference_t mountPointRef; 2174 attrreference_t volNameRef; 2175 char mountPointSpace[MAXPATHLEN]; 2176 char volNameSpace[MAXPATHLEN]; 2177} __attribute__((aligned(4), packed)); 2178typedef struct VolAttrBuf VolAttrBuf; 2179.Pp 2180. 2181static int VolDemo(const char *path) 2182{ 2183 int err; 2184 attrlist_t attrList; 2185 VolAttrBuf attrBuf; 2186.Pp 2187. 2188 memset(&attrList, 0, sizeof(attrList)); 2189 attrList.bitmapcount = ATTR_BIT_MAP_COUNT; 2190 attrList.volattr = ATTR_VOL_INFO 2191 | ATTR_VOL_FILECOUNT 2192 | ATTR_VOL_DIRCOUNT 2193 | ATTR_VOL_MOUNTPOINT 2194 | ATTR_VOL_NAME; 2195.Pp 2196 2197 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0); 2198 if (err != 0) { 2199 err = errno; 2200 } 2201.Pp 2202 2203 if (err == 0) { 2204 assert(attrBuf.length > offsetof(VolAttrBuf, mountPointSpace)); 2205 assert(attrBuf.length <= sizeof(attrBuf)); 2206.Pp 2207 2208 printf("Volume information for %s:\en", path); 2209 printf("ATTR_VOL_FILECOUNT: %u\en", attrBuf.fileCount); 2210 printf("ATTR_VOL_DIRCOUNT: %u\en", attrBuf.dirCount); 2211 printf( 2212 "ATTR_VOL_MOUNTPOINT: %.*s\en", 2213 (int) attrBuf.mountPointRef.attr_length, 2214 ( ((char *) &attrBuf.mountPointRef) 2215 + attrBuf.mountPointRef.attr_dataoffset ) 2216 ); 2217 printf( 2218 "ATTR_VOL_NAME: %.*s\en", 2219 (int) attrBuf.volNameRef.attr_length, 2220 ( ((char *) &attrBuf.volNameRef) 2221 + attrBuf.volNameRef.attr_dataoffset ) 2222 ); 2223 } 2224.Pp 2225. 2226 return err; 2227} 2228.Ed 2229.Pp 2230The following sample demonstrates the need to use packing and alignment 2231controls; without the attribute, in 64-bit code, the fields of the structure are not 2232placed at the locations that the kernel expects. 2233. 2234.Bd -literal 2235#include <stdio.h> 2236#include <stdlib.h> 2237#include <unistd.h> 2238#include <string.h> 2239#include <err.h> 2240#include <time.h> 2241#include <sys/attr.h> 2242.Pp 2243/* The alignment and packing attribute is necessary in 64-bit code */ 2244struct AttrListTimes { 2245 u_int32_t length; 2246 struct timespec st_crtime; 2247 struct timespec st_modtime; 2248} __attribute__((aligned(4), packed)); 2249.Pp 2250main(int argc, char **argv) 2251{ 2252 int rv; 2253 int i; 2254.Pp 2255 for (i = 1; i < argc; i++) { 2256 struct attrlist attrList; 2257 struct AttrListTimes myStat = {0}; 2258 char *path = argv[i]; 2259.Pp 2260 memset(&attrList, 0, sizeof(attrList)); 2261 attrList.bitmapcount = ATTR_BIT_MAP_COUNT; 2262 attrList.commonattr = ATTR_CMN_CRTIME | 2263 ATTR_CMN_MODTIME; 2264.Pp 2265 rv = getattrlist(path, &attrList, &myStat, sizeof(myStat), 0); 2266.Pp 2267 if (rv == -1) { 2268 warn("getattrlist(%s)", path); 2269 continue; 2270 } 2271 printf("%s: Modification time = %s", argv[i], ctime(&myStat.st_modtime.tv_sec)); 2272 } 2273 return 0; 2274} 2275.Ed 2276.Pp 2277 The getLinkIDInfo() function determines if ATTR_CMNEXT_LINKID and ATTR_CMN_OBJID 2278 are valid to use on the file system specified by path. 2279. 2280.Bd -literal 2281int getLinkIDInfo(const char *path, bool *cmnExtLinkIDValid, bool *cmnObjIDValid) 2282{ 2283 int result; 2284 struct statfs statfsBuf; 2285 struct attrlist attrList; 2286 struct volAttrsBuf { 2287 u_int32_t length; 2288 vol_capabilities_attr_t capabilities; 2289 vol_attributes_attr_t attributes; 2290 } __attribute__((aligned(4), packed)); 2291 struct volAttrsBuf volAttrs; 2292.Pp 2293 memset(&attrList, 0, sizeof(attrList)); 2294 attrList.bitmapcount = ATTR_BIT_MAP_COUNT; 2295 attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES | ATTR_VOL_ATTRIBUTES; 2296 // get the file system's mount point path for the input path 2297 result = statfs(path, &statfsBuf); 2298 if ( result == 0 ) { 2299 // get the supported capabilities and attributes 2300 result = getattrlist(statfsBuf.f_mntonname, &attrList, &volAttrs, sizeof(volAttrs), FSOPT_ATTR_CMN_EXTENDED); 2301 if ( result == 0 ) { 2302 if ( volAttrs.attributes.validattr.forkattr & ATTR_CMNEXT_LINKID ) { 2303 // ATTR_CMNEXT_LINKID is available; do not use ATTR_CMN_OBJID 2304 *cmnExtLinkIDValid = true; 2305 *cmnObjIDValid = false; 2306 } 2307 else { 2308 // ATTR_CMNEXT_LINKID is not available 2309 cmnExtLinkIDValid = false; 2310 // ATTR_CMN_OBJID can only be used if the file system does not use 64-bit object IDs 2311 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) ) { 2312 *cmnObjIDValid = false; 2313 } 2314 else { 2315 *cmnObjIDValid = true; 2316 } 2317 } 2318 } 2319 } 2320 if ( result != 0 ) { 2321 *cmnExtLinkIDValid = *cmnObjIDValid = false; 2322 } 2323 return result; 2324} 2325.Ed 2326.Pp 2327. 2328.Sh SEE ALSO 2329. 2330.Xr access 2 , 2331.Xr chflags 2 , 2332.Xr exchangedata 2 , 2333.Xr fcntl 2 , 2334.Xr getattrlistbulk 2 , 2335.Xr mount 2 , 2336.Xr searchfs 2 , 2337.Xr setattrlist 2 , 2338.Xr stat 2 , 2339.Xr statfs 2 2340. 2341.Sh HISTORY 2342A 2343.Fn getattrlist 2344function call appeared in Darwin 1.3.1 (Mac OS X version 10.0). 2345The 2346.Fn getattrlistat 2347function call appeared in OS X 10.10 . 2348