generic/077: fall back to /usr if /lib/modules doesn't exist
[xfstests-dev.git] / tests / xfs / 261
1 #! /bin/bash
2 # FS QA Test No. 261
3 #
4 # This test exercises an issue in libxcmd where a problem with any
5 # mount point or project quota directory causes the program to exit
6 # complete.  The effect of this is that one cannot operate on any
7 # directory, even if the problem directory is completely unrelated
8 # to the directory one wants to operate on.
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2011 SGI.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=$(basename $0)
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by ${seq}"
31
32 here=$(pwd)
33
34 tmp=/tmp/$$
35 my_mtab=${tmp}.mtab
36
37 mtab=/proc/self/mounts
38
39 status=1        # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 _cleanup()
43 {
44     cd /
45     rm -f ${tmp}.*
46 }
47
48 # get standard environment, filters and checks
49 . ./common/rc
50 . ./common/filter
51 . ./common/quota
52
53 echo "Silence is golden."
54
55 # real QA test starts here
56
57 # Modify as appropriate.
58 _supported_fs xfs
59 _supported_os Linux
60
61 _require_quota
62 _require_scratch
63
64 # Just use the current mount table as an example mtab file.  Odds
65 # are good there's nothing wrong with it.
66 _setup_my_mtab() {
67         cp "${mtab}" "${my_mtab}"
68 }
69
70 # Any bogus entry in the mtab file is enough to trigger the problem.
71 # So just append a bogus entry at the end of the private mtab file.
72 # This matches an actually-observed entry in a mount table (with a
73 # few characters in the paths changed to protect the innocent).
74 _perturb_my_mtab() {
75         cat <<-! >> "${my_mtab}"
76                 /dev/disk/by-id/scsi-3600508e000000000c329ba1d8b0c391b-part3 /tmp/autoY8qcJ9\040(deleted) xfs rw 0 0
77         !
78 }
79
80 _check() {
81         if [ $# -eq 0 ]; then
82                 export MOUNT_OPTIONS=""
83         elif [ $# -eq 1 ]; then
84                 [ $1 = u -o $1 = g -o $1 = p ] || exit
85                 export MOUNT_OPTIONS="-o${1}quota"
86         else
87                 exit
88         fi
89
90         _qmount
91
92         # Set up a private mount table file, then try out a simple quota
93         # command to show mounts
94         _setup_my_mtab
95         echo print | xfs_quota  -t "${my_mtab}" > /dev/null || exit
96
97         # Do the same simple quota command after adding a bogus entry to the
98         # mount table.  Old code will bail on this because it has trouble
99         # with the bogus entry.
100         _perturb_my_mtab
101         echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
102 }
103
104 #########
105
106 # Mount SCRATCH with no quota options
107 _check
108
109 # user quota enabled
110 _check u
111
112 # group quota enabled
113 _check g
114
115 # user quota enabled
116 _check p
117
118 status=0        # success, all done