Imported Upstream version 2.4.46
[platform/upstream/attr.git] / man / man2 / listxattr.2
1 .\"
2 .\" Extended attributes system calls manual pages
3 .\"
4 .\" (C) Andreas Gruenbacher, February 2001
5 .\" (C) Silicon Graphics Inc, September 2001
6 .\"
7 .\" This is free documentation; you can redistribute it and/or
8 .\" modify it under the terms of the GNU General Public License as
9 .\" published by the Free Software Foundation; either version 2 of
10 .\" the License, or (at your option) any later version.
11 .\"
12 .\" The GNU General Public License's references to "object code"
13 .\" and "executables" are to be interpreted as the output of any
14 .\" document formatting or typesetting system, including
15 .\" intermediate and printed output.
16 .\"
17 .\" This manual is distributed in the hope that it will be useful,
18 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 .\" GNU General Public License for more details.
21 .\"
22 .\" You should have received a copy of the GNU General Public
23 .\" License along with this manual.  If not, see
24 .\" <http://www.gnu.org/licenses/>.
25 .\"
26 .TH LISTXATTR 2 "Extended Attributes" "Dec 2001" "System calls"
27 .SH NAME
28 listxattr, llistxattr, flistxattr \- list extended attribute names
29 .SH SYNOPSIS
30 .fam C
31 .nf
32 .B #include <sys/types.h>
33 .B #include <attr/xattr.h>
34 .sp
35 .BI "ssize_t listxattr (const char\ *" path ",
36 .BI "\t\t\t\t char\ *" list ", size_t " size );
37 .BI "ssize_t llistxattr (const char\ *" path ",
38 .BI "\t\t\t\t char\ *" list ", size_t " size );
39 .BI "ssize_t flistxattr (int " filedes ",
40 .BI "\t\t\t\t char\ *" list ", size_t " size );
41 .fi
42 .fam T
43 .SH DESCRIPTION
44 Extended attributes are name:value
45 pairs associated with inodes (files, directories, symlinks, etc).
46 They are extensions to the normal attributes which are associated
47 with all inodes in the system (i.e. the
48 .BR stat (2)
49 data).
50 A complete overview of extended attributes concepts can be found in
51 .BR attr (5).
52 .PP
53 .B listxattr
54 retrieves the
55 .I list
56 of extended attribute names associated with the given
57 .I path
58 in the filesystem.
59 The list is the set of (NULL-terminated) names, one after the other.
60 Names of extended attributes to which the calling process does not
61 have access may be omitted from the list.
62 The length of the attribute name
63 .I list
64 is returned.
65 .PP
66 .B llistxattr
67 is identical to
68 .BR listxattr ,
69 except in the case of a symbolic link, where the list of names of
70 extended attributes associated with the link itself is retrieved,
71 not the file that it refers to.
72 .I list
73 is a caller-allocated buffer of size
74 .IR size .
75 .PP
76 .B flistxattr
77 is identical to
78 .BR listxattr ,
79 only the open file pointed to by
80 .I filedes
81 (as returned by
82 .BR open (2))
83 is interrogated in place of
84 .IR path .
85 .PP
86 A single extended attribute
87 .I name
88 is a simple NULL-terminated string.
89 The name includes a namespace prefix \- there may be several, disjoint
90 namespaces associated with an individual inode.
91 .PP
92 An empty buffer of
93 .I size
94 zero can be passed into these calls to return the current size of the
95 list of extended attribute names, which can be used to estimate the
96 size of a buffer which is sufficiently large to hold the list of names.
97 .SH EXAMPLES
98 The
99 .I list
100 of names is returned as an unordered array of NULL-terminated character
101 strings (attribute names are separated by NULL characters), like this:
102 .fam C
103 .RS
104 .nf
105 user.name1\\0system.name1\\0user.name2\\0
106 .fi
107 .RE
108 .fam T
109 .P
110 Filesystems like ext2, ext3 and XFS which implement POSIX ACLs using
111 extended attributes, might return a
112 .I list
113 like this:
114 .fam C
115 .RS
116 .nf
117 system.posix_acl_access\\0system.posix_acl_default\\0
118 .fi
119 .RE
120 .fam T
121 .SH RETURN VALUE
122 On success, a positive number is returned indicating the size of the
123 extended attribute name list.
124 On failure, \-1 is returned and
125 .I errno
126 is set appropriately.
127 .PP
128 If the
129 .I size
130 of the
131 .I list
132 buffer is too small to hold the result,
133 .I errno
134 is set to ERANGE.
135 .PP
136 If extended attributes are not supported by the filesystem, or are disabled,
137 .I errno
138 is set to ENOTSUP.
139 .PP
140 The errors documented for the
141 .BR stat (2)
142 system call are also applicable here.
143 .SH AUTHORS
144 Andreas Gruenbacher,
145 .RI < a.gruenbacher@bestbits.at >
146 and the SGI XFS development team,
147 .RI < linux-xfs@oss.sgi.com >.
148 Please send any bug reports or comments to these addresses.
149 .SH SEE ALSO
150 .BR getfattr (1),
151 .BR setfattr (1),
152 .BR open (2),
153 .BR stat (2),
154 .BR getxattr (2),
155 .BR setxattr (2),
156 .BR removexattr (2),
157 and
158 .BR attr (5).