aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys/extattr_get_file.2
blob: 45b767d2c09303f45997ae9ddb647cc4cbcfd0a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
.\"
.\" Copyright (c) 2001 Dima Dorfman <dima@unixfreak.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$
.\"
.Dd March 28, 2001
.Dt EXTATTR 2
.Os
.Sh NAME
.Nm extattr_get_fd ,
.Nm extattr_set_fd ,
.Nm extattr_delete_fd ,
.Nm extattr_get_file ,
.Nm extattr_set_file ,
.Nm extattr_delete_file
.Nd system calls to manipulate VFS extended attributes
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/extattr.h
.In sys/uio.h
.Ft int
.Fn extattr_get_fd "int fd" "int attrnamespace" "const char *attrname" "struct iovec *iovp" "unsigned iovcnt"
.Ft int
.Fn extattr_set_fd "int fd" "int attrnamespace" "const char *attrname" "struct iovec *iovp" "unsigned iovcnt"
.Ft int
.Fn extattr_delete_fd "int fd" "int attrnamespace" "const char *attrname"
.Ft int
.Fn extattr_get_file "const char *path" "int attrnamespace" "const char *attrname" "struct iovec *iovp" "unsigned iovcnt"
.Ft int
.Fn extattr_set_file "const char *path" "int attrnamespace" "const char *attrname" "struct iovec *iovp" "unsigned iovcnt"
.Ft int
.Fn extattr_delete_file "const char *path" "int attrnamespace" "const char *attrname"
.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.
The
.Fn extattr_get_file
call retrieves the value of the specified extended attribute into
.Fa iovp .
The
.Fn extattr_set_file
call sets the value of the specified extended attribute to the data
described by
.Fa iovp .
The
.Fn extattr_delete_file
call deletes the extended attribute specified.
The
.Fn extattr_get_file
and
.Fn extattr_set_file
calls consume the
.Fa iovp
and
.Fa iovcnt
arguments in the style of
.Xr readv 2
and
.Xr writev 2 ,
respectively.
.Pp
The
.Fn extatttr_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 filesystem implementing the call.
Not all operations may be supported for a particular attribute.
Additionally, the format of the data in
.Fa iovp
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 iovp ,
respectively.
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 filesystem implementing the call may return any
other errors it desires.
.Bl -tag -width Er
.It Bq Er EFAULT
.Fa attrnamespace ,
.Fa attrname ,
or
.Fa iovp
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
functions 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 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.