blob: c37bfe027531bdad9668d43c95737c359f264f5a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
From 8b6f34acaadd78d11415144dccf5c4750e3e1d0e Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@ubuntu.com>
Date: Wed, 6 Aug 2014 16:07:28 +0200
Subject: Align new partitions created on fresh disks
Commit fa815ad05db248d78ef214ea79a78c22772a9ffe arranged to skip
partition alignment while reading disks, but also has the effect of
skipping partition alignment when creating a partition on a fresh disk,
which is incorrect.
The proper upstream fix probably involves adding a new member to PedDisk
to keep track of whether we're in the middle of the initial read in
ped_disk_new or not. To avoid changing ABI, we instead take this hacky
approach of overloading an extra bit on PedDisk.needs_clobber.
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1352252
Forwarded: no
Last-Update: 2023-06-26
Patch-Name: align-new-partitions-on-fresh-disks.patch
---
libparted/disk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libparted/disk.c b/libparted/disk.c
index 0db7b5c9..2d6b9d49 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -198,6 +198,7 @@ ped_disk_new (PedDevice* dev)
disk = ped_disk_new_fresh (dev, type);
if (!disk)
goto error_close_dev;
+ disk->needs_clobber |= 2;
if (!type->ops->read (disk))
goto error_destroy_disk;
disk->needs_clobber = 0;
@@ -951,7 +952,7 @@ _partition_align (PedPartition* part, const PedConstraint* constraint)
PED_ASSERT (disk_type->ops->partition_align != NULL);
PED_ASSERT (part->disk->update_mode);
- if (part->disk->needs_clobber)
+ if ((part->disk->needs_clobber & 2) != 0 || !constraint)
return 1; /* do not attempt to align partitions while reading them */
return disk_type->ops->partition_align (part, constraint);
}
|