[parted-devel] [PATCH] libparted/dasd: correct the offset where the first partition begins

Hendrik Brueckner brueckner at linux.vnet.ibm.com
Tue Jun 14 10:19:40 UTC 2016


From: Wang Dong <dongdwdw at linux.vnet.ibm.com>

The start point of first partition must start at least from the third
track of DASD, due to the existence of metadata in the first two track.
The previous constraint just sets all the device to be partitioned.
So when the start point of the first partition start before the third
track, (For example if it starts from.0) parted will exit abruptly.
And this kind of job must be done with constraint explicitly.

Then the constraint is modified to exclude the first two tracks and
to make the first partition start from the third track by default.

Signed-off-by: Wang Dong <dongdwdw at linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov at linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner at linux.vnet.ibm.com>
---
 libparted/labels/dasd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index f79a867..4e68512 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -829,6 +829,7 @@ _primary_constraint (PedDisk* disk)
 	PedSector sector_size;
 	LinuxSpecific* arch_specific;
 	DasdDiskSpecific* disk_specific;
+	PedSector start;
 
 	PDEBUG;
 
@@ -842,7 +843,12 @@ _primary_constraint (PedDisk* disk)
 	if (!ped_alignment_init (&end_align, -1,
 						     disk->dev->hw_geom.sectors * sector_size))
 		return NULL;
-	if (!ped_geometry_init (&max_geom, disk->dev, 0, disk->dev->length))
+
+	start = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors
+			    * (long long) arch_specific->real_sector_size
+			    / (long long) disk->dev->sector_size);
+
+	if (!ped_geometry_init (&max_geom, disk->dev, start, disk->dev->length))
 		return NULL;
 
 	return ped_constraint_new(&start_align, &end_align, &max_geom,
-- 
1.8.3.1




More information about the parted-devel mailing list