Several top-level failure paths only printed the failed operation,
which made corrupted images hard to diagnose from fsck output.

Include the errno string for these paths so users can distinguish
I/O errors from corrupted metadata and invalid arguments.

Assisted-by: Codex:GPT-5.5
Signed-off-by: Yifan Zhao <[email protected]>
---
 fsck/main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fsck/main.c b/fsck/main.c
index 21ada19..0c628eb 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -1079,13 +1079,15 @@ int main(int argc, char *argv[])
 
        err = erofs_dev_open(&g_sbi, cfg.c_img_path, O_RDONLY);
        if (err) {
-               erofs_err("failed to open image file");
+               erofs_err("failed to open image file: %s",
+                         erofs_strerror(err));
                goto exit;
        }
 
        err = erofs_read_superblock(&g_sbi);
        if (err) {
-               erofs_err("failed to read superblock");
+               erofs_err("failed to read superblock: %s",
+                         erofs_strerror(err));
                goto exit_dev_close;
        }
 
@@ -1104,7 +1106,8 @@ int main(int argc, char *argv[])
 
                err = erofs_ilookup(fsckcfg.inode_path, &inode);
                if (err) {
-                       erofs_err("failed to lookup %s", fsckcfg.inode_path);
+                       erofs_err("failed to lookup %s: %s",
+                                 fsckcfg.inode_path, erofs_strerror(err));
                        goto exit_hardlink;
                }
                fsckcfg.nid = inode.nid;
@@ -1123,7 +1126,8 @@ int main(int argc, char *argv[])
 
                        err = erofsfsck_check_inode(g_sbi.packed_nid, 
g_sbi.packed_nid);
                        if (err) {
-                               erofs_err("failed to verify packed file");
+                               erofs_err("failed to verify packed file: %s",
+                                         erofs_strerror(err));
                                goto exit_packedinode;
                        }
                }
-- 
2.47.3


Reply via email to