]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setxattr.2
Many pages: Fix style issues reported by `make lint-groff`
[thirdparty/man-pages.git] / man2 / setxattr.2
CommitLineData
bf5a7247
MK
1.\" Copyright (C) Andreas Gruenbacher, February 2001
2.\" Copyright (C) Silicon Graphics Inc, September 2001
fea681da 3.\"
e4a74ca8 4.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da 5.\"
1d767b55 6.TH SETXATTR 2 2021-03-22 "Linux" "Linux Programmer's Manual"
fea681da
MK
7.SH NAME
8setxattr, lsetxattr, fsetxattr \- set an extended attribute value
5dcdb551
AC
9.SH LIBRARY
10Standard C library
8fc3b2cf 11.RI ( libc ", " \-lc )
fea681da 12.SH SYNOPSIS
fea681da 13.nf
4f72d935 14.B #include <sys/xattr.h>
68e4db0a 15.PP
c10859eb
MK
16.BI "int setxattr(const char\ *" path ", const char\ *" name ,
17.BI " const void\ *" value ", size_t " size ", int " flags );
18.BI "int lsetxattr(const char\ *" path ", const char\ *" name ,
19.BI " const void\ *" value ", size_t " size ", int " flags );
d3b03141 20.BI "int fsetxattr(int " fd ", const char\ *" name ,
c10859eb 21.BI " const void\ *" value ", size_t " size ", int " flags );
fea681da 22.fi
fea681da
MK
23.SH DESCRIPTION
24Extended attributes are
25.IR name :\c
26.I value
0967c11f 27pairs associated with inodes (files, directories, symbolic links, etc.).
fea681da 28They are extensions to the normal attributes which are associated
75b94dc3 29with all inodes in the system (i.e., the
fea681da
MK
30.BR stat (2)
31data).
32A complete overview of extended attributes concepts can be found in
89fabe2e 33.BR xattr (7).
fea681da 34.PP
e511ffb6 35.BR setxattr ()
fea681da
MK
36sets the
37.I value
38of the extended attribute identified by
39.I name
40and associated with the given
41.I path
9ee4a2b6 42in the filesystem.
fea681da
MK
43The
44.I size
736703bd 45argument specifies the size (in bytes) of
60da5b89
MK
46.IR value ;
47a zero-length value is permitted.
fea681da 48.PP
e511ffb6 49.BR lsetxattr ()
c13182ef 50is identical to
e511ffb6 51.BR setxattr (),
fea681da
MK
52except in the case of a symbolic link, where the extended attribute is
53set on the link itself, not the file that it refers to.
54.PP
e511ffb6 55.BR fsetxattr ()
fea681da 56is identical to
e511ffb6 57.BR setxattr (),
d3b03141
MK
58only the extended attribute is set on the open file referred to by
59.I fd
fea681da
MK
60(as returned by
61.BR open (2))
62in place of
63.IR path .
64.PP
5232e869 65An extended attribute name is a null-terminated string.
fea681da
MK
66The
67.I name
df8a3cac 68includes a namespace prefix; there may be several, disjoint
fea681da
MK
69namespaces associated with an individual inode.
70The
71.I value
72of an extended attribute is a chunk of arbitrary textual or
73binary data of specified length.
74.PP
9398702c
MK
75By default
76(i.e.,
1ae6b2c7 77.I flags
9398702c 78is zero),
736703bd
MK
79the extended attribute will be created if it does not exist,
80or the value will be replaced if the attribute already exists.
9398702c
MK
81To modify these semantics, one of the following values can be specified in
82.IR flags :
83.TP
84.B XATTR_CREATE
85Perform a pure create, which fails if the named attribute exists already.
86.TP
87.B XATTR_REPLACE
88Perform a pure replace operation,
89which fails if the named attribute does not already exist.
fea681da
MK
90.SH RETURN VALUE
91On success, zero is returned.
92On failure, \-1 is returned and
93.I errno
f6a4078b 94is set to indicate the error.
92d67001
MK
95.SH ERRORS
96.TP
97.B EDQUOT
98Disk quota limits meant that
99there is insufficient space remaining to store the extended attribute.
100.TP
101.B EEXIST
2f0af33b 102.B XATTR_CREATE
92d67001
MK
103was specified, and the attribute exists already.
104.TP
acac1139 105.B ENODATA
1274071a 106.B XATTR_REPLACE
92d67001 107was specified, and the attribute does not exist.
acac1139
MK
108.\" .RB ( ENOATTR
109.\" is defined to be a synonym for
110.\" .BR ENODATA
111.\" in
112.\" .IR <attr/attributes.h> .)
92d67001
MK
113.TP
114.B ENOSPC
115There is insufficient space remaining to store the extended attribute.
116.TP
117.B ENOTSUP
2f2a53b5
MK
118The namespace prefix of
119.I name
120is not valid.
121.TP
122.B ENOTSUP
9ee4a2b6 123Extended attributes are not supported by the filesystem, or are disabled,
937a7c87
MK
124.TP
125.B EPERM
126The file is marked immutable or append-only.
127(See
128.BR ioctl_iflags (2).)
fea681da 129.PP
92d67001 130In addition, the errors documented in
fea681da 131.BR stat (2)
92d67001 132can also occur.
8d7dde9f
MK
133.TP
134.B ERANGE
135The size of
136.I name
137or
138.I value
139exceeds a filesystem-specific limit.
570dd978
MK
140.SH VERSIONS
141These system calls have been available on Linux since kernel 2.4;
142glibc support is provided since version 2.3.
47297adb 143.SH CONFORMING TO
8382f16d 144These system calls are Linux-specific.
dc919d09
MK
145.\" .SH AUTHORS
146.\" Andreas Gruenbacher,
147.\" .RI < a.gruenbacher@computer.org >
148.\" and the SGI XFS development team,
149.\" .RI < linux-xfs@oss.sgi.com >.
150.\" Please send any bug reports or comments to these addresses.
fea681da
MK
151.SH SEE ALSO
152.BR getfattr (1),
153.BR setfattr (1),
154.BR getxattr (2),
155.BR listxattr (2),
156.BR open (2),
157.BR removexattr (2),
158.BR stat (2),
89fabe2e
MK
159.BR symlink (7),
160.BR xattr (7)