From 2a62d0d6c5cb472a842c959adf3bef1ebc0d89fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 29 Mar 2006 00:16:57 +0000 Subject: [PATCH] Added a second pass to the boot device retrieval in case nothing has been found. Right now, the size of the device is ignored in the second pass. Maybe this helps with bug #357. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16917 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs_boot.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/system/kernel/fs/vfs_boot.cpp b/src/system/kernel/fs/vfs_boot.cpp index 1cd7e8d6f1..4b2430c694 100644 --- a/src/system/kernel/fs/vfs_boot.cpp +++ b/src/system/kernel/fs/vfs_boot.cpp @@ -141,7 +141,7 @@ compute_check_sum(KDiskDevice *device, off_t offset) */ static bool -is_boot_device(kernel_args *args, KDiskDevice *device) +is_boot_device(kernel_args *args, KDiskDevice *device, bool strict) { disk_identifier &disk = args->boot_disk.identifier; @@ -163,7 +163,8 @@ is_boot_device(kernel_args *args, KDiskDevice *device) switch (disk.device_type) { case UNKNOWN_DEVICE: // test if the size of the device matches - if (device->Size() != disk.device.unknown.size) + // (the BIOS might have given us the wrong value here, though) + if (strict && device->Size() != disk.device.unknown.size) return false; // check if the check sums match, too @@ -250,14 +251,24 @@ get_boot_partitions(kernel_args *args, PartitionStack &partitions) PartitionStack &fPartitions; } visitor(*args, partitions); - KDiskDevice *device; - int32 cookie = 0; - while ((device = manager->NextDevice(&cookie)) != NULL) { - if (!is_boot_device(args, device)) - continue; + bool strict = true; - if (device->VisitEachDescendant(&visitor) != NULL) + while (true) { + KDiskDevice *device; + int32 cookie = 0; + while ((device = manager->NextDevice(&cookie)) != NULL) { + if (!is_boot_device(args, device, strict)) + continue; + + if (device->VisitEachDescendant(&visitor) != NULL) + break; + } + + if (!partitions.IsEmpty() || !strict) break; + + // we couldn't find any potential boot devices, try again less strict + strict = false; } if (!args->boot_disk.user_selected) {