int main( int argc, char *argv[] );
char *prog;
-char *reboot_code = "delay; boot";
void
usage()
{
- fprintf(stderr, "Usage: %s [-hrRfpd] [-x reboot-code]\n", prog);
+ fprintf(stderr, "Usage: %s [-hrRfpd]\n", prog);
exit(1);
}
int fast = 0; /* fast halt/reboot, don't bother being nice. */
int i;
struct stat dummy;
- char *monitor_code = "";
pid_t pid;
if ((prog = strrchr(argv[0],'/')) == NULL) prog = argv[0]; else prog++;
case 'd': flag = RBT_DEFAULT; break;
case 'p': flag = RBT_POWEROFF; break;
case 'f': fast = 1; break;
- case 'x':
- flag = RBT_MONITOR;
- if (*opt == 0) {
- if (i == argc) usage();
- opt = argv[i++];
- }
- monitor_code = opt;
- opt = "";
- break;
default:
usage();
}
exit(1);
}
- if (flag == RBT_REBOOT) {
- flag = RBT_MONITOR; /* set monitor code for reboot */
- monitor_code = reboot_code;
- }
-
if (stat("/usr/bin", &dummy) < 0) {
/* It seems that /usr isn't present, let's assume "-f." */
fast = 1;
sync();
- reboot(flag, monitor_code, strlen(monitor_code));
+ reboot(flag);
fprintf(stderr, "%s: reboot(): %s\n", prog, strerror(errno));
return 1;
}
New Minix options:
-C: crash check, i.e. is the last wtmp entry a shutdown entry?
- -x: let the monitor execute the given code
-R: reset the system
-d: default CTRL-ALT-DEL shutdown for current bootloader
*/
char message[1024];
char info[80];
int reboot_flag='h'; /* default is halt */
-char *reboot_code=""; /* optional monitor code */
int info_min, info_hour;
char *prog;
char *opt;
int tty;
static char HALT1[] = "-?";
- static char *HALT[] = { "shutdown", HALT1, NULL, NULL };
+ static char *HALT[] = { "shutdown", HALT1, NULL };
/* Parse options. */
for (i = 1; i < argc && argv[i][0] == '-'; i++) {
case 'h':
case 'r':
case 'p':
- case 'x':
case 'd':
- reboot_flag = *opt;
- if (reboot_flag == 'x') {
- if (*++opt == 0) {
- if (++i == argc) {
- fprintf (stderr,"shutdown: option '-x' requires an argument\n");
- usage();
- }
- opt=argv[i];
- }
- reboot_code=opt;
- opt+=strlen(opt)-1;
- }
- break;
case 'R':
- reboot_flag = 'R';
+ reboot_flag = *opt;
break;
case 'm':
want_message = 1;
unlink(NOLOGIN);
HALT[1][1] = reboot_flag;
- if (reboot_flag == 'x') HALT[2] = reboot_code;
#if __minix_vmd
execv("/usr/sbin/halt", HALT);
#else
void usage()
{
- fputs("Usage: shutdown [-hrRpmkd] [-x code] [time [message]]\n", stderr);
+ fputs("Usage: shutdown [-hrRpmkd] [time [message]]\n", stderr);
fputs(" -h -> halt system after shutdown\n", stderr);
fputs(" -r -> reboot system after shutdown\n", stderr);
fputs(" -R -> reset system after shutdown\n", stderr);
fputs(" -p -> power system off after shutdown\n", stderr);
- fputs(" -x -> return to the monitor doing...\n", stderr);
fputs(" -d -> default CTRL-ALT-DEL shutdown for current bootloader\n", stderr);
fputs(" -m -> read a shutdown message from standard input\n", stderr);
fputs(" -k -> stop an already running shutdown\n", stderr);
- fputs(" code -> boot monitor code to be executed\n", stderr);
fputs(" time -> keyword ``now'', minutes before shutdown ``+5'',\n", stderr);
fputs(" or absolute time specification ``11:20''\n", stderr);
fputs(" message -> short shutdown message\n", stderr);
/* Field names for SYS_ABORT. */
#define ABRT_HOW m1_i1 /* RBT_REBOOT, RBT_HALT, etc. */
-#define ABRT_MON_ENDPT m1_i2 /* process where monitor params are */
-#define ABRT_MON_LEN m1_i3 /* length of monitor params */
-#define ABRT_MON_ADDR m1_p1 /* virtual address of monitor params */
/* Field names for SYS_IOPENABLE. */
#define IOP_ENDPT m2_l1 /* target endpoint */
int _taskcall(endpoint_t who, int syscallnr, message *msgptr);
int _kernel_call(int syscallnr, message *msgptr);
-int sys_abort(int how, ...);
+int sys_abort(int how);
int sys_enable_iop(endpoint_t proc_ep);
int sys_exec(endpoint_t proc_ep, char *ptr, char *aout, vir_bytes
initpc);
#define RBT_HALT 0 /* shutdown and return to monitor */
#define RBT_REBOOT 1 /* reboot the system through the monitor */
#define RBT_PANIC 2 /* a server panics */
-#define RBT_MONITOR 3 /* let the monitor do this */
+#define RBT_POWEROFF 3 /* power off, reset if not possible */
#define RBT_RESET 4 /* hard reset the system */
#define RBT_DEFAULT 5 /* return to monitor, reset if not possible */
-#define RBT_POWEROFF 6 /* power off, reset if not possible */
-#define RBT_INVALID 7 /* first invalid reboot flag */
+#define RBT_INVALID 6 /* first invalid reboot flag */
#endif
#endif /* __PSIGNAL_DECLARED */
int rcmd(char **, int, const char *, const char *, const char *, int *);
#ifdef __minix
-int reboot(int, ...);
+int reboot(int);
#else
int reboot(int, char *);
#endif
reset();
}
- if (how == RBT_DEFAULT) {
- how = RBT_RESET;
- }
-
switch (how) {
case RBT_HALT:
/* Stop */
poweroff();
NOT_REACHABLE;
- default:
+ default:
+ case RBT_DEFAULT:
case RBT_REBOOT:
case RBT_RESET:
/* Reset the system by forcing a processor shutdown.
{
/* This function is called from prepare_shutdown or stop_sequence to bring
* down MINIX. How to shutdown is in the argument: RBT_HALT (return to the
- * monitor), RBT_MONITOR (execute given code), RBT_RESET (hard reset).
+ * monitor), RBT_RESET (hard reset).
*/
#ifdef CONFIG_SMP
/*
*
* The parameters for this kernel call are:
* m1_i1: ABRT_HOW (how to abort, possibly fetch monitor params)
- * m1_i2: ABRT_MON_ENDPT (proc nr to get monitor params from)
- * m1_i3: ABRT_MON_LEN (length of monitor params)
- * m1_p1: ABRT_MON_ADDR (virtual address of params)
*/
#include "kernel/system.h"
*/
int how = m_ptr->ABRT_HOW;
- /* See if the monitor is to run the specified instructions. */
- if (how == RBT_MONITOR) {
- int p;
- static char paramsbuffer[512];
- int len;
- len = MIN(m_ptr->ABRT_MON_LEN, sizeof(paramsbuffer)-1);
-
- if((p=data_copy(m_ptr->ABRT_MON_ENDPT, (vir_bytes) m_ptr->ABRT_MON_ADDR,
- KERNEL, (vir_bytes) paramsbuffer, len)) != OK) {
- return p;
- }
- paramsbuffer[len] = '\0';
- }
-
/* Now prepare to shutdown MINIX. */
prepare_shutdown(how);
return(OK); /* pro-forma (really EDISASTER) */
#include <sys/reboot.h>
#include <stdarg.h>
-int reboot(int how, ...)
+int reboot(int how)
{
message m;
- va_list ap;
-
- va_start(ap, how);
- if ((m.m1_i1 = how) == RBT_MONITOR) {
- m.m1_p1 = va_arg(ap, char *);
- m.m1_i2 = va_arg(ap, size_t);
- }
- va_end(ap);
+ m.m1_i1 = how;
return _syscall(PM_PROC_NR, REBOOT, &m);
}
#include <stdarg.h>
#include <unistd.h>
-int sys_abort(int how, ...)
+int sys_abort(int how)
{
/* Something awful has happened. Abandon ship. */
message m;
- va_list ap;
-
- va_start(ap, how);
- if ((m.ABRT_HOW = how) == RBT_MONITOR) {
- m.ABRT_MON_ENDPT = va_arg(ap, int);
- m.ABRT_MON_ADDR = va_arg(ap, char *);
- m.ABRT_MON_LEN = va_arg(ap, size_t);
- }
- va_end(ap);
+ m.ABRT_HOW = how;
return(_kernel_call(SYS_ABORT, &m));
}
#include <unistd.h>
-int reboot(int \fIhow\fP, ...)
+int reboot(int \fIhow\fP)
.fi
.ft P
.SH DESCRIPTION
.IR how :
.PP
.TP 5
-.BI "reboot(RBT_HALT)"
-Halt the system and return to the monitor prompt.
+.BI "reboot(RBT_DEFAULT)"
+Default shut-down action, the same as used when CTRL+ALT+DEL is pressed
+on the keyboard.
.TP
-.BI "reboot(RBT_REBOOT)"
-Reboot the system by letting the monitor execute the "boot" command.
+.BI "reboot(RBT_HALT)"
+Halt the system.
.TP
.BI "reboot(RBT_PANIC)"
Cause a system panic. This is not normally done from user mode, but by
.B sys_abort()
kernel call.
.TP
-.BI "reboot(RBT_MONITOR" ", code, length" ")"
-Halt the system and let the monitor execute the given code of the given
-length.
-.RI ( code
-is of type
-.B "char *"
-and
-.I length
-of type
-.BR size_t .)
+.BI "reboot(RBT_POWEROFF)"
+Power off the system if possible, reset otherwise.
+.TP
+.BI "reboot(RBT_REBOOT)"
+Reboot the system with a software reset (currently not supported, so
+a hardware reset is used).
.TP
.BI "reboot(RBT_RESET)"
Reboot the system with a hardware reset.
.BR reboot (8),
.BR halt (8),
.BR sync (2).
-.SH NOTES
-MINIX 3 can not return to the monitor if running in real mode. This means
-that most of the reboot functions will change to a system reset.
.SH AUTHOR
Edvard Tuinder (v892231@si.hhs.NL)
shutdown \- graciously close the system down
.SH SYNOPSIS
.B shutdown
-.RB [ \-hrRmkd ]
-.RB [ \-x
-.IR code ]
+.RB [ \-hrRmkpd ]
.RI [ time-specification
.RI [ message ]]
.SH DESCRIPTION
This flag indicates that the system should reboot after shutting down.
.TP
.B \-R
-Reboot the system by resetting it. Normally the kernel will try to return
-to the Boot Monitor. With
+Reboot the system by resetting it. With
.B \-R
the system will receive a hardware reset.
.TP
-.B \-d
-Default CTRL-ALT-DEL shutdown for current bootloader; drops to the boot
-monitor is possible and resets otherwise.
+.B \-p
+Attempt to power off the machine after shutting down; reset if that
+is not possible on the current hardware.
.TP
-.BI \-x " code"
-Halt the system and let the Monitor execute the given code as if typed at
-the monitor prompt. You can for instance use
-.B "\-x 'boot hd0'"
-as a very fast way to reboot "from the top."
+.B \-d
+Default CTRL-ALT-DEL shutdown.
.TP
.B \-m
Allows the operator to type a shutdown message on standard input, that will
#define sig_how m2_i1
#define sig_context m2_p1
#define reboot_flag m1_i1
-#define reboot_code m1_p1
-#define reboot_strlen m1_i2
#define svrctl_req m2_i1
#define svrctl_argp m2_p1
#define stime m2_l1