]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/getxattr.2
pipe.2: Note that 'pipefd' is left unchanged in the event of an error
[thirdparty/man-pages.git] / man2 / getxattr.2
CommitLineData
bf5a7247
MK
1.\" Copyright (C) Andreas Gruenbacher, February 2001
2.\" Copyright (C) Silicon Graphics Inc, September 2001
fea681da 3.\"
1dd72f9c 4.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
fea681da
MK
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
c715f741
MK
21.\" License along with this manual; if not, see
22.\" <http://www.gnu.org/licenses/>.
6a8d8745 23.\" %%%LICENSE_END
fea681da 24.\"
9ba01802 25.TH GETXATTR 2 2019-03-06 "Linux" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27getxattr, lgetxattr, fgetxattr \- retrieve an extended attribute value
28.SH SYNOPSIS
29.fam C
30.nf
31.B #include <sys/types.h>
4f72d935 32.B #include <sys/xattr.h>
68e4db0a 33.PP
c10859eb
MK
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 );
d3b03141 38.BI "ssize_t fgetxattr(int " fd ", const char\ *" name ,
c10859eb 39.BI " void\ *" value ", size_t " size );
fea681da
MK
40.fi
41.fam T
42.SH DESCRIPTION
43Extended attributes are
44.IR name :\c
45.I value
0967c11f 46pairs associated with inodes (files, directories, symbolic links, etc.).
fea681da 47They are extensions to the normal attributes which are associated
75b94dc3 48with all inodes in the system (i.e., the
fea681da
MK
49.BR stat (2)
50data).
51A complete overview of extended attributes concepts can be found in
89fabe2e 52.BR xattr (7).
fea681da 53.PP
e511ffb6 54.BR getxattr ()
fae9230b 55retrieves the value of the extended attribute identified by
fea681da
MK
56.I name
57and associated with the given
58.I path
9ee4a2b6 59in the filesystem.
fae9230b
MK
60The attribute value is placed in the buffer pointed to by
61.IR value ;
62.I size
63specifies the size of that buffer.
64The return value of the call is the number of bytes placed in
65.IR value .
fea681da 66.PP
e511ffb6 67.BR lgetxattr ()
c13182ef 68is identical to
e511ffb6 69.BR getxattr (),
fea681da
MK
70except in the case of a symbolic link, where the link itself is
71interrogated, not the file that it refers to.
72.PP
e511ffb6 73.BR fgetxattr ()
fea681da 74is identical to
e511ffb6 75.BR getxattr (),
d3b03141
MK
76only the open file referred to by
77.I fd
fea681da
MK
78(as returned by
79.BR open (2))
80is interrogated in place of
81.IR path .
82.PP
83An extended attribute
84.I name
fae9230b 85is a null-terminated string.
df8a3cac 86The name includes a namespace prefix; there may be several, disjoint
fea681da
MK
87namespaces associated with an individual inode.
88The value of an extended attribute is a chunk of arbitrary textual or
fae9230b
MK
89binary data that was assigned using
90.BR setxattr (2).
fea681da 91.PP
fae9230b 92If
fea681da 93.I size
fae9230b
MK
94is specified as zero, these calls return the current size of the
95named extended attribute (and leave
96.I value
97unchanged).
98This can be used to determine the size of the buffer that
99should be supplied in a subsequent call.
100(But, bear in mind that there is a possibility that the
101attribute value may change between the two calls,
102so that it is still necessary to check the return status
103from the second call.)
fea681da 104.SH RETURN VALUE
fae9230b
MK
105On success, these calls return a nonnegative value which is
106the size (in bytes) of the extended attribute value.
fea681da
MK
107On failure, \-1 is returned and
108.I errno
109is set appropriately.
92d67001
MK
110.SH ERRORS
111.TP
f124c136
MK
112.B E2BIG
113The size of the attribute value is larger than the maximum size allowed; the
efb3a65a
MK
114attribute cannot be retrieved.
115This can happen on filesystems that support
f124c136
MK
116very large attribute values such as NFSv4, for example.
117.TP
acac1139 118.B ENODATA
92d67001
MK
119The named attribute does not exist, or the process has no access to
120this attribute.
acac1139
MK
121.\" .RB ( ENOATTR
122.\" is defined to be a synonym for
123.\" .BR ENODATA
124.\" in
125.\" .IR <attr/attributes.h> .)
92d67001
MK
126.TP
127.B ENOTSUP
9ee4a2b6 128Extended attributes are not supported by the filesystem, or are disabled.
92d67001
MK
129.TP
130.B ERANGE
131The
fea681da
MK
132.I size
133of the
134.I value
92d67001 135buffer is too small to hold the result.
fea681da 136.PP
92d67001 137In addition, the errors documented in
fea681da 138.BR stat (2)
92d67001 139can also occur.
570dd978
MK
140.SH VERSIONS
141These system calls have been available on Linux since kernel 2.4;
142glibc support is provided since version 2.3.
47297adb 143.SH CONFORMING TO
8382f16d 144These system calls are Linux-specific.
dc919d09
MK
145.\" .SH AUTHORS
146.\" Andreas Gruenbacher,
147.\" .RI < a.gruenbacher@computer.org >
148.\" and the SGI XFS development team,
149.\" .RI < linux-xfs@oss.sgi.com >.
150.\" Please send any bug reports or comments to these addresses.
0e48cd5a
MK
151.SH EXAMPLE
152See
153.BR listxattr (2).
fea681da
MK
154.SH SEE ALSO
155.BR getfattr (1),
156.BR setfattr (1),
157.BR listxattr (2),
158.BR open (2),
159.BR removexattr (2),
160.BR setxattr (2),
161.BR stat (2),
89fabe2e
MK
162.BR symlink (7),
163.BR xattr (7)