]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
debugfs: allow <inode> for ncheck
authorLi Dongyang <dongyangli@ddn.com>
Fri, 5 Aug 2022 21:52:21 +0000 (15:52 -0600)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Aug 2022 16:36:23 +0000 (12:36 -0400)
If the ncheck argument is of the form "<ino>", allow it for ncheck
for consistency with other commands that accept an inode number.

Improve the error message, use "Invalid inode number" instead
of "Bad inode", which implies the inode content being bad.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/ncheck.c

index 011f26deb17eada68ea9423000cd80eb60e5da1b..963b3a12b4f41be7ae509073366b190da9ba5b6b 100644 (file)
@@ -134,9 +134,15 @@ 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);
-               if (*tmp) {
-                       com_err("ncheck", 0, "Bad inode - %s", argv[i]);
+               char *str = argv[i];
+               int len = strlen(str);
+
+               if ((len > 2) && (str[0] == '<') && (str[len - 1] == '>'))
+                       str++;
+               iw.iarray[i] = strtol(str, &tmp, 0);
+               if (*tmp && (str == argv[i] || *tmp != '>')) {
+                       com_err("ncheck", 0, "Invalid inode number - '%s'",
+                               argv[i]);
                        goto error_out;
                }
                if (debugfs_read_inode(iw.iarray[i], &inode, *argv))