Lines Matching +full:- +full:fs
2 * e2fsck.c - superblock checks
6 * %Begin-Header%
9 * %End-Header%
35 (flags & LOG2_CHECK && (value & (value - 1)) != 0)) { in check_super_value()
40 ctx->flags |= E2F_FLAG_ABORT; in check_super_value()
54 (flags & LOG2_CHECK && (value & (value - 1)) != 0)) { in check_super_value64()
59 ctx->flags |= E2F_FLAG_ABORT; in check_super_value64()
82 static int release_inode_block(ext2_filsys fs, in release_inode_block() argument
93 blk64_t cluster = EXT2FS_B2C(fs, *block_nr); in release_inode_block()
97 ctx = pb->ctx; in release_inode_block()
98 pctx = pb->pctx; in release_inode_block()
100 pctx->blk = blk; in release_inode_block()
101 pctx->blkcount = blockcnt; in release_inode_block()
106 if (pb->last_cluster == cluster) in release_inode_block()
109 pb->last_cluster = cluster; in release_inode_block()
111 if ((blk < fs->super->s_first_data_block) || in release_inode_block()
112 (blk >= ext2fs_blocks_count(fs->super))) { in release_inode_block()
115 pb->abort = 1; in release_inode_block()
119 if (!ext2fs_test_block_bitmap2(fs->block_map, blk)) { in release_inode_block()
129 if (pb->truncating) { in release_inode_block()
138 pb->errcode = io_channel_read_blk64(fs->io, blk, 1, in release_inode_block()
139 pb->buf); in release_inode_block()
140 if (pb->errcode) in release_inode_block()
143 limit = fs->blocksize >> 2; in release_inode_block()
144 for (i = 0, bp = (blk_t *) pb->buf; in release_inode_block()
153 if (blockcnt >= 0 && blockcnt < pb->truncate_block) in release_inode_block()
159 if ((blockcnt == pb->truncate_block) && pb->truncate_offset) { in release_inode_block()
160 pb->errcode = io_channel_read_blk64(fs->io, blk, 1, in release_inode_block()
161 pb->buf); in release_inode_block()
162 if (pb->errcode) in release_inode_block()
164 memset(pb->buf + pb->truncate_offset, 0, in release_inode_block()
165 fs->blocksize - pb->truncate_offset); in release_inode_block()
166 pb->errcode = io_channel_write_blk64(fs->io, blk, 1, in release_inode_block()
167 pb->buf); in release_inode_block()
168 if (pb->errcode) in release_inode_block()
171 pb->truncated_blocks++; in release_inode_block()
176 if (ctx->qctx) in release_inode_block()
177 quota_data_sub(ctx->qctx, pb->inode, 0, ctx->fs->blocksize); in release_inode_block()
178 ext2fs_block_alloc_stats2(fs, blk, -1); in release_inode_block()
179 ctx->free_blocks++; in release_inode_block()
193 ext2_filsys fs = ctx->fs; in release_inode_blocks() local
198 if (!ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(inode))) in release_inode_blocks()
201 pb.buf = block_buf + 3 * ctx->fs->blocksize; in release_inode_blocks()
208 if (inode->i_links_count) { in release_inode_blocks()
211 ((EXT2_I_SIZE(inode) + fs->blocksize - 1) / in release_inode_blocks()
212 fs->blocksize); in release_inode_blocks()
213 pb.truncate_offset = inode->i_size % fs->blocksize; in release_inode_blocks()
220 retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, in release_inode_blocks()
236 ext2fs_iblk_sub_blocks(fs, EXT2_INODE(inode), in release_inode_blocks()
239 blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode)); in release_inode_blocks()
241 retval = ext2fs_adjust_ea_refcount3(fs, blk, block_buf, -1, in release_inode_blocks()
254 if (ctx->qctx) in release_inode_blocks()
255 quota_data_sub(ctx->qctx, inode, 0, in release_inode_blocks()
256 ctx->fs->blocksize); in release_inode_blocks()
257 ext2fs_block_alloc_stats2(fs, blk, -1); in release_inode_blocks()
258 ctx->free_blocks++; in release_inode_blocks()
260 ext2fs_file_acl_block_set(fs, EXT2_INODE(inode), 0); in release_inode_blocks()
272 if (!ext2fs_has_feature_quota(ctx->fs->super)) in e2fsck_read_all_quotas()
275 retval = quota_init_context(&ctx->qctx, ctx->fs, 0); in e2fsck_read_all_quotas()
280 qf_ino = *quota_sb_inump(ctx->fs->super, qtype); in e2fsck_read_all_quotas()
284 retval = quota_update_limits(ctx->qctx, qf_ino, qtype); in e2fsck_read_all_quotas()
289 quota_release_context(&ctx->qctx); in e2fsck_read_all_quotas()
299 if (!ext2fs_has_feature_quota(ctx->fs->super)) in e2fsck_write_all_quotas()
305 pctx.errcode = quota_write_inode(ctx->qctx, 1 << qtype); in e2fsck_write_all_quotas()
312 quota_release_context(&ctx->qctx); in e2fsck_write_all_quotas()
322 ext2_filsys fs = ctx->fs; in release_orphan_inodes() local
328 if ((ino = fs->super->s_last_orphan) == 0) in release_orphan_inodes()
342 fs->super->s_last_orphan = 0; in release_orphan_inodes()
343 ext2fs_mark_super_dirty(fs); in release_orphan_inodes()
350 if (fs->super->s_state & EXT2_ERROR_FS) { in release_orphan_inodes()
351 if (ctx->qctx) in release_orphan_inodes()
352 quota_release_context(&ctx->qctx); in release_orphan_inodes()
356 if ((ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
357 (ino > fs->super->s_inodes_count)) { in release_orphan_inodes()
364 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4, in release_orphan_inodes()
381 ((next_ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
382 (next_ino > fs->super->s_inodes_count))) { in release_orphan_inodes()
392 if (ctx->qctx) in release_orphan_inodes()
393 quota_data_inodes(ctx->qctx, &inode, ino, -1); in release_orphan_inodes()
394 ext2fs_inode_alloc_stats2(fs, ino, -1, in release_orphan_inodes()
396 ctx->free_inodes++; in release_orphan_inodes()
397 inode.i_dtime = ctx->now; in release_orphan_inodes()
413 if (ctx->qctx) in release_orphan_inodes()
414 quota_release_context(&ctx->qctx); in release_orphan_inodes()
421 * the case where on-line resizing is not enabled (in which case the
422 * resize inode should be cleared) as well as the case where on-line
427 ext2_filsys fs = ctx->fs; in check_resize_inode() local
433 blk_t expect; /* for resize inode, which is 32-bit only */ in check_resize_inode()
439 if (ext2fs_has_feature_resize_inode(fs->super) && in check_resize_inode()
440 ext2fs_has_feature_meta_bg(fs->super) && in check_resize_inode()
442 ext2fs_clear_feature_resize_inode(fs->super); in check_resize_inode()
443 fs->super->s_reserved_gdt_blocks = 0; in check_resize_inode()
444 ext2fs_mark_super_dirty(fs); in check_resize_inode()
451 if (!ext2fs_has_feature_resize_inode(fs->super)) { in check_resize_inode()
452 if (fs->super->s_reserved_gdt_blocks) { in check_resize_inode()
453 pctx.num = fs->super->s_reserved_gdt_blocks; in check_resize_inode()
456 fs->super->s_reserved_gdt_blocks = 0; in check_resize_inode()
457 ext2fs_mark_super_dirty(fs); in check_resize_inode()
464 retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); in check_resize_inode()
466 if (ext2fs_has_feature_resize_inode(fs->super)) in check_resize_inode()
467 ctx->flags |= E2F_FLAG_RESIZE_INODE; in check_resize_inode()
475 if (!ext2fs_has_feature_resize_inode(fs->super)) { in check_resize_inode()
500 (blk < fs->super->s_first_data_block || in check_resize_inode()
501 blk >= ext2fs_blocks_count(fs->super))) { in check_resize_inode()
507 ctx->flags |= E2F_FLAG_RESIZE_INODE; in check_resize_inode()
509 if (!(ctx->options & E2F_OPT_READONLY)) { in check_resize_inode()
510 fs->super->s_state &= ~EXT2_VALID_FS; in check_resize_inode()
511 ext2fs_mark_super_dirty(fs); in check_resize_inode()
515 dind_buf = (__u32 *) e2fsck_allocate_memory(ctx, fs->blocksize * 2, in check_resize_inode()
517 ind_buf = (__u32 *) ((char *) dind_buf + fs->blocksize); in check_resize_inode()
519 retval = ext2fs_read_ind_block(fs, blk, dind_buf); in check_resize_inode()
523 gdt_off = fs->desc_blocks; in check_resize_inode()
524 pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks; in check_resize_inode()
525 if (fs->blocksize == 1024 && fs->super->s_first_data_block == 0) in check_resize_inode()
526 pblk++; /* Deal with 1024 blocksize bigalloc fs */ in check_resize_inode()
527 for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4; in check_resize_inode()
529 gdt_off %= fs->blocksize/4; in check_resize_inode()
532 retval = ext2fs_read_ind_block(fs, pblk, ind_buf); in check_resize_inode()
536 for (j = 1; j < fs->group_desc_count; j++) { in check_resize_inode()
537 if (!ext2fs_bg_has_super(fs, j)) in check_resize_inode()
539 expect = pblk + EXT2_GROUPS_TO_BLOCKS(fs->super, j); in check_resize_inode()
557 struct ext2_super_block *sb = ctx->fs->super; in e2fsck_fix_dirhash_hint()
561 if ((ctx->options & E2F_OPT_READONLY) || in e2fsck_fix_dirhash_hint()
563 (sb->s_flags & (EXT2_FLAGS_SIGNED_HASH|EXT2_FLAGS_UNSIGNED_HASH))) in e2fsck_fix_dirhash_hint()
570 if (((int) c) == -1) { in e2fsck_fix_dirhash_hint()
571 sb->s_flags |= EXT2_FLAGS_SIGNED_HASH; in e2fsck_fix_dirhash_hint()
573 sb->s_flags |= EXT2_FLAGS_UNSIGNED_HASH; in e2fsck_fix_dirhash_hint()
575 ext2fs_mark_super_dirty(ctx->fs); in e2fsck_fix_dirhash_hint()
582 ext2_filsys fs = ctx->fs; in check_super_block() local
584 struct ext2_super_block *sb = fs->super; in check_super_block()
587 blk64_t blocks_per_group = fs->super->s_blocks_per_group; in check_super_block()
601 inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super); in check_super_block()
602 ipg_max = inodes_per_block * (blocks_per_group - 4); in check_super_block()
608 bpg_max = 8 * EXT2_BLOCK_SIZE(sb) * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
612 ctx->invalid_inode_bitmap_flag = (int *) e2fsck_allocate_memory(ctx, in check_super_block()
613 sizeof(int) * fs->group_desc_count, "invalid_inode_bitmap"); in check_super_block()
614 ctx->invalid_block_bitmap_flag = (int *) e2fsck_allocate_memory(ctx, in check_super_block()
615 sizeof(int) * fs->group_desc_count, "invalid_block_bitmap"); in check_super_block()
616 ctx->invalid_inode_table_flag = (int *) e2fsck_allocate_memory(ctx, in check_super_block()
617 sizeof(int) * fs->group_desc_count, "invalid_inode_table"); in check_super_block()
619 blks_max = (1ULL << 32) * EXT2_MAX_BLOCKS_PER_GROUP(fs->super); in check_super_block()
620 if (ext2fs_has_feature_64bit(fs->super)) { in check_super_block()
621 if (blks_max > ((1ULL << 48) - 1)) in check_super_block()
622 blks_max = (1ULL << 48) - 1; in check_super_block()
624 if (blks_max > ((1ULL << 32) - 1)) in check_super_block()
625 blks_max = (1ULL << 32) - 1; in check_super_block()
633 if (!check_super_value(ctx, "inodes_count", sb->s_inodes_count, in check_super_block()
639 if (!check_super_value(ctx, "first_data_block", sb->s_first_data_block, in check_super_block()
642 if (!check_super_value(ctx, "log_block_size", sb->s_log_block_size, in check_super_block()
644 EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) in check_super_block()
647 sb->s_log_cluster_size, in check_super_block()
648 MIN_CHECK | MAX_CHECK, sb->s_log_block_size, in check_super_block()
649 (EXT2_MAX_CLUSTER_LOG_SIZE - in check_super_block()
653 sb->s_clusters_per_group, in check_super_block()
656 if (!check_super_value(ctx, "blocks_per_group", sb->s_blocks_per_group, in check_super_block()
659 if (!check_super_value(ctx, "inodes_per_group", sb->s_inodes_per_group, in check_super_block()
666 sb->s_reserved_gdt_blocks, MAX_CHECK, 0, in check_super_block()
667 fs->blocksize / sizeof(__u32))) in check_super_block()
670 sb->s_desc_size, MAX_CHECK | LOG2_CHECK, 0, in check_super_block()
674 should_be = (__u64)sb->s_inodes_per_group * fs->group_desc_count; in check_super_block()
678 ctx->flags |= E2F_FLAG_ABORT; in check_super_block()
681 if (sb->s_inodes_count != should_be) { in check_super_block()
682 pctx.ino = sb->s_inodes_count; in check_super_block()
685 sb->s_inodes_count = should_be; in check_super_block()
686 ext2fs_mark_super_dirty(fs); in check_super_block()
688 pctx.num = sb->s_inodes_count; in check_super_block()
691 ctx->flags |= E2F_FLAG_ABORT; in check_super_block()
695 if (sb->s_rev_level > EXT2_GOOD_OLD_REV && in check_super_block()
696 !check_super_value(ctx, "first_ino", sb->s_first_ino, in check_super_block()
698 EXT2_GOOD_OLD_FIRST_INO, sb->s_inodes_count)) in check_super_block()
703 EXT2_GOOD_OLD_INODE_SIZE, fs->blocksize)) in check_super_block()
705 if (sb->s_blocks_per_group != (sb->s_clusters_per_group * in check_super_block()
706 EXT2FS_CLUSTER_RATIO(fs))) { in check_super_block()
707 pctx.num = sb->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
710 ctx->flags |= E2F_FLAG_ABORT; in check_super_block()
714 if ((ctx->flags & E2F_FLAG_GOT_DEVSIZE) && in check_super_block()
715 (ctx->num_blocks < ext2fs_blocks_count(sb))) { in check_super_block()
717 pctx.blk2 = ctx->num_blocks; in check_super_block()
719 ctx->flags |= E2F_FLAG_ABORT; in check_super_block()
724 should_be = (sb->s_log_block_size == 0 && in check_super_block()
725 EXT2FS_CLUSTER_RATIO(fs) == 1) ? 1 : 0; in check_super_block()
726 if (sb->s_first_data_block != should_be) { in check_super_block()
727 pctx.blk = sb->s_first_data_block; in check_super_block()
730 ctx->flags |= E2F_FLAG_ABORT; in check_super_block()
736 sizeof(((struct ext2_inode_large *) 0)->i_extra_isize) + in check_super_block()
737 sizeof(((struct ext2_inode_large *) 0)->i_checksum_hi); in check_super_block()
738 unsigned max = EXT2_INODE_SIZE(sb) - EXT2_GOOD_OLD_INODE_SIZE; in check_super_block()
739 pctx.num = sb->s_min_extra_isize; in check_super_block()
740 if (sb->s_min_extra_isize && in check_super_block()
741 (sb->s_min_extra_isize < min || in check_super_block()
742 sb->s_min_extra_isize > max || in check_super_block()
743 sb->s_min_extra_isize & 3) && in check_super_block()
745 sb->s_min_extra_isize = in check_super_block()
746 (sizeof(struct ext2_inode_large) - in check_super_block()
748 ext2fs_mark_super_dirty(fs); in check_super_block()
750 pctx.num = sb->s_want_extra_isize; in check_super_block()
751 if (sb->s_want_extra_isize && in check_super_block()
752 (sb->s_want_extra_isize < min || in check_super_block()
753 sb->s_want_extra_isize > max || in check_super_block()
754 sb->s_want_extra_isize & 3) && in check_super_block()
756 sb->s_want_extra_isize = in check_super_block()
757 (sizeof(struct ext2_inode_large) - in check_super_block()
759 ext2fs_mark_super_dirty(fs); in check_super_block()
764 if (ext2fs_has_feature_metadata_csum(fs->super) && in check_super_block()
765 ext2fs_has_feature_gdt_csum(fs->super) && in check_super_block()
767 ext2fs_clear_feature_gdt_csum(fs->super); in check_super_block()
768 ext2fs_mark_super_dirty(fs); in check_super_block()
769 for (i = 0; i < fs->group_desc_count; i++) in check_super_block()
770 ext2fs_group_desc_csum_set(fs, i); in check_super_block()
774 if (!ext2fs_has_feature_metadata_csum(fs->super) && in check_super_block()
775 ext2fs_has_feature_csum_seed(fs->super) && in check_super_block()
777 ext2fs_clear_feature_csum_seed(fs->super); in check_super_block()
778 fs->super->s_checksum_seed = 0; in check_super_block()
779 ext2fs_mark_super_dirty(fs); in check_super_block()
783 if (ext2fs_has_feature_64bit(fs->super) && in check_super_block()
784 !ext2fs_has_feature_extents(fs->super) && in check_super_block()
786 ext2fs_set_feature_extents(fs->super); in check_super_block()
787 ext2fs_mark_super_dirty(fs); in check_super_block()
791 if (ctx->options & E2F_OPT_CONVERT_BMAP) { in check_super_block()
792 ext2fs_set_feature_extents(fs->super); in check_super_block()
793 ext2fs_mark_super_dirty(fs); in check_super_block()
796 if (ext2fs_has_feature_meta_bg(fs->super) && in check_super_block()
797 (fs->super->s_first_meta_bg > fs->desc_blocks)) { in check_super_block()
798 pctx.group = fs->desc_blocks; in check_super_block()
799 pctx.num = fs->super->s_first_meta_bg; in check_super_block()
801 ext2fs_clear_feature_meta_bg(fs->super); in check_super_block()
802 fs->super->s_first_meta_bg = 0; in check_super_block()
803 ext2fs_mark_super_dirty(fs); in check_super_block()
810 first_block = sb->s_first_data_block; in check_super_block()
811 last_block = ext2fs_blocks_count(sb)-1; in check_super_block()
813 csum_flag = ext2fs_has_group_desc_csum(fs); in check_super_block()
814 for (i = 0; i < fs->group_desc_count; i++) { in check_super_block()
817 if (!ext2fs_has_feature_flex_bg(fs->super)) { in check_super_block()
818 first_block = ext2fs_group_first_block2(fs, i); in check_super_block()
819 last_block = ext2fs_group_last_block2(fs, i); in check_super_block()
822 if ((ext2fs_block_bitmap_loc(fs, i) < first_block) || in check_super_block()
823 (ext2fs_block_bitmap_loc(fs, i) > last_block)) { in check_super_block()
824 pctx.blk = ext2fs_block_bitmap_loc(fs, i); in check_super_block()
826 ext2fs_block_bitmap_loc_set(fs, i, 0); in check_super_block()
828 if (ext2fs_block_bitmap_loc(fs, i) == 0) { in check_super_block()
829 ctx->invalid_block_bitmap_flag[i]++; in check_super_block()
830 ctx->invalid_bitmaps++; in check_super_block()
832 if ((ext2fs_inode_bitmap_loc(fs, i) < first_block) || in check_super_block()
833 (ext2fs_inode_bitmap_loc(fs, i) > last_block)) { in check_super_block()
834 pctx.blk = ext2fs_inode_bitmap_loc(fs, i); in check_super_block()
836 ext2fs_inode_bitmap_loc_set(fs, i, 0); in check_super_block()
838 if (ext2fs_inode_bitmap_loc(fs, i) == 0) { in check_super_block()
839 ctx->invalid_inode_bitmap_flag[i]++; in check_super_block()
840 ctx->invalid_bitmaps++; in check_super_block()
842 if ((ext2fs_inode_table_loc(fs, i) < first_block) || in check_super_block()
843 ((ext2fs_inode_table_loc(fs, i) + in check_super_block()
844 fs->inode_blocks_per_group - 1) > last_block)) { in check_super_block()
845 pctx.blk = ext2fs_inode_table_loc(fs, i); in check_super_block()
847 ext2fs_inode_table_loc_set(fs, i, 0); in check_super_block()
849 if (ext2fs_inode_table_loc(fs, i) == 0) { in check_super_block()
850 ctx->invalid_inode_table_flag[i]++; in check_super_block()
851 ctx->invalid_bitmaps++; in check_super_block()
853 free_blocks += ext2fs_bg_free_blocks_count(fs, i); in check_super_block()
854 free_inodes += ext2fs_bg_free_inodes_count(fs, i); in check_super_block()
856 if ((ext2fs_bg_free_blocks_count(fs, i) > sb->s_blocks_per_group) || in check_super_block()
857 (ext2fs_bg_free_inodes_count(fs, i) > sb->s_inodes_per_group) || in check_super_block()
858 (ext2fs_bg_used_dirs_count(fs, i) > sb->s_inodes_per_group)) in check_super_block()
859 ext2fs_unmark_valid(fs); in check_super_block()
862 if (!ext2fs_group_desc_csum_verify(fs, i)) { in check_super_block()
863 pctx.csum1 = ext2fs_bg_checksum(fs, i); in check_super_block()
864 pctx.csum2 = ext2fs_group_desc_csum(fs, i); in check_super_block()
866 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
867 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
868 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
871 ext2fs_unmark_valid(fs); in check_super_block()
875 (ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) || in check_super_block()
876 ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) || in check_super_block()
877 ext2fs_bg_itable_unused(fs, i) != 0)) { in check_super_block()
879 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
880 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
881 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
884 ext2fs_unmark_valid(fs); in check_super_block()
887 if (i == fs->group_desc_count - 1 && in check_super_block()
888 ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)) { in check_super_block()
890 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
893 ext2fs_unmark_valid(fs); in check_super_block()
897 (ext2fs_bg_itable_unused(fs, i) > ext2fs_bg_free_inodes_count(fs, i) || in check_super_block()
898 ext2fs_bg_itable_unused(fs, i) > sb->s_inodes_per_group)) { in check_super_block()
899 pctx.blk = ext2fs_bg_itable_unused(fs, i); in check_super_block()
901 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
904 ext2fs_unmark_valid(fs); in check_super_block()
908 ext2fs_group_desc_csum_set(fs, i); in check_super_block()
910 if (ctx->flags & E2F_FLAG_SIGNAL_MASK) in check_super_block()
914 ctx->free_blocks = EXT2FS_C2B(fs, free_blocks); in check_super_block()
915 ctx->free_inodes = free_inodes; in check_super_block()
918 (sb->s_free_inodes_count > sb->s_inodes_count)) in check_super_block()
919 ext2fs_unmark_valid(fs); in check_super_block()
926 if (ctx->invalid_bitmaps && !(ctx->options & E2F_OPT_READONLY)) { in check_super_block()
927 sb->s_state &= ~EXT2_VALID_FS; in check_super_block()
928 ext2fs_mark_super_dirty(fs); in check_super_block()
939 if (!(ctx->options & E2F_OPT_READONLY) && uuid_is_null(sb->s_uuid) && in check_super_block()
940 !ext2fs_has_feature_metadata_csum(ctx->fs->super) && in check_super_block()
941 (!csum_flag || !(ctx->mount_flags & EXT2_MF_MOUNTED))) { in check_super_block()
943 uuid_generate(sb->s_uuid); in check_super_block()
944 ext2fs_init_csum_seed(fs); in check_super_block()
945 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
946 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
954 profile_get_boolean(ctx->profile, "options", in check_super_block()
957 if (!(ctx->options & E2F_OPT_READONLY) && in check_super_block()
959 (fs->super->s_flags & EXT2_FLAGS_TEST_FILESYS) && in check_super_block()
962 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS; in check_super_block()
963 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
964 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
972 if (!(ctx->options & E2F_OPT_READONLY) && in check_super_block()
973 fs->super->s_creator_os == EXT2_OS_HURD && in check_super_block()
974 ext2fs_has_feature_filetype(fs->super)) { in check_super_block()
976 ext2fs_clear_feature_filetype(fs->super); in check_super_block()
977 ext2fs_mark_super_dirty(fs); in check_super_block()
978 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
988 if (!(ctx->options & E2F_OPT_READONLY) && in check_super_block()
989 fs->super->s_rev_level == EXT2_GOOD_OLD_REV && in check_super_block()
990 (fs->super->s_feature_compat || in check_super_block()
991 fs->super->s_feature_ro_compat || in check_super_block()
992 fs->super->s_feature_incompat) && in check_super_block()
994 ext2fs_update_dynamic_rev(fs); in check_super_block()
995 ext2fs_mark_super_dirty(fs); in check_super_block()
996 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
1002 if (!(ctx->options & E2F_OPT_READONLY) && release_orphan_inodes(ctx)) { in check_super_block()
1003 fs->super->s_state &= ~EXT2_VALID_FS; in check_super_block()
1004 ext2fs_mark_super_dirty(fs); in check_super_block()
1010 * of the more proper and less error-prone UTC time, many in check_super_block()
1028 profile_get_boolean(ctx->profile, "options", "accept_time_fudge", in check_super_block()
1030 profile_get_boolean(ctx->profile, "options", "buggy_init_scripts", in check_super_block()
1032 ctx->time_fudge = accept_time_fudge ? 86400 : 0; in check_super_block()
1034 profile_get_boolean(ctx->profile, "options", "broken_system_clock", in check_super_block()
1042 !(ctx->flags & E2F_FLAG_TIME_INSANE) && in check_super_block()
1043 fs->super->s_mtime > (__u32) ctx->now) { in check_super_block()
1044 pctx.num = fs->super->s_mtime; in check_super_block()
1046 if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
1049 fs->super->s_mtime = ctx->now; in check_super_block()
1050 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
1054 !(ctx->flags & E2F_FLAG_TIME_INSANE) && in check_super_block()
1055 fs->super->s_wtime > (__u32) ctx->now) { in check_super_block()
1056 pctx.num = fs->super->s_wtime; in check_super_block()
1058 if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
1061 fs->super->s_wtime = ctx->now; in check_super_block()
1062 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
1093 * blocks. Returns non-zero if the sb should be backed up.
1117 ext2_filsys fs = ctx->fs; in check_backup_super_block() local
1129 * do the backup. If the filesystem was opened read-only then in check_backup_super_block()
1132 if (((fs->flags & EXT2_FLAG_MASTER_SB_ONLY) == 0) || in check_backup_super_block()
1133 !ext2fs_test_valid(fs) || in check_backup_super_block()
1134 (fs->super->s_state & EXT2_ERROR_FS) || in check_backup_super_block()
1135 (ctx->flags & (E2F_FLAG_ABORT | E2F_FLAG_CANCEL)) || in check_backup_super_block()
1136 (ctx->options & E2F_OPT_READONLY)) in check_backup_super_block()
1139 for (g = 1; g < fs->group_desc_count; g++) { in check_backup_super_block()
1140 if (!ext2fs_bg_has_super(fs, g)) in check_backup_super_block()
1143 sb = ext2fs_group_first_block2(fs, g); in check_backup_super_block()
1145 retval = io_channel_read_blk(fs->io, sb, -SUPERBLOCK_SIZE, in check_backup_super_block()
1153 if ((backup_sb->s_magic != EXT2_SUPER_MAGIC) || in check_backup_super_block()
1154 (backup_sb->s_rev_level > EXT2_LIB_CURRENT_REV) || in check_backup_super_block()
1155 ((backup_sb->s_log_block_size + EXT2_MIN_BLOCK_LOG_SIZE) > in check_backup_super_block()
1161 ((fs->super->x & ~FEATURE_INCOMPAT_IGNORE) != \ in check_backup_super_block()
1162 (backup_sb->x & ~FEATURE_INCOMPAT_IGNORE)) in check_backup_super_block()
1164 ((fs->super->x & ~FEATURE_RO_COMPAT_IGNORE) != \ in check_backup_super_block()
1165 (backup_sb->x & ~FEATURE_RO_COMPAT_IGNORE)) in check_backup_super_block()
1167 (fs->super->x != backup_sb->x) in check_backup_super_block()
1175 memcmp(fs->super->s_uuid, backup_sb->s_uuid, in check_backup_super_block()
1176 sizeof(fs->super->s_uuid))) in check_backup_super_block()