Remove ability to pass commands to bootloader
This commit is contained in:
parent
4a711bea63
commit
57c748b968
14 changed files with 35 additions and 123 deletions
|
@ -29,12 +29,11 @@ void usage( void );
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -47,7 +46,6 @@ char **argv;
|
|||
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++;
|
||||
|
@ -68,15 +66,6 @@ char **argv;
|
|||
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();
|
||||
}
|
||||
|
@ -89,11 +78,6 @@ char **argv;
|
|||
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;
|
||||
|
@ -135,7 +119,7 @@ char **argv;
|
|||
|
||||
sync();
|
||||
|
||||
reboot(flag, monitor_code, strlen(monitor_code));
|
||||
reboot(flag);
|
||||
fprintf(stderr, "%s: reboot(): %s\n", prog, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
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
|
||||
*/
|
||||
|
@ -63,7 +62,6 @@ long wait_time=0L;
|
|||
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;
|
||||
|
||||
|
@ -132,7 +130,7 @@ char *argv[];
|
|||
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++) {
|
||||
|
@ -149,23 +147,9 @@ char *argv[];
|
|||
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;
|
||||
|
@ -256,7 +240,6 @@ char *argv[];
|
|||
unlink(NOLOGIN);
|
||||
|
||||
HALT[1][1] = reboot_flag;
|
||||
if (reboot_flag == 'x') HALT[2] = reboot_code;
|
||||
#if __minix_vmd
|
||||
execv("/usr/sbin/halt", HALT);
|
||||
#else
|
||||
|
@ -274,16 +257,14 @@ char *argv[];
|
|||
|
||||
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);
|
||||
|
|
|
@ -420,9 +420,6 @@
|
|||
|
||||
/* 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 */
|
||||
|
|
|
@ -33,7 +33,7 @@ struct rs_pci;
|
|||
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);
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
#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
|
||||
|
|
|
@ -356,7 +356,7 @@ void psignal(int, const char *);
|
|||
#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
|
||||
|
|
|
@ -118,10 +118,6 @@ __dead void arch_shutdown(int how)
|
|||
reset();
|
||||
}
|
||||
|
||||
if (how == RBT_DEFAULT) {
|
||||
how = RBT_RESET;
|
||||
}
|
||||
|
||||
switch (how) {
|
||||
case RBT_HALT:
|
||||
/* Stop */
|
||||
|
@ -134,6 +130,7 @@ __dead void arch_shutdown(int how)
|
|||
NOT_REACHABLE;
|
||||
|
||||
default:
|
||||
case RBT_DEFAULT:
|
||||
case RBT_REBOOT:
|
||||
case RBT_RESET:
|
||||
/* Reset the system by forcing a processor shutdown.
|
||||
|
|
|
@ -349,7 +349,7 @@ void minix_shutdown(timer_t *tp)
|
|||
{
|
||||
/* 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
|
||||
/*
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
*
|
||||
* 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"
|
||||
|
@ -23,20 +20,6 @@ int do_abort(struct proc * caller, message * m_ptr)
|
|||
*/
|
||||
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) */
|
||||
|
|
|
@ -11,17 +11,10 @@
|
|||
#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);
|
||||
}
|
||||
|
|
|
@ -2,20 +2,12 @@
|
|||
#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));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ reboot \- close down the system or reboot
|
|||
|
||||
#include <unistd.h>
|
||||
|
||||
int reboot(int \fIhow\fP, ...)
|
||||
int reboot(int \fIhow\fP)
|
||||
.fi
|
||||
.ft P
|
||||
.SH DESCRIPTION
|
||||
|
@ -18,11 +18,12 @@ down depending on
|
|||
.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
|
||||
|
@ -30,16 +31,12 @@ servers using the
|
|||
.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.
|
||||
|
@ -55,8 +52,5 @@ the return value is -1 and an error is indicated by
|
|||
.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)
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
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
|
||||
|
@ -55,20 +53,16 @@ system can now be powered off. This is the default.
|
|||
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
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#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
|
||||
|
|
Loading…
Reference in a new issue