meta_init.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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"
/*
* initialize metadevices
*/
#include <meta.h>
#include <libdevinfo.h>
int
char *uname, /* Meta Device name (eg d0) */
char *str, /* String to Parse */
)
{
char c;
int cnt;
/* parse interlace */
} else if (cnt == 1) {
}
} else switch (c) {
case 'b':
case 'B':
break;
case 'k':
case 'K':
break;
case 'm':
case 'M':
break;
default:
}
/* return success */
*interlacep = num;
return (0);
}
/*
* cook up syntax error
*/
int
md_error_t *ep,
char *uname,
int argc,
char *argv[]
)
{
int rval;
/* if we have a token, concat it to uname */
char *p;
(void) strcat(p, ": ");
} else {
p[0] = '\0';
}
(void) strcat(p, "\"");
(void) strcat(p, "\"");
Free(p);
} else {
}
return (rval);
}
int
)
{
int rval = MD_CRO_32BIT;
if (total_blocks > MD_MAX_BLKS_FOR_SMALL_DEVS) {
rval = MD_CRO_64BIT;
}
return (rval);
}
/*
* setup metadevice geometry
*/
/*ARGSUSED*/
int
)
{
if (round_cyl) {
} else {
}
return (0);
}
/*
* adjust metadevice geometry
*/
/*ARGSUSED*/
int
)
{
if (round_cyl) {
} else {
}
return (0);
}
/*
* Function: meta_init_make_device
* Purpose:
* Create the device node <uname> by constructing the necessary
* md_mkdev_params_t structure. We have to handle relative names
* The field that we need is the unit number of the metadevice (80 in
* the above examples).
* Input: spp set structure
* uname unit-name (fully qualified or relative)
* Output: ep error return structure
* Returns: 0 success
* -1 Error. <ep> contains error reason
*/
int
mdsetname_t **spp,
char *uname,
)
{
int rval = 0;
char *p, *e = uname;
e += len;
/*
* Find the start of the unit within <uname>.
*/
if (p == NULL) {
/* Relative name (e.g. d80) */
p = &uname[1];
} else {
p += 2;
if (p >= e) {
/* Invalid drive name */
Free(p);
return (rval);
}
}
e = NULL;
if (e == p) {
/* Invalid drive name */
Free(p);
return (rval);
}
}
/*
* Wait until device appears in namespace. di_devlink_init() returns
* once the /dev links have been created. If NULL is returned the
* link operation failed and we haven't got a device to use.
* NOTE: This will take a _long_ time for large numbers of metadevices.
* Change to use the enhanced di_devlink_init() interface when
* available.
*/
(void) di_devlink_fini(&hdl);
} else {
Free(p);
}
return (rval);
}
/*
* FUNCTION: is_metadb_cmd()
* INPUT: argc - number of command line arguments
* argv - pointer to array of command line arguments
* OUTPUT: none
* RETURNS: TRUE if a metadb is to be created, FALSE otherwise
* PURPOSE: parses enough of the command line to determine if a metadb
* create is being attempted
*/
static boolean_t
int argc,
char *argv[]
)
{
int len;
/* look for match */
return (B_TRUE);
}
return (B_FALSE);
}
/*
* FUNCTION: is_stripe_cmd()
* INPUT: argc - number of command line arguments
* argv - pointer to array of command line arguments
* OUTPUT: none
* RETURNS: TRUE if a stripe is to be created, FALSE otherwise
* PURPOSE: parses enough of the command line to determine if a stripe
* create is being attempted
*/
static boolean_t
int argc,
char *argv[]
)
{
return (B_FALSE);
return (B_TRUE);
}
/*
* FUNCTION: meta_get_init_type()
* INPUT: argc - number of command line arguments
* argv - pointer to array of command line arguments
* OUTPUT: none
* RETURNS: type of metadevice or hot spare pools being initialized
* PURPOSE: parses enough of the command line to determine what type
* of metainit is being attempted
*/
int argc,
char *argv[]
)
{
return (TAB_HSP);
} else { /* assume that it is a hsp */
}
}
return (init_type);
}
/*
* initialize named device or hotspare pool
*/
int
mdsetname_t **spp,
int argc,
char *argv[],
)
{
char *p;
int rval;
/* determine type of metadevice or hot spare pool being created */
/* hotspare pool */
/* metadevice */
char *cname;
/*
* We need to create the device node if the specified metadevice
* does not already exist in the database. The actual creation
* is undertaken by the md driver and the links propagated by
* devfsadm.
*/
/* initialize the spp properly */
/* Create device node */
}
switch (init_type) {
case TAB_MIRROR:
break;
case TAB_RAID:
break;
case TAB_SP:
break;
case TAB_TRANS:
break;
case TAB_STRIPE:
break;
}
}
/* unknown type */
(void) strcpy(p, "\"");
(void) strcat(p, "\"");
Free(p);
return (rval);
}