]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/getxattr.2
getxattr.2: Add pointer to example in listxattr(2)
[thirdparty/man-pages.git] / 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 value of the extended attribute identified by
56 .I name
57 and associated with the given
58 .I path
59 in the filesystem.
60 The attribute value is placed in the buffer pointed to by
61 .IR value ;
62 .I size
63 specifies the size of that buffer.
64 The return value of the call is the number of bytes placed in
65 .IR value .
66 .PP
67 .BR lgetxattr ()
68 is identical to
69 .BR getxattr (),
70 except in the case of a symbolic link, where the link itself is
71 interrogated, not the file that it refers to.
72 .PP
73 .BR fgetxattr ()
74 is identical to
75 .BR getxattr (),
76 only the open file referred to by
77 .I fd
78 (as returned by
79 .BR open (2))
80 is interrogated in place of
81 .IR path .
82 .PP
83 An extended attribute
84 .I name
85 is a null-terminated string.
86 The name includes a namespace prefix; there may be several, disjoint
87 namespaces associated with an individual inode.
88 The value of an extended attribute is a chunk of arbitrary textual or
89 binary data that was assigned using
90 .BR setxattr (2).
91 .PP
92 If
93 .I size
94 is specified as zero, these calls return the current size of the
95 named extended attribute (and leave
96 .I value
97 unchanged).
98 This can be used to determine the size of the buffer that
99 should be supplied in a subsequent call.
100 (But, bear in mind that there is a possibility that the
101 attribute value may change between the two calls,
102 so that it is still necessary to check the return status
103 from the second call.)
104 .SH RETURN VALUE
105 On success, these calls return a nonnegative value which is
106 the size (in bytes) of the extended attribute value.
107 On failure, \-1 is returned and
108 .I errno
109 is set appropriately.
110 .SH ERRORS
111 .TP
112 .B ENOATTR
113 The named attribute does not exist, or the process has no access to
114 this attribute.
115 .RB ( ENOATTR
116 is defined to be a synonym for
117 .BR ENODATA
118 in
119 .IR <attr/xattr.h> .)
120 .TP
121 .B ENOTSUP
122 Extended attributes are not supported by the filesystem, or are disabled.
123 .TP
124 .B ERANGE
125 The
126 .I size
127 of the
128 .I value
129 buffer is too small to hold the result.
130 .PP
131 In addition, the errors documented in
132 .BR stat (2)
133 can also occur.
134 .SH VERSIONS
135 These system calls have been available on Linux since kernel 2.4;
136 glibc support is provided since version 2.3.
137 .SH CONFORMING TO
138 These system calls are Linux-specific.
139 .\" .SH AUTHORS
140 .\" Andreas Gruenbacher,
141 .\" .RI < a.gruenbacher@computer.org >
142 .\" and the SGI XFS development team,
143 .\" .RI < linux-xfs@oss.sgi.com >.
144 .\" Please send any bug reports or comments to these addresses.
145 .SH EXAMPLE
146 See
147 .BR listxattr (2).
148 .SH SEE ALSO
149 .BR getfattr (1),
150 .BR setfattr (1),
151 .BR listxattr (2),
152 .BR open (2),
153 .BR removexattr (2),
154 .BR setxattr (2),
155 .BR stat (2),
156 .BR attr (5),
157 .BR symlink (7)