mirror of
https://github.com/RGBCube/serenity
synced 2025-07-03 00:42:14 +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
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/FileSystem/SysFS/RootDirectory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Directory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceDirectory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/Directory.h>
|
||||
#include <Kernel/Sections.h>
|
||||
#include <Kernel/Storage/StorageDevice.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static SysFSStorageDirectory* s_the { nullptr };
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSStorageDirectory> SysFSStorageDirectory::must_create(SysFSDevicesDirectory const& parent_directory)
|
||||
{
|
||||
auto directory = adopt_ref(*new (nothrow) SysFSStorageDirectory(parent_directory));
|
||||
s_the = directory;
|
||||
return directory;
|
||||
}
|
||||
|
||||
SysFSStorageDirectory& SysFSStorageDirectory::the()
|
||||
{
|
||||
VERIFY(s_the);
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
void SysFSStorageDirectory::plug(Badge<StorageDevice>, StorageDeviceSysFSDirectory& new_device_directory)
|
||||
{
|
||||
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(new_device_directory);
|
||||
auto pointed_component_base_name = MUST(KString::try_create(new_device_directory.name()));
|
||||
auto pointed_component_relative_path = MUST(new_device_directory.relative_path(move(pointed_component_base_name), 0));
|
||||
return {};
|
||||
}));
|
||||
}
|
||||
void SysFSStorageDirectory::unplug(Badge<StorageDevice>, SysFSDirectory& removed_device_directory)
|
||||
{
|
||||
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.remove(removed_device_directory);
|
||||
return {};
|
||||
}));
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT SysFSStorageDirectory::SysFSStorageDirectory(SysFSDevicesDirectory const& parent_directory)
|
||||
: SysFSDirectory(parent_directory)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue