mirror of
https://git.proxmox.com/git/grub2
synced 2025-10-21 07:36:46 +00:00

The overflow was in fact impossible in practice because the int parameter is only ever 0, 1, or 2, but GCC couldn't prove that.
96 lines
2.5 KiB
Diff
96 lines
2.5 KiB
Diff
From 4b5de05feb2b89ba5d3acd13826b1465c5111587 Mon Sep 17 00:00:00 2001
|
|
From: Colin Watson <cjwatson@ubuntu.com>
|
|
Date: Mon, 13 Jan 2014 12:13:23 +0000
|
|
Subject: Allow Shift to interrupt 'sleep --interruptible'
|
|
|
|
Upstream would like to consider this at more length. See
|
|
http://lists.gnu.org/archive/html/grub-devel/2009-08/msg00718.html, and
|
|
the rest of the thread for context.
|
|
|
|
Forwarded: http://lists.gnu.org/archive/html/grub-devel/2009-08/msg00694.html
|
|
Last-Update: 2013-12-04
|
|
|
|
Patch-Name: sleep_shift.patch
|
|
---
|
|
grub-core/commands/sleep.c | 27 ++++++++++++++++++++++++++-
|
|
grub-core/normal/menu.c | 19 +++++++++++++++++++
|
|
2 files changed, 45 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c
|
|
index e77e7900f..3906b1410 100644
|
|
--- a/grub-core/commands/sleep.c
|
|
+++ b/grub-core/commands/sleep.c
|
|
@@ -46,6 +46,31 @@ do_print (int n)
|
|
grub_refresh ();
|
|
}
|
|
|
|
+static int
|
|
+grub_check_keyboard (void)
|
|
+{
|
|
+ int mods = 0;
|
|
+ grub_term_input_t term;
|
|
+
|
|
+ if (grub_term_poll_usb)
|
|
+ grub_term_poll_usb (0);
|
|
+
|
|
+ FOR_ACTIVE_TERM_INPUTS(term)
|
|
+ {
|
|
+ if (term->getkeystatus)
|
|
+ mods |= term->getkeystatus (term);
|
|
+ }
|
|
+
|
|
+ if (mods >= 0 &&
|
|
+ (mods & (GRUB_TERM_STATUS_LSHIFT | GRUB_TERM_STATUS_RSHIFT)) != 0)
|
|
+ return 1;
|
|
+
|
|
+ if (grub_getkey_noblock () == GRUB_TERM_ESC)
|
|
+ return 1;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
/* Based on grub_millisleep() from kern/generic/millisleep.c. */
|
|
static int
|
|
grub_interruptible_millisleep (grub_uint32_t ms)
|
|
@@ -55,7 +80,7 @@ grub_interruptible_millisleep (grub_uint32_t ms)
|
|
start = grub_get_time_ms ();
|
|
|
|
while (grub_get_time_ms () - start < ms)
|
|
- if (grub_getkey_noblock () == GRUB_TERM_ESC)
|
|
+ if (grub_check_keyboard ())
|
|
return 1;
|
|
|
|
return 0;
|
|
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
|
|
index 719e2fb1c..9d0ad4c95 100644
|
|
--- a/grub-core/normal/menu.c
|
|
+++ b/grub-core/normal/menu.c
|
|
@@ -615,8 +615,27 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
|
saved_time = grub_get_time_ms ();
|
|
while (1)
|
|
{
|
|
+ int mods = 0;
|
|
+ grub_term_input_t term;
|
|
int key;
|
|
|
|
+ if (grub_term_poll_usb)
|
|
+ grub_term_poll_usb (0);
|
|
+
|
|
+ FOR_ACTIVE_TERM_INPUTS(term)
|
|
+ {
|
|
+ if (term->getkeystatus)
|
|
+ mods |= term->getkeystatus (term);
|
|
+ }
|
|
+
|
|
+ if (mods >= 0 &&
|
|
+ (mods & (GRUB_TERM_STATUS_LSHIFT
|
|
+ | GRUB_TERM_STATUS_RSHIFT)) != 0)
|
|
+ {
|
|
+ timeout = -1;
|
|
+ break;
|
|
+ }
|
|
+
|
|
key = grub_getkey_noblock ();
|
|
if (key != GRUB_TERM_NO_KEY)
|
|
{
|