1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:17:35 +00:00

Kernel: Introduce global variables and stats in /sys/kernel directory

The ProcFS is an utter mess currently, so let's start move things that
are not related to processes-info. To ensure it's done in a sane manner,
we start by duplicating all /proc/ global nodes to the /sys/kernel/
directory, then we will move Userland to use the new directory so the
old directory nodes can be removed from the /proc directory.
This commit is contained in:
Liav A 2022-10-14 20:51:51 +03:00 committed by Andrew Kaster
parent db2e1bfa02
commit a91589c09b
58 changed files with 2122 additions and 1 deletions

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Error.h>
#include <AK/Try.h>
#include <Kernel/FileSystem/SysFS/Component.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/CapsLockRemap.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/Directory.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/UBSANDeadly.h>
namespace Kernel {
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSGlobalKernelVariablesDirectory> SysFSGlobalKernelVariablesDirectory::must_create(SysFSDirectory const& parent_directory)
{
auto global_variables_directory = adopt_lock_ref_if_nonnull(new (nothrow) SysFSGlobalKernelVariablesDirectory(parent_directory)).release_nonnull();
MUST(global_variables_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
list.append(SysFSCapsLockRemap::must_create(*global_variables_directory));
list.append(SysFSDumpKmallocStacks::must_create(*global_variables_directory));
list.append(SysFSUBSANDeadly::must_create(*global_variables_directory));
return {};
}));
return global_variables_directory;
}
UNMAP_AFTER_INIT SysFSGlobalKernelVariablesDirectory::SysFSGlobalKernelVariablesDirectory(SysFSDirectory const& parent_directory)
: SysFSDirectory(parent_directory)
{
}
}