2 .\" Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 .\" @APPLE_LICENSE_HEADER_START@
6 .\" This file contains Original Code and/or Modifications of Original Code
7 .\" as defined in and that are subject to the Apple Public Source License
8 .\" Version 2.0 (the 'License'). You may not use this file except in
9 .\" compliance with the License. Please obtain a copy of the License at
10 .\" http://www.opensource.apple.com/apsl/ and read it before using this
13 .\" The Original Code and all software distributed under the License are
14 .\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 .\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 .\" Please see the License for the specific language governing rights and
19 .\" limitations under the License.
21 .\" @APPLE_LICENSE_HEADER_END@
29 .Nd set an extended attribute value
31 .Fd #include <sys/xattr.h>
33 .Fn setxattr "const char *path" "const char *name" "void *value" "size_t size" "u_int32_t position" "int options"
35 .Fn fsetxattr "int fd" "const char *name" "void *value" "size_t size" "u_int32_t position" "int options"
37 Extended attributes extend the basic attributes associated with files and
38 directories in the file system. They are stored as name:data pairs
39 associated with file system objects (files, directories, symlinks, etc).
46 together as an attribute of
49 An extended attribute's
51 is a simple NULL-terminated UTF-8 string.
53 is a pointer to a data buffer of
55 bytes containing textual or binary data to be associated with the
58 specifies the offset within the extended attribute. In the current
59 implementation, only the resource fork extended attribute makes use of
60 this argument. For all others,
62 is reserved and should be
66 controls how the attribute is set:
68 .Bl -tag -width XATTR_NOFOLLOW
70 do not follow symbolic links.
72 normally sets attributes on the target of
74 if it is a symbolic link.
77 will act on the link itself.
79 fail if the named attribute already exists.
81 fail if the named attribute does not exist. Failure to specify
85 allows creation and replacement.
91 except that it sets an extended attribute on an open file referenced by
95 On some filesystems, such as
97 setting the extended attribute
98 .Dv com.apple.ResourceFork
99 will update the modification time (``mtime'') of
102 Due to historical reasons, the
103 .Dv XATTR_FINDERINFO_NAME
105 .Dq com.apple.FinderInfo )
106 extended attribute must be 32 bytes; see the
107 .Dv ATTR_CMN_FNDRINFO
111 The maximum supported size of extended attribute can be found out using
113 with _PC_XATTR_SIZE_BITS option.
115 On success, 0 is returned. On failure, -1 is returned and the global
125 and the named attribute already exists.
130 and the named attribute does not exist.
132 The file system does not support extended attributes or has them disabled.
134 The file system is mounted read-only.
136 The data size of the attribute is out of range (some attributes have size
139 .\" EFTYPE could be more specific but isn't POSIX
140 Attributes cannot be associated with this type of object. For example,
141 attributes are not allowed for resource forks.
148 must be valid UTF-8 and
155 .It Bq Er ENAMETOOLONG
159 UTF-8 bytes, or a component of
163 characters, or the entire
169 Search permission is denied for a component of
171 or permission to set the attribute is denied.
173 Too many symbolic links were encountered resolving
179 points to an invalid address.
181 An I/O error occurred while reading from or writing to the file system.
183 The data size of the extended attribute is too large.
185 Not enough space left on the file system.
196 first appeared in Mac OS X 10.4.