From 7be7b1cc9f82721e65b9fa3d99828ba273e8d345 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Fri, 15 Apr 2022 18:17:04 -0700 Subject: [PATCH] utils/mqnic-fw: Confirm write and reset operations Signed-off-by: Alex Forencich --- utils/mqnic-fw.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/utils/mqnic-fw.c b/utils/mqnic-fw.c index eab58187c..3760094da 100644 --- a/utils/mqnic-fw.c +++ b/utils/mqnic-fw.c @@ -1125,6 +1125,19 @@ int main(int argc, char *argv[]) len_int += pri_flash->erase_block_size - ((segment_offset/2 + len_int) & (pri_flash->erase_block_size-1)); } + if (!no_confirm) + { + char str[32]; + + printf("Are you sure you want to write the selected segment?\n"); + printf("[y/N]: "); + + fgets(str, sizeof(str), stdin); + + if (str[0] != 'y' && str[0] != 'Y') + goto err; + } + printf("Erasing primary flash...\n"); if (flash_erase_progress(pri_flash, segment_offset/2, len_int)) { @@ -1184,6 +1197,19 @@ int main(int argc, char *argv[]) len += pri_flash->erase_block_size - ((segment_offset + len) & (pri_flash->erase_block_size-1)); } + if (!no_confirm) + { + char str[32]; + + printf("Are you sure you want to write the selected segment?\n"); + printf("[y/N]: "); + + fgets(str, sizeof(str), stdin); + + if (str[0] != 'y' && str[0] != 'Y') + goto err; + } + printf("Erasing flash...\n"); if (flash_erase_progress(pri_flash, segment_offset, len)) { @@ -1316,6 +1342,22 @@ skip_flash: if (action_boot || action_reset) { + if (!no_confirm) + { + char str[32]; + + if (action_boot) + printf("Are you sure you want to boot from flash?\n"); + else + printf("Are you sure you want to perform a reset?\n"); + printf("[y/N]: "); + + fgets(str, sizeof(str), stdin); + + if (str[0] != 'y' && str[0] != 'Y') + goto err; + } + printf("Preparing to reset device...\n"); // disable fatal error reporting on port (to prevent IPMI-triggered reboot)