1 if ! test -x $DEBUGFS_EXE; then
2 echo "$test_name: $test_description: skipped (no debugfs)"
7 TIMESTAMPS=$test_name.timestamps.log
11 create_file_with_xtime_and_extra() {
16 echo "write /dev/null $name"
17 for xtime in atime ctime mtime crtime; do
18 echo "set_inode_field $name $xtime @$time"
19 echo "set_inode_field $name ${xtime}_extra $extra"
21 } | $DEBUGFS -w $TMPFILE >> $OUT 2>&1
24 get_file_xtime_and_extra() {
26 echo "times for $name =" >> $TIMESTAMPS
27 $DEBUGFS -R "stat $name" $TMPFILE 2>&1 | egrep '^( a| c| m|cr)time:' |
28 sed 's/ --.*//' >> $TIMESTAMPS
31 rm -f $OUT $TIMESTAMPS
33 # create an empty ext4 filesystem with 256-byte inodes for testing
35 echo mkfs.ext4 -b 1024 -q -I 256 $TMPFILE 5000 >> $OUT
36 $MKE2FS -t ext4 -b 1024 -q -I 256 -F $TMPFILE 5000 >> $OUT 2>&1
38 # this is a pre-1970 file encoded with the old encoding.
39 # fsck should repair this
40 create_file_with_xtime_and_extra year-1909 -1907928000 3
42 # these are all already encoded correctly
43 create_file_with_xtime_and_extra year-1979 299592000 0
44 create_file_with_xtime_and_extra year-2039 2191752000 1
45 create_file_with_xtime_and_extra year-2139 5345352000 1
47 # confirm that the xtime is wrong on the pre-1970 file
48 get_file_xtime_and_extra year-1909
50 # and confirm that it is right on the remaining files
51 get_file_xtime_and_extra year-1979
52 get_file_xtime_and_extra year-2039
53 get_file_xtime_and_extra year-2139
55 # before we repair the filesystem, save off a copy so that
58 cp -a $TMPFILE $TMPFILE.sav
60 # repair the filesystem
61 E2FSCK_TIME=1386393539 $FSCK $FSCK_OPT $TMPFILE >> $OUT 2>&1
63 # check that the dates and xtime_extra on the file is now correct
64 get_file_xtime_and_extra year-1909
66 # check that the remaining dates have not been altered
67 get_file_xtime_and_extra year-1979
68 get_file_xtime_and_extra year-2039
69 get_file_xtime_and_extra year-2139
71 if test $SIZEOF_TIME_T -gt 4
73 # now we need to check that after the year 2242, e2fsck does not
74 # modify dates with extra_xtime=3
76 # restore the unrepaired filesystem
77 mv $TMPFILE.sav $TMPFILE
80 E2FSCK_TIME=9270393539 $FSCK $FSCK_OPT $TMPFILE >> $OUT 2>&1
82 # check that the 1909 file is unaltered (i.e. it has a post-2378 date)
83 get_file_xtime_and_extra year-1909
86 cat << EOF >> $TIMESTAMPS
88 ctime: 0x8e475440:00000003
89 atime: 0x8e475440:00000003
90 mtime: 0x8e475440:00000003
91 crtime: 0x8e475440:00000003
95 cmp -s $TIMESTAMPS $EXP
98 if [ "$status" = 0 ]; then
99 echo "$test_name: $test_description: ok"
102 echo "$test_name: $test_description: failed"
103 diff $DIFF_OPTS $EXP $TIMESTAMPS > $test_name.failed
106 unset OUT TIMESTAMPS EXP FSCK_OPT