OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[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 2013-01-27 "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 <attr/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
53 .I list
54 of extended attribute names associated with the given
55 .I path
56 in the file system.
57 The list is the set of (null-terminated) names, one after the other.
58 Names of extended attributes to which the calling process does not
59 have access may be omitted from the list.
60 The length of the attribute name
61 .I list
62 is returned.
63 .PP
64 .BR llistxattr ()
65 is identical to
66 .BR listxattr (),
67 except in the case of a symbolic link, where the list of names of
68 extended attributes associated with the link itself is retrieved,
69 not the file that it refers to.
70 .PP
71 .BR flistxattr ()
72 is identical to
73 .BR listxattr (),
74 only the open file referred to by
75 .I fd
76 (as returned by
77 .BR open (2))
78 is interrogated in place of
79 .IR path .
80 .PP
81 A single extended attribute
82 .I name
83 is a simple null-terminated string.
84 The name includes a namespace prefix; there may be several, disjoint
85 namespaces associated with an individual inode.
86 .PP
87 An empty buffer of
88 .I size
89 zero can be passed into these calls to return the current size of the
90 list of extended attribute names, which can be used to estimate the
91 size of a buffer which is sufficiently large to hold the list of names.
92 .SS Example
93 The
94 .I list
95 of names is returned as an unordered array of null-terminated character
96 strings (attribute names are separated by null bytes (\(aq\\0\(aq)), like this:
97 .fam C
98 .RS
99 .nf
100
101 user.name1\\0system.name1\\0user.name2\\0
102 .fi
103 .RE
104 .fam T
105 .P
106 Filesystems like ext2, ext3 and XFS which implement POSIX ACLs using
107 extended attributes, might return a
108 .I list
109 like this:
110 .fam C
111 .RS
112 .nf
113
114 system.posix_acl_access\\0system.posix_acl_default\\0
115 .fi
116 .RE
117 .fam T
118 .SH RETURN VALUE
119 On success, a nonnegative number is returned indicating the size of the
120 extended attribute name list.
121 On failure, \-1 is returned and
122 .I errno
123 is set appropriately.
124 .SH ERRORS
125 .TP
126 .B ENOTSUP
127 Extended attributes are not supported by the file system, or are disabled.
128 .TP
129 .B ERANGE
130 The
131 .I size
132 of the
133 .I list
134 buffer is too small to hold the result.
135 .PP
136 In addition, the errors documented in
137 .BR stat (2)
138 can also occur.
139 .SH VERSIONS
140 These system calls have been available on Linux since kernel 2.4;
141 glibc support is provided since version 2.3.
142 .SH CONFORMING TO
143 These system calls are Linux-specific.
144 .\" .SH AUTHORS
145 .\" Andreas Gruenbacher,
146 .\" .RI < a.gruenbacher@computer.org >
147 .\" and the SGI XFS development team,
148 .\" .RI < linux-xfs@oss.sgi.com >.
149 .\" Please send any bug reports or comments to these addresses.
150 .SH SEE ALSO
151 .BR getfattr (1),
152 .BR setfattr (1),
153 .BR getxattr (2),
154 .BR open (2),
155 .BR removexattr (2),
156 .BR setxattr (2),
157 .BR stat (2),
158 .BR attr (5),
159 .BR symlink (7)