/*
* 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 1995-2003 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
/*
* libmeta wrappers for event notification
*/
#include <meta.h>
#if defined(DEBUG)
#include <assert.h>
#endif /* DEBUG */
struct tag2obj_type {
} tag2obj_typetab[] =
{
{ TAG_METADEVICE, EVO_METADEV },
{ TAG_REPLICA, EVO_REPLICA },
{ TAG_MEDIATOR, EVO_MEDIATOR },
{ TAG_UNK, EVO_UNSPECIFIED },
};
struct evdrv2evlib_type {
} evdrv2evlib_typetab[] =
{
{ EQ_REPLACE, EV_REPLACE },
{ EQ_HOST_ADD, EV_HOST_ADD },
{ EQ_HOST_DELETE, EV_HOST_DELETE },
{ EQ_DRIVE_ADD, EV_DRIVE_ADD },
{ EQ_RENAME_SRC, EV_RENAME_SRC },
{ EQ_RENAME_DST, EV_RENAME_DST },
{ EQ_INIT_START, EV_INIT_START },
{ EQ_INIT_FAILED, EV_INIT_FAILED },
{ EQ_INIT_FATAL, EV_INIT_FATAL },
{ EQ_LASTERRED, EV_LASTERRED },
{ EQ_RESYNC_DONE, EV_RESYNC_DONE },
{ EQ_HOTSPARED, EV_HOTSPARED },
{ EQ_HS_FREED, EV_HS_FREED },
{ EQ_TAKEOVER, EV_TAKEOVER },
{ EQ_RELEASE, EV_RELEASE },
{ EQ_OPEN_FAIL, EV_OPEN_FAIL },
{ EQ_OFFLINE, EV_OFFLINE },
{ EQ_DETACHING, EV_DETACHING },
{ EQ_ATTACHING, EV_ATTACHING },
{ EQ_EXCHANGE, EV_EXCHANGE },
{ EQ_REGEN_START, EV_REGEN_START },
{ EQ_REGEN_DONE, EV_REGEN_DONE },
{ EQ_NOTIFY_LOST, EV_NOTIFY_LOST },
};
static ev_obj_t
{
char *miscname;
goto out;
}
goto out;
}
goto out;
}
obj = EVO_STRIPE;
obj = EVO_MIRROR;
}
out:
return (obj);
}
static ev_obj_t
{
int i;
return (tag2obj_typetab[i].obj);
}
return (EVO_UNSPECIFIED);
}
static md_tags_t
{
int i;
return (tag2obj_typetab[i].tag);
}
return (TAG_UNK);
}
static evid_t
{
int i;
return (evdrv2evlib_typetab[i].lib);
}
return (EV_UNK);
}
static md_event_type_t
{
int i;
return (evdrv2evlib_typetab[i].drv);
}
return (EQ_EMPTY);
}
/*
* meta_event
* returns 0 on succcess or < 0 to indicate error.
* abs(return code) = errno
*/
static int
{
int l;
return (-EINVAL);
return (-EINVAL);
}
mdclrerror(ep);
errno = 0;
if (errno == 0) {
}
}
return (-errno);
}
return (0);
}
static void
{
if (qname)
else
}
/*
* meta_notify_createq
* - creates an eventq
* - returns 0 on success or errno and sets ep
*/
int
{
int err = 0;
mdclrerror(ep);
"null or zero-length queue name"));
return (EINVAL);
}
/* set */ 0,
/* dev */ 0,
/* user-defined event data */ 0,
&evctl);
err = 0;
mdclrerror(ep);
}
}
return (-err);
}
/*
* meta_notify_deleteq
* - deletes an eventq
* - free's any underlying resources
* - returns 0 on success or errno and sets ep
*/
int
{
int err;
/* flags */ 0,
/* set */ 0,
/* dev */ 0,
/* user-defined event data */ 0,
&evctl);
return (-err);
}
/*
* meta_notify_validq
* - verifies that the queue exists
* - returns true or false, ep may be changed as a side-effect
*/
{
/* flags */ 0,
/* set */ 0,
/* dev */ 0,
/* user-defined event data */ 0,
&evctl);
}
/*
* meta_notify_listq
* - returns number of (currently) active queus or -errno
* - allocates qnames array and sets user's pointer to it,
* fills in array with vector of qnames
*/
int
{
#ifdef lint
#endif /* lint */
mdclrerror(ep);
return (-EOPNOTSUPP);
}
/*
* meta_notify_flushq
* - calls the underlying notify driver to flush all events
* from the named queue
* - returns 0 on success or errno and sets ep as necessary
*/
int
{
#ifdef lint
#endif /* lint */
mdclrerror(ep);
return (EOPNOTSUPP);
}
static void
{
}
}
/*
* meta_notify_getev
* - collects up to 1 event and stores it into md_ev_t
* - returns number of events found (0 or 1) on success or -errno
* - flags governs whether an empty queue is waited upon (EVFLG_WAIT)
*/
int
{
int n_ev;
if (!evp) {
goto out;
}
/* flags (unused in get) */ 0,
/* user-defined event data */ 0,
&evctl);
/*
* trap EAGAIN so that EV_EMPTY events get returned, but
* be sure n_ev = 0 so that users who just watch the count
* will also work
*/
switch (err) {
case -EAGAIN:
break;
case 0:
n_ev = 1;
break;
}
out:
}
/*
* meta_notify_getevlist
* - collects all pending events in the named queue and allocates
* an md_evlist_t * to return them
* - returns the number of events found (may be 0 if !WAIT) on success
* or -errno and sets ep as necessary
*/
int
md_error_t *ep)
{
int n_ev = 0;
mdclrerror(ep);
if (!evpp_arg) {
"No event list pointer"));
goto out;
}
"Null or zero-length queue name"));
goto out;
}
do {
continue;
}
} else {
}
n_ev++;
}
out:
err = 0;
}
if (err < 0) {
return (err);
}
if (evpp_arg) {
}
return (n_ev);
}
/*
* the guts of meta_notify_putev() and meta_notify_sendev()
* are within this function.
*
* meta_notify_putev() is intended for general use by user-level code,
* such as the GUI, to send user-defined events.
*
* meta_notify_sendev() is for "user-level driver" code, such as
* set manipulation and the multi-host daemon to generate events.
*
* Note- only convention enforces this usage.
*/
int
{
return (EINVAL);
}
/*
* users may only put events of type EQ_USER
*/
/* flags (unused in put) */ 0,
&evctl);
}
/*
* meta_notify_putev
* - sends an event down to the notify driver (hence, all queues)
* - returns 0 on success or errno
*/
int
{
return (EINVAL);
}
}
/*
* alternate put event entry point which allows
* more control of event innards (for use by md "user-level drivers")
*
* Since this routine isn't for use by clients, the user event data
* is always forced to be 0. That is only meaningful for events
* of type EQ_USER (and those go through meta_notify_putev()), so
* this is consistent.
*/
int
{
int rc;
mdclrerror(ep);
}
return (rc);
}
/*
* meta_notify_putevlist
* - sends all of the events in the event list
* - returns number of events sent (>= 0) on success or -errno
*/
int
{
int n_ev = 0;
int err;
if (!evlp) {
err = 0;
goto out; /* that was easy */
}
goto out;
}
n_ev++;
}
out:
}
/*
* meta_notify_freevlist
* - frees any memory allocated within the event list
* - returns 0 on success or errno and sets ep as necessary
*/
void
{
md_evlist_t *i;
if (i && i->evp) {
}
}
for (i = evlp; i; /* NULL */) {
Free(i);
i = next;
}
}