2014-02-07 16:35:51 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <sys/syscall.h>
|
2014-06-30 18:03:41 +00:00
|
|
|
|
2014-02-07 16:35:51 +00:00
|
|
|
#include <stdio.h>
|
2014-06-30 18:03:41 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2014-02-07 16:35:51 +00:00
|
|
|
#include "reboot.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
2015-09-07 11:02:38 +00:00
|
|
|
eprintf("usage: %s -h | -s\n", argv0);
|
2014-02-07 16:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2015-09-07 11:02:38 +00:00
|
|
|
int hflag = 0, sflag = 0, cmd;
|
2014-02-07 16:35:51 +00:00
|
|
|
|
|
|
|
ARGBEGIN {
|
|
|
|
case 'h':
|
|
|
|
hflag = 1;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
sflag = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
} ARGEND;
|
|
|
|
|
2015-09-07 11:02:38 +00:00
|
|
|
if (argc || !(hflag ^ sflag))
|
2014-02-07 16:35:51 +00:00
|
|
|
usage();
|
|
|
|
|
|
|
|
cmd = hflag ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF;
|
|
|
|
|
2015-09-07 11:02:38 +00:00
|
|
|
if (syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
|
|
|
|
cmd, NULL) < 0)
|
2014-02-07 16:35:51 +00:00
|
|
|
eprintf("reboot:");
|
2015-09-07 11:02:38 +00:00
|
|
|
|
2014-10-02 22:45:25 +00:00
|
|
|
return 0;
|
2014-02-07 16:35:51 +00:00
|
|
|
}
|