]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setxattr.2
listxattr.2: Fix RETURN VALUE description
[thirdparty/man-pages.git] / man2 / setxattr.2
CommitLineData
fea681da
MK
1.\"
2.\" Extended attributes system calls manual pages
3.\"
bf5a7247
MK
4.\" Copyright (C) Andreas Gruenbacher, February 2001
5.\" Copyright (C) Silicon Graphics Inc, September 2001
fea681da
MK
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.\"
2965fbf1 27.TH SETXATTR 2 2013-01-19 "Linux" "Linux Programmer's Manual"
fea681da
MK
28.SH NAME
29setxattr, lsetxattr, fsetxattr \- set 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
c10859eb
MK
36.BI "int setxattr(const char\ *" path ", const char\ *" name ,
37.BI " const void\ *" value ", size_t " size ", int " flags );
38.BI "int lsetxattr(const char\ *" path ", const char\ *" name ,
39.BI " const void\ *" value ", size_t " size ", int " flags );
d3b03141 40.BI "int fsetxattr(int " fd ", const char\ *" name ,
c10859eb 41.BI " const void\ *" value ", size_t " size ", int " flags );
fea681da
MK
42.fi
43.fam T
44.SH DESCRIPTION
45Extended attributes are
46.IR name :\c
47.I value
0967c11f 48pairs associated with inodes (files, directories, symbolic links, etc.).
fea681da 49They are extensions to the normal attributes which are associated
75b94dc3 50with all inodes in the system (i.e., the
fea681da
MK
51.BR stat (2)
52data).
53A complete overview of extended attributes concepts can be found in
54.BR attr (5).
55.PP
e511ffb6 56.BR setxattr ()
fea681da
MK
57sets the
58.I value
59of the extended attribute identified by
60.I name
61and associated with the given
62.I path
24d01c53 63in the file system.
fea681da
MK
64The
65.I size
66of the
67.I value
68must be specified.
69.PP
e511ffb6 70.BR lsetxattr ()
c13182ef 71is identical to
e511ffb6 72.BR setxattr (),
fea681da
MK
73except in the case of a symbolic link, where the extended attribute is
74set on the link itself, not the file that it refers to.
75.PP
e511ffb6 76.BR fsetxattr ()
fea681da 77is identical to
e511ffb6 78.BR setxattr (),
d3b03141
MK
79only the extended attribute is set on the open file referred to by
80.I fd
fea681da
MK
81(as returned by
82.BR open (2))
83in place of
84.IR path .
85.PP
836f07c1 86An extended attribute name is a simple null-terminated string.
fea681da
MK
87The
88.I name
df8a3cac 89includes a namespace prefix; there may be several, disjoint
fea681da
MK
90namespaces associated with an individual inode.
91The
92.I value
93of an extended attribute is a chunk of arbitrary textual or
94binary data of specified length.
95.PP
96The
97.I flags
c4bb193f 98argument can be used to refine the semantics of the operation.
2f0af33b
MK
99.B XATTR_CREATE
100specifies a pure create, which fails if the named
fea681da 101attribute exists already.
2f0af33b
MK
102.B XATTR_REPLACE
103specifies a pure replace operation, which fails if the
fea681da
MK
104named attribute does not already exist.
105By default (no flags), the extended attribute will be created if
106need be, or will simply replace the value if the attribute exists.
107.SH RETURN VALUE
108On success, zero is returned.
109On failure, \-1 is returned and
110.I errno
111is set appropriately.
112.PP
2f0af33b
MK
113If
114.B XATTR_CREATE
115is specified, and the attribute exists already,
fea681da 116.I errno
2f0af33b
MK
117is set to
118.BR EEXIST .
1274071a
MK
119If
120.B XATTR_REPLACE
121is specified, and the attribute does not exist,
fea681da 122.I errno
2f0af33b
MK
123is set to
124.BR ENOATTR .
2965fbf1
MK
125.RB ( ENOATTR
126is defined to be a synonym for
127.BR ENODATA
128in
129.IR <attr/xattr.h> .)
fea681da
MK
130.PP
131If there is insufficient space remaining to store the extended attribute,
132.I errno
2f0af33b
MK
133is set to either
134.BR ENOSPC ,
135or
0daa9e92 136.B EDQUOT
2f0af33b 137if quota enforcement was the cause.
fea681da 138.PP
24d01c53 139If extended attributes are not supported by the file system, or are disabled,
fea681da 140.I errno
2f0af33b
MK
141is set to
142.BR ENOTSUP .
fea681da
MK
143.PP
144The errors documented for the
145.BR stat (2)
146system call are also applicable here.
570dd978
MK
147.SH VERSIONS
148These system calls have been available on Linux since kernel 2.4;
149glibc support is provided since version 2.3.
9d9dc1e8 150.SH "CONFORMING TO"
8382f16d 151These system calls are Linux-specific.
dc919d09
MK
152.\" .SH AUTHORS
153.\" Andreas Gruenbacher,
154.\" .RI < a.gruenbacher@computer.org >
155.\" and the SGI XFS development team,
156.\" .RI < linux-xfs@oss.sgi.com >.
157.\" Please send any bug reports or comments to these addresses.
fea681da
MK
158.SH SEE ALSO
159.BR getfattr (1),
160.BR setfattr (1),
161.BR getxattr (2),
162.BR listxattr (2),
163.BR open (2),
164.BR removexattr (2),
165.BR stat (2),
a9cfde1d
MK
166.BR attr (5),
167.BR symlink (7)