4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * getlabel - gets file label.
39 #include <tsol/label.h>
46 get_label(char *filename
, uint_t opt_flag
)
51 if ((fl
= m_label_alloc(MAC_LABEL
)) == NULL
) {
52 perror("m_label_alloc");
54 } else if (getlabel(filename
, fl
) != 0) {
60 (void) printf("%s:\t", filename
);
63 if (label_to_str(fl
, &label
, M_LABEL
, LONG_NAMES
) != 0) {
64 perror(gettext("%s:unable to translate "
65 "Sensitivity label"));
71 if (label_to_str(fl
, &label
, M_LABEL
, SHORT_NAMES
) != 0) {
72 perror(gettext("unable to translate "
73 "Sensitivity label"));
79 if (label_to_str(fl
, &label
, M_LABEL
, DEF_NAMES
) != 0) {
80 perror(gettext("unable to translate "
81 "Sensitivity label"));
87 (void) printf("%s\n", label
);
97 (void) fprintf(stderr
, gettext("Usage: \n"));
98 (void) fprintf(stderr
, gettext("\t%s [-S | -s] filename ...\n"),
105 main(int argc
, char **argv
)
112 (void) setlocale(LC_ALL
, "");
113 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
114 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
116 (void) textdomain(TEXT_DOMAIN
);
118 if ((prog
= strrchr(argv
[0], '/')) == NULL
)
127 while ((opt
= getopt(argc
, argv
, ":sS")) != EOF
) {
143 if ((argc
-= optind
) < 1) {
148 if (get_label(*argv
++, opt_flag
) != 0)