]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man2/getattrlist.2
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / man / man2 / getattrlist.2
CommitLineData
91447636
A
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 October 14, 2004
20.Dt GETATTRLIST 2
21.Os Darwin
22.Sh NAME
23.Nm getattrlist
24.Nd get file system attributes
25.Sh SYNOPSIS
26.Fd #include <sys/attr.h>
27.Fd #include <unistd.h>
28.Ft int
29.Fn getattrlist "const char* path" "struct attrlist * attrList" "void * attrBuf" "size_t attrBufSize" "unsigned long options"
30.
31.Sh DESCRIPTION
32The
33.Fn getattrlist
34function returns attributes (that is, metadata) of file system objects.
35You can think of
36.Fn getattrlist
37as a seriously enhanced version of
38.Xr stat 2 .
39The function returns attributes about the file system object specified by
40.Fa path
41in the buffer specified by
42.Fa attrBuf
43and
44.Fa attrBufSize .
45The
46.Fa attrList
47parameter determines what attributes are returned.
48The
49.Fa options
50parameter lets you control specific aspects of the function's behaviour.
51.Pp
52.
53The
54.Fn getattrlist
55function is only supported by certain volume format implementations.
56For maximum compatibility, client programs should use high-level APIs
57(such as the Carbon File Manager) to access file system attributes.
58These high-level APIs include logic to emulate file system attributes
59on volumes that don't support
60.Fn getattrlist .
61.Pp
62.
63Not all volumes support all attributes.
64See the discussion of
65.Dv ATTR_VOL_ATTRIBUTES
66for a discussion of how to determine whether a particular volume supports a
67particular attribute.
68.Pp
69Furthermore, you should only request the attributes that you need.
70Some attributes are expensive to calculate on some volume formats.
71For example,
72.Dv ATTR_DIR_ENTRYCOUNT
73is usually expensive to calculate on non-HFS [Plus] volumes.
74If you don't need a particular attribute, you should not ask for it.
75.Pp
76.
77.\" path parameter
78.
79The
80.Fa path
81parameter must reference a valid file system object.
82Read, write or execute permission of the object itself is not required, but
83all directories listed in the path name leading to the object must be
84searchable.
85.Pp
86.
87.\" attrList parameter
88.
89The
90.Fa attrList
91parameter is a pointer to an
92.Vt attrlist
93structure, as defined by
94.Aq Pa sys/attr.h
95(shown below).
96It determines what attributes are returned by the function.
97You are responsible for filling out all fields of this structure before calling the function.
98.Bd -literal
99typedef u_int32_t attrgroup_t;
100.Pp
101struct attrlist {
102 u_short bitmapcount; /* number of attr. bit sets in list */
103 u_int16_t reserved; /* (to maintain 4-byte alignment) */
104 attrgroup_t commonattr; /* common attribute group */
105 attrgroup_t volattr; /* volume attribute group */
106 attrgroup_t dirattr; /* directory attribute group */
107 attrgroup_t fileattr; /* file attribute group */
108 attrgroup_t forkattr; /* fork attribute group */
109};
110#define ATTR_BIT_MAP_COUNT 5
111.Ed
112.Pp
113.
114.\" attrlist elements
115.
116The fields of the
117.Vt attrlist
118structure are defined as follows.
119.Bl -tag -width XXXbitmapcount
120.
121.It bitmapcount
122Number of attribute bit sets in the structure.
123In current systems you must set this to
124.Dv ATTR_BIT_MAP_COUNT .
125.
126.It reserved
127Reserved.
128You must set this to 0.
129.
130.It commonattr
131A bit set that specifies the common attributes that you require.
132Common attributes relate to all types of file system objects.
133See below for a description of these attributes.
134.
135.It volattr
136A bit set that specifies the volume attributes that you require.
137Volume attributes relate to volumes (that is, mounted file systems).
138See below for a description of these attributes.
139If you request volume attributes,
140.Fa path
141must reference the root of a volume.
142In addition, you can't request volume attributes if you also request
143file or directory attributes.
144.
145.It dirattr
146A bit set that specifies the directory attributes that you require.
147See below for a description of these attributes.
148.
149.It fileattr
150A bit set that specifies the file attributes that you require.
151See below for a description of these attributes.
152.
153.It forkattr
154A bit set that specifies the fork attributes that you require.
155Fork attributes relate to the actual data in the file,
156which can be held in multiple named contiguous ranges, or forks.
157See below for a description of these attributes.
158.
159.El
160.Pp
161.
162Unless otherwise noted in the lists below, attributes are read-only.
163Attributes labelled as read/write can be set using
164.Xr setattrlist 2 .
165.Pp
166.
167.\" attrBuf and attrBufSize parameters
168.
169The
170.Fa attrBuf
171and
172.Fa attrBufSize
173parameters specify a buffer into which the function places attribute values.
174The format of this buffer is sufficiently complex that its description
175requires a separate section (see below).
176The initial contents of this buffer are ignored.
177.Pp
178.
179.\" option parameter
180.
181The
182.Fa options
183parameter is a bit set that controls the behaviour of
184.Fn getattrlist .
185The following option bits are defined.
186.
187.Bl -tag -width XXXbitmapcount
188.
189.It FSOPT_NOFOLLOW
190If this bit is set,
191.Fn getattrlist
192will not follow a symlink if it occurs as
193the last component of
194.Fa path .
195.
196.El
197.
198.Sh ATTRIBUTE BUFFER
199.
200The data returned in the buffer described by
201.Fa attrBuf
202and
203.Fa attrBufSize
204is formatted as follows.
205.Pp
206.
207.Bl -enum
208.
209.It
210The first element of the buffer is a
211.Vt unsigned long
212that contains the overall length, in bytes, of the attributes returned.
213This size includes the length field itself.
214.
215.It
216Following the length field is a list of attributes.
217Each attribute is represented by a field of its type,
218where the type is given as part of the attribute description (below).
219.
220.It
221The attributes are placed into the attribute buffer in the order
222that they are described below.
223.
224.El
225.Pp
226.
227If the attribute is of variable length, it is represented
228in the list by an
229.Vt attrreference
230structure, as defined by
231.Aq Pa sys/attr.h
232(shown below).
233.
234.Bd -literal
235typedef struct attrreference {
236 long attr_dataoffset;
237 size_t attr_length;
238} attrreference_t;
239.Ed
240.Pp
241.
242This structure contains a 'pointer' to the variable length attribute data.
243The
244.Fa attr_length
245field is the length of the attribute data (in bytes).
246The
247.Fa attr_dataoffset
248field is the offset in bytes from the
249.Vt attrreference
250structure
251to the attribute data.
252This offset will always be a multiple of sizeof(unsigned long) bytes,
253so you can safely access common data types without fear of alignment
254exceptions.
255.Pp
256.
257The
258.Fn getattrlist
259function will silently truncate attribute data if
260.Fa attrBufSize
261is too small.
262The length field at the front of the attribute list always represents
263the length of the data actually copied into the attribute buffer.
264If the data is truncated, there is no easy way to determine the
265buffer size that's required to get all of the requested attributes.
266You should always pass an
267.Fa attrBufSize
268that is large enough to accommodate the known size of the attributes
269in the attribute list (including the leading length field).
270.Pp
271.
272Because the returned attributes are simply truncated if the buffer is
273too small, it's possible for a variable length attribute to reference
274data beyond the end of the attribute buffer. That is, it's possible
275for the attribute data to start beyond the end of the attribute buffer
276(that is, if
277.Fa attrRef
278is a pointer to the
279.Vt attrreference_t ,
280( ( (char *)
281.Fa attrRef
282) +
283.Fa attr_dataoffset
284) > ( ( (char *)
285.Fa attrBuf
286) +
287.Fa attrSize
288) ) or, indeed, for the attribute data to extend beyond the end of the attribute buffer (that is,
289( ( (char *)
290.Fa attrRef
291) +
292.Fa attr_dataoffset
293+
294.Fa attr_datalength
295) > ( ( (char *)
296.Fa attrBuf
297) +
298.Fa attrSize
299) ).
300If this happens you must increase the size of the buffer and call
301.Fn getattrlist
302to get an accurate copy of the attribute.
303.
304.Sh COMMON ATTRIBUTES
305.
306Common attributes relate to all types of file system objects.
307The following common attributes are defined.
308.
309.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP
310.
311.It ATTR_CMN_NAME
312An
313.Vt attrreference
314structure containing the name of the file system object as
315UTF-8 encoded, null terminated C string.
316The attribute data length will not be greater than
317.Dv NAME_MAX +
3181.
319.Pp
320.
321.It ATTR_CMN_DEVID
322A
323.Vt dev_t
324containing the device number of the device on which this
325file system object's volume is mounted.
326Equivalent to the
327.Fa st_dev
328field of the
329.Vt stat
330structure returned by
331.Xr stat 2 .
332.
333.It ATTR_CMN_FSID
334An
335.Vt fsid_t
336structure containing the file system identifier for the volume on which
337the file system object resides.
338Equivalent to the
339.Fa f_fsid
340field of the
341.Vt statfs
342structure returned by
343.Xr statfs 2 .
344.
345.Pp
346This value is not related to the file system ID from traditional Mac OS (for example,
347the
348.Fa filesystemID
349field of the
350.Vt FSVolumeInfo
351structure returned by Carbon's FSGetVolumeInfo() function).
352On current versions of Mac OS X that value is synthesised by the Carbon File Manager.
353.
354.It ATTR_CMN_OBJTYPE
355An
356.Vt fsobj_type_t
357that identifies the type of file system object.
358The values are taken from
359.Vt enum vtype
360in
361.Aq Pa sys/vnode.h .
362.
363.It ATTR_CMN_OBJTAG
364An
365.Vt fsobj_tag_t
366that identifies the type of file system containing the object.
367The values are taken from
368.Vt enum vtagtype
369in
370.Aq Pa sys/vnode.h .
371.
372.It ATTR_CMN_OBJID
373An
374.Vt fsobj_id_t
375structure that uniquely identifies the file system object
376within its volume.
377The fid_generation field of this structure will be zero for all non-root callers
378(effective UID not 0).
379This identifier need not be persistent across an unmount/mount sequence.
380.Pp
381.
382Some volume formats use well known values for the
383.Fa fid_objno
384field for the root directory (2) and the parent of root directory (1).
385This is not a required behaviour of this attribute.
386.
387.It ATTR_CMN_OBJPERMANENTID
388An
389.Vt fsobj_id_t
390structure that uniquely identifies the file system object
391within its volume.
392The fid_generation field of this structure will be zero for all non-root callers
393(effective UID not 0).
394This identifier should be persistent across an unmount/mount sequence.
395.Pp
396Some file systems (for example, original HFS) may need to modify the on-disk
397structure to return a persistent identifier.
398If such a file system is mounted read-only, an attempt to get this attribute
399will fail with the error
400.Dv EROFS .
401.
402.It ATTR_CMN_PAROBJID
403An
404.Vt fsobj_id_t
405structure that identifies the parent directory of the file system object.
406The fid_generation field of this structure will be zero for all non-root callers
407(effective UID not 0).
408Equivalent to the ATTR_CMN_OBJID attribute of the parent directory.
409This identifier need not be persistent across an unmount/mount sequence.
410.Pp
411.
412On a volume that supports hard links, a multiply linked file has no unique parent.
413This attribute will return an unspecified parent.
414.Pp
415.
416For some volume formats this attribute is very expensive to calculate.
417.
418.It ATTR_CMN_SCRIPT
419(read/write) A
420.Vt text_encoding_t
421containing a text encoding hint for
422the file system object's name.
423It is included to facilitate the lossless round trip conversion of names between
424Unicode and traditional Mac OS script encodings.
425The values are defined in
426.Aq Pa CarbonCore/TextCommon.h .
427File systems that do not have an appropriate text encoding value should return
428kTextEncodingMacUnicode.
429See DTS Q&A 1173 "File Manager Text Encoding Hints".
430.
431.It ATTR_CMN_CRTIME
432(read/write) A
433.Vt timespec
434structure containing the time that the file system object
435was created.
436.
437.It ATTR_CMN_MODTIME
438(read/write) A
439.Vt timespec
440structure containing the time that the file system object
441was last modified.
442Equivalent to the
443.Fa st_mtimespec
444field of the
445.Vt stat
446structure returned by
447.Xr stat 2 .
448.
449.It ATTR_CMN_CHGTIME
450(read/write) A
451.Vt timespec
452structure containing the time that the file system object's
453attributes were last modified.
454Equivalent to the
455.Fa st_ctimespec
456field of the
457.Vt stat
458structure returned by
459.Xr stat 2 .
460.
461.It ATTR_CMN_ACCTIME
462(read/write) A
463.Vt timespec
464structure containing the time that the file system object
465was last accessed.
466Equivalent to the
467.Fa st_atimespec
468field of the
469.Vt stat
470structure returned by
471.Xr stat 2 .
472.
473.It ATTR_CMN_BKUPTIME
474(read/write) A
475.Vt timespec
476structure containing the time that the file system object was
477last backed up.
478This value is for use by backup utilities.
479The file system stores but does not interpret the value.
480.
481.It ATTR_CMN_FNDRINFO
482(read/write) 32 bytes of data for use by the Finder.
483Equivalent to the concatenation of a
484.Vt FileInfo
485structure and an
486.Vt ExtendedFileInfo
487structure
488(or, for directories, a
489.Vt FolderInfo
490structure and an
491.Vt ExtendedFolderInfo
492structure).
493These structures are defined in
494.Aq Pa CarbonCore/Finder.h .
495.Pp
496This attribute is not byte swapped by the file system.
497The value of multibyte fields on disk is always big endian.
498When running on a little endian system (such as Darwin on x86),
499you must byte swap any multibyte fields.
500.
501.It ATTR_CMN_OWNERID
502(read/write) A
503.Vt uid_t
504containing the owner of the file system object.
505Equivalent to the
506.Fa st_uid
507field of the
508.Vt stat
509structure returned by
510.Xr stat 2 .
511.
512.It ATTR_CMN_GRPID
513(read/write) A
514.Vt gid_t
515containing the group of the file system object.
516Equivalent to the
517.Fa st_gid
518field of the
519.Vt stat
520structure returned by
521.Xr stat 2 .
522.
523.It ATTR_CMN_ACCESSMASK
524(read/write) A
525.Vt mode_t
526containing the access permissions of the file system object.
527Equivalent to the
528.Fa st_mode
529field of the
530.Vt stat
531structure returned by
532.Xr stat 2 .
533.
534.It ATTR_CMN_NAMEDATTRCOUNT
535A
536.Vt unsigned long
537containing the number of named attributes of the file system object.
538No built-in file systems on Mac OS X currently support named attributes.
539.
540.It ATTR_CMN_NAMEDATTRLIST
541An
542.Vt attrreference
543structure containing a list of named attributes of the file system object.
544No built-in file systems on Mac OS X currently support named attributes.
545Because of this, the structure of this attribute's value is not yet defined.
546.
547.It ATTR_CMN_FLAGS
548(read/write) A
549.Vt unsigned long
550containing file flags.
551Equivalent to the
552.Fa st_flags
553field of the
554.Vt stat
555structure returned by
556.Xr stat 2 .
557For more information about these flags, see
558.Xr chflags 2 .
559.Pp
560.
561The order that attributes are placed into the attribute buffer
562almost invariably matches the order of the attribute mask bit values.
563The exception is
564.Dv ATTR_CMN_FLAGS .
565If its order was based on its bit position, it would be before
566the
567.Dv ATTR_CMN_NAMEDATTRCOUNT
568/
569.Dv ATTR_CMN_NAMEDATTRLIST
570pair, however,
571it is placed in the buffer after them.
572.
573.It ATTR_CMN_USERACCESS
574A
575.Vt unsigned long
576containing the effective permissions of the current user
577(the calling process's effective UID) for this file system object.
578You can test for read, write, and execute permission using
579.Dv R_OK ,
580.Dv W_OK ,
581and
582.Dv X_OK ,
583respectively. See
584.Xr access 2
585for more details.
586.
587.El
588.
589.Sh VOLUME ATTRIBUTES
590.
591Volume attributes relate to volumes (that is, mounted file systems).
592The following volume attributes are defined.
593.
594.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP
595.
596.It ATTR_VOL_INFO
597For reasons that are not at all obvious, you must set
598.Dv ATTR_VOL_INFO
599in the
600.Fa volattr
601field if you request any other volume attributes.
602This does not result in any attribute data being added to the attribute buffer.
603.
604.It ATTR_VOL_FSTYPE
605A
606.Vt unsigned long
607containing the file system type.
608Equivalent to the
609.Fa f_type
610field of the
611.Vt statfs
612structure returned by
613.Xr statfs 2 .
614Generally not a useful value.
615.
616.It ATTR_VOL_SIGNATURE
617A
618.Vt unsigned long
619containing the volume signature word.
620This value is unique within a given file system type and lets you
621distinguish between different volume formats handled by the same file system.
622See
623.Aq Pa CarbonCore/Files.h
624for more details.
625.
626.It ATTR_VOL_SIZE
627An
628.Vt off_t
629containing the total size of the volume in bytes.
630.
631.It ATTR_VOL_SPACEFREE
632An
633.Vt off_t
634containing the free space on the volume in bytes.
635.
636.It ATTR_VOL_SPACEAVAIL
637An
638.Vt off_t
639containing the space, in bytes, on the volume available to non-privileged processes.
640This is the free space minus the amount of space reserved by the system to prevent critical
641disk exhaustion errors.
642Non-privileged programs, like a disk management tool, should use this value to display the
643space available to the user.
644.Pp
645.Dv ATTR_VOL_SPACEAVAIL
646is to
647.Dv ATTR_VOL_SPACEFREE
648as
649.Fa f_bavail
650is to
651.Fa f_bfree
652in
653.Xr statfs 2 .
654.
655.It ATTR_VOL_MINALLOCATION
656An
657.Vt off_t
658containing the minimum allocation size on the volume in bytes.
659If you create a file containing one byte, it will consume this much space.
660.
661.It ATTR_VOL_ALLOCATIONCLUMP
662An
663.Vt off_t
664containing the allocation clump size on the volume, in bytes.
665As a file is extended, the file system will attempt to allocate
666this much space each time in order to reduce fragmentation.
667.
668.It ATTR_VOL_IOBLOCKSIZE
669A
670.Vt unsigned long
671containing the optimal block size when reading or writing data.
672Equivalent to the
673.Fa f_iosize
674field of the
675.Vt statfs
676structure returned by
677.Xr statfs 2 .
678.
679.It ATTR_VOL_OBJCOUNT
680A
681.Vt unsigned long
682containing the number of file system objects on the volume.
683.
684.It ATTR_VOL_FILECOUNT
685A
686.Vt unsigned long
687containing the number of files on the volume.
688.
689.It ATTR_VOL_DIRCOUNT
690A
691.Vt unsigned long
692containing the number of directories on the volume.
693.
694.It ATTR_VOL_MAXOBJCOUNT
695A
696.Vt unsigned long
697containing the maximum number of file system objects that can be stored on the volume.
698.
699.It ATTR_VOL_MOUNTPOINT
700An
701.Vt attrreference
702structure containing the path to the volume's mount point as a
703UTF-8 encoded, null terminated C string.
704The attribute data length will not be greater than
705.Dv MAXPATHLEN .
706Equivalent to the
707.Fa f_mntonname
708field of the
709.Vt statfs
710structure returned by
711.Xr statfs 2 .
712.
713.It ATTR_VOL_NAME
714(read/write) An
715.Vt attrreference
716structure containing the name of the volume as a
717UTF-8 encoded, null terminated C string.
718The attribute data length will not be greater than
719.Dv NAME_MAX +
7201.
721.Pp
722.
723This attribute is only read/write if the
724.Dv VOL_CAP_INT_VOL_RENAME
725bit is set in the volume capabilities (see below).
726.Pp
727.
728.It ATTR_VOL_MOUNTFLAGS
729A
730.Vt unsigned long
731containing the volume mount flags.
732This is a copy of the value passed to the
733.Fa flags
734parameter of
735.Xr mount 2
736when the volume was mounted.
737Equivalent to the
738.Fa f_flags
739field of the
740.Vt statfs
741structure returned by
742.Xr statfs 2 .
743.
744.It ATTR_VOL_MOUNTEDDEVICE
745An
746.Vt attrreference
747structure that returns the same value as the
748.Fa f_mntfromname
749field of the
750.Vt statfs
751structure returned by
752.Xr statfs 2 .
753For local volumes this is the path to the device on which the volume is mounted as a
754UTF-8 encoded, null terminated C string.
755For network volumes, this is a unique string that identifies the mount.
756The attribute data length will not be greater than
757.Dv MAXPATHLEN .
758.Pp
759.
760.It ATTR_VOL_ENCODINGSUSED
761An
762.Vt unsigned long long
763containing a bitmap of the text encodings used on this volume.
764For more information about this, see the discussion of
765.Fa encodingsBitmap
766in DTS Technote 1150 "HFS Plus Volume Format".
767.
768.It ATTR_VOL_CAPABILITIES
769A
770.Vt vol_capabilities_attr_t
771structure describing the optional features supported by this volume.
772See below for a discussion of volume capabilities.
773.
774.It ATTR_VOL_ATTRIBUTES
775A
776.Vt vol_attributes_attr_t
777structure describing the attributes supported by this volume.
778This structure is discussed below, along with volume capabilities.
779.
780.El
781.
782.Sh DIRECTORY ATTRIBUTES
783.
784The following directory attributes are defined.
785.
786.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP
787.
788.It ATTR_DIR_LINKCOUNT
789A
790.Vt unsigned long
791containing the number of file system objects in the directory, including
792synthetic items such as "." and "..".
793For historical reasons, you should not always rely on this value being accurate.
794.Pp
795If you're implementing a volume format on which this is hard to calculate,
796you should not support this attribute.
797While it's traditional to return a constant value of 1 in the
798.Fa st_nlink
799field of the
800.Vt stat
801structure as returned by
802.Xr stat 2 ,
803it's not necessary to do this here because there is a
804defined way to indicate that you do not support the attribute.
805.
806.It ATTR_DIR_ENTRYCOUNT
807A
808.Vt unsigned long
809containing the number of file system objects in the directory, not including
810any synthetic items.
811.
812.It ATTR_DIR_MOUNTSTATUS
813A
814.Vt unsigned long
815containing flags describing what's mounted on the directory.
816Currently the only flag defined is
817.Dv DIR_MNTSTATUS_MNTPOINT,
818which indicates that there is a file system mounted on this directory.
819Due to a bug (r. 3502822), this flag is never set on current system.
820.
821.El
822.
823.Sh FILE ATTRIBUTES
824.
825The following file attributes are defined.
826.
827.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP
828.
829.It ATTR_FILE_LINKCOUNT
830A
831.Vt unsigned long
832containing the number of hard links to this file.
833Equivalent to the
834.Fa st_nlink
835field of the
836.Vt stat
837structure returned by
838.Xr stat 2 .
839.
840.It ATTR_FILE_TOTALSIZE
841An
842.Vt off_t
843containing the total number of bytes in all forks of the file (the logical size).
844.
845.It ATTR_FILE_ALLOCSIZE
846An
847.Vt off_t
848containing a count of the bytes on disk used by all of the file's forks (the physical size).
849.
850.It ATTR_FILE_IOBLOCKSIZE
851A
852.Vt unsigned long
853containing the optimal block size when reading or writing this file's data.
854.
855.It ATTR_FILE_CLUMPSIZE
856A
857.Vt unsigned long
858containing the allocation clump size for this file, in bytes.
859As the file is extended, the file system will attempt to allocate
860this much space each time in order to reduce fragmentation.
861This value applies to the data fork.
862.
863.It ATTR_FILE_DEVTYPE
864(read/write) A
865.Vt unsigned long
866containing the device type for a special device file.
867Equivalent to the
868.Fa st_rdev
869field of the
870.Vt stat
871structure returned by
872.Xr stat 2 .
873.
874.It ATTR_FILE_FILETYPE
875A
876.Vt unsigned long
877that whose value is reserved.
878Clients should ignore its value.
879New volume format implementations should not support this attribute.
880.
881.It ATTR_FILE_FORKCOUNT
882A
883.Vt unsigned long
884containing the number of forks in the file.
885No built-in file systems on Mac OS X currently support forks other
886than the data and resource fork.
887.
888.It ATTR_FILE_FORKLIST
889An
890.Vt attrreference
891structure containing a list of named forks of the file.
892No built-in file systems on Mac OS X currently support forks
893other than the data and resource fork.
894Because of this, the structure of this attribute's value is not yet defined.
895.
896.It ATTR_FILE_DATALENGTH
897An
898.Vt off_t
899containing the length of the data fork in bytes (the logical size).
900.
901.It ATTR_FILE_DATAALLOCSIZE
902An
903.Vt off_t
904containing a count of the bytes on disk used by the data fork (the physical size).
905.
906.It ATTR_FILE_DATAEXTENTS
907An
908.Vt extentrecord
909array for the data fork.
910The array contains eight
911.Vt diskextent
912structures which represent the first
913eight extents of the fork.
914.Pp
915This attributes exists for compatibility reasons.
916New clients should not use this attribute.
917Rather, they should use the
918.Dv F_LOG2PHYS
919command in
920.Xr fcntl 2 .
921.Pp
922.
923In current implementations the value may not be entirely accurate for
924a variety of reasons.
925.
926.It ATTR_FILE_RSRCLENGTH
927An
928.Vt off_t
929containing the length of the resource fork in bytes (the logical size).
930.
931.It ATTR_FILE_RSRCALLOCSIZE
932An
933.Vt off_t
934containing a count of the bytes on disk used by the resource fork (the physical size).
935.
936.It ATTR_FILE_RSRCEXTENTS
937An
938.Vt extentrecord
939array for the resource fork.
940The array contains eight
941.Vt diskextent
942structures which represent the first
943eight extents of the fork.
944.Pp
945See also
946.Dv ATTR_FILE_DATAEXTENTS .
947.
948.El
949.
950.Sh FORK ATTRIBUTES
951.
952Fork attributes relate to the actual data in the file,
953which can be held in multiple named contiguous ranges, or forks.
954The following fork attributes are defined.
955.
956.Bl -tag -width ATTR_VOL_ALLOCATIONCLUMP
957.
958.It ATTR_FORK_TOTALSIZE
959An
960.Vt off_t
961containing the length of the fork in bytes (the logical size).
962.
963.It ATTR_FORK_ALLOCSIZE
964An
965.Vt off_t
966containing a count of the bytes on disk used by the fork (the physical size).
967.
968.El
969.Pp
970.
971Fork attributes are not properly implemented by any current Mac OS X
972volume format implementation.
973We strongly recommend that client programs do not request fork attributes.
974If you are implementing a volume format, you should not support these attributes.
975.
976.Sh VOLUME CAPABILITIES
977.
978.\" vol_capabilities_attr_t
979.
980Not all volumes support all features. The
981.Dv ATTR_VOL_CAPABILITIES
982attribute returns a
983.Vt vol_capabilities_attr_t
984structure (shown below) that indicates which features are supported by the volume.
985.
986.Bd -literal
987typedef u_int32_t vol_capabilities_set_t[4];
988.Pp
989.
990#define VOL_CAPABILITIES_FORMAT 0
991#define VOL_CAPABILITIES_INTERFACES 1
992#define VOL_CAPABILITIES_RESERVED1 2
993#define VOL_CAPABILITIES_RESERVED2 3
994.Pp
995.
996typedef struct vol_capabilities_attr {
997 vol_capabilities_set_t capabilities;
998 vol_capabilities_set_t valid;
999} vol_capabilities_attr_t;
1000.Ed
1001.Pp
1002.
1003The structure contains two fields,
1004.Fa capabilities
1005and
1006.Fa valid .
1007Each consists of an array of four elements.
1008The arrays are indexed by the following values.
1009.
1010.Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS
1011.
1012.It VOL_CAPABILITIES_FORMAT
1013This element contains information about the volume format.
1014See
1015.Dv VOL_CAP_FMT_PERSISTENTOBJECTIDS
1016and so on, below.
1017.
1018.It VOL_CAPABILITIES_INTERFACES
1019This element contains information about which optional functions are
1020supported by the volume format implementation.
1021See
1022.Dv VOL_CAP_INT_SEARCHFS
1023and so on, below.
1024.
1025.It VOL_CAPABILITIES_RESERVED1
1026Reserved.
1027A file system implementation should set this element to zero.
1028A client program should ignore this element.
1029.
1030.It VOL_CAPABILITIES_RESERVED2
1031Reserved.
1032A file system implementation should set this element to zero.
1033A client program should ignore this element.
1034.
1035.El
1036.Pp
1037.
1038The
1039.Fa valid
1040field contains bit sets that indicate which flags are known to the volume format
1041implementation.
1042Each bit indicates whether the contents of the corresponding bit in the
1043.Fa capabilities
1044field is valid.
1045.Pp
1046.
1047The
1048.Fa capabilities
1049field contains bit sets that indicate whether a particular feature is implemented
1050by this volume format.
1051.Pp
1052.
1053The following bits are defined in the first element (indexed by
1054.Dv VOL_CAPABILITIES_FORMAT )
1055of the
1056.Fa capabilities
1057and
1058.Fa valid
1059fields of the
1060.Vt vol_capabilities_attr_t
1061structure.
1062.
1063.Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS
1064.
1065.It VOL_CAP_FMT_PERSISTENTOBJECTIDS
1066If this bit is set the volume format supports persistent object identifiers
1067and can look up file system objects by their IDs.
1068See
1069.Dv ATTR_CMN_OBJPERMANENTID
1070for details about how to obtain these identifiers.
1071.
1072.It VOL_CAP_FMT_SYMBOLICLINKS
1073If this bit is set the volume format supports symbolic links.
1074.
1075.It VOL_CAP_FMT_HARDLINKS
1076If this bit is set the volume format supports hard links.
1077.
1078.It VOL_CAP_FMT_JOURNAL
1079If this bit is set the volume format supports a journal used to
1080speed recovery in case of unplanned restart (such as a power outage
1081or crash).
1082This does not necessarily mean the volume is actively using a journal.
1083.Pp
1084Introduced with Darwin 7.0 (Mac OS X version 10.3).
1085.
1086.It VOL_CAP_FMT_JOURNAL_ACTIVE
1087If this bit is set the volume is currently using a journal for
1088speedy recovery after an unplanned restart.
1089This bit can be set only if
1090.Dv VOL_CAP_FMT_JOURNAL
1091is also set.
1092.Pp
1093Introduced with Darwin 7.0 (Mac OS X version 10.3).
1094.
1095.It VOL_CAP_FMT_NO_ROOT_TIMES
1096If this bit is set the volume format does not store reliable times for
1097the root directory, so you should not depend on them to detect changes,
1098identify volumes across unmount/mount, and so on.
1099.Pp
1100Introduced with Darwin 7.0 (Mac OS X version 10.3).
1101.
1102.It VOL_CAP_FMT_SPARSE_FILES
1103If this bit is set the volume format supports sparse files,
1104that is, files which can have 'holes' that have never been written
1105to, and thus do not consume space on disk.
1106A sparse file may have an allocated size on disk that is less than its logical length (that is,
1107.Dv ATTR_FILE_ALLOCSIZE
1108<
1109.Dv ATTR_FILE_TOTALSIZE ).
1110.
1111.Pp
1112Introduced with Darwin 7.0 (Mac OS X version 10.3).
1113.
1114.It VOL_CAP_FMT_ZERO_RUNS
1115For security reasons, parts of a file (runs) that have never been
1116written to must appear to contain zeroes.
1117When this bit is set, the volume keeps track of allocated but unwritten
1118runs of a file so that it can substitute zeroes without actually
1119writing zeroes to the media.
1120This provides performance similar to sparse files, but not the space savings.
1121.Pp
1122Introduced with Darwin 7.0 (Mac OS X version 10.3).
1123.
1124.It VOL_CAP_FMT_CASE_SENSITIVE
1125If this bit is set the volume format treats upper and lower case
1126characters in file and directory names as different.
1127Otherwise an upper case character is equivalent to a lower case character,
1128and you can't have two names that differ solely in the case of
1129the characters.
1130.Pp
1131Introduced with Darwin 7.0 (Mac OS X version 10.3).
1132.
1133.It VOL_CAP_FMT_CASE_PRESERVING
1134If this bit is set the volume format preserves the case of
1135file and directory names.
1136Otherwise the volume may change the case of some characters
1137(typically making them all upper or all lower case).
1138A volume that sets
1139.Dv VOL_CAP_FMT_CASE_SENSITIVE
1140must also set
1141.Dv VOL_CAP_FMT_CASE_PRESERVING .
1142.Pp
1143Introduced with Darwin 7.0 (Mac OS X version 10.3).
1144.
1145.It VOL_CAP_FMT_FAST_STATFS
1146This bit is used as a hint to upper layers (specifically the Carbon File Manager) to
1147indicate that
1148.Xr statfs 2
1149is fast enough that its results need not be cached by the caller.
1150A volume format implementation that caches the
1151.Xr statfs 2
1152information in memory should set this bit.
1153An implementation that must always read from disk or always perform a network
1154transaction to satisfy
1155.Xr statfs 2
1156should not set this bit.
1157.Pp
1158Introduced with Darwin 7.0 (Mac OS X version 10.3).
1159.
1160.It VOL_CAP_FMT_2TB_FILESIZE
1161If this bit is set the volume format supports file
1162sizes upto 2TB. This bit does not necessarily mean that the file
1163system does not support file size more than 2TB. This bit does
1164not mean that the currently available space on the volume is 2TB.
1165.Pp
1166Introduced with Darwin 8.0 (Mac OS X version 10.4).
1167.
1168.El
1169.Pp
1170.
1171The following bits are defined in the second element (indexed by
1172.Dv VOL_CAPABILITIES_INTERFACES )
1173of the
1174.Fa capabilities
1175and
1176.Fa valid
1177fields of the
1178.Vt vol_capabilities_attr_t
1179structure.
1180.
1181.Bl -tag -width VOL_CAP_FMT_PERSISTENTOBJECTIDS
1182.
1183.It VOL_CAP_INT_SEARCHFS
1184If this bit is set the volume format implementation supports
1185.Xr searchfs 2 .
1186.
1187.It VOL_CAP_INT_ATTRLIST
1188If this bit is set the volume format implementation supports
1189.Fn getattrlist
1190and
1191.Xr setattrlist 2 .
1192.
1193.It VOL_CAP_INT_NFSEXPORT
1194If this bit is set the volume format implementation allows this volume to be exported via NFS.
1195.
1196.It VOL_CAP_INT_READDIRATTR
1197If this bit is set the volume format implementation supports
1198.Xr getdirentriesattr 2 .
1199.
1200.It VOL_CAP_INT_EXCHANGEDATA
1201If this bit is set the volume format implementation supports
1202.Xr exchangedata 2 .
1203.Pp
1204Introduced with Darwin 7.0 (Mac OS X version 10.3).
1205.
1206.It VOL_CAP_INT_COPYFILE
1207If this bit is set the volume format implementation supports the (private and undocumented)
1208copyfile() function.
1209.Pp
1210Introduced with Darwin 7.0 (Mac OS X version 10.3).
1211.
1212.It VOL_CAP_INT_ALLOCATE
1213If this bit is set the volume format implementation supports the
1214.Dv F_PREALLOCATE
1215selector of
1216.Xr fcntl 2 .
1217.Pp
1218Introduced with Darwin 7.0 (Mac OS X version 10.3).
1219.
1220.It VOL_CAP_INT_VOL_RENAME
1221If this bit is set the volume format implementation allows you to
1222modify the volume name using
1223.Xr setattrlist 2 .
1224.Pp
1225Introduced with Darwin 7.0 (Mac OS X version 10.3).
1226.
1227.It VOL_CAP_INT_ADVLOCK
1228If this bit is set the volume format implementation supports
1229advisory locking, that is, the
1230.Dv F_GETLK ,
1231.Dv F_SETLK ,
1232and
1233.Dv F_SETLKW
1234selectors to
1235.Xr fcntl 2 .
1236.Pp
1237Introduced with Darwin 7.0 (Mac OS X version 10.3).
1238.
1239.It VOL_CAP_INT_FLOCK
1240If this bit is set the volume format implementation supports
1241whole file locks.
1242This includes
1243.Xr flock 2
1244and the
1245.Dv O_EXLOCK
1246and
1247.Dv O_SHLOCK
1248flags to
1249.Xr open 2 .
1250.Pp
1251Introduced with Darwin 7.0 (Mac OS X version 10.3).
1252.
1253.El
1254.Pp
1255.
1256.\" vol_attributes_attr_t
1257.
1258A volume can also report which attributes it supports.
1259This information is returned by the
1260.Dv ATTR_VOL_ATTRIBUTES
1261attribute, which returns a
1262.Vt vol_attributes_attr_t
1263structure (shown below).
1264.
1265.Bd -literal
1266typedef struct attribute_set {
1267 attrgroup_t commonattr; /* common attribute group */
1268 attrgroup_t volattr; /* volume attribute group */
1269 attrgroup_t dirattr; /* directory attribute group */
1270 attrgroup_t fileattr; /* file attribute group */
1271 attrgroup_t forkattr; /* fork attribute group */
1272} attribute_set_t;
1273.Pp
1274.
1275typedef struct vol_attributes_attr {
1276 attribute_set_t validattr;
1277 attribute_set_t nativeattr;
1278} vol_attributes_attr_t;
1279.Ed
1280.Pp
1281.
1282The
1283.Fa validattr
1284field consists of a number of bit sets that indicate whether an attribute is
1285supported by the volume format implementation.
1286The
1287.Fa nativeattr
1288is similar except that the bit sets indicate whether an attribute is supported
1289natively by the volume format.
1290An attribute is supported natively if the volume format implementation does not have to do
1291any complex conversions to access the attribute.
1292For example, a volume format might support persistent object identifiers, but
1293doing so requires a complex table lookup that is not part of the core volume
1294format.
1295In that case, the
1296.Dv ATTR_VOL_ATTRIBUTES
1297attribute would return
1298.Dv ATTR_CMN_OBJPERMANENTID
1299set in the
1300.Fa validattr
1301field of the
1302.Vt vol_attributes_attr_t ,
1303but not in the
1304.Fa nativeattr
1305field.
1306.
1307.Sh RETURN VALUES
1308Upon successful completion a value of 0 is returned.
1309Otherwise, a value of -1 is returned and
1310.Va errno
1311is set to indicate the error.
1312.
1313.Sh COMPATIBILITY
1314Not all volumes support
1315.Fn getattrlist .
1316The best way to test whether a volume supports this function is to
1317simply call it and check the error result.
1318.Fn getattrlist
1319will return
1320.Dv ENOTSUP
1321if it is not supported on a particular volume.
1322.Pp
1323.
1324The
1325.Fn getattrlist
1326function has been undocumented for more than two years.
1327In that time a number of volume format implementations have been created without
1328a proper specification for the behaviour of this routine.
1329You may encounter volume format implementations with slightly different
1330behaviour than what is described here.
1331Your program is expected to be tolerant of this variant behaviour.
1332.Pp
1333.
1334If you're implementing a volume format that supports
1335.Fn getattrlist ,
1336you should be careful to support the behaviour specified by this document.
1337.
1338.Sh ERRORS
1339.Fn getattrlist
1340will fail if:
1341.Bl -tag -width Er
1342.
1343.It Bq Er ENOTSUP
1344The volume does not support
1345.Fn getattrlist .
1346.
1347.It Bq Er ENOTDIR
1348A component of the path prefix is not a directory.
1349.
1350.It Bq Er ENAMETOOLONG
1351A component of a path name exceeded
1352.Dv NAME_MAX
1353characters, or an entire path name exceeded
1354.Dv PATH_MAX
1355characters.
1356.
1357.It Bq Er ENOENT
1358The file system object does not exist.
1359.
1360.It Bq Er EACCES
1361Search permission is denied for a component of the path prefix.
1362.
1363.It Bq Er ELOOP
1364Too many symbolic links were encountered in translating the pathname.
1365.
1366.It Bq Er EFAULT
1367.Fa path ,
1368.Fa attrList
1369or
1370.Em attrBuf
1371points to an invalid address.
1372.
1373.It Bq Er EINVAL
1374The
1375.Fa bitmapcount
1376field of
1377.Fa attrList
1378is not
1379.Dv ATTR_BIT_MAP_COUNT .
1380.
1381.It Bq Er EINVAL
1382You requested an invalid attribute.
1383.
1384.It Bq Er EINVAL
1385You requested an attribute that is not supported for this file system object.
1386.
1387.It Bq Er EINVAL
1388You requested volume attributes and directory or file attributes.
1389.
1390.It Bq Er EINVAL
1391You requested volume attributes but
1392.Fa path
1393does not reference the root of the volume.
1394.
1395.It Bq Er EROFS
1396The volume is read-only but must be modified in order to return this attribute.
1397.
1398.It Bq Er EIO
1399An I/O error occurred while reading from or writing to the file system.
1400.El
1401.Pp
1402.
1403.Sh CAVEATS
1404.
1405If you request any volume attributes, you must set
1406.Dv ATTR_VOL_INFO
1407in the
1408.Fa volattr
1409field, even though it generates no result in the attribute buffer.
1410.Pp
1411.
1412The order that attributes are stored in the attribute buffer almost
1413invariably matches the order of attribute mask bit values.
1414For example,
1415.Dv ATTR_CMN_NAME
1416(0x00000001) comes before
1417.Dv ATTR_CMN_DEVID
1418(0x00000002) because its value is smaller.
1419However, you can not rely on this ordering because there is one key exception:
1420.Dv ATTR_CMN_FLAGS
1421is placed after the
1422.Dv ATTR_CMN_NAMEDATTRCOUNT
1423/
1424.Dv ATTR_CMN_NAMEDATTRLIST
1425pair, even though its bit position indicates that it should come before.
1426This is due to a bug in an early version of Mac OS X that can't be fixed for
1427binary compatibility reasons.
1428When ordering attributes, you should always use the order in which they
1429are described above.
1430.Pp
1431.
1432For more caveats, see also the compatibility notes above.
1433.
1434.Sh EXAMPLES
1435.
1436The following code prints the file type and creator of a file,
1437assuming that the volume supports the required attributes.
1438.
1439.Bd -literal
1440#include <assert.h>
1441#include <stdio.h>
1442#include <string.h>
1443#include <sys/attr.h>
1444#include <sys/errno.h>
1445#include <unistd.h>
1446#include <sys/vnode.h>
1447.Pp
1448.
1449typedef struct attrlist attrlist_t;
1450.Pp
1451.
1452struct FInfoAttrBuf {
1453 unsigned long length;
1454 fsobj_type_t objType;
1455 char finderInfo[32];
1456};
1457typedef struct FInfoAttrBuf FInfoAttrBuf;
1458.Pp
1459.
1460static int FInfoDemo(const char *path)
1461{
1462 int err;
1463 attrlist_t attrList;
1464 FInfoAttrBuf attrBuf;
1465.Pp
1466.
1467 memset(&attrList, 0, sizeof(attrList));
1468 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
1469 attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
1470.Pp
1471
1472 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0);
1473 if (err != 0) {
1474 err = errno;
1475 }
1476.Pp
1477
1478 if (err == 0) {
1479 assert(attrBuf.length == sizeof(attrBuf));
1480.Pp
1481
1482 printf("Finder information for %s:\en", path);
1483 switch (attrBuf.objType) {
1484 case VREG:
1485 printf("file type = '%.4s'\en", &attrBuf.finderInfo[0]);
1486 printf("file creator = '%.4s'\en", &attrBuf.finderInfo[4]);
1487 break;
1488 case VDIR:
1489 printf("directory\en");
1490 break;
1491 default:
1492 printf("other object type, %d\en", attrBuf.objType);
1493 break;
1494 }
1495 }
1496.Pp
1497.
1498 return err;
1499}
1500.Ed
1501.Pp
1502.
1503The following code is an alternative implementation that uses nested structures
1504to group the related attributes.
1505.
1506.Bd -literal
1507#include <assert.h>
1508#include <stdio.h>
1509#include <stddef.h>
1510#include <string.h>
1511#include <sys/attr.h>
1512#include <sys/errno.h>
1513#include <unistd.h>
1514#include <sys/vnode.h>
1515.Pp
1516.
1517typedef struct attrlist attrlist_t;
1518.Pp
1519.
1520struct FInfo2CommonAttrBuf {
1521 fsobj_type_t objType;
1522 char finderInfo[32];
1523};
1524typedef struct FInfo2CommonAttrBuf FInfo2CommonAttrBuf;
1525.Pp
1526.
1527struct FInfo2AttrBuf {
1528 unsigned long length;
1529 FInfo2CommonAttrBuf common;
1530};
1531typedef struct FInfo2AttrBuf FInfo2AttrBuf;
1532.Pp
1533.
1534static int FInfo2Demo(const char *path)
1535{
1536 int err;
1537 attrlist_t attrList;
1538 FInfo2AttrBuf attrBuf;
1539.Pp
1540.
1541 memset(&attrList, 0, sizeof(attrList));
1542 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
1543 attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
1544.Pp
1545.
1546 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0);
1547 if (err != 0) {
1548 err = errno;
1549 }
1550.Pp
1551.
1552 if (err == 0) {
1553 assert(attrBuf.length == sizeof(attrBuf));
1554.Pp
1555.
1556 printf("Finder information for %s:\en", path);
1557 switch (attrBuf.common.objType) {
1558 case VREG:
1559 printf(
1560 "file type = '%.4s'\en",
1561 &attrBuf.common.finderInfo[0]
1562 );
1563 printf(
1564 "file creator = '%.4s'\en",
1565 &attrBuf.common.finderInfo[4]
1566 );
1567 break;
1568 case VDIR:
1569 printf("directory\en");
1570 break;
1571 default:
1572 printf(
1573 "other object type, %d\en",
1574 attrBuf.common.objType
1575 );
1576 break;
1577 }
1578 }
1579.Pp
1580.
1581 return err;
1582}
1583.Ed
1584.Pp
1585.
1586The following example shows how to deal with variable length attributes.
1587It assumes that the volume specified by
1588.Fa path
1589supports the necessary attributes.
1590.
1591.Bd -literal
1592#include <assert.h>
1593#include <stdio.h>
1594#include <stddef.h>
1595#include <string.h>
1596#include <sys/attr.h>
1597#include <sys/errno.h>
1598#include <unistd.h>
1599#include <sys/vnode.h>
1600.Pp
1601.
1602typedef struct attrlist attrlist_t;
1603.Pp
1604.
1605struct VolAttrBuf {
1606 unsigned long length;
1607 unsigned long fileCount;
1608 unsigned long dirCount;
1609 attrreference_t mountPointRef;
1610 attrreference_t volNameRef;
1611 char mountPointSpace[MAXPATHLEN];
1612 char volNameSpace[MAXPATHLEN];
1613};
1614typedef struct VolAttrBuf VolAttrBuf;
1615.Pp
1616.
1617static int VolDemo(const char *path)
1618{
1619 int err;
1620 attrlist_t attrList;
1621 VolAttrBuf attrBuf;
1622.Pp
1623.
1624 memset(&attrList, 0, sizeof(attrList));
1625 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
1626 attrList.volattr = ATTR_VOL_INFO
1627 | ATTR_VOL_FILECOUNT
1628 | ATTR_VOL_DIRCOUNT
1629 | ATTR_VOL_MOUNTPOINT
1630 | ATTR_VOL_NAME;
1631.Pp
1632
1633 err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0);
1634 if (err != 0) {
1635 err = errno;
1636 }
1637.Pp
1638
1639 if (err == 0) {
1640 assert(attrBuf.length > offsetof(VolAttrBuf, mountPointSpace));
1641 assert(attrBuf.length <= sizeof(attrBuf));
1642.Pp
1643
1644 printf("Volume information for %s:\en", path);
1645 printf("ATTR_VOL_FILECOUNT: %lu\en", attrBuf.fileCount);
1646 printf("ATTR_VOL_DIRCOUNT: %lu\en", attrBuf.dirCount);
1647 printf(
1648 "ATTR_VOL_MOUNTPOINT: %.*s\en",
1649 (int) attrBuf.mountPointRef.attr_length,
1650 ( ((char *) &attrBuf.mountPointRef)
1651 + attrBuf.mountPointRef.attr_dataoffset )
1652 );
1653 printf(
1654 "ATTR_VOL_NAME: %.*s\en",
1655 (int) attrBuf.volNameRef.attr_length,
1656 ( ((char *) &attrBuf.volNameRef)
1657 + attrBuf.volNameRef.attr_dataoffset )
1658 );
1659 }
1660.Pp
1661.
1662 return err;
1663}
1664.Ed
1665.Pp
1666.
1667.Sh SEE ALSO
1668.
1669.Xr access 2 ,
1670.Xr chflags 2 ,
1671.Xr exchangedata 2 ,
1672.Xr fcntl 2 ,
1673.Xr getdirentriesattr 2 ,
1674.Xr mount 2 ,
1675.Xr searchfs 2 ,
1676.Xr setattrlist 2 ,
1677.Xr stat 2 ,
1678.Xr statfs 2
1679.
1680.Sh HISTORY
1681A
1682.Fn getattrlist
1683function call appeared in Darwin 1.3.1 (Mac OS X version 10.0).
1684.