mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +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: 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(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)
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue