[9/13] Add support for the tape class.
Cornelia Huck
cohuck at de.ibm.com
Mon Jun 27 01:45:39 PDT 2005
[9/13] Add support for the tape class.
This comprises support for both the generic tape class and the tape390
class, as the two don't differ in anything but name.
classdev.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 72 insertions(+)
Index: hald/linux2/classdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/classdev.c,v
retrieving revision 1.26
diff -u -r1.26 classdev.c
--- hald/linux2/classdev.c 29 Mar 2005 20:25:13 -0000 1.26
+++ hald/linux2/classdev.c 23 Jun 2005 13:59:57 -0000
@@ -636,6 +642,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)
{
@@ -729,6 +785,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,
@@ -737,6 +813,8 @@
&classdev_handler_usbclass,
&classdev_handler_sound,
&classdev_handler_serial,
+ &classdev_handler_tape,
+ &classdev_handler_tape390,
NULL
};
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal
More information about the Hal
mailing list