Home | History | Annotate | Download | only in e2fsck

Lines Matching refs:fs

58 static int process_block(ext2_filsys fs, blk64_t	*blocknr,
61 static int process_bad_block(ext2_filsys fs, blk64_t *block_nr,
73 static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
77 /* static char *describe_illegal_block(ext2_filsys fs, blk64_t block); */
119 static void unwind_pass1(ext2_filsys fs EXT2FS_ATTR((unused)))
133 int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
168 int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
183 if (inode->i_size > fs->blocksize)
185 if (ext2fs_extent_open2(fs, ino, inode, &handle))
195 (extent.e_pblk < fs->super->s_first_data_block) ||
196 (extent.e_pblk >= ext2fs_blocks_count(fs->super)))
204 blocks = ext2fs_inode_data_blocks2(fs, inode);
206 if ((inode->i_size >= fs->blocksize) ||
207 (blocks != fs->blocksize >> 9) ||
208 (inode->i_block[0] < fs->super->s_first_data_block) ||
209 (inode->i_block[0] >= ext2fs_blocks_count(fs->super)))
216 if (io_channel_read_blk64(fs->io, inode->i_block[0], 1, buf))
219 len = strnlen(buf, fs->blocksize);
220 if (len == fs->blocksize)
273 struct ext2_super_block *sb = ctx->fs->super;
281 storage_size = EXT2_INODE_SIZE(ctx->fs->super) - EXT2_GOOD_OLD_INODE_SIZE -
352 struct ext2_super_block *sb = ctx->fs->super;
438 extent_fs = (ctx->fs->super->s_feature_incompat &
442 if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0,
455 if (blk < ctx->fs->super->s_first_data_block ||
456 blk >= ext2fs_blocks_count(ctx->fs->super) ||
475 retval = ext2fs_read_dir_block3(ctx->fs, blk, buf, 0);
481 retval = ext2fs_get_rec_len(ctx->fs, dirent, &rec_len);
489 (rec_len >= ctx->fs->blocksize - 12))
493 retval = ext2fs_get_rec_len(ctx->fs, dirent, &rec_len);
506 EXT2_INODE_SIZE(ctx->fs->super),
529 retval = ext2fs_get_num_dirs(ctx->fs, &num_dirs);
537 retval = ext2fs_create_icount_tdb(ctx->fs, tdb_dir, flags, ret);
546 ext2_filsys fs = ctx->fs;
557 struct ext2_super_block *sb = ctx->fs->super;
564 init_resource_track(&rtrack, ctx->fs->io);
570 if ((fs
597 pctx.errcode = e2fsck_allocate_inode_bitmap(fs, _("in-use inode map"),
607 pctx.errcode = e2fsck_allocate_inode_bitmap(fs,
617 pctx.errcode = e2fsck_allocate_inode_bitmap(fs,
626 pctx.errcode = e2fsck_allocate_subcluster_bitmap(fs,
637 e2fsck_set_bitmap_type(fs, EXT2FS_BMAP64_RBTREE,
639 pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
641 fs->default_bitmap_type = save_type;
649 inode_size = EXT2_INODE_SIZE(fs->super);
660 pctx.errcode = ext2fs_init_dblist(fs, 0);
676 if (fs->super->s_last_orphan) {
677 fs->super->s_last_orphan = 0;
678 ext2fs_mark_super_dirty(fs);
683 pctx.errcode = ext2fs_convert_subcluster_bitmap(fs,
691 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 3,
695 pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
711 if ((ctx->progress)(ctx, 1, 0, ctx->fs->group_desc_count))
713 if ((fs->super->s_wtime < fs->super->s_inodes_count) ||
714 (fs->super->s_mtime < fs->super->s_inodes_count))
717 if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) &&
718 fs->super->s_mmp_block > fs->super->s_first_data_block &&
719 fs->super->s_mmp_block < ext2fs_blocks_count(fs->super))
721 fs->super->s_mmp_block);
724 if (ino % (fs->super->s_inodes_per_group * 4) == 1) {
725 if (e2fsck_mmp_update(fs))
784 ext2fs_mark_super_dirty(fs);
859 pctx.errcode = ext2fs_block_iterate3(fs, ino, 0,
903 if (fs->super->s_journal_inum == EXT2_JOURNAL_INO) {
927 if ((fs->super->s_feature_ro_compat &
929 ((fs->super->s_usr_quota_inum == ino) ||
930 (fs->super->s_grp_quota_inum == ino))) {
951 } else if (ino < EXT2_FIRST_INODE(fs->super)) {
995 inode->i_dtime < ctx->fs->super->s_inodes_count) {
1037 switch (fs->super->s_creator_os) {
1049 if (!(fs->super->s_feature_incompat &
1053 if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
1054 !(fs->super->s_feature_ro_compat &
1082 !ext2fs_inode_has_valid_blocks2(fs, inode) &&
1096 e2fsck_pass1_check_device_inode(fs, inode)) {
1101 e2fsck_pass1_check_device_inode(fs, inode)) {
1106 e2fsck_pass1_check_symlink(fs, ino, inode,
1110 if (ext2fs_inode_data_blocks(fs, inode) == 0) {
1117 e2fsck_pass1_check_device_inode(fs, inode)) {
1122 e2fsck_pass1_check_device_inode(fs, inode)) {
1140 ext2fs_file_acl_block(fs, inode))) {
1189 save_bmap = fs->block_map;
1190 fs->block_map = ctx->block_found_map;
1192 pctx.errcode = ext2fs_create_resize_inode(fs);
1208 fs->block_map = save_bmap;
1220 unwind_pass1(fs);
1238 print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io);
1245 static errcode_t scan_callback(ext2_filsys fs,
1255 process_inodes((e2fsck_t) fs->priv_data, scan_struct->block_buf);
1259 ctx->fs->group_desc_count))
1344 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
1367 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
1387 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
1414 pctx.errcode = e2fsck_allocate_block_bitmap(ctx->fs,
1455 ext2_filsys fs = ctx->fs;
1467 pctx.errcode = ext2fs_read_ext_attr2(fs, blk, block_buf);
1478 pctx.errcode = ext2fs_write_ext_attr2(fs, blk,
1495 ext2_filsys fs = ctx->fs;
1505 blk = ext2fs_file_acl_block(fs, inode);
1516 if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) ||
1517 (blk < fs->super->s_first_data_block) ||
1518 (blk >= ext2fs_blocks_count(fs->super))) {
1525 pctx->errcode = e2fsck_allocate_block_bitmap(fs,
1577 pctx->errcode = ext2fs_read_ext_attr2(fs, blk, block_buf);
1581 pctx->blk = ext2fs_file_acl_block(fs, inode);
1595 region = region_create(0, fs->blocksize);
1607 end = block_buf + fs->blocksize;
1629 if (entry->e_value_offs + entry->e_value_size > fs->blocksize) {
1669 ext2fs_file_acl_block_set(fs, inode, 0);
1680 ext2_filsys fs = ctx->fs;
1686 (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) &&
1690 pctx->errcode = ext2fs_bmap2(fs, ino, inode, 0, 0, 0, 0, &blk);
1694 (blk < fs->super->s_first_data_block) ||
1695 (blk >= ext2fs_blocks_count(fs->super))) {
1702 retval = io_channel_read_blk64(fs->io, blk, 1, block_buf);
1787 extent.e_pblk < ctx->fs->super->s_first_data_block ||
1788 extent.e_pblk >= ext2fs_blocks_count(ctx->fs->super))
1800 ext2fs_blocks_count(ctx->fs->super))
1804 (1 << (21 - ctx->fs->super->s_log_block_size))))
1897 pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist,
1906 if (!ctx->fs->cluster_ratio_bits) {
1913 if (ctx->fs->cluster_ratio_bits &&
1915 (EXT2FS_B2C(ctx->fs, blk) ==
1916 EXT2FS_B2C(ctx->fs, pb->previous_block)) &&
1917 (blk & EXT2FS_CLUSTER_MASK(ctx->fs)) ==
1918 ((unsigned) blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
1926 pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist, pctx->ino, blk, blockcnt);
1960 ext2_filsys fs = ctx->fs;
1965 pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
1981 eof_lblk = ((EXT2_I_SIZE(inode) + fs->blocksize - 1) >>
1982 EXT2_BLOCK_SIZE_BITS(fs->super)) - 1;
2002 ext2_filsys fs = ctx->fs;
2023 pb.max_blocks = 1 << (31 - fs->super->s_log_block_size);
2030 extent_fs = (ctx->fs->super->s_feature_incompat &
2034 if (fs->super->s_feature_incompat &
2045 if (ext2fs_file_acl_block(fs, inode) &&
2052 if (ext2fs_inode_has_valid_blocks2(fs, inode)) {
2056 pctx->errcode = ext2fs_block_iterate3(fs, ino,
2073 if (pb.fragmented && pb.num_blocks < fs->super->s_blocks_per_group) {
2105 if (ino == EXT2_ROOT_INO || ino >= EXT2_FIRST_INODE(ctx->fs->super)) {
2107 pb.num_blocks * fs->blocksize);
2111 if (!(fs->super->s_feature_ro_compat &
2114 pb.num_blocks *= (fs->blocksize / 512);
2115 pb.num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
2118 ino, inode->i_size, pb.last_block, ext2fs_inode_i_blocks(fs, inode),
2122 int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
2123 if (inode->i_size & (fs->blocksize - 1))
2129 fs->super->s_prealloc_dir_blocks)
2138 (size < (__u64)pb.last_init_lblock * fs->blocksize) &&
2141 fs->blocksize))
2144 size > ext2_max_sizes[fs->super->s_log_block_size])
2149 ((1ULL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))
2155 pctx->num = (pb.last_block+1) * fs->blocksize;
2168 if ((pb.num_blocks != ext2fs_inode_i_blocks(fs, inode)) ||
2169 ((fs->super->s_feature_ro_compat &
2184 ((inode->i_size / fs->blocksize) >= 3))
2197 static char *describe_illegal_block(ext2_filsys fs, blk64_t block)
2203 super = fs->super->s_first_data_block;
2208 } else if (block >= ext2fs_blocks_count(fs->super)) {
2209 sprintf(problem, "> BLOCKS (%u)", ext2fs_blocks_count(fs->super));
2212 for (i = 0; i < fs->group_desc_count; i++) {
2218 block <= (super + fs->desc_blocks)) {
2223 if (block == ext2fs_block_bitmap_loc(fs, i)) {
2227 if (block == ext2fs_inode_bitmap_loc(fs, i)) {
2231 if (block >= ext2fs_inode_table_loc(fs, i) &&
2232 (block < ext2fs_inode_table_loc(fs, i)
2233 + fs->inode_blocks_per_group)) {
2238 super += fs->super->s_blocks_per_group;
2247 static int process_block(ext2_filsys fs,
2321 if (p->is_dir && blockcnt > (1 << (21 - fs->super->s_log_block_size)))
2328 if (blk < fs->super->s_first_data_block ||
2329 blk >= ext2fs_blocks_count(fs->super))
2366 } else if (!(ctx->fs->cluster_ratio_bits &&
2368 (EXT2FS_B2C(ctx->fs, blk) ==
2369 EXT2FS_B2C(ctx->fs, p->previous_block)) &&
2370 (blk & EXT2FS_CLUSTER_MASK(ctx->fs)) ==
2371 ((unsigned) blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
2381 pctx->errcode = ext2fs_add_dir_block2(fs->dblist,
2390 pctx->errcode = ext2fs_add_dir_block2(fs->dblist, p->ino,
2405 static int process_bad_block(ext2_filsys fs,
2435 if ((blk < fs->super->s_first_data_block) ||
2436 (blk >= ext2fs_blocks_count(fs->super))) {
2482 first_block = fs->super->s_first_data_block;
2484 for (i = 0; i < fs->group_desc_count; i++ ) {
2487 if (!ext2fs_bg_has_super(fs, i))
2503 (blk <= first_block + fs->desc_blocks)) {
2517 if (blk == ext2fs_block_bitmap_loc(fs, i)) {
2524 if (blk == ext2fs_inode_bitmap_loc(fs, i)) {
2531 if ((blk >= ext2fs_inode_table_loc(fs, i)) &&
2532 (blk < (ext2fs_inode_table_loc(fs, i) +
2533 fs->inode_blocks_per_group))) {
2541 first_block += fs->super->s_blocks_per_group;
2572 ext2_filsys fs = ctx->fs;
2593 is_flexbg = EXT2_HAS_INCOMPAT_FEATURE(fs->super,
2596 flexbg_size = 1 << fs->super->s_log_groups_per_flex;
2598 first_block = ext2fs_group_first_block2(fs,
2601 if (last_grp > fs->group_desc_count)
2602 last_grp = fs->group_desc_count;
2603 last_block = ext2fs_group_last_block2(fs, last_grp);
2605 last_block = ext2fs_group_last_block2(fs, group);
2606 pctx.errcode = ext2fs_get_free_blocks2(fs, first_block, last_block,
2610 pctx.errcode = ext2fs_get_free_blocks2(fs,
2611 fs->super->s_first_data_block,
2612 ext2fs_blocks_count(fs->super),
2617 ext2fs_unmark_valid(fs);
2621 pctx.errcode = ext2fs_get_mem(fs->blocksize, &buf);
2624 ext2fs_unmark_valid(fs);
2628 ext2fs_mark_super_dirty(fs);
2629 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
2638 pctx.errcode = io_channel_read_blk64(fs->io,
2643 memset(buf, 0, fs->blocksize);
2646 pctx.errcode = io_channel_write_blk64(fs->io, pctx.blk,
2663 ext2_filsys fs = ctx->fs;
2668 for (i = 0; i < fs->group_desc_count; i++) {
2669 first_block = ext2fs_group_first_block2(fs, i);
2672 new_blk = ext2fs_block_bitmap_loc(fs, i);
2675 ext2fs_block_bitmap_loc_set(fs, i, new_blk);
2678 new_blk = ext2fs_inode_bitmap_loc(fs, i);
2681 ext2fs_inode_bitmap_loc_set(fs, i, new_blk);
2684 new_blk = ext2fs_inode_table_loc(fs, i);
2686 fs->inode_blocks_per_group,
2688 ext2fs_inode_table_loc_set(fs, i, new_blk);
2701 ext2_filsys fs = ctx->fs;
2709 for (i = 0; i < fs->group_desc_count; i++) {
2712 ext2fs_reserve_super_and_bgd(fs, i, ctx->block_found_map);
2717 if (ext2fs_inode_table_loc(fs, i)) {
2718 for (j = 0, b = ext2fs_inode_table_loc(fs, i);
2719 j < fs->inode_blocks_per_group;
2740 if (ext2fs_block_bitmap_loc(fs, i)) {
2742 ext2fs_block_bitmap_loc(fs, i))) {
2743 pctx.blk = ext2fs_block_bitmap_loc(fs, i);
2750 ext2fs_block_bitmap_loc(fs, i));
2757 if (ext2fs_inode_bitmap_loc(fs, i)) {
2759 ext2fs_inode_bitmap_loc(fs, i))) {
2760 pctx.blk = ext2fs_inode_bitmap_loc(fs, i);
2767 ext2fs_inode_bitmap_loc(fs, i));
2779 static errcode_t pass1_get_blocks(ext2_filsys fs, ext2_ino_t ino,
2782 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2793 static errcode_t pass1_read_inode(ext2_filsys fs, ext2_ino_t ino,
2796 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2804 static errcode_t pass1_write_inode(ext2_filsys fs, ext2_ino_t ino,
2807 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2815 static errcode_t pass1_check_directory(ext2_filsys fs, ext2_ino_t ino)
2817 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2827 static errcode_t e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal,
2830 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2835 retval = ext2fs_new_block2(fs, goal, ctx->block_found_map,
2839 if (fs->block_map) {
2840 ext2fs_mark_block_bitmap2(fs
2841 ext2fs_mark_bb_dirty(fs);
2844 if (!fs->block_map) {
2845 retval = ext2fs_read_block_bitmap(fs);
2850 retval = ext2fs_new_block2(fs, goal, 0, &new_block);
2859 static void e2fsck_block_alloc_stats(ext2_filsys fs, blk64_t blk, int inuse)
2861 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2873 ext2_filsys fs = ctx->fs;
2876 fs->get_blocks = pass1_get_blocks;
2877 fs->check_directory = pass1_check_directory;
2878 fs->read_inode = pass1_read_inode;
2879 fs->write_inode = pass1_write_inode;
2881 ext2fs_set_alloc_block_callback(fs, e2fsck_get_alloc_block,
2883 ext2fs_set_block_alloc_stats_callback(fs,
2887 fs->get_blocks = 0;
2888 fs->check_directory = 0;
2889 fs->read_inode = 0;
2890 fs->write_inode = 0;