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]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <sys/types.h>
37 * Macros to produce a quoted string containing the value of a
38 * preprocessor macro. For example, if SIZE is defined to be 256,
39 * VAL2STR(SIZE) is "256". This is used to construct format
40 * strings for scanf-family functions below.
43 #define VAL2STR(x) QUOTE(x)
45 static int is_blank(char *);
48 * is_blank() returns 1 (true) if a line specified is composed of
49 * whitespace characters only. otherwise, it returns 0 (false).
51 * Note. the argument (line) must be null-terminated.
56 for (/* nothing */; *line
!= '\0'; line
++)
64 * Return the driver name for a major number
66 * INPUT: major number, mount point for name_to_major file, pointer
70 * 0 - SUCCESS - buf contain the driver name.
76 get_drv_name(major_t major
, char *mnt
, char *buf
)
79 char drv
[FILENAME_MAX
+ 1];
80 char entry
[FILENAME_MAX
+ 1];
81 char line
[MAX_N2M_ALIAS_LINE
], *cp
;
84 int status
= RET_NOERROR
;
85 (void) snprintf(fname
, sizeof (fname
), "%s%s", mnt
, NAME_TO_MAJOR
);
87 if ((fp
= fopen(fname
, "r")) == NULL
) {
91 while ((fgets(line
, sizeof (line
), fp
) != NULL
) &&
92 status
== RET_NOERROR
) {
93 /* cut off comments starting with '#' */
94 if ((cp
= strchr(line
, '#')) != NULL
)
96 /* ignore comment or blank lines */
101 "%" VAL2STR(FILENAME_MAX
) "s %" VAL2STR(FILENAME_MAX
) "s",
105 if (atoi(entry
) == major
)
109 if (status
== RET_NOERROR
)
110 (void) strcpy(buf
, drv
);