2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # cross check mkfs detection of foreign filesystems
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
19 # get standard environment, filters and checks
23 # real QA test starts here
24 _supported_fs xfs btrfs
27 _require_scratch_nocheck
28 _require_no_large_scratch_dev
30 # mkfs.btrfs did not have overwrite detection at first
31 if [ "$FSTYP" == "btrfs" ]; then
32 grep -q 'force overwrite' `echo $MKFS_BTRFS_PROG | awk '{print $1}'` || \
33 _notrun "Installed mkfs.btrfs does not support -f option"
36 echo "Silence is golden."
37 for fs in `echo ${MKFS_PROG}.* | sed -e "s:${MKFS_PROG}.::g"`
39 preop="" # for special input needs
40 preargs="" # for any special pre-device options
41 postargs="" # for any special post-device options
43 # minix, msdos and vfat mkfs fails for large devices, restrict to 2000 blocks
44 [ $fs = minix ] && postargs=2000
45 [ $fs = msdos ] && postargs=2000
46 [ $fs = vfat ] && postargs=2000
47 # these folks prompt before writing
48 [ $fs = jfs ] && preop="echo Y |"
49 [ $fs = gfs ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
50 [ $fs = gfs2 ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
51 [ $fs = reiserfs ] && preop="echo y |" && preargs="-f"
52 # cramfs mkfs requires a directory argument
53 [ $fs = cramfs ] && preargs=/proc/fs
54 [ $fs = ext2 ] && preargs="-F"
55 [ $fs = ext3 ] && preargs="-F"
56 [ $fs = ext4 ] && preargs="-F"
57 [ $fs = ext4dev ] && preargs="-F"
59 # overwite the first few Kb - should blow away superblocks
60 src/devzero -n 20 $SCRATCH_DEV >/dev/null
62 # create a filesystem of this type
63 echo "=== Creating $fs filesystem..." >>$seqres.full
64 echo " ( $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs )" >>$seqres.full
65 eval $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs >>$seqres.full 2>&1
67 if [ $? -eq 0 ] ; then
68 # next, ensure we don't overwrite it
69 echo "=== Attempting $FSTYP overwrite of $fs..." >>$seqres.full
70 ${MKFS_PROG}.$FSTYP $SCRATCH_DEV >>$seqres.full 2>&1
72 [ $? -eq 0 ] && echo "Failed - overwrote fs type ${fs}!"
74 echo "mkfs of type ${fs} failed" >>$seqres.full