/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <malloc.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <meta.h>
#include <svm.h>
#include <libsvm.h>
/*
* FUNCTION: svm_start
* components of the root mirror are returned in svmpp.
*
* INPUT: mntpnt - root mount point
* svmpp - prealloced structure to return components
* repl_state_flag - SVM_CONV/SVM_DONT_CONV
*
* RETURN:
* 0 - SUCCESS
* !0 - ERROR
* if > 0 errno
*/
int
{
int rval = 0;
else
rootdir, SYSTEM_FILE)) < 0) {
return (RET_ERROR);
}
return (RET_ERROR);
}
debug_printf("svm_start(): repl_state_flag %s\n",
"SVM_CONV");
return (RET_ERROR);
case 0:
break;
default: /* convert bootlist failed */
debug_printf("svm_start(): convert_bootlist failed."
"rval %d\n", rval);
goto errout;
}
if (repl_state_flag == SVM_DONT_CONV) {
if (rval != 0)
goto errout;
}
if (is_upgrade_prop(PROP_DEVID_DESTROY)) {
/*
* For the idempotent behavior reset internal
* flag incase we have to return due to errors
*/
if (rval != 0)
goto errout;
}
/*
* Since svm_start is called only after svm_check,
* we can assume that there is a valid metadb. If the mddb_bootlist
* we copied to temporary file pointed to by tf
*/
MD_CONF);
goto errout;
}
debug_printf("svm_start(): write_xlate_to_mdconf(%s) failed\n",
rootdir);
goto errout;
}
goto errout;
}
/* run devfsadm to create the devices specified in md.conf */
"/tmp/root/etc/path_to_inst -i md")) != 0) {
goto errout;
}
/*
* We have to unload md after the devfsadm run so that when metainit
* loads things it gets the right information from md.conf.
*/
debug_printf("svm_start(): svm_stop failed.\n");
return (RET_ERROR);
}
goto errout;
}
goto errout;
}
/*
* We ignore failures from metadevadm, since it can fail if
* miniroot dev_t's don't match target dev_ts. But it still
* will update md.conf with device Id information which is
* why we are calling it here.
*/
(void) system("/usr/sbin/metadevadm -r");
/*
* check to see if we have a root metadevice and if so
* get its components.
*/
debug_printf("svm_start(): get_mdcomponents(%s,..)"
goto errout;
}
} else {
rval = 0; /* not a mirrored root */
debug_printf("svm_start(): get_rootmetadevice(%s,..) "
"No root mirrors! ", rootdir);
}
if (rval != 0) {
} else {
int i;
debug_printf("svmpp: ");
debug_printf(" md_comps[%d]: %s", i,
}
debug_printf(" \n");
} else {
debug_printf("svm_start(): no mirrored root\n");
}
debug_printf("svm_start(): svm_start succeeded.\n");
}
return (rval);
}
/*
* FUNCTION: copyfile
*
* INPUT: self descriptive
*
* RETURN:
* RET_SUCCESS
* RET_ERROR
*/
int
{
return (RET_ERROR);
return (RET_ERROR);
}
return (RET_ERROR);
}
/*
* in case the file exists then perm is forced by this chmod
*/
for (;;) {
/*
* no need to check for negative values since the file
* has been successfully stat'ed
*/
if (rbytes == 0)
break;
rbytes = -1;
break;
}
}
if (rbytes < 0) {
return (RET_ERROR);
}
return (RET_SUCCESS);
}