mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 00:57:43 +00:00
Kernel: Remove most String usage from storage_name() API
This change is another minor step towards removing `AK::String` from the Kernel. Instead of dynamically allocating the storage_name we can instead allocate it via a KString in the factory for each device, and then push the device name down into the StorageDevice base class. We don't have a way of doing `AK::String::formatted(..)` with a KString at the moment, so cleaning that up will be left for a later day.
This commit is contained in:
parent
3a945051fc
commit
70ad18fbcd
8 changed files with 45 additions and 40 deletions
|
@ -13,16 +13,18 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
StorageDevice::StorageDevice(const StorageController& controller, size_t sector_size, u64 max_addressable_block)
|
||||
StorageDevice::StorageDevice(const StorageController& controller, size_t sector_size, u64 max_addressable_block, NonnullOwnPtr<KString> device_name)
|
||||
: BlockDevice(StorageManagement::major_number(), StorageManagement::minor_number(), sector_size)
|
||||
, m_storage_controller(controller)
|
||||
, m_device_name(move(device_name))
|
||||
, m_max_addressable_block(max_addressable_block)
|
||||
{
|
||||
}
|
||||
|
||||
StorageDevice::StorageDevice(const StorageController& controller, int major, int minor, size_t sector_size, u64 max_addressable_block)
|
||||
StorageDevice::StorageDevice(const StorageController& controller, int major, int minor, size_t sector_size, u64 max_addressable_block, NonnullOwnPtr<KString> device_name)
|
||||
: BlockDevice(major, minor, sector_size)
|
||||
, m_storage_controller(controller)
|
||||
, m_storage_device_name(move(device_name))
|
||||
, m_max_addressable_block(max_addressable_block)
|
||||
{
|
||||
}
|
||||
|
@ -189,6 +191,11 @@ KResultOr<size_t> StorageDevice::write(OpenFileDescription&, u64 offset, const U
|
|||
return pos + remaining;
|
||||
}
|
||||
|
||||
StringView StorageDevice::storage_name() const
|
||||
{
|
||||
return m_storage_device_name->view();
|
||||
}
|
||||
|
||||
bool StorageDevice::can_write(const OpenFileDescription&, size_t offset) const
|
||||
{
|
||||
return offset < (max_addressable_block() * block_size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue