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 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <tsol/label.h>
32 #include <bsm/devices.h>
37 * Gets the minimum and maximum labels within which the device can
38 * be used. If label range is not specified for the device in
39 * device_allocate, defaults to admin_low and admin_high.
40 * Returns malloc'ed blrange pointer, or NULL on any error.
43 getdevicerange(const char *dev
)
52 if ((range
= malloc(sizeof (blrange_t
))) == NULL
)
54 if ((range
->lower_bound
= blabel_alloc()) == NULL
) {
58 if ((range
->upper_bound
= blabel_alloc()) == NULL
) {
59 blabel_free(range
->lower_bound
);
65 * If an entry is found for the named device,
66 * return its label range.
69 if ((da
= getdanam((char *)dev
)) == NULL
) {
71 /* check for an actual device file */
72 if ((dm
= getdmapdev((char *)dev
)) != NULL
) {
73 da
= getdanam(dm
->dmap_devname
);
80 bsllow(range
->lower_bound
);
81 bslhigh(range
->upper_bound
);
83 lstr
= kva_match(da
->da_devopts
, DAOPT_MINLABEL
);
85 bsllow(range
->lower_bound
);
86 } else if (stobsl(lstr
, range
->lower_bound
, NO_CORRECTION
,
88 blabel_free(range
->lower_bound
);
89 blabel_free(range
->upper_bound
);
94 lstr
= kva_match(da
->da_devopts
, DAOPT_MAXLABEL
);
96 bslhigh(range
->upper_bound
);
97 } else if (stobsl(lstr
, range
->upper_bound
, NO_CORRECTION
,
99 blabel_free(range
->lower_bound
);
100 blabel_free(range
->upper_bound
);