Lines Matching defs:fs
58 static int process_block(ext2_filsys fs, blk_t *blocknr,
61 static int process_bad_block(ext2_filsys fs, blk_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, blk_t block); */
118 static void unwind_pass1(ext2_filsys fs EXT2FS_ATTR((unused)))
132 int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
167 int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
182 if (inode->i_size > fs->blocksize)
184 if (ext2fs_extent_open2(fs, ino, inode, &handle))
194 (extent.e_pblk < fs->super->s_first_data_block) ||
195 (extent.e_pblk >= fs->super->s_blocks_count))
203 blocks = ext2fs_inode_data_blocks(fs, inode);
205 if ((inode->i_size >= fs->blocksize) ||
206 (blocks != fs->blocksize >> 9) ||
207 (inode->i_block[0] < fs->super->s_first_data_block) ||
208 (inode->i_block[0] >= fs->super->s_blocks_count))
215 if (io_channel_read_blk(fs->io, inode->i_block[0], 1, buf))
218 len = strnlen(buf, fs->blocksize);
219 if (len == fs->blocksize)
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);
352 struct ext2_super_block *sb = ctx->fs->super;
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 ||
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);
507 EXT2_INODE_SIZE(ctx->fs->super),
530 retval = ext2fs_get_num_dirs(ctx->fs, &num_dirs);
538 retval = ext2fs_create_icount_tdb(ctx->fs, tdb_dir, flags, ret);
547 ext2_filsys fs = ctx->fs;
558 struct ext2_super_block *sb = ctx->fs->super;
564 init_resource_track(&rtrack, ctx->fs->io);
570 fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) &&
597 pctx.errcode = ext2fs_allocate_inode_bitmap(fs, _("in-use inode map"),
605 pctx.errcode = ext2fs_allocate_inode_bitmap(fs,
613 pctx.errcode = ext2fs_allocate_inode_bitmap(fs,
621 pctx.errcode = ext2fs_allocate_block_bitmap(fs, _("in-use block map"),
631 pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
638 inode_size = EXT2_INODE_SIZE(fs->super);
649 pctx.errcode = ext2fs_init_dblist(fs, 0);
665 if (fs->super->s_last_orphan) {
666 fs->super->s_last_orphan = 0;
667 ext2fs_mark_super_dirty(fs);
672 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 3,
676 pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
692 if ((ctx->progress)(ctx, 1, 0, ctx->fs->group_desc_count))
694 if ((fs->super->s_wtime < fs->super->s_inodes_count) ||
695 (fs->super->s_mtime < fs->super->s_inodes_count))
755 ext2fs_mark_super_dirty(fs);
822 pctx.errcode = ext2fs_block_iterate2(fs, ino, 0,
866 if (fs->super->s_journal_inum == EXT2_JOURNAL_INO) {
887 } else if (ino < EXT2_FIRST_INODE(fs->super)) {
930 inode->i_dtime < ctx->fs->super->s_inodes_count) {
972 switch (fs->super->s_creator_os) {
984 if (!(fs->super->s_feature_incompat &
988 if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
989 !(fs->super->s_feature_ro_compat &
1031 e2fsck_pass1_check_device_inode(fs, inode)) {
1036 e2fsck_pass1_check_device_inode(fs, inode)) {
1041 e2fsck_pass1_check_symlink(fs, ino, inode,
1045 if (ext2fs_inode_data_blocks(fs, inode) == 0) {
1052 e2fsck_pass1_check_device_inode(fs, inode)) {
1057 e2fsck_pass1_check_device_inode(fs, inode)) {
1124 save_bmap = fs->block_map;
1125 fs->block_map = ctx->block_found_map;
1127 pctx.errcode = ext2fs_create_resize_inode(fs);
1143 fs->block_map = save_bmap;
1155 unwind_pass1(fs);
1173 print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io);
1180 static errcode_t scan_callback(ext2_filsys fs,
1190 process_inodes((e2fsck_t) fs->priv_data, scan_struct->block_buf);
1194 ctx->fs->group_desc_count))
1273 pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
1295 pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
1315 pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
1342 pctx.errcode = ext2fs_allocate_block_bitmap(ctx->fs,
1372 ext2_filsys fs = ctx->fs;
1384 pctx.errcode = ext2fs_read_ext_attr(fs, blk, block_buf);
1395 pctx.errcode = ext2fs_write_ext_attr(fs, blk,
1412 ext2_filsys fs = ctx->fs;
1433 if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) ||
1434 (blk < fs->super->s_first_data_block) ||
1435 (blk >= fs->super->s_blocks_count)) {
1442 pctx->errcode = ext2fs_allocate_block_bitmap(fs,
1493 pctx->errcode = ext2fs_read_ext_attr(fs, blk, block_buf);
1511 region = region_create(0, fs->blocksize);
1523 end = block_buf + fs->blocksize;
1545 if (entry->e_value_offs + entry->e_value_size > fs->blocksize) {
1596 ext2_filsys fs = ctx->fs;
1602 (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) &&
1606 pctx->errcode = ext2fs_bmap(fs, ino, inode, 0, 0, 0, &blk);
1610 (blk < fs->super->s_first_data_block) ||
1611 (blk >= fs->super->s_blocks_count)) {
1618 retval = io_channel_read_blk(fs->io, blk, 1, block_buf);
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)
1780 pctx->errcode = ext2fs_add_dir_block(ctx->fs->dblist,
1795 pctx->errcode = ext2fs_add_dir_block(ctx->fs->dblist, pctx->ino, blk, blockcnt);
1827 ext2_filsys fs = ctx->fs;
1831 pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
1859 static blk64_t ext2fs_inode_i_blocks(ext2_filsys fs,
1863 (fs->super->s_feature_ro_compat &
1875 ext2_filsys fs = ctx->fs;
1895 pb.max_blocks = 1 << (31 - fs->super->s_log_block_size);
1902 extent_fs = (ctx->fs->super->s_feature_incompat &
1906 if (fs->super->s_feature_incompat &
1927 pctx->errcode = ext2fs_block_iterate2(fs, ino,
1938 if (pb.fragmented && pb.num_blocks < fs->super->s_blocks_per_group) {
1970 if (!(fs->super->s_feature_ro_compat &
1973 pb.num_blocks *= (fs->blocksize / 512);
1980 int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
1981 if (inode->i_size & (fs->blocksize - 1))
1987 fs->super->s_prealloc_dir_blocks)
1996 (size < (__u64)pb.last_block * fs->blocksize) &&
1998 size < (__u64)(pb.last_block & ~(blkpg-1)) *fs->blocksize) &&
2002 size > ext2_max_sizes[fs->super->s_log_block_size])
2007 ((1ULL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))
2016 (size >= (((__u64)pb.last_block + 1) * fs->blocksize))) {
2026 pctx->num = (pb.last_block+1) * fs->blocksize;
2039 if ((pb.num_blocks != ext2fs_inode_i_blocks(fs, inode)) ||
2040 ((fs->super->s_feature_ro_compat &
2055 ((inode->i_size / fs->blocksize) >= 3))
2068 static char *describe_illegal_block(ext2_filsys fs, blk_t block)
2074 super = fs->super->s_first_data_block;
2079 } else if (block >= fs->super->s_blocks_count) {
2080 sprintf(problem, "> BLOCKS (%u)", fs->super->s_blocks_count);
2083 for (i = 0; i < fs->group_desc_count; i++) {
2089 block <= (super + fs->desc_blocks)) {
2094 if (block == fs->group_desc[i].bg_block_bitmap) {
2098 if (block == fs->group_desc[i].bg_inode_bitmap) {
2102 if (block >= fs->group_desc[i].bg_inode_table &&
2103 (block < fs->group_desc[i].bg_inode_table
2104 + fs->inode_blocks_per_group)) {
2109 super += fs->super->s_blocks_per_group;
2118 static int process_block(ext2_filsys fs,
2193 if (p->is_dir && blockcnt > (1 << (21 - fs->super->s_log_block_size)))
2200 if (blk < fs->super->s_first_data_block ||
2201 blk >= fs->super->s_blocks_count)
2245 pctx->errcode = ext2fs_add_dir_block(fs->dblist,
2254 pctx->errcode = ext2fs_add_dir_block(fs->dblist, p->ino,
2269 static int process_bad_block(ext2_filsys fs,
2299 if ((blk < fs->super->s_first_data_block) ||
2300 (blk >= fs->super->s_blocks_count)) {
2346 first_block = fs->super->s_first_data_block;
2348 for (i = 0; i < fs->group_desc_count; i++ ) {
2351 if (!ext2fs_bg_has_super(fs, i))
2367 (blk <= first_block + fs->desc_blocks)) {
2381 if (blk == fs->group_desc[i].bg_block_bitmap) {
2388 if (blk == fs->group_desc[i].bg_inode_bitmap) {
2395 if ((blk >= fs->group_desc[i].bg_inode_table) &&
2396 (blk < (fs->group_desc[i].bg_inode_table +
2397 fs->inode_blocks_per_group))) {
2405 first_block += fs->super->s_blocks_per_group;
2436 ext2_filsys fs = ctx->fs;
2455 is_flexbg = EXT2_HAS_INCOMPAT_FEATURE(fs->super,
2458 flexbg_size = 1 << fs->super->s_log_groups_per_flex;
2460 first_block = ext2fs_group_first_block(fs,
2463 if (last_grp > fs->group_desc_count)
2464 last_grp = fs->group_desc_count;
2465 last_block = ext2fs_group_last_block(fs, last_grp);
2467 last_block = ext2fs_group_last_block(fs, group);
2468 pctx.errcode = ext2fs_get_free_blocks(fs, first_block, last_block,
2472 pctx.errcode = ext2fs_get_free_blocks(fs,
2473 fs->super->s_first_data_block,
2474 fs->super->s_blocks_count,
2479 ext2fs_unmark_valid(fs);
2483 pctx.errcode = ext2fs_get_mem(fs->blocksize, &buf);
2486 ext2fs_unmark_valid(fs);
2490 ext2fs_mark_super_dirty(fs);
2491 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
2500 pctx.errcode = io_channel_read_blk(fs->io,
2505 memset(buf, 0, fs->blocksize);
2508 pctx.errcode = io_channel_write_blk(fs->io, pctx.blk,
2525 ext2_filsys fs = ctx->fs;
2529 for (i = 0; i < fs->group_desc_count; i++) {
2530 first_block = ext2fs_group_first_block(fs, i);
2534 1, &fs->group_desc[i].bg_block_bitmap);
2538 1, &fs->group_desc[i].bg_inode_bitmap);
2542 fs->inode_blocks_per_group,
2543 &fs->group_desc[i].bg_inode_table);
2556 ext2_filsys fs = ctx->fs;
2564 for (i = 0; i < fs->group_desc_count; i++) {
2567 ext2fs_reserve_super_and_bgd(fs, i, ctx->block_found_map);
2572 if (fs->group_desc[i].bg_inode_table) {
2573 for (j = 0, b = fs->group_desc[i].bg_inode_table;
2574 j < fs->inode_blocks_per_group;
2595 if (fs->group_desc[i].bg_block_bitmap) {
2597 fs->group_desc[i].bg_block_bitmap)) {
2598 pctx.blk = fs->group_desc[i].bg_block_bitmap;
2605 fs->group_desc[i].bg_block_bitmap);
2612 if (fs->group_desc[i].bg_inode_bitmap) {
2614 fs->group_desc[i].bg_inode_bitmap)) {
2615 pctx.blk = fs->group_desc[i].bg_inode_bitmap;
2622 fs->group_desc[i].bg_inode_bitmap);
2634 static errcode_t pass1_get_blocks(ext2_filsys fs, ext2_ino_t ino,
2637 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2648 static errcode_t pass1_read_inode(ext2_filsys fs, ext2_ino_t ino,
2651 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2659 static errcode_t pass1_write_inode(ext2_filsys fs, ext2_ino_t ino,
2662 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2670 static errcode_t pass1_check_directory(ext2_filsys fs, ext2_ino_t ino)
2672 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2682 static errcode_t e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal,
2685 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2690 retval = ext2fs_new_block(fs, (blk_t) goal,
2694 if (fs->block_map) {
2695 ext2fs_mark_block_bitmap(fs->block_map, new_block);
2696 ext2fs_mark_bb_dirty(fs);
2699 if (!fs->block_map) {
2700 retval = ext2fs_read_block_bitmap(fs);
2705 retval = ext2fs_new_block(fs, (blk_t) goal, 0, &new_block);
2714 static void e2fsck_block_alloc_stats(ext2_filsys fs, blk64_t blk, int inuse)
2716 e2fsck_t ctx = (e2fsck_t) fs->priv_data;
2730 ext2_filsys fs = ctx->fs;
2733 fs->get_blocks = pass1_get_blocks;
2734 fs->check_directory = pass1_check_directory;
2735 fs->read_inode = pass1_read_inode;
2736 fs->write_inode = pass1_write_inode;
2738 ext2fs_set_alloc_block_callback(fs, e2fsck_get_alloc_block,
2740 ext2fs_set_block_alloc_stats_callback(fs,
2744 fs->get_blocks = 0;
2745 fs->check_directory = 0;
2746 fs->read_inode = 0;
2747 fs->write_inode = 0;