Whamcloud - gitweb
Fix 32-bit build and test failures
authorTheodore Ts'o <tytso@mit.edu>
Thu, 18 Apr 2024 03:47:02 +0000 (23:47 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 18 Apr 2024 03:47:02 +0000 (23:47 -0400)
Commit ca8bc9240a00 ("Add post-2038 timestamp support to e2fsprogs")
was never built or tested on a 32-bit.  It introduced some build
problems when time_t is a 32-bit integer, and it exposed some test
bugs.  Fix them.

Fixes: ca8bc9240a00 ("Add post-2038 timestamp support to e2fsprogs")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ext2fs.h
tests/f_desc_size_bad/script
tests/f_dup4/script
tests/f_itable_collision/expect.1
tests/f_itable_collision/script
tests/f_uninit_last_uninit/script

index e043551..9ecbb50 100644 (file)
@@ -581,13 +581,19 @@ typedef struct ext2_struct_inode_scan *ext2_inode_scan;
 
 static inline __u32 __encode_extra_time(time_t seconds, __u32 nsec)
 {
-       __u32 extra = ((seconds - (__s32)seconds) >> 32) & EXT4_EPOCH_MASK;
+       __u32 extra = 0;
+
+#if (SIZEOF_TIME_T > 4)
+       extra = ((seconds - (__s32)seconds) >> 32) & EXT4_EPOCH_MASK;
+#endif
        return extra | (nsec << EXT4_EPOCH_BITS);
 }
 static inline time_t __decode_extra_sec(time_t seconds, __u32 extra)
 {
+#if (SIZEOF_TIME_T > 4)
        if (extra & EXT4_EPOCH_MASK)
                seconds += ((time_t)(extra & EXT4_EPOCH_MASK) << 32);
+#endif
        return seconds;
 }
 static inline __u32 __decode_extra_nsec(__u32 extra)
@@ -620,11 +626,19 @@ do {                                                                            \
 static inline void __sb_set_tstamp(__u32 *lo, __u8 *hi, time_t seconds)
 {
        *lo = seconds & 0xffffffff;
+#if (SIZEOF_TIME_T > 4)
        *hi = seconds >> 32;
+#else
+       *hi = 0;
+#endif
 }
 static inline time_t __sb_get_tstamp(__u32 *lo, __u8 *hi)
 {
+#if (SIZEOF_TIME_T == 4)
+       return *lo;
+#else
        return ((time_t)(*hi) << 32) | *lo;
+#endif
 }
 #define ext2fs_set_tstamp(sb, field, seconds) \
        __sb_set_tstamp(&(sb)->field, &(sb)->field ## _hi, seconds)
index ae29627..40852c9 100644 (file)
@@ -9,8 +9,8 @@ touch $TMPFILE
 $MKE2FS -F -o Linux -O 64bit,extents -N 32 -b 1024 -g 512 -E desc_size=128 $TMPFILE 2048 > $test_name.log 2>&1
 $DEBUGFS -R "ssv desc_size 129" -w $TMPFILE >> $test_name.log 2>&1
 
-E2FSCK_TIME=200704102100
-export E2FSCK_TIME
+#E2FSCK_TIME=1176238800
+#export E2FSCK_TIME
 
 . $cmd_dir/run_e2fsck
 
index aec862d..94db73a 100644 (file)
@@ -45,7 +45,7 @@ set_inode_field /dir3/foe block[0] 34
 q
 EOF
 
-E2FSCK_TIME=200704102100
+E2FSCK_TIME=1176238800
 export E2FSCK_TIME
 
 . $cmd_dir/run_e2fsck
index 01c85d4..fbab323 100644 (file)
@@ -27,14 +27,14 @@ Clear inode? yes
 Restarting e2fsck from the beginning...
 Pass 1: Checking inodes, blocks, and sizes
 Inode 12 block 37 conflicts with critical metadata, skipping block checks.
-Illegal block number passed to ext2fs_test_block_bitmap #4294967294 for in-use block map
-Illegal block number passed to ext2fs_mark_block_bitmap #4294967294 for in-use block map
+Illegal block number passed to ext2fs_test_block_bitmap #2147483646 for in-use block map
+Illegal block number passed to ext2fs_mark_block_bitmap #2147483646 for in-use block map
 Illegal block number passed to ext2fs_test_block_bitmap #268435455 for in-use block map
 Illegal block number passed to ext2fs_mark_block_bitmap #268435455 for in-use block map
 
 Running additional passes to resolve blocks claimed by more than one inode...
 Pass 1B: Rescanning for multiply-claimed blocks
-Illegal block number passed to ext2fs_test_block_bitmap #4294967294 for multiply claimed block map
+Illegal block number passed to ext2fs_test_block_bitmap #2147483646 for multiply claimed block map
 Illegal block number passed to ext2fs_test_block_bitmap #268435455 for multiply claimed block map
 Multiply-claimed block(s) in inode 12: 37
 Pass 1C: Scanning directories for inodes with multiply-claimed blocks
@@ -46,7 +46,7 @@ File /a (inode #12, mod time Fri Jun 27 18:34:44 2014)
        <filesystem metadata>
 Clone multiply-claimed blocks? yes
 
-Illegal block number passed to ext2fs_test_block_bitmap #4294967294 for multiply claimed block map
+Illegal block number passed to ext2fs_test_block_bitmap #2147483646 for multiply claimed block map
 Illegal block number passed to ext2fs_test_block_bitmap #268435455 for multiply claimed block map
 Pass 2: Checking directory structure
 Setting filetype for entry 'bad1' in / (2) to 1.
@@ -54,7 +54,7 @@ Setting filetype for entry 'bad2' in / (2) to 1.
 Restarting e2fsck from the beginning...
 Pass 1: Checking inodes, blocks, and sizes
 Inode 12 has an invalid extent
-       (logical block 0, invalid physical block 4294967294, len 1)
+       (logical block 0, invalid physical block 2147483646, len 1)
 Clear? yes
 
 Inode 12 has an invalid extent
index 66abd90..9d76c23 100755 (executable)
@@ -6,7 +6,7 @@
 
 FSCK_OPT=-fy
 IMAGE=$test_dir/image.gz
-E2FSCK_TIME=4294967294
+E2FSCK_TIME=2147483646
 export E2FSCK_TIME
 
 gzip -d < $IMAGE > $TMPFILE
index 53105a4..d0930b8 100644 (file)
@@ -17,7 +17,7 @@ set_bg 1 checksum calc
 q
 EOF
 
-E2FSCK_TIME=200704102100
+E2FSCK_TIME=1176238800
 export E2FSCK_TIME
 
 . $cmd_dir/run_e2fsck