3 # Routines for fuzzing and scrubbing a filesystem.
5 #-----------------------------------------------------------------------
6 # Copyright (c) 2017 Oracle. All Rights Reserved.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 #-----------------------------------------------------------------------
23 # Modify various files after a fuzzing operation
24 _scratch_fuzz_modify() {
27 test -z "${nr}" && nr=50000
28 echo "+++ touch ${nr} files"
29 blk_sz=$(stat -f -c '%s' ${SCRATCH_MNT})
30 $XFS_IO_PROG -f -c "pwrite -S 0x63 0 ${blk_sz}" "/tmp/afile" > /dev/null
32 find "${SCRATCH_MNT}/" -type f 2> /dev/null | head -n "${nr}" | while read f; do
33 setfattr -n "user.date" -v "${date}" "$f"
34 cat "/tmp/afile" >> "$f"
40 echo "+++ create files"
41 mkdir -p "${SCRATCH_MNT}/test.moo"
42 $XFS_IO_PROG -f -c 'pwrite -S 0x80 0 65536' "${SCRATCH_MNT}/test.moo/urk"
45 echo "+++ remove files"
46 rm -rf "${SCRATCH_MNT}/test.moo"
49 # Try to access files after fuzzing
50 _scratch_fuzz_test() {
51 echo "+++ ls -laR" >> $seqres.full
52 ls -laR "${SCRATCH_MNT}/test.1/" >/dev/null 2>&1
54 echo "+++ cat files" >> $seqres.full
55 (find "${SCRATCH_MNT}/test.1/" -type f -size -1048576k -print0 | xargs -0 cat) >/dev/null 2>&1
58 # Do we have an online scrub program?
62 test -x "$XFS_SCRUB_PROG" || _notrun "xfs_scrub not found"
65 _notrun "No online scrub program for ${FSTYP}."
70 # Scrub the scratch filesystem metadata (online)
73 "xfs"|"ext4"|"ext3"|"ext2")
74 $XFS_SCRUB_PROG -d -T -v "$@" $SCRATCH_MNT
77 _fail "No online scrub program for ${FSTYP}."