hal/hald/linux2 blockdev.c, 1.16, 1.17 classdev.c, 1.26, 1.27 osspec.c, 1.25, 1.26 osspec_linux.h, 1.2, 1.3 physdev.c, 1.16, 1.17

David Zeuthen david at freedesktop.org
Mon Jun 27 12:13:05 PDT 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv9505/hald/linux2

Modified Files:
	blockdev.c classdev.c osspec.c osspec_linux.h physdev.c 
Log Message:
2005-06-27  David Zeuthen  <davidz at redhat.com>

	Patch-set from Cornelia Huck <cohuck at de.ibm.com>. I've been
	working on support for Linux on S/390 specific devices in HAL. The
	following patchset includes some non-s390 specific patches and
	support for the S/390 bus types.

	* doc/spec/hal-spec.xml.in: Document the properties of ccw,
	ccwgroup, iucv, and tape devices.

	* hald/linux2/classdev.c (tape_add, tape_compute_udi): This
	comprises support for both the generic tape class and the tape390
	class, as the two don't differ in anything but name.

	* hald/linux2/blockdev.c (hotplug_event_begin_add_blockdev): ccw
	devices need to be considered for block devices.

	* hald/linux2/physdev.c (iucv_add_netiucv_properties)
	(iucv_add, iucv_compute_udi): The iucv bus is for virtual devices
	under z/VM - currently only netiucv is implemented.

	* hald/linux2/physdev.c (ccwgroup_add_qeth_properties)
	(ccwgroup_add_ctc_properties, ccwgroup_add_lcs_properties)
	(ccwgroup_add_claw_properties, ccwgroup_add)
	(ccwgroup_compute_udi): The ccwgroup on S/390 contains devices
	consisting of grouped ccw devices - usually networking devices. As
	with the ccw bus, there are some common properties and lots of
	device specific ones.

	* hald/linux2/physdev.c (ccw_add_dasd_properties)
	(ccw_add_zfcp_properties, ccw_add_tape_properties)
	(ccw_add_3270_properties, ccw_add, ccw_compute_udi): The ccw bus
	on s390 contains all classic channel-attached devices. They all
	have a few common properties, but also driver-specific ones.

	* hald/linux2/osspec_linux.h: Export hal_util_get_driver_name ()

	* hald/linux2/osspec.c (hal_util_get_driver_name): New function
	(hal_util_set_driver): Refactor to use hal_util_get_driver_name

	* hald/linux2/classdev.c (net_add): Set MAC-address to zero's
	if we can't read it.
	(net_compute_udi): Use some other unique ID if MAC address is
	missing or set to all zero's.

	* hald/linux2/blockdev.c (blockdev_compute_udi): Generate a
	sensible name for block devices for which the model is an
	empty string.

	* hald/util.c: This patch adds a needed include for some
	interfaces, or gcc 4.0 will make incorrect assumptions on the
	format of some functions.



Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- blockdev.c	29 Apr 2005 21:39:58 -0000	1.16
+++ blockdev.c	27 Jun 2005 19:13:03 -0000	1.17
@@ -107,7 +107,7 @@
 			hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
 					      "/org/freedesktop/Hal/devices/storage_serial_%s", 
 					      serial);
-		} else if (model != NULL) {
+		} else if ((model != NULL) && (strlen(model) != 0) ) {
 			hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
 					      "/org/freedesktop/Hal/devices/storage_model_%s", 
 					      model);
@@ -726,7 +726,14 @@
 					physdev_udi = udi_it;
 					hal_device_property_set_string (d, "storage.bus", "mmc");
 					break;
+				} else if (strcmp (bus, "ccw") == 0) {
+					physdev = d_it;
+					physdev_udi = udi_it;
+					is_hotpluggable = TRUE;
+					hal_device_property_set_string
+						(d, "storage.bus", "ccw");
 				}
+									
 			}
 
 			/* Go to parent */

Index: classdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/classdev.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- classdev.c	29 Mar 2005 20:25:13 -0000	1.26
+++ classdev.c	27 Jun 2005 19:13:03 -0000	1.27
@@ -193,8 +193,10 @@
 	ifname = hal_util_get_last_element (sysfs_path);
 	hal_device_property_set_string (d, "net.interface", ifname);
 
-	if (!hal_util_set_string_from_file (d, "net.address", sysfs_path, "address"))
-		goto error;
+	if (!hal_util_set_string_from_file (d, "net.address", sysfs_path, "address")) {
+		hal_device_property_set_string (d, "net.address", "00:00:00:00:00:00");	
+	}
+
 	if (!hal_util_set_int_from_file (d, "net.linux.ifindex", sysfs_path, "ifindex", 10))
 		goto error;
 
@@ -294,10 +296,16 @@
 net_compute_udi (HalDevice *d)
 {
 	gchar udi[256];
+	const gchar *id;
 
+	id = hal_device_property_get_string (d, "net.address");
+	if (id == NULL || (strcmp (id, "00:00:00:00:00:00") == 0)) {
+		/* Need to fall back to something else if mac not available. */
+		id = hal_util_get_last_element(hal_device_property_get_string(d, "net.physical_device"));
+	}
 	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
 			      "/org/freedesktop/Hal/devices/net_%s",
-			      hal_device_property_get_string (d, "net.address"));
+			      id);
 	hal_device_set_udi (d, udi);
 	hal_device_property_set_string (d, "info.udi", udi);
 	return TRUE;
@@ -630,6 +638,56 @@
 
 /*--------------------------------------------------------------------------------------------------------------*/
 
+static HalDevice *
+tape_add (const gchar *sysfs_path, const gchar *device_file, 
+	  HalDevice *physdev, const gchar *sysfs_path_in_devices)
+{
+	HalDevice *d;
+	const gchar *dev_entry;
+
+	if (physdev == NULL)
+		return NULL;
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "info.parent", physdev->udi);
+	hal_device_property_set_string (d, "info.category", "tape");
+	hal_device_add_capability (d, "tape");
+	hal_device_add_capability (physdev, "tape");
+
+	dev_entry = hal_util_get_string_from_file (sysfs_path, "dev");
+	if (dev_entry != NULL) {
+		unsigned int major, minor;
+
+		if (sscanf (dev_entry, "%d:%d", &major, &minor) != 2) {
+			hal_device_property_set_int (d, "tape.major", major);
+			hal_device_property_set_int (d, "tape.minor", minor);
+		}
+	}
+	return d;
+}
+
+static gboolean
+tape_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+	const gchar *sysfs_name;
+
+	sysfs_name = hal_util_get_last_element (hal_device_property_get_string
+						(d, "linux.sysfs_path"));
+	if (!sysfs_name)
+		return FALSE;
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/tape_%s",
+			      sysfs_name);
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
 static gboolean
 classdev_remove (HalDevice *d)
 {
@@ -723,6 +781,26 @@
 	.remove       = classdev_remove
 };
 
+static ClassDevHandler classdev_handler_tape =
+{
+	.subsystem    = "tape",
+	.add          = tape_add,
+	.get_prober   = NULL,
+	.post_probing = NULL,
+	.compute_udi  = tape_compute_udi,
+	.remove       = classdev_remove
+};
+
+static ClassDevHandler classdev_handler_tape390 =
+{
+	.subsystem    = "tape390",
+	.add          = tape_add,
+	.get_prober   = NULL,
+	.post_probing = NULL,
+	.compute_udi  = tape_compute_udi,
+	.remove       = classdev_remove
+};
+
 static ClassDevHandler *classdev_handlers[] = {
 	&classdev_handler_input,
 	&classdev_handler_bluetooth,
@@ -731,6 +809,8 @@
 	&classdev_handler_usbclass,
 	&classdev_handler_sound,
 	&classdev_handler_serial,
+	&classdev_handler_tape,
+	&classdev_handler_tape390,
 	NULL
 };
 

Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- osspec.c	23 Jun 2005 14:50:04 -0000	1.25
+++ osspec.c	27 Jun 2005 19:13:03 -0000	1.26
@@ -569,23 +569,33 @@
 }
 
 gboolean
-hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path)
+hal_util_get_driver_name (const char *sysfs_path, gchar *driver_name)
 {
-	gboolean ret;
 	gchar driver_path[HAL_PATH_MAX];
 	struct stat statbuf;
 
-	ret = FALSE;
-
 	g_snprintf (driver_path, sizeof (driver_path), "%s/driver", sysfs_path);
 	if (stat (driver_path, &statbuf) == 0) {
 		gchar buf[256];
 		memset (buf, '\0', sizeof (buf));
 		if (readlink (driver_path, buf, sizeof (buf) - 1) > 0) {
-			hal_device_property_set_string (d, property_name, hal_util_get_last_element (buf));
-			ret = TRUE;
+			g_snprintf (driver_name, strlen(buf), "%s", hal_util_get_last_element(buf));
+			return TRUE;
 		}
 	}
+	return FALSE;
+}
+
+gboolean
+hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path)
+{
+	gboolean ret;
+	gchar driver_name[256];
+
+	memset (driver_name, '\0', sizeof (driver_name));
+	ret = hal_util_get_driver_name (sysfs_path, driver_name);
+	if (ret == TRUE)
+		hal_device_property_set_string (d, property_name, driver_name);
 
 	return ret;
 }

Index: osspec_linux.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec_linux.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- osspec_linux.h	27 Apr 2005 18:53:39 -0000	1.2
+++ osspec_linux.h	27 Jun 2005 19:13:03 -0000	1.3
@@ -33,6 +33,8 @@
 
 const gchar *get_hal_proc_path (void);
 
+gboolean hal_util_get_driver_name (const char *sysfs_path, gchar *driver_name);
+
 gboolean hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path);
 
 HalDevice *hal_util_find_closest_ancestor (const gchar *sysfs_path);

Index: physdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/physdev.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- physdev.c	25 Mar 2005 03:24:51 -0000	1.16
+++ physdev.c	27 Jun 2005 19:13:03 -0000	1.17
@@ -841,6 +841,365 @@
 
 /*--------------------------------------------------------------------------------------------------------------*/
 
+static inline void
+ccw_add_dasd_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	const gchar *disc;
+	
+	hal_util_set_int_from_file (d, "ccw.dasd.use_diag", sysfs_path,
+				    "use_diag", 2);
+	hal_util_set_int_from_file (d, "ccw.dasd.readonly", sysfs_path,
+				    "readonly", 2);
+	disc = hal_util_get_string_from_file (sysfs_path, "discipline");
+	if (disc)
+		hal_device_property_set_string(d, "ccw.dasd.discipline", disc);
+}
+
+static inline void
+ccw_add_zfcp_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	int online;
+
+	/* zfcp adapter properties are only valid for online devices. */
+	if (!hal_util_get_int_from_file (sysfs_path, "online", &online, 2))
+		return;
+	if (!online)
+		return;
+
+	hal_util_set_int_from_file (d, "ccw.zfcp.in_recovery", sysfs_path,
+				    "in_recovery", 2);
+	hal_util_set_int_from_file (d, "ccw.zfcp.failed", sysfs_path,
+				    "failed", 2);
+}
+
+static inline void
+ccw_add_tape_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	int medium_state, online;
+
+	const gchar *state_text[3] = {"unknown", "loaded", "no medium"};
+
+	hal_util_set_string_from_file (d, "ccw.tape.state", sysfs_path, "state");
+	hal_util_set_string_from_file (d, "ccw.tape.operation", sysfs_path,
+				       "operation");
+	/* The following properties are only valid for online devices. */
+	if (!hal_util_get_int_from_file (sysfs_path, "online", &online, 2))
+		return;
+	if (!online)
+		return;
+	hal_util_set_int_from_file (d, "ccw.tape.blocksize", sysfs_path,
+				    "blocksize", 10);
+	if (!hal_util_get_int_from_file (sysfs_path, "medium_state",
+					&medium_state, 10))
+		return;
+	hal_device_property_set_string (d, "tape.ccw.medium_state",
+					state_text[medium_state]);
+}
+
+static inline void
+ccw_add_3270_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	hal_util_set_int_from_file (d, "ccw.3270.model", sysfs_path,
+				    "model", 10);
+	hal_util_set_int_from_file (d, "ccw.3270.rows", sysfs_path, "rows", 10);
+	hal_util_set_int_from_file (d, "ccw.3270.columns", sysfs_path,
+				    "columns", 10);
+}
+
+static HalDevice *
+ccw_add (const gchar *sysfs_path, HalDevice *parent)
+{
+	HalDevice *d;
+	const gchar *bus_id;
+	const gchar *pimpampom;
+	int pim, pam, pom;
+	const gchar *chpids;
+	int chpid[8];
+	gchar attr[25];
+	int i;
+	gchar driver_name[256];
+
+	bus_id = hal_util_get_last_element (sysfs_path);
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "linux.sysfs_path_device",
+					sysfs_path);
+	hal_device_property_set_string (d, "info.bus", "ccw");
+	if (parent != NULL)
+                hal_device_property_set_string (d, "info.parent", parent->udi);
+        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, "ccw.bus_id", bus_id);
+	hal_util_set_int_from_file (d, "ccw.online", sysfs_path, "online", 2);
+	hal_util_set_string_from_file (d, "ccw.availablity", sysfs_path,
+				       "availability");
+	hal_util_set_int_from_file (d, "ccw.cmb_enable", sysfs_path,
+				    "cmb_enable", 2);
+	hal_util_set_string_from_file (d, "ccw.cutype", sysfs_path, "cutype");
+	hal_util_set_string_from_file (d, "ccw.devtype", sysfs_path, "devtype");
+
+	/* Get some values from the higher level subchannel structure.*/
+	pimpampom = hal_util_get_string_from_file (sysfs_path, "../pimpampom");
+	if (pimpampom) {
+		sscanf (pimpampom, "%x %x %x", &pim, &pam, &pom);
+		hal_device_property_set_int (d, "ccw.subchannel.pim", pim);
+		hal_device_property_set_int (d, "ccw.subchannel.pam", pam);
+		hal_device_property_set_int (d, "ccw.subchannel.pom", pom);
+	}
+
+	chpids = hal_util_get_string_from_file (sysfs_path, "../chpids");
+	if (chpids) {
+		sscanf (chpids, "%x %x %x %x %x %x %x %x", &chpid[0], &chpid[1],
+			&chpid[2], &chpid[3], &chpid[4], &chpid[5], &chpid[6],
+			&chpid[7]);
+		for (i=0; i<8 && (chpid[i] != 0); i++) {
+			g_snprintf (attr, sizeof (attr),
+				    "ccw.subchannel.chpid%x", i);
+			hal_device_property_set_int (d, attr, chpid[i]);
+		}
+	}
+
+	/* Add some special properties. */
+	if (hal_util_get_driver_name (sysfs_path, driver_name)) {
+		if (!strncmp (driver_name, "dasd", 4))
+			/* Same attributes for dasd_eckd and dasd_fba. */
+			ccw_add_dasd_properties (d, sysfs_path);
+		if (!strncmp (driver_name, "zfcp", 4))
+			ccw_add_zfcp_properties (d, sysfs_path);
+		if (!strncmp (driver_name, "tape_3", 6))
+			/* For all channel attached tapes. */
+			ccw_add_tape_properties (d, sysfs_path);
+		if (!strncmp (driver_name, "3270", 4))
+			ccw_add_3270_properties (d, sysfs_path);
+	}
+	return d;
+}
+
+static gboolean
+ccw_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/ccw_%s",
+			      hal_device_property_get_string
+			      (d, "ccw.bus_id"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static inline void
+ccwgroup_add_qeth_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	int is_layer2;
+
+	/* Some attributes are not applicable for devices in layer2 mode. */
+	hal_util_get_int_from_file (sysfs_path, "layer2", &is_layer2, 2);
+
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.large_send",
+				       sysfs_path, "large_send");
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.card_type", sysfs_path,
+				       "card_type");
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.checksumming",
+				       sysfs_path, "checksumming");
+	if (!is_layer2) {
+		//CH: the next two are only valid for token ring devices
+		hal_util_set_int_from_file (d,
+					    "ccwgroup.qeth.canonical_macaddr",
+					    sysfs_path, "canonical_macaddr", 2);
+		hal_util_set_string_from_file (d,
+					       "ccwgroup.qeth.broadcast_mode",
+					       sysfs_path, "broadcast_mode");
+		hal_util_set_int_from_file (d, "ccwgroup.qeth.fake_broadcast",
+					    sysfs_path, "fake_broadcast", 2);
+		hal_util_set_int_from_file (d, "ccwgroup.qeth.fake_ll",
+					    sysfs_path, "fake_ll", 2);
+	}
+	hal_device_property_set_int (d, "ccwgroup.qeth.layer2", is_layer2);
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.portname", sysfs_path,
+				       "portname");
+	hal_util_set_int_from_file (d, "ccwgroup.qeth.portno", sysfs_path,
+				    "portno", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.qeth.buffer_count", sysfs_path,
+				    "buffer_count", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.qeth.add_hhlen", sysfs_path,
+				    "add_hhlen", 10);
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.priority_queueing",
+				       sysfs_path, "priority_queueing");
+	if (!is_layer2) {
+		hal_util_set_string_from_file (d, "ccwgroup.qeth.route4",
+					       sysfs_path, "route4");
+		hal_util_set_string_from_file (d, "ccwgroup.qeth.route6",
+					       sysfs_path, "route6");
+	}
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.state", sysfs_path,
+				       "state");
+}
+
+static inline void
+ccwgroup_add_ctc_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	//CH: use protocol descriptions?
+	hal_util_set_int_from_file (d, "ccwgroup.ctc.protocol", sysfs_path,
+				    "protocol", 2);
+	hal_util_set_string_from_file (d, "ccwgroup.ctc.type", sysfs_path,
+				       "type");
+	hal_util_set_int_from_file (d, "ccwgroup.ctc.buffer", sysfs_path,
+				    "buffer", 10);
+}
+
+static inline void
+ccwgroup_add_lcs_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	hal_util_set_int_from_file (d, "ccwgroup.lcs.portnumber", sysfs_path,
+				    "portno", 2);
+	hal_util_set_string_from_file (d, "ccwgroup.lcs.type", sysfs_path,
+				       "type");
+	hal_util_set_int_from_file (d, "ccwgroup.lcs.lancmd_timeout",
+				    sysfs_path, "lancmd_timeout", 10);
+}
+
+static inline void
+ccwgroup_add_claw_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	hal_util_set_string_from_file (d, "ccwgroup.claw.api_type", sysfs_path,
+				       "api_type");
+	hal_util_set_string_from_file (d, "ccwgroup.claw.adapter_name",
+				       sysfs_path, "adapter_name");
+	hal_util_set_string_from_file (d, "ccwgroup.claw.host_name", sysfs_path,
+				       "host_name");
+	hal_util_set_int_from_file (d, "ccwgroup.claw.read_buffer", sysfs_path,
+				    "read_buffer", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.claw.write_buffer", sysfs_path,
+				    "write_buffer", 10);
+}
+
+static HalDevice *
+ccwgroup_add (const gchar *sysfs_path, HalDevice *parent)
+{
+	HalDevice *d;
+	const gchar *bus_id;
+	gchar driver_name[256];
+
+	bus_id = hal_util_get_last_element (sysfs_path);
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "linux.sysfs_path_device",
+					sysfs_path);
+	hal_device_property_set_string (d, "info.bus", "ccwgroup");
+	if (parent != NULL)
+                hal_device_property_set_string (d, "info.parent", parent->udi);
+        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, "ccwgroup.bus_id", bus_id);
+	hal_util_set_int_from_file (d, "ccwgroup.online", sysfs_path,
+				    "online", 2);
+
+	/* Some devices have extra properties. */
+	if (hal_util_get_driver_name (sysfs_path, driver_name)) {
+		if (!strncmp (driver_name, "qeth", 4))
+			ccwgroup_add_qeth_properties (d, sysfs_path);
+		if (!strncmp (driver_name, "ctc", 3))
+			ccwgroup_add_ctc_properties (d, sysfs_path);
+		if (!strncmp (driver_name, "lcs", 3))
+			ccwgroup_add_lcs_properties (d, sysfs_path);
+		if (!strncmp (driver_name, "claw", 4))
+			ccwgroup_add_claw_properties (d, sysfs_path);
+	}
+	return d;
+}
+
+static gboolean
+ccwgroup_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/ccwgroup_%s",
+			      hal_device_property_get_string
+			      (d, "ccwgroup.bus_id"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static inline void
+iucv_add_netiucv_properties (HalDevice *d, const gchar *sysfs_path)
+{
+	hal_util_set_string_from_file (d, "iucv.netiucv.user", sysfs_path,
+				       "user");
+	hal_util_set_int_from_file (d, "iucv.netiucv.buffer", sysfs_path,
+				    "buffer", 10);
+}
+
+static HalDevice *
+iucv_add (const gchar *sysfs_path, HalDevice *parent)
+{
+	HalDevice *d;
+	const gchar *bus_id;
+	gchar driver_name[256];
+
+	bus_id = hal_util_get_last_element (sysfs_path);
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "linux.sysfs_path_device",
+					sysfs_path);
+	hal_device_property_set_string (d, "info.bus", "iucv");
+	if (parent != NULL)
+                hal_device_property_set_string (d, "info.parent", parent->udi);
+        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, "iucv.bus_id", bus_id);
+
+	if (hal_util_get_driver_name (sysfs_path, driver_name)) {
+		if (!strncmp (driver_name, "netiucv", 7))
+			iucv_add_netiucv_properties (d, sysfs_path);
+	}
+	return d;
+}
+
+static gboolean
+iucv_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/iucv_%s",
+			      hal_device_property_get_string
+			      (d, "iucv.bus_id"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
 static gboolean
 physdev_remove (HalDevice *d)
 {
@@ -919,7 +1278,29 @@
 	.compute_udi = ieee1394_compute_udi,
 	.remove      = physdev_remove
 };
-	
+
+
+/* s390 specific busses */	
+static PhysDevHandler physdev_handler_ccw = {
+	.subsystem   = "ccw",
+	.add         = ccw_add,
+	.compute_udi = ccw_compute_udi,
+	.remove      = physdev_remove
+};
+
+static PhysDevHandler physdev_handler_ccwgroup = {
+	.subsystem   = "ccwgroup",
+	.add         = ccwgroup_add,
+	.compute_udi = ccwgroup_compute_udi,
+	.remove      = physdev_remove
+};
+
+static PhysDevHandler physdev_handler_iucv = {
+	.subsystem   = "iucv",
+	.add         = iucv_add,
+	.compute_udi = iucv_compute_udi,
+	.remove      = physdev_remove
+};
 
 static PhysDevHandler *phys_handlers[] = {
 	&physdev_handler_pci,
@@ -931,6 +1312,9 @@
 	&physdev_handler_scsi,
 	&physdev_handler_mmc,
 	&physdev_handler_ieee1394,
+	&physdev_handler_ccw,
+	&physdev_handler_ccwgroup,
+	&physdev_handler_iucv,
 	NULL
 };
 




More information about the hal-commit mailing list