~ubuntu-branches/ubuntu/edgy/e2fsprogs/edgy-security

« back to all changes in this revision

Viewing changes to e2fsck/pass5.c

  • Committer: Bazaar Package Importer
  • Author(s): Theodore Y. Ts'o
  • Date: 2006-05-29 11:07:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060529110753-uvkuaxqr96y31kqy
Tags: 1.39-1
* New upstream version
* Fix debugfs's dump_unused command so it will not core dump on
  filesystems with a 64k blocksize
* Clarified and improved man pages, including spelling errors
  (Closes: #368392, #368393, #368394, #368179)
* New filesystems are now created with directory indexing and
  on-line resizing enabled by default
* Fix previously mangled wording in an older Debian changelog entry
* Fix doc-base pointer to the top-level html file (Closes: #362544, #362970)

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
static void check_block_bitmaps(e2fsck_t ctx)
112
112
{
113
113
        ext2_filsys fs = ctx->fs;
114
 
        blk_t   i;
 
114
        blk_t   i, super;
115
115
        int     *free_array;
116
116
        int     group = 0;
117
117
        unsigned int    blocks = 0;
121
121
        struct problem_context  pctx;
122
122
        int     problem, save_problem, fixit, had_problem;
123
123
        errcode_t       retval;
 
124
        int             lazy_bg = 0;
 
125
        int             skip_group = 0;
124
126
        
125
127
        clear_problem_context(&pctx);
126
128
        free_array = (int *) e2fsck_allocate_memory(ctx,
156
158
                return;
157
159
        }
158
160
                       
 
161
        if (EXT2_HAS_COMPAT_FEATURE(fs->super, 
 
162
                                    EXT2_FEATURE_COMPAT_LAZY_BG))
 
163
                lazy_bg++;
 
164
 
159
165
redo_counts:
160
166
        had_problem = 0;
161
167
        save_problem = 0;
162
168
        pctx.blk = pctx.blk2 = NO_BLK;
 
169
        if (lazy_bg && (fs->group_desc[group].bg_flags &
 
170
                        EXT2_BG_BLOCK_UNINIT))
 
171
                skip_group++;
 
172
        super = fs->super->s_first_data_block;
163
173
        for (i = fs->super->s_first_data_block;
164
174
             i < fs->super->s_blocks_count;
165
175
             i++) {
166
176
                actual = ext2fs_fast_test_block_bitmap(ctx->block_found_map, i);
167
 
                bitmap = ext2fs_fast_test_block_bitmap(fs->block_map, i);
 
177
 
 
178
                if (skip_group) {
 
179
                        if ((i >= super) &&
 
180
                            (i <= super + fs->desc_blocks) &&
 
181
                            ext2fs_bg_has_super(fs, group))
 
182
                                bitmap = 1;
 
183
                        else if (i == fs->group_desc[group].bg_block_bitmap)
 
184
                                bitmap = 1;
 
185
                        else if (i == fs->group_desc[group].bg_inode_bitmap)
 
186
                                bitmap = 1;
 
187
                        else if (i >= fs->group_desc[group].bg_inode_table &&
 
188
                                 (i < fs->group_desc[group].bg_inode_table
 
189
                                  + fs->inode_blocks_per_group))
 
190
                                bitmap = 1;
 
191
                        else
 
192
                                bitmap = 0;
 
193
                        actual = (actual != 0);
 
194
                } else
 
195
                        bitmap = ext2fs_fast_test_block_bitmap(fs->block_map, i);
168
196
                
169
197
                if (actual == bitmap)
170
198
                        goto do_counts;
171
 
                
 
199
 
172
200
                if (!actual && bitmap) {
173
201
                        /*
174
202
                         * Block not used, but marked in use in the bitmap.
197
225
                had_problem++;
198
226
                
199
227
        do_counts:
200
 
                if (!bitmap) {
 
228
                if (!bitmap && !skip_group) {
201
229
                        group_free++;
202
230
                        free_blocks++;
203
231
                }
208
236
                        group ++;
209
237
                        blocks = 0;
210
238
                        group_free = 0;
 
239
                        skip_group = 0;
 
240
                        super += fs->super->s_blocks_per_group;
211
241
                        if (ctx->progress)
212
242
                                if ((ctx->progress)(ctx, 5, group,
213
243
                                                    fs->group_desc_count*2))
214
244
                                        return;
 
245
                        if (lazy_bg &&
 
246
                            (i != fs->super->s_blocks_count-1) &&
 
247
                            (fs->group_desc[group].bg_flags &
 
248
                             EXT2_BG_BLOCK_UNINIT))
 
249
                                skip_group++;
215
250
                }
216
251
        }
217
252
        if (pctx.blk != NO_BLK)
286
321
        errcode_t       retval;
287
322
        struct problem_context  pctx;
288
323
        int             problem, save_problem, fixit, had_problem;
 
324
        int             lazy_bg = 0;
 
325
        int             skip_group = 0;
289
326
        
290
327
        clear_problem_context(&pctx);
291
328
        free_array = (int *) e2fsck_allocate_memory(ctx,
321
358
                return;
322
359
        }
323
360
 
 
361
        if (EXT2_HAS_COMPAT_FEATURE(fs->super, 
 
362
                                    EXT2_FEATURE_COMPAT_LAZY_BG))
 
363
                lazy_bg++;
 
364
 
324
365
redo_counts:
325
366
        had_problem = 0;
326
367
        save_problem = 0;
327
368
        pctx.ino = pctx.ino2 = 0;
 
369
        if (lazy_bg && (fs->group_desc[group].bg_flags &
 
370
                        EXT2_BG_INODE_UNINIT))
 
371
                skip_group++;
 
372
 
328
373
        for (i = 1; i <= fs->super->s_inodes_count; i++) {
329
374
                actual = ext2fs_fast_test_inode_bitmap(ctx->inode_used_map, i);
330
 
                bitmap = ext2fs_fast_test_inode_bitmap(fs->inode_map, i);
331
 
                
 
375
                if (skip_group) 
 
376
                        bitmap = 0;
 
377
                else
 
378
                        bitmap = ext2fs_fast_test_inode_bitmap(fs->inode_map, i);
332
379
                if (actual == bitmap)
333
380
                        goto do_counts;
334
381
                
360
407
                had_problem++;
361
408
                
362
409
do_counts:
363
 
                if (!bitmap) {
364
 
                        group_free++;
365
 
                        free_inodes++;
366
 
                } else {
 
410
                if (bitmap) {
367
411
                        if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, i))
368
412
                                dirs_count++;
 
413
                } else if (!skip_group) {
 
414
                        group_free++;
 
415
                        free_inodes++;
369
416
                }
370
417
                inodes++;
371
418
                if ((inodes == fs->super->s_inodes_per_group) ||
374
421
                        dir_array[group] = dirs_count;
375
422
                        group ++;
376
423
                        inodes = 0;
 
424
                        skip_group = 0;
377
425
                        group_free = 0;
378
426
                        dirs_count = 0;
379
427
                        if (ctx->progress)
381
429
                                            group + fs->group_desc_count,
382
430
                                            fs->group_desc_count*2))
383
431
                                        return;
 
432
                        if (lazy_bg &&
 
433
                            (i != fs->super->s_inodes_count) &&
 
434
                            (fs->group_desc[group].bg_flags &
 
435
                             EXT2_BG_INODE_UNINIT))
 
436
                                skip_group++;
384
437
                }
385
438
        }
386
439
        if (pctx.ino)