To check if LBA sector can be represented in CHS without overflow it is
required to check for cylinder value which belongs to the LBA sector. And
not the total number of disk cylinders. Note that maximal representable
total number of disk cylinders is 1024 and therefore the last cylinder
which which can be stored in CHS tuple is 1023. Hence strict inequality is
used.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
(uintmax_t) cxt->geom.cylinders);
nerrors++;
}
- if (cxt->geom.cylinders <= 1024 && lba_sector != chs_sector) {
+ if (lba_sector / (cxt->geom.heads * cxt->geom.sectors) < 1024 && lba_sector != chs_sector) {
fdisk_warnx(cxt, _("Partition %zu: LBA sector %u "
"disagrees with C/H/S calculated sector %u"),
n, lba_sector, chs_sector);