hal/hald/linux2 blockdev.c,1.34,1.35 osspec.c,1.43,1.44
David Zeuthen
david at freedesktop.org
Sun Feb 12 13:47:30 PST 2006
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv15287/hald/linux2
Modified Files:
blockdev.c osspec.c
Log Message:
2006-02-12 David Zeuthen <davidz at redhat.com>
* tools/hal-system-storage-unmount (MOUNT_POINT): Attempt to use
volume.mount_point if we cannot find
info.hal_mount.created_mount_point
* libhal/libhal.h: Export prototype for new function
libhal_ctx_get_dbus_connection()
* libhal/libhal.c (libhal_ctx_get_dbus_connection): New function
* hald/linux2/addons/addon-storage.c (force_unmount): Use a the
Unmount() hal method to lazy unmount
* hald/linux2/osspec.c (hald_udev_data): Ugh ugh ugh.. clear
buffer before receiving data from udev.. we didn't use to do this
and we got all sorts of weird side-effects since we'd for instance
pick up DEVNAME='/dev/sdb' and _then_ DEVNAME='/dev/sda1' for
/sys/block/sdb.. This was because this data was left in the buffer
from the old run. It now appears to work..
* hald/linux2/blockdev.c (force_unmount_cb): New function, pass
end_token to hal_util_callout_device_remove()
(force_unmount): Use the Unmount method call to lazy unmount, thus
making sure we don't block
(hotplug_event_begin_remove_blockdev): Pass end_token to force_unmount
and let that function invoke hal_util_callout_device_remove()
* hald/hald_dbus.c (hald_exec_method_cb, hald_exec_method): Make
this work for helpers using a direct connection to hald
(hald_dbus_filter_handle_methods): Pass local_interface to
hald_exec_method
* hald/valgrind-hald.sh, /debug-hald.sh: Update to use 'pwd' just
like run-hald.sh was updated
Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- blockdev.c 9 Feb 2006 17:41:22 -0000 1.34
+++ blockdev.c 12 Feb 2006 21:47:28 -0000 1.35
@@ -939,86 +939,49 @@
}
static void
-force_unmount (HalDevice *d)
+force_unmount_cb (HalDevice *d, guint32 exit_type,
+ gint return_code, gchar **error,
+ gpointer data1, gpointer data2)
{
- const char *storudi;
- HalDevice *stordev;
- const char *device_file;
- const char *device_mount_point;
- const char *umount_argv[4] = { "/bin/umount", "-l", NULL, NULL };
- char *umount_stdout;
- char *umount_stderr;
- int umount_exitcode;
+ void *end_token = (void *) data1;
- device_file = hal_device_property_get_string (d, "block.device");
- device_mount_point = hal_device_property_get_string (d, "volume.mount_point");
+ HAL_INFO (("force_unmount_cb for udi='%s', exit_type=%d, return_code=%d", d->udi, exit_type, return_code));
- HAL_INFO (("Entering... udi=%s device_file=%s mount_point=%s", d->udi, device_file, device_mount_point));
+ if (exit_type == HALD_RUN_SUCCESS && error != NULL &&
+ error[0] != NULL && error[1] != NULL) {
+ char *exp_name = NULL;
+ char *exp_detail = NULL;
- /* Only attempt to 'umount -l' if some hal policy piece are performing policy on the device */
- storudi = hal_device_property_get_string (d, "block.storage_device");
- if (storudi == NULL) {
- HAL_WARNING (("Could not get block.storage_device"));
- goto out;
- }
- stordev = hal_device_store_find (hald_get_gdl (), storudi);
- if (stordev == NULL) {
- HAL_WARNING (("Could not get device object for storage device"));
- goto out;
- } else {
- if ((!hal_device_has_property (stordev, "storage.policy.should_mount")) ||
- (!hal_device_property_get_bool (stordev, "storage.policy.should_mount"))) {
- HAL_WARNING (("storage device doesn't have storage.policy.should_mount"));
- goto out;
+ exp_name = error[0];
+ if (error[0] != NULL) {
+ exp_detail = error[1];
}
+ HAL_INFO (("failed with '%s' '%s'", exp_name, exp_detail));
}
- umount_argv[2] = device_mount_point;
+ hal_util_callout_device_remove (d, blockdev_callouts_remove_done, end_token, NULL);
- if (hal_device_has_property (d, "block.is_volume") &&
- hal_device_property_get_bool (d, "block.is_volume") &&
- hal_device_property_get_bool (d, "volume.is_mounted") &&
- device_mount_point != NULL &&
- strlen (device_mount_point) > 0) {
- HAL_INFO (("attempting /bin/umount -l %s", device_mount_point));
+}
- /* TODO: this is a bit dangerous; rather spawn async and do some timout on it */
+static void
+force_unmount (HalDevice *d, void *end_token)
+{
+ char *unmount_stdin;
+ char *extra_env[2];
- /* invoke umount */
- if (g_spawn_sync ("/",
- (char **) umount_argv,
- NULL,
- 0,
- NULL,
- NULL,
- &umount_stdout,
- &umount_stderr,
- &umount_exitcode, NULL) != TRUE) {
- HAL_ERROR (("Couldn't invoke /bin/umount"));
- }
+ extra_env[0] = "HAL_METHOD_INVOKED_BY_UID=0";
+ extra_env[1] = NULL;
- if (umount_exitcode != 0) {
- HAL_ERROR (("/bin/umount returned %d", umount_exitcode));
- } else {
- /* Tell clients we are going to unmount so they close
- * can files - otherwise this unmount is going to stall
- *
- * One candidate for catching this would be FAM - the
- * File Alteration Monitor
- *
- * Lazy unmount been in Linux since 2.4.11, so we're
- * homefree (but other kernels might not support this)
- */
- HAL_INFO (("Goint to emit VolumeUnmountForced('%s', '%s', TRUE)", device_file, device_mount_point));
- device_send_signal_condition (d,
- "VolumeUnmountForced",
- device_file);
- }
- } else {
- HAL_INFO (("Didn't want to unmount %s", device_file));
- }
-out:
- ;
+ HAL_INFO (("force_unmount for udi='%s'", d->udi));
+
+ unmount_stdin = "lazy\n";
+
+ hald_runner_run_method (d,
+ "hal-system-storage-unmount", extra_env,
+ unmount_stdin, TRUE,
+ 0,
+ force_unmount_cb,
+ end_token, NULL);
}
void
@@ -1133,10 +1096,10 @@
/* if we're mounted, then do a lazy unmount so the system can gracefully recover */
if (hal_device_property_get_bool (d, "volume.is_mounted")) {
- force_unmount (d);
+ force_unmount (d, end_token);
+ } else {
+ hal_util_callout_device_remove (d, blockdev_callouts_remove_done, end_token, NULL);
}
-
- hal_util_callout_device_remove (d, blockdev_callouts_remove_done, end_token, NULL);
}
out:
;
Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- osspec.c 24 Jan 2006 11:26:08 -0000 1.43
+++ osspec.c 12 Feb 2006 21:47:28 -0000 1.44
@@ -111,6 +111,8 @@
const char *action = NULL;
HotplugEvent *hotplug_event;
+ memset(buf, 0x00, sizeof (buf));
+
fd = g_io_channel_unix_get_fd (source);
iov.iov_base = &buf;
More information about the hal-commit
mailing list