016: Do not discard blocks at mkfs time
[xfstests-dev.git] / 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 # creator
28 owner=aelder@sgi.com
29
30 seq=$(basename $0)
31 echo "QA output created by ${seq}"
32
33 here=$(pwd)
34
35 tmp=/tmp/$$
36 my_mtab=${tmp}.mtab
37
38 mtab=/proc/self/mounts
39
40 status=1        # failure is the default!
41 trap "_cleanup; exit \$status" 0 1 2 3 15
42
43 _cleanup()
44 {
45     cd /
46     rm -f ${tmp}.*
47 }
48
49 # get standard environment, filters and checks
50 . ./common.rc
51 . ./common.filter
52 . ./common.quota
53
54 echo "Silence is golden."
55
56 # real QA test starts here
57
58 # Modify as appropriate.
59 _supported_fs xfs
60 _supported_os Linux
61
62 _require_quota
63 _require_scratch
64
65 # Just use the current mount table as an example mtab file.  Odds
66 # are good there's nothing wrong with it.
67 _setup_my_mtab() {
68         cp "${mtab}" "${my_mtab}"
69 }
70
71 # Any bogus entry in the mtab file is enough to trigger the problem.
72 # So just append a bogus entry at the end of the private mtab file.
73 # This matches an actually-observed entry in a mount table (with a
74 # few characters in the paths changed to protect the innocent).
75 _perturb_my_mtab() {
76         cat <<-! >> "${my_mtab}"
77                 /dev/disk/by-id/scsi-3600508e000000000c329ba1d8b0c391b-part3 /tmp/autoY8qcJ9\040(deleted) xfs rw 0 0
78         !
79 }
80
81 _check() {
82         if [ $# -eq 0 ]; then
83                 export MOUNT_OPTIONS=""
84         elif [ $# -eq 1 ]; then
85                 [ $1 = u -o $1 = g -o $1 = p ] || exit
86                 export MOUNT_OPTIONS="-o${1}quota"
87         else
88                 exit
89         fi
90
91         _qmount
92
93         # Set up a private mount table file, then try out a simple quota
94         # command to show mounts
95         _setup_my_mtab
96         echo print | xfs_quota  -t "${my_mtab}" > /dev/null || exit
97
98         # Do the same simple quota command after adding a bogus entry to the
99         # mount table.  Old code will bail on this because it has trouble
100         # with the bogus entry.
101         _perturb_my_mtab
102         echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
103 }
104
105 #########
106
107 # Mount SCRATCH with no quota options
108 _check
109
110 # user quota enabled
111 _check u
112
113 # group quota enabled
114 _check g
115
116 # user quota enabled
117 _check p
118
119 status=0        # success, all done