Blame man2/setxattr.2

Packit 7cfc04
.\" Copyright (C) Andreas Gruenbacher, February 2001
Packit 7cfc04
.\" Copyright (C) Silicon Graphics Inc, September 2001
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
Packit 7cfc04
.\" This is free documentation; you can redistribute it and/or
Packit 7cfc04
.\" modify it under the terms of the GNU General Public License as
Packit 7cfc04
.\" published by the Free Software Foundation; either version 2 of
Packit 7cfc04
.\" the License, or (at your option) any later version.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The GNU General Public License's references to "object code"
Packit 7cfc04
.\" and "executables" are to be interpreted as the output of any
Packit 7cfc04
.\" document formatting or typesetting system, including
Packit 7cfc04
.\" intermediate and printed output.
Packit 7cfc04
.\"
Packit 7cfc04
.\" This manual is distributed in the hope that it will be useful,
Packit 7cfc04
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7cfc04
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7cfc04
.\" GNU General Public License for more details.
Packit 7cfc04
.\"
Packit 7cfc04
.\" You should have received a copy of the GNU General Public
Packit 7cfc04
.\" License along with this manual; if not, see
Packit 7cfc04
.\" <http://www.gnu.org/licenses/>.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.TH SETXATTR 2 2017-03-13 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
setxattr, lsetxattr, fsetxattr \- set an extended attribute value
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.fam C
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <sys/types.h>
Packit 7cfc04
.B #include <sys/xattr.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int setxattr(const char\ *" path ", const char\ *" name ,
Packit 7cfc04
.BI "              const void\ *" value ", size_t " size ", int " flags );
Packit 7cfc04
.BI "int lsetxattr(const char\ *" path ", const char\ *" name ,
Packit 7cfc04
.BI "              const void\ *" value ", size_t " size ", int " flags );
Packit 7cfc04
.BI "int fsetxattr(int " fd ", const char\ *" name ,
Packit 7cfc04
.BI "              const void\ *" value ", size_t " size ", int " flags );
Packit 7cfc04
.fi
Packit 7cfc04
.fam T
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
Extended attributes are
Packit 7cfc04
.IR name :\c
Packit 7cfc04
.I value
Packit 7cfc04
pairs associated with inodes (files, directories, symbolic links, etc.).
Packit 7cfc04
They are extensions to the normal attributes which are associated
Packit 7cfc04
with all inodes in the system (i.e., the
Packit 7cfc04
.BR stat (2)
Packit 7cfc04
data).
Packit 7cfc04
A complete overview of extended attributes concepts can be found in
Packit 7cfc04
.BR xattr (7).
Packit 7cfc04
.PP
Packit 7cfc04
.BR setxattr ()
Packit 7cfc04
sets the
Packit 7cfc04
.I value
Packit 7cfc04
of the extended attribute identified by
Packit 7cfc04
.I name
Packit 7cfc04
and associated with the given
Packit 7cfc04
.I path
Packit 7cfc04
in the filesystem.
Packit 7cfc04
The
Packit 7cfc04
.I size
Packit 7cfc04
argument specifies the size (in bytes) of
Packit 7cfc04
.IR value ;
Packit 7cfc04
a zero-length value is permitted.
Packit 7cfc04
.PP
Packit 7cfc04
.BR lsetxattr ()
Packit 7cfc04
is identical to
Packit 7cfc04
.BR setxattr (),
Packit 7cfc04
except in the case of a symbolic link, where the extended attribute is
Packit 7cfc04
set on the link itself, not the file that it refers to.
Packit 7cfc04
.PP
Packit 7cfc04
.BR fsetxattr ()
Packit 7cfc04
is identical to
Packit 7cfc04
.BR setxattr (),
Packit 7cfc04
only the extended attribute is set on the open file referred to by
Packit 7cfc04
.I fd
Packit 7cfc04
(as returned by
Packit 7cfc04
.BR open (2))
Packit 7cfc04
in place of
Packit 7cfc04
.IR path .
Packit 7cfc04
.PP
Packit 7cfc04
An extended attribute name is a null-terminated string.
Packit 7cfc04
The
Packit 7cfc04
.I name
Packit 7cfc04
includes a namespace prefix; there may be several, disjoint
Packit 7cfc04
namespaces associated with an individual inode.
Packit 7cfc04
The
Packit 7cfc04
.I value
Packit 7cfc04
of an extended attribute is a chunk of arbitrary textual or
Packit 7cfc04
binary data of specified length.
Packit 7cfc04
.PP
Packit 7cfc04
By default
Packit 7cfc04
(i.e.,
Packit 7cfc04
.IR flags
Packit 7cfc04
is zero),
Packit 7cfc04
the extended attribute will be created if it does not exist,
Packit 7cfc04
or the value will be replaced if the attribute already exists.
Packit 7cfc04
To modify these semantics, one of the following values can be specified in
Packit 7cfc04
.IR flags :
Packit 7cfc04
.TP
Packit 7cfc04
.B XATTR_CREATE
Packit 7cfc04
Perform a pure create, which fails if the named attribute exists already.
Packit 7cfc04
.TP
Packit 7cfc04
.B XATTR_REPLACE
Packit 7cfc04
Perform a pure replace operation,
Packit 7cfc04
which fails if the named attribute does not already exist.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success, zero is returned.
Packit 7cfc04
On failure, \-1 is returned and
Packit 7cfc04
.I errno
Packit 7cfc04
is set appropriately.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EDQUOT
Packit 7cfc04
Disk quota limits meant that
Packit 7cfc04
there is insufficient space remaining to store the extended attribute.
Packit 7cfc04
.TP
Packit 7cfc04
.B EEXIST
Packit 7cfc04
.B XATTR_CREATE
Packit 7cfc04
was specified, and the attribute exists already.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOATTR
Packit 7cfc04
.B XATTR_REPLACE
Packit 7cfc04
was specified, and the attribute does not exist.
Packit 7cfc04
.RB ( ENOATTR
Packit 7cfc04
is defined to be a synonym for
Packit 7cfc04
.BR ENODATA
Packit 7cfc04
in
Packit 7cfc04
.IR <attr/xattr.h> .)
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOSPC
Packit 7cfc04
There is insufficient space remaining to store the extended attribute.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOTSUP
Packit 7cfc04
The namespace prefix of
Packit 7cfc04
.I name
Packit 7cfc04
is not valid.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOTSUP
Packit 7cfc04
Extended attributes are not supported by the filesystem, or are disabled,
Packit 7cfc04
.TP
Packit 7cfc04
.B EPERM
Packit 7cfc04
The file is marked immutable or append-only.
Packit 7cfc04
(See
Packit 7cfc04
.BR ioctl_iflags (2).)
Packit 7cfc04
.PP
Packit 7cfc04
In addition, the errors documented in
Packit 7cfc04
.BR stat (2)
Packit 7cfc04
can also occur.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
These system calls have been available on Linux since kernel 2.4;
Packit 7cfc04
glibc support is provided since version 2.3.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
These system calls are Linux-specific.
Packit 7cfc04
.\" .SH AUTHORS
Packit 7cfc04
.\" Andreas Gruenbacher,
Packit 7cfc04
.\" .RI < a.gruenbacher@computer.org >
Packit 7cfc04
.\" and the SGI XFS development team,
Packit 7cfc04
.\" .RI < linux-xfs@oss.sgi.com >.
Packit 7cfc04
.\" Please send any bug reports or comments to these addresses.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR getfattr (1),
Packit 7cfc04
.BR setfattr (1),
Packit 7cfc04
.BR getxattr (2),
Packit 7cfc04
.BR listxattr (2),
Packit 7cfc04
.BR open (2),
Packit 7cfc04
.BR removexattr (2),
Packit 7cfc04
.BR stat (2),
Packit 7cfc04
.BR symlink (7),
Packit 7cfc04
.BR xattr (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.