xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / xfs / 261
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 SGI.  All Rights Reserved.
4 #
5 # FS QA Test No. 261
6 #
7 # This test exercises an issue in libxcmd where a problem with any
8 # mount point or project quota directory causes the program to exit
9 # complete.  The effect of this is that one cannot operate on any
10 # directory, even if the problem directory is completely unrelated
11 # to the directory one wants to operate on.
12 #
13 seq=$(basename $0)
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by ${seq}"
16
17 here=$(pwd)
18
19 tmp=/tmp/$$
20 my_mtab=${tmp}.mtab
21
22 mtab=/proc/self/mounts
23
24 status=1        # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
26
27 _cleanup()
28 {
29     cd /
30     rm -f ${tmp}.*
31 }
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36 . ./common/quota
37
38 echo "Silence is golden."
39 rm -f $seqres.full
40
41 # real QA test starts here
42
43 # Modify as appropriate.
44 _supported_fs xfs
45
46 _require_quota
47 _require_scratch
48
49 _scratch_mkfs >> $seqres.full 2>&1
50
51 # Just use the current mount table as an example mtab file.  Odds
52 # are good there's nothing wrong with it.
53 _setup_my_mtab() {
54         cp "${mtab}" "${my_mtab}"
55 }
56
57 # Any bogus entry in the mtab file is enough to trigger the problem.
58 # So just append a bogus entry at the end of the private mtab file.
59 # This matches an actually-observed entry in a mount table (with a
60 # few characters in the paths changed to protect the innocent).
61 _perturb_my_mtab() {
62         cat <<-! >> "${my_mtab}"
63                 /dev/disk/by-id/scsi-3600508e000000000c329ba1d8b0c391b-part3 /tmp/autoY8qcJ9\040(deleted) xfs rw 0 0
64         !
65 }
66
67 _check() {
68         if [ $# -eq 0 ]; then
69                 export MOUNT_OPTIONS=""
70         elif [ $# -eq 1 ]; then
71                 [ $1 = u -o $1 = g -o $1 = p ] || exit
72                 export MOUNT_OPTIONS="-o${1}quota"
73         else
74                 exit
75         fi
76
77         _qmount
78
79         # Set up a private mount table file, then try out a simple quota
80         # command to show mounts
81         _setup_my_mtab
82         echo print | xfs_quota  -t "${my_mtab}" > /dev/null || exit
83
84         # Do the same simple quota command after adding a bogus entry to the
85         # mount table.  Old code will bail on this because it has trouble
86         # with the bogus entry.
87         _perturb_my_mtab
88         echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
89 }
90
91 #########
92
93 # Mount SCRATCH with no quota options
94 _check
95
96 # user quota enabled
97 _check u
98
99 # group quota enabled
100 _check g
101
102 # user quota enabled
103 _check p
104
105 status=0        # success, all done