/*
* CDDL HEADER START
*
* 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.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Just in case we're not in a build environment, make sure that
* TEXT_DOMAIN gets set to something.
*/
#if !defined(TEXT_DOMAIN)
#endif
/*
*/
#include <meta.h>
/*
* magic strings in system
*/
/*
* copy system file, yank root and database lines
*/
int
char *sname, /* system file name */
int doroot, /* remove mdd root stuff */
int domddb, /* remove mdd database stuff */
int doit, /* really copy file */
int verbose, /* show what we're doing */
char **tname, /* returned temp file name */
)
{
int delroot = 0;
int delmddb = 0;
/* check names */
/* get temp name */
/* copy system file, yank stuff */
goto out;
}
}
if (doit) {
/*
* If we are on the miniroot we need to create
* in the miniroot result is EROFS error.
*/
goto out;
}
goto out;
}
goto out;
}
}
!= 0) ||
!= 0)) {
goto out;
}
}
}
if (verbose) {
"Delete the following lines from %s:\n\n"), sname);
}
delroot = 1;
if (verbose)
continue;
}
if (delroot) {
delroot = 0;
if (verbose)
continue;
}
delmddb = 1;
if (verbose)
continue;
}
if (delmddb) {
delmddb = 0;
if (verbose)
continue;
}
if (doit) {
goto out;
}
}
}
goto out;
}
}
if (verbose)
(void) printf("\n");
/* make sure we didn't stop mid-delete */
goto out;
}
/* flush stuff */
if (doit) {
goto out;
}
}
/* return success */
return (0);
/* cleanup, return error */
out:
}
return (-1);
}
/*
* append root on MD lines to system
*/
int
char *sname, /* system file name */
char *tname, /* temp file name */
int ismeta, /* is a metadevice */
int doit, /* really patch file */
int verbose, /* show what we're doing */
)
{
char *longblkname;
/* check names */
/* get root /devices name */
return (-1);
/* add header */
if (verbose) {
"Add the following lines to %s:\n\n"), sname);
}
if (doit) {
}
}
/* add rootdev */
if (ismeta) {
if (verbose)
if (doit) {
}
}
}
/* add trailer */
if (verbose) {
}
if (doit) {
}
}
/* flush stuff */
if (doit) {
}
}
/* return success */
return (0);
}
/*
* parse mddb.cf line
*
* Caller of this routine needs to free the device id string that
* is passed back during a successful return.
*/
static int
char *line, /* line in file */
char **driver, /* returned driver name */
char **devid_char_pp /* returned device id string */
)
{
char *p = line;
int chksum = 0;
int i;
if (*p == '#') {
return (-1);
}
*driver = p;
while ((*p != ' ') && (*p != '\t'))
chksum += *p++;
if (*driver == p) {
return (-1);
}
*p++ = '\0';
/* parse out devid */
while ((*p == ' ') || (*p == '\t')) {
p++;
}
i = strcspn(p, " \t");
(void) strncpy(*devid_char_pp, p, i);
(*devid_char_pp)[i] = '\0';
devid_size = i;
p += devid_size;
for (i = 0; i < devid_size; i++) {
chksum += (*devid_char_pp)[i];
}
if (chksum != 42) {
Free (*devid_char_pp);
return (-1);
}
return (0);
}
/*
* append MDDB lines to system
*/
int
char *sname, /* system file name */
char *tname, /* temp file name */
int doit, /* really patch file */
int verbose, /* show what we're doing */
/* empty before updating md.conf */
)
{
char *p;
int i;
char *driver;
/* check names */
/* open database conf file */
goto out;
}
/* Check that it is an ordinary file */
goto out;
}
goto out;
}
/* add header */
if (verbose) {
"Add the following lines to %s:\n\n"), sname);
}
if (doit) {
goto out;
}
}
/* append database lines */
;
/*
* It is possible to be in a state where the md_devid_destroy flag
* has been set and the mdmonitor service not be enabled on reboot
* such that metadevadm doesn't get run and the entries in mddb.cf
* recreated. The following checks for this condition and will not
* configuration
*/
goto out;
}
"mddb_bootlist%d=\"%s:%lu:%ld:%s",
if (devid_char_p != NULL) {
devid_char_p = NULL;
}
&devid_char_p) != 0) {
continue;
}
break;
if (devid_char_p != NULL) {
devid_char_p = NULL;
}
}
if (verbose)
/* CSTYLED */
if (doit) {
/* CSTYLED */
goto out;
}
}
}
if (devid_char_p != NULL) {
devid_char_p = NULL;
}
/* add trailer */
if (verbose)
if (doit) {
goto out;
}
}
/* close database conf file */
goto out;
}
/* flush stuff */
if (doit) {
goto out;
}
}
/* return success */
return (0);
/* cleanup, return error */
out:
return (-1);
}