blob: be2edd9a9801c0d419e9786194abe8b7263935e2 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001/*
2 * pass5.c --- check block and inode bitmaps against on-disk bitmaps
3 *
Theodore Ts'o21c84b71997-04-29 16:15:03 +00004 * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
Theodore Ts'o3839e651997-04-26 13:21:57 +000010 *
11 */
12
Theodore Ts'o3839e651997-04-26 13:21:57 +000013#include "e2fsck.h"
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000014#include "problem.h"
Theodore Ts'o3839e651997-04-26 13:21:57 +000015
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000016static void check_block_bitmaps(e2fsck_t ctx);
17static void check_inode_bitmaps(e2fsck_t ctx);
18static void check_inode_end(e2fsck_t ctx);
19static void check_block_end(e2fsck_t ctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +000020
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000021void pass5(e2fsck_t ctx)
Theodore Ts'o3839e651997-04-26 13:21:57 +000022{
Theodore Ts'o8bf191e1997-10-20 01:38:32 +000023#ifdef RESOURCE_TRACK
Theodore Ts'o3839e651997-04-26 13:21:57 +000024 struct resource_track rtrack;
Theodore Ts'o8bf191e1997-10-20 01:38:32 +000025#endif
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000026 struct problem_context pctx;
Theodore Ts'o3839e651997-04-26 13:21:57 +000027
28#ifdef MTRACE
29 mtrace_print("Pass 5");
30#endif
31
Theodore Ts'o8bf191e1997-10-20 01:38:32 +000032#ifdef RESOURCE_TRACK
Theodore Ts'o3839e651997-04-26 13:21:57 +000033 init_resource_track(&rtrack);
Theodore Ts'o8bf191e1997-10-20 01:38:32 +000034#endif
Theodore Ts'o3839e651997-04-26 13:21:57 +000035
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000036 clear_problem_context(&pctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +000037
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000038 if (!(ctx->options & E2F_OPT_PREEN))
39 fix_problem(ctx, PR_5_PASS_HEADER, &pctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +000040
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000041 read_bitmaps(ctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +000042
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000043 check_block_bitmaps(ctx);
44 check_inode_bitmaps(ctx);
45 check_inode_end(ctx);
46 check_block_end(ctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +000047
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000048 ext2fs_free_inode_bitmap(ctx->inode_used_map);
49 ctx->inode_used_map = 0;
50 ext2fs_free_inode_bitmap(ctx->inode_dir_map);
51 ctx->inode_dir_map = 0;
52 ext2fs_free_block_bitmap(ctx->block_found_map);
53 ctx->block_found_map = 0;
54
Theodore Ts'o8bf191e1997-10-20 01:38:32 +000055#ifdef RESOURCE_TRACK
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000056 if (ctx->options & E2F_OPT_TIME2)
57 print_resource_track("Pass 5", &rtrack);
Theodore Ts'o8bf191e1997-10-20 01:38:32 +000058#endif
Theodore Ts'o3839e651997-04-26 13:21:57 +000059}
60
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000061static void check_block_bitmaps(e2fsck_t ctx)
Theodore Ts'o3839e651997-04-26 13:21:57 +000062{
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000063 ext2_filsys fs = ctx->fs;
Theodore Ts'of3db3561997-04-26 13:34:30 +000064 blk_t i;
Theodore Ts'o3839e651997-04-26 13:21:57 +000065 int *free_array;
66 int group = 0;
67 int blocks = 0;
68 int free_blocks = 0;
69 int group_free = 0;
70 int actual, bitmap;
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000071 struct problem_context pctx;
72 int problem, fixit;
73 errcode_t retval;
Theodore Ts'o3839e651997-04-26 13:21:57 +000074
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000075 clear_problem_context(&pctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +000076 free_array = allocate_memory(fs->group_desc_count * sizeof(int),
77 "free block count array");
Theodore Ts'o50e1e101997-04-26 13:58:21 +000078
79 if ((fs->super->s_first_data_block <
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000080 ext2fs_get_block_bitmap_start(ctx->block_found_map)) ||
Theodore Ts'o50e1e101997-04-26 13:58:21 +000081 (fs->super->s_blocks_count-1 >
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000082 ext2fs_get_block_bitmap_end(ctx->block_found_map))) {
83 pctx.num = 1;
84 pctx.blk = fs->super->s_first_data_block;
85 pctx.blk2 = fs->super->s_blocks_count -1;
86 pctx.ino = ext2fs_get_block_bitmap_start(ctx->block_found_map);
87 pctx.ino2 = ext2fs_get_block_bitmap_end(ctx->block_found_map);
88 fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
89 /* fatal */
Theodore Ts'o50e1e101997-04-26 13:58:21 +000090 fatal_error(0);
91 }
92
93 if ((fs->super->s_first_data_block <
94 ext2fs_get_block_bitmap_start(fs->block_map)) ||
95 (fs->super->s_blocks_count-1 >
96 ext2fs_get_block_bitmap_end(fs->block_map))) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +000097 pctx.num = 2;
98 pctx.blk = fs->super->s_first_data_block;
99 pctx.blk2 = fs->super->s_blocks_count -1;
100 pctx.ino = ext2fs_get_block_bitmap_start(fs->block_map);
101 pctx.ino2 = ext2fs_get_block_bitmap_end(fs->block_map);
102 fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
103 /* fatal */
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000104 fatal_error(0);
105 }
106
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000107redo_counts:
Theodore Ts'o3839e651997-04-26 13:21:57 +0000108 for (i = fs->super->s_first_data_block;
109 i < fs->super->s_blocks_count;
110 i++) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000111 actual = ext2fs_fast_test_block_bitmap(ctx->block_found_map, i);
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000112 bitmap = ext2fs_fast_test_block_bitmap(fs->block_map, i);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000113
114 if (actual == bitmap)
115 goto do_counts;
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000116
Theodore Ts'o3839e651997-04-26 13:21:57 +0000117 if (!actual && bitmap) {
118 /*
119 * Block not used, but marked in use in the bitmap.
120 */
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000121 problem = PR_5_UNUSED_BLOCK;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000122 } else {
123 /*
124 * Block used, but not marked in use in the bitmap.
125 */
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000126 problem = PR_5_BLOCK_USED;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000127 }
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000128 pctx.blk = i;
129 fix_problem(ctx, problem, &pctx);
130
Theodore Ts'o3839e651997-04-26 13:21:57 +0000131 do_counts:
132 if (!bitmap) {
133 group_free++;
134 free_blocks++;
135 }
136 blocks ++;
137 if ((blocks == fs->super->s_blocks_per_group) ||
138 (i == fs->super->s_blocks_count-1)) {
139 free_array[group] = group_free;
140 group ++;
141 blocks = 0;
142 group_free = 0;
143 }
144 }
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000145 fixit = end_problem_latch(ctx, PR_LATCH_BBITMAP);
146 if (fixit == 1) {
147 ext2fs_free_block_bitmap(fs->block_map);
148 retval = ext2fs_copy_bitmap(ctx->block_found_map,
149 &fs->block_map);
150 /* XXX check retval --- should never fail! */
151 ext2fs_set_bitmap_padding(fs->block_map);
152 ext2fs_mark_bb_dirty(fs);
153
154 /* Redo the counts */
155 blocks = 0; free_blocks = 0; group_free = 0; group = 0;
156 memset(free_array, 0, fs->group_desc_count * sizeof(int));
157 goto redo_counts;
158 } else if (fixit == 0)
159 ext2fs_unmark_valid(fs);
160
Theodore Ts'o3839e651997-04-26 13:21:57 +0000161 for (i = 0; i < fs->group_desc_count; i++) {
162 if (free_array[i] != fs->group_desc[i].bg_free_blocks_count) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000163 pctx.group = i;
164 pctx.blk = fs->group_desc[i].bg_free_blocks_count;
165 pctx.blk2 = free_array[i];
166
167 if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT_GROUP,
168 &pctx)) {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000169 fs->group_desc[i].bg_free_blocks_count =
170 free_array[i];
171 ext2fs_mark_super_dirty(fs);
172 } else
173 ext2fs_unmark_valid(fs);
174 }
175 }
176 if (free_blocks != fs->super->s_free_blocks_count) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000177 pctx.group = 0;
178 pctx.blk = fs->super->s_free_blocks_count;
179 pctx.blk2 = free_blocks;
180
181 if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT, &pctx)) {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000182 fs->super->s_free_blocks_count = free_blocks;
183 ext2fs_mark_super_dirty(fs);
184 } else
185 ext2fs_unmark_valid(fs);
186 }
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000187 free(free_array);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000188}
189
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000190static void check_inode_bitmaps(e2fsck_t ctx)
Theodore Ts'o3839e651997-04-26 13:21:57 +0000191{
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000192 ext2_filsys fs = ctx->fs;
Theodore Ts'of3db3561997-04-26 13:34:30 +0000193 ino_t i;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000194 int free_inodes = 0;
195 int group_free = 0;
196 int dirs_count = 0;
197 int group = 0;
198 int inodes = 0;
199 int *free_array;
200 int *dir_array;
201 int actual, bitmap;
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000202 errcode_t retval;
203 struct problem_context pctx;
204 int problem, fixit;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000205
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000206 clear_problem_context(&pctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000207 free_array = allocate_memory(fs->group_desc_count * sizeof(int),
208 "free inode count array");
209
210 dir_array = allocate_memory(fs->group_desc_count * sizeof(int),
211 "directory count array");
212
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000213 if ((1 < ext2fs_get_inode_bitmap_start(ctx->inode_used_map)) ||
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000214 (fs->super->s_inodes_count >
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000215 ext2fs_get_inode_bitmap_end(ctx->inode_used_map))) {
216 pctx.num = 3;
217 pctx.blk = 1;
218 pctx.blk2 = fs->super->s_inodes_count;
219 pctx.ino = ext2fs_get_inode_bitmap_start(ctx->inode_used_map);
220 pctx.ino2 = ext2fs_get_inode_bitmap_end(ctx->inode_used_map);
221 fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
222 /* fatal */
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000223 fatal_error(0);
224 }
225 if ((1 < ext2fs_get_inode_bitmap_start(fs->inode_map)) ||
226 (fs->super->s_inodes_count >
227 ext2fs_get_inode_bitmap_end(fs->inode_map))) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000228 pctx.num = 4;
229 pctx.blk = 1;
230 pctx.blk2 = fs->super->s_inodes_count;
231 pctx.ino = ext2fs_get_inode_bitmap_start(fs->inode_map);
232 pctx.ino2 = ext2fs_get_inode_bitmap_end(fs->inode_map);
233 fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
234 /* fatal */
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000235 fatal_error(0);
236 }
237
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000238redo_counts:
Theodore Ts'o3839e651997-04-26 13:21:57 +0000239 for (i = 1; i <= fs->super->s_inodes_count; i++) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000240 actual = ext2fs_fast_test_inode_bitmap(ctx->inode_used_map, i);
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000241 bitmap = ext2fs_fast_test_inode_bitmap(fs->inode_map, i);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000242
243 if (actual == bitmap)
244 goto do_counts;
245
Theodore Ts'o3839e651997-04-26 13:21:57 +0000246 if (!actual && bitmap) {
247 /*
248 * Inode wasn't used, but marked in bitmap
249 */
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000250 problem = PR_5_UNUSED_INODE;
251 } else /* if (actual && !bitmap) */ {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000252 /*
253 * Inode used, but not in bitmap
254 */
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000255 problem = PR_5_INODE_USED;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000256 }
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000257 pctx.ino = i;
258 fix_problem(ctx, problem, &pctx);
259
Theodore Ts'o3839e651997-04-26 13:21:57 +0000260do_counts:
261 if (!bitmap) {
262 group_free++;
263 free_inodes++;
264 } else {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000265 if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, i))
Theodore Ts'o3839e651997-04-26 13:21:57 +0000266 dirs_count++;
267 }
268 inodes++;
269 if ((inodes == fs->super->s_inodes_per_group) ||
270 (i == fs->super->s_inodes_count)) {
271 free_array[group] = group_free;
272 dir_array[group] = dirs_count;
273 group ++;
274 inodes = 0;
275 group_free = 0;
276 dirs_count = 0;
277 }
278 }
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000279 fixit = end_problem_latch(ctx, PR_LATCH_IBITMAP);
280 if (fixit == 1) {
281 ext2fs_free_inode_bitmap(fs->inode_map);
282 retval = ext2fs_copy_bitmap(ctx->inode_used_map,
283 &fs->inode_map);
284 /* XXX check retval --- should never fail! */
285 ext2fs_set_bitmap_padding(fs->inode_map);
286 ext2fs_mark_ib_dirty(fs);
287
288 /* redo counts */
289 inodes = 0; free_inodes = 0; group_free = 0;
290 dirs_count = 0; group = 0;
291 memset(free_array, 0, fs->group_desc_count * sizeof(int));
292 memset(dir_array, 0, fs->group_desc_count * sizeof(int));
293 goto redo_counts;
294 } else if (fixit == 0)
295 ext2fs_unmark_valid(fs);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000296
297 for (i = 0; i < fs->group_desc_count; i++) {
298 if (free_array[i] != fs->group_desc[i].bg_free_inodes_count) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000299 pctx.group = i;
300 pctx.ino = fs->group_desc[i].bg_free_inodes_count;
301 pctx.ino2 = free_array[i];
302 if (fix_problem(ctx, PR_5_FREE_INODE_COUNT_GROUP,
303 &pctx)) {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000304 fs->group_desc[i].bg_free_inodes_count =
305 free_array[i];
306 ext2fs_mark_super_dirty(fs);
307 } else
308 ext2fs_unmark_valid(fs);
309 }
310 if (dir_array[i] != fs->group_desc[i].bg_used_dirs_count) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000311 pctx.group = i;
312 pctx.ino = fs->group_desc[i].bg_used_dirs_count;
313 pctx.ino2 = dir_array[i];
314
315 if (fix_problem(ctx, PR_5_FREE_DIR_COUNT_GROUP,
316 &pctx)) {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000317 fs->group_desc[i].bg_used_dirs_count =
318 dir_array[i];
319 ext2fs_mark_super_dirty(fs);
320 } else
321 ext2fs_unmark_valid(fs);
322 }
323 }
324 if (free_inodes != fs->super->s_free_inodes_count) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000325 pctx.group = -1;
326 pctx.ino = fs->super->s_free_inodes_count;
327 pctx.ino2 = free_inodes;
328
329 if (fix_problem(ctx, PR_5_FREE_INODE_COUNT, &pctx)) {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000330 fs->super->s_free_inodes_count = free_inodes;
331 ext2fs_mark_super_dirty(fs);
332 } else
333 ext2fs_unmark_valid(fs);
334 }
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000335 free(free_array);
336 free(dir_array);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000337}
338
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000339static void check_inode_end(e2fsck_t ctx)
Theodore Ts'o3839e651997-04-26 13:21:57 +0000340{
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000341 ext2_filsys fs = ctx->fs;
Theodore Ts'of3db3561997-04-26 13:34:30 +0000342 ino_t end, save_inodes_count, i;
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000343 struct problem_context pctx;
344
345 clear_problem_context(&pctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000346
347 end = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000348 pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map, end,
349 &save_inodes_count);
350 if (pctx.errcode) {
351 pctx.num = 1;
352 fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
Theodore Ts'of3db3561997-04-26 13:34:30 +0000353 fatal_error(0);
354 }
Theodore Ts'o3839e651997-04-26 13:21:57 +0000355 if (save_inodes_count == end)
356 return;
357
Theodore Ts'o3839e651997-04-26 13:21:57 +0000358 for (i = save_inodes_count + 1; i <= end; i++) {
Theodore Ts'of3db3561997-04-26 13:34:30 +0000359 if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000360 if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000361 for (i = save_inodes_count + 1; i <= end; i++)
Theodore Ts'of3db3561997-04-26 13:34:30 +0000362 ext2fs_mark_inode_bitmap(fs->inode_map,
Theodore Ts'o3839e651997-04-26 13:21:57 +0000363 i);
364 ext2fs_mark_ib_dirty(fs);
365 } else
366 ext2fs_unmark_valid(fs);
367 break;
368 }
369 }
370
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000371 pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map,
372 save_inodes_count, 0);
373 if (pctx.errcode) {
374 pctx.num = 2;
375 fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
Theodore Ts'of3db3561997-04-26 13:34:30 +0000376 fatal_error(0);
377 }
Theodore Ts'o3839e651997-04-26 13:21:57 +0000378}
379
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000380static void check_block_end(e2fsck_t ctx)
Theodore Ts'o3839e651997-04-26 13:21:57 +0000381{
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000382 ext2_filsys fs = ctx->fs;
Theodore Ts'of3db3561997-04-26 13:34:30 +0000383 blk_t end, save_blocks_count, i;
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000384 struct problem_context pctx;
385
386 clear_problem_context(&pctx);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000387
Theodore Ts'of3db3561997-04-26 13:34:30 +0000388 end = fs->block_map->start +
389 (EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count) - 1;
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000390 pctx.errcode = ext2fs_fudge_block_bitmap_end(fs->block_map, end,
391 &save_blocks_count);
392 if (pctx.errcode) {
393 pctx.num = 3;
394 fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
Theodore Ts'of3db3561997-04-26 13:34:30 +0000395 fatal_error(0);
396 }
Theodore Ts'o3839e651997-04-26 13:21:57 +0000397 if (save_blocks_count == end)
398 return;
399
Theodore Ts'of3db3561997-04-26 13:34:30 +0000400 for (i = save_blocks_count + 1; i <= end; i++) {
401 if (!ext2fs_test_block_bitmap(fs->block_map, i)) {
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000402 if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
Theodore Ts'o3839e651997-04-26 13:21:57 +0000403 for (i = save_blocks_count + 1; i < end; i++)
Theodore Ts'of3db3561997-04-26 13:34:30 +0000404 ext2fs_mark_block_bitmap(fs->block_map,
Theodore Ts'o3839e651997-04-26 13:21:57 +0000405 i);
406 ext2fs_mark_bb_dirty(fs);
407 } else
408 ext2fs_unmark_valid(fs);
409 break;
410 }
411 }
412
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000413 pctx.errcode = ext2fs_fudge_block_bitmap_end(fs->block_map,
414 save_blocks_count, 0);
415 if (pctx.errcode) {
416 pctx.num = 4;
417 fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
Theodore Ts'of3db3561997-04-26 13:34:30 +0000418 fatal_error(0);
419 }
Theodore Ts'o3839e651997-04-26 13:21:57 +0000420}
421
Theodore Ts'o1b6bf171997-10-03 17:48:10 +0000422
423