[klibc] Clean up the halt program somewhat; add symlinks
Minor source cleanup in the halt program; add symlinks to
"reboot" and "poweroff".
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
index f760a6b..b3b8d8a 100644
--- a/usr/utils/Kbuild
+++ b/usr/utils/Kbuild
@@ -4,7 +4,7 @@
progs := chroot dd mkdir mkfifo mount pivot_root umount
progs += true false sleep ln nuke minips cat
-progs += insmod uname
+progs += insmod uname halt
static-y := $(addprefix static/, $(progs))
shared-y := $(addprefix shared/, $(progs))
@@ -42,6 +42,16 @@
shared/insmod-y := insmod.o
static/uname-y := uname.o
shared/uname-y := uname.o
+static/halt-y := halt.o
+shared/halt-y := halt.o
+
+# Additionally linked targets
+always := static/reboot static/poweroff shared/reboot shared/poweroff
+
+$(obj)/static/reboot $(obj)/static/poweroff: $(obj)/static/halt
+ $(call cmd,ln)
+$(obj)/shared/reboot $(obj)/shared/poweroff: $(obj)/shared/halt
+ $(call cmd,ln)
# Clean deletes the static and shared dir
clean-dirs := static shared
diff --git a/usr/utils/halt.c b/usr/utils/halt.c
index 77ca72d..a6656b5 100644
--- a/usr/utils/halt.c
+++ b/usr/utils/halt.c
@@ -1,12 +1,14 @@
+#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/reboot.h>
+#include <klibc/compiler.h>
-static volatile void usage()
+static __noreturn usage(void)
{
static char mesg[] = "Usage: {halt|reboot|poweroff} [-n]\n";
write(2, mesg, sizeof(mesg) - 1);
- _exit(1);
+ exit(1);
}
int main(int argc, char *argv[])