diff options
author | Simon Glass <sjg@chromium.org> | 2021-05-08 07:00:04 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-06-08 11:39:09 -0400 |
commit | 735dd6ef89ebd3e05c1dfaef06aca61046503c63 (patch) | |
tree | 5c9bca4a0860d6d4ebfe1a242ec749129584df09 /lib/hexdump.c | |
parent | 5d6d2b88389a99c9e20618593e64a9dd74862c8a (diff) |
hexdump: Allow ctrl-c to interrupt output
If a long hexdump is initated the user may wish to interrupt it. Add
support for this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/hexdump.c')
-rw-r--r-- | lib/hexdump.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/hexdump.c b/lib/hexdump.c index a56e108164..149c93ead8 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c @@ -125,8 +125,8 @@ overflow1: return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1; } -void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, - int groupsize, const void *buf, size_t len, bool ascii) +int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii) { const u8 *ptr = buf; int i, linelen, remaining = len; @@ -157,7 +157,11 @@ void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, printf("%s%s\n", prefix_str, linebuf); break; } + if (!IS_ENABLED(CONFIG_SPL_BUILD) && ctrlc()) + return -EINTR; } + + return 0; } void print_hex_dump_bytes(const char *prefix_str, int prefix_type, @@ -170,9 +174,10 @@ void print_hex_dump_bytes(const char *prefix_str, int prefix_type, * Some code in U-Boot copy-pasted from Linux kernel uses both * functions below so to keep stuff compilable we keep these stubs here. */ -void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, - int groupsize, const void *buf, size_t len, bool ascii) +int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii) { + return -ENOSYS; } void print_hex_dump_bytes(const char *prefix_str, int prefix_type, |