File libparted-dasd-correct-the-offset-where-the-first-pa.patch of Package parted.15765

From 4126d0292c75cf7d50a2f4e9d485a52b5beafccc Mon Sep 17 00:00:00 2001
From: Wang Dong <>
Date: Tue, 14 Jun 2016 12:19:40 +0200
Subject: [PATCH] libparted/dasd: correct the offset where the first partition

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 <>
Reviewed-by: Viktor Mihajlovski <>
Signed-off-by: Hendrik Brueckner <>
Signed-off-by: Brian C. Lane <>
 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;
@@ -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,
openSUSE Build Service is sponsored by