From 82ead3fe322a2c2869238f1cb7b0f9358bdce9b2 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 13 Apr 2008 18:40:25 +0000 Subject: [PATCH] 2008-04-13 Robert Millan * disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Fix CHS limit check, as per http://www.allensmith.net/Storage/HDDlimit/Int13h.htm --- ChangeLog | 5 +++++ disk/i386/pc/biosdisk.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8ab8ba767..79c1db86b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-13 Robert Millan + + * disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Fix CHS limit check, + as per http://www.allensmith.net/Storage/HDDlimit/Int13h.htm + 2008-04-13 Christian Franke * util/i386/pc/grub-mkrescue.in: Add --emulation=floppy diff --git a/disk/i386/pc/biosdisk.c b/disk/i386/pc/biosdisk.c index 93f0da91f..094bde0aa 100644 --- a/disk/i386/pc/biosdisk.c +++ b/disk/i386/pc/biosdisk.c @@ -234,15 +234,17 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk, { unsigned coff, hoff, soff; unsigned head; - unsigned real_sector = (unsigned) sector; - /* It is impossible to reach over 2TB with the traditional - CHS access. */ - if (sector > ~0UL) + /* It is impossible to reach over 8064 MiB (a bit less than LBA24) with + the traditional CHS access. */ + if (sector > + 1024 /* cylinders */ * + 256 /* heads */ * + 63 /* spt */) return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk"); - soff = real_sector % data->sectors + 1; - head = real_sector / data->sectors; + soff = ((grub_uint32_t) sector) % data->sectors + 1; + head = ((grub_uint32_t) sector) / data->sectors; hoff = head % data->heads; coff = head / data->heads;