[parted-devel] [PATCH] libparted: remove device mapper node for last partition

Petr Uzel petr.uzel at suse.cz
Wed Jul 25 14:29:19 UTC 2012


This patch fixes the situation when last partition is removed
on device-mapper. In such case, ped_disk_get_last_partition_num()
returns 0 (the last partition is already gone), so
_dm_remove_parts() is not called at all and device-mapper node for
the last partition is not removed.

* libparted/arch/linux.c (_dm_reread_part_table): Call
_dm_remove_parts() unconditionally.
---
 libparted/arch/linux.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index e2c4139..3cb195e 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2854,18 +2854,19 @@ err:
 static int
 _dm_reread_part_table (PedDisk* disk)
 {
+        int     rc = 1;
+
+        sync();
+        if (!_dm_remove_parts(disk->dev))
+                rc = 0;
+
         int largest_partnum = ped_disk_get_last_partition_num (disk);
         if (largest_partnum <= 0)
           return 1;
 
-        int     rc = 1;
         int     last = PED_MIN (largest_partnum, 16);
         int     i;
 
-        sync();
-        if (!_dm_remove_parts(disk->dev))
-                rc = 0;
-
         for (i = 1; i <= last; i++) {
                 PedPartition*      part;
 
-- 
1.7.7




More information about the parted-devel mailing list