/*
* 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.
*/
/*
* namespace utilities
*/
#include <meta.h>
typedef struct deviceinfo {
} deviceinfo_t;
/*
* Ask the driver for the device name, driver name, and minor number;
* which has been stored in the metadevice state database
* (on behalf of the utilities).
* (by key)
*/
char *
char **drvnm,
)
{
return (NULL);
}
return (Strdup(device_name));
}
/*
* Ask the driver for the hsp name, driver name, and minor number;
* which has been stored in the metadevice state database
* (on behalf of the utilities).
* (by key)
*/
char *
)
{
char *device_name;
device_name[0] = '\0';
return (NULL);
}
return (device_name);
}
/*
* Ask the driver for the hsp_self_id;
* which has been stored in the metadevice state database
* (on behalf of the utilities).
* (by hsp name)
*/
char *hspname,
)
{
char *device_name;
/* must have a hsp name */
/*
* The ioctl expects the a hsp name and return its hsp_self_id.
*/
return (MD_HSP_NONE);
}
return (MD_HSP_NONE);
}
}
/*
* Ask the driver for the minor name which has been stored in the
* metadevice state database.
* (by key)
*/
char *
)
{
return (NULL);
}
}
/*
* Ask the driver for the device id string which has been stored in the
* metadevice state database (on behalf of the utilities).
* (by key)
*/
)
{
/*
* First ask the driver for the size of the device id string. This is
* signaled by passing the driver a devid_size of zero.
*/
nm.devid_size = 0;
return (NULL);
}
/*
* If the devid_size is still zero then something is wrong.
*/
if (nm.devid_size == 0) {
return (NULL);
}
/*
* Now go get the actual device id string. Caller is responsible for
* free'ing device id memory buffer.
*/
return (NULL);
}
return (NULL);
}
}
/*
* set the devid.
*/
int
)
{
int i;
return (-1);
}
if (setno == MD_LOCAL_SET) {
/*
* If this is the local set then we are adding in the devids
* for the disks in the diskset and so this means adding
* a reference count for each side. Need to do this after
* the initial add so that the correct devid is picked up.
* The key is the key of the drive record and as such this
* means the minor number of the device which is used to
* get the devid. If the wrong side is used then it would
* be possible to get the wrong devid in the namespace, hence
* the requirement to process the local side first of all.
*/
for (i = 0 + SKEW; i < MD_MAXSIDES; i++) {
/*
* We can just call the ioctl again because it will
* fail with ENOENT if the side does not exist, and
* more importantly does not increment the usage count
* on the devid.
*/
continue;
} else {
return (-1);
}
}
}
}
return (0);
}
/*
* Ask the driver for the name, which has been stored in the
* metadevice state database (on behalf of the utilities).
* (by key)
*/
char *
)
{
}
/*
* Ask the driver for the device name, driver name, minor number, and key;
* which has been stored in the metadevice state database
* (on behalf of the utilities).
* (by md_dev64_t)
*/
char *
char **drvnm,
)
{
/* must have a dev */
return (NULL);
}
/*
* With the friendly name work, each metadevice will have
* an NM entry. However, to allow backward compatibility,
* systems upgraded to a friendly name release won't have
* NM entries for the pre-existing top level metadevices. This
* implementation allows users to downgrade to a pre-friendly
* name release since the configuration information (mddb) is
* not modified.
*
* meta_getnmentbydev is called to get nm entry for all metadevices
* and expects the minor and major number and returns a key and
* name. For upgraded systems with pre-existing metadevices,
* the only returning value will be the name since there's no nm
* entry for pre-friendly name top level metadevices. So a return
* key for the device will not be available and will be NULL.
* Thus, the caller is responsible for making sure the returned key
* is valid, not NULL.
*/
return (Strdup(device_name));
}
/*
* The arguments, minorname and devid, are only used with the partial
* import code and should be NULL otherwise.
*/
int
char *dname,
char *bname,
char *minorname, /* only used with a partial import */
)
{
}
}
/*
* Remove the device name which corresponds to the given device number.
*/
int
)
{
return (0);
}
static void
{
}
}
}
static void
char *bname,
char *dname,
)
{
}
/*
* Build a list of the names on the systems, if this fails the caller
* will tidy up the entries in the devlist.
*/
static int
)
{
int err;
/*CONSTCOND*/
while (1) {
return (-1);
if (err == 0)
break;
/* the sideno gives us the index into the array */
}
return (0);
}
/*
* add name key
* the meta_create* functions should be the only ones using this. The
* adding of a name to the namespace must be done in a particular order
* to devid support for the disksets. The order is: add the 'local' side
* first of all, so the devid lookup in the kernel will use the correct
* device information and then add in the other sides.
*/
int
mdnamelist_t **nlpp,
)
{
int err;
int maxsides;
/* should have a set */
if (! metaislocalset(sp)) {
return (-1);
}
}
return (-1);
}
/*
* When a disk is added into the namespace the local information for
* that disk is added in first of all. For the local set this is not
* a concern and for the host that owns the diskset it is not a concern
* but when a disk is added in the remote namespace we *must* use the
* local information for that disk first of all. This is because when
* in the kernel (md_setdevname) the passed in dev_t is used to find
* the devid of the disk. This means we have to cater for the following:
*
* - a disk on the remote host having the dev_t that has been passed
* into the kernel and this disk is not actually the disk that is
* being added into the diskset.
* - the dev_t does not exist on this node
*
* So putting in the local information first of all makes sure that the
* dev_t passed into the kernel is correct with respect to that node
* and then any further additions for that name match on the key
* passed back.
*/
/*
* Did not find the disk information for the disk. This can
* be because of an inconsistancy in the namespace: that is the
* devid we have in the namespace does not exist on the
* system and thus when looking up the disk information
* using this devid we fail to find anything.
*/
return (-1);
}
return (-1);
}
/* We now have a 'key' so add in the other sides */
if (metaislocalset(sp))
goto done;
if (MD_MNSET_DESC(sd))
else
/* ignore thisside, as it has been added above */
continue;
if (err == -1) {
return (-1);
}
}
}
done:
/* save key, return success */
return (0);
}
/*
* delete name key
* the meta_create* functions should be the only ones using this. The
* removal of the names must be done in a particular order: remove the
* non-local entries first of all and then finally the local entry.
*/
int
)
{
int err;
int retval = 0;
/* should have a set */
/* should have a key */
/* remove the remote sides first of all */
for (;;) {
return (-1);
if (err == 0)
break;
/* ignore thisside */
continue;
}
retval = -1;
}
/* now remove this side */
if (retval == 0)
retval = -1;
return (retval);
}
/*
* delete namelist keys
* the meta_create* functions should be the only ones using this
*/
int
)
{
mdnamelist_t *p;
int rval = 0;
/* if ignoring errors */
/* delete names */
rval = -1;
}
/* cleanup, return success */
mdclrerror(&status);
return (rval);
}
/*
* This routine when is called will store the metadevice name
* when it is first created
*/
char *uname,
)
{
char *p, *devname;
int len;
if (p == NULL)
p = uname;
else
p++;
/*
* The valid qualified name
*/
if (metaislocalset(sp)) {
} else {
}
/*
* Add self to the namespace
*/
return (-1);
}
if (metaislocalset(sp)) {
return (-1);
}
} else {
/*
* Add myside first and use the returned key to add other sides
*/
return (-1);
}
/*
* Add for all other sides
*/
return (-1);
}
if (MD_MNSET_DESC(sd)) {
continue;
ep) == -1) {
return (-1);
}
}
} else {
continue;
continue;
return (-1);
}
}
}
}
return (key);
}
/*
* This routine when is called will remove the metadevice name
* from the namespace and it is the last thing to do in the
* metaclear operation
*/
int
)
{
int rval = 0;
return (-1);
if (metaislocalset(sp)) {
} else {
/*
* Remove all other sides first
*/
return (-1);
}
if (MD_MNSET_DESC(sd)) {
continue;
ep)) == -1) {
goto out;
}
}
} else {
continue;
continue;
ep)) == -1) {
goto out;
}
}
}
/*
* del myside
*/
}
out:
return (rval);
}