xfstests: move GPL boilerplates to fix lsqa.pl
[xfstests-dev.git] / 054
1 #! /bin/sh
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 # creator
26 owner=nathans@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38 . ./common.quota
39
40 _cleanup()
41 {
42         umount $SCRATCH_MNT 2>/dev/null
43         rm -f $tmp.*
44 }
45 trap "_cleanup; exit \$status" 0 1 2 3 15
46
47 # real QA test starts here
48 _supported_fs xfs
49 _supported_os Linux IRIX
50
51 cp /dev/null $seq.full
52 chmod ugo+rwx $seq.full
53
54 _require_scratch
55 _require_quota
56
57 _filter_stat()
58 {
59     sed "
60         /^Access:/d;
61         /^Modify:/d;
62         /^Change:/d;
63         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
64         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
65         s,$SCRATCH_MNT,<MOUNT>,;
66     " | tr -s ' '
67 }
68
69 _exercise()
70 {
71         _scratch_mkfs_xfs >/dev/null 2>&1
72         _qmount
73
74         umask 022
75         touch $SCRATCH_MNT/testfile
76         if src/feature -c $SCRATCH_MNT/testfile; then
77                 :
78         else
79                 _notrun "Installed fileutils doesn't support 32 bit uids/gids"
80         fi
81
82         chown 12345 $SCRATCH_MNT/testfile
83         chgrp 54321 $SCRATCH_MNT/testfile
84         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
85
86         chown 34567 $SCRATCH_MNT/testfile
87         chgrp 76543 $SCRATCH_MNT/testfile
88         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
89
90         chown 56789 $SCRATCH_MNT/testfile
91         chgrp 98765 $SCRATCH_MNT/testfile
92         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
93
94         # finally give back to original owners
95         chown 12345 $SCRATCH_MNT/testfile
96         chgrp 54321 $SCRATCH_MNT/testfile
97         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
98
99         echo
100         umount $SCRATCH_MNT 2>/dev/null
101 }
102
103 _scratch_mkfs_xfs >> $seq.full 2>&1 || _fail "mkfs failed!"
104
105 _qmount_option "uquota,gquota"
106 _qmount
107 if src/feature -G $SCRATCH_DEV ; then
108         :
109 else
110         _notrun "No quota support at mount time"
111 fi
112 umount $SCRATCH_MNT 2>/dev/null
113
114 _qmount_option "rw" # no quota options
115 echo "*** Default mount options"
116 _exercise
117
118 _qmount_option "uquota"
119 echo "*** User quota mount option"
120 _exercise
121
122 export MOUNT_OPTIONS="-o gquota"
123 _qmount_option "gquota"
124 echo "*** Group quota mount option"
125 _exercise
126
127 _qmount_option "uquota,gquota"
128 echo "*** User and Group quota mount options"
129 _exercise
130
131 # success, all done
132 status=0
133 exit