void dump_mmp_msg(struct mmp_struct *mmp, const char *msg);
errcode_t e2fsck_mmp_update(ext2_filsys fs);
+extern void e2fsck_set_bitmap_type(ext2_filsys fs,
+ unsigned int default_type,
+ const char *profile_name,
+ unsigned int *old_type);
+extern errcode_t e2fsck_allocate_inode_bitmap(ext2_filsys fs,
+ const char *descr,
+ int default_type,
+ const char *profile_name,
+ ext2fs_inode_bitmap *ret);
+extern errcode_t e2fsck_allocate_block_bitmap(ext2_filsys fs,
+ const char *descr,
+ int default_type,
+ const char *profile_name,
+ ext2fs_block_bitmap *ret);
+extern errcode_t e2fsck_allocate_subcluster_bitmap(ext2_filsys fs,
+ const char *descr,
+ int default_type,
+ const char *profile_name,
+ ext2fs_block_bitmap *ret);
+
/* unix.c */
extern void e2fsck_clear_progbar(e2fsck_t ctx);
extern int e2fsck_simple_progress(e2fsck_t ctx, const char *label,
struct scan_callback_struct scan_struct;
struct ext2_super_block *sb = ctx->fs->super;
const char *old_op;
+ unsigned int save_type;
int imagic_fs, extent_fs;
int busted_fs_time = 0;
int inode_size;
/*
* Allocate bitmaps structures
*/
- pctx.errcode = ext2fs_allocate_inode_bitmap(fs, _("in-use inode map"),
- &ctx->inode_used_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(fs, _("in-use inode map"),
+ EXT2FS_BMAP64_RBTREE,
+ "inode_used_map",
+ &ctx->inode_used_map);
if (pctx.errcode) {
pctx.num = 1;
fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
return;
}
- pctx.errcode = ext2fs_allocate_inode_bitmap(fs,
- _("directory inode map"), &ctx->inode_dir_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(fs,
+ _("directory inode map"),
+ EXT2FS_BMAP64_AUTODIR,
+ "inode_dir_map", &ctx->inode_dir_map);
if (pctx.errcode) {
pctx.num = 2;
fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
return;
}
- pctx.errcode = ext2fs_allocate_inode_bitmap(fs,
- _("regular file inode map"), &ctx->inode_reg_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(fs,
+ _("regular file inode map"), EXT2FS_BMAP64_RBTREE,
+ "inode_reg_map", &ctx->inode_reg_map);
if (pctx.errcode) {
pctx.num = 6;
fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
return;
}
- pctx.errcode = ext2fs_allocate_subcluster_bitmap(fs,
- _("in-use block map"),
- &ctx->block_found_map);
+ pctx.errcode = e2fsck_allocate_subcluster_bitmap(fs,
+ _("in-use block map"), EXT2FS_BMAP64_RBTREE,
+ "block_found_map", &ctx->block_found_map);
if (pctx.errcode) {
pctx.num = 1;
fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx);
return;
}
e2fsck_setup_tdb_icount(ctx, 0, &ctx->inode_link_info);
- if (!ctx->inode_link_info)
+ if (!ctx->inode_link_info) {
+ e2fsck_set_bitmap_type(fs, EXT2FS_BMAP64_RBTREE,
+ "inode_link_info", &save_type);
pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
&ctx->inode_link_info);
+ fs->default_bitmap_type = save_type;
+ }
+
if (pctx.errcode) {
fix_problem(ctx, PR_1_ALLOCATE_ICOUNT, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
if (!ctx->inode_bad_map) {
clear_problem_context(&pctx);
- pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
- _("bad inode map"), &ctx->inode_bad_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
+ _("bad inode map"), EXT2FS_BMAP64_RBTREE,
+ "inode_bad_map", &ctx->inode_bad_map);
if (pctx.errcode) {
pctx.num = 3;
fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
struct problem_context pctx;
clear_problem_context(&pctx);
- pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
- _("inode in bad block map"),
- &ctx->inode_bb_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
+ _("inode in bad block map"), EXT2FS_BMAP64_RBTREE,
+ "inode_bb_map", &ctx->inode_bb_map);
if (pctx.errcode) {
pctx.num = 4;
fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
struct problem_context pctx;
clear_problem_context(&pctx);
- pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
- _("imagic inode map"),
- &ctx->inode_imagic_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
+ _("imagic inode map"), EXT2FS_BMAP64_RBTREE,
+ "inode_imagic_map", &ctx->inode_imagic_map);
if (pctx.errcode) {
pctx.num = 5;
fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
if (ext2fs_fast_test_block_bitmap2(ctx->block_found_map, block)) {
if (!ctx->block_dup_map) {
- pctx.errcode = ext2fs_allocate_block_bitmap(ctx->fs,
- _("multiply claimed block map"),
- &ctx->block_dup_map);
+ pctx.errcode = e2fsck_allocate_block_bitmap(ctx->fs,
+ _("multiply claimed block map"),
+ EXT2FS_BMAP64_RBTREE, "block_dup_map",
+ &ctx->block_dup_map);
if (pctx.errcode) {
pctx.num = 3;
fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR,
/* If ea bitmap hasn't been allocated, create it */
if (!ctx->block_ea_map) {
- pctx->errcode = ext2fs_allocate_block_bitmap(fs,
- _("ext attr block map"),
- &ctx->block_ea_map);
+ pctx->errcode = e2fsck_allocate_block_bitmap(fs,
+ _("ext attr block map"),
+ EXT2FS_BMAP64_RBTREE, "block_ea_map",
+ &ctx->block_ea_map);
if (pctx->errcode) {
pctx->num = 2;
fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, pctx);
clear_problem_context(&pctx);
- pctx.errcode = ext2fs_allocate_inode_bitmap(fs,
- _("multiply claimed inode map"), &inode_dup_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(fs,
+ _("multiply claimed inode map"),
+ EXT2FS_BMAP64_RBTREE, "inode_dup_map",
+ &inode_dup_map);
if (pctx.errcode) {
fix_problem(ctx, PR_1B_ALLOCATE_IBITMAP_ERROR, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
struct check_dir_struct cd;
struct dx_dir_info *dx_dir;
struct dx_dirblock_info *dx_db, *dx_parent;
+ unsigned int save_type;
int b;
int i, depth;
problem_t code;
&ctx->inode_count);
if (ctx->inode_count)
cd.pctx.errcode = 0;
- else
+ else {
+ e2fsck_set_bitmap_type(fs, EXT2FS_BMAP64_RBTREE,
+ "inode_count", &save_type);
cd.pctx.errcode = ext2fs_create_icount2(fs,
EXT2_ICOUNT_OPT_INCREMENT,
0, ctx->inode_link_info,
&ctx->inode_count);
+ fs->default_bitmap_type = save_type;
+ }
if (cd.pctx.errcode) {
fix_problem(ctx, PR_2_ALLOCATE_ICOUNT, &cd.pctx);
ctx->flags |= E2F_FLAG_ABORT;
/*
* Allocate some bitmaps to do loop detection.
*/
- pctx.errcode = ext2fs_allocate_inode_bitmap(fs, _("inode done bitmap"),
- &inode_done_map);
+ pctx.errcode = e2fsck_allocate_inode_bitmap(fs, _("inode done bitmap"),
+ EXT2FS_BMAP64_AUTODIR,
+ "inode_done_map", &inode_done_map);
if (pctx.errcode) {
pctx.num = 2;
fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, &pctx);
if (inode_loop_detect)
ext2fs_clear_inode_bitmap(inode_loop_detect);
else {
- pctx->errcode = ext2fs_allocate_inode_bitmap(fs, _("inode loop detection bitmap"), &inode_loop_detect);
+ pctx->errcode = e2fsck_allocate_inode_bitmap(fs, _("inode loop detection bitmap"), EXT2FS_BMAP64_AUTODIR, "inode_loop_detect", &inode_loop_detect);
if (pctx->errcode) {
pctx->num = 1;
fix_problem(ctx,
} else
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
flags, 0, 0, io_ptr, ret_fs);
+
+ if (ret_fs)
+ e2fsck_set_bitmap_type(*ret_fs, EXT2FS_BMAP64_RBTREE,
+ "default", NULL);
return retval;
}
ext2_filsys fs = ctx->fs;
errcode_t retval;
const char *old_op;
+ unsigned int save_type;
if (ctx->invalid_bitmaps) {
com_err(ctx->program_name, 0,
}
old_op = ehandler_operation(_("reading inode and block bitmaps"));
+ e2fsck_set_bitmap_type(fs, EXT2FS_BMAP64_RBTREE, "fs_bitmaps",
+ &save_type);
retval = ext2fs_read_bitmaps(fs);
+ fs->default_bitmap_type = save_type;
ehandler_operation(old_op);
if (retval) {
com_err(ctx->program_name, retval,
return retval;
}
+
+void e2fsck_set_bitmap_type(ext2_filsys fs, unsigned int default_type,
+ const char *profile_name, unsigned int *old_type)
+{
+ unsigned type;
+ errcode_t retval;
+
+ if (old_type)
+ *old_type = fs->default_bitmap_type;
+ profile_get_uint(e2fsck_global_ctx->profile, "bitmaps",
+ profile_name, 0, default_type, &type);
+ profile_get_uint(e2fsck_global_ctx->profile, "bitmaps",
+ "all", 0, type, &type);
+ fs->default_bitmap_type = type ? type : default_type;
+}
+
+errcode_t e2fsck_allocate_inode_bitmap(ext2_filsys fs, const char *descr,
+ int deftype,
+ const char *name,
+ ext2fs_inode_bitmap *ret)
+{
+ errcode_t retval;
+ unsigned int save_type;
+
+ e2fsck_set_bitmap_type(fs, deftype, name, &save_type);
+ retval = ext2fs_allocate_inode_bitmap(fs, descr, ret);
+ fs->default_bitmap_type = save_type;
+ return retval;
+}
+
+errcode_t e2fsck_allocate_block_bitmap(ext2_filsys fs, const char *descr,
+ int deftype,
+ const char *name,
+ ext2fs_block_bitmap *ret)
+{
+ errcode_t retval;
+ unsigned int save_type;
+
+ e2fsck_set_bitmap_type(fs, deftype, name, &save_type);
+ retval = ext2fs_allocate_block_bitmap(fs, descr, ret);
+ fs->default_bitmap_type = save_type;
+ return retval;
+}
+
+errcode_t e2fsck_allocate_subcluster_bitmap(ext2_filsys fs, const char *descr,
+ int deftype,
+ const char *name,
+ ext2fs_block_bitmap *ret)
+{
+ errcode_t retval;
+ unsigned int save_type;
+
+ e2fsck_set_bitmap_type(fs, deftype, name, &save_type);
+ retval = ext2fs_allocate_subcluster_bitmap(fs, descr, ret);
+ fs->default_bitmap_type = save_type;
+ return retval;
+}
/*
* 64-bit bitmap backend types
*/
-
#define EXT2FS_BMAP64_BITARRAY 1
#define EXT2FS_BMAP64_RBTREE 2
#define EXT2FS_BMAP64_AUTODIR 3