e2fsck: fix last mount/write time when e2fsck is forced
commit2c69c94217b6db083d601d4fd62d6ab6c1628fee
authorLukas Czerner <lczerner@redhat.com>
Mon, 14 Jun 2021 13:27:25 +0000 (14 15:27 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 6 Jul 2021 23:48:20 +0000 (6 19:48 -0400)
tree1450a28bdb2617577eecd13587469f3f6ed8b43f
parent63f44aafb1f20f8dffdede1e824ce8cbf252bbfc
e2fsck: fix last mount/write time when e2fsck is forced

With commit c52d930f e2fsck is no longer able to fix bad last
mount/write time by default because it is conditioned on s_checkinterval
not being zero, which it is by default.

One place where it matters is when other e2fsprogs tools require to run
full file system check before a certain operation. If the last mount
time is for any reason in future, it will not allow it to run even if
full e2fsck is ran.

Fix it by checking the last mount/write time when the e2fsck is forced,
except for the case where we know the system clock is broken.

[ Reworked the conditionals so error messages claiming that the last
  write/mount time were corrupted wouldn't be always printed when the
  e2fsck was run with the -f option, thus causing 299 out of 372
  regression tests to fail.  -- TYT ]

Fixes: c52d930f ("e2fsck: don't check for future superblock times if checkinterval == 0")
Reported-by: Dusty Mabe <dustymabe@redhat.com>
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/super.c