Blob Blame History Raw
From 40270928ff4ac2a87825f47e53c680ffb18b5bc4 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Tue, 14 Jun 2016 12:19:40 +0200
Subject: [PATCH 41/53] libparted/dasd: correct the offset where the first
 partition begins

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@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
(cherry picked from commit 4126d0292c75cf7d50a2f4e9d485a52b5beafccc)
---
 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,
-- 
2.7.4