1 Index: exo-mount/exo-mount-hal.c
2 ===================================================================
3 --- exo-mount/exo-mount-hal.c (revision 27040)
4 +++ exo-mount/exo-mount-hal.c (working copy)
9 + const gchar *backing_udi = NULL;
11 g_return_val_if_fail (device != NULL, FALSE);
12 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
14 + /* see if the udi is a crypto fs, in which case we'll have to tear down the crypto layer. */
15 + backing_udi = libhal_volume_crypto_get_backing_volume_udi(device->volume);
19 + /* never eject a LUKS-encrypted device */
20 + return exo_mount_hal_device_unmount(device, error);
23 /* allocate the D-Bus message for the "Eject" method */
24 message = dbus_message_new_method_call ("org.freedesktop.Hal", device->udi, "org.freedesktop.Hal.Device.Volume", "Eject");
25 if (G_UNLIKELY (message == NULL))
31 +exo_mount_teardown_crypto_volume(const gchar *udi, GError **error)
33 + DBusMessage *message = NULL;
34 + DBusMessage *result = NULL;
37 + message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
38 + "org.freedesktop.Hal.Device.Volume.Crypto",
41 + if (G_UNLIKELY (message == NULL))
44 +oom: g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM, g_strerror (ENOMEM));
48 + if (!dbus_message_append_args (message,
49 + DBUS_TYPE_INVALID)) {
50 + dbus_message_unref (message);
54 + dbus_error_init (&derror);
56 + result = dbus_connection_send_with_reply_and_block (dbus_connection, message, -1, &derror);
57 + if (G_LIKELY (result != NULL))
59 + /* check if an error was returned */
60 + if (dbus_message_get_type (result) == DBUS_MESSAGE_TYPE_ERROR)
61 + dbus_set_error_from_message (&derror, result);
63 + /* release the result */
64 + dbus_message_unref (result);
67 + /* release the message */
68 + dbus_message_unref (message);
70 + if (G_UNLIKELY (dbus_error_is_set (&derror)))
72 + /* try to translate the error appropriately */
73 + if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0)
75 + /* TRANSLATORS: The user tried to eject a device although he's not privileged to do so. */
76 + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("You are not privileged to teardown the crypto layer"));
78 + else if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.Busy") == 0)
80 + /* TRANSLATORS: An application is blocking a mounted volume from being ejected. */
81 + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("An application is preventing the crypto layer from being torn down"));
85 + /* no precise error message, use the HAL one */
86 + exo_mount_hal_propagate_error (error, &derror);
89 + /* release the DBus error */
90 + dbus_error_free (&derror);
98 * exo_mount_hal_device_unmount:
99 * @device : an #ExoMountHalDevice.
100 @@ -894,10 +969,14 @@
101 DBusMessage *message;
104 + const gchar *backing_udi = NULL;
106 g_return_val_if_fail (device != NULL, FALSE);
107 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
109 + /* see if the udi is a crypto fs, in which case we'll have to teardown the crypto layer. */
110 + backing_udi = libhal_volume_crypto_get_backing_volume_udi(device->volume);
112 /* allocate the D-Bus message for the "Unmount" method */
113 message = dbus_message_new_method_call ("org.freedesktop.Hal", device->udi, "org.freedesktop.Hal.Device.Volume", "Unmount");
114 if (G_UNLIKELY (message == NULL))
117 /* Ups, volume not mounted, we succeed! */
118 dbus_error_free (&derror);
124 @@ -968,6 +1047,11 @@
129 + if (G_UNLIKELY(backing_udi != NULL))
131 + return exo_mount_teardown_crypto_volume(backing_udi, error);