diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/osh/osh.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index 2f592ad..c45d9c8 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -29,6 +29,7 @@ #include <sys/types.h> #include <sys/cdefs.h> +#include <sys/reboot.h> #include <fcntl.h> #include <stddef.h> #include <unistd.h> @@ -44,9 +45,11 @@ #define HELP \ "Default commands:\n" \ - "help - Display this help message\n" \ - "echo - Print the arguments to the console\n" \ - "exit - Exit the shell\n" + "help - Display this help message\n" \ + "echo - Print the arguments to the console\n" \ + "reboot - Reboot the machine\n" \ + "shutdown - Power off the machine\n" \ + "exit - Exit the shell\n" #define PROMPT "[root::osmora]~ " @@ -72,6 +75,18 @@ cmd_exit(int fd, int argc, char *argv[]) } void +cmd_reboot(int fd, int argc, char *argv[]) +{ + cpu_reboot(REBOOT_RESET); +} + +void +cmd_shutdown(int fd, int argc, char *argv[]) +{ + cpu_reboot(REBOOT_POWEROFF | REBOOT_HALT); +} + +void cmd_echo(int fd, int argc, char *argv[]) { for (i = 1; i < argc; i++) { @@ -154,6 +169,8 @@ struct command cmds[] = { {"help", cmd_help}, {"echo", cmd_echo}, {"exit", cmd_exit}, + {"reboot", cmd_reboot}, + {"shutdown", cmd_shutdown}, {NULL, NULL} }; |