Merge branch 'less_closed'
[unleashed.git] / usr / src / man / man2 / getlabel.2
blobd0412a2e0bfe4916240aaafaf81ec22ce2d25d05
1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH GETLABEL 2 "Jul 20, 2007"
7 .SH NAME
8 getlabel, fgetlabel \- get file sensitivity label
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBcc\fR [\fIflags\fR...] \fIfile\fR... \fB-ltsol\fR [\fIlibrary\fR...]
13 .fi
15 .LP
16 .nf
17 #include <tsol/label.h>
19 \fBint\fR \fBgetlabel\fR(\fBconst char *\fR\fIpath\fR, \fBm_label_t *\fR\fIlabel_p\fR);
20 .fi
22 .LP
23 .nf
24 \fBint\fR \fBfgetlabel\fR(\fBint\fR \fIfd\fR, \fBm_label_t *\fR\fIlabel_p\fR);
25 .fi
27 .SH DESCRIPTION
28 .sp
29 .LP
30 The \fBgetlabel()\fR function obtains the sensitivity label of the file that is
31 named by \fIpath\fR. Discretionary read, write or execute permission to the
32 final component of \fIpath\fR is not required, but all directories in the path
33 prefix of \fIpath\fR must be searchable.
34 .sp
35 .LP
36 The \fBfgetlabel()\fR function obtains the label of an open file that is
37 referred to by the argument descriptor, such as would be obtained by an
38 \fBopen\fR(2) call.
39 .sp
40 .LP
41 The \fIlabel_p\fR argument is a pointer to an opaque label structure. The
42 caller must allocate space for \fIlabel_p\fR by using
43 \fBm_label_alloc\fR(3TSOL).
44 .SH RETURN VALUES
45 .sp
46 .LP
47 Upon successful completion, \fBgetlabel()\fR and \fBfgetlabel()\fR return 0.
48 Otherwise they return \(mi1 and set \fBerrno\fR to indicate the error.
49 .SH ERRORS
50 .sp
51 .LP
52 The \fBgetlabel()\fR function will fail if:
53 .sp
54 .ne 2
55 .na
56 \fB\fBEACCES\fR\fR
57 .ad
58 .RS 16n
59 Search permission is denied for a component of the path prefix of \fIpath\fR.
60 To override this restriction, the calling process can assert the
61 \fBPRIV_FILE_DAC_SEARCH\fR privilege.
62 .RE
64 .sp
65 .ne 2
66 .na
67 \fB\fBEFAULT\fR\fR
68 .ad
69 .RS 16n
70 \fIlabel_p\fR or \fIpath\fR points to an invalid address.
71 .RE
73 .sp
74 .ne 2
75 .na
76 \fB\fBEIO\fR\fR
77 .ad
78 .RS 16n
79 An \fBI/O\fR error occurred while reading from or writing to the file system.
80 .RE
82 .sp
83 .ne 2
84 .na
85 \fB\fBELOOP\fR\fR
86 .ad
87 .RS 16n
88 Too many symbolic links were encountered in translating \fIpath\fR.
89 .RE
91 .sp
92 .ne 2
93 .na
94 \fB\fBENAMETOOLONG\fR\fR
95 .ad
96 .RS 16n
97 The length of the path argument exceeds \fIPATH_MAX\fR, or a pathname component
98 is longer than \fINAME_MAX\fR while \fI_POSIX_NO_TRUNC\fR is in effect (see
99 \fBpathconf\fR(2)).
103 .ne 2
105 \fB\fBENOENT\fR\fR
107 .RS 16n
108 The file referred to by \fIpath\fR does not exist.
112 .ne 2
114 \fB\fBENOTDIR\fR\fR
116 .RS 16n
117 A component of the path prefix of \fIpath\fR is not a directory.
122 The \fBfgetlabel()\fR function will fail if:
124 .ne 2
126 \fB\fBEBADF\fR\fR
128 .RS 10n
129 The \fIfd\fR argument is not a valid open file descriptor.
133 .ne 2
135 \fB\fBEFAULT\fR\fR
137 .RS 10n
138 The \fIlabel_p\fR argument points to an invalid address.
142 .ne 2
144 \fB\fBEIO\fR\fR
146 .RS 10n
147 An \fBI/O\fR error occurred while reading from or writing to the file system.
150 .SH ATTRIBUTES
153 See \fBattributes\fR(5) for descriptions of the following attributes:
158 box;
159 c | c
160 l | l .
161 ATTRIBUTE TYPE  ATTRIBUTE VALUE
163 Interface Stability     Committed
166 .SH SEE ALSO
169 \fBopen\fR(2), \fBpathconf\fR(2), \fBm_label_alloc\fR(3TSOL),
170 \fBattributes\fR(5), \fBlabels\fR(5)
173 \fIObtaining a File Label\fR in \fISolaris Trusted Extensions Developer\&'s
174 Guide\fR
175 .SH NOTES
178 The functionality described on this manual page is available only if the system
179 is configured with Trusted Extensions.