92ec915f9a66f28ff103d1c031bb22c348baf57b
[xfstests-dev.git] / tests / xfs / 007
1 #! /bin/bash
2 # FS QA Test No. xfs/007
3 #
4 # Test to verify Q_XQUOTARM functionality.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35     cd /
36     rm -f $tmp.*
37 }
38
39 # get standard environment, filters and checks
40 . ./common/rc
41 . ./common/filter
42 . ./common/quota
43
44 # Modify as appropriate.
45 _supported_fs xfs
46 _supported_os Linux Irix
47
48 _require_scratch
49 _require_xfs_quota
50
51 rm -f $seqres.full
52
53 _scratch_mkfs_xfs | _filter_mkfs > /dev/null 2> $tmp.mkfs
54 . $tmp.mkfs
55
56 do_test()
57 {
58         qino_1=$1
59         qino_2=$2
60         off_opts=$3
61
62         echo "*** umount"
63         _scratch_unmount
64
65         QINO_1=`xfs_db -c "sb 0" -c "p" $SCRATCH_DEV | \
66                         grep $qino_1 | awk '{print $NF}'`
67         QINO_2=`xfs_db -c "sb 0" -c "p" $SCRATCH_DEV | \
68                         grep $qino_2 | awk '{print $NF}'`
69
70         echo "*** Usage before quotarm ***"
71         _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks"
72         _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks"
73
74         _qmount
75         echo "*** turn off $off_opts quotas"
76         xfs_quota -x -c "off -$off_opts" $SCRATCH_MNT
77         xfs_quota -x -c "remove -$off_opts" $SCRATCH_MNT
78         echo "*** umount"
79         _scratch_unmount
80
81         echo "*** Usage after quotarm ***"
82         _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks"
83         _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks"
84 }
85
86
87 # Test user and group first
88 _qmount_option "uquota,gquota"
89 _qmount
90 do_test uquotino gquotino ug
91
92 # Test user and project. Note that pquotino only exists on v5 (crc=1)
93 # superblocks. Older supers reuse gquotino.
94 PQUOTINO=pquotino
95 if [ $_fs_has_crcs == 0 ]; then
96         PQUOTINO=gquotino
97 fi
98 _qmount_option "uquota,pquota"
99 _qmount
100 _require_prjquota $SCRATCH_DEV
101 do_test uquotino $PQUOTINO up
102
103 # success, all done
104 status=0
105 exit