mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
reboot: Port to LibMain
First commit to the project! :^)
This commit is contained in:
parent
58a865f349
commit
6302ca0043
Notes:
sideshowbarker
2024-07-17 17:58:41 +09:00
Author: https://github.com/Wuzado 🔰 Commit: https://github.com/SerenityOS/serenity/commit/6302ca0043 Pull-request: https://github.com/SerenityOS/serenity/pull/12865 Reviewed-by: https://github.com/bgianfo ✅
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…
Reference in a new issue