diff options
author | Phillip Susi <psusi@ubuntu.com> | 2014-04-26 20:52:25 -0400 |
---|---|---|
committer | Phillip Susi <psusi@ubuntu.com> | 2014-05-22 19:56:36 -0400 |
commit | 9e07d797b18609613c53ceb2dabbb5e69d961186 (patch) | |
tree | 5e2d4eda1e34cb4f039d8e459278424ff98c5339 /libparted | |
parent | 82eda230f252ddf2d5909eff3ab092c4af33eb60 (diff) | |
download | parted-9e07d797b18609613c53ceb2dabbb5e69d961186.tar.gz |
libparted: remove old partitions *first* before adding new ones
"libparted: avoid disturbing partitions" put the remove of the old
partition in second pass. If you simultaneously removed partitions 1
and 2, and created a new partition #1 that overlapped the previous second
partition, the sync would fail because it would try to create the new,
larger partition #1 before removing the old partition #2.
Diffstat (limited to 'libparted')
-rw-r--r-- | libparted/arch/linux.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index 71f5034..ced06a3 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -2855,23 +2855,8 @@ _disk_sync_part_table (PedDisk* disk) && start == part->geom.start && length == part->geom.length) { - ok[i - 1] = 1; - continue; - } - } - } - for (i = 1; i <= lpn; i++) { - PedPartition *part = ped_disk_get_partition (disk, i); - if (part) { - unsigned long long length; - unsigned long long start; - /* get start and length of existing partition */ - if (get_partition_start_and_length(part, - &start, &length) - && start == part->geom.start - && length == part->geom.length) { - ok[i - 1] = 1; /* partition is unchanged, so nothing to do */ + ok[i - 1] = 1; continue; } } @@ -2890,12 +2875,26 @@ _disk_sync_part_table (PedDisk* disk) } while (n_sleep--); if (!ok[i - 1] && errnums[i - 1] == ENXIO) ok[i - 1] = 1; /* it already doesn't exist */ - if (part && ok[i - 1]) { - /* add the (possibly modified or new) partition */ - if (!add_partition (disk, part)) { - ok[i - 1] = 0; - errnums[i - 1] = errno; - } + } + for (i = 1; i <= lpn; i++) { + PedPartition *part = ped_disk_get_partition (disk, i); + if (!part) + continue; + unsigned long long length; + unsigned long long start; + /* get start and length of existing partition */ + if (get_partition_start_and_length(part, + &start, &length) + && start == part->geom.start + && length == part->geom.length) { + ok[i - 1] = 1; + /* partition is unchanged, so nothing to do */ + continue; + } + /* add the (possibly modified or new) partition */ + if (!add_partition (disk, part)) { + ok[i - 1] = 0; + errnums[i - 1] = errno; } } |