OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man2 / setxattr.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 SETXATTR 2 2014-02-06 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 setxattr, lsetxattr, fsetxattr \- set 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 "int setxattr(const char\ *" path ", const char\ *" name ,
35 .BI "              const void\ *" value ", size_t " size ", int " flags );
36 .BI "int lsetxattr(const char\ *" path ", const char\ *" name ,
37 .BI "              const void\ *" value ", size_t " size ", int " flags );
38 .BI "int fsetxattr(int " fd ", const char\ *" name ,
39 .BI "              const void\ *" value ", size_t " size ", int " flags );
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 setxattr ()
55 sets 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
63 .I size
64 of the
65 .I value
66 must be specified.
67 .PP
68 .BR lsetxattr ()
69 is identical to
70 .BR setxattr (),
71 except in the case of a symbolic link, where the extended attribute is
72 set on the link itself, not the file that it refers to.
73 .PP
74 .BR fsetxattr ()
75 is identical to
76 .BR setxattr (),
77 only the extended attribute is set on the open file referred to by
78 .I fd
79 (as returned by
80 .BR open (2))
81 in place of
82 .IR path .
83 .PP
84 An extended attribute name is a simple null-terminated string.
85 The
86 .I name
87 includes a namespace prefix; there may be several, disjoint
88 namespaces associated with an individual inode.
89 The
90 .I value
91 of an extended attribute is a chunk of arbitrary textual or
92 binary data of specified length.
93 .PP
94 The
95 .I flags
96 argument can be used to refine the semantics of the operation.
97 .B XATTR_CREATE
98 specifies a pure create, which fails if the named
99 attribute exists already.
100 .B XATTR_REPLACE
101 specifies a pure replace operation, which fails if the
102 named attribute does not already exist.
103 By default (no flags), the extended attribute will be created if
104 need be, or will simply replace the value if the attribute exists.
105 .SH RETURN VALUE
106 On success, zero is returned.
107 On failure, \-1 is returned and
108 .I errno
109 is set appropriately.
110 .SH ERRORS
111 .TP
112 .B EDQUOT
113 Disk quota limits meant that
114 there is insufficient space remaining to store the extended attribute.
115 .TP
116 .B EEXIST
117 .B XATTR_CREATE
118 was specified, and the attribute exists already.
119 .TP
120 .B ENOATTR
121 .B XATTR_REPLACE
122 was specified, and the attribute does not exist.
123 .RB ( ENOATTR
124 is defined to be a synonym for
125 .BR ENODATA
126 in
127 .IR <attr/xattr.h> .)
128 .TP
129 .B ENOSPC
130 There is insufficient space remaining to store the extended attribute.
131 .TP
132 .B ENOTSUP
133 Extended attributes are not supported by the filesystem, or are disabled,
134 .I errno
135 is set to
136 .BR ENOTSUP .
137 .PP
138 In addition, the errors documented in
139 .BR stat (2)
140 can also occur.
141 .SH VERSIONS
142 These system calls have been available on Linux since kernel 2.4;
143 glibc support is provided since version 2.3.
144 .SH CONFORMING TO
145 These system calls are Linux-specific.
146 .\" .SH AUTHORS
147 .\" Andreas Gruenbacher,
148 .\" .RI < a.gruenbacher@computer.org >
149 .\" and the SGI XFS development team,
150 .\" .RI < linux-xfs@oss.sgi.com >.
151 .\" Please send any bug reports or comments to these addresses.
152 .SH SEE ALSO
153 .BR getfattr (1),
154 .BR setfattr (1),
155 .BR getxattr (2),
156 .BR listxattr (2),
157 .BR open (2),
158 .BR removexattr (2),
159 .BR stat (2),
160 .BR attr (5),
161 .BR symlink (7)
162 .SH COLOPHON
163 This page is part of release 3.68 of the Linux
164 .I man-pages
165 project.
166 A description of the project,
167 information about reporting bugs,
168 and the latest version of this page,
169 can be found at
170 \%http://www.kernel.org/doc/man\-pages/.