1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:35:09 +00:00

Kernel: Expose device presence in /sys/dev/char and /sys/dev/block

These files are not marked as block devices or character devices so they
are not meant to be used as device nodes. The filenames are formatted to
the pattern "major:minor", but a Userland program need to call the parse
these format and inspect the the major and minor numbers and create the
real device nodes in /dev.

Later on, it might be a good idea to ensure we don't create new
SysFSComponents on the heap for each Device, but rather generate
them only when required (and preferably to not create a SysFSComponent
at all if possible).
This commit is contained in:
Liav A 2021-08-14 11:40:37 +03:00 committed by Andreas Kling
parent 009feefee0
commit 6a9c717a30
5 changed files with 183 additions and 2 deletions

View file

@ -6,6 +6,7 @@
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <Kernel/Devices/Device.h>
#include <Kernel/FileSystem/SysFS.h>
#include <Kernel/Sections.h>
@ -35,6 +36,11 @@ UNMAP_AFTER_INIT void SysFSComponentRegistry::register_new_component(SysFSCompon
m_root_directory->m_components.append(component);
}
SysFSComponentRegistry::DevicesList& SysFSComponentRegistry::devices_list()
{
return m_devices_list;
}
NonnullRefPtr<SysFSRootDirectory> SysFSRootDirectory::create()
{
return adopt_ref(*new (nothrow) SysFSRootDirectory);
@ -57,7 +63,9 @@ SysFSRootDirectory::SysFSRootDirectory()
: SysFSDirectory(".")
{
auto buses_directory = SysFSBusDirectory::must_create(*this);
auto devices_directory = SysFSDevicesDirectory::must_create(*this);
m_components.append(buses_directory);
m_components.append(devices_directory);
m_buses_directory = buses_directory;
}