From ee895139d79c364aa43e6c0113c3f060081cb9fe Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 7 Nov 2002 16:16:55 -0500 Subject: [PATCH] e2fsck.h, unix.c (main, check_mount): Fix e2fsck so that it returns the appropriate exit code, so that the boot scripts will be told that they need to automatically reboot. --- e2fsck/ChangeLog | 7 +++++++ e2fsck/e2fsck.h | 1 + e2fsck/unix.c | 16 +++++++--------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 6f8dee0..b50b25f 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,10 @@ +2002-11-07 Theodore Ts'o + + * e2fsck.h, unix.c (main, check_mount): Fix e2fsck so that it + returns the appropriate exit code, so that the boot + scripts will be told that they need to automatically + reboot. + 2002-10-31 Theodore Ts'o * Release of E2fsprogs 1.30 diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index 9fb3922..492a231 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -188,6 +188,7 @@ struct e2fsck_struct { blk_t superblock; /* sb used to open fs */ int blocksize; /* blocksize */ blk_t num_blocks; /* Total number of blocks */ + int mount_flags; #ifdef HAVE_SETJMP_H jmp_buf abort_loc; diff --git a/e2fsck/unix.c b/e2fsck/unix.c index e3ff404..bee6636 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -51,9 +51,6 @@ static int verbose = 0; static int replace_bad_blocks = 0; static char *bad_blocks_file = 0; -static int root_filesystem = 0; -static int read_only_root = 0; - e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ static void usage(e2fsck_t ctx) @@ -201,9 +198,10 @@ static void show_stats(e2fsck_t ctx) static void check_mount(e2fsck_t ctx) { errcode_t retval; - int mount_flags, cont; + int cont; - retval = ext2fs_check_if_mounted(ctx->filesystem_name, &mount_flags); + retval = ext2fs_check_if_mounted(ctx->filesystem_name, + &ctx->mount_flags); if (retval) { com_err("ext2fs_check_if_mount", retval, _("while determining whether %s is mounted."), @@ -215,9 +213,9 @@ static void check_mount(e2fsck_t ctx) * If the filesystem isn't mounted, or it's the root filesystem * and it's mounted read-only, then everything's fine. */ - if ((!(mount_flags & EXT2_MF_MOUNTED)) || - ((mount_flags & EXT2_MF_ISROOT) && - (mount_flags & EXT2_MF_READONLY))) + if ((!(ctx->mount_flags & EXT2_MF_MOUNTED)) || + ((ctx->mount_flags & EXT2_MF_ISROOT) && + (ctx->mount_flags & EXT2_MF_READONLY))) return; if (ctx->options & E2F_OPT_READONLY) { @@ -1055,7 +1053,7 @@ restart: if (!(ctx->options & E2F_OPT_PREEN)) printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"), ctx->device_name); - if (root_filesystem && !read_only_root) { + if (ctx->mount_flags & EXT2_MF_ISROOT) { printf(_("%s: ***** REBOOT LINUX *****\n"), ctx->device_name); exit_value |= FSCK_REBOOT; -- 1.8.3.1