Skip to contentSkip to conversation

e2fsck: always fix invalid extra field in timestamps if time_t is 32-bits

PATCH New Theodore Ts'o 1 participant 2 messages May 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 e2fsck: always fix invalid extra field in timestamps if time_t is 32-bits

Systems with 32-bit time_t's can be used past 2038, so we should always modify dates with extra_time=3. (On systems with 64-bit time_t's we will fix these dates before the year 2242.)

---
 e2fsck/pass1.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
e2fsck/pass1.c +3 -1
index 799158e..c924d31 100644
@@ -512,7 +512,9 @@ static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx)
 	 * If the inode's extended atime (ctime, crtime, mtime) is stored in
 	 * the old, invalid format, repair it.
 	 */
-	if (sizeof(time_t) > 4 && ctx->now < EXT4_EXTRA_NEGATIVE_DATE_CUTOFF &&
+	if (((sizeof(time_t) <= 4) ||
+	     ((sizeof(time_t) > 4) &&
+	      ctx->now < EXT4_EXTRA_NEGATIVE_DATE_CUTOFF)) &&
 	    (CHECK_INODE_EXTRA_NEGATIVE_EPOCH(inode, atime) ||
 	     CHECK_INODE_EXTRA_NEGATIVE_EPOCH(inode, ctime) ||
 	     CHECK_INODE_EXTRA_NEGATIVE_EPOCH(inode, crtime) ||
Signature · 1 line
2.5.0
#1 lore raw

PATCH 2/2 tests: fix f_pre_1970_date_encoding on systems with a 32-bit time_t

---
 configure                             | 36 +++++++++++++++++++++++++++++++++++
 configure.ac                          |  3 +++
 tests/Makefile.in                     |  1 +
 tests/f_pre_1970_date_encoding/script | 28 +++++++++++++++++++--------
 4 files changed, 60 insertions(+), 8 deletions(-)
configure +36 -0
index 3759c9c..8f6d6cb 100755
@@ -650,6 +650,7 @@ FUSE_CMT
 FUSE_LIB
 MAGIC_LIB
 SOCKET_LIB
+SIZEOF_TIME_T
 SIZEOF_OFF_T
 SIZEOF_LONG_LONG
 SIZEOF_LONG
@@ -12593,11 +12594,46 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5
+$as_echo_n "checking size of time_t... " >&6; }
+if ${ac_cv_sizeof_time_t+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_time_t" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (time_t)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_time_t=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5
+$as_echo "$ac_cv_sizeof_time_t" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_TIME_T $ac_cv_sizeof_time_t
+_ACEOF
+
+
 SIZEOF_SHORT=$ac_cv_sizeof_short
 SIZEOF_INT=$ac_cv_sizeof_int
 SIZEOF_LONG=$ac_cv_sizeof_long
 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
 SIZEOF_OFF_T=$ac_cv_sizeof_off_t
+SIZEOF_TIME_T=$ac_cv_sizeof_time_t
+
 
 
 
configure.ac +3 -0
index e8e0d68..b8e2d4a 100644
@@ -971,16 +971,19 @@ AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
 AC_CHECK_SIZEOF(off_t)
+AC_CHECK_SIZEOF(time_t)
 SIZEOF_SHORT=$ac_cv_sizeof_short
 SIZEOF_INT=$ac_cv_sizeof_int
 SIZEOF_LONG=$ac_cv_sizeof_long
 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
 SIZEOF_OFF_T=$ac_cv_sizeof_off_t
+SIZEOF_TIME_T=$ac_cv_sizeof_time_t
 AC_SUBST(SIZEOF_SHORT)
 AC_SUBST(SIZEOF_INT)
 AC_SUBST(SIZEOF_LONG)
 AC_SUBST(SIZEOF_LONG_LONG)
 AC_SUBST(SIZEOF_OFF_T)
+AC_SUBST(SIZEOF_TIME_T)
 AC_C_BIGENDIAN
 if test $cross_compiling = no; then
   BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
tests/Makefile.in +1 -0
index 9a7d3ff..c130f4a 100644
@@ -20,6 +20,7 @@ test_one: $(srcdir)/test_one.in Makefile mke2fs.conf
 	@echo "QUOTA=y" >> test_one
 	@echo "SRCDIR=@srcdir@" >> test_one
 	@echo "DIFF_OPTS=@UNI_DIFF_OPTS@" >> test_one
+	@echo "SIZEOF_TIME_T=@SIZEOF_TIME_T@" >> test_one
 	@cat $(srcdir)/test_one.in >> test_one
 	@chmod +x test_one
 
tests/f_pre_1970_date_encoding/script +20 -8
index e6d7bbd..06ff98a 100644
@@ -68,17 +68,29 @@ get_file_xtime_and_extra year-1979
 get_file_xtime_and_extra year-2039
 get_file_xtime_and_extra year-2139
 
-# now we need to check that after the year 2242, e2fsck does not
-# modify dates with extra_xtime=3
+if test $SIZEOF_TIME_T -gt 4
+then
+  # now we need to check that after the year 2242, e2fsck does not
+  # modify dates with extra_xtime=3
 
-# restore the unrepaired filesystem
-mv $TMPFILE.sav $TMPFILE
+  # restore the unrepaired filesystem
+  mv $TMPFILE.sav $TMPFILE
 
-#retry the repair
-E2FSCK_TIME=9270393539 $FSCK $FSCK_OPT $TMPFILE >> $OUT 2>&1
+  #retry the repair
+  E2FSCK_TIME=9270393539 $FSCK $FSCK_OPT $TMPFILE >> $OUT 2>&1
 
-# check that the 1909 file is unaltered (i.e. it has a post-2378 date)
-get_file_xtime_and_extra year-1909
+  # check that the 1909 file is unaltered (i.e. it has a post-2378 date)
+  get_file_xtime_and_extra year-1909
+else
+  rm -f TMPFILE.sav
+cat << EOF >> $TIMESTAMPS
+times for year-1909 =
+ ctime: 0x8e475440:00000003
+ atime: 0x8e475440:00000003
+ mtime: 0x8e475440:00000003
+crtime: 0x8e475440:00000003
+EOF
+fi
 
 cmp -s $TIMESTAMPS $EXP
 status=$?
Signature · 1 line
2.5.0