xref: /freebsd/lib/libc/posix1e/extattr.3 (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1.\"
2.\" Copyright (c) 2001 Dima Dorfman <dd@FreeBSD.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.Dd June 24, 2001
27.Dt EXTATTR 3
28.Os
29.Sh NAME
30.Nm extattr_namespace_to_string ,
31.Nm extattr_string_to_namespace
32.Nd convert an extended attribute namespace identifier to a string and
33vice versa
34.Sh LIBRARY
35.Lb libutil
36.Sh SYNOPSIS
37.In sys/extattr.h
38.In libutil.h
39.Ft int
40.Fn extattr_namespace_to_string "int attrnamespace" "char **string"
41.Ft int
42.Fn extattr_string_to_namespace "const char *string" "int *attrnamespace"
43.Sh DESCRIPTION
44The
45.Fn extattr_namespace_to_string
46function converts a VFS extended attribute identifier to a human-readable
47string;
48the
49.Fn extattr_string_to_namespace
50function undoes the aforementioned operation,
51and converts a human-readable string representing a namespace to a
52namespace identifier.
53Although a file system may implement arbitrary namespaces,
54these functions only support the
55.Dv EXTATTR_NAMESPACE_USER
56.Pq Dq user
57and
58.Dv EXTATTR_NAMESPACE_SYSTEM
59.Pq Dq system
60namespaces,
61which are defined in
62.Xr extattr 9 .
63.Pp
64These functions are meant to be used in error reporting and other
65interactive tasks.
66For example,
67instead of printing the integer identifying an extended attribute in
68an error message,
69a program might use
70.Fn extattr_namespace_to_string
71to obtain a human-readable representation.
72Likewise,
73instead of requiring a user to enter the integer representing a namespace,
74an interactive program might ask for a name and use
75.Fn extattr_string_to_namespace
76to get the desired identifier.
77.Sh RETURN VALUES
78If any of the calls are unsuccessful, the value \-1 is returned
79and the global variable
80.Va errno
81is set to indicate the error.
82.Sh ERRORS
83.Bl -tag -width Er
84.It Bq Er EINVAL
85The requested namespace could not be identified.
86.El
87.Sh SEE ALSO
88.Xr extattr 2 ,
89.Xr getextattr 8 ,
90.Xr setextattr 8 ,
91.Xr extattr 9
92.Sh HISTORY
93Extended attribute support was developed as part of the
94.Tn TrustedBSD
95Project, and introduced in
96.Fx 5.0 .
97It was developed to support security extensions requiring additional labels
98to be associated with each file or directory.
99