From 268461b7509f5d5a6b9b6d37ee8178966a3ff855 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 9 Apr 2015 13:17:20 +0200 Subject: [PATCH 1/2] boot.c: delay exiting boot if menu key is ESC Message-id: <1428585441-26367-2-git-send-email-pbonzini@redhat.com> Patchwork-id: 64758 O-Subject: [PATCH RHEL7.2 seabios 1/2] boot.c: delay exiting boot if menu key is ESC Bugzilla: 841638 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Gerd Hoffmann RH-Acked-by: Laszlo Ersek If the menu key is ESC, do not restart boot unless 1.5 seconds have passed. Otherwise users (trained by years of repeatedly hitting keys to enter the BIOS) will end up hitting ESC multiple times and immediately booting the primary boot device. Suggested-by: Matt DeVillier Signed-off-by: Paolo Bonzini (cherry picked from commit 80aae26c9ef060bde15aebd84d0cc79a978706a9) Signed-off-by: Miroslav Rezanina --- src/boot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/boot.c b/src/boot.c index e60ed3e..ac79724 100644 --- a/src/boot.c +++ b/src/boot.c @@ -486,9 +486,15 @@ interactive_bootmenu(void) , strtcpy(desc, pos->description, ARRAY_SIZE(desc))); } - // Get key press + // Get key press. If the menu key is ESC, do not restart boot unless + // 1.5 seconds have passed. Otherwise users (trained by years of + // repeatedly hitting keys to enter the BIOS) will end up hitting ESC + // multiple times and immediately booting the primary boot device. + int esc_accepted_time = irqtimer_calc(menukey == 1 ? 1500 : 0); for (;;) { scan_code = get_keystroke(1000); + if (scan_code == 1 && !irqtimer_check(esc_accepted_time)) + continue; if (scan_code >= 1 && scan_code <= maxmenu+1) break; } -- 1.8.3.1