1SETXATTR(2)                Linux Programmer's Manual               SETXATTR(2)
2
3
4

NAME

6       setxattr, lsetxattr, fsetxattr - set an extended attribute value
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/xattr.h>
11
12       int setxattr(const char *path, const char *name,
13                     const void *value, size_t size, int flags);
14       int lsetxattr(const char *path, const char *name,
15                     const void *value, size_t size, int flags);
16       int fsetxattr(int fd, const char *name,
17                     const void *value, size_t size, int flags);
18

DESCRIPTION

20       Extended attributes are name:value pairs associated with inodes (files,
21       directories, symbolic links, etc.).  They are extensions to the  normal
22       attributes  which  are  associated with all inodes in the system (i.e.,
23       the stat(2) data).  A complete overview of extended attributes concepts
24       can be found in xattr(7).
25
26       setxattr()  sets the value of the extended attribute identified by name
27       and associated with the given path in the filesystem.  The  size  argu‐
28       ment  specifies  the  size  (in bytes) of value; a zero-length value is
29       permitted.
30
31       lsetxattr() is identical to setxattr(), except in the case  of  a  sym‐
32       bolic link, where the extended attribute is set on the link itself, not
33       the file that it refers to.
34
35       fsetxattr() is identical to setxattr(), only the extended attribute  is
36       set  on  the  open  file  referred to by fd (as returned by open(2)) in
37       place of path.
38
39       An extended attribute name  is  a  null-terminated  string.   The  name
40       includes  a namespace prefix; there may be several, disjoint namespaces
41       associated  with  an  individual  inode.   The  value  of  an  extended
42       attribute  is  a chunk of arbitrary textual or binary data of specified
43       length.
44
45       By default (i.e., flags is zero), the extended attribute will  be  cre‐
46       ated  if  it  does  not  exist,  or  the  value will be replaced if the
47       attribute already exists.  To modify these semantics, one of  the  fol‐
48       lowing values can be specified in flags:
49
50       XATTR_CREATE
51              Perform a pure create, which fails if the named attribute exists
52              already.
53
54       XATTR_REPLACE
55              Perform a pure replace  operation,  which  fails  if  the  named
56              attribute does not already exist.
57

RETURN VALUE

59       On  success, zero is returned.  On failure, -1 is returned and errno is
60       set appropriately.
61

ERRORS

63       EDQUOT Disk quota limits meant that there is insufficient space remain‐
64              ing to store the extended attribute.
65
66       EEXIST XATTR_CREATE was specified, and the attribute exists already.
67
68       ENODATA
69              XATTR_REPLACE was specified, and the attribute does not exist.
70
71       ENOSPC There  is  insufficient  space  remaining  to store the extended
72              attribute.
73
74       ENOTSUP
75              The namespace prefix of name is not valid.
76
77       ENOTSUP
78              Extended attributes are not supported by the filesystem, or  are
79              disabled,
80
81       EPERM  The   file   is   marked   immutable   or   append-only.    (See
82              ioctl_iflags(2).)
83
84       In addition, the errors documented in stat(2) can also occur.
85
86       ERANGE The size of name or value exceeds a filesystem-specific limit.
87

VERSIONS

89       These system calls have been available on Linux since kernel 2.4; glibc
90       support is provided since version 2.3.
91

CONFORMING TO

93       These system calls are Linux-specific.
94

SEE ALSO

96       getfattr(1),  setfattr(1), getxattr(2), listxattr(2), open(2), removex‐
97       attr(2), stat(2), symlink(7), xattr(7)
98

COLOPHON

100       This page is part of release 5.07 of the Linux  man-pages  project.   A
101       description  of  the project, information about reporting bugs, and the
102       latest    version    of    this    page,    can     be     found     at
103       https://www.kernel.org/doc/man-pages/.
104
105
106
107Linux                             2019-08-02                       SETXATTR(2)
Impressum