Ticket #10880: 0001-haiku_loader-now-ignores-unusable-drives-reported-by.patch

File 0001-haiku_loader-now-ignores-unusable-drives-reported-by.patch, 1.5 KB (added by MasterM, 10 years ago)

Ok, let's try again. :)

  • src/system/boot/platform/bios_ia32/devices.cpp

    From dbfaf3080764f263ea2f32d9fcbd5d0505867807 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Micha=C5=82=20Siejak?= <michal@siejak.pl>
    Date: Thu, 29 May 2014 22:11:47 +0200
    Subject: [PATCH] haiku_loader now ignores unusable drives reported by BIOS.
    
    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.
    ---
     src/system/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 9612578..cdb6cc9 100644
    a b compute_check_sum(BIOSDrive *drive, off_t offset)  
    409409    return sum;
    410410}
    411411
     412/** Checks if the specified drive is usable for reading.
     413 */
     414
     415static bool
     416is_drive_readable(BIOSDrive *drive)
     417{
     418    char buffer;
     419    return drive->ReadAt(NULL, 0, &buffer, sizeof(buffer)) > 0;
     420}
     421
    412422
    413423static void
    414424find_unique_check_sums(NodeList *devices)
    add_block_devices(NodeList *devicesList, bool identifierMissing)  
    532542            continue;
    533543        }
    534544
    535         devicesList->Add(drive);
     545        // Only add usable drives
     546        if (is_drive_readable(drive))
     547            devicesList->Add(drive);
     548        else {
     549            dprintf("could not read from drive %" B_PRIu8 ", not adding\n", driveID);
     550            delete drive;
     551            continue;
     552        }
    536553
    537554        if (drive->FillIdentifier() != B_OK)
    538555            identifierMissing = true;