generic/077: fall back to /usr if /lib/modules doesn't exist
[xfstests-dev.git] / tests / xfs / 054
1 #! /bin/bash
2 # FS QA Test No. 054
3 #
4 # Check behavior of chown with both user and group quota enabled,
5 # and changing both user and group together via chown(2).
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33
34 # get standard environment, filters and checks
35 . ./common/rc
36 . ./common/filter
37 . ./common/quota
38
39 _cleanup()
40 {
41         umount $SCRATCH_MNT 2>/dev/null
42         rm -f $tmp.*
43 }
44 trap "_cleanup; exit \$status" 0 1 2 3 15
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os Linux IRIX
49
50 cp /dev/null $seqres.full
51 chmod ugo+rwx $seqres.full
52
53 _require_scratch
54 _require_xfs_quota
55
56 _filter_stat()
57 {
58     sed "
59         /^Access:/d;
60         /^Modify:/d;
61         /^Change:/d;
62         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
63         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
64         s,$SCRATCH_MNT,<MOUNT>,;
65     " | tr -s ' '
66 }
67
68 _exercise()
69 {
70         _scratch_mkfs_xfs >/dev/null 2>&1
71         _qmount
72
73         umask 022
74         touch $SCRATCH_MNT/testfile
75         if src/feature -c $SCRATCH_MNT/testfile; then
76                 :
77         else
78                 _notrun "Installed fileutils doesn't support 32 bit uids/gids"
79         fi
80
81         chown 12345 $SCRATCH_MNT/testfile
82         chgrp 54321 $SCRATCH_MNT/testfile
83         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
84
85         chown 34567 $SCRATCH_MNT/testfile
86         chgrp 76543 $SCRATCH_MNT/testfile
87         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
88
89         chown 56789 $SCRATCH_MNT/testfile
90         chgrp 98765 $SCRATCH_MNT/testfile
91         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
92
93         # finally give back to original owners
94         chown 12345 $SCRATCH_MNT/testfile
95         chgrp 54321 $SCRATCH_MNT/testfile
96         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
97
98         echo
99         umount $SCRATCH_MNT 2>/dev/null
100 }
101
102 _scratch_mkfs_xfs >> $seqres.full 2>&1 || _fail "mkfs failed!"
103
104 _qmount_option "uquota,gquota"
105 _qmount
106 if src/feature -G $SCRATCH_DEV ; then
107         :
108 else
109         _notrun "No quota support at mount time"
110 fi
111 umount $SCRATCH_MNT 2>/dev/null
112
113 _qmount_option "rw" # no quota options
114 echo "*** Default mount options"
115 _exercise
116
117 _qmount_option "uquota"
118 echo "*** User quota mount option"
119 _exercise
120
121 export MOUNT_OPTIONS="-o gquota"
122 _qmount_option "gquota"
123 echo "*** Group quota mount option"
124 _exercise
125
126 _qmount_option "uquota,gquota"
127 echo "*** User and Group quota mount options"
128 _exercise
129
130 # success, all done
131 status=0
132 exit