Add support for rebooting the system through halt

Remove reboot
This commit is contained in:
sin 2013-09-17 16:34:26 +01:00
parent 450f930c17
commit d8a51e73b9
3 changed files with 11 additions and 36 deletions

View File

@ -35,7 +35,6 @@ SRC = \
pidof.c \
pivot_root.c \
ps.c \
reboot.c \
rmmod.c \
stat.c \
swapoff.c \

14
halt.c
View File

@ -8,19 +8,22 @@
static void
usage(void)
{
eprintf("usage: %s [-p]\n", argv0);
eprintf("usage: %s [-pr]\n", argv0);
}
int
main(int argc, char *argv[])
{
int pflag = 0;
int pflag = 0, rflag = 0;
int cmd = LINUX_REBOOT_CMD_HALT;
ARGBEGIN {
case 'p':
pflag = 1;
break;
case 'r':
rflag = 1;
break;
default:
usage();
} ARGEND;
@ -30,11 +33,16 @@ main(int argc, char *argv[])
sync();
if (pflag && rflag)
usage();
if (pflag)
cmd = LINUX_REBOOT_CMD_POWER_OFF;
if (rflag)
cmd = LINUX_REBOOT_CMD_RESTART;
if (syscall(__NR_reboot, LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2, cmd, NULL) < 0)
eprintf("reboot:");
eprintf("halt:");
return 0;
}

View File

@ -1,32 +0,0 @@
/* See LICENSE file for copyright and license details. */
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>
#include "reboot.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, LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2,
LINUX_REBOOT_CMD_RESTART, NULL) < 0)
eprintf("reboot:");
return 0;
}