OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / listxattr.2
1 .\" Copyright (C) Andreas Gruenbacher, February 2001
2 .\" Copyright (C) Silicon Graphics Inc, September 2001
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\" %%%LICENSE_END
24 .\"
25 .TH LISTXATTR 2 2014-02-06 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 listxattr, llistxattr, flistxattr \- list extended attribute names
28 .SH SYNOPSIS
29 .fam C
30 .nf
31 .B #include <sys/types.h>
32 .B #include <sys/xattr.h>
33 .sp
34 .BI "ssize_t listxattr(const char\ *" path ", char\ *" list \
35 ", size_t " size );
36 .BI "ssize_t llistxattr(const char\ *" path ", char\ *" list \
37 ", size_t " size );
38 .BI "ssize_t flistxattr(int " fd ", char\ *" list ", size_t " size );
39 .fi
40 .fam T
41 .SH DESCRIPTION
42 Extended attributes are name:value
43 pairs associated with inodes (files, directories, symbolic links, etc.).
44 They are extensions to the normal attributes which are associated
45 with all inodes in the system (i.e., the
46 .BR stat (2)
47 data).
48 A complete overview of extended attributes concepts can be found in
49 .BR attr (5).
50 .PP
51 .BR listxattr ()
52 retrieves the list
53 of extended attribute names associated with the given
54 .I path
55 in the filesystem.
56 The retrieved list is placed in
57 .IR list ,
58 a caller-allocated buffer whose size (in bytes) is specified in the argument
59 .IR size .
60 The list is the set of (null-terminated) names, one after the other.
61 Names of extended attributes to which the calling process does not
62 have access may be omitted from the list.
63 The length of the attribute name
64 .I list
65 is returned.
66 .PP
67 .BR llistxattr ()
68 is identical to
69 .BR listxattr (),
70 except in the case of a symbolic link, where the list of names of
71 extended attributes associated with the link itself is retrieved,
72 not the file that it refers to.
73 .PP
74 .BR flistxattr ()
75 is identical to
76 .BR listxattr (),
77 only the open file referred to by
78 .I fd
79 (as returned by
80 .BR open (2))
81 is interrogated in place of
82 .IR path .
83 .PP
84 A single extended attribute
85 .I name
86 is a simple null-terminated string.
87 The name includes a namespace prefix; there may be several, disjoint
88 namespaces associated with an individual inode.
89 .PP
90 An empty buffer of
91 .I size
92 zero can be passed into these calls to return the current size of the
93 list of extended attribute names, which can be used to estimate the
94 size of a buffer which is sufficiently large to hold the list of names.
95 .SS Example
96 The
97 .I list
98 of names is returned as an unordered array of null-terminated character
99 strings (attribute names are separated by null bytes (\(aq\\0\(aq)), like this:
100 .fam C
101 .RS
102 .nf
103
104 user.name1\\0system.name1\\0user.name2\\0
105 .fi
106 .RE
107 .fam T
108 .P
109 Filesystems like ext2, ext3 and XFS which implement POSIX ACLs using
110 extended attributes, might return a
111 .I list
112 like this:
113 .fam C
114 .RS
115 .nf
116
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 nonnegative 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 .SH ERRORS
128 .TP
129 .B ENOTSUP
130 Extended attributes are not supported by the filesystem, or are disabled.
131 .TP
132 .B ERANGE
133 The
134 .I size
135 of the
136 .I list
137 buffer is too small to hold the result.
138 .PP
139 In addition, the errors documented in
140 .BR stat (2)
141 can also occur.
142 .SH VERSIONS
143 These system calls have been available on Linux since kernel 2.4;
144 glibc support is provided since version 2.3.
145 .SH CONFORMING TO
146 These system calls are Linux-specific.
147 .\" .SH AUTHORS
148 .\" Andreas Gruenbacher,
149 .\" .RI < a.gruenbacher@computer.org >
150 .\" and the SGI XFS development team,
151 .\" .RI < linux-xfs@oss.sgi.com >.
152 .\" Please send any bug reports or comments to these addresses.
153 .SH SEE ALSO
154 .BR getfattr (1),
155 .BR setfattr (1),
156 .BR getxattr (2),
157 .BR open (2),
158 .BR removexattr (2),
159 .BR setxattr (2),
160 .BR stat (2),
161 .BR attr (5),
162 .BR symlink (7)
163 .SH COLOPHON
164 This page is part of release 3.79 of the Linux
165 .I man-pages
166 project.
167 A description of the project,
168 information about reporting bugs,
169 and the latest version of this page,
170 can be found at
171 \%http://www.kernel.org/doc/man\-pages/.