boot_loader: Add an error message to the "Continue booting" item.

This way, when it is disabled, at least there will be an error
message giving some indication of what has gone wrong.
This commit is contained in:
Augustin Cavalier 2019-12-30 19:07:21 -05:00
parent 94d36145df
commit c9606abe0c

View File

@ -923,25 +923,39 @@ get_continue_booting_menu_item()
}
static bool
user_menu_boot_volume(Menu* menu, MenuItem* item)
static void
update_continue_booting_menu_item(status_t status)
{
MenuItem* bootItem = get_continue_booting_menu_item();
if (bootItem == NULL) {
// huh?
return true;
return;
}
if (status == B_OK) {
bootItem->SetLabel("Continue booting");
bootItem->SetEnabled(true);
bootItem->Select(true);
} else {
char label[128];
snprintf(label, sizeof(label), "Cannot continue booting (%s)",
strerror(status));
bootItem->SetLabel(label);
bootItem->SetEnabled(false);
}
}
static bool
user_menu_boot_volume(Menu* menu, MenuItem* item)
{
if (sBootVolume->IsValid() && sBootVolume->RootDirectory() == item->Data())
return true;
sPathBlacklist->MakeEmpty();
bool valid = sBootVolume->SetTo((Directory*)item->Data()) == B_OK;
bootItem->SetEnabled(valid);
if (valid)
bootItem->Select(true);
status_t status = sBootVolume->SetTo((Directory*)item->Data());
update_continue_booting_menu_item(status);
gBootVolume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
return true;
@ -951,12 +965,6 @@ user_menu_boot_volume(Menu* menu, MenuItem* item)
static bool
user_menu_boot_volume_state(Menu* menu, MenuItem* _item)
{
MenuItem* bootItem = get_continue_booting_menu_item();
if (bootItem == NULL) {
// huh?
return true;
}
PackageVolumeStateMenuItem* item = static_cast<PackageVolumeStateMenuItem*>(
_item);
if (sBootVolume->IsValid() && sBootVolume->GetPackageVolumeState() != NULL
@ -972,12 +980,9 @@ user_menu_boot_volume_state(Menu* menu, MenuItem* _item)
sPathBlacklist->MakeEmpty();
bool valid = sBootVolume->SetTo((Directory*)item->Data(),
item->VolumeInfo(), item->VolumeState()) == B_OK;
bootItem->SetEnabled(valid);
if (valid)
bootItem->Select(true);
status_t status = sBootVolume->SetTo((Directory*)item->Data(),
item->VolumeInfo(), item->VolumeState());
update_continue_booting_menu_item(status);
gBootVolume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
return true;
@ -1606,6 +1611,7 @@ user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist)
menu->AddItem(item = new(std::nothrow) MenuItem("Continue booting"));
if (!_bootVolume.IsValid()) {
item->SetLabel("Cannot continue booting (Boot volume is not valid)");
item->SetEnabled(false);
menu->ItemAt(0)->Select(true);
} else