/*
* 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"
/*
* Just in case we're not in a build environment, make sure that
* TEXT_DOMAIN gets set to something.
*/
#if !defined(TEXT_DOMAIN)
#endif
/*
* change the identity of a metadevice
* These are the "do it" functions for the metarename command.
*/
#include <string.h>
#include <meta.h>
/* private */
/*
* Check if from_np is open
* Return 0 if not open, -1 if open
*/
static int
md_error_t *ep)
{
int rc;
return (-1);
} else if (rc > 0) {
}
return (-1);
}
return (0);
}
/*
* meta_swap is the common code used by the
* meta_rename() and meta_exchange() entry points
*/
static int
int flags,
md_error_t *ep)
{
int from_add_flag = 0;
int to_add_flag = 0;
/*
* What types of devices we have here?
* For MDRNOP_RENAME to_mdp is NULL
*/
if (to_mdp) {
}
/*
* If the device exists a key may already exist so need to find it
* otherwise we'll end up adding the key in again which will lead
* to an inconsistent n_count for the namespace record.
*/
}
}
/*
* If we are top and revision indicates that we
* should have key but we don't then something
* really goes wrong
*/
if (from_has_parent || from_is_fn) {
return (-1);
}
/*
* So only add the entry if necessary
*/
return (-1);
} else {
from_add_flag = 1;
}
}
/*
* If we are top and revision indicates that we
* should have key but we don't then something
* really goes wrong
*/
if (to_has_parent || to_is_fn) {
return (-1);
}
/*
* So only add the entry if necessary
*/
if (from_add_flag)
return (-1);
} else {
to_add_flag = 1;
}
}
"\tfrom(mnum,key): %ld, %d\tto: %ld, %d\n",
}
mdclrerror(ep);
if (from_add_flag) {
/*
* Attempt removal of device node
*/
}
/*
* Attempt removal of device node
*/
}
}
/*
* Since now the metadevice can be ref'd in the namespace
* by self and by the top device so upon the successful
* necessary adjustment for the device's n_cnt in the namespace
* by calling add_key_name/del_key_name to do the tricks
*/
if (from_is_fn)
}
}
/* force the name cache to re-read device state */
return (0);
}
/*
* rename a metadevice
*/
int
)
{
int rc = 0;
char *p;
/* must have a set */
mdclrerror(ep);
}
/* if DOIT is not set, we are in dryrun mode */
if ((options & MDCMD_DOIT) == 0) {
}
return (-1);
}
mdclrerror(ep);
return (-1);
}
}
return (-1);
}
mdclrerror(ep);
/*
* The dest device name has been added early on
* by meta_init_make_device call so get the entry from
* the namespace
*/
return (-1);
}
/* If FORCE is not set, check if metadevice is open */
return (-1);
}
}
/*
* All checks are done, now we do the real work.
* If we are in dryrun mode, clear the deivce node
* and we are done.
*/
return (0); /* success */
}
return (-1);
}
if (rc == 0) {
if (options & MDCMD_PRINT) {
"%s: has been renamed to %s\n"),
}
}
return (rc);
}
/*
* return TRUE if current <from>, <to> ordering would
* prevent <from> from being in the role of <self>
*/
static bool_t
)
{
/*
* ?
* \
* <to>
* \
* <from>
*/
return (TRUE);
}
}
}
/*
* <from>
* \
* <to>
* \
* ?
*/
return (TRUE);
}
}
/*
* <to>
* \
* <from>
*/
return (TRUE);
}
}
}
/*
* <from> or <to>
* \ \
* <to> <from>
* \
* ?
*/
return (FALSE);
}
/*
* exchange the names of two metadevices
*/
int
)
{
int rc;
char *p, *p2;
/* must have a set */
return (-1);
}
return (-1);
}
if ((options & MDCMD_DOIT) == 0) {
}
}
}
}
}
return (-1);
}
return (-1);
}
/* If FORCE is not set, check if metadevice is open */
return (-1);
}
}
/*
* All checks are done, now we do the real work.
* If we are in dryrun mode, we're done.
*/
return (0); /* success */
}
/*
* NOFLIP is used only for debugging; the driver
* will catch this and return MDE_RENAME_ORDER, if necessary
*/
} else {
}
if (rc == 0) {
if (options & MDCMD_PRINT) {
"%s and %s have exchanged identities\n"),
}
}
return (rc);
}