2 .\" Copyright (c) 2001 Dima Dorfman <dima@unixfreak.org>
3 .\" Copyright (c) 2003 Robert Watson <rwatson@FreeBSD.org>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nm extattr_delete_fd ,
32 .Nm extattr_delete_file ,
33 .Nm extattr_delete_link ,
35 .Nm extattr_get_file ,
36 .Nm extattr_get_link ,
38 .Nm extattr_list_file ,
39 .Nm extattr_list_link ,
41 .Nm extattr_set_file ,
43 .Nd system calls to manipulate VFS extended attributes
50 .Fn extattr_delete_fd "int fd" "int attrnamespace" "const char *attrname"
52 .Fn extattr_delete_file "const char *path" "int attrnamespace" "const char *attrname"
54 .Fn extattr_delete_link "const char *path" "int attrnamespace" "const char *attrname"
56 .Fn extattr_get_fd "int fd" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes"
58 .Fn extattr_get_file "const char *path" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes"
60 .Fn extattr_get_link "const char *path" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes"
62 .Fn extattr_list_fd "int fd" "int attrnamespace" "void *data" "size_t nbytes"
64 .Fn extattr_list_file "const char *path" "int attrnamespace" "void *data" "size_t nbytes"
66 .Fn extattr_list_link "const char *path" "int attrnamespace" "void *data" "size_t nbytes"
68 .Fn extattr_set_fd "int fd" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes"
70 .Fn extattr_set_file "const char *path" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes"
72 .Fn extattr_set_link "const char *path" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes"
74 Named extended attributes are meta-data associated with vnodes
75 representing files and directories.
78 pairs within a set of namespaces.
82 system call retrieves the value of the specified extended attribute into
83 a buffer pointed to by
89 system call sets the value of the specified extended attribute to the data
93 .Fn extattr_delete_file
94 system call deletes the extended attribute specified.
97 returns a list of attributes present in the requested namespace.
98 Each list entry consists of a single byte containing the length
99 of the attribute name, followed by the attribute name.
100 The attribute name is not terminated by ASCII 0 (nul).
104 .Fn extattr_list_file
109 arguments in the style of
112 consumes these arguments in the style of
122 .Fn extattr_list_file
123 then the size of defined extended attribute data will be returned, rather
124 than the quantity read, permitting applications to test the size of the
125 data without performing a read.
127 .Fn extattr_delete_link ,
128 .Fn extattr_get_link ,
131 system calls behave in the same way as their _file counterparts, except that
132 they do not follow symlinks.
136 .Fn extattr_delete_fd ,
137 .Fn extattr_list_fd ,
140 calls are identical to their
142 counterparts except for the first argument.
145 functions take a file descriptor, while the
147 functions take a path.
148 Both arguments describe a file associated with the extended attribute
149 that should be manipulated.
152 functions can be used with file descriptors opened with the
156 The following arguments are common to all the system calls described here:
157 .Bl -tag -width attrnamespace
159 the namespace in which the extended attribute resides; see
162 the name of the extended attribute
165 Named extended attribute semantics vary by file system implementing the call.
166 Not all operations may be supported for a particular attribute.
167 Additionally, the format of the data in
169 is attribute-specific.
171 For more information on named extended attributes, please see
176 .Fn extattr_get_file ,
177 .Fn extattr_get_link ,
178 .Fn extattr_list_fd ,
179 .Fn extattr_list_file ,
180 .Fn extattr_list_link ,
182 .Fn extattr_set_file ,
185 calls return the number of bytes
186 that were read or written from the
195 .Fn extattr_get_file ,
196 .Fn extattr_get_link ,
197 .Fn extattr_list_fd ,
198 .Fn extattr_list_file ,
200 .Fn extattr_list_link
201 return the number of bytes available to read.
202 If any of the calls are unsuccessful, the value \-1 is returned
203 and the global variable
205 is set to indicate the error.
207 .Rv -std extattr_delete_file
209 The following errors may be returned by the system calls themselves.
210 Additionally, the file system implementing the call may return any
211 other errors it desires.
219 or the memory range defined by
223 point outside the process's allocated address space.
224 .It Bq Er ENAMETOOLONG
225 The attribute name was longer than
226 .Dv EXTATTR_MAXNAMELEN .
232 .Fn extattr_delete_fd ,
235 system calls may also fail if:
238 The file descriptor referenced by
244 .Fn extattr_get_file ,
245 .Fn extattr_set_file ,
247 .Fn extattr_delete_file
248 calls may also fail due to the following errors:
251 The requested attribute was not defined for this file.
253 A component of the path prefix is not a directory.
254 .It Bq Er ENAMETOOLONG
255 A component of a pathname exceeded 255 characters,
256 or an entire path name exceeded 1023 characters.
258 A component of the path name that must exist does not exist.
260 Search permission is denied for a component of the path prefix.
261 .\" XXX are any missing?
268 .Xr VOP_GETEXTATTR 9 ,
271 Extended attribute support was developed as part of the
273 Project, and introduced in
275 It was developed to support security extensions requiring additional labels
276 to be associated with each file or directory.
278 This interface is under active development, and as such is subject to
279 change as applications are adapted to use it.
280 Developers are discouraged from relying on its stability.
282 In earlier versions of this API, passing an empty string for the
285 .Fn extattr_get_file ,
288 would return the list of attributes defined for the target object.
289 This interface has been deprecated in preference to using the explicit
290 list API, and should not be used.