common/xfs: refactor commands to select a particular xfs backing device
[xfstests-dev.git] / tests / xfs / 045
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 045
6 #
7 # test mount of two FSes with identical UUID and mount with unknown option
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21
22 _get_existing_uuid()
23 {
24         _test_xfs_db -r -c "uuid" | $AWK_PROG '/^UUID/ { print $3 }'
25 }
26
27 # real QA test starts here
28 _supported_fs xfs
29
30 _require_test
31 _require_scratch_nocheck
32
33 echo "*** get uuid"
34 uuid=`_get_existing_uuid`
35
36 # We can only change the UUID on a v4 filesystem. Revist this when/if UUIDs
37 # canbe changed on v5 filesystems.
38 echo "*** mkfs"
39 if ! _scratch_mkfs_xfs -m crc=0 >$tmp.out 2>&1
40 then
41     cat $tmp.out
42     echo "!!! failed to mkfs on $SCRATCH_DEV"
43     exit
44 fi
45
46 echo "*** mount fs with bad mount option (expect failure)"
47 if _try_scratch_mount -o foobar >$tmp.out 2>&1
48 then
49     cat $tmp.out
50     echo "!!! mount succeeded (expecting failure)"
51     exit
52 fi
53
54 echo "*** duplicate uuid"
55 xfs_db -x -c "uuid $uuid" `_scratch_xfs_db_options` >/dev/null
56
57 echo "*** mount fs with duplicate uuid (expect failure)"
58 if _try_scratch_mount >$tmp.out 2>&1
59 then
60     cat $tmp.out
61     echo "!!! mount succeeded (expecting failure)"
62     exit
63 fi
64
65 echo "*** ok!"
66 # success, all done
67 status=0
68 exit