[git commit] fdisk_sun: fix partition alignment

Denys Vlasenko vda.linux at googlemail.com
Sun Feb 10 23:22:59 UTC 2013


commit: http://git.busybox.net/busybox/commit/?id=cf5731bcbd3b65c5efb9a8b24ed6b95a0a239e67
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

When the display unit is sectors, the partition alignment will convert
the partition start to a wrong unit (it should always be in sectors). Fix
this.

Signed-off-by: Aaro Koskinen <aaro.koskinen at iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 util-linux/fdisk_sun.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index d11c540..e32740d 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -498,11 +498,14 @@ add_sun_partition(int n, int sys)
 		else
 			first = read_int(scround(start), scround(stop)+1,
 					 scround(stop), 0, mesg);
-		if (display_in_cyl_units)
+		if (display_in_cyl_units) {
 			first *= units_per_sector;
-		else
+		} else {
 			/* Starting sector has to be properly aligned */
-			first = (first + g_heads * g_sectors - 1) / (g_heads * g_sectors);
+			first = (first + g_heads * g_sectors - 1) /
+				(g_heads * g_sectors);
+			first *= g_heads * g_sectors;
+		}
 		if (n == 2 && first != 0)
 			printf("\
 It is highly recommended that the third partition covers the whole disk\n\


More information about the busybox-cvs mailing list