2001-06-25 01:21:13 +00:00
|
|
|
.\"
|
2001-04-01 23:45:11 +00:00
|
|
|
.\" Copyright (c) 2001 Dima Dorfman <dima@unixfreak.org>
|
2003-06-04 04:00:26 +00:00
|
|
|
.\" Copyright (c) 2003 Robert Watson <rwatson@FreeBSD.org>
|
2001-04-01 23:45:11 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2005-02-24 00:04:45 +00:00
|
|
|
.Dd February 23, 2005
|
2001-06-25 01:21:13 +00:00
|
|
|
.Dt EXTATTR 2
|
2001-04-01 23:45:11 +00:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
2001-04-05 01:24:05 +00:00
|
|
|
.Nm extattr_get_fd ,
|
|
|
|
.Nm extattr_set_fd ,
|
|
|
|
.Nm extattr_delete_fd ,
|
2003-06-04 04:00:26 +00:00
|
|
|
.Nm extattr_list_fd ,
|
2001-04-01 23:45:11 +00:00
|
|
|
.Nm extattr_get_file ,
|
|
|
|
.Nm extattr_set_file ,
|
2004-07-05 17:12:53 +00:00
|
|
|
.Nm extattr_delete_file ,
|
2003-06-04 04:00:26 +00:00
|
|
|
.Nm extattr_list_file ,
|
2002-10-09 22:26:48 +00:00
|
|
|
.Nm extattr_get_link ,
|
|
|
|
.Nm extattr_set_link ,
|
2004-07-05 17:12:53 +00:00
|
|
|
.Nm extattr_delete_link ,
|
|
|
|
.Nm extattr_list_link
|
2001-06-25 01:21:13 +00:00
|
|
|
.Nd system calls to manipulate VFS extended attributes
|
2001-04-01 23:45:11 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
|
|
|
.Sh SYNOPSIS
|
2001-10-03 00:51:30 +00:00
|
|
|
.In sys/types.h
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/extattr.h
|
2002-02-10 04:46:28 +00:00
|
|
|
.Ft ssize_t
|
|
|
|
.Fn extattr_get_fd "int fd" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes"
|
2001-04-01 23:45:11 +00:00
|
|
|
.Ft int
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fn extattr_set_fd "int fd" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes"
|
2001-04-05 01:24:05 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn extattr_delete_fd "int fd" "int attrnamespace" "const char *attrname"
|
2002-02-10 04:46:28 +00:00
|
|
|
.Ft ssize_t
|
2003-06-04 04:00:26 +00:00
|
|
|
.Fn extattr_list_fd "int fd" "int attrnamespace" "void *data" "size_t nbytes"
|
|
|
|
.Ft ssize_t
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fn extattr_get_file "const char *path" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes"
|
2001-04-05 01:24:05 +00:00
|
|
|
.Ft int
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fn extattr_set_file "const char *path" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes"
|
2001-04-01 23:45:11 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn extattr_delete_file "const char *path" "int attrnamespace" "const char *attrname"
|
2002-10-09 22:26:48 +00:00
|
|
|
.Ft ssize_t
|
2003-06-04 04:00:26 +00:00
|
|
|
.Fn extattr_list_file "const char *path" "int attrnamespace" "void *data" "size_t nbytes"
|
|
|
|
.Ft ssize_t
|
2002-10-09 22:26:48 +00:00
|
|
|
.Fn extattr_get_link "const char *path" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes"
|
|
|
|
.Ft int
|
|
|
|
.Fn extattr_set_link "const char *path" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes"
|
|
|
|
.Ft int
|
|
|
|
.Fn extattr_delete_link "const char *path" "int attrnamespace" "const char *attrname"
|
2003-06-04 04:00:26 +00:00
|
|
|
.Ft ssize_t
|
|
|
|
.Fn extattr_list_link "const char *path" "int attrnamespace" "void *data" "size_t nbytes"
|
2001-04-01 23:45:11 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
Named extended attributes are meta-data associated with vnodes
|
|
|
|
representing files and directories.
|
|
|
|
They exist as
|
|
|
|
.Qq Li name=value
|
|
|
|
pairs within a set of namespaces.
|
2003-06-04 04:00:26 +00:00
|
|
|
.Pp
|
2001-04-01 23:45:11 +00:00
|
|
|
The
|
|
|
|
.Fn extattr_get_file
|
2002-12-18 09:22:32 +00:00
|
|
|
system call retrieves the value of the specified extended attribute into
|
2002-02-10 04:46:28 +00:00
|
|
|
a buffer pointed to by
|
|
|
|
.Fa data
|
|
|
|
of size
|
2002-03-15 17:57:41 +00:00
|
|
|
.Fa nbytes .
|
2001-04-01 23:45:11 +00:00
|
|
|
The
|
|
|
|
.Fn extattr_set_file
|
2002-12-18 09:22:32 +00:00
|
|
|
system call sets the value of the specified extended attribute to the data
|
2001-04-01 23:45:11 +00:00
|
|
|
described by
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fa data .
|
2001-04-01 23:45:11 +00:00
|
|
|
The
|
|
|
|
.Fn extattr_delete_file
|
2002-12-18 09:22:32 +00:00
|
|
|
system call deletes the extended attribute specified.
|
2001-04-01 23:45:11 +00:00
|
|
|
The
|
2003-06-04 04:00:26 +00:00
|
|
|
.Fn extattr_list_file
|
2005-06-10 16:54:17 +00:00
|
|
|
returns a list of attributes present in the requested namespace.
|
|
|
|
Each list entry consists of a single byte containing the length
|
|
|
|
of the attribute name, followed by the attribute name.
|
|
|
|
The attribute name is not terminated by ASCII 0 (nul).
|
2003-06-04 04:00:26 +00:00
|
|
|
The
|
|
|
|
.Fn extattr_get_file ,
|
2001-04-01 23:45:11 +00:00
|
|
|
and
|
2003-06-04 04:00:26 +00:00
|
|
|
.Fn extattr_list_file
|
2001-04-01 23:45:11 +00:00
|
|
|
calls consume the
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fa data
|
2001-04-01 23:45:11 +00:00
|
|
|
and
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fa nbytes
|
2001-04-01 23:45:11 +00:00
|
|
|
arguments in the style of
|
2003-06-04 04:00:26 +00:00
|
|
|
.Xr read 2 ;
|
|
|
|
.Fn extattr_set_file
|
|
|
|
consumes these arguments in the style of
|
2005-01-21 20:48:00 +00:00
|
|
|
.Xr write 2 .
|
2003-06-04 04:00:26 +00:00
|
|
|
.Pp
|
2002-02-10 04:46:28 +00:00
|
|
|
If
|
|
|
|
.Fa data
|
|
|
|
is
|
|
|
|
.Dv NULL
|
|
|
|
in a call to
|
|
|
|
.Fn extattr_get_file
|
|
|
|
then the size of defined extended attribute data will be returned, rather
|
|
|
|
than the quantity read, permitting applications to test the size of the
|
|
|
|
data without performing a read.
|
2002-10-09 22:26:48 +00:00
|
|
|
The
|
|
|
|
.Fn extattr_delete_link ,
|
|
|
|
.Fn extattr_get_link ,
|
|
|
|
and
|
|
|
|
.Fn extattr_set_link
|
2002-12-18 09:22:32 +00:00
|
|
|
system calls behave in the same way as their _file counterparts, except that
|
2002-10-09 22:26:48 +00:00
|
|
|
they do not follow symlinks.
|
2001-04-01 23:45:11 +00:00
|
|
|
.Pp
|
2001-04-05 01:24:05 +00:00
|
|
|
The
|
2002-12-18 09:22:32 +00:00
|
|
|
.Fn extattr_get_fd ,
|
2001-04-05 01:24:05 +00:00
|
|
|
.Fn extattr_set_fd ,
|
|
|
|
and
|
|
|
|
.Fn extattr_delete_fd
|
|
|
|
calls are identical to their
|
|
|
|
.Qq Li _file
|
|
|
|
counterparts except for the first argument.
|
|
|
|
The
|
|
|
|
.Qq Li _fd
|
|
|
|
functions take a file descriptor, while the
|
|
|
|
.Qq Li _file
|
|
|
|
functions take a path.
|
|
|
|
Both arguments describe a file associated with the extended attribute
|
|
|
|
that should be manipulated.
|
|
|
|
.Pp
|
|
|
|
The following arguments are common to all the system calls described here:
|
2001-04-01 23:45:11 +00:00
|
|
|
.Bl -tag -width attrnamespace
|
|
|
|
.It Fa attrnamespace
|
|
|
|
the namespace in which the extended attribute resides; see
|
|
|
|
.Xr extattr 9
|
|
|
|
.It Fa attrname
|
|
|
|
the name of the extended attribute
|
|
|
|
.El
|
|
|
|
.Pp
|
2002-12-12 17:26:04 +00:00
|
|
|
Named extended attribute semantics vary by file system implementing the call.
|
2001-04-01 23:45:11 +00:00
|
|
|
Not all operations may be supported for a particular attribute.
|
|
|
|
Additionally, the format of the data in
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fa data
|
2001-04-01 23:45:11 +00:00
|
|
|
is attribute-specific.
|
|
|
|
.Pp
|
|
|
|
For more information on named extended attributes, please see
|
|
|
|
.Xr extattr 9 .
|
2001-04-05 01:24:05 +00:00
|
|
|
.Sh CAVEAT
|
|
|
|
This interface is under active development, and as such is subject to
|
|
|
|
change as applications are adapted to use it.
|
|
|
|
Developers are discouraged from relying on its stability.
|
2001-04-01 23:45:11 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
If successful, the
|
|
|
|
.Fn extattr_get_file
|
|
|
|
and
|
|
|
|
.Fn extattr_set_file
|
|
|
|
calls return the number of bytes
|
|
|
|
that were read or written from the
|
2002-02-10 04:46:28 +00:00
|
|
|
.Fa data ,
|
|
|
|
respectively, or if
|
|
|
|
.Fa data
|
|
|
|
was
|
|
|
|
.Dv NULL ,
|
|
|
|
then
|
|
|
|
.Fn extattr_get_file
|
|
|
|
returns the number of bytes available to read.
|
2001-04-01 23:45:11 +00:00
|
|
|
If any of the calls are unsuccessful, the value \-1 is returned
|
|
|
|
and the global variable
|
|
|
|
.Va errno
|
|
|
|
is set to indicate the error.
|
2001-08-31 09:57:38 +00:00
|
|
|
.Pp
|
|
|
|
.Rv -std extattr_delete_file
|
2001-04-01 23:45:11 +00:00
|
|
|
.Sh ERRORS
|
|
|
|
The following errors may be returned by the system calls themselves.
|
2002-12-12 17:26:04 +00:00
|
|
|
Additionally, the file system implementing the call may return any
|
2001-04-01 23:45:11 +00:00
|
|
|
other errors it desires.
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EFAULT
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
|
|
|
.Fa attrnamespace
|
|
|
|
and
|
|
|
|
.Fa attrname
|
|
|
|
arguments,
|
2002-02-10 04:46:28 +00:00
|
|
|
or the memory range defined by
|
|
|
|
.Fa data
|
|
|
|
and
|
|
|
|
.Fa nbytes
|
2002-12-19 09:40:28 +00:00
|
|
|
point outside the process's allocated address space.
|
2001-04-01 23:45:11 +00:00
|
|
|
.It Bq Er ENAMETOOLONG
|
|
|
|
The attribute name was longer than
|
|
|
|
.Dv EXTATTR_MAXNAMELEN .
|
2001-04-05 01:24:05 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn extattr_get_fd ,
|
|
|
|
.Fn extattr_set_fd ,
|
|
|
|
and
|
|
|
|
.Fn extattr_delete_fd
|
2002-12-18 09:22:32 +00:00
|
|
|
system calls may also fail if:
|
2001-04-05 01:24:05 +00:00
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EBADF
|
|
|
|
The file descriptor referenced by
|
|
|
|
.Fa fd
|
|
|
|
was invalid.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Additionally, the
|
|
|
|
.Fn extattr_get_file ,
|
|
|
|
.Fn extattr_set_file ,
|
|
|
|
and
|
|
|
|
.Fn extattr_delete_file
|
|
|
|
calls may also fail due to the following errors:
|
|
|
|
.Bl -tag -width Er
|
2005-02-24 00:04:45 +00:00
|
|
|
.It Bq Er ENOATTR
|
|
|
|
The requested attribute was not defined for this file.
|
2001-04-01 23:45:11 +00:00
|
|
|
.It Bq Er ENOTDIR
|
|
|
|
A component of the path prefix is not a directory.
|
|
|
|
.It Bq Er ENAMETOOLONG
|
|
|
|
A component of a pathname exceeded 255 characters,
|
|
|
|
or an entire path name exceeded 1023 characters.
|
|
|
|
.It Bq Er ENOENT
|
|
|
|
A component of the path name that must exist does not exist.
|
|
|
|
.It Bq Er EACCES
|
|
|
|
Search permission is denied for a component of the path prefix.
|
|
|
|
.\" XXX are any missing?
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
2001-06-25 01:21:13 +00:00
|
|
|
.Xr extattr 3 ,
|
2001-04-01 23:45:11 +00:00
|
|
|
.Xr getextattr 8 ,
|
|
|
|
.Xr setextattr 8 ,
|
|
|
|
.Xr extattr 9 ,
|
|
|
|
.Xr VOP_GETEXTATTR 9 ,
|
|
|
|
.Xr VOP_SETEXTATTR 9
|
|
|
|
.Sh HISTORY
|
|
|
|
Extended attribute support was developed as part of the
|
|
|
|
.Tn TrustedBSD
|
|
|
|
Project, and introduced in
|
|
|
|
.Fx 5.0 .
|
|
|
|
It was developed to support security extensions requiring additional labels
|
|
|
|
to be associated with each file or directory.
|
2003-06-04 04:00:26 +00:00
|
|
|
.Sh BUGS
|
|
|
|
In earlier versions of this API, passing an empty string for the
|
|
|
|
attribute name to
|
|
|
|
.Fn extattr_get_fd ,
|
|
|
|
.Fn extattr_get_file ,
|
|
|
|
or
|
|
|
|
.Fn extattr_get_link
|
|
|
|
would return the list of attributes defined for the target object.
|
|
|
|
This interface has been deprecated in preference to using the explicit
|
|
|
|
list API, and should not be used.
|