Home | History | Annotate | Download | only in e2fsck

Lines Matching defs: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,
74 static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
78 /* static char *describe_illegal_block(ext2_filsys fs, blk64_t block); */
120 static void unwind_pass1(ext2_filsys fs EXT2FS_ATTR((unused)))
134 int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
169 int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
184 if (inode->i_size > fs->blocksize)
186 if (ext2fs_extent_open2(fs, ino, inode, &handle))
196 (extent.e_pblk < fs->super->s_first_data_block) ||
197 (extent.e_pblk >= ext2fs_blocks_count(fs->super)))
205 blocks = ext2fs_inode_data_blocks2(fs, inode);
207 if ((inode->i_size >= fs->blocksize) ||
208 (blocks != fs->blocksize >> 9) ||
209 (inode->i_block[0] < fs->super->s_first_data_block) ||
210 (inode->i_block[0] >= ext2fs_blocks_count(fs->super)))
217 if (io_channel_read_blk64(fs->io, inode->i_block[0], 1, buf))
223 len = strnlen(buf, fs->blocksize);
225 if (len == fs->blocksize)
279 struct ext2_super_block *sb = ctx->fs->super;
287 storage_size = EXT2_INODE_SIZE(ctx->fs->super) - EXT2_GOOD_OLD_INODE_SIZE -
358 struct ext2_super_block *sb = ctx->fs->super;
444 extent_fs = (ctx->fs->super->s_feature_incompat &
448 if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0,
461 if (blk < ctx->fs->super->s_first_data_block ||
462 blk >= ext2fs_blocks_count(ctx->fs->super) ||
481 retval = ext2fs_read_dir_block3(ctx->fs, blk, buf, 0);
487 retval = ext2fs_get_rec_len(ctx->fs, dirent, &rec_len);
495 (rec_len >= ctx->fs->blocksize - 12))
499 retval = ext2fs_get_rec_len(ctx->fs, dirent, &rec_len);
512 EXT2_INODE_SIZE(ctx->fs->super),
535 retval = ext2fs_get_num_dirs(ctx->fs, &num_dirs);
543 retval = ext2fs_create_icount_tdb(ctx->fs, tdb_dir, flags, ret);
552 ext2_filsys fs = ctx->fs;
563 struct ext2_super_block *sb = ctx->fs->super;
570 fs->io);
576 if ((fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) &&
603 pctx.errcode = e2fsck_allocate_inode_bitmap(fs, _("in-use inode map"),
613 pctx.errcode = e2fsck_allocate_inode_bitmap(fs,
623 pctx.errcode = e2fsck_allocate_inode_bitmap(fs,
632 pctx.errcode = e2fsck_allocate_subcluster_bitmap(fs,
643 e2fsck_set_bitmap_type(fs, EXT2FS_BMAP64_RBTREE,
645 pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
647 fs->default_bitmap_type = save_type;
655 inode_size = EXT2_INODE_SIZE(fs->super);
666 pctx.errcode = ext2fs_init_dblist(fs, 0);
682 if (fs->super->s_last_orphan) {
683 fs->super->s_last_orphan = 0;
684 ext2fs_mark_super_dirty(fs);
689 pctx.errcode = ext2fs_convert_subcluster_bitmap(fs,
697 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 3,
701 pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
717 if ((ctx->progress)(ctx, 1, 0, ctx->fs->group_desc_count))
719 if ((fs->super->s_wtime < fs->super->s_inodes_count) ||
720 (fs->super->s_mtime < fs->super->s_inodes_count))
723 if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) &&
724 fs->super->s_mmp_block > fs->super->s_first_data_block &&
725 fs->super->s_mmp_block < ext2fs_blocks_count(fs->super))
727 fs->super->s_mmp_block);
730 if (ino % (fs->super->s_inodes_per_group * 4) == 1) {
731 if (e2fsck_mmp_update(fs))
790 ext2fs_mark_super_dirty(fs);
865 pctx.errcode = ext2fs_block_iterate3(fs, ino, 0,
909 if (fs->super->s_journal_inum == EXT2_JOURNAL_INO) {
933 if ((fs->super->s_feature_ro_compat &
935 ((fs->super->s_usr_quota_inum == ino) ||
936 (fs->super->s_grp_quota_inum == ino))) {
957 } else if (ino < EXT2_FIRST_INODE(fs->super)) {
1001 inode->i_dtime < ctx->fs->super->s_inodes_count) {
1043 switch (fs->super->s_creator_os) {
1055 if (!(fs->super->s_feature_incompat &
1059 if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
1060 !(fs->super->s_feature_ro_compat &
1088 !ext2fs_inode_has_valid_blocks2(fs, inode) &&
1104 e2fsck_pass1_check_device_inode(fs, inode)) {
1109 e2fsck_pass1_check_device_inode(fs, inode)) {
1114 e2fsck_pass1_check_symlink(fs, ino, inode,
1118 if (ext2fs_inode_data_blocks(fs, inode) == 0) {
1125 e2fsck_pass1_check_device_inode(fs, inode)) {
1130 e2fsck_pass1_check_device_inode(fs, inode)) {
1148 ext2fs_file_acl_block(fs, inode))) {
1197 save_bmap = fs->block_map;
1198 fs->block_map = ctx->block_found_map;
1200 pctx.errcode = ext2fs_create_resize_inode(fs);
1216 fs->block_map = save_bmap;
1228 unwind_pass1(fs);
1246 print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io);
1253 static errcode_t scan_callback(ext2_filsys fs,
1263 process_inodes((e2fsck_t) fs->priv_data, scan_struct->block_buf);
1267 ctx->fs->group_desc_count))
1352 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
1392 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
1412 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs,
1439 pctx.errcode = e2fsck_allocate_block_bitmap(ctx->fs,
1480 ext2_filsys fs = ctx->fs;
1492 pctx.errcode = ext2fs_read_ext_attr2(fs, blk, block_buf);
1503 pctx.errcode = ext2fs_write_ext_attr2(fs, blk,
1520 ext2_filsys fs = ctx->fs;
1530 blk = ext2fs_file_acl_block(fs, inode);
1541 if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) ||
1542 (blk < fs->super->s_first_data_block) ||
1543 (blk >= ext2fs_blocks_count(fs->super))) {
1550 pctx->errcode = e2fsck_allocate_block_bitmap(fs,
1602 pctx->errcode = ext2fs_read_ext_attr2(fs, blk, block_buf);
1606 pctx->blk = ext2fs_file_acl_block(fs, inode);
1620 region = region_create(0, fs->blocksize);
1632 end = block_buf + fs->blocksize;
1654 if (entry->e_value_offs + entry->e_value_size > fs->blocksize) {
1694 ext2fs_file_acl_block_set(fs, inode, 0);
1705 ext2_filsys fs = ctx->fs;
1711 (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) &&
1715 pctx->errcode = ext2fs_bmap2(fs, ino, inode, 0, 0, 0, 0, &blk);
1719 (blk < fs->super->s_first_data_block) ||
1720 (blk >= ext2fs_blocks_count(fs->super))) {
1727 retval = io_channel_read_blk64(fs->io, blk, 1, block_buf);
1812 extent.e_pblk < ctx->fs->super->s_first_data_block ||
1813 extent.e_pblk >= ext2fs_blocks_count(ctx->fs->super))
1825 ext2fs_blocks_count(ctx->fs->super))
1829 (1 << (21 - ctx->fs->super->s_log_block_size))))
1922 pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist,
1931 if (!ctx->fs->cluster_ratio_bits) {
1938 if (ctx->fs->cluster_ratio_bits &&
1940 (EXT2FS_B2C(ctx->fs, blk) ==
1941 EXT2FS_B2C(ctx->fs, pb->previous_block)) &&
1942 (blk & EXT2FS_CLUSTER_MASK(ctx->fs)) ==
1943 ((unsigned) blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
1951 pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist, pctx->ino, blk, blockcnt);
1985 ext2_filsys fs = ctx->fs;
1990 pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
2006 eof_lblk = ((EXT2_I_SIZE(inode) + fs->blocksize - 1) >>
2007 EXT2_BLOCK_SIZE_BITS(fs->super)) - 1;
2027 ext2_filsys fs = ctx->fs;
2048 pb.max_blocks = 1 << (31 - fs->super->s_log_block_size);
2055 extent_fs = (ctx->fs->super->s_feature_incompat &
2059 if (fs->super->s_feature_incompat &
2070 if (ext2fs_file_acl_block(fs, inode) &&
2077 if (ext2fs_inode_has_valid_blocks2(fs, inode)) {
2081 pctx->errcode = ext2fs_block_iterate3(fs, ino,
2098 if (pb.fragmented && pb.num_blocks < fs->super->s_blocks_per_group) {
2130 if (ino == EXT2_ROOT_INO || ino >= EXT2_FIRST_INODE(ctx->fs->super)) {
2132 pb.num_blocks * fs->blocksize);
2136 if (!(fs->super->s_feature_ro_compat &
2139 pb.num_blocks *= (fs->blocksize / 512);
2140 pb.num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
2143 ino, inode->i_size, pb.last_block, ext2fs_inode_i_blocks(fs, inode),
2147 int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
2148 if (inode->i_size & (fs->blocksize - 1))
2154 fs->super->s_prealloc_dir_blocks)
2163 (size < (__u64)pb.last_init_lblock * fs->blocksize) &&
2166 fs->blocksize))
2169 size > ext2_max_sizes[fs->super->s_log_block_size])
2174 ((1ULL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))
2180 pctx->num = (pb.last_block+1) * fs->blocksize;
2193 if ((pb.num_blocks != ext2fs_inode_i_blocks(fs, inode)) ||
2194 ((fs->super->s_feature_ro_compat &
2209 ((inode->i_size / fs->blocksize) >= 3))
2222 static char *describe_illegal_block(ext2_filsys fs, blk64_t block)
2228 super = fs->super->s_first_data_block;
2233 } else if (block >= ext2fs_blocks_count(fs->super)) {
2234 sprintf(problem, "> BLOCKS (%u)", ext2fs_blocks_count(fs->super));
2237 for (i = 0; i < fs->group_desc_count; i++) {
2243 fs->desc_blocks)) {
2248 if (block == ext2fs_block_bitmap_loc(fs, i)) {
2252 if (block == ext2fs_inode_bitmap_loc(fs, i)) {
2256 if (block >= ext2fs_inode_table_loc(fs, i) &&
2257 (block < ext2fs_inode_table_loc(fs, i)
2258 + fs->inode_blocks_per_group)) {
2263 super += fs->super->s_blocks_per_group;
2272 static int process_block(ext2_filsys fs,
2346 if (p->is_dir && blockcnt > (1 << (21 - fs->super->s_log_block_size)))
2353 if (blk < fs->super->s_first_data_block ||
2354 blk >= ext2fs_blocks_count(fs->super))
2391 } else if (!(ctx->fs->cluster_ratio_bits &&
2393 (EXT2FS_B2C(ctx->fs, blk) ==
2394 EXT2FS_B2C(ctx->fs, p->previous_block)) &&
2395 (blk & EXT2FS_CLUSTER_MASK(ctx->fs)) ==
2396 ((unsigned) blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
2406 pctx->errcode = ext2fs_add_dir_block2(fs->dblist,
2415 pctx->errcode = ext2fs_add_dir_block2(fs->dblist, p->ino,
2430 static int process_bad_block(ext2_filsys fs,
2460 if ((blk < fs->super->s_first_data_block) ||
2461 (blk >= ext2fs_blocks_count(fs->super))) {
2507 first_block = fs->super->s_first_data_block;
2509 for (i = 0; i < fs->group_desc_count; i++ ) {
2512 if (!ext2fs_bg_has_super(fs, i))
2528 (blk <= first_block + fs->desc_blocks)) {
2542 if (blk == ext2fs_block_bitmap_loc(fs, i)) {
2549 if (blk == ext2fs_inode_bitmap_loc(fs, i)) {
2556 if ((blk >= ext2fs_inode_table_loc(fs, i)) &&
2557 (blk < (ext2fs_inode_table_loc(fs, i) +
2558 fs->inode_blocks_per_group))) {
2566 first_block += fs->super->s_blocks_per_group;
2597 ext2_filsys fs = ctx->fs;
2618 is_flexbg = EXT2_HAS_INCOMPAT_FEATURE(fs->super,
2621 flexbg_size = 1 << fs->super->s_log_groups_per_flex;
2623 first_block = ext2fs_group_first_block2(fs,
2626 if (last_grp > fs->group_desc_count)
2627 last_grp = fs->group_desc_count;
2628 last_block = ext2fs_group_last_block2(fs, last_grp);
2630 last_block = ext2fs_group_last_block2(fs, group);
2631 pctx.errcode = ext2fs_get_free_blocks2(fs, first_block, last_block,
2635 pctx.errcode = ext2fs_get_free_blocks2(fs,
2636 fs->super->s_first_data_block,
2637 ext2fs_blocks_count(fs->super),
2642 ext2fs_unmark_valid(fs);
2646 pctx.errcode = ext2fs_get_mem(fs->blocksize, &buf);
2649 ext2fs_unmark_valid(fs);
2653 ext2fs_mark_super_dirty(fs);
2654 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
2663 pctx.errcode = io_channel_read_blk64(fs->io,
2668 memset(buf, 0, fs->blocksize);
2671 pctx.errcode = io_channel_write_blk64(fs->io, pctx.blk,
2688 ext2_filsys fs = ctx->fs;
2693 for (i = 0; i < fs->group_desc_count; i++) {
2694 first_block = ext2fs_group_first_block2(fs, i);
2697 new_blk = ext2fs_block_bitmap_loc(fs, i);
2700 ext2fs_block_bitmap_loc_set(fs, i, new_blk);
2703 new_blk = ext2fs_inode_bitmap_loc(fs, i);
2706 ext2fs_inode_bitmap_loc_set(fs, i, new_blk);
2709 new_blk = ext2fs_inode_table_loc(fs, i);
2711 fs->inode_blocks_per_group,
2713 ext2fs_inode_table_loc_set(fs, i, new_blk);
2726 ext2_filsys fs = ctx->fs;
2734 for (i = 0; i < fs->group_desc_count; i++) {
2737 ext2fs_reserve_super_and_bgd(fs, i, ctx->block_found_map);
2742 if (ext2fs_inode_table_loc(fs, i)) {
2743 for (j = 0, b = ext2fs_inode_table_loc(fs, i);
2744 j < fs->inode_blocks_per_group;
2765 if (ext2fs_block_bitmap_loc(fs, i)) {
2767 ext2fs_block_bitmap_loc(fs, i))) {
2768 pctx.blk = ext2fs_block_bitmap_loc(fs, i);
2775 ext2fs_block_bitmap_loc(fs, i));
2782 if (ext2fs_inode_bitmap_loc(fs, i)) {
2784 ext2fs_inode_bitmap_loc(fs, i))) {
2785 pctx.blk = ext2fs_inode_bitmap_loc(fs, i);
2792 ext2fs_inode_bitmap_loc(fs, i));
2804 static errcode_t pass1_get_blocks(ext2_filsys fs, ext2_ino_t ino,
2807 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2818 static errcode_t pass1_read_inode(ext2_filsys fs, ext2_ino_t ino,
2821 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2829 static errcode_t pass1_write_inode(ext2_filsys fs, ext2_ino_t ino,
2832 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2840 static errcode_t pass1_check_directory(ext2_filsys fs, ext2_ino_t ino)
2842 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2852 static errcode_t e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal,
2855 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2860 retval = ext2fs_new_block2(fs, goal, ctx->block_found_map,
2864 if (fs->block_map) {
2865 ext2fs_mark_block_bitmap2(fs->block_map, new_block);
2866 ext2fs_mark_bb_dirty(fs);
2869 if (!fs->block_map) {
2870 retval = ext2fs_read_block_bitmap(fs);
2875 retval = ext2fs_new_block2(fs, goal, 0, &new_block);
2884 static void e2fsck_block_alloc_stats(ext2_filsys fs, blk64_t blk, int inuse)
2886 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2898 ext2_filsys fs = ctx->fs;
2901 fs->get_blocks = pass1_get_blocks;
2902 fs->check_directory = pass1_check_directory;
2903 fs->read_inode = pass1_read_inode;
2904 fs->write_inode = pass1_write_inode;
2906 ext2fs_set_alloc_block_callback(fs, e2fsck_get_alloc_block,
2908 ext2fs_set_block_alloc_stats_callback(fs,
2912 fs->get_blocks = 0;
2913 fs->check_directory = 0;
2914 fs->read_inode = 0;
2915 fs->write_inode = 0;