mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
Kernel/Storage: Don't hardcode a maximum of 16 partitions per drive
In the near future, we will be able to figure out connections between storage devices and their partitions, so there's no need to hardcode 16 partitions per storage device - each storage device should be able to have "infinite" count of partitions in it, and we should be able to use and figure out about them.
This commit is contained in:
parent
cb68619b7f
commit
1102089f9f
5 changed files with 17 additions and 12 deletions
|
@ -30,7 +30,8 @@
|
|||
namespace Kernel {
|
||||
|
||||
static Singleton<StorageManagement> s_the;
|
||||
static Atomic<u32> s_device_minor_number;
|
||||
static Atomic<u32> s_storage_device_minor_number;
|
||||
static Atomic<u32> s_partition_device_minor_number;
|
||||
static Atomic<u32> s_controller_id;
|
||||
|
||||
static constexpr StringView partition_uuid_prefix = "PARTUUID:"sv;
|
||||
|
@ -156,8 +157,7 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_disk_partitions()
|
|||
auto partition_metadata = partition_table->partition(partition_index);
|
||||
if (!partition_metadata.has_value())
|
||||
continue;
|
||||
// FIXME: Try to not hardcode a maximum of 16 partitions per drive!
|
||||
auto disk_partition = DiskPartition::create(device, (partition_index + (16 * device_index)), partition_metadata.value());
|
||||
auto disk_partition = DiskPartition::create(device, generate_partition_minor_number(), partition_metadata.value());
|
||||
device.add_partition(disk_partition);
|
||||
}
|
||||
device_index++;
|
||||
|
@ -241,7 +241,12 @@ MajorNumber StorageManagement::storage_type_major_number()
|
|||
}
|
||||
MinorNumber StorageManagement::generate_storage_minor_number()
|
||||
{
|
||||
return s_device_minor_number.fetch_add(1);
|
||||
return s_storage_device_minor_number.fetch_add(1);
|
||||
}
|
||||
|
||||
MinorNumber StorageManagement::generate_partition_minor_number()
|
||||
{
|
||||
return s_partition_device_minor_number.fetch_add(1);
|
||||
}
|
||||
|
||||
u32 StorageManagement::generate_controller_id()
|
||||
|
@ -270,7 +275,7 @@ NonnullRefPtr<FileSystem> StorageManagement::root_filesystem() const
|
|||
|
||||
UNMAP_AFTER_INIT void StorageManagement::initialize(StringView root_device, bool force_pio, bool poll)
|
||||
{
|
||||
VERIFY(s_device_minor_number == 0);
|
||||
VERIFY(s_storage_device_minor_number == 0);
|
||||
m_boot_argument = root_device;
|
||||
if (PCI::Access::is_disabled()) {
|
||||
// Note: If PCI is disabled, we assume that at least we have an ISA IDE controller
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue