From de65ee2b2c9ba22b5b89a643ecf6299a0e0016f2 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 8 Jun 2009 13:29:05 +0000 Subject: [PATCH] 2009-06-08 Vladimir Serbinenko Not fail if unable to retrieve C/H/S on LBA disks * disk/i386/pc/biosdisk.c (grub_biosdisk_open): behave gracefully if unable to retrieve C/H/S on LBA disks --- ChangeLog | 7 +++++++ disk/i386/pc/biosdisk.c | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9ef1ba40..6eb19f8a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-06-08 Vladimir Serbinenko + + Not fail if unable to retrieve C/H/S on LBA disks + + * disk/i386/pc/biosdisk.c (grub_biosdisk_open): behave gracefully + if unable to retrieve C/H/S on LBA disks + 2009-06-08 Pavel Roskin * fs/hfs.c (grub_hfs_find_dir): Use union to avoid a warning diff --git a/disk/i386/pc/biosdisk.c b/disk/i386/pc/biosdisk.c index ba1eb77b8..f9663305a 100644 --- a/disk/i386/pc/biosdisk.c +++ b/disk/i386/pc/biosdisk.c @@ -158,8 +158,20 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) &data->heads, &data->sectors) != 0) { - grub_free (data); - return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values"); + if (total_sectors && (data->flags & GRUB_BIOSDISK_FLAG_LBA)) + { + data->sectors = 63; + data->heads = 255; + data->cylinders + = grub_divmod64 (total_sectors + + data->heads * data->sectors - 1, + data->heads * data->sectors, 0); + } + else + { + grub_free (data); + return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values"); + } } if (! total_sectors)