Add a couple of more errors
authorDavid Zeuthen <davidz@redhat.com>
Mon, 25 Oct 2010 20:02:34 +0000 (16:02 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Mon, 25 Oct 2010 20:02:34 +0000 (16:02 -0400)
Signed-off-by: David Zeuthen <davidz@redhat.com>
src/udisksfilesystemimpl.c
udisks/udisksenums.h
udisks/udiskserror.c

index a05a538..6712862 100644 (file)
@@ -542,7 +542,7 @@ calculate_mount_options (UDisksBlockDevice         *block,
         {
           g_set_error (error,
                        UDISKS_ERROR,
-                       UDISKS_ERROR_FAILED,
+                       UDISKS_ERROR_OPTION_NOT_PERMITTED,
                        "Malformed mount option `%s'",
                        option);
           g_string_free (str, TRUE);
@@ -554,7 +554,7 @@ calculate_mount_options (UDisksBlockDevice         *block,
         {
           g_set_error (error,
                        UDISKS_ERROR,
-                       UDISKS_ERROR_FAILED,
+                       UDISKS_ERROR_OPTION_NOT_PERMITTED,
                        "Mount option `%s' is not allowed",
                        option);
           g_string_free (str, TRUE);
@@ -779,7 +779,7 @@ handle_mount (UDisksFilesystem       *filesystem,
         }
       g_dbus_method_invocation_return_error (invocation,
                                              UDISKS_ERROR,
-                                             UDISKS_ERROR_FAILED,
+                                             UDISKS_ERROR_ALREADY_MOUNTED,
                                              "Device %s is already mounted at %s.\n",
                                              udisks_block_device_get_device (block),
                                              str->str);
@@ -1053,7 +1053,7 @@ handle_unmount (UDisksFilesystem       *filesystem,
         {
           g_dbus_method_invocation_return_error (invocation,
                                                  UDISKS_ERROR,
-                                                 UDISKS_ERROR_FAILED,
+                                                 UDISKS_ERROR_OPTION_NOT_PERMITTED,
                                                  "Unsupported option `%s'",
                                                  option);
           goto out;
@@ -1065,7 +1065,7 @@ handle_unmount (UDisksFilesystem       *filesystem,
     {
       g_dbus_method_invocation_return_error (invocation,
                                              UDISKS_ERROR,
-                                             UDISKS_ERROR_FAILED,
+                                             UDISKS_ERROR_NOT_MOUNTED,
                                              "Device `%s' is not mounted",
                                              udisks_block_device_get_device (block));
       goto out;
@@ -1114,7 +1114,7 @@ handle_unmount (UDisksFilesystem       *filesystem,
       /* TODO: allow with special authorization (unmount-others) */
       g_dbus_method_invocation_return_error (invocation,
                                              UDISKS_ERROR,
-                                             UDISKS_ERROR_FAILED,
+                                             UDISKS_ERROR_MOUNTED_BY_OTHER_USER,
                                              "Cannot unmount filesystem at `%s' mounted by other user with uid %d",
                                              mount_point,
                                              mounted_by_uid);
@@ -1126,7 +1126,7 @@ handle_unmount (UDisksFilesystem       *filesystem,
     {
       g_dbus_method_invocation_return_error (invocation,
                                              UDISKS_ERROR,
-                                             UDISKS_ERROR_FAILED,
+                                             UDISKS_ERROR_ALREADY_UNMOUNTING,
                                              "Cannot unmount %s: Mount point `%s' is currently being unmounted",
                                              udisks_block_device_get_device (block),
                                              mount_point);
index 2985c63..f2a5e8d 100644 (file)
@@ -36,6 +36,11 @@ G_BEGIN_DECLS
  * @UDISKS_ERROR_ALREADY_CANCELLED: The operation has already been cancelled.
  * @UDISKS_ERROR_NOT_AUTHORIZED: Not authorized to perform the requested operation.
  * @UDISKS_ERROR_NOT_AUTHORIZED_CAN_OBTAIN: Like %UDISKS_ERROR_NOT_AUTHORIZED but authorization can be obtained through e.g. authentication.
+ * @UDISKS_ERROR_ALREADY_MOUNTED: The device is already mounted.
+ * @UDISKS_ERROR_NOT_MOUNTED: The device is not mounted.
+ * @UDISKS_ERROR_OPTION_NOT_PERMITTED: Not permitted to use the requested option.
+ * @UDISKS_ERROR_MOUNTED_BY_OTHER_USER: The device is mounted by another user.
+ * @UDISKS_ERROR_ALREADY_UNMOUNTING: The device is already unmounting.
  *
  * Error codes for the #UDISKS_ERROR error domain and the
  * corresponding D-Bus error names.
@@ -46,10 +51,15 @@ typedef enum
   UDISKS_ERROR_CANCELLED,                  /* org.freedesktop.UDisks.Error.Cancelled */
   UDISKS_ERROR_ALREADY_CANCELLED,          /* org.freedesktop.UDisks.Error.AlreadyCancelled */
   UDISKS_ERROR_NOT_AUTHORIZED,             /* org.freedesktop.UDisks.Error.NotAuthorized */
-  UDISKS_ERROR_NOT_AUTHORIZED_CAN_OBTAIN   /* org.freedesktop.UDisks.Error.NotAuthorizedCanObtain */
+  UDISKS_ERROR_NOT_AUTHORIZED_CAN_OBTAIN,  /* org.freedesktop.UDisks.Error.NotAuthorizedCanObtain */
+  UDISKS_ERROR_ALREADY_MOUNTED,            /* org.freedesktop.UDisks.Error.AlreadyMounted */
+  UDISKS_ERROR_NOT_MOUNTED,                /* org.freedesktop.UDisks.Error.NotMounted */
+  UDISKS_ERROR_OPTION_NOT_PERMITTED,       /* org.freedesktop.UDisks.Error.OptionNotPermitted */
+  UDISKS_ERROR_MOUNTED_BY_OTHER_USER,      /* org.freedesktop.UDisks.Error.MountedByOtherUser */
+  UDISKS_ERROR_ALREADY_UNMOUNTING          /* org.freedesktop.UDisks.Error.AlreadyUnmounting */
 } UDisksError;
 
-#define UDISKS_ERROR_NUM_ENTRIES  (UDISKS_ERROR_NOT_AUTHORIZED_CAN_OBTAIN + 1)
+#define UDISKS_ERROR_NUM_ENTRIES  (UDISKS_ERROR_ALREADY_UNMOUNTING + 1)
 
 G_END_DECLS
 
index adbd612..adb4109 100644 (file)
@@ -37,6 +37,11 @@ static const GDBusErrorEntry dbus_error_entries[] =
   {UDISKS_ERROR_ALREADY_CANCELLED,            "org.freedesktop.UDisks.Error.AlreadyCancelled"},
   {UDISKS_ERROR_NOT_AUTHORIZED,               "org.freedesktop.UDisks.Error.NotAuthorized"},
   {UDISKS_ERROR_NOT_AUTHORIZED_CAN_OBTAIN,    "org.freedesktop.UDisks.Error.NotAuthorizedCanObtain"},
+  {UDISKS_ERROR_ALREADY_MOUNTED,              "org.freedesktop.UDisks.Error.AlreadyMounted"},
+  {UDISKS_ERROR_NOT_MOUNTED,                  "org.freedesktop.UDisks.Error.NotMounted"},
+  {UDISKS_ERROR_OPTION_NOT_PERMITTED,         "org.freedesktop.UDisks.Error.OptionNotPermitted"},
+  {UDISKS_ERROR_MOUNTED_BY_OTHER_USER,        "org.freedesktop.UDisks.Error.MountedByOtherUser"},
+  {UDISKS_ERROR_ALREADY_UNMOUNTING,           "org.freedesktop.UDisks.Error.AlreadyUnmounting"}
 };
 
 GQuark