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
26 _require_scratch_nocheck
27 _require_no_large_scratch_dev
29 # mkfs.btrfs did not have overwrite detection at first
30 if [ "$FSTYP" == "btrfs" ]; then
31 grep -q 'force overwrite' `echo $MKFS_BTRFS_PROG | awk '{print $1}'` || \
32 _notrun "Installed mkfs.btrfs does not support -f option"
35 echo "Silence is golden."
36 for fs in `echo ${MKFS_PROG}.* | sed -e "s:${MKFS_PROG}.::g"`
38 preop="" # for special input needs
39 preargs="" # for any special pre-device options
40 postargs="" # for any special post-device options
42 # minix, msdos and vfat mkfs fails for large devices, restrict to 2000 blocks
43 [ $fs = minix ] && postargs=2000
44 [ $fs = msdos ] && postargs=2000
45 [ $fs = vfat ] && postargs=2000
46 # these folks prompt before writing
47 [ $fs = jfs ] && preop="echo Y |"
48 [ $fs = gfs ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
49 [ $fs = gfs2 ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
50 [ $fs = reiserfs ] && preop="echo y |" && preargs="-f"
51 [ $fs = reiser4 ] && 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"
58 # jffs2 mkfs requires '-r $directory' and '-o $image'
59 [ $fs = jffs2 ] && preargs="-r /proc/fs -o"
61 # overwite the first few Kb - should blow away superblocks
62 $here/src/devzero -n 20 $SCRATCH_DEV >/dev/null
64 # create a filesystem of this type
65 echo "=== Creating $fs filesystem..." >>$seqres.full
66 echo " ( $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs )" >>$seqres.full
67 eval $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs >>$seqres.full 2>&1
69 if [ $? -eq 0 ] ; then
70 # next, ensure we don't overwrite it
71 # jffs2 mkfs doesn't check overwrite case
72 [ $fs = jffs2 ] && continue
74 echo "=== Attempting $FSTYP overwrite of $fs..." >>$seqres.full
75 ${MKFS_PROG} -t $FSTYP $SCRATCH_DEV >>$seqres.full 2>&1
77 [ $? -eq 0 ] && echo "Failed - overwrote fs type ${fs}!"
79 echo "mkfs of type ${fs} failed" >>$seqres.full