Unmount a mounted device.
- If the filesystem is busy, this operation fails unless the
- option <parameter>force</parameter> is given.
+ If the filesystem is busy, this operation fails with the error
+ <link linkend="UDISKS-ERROR-DEVICE-BUSY:CAPS"><constant>org.freedesktop.UDisks.Error.DeviceBusy</constant></link>
+ unless the option <parameter>force</parameter> is used.
If the device in question is referenced in a system-wide
configuration file (such as the <filename>/etc/fstab</filename> file)
<citerefentry><refentrytitle>umount</refentrytitle><manvolnum>8</manvolnum></citerefentry>
command is invoked as root.
-->
- <method name="Unmount">
+<method name="Unmount">
<arg name="options" direction="in" type="a{sv}"/>
</method>
</interface>
/* ---------------------------------------------------------------------------------------------------- */
+static guint
+get_error_code_for_umount (gint exit_status,
+ const gchar *error_message)
+{
+ if (strstr (error_message, "device is busy") != NULL)
+ return UDISKS_ERROR_DEVICE_BUSY;
+ else
+ return UDISKS_ERROR_FAILED;
+}
+
/* runs in thread dedicated to handling @invocation */
static gboolean
handle_unmount (UDisksFilesystem *filesystem,
GError *error;
uid_t mounted_by_uid;
uid_t caller_uid;
+ gint status;
gchar *error_message;
const gchar *const *mount_points;
gboolean opt_force;
*/
if (system_managed)
{
- gint status;
gboolean unmount_fstab_as_root;
unmount_fstab_as_root = FALSE;
g_dbus_method_invocation_return_error (invocation,
UDISKS_ERROR,
- UDISKS_ERROR_FAILED,
+ get_error_code_for_umount (status, error_message),
"Error unmounting system-managed device %s: %s",
udisks_block_get_device (block),
error_message);
NULL, /* GCancellable */
0, /* uid_t run_as_uid */
0, /* uid_t run_as_euid */
- NULL, /* gint *out_status */
+ &status,
&error_message,
NULL, /* input_string */
"umount %s \"%s\"",
{
g_dbus_method_invocation_return_error (invocation,
UDISKS_ERROR,
- UDISKS_ERROR_FAILED,
+ get_error_code_for_umount (status, error_message),
"Error unmounting %s: %s",
udisks_block_get_device (block),
error_message);
* @UDISKS_ERROR_NOT_SUPPORTED: The operation is not supported due to missing driver/tool support.
* @UDISKS_ERROR_TIMED_OUT: The operation timed out.
* @UDISKS_ERROR_WOULD_WAKEUP: The operation would wake up a disk that is in a deep-sleep state.
+ * @UDISKS_ERROR_DEVICE_BUSY: Attempting to unmount a device that is busy.
*
* Error codes for the #UDISKS_ERROR error domain and the
* corresponding D-Bus error names.
UDISKS_ERROR_NOT_SUPPORTED, /* org.freedesktop.UDisks.Error.NotSupported */
UDISKS_ERROR_TIMED_OUT, /* org.freedesktop.UDisks.Error.Timedout */
UDISKS_ERROR_WOULD_WAKEUP, /* org.freedesktop.UDisks.Error.WouldWakeup */
+ UDISKS_ERROR_DEVICE_BUSY /* org.freedesktop.UDisks.Error.DeviceBusy */
} UDisksError;
-#define UDISKS_ERROR_NUM_ENTRIES (UDISKS_ERROR_WOULD_WAKEUP + 1)
+#define UDISKS_ERROR_NUM_ENTRIES (UDISKS_ERROR_DEVICE_BUSY + 1)
G_END_DECLS
{UDISKS_ERROR_NOT_SUPPORTED, "org.freedesktop.UDisks.Error.NotSupported"},
{UDISKS_ERROR_TIMED_OUT, "org.freedesktop.UDisks.Error.Timedout"},
{UDISKS_ERROR_WOULD_WAKEUP, "org.freedesktop.UDisks.Error.WouldWakeup"},
+ {UDISKS_ERROR_DEVICE_BUSY, "org.freedesktop.UDisks.Error.DeviceBusy"},
};
GQuark