1SETXATTR(2)                      System calls                      SETXATTR(2)
2
3
4

NAME

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

SYNOPSIS

9       #include <sys/types.h>
10       #include <attr/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 filedes, 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,  symlinks,  etc).   They  are  extensions  to  the  normal
22       attributes which are associated with all inodes in the system (i.e. the
23       stat(2) data).  A complete overview of extended attributes concepts can
24       be found in attr(5).
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 of  the
28       value must be specified.
29
30       lsetxattr  is  identical  to setxattr, except in the case of a symbolic
31       link, where the extended attribute is set on the link itself,  not  the
32       file that it refers to.
33
34       fsetxattr  is identical to setxattr, only the extended attribute is set
35       on the open file pointed to by filedes  (as  returned  by  open(2))  in
36       place of path.
37
38       An  extended  attribute  name  is a simple NULL-terminated string.  The
39       name includes a namespace prefix  -  there  may  be  several,  disjoint
40       namespaces  associated  with  an  individual  inode.   The  value of an
41       extended attribute is a chunk of arbitrary textual or  binary  data  of
42       specified length.
43
44       The  flags  parameter can be used to refine the semantics of the opera‐
45       tion.  XATTR_CREATE specifies a pure create, which fails if  the  named
46       attribute exists already.  XATTR_REPLACE specifies a pure replace oper‐
47       ation, which fails if the named attribute does not already  exist.   By
48       default  (no flags), the extended attribute will be created if need be,
49       or will simply replace the value if the attribute exists.
50

RETURN VALUE

52       On success, zero is returned.  On failure, -1 is returned and errno  is
53       set appropriately.
54
55       If  XATTR_CREATE  is specified, and the attribute exists already, errno
56       is set to EEXIST.  If XATTR_REPLACE is  specified,  and  the  attribute
57       does not exist, errno is set to ENOATTR.
58
59       If  there  is  insufficient  space  remaining  to  store  the  extended
60       attribute, errno is set to either ENOSPC, or EDQUOT if  quota  enforce‐
61       ment was the cause.
62
63       If extended attributes are not supported by the filesystem, or are dis‐
64       abled, errno is set to ENOTSUP.
65
66       The errors documented for the stat(2) system call are  also  applicable
67       here.
68

AUTHORS

70       Andreas Gruenbacher, <a.gruenbacher@bestbits.at> and the SGI XFS devel‐
71       opment team, <linux-xfs@oss.sgi.com>.  Please send any bug  reports  or
72       comments to these addresses.
73

SEE ALSO

75       getfattr(1),  setfattr(1), open(2), stat(2), getxattr(2), listxattr(2),
76       removexattr(2), and attr(5).
77
78
79
80Dec 2001                      Extended Attributes                  SETXATTR(2)
Impressum