sysevent.c revision d2ec54f7875f7e05edd56195adbeb593c947763f
/***************************************************************************
*
* sysevent.c : Solaris sysevents
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Licensed under the Academic Free License version 2.1
*
**************************************************************************/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <libdevinfo.h>
#include <libsysevent.h>
#include <glib.h>
#include "../osspec.h"
#include "../logger.h"
#include "../hald.h"
#include "../hald_dbus.h"
#include "../device_info.h"
#include "../util.h"
#include "osspec_solaris.h"
#include "hotplug.h"
#include "devinfo.h"
#include "devinfo_storage.h"
#include "devinfo_acpi.h"
#include "devinfo_usb.h"
#include "sysevent.h"
#ifndef ESC_LOFI
#define ESC_LOFI "lofi"
#endif
static void sysevent_dev_handler(sysevent_t *);
static void sysevent_dev_branch(gchar *);
static void sysevent_devfs_add(gchar *);
static sysevent_handle_t *shp;
static int sysevent_pipe_fds[2];
static GIOChannel *sysevent_iochannel;
static guint sysevent_source_id;
sysevent_init(void)
{
const char *subcl[6];
/*
* pipe used to serialize sysevents through the main loop
*/
if (pipe (sysevent_pipe_fds) != 0) {
return (FALSE);
}
if (sysevent_iochannel == NULL) {
HAL_INFO (("g_io_channel_unix_new failed"));
return (FALSE);
}
return (FALSE);
}
return (FALSE);
}
return (FALSE);
}
subcl[0] = ESC_DEV_BRANCH_REMOVE;
return (FALSE);
}
subcl[0] = ESC_PWRCTL_ADD;
return (FALSE);
}
subcl[0] = ESC_DEVFS_DEVI_ADD;
return (FALSE);
}
return (B_TRUE);
}
void
sysevent_fini(void)
{
}
static void
{
char *class;
char *subclass;
char *phys_path;
char *dev_name;
char *dev_hid;
char *dev_uid;
char s[1024];
return;
return;
return;
goto out;
}
snprintf(s, sizeof (s), "%s %s %s\n",
goto out;
}
&phys_path) != 0) {
goto out;
}
!= 0) {
goto out;
}
dev_name = "noname";
} else {
dev_name = "";
}
}
dev_hid = "";
}
dev_uid = "";
}
!= 0) {
dev_index = 0;
}
snprintf(s, sizeof (s), "%s %s %s %s %s %s %d\n",
out:
}
static gboolean
{
int matches;
HAL_INFO (("sysevent_iochannel_data"));
&err) == G_IO_STATUS_NORMAL) {
if (len == 0) {
break;
}
g_free (s);
s = NULL;
if (matches < 3) {
continue;
}
}
}
}
}
}
if (err) {
g_error_free (err);
}
return (TRUE);
}
static void
{
return;
}
}
static void
{
}
static void
{
}
static void
{
const char *parent_udi;
if ((d = hal_device_store_match_key_value_string (hald_get_gdl (),
return;
}
return;
}
return;
}
return;
}
}
static void
{
}
static HalDevice *
lookup_parent(char *devfs_path)
{
char *p;
if (p == NULL) {
return (NULL);
}
*p = '\0';
/* Look up the parent node in the gdl. */
"solaris.devfs_path", path);
/* Look up the parent node in the tdl. */
"solaris.devfs_path", path);
}
return (parent);
}
/*
* Handle the USB bus devices hot plugging events.
*/
static void
{
char *driver_name;
return;
}
goto out;
/* The disk and printer devices are handled by EC_DEV_ADD class. */
goto out;
goto out;
return;
out:
}
static void
{
} else {
HAL_INFO(("Unmatched EC_PWRCTL"));
}
}