1LISTXATTR(2) System calls LISTXATTR(2)
2
3
4
6 listxattr, llistxattr, flistxattr - list extended attribute names
7
9 #include <sys/types.h>
10 #include <attr/xattr.h>
11
12 ssize_t listxattr (const char *path,
13 char *list, size_t size);
14 ssize_t llistxattr (const char *path,
15 char *list, size_t size);
16 ssize_t flistxattr (int filedes,
17 char *list, size_t size);
18
20 Extended attributes are name:value pairs associated with inodes (files,
21 directories, symlinks, etc). They are extensions to the normal
22 attributes which are associated with all inodes in the system (i.e. the
23 stat(2) data). A complete overview of extended attributes concepts can
24 be found in attr(5).
25
26 listxattr retrieves the list of extended attribute names associated
27 with the given path in the filesystem. The list is the set of (NULL-
28 terminated) names, one after the other. Names of extended attributes
29 to which the calling process does not have access may be omitted from
30 the list. The length of the attribute name list is returned.
31
32 llistxattr is identical to listxattr, except in the case of a symbolic
33 link, where the list of names of extended attributes associated with
34 the link itself is retrieved, not the file that it refers to. list is
35 a caller-allocated buffer of size size.
36
37 flistxattr is identical to listxattr, only the open file pointed to by
38 filedes (as returned by open(2)) is interrogated in place of path.
39
40 A single extended attribute name is a simple NULL-terminated string.
41 The name includes a namespace prefix - there may be several, disjoint
42 namespaces associated with an individual inode.
43
44 An empty buffer of size zero can be passed into these calls to return
45 the current size of the list of extended attribute names, which can be
46 used to estimate the size of a buffer which is sufficiently large to
47 hold the list of names.
48
50 The list of names is returned as an unordered array of NULL-terminated
51 character strings (attribute names are separated by NULL characters),
52 like this:
53 user.name1\0system.name1\0user.name2\0
54
55 Filesystems like ext2, ext3 and XFS which implement POSIX ACLs using
56 extended attributes, might return a list like this:
57 system.posix_acl_access\0system.posix_acl_default\0
58
60 On success, a positive number is returned indicating the size of the
61 extended attribute name list. On failure, -1 is returned and errno is
62 set appropriately.
63
64 If the size of the list buffer is too small to hold the result, errno
65 is set to ERANGE.
66
67 If extended attributes are not supported by the filesystem, or are dis‐
68 abled, errno is set to ENOTSUP.
69
70 The errors documented for the stat(2) system call are also applicable
71 here.
72
74 Andreas Gruenbacher, <a.gruenbacher@bestbits.at> and the SGI XFS devel‐
75 opment team, <linux-xfs@oss.sgi.com>. Please send any bug reports or
76 comments to these addresses.
77
79 getfattr(1), setfattr(1), open(2), stat(2), getxattr(2), setxattr(2),
80 removexattr(2), and attr(5).
81
82
83
84Dec 2001 Extended Attributes LISTXATTR(2)