840b32d45657d4c6ee482d26f07eb612a9576c2d
[xfstests-dev.git] / 032
1 #! /bin/sh
2 # FS QA Test No. 032
3 #
4 # cross check mkfs detection of foreign filesystems
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=nathans@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20 rm -f $seq.full
21
22 # get standard environment, filters and checks
23 . ./common.rc
24 . ./common.filter
25
26 # real QA test starts here
27 _supported_fs xfs
28 _supported_os Linux
29
30 _require_nobigloopfs
31 _require_scratch
32
33 echo "Silence is golden."
34 for fs in `echo /sbin/mkfs.* | sed -e 's/.sbin.mkfs.//g'`
35 do
36         preop=""        # for special input needs
37         preargs=""      # for any special pre-device options
38         postargs=""     # for any special post-device options
39
40         # minix, msdos and vfat mkfs fails for large devices, restrict to 2000 blocks
41         [ $fs = minix ] && postargs=2000
42         [ $fs = msdos ] && postargs=2000
43         [ $fs = vfat ] && postargs=2000
44         # these folks prompt before writing
45         [ $fs = jfs ] && preop="echo Y |"
46         [ $fs = gfs ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
47         [ $fs = gfs2 ] && preop="echo y |"
48         [ $fs = reiserfs ] && preop="echo y |" && preargs="-f"
49         # cramfs mkfs requires a directory argument
50         [ $fs = cramfs ] && preargs=/proc/fs/xfs
51         [ $fs = ext2 ] && preargs="-F"
52         [ $fs = ext3 ] && preargs="-F"
53         [ $fs = ext4 ] && preargs="-F"
54         [ $fs = ext4dev ] && preargs="-F"
55
56         # overwite the first few Kb - should blow away superblocks
57         src/devzero -n 20 $SCRATCH_DEV >/dev/null
58
59         # create a filesystem of this type
60         echo "=== Creating $fs filesystem..." >>$seq.full
61         echo "    ( $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs )" >>$seq.full
62         eval $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs >>$seq.full 2>&1
63
64         # next, ensure we don't overwrite it
65         echo "=== Attempting XFS overwrite of $fs..." >>$seq.full
66         /sbin/mkfs.xfs $SCRATCH_DEV >>$seq.full 2>&1
67
68         [ $? -eq 0 ] && echo "Failed - overwrote fs type ${fs}!"
69 done
70
71 # success, all done
72 status=0
73 exit