From a99d9cc5bd8ed75e314584087d8fdec68b571c80 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 28 Oct 2009 15:30:40 +0100 Subject: [PATCH 6/6] =?utf-8?q?Bug=2024718=20=E2=80=94=20Proper=20handling=20of=20missing=20mkfs.*/fsck.*?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Introduce two new errors: org.freedesktop.DeviceKit.Disks.Error.FilesystemDriverMissing org.freedesktop.DeviceKit.Disks.Error.FilesystemToolsMissing which are thrown instead of a general Error.Failed when file system tools (such as mkfs. or xfs_admin) are not installed, or the kernel does not support the fs type for FilesystemMount(). Note that this does not yet cover a missing cryptsetup. --- data/org.freedesktop.DeviceKit.Disks.Device.xml | 5 +++++ src/devkit-disks-daemon.c | 2 ++ src/devkit-disks-daemon.h | 2 ++ src/devkit-disks-device.c | 15 +++++++++++++++ src/job-change-filesystem-label.c | 1 + src/job-mkfs.c | 2 ++ 6 files changed, 27 insertions(+), 0 deletions(-) diff --git a/data/org.freedesktop.DeviceKit.Disks.Device.xml b/data/org.freedesktop.DeviceKit.Disks.Device.xml index 0984f82..ddc3caa 100644 --- a/data/org.freedesktop.DeviceKit.Disks.Device.xml +++ b/data/org.freedesktop.DeviceKit.Disks.Device.xml @@ -9,6 +9,8 @@ + + ]> @@ -456,6 +458,7 @@ if the device is busy if the operation failed if the job was cancelled + if mkfs for this type is not available @@ -501,6 +504,7 @@ if the device is busy and changing the label requires an unmounted file system if the operation failed if the job was cancelled + if the label changing tool for this file system type is not available @@ -553,6 +557,7 @@ if the operation failed if the job was cancelled if an invalid or malformed mount option was given + if the kernel driver for this file system type is not available diff --git a/src/devkit-disks-daemon.c b/src/devkit-disks-daemon.c index 926acd4..1c58ddb 100644 --- a/src/devkit-disks-daemon.c +++ b/src/devkit-disks-daemon.c @@ -170,6 +170,8 @@ devkit_disks_error_get_type (void) ENUM_ENTRY (DEVKIT_DISKS_ERROR_INVALID_OPTION, "InvalidOption"), ENUM_ENTRY (DEVKIT_DISKS_ERROR_NOT_SUPPORTED, "NotSupported"), ENUM_ENTRY (DEVKIT_DISKS_ERROR_ATA_SMART_WOULD_WAKEUP, "AtaSmartWouldWakeup"), + ENUM_ENTRY (DEVKIT_DISKS_ERROR_FILESYSTEM_DRIVER_MISSING, "FilesystemDriverMissing"), + ENUM_ENTRY (DEVKIT_DISKS_ERROR_FILESYSTEM_TOOLS_MISSING, "FilesystemToolsMissing"), { 0, 0, 0 } }; g_assert (DEVKIT_DISKS_NUM_ERRORS == G_N_ELEMENTS (values) - 1); diff --git a/src/devkit-disks-daemon.h b/src/devkit-disks-daemon.h index 3164734..edbeb09 100644 --- a/src/devkit-disks-daemon.h +++ b/src/devkit-disks-daemon.h @@ -60,6 +60,8 @@ typedef enum DEVKIT_DISKS_ERROR_INVALID_OPTION, DEVKIT_DISKS_ERROR_NOT_SUPPORTED, DEVKIT_DISKS_ERROR_ATA_SMART_WOULD_WAKEUP, + DEVKIT_DISKS_ERROR_FILESYSTEM_DRIVER_MISSING, + DEVKIT_DISKS_ERROR_FILESYSTEM_TOOLS_MISSING, DEVKIT_DISKS_NUM_ERRORS } DevkitDisksError; diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c index dbdc394..9263d4a 100644 --- a/src/devkit-disks-device.c +++ b/src/devkit-disks-device.c @@ -4569,6 +4569,11 @@ filesystem_mount_completed_cb (DBusGMethodInvocation *context, throw_error (context, DEVKIT_DISKS_ERROR_CANCELLED, "Job was cancelled"); + } else if (WEXITSTATUS (status) == 32) { + throw_error (context, + DEVKIT_DISKS_ERROR_FILESYSTEM_DRIVER_MISSING , + "Error mounting: %s", + stderr); } else { throw_error (context, DEVKIT_DISKS_ERROR_FAILED, @@ -5736,6 +5741,11 @@ filesystem_create_completed_cb (DBusGMethodInvocation *context, throw_error (context, DEVKIT_DISKS_ERROR_CANCELLED, "Job was cancelled"); + } else if (WEXITSTATUS (status) == 3) { + throw_error (context, + DEVKIT_DISKS_ERROR_FILESYSTEM_TOOLS_MISSING , + "Error creating file system: Cannot run mkfs: %s", + stderr); } else { throw_error (context, DEVKIT_DISKS_ERROR_FAILED, @@ -7743,6 +7753,11 @@ filesystem_set_label_completed_cb (DBusGMethodInvocation *context, throw_error (context, DEVKIT_DISKS_ERROR_CANCELLED, "Job was cancelled"); + } else if (WEXITSTATUS (status) == 3) { + throw_error (context, + DEVKIT_DISKS_ERROR_FILESYSTEM_TOOLS_MISSING , + "Error changing fs label: tool not available: %s", + stderr); } else { throw_error (context, DEVKIT_DISKS_ERROR_FAILED, diff --git a/src/job-change-filesystem-label.c b/src/job-change-filesystem-label.c index e2847a4..d21bcb4 100644 --- a/src/job-change-filesystem-label.c +++ b/src/job-change-filesystem-label.c @@ -101,6 +101,7 @@ main (int argc, char **argv) &error)) { g_printerr ("cannot spawn '%s': %s\n", command_line, error->message); g_error_free (error); + ret = 3; /* indicate FilesystemToolsMissing error */ goto out; } if (WEXITSTATUS (exit_status) != 0) { diff --git a/src/job-mkfs.c b/src/job-mkfs.c index 43b9be9..15f0971 100644 --- a/src/job-mkfs.c +++ b/src/job-mkfs.c @@ -284,6 +284,7 @@ main (int argc, char **argv) &exit_status, &error)) { g_printerr ("cannot spawn '%s': %s\n", command_line, error->message); + ret = 3; /* indicate FilesystemToolsMissing error */ g_error_free (error); goto out; } @@ -311,6 +312,7 @@ main (int argc, char **argv) &error)) { g_printerr ("cannot spawn '%s': %s\n", command_line, error->message); g_error_free (error); + ret = 3; /* indicate FilesystemToolsMissing error */ goto out; } if (WEXITSTATUS (exit_status) != 0) { -- 1.6.3.3