Kernel+Userland: Introduce a new way to reboot and poweroff the machine

This change removes the halt and reboot syscalls, and create a new
mechanism to change the power state of the machine.
Instead of how power state was changed until now, put a SysFS node as
writable only for the superuser, that with a defined value, can result
in either reboot or poweroff.
In the future, a power group can be assigned to this node (which will be
the GroupID responsible for power management).

This opens an opportunity to permit to shutdown/reboot without superuser
permissions, so in the future, a userspace daemon can take control of
this node to perform power management operations without superuser
permissions, if we enforce different UserID/GroupID on that node.
This commit is contained in:
Liav A 2021-09-11 12:20:47 +03:00 committed by Andreas Kling
parent 06e95d0fd7
commit 8d0dbdeaac
Notes: sideshowbarker 2024-07-18 04:11:31 +09:00
11 changed files with 161 additions and 97 deletions

View file

@ -6,6 +6,7 @@
#include <Kernel/Firmware/ACPI/Parser.h>
#include <Kernel/Firmware/BIOS.h>
#include <Kernel/Firmware/PowerStateSwitch.h>
#include <Kernel/Firmware/SysFSFirmware.h>
#include <Kernel/Sections.h>
@ -24,8 +25,10 @@ void FirmwareSysFSDirectory::create_components()
VERIFY(!bios_directory_or_error.is_error());
auto acpi_directory_or_error = ACPI::ACPISysFSDirectory::try_create(*this);
VERIFY(!acpi_directory_or_error.is_error());
auto power_state_switch_node = PowerStateSwitchNode::must_create(*this);
m_components.append(bios_directory_or_error.release_value());
m_components.append(acpi_directory_or_error.release_value());
m_components.append(power_state_switch_node);
}
UNMAP_AFTER_INIT FirmwareSysFSDirectory::FirmwareSysFSDirectory()