diff options
| author | thorpej <thorpej@NetBSD.org> | 2005-01-02 16:43:26 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2005-01-02 16:43:26 +0000 |
| commit | c165c2b31df884b08cbc9d62356c8a1778dfb986 (patch) | |
| tree | 5d41f82bcba63c8ec8efc4f61ebf93af36aa140d /lib/libc/sys | |
| parent | 9eca3a4ad48549b292fb18f0bf28c41c00c5eec4 (diff) | |
System calls and support routines for file system extended attributes. Libc
version is bumped to 12.125.
From FreeBSD.
Diffstat (limited to 'lib/libc/sys')
| -rw-r--r-- | lib/libc/sys/Makefile.inc | 21 | ||||
| -rw-r--r-- | lib/libc/sys/extattr_get_file.2 | 258 |
2 files changed, 277 insertions, 2 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 28a12099b77..df0c504a2ec 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.153 2004/05/21 17:15:42 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.154 2005/01/02 16:43:26 thorpej Exp $ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # sys sources @@ -44,6 +44,11 @@ SRCS+= _brk.c _fork.c _getcontext.c _pipe.c _sbrk.c ASM= access.S acct.S bind.S chdir.S chflags.S \ chmod.S chown.S chroot.S clock_getres.S clock_gettime.S \ dup.S dup2.S \ + extattrctl.S \ + extattr_delete_fd.S extattr_delete_file.S extattr_delete_link.S \ + extattr_get_fd.S extattr_get_file.S extattr_get_link.S \ + extattr_list_fd.S extattr_list_file.S extattr_list_link.S \ + extattr_set_fd.S extattr_set_file.S extattr_set_link.S \ fchdir.S fchflags.S fchmod.S fchown.S fchroot.S \ fhopen.S fhstat.S fhstatvfs1.S \ fktrace.S flock.S fpathconf.S __fstat13.S fstatvfs1.S \ @@ -137,7 +142,8 @@ LintSysPseudoNoerr.c: ${.CURDIR}/sys/makelintstub \ MAN+= accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 \ chflags.2 chmod.2 chown.2 chroot.2 clock_settime.2 clone.2 close.2 \ - connect.2 dup.2 execve.2 _exit.2 fcntl.2 fdatasync.2 fhopen.2 \ + connect.2 dup.2 execve.2 _exit.2 extattr_get_file.2 \ + fcntl.2 fdatasync.2 fhopen.2 \ flock.2 fork.2 fsync.2 getcontext.2 getdents.2 getdirentries.3 \ getfh.2 getvfsstat.2 getgid.2 getgroups.2 \ getitimer.2 getlogin.2 getpeername.2 getpgrp.2 getpid.2 \ @@ -177,6 +183,17 @@ MLINKS+=chown.2 fchown.2 chown.2 lchown.2 MLINKS+=chroot.2 fchroot.2 MLINKS+=clock_settime.2 clock_gettime.2 MLINKS+=clock_settime.2 clock_getres.2 +MLINKS+=extattr_get_file.2 extattr_set_file.2 \ + extattr_get_file.2 extattr_delete_file.2 \ + extattr_get_file.2 extattr_list_file.2 \ + extattr_get_file.2 extattr_get_fd.2 \ + extattr_get_file.2 extattr_set_fd.2 \ + extattr_get_file.2 extattr_delete_fd.2 \ + extattr_get_file.2 extattr_list_fd.2 \ + extattr_get_file.2 extattr_get_link.2 \ + extattr_get_file.2 extattr_set_link.2 \ + extattr_get_file.2 extattr_delete_link.2 \ + extattr_get_file.2 extattr_list_link.2 MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatvfs.2 fhopen.2 fhstatvfs1.2 MLINKS+=fsync.2 fsync_range.2 MLINKS+=getcontext.2 setcontext.2 diff --git a/lib/libc/sys/extattr_get_file.2 b/lib/libc/sys/extattr_get_file.2 new file mode 100644 index 00000000000..d602ac94627 --- /dev/null +++ b/lib/libc/sys/extattr_get_file.2 @@ -0,0 +1,258 @@ +.\" $NetBSD: extattr_get_file.2,v 1.1 2005/01/02 16:43:26 thorpej Exp $ +.\" +.\" Copyright (c) 2001 Dima Dorfman <dima@unixfreak.org> +.\" Copyright (c) 2003 Robert Watson <rwatson@FreeBSD.org> +.\" 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: src/lib/libc/sys/extattr_get_file.2,v 1.14 2004/07/05 17:12:52 ru Exp +.\" +.Dd January 2, 2004 +.Dt EXTATTR_GET_FILE 2 +.Os +.Sh NAME +.Nm extattr_get_fd , +.Nm extattr_set_fd , +.Nm extattr_delete_fd , +.Nm extattr_list_fd , +.Nm extattr_get_file , +.Nm extattr_set_file , +.Nm extattr_delete_file , +.Nm extattr_list_file , +.Nm extattr_get_link , +.Nm extattr_set_link , +.Nm extattr_delete_link , +.Nm extattr_list_link +.Nd system calls to manipulate VFS extended attributes +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/extattr.h +.Ft ssize_t +.Fn extattr_get_fd "int fd" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes" +.Ft int +.Fn extattr_set_fd "int fd" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes" +.Ft int +.Fn extattr_delete_fd "int fd" "int attrnamespace" "const char *attrname" +.Ft ssize_t +.Fn extattr_list_fd "int fd" "int attrnamespace" "void *data" "size_t nbytes" +.Ft ssize_t +.Fn extattr_get_file "const char *path" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes" +.Ft int +.Fn extattr_set_file "const char *path" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes" +.Ft int +.Fn extattr_delete_file "const char *path" "int attrnamespace" "const char *attrname" +.Ft ssize_t +.Fn extattr_list_file "const char *path" "int attrnamespace" "void *data" "size_t nbytes" +.Ft ssize_t +.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" +.Ft ssize_t +.Fn extattr_list_link "const char *path" "int attrnamespace" "void *data" "size_t nbytes" +.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. +.Pp +The +.Fn extattr_get_file +system call retrieves the value of the specified extended attribute into +a buffer pointed to by +.Fa data +of size +.Fa nbytes . +The +.Fn extattr_set_file +system call sets the value of the specified extended attribute to the data +described by +.Fa data . +The +.Fn extattr_delete_file +system call deletes the extended attribute specified. +The +.Fn extattr_list_file +returns a list of attributes present in the requested namespace, separated +by ASCII 0 (nul) characters. +The +.Fn extattr_get_file , +and +.Fn extattr_list_file +calls consume the +.Fa data +and +.Fa nbytes +arguments in the style of +.Xr read 2 ; +.Fn extattr_set_file +consumes these arguments in the style of +.Xr write 2 . +.Pp +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. +.Pp +The +.Fn extattr_delete_link , +.Fn extattr_get_link , +and +.Fn extattr_set_link +system calls behave in the same way as their _file counterparts, except that +they do not follow symlinks. +.Pp +The +.Fn extattr_get_fd , +.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: +.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 +Named extended attribute semantics vary by file system implementing the call. +Not all operations may be supported for a particular attribute. +Additionally, the format of the data in +.Fa data +is attribute-specific. +.Pp +For more information on named extended attributes, please see +.Xr extattr 9 . +.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. +.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 +.Fa data , +respectively, or if +.Fa data +was +.Dv NULL , +then +.Fn extattr_get_file +returns the number of bytes available to read. +If any of the calls are unsuccessful, the value \-1 is returned +and the global variable +.Va errno +is set to indicate the error. +.Pp +.Rv -std extattr_delete_file +.Sh ERRORS +The following errors may be returned by the system calls themselves. +Additionally, the file system implementing the call may return any +other errors it desires. +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa attrnamespace +and +.Fa attrname +arguments, +or the memory range defined by +.Fa data +and +.Fa nbytes +point outside the process's allocated address space. +.It Bq Er ENAMETOOLONG +The attribute name was longer than +.Dv EXTATTR_MAXNAMELEN . +.El +.Pp +The +.Fn extattr_get_fd , +.Fn extattr_set_fd , +and +.Fn extattr_delete_fd +system calls may also fail if: +.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 +.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 +.Xr extattr 3 , +.Xr getextattr 1 , +.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 +and +.Nx 3.0 . +It was developed to support security extensions requiring additional labels +to be associated with each file or directory. |
