nshlib/md5: Support reading from standard input

Sometimes users may want to calculate the MD5 of part of a file(e.g. check
partition contents for debug after flashing, size of which may be greater
than image). This can be done with the "dd" command and pipes, the "md5"
command just needs to support reading from standard input. For example:
`dd if=/dev/virtblk0 bs=512 count=1 | md5`.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3
2025-07-02 11:40:03 +08:00
committed by Alan C. Assis
parent ecd7b84871
commit c3e628c45a
2 changed files with 22 additions and 1 deletions

View File

@@ -353,7 +353,8 @@ static const struct cmdmap_s g_cmdmap[] =
#if defined(CONFIG_NETUTILS_CODECS) && defined(CONFIG_CODECS_HASH_MD5)
# ifndef CONFIG_NSH_DISABLE_MD5
CMD_MAP("md5", cmd_md5, 2, 3, "[-f] <string or filepath>"),
CMD_MAP("md5", cmd_md5, 1, 3,
"[string] or [-f <filepath>] or read stdin"),
# endif
#endif