OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / getxattr.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 GETXATTR 2 2014-04-06 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 getxattr, lgetxattr, fgetxattr \- retrieve an extended attribute value
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 getxattr(const char\ *" path ", const char\ *" name ,
35 .BI "                 void\ *" value ", size_t " size );
36 .BI "ssize_t lgetxattr(const char\ *" path ", const char\ *" name ,
37 .BI "                 void\ *" value ", size_t " size );
38 .BI "ssize_t fgetxattr(int " fd ", const char\ *" name ,
39 .BI "                 void\ *" value ", size_t " size );
40 .fi
41 .fam T
42 .SH DESCRIPTION
43 Extended attributes are
44 .IR name :\c
45 .I value
46 pairs associated with inodes (files, directories, symbolic links, etc.).
47 They are extensions to the normal attributes which are associated
48 with all inodes in the system (i.e., the
49 .BR stat (2)
50 data).
51 A complete overview of extended attributes concepts can be found in
52 .BR attr (5).
53 .PP
54 .BR getxattr ()
55 retrieves the
56 .I value
57 of the extended attribute identified by
58 .I name
59 and associated with the given
60 .I path
61 in the filesystem.
62 The length of the attribute
63 .I value
64 is returned.
65 .PP
66 .BR lgetxattr ()
67 is identical to
68 .BR getxattr (),
69 except in the case of a symbolic link, where the link itself is
70 interrogated, not the file that it refers to.
71 .PP
72 .BR fgetxattr ()
73 is identical to
74 .BR getxattr (),
75 only the open file referred to by
76 .I fd
77 (as returned by
78 .BR open (2))
79 is interrogated in place of
80 .IR path .
81 .PP
82 An extended attribute
83 .I name
84 is a simple null-terminated string.
85 The name includes a namespace prefix; there may be several, disjoint
86 namespaces associated with an individual inode.
87 The value of an extended attribute is a chunk of arbitrary textual or
88 binary data of specified length.
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 named extended attribute, which can be used to estimate the size of a
94 buffer which is sufficiently large to hold the value associated with
95 the extended attribute.
96 .PP
97 The interface is designed to allow guessing of initial buffer
98 sizes, and to enlarge buffers when the return value indicates
99 that the buffer provided was too small.
100 .SH RETURN VALUE
101 On success, a nonnegative number is returned indicating the size of the
102 extended attribute value.
103 On failure, \-1 is returned and
104 .I errno
105 is set appropriately.
106 .SH ERRORS
107 .TP
108 .B ENOATTR
109 The named attribute does not exist, or the process has no access to
110 this attribute.
111 .RB ( ENOATTR
112 is defined to be a synonym for
113 .BR ENODATA
114 in
115 .IR <attr/xattr.h> .)
116 .TP
117 .B ENOTSUP
118 Extended attributes are not supported by the filesystem, or are disabled.
119 .TP
120 .B ERANGE
121 The
122 .I size
123 of the
124 .I value
125 buffer is too small to hold the result.
126 .PP
127 In addition, the errors documented in
128 .BR stat (2)
129 can also occur.
130 .SH VERSIONS
131 These system calls have been available on Linux since kernel 2.4;
132 glibc support is provided since version 2.3.
133 .SH CONFORMING TO
134 These system calls are Linux-specific.
135 .\" .SH AUTHORS
136 .\" Andreas Gruenbacher,
137 .\" .RI < a.gruenbacher@computer.org >
138 .\" and the SGI XFS development team,
139 .\" .RI < linux-xfs@oss.sgi.com >.
140 .\" Please send any bug reports or comments to these addresses.
141 .SH SEE ALSO
142 .BR getfattr (1),
143 .BR setfattr (1),
144 .BR listxattr (2),
145 .BR open (2),
146 .BR removexattr (2),
147 .BR setxattr (2),
148 .BR stat (2),
149 .BR attr (5),
150 .BR symlink (7)
151 .SH COLOPHON
152 This page is part of release 3.79 of the Linux
153 .I man-pages
154 project.
155 A description of the project,
156 information about reporting bugs,
157 and the latest version of this page,
158 can be found at
159 \%http://www.kernel.org/doc/man\-pages/.