mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
reboot: Port to LibMain
First commit to the project! :^)
This commit is contained in:
parent
58a865f349
commit
6302ca0043
2 changed files with 10 additions and 14 deletions
|
@ -162,6 +162,7 @@ target_link_libraries(profile LibMain)
|
|||
target_link_libraries(ps LibMain)
|
||||
target_link_libraries(pwd LibMain)
|
||||
target_link_libraries(realpath LibMain)
|
||||
target_link_libraries(reboot LibMain)
|
||||
target_link_libraries(rev LibMain)
|
||||
target_link_libraries(rm LibMain)
|
||||
target_link_libraries(rmdir LibMain)
|
||||
|
|
|
@ -5,21 +5,16 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
int main(int, char**)
|
||||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
int power_state_switch_node = open("/sys/firmware/power_state", O_WRONLY);
|
||||
if (power_state_switch_node < 0) {
|
||||
perror("open");
|
||||
return 1;
|
||||
}
|
||||
const char* value = "1";
|
||||
if (write(power_state_switch_node, value, 1) < 0) {
|
||||
perror("write");
|
||||
return 1;
|
||||
}
|
||||
auto file = TRY(Core::Stream::File::open("/sys/firmware/power_state", Core::Stream::OpenMode::Write));
|
||||
|
||||
const String file_contents = "1";
|
||||
TRY(file->write(file_contents.bytes()));
|
||||
file->close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue