From 6de289cb103b1fff1a5f1f253da73612aa8429c9 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 21 Nov 2003 10:54:54 -0500 Subject: [PATCH] In e2fsck, if the number of mounts until the next forced filesystem check is 5 or less, mention this to the user. (Addresses Debian bug #157194) --- e2fsck/ChangeLog | 4 ++++ e2fsck/unix.c | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 094555a..8724eb2 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,5 +1,9 @@ 2003-09-13 Theodore Ts'o + * unix.c (check_if_skip): If the number of mounts until the next + forced filesystem check is 5 or less, mention this to the + user. (Addresses Debian bug #157194) + * pass1.c (e2fsck_pass1), problem.h (PR_1_BB_FS_BLOCK), problem.c (PR_1_BB_FS_BLOCK, PR_1_BBINODE_BAD_METABLOCK_PROMPT): Fix up the handling of corrupted indirect blocks in the diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 9109773..211a127 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -209,6 +209,8 @@ static void check_if_skip(e2fsck_t ctx) ext2_filsys fs = ctx->fs; const char *reason = NULL; unsigned int reason_arg = 0; + long next_check; + time_t now = time(0); if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag || swapfs) @@ -224,10 +226,10 @@ static void check_if_skip(e2fsck_t ctx) reason = _(" has been mounted %u times without being checked"); reason_arg = fs->super->s_mnt_count; } else if (fs->super->s_checkinterval && - time(0) >= (fs->super->s_lastcheck + + now >= (fs->super->s_lastcheck + fs->super->s_checkinterval)) { reason = _(" has gone %u days without being checked"); - reason_arg = (time(0) - fs->super->s_lastcheck)/(3600*24); + reason_arg = (now - fs->super->s_lastcheck)/(3600*24); } if (reason) { fputs(ctx->device_name, stdout); @@ -235,11 +237,26 @@ static void check_if_skip(e2fsck_t ctx) fputs(_(", check forced.\n"), stdout); return; } - printf(_("%s: clean, %d/%d files, %d/%d blocks\n"), ctx->device_name, + printf(_("%s: clean, %d/%d files, %d/%d blocks"), ctx->device_name, fs->super->s_inodes_count - fs->super->s_free_inodes_count, fs->super->s_inodes_count, fs->super->s_blocks_count - fs->super->s_free_blocks_count, fs->super->s_blocks_count); + next_check = 100000; + if (fs->super->s_max_mnt_count > 0) { + next_check = fs->super->s_max_mnt_count - fs->super->s_mnt_count; + if (next_check <= 0) + next_check = 1; + } + if (now >= (fs->super->s_lastcheck + fs->super->s_checkinterval)) + next_check = 1; + if (next_check <= 5) { + if (next_check == 1) + fputs(_(" (check after next mount)"), stdout); + else + printf(_(" (check in %d mounts)"), next_check); + } + fputc('\n', stdout); ext2fs_close(fs); ctx->fs = NULL; e2fsck_free_context(ctx); -- 1.8.3.1