mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
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.
This commit is contained in:
parent
a2601e1308
commit
f64e287b82
29 changed files with 76 additions and 69 deletions
|
@ -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;
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
|
||||
// ^BlockDevice
|
||||
virtual void start_request(AsyncBlockDeviceRequest&) override;
|
||||
virtual String device_name() const override;
|
||||
|
||||
private:
|
||||
PATADiskDevice(const IDEController&, IDEChannel&, DriveType, u8, u8, u8, int major, int minor);
|
||||
|
|
|
@ -102,6 +102,13 @@ bool DiskPartition::can_write(const FileDescription& fd, size_t offset) const
|
|||
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);
|
||||
}
|
||||
|
||||
const char* DiskPartition::class_name() const
|
||||
{
|
||||
return "DiskPartition";
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
|
||||
// ^Device
|
||||
virtual mode_t required_mode() const override { return 0600; }
|
||||
virtual String device_name() const override;
|
||||
|
||||
const DiskPartitionMetadata& metadata() const;
|
||||
|
||||
|
|
|
@ -82,4 +82,11 @@ void RamdiskDevice::start_request(AsyncBlockDeviceRequest& request)
|
|||
}
|
||||
}
|
||||
|
||||
String RamdiskDevice::device_name() const
|
||||
{
|
||||
// FIXME: Try to not hardcode a maximum of 16 partitions per drive!
|
||||
size_t drive_index = minor() / 16;
|
||||
return String::formatted("ramdisk{}", drive_index);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
|
||||
// ^DiskDevice
|
||||
virtual const char* class_name() const override;
|
||||
virtual String device_name() const override;
|
||||
|
||||
bool is_slave() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue