From 4011cb5d303d89140dc966279f894865a6e9a208 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 21 Nov 2014 18:14:10 +0100 Subject: [PATCH] BootManager: different error when no MBR is found We were using the same "no space available" message used when the first partition starts too early. Be more specific here to make it clearer what the problem is. Fixes #7087. --- .../bootmanager/BootManagerController.cpp | 10 ++++++++-- src/apps/bootmanager/DrivesPage.cpp | 19 ++++++++++++++++--- src/apps/bootmanager/LegacyBootMenu.cpp | 7 ++++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/apps/bootmanager/BootManagerController.cpp b/src/apps/bootmanager/BootManagerController.cpp index 7cc5fcdf5e..4899983cce 100644 --- a/src/apps/bootmanager/BootManagerController.cpp +++ b/src/apps/bootmanager/BootManagerController.cpp @@ -297,12 +297,18 @@ BootManagerController::_CreateErrorEntryPage() { BString description; - if (fCollectPartitionsStatus == B_PARTITION_TOO_SMALL) { + if (fCollectPartitionsStatus == B_ENTRY_NOT_FOUND) { description << B_TRANSLATE_COMMENT("Partition table not compatible", "Title") << "\n\n" << B_TRANSLATE("The partition table of the first hard disk is not " "compatible with Boot Manager.\n" - "Boot Manager needs 2 KB available space before the first " + "Boot Manager only works with IBM PC MBR partitions."); + } else if (fCollectPartitionsStatus == B_PARTITION_TOO_SMALL) { + description << B_TRANSLATE_COMMENT("First partition starts too early", + "Title") << "\n\n" + << B_TRANSLATE("The first partition on the disk starts too early " + "and does not leave enough space free for a boot menu.\n" + "Boot Manager needs 2 KiB available space before the first " "partition."); } else { description << B_TRANSLATE_COMMENT("Error reading partition table", diff --git a/src/apps/bootmanager/DrivesPage.cpp b/src/apps/bootmanager/DrivesPage.cpp index 0326b3b9bd..43a96cefdf 100644 --- a/src/apps/bootmanager/DrivesPage.cpp +++ b/src/apps/bootmanager/DrivesPage.cpp @@ -164,9 +164,22 @@ DriveItem::DrawItem(BView* owner, BRect frame, bool complete) if (fCanBeInstalled != B_OK) { owner->SetHighColor(140, 0, 0); owner->MovePenBy(fBaselineOffset, 0); - owner->DrawString(fCanBeInstalled == B_PARTITION_TOO_SMALL - ? B_TRANSLATE_COMMENT("No space available!", "Cannot install") - : B_TRANSLATE_COMMENT("Cannot access!", "Cannot install")); + const char* message; + switch (fCanBeInstalled) { + case B_PARTITION_TOO_SMALL: + message = B_TRANSLATE_COMMENT("No space available!", + "Cannot install"); + break; + case B_ENTRY_NOT_FOUND: + message = B_TRANSLATE_COMMENT("Incompatible format!", + "Cannot install"); + break; + default: + message = B_TRANSLATE_COMMENT("Cannot access!", + "Cannot install"); + break; + } + owner->DrawString(message); } owner->PopState(); diff --git a/src/apps/bootmanager/LegacyBootMenu.cpp b/src/apps/bootmanager/LegacyBootMenu.cpp index 9fe02be795..185b31d376 100644 --- a/src/apps/bootmanager/LegacyBootMenu.cpp +++ b/src/apps/bootmanager/LegacyBootMenu.cpp @@ -318,11 +318,12 @@ LegacyBootMenu::CanBeInstalled(const BootDrive& drive) PartitionVisitor visitor; device.VisitEachDescendant(&visitor); + if (!visitor.HasPartitions()) + return B_ENTRY_NOT_FOUND; + // Enough space to write boot menu to drive? - if (!visitor.HasPartitions() - || visitor.FirstOffset() < (int)sizeof(kBootLoader)) { + if (visitor.FirstOffset() < (int)sizeof(kBootLoader)) return B_PARTITION_TOO_SMALL; - } return B_OK; }