Skip to content

Commit

Permalink
fdisk_sun: fix partition alignment
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Denys Vlasenko <[email protected]>
  • Loading branch information
aakoskin authored and Denys Vlasenko committed Feb 10, 2013
1 parent 1bd5ca2 commit cf5731b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions util-linux/fdisk_sun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down

0 comments on commit cf5731b

Please sign in to comment.