mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
Kernel/Storage: Restore booting from MBR partitions functionality
We had such functionality in the past, but it was regressed and now is restored.
This commit is contained in:
parent
cf4fa936be
commit
ed5a4f2938
2 changed files with 16 additions and 1 deletions
|
@ -46,7 +46,7 @@ public:
|
||||||
// FIXME: Remove this method after figuring out another scheme for naming.
|
// FIXME: Remove this method after figuring out another scheme for naming.
|
||||||
StringView early_storage_name() const;
|
StringView early_storage_name() const;
|
||||||
|
|
||||||
NonnullRefPtrVector<DiskPartition> partitions() const { return m_partitions; }
|
NonnullRefPtrVector<DiskPartition> const& partitions() const { return m_partitions; }
|
||||||
|
|
||||||
virtual CommandSet command_set() const = 0;
|
virtual CommandSet command_set() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,21 @@ UNMAP_AFTER_INIT void StorageManagement::determine_boot_device()
|
||||||
for (auto& storage_device : m_storage_devices) {
|
for (auto& storage_device : m_storage_devices) {
|
||||||
if (storage_device.early_storage_name() == storage_name) {
|
if (storage_device.early_storage_name() == storage_name) {
|
||||||
m_boot_block_device = storage_device;
|
m_boot_block_device = storage_device;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto start_storage_name = storage_name.substring_view(0, min(storage_device.early_storage_name().length(), storage_name.length()));
|
||||||
|
|
||||||
|
if (storage_device.early_storage_name().starts_with(start_storage_name)) {
|
||||||
|
StringView partition_sign = storage_name.substring_view(start_storage_name.length());
|
||||||
|
auto possible_partition_number = partition_sign.to_uint<size_t>();
|
||||||
|
if (!possible_partition_number.has_value())
|
||||||
|
break;
|
||||||
|
if (possible_partition_number.value() == 0)
|
||||||
|
break;
|
||||||
|
if (storage_device.partitions().size() < possible_partition_number.value())
|
||||||
|
break;
|
||||||
|
m_boot_block_device = storage_device.partitions()[possible_partition_number.value() - 1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue