hal/hald/linux block_class_device.c,1.66,1.67
David Zeuthen
david at freedesktop.org
Tue Aug 31 09:53:44 PDT 2004
Update of /cvs/hal/hal/hald/linux
In directory gabe:/tmp/cvs-serv15769/hald/linux
Modified Files:
block_class_device.c
Log Message:
2004-08-31 David Zeuthen <david at fubar.dk>
* hald/linux/block_class_device.c:
(detect_media): Don't poll on drives with storage.removable set to FALSE
(block_class_pre_process): Use the /sys/block/<drive>/removable file
* tools/device-manager/DeviceManager.py: Don't print out Conditions;
should give us more headroom until D-BUS is fixed wrt. rules maximum
and subscription of signals in the python bindings
* tools/linux/hal_hotplug.c: Wait for 'removable' file for 'block'
system events
Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- block_class_device.c 29 Aug 2004 15:57:41 -0000 1.66
+++ block_class_device.c 31 Aug 2004 16:53:33 -0000 1.67
@@ -723,6 +723,10 @@
!hal_device_property_get_bool (d, "storage.media_check_enabled"))
return FALSE;
+ /* Refuse to poll on storage devices without removable media */
+ if (!force_poll && !hal_device_property_get_bool (d, "storage.removable"))
+ return FALSE;
+
/* need to be in GDL */
if (!hal_device_store_find (hald_get_gdl (), hal_device_get_udi (d)))
return FALSE;
@@ -1070,6 +1074,8 @@
const char *device_file;
dbus_bool_t has_removable_media = FALSE;
dbus_bool_t is_hotpluggable = FALSE;
+ char attr_path[SYSFS_PATH_MAX];
+ struct sysfs_attribute *attr;
parent = hal_device_store_find (hald_get_gdl (),
hal_device_property_get_string (
@@ -1361,8 +1367,6 @@
const char *device_file;
struct drive_id *did;
const char *sysfs_path;
- char attr_path[SYSFS_PATH_MAX];
- struct sysfs_attribute *attr;
int scsi_host;
char *scsi_protocol;
@@ -1485,15 +1489,21 @@
hal_device_property_set_string (d, "info.product", "Disk");
}
+
+ snprintf (attr_path, SYSFS_PATH_MAX, "%s/removable", sysfs_path);
+ attr = sysfs_open_attribute (attr_path);
+ if (sysfs_read_attribute (attr) >= 0) {
+ if (attr->value [0] == '0')
+ has_removable_media = FALSE;
+ else
+ has_removable_media = TRUE;
+
+ sysfs_close_attribute (attr);
+ }
+
+
-
- /* XYZME: Read the removable file in sysfs,
- * e.g. /sys/block/sdb/removable
- */
- hal_device_property_set_bool (
- stordev,
- "storage.removable",
- has_removable_media);
+ hal_device_property_set_bool (stordev, "storage.removable", has_removable_media);
if (hal_device_has_property (stordev, "storage.drive_type") &&
strcmp (hal_device_property_get_string (stordev, "storage.drive_type"),
More information about the hal-commit
mailing list