Пример #1
0
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
			&& sBootVolume->GetPackageVolumeState() == item->VolumeState()) {
		return true;
	}

	BootVolumeMenuItem* volumeItem = static_cast<BootVolumeMenuItem*>(
		item->Supermenu()->Superitem());
	volumeItem->SetMarked(true);
	volumeItem->Select(true);
	volumeItem->UpdateStateName(item->VolumeState());

	sPathBlacklist->MakeEmpty();

	bool valid = sBootVolume->SetTo((Directory*)item->Data(),
		item->VolumeInfo(), item->VolumeState()) == B_OK;

	bootItem->SetEnabled(valid);
	if (valid)
		bootItem->Select(true);

	gBootVolume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
	return true;
}
Пример #2
0
static Menu *
add_boot_volume_menu(Directory *bootVolume)
{
    Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Boot Volume");
    MenuItem *item;
    void *cookie;
    int32 count = 0;

    if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
        Directory *volume;
        while (gRoot->GetNextNode(cookie, (Node **)&volume) == B_OK) {
            // only list bootable volumes
            if (!is_bootable(volume))
                continue;

            char name[B_FILE_NAME_LENGTH];
            if (volume->GetName(name, sizeof(name)) == B_OK) {
                menu->AddItem(item = new(nothrow) MenuItem(name));
                item->SetTarget(user_menu_boot_volume);
                item->SetData(volume);

                if (volume == bootVolume) {
                    item->SetMarked(true);
                    item->Select(true);
                }

                count++;
            }
        }
        gRoot->Close(cookie);
    }

    if (count == 0) {
        // no boot volume found yet
        menu->AddItem(item = new(nothrow) MenuItem("<No boot volume found>"));
        item->SetType(MENU_ITEM_NO_CHOICE);
        item->SetEnabled(false);
    }

    menu->AddSeparatorItem();

    menu->AddItem(item = new(nothrow) MenuItem("Rescan volumes"));
    item->SetHelpText("Please insert a Antares CD-ROM or attach a USB disk - "
                      "depending on your system, you can then boot from them.");
    item->SetType(MENU_ITEM_NO_CHOICE);
    if (count == 0)
        item->Select(true);

    menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
    item->SetType(MENU_ITEM_NO_CHOICE);

    if (gKernelArgs.boot_volume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false))
        menu->SetChoiceText("CD-ROM or hard drive");

    return menu;
}
Пример #3
0
status_t
user_menu(Directory** _bootVolume)
{
	Menu* menu = new(std::nothrow) Menu(MAIN_MENU);
	Menu* safeModeMenu = NULL;
	Menu* debugMenu = NULL;
	MenuItem* item;

	TRACE(("user_menu: enter\n"));

	// Add boot volume
	menu->AddItem(item = new(std::nothrow) MenuItem("Select boot volume",
		add_boot_volume_menu(*_bootVolume)));

	// Add safe mode
	menu->AddItem(item = new(std::nothrow) MenuItem("Select safe mode options",
		safeModeMenu = add_safe_mode_menu()));

	// add debug menu
	menu->AddItem(item = new(std::nothrow) MenuItem("Select debug options",
		debugMenu = add_debug_menu()));

	// Add platform dependent menus
	platform_add_menus(menu);

	menu->AddSeparatorItem();

	menu->AddItem(item = new(std::nothrow) MenuItem("Reboot"));
	item->SetTarget(user_menu_reboot);
	item->SetShortcut('r');

	menu->AddItem(item = new(std::nothrow) MenuItem("Continue booting"));
	if (*_bootVolume == NULL) {
		item->SetEnabled(false);
		menu->ItemAt(0)->Select(true);
	} else
		item->SetShortcut('b');

	menu->Run();

	// See if a new boot device has been selected, and propagate that back
	if (item->Data() != NULL)
		*_bootVolume = (Directory*)item->Data();

	apply_safe_mode_options(safeModeMenu);
	apply_safe_mode_options(debugMenu);
	delete menu;

	TRACE(("user_menu: leave\n"));

	return B_OK;
}
Пример #4
0
static bool
user_menu_boot_volume(Menu *menu, MenuItem *item)
{
    Menu *super = menu->Supermenu();
    if (super == NULL) {
        // huh?
        return true;
    }

    MenuItem *bootItem = super->ItemAt(super->CountItems() - 1);
    bootItem->SetEnabled(true);
    bootItem->Select(true);
    bootItem->SetData(item->Data());

    gKernelArgs.boot_volume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
    return true;
}
Пример #5
0
static bool
user_menu_boot_volume(Menu* menu, MenuItem* item)
{
	MenuItem* bootItem = get_continue_booting_menu_item();
	if (bootItem == NULL) {
		// huh?
		return true;
	}

	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);

	gBootVolume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
	return true;
}
Пример #6
0
static Menu*
add_save_debug_syslog_menu()
{
	Menu* menu = new(nothrow) Menu(STANDARD_MENU, "Save syslog to volume ...");
	MenuItem* item;

	const char* const kHelpText = "Currently only FAT32 volumes are supported. "
		"Newly plugged in removable devices are only recognized after "
		"rebooting.";

	int32 itemsAdded = 0;

	void* cookie;
	if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
		Node* node;
		while (gRoot->GetNextNode(cookie, &node) == B_OK) {
			Directory* volume = static_cast<Directory*>(node);
			Partition* partition;
			if (gRoot->GetPartitionFor(volume, &partition) != B_OK)
				continue;

			// we support only FAT32 volumes ATM
			if (partition->content_type == NULL
				|| strcmp(partition->content_type, kPartitionTypeFAT32) != 0) {
				continue;
			}

			char name[B_FILE_NAME_LENGTH];
			if (volume->GetName(name, sizeof(name)) != B_OK)
				strcpy(name, "unnamed");

			// append offset, size, and type to the name
			size_t len = strlen(name);
			char offsetBuffer[32];
			char sizeBuffer[32];
			snprintf(name + len, sizeof(name) - len,
				" (%s, offset %s, size %s)", partition->content_type,
				size_to_string(partition->offset, offsetBuffer,
					sizeof(offsetBuffer)),
				size_to_string(partition->size, sizeBuffer,
					sizeof(sizeBuffer)));

			item = new(nothrow) MenuItem(name);
			item->SetData(volume);
			item->SetTarget(&debug_menu_save_syslog);
			item->SetType(MENU_ITEM_NO_CHOICE);
			item->SetHelpText(kHelpText);
			menu->AddItem(item);
			itemsAdded++;
		}

		gRoot->Close(cookie);
	}

	if (itemsAdded == 0) {
		menu->AddItem(item
			= new(nothrow) MenuItem("No supported volumes found"));
		item->SetType(MENU_ITEM_NO_CHOICE);
		item->SetHelpText(kHelpText);
		item->SetEnabled(false);
	}

	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem("Return to debug menu"));
	item->SetHelpText(kHelpText);

	return menu;
}
Пример #7
0
status_t
user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist)
{

	Menu* menu = new(std::nothrow) Menu(MAIN_MENU);

	sMainMenu = menu;
	sBootVolume = &_bootVolume;
	sPathBlacklist = &_pathBlacklist;

	Menu* safeModeMenu = NULL;
	Menu* debugMenu = NULL;
	MenuItem* item;

	TRACE(("user_menu: enter\n"));

	// Add boot volume
	menu->AddItem(item = new(std::nothrow) MenuItem("Select boot volume",
		add_boot_volume_menu()));

	// Add safe mode
	menu->AddItem(item = new(std::nothrow) MenuItem("Select safe mode options",
		safeModeMenu = add_safe_mode_menu()));

	// add debug menu
	menu->AddItem(item = new(std::nothrow) MenuItem("Select debug options",
		debugMenu = add_debug_menu()));

	// Add platform dependent menus
	platform_add_menus(menu);

	menu->AddSeparatorItem();

	menu->AddItem(item = new(std::nothrow) MenuItem("Reboot"));
	item->SetTarget(user_menu_reboot);
	item->SetShortcut('r');

	menu->AddItem(item = new(std::nothrow) MenuItem("Continue booting"));
	if (!_bootVolume.IsValid()) {
		item->SetEnabled(false);
		menu->ItemAt(0)->Select(true);
	} else
		item->SetShortcut('b');

	menu->Run();

	apply_safe_mode_options(safeModeMenu);
	apply_safe_mode_options(debugMenu);
	apply_safe_mode_path_blacklist();
	add_safe_mode_settings(sSafeModeOptionsBuffer.String());
	delete menu;


	TRACE(("user_menu: leave\n"));

	sMainMenu = NULL;
	sBlacklistRootMenu = NULL;
	sBootVolume = NULL;
	sPathBlacklist = NULL;
	return B_OK;
}