/*
* 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"
#include <stdio.h>
#include <string.h>
#include <meta.h>
#include <libsvm.h>
#include <svm.h>
#include <sdssc.h>
extern int mod_unload(char *modname);
static int inited = 0;
/*
* FUNCTION: init_metalib
* initialize libmeta only once.
*
* RETURN VALUES:
* 0 - SUCCESS
* -1 - FAIL
*/
static int
{
if (!inited) {
meta_check_root(&status) != 0) {
return (-1);
}
inited = 1;
}
return (RET_SUCCESS);
}
/*
* FUNCTION: reset_metalib
*
* INPUT: ptr to md_error_t
*/
static void
{
inited = 0;
(void) close_admin(ep);
}
/*
* FUNCTION: metahalt
* halt the metadb
*
*/
static void
metahalt()
{
(void) init_metalib();
return;
}
return;
}
debug_printf("metahalt(): errno %d\n",
}
}
/*
* FUNCTION: svm_stop
*
* RETURN VALUES:
* 0 - SUCCESS
* RET_ERROR
*/
int
svm_stop()
{
int timeval = 0;
metahalt();
while (timeval < MAX_TIMEOUT) {
debug_printf("svm_stop(): mod_unload succeeded."
" Time %d\n", timeval);
break;
}
debug_printf("svm_stop(): mod_unload failed. Trying "
metahalt();
}
if (rval != 0) {
debug_printf("svm_stop(): mod_unload FAILED!\n");
}
}
return (rval);
}
/*
* FUNCTION: get_rootmetadevice
* parses the vfstab to return the metadevice
*
* INPUT:
* mount point
* mdname - pointer to string pointer that will contain the
* metadevice name. Caller must free the allocated space.
* RETURN VALUES:
* mdname - md root device name
* 0 - SUCCESS
* !0 - FAIL
* > 0 errno
* RET_ERROR
*/
int
{
struct vfstab v;
char *cp;
return (EINVAL);
return (ENOMEM);
return (rval);
}
goto out;
}
/* md device not found */
goto out;
}
/* found a match fill it and return */
goto out;
}
debug_printf("get_rootmetadevice(): *mdname %s rval %d\n",
out:
return (rval);
}
/*
* FUNCTION: create_diskset_links
* names found in the set records. These are normally created
* in rpc.metad when you create the set but those symlinks are
* sitting out on the real system disk and we're running off the
* devfs that got created when we booted off the install image.
*/
void
{
int max_sets;
int i;
/*
* Resolve the function pointers for libsds_sc so that we can
* snarf the set records.
*/
(void) sdssc_bind_library();
(void) init_metalib();
debug_printf("create_diskset_links(): get_max_sets failed\n");
mdclrerror(&error);
return;
}
for (i = 1; i < max_sets; i++) {
mdclrerror(&error);
continue;
}
sr->sr_setname);
/*
* Ignore failures to create the symlink. This could
* happen because suninstall is restartable so the
* symlink might have already been created.
*/
}
}
/*
* FUNCTION: svm_alloc
* Return a pointer to an opaque piece of zeroed memory.
*
* RETURN VALUES:
* Non null - SUCCESS
* NULL - FAIL
*/
{
}
/*
* FUNCTION: svm_free
*
* INPUT: pointer to struct svm_info
*/
void
{
int i;
return;
}
}
/*
* FUNCTION: get_mdcomponents
* Given "uname" metadevice, return the physical components
* of that metadevice.
*
* INPUT:
* uname - metadevice name
*
* RETURN VALUES:
* svmp - structure containing md name and components
* RET_SUCCESS
* RET_ERROR
*
*/
int
{
mdnamelist_t *p;
rval = RET_SUCCESS;
cnt = 0;
(void) init_metalib();
debug_printf("get_mdcomponents(): "
"metaname or metachkmeta failed\n");
mdclrerror(ep);
return (RET_ERROR);
}
debug_printf("get_mdcomponents(): "
"comp %s - meta_getdevs failed\n", uname);
mdclrerror(ep);
return (RET_ERROR);
}
/* compute the number of devices */
;
/*
* Need to add n -1 components since slvmp already has space
* for one device.
*/
(sizeof (char *) * (cnt - 1)));
debug_printf("get_mdcomponents(): realloc of svmp failed\n");
return (RET_ERROR);
}
break;
}
}
/* count is set to the number of devices in the list */
debug_printf("get_mdcomponents(): root_md %s count %d \n",
debug_printf("get_mdcomponents(): %s\n",
} else {
debug_printf("get_mdcomponents(): malloc failed\n");
}
return (rval);
}
/*
* FUNCTION: svm_get_components
* return svm_infop with the components of a metadevice.
*
* INPUT:
*
* RETURN:
* 0 - SUCCESS
* !0 - FAIL
*/
int
{
int len;
/*
* If this is a named diskset with a shared name
* get_mdcomponents can handle directly.
*/
int numlen;
int setnum;
char *cp;
char *slashp;
return (RET_ERROR);
return (RET_ERROR);
/* setnum now contains the diskset number */
return (RET_ERROR);
/* cp now pointing at dsk/... */
return (RET_ERROR);
slashp + 1);
} else {
}
}