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>
This commit is contained in:
parent
5d6d2b8838
commit
735dd6ef89
2 changed files with 13 additions and 6 deletions
|
@ -125,6 +125,8 @@ int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize,
|
||||||
* @buf: data blob to dump
|
* @buf: data blob to dump
|
||||||
* @len: number of bytes in the @buf
|
* @len: number of bytes in the @buf
|
||||||
* @ascii: include ASCII after the hex output
|
* @ascii: include ASCII after the hex output
|
||||||
|
* Returns: 0 if finished normally, -EINTR if Ctrl-C was pressed, -ENOSYS if not
|
||||||
|
* supported
|
||||||
*
|
*
|
||||||
* Given a buffer of u8 data, print_hex_dump() prints a hex + ASCII dump
|
* Given a buffer of u8 data, print_hex_dump() prints a hex + ASCII dump
|
||||||
* to the stdio, with an optional leading prefix.
|
* to the stdio, with an optional leading prefix.
|
||||||
|
@ -143,7 +145,7 @@ int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize,
|
||||||
* Example output using %DUMP_PREFIX_ADDRESS and 4-byte mode:
|
* Example output using %DUMP_PREFIX_ADDRESS and 4-byte mode:
|
||||||
* ffffffff88089af0: 73727170 77767574 7b7a7978 7f7e7d7c pqrstuvwxyz{|}~.
|
* ffffffff88089af0: 73727170 77767574 7b7a7978 7f7e7d7c pqrstuvwxyz{|}~.
|
||||||
*/
|
*/
|
||||||
void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
|
int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
|
||||||
int groupsize, const void *buf, size_t len, bool ascii);
|
int groupsize, const void *buf, size_t len, bool ascii);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -125,7 +125,7 @@ overflow1:
|
||||||
return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1;
|
return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
|
int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
|
||||||
int groupsize, const void *buf, size_t len, bool ascii)
|
int groupsize, const void *buf, size_t len, bool ascii)
|
||||||
{
|
{
|
||||||
const u8 *ptr = buf;
|
const u8 *ptr = buf;
|
||||||
|
@ -157,7 +157,11 @@ void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
|
||||||
printf("%s%s\n", prefix_str, linebuf);
|
printf("%s%s\n", prefix_str, linebuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!IS_ENABLED(CONFIG_SPL_BUILD) && ctrlc())
|
||||||
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
|
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
|
* Some code in U-Boot copy-pasted from Linux kernel uses both
|
||||||
* functions below so to keep stuff compilable we keep these stubs here.
|
* 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 print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
|
||||||
int groupsize, const void *buf, size_t len, bool ascii)
|
int groupsize, const void *buf, size_t len, bool ascii)
|
||||||
{
|
{
|
||||||
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
|
void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
|
||||||
|
|
Loading…
Reference in a new issue