diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 66ff69a3..2370bb0e 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -2138,7 +2138,20 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx, ext2_ino_t ino = pctx->ino; errcode_t retval; blk64_t eof_lblk; + struct ext3_extent_header *eh; + /* Check for a proper extent header... */ + eh = (struct ext3_extent_header *) &inode->i_block[0]; + retval = ext2fs_extent_header_verify(eh, sizeof(inode->i_block)); + if (retval) { + if (fix_problem(ctx, PR_1_MISSING_EXTENT_HEADER, pctx)) + e2fsck_clear_inode(ctx, ino, inode, 0, + "check_blocks_extents"); + pctx->errcode = 0; + return; + } + + /* ...since this function doesn't fail if i_block is zeroed. */ pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle); if (pctx->errcode) { if (fix_problem(ctx, PR_1_READ_EXTENT, pctx)) diff --git a/e2fsck/problem.c b/e2fsck/problem.c index f442a330..e7831481 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -987,6 +987,11 @@ static struct e2fsck_problem problem_table[] = { N_("@i %i logical @b %b (physical @b %c) violates cluster allocation rules.\nWill fix in pass 1B.\n"), PROMPT_NONE, 0 }, + /* Inode has corrupt extent header */ + { PR_1_MISSING_EXTENT_HEADER, + N_("@i %i has corrupt @x header. "), + PROMPT_CLEAR_INODE, 0 }, + /* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index 212ed350..85014f9c 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -587,6 +587,45 @@ struct problem_context { /* Inode logical block is misaligned */ #define PR_1_MISALIGNED_CLUSTER 0x010074 +/* Inode has INLINE_DATA_FL flag but extended attribute not found */ +#define PR_1_INLINE_DATA_NO_ATTR 0x010075 + +/* extents/inlinedata set on fifo/socket/device */ +#define PR_1_SPECIAL_EXTENTS_IDATA 0x010076 + +/* idata/extent flag set and extent header found, clear idata flag */ +#define PR_1_CLEAR_INLINE_DATA_FOR_EXTENT 0x010077 + +/* inlinedata/extent set and no extent header found, clear extent flag */ +#define PR_1_CLEAR_EXTENT_FOR_INLINE_DATA 0x010078 + +/* inlinedata/extent set, clear both flags */ +#define PR_1_CLEAR_EXTENT_INLINE_DATA_FLAGS 0x010079 + +/* inlinedata/extent set, clear inode */ +#define PR_1_CLEAR_EXTENT_INLINE_DATA_INODE 0x01007A + +/* badblocks is in badblocks */ +#define PR_1_BADBLOCKS_IN_BADBLOCKS 0x01007B + +/* can't allocate extent region */ +#define PR_1_EXTENT_ALLOC_REGION_ABORT 0x01007C + +/* leaf extent collision */ +#define PR_1_EXTENT_COLLISION 0x01007D + +/* Error allocating memory for encrypted directory list */ +#define PR_1_ALLOCATE_ENCRYPTED_DIRLIST 0x01007E + +/* extent tree max depth too big */ +#define PR_1_EXTENT_BAD_MAX_DEPTH 0x01007F + +/* bigalloc fs cannot have blockmap files */ +#define PR_1_NO_BIGALLOC_BLOCKMAP_FILES 0x010080 + +/* Missing extent header */ +#define PR_1_MISSING_EXTENT_HEADER 0x010081 + /* * Pass 1b errors */ diff --git a/tests/f_extents/expect.1 b/tests/f_extents/expect.1 index 2abe32e3..882c321b 100644 --- a/tests/f_extents/expect.1 +++ b/tests/f_extents/expect.1 @@ -17,8 +17,7 @@ Clear? yes Inode 17, i_blocks is 32, should be 0. Fix? yes -Error while reading over extent tree in inode 18: Corrupt extent header -Clear inode? yes +Inode 18 has corrupt extent header. Clear inode? yes Inode 18, i_blocks is 2, should be 0. Fix? yes diff --git a/tests/f_zeroed_ext_header/expect.1 b/tests/f_zeroed_ext_header/expect.1 new file mode 100644 index 00000000..2613e9ff --- /dev/null +++ b/tests/f_zeroed_ext_header/expect.1 @@ -0,0 +1,22 @@ +Pass 1: Checking inodes, blocks, and sizes +Inode 12 has corrupt extent header. Clear inode? yes + +Pass 2: Checking directory structure +Entry 'testa' in / (2) has deleted/unused inode 12. Clear? yes + +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +Inode bitmap differences: -12 +Fix? yes + +Free inodes count wrong for group #0 (115, counted=116). +Fix? yes + +Free inodes count wrong (115, counted=116). +Fix? yes + + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 12/128 files (0.0% non-contiguous), 15/256 blocks +Exit status is 1 diff --git a/tests/f_zeroed_ext_header/expect.2 b/tests/f_zeroed_ext_header/expect.2 new file mode 100644 index 00000000..177288fb --- /dev/null +++ b/tests/f_zeroed_ext_header/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 12/128 files (0.0% non-contiguous), 15/256 blocks +Exit status is 0 diff --git a/tests/f_zeroed_ext_header/image.gz b/tests/f_zeroed_ext_header/image.gz new file mode 100644 index 00000000..67a43341 Binary files /dev/null and b/tests/f_zeroed_ext_header/image.gz differ diff --git a/tests/f_zeroed_ext_header/name b/tests/f_zeroed_ext_header/name new file mode 100644 index 00000000..31394cf5 --- /dev/null +++ b/tests/f_zeroed_ext_header/name @@ -0,0 +1 @@ +zap inode with zeroed extent header