Whamcloud - gitweb
LU-11545 debugfs: allow <inode> for ncheck 88/44388/4
authorLi Dongyang <dongyangli@ddn.com>
Fri, 23 Jul 2021 03:19:03 +0000 (13:19 +1000)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 24 Feb 2022 03:18:00 +0000 (03:18 +0000)
If the arg string is of the form <ino>, 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 <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/44388
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
debugfs/ncheck.c

index cbe9ce0..9a8d734 100644 (file)
@@ -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))