diff options
author | Karel Zak | 2015-06-10 16:55:29 +0200 |
---|---|---|
committer | Karel Zak | 2015-06-10 16:55:29 +0200 |
commit | 535748a6175a142901069724cb11b60d4a63b671 (patch) | |
tree | 3a109c5854885f5f5a68d1678f0c7df4ff9225c5 /libfdisk/src/dos.c | |
parent | fstrim: de-duplicate by mount source too (diff) | |
download | kernel-qcow2-util-linux-535748a6175a142901069724cb11b60d4a63b671.tar.gz kernel-qcow2-util-linux-535748a6175a142901069724cb11b60d4a63b671.tar.xz kernel-qcow2-util-linux-535748a6175a142901069724cb11b60d4a63b671.zip |
libfdisk: (dos) fix cylinders calculation
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r-- | libfdisk/src/dos.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 52836ebf1..de70728c2 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -1030,7 +1030,6 @@ static int add_partition(struct fdisk_context *cxt, size_t n, struct pte *ext_pe = l->ext_offset ? self_pte(cxt, l->ext_index) : NULL; struct fdisk_ask *ask = NULL; - fdisk_sector_t start, stop = 0, limit, temp, first[cxt->label->nparts_max], last[cxt->label->nparts_max]; @@ -1172,7 +1171,6 @@ static int add_partition(struct fdisk_context *cxt, size_t n, fdisk_reset_ask(ask); if (!ask) return -ENOMEM; - fdisk_ask_set_type(ask, FDISK_ASKTYPE_OFFSET); if (fdisk_use_cylinders(cxt)) { @@ -1196,18 +1194,16 @@ static int add_partition(struct fdisk_context *cxt, size_t n, stop = fdisk_ask_number_get_result(ask); isrel = fdisk_ask_number_is_relative(ask); + if (fdisk_use_cylinders(cxt)) { + stop = stop * fdisk_get_units_per_sector(cxt) - 1; + if (stop >limit) + stop = limit; + } if (stop >= start && stop <= limit) break; - fdisk_warnx(cxt, _("Value out of range.")); } - - if (fdisk_use_cylinders(cxt)) { - stop = stop * fdisk_get_units_per_sector(cxt) - 1; - if (stop >limit) - stop = limit; - } } DBG(LABEL, ul_debug("DOS: raw stop: %ju", (uintmax_t) stop)); @@ -1266,7 +1262,6 @@ static int add_partition(struct fdisk_context *cxt, size_t n, fdisk_label_set_changed(cxt->label, 1); rc = 0; - done: fdisk_unref_ask(ask); return rc; |