/*
* 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 2004 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
/*
* MH ioctl functions
*/
#include <meta.h>
#include <metamhd.h>
#include <string.h>
#include "meta_runtime.h"
/*
* default timeout values
*/
1000, /* failfast */
{ 6000, 6000, 30000 } /* take ownership */
};
/* RPC timeouts */
/*
* RPC handle
*/
typedef struct {
char *hostname;
} mhd_handle_t;
/*
* close RPC connection
*/
static void
)
{
}
}
}
/*
* open RPC connection to rpc.metamhd
*/
static mhd_handle_t *
char *hostname,
)
{
/* default to local host */
/* open RPC connection */
"tcp")) == NULL) {
return (NULL);
} else {
}
/* return connection */
return (hp);
}
/*
* steal and convert mherror_t
*/
int
)
{
/* no error */
/* assert(mhep->name == NULL); */
rval = 0;
goto out;
}
/* steal error */
case MHD_E_MAJORITY:
break;
case MHD_E_RESERVED:
break;
default:
break;
}
/* cleanup, return success */
out:
return (rval);
}
/*
* should we do MHIOCTLs ?
*/
static int
{
"NOT doing MH ioctls\n"));
return (0);
}
return (1);
}
/*
* take ownership of drives
*/
int
char *sname,
int partial_set,
)
{
uint_t i;
char *e;
/*
* RFE 4126509. Check the runtime parameters to see if
* they're set to disable MHIOCTKOWN ioctl() operations
* on the disks. If so, return immediately without
* performing the operations.
*/
if (do_owner_ioctls() == B_FALSE) {
return (0);
}
/* count drives, get set */
++ndev;
if (ndev == 0)
return (0);
/* initialize */
/* build arguments */
}
++e;
if (strcmp(e, "NONE") == 0)
else if (strcmp(e, "DRIVER") == 0)
else if (strcmp(e, "DEBUG") == 0)
else if (strcmp(e, "HALT") == 0)
else if (strcmp(e, "PANIC") == 0)
}
if (partial_set)
}
/* open connection */
return (-1);
/* take ownership */
"metamhd tkown");
rval = 0; /* success */
}
/* cleanup, return success */
out:
return (rval);
}
/*
* take ownership of drives
*/
int
int partial_set,
)
{
md_drive_desc *p;
int rval;
/*
* Add the drivename struct to the end of the
* drivenamelist but keep a pointer to the last
* element so that we don't incur the overhead
* of traversing the list each time
*/
/* take ownership */
/* cleanup, return success */
return (rval);
}
/*
* release ownership of drives
*/
int
char *sname,
int partial_set,
)
{
uint_t i;
char *e;
/*
* RFE 4126509. Check the runtime parameters to see if
* they're set to disable MHIOCRELEASE and MHIOCENFAILFAST
* ioctl() operations on the disks. If so, return
* immediately without performing the operations.
*/
if (do_owner_ioctls() == B_FALSE) {
return (0);
}
/*
* if not doing ioctls (HK 98/10/28: the following code tests
* an environment variable, and was apparently inserted to
* make testing easier.)
*/
if (! do_mhioctl())
return (0);
/* count drives, get set */
++ndev;
if (ndev == 0)
return (0);
/* initialize */
/* build arguments */
}
if (partial_set)
}
/* open connection */
return (-1);
/* take ownership */
"metamhd relown");
rval = 0; /* success */
}
/* cleanup, return success */
out:
return (rval);
}
/*
* release ownership of drives
*/
int
int partial_set,
)
{
md_drive_desc *p;
int rval;
/*
* Add the drivename struct to the end of the
* drivenamelist but keep a pointer to the last
* element so that we don't incur the overhead
* of traversing the list each time
*/
/* release ownership */
/* cleanup, return success */
return (rval);
}
/*
* get status of drives
*/
int
char *sname,
int partial_set,
)
{
uint_t i;
char *e;
/* if not doing ioctls */
if (! do_mhioctl())
return (0);
/* count drives, get set */
++ndev;
if (ndev == 0)
return (0);
/* initialize */
/* build arguments */
}
if (partial_set)
}
/* open connection */
return (-1);
/* get status */
goto out;
goto out;
}
/* do something with it */
/* make sure we have the right drive */
/* copy status */
}
}
rval = 0; /* success */
/* cleanup, return success */
out:
return (rval);
}
/*
* build disk status list from drivename list
*/
)
{
/* copy list */
}
/* return list */
return (head);
}
/*
* free disk status list
*/
void
)
{
}
}
/*
* free drive info list
*/
void
)
{
}
/*
* sort drive info list
*/
static int
const void *p1,
const void *p2
)
{
n1 = "";
n2 = "";
/* attempt to sort correctly for c0t1d0s0 .vs. c0t18d0s0 */
goto u;
goto u;
goto u;
goto u;
return (0);
}
static void
)
{
sizeof (*listp->mhd_drive_info_list_t_val),
}
/*
* return list of all drives
*/
int
char *hostname,
char *path,
)
{
/* if not doing ioctls */
if (! do_mhioctl())
return (0);
/* initialize */
/* build arguments */
/* open connection */
return (-1);
/* get list */
goto out;
goto out;
}
/* sort list */
/* steal list */
/* cleanup, return success */
out:
return (rval);
}
static void
{
*p,
*x;
/*
* Read each line from the file. Lines will be either
* comments or path names to pass to rpc.metamhd. If
* path names check to see if their a colon seperate
* list of names which must be processed one at a time.
*/
if (buf[0] == '#') {
/*
* Ignore comment lines
*/
continue;
p = buf;
*x = '\0';
(void) meta_list_drives(NULL, p, 0,
p = x + 1;
}
/*
* We won't pick up the last path name
* because the line ends with a newline
* not a ':'. So p will still point to
* a valid path in this case. Copy the
* data that p points to to the beginning
* of the buf and let the default case
* handle this buffer.
* NOTE:
* If the file does end with a ":\n", p at
* will point to the newline. The default
* cause would then set the newline to a
* NULL which is okay because meta_list_drives
*/
}
/*
* Remove any newlines in the buffer.
*/
*p = '\0';
}
}
}
/*
* build list of all drives in set
*/
/*ARGSUSED*/
int
int options,
)
{
uint_t i;
unsigned cnt = 0;
/* must have a set */
return (-1);
/* find drives in set */
for (i = 0; (i < list.mhd_drive_info_list_t_len); ++i) {
continue;
/* quietly skip drives which don't conform */
mdclrerror(ep);
continue;
}
/* check in set */
goto out;
mdclrerror(ep);
continue;
}
/*
* Add the drivename struct to the end of the
* drivenamelist but keep a pointer to the last
* element so that we don't incur the overhead
* of traversing the list each time
*/
++cnt;
}
/* cleanup, return error */
out:
return (rval);
}