bootloader: Fetch and display the size of the partition, if possible.

Fixes #19202.
This commit is contained in:
Augustin Cavalier 2024-11-04 17:15:33 -05:00
parent 105f00f768
commit 44d5b89d66

View File

@ -1190,6 +1190,21 @@ add_boot_volume_item(Menu* menu, Directory* volume, const char* name)
volumeInfo.Unset();
}
// Display the size of this boot partition, if we can.
Partition* partition;
if (gRoot->GetPartitionFor(volume, &partition) == B_OK) {
float size = partition->Size() / (1024.0 * 1024.0);
const char* unit = "MiB";
if (size > 1024.0) {
size /= 1024.0;
unit = "GiB";
}
char* newName = (char*)alloca(128);
snprintf(newName, 128, "%s (%f %s)", name, size, unit);
name = newName;
}
BootVolumeMenuItem* item = new(nothrow) BootVolumeMenuItem(name);
menu->AddItem(item);