summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-03-22 20:20:07 +0300
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-03-26 09:46:21 +0300
commit24cf707ed71534f6c4dc9a4a04f9a7b4c93d286b (patch)
treee7f87521157f21660340bade6feb5133320ac720 /lib
parentae794fae091759aa53fd2f88b09a8e5f31688167 (diff)
downloadu-boot-24cf707ed71534f6c4dc9a4a04f9a7b4c93d286b.tar.xz
efi_loader: initrddump: drain input before prompt
Up to now the initrddump.efi application has drained the input after showing the prompt. This works for humans but leads to problems when automating testing. If the input is drained, this should be done before showing the prompt. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/initrddump.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/efi_loader/initrddump.c b/lib/efi_loader/initrddump.c
index 6f8dd09a79..9872106981 100644
--- a/lib/efi_loader/initrddump.c
+++ b/lib/efi_loader/initrddump.c
@@ -121,6 +121,14 @@ static void printx(u64 val, u32 prec)
}
/**
+ * efi_drain_input() - drain console input
+ */
+static void efi_drain_input(void)
+{
+ cin->reset(cin, true);
+}
+
+/**
* efi_input_yn() - get answer to yes/no question
*
* Return:
@@ -137,8 +145,6 @@ static efi_status_t efi_input_yn(void)
efi_uintn_t index;
efi_status_t ret;
- /* Drain the console input */
- ret = cin->reset(cin, true);
for (;;) {
ret = bs->wait_for_event(1, &cin->wait_for_key, &index);
if (ret != EFI_SUCCESS)
@@ -179,8 +185,6 @@ static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
u16 outbuf[2] = u" ";
efi_status_t ret;
- /* Drain the console input */
- ret = cin->reset(cin, true);
*buffer = 0;
for (;;) {
ret = bs->wait_for_event(1, &cin->wait_for_key, &index);
@@ -393,6 +397,7 @@ static efi_status_t do_save(u16 *filename)
ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0);
if (ret == EFI_SUCCESS) {
file->close(file);
+ efi_drain_input();
print(u"Overwrite existing file (y/n)? ");
ret = efi_input_yn();
print(u"\r\n");
@@ -486,6 +491,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
u16 *pos;
efi_uintn_t ret;
+ efi_drain_input();
print(u"=> ");
ret = efi_input(command, sizeof(command));
if (ret == EFI_ABORTED)