From 917847f8ce7cbe2df385b842196d27f07db2a5fc Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Tue, 24 Jun 2014 10:50:13 +0200 Subject: [PATCH] Fail before formating if partition contains partition table Formating procedure fails for partition containing partition table (e.g. Fedora hybrid iso). Consequently the device is in wrong state, so check it before modification and fail with understandable error message. https://bugs.freedesktop.org/show_bug.cgi?id=76178 --- src/udiskslinuxblock.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c index d619850..bf798ca 100644 --- a/src/udiskslinuxblock.c +++ b/src/udiskslinuxblock.c @@ -2174,6 +2174,19 @@ handle_format (UDisksBlock *block, if (partition != NULL) { UDisksObject *partition_table_object; + + /* Fail if partition contains partition table (e.g. Fedora Hybrid ISO). + * See: https://bugs.freedesktop.org/show_bug.cgi?id=76178 + */ + if (udisks_partition_get_offset (partition) == 0) + { + g_dbus_method_invocation_return_error (invocation, + UDISKS_ERROR, + UDISKS_ERROR_NOT_SUPPORTED, + "This partition cannot be modified because probably contains partition table, please reinitialize layout of the whole device."); + goto out; + } + partition_table_object = udisks_daemon_find_object (daemon, udisks_partition_get_table (partition)); if (partition_table_object == NULL) { -- 1.9.3