2 .\" Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 .\" @APPLE_LICENSE_HEADER_START@
6 .\" This file contains Original Code and/or Modifications of Original Code
7 .\" as defined in and that are subject to the Apple Public Source License
8 .\" Version 2.0 (the 'License'). You may not use this file except in
9 .\" compliance with the License. Please obtain a copy of the License at
10 .\" http://www.opensource.apple.com/apsl/ and read it before using this
13 .\" The Original Code and all software distributed under the License are
14 .\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 .\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 .\" Please see the License for the specific language governing rights and
19 .\" limitations under the License.
21 .\" @APPLE_LICENSE_HEADER_END@
29 .Nd get an extended attribute value
31 .Fd #include <sys/xattr.h>
33 .Fn getxattr "const char *path" "const char *name" "void *value" "size_t size" "u_int32_t position" "int options"
35 .Fn fgetxattr "int fd" "const char *name" "void *value" "size_t size" "u_int32_t position" "int options"
37 Extended attributes extend the basic attributes of files and
38 directories in the file system. They are stored as name:data pairs
39 associated with file system objects (files, directories, symlinks, etc).
43 function retrieves up to
45 bytes of data from the extended attribute identified by
49 into the pre-allocated buffer pointed to by
51 The function returns the number of bytes of data retrieved.
53 An extended attribute's
55 is a simple NULL-terminated UTF-8 string.
57 specifies an offset within the extended attribute. In the current
58 implementation, this argument is only used with the resource fork attribute.
59 For all other extended attributes, this parameter is reserved and should
64 contains the data associated with
70 returns current size of the named attribute. This facility can be used
71 to determine the size of a buffer sufficiently large to hold the data
72 currently associated with the attribute.
75 specify options for retrieving extended attributes:
77 .Bl -tag -width XATTR_NOFOLLOW
79 do not follow symbolic links.
81 normally returns information from the target of
83 if it is a symbolic link. With this option,
85 will return extended attribute data from the symbolic link instead.
86 .It Dv XATTR_SHOWCOMPRESSION
90 will return HFS Plus Compression extended attribute
92 (if present) for the file referred to by
101 except that it retrieves extended attribute data from the open file
102 referenced by the file descriptor
105 On success, the size of the extended attribute data is returned. On
106 failure, -1 is returned and the global variable
112 The extended attribute does not exist.
114 The file system does not support extended attributes or has the feature
120 is too small to hold the extended attribute data.
122 The named attribute is not permitted for this type of object.
127 has an unsupported bit set.
132 do not refer to a regular file and the attribute in question is only
133 applicable to files. Similar to EPERM.
137 prefix is not a directory.
138 .It Bq Er ENAMETOOLONG
143 UTF-8 bytes, or a component of
147 characters, or the entire
153 Search permission is denied for a component of
155 or the attribute is not allowed to be read (e.g. an ACL prohibits reading
156 the attributes of this file).
158 Too many symbolic links were encountered in translating the pathname.
163 points to an invalid address.
165 An I/O error occurred while reading from or writing to the file system.
175 first appeared in Mac OS X 10.4.