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