diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-03-23 03:31:15 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-03-23 03:31:15 +0800 |
commit | 9f466ea95f2bfe610ca998e367e7481acebd18d5 (patch) | |
tree | 382d5e2f5471a44458c64a25b2fb3540474001b5 | |
parent | 68fbe0addf1c73e15bc36dcbc3c54592dcdbfeb9 (diff) | |
download | marcuscom-ports-9f466ea95f2bfe610ca998e367e7481acebd18d5.tar marcuscom-ports-9f466ea95f2bfe610ca998e367e7481acebd18d5.tar.gz marcuscom-ports-9f466ea95f2bfe610ca998e367e7481acebd18d5.tar.bz2 marcuscom-ports-9f466ea95f2bfe610ca998e367e7481acebd18d5.tar.lz marcuscom-ports-9f466ea95f2bfe610ca998e367e7481acebd18d5.tar.xz marcuscom-ports-9f466ea95f2bfe610ca998e367e7481acebd18d5.tar.zst marcuscom-ports-9f466ea95f2bfe610ca998e367e7481acebd18d5.zip |
Register support for the CheckForMedia dbus message so that we can force
a poll of devices.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@10808 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r-- | sysutils/hal/Makefile | 4 | ||||
-rw-r--r-- | sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c | 130 |
2 files changed, 128 insertions, 6 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile index 7374b3cc7..ed9b51962 100644 --- a/sysutils/hal/Makefile +++ b/sysutils/hal/Makefile @@ -3,12 +3,12 @@ # Whom: Joe Marcus Clarke <marcus@FreeBSD.org> # # $FreeBSD$ -# $MCom: ports/sysutils/hal/Makefile,v 1.41 2008/03/18 07:39:54 marcus Exp $ +# $MCom: ports/sysutils/hal/Makefile,v 1.42 2008/03/18 20:05:55 marcus Exp $ # PORTNAME= hal DISTVERSION= 0.5.11rc2 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= sysutils MASTER_SITES= http://hal.freedesktop.org/releases/ diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c index 460927eb6..ebeeb072c 100644 --- a/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c +++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c @@ -1,13 +1,135 @@ ---- hald/freebsd/addons/addon-storage.c.orig 2008-03-18 03:37:34.000000000 -0400 -+++ hald/freebsd/addons/addon-storage.c 2008-03-18 03:34:58.000000000 -0400 -@@ -202,6 +202,10 @@ main (int argc, char **argv) +--- hald/freebsd/addons/addon-storage.c.orig 2008-03-17 17:25:16.000000000 -0400 ++++ hald/freebsd/addons/addon-storage.c 2008-03-22 03:25:19.000000000 -0400 +@@ -150,6 +150,34 @@ hf_addon_storage_update (void) + return has_media; + } + ++static boolean ++poll_for_media (void) ++{ ++ boolean has_media; ++ ++ 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; ++ ++ return TRUE; ++ } ++ return FALSE; ++} ++ + static void + update_proc_title (const char *device, boolean polling_enabled) + { +@@ -159,6 +187,29 @@ update_proc_title (const char *device, b + setproctitle("no polling on %s because it is explicitly disabled", device); + } + ++static DBusHandlerResult ++filter_function (DBusConnection *connection, DBusMessage *message, void *user_data) ++{ ++ if (dbus_message_is_method_call(message, ++ "org.freedesktop.Hal.Device.Storage.Removable", ++ "CheckForMedia")) ++ { ++ DBusMessage *reply; ++ dbus_bool_t had_effect; ++ ++ hfp_info("Forcing poll for media becusse CheckForMedia() was called"); ++ ++ had_effect = poll_for_media(); ++ ++ reply = dbus_message_new_method_return (message); ++ dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &had_effect, DBUS_TYPE_INVALID); ++ dbus_connection_send(connection, reply, NULL); ++ dbus_message_unref(reply); ++ } ++ ++ return DBUS_HANDLER_RESULT_HANDLED; ++} ++ + int + main (int argc, char **argv) + { +@@ -202,13 +253,30 @@ main (int argc, char **argv) ! strcmp(driver, "cd")))) && ! strcmp(removable, "true"); addon.had_media = hf_addon_storage_update(); -+ if (!libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error)) ++ if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error)) + goto end; + dbus_error_free(&hfp_error); + connection = libhal_ctx_get_dbus_connection(hfp_ctx); assert(connection != NULL); ++ dbus_connection_set_exit_on_disconnect(connection, 0); ++ dbus_connection_add_filter(connection, filter_function, NULL, NULL); + +- while (TRUE) ++ if (! libhal_device_claim_interface(hfp_ctx, ++ hfp_udi, ++ "org.freedesktop.Hal.Device.Storage.Removable", ++ " <method name=\"CheckForMedia\">\n" ++ " <arg name=\"call_had_sideeffect\" direction=\"out\" type=\"b\"/>\n" ++ " </method>\n", ++ &hfp_error)) + { +- boolean has_media; ++ hfp_critical("Cannot claim interface 'org.freedesktop.Hal.Device.Storage.Removable'"); ++ goto end; ++ } ++ dbus_error_free(&hfp_error); + ++ while (TRUE) ++ { + /* process dbus traffic until update interval has elapsed */ + while (TRUE) + { +@@ -225,7 +293,7 @@ main (int argc, char **argv) + if (timeout.tv_sec < 0) /* current time went backwards */ + timeout = addon.update_interval; + +- dbus_connection_read_write(connection, timeout.tv_sec * 1000 + timeout.tv_usec / 1000); ++ dbus_connection_read_write_dispatch(connection, timeout.tv_sec * 1000 + timeout.tv_usec / 1000); + if (! dbus_connection_get_is_connected(connection)) + goto end; + } +@@ -239,24 +307,7 @@ main (int argc, char **argv) + 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; +- } ++ poll_for_media(); + } + else + { |