2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:53 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2009-05-28 17:04:15 +02:00
|
|
|
# FS QA Test No. 032
|
|
|
|
|
#
|
|
|
|
|
# cross check mkfs detection of foreign filesystems
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
|
2013-03-15 12:28:02 +00:00
|
|
|
rm -f $seqres.full
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
2013-03-13 16:01:00 +00:00
|
|
|
_supported_fs xfs btrfs
|
2004-06-15 07:32:36 +00:00
|
|
|
_supported_os Linux
|
|
|
|
|
|
2014-10-14 22:59:39 +11:00
|
|
|
_require_scratch_nocheck
|
2013-03-15 11:53:21 +00:00
|
|
|
_require_no_large_scratch_dev
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2013-03-13 16:01:00 +00:00
|
|
|
# mkfs.btrfs did not have overwrite detection at first
|
|
|
|
|
if [ "$FSTYP" == "btrfs" ]; then
|
|
|
|
|
grep -q 'force overwrite' `echo $MKFS_BTRFS_PROG | awk '{print $1}'` || \
|
|
|
|
|
_notrun "Installed mkfs.btrfs does not support -f option"
|
|
|
|
|
fi
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "Silence is golden."
|
2015-02-12 14:11:04 +11:00
|
|
|
for fs in `echo ${MKFS_PROG}.* | sed -e "s:${MKFS_PROG}.::g"`
|
2001-01-15 05:01:19 +00:00
|
|
|
do
|
|
|
|
|
preop="" # for special input needs
|
|
|
|
|
preargs="" # for any special pre-device options
|
|
|
|
|
postargs="" # for any special post-device options
|
|
|
|
|
|
2005-07-08 15:05:17 +00:00
|
|
|
# minix, msdos and vfat mkfs fails for large devices, restrict to 2000 blocks
|
2003-05-14 05:25:31 +00:00
|
|
|
[ $fs = minix ] && postargs=2000
|
|
|
|
|
[ $fs = msdos ] && postargs=2000
|
2005-07-08 15:05:17 +00:00
|
|
|
[ $fs = vfat ] && postargs=2000
|
2003-05-14 05:25:31 +00:00
|
|
|
# these folks prompt before writing
|
|
|
|
|
[ $fs = jfs ] && preop="echo Y |"
|
2008-11-20 14:23:38 +00:00
|
|
|
[ $fs = gfs ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
|
2010-01-15 11:59:11 -06:00
|
|
|
[ $fs = gfs2 ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
|
2008-05-29 17:01:09 +00:00
|
|
|
[ $fs = reiserfs ] && preop="echo y |" && preargs="-f"
|
2003-05-14 05:25:31 +00:00
|
|
|
# cramfs mkfs requires a directory argument
|
2013-03-13 16:01:00 +00:00
|
|
|
[ $fs = cramfs ] && preargs=/proc/fs
|
2008-11-26 02:43:44 +00:00
|
|
|
[ $fs = ext2 ] && preargs="-F"
|
|
|
|
|
[ $fs = ext3 ] && preargs="-F"
|
|
|
|
|
[ $fs = ext4 ] && preargs="-F"
|
|
|
|
|
[ $fs = ext4dev ] && preargs="-F"
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# overwite the first few Kb - should blow away superblocks
|
|
|
|
|
src/devzero -n 20 $SCRATCH_DEV >/dev/null
|
|
|
|
|
|
|
|
|
|
# create a filesystem of this type
|
2013-03-15 12:28:02 +00:00
|
|
|
echo "=== Creating $fs filesystem..." >>$seqres.full
|
|
|
|
|
echo " ( $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs )" >>$seqres.full
|
|
|
|
|
eval $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs >>$seqres.full 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2011-06-16 20:01:12 +02:00
|
|
|
if [ $? -eq 0 ] ; then
|
|
|
|
|
# next, ensure we don't overwrite it
|
2013-03-15 12:28:02 +00:00
|
|
|
echo "=== Attempting $FSTYP overwrite of $fs..." >>$seqres.full
|
|
|
|
|
${MKFS_PROG}.$FSTYP $SCRATCH_DEV >>$seqres.full 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2011-06-16 20:01:12 +02:00
|
|
|
[ $? -eq 0 ] && echo "Failed - overwrote fs type ${fs}!"
|
|
|
|
|
else
|
2013-03-15 12:28:02 +00:00
|
|
|
echo "mkfs of type ${fs} failed" >>$seqres.full
|
2011-06-16 20:01:12 +02:00
|
|
|
fi
|
2001-01-15 05:01:19 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|