]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (dos) Recalculate number of cylinders after changing number of heads and...
authorPali Rohár <pali.rohar@gmail.com>
Mon, 5 Jul 2021 20:13:11 +0000 (22:13 +0200)
committerPali Rohár <pali.rohar@gmail.com>
Thu, 15 Jul 2021 19:49:30 +0000 (21:49 +0200)
After geometry is changes it is required to recalculate total number of
cylinders. Otherwise total disk capacity is either reduced or extended.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
libfdisk/src/dos.c

index ce545f85710f3300451478a62baffda1604bf8b4..39dd9ef43c3ee6c48ae6c3ba24ba14ca2692c817 100644 (file)
@@ -846,6 +846,8 @@ static int dos_probe_label(struct fdisk_context *cxt)
        if (h && s) {
                cxt->geom.heads = h;
                cxt->geom.sectors = s;
+               cxt->geom.cylinders = cxt->total_sectors /
+                                       (cxt->geom.heads * cxt->geom.sectors);
 
                if (fdisk_has_user_device_geometry(cxt))
                        fdisk_apply_user_device_properties(cxt);