p = (char *) buf;
end = (char *) buf + fs->blocksize;
while (p < end-8) {
- dirent = (struct ext2_dir_entry_2 *) p;
+ dirent = (struct ext2_dir_entry *) p;
if (do_swap) {
dirent->inode = ext2fs_swab32(dirent->inode);
dirent->rec_len = ext2fs_swab16(dirent->rec_len);
rec_len = 8;
retval = EXT2_ET_DIR_CORRUPTED;
}
- dirent2 = dirent;
+ dirent2 = (struct ext2_dir_entry_2 *) dirent;
if ((dirent2->name_len +8) > dirent2->rec_len)
retval = EXT2_ET_DIR_CORRUPTED;
p += rec_len;
--- /dev/null
+debugfs load/dump test
+mke2fs -Fq ./test.img 512
+Exit status is 0
+debugfs -R ''write test.data test_data'' -w ./test.img
+Allocated inode: 12
+Exit status is 0
+e2fsck -yf -N test_filesys
+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
+test_filesys: 12/64 files (0.0% non-contiguous), 156/512 blocks
+Exit status is 0
+debugfs -R ''dump test_data test.verify'' ./test.img
+Exit status is 0
+cmp test.data test.verify
+Exit status is 0
--- /dev/null
+OUT=$test_name.log
+EXP=$test_dir/expect
+VERIFY_FSCK_OPT=-yf
+
+TEST_DATA=test.data
+VERIFY_DATA=test.verify
+
+echo "debugfs load/dump test" > $OUT
+
+dd if=/dev/zero of=$TMPFILE bs=1k count=512 >& /dev/null
+
+echo "mke2fs -Fq $TMPFILE 512" >> $OUT
+
+$MKE2FS -Fq $TMPFILE 512 >& /dev/null
+status=$?
+echo Exit status is $status >> $OUT
+
+dd if=$DEBUGFS of=$TEST_DATA bs=1k count=128 >& /dev/null
+echo "file fragment odd size" >> $TEST_DATA
+
+echo "debugfs -R ''write $TEST_DATA test_data'' -w $TMPFILE" > $OUT.new
+$DEBUGFS -R "write $TEST_DATA test_data" -w $TMPFILE >> $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -e '2d' $OUT.new >> $OUT
+
+echo e2fsck $VERIFY_FSCK_OPT -N test_filesys > $OUT.new
+$FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -e '2d' $OUT.new >> $OUT
+
+echo "debugfs -R ''dump test_data $VERIFY_DATA'' $TMPFILE" > $OUT.new
+$DEBUGFS -R "dump test_data $VERIFY_DATA" $TMPFILE >> $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -e '2d' $OUT.new >> $OUT
+
+echo "cmp $TEST_DATA $VERIFY_DATA" >> $OUT
+cmp $TEST_DATA $VERIFY_DATA >>$OUT
+status=$?
+echo Exit status is $status >> $OUT
+
+#
+# Do the verification
+#
+
+rm -f $test_name.ok $test_name.failed $VERIFY_DATA $TEST_DATA $TMPFILE
+cmp -s $OUT $EXP
+status=$?
+
+if [ "$status" = 0 ] ; then
+ echo "ok"
+ touch $test_name.ok
+else
+ echo "failed"
+ diff -c $EXP $OUT > $test_name.failed
+fi
+
+unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA
+