mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
Kernel: Remove the /sys/kernel/constants directory
The name for this directory is a bit awkward. Also, the distinction of constant information is not really valuable as I thought it would be, so let's bring that information back into the /sys/kernel directory.
This commit is contained in:
parent
751aae77bc
commit
aee5f4e4b2
8 changed files with 32 additions and 88 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Constants/ConstantInformation.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/ConstantInformation.h>
|
||||
#include <Kernel/Sections.h>
|
||||
#include <Kernel/Tasks/Process.h>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Try.h>
|
||||
#include <Kernel/Boot/CommandLine.h>
|
||||
#include <Kernel/FileSystem/SysFS/Component.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Constants/ConstantInformation.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Constants/Directory.h>
|
||||
#include <Kernel/Library/KBufferBuilder.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSGlobalKernelConstantsDirectory> SysFSGlobalKernelConstantsDirectory::must_create(SysFSDirectory const& parent_directory)
|
||||
{
|
||||
auto global_constants_directory = adopt_ref_if_nonnull(new (nothrow) SysFSGlobalKernelConstantsDirectory(parent_directory)).release_nonnull();
|
||||
MUST(global_constants_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
{
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
MUST(builder.appendff("{}", kernel_load_base));
|
||||
auto load_base_buffer = builder.build();
|
||||
VERIFY(load_base_buffer);
|
||||
list.append(SysFSSystemConstantInformation::must_create(*global_constants_directory, load_base_buffer.release_nonnull(), S_IRUSR, SysFSSystemConstantInformation::ReadableByJailedProcesses::No, SysFSSystemConstantInformation::NodeName::LoadBase));
|
||||
}
|
||||
|
||||
{
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
MUST(builder.append(kernel_command_line().string()));
|
||||
MUST(builder.append('\n'));
|
||||
auto command_line_buffer = builder.build();
|
||||
VERIFY(command_line_buffer);
|
||||
list.append(SysFSSystemConstantInformation::must_create(*global_constants_directory, command_line_buffer.release_nonnull(), S_IRUSR | S_IRGRP | S_IROTH, SysFSSystemConstantInformation::ReadableByJailedProcesses::No, SysFSSystemConstantInformation::NodeName::CommandLine));
|
||||
}
|
||||
|
||||
{
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
MUST(builder.append(kernel_command_line().system_mode()));
|
||||
MUST(builder.append('\n'));
|
||||
auto system_mode_buffer = builder.build();
|
||||
VERIFY(system_mode_buffer);
|
||||
list.append(SysFSSystemConstantInformation::must_create(*global_constants_directory, system_mode_buffer.release_nonnull(), S_IRUSR | S_IRGRP | S_IROTH, SysFSSystemConstantInformation::ReadableByJailedProcesses::No, SysFSSystemConstantInformation::NodeName::SystemMode));
|
||||
}
|
||||
return {};
|
||||
}));
|
||||
return global_constants_directory;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT SysFSGlobalKernelConstantsDirectory::SysFSGlobalKernelConstantsDirectory(SysFSDirectory const& parent_directory)
|
||||
: SysFSDirectory(parent_directory)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/FileSystem/SysFS/Component.h>
|
||||
#include <Kernel/FileSystem/SysFS/RootDirectory.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class SysFSGlobalKernelConstantsDirectory : public SysFSDirectory {
|
||||
public:
|
||||
static NonnullRefPtr<SysFSGlobalKernelConstantsDirectory> must_create(SysFSDirectory const&);
|
||||
virtual StringView name() const override { return "constants"sv; }
|
||||
|
||||
private:
|
||||
explicit SysFSGlobalKernelConstantsDirectory(SysFSDirectory const&);
|
||||
};
|
||||
|
||||
}
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Try.h>
|
||||
#include <Kernel/Boot/CommandLine.h>
|
||||
#include <Kernel/FileSystem/SysFS/Component.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/CPUInfo.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Configuration/Directory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Constants/Directory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/ConstantInformation.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Directory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/DiskUsage.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/GlobalInformation.h>
|
||||
|
@ -30,9 +31,7 @@ namespace Kernel {
|
|||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSGlobalKernelStatsDirectory> SysFSGlobalKernelStatsDirectory::must_create(SysFSRootDirectory const& root_directory)
|
||||
{
|
||||
auto global_kernel_stats_directory = adopt_ref_if_nonnull(new (nothrow) SysFSGlobalKernelStatsDirectory(root_directory)).release_nonnull();
|
||||
auto global_constants_directory = SysFSGlobalKernelConstantsDirectory::must_create(*global_kernel_stats_directory);
|
||||
MUST(global_kernel_stats_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(global_constants_directory);
|
||||
list.append(SysFSDiskUsage::must_create(*global_kernel_stats_directory));
|
||||
list.append(SysFSMemoryStatus::must_create(*global_kernel_stats_directory));
|
||||
list.append(SysFSSystemStatistics::must_create(*global_kernel_stats_directory));
|
||||
|
@ -48,6 +47,32 @@ UNMAP_AFTER_INIT NonnullRefPtr<SysFSGlobalKernelStatsDirectory> SysFSGlobalKerne
|
|||
|
||||
list.append(SysFSGlobalNetworkStatsDirectory::must_create(*global_kernel_stats_directory));
|
||||
list.append(SysFSKernelConfigurationDirectory::must_create(*global_kernel_stats_directory));
|
||||
|
||||
{
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
MUST(builder.appendff("{}", kernel_load_base));
|
||||
auto load_base_buffer = builder.build();
|
||||
VERIFY(load_base_buffer);
|
||||
list.append(SysFSSystemConstantInformation::must_create(*global_kernel_stats_directory, load_base_buffer.release_nonnull(), S_IRUSR, SysFSSystemConstantInformation::ReadableByJailedProcesses::No, SysFSSystemConstantInformation::NodeName::LoadBase));
|
||||
}
|
||||
|
||||
{
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
MUST(builder.append(kernel_command_line().string()));
|
||||
MUST(builder.append('\n'));
|
||||
auto command_line_buffer = builder.build();
|
||||
VERIFY(command_line_buffer);
|
||||
list.append(SysFSSystemConstantInformation::must_create(*global_kernel_stats_directory, command_line_buffer.release_nonnull(), S_IRUSR | S_IRGRP | S_IROTH, SysFSSystemConstantInformation::ReadableByJailedProcesses::No, SysFSSystemConstantInformation::NodeName::CommandLine));
|
||||
}
|
||||
|
||||
{
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
MUST(builder.append(kernel_command_line().system_mode()));
|
||||
MUST(builder.append('\n'));
|
||||
auto system_mode_buffer = builder.build();
|
||||
VERIFY(system_mode_buffer);
|
||||
list.append(SysFSSystemConstantInformation::must_create(*global_kernel_stats_directory, system_mode_buffer.release_nonnull(), S_IRUSR | S_IRGRP | S_IROTH, SysFSSystemConstantInformation::ReadableByJailedProcesses::No, SysFSSystemConstantInformation::NodeName::SystemMode));
|
||||
}
|
||||
return {};
|
||||
}));
|
||||
return global_kernel_stats_directory;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue