summaryrefslogtreecommitdiff
path: root/e2fsck/util.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2011-11-01 07:32:28 +0000
committerTheodore Ts'o <tytso@mit.edu>2011-11-20 15:56:11 -0500
commit13dcce8bb46961fcab14e87343e25aaebef7f44c (patch)
treef267404ab6705081b605983857a88c9d6bfba659 /e2fsck/util.c
parent9c23b8961205f30d29c4137f4833f78cc48ce3fb (diff)
downloade2fsprogs-13dcce8bb46961fcab14e87343e25aaebef7f44c.tar.gz
e2fsck: return more status if fsck aborts
If we abort fsck (due to ENOMEM for example) we exit with only the FSCK_ERROR flag. It seems useful to do the same sorts of checks as we do on normal exit, and return whether the filesystem was modified, whether there are still uncorrected errors, etc, even in the abort case. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'e2fsck/util.c')
-rw-r--r--e2fsck/util.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 06daf12c..f00734e4 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -47,19 +47,38 @@ extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
void fatal_error(e2fsck_t ctx, const char *msg)
{
+ ext2_filsys fs = ctx->fs;
+ int exit_value = FSCK_ERROR;
+
if (msg)
fprintf (stderr, "e2fsck: %s\n", msg);
- if (ctx->fs && ctx->fs->io) {
+ if (!fs)
+ goto out;
+ if (fs->io) {
ext2fs_mmp_stop(ctx->fs);
if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL)
io_channel_flush(ctx->fs->io);
else
fprintf(stderr, "e2fsck: io manager magic bad!\n");
}
+ if (ext2fs_test_changed(fs)) {
+ exit_value |= FSCK_NONDESTRUCT;
+ printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
+ ctx->device_name);
+ if (ctx->mount_flags & EXT2_MF_ISROOT)
+ exit_value |= FSCK_REBOOT;
+ }
+ if (!ext2fs_test_valid(fs)) {
+ printf(_("\n%s: ********** WARNING: Filesystem still has "
+ "errors **********\n\n"), ctx->device_name);
+ exit_value |= FSCK_UNCORRECTED;
+ exit_value &= ~FSCK_NONDESTRUCT;
+ }
+out:
ctx->flags |= E2F_FLAG_ABORT;
if (ctx->flags & E2F_FLAG_SETJMP_OK)
longjmp(ctx->abort_loc, 1);
- exit(FSCK_ERROR);
+ exit(exit_value);
}
void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,