OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / original / man2 / getxattr.2
1 .\"
2 .\" Extended attributes system calls manual pages
3 .\"
4 .\" Copyright (C) Andreas Gruenbacher, February 2001
5 .\" Copyright (C) Silicon Graphics Inc, September 2001
6 .\"
7 .\" This is free documentation; you can redistribute it and/or
8 .\" modify it under the terms of the GNU General Public License as
9 .\" published by the Free Software Foundation; either version 2 of
10 .\" the License, or (at your option) any later version.
11 .\"
12 .\" The GNU General Public License's references to "object code"
13 .\" and "executables" are to be interpreted as the output of any
14 .\" document formatting or typesetting system, including
15 .\" intermediate and printed output.
16 .\"
17 .\" This manual is distributed in the hope that it will be useful,
18 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 .\" GNU General Public License for more details.
21 .\"
22 .\" You should have received a copy of the GNU General Public
23 .\" License along with this manual; if not, write to the Free
24 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
25 .\" USA.
26 .\"
27 .TH GETXATTR 2 2001-12-01 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 getxattr, lgetxattr, fgetxattr \- retrieve an extended attribute value
30 .SH SYNOPSIS
31 .fam C
32 .nf
33 .B #include <sys/types.h>
34 .B #include <attr/xattr.h>
35 .sp
36 .BI "ssize_t getxattr(const char\ *" path ", const char\ *" name ,
37 .BI "                 void\ *" value ", size_t " size );
38 .BI "ssize_t lgetxattr(const char\ *" path ", const char\ *" name ,
39 .BI "                 void\ *" value ", size_t " size );
40 .BI "ssize_t fgetxattr(int " fd ", const char\ *" name ,
41 .BI "                 void\ *" value ", size_t " size );
42 .fi
43 .fam T
44 .SH DESCRIPTION
45 Extended attributes are
46 .IR name :\c
47 .I value
48 pairs associated with inodes (files, directories, symbolic links, etc.).
49 They are extensions to the normal attributes which are associated
50 with all inodes in the system (i.e., the
51 .BR stat (2)
52 data).
53 A complete overview of extended attributes concepts can be found in
54 .BR attr (5).
55 .PP
56 .BR getxattr ()
57 retrieves the
58 .I value
59 of the extended attribute identified by
60 .I name
61 and associated with the given
62 .I path
63 in the file system.
64 The length of the attribute
65 .I value
66 is returned.
67 .PP
68 .BR lgetxattr ()
69 is identical to
70 .BR getxattr (),
71 except in the case of a symbolic link, where the link itself is
72 interrogated, not the file that it refers to.
73 .PP
74 .BR fgetxattr ()
75 is identical to
76 .BR getxattr (),
77 only the open file referred to by
78 .I fd
79 (as returned by
80 .BR open (2))
81 is interrogated in place of
82 .IR path .
83 .PP
84 An extended attribute
85 .I name
86 is a simple null-terminated string.
87 The name includes a namespace prefix; there may be several, disjoint
88 namespaces associated with an individual inode.
89 The value of an extended attribute is a chunk of arbitrary textual or
90 binary data of specified length.
91 .PP
92 An empty buffer of
93 .I size
94 zero can be passed into these calls to return the current size of the
95 named extended attribute, which can be used to estimate the size of a
96 buffer which is sufficiently large to hold the value associated with
97 the extended attribute.
98 .PP
99 The interface is designed to allow guessing of initial buffer
100 sizes, and to enlarge buffers when the return value indicates
101 that the buffer provided was too small.
102 .SH RETURN VALUE
103 On success, a positive number is returned indicating the size of the
104 extended attribute value.
105 On failure, \-1 is returned and
106 .I errno
107 is set appropriately.
108 .PP
109 If the named attribute does not exist, or the process has no access to
110 this attribute,
111 .I errno
112 is set to
113 .BR ENOATTR .
114 .PP
115 If the
116 .I size
117 of the
118 .I value
119 buffer is too small to hold the result,
120 .I errno
121 is set to
122 .BR ERANGE .
123 .PP
124 If extended attributes are not supported by the file system, or are disabled,
125 .I errno
126 is set to
127 .BR ENOTSUP .
128 .PP
129 The errors documented for the
130 .BR stat (2)
131 system call are also applicable here.
132 .SH VERSIONS
133 These system calls have been available on Linux since kernel 2.4;
134 glibc support is provided since version 2.3.
135 .SH "CONFORMING TO"
136 These system calls are Linux-specific.
137 .\" .SH AUTHORS
138 .\" Andreas Gruenbacher,
139 .\" .RI < a.gruenbacher@computer.org >
140 .\" and the SGI XFS development team,
141 .\" .RI < linux-xfs@oss.sgi.com >.
142 .\" Please send any bug reports or comments to these addresses.
143 .SH SEE ALSO
144 .BR getfattr (1),
145 .BR setfattr (1),
146 .BR listxattr (2),
147 .BR open (2),
148 .BR removexattr (2),
149 .BR setxattr (2),
150 .BR stat (2),
151 .BR attr (5),
152 .BR symlink (7)