summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hald/linux/blockdev.c56
-rw-r--r--hald/linux/probing/probe-volume.c10
2 files changed, 63 insertions, 3 deletions
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index c46d4fbc..ec4e4053 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -57,6 +57,34 @@
#include "blockdev.h"
+static gchar *
+strdup_valid_utf8 (const char *str)
+{
+ char *endchar;
+ char *newstr;
+ unsigned int fixes;
+
+ if (str == NULL)
+ return NULL;
+
+ newstr = g_strdup (str);
+
+ fixes = 0;
+ while (!g_utf8_validate (newstr, -1, (const char **) &endchar)) {
+ *endchar = '_';
+ ++fixes;
+ }
+
+ /* If we had to fix more than 20% of the characters, give up */
+ if (fixes > 0 && g_utf8_strlen (newstr, -1) / fixes < 5) {
+ g_free (newstr);
+ newstr = g_strdup("");
+ }
+
+ return newstr;
+}
+
+
/*--------------------------------------------------------------------------------------------------------------*/
static gboolean
@@ -1428,6 +1456,8 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
} else {
guint sysfs_path_len;
gboolean is_physical_partition;
+ char *volume_label;
+ char buf[64];
/*************************
*
@@ -1443,12 +1473,32 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
hal_device_property_set_string (d, "volume.uuid", "");
hal_device_property_set_string (d, "volume.label", "");
hal_device_property_set_string (d, "volume.mount_point", "");
+
+ /* persistent properties from udev (may be empty) */
+ hal_device_property_set_string (d, "volume.fsusage", hotplug_event->sysfs.fsusage);
+ hal_device_property_set_string (d, "volume.fsversion", hotplug_event->sysfs.fsversion);
+ hal_device_property_set_string (d, "volume.uuid", hotplug_event->sysfs.fsuuid);
+ hal_device_property_set_string (d, "volume.fstype", hotplug_event->sysfs.fstype);
+ if (hotplug_event->sysfs.fstype[0] != '\0') {
+ snprintf (buf, sizeof (buf), "Volume (%s)", hotplug_event->sysfs.fstype);
+ } else {
+ snprintf (buf, sizeof (buf), "Volume");
+ }
+ hal_device_property_set_string (d, "info.product", buf);
+
+ volume_label = strdup_valid_utf8 (hotplug_event->sysfs.fslabel);
+ if (volume_label) {
+ hal_device_property_set_string (d, "volume.label", volume_label);
+ if (volume_label[0] != '\0') {
+ hal_device_property_set_string (d, "info.product", volume_label);
+ }
+ g_free(volume_label);
+ }
+
hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
hal_device_property_set_bool (d, "volume.linux.is_device_mapper", is_device_mapper);
- hal_device_property_set_bool (
- d, "volume.is_disc",
- strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
+ hal_device_property_set_bool (d, "volume.is_disc", strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
is_physical_partition = TRUE;
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index d9ea48da..d298db29 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -316,6 +316,7 @@ main (int argc, char *argv[])
char *partition_number_str;
char *partition_start_str;
char *is_disc_str;
+ char *fsusage;
dbus_bool_t is_disc;
unsigned int partition_number;
guint64 partition_start;
@@ -364,6 +365,8 @@ main (int argc, char *argv[])
else
is_disc = FALSE;
+ fsusage = getenv ("HAL_PROP_VOLUME_FSUSAGE");
+
dbus_error_init (&error);
if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
goto out;
@@ -603,8 +606,15 @@ main (int argc, char *argv[])
}
}
+ if (fsusage != NULL && strlen(fsusage) > 0) {
+ HAL_DEBUG(("have already information about fsusage from udev, no need to probe for filesystem"));
+ should_probe_for_fs = FALSE;
+ }
+
if (should_probe_for_fs) {
+ HAL_DEBUG(("start probing for filesystem ..."));
+
if ((stordev_dev_file = libhal_device_get_property_string (
ctx, parent_udi, "block.device", &error)) == NULL) {
goto out;