commit 4a8e5b14ab28485d797c4f39e1bcde81a536fb81
parent 423e0020982122a7d7d4f5e2e2e62f0ba795de19
Author: sin <sin@2f30.org>
Date: Fri, 9 Aug 2013 14:55:50 +0100
Add reboot(8)
This is a very barebones reboot cmd. Please make sure that your
system is in a proper state to reboot before using this. This is
likely only useful for very barebones systems like an emergency
shell or similar.
Normally this command would be part of an actual init system.
Diffstat:
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -21,6 +21,7 @@ SRC += \
insmod.c \
lsmod.c \
mkswap.c \
+ reboot.c \
rmmod.c
endif
diff --git a/reboot.c b/reboot.c
@@ -0,0 +1,31 @@
+/* See LICENSE file for copyright and license details. */
+#include <linux/reboot.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "util.h"
+
+static void
+usage(void)
+{
+ eprintf("usage: %s\n", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc > 0)
+ usage();
+
+ sync();
+
+ if (syscall(__NR_reboot, 0xfee1dead, 672274793,
+ LINUX_REBOOT_CMD_RESTART, NULL) < 0)
+ eprintf("reboot:");
+ return 0;
+}