2 .\" Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 .\" @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 .\" License may not be used to create, or enable the creation or
11 .\" redistribution of, unlawful or unlicensed copies of an Apple operating
12 .\" system, or to circumvent, violate, or enable the circumvention or
13 .\" violation of, any terms of an Apple operating system software license
16 .\" Please obtain a copy of the License at
17 .\" http://www.opensource.apple.com/apsl/ and read it before using this
20 .\" The Original Code and all software distributed under the License are
21 .\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 .\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 .\" Please see the License for the specific language governing rights and
26 .\" limitations under the License.
28 .\" @APPLE_LICENSE_OSREFERENCE_HEADER_END@
36 .Nd set an extended attribute value
38 .Fd #include <sys/xattr.h>
40 .Fn setxattr "const char *path" "const char *name" "void *value" "size_t size" "u_int32_t position" "int options"
42 .Fn fsetxattr "int fd" "const char *name" "void *value" "size_t size" "u_int32_t position" "int options"
44 Extended attributes extend the basic attributes associated with files and
45 directories in the file system. They are stored as name:data pairs
46 associated with file system objects (files, directories, symlinks, etc).
53 together as an attribute of
56 An extended attribute's
58 is a simple NULL-terminated UTF-8 string.
60 is a pointer to a data buffer of
62 bytes containing textual or binary data to be associated with the
65 specifies the offset within the extended attribute. In the current
66 implementation, only the resource fork extended attribute makes use of
67 this argument. For all others,
69 is reserved and should be
73 controls how the attribute is set:
75 .Bl -tag -width XATTR_NOFOLLOW
77 do not follow symbolic links.
79 normally sets attributes on the target of
81 if it is a symbolic link.
84 will act on the link itself.
86 fail if the named attribute already exists.
88 fail if the named attribute does not exist. Failure to specify
92 allows creation and replacement.
98 except that it sets an extended attribute on an open file referenced by
102 On success, 0 is returned. On failure, -1 is returned and the global
112 and the named attribute already exists.
117 and the named attribute does not exist.
119 The file system does not support extended attributes or has them disabled.
121 The file system is mounted read-only.
123 The data size of the attribute is out of range (some attributes have size
126 .\" EFTYPE could be more specific but isn't POSIX
127 Attributes cannot be associated with this type of object. For example,
128 attributes are not allowed for resource forks.
135 must be valid UTF-8 and
142 .It Bq Er ENAMETOOLONG
146 UTF-8 bytes, or a component of
150 characters, or the entire
156 Search permission is denied for a component of
158 or permission to set the attribute is denied.
160 Too many symbolic links were encountered resolving
166 points to an invalid address.
168 An I/O error occurred while reading from or writing to the file system.
170 The data size of the extended attribute is too large.
172 Not enough space left on the file system.
182 first appeared in Mac OS X 10.4.