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