GETXATTR(2) | System Calls Manual | GETXATTR(2) |
getxattr,
fgetxattr
— get an extended
attribute value
#include
<sys/xattr.h>
ssize_t
getxattr
(const
char *path, const char
*name, void *value,
size_t size,
u_int32_t position,
int options);
ssize_t
fgetxattr
(int
fd, const char
*name, void *value,
size_t size,
u_int32_t position,
int options);
Extended attributes extend the basic attributes of files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).
The
getxattr
()
function retrieves up to size bytes of data from the
extended attribute identified by name associated with
path into the pre-allocated buffer pointed to by
value. The function returns the number of bytes of
data retrieved.
An extended attribute's name is a simple NULL-terminated UTF-8 string. position specifies an offset within the extended attribute. In the current implementation, this argument is only used with the resource fork attribute. For all other extended attributes, this parameter is reserved and should be zero.
On success, value contains
the data associated with name. When
value is set to NULL,
getxattr
()
returns current size of the named attribute. This facility can be used to
determine the size of a buffer sufficiently large to hold the data currently
associated with the attribute.
options specify options for retrieving extended attributes:
XATTR_NOFOLLOW
getxattr
()
normally returns information from the target of path
if it is a symbolic link. With this option,
getxattr
() will return extended attribute data
from the symbolic link instead.XATTR_NOFOLLOW_ANY
XATTR_SHOWCOMPRESSION
getxattr
() and fgetxattr
()
will return HFS Plus Compression extended attribute
name (if present) for the file referred to by
path or fd.fgetxattr
()
is identical to getxattr
(), except that it retrieves
extended attribute data from the open file referenced by the file descriptor
fd.
On success, the size of the extended attribute data is returned. On failure, -1 is returned and the global variable errno is set as follows.
ENOATTR
]ENOTSUP
]ERANGE
]EPERM
]EINVAL
]EINVAL
]fgetxattr
().EISDIR
]ENOTDIR
]ENAMETOOLONG
]XATTR_MAXNAMELEN
UTF-8 bytes, or a component of
path exceeds NAME_MAX
characters, or the entire path exceeds
PATH_MAX
characters.EACCES
]ELOOP
]ELOOP
]EFAULT
]EIO
]getxattr
() and
fgetxattr
() first appeared in Mac OS X 10.4.
October 19, 2004 | Mac OS X |