File libparted-allow-bigger-snap-radius-if-cylinders-are-used.patch of Package parted.3440

From 2ef86fbe0fd8a6c4b48dd8edfbe41728a7343dac Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Thu, 29 May 2014 14:50:31 +0200
Subject: [PATCH] libparted: allow bigger snap radius if cylinders are used

This is partial revert of commit

   commit 18e727d492933ae1ebb16961e1df553f9299af8b
   Author: Brian C. Lane <bcl@redhat.com>
   Date:   Tue Jun 21 10:44:15 2011 -0700

   libparted: fix snap radius so that it is using half (#665496)

   The snap radius didn't match the documentation, it has been
   using +/- unit size instead +/- 0.5 * unit (eg. 500KB for a MB
   unit). This caused problems when specifying 1MB, 1GB, etc. as a
   partition start or end resulting in partitions being created
   that were nowhere near the specified size.

Only revert to the old behavior if cylinders are used in order to
give parted more flexibility when snapping the partition start/end.

References: bnc#879387
---
 libparted/unit.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: parted-3.1/libparted/unit.c
===================================================================
--- parted-3.1.orig/libparted/unit.c
+++ parted-3.1/libparted/unit.c
@@ -540,7 +540,10 @@ ped_unit_parse_custom (const char* str,
         }
 
 	unit_size = ped_unit_get_size (dev, unit);
-	radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1;
+	if (unit == PED_UNIT_CYLINDER)
+		radius = ped_div_round_up (unit_size, dev->sector_size) - 1;
+	else
+		radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1;
 	if (radius < 0)
 		radius = 0;
 	/* If the user specifies units in a power of 2, e.g., 4MiB, as in
openSUSE Build Service is sponsored by