commit: ca74af14851cb9aec37acfdb06c0d0bbdb6210d8
parent d9af8c471b58b64f251f776c7b67606c488cfab3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 8 Feb 2025 17:58:32 +0100
src/reboot-stub.c: new stub
Diffstat:
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/init.sh b/init.sh
@@ -25,7 +25,7 @@ build_awk() {
}
build_stubs() {
- for i in ls grep cp getty mount
+ for i in ls grep cp getty mount reboot
do
$CC $CFLAGS -o "/bin/$i" "/src/${i}-stub.c" || die "Failed compiling $i stub"
done
diff --git a/make-root.sh b/make-root.sh
@@ -23,6 +23,7 @@ local_files="
src/cp-stub.c
src/getty-stub.c
src/mount-stub.c
+ src/reboot-stub.c
"
distfiles="
make-4.4.1.tar.gz
diff --git a/src/reboot-stub.c b/src/reboot-stub.c
@@ -0,0 +1,16 @@
+// SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+// SPDX-License-Identifier: MPL-2.0
+#define _GNU_SOURCE
+
+#include <linux/reboot.h> // LINUX_REBOOT_*
+#include <sys/syscall.h> // SYS_*
+#include <unistd.h> // syscall
+#include <stdio.h> // perror
+
+int
+main(void)
+{
+ syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART);
+ perror("reboot");
+ return 1;
+}