mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
Kernel/Devices: Abstract SysFS Device add/remove methods more properly
It is starting to get a little messy with how each device can try to add or remove itself to either /sys/dev/block or /sys/dev/char directories. To better do this, we introduce 4 virtual methods to take care of that, so until we ensure all nodes in /sys/dev/block and /sys/dev/char are actual symlinks, we allow the Device base class to call virtual methods upon insertion or before being destroying, so it add itself elegantly to either of these directories or remove itself when needed. For special cases where we need to create symlinks, we have two virtual methods to be called otherwise to do almost the same thing mentioned before, but to use symlinks instead.
This commit is contained in:
parent
da8d18b263
commit
3af70cb0fc
10 changed files with 107 additions and 46 deletions
|
@ -72,6 +72,14 @@ protected:
|
|||
void after_inserting_add_to_device_management();
|
||||
void before_will_be_destroyed_remove_from_device_management();
|
||||
|
||||
virtual void after_inserting_add_symlink_to_device_identifier_directory() = 0;
|
||||
virtual void before_will_be_destroyed_remove_symlink_from_device_identifier_directory() = 0;
|
||||
|
||||
// FIXME: These methods will be eventually removed after all nodes in /sys/dev/block/ and
|
||||
// /sys/dev/char/ are symlinks.
|
||||
virtual void after_inserting_add_to_device_identifier_directory() = 0;
|
||||
virtual void before_will_be_destroyed_remove_from_device_identifier_directory() = 0;
|
||||
|
||||
private:
|
||||
MajorNumber const m_major { 0 };
|
||||
MinorNumber const m_minor { 0 };
|
||||
|
@ -82,9 +90,12 @@ private:
|
|||
|
||||
Spinlock m_requests_lock;
|
||||
DoublyLinkedList<RefPtr<AsyncDeviceRequest>> m_requests;
|
||||
RefPtr<SysFSDeviceComponent> m_sysfs_component;
|
||||
|
||||
protected:
|
||||
// FIXME: This pointer will be eventually removed after all nodes in /sys/dev/block/ and
|
||||
// /sys/dev/char/ are symlinks.
|
||||
RefPtr<SysFSDeviceComponent> m_sysfs_component;
|
||||
|
||||
RefPtr<SysFSSymbolicLinkDeviceComponent> m_symlink_sysfs_component;
|
||||
RefPtr<SysFSDirectory> m_sysfs_device_directory;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue