Copyright (c) 2004 Apple Computer, Inc. All rights reserved.

@APPLE_LICENSE_HEADER_START@

This file contains Original Code and/or Modifications of Original Code
as defined in and that are subject to the Apple Public Source License
Version 2.0 (the 'License'). You may not use this file except in
compliance with the License. Please obtain a copy of the License at
http://www.opensource.apple.com/apsl/ and read it before using this
file.

The Original Code and all software distributed under the License are
distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
Please see the License for the specific language governing rights and
limitations under the License.

@APPLE_LICENSE_HEADER_END@

.Dd Oct 19, 2004 .Dt LISTXATTR 2 .Os "Mac OS X" .Sh NAME .Nm listxattr, .Nm flistxattr .Nd list extended attribute names .Sh SYNOPSIS .Fd #include <sys/xattr.h> .Ft ssize_t .Fn listxattr "const char *path" "char *namebuf" "size_t size" "int options" .Ft ssize_t .Fn flistxattr "int fd" "char *namebuf" "size_t size" "int options" .Sh DESCRIPTION Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

p .Fn listxattr retrieves a list of names of extended attributes associated with the given .Fa path in the file system.

p .Fa namebuf is a data buffer of

a size bytes for the names of the extended attributes associated with .Fa path . The extended attribute names are simple NULL-terminated UTF-8 strings and are returned in arbitrary order. No extra padding is provided between names in the buffer. The list will only include names of extended attributes to which the calling process has access. The function returns the size of the list of names.

p .Fa options controls how the attribute list is generated:

p l -tag -width XATTR_NOFOLLOW t Dv XATTR_NOFOLLOW do not follow symbolic links. .Fn listxattr normally lists attributes of the target of .Fa path if it is a symbolic link. With this option, .Fn listxattr will list attributes of the link itself. t Dv XATTR_SHOWCOMPRESSION .Fn listxattr and .Fn flistxattr will list HFS Plus Compression extended attribute(s) (if present) for the file referred to by .Fa path or .Fa fd . .El

p If .Fa namebuf is set to NULL, the function returns the size of the list of extended attribute names. This facility can be used to determine the size of a buffer sufficiently large to hold the names of the attributes currently associated with .Fa path .

p .Fn flistxattr is identical to .Fn listxattr , except that it returns the list of extended attribute names associated with the open file referenced by file descriptor .Fa fd . .Sh RETURN VALUES On success, the size of the extended attribute name list is returned. If no accessible extended attributes are associated with the given .Fa path or .Fa fd , the function returns zero. On failure, -1 is returned and the global variable .Va errno is set as follows. .Sh ERRORS l -tag -width Er t Bq Er ENOTSUP The file system does not support extended attributes or has the feature disabled. t Bq Er ERANGE .Fa namebuf (as indicated by .Fa size ) is too small to hold the list of names. t Bq Er EPERM .Fa path or .Fa fd refer to a file system object that does not support extended attributes. For example, resource forks don't support extended attributes. If only EFTYPE was a POSIX error
t Bq Er ENOTDIR A component of .Fa path 's prefix is not a directory. t Bq Er ENAMETOOLONG .Fa name exceeds .Dv XATTR_MAXNAMELEN UTF-8 bytes, or a component of .Fa path exceeds .Dv NAME_MAX characters, or the entire .Fa path exceeds .Dv PATH_MAX characters. t Bq Er EACCES Search permission is denied for a component of .Fa path or permission is denied to read the list of attributes from this file. t Bq Er ELOOP Too many symbolic links were encountered resolving .Fa path . t Bq Er EFAULT .Fa path points to an invalid address. t Bq Er EIO An I/O error occurred. t Bq Er EINVAL .Fa options does not make sense. .El .Sh SEE ALSO .Xr getxattr 2 , .Xr removexattr 2 , .Xr setxattr 2 .Sh HISTORY .Fn listxattr and .Fn flistxattr first appeared in Mac OS X 10.4.