From 7b1dee3929445395f029da22c4a692534b52d629 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 26 Oct 2013 02:48:18 +0200 Subject: [PATCH] boot loader: Fix find_unique_check_sums() Comparing the complete disk_identifer structure isn't helpful as long as we don't (can't) compare it in the kernel as well. ATM we only check the check sums there, so that's what we need to do here as well. This fixes potential mix-ups when booting off one of multiple equally sized disks. --- src/system/boot/platform/bios_ia32/devices.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/system/boot/platform/bios_ia32/devices.cpp b/src/system/boot/platform/bios_ia32/devices.cpp index 3a93f2f885..96125781d6 100644 --- a/src/system/boot/platform/bios_ia32/devices.cpp +++ b/src/system/boot/platform/bios_ia32/devices.cpp @@ -451,11 +451,24 @@ find_unique_check_sums(NodeList *devices) || compareDrive->Identifier().device_type != UNKNOWN_DEVICE) continue; +// TODO: Until we can actually get and compare *all* fields of the disk +// identifier in the kernel, we cannot compare the whole structure (we also +// should be more careful zeroing the structure before we fill it). +#if 0 if (!memcmp(&drive->Identifier(), &compareDrive->Identifier(), sizeof(disk_identifier))) { clash = true; break; } +#else + const disk_identifier& ourId = drive->Identifier(); + const disk_identifier& otherId = compareDrive->Identifier(); + if (memcmp(&ourId.device.unknown.check_sums, + &otherId.device.unknown.check_sums, + sizeof(ourId.device.unknown.check_sums)) == 0) { + clash = true; + } +#endif } if (clash)