/*
* 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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "volume_devconfig.h"
#include <string.h>
#include <ctype.h>
#include <meta.h>
#include "volume_nvpair.h"
#include "volume_error.h"
#include "volume_output.h"
#include "volume_string.h"
/*
* Methods which manipulate a devconfig_t struct
*/
/*
* Constructor: Create a devconfig_t struct. This devconfig_t must be
* freed with free_devconfig().
*
* @param devconfig
* RETURN: a new devconfig_t
*
* @param type
* the type of devconfig_t to create
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
int error;
return (-1);
}
/* Create attribute list */
NV_UNIQUE_NAME_TYPE, 0)) != 0) {
return (error);
}
return (error);
}
return (0);
}
/*
* Free memory (recursively) allocated to a devconfig_t struct
*
* @param arg
* pointer to the devconfig_t to be freed
*/
void
void *arg)
{
return;
}
/* Free the attributes nvlist */
}
/* Free available devices */
}
/* Free unavailable devices */
}
/* Free the components */
}
/* Free the devconfig itself */
}
/*
* Check the type of the given device.
*
* @param device
* the device whose type to check
*
* @param type
* the type of the device against which to compare
*
* @return B_TRUE if the device is of the given type, B_FALSE
* otherwise
*/
{
return (B_FALSE);
}
return (B_FALSE);
}
return (B_FALSE);
}
return (B_TRUE);
}
/*
* Get the first component of the given type from the given
* devconfig_t. Create the component if create is B_TRUE.
*
* @return ENOENT
* if the requested component does not exist and its
* creation was not requested
*
* @return 0
* if the requested component exists or was created
*
* @return non-zero
* if the requested component did not exist and could not
* be created
*/
int
{
int error = 0;
/* For each component of this device... */
/* Is this subcomponent an instance of the given type? */
return (0);
}
}
/* No component found */
/*
* An existing singleton component of the given type was
* not found under the given disk set. So, create one.
*/
/* Attach new component to given device */
}
}
return (error);
}
/*
* Set the available devices for use in creating this device
*
* @param device
* a devconfig_t representing the device to modify
*
* @param available
* A NULL-terminated array of device names
*/
void
char **available)
{
}
/*
* Get the available devices for use in creating this device
*
* @param device
* a devconfig_t representing the device to examine
*
* @return available
* A NULL-terminated array of device names
*/
char **
{
}
/*
* Set the unavailable devices which may not be used in creating this
* device
*
* @param device
* a devconfig_t representing the device to modify
*
* @param available
* A NULL-terminated array of device names
*/
void
char **unavailable)
{
}
/*
* Get the unavailable devices for use in creating this device
*
* @param device
* a devconfig_t representing the device to examine
*
* @return unavailable
* A NULL-terminated array of device names
*/
char **
{
return (device->unavailable);
}
/*
* Set the subcomponent devices of a given device
*
* @param device
* a devconfig_t representing the device to examine
*
* @param components
* A dlist_t containing devconfig_t devices
*/
void
{
}
/*
* Get the subcomponent devices of a given device
*
* @param device
* a devconfig_t representing the device to examine
*
* @return A dlist_t containing devconfig_t devices
*/
dlist_t *
{
return (device->components);
}
/*
* Set the device name
*
* @param device
* a devconfig_t representing the device to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
char *name)
{
}
/*
* Set the disk set name
*
* @param diskset
* a devconfig_t representing the diskset to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
char *name)
{
/* Verify syntax of disk set name */
return (-1);
}
}
/*
* Set the device name
*
* @param hsp
* a devconfig_t representing the hsp to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
char *name)
{
/* Validate name */
if (!is_hspname(name)) {
return (-1);
}
}
/*
* Set the device name
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
char *name)
{
/* Validate name */
if (!is_metaname(name)) {
return (-1);
}
}
/*
* Get the device name
*
* @param volume
* a devconfig_t representing the volume to examine
*
* @param name
* RETURN: the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
char **name)
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the device type
*
* @param device
* a devconfig_t representing the device to modify
*
* @param type
* the value to set as the device type
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
}
/*
* Get the device type
*
* @param device
* a devconfig_t representing the device to examine
*
* @param type
* RETURN: the device type
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
switch (error) {
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
case ENOENT:
break;
/* Success */
case 0:
}
return (error);
}
/*
* Set the device size (for volume, mirror, stripe, concat) in bytes
*
* Note that size in bytes in a 64-bit field cannot hold the size that
* can be accessed in a 16 byte CDB. Since CDBs operate on blocks,
* the max capacity is 2^73 bytes with 512 byte blocks.
*
* @param device
* a devconfig_t representing the device to modify
*
* @param size_in_bytes
* the value to set as the device size in bytes
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against limits */
/* LINTED -- MIN_SIZE may be 0 */
if (size_in_bytes < MIN_SIZE) {
(unsigned long long)size_in_bytes);
return (-1);
}
}
/*
* Get the device size (for volume, mirror, stripe, concat) in bytes
*
* Note that size in bytes in a 64-bit field cannot hold the size that
* can be accessed in a 16 byte CDB. Since CDBs operate on blocks,
* the max capacity is 2^73 bytes with 512 byte blocks.
*
* @param device
* a devconfig_t representing the device to examine
*
* @param size_in_bytes
* RETURN: the device size in bytes
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the device size in blocks
*
* @param device
* a devconfig_t representing the device to modify
*
* @param type
* the value to set as the device size in blocks
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against limits */
/* LINTED -- MIN_SIZE_IN_BLOCKS may be 0 */
if (size_in_blocks < MIN_SIZE_IN_BLOCKS) {
(unsigned long long)size_in_blocks);
return (-1);
}
}
/*
* Get the device size in blocks
*
* @param device
* a devconfig_t representing the device to examine
*
* @param size_in_blocks
* RETURN: the device size in blocks
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the the slice index
*
* @param slice
* a devconfig_t representing the slice to modify
*
* @param index
* the value to set as the the slice index
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
}
/*
* Get the slice index
*
* @param device
* a devconfig_t representing the device to examine
*
* @param index
* RETURN: the slice index
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the the slice start block
*
* @param slice
* a devconfig_t representing the slice to modify
*
* @param start_block
* the value to set as the the slice start block
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
}
/*
* Get the slice start block
*
* @param device
* a devconfig_t representing the device to examine
*
* @param start_block
* RETURN: the slice start block
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the number of subcomponents in mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param nsubs
* the value to set as the number of subcomponents in
* mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against limits */
gettext("number of submirrors (%d) out of valid range (%d-%d)"),
return (-1);
}
}
/*
* Get number of subcomponents in mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param nsubs
* RETURN: number of subcomponents in mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the read strategy for mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param read
* the value to set as the read strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
}
/*
* Get read strategy for mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param read
* RETURN: read strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
switch (error) {
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
case ENOENT:
break;
/* Success */
case 0:
}
return (error);
}
/*
* Set the write strategy for mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param write
* the value to set as the write strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
}
/*
* Get write strategy for mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param write
* RETURN: write strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
switch (error) {
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
case ENOENT:
break;
/* Success */
case 0:
}
return (error);
}
/*
* Set the resync pass for mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param pass
* the value to set as the resync pass for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against max value */
if (pass > MD_PASS_MAX) {
gettext("mirror pass number (%d) out of valid range (0-%d)"),
pass, MD_PASS_MAX);
return (-1);
}
}
/*
* Get resync pass for mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param pass
* RETURN: resync pass for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the minimum number of components in stripe
*
* @param stripe
* a devconfig_t representing the stripe to modify
*
* @param mincomp
* the value to set as the minimum number of components
* in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against minimum value */
if (mincomp < MIN_NSTRIPE_COMP) {
"minimum stripe components (%d) below minimum allowable (%d)"),
return (-1);
}
}
/*
* Get minimum number of components in stripe
*
* @param device
* a devconfig_t representing the device to examine
*
* @param mincomp
* RETURN: minimum number of components in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
gettext("minimum number of stripe components not set"));
}
return (error);
}
/*
* Set the maximum number of components in stripe
*
* @param stripe
* a devconfig_t representing the stripe to modify
*
* @param maxcomp
* the value to set as the maximum number of components
* in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against minimum value */
if (maxcomp < MIN_NSTRIPE_COMP) {
"maximum stripe components (%d) below minimum allowable (%d)"),
return (-1);
}
}
/*
* Get maximum number of components in stripe
*
* @param device
* a devconfig_t representing the device to examine
*
* @param maxcomp
* RETURN: maximum number of components in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
gettext("maximum number of stripe components not set"));
}
return (error);
}
/*
* Set the stripe interlace
*
* @param stripe
* a devconfig_t representing the stripe to modify
*
* @param interlace
* the value to set as the stripe interlace
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Get string representations of interlaces */
gettext("interlace (%s) out of valid range (%s - %s)"),
return (-1);
}
}
/*
* Get stripe interlace
*
* @param device
* a devconfig_t representing the device to examine
*
* @param interlace
* RETURN: stripe interlace
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the redundancy level for a volume.
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param rlevel
* If 0, a stripe will be created. If > 0, a mirror with
* this number of submirrors will be created.
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against limits */
"volume redundancy level (%d) out of valid range (%d-%d)"),
return (-1);
}
}
/*
* Get the redundancy level for a volume.
*
* @param device
* a devconfig_t representing the device to examine
*
* @param rlevel
* RETURN: the redundancy level for a volume
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the number of paths in volume
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param npaths
* the value to set as the number of paths in volume
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Validate against limits */
gettext("number of data paths (%d) out of valid range (%d-%d)"),
return (-1);
}
}
/*
* Get number of paths in volume
*
* @param device
* a devconfig_t representing the device to examine
*
* @param npaths
* RETURN: number of paths in volume
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Set the HSP creation option (for volume, stripe, concat, mirror)
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param usehsp
* the value to set as the HSP creation option
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
}
/*
* Get HSP creation option (for volume, stripe, concat, mirror)
*
* @param device
* a devconfig_t representing the device to examine
*
* @param usehsp
* RETURN: HSP creation option (for volume, stripe,
* concat, mirror)
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
int
{
/* Convert ENOENT to ERR_ATTR_UNSET for a custom error message */
}
return (error);
}
/*
* Get the string representation of the volume's type
*
* @param type
* a valid component_type_t
*
* @return an internationalized string representing the given
* type
*/
char *
{
char *str;
switch (type) {
default:
}
return (str);
}
/*
* Get the string representation of the mirror's read strategy
*
* @param read
* a valid mirror_read_strategy_t
*
* @return an internationalized string representing the given
* read strategy
*/
char *
{
char *str;
switch (read) {
default: str = "";
}
return (str);
}
/*
* Get the string representation of the mirror's write strategy
*
* @param write
* a valid mirror_write_strategy_t
*
* @return an internationalized string representing the given
* write strategy
*/
char *
{
char *str;
switch (write) {
default: str = "";
}
return (str);
}
#ifdef DEBUG
/*
* Dump the contents of a devconfig_t struct to stdout.
*
* @param device
* the devconfig_t to examine
*
* @param prefix
* a prefix string to print before each line
*/
void
char *prefix)
{
int i = 0;
return;
}
/* Type */
}
/* Name */
}
/* Size in bytes */
}
/* Size in blocks */
}
/* Use HSP */
if (devconfig_get_volume_usehsp(device, &bool) == 0) {
}
switch (type) {
case TYPE_VOLUME:
/* Volume rlevel */
}
/* Volume npaths */
}
break;
case TYPE_MIRROR:
/* Mirror nsubs */
}
/* Mirror read */
}
/* Mirror write */
}
/* Mirror pass */
}
break;
case TYPE_STRIPE:
/* Stripe mincomp */
}
/* Stripe maxcomp */
}
/* Stripe interlace */
}
break;
case TYPE_SLICE:
/* Slice index */
}
/* Slice start block */
}
break;
}
}
}
}
}
printf("\n");
}
}
}
#endif /* DEBUG */