]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/setxattr.2
grfix
[thirdparty/man-pages.git] / man2 / setxattr.2
1 .\"
2 .\" Extended attributes system calls manual pages
3 .\"
4 .\" (C) Andreas Gruenbacher, February 2001
5 .\" (C) Silicon Graphics Inc, September 2001
6 .\"
7 .\" This is free documentation; you can redistribute it and/or
8 .\" modify it under the terms of the GNU General Public License as
9 .\" published by the Free Software Foundation; either version 2 of
10 .\" the License, or (at your option) any later version.
11 .\"
12 .\" The GNU General Public License's references to "object code"
13 .\" and "executables" are to be interpreted as the output of any
14 .\" document formatting or typesetting system, including
15 .\" intermediate and printed output.
16 .\"
17 .\" This manual is distributed in the hope that it will be useful,
18 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 .\" GNU General Public License for more details.
21 .\"
22 .\" You should have received a copy of the GNU General Public
23 .\" License along with this manual; if not, write to the Free
24 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
25 .\" USA.
26 .\"
27 .TH SETXATTR 2 2001-12-31 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 setxattr, lsetxattr, fsetxattr \- set an extended attribute value
30 .SH SYNOPSIS
31 .fam C
32 .nf
33 .B #include <sys/types.h>
34 .B #include <attr/xattr.h>
35 .sp
36 .BI "int setxattr(const char\ *" path ", const char\ *" name ,
37 .BI " const void\ *" value ", size_t " size ", int " flags );
38 .BI "int lsetxattr(const char\ *" path ", const char\ *" name ,
39 .BI " const void\ *" value ", size_t " size ", int " flags );
40 .BI "int fsetxattr(int " fd ", const char\ *" name ,
41 .BI " const void\ *" value ", size_t " size ", int " flags );
42 .fi
43 .fam T
44 .SH DESCRIPTION
45 Extended attributes are
46 .IR name :\c
47 .I value
48 pairs associated with inodes (files, directories, symbolic links, etc.).
49 They are extensions to the normal attributes which are associated
50 with all inodes in the system (i.e., the
51 .BR stat (2)
52 data).
53 A complete overview of extended attributes concepts can be found in
54 .BR attr (5).
55 .PP
56 .BR setxattr ()
57 sets the
58 .I value
59 of the extended attribute identified by
60 .I name
61 and associated with the given
62 .I path
63 in the filesystem.
64 The
65 .I size
66 of the
67 .I value
68 must be specified.
69 .PP
70 .BR lsetxattr ()
71 is identical to
72 .BR setxattr (),
73 except in the case of a symbolic link, where the extended attribute is
74 set on the link itself, not the file that it refers to.
75 .PP
76 .BR fsetxattr ()
77 is identical to
78 .BR setxattr (),
79 only the extended attribute is set on the open file referred to by
80 .I fd
81 (as returned by
82 .BR open (2))
83 in place of
84 .IR path .
85 .PP
86 An extended attribute name is a simple null-terminated string.
87 The
88 .I name
89 includes a namespace prefix; there may be several, disjoint
90 namespaces associated with an individual inode.
91 The
92 .I value
93 of an extended attribute is a chunk of arbitrary textual or
94 binary data of specified length.
95 .PP
96 The
97 .I flags
98 parameter can be used to refine the semantics of the operation.
99 .B XATTR_CREATE
100 specifies a pure create, which fails if the named
101 attribute exists already.
102 .B XATTR_REPLACE
103 specifies a pure replace operation, which fails if the
104 named attribute does not already exist.
105 By default (no flags), the extended attribute will be created if
106 need be, or will simply replace the value if the attribute exists.
107 .SH RETURN VALUE
108 On success, zero is returned.
109 On failure, \-1 is returned and
110 .I errno
111 is set appropriately.
112 .PP
113 If
114 .B XATTR_CREATE
115 is specified, and the attribute exists already,
116 .I errno
117 is set to
118 .BR EEXIST .
119 If
120 .B XATTR_REPLACE
121 is specified, and the attribute does not exist,
122 .I errno
123 is set to
124 .BR ENOATTR .
125 .PP
126 If there is insufficient space remaining to store the extended attribute,
127 .I errno
128 is set to either
129 .BR ENOSPC ,
130 or
131 .B EDQUOT
132 if quota enforcement was the cause.
133 .PP
134 If extended attributes are not supported by the filesystem, or are disabled,
135 .I errno
136 is set to
137 .BR ENOTSUP .
138 .PP
139 The errors documented for the
140 .BR stat (2)
141 system call are also applicable here.
142 .SH VERSIONS
143 These system calls have been available on Linux since kernel 2.4;
144 glibc support is provided since version 2.3.
145 .SH "CONFORMING TO"
146 These system calls are Linux-specific.
147 .\" .SH AUTHORS
148 .\" Andreas Gruenbacher,
149 .\" .RI < a.gruenbacher@computer.org >
150 .\" and the SGI XFS development team,
151 .\" .RI < linux-xfs@oss.sgi.com >.
152 .\" Please send any bug reports or comments to these addresses.
153 .SH SEE ALSO
154 .BR getfattr (1),
155 .BR setfattr (1),
156 .BR getxattr (2),
157 .BR listxattr (2),
158 .BR open (2),
159 .BR removexattr (2),
160 .BR stat (2),
161 .BR attr (5)