• 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 > $EXP
11else
12	EXP=$test_dir/expect
13fi
14
15cat > $TMPFILE.conf << ENDL
16[fs_types]
17ext4 = {
18	cluster_size = 8192
19        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
20        blocksize = 1024
21        inode_size = 256
22        inode_ratio = 16384
23}
24ENDL
25MKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O bigalloc -T ext4 $TMPFILE 65536 > $OUT.new 2>&1
26rm -f $TMPFILE.conf
27
28$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
29status=$?
30echo Exit status is $status >> $OUT.new
31
32echo "debugfs write files" >> $OUT.new
33make_file() {
34	name="$1"
35	start="$2"
36	flag="$3"
37
38	cat << ENDL
39write /dev/null $name
40sif /$name size 40960
41eo /$name
42set_bmap $flag 10 $((start + 10))
43set_bmap $flag 13 $((start + 13))
44set_bmap $flag 26 $((start + 26))
45set_bmap $flag 29 $((start + 29))
46ec
47sif /$name blocks 32
48setb $((start + 10))
49setb $((start + 13))
50setb $((start + 26))
51setb $((start + 29))
52ENDL
53}
54
55#Files we create:
56# a: fallocate a 40k file
57# b*: falloc sparse file starting at b*
58# c*: falloc spare file ending at c*
59# d: midcluster to midcluster, surrounding sparse
60# e: partial middle cluster alloc
61# f: one big file
62# g*: falloc sparse init file starting at g*
63# h*: falloc sparse init file ending at h*
64# i: midcluster to midcluster, surrounding sparse init
65# j: partial middle cluster alloc
66# k: one big init file
67base=5000
68cat > $TMPFILE.cmd << ENDL
69write /dev/null a
70sif /a size 40960
71fallocate /a 0 39
72ENDL
73echo "ex /a" >> $TMPFILE.cmd2
74
75make_file sample $base --uninit >> $TMPFILE.cmd
76echo "ex /sample" >> $TMPFILE.cmd2
77base=10000
78
79for i in 8 9 10 11 12 13 14 15; do
80	make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd
81	echo "fallocate /b$i $i 39" >> $TMPFILE.cmd
82	echo "ex /b$i" >> $TMPFILE.cmd2
83done
84
85for i in 24 25 26 27 28 29 30 31; do
86	make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd
87	echo "fallocate /c$i 0 $i" >> $TMPFILE.cmd
88	echo "ex /c$i" >> $TMPFILE.cmd2
89done
90
91make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd
92echo "fallocate /d 4 35" >> $TMPFILE.cmd
93echo "ex /d" >> $TMPFILE.cmd2
94
95make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd
96echo "fallocate /e 19 20" >> $TMPFILE.cmd
97echo "ex /e" >> $TMPFILE.cmd2
98
99cat >> $TMPFILE.cmd << ENDL
100write /dev/null f
101sif /f size 1024
102eo /f
103set_bmap --uninit 0 9000
104ec
105sif /f blocks 16
106setb 9000
107fallocate /f 0 8999
108ENDL
109echo "ex /f" >> $TMPFILE.cmd2
110
111# Now do it again, but with initialized blocks
112base=20000
113for i in 8 9 10 11 12 13 14 15; do
114	make_file g$i $(($base + (40 * ($i - 8)))) >> $TMPFILE.cmd
115	echo "fallocate /g$i $i 39" >> $TMPFILE.cmd
116	echo "ex /g$i" >> $TMPFILE.cmd2
117done
118
119for i in 24 25 26 27 28 29 30 31; do
120	make_file h$i $(($base + 320 + (40 * ($i - 24)))) >> $TMPFILE.cmd
121	echo "fallocate /h$i 0 $i" >> $TMPFILE.cmd
122	echo "ex /h$i" >> $TMPFILE.cmd2
123done
124
125make_file i $(($base + 640)) >> $TMPFILE.cmd
126echo "fallocate /i 4 35" >> $TMPFILE.cmd
127echo "ex /i" >> $TMPFILE.cmd2
128
129make_file j $(($base + 680)) >> $TMPFILE.cmd
130echo "fallocate /j 19 20" >> $TMPFILE.cmd
131echo "ex /j" >> $TMPFILE.cmd2
132
133cat >> $TMPFILE.cmd << ENDL
134write /dev/null k
135sif /k size 1024
136eo /k
137set_bmap 0 19000
138ec
139sif /k blocks 16
140setb 19000
141fallocate /k 0 8999
142sif /k size 9216000
143ENDL
144echo "ex /k" >> $TMPFILE.cmd2
145
146$DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
147$DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
148
149$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
150status=$?
151echo Exit status is $status >> $OUT.new
152
153sed -f $cmd_dir/filter.sed $OUT.new > $OUT
154rm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new
155
156cmp -s $OUT $EXP
157status=$?
158
159if [ "$status" = 0 ] ; then
160	echo "$test_name: $test_description: ok"
161	touch $test_name.ok
162else
163	echo "$test_name: $test_description: failed"
164	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
165fi
166rm -f $EXP
167
168unset IMAGE FSCK_OPT OUT EXP
169