aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e2fsck/unix.c8
-rw-r--r--misc/filefrag.c5
-rw-r--r--tests/f_readonly_fsck/expect11
-rw-r--r--tests/f_readonly_fsck/image.gzbin0 -> 2538 bytes
-rw-r--r--tests/f_readonly_fsck/name1
-rw-r--r--tests/f_readonly_fsck/script46
-rw-r--r--tests/i_e2image/i_e2image.crc15
-rw-r--r--tests/i_e2image/i_e2image.md515
-rw-r--r--tests/i_e2image/script24
-rw-r--r--tests/u_mke2fs/script14
-rw-r--r--tests/u_tune2fs/script14
11 files changed, 107 insertions, 46 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index c1d5b62d..1a089a94 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1734,9 +1734,11 @@ no_journal:
}
e2fsck_write_bitmaps(ctx);
- pctx.errcode = ext2fs_flush(ctx->fs);
- if (pctx.errcode)
- fix_problem(ctx, PR_6_FLUSH_FILESYSTEM, &pctx);
+ if (fs->flags & EXT2_FLAG_DIRTY) {
+ pctx.errcode = ext2fs_flush(ctx->fs);
+ if (pctx.errcode)
+ fix_problem(ctx, PR_6_FLUSH_FILESYSTEM, &pctx);
+ }
pctx.errcode = io_channel_flush(ctx->fs->io);
if (pctx.errcode)
fix_problem(ctx, PR_6_IO_FLUSH, &pctx);
diff --git a/misc/filefrag.c b/misc/filefrag.c
index d71bf43e..c1a86840 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -329,16 +329,17 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
print_extent_info(&fm_ext, *num_extents - 1,
(last_block + 1) * st->st_blksize,
blk_shift, st);
- fm_ext.fe_logical = logical;
- fm_ext.fe_physical = block * st->st_blksize;
fm_ext.fe_length = 0;
(*num_extents)++;
} else if (last_block && (block != last_block + 1)) {
if (verbose)
printf("Discontinuity: Block %ld is at %lu (was "
"%lu)\n", i, block, last_block + 1);
+ fm_ext.fe_length = 0;
(*num_extents)++;
}
+ fm_ext.fe_logical = logical;
+ fm_ext.fe_physical = block * st->st_blksize;
fm_ext.fe_length += st->st_blksize;
last_block = block;
}
diff --git a/tests/f_readonly_fsck/expect b/tests/f_readonly_fsck/expect
new file mode 100644
index 00000000..994dfa47
--- /dev/null
+++ b/tests/f_readonly_fsck/expect
@@ -0,0 +1,11 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Free blocks count wrong (4294968254, counted=958).
+Fix? no
+
+test_filesys: 11/256 files (9.1% non-contiguous), 18446744069414585410/2048 blocks
+Exit status is 0
+crc did not change. 2466215161
diff --git a/tests/f_readonly_fsck/image.gz b/tests/f_readonly_fsck/image.gz
new file mode 100644
index 00000000..59f9cd91
--- /dev/null
+++ b/tests/f_readonly_fsck/image.gz
Binary files differ
diff --git a/tests/f_readonly_fsck/name b/tests/f_readonly_fsck/name
new file mode 100644
index 00000000..97ab428a
--- /dev/null
+++ b/tests/f_readonly_fsck/name
@@ -0,0 +1 @@
+ensure that a readonly check doesn't modify the fs
diff --git a/tests/f_readonly_fsck/script b/tests/f_readonly_fsck/script
new file mode 100644
index 00000000..d46c5a80
--- /dev/null
+++ b/tests/f_readonly_fsck/script
@@ -0,0 +1,46 @@
+FSCK_OPT=-fn
+OUT=$test_name.log
+if [ -f $test_dir/expect.gz ]; then
+ EXP=$test_name.tmp
+ gunzip < $test_dir/expect.gz > $EXP1
+else
+ EXP=$test_dir/expect
+fi
+
+cp /dev/null $OUT
+
+dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
+
+gzip -d < $test_dir/image.gz > $TMPFILE
+
+old="$($CRCSUM < $TMPFILE)"
+
+$FSCK $FSCK_OPT -N test_filesys $TMPFILE > $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
+rm -f $OUT.new
+
+new="$($CRCSUM < $TMPFILE)"
+
+if [ "${old}" != "${new}" ]; then
+ echo "ERROR: crc mismatch! ${old} ${new}" >> $OUT
+else
+ echo "crc did not change. ${old}" >> $OUT
+fi
+
+rm -f $TMPFILE
+
+cmp -s $OUT $EXP
+status=$?
+
+if [ "$status" = 0 ] ; then
+ echo "$test_name: $test_description: ok"
+ touch $test_name.ok
+else
+ echo "$test_name: $test_description: failed"
+ diff $DIFF_OPTS $EXP $OUT > $test_name.failed
+ rm -f $test_name.tmp
+fi
+
+unset IMAGE FSCK_OPT OUT EXP old new
diff --git a/tests/i_e2image/i_e2image.crc b/tests/i_e2image/i_e2image.crc
new file mode 100644
index 00000000..02a84644
--- /dev/null
+++ b/tests/i_e2image/i_e2image.crc
@@ -0,0 +1,15 @@
+i_e2image/image1024.orig
+2161078647 image1024.orig
+467277198 _image.raw
+2164212449 _image.qcow2
+467277198 _image.qcow2.raw
+i_e2image/image2048.orig
+672740642 image2048.orig
+3688408350 _image.raw
+3821412753 _image.qcow2
+3688408350 _image.qcow2.raw
+i_e2image/image4096.orig
+4077552412 image4096.orig
+4159471388 _image.raw
+636354894 _image.qcow2
+4159471388 _image.qcow2.raw
diff --git a/tests/i_e2image/i_e2image.md5 b/tests/i_e2image/i_e2image.md5
deleted file mode 100644
index f96e7214..00000000
--- a/tests/i_e2image/i_e2image.md5
+++ /dev/null
@@ -1,15 +0,0 @@
-i_e2image/image1024.orig
-d34914e0da07bdae80ab02288118fae2 image1024.orig
-bbef4e50d7237546c7d9c521d3df5b68 _image.raw
-1d4eb39452bed097dcd2c5bcd57180e6 _image.qcow2
-bbef4e50d7237546c7d9c521d3df5b68 _image.qcow2.raw
-i_e2image/image2048.orig
-aa9f702de181188f2a6d2c5158686c09 image2048.orig
-e6f8410d0690ef551bee0c2c0c642d8c _image.raw
-dbbd9aa97c6c946b9122586bbd2a325a _image.qcow2
-e6f8410d0690ef551bee0c2c0c642d8c _image.qcow2.raw
-i_e2image/image4096.orig
-1d3e7f15b2ce9ca07aa23c32951c5176 image4096.orig
-734119dd8f240a33704139f8cdd8127c _image.raw
-85fdbf5a8451b24b36ab82a02196deb9 _image.qcow2
-734119dd8f240a33704139f8cdd8127c _image.qcow2.raw
diff --git a/tests/i_e2image/script b/tests/i_e2image/script
index adf59a46..c5b06666 100644
--- a/tests/i_e2image/script
+++ b/tests/i_e2image/script
@@ -7,42 +7,42 @@ RAW_IMG=_image.raw
QCOW2_IMG=_image.qcow2
QCOW2_TO_RAW=_image.qcow2.raw
OUT=$test_name.log
-MD5=$SRCDIR/$test_name/$test_name.md5
-MD5_TMP=$test_name.md5.tmp
+CRC=$SRCDIR/$test_name/$test_name.crc
+CRC_TMP=$test_name.crc.tmp
-rm -f $test_name/_image.* $MD5_TMP $OUT >/dev/null 2>&1
+rm -f $test_name/_image.* $CRC_TMP $OUT >/dev/null 2>&1
(
for i in $ORIG_IMAGES; do
ORIG_IMG=$test_name/$i
- echo $ORIG_IMG >> $MD5_TMP
+ echo $ORIG_IMG >> $CRC_TMP
bunzip2 < $SRCDIR/$ORIG_IMG.bz2 > $i
- md5sum $i >> $MD5_TMP
+ echo "$($CRCSUM $i) $i" >> $CRC_TMP
rm -f $RAW_IMG
echo "e2image -r $ORIG_IMG $RAW_IMG"
$E2IMAGE -r $i $RAW_IMG
- md5sum $RAW_IMG >> $MD5_TMP
+ echo "$($CRCSUM $RAW_IMG) $RAW_IMG" >> $CRC_TMP
echo "e2image -Q $ORIG_IMG $QCOW2_IMG"
$E2IMAGE -Q $i $QCOW2_IMG
- md5sum $QCOW2_IMG >> $MD5_TMP
+ echo "$($CRCSUM $QCOW2_IMG) $QCOW2_IMG" >> $CRC_TMP
rm -f $QCOW2_TO_RAW
echo "e2image -r $QCOW2_IMG $QCOW2_TO_RAW"
$E2IMAGE -r $i $QCOW2_TO_RAW
- md5sum $QCOW2_TO_RAW >> $MD5_TMP
+ echo "$($CRCSUM $QCOW2_TO_RAW) $QCOW2_TO_RAW" >> $CRC_TMP
rm -f $i
done
) >> $OUT 2>&1
-echo "md5sums:" >> $OUT
-cat $MD5_TMP >> $OUT
+echo "checksum:" >> $OUT
+cat $CRC_TMP >> $OUT
echo "" >> $OUT
-diff $MD5 $MD5_TMP >> $OUT 2>&1
+diff $CRC $CRC_TMP >> $OUT 2>&1
if [ $? -eq 0 ]; then
echo "$test_name: $test_description: ok"
@@ -52,7 +52,7 @@ else
echo "$test_name: $test_description: failed"
fi
-rm -f _image.* $MD5_TMP >/dev/null 2>&1
+rm -f _image.* $CRC_TMP >/dev/null 2>&1
else #if test -x $E2IMAGE_EXE; then
echo "$test_name: $test_description: skipped"
diff --git a/tests/u_mke2fs/script b/tests/u_mke2fs/script
index fcf5eae9..d249ddd3 100644
--- a/tests/u_mke2fs/script
+++ b/tests/u_mke2fs/script
@@ -11,19 +11,19 @@ dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
echo mke2fs -q -F -o Linux -b 1024 test.img > $OUT
$MKE2FS -F -o Linux -I 128 -b 1024 $TMPFILE >> $OUT 2>&1
-md5=`md5sum $TMPFILE | cut -d " " -f 1`
-echo md5sum before mke2fs $md5 >> $OUT
+crc=`$CRCSUM $TMPFILE`
+echo $CRCSUM before mke2fs $crc >> $OUT
echo using mke2fs to test e2undo >> $OUT
$MKE2FS -q -F -o Linux -I 256 -O uninit_bg -E lazy_itable_init=1 -b 1024 $TMPFILE >> $OUT 2>&1
-new_md5=`md5sum $TMPFILE | cut -d " " -f 1`
-echo md5sum after mke2fs $new_md5 >> $OUT
+new_crc=`$CRCSUM $TMPFILE`
+echo $CRCSUM after mke2fs $new_crc >> $OUT
$E2UNDO_EXE $TDB_FILE $TMPFILE >> $OUT 2>&1
-new_md5=`md5sum $TMPFILE | cut -d " " -f 1`
-echo md5sum after e2undo $new_md5 >> $OUT
+new_crc=`$CRCSUM $TMPFILE`
+echo $CRCSUM after e2undo $new_crc >> $OUT
-if [ $md5 = $new_md5 ]; then
+if [ $crc = $new_crc ]; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
else
diff --git a/tests/u_tune2fs/script b/tests/u_tune2fs/script
index 4cc1e0c0..a443f5ae 100644
--- a/tests/u_tune2fs/script
+++ b/tests/u_tune2fs/script
@@ -11,19 +11,19 @@ dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
echo mke2fs -q -F -o Linux -b 1024 $TMPFILE > $OUT
$MKE2FS -q -F -o Linux -I 128 -b 1024 $TMPFILE >> $OUT 2>&1
-md5=`md5sum $TMPFILE | cut -d " " -f 1`
-echo md5sum before tune2fs $md5 >> $OUT
+crc=`$CRCSUM $TMPFILE`
+echo $CRCSUM before tune2fs $crc >> $OUT
echo using tune2fs to test e2undo >> $OUT
$TUNE2FS -I 256 $TMPFILE >> $OUT 2>&1
-new_md5=`md5sum $TMPFILE | cut -d " " -f 1`
-echo md5sum after tune2fs $new_md5 >> $OUT
+new_crc=`$CRCSUM $TMPFILE`
+echo $CRCSUM after tune2fs $new_crc >> $OUT
$E2UNDO_EXE $TDB_FILE $TMPFILE >> $OUT 2>&1
-new_md5=`md5sum $TMPFILE | cut -d " " -f 1`
-echo md5sum after e2undo $new_md5 >> $OUT
+new_crc=`$CRCSUM $TMPFILE`
+echo $CRCSUM after e2undo $new_crc >> $OUT
-if [ $md5 = $new_md5 ]; then
+if [ $crc = $new_crc ]; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
else