summaryrefslogtreecommitdiff
path: root/debugfs
diff options
context:
space:
mode:
authorLi Dongyang <dongyangli@ddn.com>2022-08-05 15:52:21 -0600
committerTheodore Ts'o <tytso@mit.edu>2022-08-11 12:36:23 -0400
commit3a3f3f153372ae5daafad5fb68d84847e9f17e9c (patch)
tree2b83dd850e8181b831a7a12aadb03dff28306a57 /debugfs
parentd00971011385a4dfcd0349763e2239052dc1d22b (diff)
downloade2fsprogs-3a3f3f153372ae5daafad5fb68d84847e9f17e9c.tar.gz
debugfs: allow <inode> for ncheck
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>
Diffstat (limited to 'debugfs')
-rw-r--r--debugfs/ncheck.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/debugfs/ncheck.c b/debugfs/ncheck.c
index 011f26de..963b3a12 100644
--- a/debugfs/ncheck.c
+++ b/debugfs/ncheck.c
@@ -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))