diff options
author | Theodore Ts'o <tytso@mit.edu> | 2024-04-17 23:47:02 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2024-04-17 23:47:02 -0400 |
commit | 5b599a325c1af94111940c14d888ade937f29d19 (patch) | |
tree | f7839a08dbfd48ff13cce0d81c842a1b1164c4a5 | |
parent | b53ce7848c2ed2cf4acf2ba9384e96129bc89d25 (diff) | |
download | e2fsprogs-5b599a325c1af94111940c14d888ade937f29d19.tar.gz |
Fix 32-bit build and test failures
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>
-rw-r--r-- | lib/ext2fs/ext2fs.h | 16 | ||||
-rw-r--r-- | tests/f_desc_size_bad/script | 4 | ||||
-rw-r--r-- | tests/f_dup4/script | 2 | ||||
-rw-r--r-- | tests/f_itable_collision/expect.1 | 10 | ||||
-rwxr-xr-x | tests/f_itable_collision/script | 2 | ||||
-rw-r--r-- | tests/f_uninit_last_uninit/script | 2 |
6 files changed, 25 insertions, 11 deletions
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index e04355134..9ecbb50ba 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -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) diff --git a/tests/f_desc_size_bad/script b/tests/f_desc_size_bad/script index ae2962770..40852c9f2 100644 --- a/tests/f_desc_size_bad/script +++ b/tests/f_desc_size_bad/script @@ -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 diff --git a/tests/f_dup4/script b/tests/f_dup4/script index aec862d1f..94db73ac6 100644 --- a/tests/f_dup4/script +++ b/tests/f_dup4/script @@ -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 diff --git a/tests/f_itable_collision/expect.1 b/tests/f_itable_collision/expect.1 index 01c85d4d2..fbab3238f 100644 --- a/tests/f_itable_collision/expect.1 +++ b/tests/f_itable_collision/expect.1 @@ -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 diff --git a/tests/f_itable_collision/script b/tests/f_itable_collision/script index 66abd9022..9d76c2389 100755 --- a/tests/f_itable_collision/script +++ b/tests/f_itable_collision/script @@ -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 diff --git a/tests/f_uninit_last_uninit/script b/tests/f_uninit_last_uninit/script index 53105a417..d0930b8a9 100644 --- a/tests/f_uninit_last_uninit/script +++ b/tests/f_uninit_last_uninit/script @@ -17,7 +17,7 @@ set_bg 1 checksum calc q EOF -E2FSCK_TIME=200704102100 +E2FSCK_TIME=1176238800 export E2FSCK_TIME . $cmd_dir/run_e2fsck |