+ was_changed = ext2fs_test_changed(fs);
+ if (!(ctx->flags & E2F_FLAG_RUN_RETURN) &&
+ !(ctx->options & E2F_OPT_READONLY)) {
+ if (ext2fs_test_valid(fs)) {
+ if (!(sb->s_state & EXT2_VALID_FS))
+ exit_value |= FSCK_NONDESTRUCT;
+ sb->s_state = EXT2_VALID_FS;
+ if (check_backup_super_block(ctx))
+ fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
+ } else
+ sb->s_state &= ~EXT2_VALID_FS;
+ if (!(ctx->flags & E2F_FLAG_TIME_INSANE))
+ sb->s_lastcheck = ctx->now;
+ sb->s_mnt_count = 0;
+ memset(((char *) sb) + EXT4_S_ERR_START, 0, EXT4_S_ERR_LEN);
+ pctx.errcode = ext2fs_set_gdt_csum(ctx->fs);
+ if (pctx.errcode)
+ fix_problem(ctx, PR_6_SET_BG_CHECKSUM, &pctx);
+ ext2fs_mark_super_dirty(fs);
+ }
+
+ if (ext2fs_has_feature_shared_blocks(ctx->fs->super) &&
+ (ctx->options & E2F_OPT_UNSHARE_BLOCKS) &&
+ (ctx->options & E2F_OPT_NO))
+ /* Don't try to write or flush I/O, we just wanted to know whether or
+ * not there were enough free blocks to undo deduplication.
+ */
+ goto skip_write;
+
+ if (!(ctx->options & E2F_OPT_READONLY)) {
+ e2fsck_write_bitmaps(ctx);
+ if (fs->flags & EXT2_FLAG_DIRTY) {
+ pctx.errcode = ext2fs_flush(ctx->fs);
+ if (pctx.errcode)
+ fix_problem(ctx, PR_6_FLUSH_FILESYSTEM, &pctx);
+ }
+ pctx.errcode = io_channel_flush(ctx->fs->io);
+ if (pctx.errcode)
+ fix_problem(ctx, PR_6_IO_FLUSH, &pctx);
+ }
+
+ if (was_changed) {
+ int fs_fixed = (ctx->flags & E2F_FLAG_PROBLEMS_FIXED);
+
+ if (fs_fixed)
+ exit_value |= FSCK_NONDESTRUCT;
+ if (!(ctx->options & E2F_OPT_PREEN)) {
+#if 0 /* Do this later; it breaks too many tests' golden outputs */
+ log_out(ctx, fs_fixed ?
+ _("\n%s: ***** FILE SYSTEM ERRORS "
+ "CORRECTED *****\n") :
+ _("%s: File system was modified.\n"),
+ ctx->device_name);
+#else
+ log_out(ctx,
+ _("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),