hal: Branch 'master' - 2 commits
Joe Marcus Clarke
marcus at kemper.freedesktop.org
Sat Mar 15 11:35:10 PDT 2008
hald/freebsd/addons/addon-storage.c | 57 ++++++++++++++++++++++++------------
hald/freebsd/hf-util.c | 10 ++++--
hald/freebsd/hf-util.h | 2 -
3 files changed, 46 insertions(+), 23 deletions(-)
New commits:
commit 97d74d9cb524516c11d4442701891b09ad2ee116
Author: Joe Marcus Clarke <marcus at FreeBSD.org>
Date: Sat Mar 15 14:35:09 2008 -0400
properly escape the UDI
Since the code was changed to guarantee a unique UDI, FreeBSD UDIs are no
longer escaped properly. That is, space characters may cause hal programs
to abort. Fix this by chaning out slash escaping function to be a generic
escaping function.
diff --git a/hald/freebsd/hf-util.c b/hald/freebsd/hf-util.c
index 486ee09..9606360 100644
--- a/hald/freebsd/hf-util.c
+++ b/hald/freebsd/hf-util.c
@@ -263,7 +263,7 @@ hf_device_set_udi (HalDevice *device, const char *format, ...)
udi = g_strdup_vprintf(format, args);
va_end(args);
- safe_str = hf_str_no_slashes(udi);
+ safe_str = hf_str_escape(udi);
g_free(udi);
hf_device_set_full_udi(device, "/org/freedesktop/Hal/devices/%s", safe_str);
@@ -675,14 +675,18 @@ hf_device_store_match (HalDeviceStore *store, ...)
}
char *
-hf_str_no_slashes (const char *str)
+hf_str_escape (const char *str)
{
char *safe_str;
g_return_val_if_fail(str != NULL, NULL);
safe_str = g_strdup(str);
- safe_str = g_strdelimit(safe_str, "/", '_');
+ g_strcanon(safe_str,
+ "_"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "1234567890", '_');
return safe_str;
}
diff --git a/hald/freebsd/hf-util.h b/hald/freebsd/hf-util.h
index f272ae2..d4590ce 100644
--- a/hald/freebsd/hf-util.h
+++ b/hald/freebsd/hf-util.h
@@ -110,7 +110,7 @@ int hf_runner_run_sync (HalDevice *device, int timeout, const char *command_line
int hf_strv_find (char **strv, const char *elem);
-char *hf_str_no_slashes (const char *str);
+char *hf_str_escape (const char *str);
HalDevice *hf_device_store_match (HalDeviceStore *store, ...);
commit 836dbba3fa8b14bd05deb175d71dca61f3da98a7
Author: Joe Marcus Clarke <marcus at FreeBSD.org>
Date: Sat Mar 15 14:33:51 2008 -0400
check storage.media_check_enabled before polling the device
Adapt code from the Linux addon-storage to catch up with the recent fdi
changes. Now, a device will not be probed for media if its
storage.media_check_enabled property is TRUE.
diff --git a/hald/freebsd/addons/addon-storage.c b/hald/freebsd/addons/addon-storage.c
index ddef41b..140fcd7 100644
--- a/hald/freebsd/addons/addon-storage.c
+++ b/hald/freebsd/addons/addon-storage.c
@@ -150,6 +150,15 @@ hf_addon_storage_update (void)
return has_media;
}
+static void
+update_proc_title (const char *device, boolean polling_enabled)
+{
+ if (polling_enabled)
+ setproctitle("%s", device);
+ else
+ setproctitle("no polling on %s because it is explicitly disabled", device);
+}
+
int
main (int argc, char **argv)
{
@@ -157,6 +166,7 @@ main (int argc, char **argv)
char *removable;
char *bus;
char *driver;
+ boolean should_poll;
DBusConnection *connection;
if (! hfp_init(argc, argv))
@@ -186,9 +196,6 @@ main (int argc, char **argv)
if (! addon.parent)
goto end;
- /* give a meaningful process title for ps(1) */
- setproctitle("%s", addon.device_file);
-
addon.is_cdrom = ! strcmp(drive_type, "cdrom");
addon.is_scsi_removable = (! strcmp(bus, "scsi") ||
(! strcmp(bus, "usb") && (! strcmp(driver, "da") || ! strcmp(driver, "sa") ||
@@ -226,23 +233,35 @@ main (int argc, char **argv)
break;
}
- has_media = hf_addon_storage_update();
- if (has_media != addon.had_media)
- {
- /*
- * FIXME: if the media was removed, we should force-unmount
- * all its child volumes (see linux2/addons/addon-storage.c).
- * However, currently (FreeBSD 6.0) umount -f is broken and
- * can cause kernel panics. When I tried to umount -f a
- * flash card after removing it, it failed with EAGAIN. It
- * continued to fail after I inserted the card. The system
- * then hung while rebooting and did not unmount my other
- * filesystems.
- */
+ should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error);
+ dbus_error_free(&hfp_error);
+ update_proc_title(addon.device_file, should_poll);
- libhal_device_rescan(hfp_ctx, hfp_udi, &hfp_error);
- dbus_error_free(&hfp_error);
- addon.had_media = has_media;
+ if (should_poll)
+ {
+ has_media = hf_addon_storage_update();
+ if (has_media != addon.had_media)
+ {
+ /*
+ * FIXME: if the media was removed, we should force-unmount
+ * all its child volumes (see linux2/addons/addon-storage.c).
+ * However, currently (FreeBSD 6.0) umount -f is broken and
+ * can cause kernel panics. When I tried to umount -f a
+ * flash card after removing it, it failed with EAGAIN. It
+ * continued to fail after I inserted the card. The system
+ * then hung while rebooting and did not unmount my other
+ * filesystems.
+ */
+
+ libhal_device_rescan(hfp_ctx, hfp_udi, &hfp_error);
+ dbus_error_free(&hfp_error);
+ addon.had_media = has_media;
+ }
+ }
+ else
+ {
+ hfp_gettimeofday(&addon.next_update);
+ hfp_timevaladd(&addon.next_update, &addon.update_interval);
}
}
More information about the hal-commit
mailing list