/*
* 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"
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <door.h>
#include <fcntl.h>
#include <syslog.h>
#include <libsysevent.h>
#include <picl.h>
#include <pthread.h>
#include "piclevent.h"
/*
* syseventd event handler
*/
static int piclslm_debug = 0;
typedef struct nvlist_queue {
static int cleanup;
static void
init_queue(void)
{
}
static int
{
return (-1);
else
return (0);
}
static nvlist_queue_t *
remove_from_queue(void)
{
return (NULL);
return (nvqp);
}
static void
{
}
/*
* deliver the event to the plugin if the door exists
*/
static void
{
if (door_fd >= 0) {
return;
}
/*
* It's not a valid door file descriptor.
* Close and reopen the door and try again
* as "picld" may have restarted.
*/
}
if (piclslm_debug)
"picl_slm: opened door %s door_fd: %d\n",
return;
}
}
if (piclslm_debug)
"picl_slm: sent sysevent door:%d pack_buf:%p size:0x%x\n",
}
/*ARGSUSED*/
static void *
{
for (;;) {
(void) mutex_lock(&nvq_lock);
}
nvqp = remove_from_queue();
(void) mutex_unlock(&nvq_lock);
while (nvqp) {
(void) mutex_lock(&nvq_lock);
nvqp = remove_from_queue();
(void) mutex_unlock(&nvq_lock);
}
if (cleanup)
return (NULL);
}
/*NOTREACHED*/
}
/*
* returns 0 if arguments successfully added to nvl, EINVAL if arguments missing
* from ev and EAGAIN if nvlist_add_string() fails
*/
static int
{
return (EINVAL);
}
return (EAGAIN);
}
return (0);
}
/*
* returns 0 if arguments successfully added to nvl, EINVAL if arguments missing
* from ev and EAGAIN if nvlist_add_string() fails
*/
static int
{
return (EINVAL);
}
return (EAGAIN);
}
return (EAGAIN);
} else {
return (EAGAIN);
}
return (0);
}
/*
* returns 0 if arguments successfully added to nvl, EINVAL if arguments missing
* from ev and EAGAIN if nvlist_add_string() fails
*/
static int
{
return (EAGAIN);
}
return (EINVAL);
}
return (EAGAIN);
}
dr_req = "";
dr_req)) {
return (EAGAIN);
}
if (piclslm_debug)
return (0);
}
/*
* piclslm_deliver_event - called by syseventd to deliver an event buffer.
* The event buffer is subsequently delivered to
* picld. If picld, is not responding to the
* delivery attempt, we will ignore it.
*/
/*ARGSUSED*/
static int
{
char *ec;
char *esc;
char *ename;
int retval;
char *pack_buf;
int rval;
/*
* Filter out uninteresting events
*/
if (piclslm_debug)
"picl_slm: got sysevent ev:%p class:%s subclass:%s\n",
return (0);
else
return (0);
else
return (0);
} else {
return (0);
}
return (EAGAIN);
/*
* Make a copy to expand attribute list
*/
return (EAGAIN);
}
return (EAGAIN);
}
} else {
}
}
if (rval != 0) {
}
return (EAGAIN);
}
/*
* Add nvlist_t to queue
*/
(void) mutex_lock(&nvq_lock);
(void) cond_signal(&nvq_cv);
(void) mutex_unlock(&nvq_lock);
}
struct slm_mod_ops *
slm_init(void)
{
cleanup = 0;
init_queue();
(void) mutex_destroy(&nvq_lock);
(void) cond_destroy(&nvq_cv);
return (NULL);
}
return (&piclslm_mod_ops);
}
void
slm_fini(void)
{
/*
* Wait for all events to be sent
*/
(void) mutex_lock(&nvq_lock);
cleanup = 1;
(void) cond_signal(&nvq_cv);
(void) mutex_unlock(&nvq_lock);
/* Wait for delivery thread to exit */
(void) mutex_destroy(&nvq_lock);
(void) cond_destroy(&nvq_cv);
if (door_fd >= 0)
door_fd = -1;
}