summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/dos.c
diff options
context:
space:
mode:
authorThorsten Wilmer2014-06-24 09:38:30 +0200
committerKarel Zak2014-06-24 09:40:06 +0200
commit9bb8caff87c2ae1ea22068176d3375c1cc2cb76d (patch)
tree9df2241729c98a66983bcb353a2b72f144dec144 /libfdisk/src/dos.c
parentlibmount: special treatment for auto in fstype pattern (diff)
downloadkernel-qcow2-util-linux-9bb8caff87c2ae1ea22068176d3375c1cc2cb76d.tar.gz
kernel-qcow2-util-linux-9bb8caff87c2ae1ea22068176d3375c1cc2cb76d.tar.xz
kernel-qcow2-util-linux-9bb8caff87c2ae1ea22068176d3375c1cc2cb76d.zip
libfdisk: (dos) calculation of total size based on CHS in check function
Many people report a problem with the message if (cylinders <= 1024 && start != total) fprintf(stderr, _("Partition %d: previous sectors %d disagrees with " "total %d\n"), n, start, total); This message comes from the fact that the previous code caluclates the total number of sectors in the wrong way. The formula should be total = (real_c * heads + h) * sectors + real_s; As a Cylinder consists of some heads * sectors A Head consists of some sectors and finally sectors are the smallest unit Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r--libfdisk/src/dos.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index e365e722d..f3b162af1 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -1155,7 +1155,7 @@ static void check(struct fdisk_context *cxt, size_t n,
real_s = sector(s) - 1;
real_c = cylinder(s, c);
- total = (real_c * cxt->geom.sectors + real_s) * cxt->geom.heads + h;
+ total = (real_c * cxt->geom.heads + h) * cxt->geom.sectors + real_s;
if (!total)
fdisk_warnx(cxt, _("Partition %zu: contains sector 0"), n);