int e2fsck_run_ext3_journal(e2fsck_t ctx) { io_manager io_ptr = ctx->fs->io->manager; int blocksize = ctx->fs->blocksize; errcode_t retval, recover_retval; io_stats stats = 0; unsigned long long kbytes_written = 0; printf(_("%s: recovering journal\n"), ctx->device_name); if (ctx->options & E2F_OPT_READONLY) { printf(_("%s: won't do journal recovery while read-only\n"), ctx->device_name); return EXT2_ET_FILE_RO; } if (ctx->fs->flags & EXT2_FLAG_DIRTY) ext2fs_flush(ctx->fs); /* Force out any modifications */ recover_retval = recover_ext3_journal(ctx); /* * Reload the filesystem context to get up-to-date data from disk * because journal recovery will change the filesystem under us. */ if (ctx->fs->super->s_kbytes_written && ctx->fs->io->manager->get_stats) ctx->fs->io->manager->get_stats(ctx->fs->io, &stats); if (stats && stats->bytes_written) kbytes_written = stats->bytes_written >> 10; ext2fs_mmp_stop(ctx->fs); ext2fs_free(ctx->fs); retval = ext2fs_open(ctx->filesystem_name, EXT2_FLAG_RW, ctx->superblock, blocksize, io_ptr, &ctx->fs); if (retval) { com_err(ctx->program_name, retval, _("while trying to re-open %s"), ctx->device_name); fatal_error(ctx, 0); } ctx->fs->priv_data = ctx; ctx->fs->now = ctx->now; ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; ctx->fs->super->s_kbytes_written += kbytes_written; /* Set the superblock flags */ e2fsck_clear_recover(ctx, recover_retval); /* * Do one last sanity check, and propagate journal->s_errno to * the EXT2_ERROR_FS flag in the fs superblock if needed. */ retval = e2fsck_check_ext3_journal(ctx); return retval ? retval : recover_retval; }
errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp) { ext2_filsys fs = *fsp; io_manager io_ptr = fs->io->manager; errcode_t retval, recover_retval; io_stats stats = 0; unsigned long long kbytes_written = 0; char *fsname; int fsflags; int fsblocksize; if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_FILE_RO; if (fs->flags & EXT2_FLAG_DIRTY) ext2fs_flush(fs); /* Force out any modifications */ recover_retval = recover_ext3_journal(fs); /* * Reload the filesystem context to get up-to-date data from disk * because journal recovery will change the filesystem under us. */ if (fs->super->s_kbytes_written && fs->io->manager->get_stats) fs->io->manager->get_stats(fs->io, &stats); if (stats && stats->bytes_written) kbytes_written = stats->bytes_written >> 10; ext2fs_mmp_stop(fs); fsname = strdup(fs->device_name); fsflags = fs->flags; fsblocksize = fs->blocksize; ext2fs_free(fs); retval = ext2fs_open(fsname, fsflags, 0, fsblocksize, io_ptr, fsp); free(fsname); if (retval) return retval; fs = *fsp; fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; fs->super->s_kbytes_written += kbytes_written; /* Set the superblock flags */ ext2fs_clear_recover(fs, recover_retval != 0); /* * Do one last sanity check, and propagate journal->s_errno to * the EXT2_ERROR_FS flag in the fs superblock if needed. */ retval = ext2fs_check_ext3_journal(fs); return retval ? retval : recover_retval; }
int e2fsck_run_ext3_journal(e2fsck_t ctx) { io_manager io_ptr = ctx->fs->io->manager; int blocksize = ctx->fs->blocksize; errcode_t retval, recover_retval; printf(_("%s: recovering journal\n"), ctx->device_name); if (ctx->options & E2F_OPT_READONLY) { printf(_("%s: won't do journal recovery while read-only\n"), ctx->device_name); return EXT2_ET_FILE_RO; } if (ctx->fs->flags & EXT2_FLAG_DIRTY) ext2fs_flush(ctx->fs); /* Force out any modifications */ recover_retval = recover_ext3_journal(ctx); /* * Reload the filesystem context to get up-to-date data from disk * because journal recovery will change the filesystem under us. */ ext2fs_close(ctx->fs); retval = ext2fs_open(ctx->filesystem_name, EXT2_FLAG_RW, ctx->superblock, blocksize, io_ptr, &ctx->fs); if (retval) { com_err(ctx->program_name, retval, _("while trying to re-open %s"), ctx->device_name); fatal_error(ctx, 0); } ctx->fs->priv_data = ctx; ctx->fs->now = ctx->now; ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; /* Set the superblock flags */ e2fsck_clear_recover(ctx, recover_retval); return recover_retval; }