summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Shaw <joeshaw@novell.com>2004-05-25 20:09:29 +0000
committerJoe Shaw <joeshaw@novell.com>2004-05-25 20:09:29 +0000
commita1629ab38a8a81963e93daae6acbc968614f28b2 (patch)
tree411ccb0a3b49c22a4be871c4b1307cfd782dd883
parentbbe45ca5b5310e450b70ce89c65490363d0b71d1 (diff)
Add the ieee1394 class devices.
Replace use of locally defined AsyncInfo with ClassAsyncData. Replace use of locally defined AsyncInfo with BusAsyncData. Replace use of locally defined AsyncInfo with ClassAsyncData. (class_device_accept): Check here if the class device has a sysdevice and reject it if it doesn't. (class_device_visit): Don't check for it here. If it is NULL, set merge_or_add to FALSE so that we don't try to merge it onto a fake device. If the sysdevice is NULL, set the parent sysfs path to "(none)", which will match our fake parent device. (class_device_final): Take a third argument for merge_or_add and check it instead of the ClassDeviceHandler's default behavior. New IEEE1394 class device implementation. Seems to even work somewhat on some small subset of the world's computers. If there is an address, set the net.address property to it, regardless of what type of net device it is. (net_class_accept): Added. Allows us to have net class devices without an associated sysdevice. Only allow it if it's an ethernet device for now. (net_class_compute_udi): Added. Needed in situations where the class device has no sysdevice, we need to generate a UDI since we aren't merging onto a parent device. Reenable the ieee1394 class device handlers. (osspec_probe): Create a fake root device to be the parent for all of our sysdevice-less devices. It's a virtual device, has the UDI "/org/freedesktop/Hal/devices/fakeroot", and the sysfs path device of "(none)". Add "unknown" to the list of known bus names.
-rw-r--r--ChangeLog49
-rw-r--r--Doxyfile2
-rw-r--r--hald/Makefile.am3
-rw-r--r--hald/linux/block_class_device.c15
-rw-r--r--hald/linux/bus_device.c25
-rw-r--r--hald/linux/bus_device.h7
-rw-r--r--hald/linux/class_device.c111
-rw-r--r--hald/linux/class_device.h8
-rw-r--r--hald/linux/ieee1394_class_device.c128
-rw-r--r--hald/linux/ieee1394_host_class_device.c127
-rw-r--r--hald/linux/ieee1394_node_class_device.c141
-rw-r--r--hald/linux/net_class_device.c58
-rw-r--r--hald/linux/osspec.c27
-rw-r--r--tools/device-manager/Const.py.in3
14 files changed, 627 insertions, 77 deletions
diff --git a/ChangeLog b/ChangeLog
index ce872c53..f8772ce9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,50 @@
+2004-05-25 Joe Shaw <joeshaw@novell.com>
+
+ * hald/Makefile.am: Add the ieee1394 class devices.
+
+ * hald/linux/block_class_device.c: Replace use of locally defined
+ AsyncInfo with ClassAsyncData.
+
+ * hald/linux/bus_device.c: Replace use of locally defined
+ AsyncInfo with BusAsyncData.
+
+ * hald/linux/class_device.c: Replace use of locally defined
+ AsyncInfo with ClassAsyncData.
+ (class_device_accept): Check here if the class device has a
+ sysdevice and reject it if it doesn't.
+ (class_device_visit): Don't check for it here. If it is NULL, set
+ merge_or_add to FALSE so that we don't try to merge it onto a fake
+ device. If the sysdevice is NULL, set the parent sysfs path to
+ "(none)", which will match our fake parent device.
+ (class_device_final): Take a third argument for merge_or_add and
+ check it instead of the ClassDeviceHandler's default behavior.
+
+ * hald/linux/ieee1394_class_device.c,
+ hald/linux/ieee1394_host_class_device.c,
+ hald/linux/ieee1394_node_class_device.c: New IEEE1394 class device
+ implementation. Seems to even work somewhat on some small subset
+ of the world's computers.
+
+ * hald/linux/net_class_device.c (net_class_pre_process): If there
+ is an address, set the net.address property to it, regardless of
+ what type of net device it is.
+ (net_class_accept): Added. Allows us to have net class devices
+ without an associated sysdevice. Only allow it if it's an
+ ethernet device for now.
+ (net_class_compute_udi): Added. Needed in situations where the
+ class device has no sysdevice, we need to generate a UDI since we
+ aren't merging onto a parent device.
+
+ * hald/linux/osspec.c: Reenable the ieee1394 class device
+ handlers.
+ (osspec_probe): Create a fake root device to be the parent for all
+ of our sysdevice-less devices. It's a virtual device, has the UDI
+ "/org/freedesktop/Hal/devices/fakeroot", and the sysfs path device
+ of "(none)".
+
+ * tools/device-manager/Const.py.in (BUS_NAMES): Add "unknown" to
+ the list of known bus names.
+
2004-05-25 David Zeuthen <david@fubar.dk>
* configure.in: Bump to 0.2.91
@@ -18,7 +65,7 @@
there was a blank cd inside :). Patch from Sjoerd Simons
<sjoerd@luon.net>.
-2004-05-18 Joe shaw <joeshaw@novell.com>
+2004-05-18 Joe Shaw <joeshaw@novell.com>
* tools/callouts/fstab-update.sh: Use /media as long as it's there
and /mnt doesn't exist. Otherwise fallback to /mnt. Should
diff --git a/Doxyfile b/Doxyfile
index 79a1c7a5..69c1bf90 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -23,7 +23,7 @@ PROJECT_NAME = HAL
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 0.2.90
+PROJECT_NUMBER = 0.2.91
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
diff --git a/hald/Makefile.am b/hald/Makefile.am
index 0250755a..26817dc4 100644
--- a/hald/Makefile.am
+++ b/hald/Makefile.am
@@ -45,6 +45,9 @@ hald_SOURCES += \
linux/ide_bus_device.c \
linux/pcmcia_socket_class_device.c \
linux/macio_bus_device.c \
+ linux/ieee1394_class_device.c \
+ linux/ieee1394_node_class_device.c \
+ linux/ieee1394_host_class_device.c \
linux/linux_dvd_rw_utils.h linux/linux_dvd_rw_utils.c
# linux/ieee1394_host_class_device.c
diff --git a/hald/linux/block_class_device.c b/hald/linux/block_class_device.c
index c1d40981..ee9044ef 100644
--- a/hald/linux/block_class_device.c
+++ b/hald/linux/block_class_device.c
@@ -71,11 +71,6 @@ static void etc_mtab_process_all_block_devices (dbus_bool_t force);
static void detect_fs (HalDevice *d);
-typedef struct {
- HalDevice *device;
- ClassDeviceHandler *handler;
-} AsyncInfo;
-
static void
block_class_visit (ClassDeviceHandler *self,
const char *path,
@@ -83,7 +78,7 @@ block_class_visit (ClassDeviceHandler *self,
{
HalDevice *d;
char *parent_sysfs_path;
- AsyncInfo *ai;
+ ClassAsyncData *cad;
/* only care about given sysfs class name */
if (strcmp (class_device->classname, "block") != 0)
@@ -128,15 +123,15 @@ block_class_visit (ClassDeviceHandler *self,
/* Now find the parent device; this happens asynchronously as it
* might be added later. */
- ai = g_new0 (AsyncInfo, 1);
- ai->device = d;
- ai->handler = self;
+ cad = g_new0 (ClassAsyncData, 1);
+ cad->device = d;
+ cad->handler = self;
hal_device_store_match_key_value_string_async (
hald_get_gdl (),
"linux.sysfs_path_device",
parent_sysfs_path,
- class_device_got_parent_device, ai,
+ class_device_got_parent_device, cad,
HAL_LINUX_HOTPLUG_TIMEOUT);
}
diff --git a/hald/linux/bus_device.c b/hald/linux/bus_device.c
index fbe6034e..7df7f999 100644
--- a/hald/linux/bus_device.c
+++ b/hald/linux/bus_device.c
@@ -52,11 +52,6 @@
* @{
*/
-typedef struct {
- HalDevice *device;
- BusDeviceHandler *handler;
-} AsyncInfo;
-
/* fwd decl */
static void bus_device_got_parent (HalDeviceStore *store, HalDevice *parent,
gpointer user_data);
@@ -89,7 +84,7 @@ void
bus_device_visit (BusDeviceHandler *self, const char *path,
struct sysfs_device *device)
{
- AsyncInfo *ai;
+ BusAsyncData *bad;
HalDevice *d;
char *parent_sysfs_path;
char buf[256];
@@ -110,15 +105,15 @@ bus_device_visit (BusDeviceHandler *self, const char *path,
parent_sysfs_path = get_parent_sysfs_path (path);
- ai = g_new0 (AsyncInfo, 1);
- ai->device = d;
- ai->handler = self;
+ bad = g_new0 (BusAsyncData, 1);
+ bad->device = d;
+ bad->handler = self;
if (!got_parent(path)) {
/* no need to find parent; we have none; just add directly
* with parent set to NULL
*/
- bus_device_got_parent (hald_get_gdl(), NULL, ai);
+ bus_device_got_parent (hald_get_gdl(), NULL, bad);
} else {
/* Find parent; this happens asynchronously as our parent might
* be added later. If we are probing this can't happen so the
@@ -128,7 +123,7 @@ bus_device_visit (BusDeviceHandler *self, const char *path,
hald_get_gdl (),
"linux.sysfs_path_device",
parent_sysfs_path,
- bus_device_got_parent, ai,
+ bus_device_got_parent, bad,
HAL_LINUX_HOTPLUG_TIMEOUT);
}
@@ -149,12 +144,12 @@ bus_device_got_parent (HalDeviceStore *store, HalDevice *parent,
const char *sysfs_path = NULL;
char *new_udi = NULL;
HalDevice *new_d = NULL;
- AsyncInfo *ai = (AsyncInfo*) user_data;
- HalDevice *d = (HalDevice *) ai->device;
- BusDeviceHandler *self = (BusDeviceHandler *) ai->handler;
+ BusAsyncData *bad = (BusAsyncData*) user_data;
+ HalDevice *d = (HalDevice *) bad->device;
+ BusDeviceHandler *self = (BusDeviceHandler *) bad->handler;
struct sysfs_device *device;
- g_free (ai);
+ g_free (bad);
/* set parent, if any */
if (parent != NULL) {
diff --git a/hald/linux/bus_device.h b/hald/linux/bus_device.h
index 1962e8cf..0e0dacde 100644
--- a/hald/linux/bus_device.h
+++ b/hald/linux/bus_device.h
@@ -174,4 +174,11 @@ void bus_device_got_udi (BusDeviceHandler *self,
HalDevice *d,
const char *udi);
+/* Convenience structure for passing around multiple pieces of data to
+ the got_parent_device() functions */
+typedef struct {
+ HalDevice *device;
+ BusDeviceHandler *handler;
+} BusAsyncData;
+
#endif /* BUS_DEVICE_H */
diff --git a/hald/linux/class_device.c b/hald/linux/class_device.c
index 78258e8a..ce030dcf 100644
--- a/hald/linux/class_device.c
+++ b/hald/linux/class_device.c
@@ -52,17 +52,13 @@
* @{
*/
-typedef struct {
- HalDevice *device;
- ClassDeviceHandler *handler;
-} AsyncInfo;
-
static void
class_device_got_device_file (HalDevice *d, gpointer user_data,
gboolean prop_exists);
static void
-class_device_final (ClassDeviceHandler* self, HalDevice *d);
+class_device_final (ClassDeviceHandler* self, HalDevice *d,
+ gboolean merge_or_add);
/** Generic accept function that accepts the device if and only if
@@ -81,6 +77,10 @@ class_device_accept (ClassDeviceHandler *self,
/*HAL_INFO (("path = %s, classname = %s",
path, self->sysfs_class_name));*/
+ /* Don't care if there's no sysdevice */
+ if (class_device->sysdevice == NULL)
+ return FALSE;
+
/* only care about given sysfs class name */
if (strcmp (class_device->classname, self->sysfs_class_name) == 0) {
return TRUE;
@@ -106,10 +106,12 @@ class_device_visit (ClassDeviceHandler *self,
HalDevice *d;
char dev_file[SYSFS_PATH_MAX];
char dev_file_prop_name[SYSFS_PATH_MAX];
+ gboolean merge_or_add;
- /* don't care if there is no sysdevice */
if (class_device->sysdevice == NULL) {
- return;
+ merge_or_add = FALSE;
+ } else {
+ merge_or_add = self->merge_or_add;
}
/* Construct a new device and add to temporary device list */
@@ -117,12 +119,26 @@ class_device_visit (ClassDeviceHandler *self,
hal_device_store_add (hald_get_tdl (), d);
/* Need some properties if we are to appear in the tree on our own */
- if (!self->merge_or_add) {
- hal_device_property_set_string (d, "info.bus",
- self->hal_class_name);
+ if (!merge_or_add) {
+ /*
+ * Kind of a hack... we only want to set the bus if
+ * our handler's merge_or_add is normally false. Otherwise
+ * we want the bus to just be "unknown"
+ */
+ if (!self->merge_or_add) {
+ hal_device_property_set_string (d, "info.bus",
+ self->hal_class_name);
+ } else {
+ hal_device_property_set_string (d, "info.bus",
+ "unknown");
+ }
+
hal_device_property_set_string (d, "linux.sysfs_path", path);
- hal_device_property_set_string (d, "linux.sysfs_path_device",
- class_device->sysdevice->path);
+
+ if (class_device->sysdevice != NULL) {
+ hal_device_property_set_string (d, "linux.sysfs_path_device",
+ class_device->sysdevice->path);
+ }
}
/* Temporary property used for _udev_event() */
@@ -157,34 +173,40 @@ class_device_visit (ClassDeviceHandler *self,
/* Now find the physical device; this happens asynchronously as it
* might be added later. */
- if (self->merge_or_add) {
- AsyncInfo *ai = g_new0 (AsyncInfo, 1);
- ai->device = d;
- ai->handler = self;
+ if (merge_or_add) {
+ ClassAsyncData *cad = g_new0 (ClassAsyncData, 1);
+ cad->device = d;
+ cad->handler = self;
+ cad->merge_or_add = merge_or_add;
/* find the sysdevice */
hal_device_store_match_key_value_string_async (
hald_get_gdl (),
"linux.sysfs_path_device",
class_device->sysdevice->path,
- class_device_got_sysdevice, ai,
+ class_device_got_sysdevice, cad,
HAL_LINUX_HOTPLUG_TIMEOUT);
} else {
char *parent_sysfs_path;
- AsyncInfo *ai = g_new0 (AsyncInfo, 1);
+ ClassAsyncData *cad = g_new0 (ClassAsyncData, 1);
- parent_sysfs_path =
- get_parent_sysfs_path (class_device->sysdevice->path);
+ if (class_device->sysdevice != NULL) {
+ parent_sysfs_path =
+ get_parent_sysfs_path (class_device->sysdevice->path);
+ } else {
+ parent_sysfs_path = "(none)";
+ }
- ai->device = d;
- ai->handler = self;
+ cad->device = d;
+ cad->handler = self;
+ cad->merge_or_add = merge_or_add;
/* find the parent */
hal_device_store_match_key_value_string_async (
hald_get_gdl (),
"linux.sysfs_path_device",
parent_sysfs_path,
- class_device_got_parent_device, ai,
+ class_device_got_parent_device, cad,
HAL_LINUX_HOTPLUG_TIMEOUT);
}
}
@@ -246,11 +268,10 @@ void
class_device_got_parent_device (HalDeviceStore *store, HalDevice *parent,
gpointer user_data)
{
- AsyncInfo *ai = user_data;
- HalDevice *d = (HalDevice *) ai->device;
- ClassDeviceHandler *self = ai->handler;
-
- g_free (ai);
+ ClassAsyncData *cad = user_data;
+ HalDevice *d = (HalDevice *) cad->device;
+ ClassDeviceHandler *self = cad->handler;
+ gboolean merge_or_add = cad->merge_or_add;
if (parent == NULL) {
HAL_WARNING (("No parent for class device at sysfs path %s",
@@ -273,10 +294,12 @@ class_device_got_parent_device (HalDeviceStore *store, HalDevice *parent,
hal_device_async_wait_property (
d, target_dev,
class_device_got_device_file,
- (gpointer) self,
+ (gpointer) cad,
HAL_LINUX_HOTPLUG_TIMEOUT);
} else {
- class_device_final (self, d);
+ class_device_final (self, d, merge_or_add);
+
+ g_free (cad);
}
}
@@ -294,9 +317,10 @@ class_device_got_sysdevice (HalDeviceStore *store,
HalDevice *sysdevice,
gpointer user_data)
{
- AsyncInfo *ai = user_data;
- HalDevice *d = (HalDevice *) ai->device;
- ClassDeviceHandler *self = ai->handler;
+ ClassAsyncData *cad = user_data;
+ HalDevice *d = (HalDevice *) cad->device;
+ ClassDeviceHandler *self = cad->handler;
+ gboolean merge_or_add = cad->merge_or_add;
HAL_INFO (("Entering d=0x%0x, sysdevice=0x%0x!", d, sysdevice));
@@ -337,10 +361,12 @@ class_device_got_sysdevice (HalDeviceStore *store,
hal_device_async_wait_property (
d, target_dev,
class_device_got_device_file,
- (gpointer) self,
+ (gpointer) cad,
HAL_LINUX_HOTPLUG_TIMEOUT);
} else {
- class_device_final (self, d);
+ class_device_final (self, d, merge_or_add);
+
+ g_free (cad);
}
}
@@ -348,10 +374,14 @@ static void
class_device_got_device_file (HalDevice *d, gpointer user_data,
gboolean prop_exists)
{
- ClassDeviceHandler *self = (ClassDeviceHandler *) user_data;
+ ClassAsyncData *cad = (ClassAsyncData *) user_data;
+ ClassDeviceHandler *self = cad->handler;
+ gboolean merge_or_add = cad->merge_or_add;
/*HAL_INFO (("entering"));*/
+ g_free (cad);
+
if (!prop_exists) {
HAL_WARNING (("Never got device file for class device at %s",
hal_device_property_get_string (d, ".udev.sysfs_path")));
@@ -360,11 +390,12 @@ class_device_got_device_file (HalDevice *d, gpointer user_data,
return;
}
- class_device_final (self, d);
+ class_device_final (self, d, merge_or_add);
}
static void
-class_device_final (ClassDeviceHandler* self, HalDevice *d)
+class_device_final (ClassDeviceHandler* self, HalDevice *d,
+ gboolean merge_or_add)
{
const char *sysfs_path = NULL;
struct sysfs_class_device *class_device;
@@ -380,7 +411,7 @@ class_device_final (ClassDeviceHandler* self, HalDevice *d)
self->pre_process (self, d, sysfs_path, class_device);
sysfs_close_class_device (class_device);
- if (self->merge_or_add) {
+ if (merge_or_add) {
const char *sysdevice_udi;
HalDevice *sysdevice;
diff --git a/hald/linux/class_device.h b/hald/linux/class_device.h
index 5c3a438b..7889528e 100644
--- a/hald/linux/class_device.h
+++ b/hald/linux/class_device.h
@@ -276,4 +276,12 @@ void class_device_got_parent_device (HalDeviceStore *store,
gpointer user_data);
+/* Convenience structure for passing around multiple pieces of data
+ to the got_parent_device() functions */
+typedef struct {
+ HalDevice *device;
+ ClassDeviceHandler *handler;
+ gboolean merge_or_add;
+} ClassAsyncData;
+
#endif /* CLASS_DEVICE_H */
diff --git a/hald/linux/ieee1394_class_device.c b/hald/linux/ieee1394_class_device.c
new file mode 100644
index 00000000..31ed47a1
--- /dev/null
+++ b/hald/linux/ieee1394_class_device.c
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * CVSID: $Id$
+ *
+ * IEEE1394 class device
+ *
+ * Copyright (C) 2004 Novell, Inc.
+ *
+ * Licensed under the Academic Free License version 2.0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "../logger.h"
+#include "../device_store.h"
+#include "../hald.h"
+
+#include "class_device.h"
+#include "common.h"
+
+static char *
+ieee1394_class_compute_udi (HalDevice *d, int append_num)
+{
+ static int counter = 0;
+ const char *format;
+ static char buf[256];
+
+ if (append_num == -1)
+ format = "/org/freedesktop/Hal/devices/ieee1394_%d";
+ else
+ format = "/org/freedesktop/Hal/devices/ieee1394_%d-%d";
+
+ snprintf (buf, 256, format, counter, append_num);
+
+ return buf;
+}
+
+static void
+ieee1394_class_pre_process (ClassDeviceHandler *self,
+ HalDevice *d,
+ const char *sysfs_path,
+ struct sysfs_class_device *class_device)
+{
+ struct sysfs_attribute *cur;
+ char attr_name[SYSFS_NAME_LEN];
+ int tmp;
+ int model_id = -1;
+ char *model_name = NULL;
+
+ dlist_for_each_data (sysfs_get_device_attributes (class_device->sysdevice),
+ cur, struct sysfs_attribute) {
+ int len, i;
+
+ if (sysfs_get_name_from_path (cur->path,
+ attr_name,
+ SYSFS_NAME_LEN) != 0)
+ continue;
+
+ /* strip whitespace */
+ len = strlen (cur->value);
+ for (i = len - 1; i >= 0 && isspace (cur->value[i]); --i)
+ cur->value[i] = '\0';
+
+ if (strcmp (attr_name, "model_id") == 0) {
+ model_id = parse_hex (cur->value);
+ } else if (strcmp (attr_name, "model_name_kv") == 0) {
+ model_name = cur->value;
+ } else if (strcmp (attr_name, "specifier_id") == 0) {
+ tmp = parse_hex (cur->value);
+
+ hal_device_property_set_int (d,
+ "ieee1394.specifier_id",
+ tmp);
+ }
+ }
+
+ if (model_name) {
+ hal_device_property_set_string (d, "ieee1394.product",
+ model_name);
+ hal_device_property_set_string (d, "info.product", model_name);
+ } else if (model_id != -1) {
+ char numeric_name[32];
+
+ snprintf (numeric_name, sizeof (numeric_name),
+ "Unknown (0x%04x)", model_id);
+
+ hal_device_property_set_string (d, "ieee1394.product",
+ numeric_name);
+ hal_device_property_set_string (d, "info.product",
+ numeric_name);
+ }
+}
+
+/** Method specialisations for ieee1394 device class */
+ClassDeviceHandler ieee1394_class_handler = {
+ class_device_init, /**< init function */
+ class_device_shutdown, /**< shutdown function */
+ class_device_tick, /**< timer function */
+ class_device_accept, /**< accept function */
+ class_device_visit, /**< visitor function */
+ class_device_removed, /**< class device is removed */
+ class_device_udev_event, /**< handle udev event */
+ class_device_get_device_file_target,/**< where to store devfile name */
+ ieee1394_class_pre_process, /**< add more properties */
+ class_device_post_merge, /**< post merge function */
+ class_device_got_udi, /**< got UDI */
+ ieee1394_class_compute_udi, /**< No UDI computation */
+ "ieee1394", /**< sysfs class name */
+ "ieee1394", /**< hal class name */
+ FALSE, /**< don't require device file */
+ FALSE /**< add as child to parent */
+};
diff --git a/hald/linux/ieee1394_host_class_device.c b/hald/linux/ieee1394_host_class_device.c
new file mode 100644
index 00000000..bd3feb6c
--- /dev/null
+++ b/hald/linux/ieee1394_host_class_device.c
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * CVSID: $Id$
+ *
+ * IEEE1394 host class device
+ *
+ * Copyright (C) 2004 Novell, Inc.
+ *
+ * Licensed under the Academic Free License version 2.0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "../logger.h"
+#include "../device_store.h"
+#include "../hald.h"
+
+#include "class_device.h"
+#include "common.h"
+
+static char *
+ieee1394_host_class_compute_udi (HalDevice *d, int append_num)
+{
+ static int counter = 0;
+ const char *format;
+ static char buf[256];
+
+ if (append_num == -1)
+ format = "/org/freedesktop/Hal/devices/ieee1394_host_%d";
+ else
+ format = "/org/freedesktop/Hal/devices/ieee1394_host_%d-%d";
+
+ snprintf (buf, 256, format, counter, append_num);
+
+ return buf;
+}
+
+static void
+ieee1394_host_class_pre_process (ClassDeviceHandler *self,
+ HalDevice *d,
+ const char *sysfs_path,
+ struct sysfs_class_device *class_device)
+{
+ struct sysfs_attribute *cur;
+ char attr_name[SYSFS_NAME_LEN];
+ int tmp;
+
+ dlist_for_each_data (sysfs_get_device_attributes (class_device->sysdevice),
+ cur, struct sysfs_attribute) {
+ int len, i;
+
+ if (sysfs_get_name_from_path (cur->path,
+ attr_name,
+ SYSFS_NAME_LEN) != 0)
+ continue;
+
+ /* strip whitespace */
+ len = strlen (cur->value);
+ for (i = len - 1; i >= 0 && isspace (cur->value[i]); --i)
+ cur->value[i] = '\0';
+
+ if (strcmp (attr_name, "is_busmgr") == 0) {
+ tmp = parse_dec (cur->value);
+
+ hal_device_property_set_bool (d, "ieee1394.is_busmgr",
+ tmp);
+ } else if (strcmp (attr_name, "is_irm") == 0) {
+ tmp = parse_dec (cur->value);
+
+ hal_device_property_set_bool (d, "ieee1394.is_irn",
+ tmp);
+ } else if (strcmp (attr_name, "is_root") == 0) {
+ tmp = parse_dec (cur->value);
+
+ hal_device_property_set_bool (d, "ieee1394.is_root",
+ tmp);
+ } else if (strcmp (attr_name, "node_count") == 0) {
+ tmp = parse_dec (cur->value);
+
+ hal_device_property_set_int (d, "ieee1394.node_count",
+ tmp);
+ } else if (strcmp (attr_name, "nodes_active") == 0) {
+ tmp = parse_dec (cur->value);
+
+ hal_device_property_set_int (d, "ieee1394.nodes_active",
+ tmp);
+ }
+ }
+
+ hal_device_property_set_bool (d, "info.virtual", TRUE);
+}
+
+/** Method specialisations for ieee1394_host device class */
+ClassDeviceHandler ieee1394_host_class_handler = {
+ class_device_init, /**< init function */
+ class_device_shutdown, /**< shutdown function */
+ class_device_tick, /**< timer function */
+ class_device_accept, /**< accept function */
+ class_device_visit, /**< visitor function */
+ class_device_removed, /**< class device is removed */
+ class_device_udev_event, /**< handle udev event */
+ class_device_get_device_file_target,/**< where to store devfile name */
+ ieee1394_host_class_pre_process, /**< add more properties */
+ class_device_post_merge, /**< post merge function */
+ class_device_got_udi, /**< got UDI */
+ ieee1394_host_class_compute_udi, /**< No UDI computation */
+ "ieee1394_host", /**< sysfs class name */
+ "ieee1394_host", /**< hal class name */
+ FALSE, /**< don't require device file */
+ FALSE /**< add as child to parent */
+};
diff --git a/hald/linux/ieee1394_node_class_device.c b/hald/linux/ieee1394_node_class_device.c
new file mode 100644
index 00000000..f4cc3e4a
--- /dev/null
+++ b/hald/linux/ieee1394_node_class_device.c
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * CVSID: $Id$
+ *
+ * IEEE1394 node class device
+ *
+ * Copyright (C) 2004 Novell, Inc.
+ *
+ * Licensed under the Academic Free License version 2.0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "../logger.h"
+#include "../device_store.h"
+#include "../hald.h"
+
+#include "class_device.h"
+#include "common.h"
+
+static char *
+ieee1394_node_class_compute_udi (HalDevice *d, int append_num)
+{
+ static int counter = 0;
+ const char *format;
+ static char buf[256];
+
+ if (append_num == -1)
+ format = "/org/freedesktop/Hal/devices/ieee1394_node_%d";
+ else
+ format = "/org/freedesktop/Hal/devices/ieee1394_node_%d-%d";
+
+ snprintf (buf, 256, format, counter, append_num);
+
+ return buf;
+}
+
+static void
+ieee1394_node_class_pre_process (ClassDeviceHandler *self,
+ HalDevice *d,
+ const char *sysfs_path,
+ struct sysfs_class_device *class_device)
+{
+ struct sysfs_attribute *cur;
+ char attr_name[SYSFS_NAME_LEN];
+ int tmp;
+ const char *vendor_name = NULL;
+ int vendor_id;
+
+ dlist_for_each_data (sysfs_get_device_attributes (class_device->sysdevice),
+ cur, struct sysfs_attribute) {
+ int len, i;
+
+ if (sysfs_get_name_from_path (cur->path,
+ attr_name,
+ SYSFS_NAME_LEN) != 0)
+ continue;
+
+ /* strip whitespace */
+ len = strlen (cur->value);
+ for (i = len - 1; i >= 0 && isspace (cur->value[i]); --i)
+ cur->value[i] = '\0';
+
+ if (strcmp (attr_name, "capabilities") == 0) {
+ tmp = parse_hex (cur->value);
+
+ hal_device_property_set_int (d,
+ "ieee1394.capabilities",
+ tmp);
+ } else if (strcmp (attr_name, "guid") == 0) {
+ tmp = parse_hex (cur->value);
+
+ hal_device_property_set_int (d, "ieee1394.guid", tmp);
+ } else if (strcmp (attr_name, "nodeid") == 0) {
+ tmp = parse_hex (cur->value);
+
+ hal_device_property_set_int (d, "ieee1394.nodeid",
+ tmp);
+ } else if (strcmp (attr_name, "vendor_id") == 0) {
+ vendor_id = parse_hex (cur->value);
+ } else if (strcmp (attr_name, "vendor_name_kv") == 0) {
+ vendor_name = cur->value;
+ }
+ }
+
+ hal_device_property_set_int (d, "ieee1394.vendor_id", vendor_id);
+
+ if (vendor_name) {
+ hal_device_property_set_string (d, "ieee1394.vendor",
+ vendor_name);
+ hal_device_property_set_string (d, "info.vendor", vendor_name);
+ } else {
+ char numeric_name[32];
+
+ snprintf (numeric_name, sizeof (numeric_name),
+ "Unknown (0x%04x)", vendor_id);
+
+ hal_device_property_set_string (d, "ieee1394.vendor",
+ numeric_name);
+ hal_device_property_set_string (d, "info.vendor",
+ numeric_name);
+ }
+
+ hal_device_property_set_bool (d, "info.virtual", TRUE);
+}
+
+/** Method specialisations for ieee1394_node device class */
+ClassDeviceHandler ieee1394_node_class_handler = {
+ class_device_init, /**< init function */
+ class_device_shutdown, /**< shutdown function */
+ class_device_tick, /**< timer function */
+ class_device_accept, /**< accept function */
+ class_device_visit, /**< visitor function */
+ class_device_removed, /**< class device is removed */
+ class_device_udev_event, /**< handle udev event */
+ class_device_get_device_file_target,/**< where to store devfile name */
+ ieee1394_node_class_pre_process, /**< add more properties */
+ class_device_post_merge, /**< post merge function */
+ class_device_got_udi, /**< got UDI */
+ ieee1394_node_class_compute_udi, /**< No UDI computation */
+ "ieee1394_node", /**< sysfs class name */
+ "ieee1394_node", /**< hal class name */
+ FALSE, /**< don't require device file */
+ FALSE /**< add as child to parent */
+};
diff --git a/hald/linux/net_class_device.c b/hald/linux/net_class_device.c
index 61c8eb00..58e19b5e 100644
--- a/hald/linux/net_class_device.c
+++ b/hald/linux/net_class_device.c
@@ -431,8 +431,10 @@ net_class_pre_process (ClassDeviceHandler *self,
attr = sysfs_get_classdev_attr (class_device, "address");
- if (attr != NULL)
+ if (attr != NULL) {
address = g_strstrip (g_strdup (attr->value));
+ hal_device_property_set_string (d, "net.address", address);
+ }
attr = sysfs_get_classdev_attr (class_device, "type");
@@ -477,6 +479,36 @@ net_class_pre_process (ClassDeviceHandler *self,
hal_device_property_set_string (d, "info.category", "net.ethernet");
}
+static dbus_bool_t
+net_class_accept (ClassDeviceHandler *self, const char *path,
+ struct sysfs_class_device *class_device)
+{
+ struct sysfs_attribute *attr;
+
+ /* If the class name isn't 'net', deny it. */
+ if (strcmp (class_device->classname, self->sysfs_class_name) != 0)
+ return FALSE;
+
+ /* If we have a sysdevice, allow it. */
+ if (class_device->sysdevice != NULL)
+ return TRUE;
+
+ /*
+ * Get the "type" attribute from sysfs to see if this is a
+ * network device we're interested in.
+ */
+ attr = sysfs_get_classdev_attr (class_device, "type");
+
+ if (attr == NULL || attr->value == NULL)
+ return FALSE;
+
+ /* 1 is the type for ethernet (incl. wireless) devices */
+ if (attr->value[0] == '1')
+ return TRUE;
+ else
+ return FALSE;
+}
+
static void
net_class_post_merge (ClassDeviceHandler *self, HalDevice *d)
{
@@ -484,12 +516,32 @@ net_class_post_merge (ClassDeviceHandler *self, HalDevice *d)
link_detection_init (d);
}
+static char *
+net_class_compute_udi (HalDevice *d, int append_num)
+{
+ const char *format;
+ static char buf[256];
+
+ hal_device_print (d);
+
+ if (append_num == -1)
+ format = "/org/freedesktop/Hal/devices/net-%s";
+ else
+ format = "/org/freedesktop/Hal/devices_net-%s-%d";
+
+ snprintf (buf, 256, format,
+ hal_device_property_get_string (d, "net.address"),
+ append_num);
+
+ return buf;
+}
+
/** Method specialisations for input device class */
ClassDeviceHandler net_class_handler = {
class_device_init, /**< init function */
class_device_shutdown, /**< shutdown function */
class_device_tick, /**< timer function */
- class_device_accept, /**< accept function */
+ net_class_accept, /**< accept function */
class_device_visit, /**< visitor function */
class_device_removed, /**< class device is removed */
class_device_udev_event, /**< handle udev event */
@@ -497,7 +549,7 @@ ClassDeviceHandler net_class_handler = {
net_class_pre_process, /**< add more properties */
net_class_post_merge, /**< post merge function */
class_device_got_udi, /**< got UDI */
- NULL, /**< No UDI computation */
+ net_class_compute_udi, /**< compute UDI */
"net", /**< sysfs class name */
"net", /**< hal class name */
FALSE, /**< require device file */
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 4e372da1..1605e337 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -58,11 +58,9 @@ extern ClassDeviceHandler scsi_device_class_handler;
extern ClassDeviceHandler scsi_generic_class_handler;
extern ClassDeviceHandler block_class_handler;
extern ClassDeviceHandler pcmcia_socket_class_handler;
-
-/*
-extern ClassDeviceHandler ieee1394_host_class_handler;
+extern ClassDeviceHandler ieee1394_class_handler;
extern ClassDeviceHandler ieee1394_node_class_handler;
-*/
+extern ClassDeviceHandler ieee1394_host_class_handler;
extern BusDeviceHandler pci_bus_handler;
extern BusDeviceHandler usb_bus_handler;
@@ -86,8 +84,9 @@ static ClassDeviceHandler* class_device_handlers[] = {
&scsi_generic_class_handler,
&block_class_handler,
&pcmcia_socket_class_handler,
- /*&ieee1394_host_class_handler,
- &ieee1394_node_class_handler,*/
+ &ieee1394_host_class_handler,
+ &ieee1394_node_class_handler,
+ &ieee1394_class_handler,
NULL
};
@@ -370,10 +369,26 @@ dbus_bool_t hald_is_initialising;
void
osspec_probe ()
{
+ HalDevice *fakeroot;
int i;
hald_is_initialising = TRUE;
+ /*
+ * Create the "fakeroot" device for all the devices which don't
+ * have sysdevices in sysfs.
+ */
+ fakeroot = hal_device_new ();
+ hal_device_property_set_string (fakeroot, "info.bus", "unknown");
+ hal_device_property_set_string (fakeroot,
+ "linux.sysfs_path_device",
+ "(none)");
+ hal_device_property_set_string (fakeroot, "info.product",
+ "City of Lost Devices");
+ hal_device_property_set_bool (fakeroot, "info.virtual", TRUE);
+ hal_device_set_udi (fakeroot, "/org/freedesktop/Hal/devices/fakeroot");
+ hal_device_store_add (hald_get_gdl (), fakeroot);
+
/** @todo When the kernel has all devices in /sys/devices
* under either /sys/bus or /sys/class then we can
* have code like this
diff --git a/tools/device-manager/Const.py.in b/tools/device-manager/Const.py.in
index 9b6e5f3d..c202f1d5 100644
--- a/tools/device-manager/Const.py.in
+++ b/tools/device-manager/Const.py.in
@@ -16,7 +16,8 @@ PIXBUF_COLUMN = 0
TITLE_COLUMN = 1
UDI_COLUMN = 2
-BUS_NAMES = {"usb" : "USB",
+BUS_NAMES = {"unknown" : "Unknown",
+ "usb" : "USB",
"usbif" : "USB Interface",
"pci" : "PCI",
"i2c" : "I2C",