4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include <sys/types.h>
35 #include <sys/mkdev.h>
41 * FUNCTION: valid_bootlist
43 * INPUT: file pointer, line buffer, line_length
52 valid_bootlist(FILE *fp
, int line_len
)
58 * errno may not be cleared by callee routines and we
59 * we want to catch fgets failures hence errno is reset.
62 if ((line
= malloc(line_len
)) == NULL
)
65 while (fgets(line
, line_len
, fp
) != NULL
) {
66 bp
= strstr(line
, "mddb_bootlist");
68 /* if not commented out then breakout */
69 if (*line
!= '*' && *line
!= '#') {
76 if (bp
== NULL
|| errno
!= 0)
84 * Check the existance of DiskSuite or SVM
97 char tmppath
[PATH_MAX
];
100 (void) strcat(strcpy(tmppath
, path
), MD_CONF
);
102 if ((fp
= fopen(tmppath
, "r")) == NULL
) {
107 rval
= valid_bootlist(fp
, MDDB_BOOTLIST_MAX_LEN
);
109 debug_printf("svm_check(): valid bootlist in %s. status %d\n",
112 if (rval
== RET_SUCCESS
) {
117 /* not found in md.conf try etc/system */
118 (void) strcat(strcpy(tmppath
, path
), SYSTEM_FILE
);
120 if ((fp
= fopen(tmppath
, "r")) == NULL
) {
125 rval
= valid_bootlist(fp
, MDDB_BOOTLIST_MAX_LEN
);
127 debug_printf("svm_check(): valid bootlist in %s. status %d\n",
137 * FUNCTION: svm_is_md
138 * Check if the the given device name has an md driver.
139 * INPUT: special device name (/dev/dsk/c0t0d0s0 or /dev/md/dsk/d10)
142 * 1 - if it is a metadevice.
143 * 0 - if it is not a metadevice.
147 svm_is_md(char *device_name
)
153 (void) memset(buf
, 0, 30);
155 debug_printf("svm_is_md(): device %s\n", device_name
);
156 if (stat(device_name
, &sbuf
) != 0)
159 if (get_drv_name(major(sbuf
.st_rdev
), "/", buf
) == RET_ERROR
) {
160 debug_printf("svm_is_md(): device get_drv_name failed: %s\n",
164 if (strcmp(buf
, MD_MODULE
) == 0) {
165 debug_printf("svm_is_md(): device %s succeed\n", device_name
);