1 /* reboot.c - Restart, halt or powerdown the system.
2 *
3 * Copyright 2013 Elie De Brauwer <eliedebrauwer@gmail.com>
4
5 USE_REBOOT(NEWTOY(reboot, "n", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
6 USE_REBOOT(OLDTOY(halt, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
7 USE_REBOOT(OLDTOY(poweroff, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
8
9 config REBOOT
10 bool "reboot"
11 default y
12 help
13 usage: reboot/halt/poweroff [-n]
14
15 Restart, halt or powerdown the system.
16
17 -n Don't sync before stopping the system.
18 */
19
20 #define FOR_reboot
21 #include "toys.h"
22 #include <sys/reboot.h>
23
reboot_main(void)24 void reboot_main(void)
25 {
26 int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF};
27
28 if (!(toys.optflags & FLAG_n)) sync();
29
30 toys.exitval = reboot(types[stridx("hp", *toys.which->name)+1]);
31 }
32