how to add a new bus to lshal output

Olaf Hering olh at suse.de
Wed Sep 19 06:26:53 PDT 2007


This patch appears to work ok. Still two bugs in the kernel driver to
resolve.

---
 hald/linux/blockdev.c |   22 +++++++++++++++++++++
 hald/linux/device.c   |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)

--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1167,6 +1167,10 @@ hotplug_event_begin_add_blockdev (const 
 					is_hotpluggable = TRUE;
 					hal_device_property_set_string
 						(d, "storage.bus", "ccw");
+				} else if (strcmp (bus, "vio") == 0) {
+					physdev = d_it;
+					physdev_udi = udi_it;
+					hal_device_property_set_string (d, "storage.bus", "vio");
 				}
 			}
 
@@ -1302,6 +1306,24 @@ hotplug_event_begin_add_blockdev (const 
 
 		} else if (strcmp (parent_bus, "mmc") == 0) {
 			hal_device_property_set_string (d, "storage.drive_type", "sd_mmc");
+		} else if (strcmp (parent_bus, "vio") == 0) {
+			char buf[256];
+			const gchar *prop;
+
+			snprintf(buf, sizeof(buf), "%s/device", sysfs_path_real);
+			prop = hal_util_get_string_from_file (buf, "name");
+			if (prop) {
+				if (strcmp (prop, "viocd") == 0) {
+					hal_device_property_set_string (d, "info.product", "iSeries Virtual CD");
+					hal_device_property_set_string (d, "storage.drive_type", "cdrom");
+				} else if (strcmp (prop, "viodasd") == 0) {
+					hal_device_property_set_string (d, "info.product", "iSeries Virtual Disk");
+					hal_device_property_set_string (d, "storage.drive_type", "disk");
+				} else if (strcmp (prop, "viotape") == 0) {
+					hal_device_property_set_string (d, "info.product", "iSeries Virtual Tape");
+					hal_device_property_set_string (d, "storage.drive_type", "tape");
+				}
+			}
 		}
 
 		hal_device_property_set_string (d, "info.category", "storage");
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2287,6 +2287,50 @@ mmc_compute_udi (HalDevice *d)
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
+vio_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
+{
+	HalDevice *d;
+	const gchar *devname;
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "info.subsystem", "vio");
+	hal_device_property_set_string (d, "info.bus", "vio");
+	if (parent_dev)
+		hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+	else
+		hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+
+	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+	hal_device_property_set_string (d, "vio.bus_id",
+					hal_util_get_last_element (sysfs_path));
+
+	devname = hal_util_get_string_from_file (sysfs_path, "name");
+	if (devname)
+		hal_device_property_set_string (d, "vio.type", devname);
+	else
+		 hal_device_property_set_string (d, "info.product", "iSeries Device (unknown)");
+
+	return d;
+}
+
+static gboolean
+vio_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/vio_%s",
+			      hal_device_property_get_string (d, "vio.bus_id"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
 xen_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d;
@@ -3584,6 +3628,13 @@ static DevHandler dev_handler_firewire =
 	.remove       = dev_remove
 };
 
+static DevHandler dev_handler_vio = {
+	.subsystem   = "vio",
+	.add         = vio_add,
+	.compute_udi = vio_compute_udi,
+	.remove      = dev_remove
+};
+
 static DevHandler dev_handler_xen = {
 	.subsystem   = "xen",
 	.add         = xen_add,
@@ -3652,6 +3703,7 @@ static DevHandler *dev_handlers[] = {
 	&dev_handler_scsi,
 	&dev_handler_mmc,
 	&dev_handler_ieee1394,
+	&dev_handler_vio,
 	&dev_handler_xen,
 	&dev_handler_ccw,
 	&dev_handler_ccwgroup,


More information about the hal mailing list