readv2: Note preadv2(..., RWF_NOWAIT) bug in BUGS section
[man-pages.git] / man2 / getxattr.2
blob15f0f9b4a2a835f87e53aa531383a0ddf9cde9b9
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 2021-03-22 "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/xattr.h>
32 .PP
33 .BI "ssize_t getxattr(const char *" path ", const char *" name ,
34 .BI "                 void *" value ", size_t " size );
35 .BI "ssize_t lgetxattr(const char *" path ", const char *" name ,
36 .BI "                 void *" value ", size_t " size );
37 .BI "ssize_t fgetxattr(int " fd ", const char *" name ,
38 .BI "                 void *" value ", size_t " size );
39 .fi
40 .fam T
41 .SH DESCRIPTION
42 Extended attributes are
43 .IR name :\c
44 .I value
45 pairs associated with inodes (files, directories, symbolic links, 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 xattr (7).
52 .PP
53 .BR getxattr ()
54 retrieves the value of the extended attribute identified by
55 .I name
56 and associated with the given
57 .I path
58 in the filesystem.
59 The attribute value is placed in the buffer pointed to by
60 .IR value ;
61 .I size
62 specifies the size of that buffer.
63 The return value of the call is the number of bytes placed in
64 .IR value .
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 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 that was assigned using
89 .BR setxattr (2).
90 .PP
92 .I size
93 is specified as zero, these calls return the current size of the
94 named extended attribute (and leave
95 .I value
96 unchanged).
97 This can be used to determine the size of the buffer that
98 should be supplied in a subsequent call.
99 (But, bear in mind that there is a possibility that the
100 attribute value may change between the two calls,
101 so that it is still necessary to check the return status
102 from the second call.)
103 .SH RETURN VALUE
104 On success, these calls return a nonnegative value which is
105 the size (in bytes) of the extended attribute value.
106 On failure, \-1 is returned and
107 .I errno
108 is set to indicate the error.
109 .SH ERRORS
111 .B E2BIG
112 The size of the attribute value is larger than the maximum size allowed; the
113 attribute cannot be retrieved.
114 This can happen on filesystems that support
115 very large attribute values such as NFSv4, for example.
117 .B ENODATA
118 The named attribute does not exist, or the process has no access to
119 this attribute.
120 .\" .RB ( ENOATTR
121 .\" is defined to be a synonym for
122 .\" .BR ENODATA
123 .\" in
124 .\" .IR <attr/attributes.h> .)
126 .B ENOTSUP
127 Extended attributes are not supported by the filesystem, or are disabled.
129 .B ERANGE
131 .I size
132 of the
133 .I value
134 buffer is too small to hold the result.
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 EXAMPLES
152 .BR listxattr (2).
153 .SH SEE ALSO
154 .BR getfattr (1),
155 .BR setfattr (1),
156 .BR listxattr (2),
157 .BR open (2),
158 .BR removexattr (2),
159 .BR setxattr (2),
160 .BR stat (2),
161 .BR symlink (7),
162 .BR xattr (7)