mount_setattr.2: SEE ALSO: place entries in correct order
[man-pages.git] / man2 / setxattr.2
blob2d3a5a4365ebc0e817cb68906272652332fd479f
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 2021-03-22 "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/xattr.h>
32 .PP
33 .BI "int setxattr(const char\ *" path ", const char\ *" name ,
34 .BI "              const void\ *" value ", size_t " size ", int " flags );
35 .BI "int lsetxattr(const char\ *" path ", const char\ *" name ,
36 .BI "              const void\ *" value ", size_t " size ", int " flags );
37 .BI "int fsetxattr(int " fd ", const char\ *" name ,
38 .BI "              const void\ *" value ", size_t " size ", int " flags );
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 setxattr ()
54 sets the
55 .I value
56 of the extended attribute identified by
57 .I name
58 and associated with the given
59 .I path
60 in the filesystem.
61 The
62 .I size
63 argument specifies the size (in bytes) of
64 .IR value ;
65 a zero-length value is permitted.
66 .PP
67 .BR lsetxattr ()
68 is identical to
69 .BR setxattr (),
70 except in the case of a symbolic link, where the extended attribute is
71 set on the link itself, not the file that it refers to.
72 .PP
73 .BR fsetxattr ()
74 is identical to
75 .BR setxattr (),
76 only the extended attribute is set on the open file referred to by
77 .I fd
78 (as returned by
79 .BR open (2))
80 in place of
81 .IR path .
82 .PP
83 An extended attribute name is a null-terminated string.
84 The
85 .I name
86 includes a namespace prefix; there may be several, disjoint
87 namespaces associated with an individual inode.
88 The
89 .I value
90 of an extended attribute is a chunk of arbitrary textual or
91 binary data of specified length.
92 .PP
93 By default
94 (i.e.,
95 .IR flags
96 is zero),
97 the extended attribute will be created if it does not exist,
98 or the value will be replaced if the attribute already exists.
99 To modify these semantics, one of the following values can be specified in
100 .IR flags :
102 .B XATTR_CREATE
103 Perform a pure create, which fails if the named attribute exists already.
105 .B XATTR_REPLACE
106 Perform a pure replace operation,
107 which fails if the named attribute does not already exist.
108 .SH RETURN VALUE
109 On success, zero is returned.
110 On failure, \-1 is returned and
111 .I errno
112 is set to indicate the error.
113 .SH ERRORS
115 .B EDQUOT
116 Disk quota limits meant that
117 there is insufficient space remaining to store the extended attribute.
119 .B EEXIST
120 .B XATTR_CREATE
121 was specified, and the attribute exists already.
123 .B ENODATA
124 .B XATTR_REPLACE
125 was specified, and the attribute does not exist.
126 .\" .RB ( ENOATTR
127 .\" is defined to be a synonym for
128 .\" .BR ENODATA
129 .\" in
130 .\" .IR <attr/attributes.h> .)
132 .B ENOSPC
133 There is insufficient space remaining to store the extended attribute.
135 .B ENOTSUP
136 The namespace prefix of
137 .I name
138 is not valid.
140 .B ENOTSUP
141 Extended attributes are not supported by the filesystem, or are disabled,
143 .B EPERM
144 The file is marked immutable or append-only.
145 (See
146 .BR ioctl_iflags (2).)
148 In addition, the errors documented in
149 .BR stat (2)
150 can also occur.
152 .B ERANGE
153 The size of
154 .I name
156 .I value
157 exceeds a filesystem-specific limit.
158 .SH VERSIONS
159 These system calls have been available on Linux since kernel 2.4;
160 glibc support is provided since version 2.3.
161 .SH CONFORMING TO
162 These system calls are Linux-specific.
163 .\" .SH AUTHORS
164 .\" Andreas Gruenbacher,
165 .\" .RI < a.gruenbacher@computer.org >
166 .\" and the SGI XFS development team,
167 .\" .RI < linux-xfs@oss.sgi.com >.
168 .\" Please send any bug reports or comments to these addresses.
169 .SH SEE ALSO
170 .BR getfattr (1),
171 .BR setfattr (1),
172 .BR getxattr (2),
173 .BR listxattr (2),
174 .BR open (2),
175 .BR removexattr (2),
176 .BR stat (2),
177 .BR symlink (7),
178 .BR xattr (7)