1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:27:34 +00:00

Kernel/Devices: Remove required_mode and device_name methods

These methods are no longer needed because SystemServer is able to
populate the DevFS on its own.

Device absolute_path no longer assume a path to the /dev location,
because it really should not assume any path to a Device node.

Because StorageManagement still needs to know the storage name, we
declare a virtual method only for StorageDevices to override, but this
technique should really be removed later on.
This commit is contained in:
Liav A 2021-08-14 07:01:19 +03:00 committed by Andreas Kling
parent 4f04cb98c1
commit 21b6d84ff0
38 changed files with 18 additions and 141 deletions

View file

@ -41,7 +41,7 @@ void PATADiskDevice::start_request(AsyncBlockDeviceRequest& request)
m_channel->start_request(request, is_slave(), m_capabilities);
}
String PATADiskDevice::device_name() const
String PATADiskDevice::storage_name() const
{
return String::formatted("hd{:c}", 'a' + minor());
}

View file

@ -42,7 +42,7 @@ public:
// ^BlockDevice
virtual void start_request(AsyncBlockDeviceRequest&) override;
virtual String device_name() const override;
virtual String storage_name() const override;
private:
PATADiskDevice(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64);

View file

@ -68,13 +68,6 @@ bool DiskPartition::can_write(const OpenFileDescription& fd, size_t offset) cons
return m_device->can_write(fd, offset + adjust);
}
String DiskPartition::device_name() const
{
// FIXME: Try to not hardcode a maximum of 16 partitions per drive!
size_t partition_index = minor() % 16;
return String::formatted("{}{}", m_device->device_name(), partition_index + 1);
}
StringView DiskPartition::class_name() const
{
return "DiskPartition";

View file

@ -25,10 +25,6 @@ public:
virtual KResultOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
virtual bool can_write(const OpenFileDescription&, size_t) const override;
// ^Device
virtual mode_t required_mode() const override { return 0600; }
virtual String device_name() const override;
const DiskPartitionMetadata& metadata() const;
private:

View file

@ -55,7 +55,7 @@ void RamdiskDevice::start_request(AsyncBlockDeviceRequest& request)
}
}
String RamdiskDevice::device_name() const
String RamdiskDevice::storage_name() const
{
// FIXME: Try to not hardcode a maximum of 16 partitions per drive!
size_t drive_index = minor() / 16;

View file

@ -26,7 +26,7 @@ public:
// ^DiskDevice
virtual StringView class_name() const override;
virtual String device_name() const override;
virtual String storage_name() const override;
bool is_slave() const;

View file

@ -37,7 +37,7 @@ void SATADiskDevice::start_request(AsyncBlockDeviceRequest& request)
m_port->start_request(request);
}
String SATADiskDevice::device_name() const
String SATADiskDevice::storage_name() const
{
return String::formatted("hd{:c}", 'a' + minor());
}

View file

@ -30,7 +30,7 @@ public:
// ^StorageDevice
// ^BlockDevice
virtual void start_request(AsyncBlockDeviceRequest&) override;
virtual String device_name() const override;
virtual String storage_name() const override;
private:
SATADiskDevice(const AHCIController&, const AHCIPort&, size_t sector_size, u64 max_addressable_block);

View file

@ -29,8 +29,8 @@ public:
virtual KResultOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
virtual bool can_write(const OpenFileDescription&, size_t) const override;
// ^Device
virtual mode_t required_mode() const override { return 0600; }
// FIXME: This is being used only during early boot, find a better way to find devices...
virtual String storage_name() const = 0;
protected:
StorageDevice(const StorageController&, size_t, u64);

View file

@ -126,15 +126,12 @@ UNMAP_AFTER_INIT void StorageManagement::determine_boot_device()
{
VERIFY(!m_controllers.is_empty());
if (m_boot_argument.starts_with("/dev/")) {
StringView device_name = m_boot_argument.substring_view(5);
Device::for_each([&](Device& device) {
if (device.is_block_device()) {
auto& block_device = static_cast<BlockDevice&>(device);
if (device.device_name() == device_name) {
m_boot_block_device = block_device;
}
StringView storage_name = m_boot_argument.substring_view(5);
for (auto& storage_device : m_storage_devices) {
if (storage_device.storage_name() == storage_name) {
m_boot_block_device = storage_device;
}
});
}
}
if (m_boot_block_device.is_null()) {