static int allocate_dir_block(e2fsck_t ctx,
struct ext2_db_entry *dir_blocks_info,
char *buf, struct problem_context *pctx);
-static int update_dir_block(ext2_filsys fs,
- blk_t *block_nr,
- e2_blkcnt_t blockcnt,
- blk_t ref_block,
- int ref_offset,
- void *priv_data);
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
static int htree_depth(struct dx_dir_info *dx_dir,
struct dx_dirblock_info *dx_db);
group = ext2fs_group_of_ino(fs, dirent->inode);
first_unused_inode = group * fs->super->s_inodes_per_group +
1 + fs->super->s_inodes_per_group -
- fs->group_desc[group].bg_itable_unused;
+ ext2fs_bg_itable_unused(fs, group);
cd->pctx.group = group;
/*
* we could call a function in pass1.c that checks the
* newly visible inodes.
*/
- if (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)) {
+ if (ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT)) {
pctx.num = dirent->inode;
if (fix_problem(ctx, PR_2_INOREF_BG_INO_UNINIT,
&cd->pctx)){
- ext2fs_bg_flag_clear(fs, group,
+ ext2fs_bg_flags_clear(fs, group,
EXT2_BG_INODE_UNINIT);
ext2fs_mark_super_dirty(fs);
ctx->flags |= E2F_FLAG_RESTART_LATER;
} else if (dirent->inode >= first_unused_inode) {
pctx.num = dirent->inode;
if (fix_problem(ctx, PR_2_INOREF_IN_UNUSED, &cd->pctx)){
- fs->group_desc[group].bg_itable_unused = 0;
+ ext2fs_bg_itable_unused_set(fs, group, 0);
ext2fs_mark_super_dirty(fs);
ctx->flags |= E2F_FLAG_RESTART_LATER;
} else {
}
}
- if (!(ext2fs_test_inode_bitmap2(ctx->inode_used_map,
- dirent->inode))) {
- /*
- * If the inode is unused, offer to clear it.
- */
+ /*
+ * Offer to clear unused inodes; if we are going to be
+ * restarting the scan due to bg_itable_unused being
+ * wrong, then don't clear any inodes to avoid zapping
+ * inodes that were skipped during pass1 due to an
+ * incorrect bg_itable_unused; we'll get any real
+ * problems after we restart.
+ */
+ if (!(ctx->flags & E2F_FLAG_RESTART_LATER) &&
+ !(ext2fs_test_inode_bitmap2(ctx->inode_used_map,
+ dirent->inode)))
problem = PR_2_UNUSED_INODE;
- }
if (problem) {
if (fix_problem(ctx, problem, &cd->pctx)) {
if (HOLE_BLKADDR(*block_nr))
return 0;
if ((*block_nr < fs->super->s_first_data_block) ||
- (*block_nr >= fs->super->s_blocks_count))
+ (*block_nr >= ext2fs_blocks_count(fs->super)))
return 0;
ext2fs_unmark_block_bitmap2(ctx->block_found_map, *block_nr);
- ext2fs_block_alloc_stats(fs, *block_nr, -1);
+ ext2fs_block_alloc_stats2(fs, *block_nr, -1);
return 0;
}
}
if (count == 0) {
ext2fs_unmark_block_bitmap2(ctx->block_found_map,
- ext2fs_file_acl_block(&inode));
- ext2fs_block_alloc_stats(fs, ext2fs_file_acl_block(&inode), -1);
+ ext2fs_file_acl_block(&inode));
+ ext2fs_block_alloc_stats2(fs,
+ ext2fs_file_acl_block(&inode),
+ -1);
}
ext2fs_file_acl_block_set(&inode, 0);
}
if (ext2fs_file_acl_block(&inode) &&
((ext2fs_file_acl_block(&inode) < fs->super->s_first_data_block) ||
- (ext2fs_file_acl_block(&inode) >= fs->super->s_blocks_count))) {
+ (ext2fs_file_acl_block(&inode) >= ext2fs_blocks_count(fs->super)))) {
if (fix_problem(ctx, PR_2_FILE_ACL_BAD, &pctx)) {
ext2fs_file_acl_block_set(&inode, 0);
inode_modified++;
* Finally, update the block pointers for the inode
*/
db->blk = blk;
- pctx->errcode = ext2fs_block_iterate2(fs, db->ino, BLOCK_FLAG_HOLE,
- 0, update_dir_block, db);
+ pctx->errcode = ext2fs_bmap2(fs, db->ino, &inode, 0, BMAP_SET,
+ db->blockcnt, 0, &blk);
if (pctx->errcode) {
pctx->str = "ext2fs_block_iterate";
fix_problem(ctx, PR_2_ALLOC_DIRBOCK, pctx);
return 0;
}
-
-/*
- * This is a helper function for allocate_dir_block().
- */
-static int update_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)),
- blk_t *block_nr,
- e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
- int ref_offset EXT2FS_ATTR((unused)),
- void *priv_data)
-{
- struct ext2_db_entry *db;
-
- db = (struct ext2_db_entry *) priv_data;
- if (db->blockcnt == (int) blockcnt) {
- *block_nr = db->blk;
- return BLOCK_CHANGED;
- }
- return 0;
-}