diff options
author | Theodore Ts'o <tytso@mit.edu> | 2024-04-23 23:18:28 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2024-04-23 23:20:43 -0400 |
commit | f5f03776ca2799ffa094d71318c2960af5f2c63c (patch) | |
tree | 5a75a48530d58ae325c68e0b74eb5e1456f9c76e | |
parent | ec1c87f84bc4b3ca60c422f02c08b0e4e0543bd6 (diff) | |
download | e2fsprogs-f5f03776ca2799ffa094d71318c2960af5f2c63c.tar.gz |
e2fsck, tune2fs: fix post-2038 support for s_lastcheck
This changes were missed in commit ca8bc9240a00 ("Add post-2038
timestamp support to e2fsprogs").
Addresses-Coverity-Bug: 1531832
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | e2fsck/unix.c | 11 | ||||
-rw-r--r-- | misc/tune2fs.c | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c index bc6b518d5..de20b216d 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -342,6 +342,7 @@ static int is_on_batt(void) static void check_if_skip(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; + struct ext2_super_block *sb = fs->super; struct problem_context pctx; const char *reason = NULL; unsigned int reason_arg = 0; @@ -370,7 +371,7 @@ static void check_if_skip(e2fsck_t ctx) if (ctx->options & E2F_OPT_JOURNAL_ONLY) goto skip; - lastcheck = fs->super->s_lastcheck; + lastcheck = ext2fs_get_tstamp(sb, s_lastcheck); if (lastcheck > ctx->now) lastcheck -= ctx->time_fudge; if ((fs->super->s_state & EXT2_ERROR_FS) || @@ -397,8 +398,9 @@ static void check_if_skip(e2fsck_t ctx) ((ctx->now - lastcheck) >= ((time_t) fs->super->s_checkinterval))) { reason = _(" has gone %u days without being checked"); - reason_arg = (ctx->now - fs->super->s_lastcheck)/(3600*24); - if (batt && ((ctx->now - fs->super->s_lastcheck) < + reason_arg = (ctx->now - ext2fs_get_tstamp(sb, s_lastcheck)) / + (3600*24); + if (batt && ((ctx->now - ext2fs_get_tstamp(sb, s_lastcheck)) < fs->super->s_checkinterval*2)) reason = 0; } else if (broken_system_clock && fs->super->s_checkinterval) { @@ -457,7 +459,8 @@ static void check_if_skip(e2fsck_t ctx) next_check = 1; } if (!broken_system_clock && fs->super->s_checkinterval && - ((ctx->now - fs->super->s_lastcheck) >= fs->super->s_checkinterval)) + ((ctx->now - ext2fs_get_tstamp(sb, s_lastcheck)) >= + fs->super->s_checkinterval)) next_check = 1; if (next_check <= 5) { if (next_check == 1) { diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 5f077663c..d7401f7b6 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -3445,7 +3445,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" goto closefs; } if (T_flag) { - sb->s_lastcheck = last_check_time; + ext2fs_set_tstamp(sb, s_lastcheck, last_check_time); ext2fs_mark_super_dirty(fs); printf(_("Setting time filesystem last checked to %s\n"), ctime(&last_check_time)); |