Home | History | Annotate | Download | only in e2fsck

Lines Matching refs:ctx

64 static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
66 static void mark_table_blocks(e2fsck_t ctx);
67 static void alloc_bb_map(e2fsck_t ctx);
68 static void alloc_imagic_map(e2fsck_t ctx);
69 static void mark_inode_bad(e2fsck_t ctx, ino_t ino);
70 static void handle_fs_bad_blocks(e2fsck_t ctx);
71 static void process_inodes(e2fsck_t ctx, char *block_buf);
75 static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
92 e2fsck_t ctx;
101 e2fsck_t ctx;
239 static void check_immutable(e2fsck_t ctx, struct problem_context *pctx)
244 if (!fix_problem(ctx, PR_1_SET_IMMUTABLE, pctx))
248 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
255 static void check_size(e2fsck_t ctx, struct problem_context *pctx)
262 if (!fix_problem(ctx, PR_1_SET_NONZSIZE, pctx))
267 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
270 static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx)
272 struct ext2_super_block *sb = ctx->fs->super;
280 storage_size = EXT2_INODE_SIZE(ctx->fs->super) - EXT2_GOOD_OLD_INODE_SIZE -
284 end = (char *) inode + EXT2_INODE_SIZE(ctx->fs->super);
341 if (problem == 0 || !fix_problem(ctx, problem, pctx))
346 e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode,
350 static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx)
352 struct ext2_super_block *sb = ctx->fs->super;
376 if (!fix_problem(ctx, PR_1_EXTRA_ISIZE, pctx))
379 e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode,
388 check_ea_in_inode(ctx, pctx);
400 static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
440 extent_fs = (ctx->fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS);
443 if (ext2fs_bmap(ctx->fs, pctx->ino, inode, 0, 0, 0,
456 if (blk < ctx->fs->super->s_first_data_block ||
457 blk >= ctx->fs->super->s_blocks_count ||
458 ext2fs_fast_test_block_bitmap(ctx->block_found_map,
476 retval = ext2fs_read_dir_block(ctx->fs, blk, buf);
482 retval = ext2fs_get_rec_len(ctx->fs, dirent, &rec_len);
490 (rec_len >= ctx->fs->blocksize - 12))
494 retval = ext2fs_get_rec_len(ctx->fs, dirent, &rec_len);
504 if (fix_problem(ctx, PR_1_TREAT_AS_DIRECTORY, pctx)) {
506 e2fsck_write_inode_full(ctx, pctx->ino, inode,
507 EXT2_INODE_SIZE(ctx->fs->super),
512 extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
523 profile_get_string(ctx->profile, "scratch_files", "directory", 0, 0,
525 profile_get_uint(ctx->profile, "scratch_files",
527 profile_get_boolean(ctx->profile, "scratch_files",
530 retval = ext2fs_get_num_dirs(ctx->fs, &num_dirs);
538 retval = ext2fs_create_icount_tdb(ctx->fs, tdb_dir, flags, ret);
543 void e2fsck_pass1(e2fsck_t ctx)
547 ext2_filsys fs = ctx->fs;
558 struct ext2_super_block *sb = ctx->fs->super;
564 init_resource_track(&rtrack, ctx->fs->io);
567 if (!(ctx->options & E2F_OPT_PREEN))
568 fix_problem(ctx, PR_1_PASS_HEADER, &pctx);
571 !(ctx->options & E2F_OPT_NO)) {
572 if (ext2fs_u32_list_create(&ctx->dirs_to_hash, 50))
573 ctx->dirs_to_hash = 0;
598 &ctx->inode_used_map);
601 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
602 ctx->flags |= E2F_FLAG_ABORT;
606 _("directory inode map"), &ctx->inode_dir_map);
609 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
610 ctx->flags |= E2F_FLAG_ABORT;
614 _("regular file inode map"), &ctx->inode_reg_map);
617 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
618 ctx->flags |= E2F_FLAG_ABORT;
622 &ctx->block_found_map);
625 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx);
626 ctx->flags |= E2F_FLAG_ABORT;
629 e2fsck_setup_tdb_icount(ctx, 0, &ctx->inode_link_info);
630 if (!ctx->inode_link_info)
632 &ctx->inode_link_info);
634 fix_problem(ctx, PR_1_ALLOCATE_ICOUNT, &pctx);
635 ctx->flags |= E2F_FLAG_ABORT;
640 e2fsck_allocate_memory(ctx, inode_size, "scratch inode");
643 e2fsck_allocate_memory(ctx,
644 (ctx->process_inode_size *
651 fix_problem(ctx, PR_1_ALLOCATE_DBCOUNT, &pctx);
652 ctx->flags |= E2F_FLAG_ABORT;
664 if (!(ctx->options & E2F_OPT_READONLY)) {
671 mark_table_blocks(ctx);
672 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 3,
674 e2fsck_use_inode_shortcuts(ctx, 1);
676 pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
680 fix_problem(ctx, PR_1_ISCAN_ERROR, &pctx);
681 ctx->flags |= E2F_FLAG_ABORT;
687 ctx->stashed_inode = inode;
688 scan_struct.ctx = ctx;
691 if (ctx->progress)
692 if ((ctx->progress)(ctx, 1, 0, ctx->fs->group_desc_count))
703 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
706 if (!ctx->inode_bb_map)
707 alloc_bb_map(ctx);
708 ext2fs_mark_inode_bitmap(ctx->inode_bb_map, ino);
709 ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
713 fix_problem(ctx, PR_1_ISCAN_ERROR, &pctx);
714 ctx->flags |= E2F_FLAG_ABORT;
721 ctx->stashed_ino = ino;
723 pctx.errcode = ext2fs_icount_store(ctx->inode_link_info,
727 fix_problem(ctx, PR_1_ICOUNT_STORE, &pctx);
728 ctx->flags |= E2F_FLAG_ABORT;
753 fix_problem(ctx, PR_1_EXTENT_FEATURE, &pctx)) {
757 } else if (fix_problem(ctx, PR_1_EXTENTS_SET, &pctx)) {
759 e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
761 ext2fs_mark_inode_bitmap(ctx->inode_used_map,
792 (fix_problem(ctx, PR_1_UNSET_EXTENT_FL, &pctx))) {
798 e2fsck_write_inode(ctx, ino, inode, "pass1");
805 pctx.errcode = ext2fs_copy_bitmap(ctx->block_found_map,
809 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx);
810 ctx->flags |= E2F_FLAG_ABORT;
821 pb.ctx = ctx;
826 fix_problem(ctx, PR_1_BLOCK_ITERATE, &pctx);
827 ctx->flags |= E2F_FLAG_ABORT;
831 if (!fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK_PROMPT, &pctx)) {
832 ctx->flags |= E2F_FLAG_ABORT;
835 ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
845 if (fix_problem(ctx, PR_1_ROOT_NO_DIR, &pctx))
858 if (fix_problem(ctx, PR_1_ROOT_DTIME, &pctx)) {
860 e2fsck_write_inode(ctx, ino, inode,
865 ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
868 fix_problem(ctx, PR_1_JOURNAL_BAD_MODE,
871 e2fsck_write_inode(ctx, ino, inode,
874 check_blocks(ctx, &pctx, block_buf);
879 fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
882 ext2fs_icount_store(ctx->inode_link_info,
884 e2fsck_write_inode_full(ctx, ino, inode,
890 ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
903 if (fix_problem(ctx, problem, &pctx)) {
905 e2fsck_write_inode(ctx, ino, inode,
909 check_blocks(ctx, &pctx, block_buf);
930 inode->i_dtime < ctx->fs->super->s_inodes_count) {
931 if (fix_problem(ctx, PR_1_LOW_DTIME, &pctx)) {
933 0 : ctx->now;
934 e2fsck_write_inode(ctx, ino, inode,
945 if (fix_problem(ctx,
947 inode->i_dtime = ctx->now;
948 e2fsck_write_inode(ctx, ino, inode,
965 if (fix_problem(ctx, PR_1_SET_DTIME, &pctx)) {
967 e2fsck_write_inode(ctx, ino, inode, "pass1");
971 ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
983 mark_inode_bad(ctx, ino);
987 mark_inode_bad(ctx, ino);
992 mark_inode_bad(ctx, ino);
995 if (!ctx->inode_imagic_map)
996 alloc_imagic_map(ctx);
997 ext2fs_mark_inode_bitmap(ctx->inode_imagic_map,
1000 if (fix_problem(ctx, PR_1_SET_IMAGIC, &pctx)) {
1002 e2fsck_write_inode(ctx, ino,
1008 check_inode_extra_space(ctx, &pctx);
1009 check_is_really_dir(ctx, &pctx, block_buf);
1018 fix_problem(ctx, PR_1_FAST_SYMLINK_EXTENT_FL, &pctx)) {
1020 e2fsck_write_inode(ctx, ino, inode, "pass1");
1024 ext2fs_mark_inode_bitmap(ctx->inode_dir_map, ino);
1025 e2fsck_add_dir_info(ctx, ino, 0);
1026 ctx->fs_directory_count++;
1028 ext2fs_mark_inode_bitmap(ctx->inode_reg_map, ino);
1029 ctx->fs_regular_count++;
1032 check_immutable(ctx, &pctx);
1033 check_size(ctx, &pctx);
1034 ctx->fs_chardev_count++;
1037 check_immutable(ctx, &pctx);
1038 check_size(ctx, &pctx);
1039 ctx->fs_blockdev_count++;
1043 check_immutable(ctx, &pctx);
1044 ctx->fs_symlinks_count++;
1046 ctx->fs_fast_symlinks_count++;
1047 check_blocks(ctx, &pctx, block_buf);
1053 check_immutable(ctx, &pctx);
1054 check_size(ctx, &pctx);
1055 ctx->fs_fifo_count++;
1058 check_immutable(ctx, &pctx);
1059 check_size(ctx, &pctx);
1060 ctx->fs_sockets_count++;
1062 mark_inode_bad(ctx, ino);
1065 ctx->fs_ind_count++;
1067 ctx->fs_dind_count++;
1069 ctx->fs_tind_count++;
1080 check_blocks(ctx, &pctx, block_buf);
1082 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
1085 if (process_inode_count >= ctx->process_inode_size) {
1086 process_inodes(ctx, block_buf);
1088 if (ctx
1092 process_inodes(ctx, block_buf);
1097 * be adjusted, either up (ctx->refcount_extra), or down
1098 * (ctx->refcount), then fix them.
1100 if (ctx->refcount) {
1101 adjust_extattr_refcount(ctx, ctx->refcount, block_buf, -1);
1102 ea_refcount_free(ctx->refcount);
1103 ctx->refcount = 0;
1105 if (ctx->refcount_extra) {
1106 adjust_extattr_refcount(ctx, ctx->refcount_extra,
1108 ea_refcount_free(ctx->refcount_extra);
1109 ctx->refcount_extra = 0;
1112 if (ctx->invalid_bitmaps)
1113 handle_fs_bad_blocks(ctx);
1116 if (ctx->block_ea_map) {
1117 ext2fs_free_block_bitmap(ctx->block_ea_map);
1118 ctx->block_ea_map = 0;
1121 if (ctx->flags & E2F_FLAG_RESIZE_INODE) {
1125 fs->block_map = ctx->block_found_map;
1129 if (!fix_problem(ctx, PR_1_RESIZE_INODE_CREATE,
1131 ctx->flags |= E2F_FLAG_ABORT;
1137 e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
1139 inode->i_mtime = ctx->now;
1140 e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
1144 ctx->flags &= ~E2F_FLAG_RESIZE_INODE;
1147 if (ctx->flags & E2F_FLAG_RESTART) {
1154 ctx->use_superblock = 0;
1159 if (ctx->block_dup_map) {
1160 if (ctx->options & E2F_OPT_PREEN) {
1162 fix_problem(ctx, PR_1_DUP_BLOCKS_PREENSTOP, &pctx);
1164 e2fsck_pass1_dupblocks(ctx, block_buf);
1168 e2fsck_use_inode_shortcuts(ctx, 0);
1173 print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io);
1185 e2fsck_t ctx;
1188 ctx = scan_struct->ctx;
1192 if (ctx->progress)
1193 if ((ctx->progress)(ctx, 1, group+1,
1194 ctx->fs->group_desc_count))
1203 static void process_inodes(e2fsck_t ctx, char *block_buf)
1218 old_stashed_inode = ctx->stashed_inode;
1219 old_stashed_ino = ctx->stashed_ino;
1224 pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
1225 pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino;
1233 check_blocks(ctx, &pctx, block_buf);
1234 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
1237 ctx->stashed_inode = old_stashed_inode;
1238 ctx->stashed_ino = old_stashed_ino;
1266 static void mark_inode_bad(e2fsck_t ctx, ino_t ino)
1270 if (!ctx->inode_bad_map) {
1273 pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
1274 _("bad inode map"), &ctx->inode_bad_map);
1277 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
1279 ctx->flags |= E2F_FLAG_ABORT;
1283 ext2fs_mark_inode_bitmap(ctx->inode_bad_map, ino);
1290 static void alloc_bb_map(e2fsck_t ctx)
1295 pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
1297 &ctx->inode_bb_map);
1300 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
1302 ctx->flags |= E2F_FLAG_ABORT;
1310 static void alloc_imagic_map(e2fsck_t ctx)
1315 pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
1317 &ctx->inode_imagic_map);
1320 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
1322 ctx->flags |= E2F_FLAG_ABORT;
1334 static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
1340 if (ext2fs_fast_test_block_bitmap(ctx->block_found_map, block)) {
1341 if (!ctx->block_dup_map) {
1342 pctx.errcode = ext2fs_allocate_block_bitmap(ctx->fs,
1344 &ctx->block_dup_map);
1347 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR,
1350 ctx->flags |= E2F_FLAG_ABORT;
1354 ext2fs_fast_mark_block_bitmap(ctx->block_dup_map, block);
1356 ext2fs_fast_mark_block_bitmap(ctx->block_found_map, block);
1363 * are still referenced in ctx->refcount, or by adding references for
1365 * ctx->refcount_extra.
1367 static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
1372 ext2_filsys fs = ctx->fs;
1386 fix_problem(ctx, PR_1_EXTATTR_READ_ABORT, &pctx);
1393 if (fix_problem(ctx, PR_1_EXTATTR_REFCOUNT, &pctx)) {
1398 fix_problem(ctx, PR_1_EXTATTR_WRITE_ABORT,
1409 static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
1412 ext2_filsys fs = ctx->fs;
1436 mark_inode_bad(ctx, ino);
1441 if (!ctx->block_ea_map) {
1444 &ctx->block_ea_map);
1447 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, pctx);
1448 ctx->flags |= E2F_FLAG_ABORT;
1454 if (!ctx->refcount) {
1455 pctx->errcode = ea_refcount_create(0, &ctx->refcount);
1458 fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx);
1459 ctx->flags |= E2F_FLAG_ABORT;
1470 if (ext2fs_fast_test_block_bitmap(ctx->block_ea_map, blk)) {
1471 if (ea_refcount_decrement(ctx->refcount, blk, 0) == 0)
1474 if (!ctx->refcount_extra) {
1476 &ctx->refcount_extra);
1479 fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx);
1480 ctx->flags |= E2F_FLAG_ABORT;
1484 ea_refcount_increment(ctx->refcount_extra, blk, 0);
1494 if (pctx->errcode && fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx))
1498 if (((ctx->ext_attr_ver == 1) &&
1500 ((ctx->ext_attr_ver == 2) &&
1502 if (fix_problem(ctx, PR_1_BAD_EA_BLOCK, pctx))
1507 if (fix_problem(ctx, PR_1_EA_MULTI_BLOCK, pctx))
1513 fix_problem(ctx, PR_1_EA_ALLOC_REGION_ABORT, pctx);
1514 ctx->flags |= E2F_FLAG_ABORT;
1518 if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx))
1529 if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx))
1533 if ((ctx->ext_attr_ver == 1 &&
1535 (ctx->ext_attr_ver == 2 &&
1537 if (fix_problem(ctx, PR_1_EA_BAD_NAME, pctx))
1542 if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx))
1546 if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx))
1553 if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx))
1562 if (fix_problem(ctx, PR_1_ATTR_HASH, pctx))
1570 if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx))
1577 ea_refcount_store(ctx->refcount, blk, count);
1578 mark_block_used(ctx, blk);
1579 ext2fs_fast_mark_block_bitmap(ctx->block_ea_map, blk);
1586 e2fsck_write_inode(ctx, ino, inode, "check_ext_attr");
1591 static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
1596 ext2_filsys fs = ctx->fs;
1601 fix_problem(ctx, PR_1_HTREE_NODIR, pctx)) ||
1603 fix_problem(ctx, PR_1_HTREE_SET, pctx)))
1612 if (fix_problem(ctx, PR_1_HTREE_BADROOT, pctx))
1619 if (retval && fix_problem(ctx, PR_1_HTREE_BADROOT, pctx))
1626 fix_problem(ctx, PR_1_HTREE_BADROOT, pctx))
1633 fix_problem(ctx, PR_1_HTREE_HASHV, pctx))
1637 fix_problem(ctx, PR_1_HTREE_INCOMPAT, pctx))
1642 fix_problem(ctx, PR_1_HTREE_DEPTH, pctx))
1648 void e2fsck_clear_inode(e2fsck_t ctx, ext2_ino_t ino,
1654 ext2fs_icount_store(ctx->inode_link_info, ino, 0);
1655 inode->i_dtime = ctx->now;
1657 ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino);
1658 ext2fs_unmark_inode_bitmap(ctx->inode_used_map, ino);
1659 if (ctx->inode_reg_map)
1660 ext2fs_unmark_inode_bitmap(ctx->inode_reg_map, ino);
1661 if (ctx->inode_bad_map)
1662 ext2fs_unmark_inode_bitmap(ctx->inode_bad_map, ino);
1668 ctx->flags |= restart_flag;
1670 e2fsck_write_inode(ctx, ino, inode, source);
1673 static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
1698 extent.e_pblk < ctx->fs->super->s_first_data_block ||
1699 extent.e_pblk >= ctx->fs->super->s_blocks_count)
1705 ctx->fs->super->s_blocks_count)
1713 if (fix_problem(ctx, problem, pctx)) {
1714 e2fsck_read_bitmaps(ctx);
1744 scan_extent_node(ctx, pctx, pb, extent.e_lblk, ehandle);
1753 mark_block_used(ctx, blk);
1760 if (ctx->options & E2F_OPT_FRAGCHECK) {
1780 pctx->errcode = ext2fs_add_dir_block(ctx->fs->dblist,
1792 mark_block_used(ctx, blk);
1795 pctx->errcode = ext2fs_add_dir_block(ctx->fs->dblist, pctx->ino, blk, blockcnt);
1800 fix_problem(ctx, PR_1_ADD_DBLOCK, pctx);
1802 ctx->flags |= E2F_FLAG_ABORT;
1821 static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
1827 ext2_filsys fs = ctx->fs;
1833 if (fix_problem(ctx, PR_1_READ_EXTENT, pctx))
1834 e2fsck_clear_inode(ctx, ino, inode, 0,
1844 ctx->extent_depth_count[info.max_depth]++;
1847 scan_extent_node(ctx, pctx, pb, 0, ehandle);
1849 fix_problem(ctx, PR_1_EXTENT_ITERATE_FAILURE, pctx)) {
1852 e2fsck_clear_inode(ctx, ino, inode, E2F_FLAG_RESTART,
1872 static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
1875 ext2_filsys fs = ctx->fs;
1898 pb.ctx = ctx;
1902 extent_fs = (ctx->fs->super->s_feature_incompat &
1910 if (fix_problem(ctx, PR_1_COMPR_SET, pctx)) {
1917 if (inode->i_file_acl && check_ext_attr(ctx, pctx, block_buf)) {
1918 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
1925 check_blocks_extents(ctx, pctx, &pb);
1931 end_problem_latch(ctx, PR_LATCH_BLOCK);
1932 end_problem_latch(ctx, PR_LATCH_TOOBIG);
1933 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
1936 fix_problem(ctx, PR_1_BLOCK_ITERATE, pctx);
1940 ctx->fs_fragmented_dir++;
1942 ctx->fs_fragmented++;
1946 e2fsck_clear_inode(ctx, ino, inode, E2F_FLAG_RESTART,
1952 if (handle_htree(ctx, pctx, ino, inode, block_buf)) {
1957 e2fsck_add_dx_dir(ctx, ino, pb.last_block+1);
1963 if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) {
1964 e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks");
1965 ctx->fs_directory_count--;
1991 e2_blkcnt_t blkpg = ctx->blocks_per_page;
2018 if (fix_problem(ctx, PR_1_EOFBLOCKS_FL_SET, pctx)) {
2028 if (fix_problem(ctx, PR_1_BAD_I_SIZE, pctx)) {
2038 ctx->large_files++;
2045 if (fix_problem(ctx, PR_1_BAD_I_BLOCKS, pctx)) {
2053 if (ctx->dirs_to_hash && pb.is_dir &&
2056 ext2fs_u32_list_add(ctx->dirs_to_hash, ino);
2060 e2fsck_write_inode(ctx, ino, inode, "check_blocks");
2130 e2fsck_t ctx;
2134 ctx = p->ctx;
2173 if (ctx->options & E2F_OPT_FRAGCHECK) {
2207 if (fix_problem(ctx, PR_1_TOO_MANY_BAD_BLOCKS, pctx)) {
2211 if (fix_problem(ctx, PR_1_SUPPRESS_MESSAGES, pctx)) {
2219 if (fix_problem(ctx, problem, pctx)) {
2236 mark_block_used(ctx, blk);
2238 mark_block_used(ctx, blk);
2260 fix_problem(ctx, PR_1_ADD_DBLOCK, pctx);
2262 ctx->flags |= E2F_FLAG_ABORT;
2281 e2fsck_t ctx;
2292 ctx = p->ctx;
2301 if (fix_problem(ctx, PR_1_BB_ILLEGAL_BLOCK_NUM, pctx)) {
2311 if (fix_problem(ctx, PR_1_BB_FS_BLOCK, pctx)) {
2315 } else if (ext2fs_test_block_bitmap(ctx->block_found_map,
2318 if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK,
2323 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
2326 mark_block_used(ctx, blk);
2332 ctx->fs_badblocks_count++;
2339 if (!ext2fs_test_block_bitmap(ctx->block_found_map, blk)) {
2340 ext2fs_mark_block_bitmap(ctx->block_found_map, blk);
2355 if (fix_problem(ctx,
2363 fix_problem(ctx, PR_1_BAD_SUPERBLOCK, pctx);
2370 if (fix_problem(ctx,
2377 fix_problem(ctx, PR_1_BAD_GROUP_DESCRIPTORS, pctx);
2382 if (fix_problem(ctx, PR_1_BB_BAD_BLOCK, pctx)) {
2383 ctx->invalid_block_bitmap_flag[i]++;
2384 ctx->invalid_bitmaps++;
2389 if (fix_problem(ctx, PR_1_IB_BAD_BLOCK, pctx)) {
2390 ctx->invalid_inode_bitmap_flag[i]++;
2391 ctx->invalid_bitmaps++;
2416 if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK, pctx)) {
2420 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
2428 fix_problem(ctx, PR_1_PROGERR_CLAIMED_BLOCK, pctx);
2433 static void new_table_block(e2fsck_t ctx, blk_t first_block, int group,
2436 ext2_filsys fs = ctx->fs;
2469 num, ctx->block_found_map,
2475 num, ctx->block_found_map, new_block);
2478 fix_problem(ctx, PR_1_RELOC_BLOCK_ALLOCATE, &pctx);
2480 ctx->flags |= E2F_FLAG_ABORT;
2485 fix_problem(ctx, PR_1_RELOC_MEMORY_ALLOCATE, &pctx);
2487 ctx->flags |= E2F_FLAG_ABORT;
2493 fix_problem(ctx, (old_block ? PR_1_RELOC_FROM_TO :
2498 ext2fs_mark_block_bitmap(ctx->block_found_map, (*new_block)+i);
2503 fix_problem(ctx, PR_1_RELOC_READ_ERR, &pctx);
2511 fix_problem(ctx, PR_1_RELOC_WRITE_ERR, &pctx);
2523 static void handle_fs_bad_blocks(e2fsck_t ctx)
2525 ext2_filsys fs = ctx->fs;
2532 if (ctx->invalid_block_bitmap_flag[i]) {
2533 new_table_block(ctx, first_block, i, _("block bitmap"),
2536 if (ctx->invalid_inode_bitmap_flag[i]) {
2537 new_table_block(ctx, first_block, i, _("inode bitmap"),
2540 if (ctx->invalid_inode_table_flag[i]) {
2541 new_table_block(ctx, first_block, i, _("inode table"),
2544 ctx->flags |= E2F_FLAG_RESTART;
2547 ctx->invalid_bitmaps = 0;
2554 static void mark_table_blocks(e2fsck_t ctx)
2556 ext2_filsys fs = ctx->fs;
2567 ext2fs_reserve_super_and_bgd(fs, i, ctx->block_found_map);
2576 if (ext2fs_test_block_bitmap(ctx->block_found_map,
2579 if (!ctx->invalid_inode_table_flag[i] &&
2580 fix_problem(ctx,
2582 ctx->invalid_inode_table_flag[i]++;
2583 ctx->invalid_bitmaps++;
2586 ext2fs_mark_block_bitmap(ctx->block_found_map,
2596 if (ext2fs_test_block_bitmap(ctx->block_found_map,
2599 if (fix_problem(ctx, PR_1_BB_CONFLICT, &pctx)) {
2600 ctx->invalid_block_bitmap_flag[i]++;
2601 ctx->invalid_bitmaps++;
2604 ext2fs_mark_block_bitmap(ctx->block_found_map,
2613 if (ext2fs_test_block_bitmap(ctx->block_found_map,
2616 if (fix_problem(ctx, PR_1_IB_CONFLICT, &pctx)) {
2617 ctx->invalid_inode_bitmap_flag[i]++;
2618 ctx->invalid_bitmaps++;
2621 ext2fs_mark_block_bitmap(ctx->block_found_map,
2637 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2640 if ((ino != ctx->stashed_ino) || !ctx->stashed_inode)
2644 blocks[i] = ctx->stashed_inode->i_block[i];
2651 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2653 if ((ino != ctx->stashed_ino) || !ctx->stashed_inode)
2655 *inode = *ctx->stashed_inode;
2662 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2664 if ((ino == ctx->stashed_ino) && ctx->stashed_inode &&
2665 (inode != ctx->stashed_inode))
2666 *ctx->stashed_inode = *inode;
2672 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2674 if ((ino != ctx->stashed_ino) || !ctx->stashed_inode)
2677 if (!LINUX_S_ISDIR(ctx->stashed_inode->i_mode))
2685 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2689 if (ctx->block_found_map) {
2691 ctx->block_found_map, &new_block);
2716 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2718 if (ctx->block_found_map) {
2720 ext2fs_mark_block_bitmap(ctx->block_found_map,
2723 ext2fs_unmark_block_bitmap(ctx->block_found_map,
2728 void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool)
2730 ext2_filsys fs = ctx->fs;
2737 ctx->stashed_ino = 0;