From: Theodore Ts'o Date: Thu, 22 Mar 2012 03:40:24 +0000 (-0400) Subject: e2fsck: report ext2fs_open2() and ext2fs_check_desc() errors X-Git-Tag: v1.42.2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=010c49cf499738c7a06de13077f31f2a12ecadeb;p=thirdparty%2Fe2fsprogs.git e2fsck: report ext2fs_open2() and ext2fs_check_desc() errors Print the actual errors returned by ext2fs_open2() and ext2fs_check_desc() before we fall back to the backup block group descriptors so that it's easier to see if there is some obscure failure that is causing e2fsck to think that it should use the backup block group descriptors. Addresses-Google-Bug: #6208183 Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 56d10b157..f5c0554c9 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -423,6 +423,16 @@ static struct e2fsck_problem problem_table[] = { N_("@S has invalid MMP magic. "), PROMPT_FIX, PR_PREEN_OK | PR_NO_OK}, + /* Opening file system failed */ + { PR_0_OPEN_FAILED, + N_("ext2fs_open2: %m\n"), + PROMPT_NONE, 0 }, + + /* Checking group descriptor failed */ + { PR_0_CHECK_DESC_FAILED, + N_("ext2fs_check_desc: %m\n"), + PROMPT_NONE, 0 }, + /* Pass 1 errors */ /* Pass 1: Checking inodes, blocks, and sizes */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index 66330559d..348cfbce6 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -243,6 +243,11 @@ struct problem_context { /* Superblock has invalid MMP magic. */ #define PR_0_MMP_INVALID_MAGIC 0x000043 +/* Opening file system failed */ +#define PR_0_OPEN_FAILED 0x000044 + +/* Checking group descriptor failed */ +#define PR_0_CHECK_DESC_FAILED 0x000045 /* * Pass 1 errors diff --git a/e2fsck/unix.c b/e2fsck/unix.c index d0b10d494..190deaf9b 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1232,6 +1232,15 @@ restart: ((retval == EXT2_ET_BAD_MAGIC) || (retval == EXT2_ET_CORRUPT_SUPERBLOCK) || ((retval == 0) && (retval2 = ext2fs_check_desc(fs))))) { + if (retval) { + pctx.errcode = retval; + fix_problem(ctx, PR_0_OPEN_FAILED, &pctx); + } + if (retval2) { + pctx.errcode = retval2; + fix_problem(ctx, PR_0_CHECK_DESC_FAILED, &pctx); + } + pctx.errcode = 0; if (retval2 == ENOMEM || retval2 == EXT2_ET_NO_MEMORY) { retval = retval2; goto failure; diff --git a/tests/f_crashdisk/expect.1 b/tests/f_crashdisk/expect.1 index 132d49af9..70ddf2ecb 100644 --- a/tests/f_crashdisk/expect.1 +++ b/tests/f_crashdisk/expect.1 @@ -1,3 +1,4 @@ +ext2fs_open2: The ext2 superblock is corrupt ../e2fsck/e2fsck: Superblock invalid, trying backup blocks... ../e2fsck/e2fsck: The ext2 superblock is corrupt while trying to open test.img diff --git a/tests/f_illbbitmap/expect.1 b/tests/f_illbbitmap/expect.1 index ae61bf528..8746d23a5 100644 --- a/tests/f_illbbitmap/expect.1 +++ b/tests/f_illbbitmap/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for block bitmap Note: if several inode or block bitmap blocks or part of the inode table require relocation, you may wish to try running e2fsck with the '-b 8193' option first. The problem diff --git a/tests/f_illibitmap/expect.1 b/tests/f_illibitmap/expect.1 index 2ed55b67e..5bae25d14 100644 --- a/tests/f_illibitmap/expect.1 +++ b/tests/f_illibitmap/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for inode bitmap Note: if several inode or block bitmap blocks or part of the inode table require relocation, you may wish to try running e2fsck with the '-b 8193' option first. The problem diff --git a/tests/f_illitable/expect.1 b/tests/f_illitable/expect.1 index fbb3aefa9..552a2e794 100644 --- a/tests/f_illitable/expect.1 +++ b/tests/f_illitable/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for inode table Note: if several inode or block bitmap blocks or part of the inode table require relocation, you may wish to try running e2fsck with the '-b 8193' option first. The problem diff --git a/tests/f_illitable_flexbg/expect.1 b/tests/f_illitable_flexbg/expect.1 index 2d5472857..fa42a0f8b 100644 --- a/tests/f_illitable_flexbg/expect.1 +++ b/tests/f_illitable_flexbg/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for inode table ../e2fsck/e2fsck: Group descriptors look bad... trying backup blocks... Inode table for group 1 is not in group. (block 0) WARNING: SEVERE DATA LOSS POSSIBLE. diff --git a/tests/f_miss_blk_bmap/expect.1 b/tests/f_miss_blk_bmap/expect.1 index 4c51a16e5..998b61ad6 100644 --- a/tests/f_miss_blk_bmap/expect.1 +++ b/tests/f_miss_blk_bmap/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for block bitmap Pass 1: Checking inodes, blocks, and sizes Relocating group 0's block bitmap to 2... Pass 2: Checking directory structure diff --git a/tests/f_misstable/expect.1 b/tests/f_misstable/expect.1 index 93d4e8996..a8cf264e9 100644 --- a/tests/f_misstable/expect.1 +++ b/tests/f_misstable/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for inode table ../e2fsck/e2fsck: Group descriptors look bad... trying backup blocks... Inode table for group 1 is not in group. (block 0) WARNING: SEVERE DATA LOSS POSSIBLE. diff --git a/tests/f_overfsblks/expect.1 b/tests/f_overfsblks/expect.1 index 60f77d557..e5b93f0d5 100644 --- a/tests/f_overfsblks/expect.1 +++ b/tests/f_overfsblks/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for inode bitmap Filesystem did not have a UUID; generating one. Pass 1: Checking inodes, blocks, and sizes diff --git a/tests/f_resize_inode/expect b/tests/f_resize_inode/expect index a396927c8..84618d4d3 100644 --- a/tests/f_resize_inode/expect +++ b/tests/f_resize_inode/expect @@ -113,6 +113,7 @@ Exit status is 0 debugfs -R ''set_super_value reserved_gdt_blocks 15679'' -w test.img Exit status is 0 +ext2fs_check_desc: Corrupt group descriptor: bad block for block bitmap ../e2fsck/e2fsck: Group descriptors look bad... trying backup blocks... Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure diff --git a/tests/f_zero_group/expect.1 b/tests/f_zero_group/expect.1 index 577dadd46..2a077674f 100644 --- a/tests/f_zero_group/expect.1 +++ b/tests/f_zero_group/expect.1 @@ -1,3 +1,4 @@ +ext2fs_check_desc: Corrupt group descriptor: bad block for block bitmap ../e2fsck/e2fsck: Group descriptors look bad... trying backup blocks... Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure diff --git a/tests/f_zero_inode_size/expect.1 b/tests/f_zero_inode_size/expect.1 index 9202131f8..b8bd7da20 100644 --- a/tests/f_zero_inode_size/expect.1 +++ b/tests/f_zero_inode_size/expect.1 @@ -1,3 +1,4 @@ +ext2fs_open2: The ext2 superblock is corrupt ../e2fsck/e2fsck: Superblock invalid, trying backup blocks... Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure diff --git a/tests/f_zero_super/expect.1 b/tests/f_zero_super/expect.1 index 029f3f149..e2b954d00 100644 --- a/tests/f_zero_super/expect.1 +++ b/tests/f_zero_super/expect.1 @@ -1,3 +1,4 @@ +ext2fs_open2: Bad magic number in super-block ../e2fsck/e2fsck: Superblock invalid, trying backup blocks... Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure