4 # cross check mkfs detection of foreign filesystems
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35 # get standard environment, filters and checks
39 # real QA test starts here
40 _supported_fs xfs btrfs
44 _require_no_large_scratch_dev
46 # mkfs.btrfs did not have overwrite detection at first
47 if [ "$FSTYP" == "btrfs" ]; then
48 grep -q 'force overwrite' `echo $MKFS_BTRFS_PROG | awk '{print $1}'` || \
49 _notrun "Installed mkfs.btrfs does not support -f option"
52 echo "Silence is golden."
53 for fs in `echo ${MKFS_PROG}.* | sed -e 's/.sbin.mkfs.//g'`
55 preop="" # for special input needs
56 preargs="" # for any special pre-device options
57 postargs="" # for any special post-device options
59 # minix, msdos and vfat mkfs fails for large devices, restrict to 2000 blocks
60 [ $fs = minix ] && postargs=2000
61 [ $fs = msdos ] && postargs=2000
62 [ $fs = vfat ] && postargs=2000
63 # these folks prompt before writing
64 [ $fs = jfs ] && preop="echo Y |"
65 [ $fs = gfs ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
66 [ $fs = gfs2 ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
67 [ $fs = reiserfs ] && preop="echo y |" && preargs="-f"
68 # cramfs mkfs requires a directory argument
69 [ $fs = cramfs ] && preargs=/proc/fs
70 [ $fs = ext2 ] && preargs="-F"
71 [ $fs = ext3 ] && preargs="-F"
72 [ $fs = ext4 ] && preargs="-F"
73 [ $fs = ext4dev ] && preargs="-F"
75 # overwite the first few Kb - should blow away superblocks
76 src/devzero -n 20 $SCRATCH_DEV >/dev/null
78 # create a filesystem of this type
79 echo "=== Creating $fs filesystem..." >>$seqres.full
80 echo " ( $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs )" >>$seqres.full
81 eval $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs >>$seqres.full 2>&1
83 if [ $? -eq 0 ] ; then
84 # next, ensure we don't overwrite it
85 echo "=== Attempting $FSTYP overwrite of $fs..." >>$seqres.full
86 ${MKFS_PROG}.$FSTYP $SCRATCH_DEV >>$seqres.full 2>&1
88 [ $? -eq 0 ] && echo "Failed - overwrote fs type ${fs}!"
90 echo "mkfs of type ${fs} failed" >>$seqres.full