util-linux/util-linux-2.12r-fdisk_cyl.patch

34 lines
1.1 KiB
Diff

Index: util-linux-ng-2.12r+2.13pre7/fdisk/fdisk.c
===================================================================
--- util-linux-ng-2.12r+2.13pre7.orig/fdisk/fdisk.c
+++ util-linux-ng-2.12r+2.13pre7/fdisk/fdisk.c
@@ -1918,6 +1918,16 @@ verify(void) {
total_number_of_sectors - total);
}
+static unsigned long long
+roundup_to_cylinder_boundary(unsigned long long offset) {
+ if (units_per_sector) {
+ unsigned long long extra_sectors = offset % units_per_sector;
+ if (extra_sectors != 0)
+ offset += (units_per_sector - extra_sectors) - 1;
+ }
+ return offset;
+}
+
static void
add_partition(int n, int sys) {
char mesg[256]; /* 48 does not suffice in Japanese */
@@ -1953,8 +1963,10 @@ add_partition(int n, int sys) {
limit = get_start_sect(q) + get_nr_sects(q) - 1;
}
if (display_in_cyl_units)
- for (i = 0; i < partitions; i++)
+ for (i = 0; i < partitions; i++) {
first[i] = (cround(first[i]) - 1) * units_per_sector;
+ last[i] = roundup_to_cylinder_boundary(last[i]);
+ }
snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR));
do {