1f2749378SSascha Wildner.\" 2f2749378SSascha Wildner.\" Copyright (c) 2001 Dima Dorfman <dima@unixfreak.org> 3f2749378SSascha Wildner.\" Copyright (c) 2003 Robert Watson <rwatson@FreeBSD.org> 4f2749378SSascha Wildner.\" All rights reserved. 5f2749378SSascha Wildner.\" 6f2749378SSascha Wildner.\" Redistribution and use in source and binary forms, with or without 7f2749378SSascha Wildner.\" modification, are permitted provided that the following conditions 8f2749378SSascha Wildner.\" are met: 9f2749378SSascha Wildner.\" 1. Redistributions of source code must retain the above copyright 10f2749378SSascha Wildner.\" notice, this list of conditions and the following disclaimer. 11f2749378SSascha Wildner.\" 2. Redistributions in binary form must reproduce the above copyright 12f2749378SSascha Wildner.\" notice, this list of conditions and the following disclaimer in the 13f2749378SSascha Wildner.\" documentation and/or other materials provided with the distribution. 14f2749378SSascha Wildner.\" 15f2749378SSascha Wildner.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16f2749378SSascha Wildner.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17f2749378SSascha Wildner.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18f2749378SSascha Wildner.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19f2749378SSascha Wildner.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20f2749378SSascha Wildner.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21f2749378SSascha Wildner.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22f2749378SSascha Wildner.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23f2749378SSascha Wildner.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24f2749378SSascha Wildner.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25f2749378SSascha Wildner.\" SUCH DAMAGE. 26f2749378SSascha Wildner.\" 27f2749378SSascha Wildner.\" $FreeBSD: src/lib/libc/sys/extattr_get_file.2,v 1.19 2008/01/29 18:15:38 trhodes Exp $ 28f2749378SSascha Wildner.\" 29f2749378SSascha Wildner.Dd May 8, 2010 30f2749378SSascha Wildner.Dt EXTATTR 2 31f2749378SSascha Wildner.Os 32f2749378SSascha Wildner.Sh NAME 33f2749378SSascha Wildner.Nm extattr_get_file , 34f2749378SSascha Wildner.Nm extattr_set_file , 35f2749378SSascha Wildner.Nm extattr_delete_file 36f2749378SSascha Wildner.Nd system calls to manipulate VFS extended attributes 37f2749378SSascha Wildner.Sh LIBRARY 38f2749378SSascha Wildner.Lb libc 39f2749378SSascha Wildner.Sh SYNOPSIS 40f2749378SSascha Wildner.In sys/types.h 41f2749378SSascha Wildner.In sys/extattr.h 42f2749378SSascha Wildner.Ft ssize_t 43f2749378SSascha Wildner.Fn extattr_get_file "const char *path" "int attrnamespace" "const char *attrname" "void *data" "size_t nbytes" 44f2749378SSascha Wildner.Ft int 45f2749378SSascha Wildner.Fn extattr_set_file "const char *path" "int attrnamespace" "const char *attrname" "const void *data" "size_t nbytes" 46f2749378SSascha Wildner.Ft int 47f2749378SSascha Wildner.Fn extattr_delete_file "const char *path" "int attrnamespace" "const char *attrname" 48f2749378SSascha Wildner.Sh DESCRIPTION 49f2749378SSascha WildnerNamed extended attributes are meta-data associated with vnodes 50f2749378SSascha Wildnerrepresenting files and directories. 51f2749378SSascha WildnerThey exist as 52f2749378SSascha Wildner.Qq Li name=value 53f2749378SSascha Wildnerpairs within a set of namespaces. 54f2749378SSascha Wildner.Pp 55f2749378SSascha WildnerThe 56f2749378SSascha Wildner.Fn extattr_get_file 57f2749378SSascha Wildnersystem call retrieves the value of the specified extended attribute into 58f2749378SSascha Wildnera buffer pointed to by 59f2749378SSascha Wildner.Fa data 60f2749378SSascha Wildnerof size 61f2749378SSascha Wildner.Fa nbytes . 62f2749378SSascha WildnerThe 63f2749378SSascha Wildner.Fn extattr_set_file 64f2749378SSascha Wildnersystem call sets the value of the specified extended attribute to the data 65f2749378SSascha Wildnerdescribed by 66f2749378SSascha Wildner.Fa data . 67f2749378SSascha WildnerThe 68f2749378SSascha Wildner.Fn extattr_delete_file 69f2749378SSascha Wildnersystem call deletes the extended attribute specified. 70f2749378SSascha WildnerThe 71f2749378SSascha Wildner.Fn extattr_get_file 72f2749378SSascha Wildnercall consumes the 73f2749378SSascha Wildner.Fa data 74f2749378SSascha Wildnerand 75f2749378SSascha Wildner.Fa nbytes 76f2749378SSascha Wildnerarguments in the style of 77f2749378SSascha Wildner.Xr read 2 ; 78f2749378SSascha Wildner.Fn extattr_set_file 79f2749378SSascha Wildnerconsumes these arguments in the style of 80f2749378SSascha Wildner.Xr write 2 . 81f2749378SSascha Wildner.Pp 82f2749378SSascha WildnerIf 83f2749378SSascha Wildner.Fa data 84f2749378SSascha Wildneris 85f2749378SSascha Wildner.Dv NULL 86f2749378SSascha Wildnerin a call to 87f2749378SSascha Wildner.Fn extattr_get_file 88f2749378SSascha Wildnerthen the size of defined extended attribute data will be returned, rather 89f2749378SSascha Wildnerthan the quantity read, permitting applications to test the size of the 90f2749378SSascha Wildnerdata without performing a read. 91f2749378SSascha Wildner.Pp 92f2749378SSascha WildnerThe following arguments are common to all the system calls described here: 93f2749378SSascha Wildner.Bl -tag -width attrnamespace 94f2749378SSascha Wildner.It Fa attrnamespace 95f2749378SSascha Wildnerthe namespace in which the extended attribute resides; see 96f2749378SSascha Wildner.Xr extattr 9 97f2749378SSascha Wildner.It Fa attrname 98f2749378SSascha Wildnerthe name of the extended attribute 99f2749378SSascha Wildner.El 100f2749378SSascha Wildner.Pp 101f2749378SSascha WildnerNamed extended attribute semantics vary by file system implementing the call. 102f2749378SSascha WildnerNot all operations may be supported for a particular attribute. 103f2749378SSascha WildnerAdditionally, the format of the data in 104f2749378SSascha Wildner.Fa data 105f2749378SSascha Wildneris attribute-specific. 106f2749378SSascha Wildner.Pp 107f2749378SSascha WildnerFor more information on named extended attributes, please see 108f2749378SSascha Wildner.Xr extattr 9 . 109*4a5f69f6SSascha Wildner.Sh CAVEATS 110f2749378SSascha WildnerThis interface is under active development, and as such is subject to 111f2749378SSascha Wildnerchange as applications are adapted to use it. 112f2749378SSascha WildnerDevelopers are discouraged from relying on its stability. 113f2749378SSascha Wildner.Sh RETURN VALUES 114f2749378SSascha WildnerIf successful, the 115f2749378SSascha Wildner.Fn extattr_get_file 116f2749378SSascha Wildnerand 117f2749378SSascha Wildner.Fn extattr_set_file 118f2749378SSascha Wildnercalls return the number of bytes 119f2749378SSascha Wildnerthat were read or written from the 120f2749378SSascha Wildner.Fa data , 121f2749378SSascha Wildnerrespectively, or if 122f2749378SSascha Wildner.Fa data 123f2749378SSascha Wildnerwas 124f2749378SSascha Wildner.Dv NULL , 125f2749378SSascha Wildnerthen 126f2749378SSascha Wildner.Fn extattr_get_file 127f2749378SSascha Wildnerreturns the number of bytes available to read. 128f2749378SSascha WildnerIf any of the calls are unsuccessful, the value \-1 is returned 129f2749378SSascha Wildnerand the global variable 130f2749378SSascha Wildner.Va errno 131f2749378SSascha Wildneris set to indicate the error. 132f2749378SSascha Wildner.Pp 133f2749378SSascha Wildner.Rv -std extattr_delete_file 134f2749378SSascha Wildner.Sh ERRORS 135f2749378SSascha WildnerThe following errors may be returned by the system calls themselves. 136f2749378SSascha WildnerAdditionally, the file system implementing the call may return any 137f2749378SSascha Wildnerother errors it desires. 138f2749378SSascha Wildner.Bl -tag -width Er 139f2749378SSascha Wildner.It Bq Er EFAULT 140f2749378SSascha WildnerThe 141f2749378SSascha Wildner.Fa attrnamespace 142f2749378SSascha Wildnerand 143f2749378SSascha Wildner.Fa attrname 144f2749378SSascha Wildnerarguments, 145f2749378SSascha Wildneror the memory range defined by 146f2749378SSascha Wildner.Fa data 147f2749378SSascha Wildnerand 148f2749378SSascha Wildner.Fa nbytes 149f2749378SSascha Wildnerpoint outside the process's allocated address space. 150f2749378SSascha Wildner.It Bq Er ENAMETOOLONG 151f2749378SSascha WildnerThe attribute name was longer than 152f2749378SSascha Wildner.Dv EXTATTR_MAXNAMELEN . 153f2749378SSascha Wildner.El 154f2749378SSascha Wildner.Pp 155f2749378SSascha WildnerAdditionally, the 156f2749378SSascha Wildner.Fn extattr_get_file , 157f2749378SSascha Wildner.Fn extattr_set_file , 158f2749378SSascha Wildnerand 159f2749378SSascha Wildner.Fn extattr_delete_file 160f2749378SSascha Wildnercalls may also fail due to the following errors: 161f2749378SSascha Wildner.Bl -tag -width Er 162f2749378SSascha Wildner.It Bq Er ENOATTR 163f2749378SSascha WildnerThe requested attribute was not defined for this file. 164f2749378SSascha Wildner.It Bq Er ENOTDIR 165f2749378SSascha WildnerA component of the path prefix is not a directory. 166f2749378SSascha Wildner.It Bq Er ENAMETOOLONG 167f2749378SSascha WildnerA component of a pathname exceeded 255 characters, 168f2749378SSascha Wildneror an entire path name exceeded 1023 characters. 169f2749378SSascha Wildner.It Bq Er ENOENT 170f2749378SSascha WildnerA component of the path name that must exist does not exist. 171f2749378SSascha Wildner.It Bq Er EACCES 172f2749378SSascha WildnerSearch permission is denied for a component of the path prefix. 173f2749378SSascha Wildner.\" XXX are any missing? 174f2749378SSascha Wildner.El 175f2749378SSascha Wildner.Sh SEE ALSO 176f2749378SSascha Wildner.\".Xr extattr 3 , 177f2749378SSascha Wildner.\".Xr getextattr 8 , 178f2749378SSascha Wildner.\".Xr setextattr 8 , 179f2749378SSascha Wildner.Xr extattr 9 , 180f2749378SSascha Wildner.Xr VOP_GETEXTATTR 9 , 181f2749378SSascha Wildner.Xr VOP_SETEXTATTR 9 182f2749378SSascha Wildner.Sh HISTORY 183f2749378SSascha WildnerExtended attribute support was developed as part of the 184f2749378SSascha Wildner.Tn TrustedBSD 185f2749378SSascha WildnerProject, and introduced in 186f2749378SSascha Wildner.Fx 5.0 . 187f2749378SSascha WildnerIt was developed to support security extensions requiring additional labels 188f2749378SSascha Wildnerto be associated with each file or directory. 189f2749378SSascha Wildner.Sh BUGS 190f2749378SSascha WildnerIn earlier versions of this API, passing an empty string for the 191f2749378SSascha Wildnerattribute name to 192f2749378SSascha Wildner.Fn extattr_get_file 193f2749378SSascha Wildnerwould return the list of attributes defined for the target object. 194f2749378SSascha WildnerThis interface has been deprecated in preference to using the explicit 195f2749378SSascha Wildnerlist API, and should not be used. 196