2 TMPDIR=${TMPDIR:-"/tmp"}
9 SRC=$TMPDIR/$test_name.tmp
11 BASE=$SRC/$SUB/$(yes | tr -d '\n' | dd bs=$NAMELEN count=1 2> /dev/null)
12 TMPFILE=${TMPFILE:-"$TMPDIR/image"}
17 # calculate the number of files needed to create the directory extent tree
18 # deep enough to exceed the in-inode index and spill into an index block.
20 # dirents per block * extents per block * (index blocks > i_blocks)
21 NUM=$(((BSIZE / (NAMELEN + 8)) * (BSIZE / 12) * 2))
22 # Create source files. Unfortunately hard links will be copied as links,
23 # and blocks with only NULs will be turned into holes.
24 if [ ! -f $BASE.1 ]; then
25 for N in $(seq $NUM); do
30 # make filesystem with enough inodes and blocks to hold all the test files
33 echo "mke2fs -b $BSIZE -O dir_index,extent -E no_copy_xattrs -d$SRC -N$NUM $TMPFILE $NUM" >> $OUT
34 $MKE2FS -b $BSIZE -O dir_index,extent -E no_copy_xattrs -d$SRC -N$NUM $TMPFILE $NUM >> $OUT 2>&1
37 # Run e2fsck to convert dir to htree before deleting the files, as mke2fs
38 # doesn't do this. Run second e2fsck to verify there is no corruption yet.
40 EXP1=$test_dir/expect.pre.1
41 EXP2=$test_dir/expect.pre.2
42 OUT1=$test_name.pre.1.log
43 OUT2=$test_name.pre.2.log
44 DESCRIPTION="$(cat $test_dir/name) setup"
48 # generate a list of filenames for debugfs to delete, one from each leaf block
49 DELETE_LIST=$TMPDIR/delete.$$
50 $DEBUGFS -c -R "htree subdir" $TMPFILE 2>> $OUT |
51 grep -A2 "Reading directory block" |
52 awk '/yyyyy/ { print "rm '$SUB'/"$4 }' > $DELETE_LIST
53 $DEBUGFS -w -f $DELETE_LIST $TMPFILE >> $OUT 2>&1