meta_getdevs.c revision 856669dc1a0b09671e48a0220e5ec3b865c22c78
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* get dev_t list
*/
#include <meta.h>
#include <strings.h>
/*
* private version of minor(), able to handle 64 bit and 32 bit devices.
* print a warning out in case a 32 bit dev is specified.
*/
{
/* check if it's a real 64 bit dev */
if ((dev64 >> NBITSMAJOR64) > 0) {
} else {
if (getenv("META_DEBUG"))
(void) printf(
"meta_getminor called with 32 bit dev: 0x%llx\n",
dev64);
}
}
/*
* private version of major(), able to handle 64 bit and 32 bit devices.
* print a warning out in case a 32 bit dev is specified.
*/
{
/* check if it's a real 64 bit dev */
if ((dev64 >> NBITSMAJOR64) > 0) {
} else {
if (getenv("META_DEBUG"))
(void) printf(
"meta_getmajor called with 32 bit dev: 0x%llx\n",
dev64);
}
}
/*
* private version of cmpldev(), able to handle 64 bit and 32 bit devices.
*/
{
if (major == 0) {
}
}
/*
* private version of expldev(), able to handle 64 bit and 32 bit devices.
*/
{
if (major > 0) { /* a 64 bit device was given, return unchanged */
return (dev64);
}
}
/*
* get underlying devices (recursively)
*/
int
mdnamelist_t **nlpp,
)
{
char *miscname;
size_t i;
int rval = -1;
/* must have local set */
/* if no valid name then return an error */
return (-1);
/* just add regular devices */
if (! metaismeta(namep)) {
mdnamelist_t *p;
/*
* If the dev_t is in the array already
* then let's continue.
*/
rval = 0;
goto out;
}
}
/* add to list */
rval = 0;
goto out;
}
/* get MD misc module */
goto out;
/* get count of underlying devices */
rval = 0;
goto out;
}
}
goto out;
rval = 0;
goto out;
}
/* get underlying devices */
rval = 0;
goto out;
}
}
goto out;
rval = 0;
goto out;
}
/* recurse */
continue;
}
goto out;
}
goto out;
}
/* success */
rval = 0;
/* cleanup, return error */
out:
return (rval);
}
/*
* get all dev_t for a set
*/
int
int check_db,
)
{
int rval = 0;
/*
* Get a replica namelist,
* and then get all the devs within the replicas.
*/
rval = -1;
rval = -1;
}
}
/*
* Get a stripe namelist,
* and then get all the devs within the stripes.
*/
rval = -1;
rval = -1;
}
/*
* Get a mirror namelist,
* and then get all the devs within the mirrors.
*/
rval = -1;
rval = -1;
}
/*
* Get a trans namelist,
* and then get all the devs within the trans.
*/
rval = -1;
rval = -1;
}
/*
* Get a hot spare pool namelist,
* and then get all the devs within the hot spare pools.
*/
rval = -1;
uint_t i;
rval = -1;
rval = -1;
}
}
/*
* Get a raid namelist,
* and then get all the devs within the raids.
*/
rval = -1;
rval = -1;
}
/*
* Get a soft partition namelist,
* and then get all the devs within the softpartitions
*/
rval = -1;
rval = -1;
}
return (rval);
}
/*
* get vtoc from a device already opened.
* returns
* 0 on success,
* -1 on error. If the error was ENOTSUP, partno will be set to
* VT_ENOTSUP if possible.
*/
int
int fd, /* fd for named device */
char *devname, /* name of device */
int *partno, /* return partno here */
)
{
int part;
else if (part == VT_ENOTSUP) {
if (partno) {
*partno = VT_ENOTSUP;
return (-1);
}
}
}
/* Slice number for *p0 partition (whole disk on x86) is 16 */
if (partno)
return (0);
}
/*
* set mdvtoc for a meta devices
*/
int
int fd, /* fd for named device */
char *devname, /* name of device */
)
{
uint_t i;
/*
* Sanity-check the mdvtoc
*/
return (-1);
}
/*
* since many drivers won't allow opening a device make sure
* all partitions aren't being set to zero. If all are zero then
* we have no way to set them to something else
*/
break;
return (-1);
/*
* Write the mdvtoc
*/
}
return (0);
}
/*
* set vtoc
*/
int
int fd, /* fd for named device */
char *devname, /* name of device */
)
{
int part;
int err;
else
}
return (0);
}
/*
* FUNCTION: meta_get_names()
* INPUT: drivername - char string containing the driver name
* sp - the set name to get soft partitions from
* options - options from the command line
* OUTPUT: nlpp - list of all soft partition names
* ep - return error pointer
* RETURNS: int - -1 if error, 0 success
* PURPOSE: returns a list of all specified devices in the metadb
* for all devices in the specified set
*/
int
char *drivername,
mdnamelist_t **nlpp,
)
{
int i;
/* get number of devices */
} else {
return (-1);
}
}
/* malloc minor number buffer to be filled by ioctl */
return (ENOMEM);
}
return (-1);
}
/* get name */
/*
* do not exist. This could happen on a metaset
* take due to devfsadmd not having created them.
* Therefore, with disksets and a null np, assume
* devfsadmd has not run and so tell it to run
* for the specific device that is missing.
* The call to meta_update_devtree does not return
*/
(void) meta_update_devtree(*m_ptr);
}
goto out;
/* next device */
m_ptr++;
}
}
out:
return (-1);
}
/*
* Wrap lib/libdevid/devid_deviceid_to_nmlist. We want to take the
* results from that function and filter out the c[t]dp style names that
* we typically see on x86 so that we never see them.
*/
int
{
int res;
int i = 1;
if (res != 0) {
return (res);
}
/* first count the number of non c[t]dp items in retlist */
uint_t s;
/* Check if this is a c[t]dp style name. */
i++;
}
}
/* create an array to hold the non c[t]dp items */
/* copy the non c[t]dp items to the array */
uint_t s;
/* Check if this is a c[t]dp style name. */
/* nope, so copy and go to the next */
rp++;
}
/* if it is c[t]dp, just skip the element */
}
/* copy the list terminator */
*retlist = tmp_retlist;
return (res);
}