]>
Commit | Line | Data |
---|---|---|
bf5a7247 MK |
1 | .\" Copyright (C) Andreas Gruenbacher, February 2001 |
2 | .\" Copyright (C) Silicon Graphics Inc, September 2001 | |
fea681da | 3 | .\" |
1dd72f9c | 4 | .\" %%%LICENSE_START(GPLv2+_DOC_FULL) |
fea681da MK |
5 | .\" This is free documentation; you can redistribute it and/or |
6 | .\" modify it under the terms of the GNU General Public License as | |
7 | .\" published by the Free Software Foundation; either version 2 of | |
8 | .\" the License, or (at your option) any later version. | |
9 | .\" | |
10 | .\" The GNU General Public License's references to "object code" | |
11 | .\" and "executables" are to be interpreted as the output of any | |
12 | .\" document formatting or typesetting system, including | |
13 | .\" intermediate and printed output. | |
14 | .\" | |
15 | .\" This manual is distributed in the hope that it will be useful, | |
16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | .\" GNU General Public License for more details. | |
19 | .\" | |
20 | .\" You should have received a copy of the GNU General Public | |
c715f741 MK |
21 | .\" License along with this manual; if not, see |
22 | .\" <http://www.gnu.org/licenses/>. | |
6a8d8745 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
63121bd4 | 25 | .TH SETXATTR 2 2019-08-02 "Linux" "Linux Programmer's Manual" |
fea681da MK |
26 | .SH NAME |
27 | setxattr, lsetxattr, fsetxattr \- set an extended attribute value | |
28 | .SH SYNOPSIS | |
29 | .fam C | |
30 | .nf | |
31 | .B #include <sys/types.h> | |
4f72d935 | 32 | .B #include <sys/xattr.h> |
68e4db0a | 33 | .PP |
c10859eb MK |
34 | .BI "int setxattr(const char\ *" path ", const char\ *" name , |
35 | .BI " const void\ *" value ", size_t " size ", int " flags ); | |
36 | .BI "int lsetxattr(const char\ *" path ", const char\ *" name , | |
37 | .BI " const void\ *" value ", size_t " size ", int " flags ); | |
d3b03141 | 38 | .BI "int fsetxattr(int " fd ", const char\ *" name , |
c10859eb | 39 | .BI " const void\ *" value ", size_t " size ", int " flags ); |
fea681da MK |
40 | .fi |
41 | .fam T | |
42 | .SH DESCRIPTION | |
43 | Extended attributes are | |
44 | .IR name :\c | |
45 | .I value | |
0967c11f | 46 | pairs associated with inodes (files, directories, symbolic links, etc.). |
fea681da | 47 | They are extensions to the normal attributes which are associated |
75b94dc3 | 48 | with all inodes in the system (i.e., the |
fea681da MK |
49 | .BR stat (2) |
50 | data). | |
51 | A complete overview of extended attributes concepts can be found in | |
89fabe2e | 52 | .BR xattr (7). |
fea681da | 53 | .PP |
e511ffb6 | 54 | .BR setxattr () |
fea681da MK |
55 | sets the |
56 | .I value | |
57 | of the extended attribute identified by | |
58 | .I name | |
59 | and associated with the given | |
60 | .I path | |
9ee4a2b6 | 61 | in the filesystem. |
fea681da MK |
62 | The |
63 | .I size | |
736703bd | 64 | argument specifies the size (in bytes) of |
60da5b89 MK |
65 | .IR value ; |
66 | a zero-length value is permitted. | |
fea681da | 67 | .PP |
e511ffb6 | 68 | .BR lsetxattr () |
c13182ef | 69 | is identical to |
e511ffb6 | 70 | .BR setxattr (), |
fea681da MK |
71 | except in the case of a symbolic link, where the extended attribute is |
72 | set on the link itself, not the file that it refers to. | |
73 | .PP | |
e511ffb6 | 74 | .BR fsetxattr () |
fea681da | 75 | is identical to |
e511ffb6 | 76 | .BR setxattr (), |
d3b03141 MK |
77 | only the extended attribute is set on the open file referred to by |
78 | .I fd | |
fea681da MK |
79 | (as returned by |
80 | .BR open (2)) | |
81 | in place of | |
82 | .IR path . | |
83 | .PP | |
5232e869 | 84 | An extended attribute name is a null-terminated string. |
fea681da MK |
85 | The |
86 | .I name | |
df8a3cac | 87 | includes a namespace prefix; there may be several, disjoint |
fea681da MK |
88 | namespaces associated with an individual inode. |
89 | The | |
90 | .I value | |
91 | of an extended attribute is a chunk of arbitrary textual or | |
92 | binary data of specified length. | |
93 | .PP | |
9398702c MK |
94 | By default |
95 | (i.e., | |
96 | .IR flags | |
97 | is zero), | |
736703bd MK |
98 | the extended attribute will be created if it does not exist, |
99 | or the value will be replaced if the attribute already exists. | |
9398702c MK |
100 | To modify these semantics, one of the following values can be specified in |
101 | .IR flags : | |
102 | .TP | |
103 | .B XATTR_CREATE | |
104 | Perform a pure create, which fails if the named attribute exists already. | |
105 | .TP | |
106 | .B XATTR_REPLACE | |
107 | Perform a pure replace operation, | |
108 | which fails if the named attribute does not already exist. | |
fea681da MK |
109 | .SH RETURN VALUE |
110 | On success, zero is returned. | |
111 | On failure, \-1 is returned and | |
112 | .I errno | |
113 | is set appropriately. | |
92d67001 MK |
114 | .SH ERRORS |
115 | .TP | |
116 | .B EDQUOT | |
117 | Disk quota limits meant that | |
118 | there is insufficient space remaining to store the extended attribute. | |
119 | .TP | |
120 | .B EEXIST | |
2f0af33b | 121 | .B XATTR_CREATE |
92d67001 MK |
122 | was specified, and the attribute exists already. |
123 | .TP | |
acac1139 | 124 | .B ENODATA |
1274071a | 125 | .B XATTR_REPLACE |
92d67001 | 126 | was specified, and the attribute does not exist. |
acac1139 MK |
127 | .\" .RB ( ENOATTR |
128 | .\" is defined to be a synonym for | |
129 | .\" .BR ENODATA | |
130 | .\" in | |
131 | .\" .IR <attr/attributes.h> .) | |
92d67001 MK |
132 | .TP |
133 | .B ENOSPC | |
134 | There is insufficient space remaining to store the extended attribute. | |
135 | .TP | |
136 | .B ENOTSUP | |
2f2a53b5 MK |
137 | The namespace prefix of |
138 | .I name | |
139 | is not valid. | |
140 | .TP | |
141 | .B ENOTSUP | |
9ee4a2b6 | 142 | Extended attributes are not supported by the filesystem, or are disabled, |
937a7c87 MK |
143 | .TP |
144 | .B EPERM | |
145 | The file is marked immutable or append-only. | |
146 | (See | |
147 | .BR ioctl_iflags (2).) | |
fea681da | 148 | .PP |
92d67001 | 149 | In addition, the errors documented in |
fea681da | 150 | .BR stat (2) |
92d67001 | 151 | can also occur. |
8d7dde9f MK |
152 | .TP |
153 | .B ERANGE | |
154 | The size of | |
155 | .I name | |
156 | or | |
157 | .I value | |
158 | exceeds a filesystem-specific limit. | |
570dd978 MK |
159 | .SH VERSIONS |
160 | These system calls have been available on Linux since kernel 2.4; | |
161 | glibc support is provided since version 2.3. | |
47297adb | 162 | .SH CONFORMING TO |
8382f16d | 163 | These system calls are Linux-specific. |
dc919d09 MK |
164 | .\" .SH AUTHORS |
165 | .\" Andreas Gruenbacher, | |
166 | .\" .RI < a.gruenbacher@computer.org > | |
167 | .\" and the SGI XFS development team, | |
168 | .\" .RI < linux-xfs@oss.sgi.com >. | |
169 | .\" Please send any bug reports or comments to these addresses. | |
fea681da MK |
170 | .SH SEE ALSO |
171 | .BR getfattr (1), | |
172 | .BR setfattr (1), | |
173 | .BR getxattr (2), | |
174 | .BR listxattr (2), | |
175 | .BR open (2), | |
176 | .BR removexattr (2), | |
177 | .BR stat (2), | |
89fabe2e MK |
178 | .BR symlink (7), |
179 | .BR xattr (7) |