From b15a0ad2fb8703c87dedcf0b2af26e3e750bcb76 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Fri, 23 Jul 2021 13:19:03 +1000 Subject: [PATCH] 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 --- debugfs/ncheck.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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)) -- 1.8.3.1