From: Li Dongyang Date: Fri, 23 Jul 2021 03:19:03 +0000 (+1000) Subject: LU-11545 debugfs: allow for ncheck X-Git-Tag: v1.46.2.wc5~3 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b15a0ad2f;p=tools%2Fe2fsprogs.git LU-11545 debugfs: allow for ncheck If the arg string is of the form , allow it for ncheck. Improve the error message, use "Invalid inode number" instead of "Bad inode", which implies the inode content being bad. Change-Id: Ib6d7eb53342d93c9e8ecf25835d8ff65bc340980 Signed-off-by: Li Dongyang Reviewed-on: https://review.whamcloud.com/44388 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- diff --git a/debugfs/ncheck.c b/debugfs/ncheck.c index cbe9ce0..9a8d734 100644 --- a/debugfs/ncheck.c +++ b/debugfs/ncheck.c @@ -137,9 +137,21 @@ void do_ncheck(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)), iw.names_left = 0; for (i=0; i < argc; i++) { - iw.iarray[i] = strtol(argv[i], &tmp, 0); + char *str = argv[i]; + int len = strlen(str); + + if ((len > 2) && (str[0] == '<') && (str[len-1] == '>')) { + str[len-1] = '\0'; + str++; + } + iw.iarray[i] = strtol(str, &tmp, 0); if (*tmp) { - com_err("ncheck", 0, "Bad inode - %s", argv[i]); + if (str != argv[i]) { + str--; + str[len-1] = '>'; + } + com_err("ncheck", 0, "Invalid inode number - '%s'", + argv[i]); goto error_out; } if (debugfs_read_inode(iw.iarray[i], &inode, *argv))