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

reboot: Port to LibMain

First commit to the project! :^)
This commit is contained in:
Wuzado 2022-03-03 23:51:39 +01:00 committed by Brian Gianforcaro
parent 58a865f349
commit 6302ca0043
2 changed files with 10 additions and 14 deletions

View file

@ -162,6 +162,7 @@ target_link_libraries(profile LibMain)
target_link_libraries(ps LibMain) target_link_libraries(ps LibMain)
target_link_libraries(pwd LibMain) target_link_libraries(pwd LibMain)
target_link_libraries(realpath LibMain) target_link_libraries(realpath LibMain)
target_link_libraries(reboot LibMain)
target_link_libraries(rev LibMain) target_link_libraries(rev LibMain)
target_link_libraries(rm LibMain) target_link_libraries(rm LibMain)
target_link_libraries(rmdir LibMain) target_link_libraries(rmdir LibMain)

View file

@ -5,21 +5,16 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <fcntl.h> #include <LibCore/Stream.h>
#include <stdio.h> #include <LibMain/Main.h>
#include <unistd.h>
int main(int, char**) ErrorOr<int> serenity_main(Main::Arguments)
{ {
int power_state_switch_node = open("/sys/firmware/power_state", O_WRONLY); auto file = TRY(Core::Stream::File::open("/sys/firmware/power_state", Core::Stream::OpenMode::Write));
if (power_state_switch_node < 0) {
perror("open"); const String file_contents = "1";
return 1; TRY(file->write(file_contents.bytes()));
} file->close();
const char* value = "1";
if (write(power_state_switch_node, value, 1) < 0) {
perror("write");
return 1;
}
return 0; return 0;
} }