272 lines
6.2 KiB
HTML
272 lines
6.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SETXATTR</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SETXATTR</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2019-08-02<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
setxattr, lsetxattr, fsetxattr - set an extended attribute value
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/sys/xattr.h">sys/xattr.h</A>></B>
|
|
|
|
<B>int setxattr(const char *</B><I>path</I><B>, const char *</B><I>name</I><B>,</B>
|
|
<B> const void *</B><I>value</I><B>, size_t </B><I>size</I><B>, int </B><I>flags</I><B>);</B>
|
|
<B>int lsetxattr(const char *</B><I>path</I><B>, const char *</B><I>name</I><B>,</B>
|
|
<B> const void *</B><I>value</I><B>, size_t </B><I>size</I><B>, int </B><I>flags</I><B>);</B>
|
|
<B>int fsetxattr(int </B><I>fd</I><B>, const char *</B><I>name</I><B>,</B>
|
|
<B> const void *</B><I>value</I><B>, size_t </B><I>size</I><B>, int </B><I>flags</I><B>);</B>
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
Extended attributes are
|
|
<I>name</I>:<I>value</I>
|
|
|
|
pairs associated with inodes (files, directories, symbolic links, etc.).
|
|
They are extensions to the normal attributes which are associated
|
|
with all inodes in the system (i.e., the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+stat">stat</A></B>(2)
|
|
|
|
data).
|
|
A complete overview of extended attributes concepts can be found in
|
|
<B><A HREF="/cgi-bin/man/man2html?7+xattr">xattr</A></B>(7).
|
|
|
|
<P>
|
|
|
|
<B>setxattr</B>()
|
|
|
|
sets the
|
|
<I>value</I>
|
|
|
|
of the extended attribute identified by
|
|
<I>name</I>
|
|
|
|
and associated with the given
|
|
<I>path</I>
|
|
|
|
in the filesystem.
|
|
The
|
|
<I>size</I>
|
|
|
|
argument specifies the size (in bytes) of
|
|
<I>value</I>;
|
|
|
|
a zero-length value is permitted.
|
|
<P>
|
|
|
|
<B>lsetxattr</B>()
|
|
|
|
is identical to
|
|
<B>setxattr</B>(),
|
|
|
|
except in the case of a symbolic link, where the extended attribute is
|
|
set on the link itself, not the file that it refers to.
|
|
<P>
|
|
|
|
<B>fsetxattr</B>()
|
|
|
|
is identical to
|
|
<B>setxattr</B>(),
|
|
|
|
only the extended attribute is set on the open file referred to by
|
|
<I>fd</I>
|
|
|
|
(as returned by
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2))
|
|
|
|
in place of
|
|
<I>path</I>.
|
|
|
|
<P>
|
|
|
|
An extended attribute name is a null-terminated string.
|
|
The
|
|
<I>name</I>
|
|
|
|
includes a namespace prefix; there may be several, disjoint
|
|
namespaces associated with an individual inode.
|
|
The
|
|
<I>value</I>
|
|
|
|
of an extended attribute is a chunk of arbitrary textual or
|
|
binary data of specified length.
|
|
<P>
|
|
|
|
By default
|
|
(i.e.,
|
|
<I>flags</I>
|
|
|
|
is zero),
|
|
the extended attribute will be created if it does not exist,
|
|
or the value will be replaced if the attribute already exists.
|
|
To modify these semantics, one of the following values can be specified in
|
|
<I>flags</I>:
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>XATTR_CREATE</B>
|
|
|
|
<DD>
|
|
Perform a pure create, which fails if the named attribute exists already.
|
|
<DT id="2"><B>XATTR_REPLACE</B>
|
|
|
|
<DD>
|
|
Perform a pure replace operation,
|
|
which fails if the named attribute does not already exist.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success, zero is returned.
|
|
On failure, -1 is returned and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="3"><B>EDQUOT</B>
|
|
|
|
<DD>
|
|
Disk quota limits meant that
|
|
there is insufficient space remaining to store the extended attribute.
|
|
<DT id="4"><B>EEXIST</B>
|
|
|
|
<DD>
|
|
<B>XATTR_CREATE</B>
|
|
|
|
was specified, and the attribute exists already.
|
|
<DT id="5"><B>ENODATA</B>
|
|
|
|
<DD>
|
|
<B>XATTR_REPLACE</B>
|
|
|
|
was specified, and the attribute does not exist.
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="6"><B>ENOSPC</B>
|
|
|
|
<DD>
|
|
There is insufficient space remaining to store the extended attribute.
|
|
<DT id="7"><B>ENOTSUP</B>
|
|
|
|
<DD>
|
|
The namespace prefix of
|
|
<I>name</I>
|
|
|
|
is not valid.
|
|
<DT id="8"><B>ENOTSUP</B>
|
|
|
|
<DD>
|
|
Extended attributes are not supported by the filesystem, or are disabled,
|
|
<DT id="9"><B>EPERM</B>
|
|
|
|
<DD>
|
|
The file is marked immutable or append-only.
|
|
(See
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_iflags">ioctl_iflags</A></B>(2).)
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
In addition, the errors documented in
|
|
<B><A HREF="/cgi-bin/man/man2html?2+stat">stat</A></B>(2)
|
|
|
|
can also occur.
|
|
<DL COMPACT>
|
|
<DT id="10"><B>ERANGE</B>
|
|
|
|
<DD>
|
|
The size of
|
|
<I>name</I>
|
|
|
|
or
|
|
<I>value</I>
|
|
|
|
exceeds a filesystem-specific limit.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
These system calls have been available on Linux since kernel 2.4;
|
|
glibc support is provided since version 2.3.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
These system calls are Linux-specific.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+getfattr">getfattr</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+setfattr">setfattr</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getxattr">getxattr</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+listxattr">listxattr</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+removexattr">removexattr</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+stat">stat</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+symlink">symlink</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+xattr">xattr</A></B>(7)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="11"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="12"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="13"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="14"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="15"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="16"><A HREF="#lbAG">VERSIONS</A><DD>
|
|
<DT id="17"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="18"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="19"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:34 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|