1 Star 0 Fork 99

陈亚强/grub2

forked from src-openEuler/grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
normal-menu-Do-not-treat-error-values-as-key-presses.patch 2.59 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:52 . Package init
From d3a3543a5666c1dd180ae6027948ca753dcffc18 Mon Sep 17 00:00:00 2001
From: Paul Menzel <[email protected]>
Date: Tue, 5 Feb 2019 17:29:13 +0100
Subject: [PATCH 260/270] normal/menu: Do not treat error values as key presses
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Some terminals, like `grub-core/term/at_keyboard.c`, return `-1` in case
they are not ready yet.
if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
return -1;
Currently, that is treated as a key press, and the menu time-out is
cancelled/cleared. This is unwanted, as the boot is stopped and the user
manually has to select a menu entry. Therefore, adapt the condition to
require the key value also to be greater than 0.
`GRUB_TERM_NO_KEY` is defined as 0, so the condition could be collapsed
to greater or equal than (≥) 0, but the compiler will probably do that
for us anyway, so keep the cases separate for clarity.
This is tested with coreboot, the GRUB default payload, and the
configuration file `grub.cfg` below.
For GRUB:
$ ./autogen.sh
$ ./configure --with-platform=coreboot
$ make -j`nproc`
$ make default_payload.elf
For coreboot:
$ more grub.cfg
serial --unit 0 --speed 115200
set timeout=5
menuentry 'halt' {
halt
}
$ build/cbfstool build/coreboot.rom add-payload \
-f /dev/shm/grub/default_payload.elf -n fallback/payload -c lzma
$ build/cbfstool build/coreboot.rom add -f grub.cfg -n etc/grub.cfg -t raw
$ qemu-system-x86_64 --version
QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2+b1)
Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers
$ qemu-system-x86_64 -M pc -bios build/coreboot.rom -serial stdio -nic none
Currently, the time-out is cancelled/cleared. With the commit, it is not.
With a small GRUB payload, this the problem is also reproducible on the
ASRock E350M1.
Link: http://lists.gnu.org/archive/html/grub-devel/2019-01/msg00037.html
Signed-off-by: Paul Menzel <[email protected]>
Reviewed-by: Daniel Kiper <[email protected]>
---
grub-core/normal/menu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index e7a83c2..d5e0c79 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -698,7 +698,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
c = grub_getkey_noblock ();
- if (c != GRUB_TERM_NO_KEY)
+ /* Negative values are returned on error. */
+ if ((c != GRUB_TERM_NO_KEY) && (c > 0))
{
if (timeout >= 0)
{
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yaqiangchen/grub2.git
[email protected]:yaqiangchen/grub2.git
yaqiangchen
grub2
grub2
master

搜索帮助