[PATCH 6/6] commands: stat: print mode in octal if type unknown

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jan 6 01:18:35 PST 2025


The stat command is meant as debugging aid and thus it's useful to print
information about the mode, even for broken inodes that lack file type
information in their mode field.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 fs/fs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index 8cdd0c55202b..57bd781025f9 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -201,6 +201,8 @@ void stat_print(int dirfd, const char *filename, const struct stat *st)
 
 	if (type)
 		printf("  %s%s", typeprefix, type);
+	else
+		printf("  unknown (mode=0%o)", st->st_mode);
 
 	fdev = get_fsdevice_by_path(dirfd, filename);
 
-- 
2.39.5




More information about the barebox mailing list