[ipxe-devel] Patch: Add support for rebootdelay
Earl Chew
earl_chew at yahoo.com
Thu Nov 5 15:08:49 UTC 2015
commit af760211bc3cf5c86e28ade72cc4f6b0144da0d3
Author: Earl Chew <earl_chew at yahoo.com>
Date: Sun Nov 1 15:59:49 2015 -0800
[rebootdelay] Add support for rebootdelay
Signed-off-by: Earl Chew <earl_chew at yahoo.com>
diff --git a/src/cmdline.c b/src/cmdline.c
index 78a358d..952d903 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -47,6 +47,9 @@ int cmdline_pause_quiet;
/** WIM boot index */
unsigned int cmdline_index;
+/** Delay before reboot */
+unsigned int cmdline_rebootdelay;
+
/**
* Process command line
*
@@ -100,6 +103,15 @@ void process_cmdline ( char *cmdline ) {
cmdline_index = strtoul ( value, &endp, 0 );
if ( *endp )
die ( "Invalid index \"%s\"\n", value );
+ } else if ( strcmp ( key, "rebootdelay" ) == 0 ) {
+ unsigned int delay;
+ if ( ( ! value ) || ( ! value[0] ) )
+ die ( "Argument \"rebootdelay\" "
+ "needs a value\n" );
+ delay = strtoul ( value, &endp, 0 );
+ if ( *endp )
+ die ( "Invalid rebootdelay \"%s\"\n", value );
+ cmdline_rebootdelay = delay;
} else if ( strcmp ( key, "initrdfile" ) == 0 ) {
/* Ignore this keyword to allow for use with syslinux */
} else if ( key == cmdline ) {
diff --git a/src/cmdline.h b/src/cmdline.h
index 5559ebd..aae5af8 100644
--- a/src/cmdline.h
+++ b/src/cmdline.h
@@ -32,6 +32,7 @@ extern int cmdline_gui;
extern int cmdline_pause;
extern int cmdline_pause_quiet;
extern unsigned int cmdline_index;
+extern unsigned int cmdline_rebootdelay;
extern void process_cmdline ( char *cmdline );
#endif /* _CMDLINE_H */
diff --git a/src/die.c b/src/die.c
index 54e287e..55b1de9 100644
--- a/src/die.c
+++ b/src/die.c
@@ -27,6 +27,8 @@
#include <stdarg.h>
#include <stdio.h>
#include "wimboot.h"
+#include "cmdline.h"
+#include "pause.h"
#include "efi.h"
/**
@@ -38,6 +40,7 @@
void die ( const char *fmt, ... ) {
EFI_BOOT_SERVICES *bs;
EFI_RUNTIME_SERVICES *rs;
+ int wait;
va_list args;
/* Print message */
@@ -45,6 +48,13 @@ void die ( const char *fmt, ... ) {
vprintf ( fmt, args );
va_end ( args );
+ wait = 1;
+ if ( cmdline_rebootdelay ) {
+ printf ( "Press a key to pause reboot..." );
+ wait = revocable_pause( cmdline_rebootdelay );
+ printf ( "\n" );
+ }
+
/* Reboot or exit as applicable */
if ( efi_systab ) {
@@ -59,9 +69,11 @@ void die ( const char *fmt, ... ) {
} else {
/* Wait for keypress */
- printf ( "Press a key to reboot..." );
- getchar();
- printf ( "\n" );
+ if ( wait ) {
+ printf ( "Press a key to reboot..." );
+ getchar();
+ printf ( "\n" );
+ }
/* Reboot system */
reboot();
More information about the ipxe-devel
mailing list