From 679ad262e91e4e88e7a87943dd94fef6c57094be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Siejak?= Date: Thu, 29 May 2014 22:11:47 +0200 Subject: [PATCH] haiku_loader now ignores unusable drives reported by BIOS. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the problem with find_unique_check_sums() taking a very long time to complete when one or more drives report read errors. Fixes #10880. [Paweł: minor style issue] Signed-off-by: Paweł Dziepak --- .../boot/platform/bios_ia32/devices.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/system/boot/platform/bios_ia32/devices.cpp b/src/system/boot/platform/bios_ia32/devices.cpp index 96125781d6..cdb6cc9e91 100644 --- a/src/system/boot/platform/bios_ia32/devices.cpp +++ b/src/system/boot/platform/bios_ia32/devices.cpp @@ -409,6 +409,16 @@ compute_check_sum(BIOSDrive *drive, off_t offset) return sum; } +/** Checks if the specified drive is usable for reading. + */ + +static bool +is_drive_readable(BIOSDrive *drive) +{ + char buffer; + return drive->ReadAt(NULL, 0, &buffer, sizeof(buffer)) > 0; +} + static void find_unique_check_sums(NodeList *devices) @@ -532,7 +542,14 @@ add_block_devices(NodeList *devicesList, bool identifierMissing) continue; } - devicesList->Add(drive); + // Only add usable drives + if (is_drive_readable(drive)) + devicesList->Add(drive); + else { + dprintf("could not read from drive %" B_PRIu8 ", not adding\n", driveID); + delete drive; + continue; + } if (drive->FillIdentifier() != B_OK) identifierMissing = true;