* [PATCH v2] debugfs: allow <inode> for ncheck
@ 2022-08-05 21:52 Andreas Dilger
  0 siblings, 0 replies; only message in thread
From: Andreas Dilger @ 2022-08-05 21:52 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, Li Dongyang, Andreas Dilger
From: Li Dongyang <dongyangli@ddn.com>
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>
---
 debugfs/ncheck.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
v2: don't modify argv[] during parsing
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))
-- 
2.25.1
^ permalink raw reply related	[flat|nested] only message in thread
only message in thread, other threads:[~2022-08-05 21:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-05 21:52 [PATCH v2] debugfs: allow <inode> for ncheck Andreas Dilger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).