diff options
author | Jean-Baptiste Boric <jblbeurope@gmail.com> | 2021-01-21 18:49:56 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-22 22:17:39 +0100 |
commit | f64e287b82fceb81c843bdaf6bad4e608330ae60 (patch) | |
tree | c7e326d98481975f97eac54c91bc7d9f24770e9f /Kernel/Storage/PATADiskDevice.cpp | |
parent | a2601e13088d61b796220dbb1085ec74a3f6d9fd (diff) | |
download | serenity-f64e287b82fceb81c843bdaf6bad4e608330ae60.zip |
Kernel: Make device generate their own names
Besides removing the monolithic DevFSDeviceInode::determine_name()
method, being able to determine a device's name inside the /dev
hierarchy outside of DevFS has its uses.
Diffstat (limited to 'Kernel/Storage/PATADiskDevice.cpp')
-rw-r--r-- | Kernel/Storage/PATADiskDevice.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Kernel/Storage/PATADiskDevice.cpp b/Kernel/Storage/PATADiskDevice.cpp index 21ee558eef..8065585902 100644 --- a/Kernel/Storage/PATADiskDevice.cpp +++ b/Kernel/Storage/PATADiskDevice.cpp @@ -65,6 +65,13 @@ void PATADiskDevice::start_request(AsyncBlockDeviceRequest& request) m_channel.start_request(request, use_dma, is_slave()); } +String PATADiskDevice::device_name() const +{ + // FIXME: Try to not hardcode a maximum of 16 partitions per drive! + size_t drive_index = minor() / 16; + return String::formatted("hd{:c}{}", 'a' + drive_index, minor() + 1); +} + size_t PATADiskDevice::max_addressable_block() const { return m_cylinders * m_heads * m_sectors_per_track; |