e2fsck: Fix superblock times in the future even if buggy_init_scripts=1
Unfortunately, distributions like Ubuntu seem to have buggy init
scripts that run e2fsck and mount the root filesystem before making
sure the system time and time zone is correctly set. As a result, a
filesystem's last write and last mounted time can be set in future.
The buggy_init_scripts configuration option will stop e2fsck from
aborting the boot process, but it also inhibits the superblock times
from getting fixed. This causes resize2fs to refuse to resize the
filesystem, even after running e2fsck on the file system. To deal
with this, we need to fix the superblock write times unconditionally.
Addresses-Launchpad-bug: #373409
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 43a0aa6..d6b345c 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -335,12 +335,12 @@
/* Last mount time is in the future */
{ PR_0_FUTURE_SB_LAST_MOUNT,
N_("@S last mount time is in the future. "),
- PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+ PROMPT_FIX, PR_NO_OK },
/* Last write time is in the future */
{ PR_0_FUTURE_SB_LAST_WRITE,
N_("@S last write time is in the future. "),
- PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+ PROMPT_FIX, PR_NO_OK },
{ PR_0_EXTERNAL_JOURNAL_HINT,
N_("@S hint for external superblock @s %X. "),
@@ -385,6 +385,18 @@
N_("The test_fs flag is set (and ext4 is available). "),
PROMPT_CLEAR, PR_PREEN_OK },
+ /* Last mount time is in the future (fudged) */
+ { PR_0_FUTURE_SB_LAST_MOUNT_FUDGED,
+ N_("@S last mount time is in the future.\n\t(by less than a day, "
+ "probably due to buggy init scripts) "),
+ PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+
+ /* Last write time is in the future (fudged) */
+ { PR_0_FUTURE_SB_LAST_WRITE_FUDGED,
+ N_("@S last write time is in the future.\n\t(by less than a day, "
+ "probably due to buggy init scripts). "),
+ PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+
/* Pass 1 errors */
/* Pass 1: Checking inodes, blocks, and sizes */