mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
Kernel: Allow specifying partition index with NVMe devices
Since NVME devices end with a digit that indicates the node index we cannot simply append a partition index. Instead, there will be a "p" character as separator, e.g. /dev/nvme0n1p3 for the 3rd partition. So, if the early device name ends in a digit we need to add this separater before matching for the partition index. If the partition index is omitted (as is the default) the root file system is on a disk without any partition table (e.g. using QEMU). This enables booting from the correct partition on an NVMe drive by setting the command line variable root to e.g. root=/dev/nvme0n1p1
This commit is contained in:
parent
c748c0726a
commit
2251733744
1 changed files with 13 additions and 2 deletions
|
@ -142,9 +142,20 @@ UNMAP_AFTER_INIT void StorageManagement::determine_boot_device()
|
||||||
m_boot_block_device = storage_device;
|
m_boot_block_device = storage_device;
|
||||||
break;
|
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)) {
|
// If the early storage name's last character is a digit (e.g. in the case of NVMe where the last
|
||||||
|
// number in the device name indicates the node, e.g. /dev/nvme0n1 we need to append a "p" character
|
||||||
|
// so that we can properly distinguish the partition index from the device itself
|
||||||
|
char storage_name_last_char = *(storage_device.early_storage_name().end() - 1);
|
||||||
|
String early_storage_name;
|
||||||
|
if (storage_name_last_char >= '0' && storage_name_last_char <= '9')
|
||||||
|
early_storage_name = String::formatted("{}p", storage_device.early_storage_name());
|
||||||
|
else
|
||||||
|
early_storage_name = storage_device.early_storage_name();
|
||||||
|
|
||||||
|
auto start_storage_name = storage_name.substring_view(0, min(early_storage_name.length(), storage_name.length()));
|
||||||
|
|
||||||
|
if (early_storage_name.starts_with(start_storage_name)) {
|
||||||
StringView partition_sign = storage_name.substring_view(start_storage_name.length());
|
StringView partition_sign = storage_name.substring_view(start_storage_name.length());
|
||||||
auto possible_partition_number = partition_sign.to_uint<size_t>();
|
auto possible_partition_number = partition_sign.to_uint<size_t>();
|
||||||
if (!possible_partition_number.has_value())
|
if (!possible_partition_number.has_value())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue