64
66
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
69
check_inode_bitmap_checksum(ctx);
70
check_block_bitmap_checksum(ctx);
67
72
ext2fs_free_inode_bitmap(ctx->inode_used_map);
68
73
ctx->inode_used_map = 0;
69
74
ext2fs_free_inode_bitmap(ctx->inode_dir_map);
70
75
ctx->inode_dir_map = 0;
71
76
ext2fs_free_block_bitmap(ctx->block_found_map);
72
77
ctx->block_found_map = 0;
78
ext2fs_free_block_bitmap(ctx->block_metadata_map);
79
ctx->block_metadata_map = 0;
74
81
print_resource_track(ctx, _("Pass 5"), &rtrack, ctx->fs->io);
84
static void check_inode_bitmap_checksum(e2fsck_t ctx)
86
struct problem_context pctx;
93
if (!EXT2_HAS_RO_COMPAT_FEATURE(ctx->fs->super,
94
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
97
/* If bitmap is dirty from being fixed, checksum will be corrected */
98
if (ext2fs_test_ib_dirty(ctx->fs))
101
nbytes = (size_t)(EXT2_INODES_PER_GROUP(ctx->fs->super) / 8);
102
retval = ext2fs_get_mem(ctx->fs->blocksize, &buf);
104
com_err(ctx->program_name, 0, "%s",
105
_("check_inode_bitmap_checksum: Memory allocation error"));
109
clear_problem_context(&pctx);
110
for (i = 0; i < ctx->fs->group_desc_count; i++) {
111
if (ext2fs_bg_flags_test(ctx->fs, i, EXT2_BG_INODE_UNINIT))
114
ino_itr = 1 + (i * (nbytes << 3));
115
retval = ext2fs_get_inode_bitmap_range2(ctx->fs->inode_map,
116
ino_itr, nbytes << 3,
121
if (ext2fs_inode_bitmap_csum_verify(ctx->fs, i, buf, nbytes))
124
if (!fix_problem(ctx, PR_5_INODE_BITMAP_CSUM_INVALID, &pctx))
128
* Fixing one checksum will rewrite all of them. The bitmap
129
* will be checked against the one we made during pass1 for
130
* discrepancies, and fixed if need be.
132
ext2fs_mark_ib_dirty(ctx->fs);
136
ext2fs_free_mem(&buf);
139
static void check_block_bitmap_checksum(e2fsck_t ctx)
141
struct problem_context pctx;
148
if (!EXT2_HAS_RO_COMPAT_FEATURE(ctx->fs->super,
149
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
152
/* If bitmap is dirty from being fixed, checksum will be corrected */
153
if (ext2fs_test_bb_dirty(ctx->fs))
156
nbytes = (size_t)(EXT2_CLUSTERS_PER_GROUP(ctx->fs->super) / 8);
157
retval = ext2fs_get_mem(ctx->fs->blocksize, &buf);
159
com_err(ctx->program_name, 0, "%s",
160
_("check_block_bitmap_checksum: Memory allocation error"));
164
clear_problem_context(&pctx);
165
for (i = 0; i < ctx->fs->group_desc_count; i++) {
166
if (ext2fs_bg_flags_test(ctx->fs, i, EXT2_BG_BLOCK_UNINIT))
169
blk_itr = EXT2FS_B2C(ctx->fs,
170
ctx->fs->super->s_first_data_block) +
171
((blk64_t) i * (nbytes << 3));
172
retval = ext2fs_get_block_bitmap_range2(ctx->fs->block_map,
173
blk_itr, nbytes << 3,
178
if (ext2fs_block_bitmap_csum_verify(ctx->fs, i, buf, nbytes))
181
if (!fix_problem(ctx, PR_5_BLOCK_BITMAP_CSUM_INVALID, &pctx))
185
* Fixing one checksum will rewrite all of them. The bitmap
186
* will be checked against the one we made during pass1 for
187
* discrepancies, and fixed if need be.
189
ext2fs_mark_bb_dirty(ctx->fs);
193
ext2fs_free_mem(&buf);
77
196
static void e2fsck_discard_blocks(e2fsck_t ctx, blk64_t start,