• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if ! test -x $DEBUGFS_EXE; then
2	echo "$test_name: $test_description: skipped (no debugfs)"
3	return 0
4fi
5
6FSCK_OPT=-fy
7OUT=$test_name.log
8if [ -f $test_dir/expect.gz ]; then
9	EXP=$test_name.tmp
10	gunzip < $test_dir/expect.gz > $EXP1
11else
12	EXP=$test_dir/expect
13fi
14
15cat > $TMPFILE.conf << ENDL
16[fs_types]
17ext4 = {
18        base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr,^has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit
19        blocksize = 1024
20        inode_size = 256
21        inode_ratio = 16384
22}
23ENDL
24MKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O ^bigalloc -T ext4 $TMPFILE 65536 > $OUT.new 2>&1
25rm -f $TMPFILE.conf
26
27$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
28status=$?
29echo Exit status is $status >> $OUT.new
30
31echo "debugfs write files" >> $OUT.new
32make_file() {
33	name="$1"
34	start="$2"
35	flag="$3"
36
37	cat << ENDL
38write /dev/null $name
39fallocate /$name 0 39
40punch /$name 10 10
41punch /$name 13 13
42punch /$name 26 26
43punch /$name 29 29
44ENDL
45}
46
47#Files we create:
48# a: punch a 40k file
49# b*: punch sparse file starting at b*
50# c*: punch spare file ending at c*
51# d: midcluster to midcluster, surrounding sparse
52# e: partial middle cluster alloc
53# f: one big file
54base=5000
55cat > $TMPFILE.cmd << ENDL
56write /dev/null a
57fallocate /a 0 39
58punch /a 0 39
59ENDL
60echo "ex /a" >> $TMPFILE.cmd2
61
62make_file sample $base --uninit >> $TMPFILE.cmd
63echo "ex /sample" >> $TMPFILE.cmd2
64base=10000
65
66for i in 8 9 10 11 12 13 14 15; do
67	make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd
68	echo "punch /b$i $i 39" >> $TMPFILE.cmd
69	echo "ex /b$i" >> $TMPFILE.cmd2
70done
71
72for i in 24 25 26 27 28 29 30 31; do
73	make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd
74	echo "punch /c$i 0 $i" >> $TMPFILE.cmd
75	echo "ex /c$i" >> $TMPFILE.cmd2
76done
77
78make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd
79echo "punch /d 4 35" >> $TMPFILE.cmd
80echo "ex /d" >> $TMPFILE.cmd2
81
82make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd
83echo "punch /e 19 20" >> $TMPFILE.cmd
84echo "ex /e" >> $TMPFILE.cmd2
85
86cat >> $TMPFILE.cmd << ENDL
87write /dev/null f
88sif /f size 1024
89eo /f
90set_bmap --uninit 0 9000
91ec
92sif /f blocks 2
93setb 9000
94fallocate /f 0 8999
95punch /f 1 8998
96ENDL
97echo "ex /f" >> $TMPFILE.cmd2
98
99$DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
100$DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
101
102$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
103status=$?
104echo Exit status is $status >> $OUT.new
105sed -f $cmd_dir/filter.sed $OUT.new > $OUT
106rm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new
107
108cmp -s $OUT $EXP
109status=$?
110
111if [ "$status" = 0 ] ; then
112	echo "$test_name: $test_description: ok"
113	touch $test_name.ok
114else
115	echo "$test_name: $test_description: failed"
116	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
117	rm -f $test_name.tmp
118fi
119
120unset IMAGE FSCK_OPT OUT EXP
121