fdisk_sun: fix partition alignment
authorAaro Koskinen <aaro.koskinen@iki.fi>
Sat, 9 Feb 2013 19:12:26 +0000 (21:12 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 10 Feb 2013 23:22:59 +0000 (00:22 +0100)
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@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
util-linux/fdisk_sun.c

index d11c54012312ce3277aedf56920c74a1e91c5e74..e32740dea4531460677f093571b3927ee2b486ba 100644 (file)
@@ -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\