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