mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
Kernel/SysFS: Add /sys/devices/storage directory
This change in fact does the following: 1. Use support for symlinks between /sys/dev/block/ storage device identifier nodes and devices in /sys/devices/storage/{LUN}. 2. Add basic nodes in a /sys/devices/storage/{LUN} directory, to let userspace to know about the device and its details.
This commit is contained in:
parent
22335e53e0
commit
1dbd32488f
19 changed files with 450 additions and 1 deletions
|
@ -7,7 +7,12 @@
|
|||
#include <AK/Memory.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Devices/DeviceManagement.h>
|
||||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/BlockDevicesDirectory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/SymbolicLinkDeviceComponent.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceDirectory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/Directory.h>
|
||||
#include <Kernel/Storage/StorageDevice.h>
|
||||
#include <Kernel/Storage/StorageManagement.h>
|
||||
#include <LibC/sys/ioctl_numbers.h>
|
||||
|
@ -23,6 +28,33 @@ StorageDevice::StorageDevice(LUNAddress logical_unit_number_address, MajorNumber
|
|||
{
|
||||
}
|
||||
|
||||
void StorageDevice::after_inserting()
|
||||
{
|
||||
after_inserting_add_to_device_management();
|
||||
auto sysfs_storage_device_directory = StorageDeviceSysFSDirectory::create(SysFSStorageDirectory::the(), *this);
|
||||
m_sysfs_device_directory = sysfs_storage_device_directory;
|
||||
SysFSStorageDirectory::the().plug({}, *sysfs_storage_device_directory);
|
||||
VERIFY(!m_symlink_sysfs_component);
|
||||
auto sys_fs_component = MUST(SysFSSymbolicLinkDeviceComponent::try_create(SysFSDeviceIdentifiersDirectory::the(), *this, *m_sysfs_device_directory));
|
||||
m_symlink_sysfs_component = sys_fs_component;
|
||||
VERIFY(is_block_device());
|
||||
SysFSBlockDevicesDirectory::the().m_child_components.with([&](auto& list) -> void {
|
||||
list.append(sys_fs_component);
|
||||
});
|
||||
}
|
||||
|
||||
void StorageDevice::will_be_destroyed()
|
||||
{
|
||||
VERIFY(m_symlink_sysfs_component);
|
||||
VERIFY(is_block_device());
|
||||
SysFSBlockDevicesDirectory::the().m_child_components.with([&](auto& list) -> void {
|
||||
list.remove(*m_symlink_sysfs_component);
|
||||
});
|
||||
m_symlink_sysfs_component.clear();
|
||||
SysFSStorageDirectory::the().unplug({}, *m_sysfs_device_directory);
|
||||
before_will_be_destroyed_remove_from_device_management();
|
||||
}
|
||||
|
||||
StringView StorageDevice::class_name() const
|
||||
{
|
||||
return "StorageDevice"sv;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue