diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2006-02-02 13:06:32 +0000 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2006-02-02 13:06:32 +0000 |
commit | 9e52d76bb939d4f62b5f3192e1bd09bf14f00816 (patch) | |
tree | 66e9d4bd75b48fc41dcab1ecb16265364f926298 | |
parent | 2ecf6bec4e3b17fad46833b2f6111abda56b4013 (diff) |
Add "pseudo" bus to make it possible to use: modprobe scsi_debug num_tgts=5
add_host=5 num_parts=2
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | hald/linux2/physdev.c | 57 |
2 files changed, 61 insertions, 2 deletions
@@ -1,3 +1,9 @@ +2006-02-02 Kay Sievers <kay.sievers@vrfy.org> + + * hald/linux2/physdev.c: (pseudo_add), (pseudo_compute_udi): + Add "pseudo" bus to make it possible to use: + modprobe scsi_debug num_tgts=5 add_host=5 num_parts=2 + 2006-01-29 Richard Hughes <richard@hughsie.com> * doc/spec/hal-spec.xml.in, diff --git a/hald/linux2/physdev.c b/hald/linux2/physdev.c index 0792e9b8..24126191 100644 --- a/hald/linux2/physdev.c +++ b/hald/linux2/physdev.c @@ -1247,6 +1247,51 @@ iucv_compute_udi (HalDevice *d) /*--------------------------------------------------------------------------------------------------------------*/ +static HalDevice * +pseudo_add (const gchar *sysfs_path, HalDevice *parent) +{ + HalDevice *d; + const gchar *dev_id; + gchar buf[64]; + + 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", "pseudo"); + 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); + + dev_id = hal_util_get_last_element (sysfs_path); + hal_device_property_set_string (d, "pseudo.id", dev_id); + + g_snprintf (buf, sizeof (buf), "SCSI Debug Device (%s)", hal_device_property_get_string (d, "pseudo.id")); + hal_device_property_set_string (d, "info.product", buf); + + return d; +} + +static gboolean +pseudo_compute_udi (HalDevice *d) +{ + gchar udi[256]; + + hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi), + "/org/freedesktop/Hal/devices/pseudo", + hal_device_property_get_string (d, "platform.id")); + hal_device_set_udi (d, udi); + hal_device_property_set_string (d, "info.udi", udi); + + return TRUE; + +} + +/*--------------------------------------------------------------------------------------------------------------*/ + static gboolean physdev_remove (HalDevice *d) { @@ -1333,8 +1378,7 @@ static PhysDevHandler physdev_handler_ieee1394 = { .remove = physdev_remove }; - -/* s390 specific busses */ +/* s390 specific busses */ static PhysDevHandler physdev_handler_ccw = { .subsystem = "ccw", .add = ccw_add, @@ -1356,6 +1400,14 @@ static PhysDevHandler physdev_handler_iucv = { .remove = physdev_remove }; +/* SCSI debug, to test thousends of fake devices */ +static PhysDevHandler physdev_handler_pseudo = { + .subsystem = "pseudo", + .add = pseudo_add, + .compute_udi = pseudo_compute_udi, + .remove = physdev_remove +}; + static PhysDevHandler *phys_handlers[] = { &physdev_handler_pci, &physdev_handler_usb, @@ -1370,6 +1422,7 @@ static PhysDevHandler *phys_handlers[] = { &physdev_handler_ccw, &physdev_handler_ccwgroup, &physdev_handler_iucv, + &physdev_handler_pseudo, NULL }; |