1test_description="create fs image from dir, then minimize it" 2if ! test -x $RESIZE2FS_EXE -o ! -x $DEBUGFS_EXE; then 3 echo "$test_name: $test_description: skipped (no debugfs/resize2fs)" 4 return 0 5fi 6 7MKFS_DIR=$TMPFILE.dir 8OUT=$test_name.log 9EXP=$test_dir/expect 10 11rm -rf $MKFS_DIR 12mkdir -p $MKFS_DIR 13mkdir $MKFS_DIR/dir 14mkdir $MKFS_DIR/emptydir 15dd if=/dev/zero of=$MKFS_DIR/bigzerofile bs=1 count=1 seek=1073741824 2> /dev/null 16echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null 17echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=524288 conv=notrunc 2> /dev/null 18echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1048576 conv=notrunc 2> /dev/null 19echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=536870912 conv=notrunc 2> /dev/null 20echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1073741824 conv=notrunc 2> /dev/null 21dd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile 22touch $MKFS_DIR/emptyfile 23echo "Test me" > $MKFS_DIR/dir/file 24 25echo "create fs" > $OUT 26$MKE2FS -q -F -o Linux -T ext4 -O ^has_journal,metadata_csum,64bit,^resize_inode -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 >> $OUT 2>&1 27 28$DUMPE2FS $TMPFILE >> $OUT 2>&1 29cat > $TMPFILE.cmd << ENDL 30stat /emptyfile 31stat /bigfile 32stat /sparsefile 33stat /bigzerofile 34stat /fifo 35stat /emptydir 36stat /dir 37stat /dir/file 38ENDL 39$DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | egrep "(stat|Size:|Type:)" >> $OUT 40 41cat > $TMPFILE.cmd << ENDL 42ex /emptyfile 43ex /bigfile 44ex /sparsefile 45ex /bigzerofile 46ex /dir 47ex /dir/file 48ENDL 49$DEBUGFS -f $TMPFILE.cmd $TMPFILE >> $OUT 2>&1 50$FSCK -f -n $TMPFILE >> $OUT 2>&1 51 52echo "minify fs" >> $OUT 53$TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1 54$RESIZE2FS -M $TMPFILE >> $OUT 2>&1 55$DUMPE2FS $TMPFILE >> $OUT 2>&1 56$FSCK -f -n $TMPFILE >> $OUT 2>&1 57 58echo "minify fs (2)" >> $OUT 59$TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1 60$RESIZE2FS -M $TMPFILE >> $OUT 2>&1 61$DUMPE2FS $TMPFILE >> $OUT 2>&1 62$FSCK -f -n $TMPFILE >> $OUT 2>&1 63 64sed -f $cmd_dir/filter.sed -f $test_dir/output.sed -e "s;$TMPFILE;test.img;" < $OUT > $OUT.tmp 65mv $OUT.tmp $OUT 66 67# Do the verification 68cmp -s $OUT $EXP 69status=$? 70 71if [ "$status" = 0 ] ; then 72 echo "$test_name: $test_description: ok" 73 touch $test_name.ok 74else 75 echo "$test_name: $test_description: failed" 76 diff $DIFF_OPTS $EXP $OUT > $test_name.failed 77fi 78 79rm -rf $TMPFILE.cmd $MKFS_DIR 80unset MKFS_DIR OUT EXP 81