Fix more filters that will fail on xscsi names
[xfstests-dev.git] / 054
1 #! /bin/sh
2 # XFS QA Test No. 054
3 # $Id: 1.1 $
4 #
5 # Check behavior of chown with both user and group quota enabled,
6 # and changing both user and group together via chown(2).
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
10
11 # This program is free software; you can redistribute it and/or modify it
12 # under the terms of version 2 of the GNU General Public License as
13 # published by the Free Software Foundation.
14
15 # This program is distributed in the hope that it would be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
19 # Further, this software is distributed without any warranty that it is
20 # free of the rightful claim of any third person regarding infringement
21 # or the like.  Any license provided herein, whether implied or
22 # otherwise, applies only to this software file.  Patent licenses, if
23 # any, provided herein do not apply to combinations of this program with
24 # other software, or any other product whatsoever.
25
26 # You should have received a copy of the GNU General Public License along
27 # with this program; if not, write the Free Software Foundation, Inc., 59
28 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
29
30 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
31 # Mountain View, CA  94043, or:
32
33 # http://www.sgi.com 
34
35 # For further information regarding this notice, see: 
36
37 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #-----------------------------------------------------------------------
39 #
40 # creator
41 owner=nathans@sgi.com
42
43 seq=`basename $0`
44 echo "QA output created by $seq"
45
46 here=`pwd`
47 tmp=/tmp/$$
48 status=1        # failure is the default!
49
50 # get standard environment, filters and checks
51 . ./common.rc
52 . ./common.filter
53 . ./common.quota
54
55 _cleanup()
56 {
57         umount $SCRATCH_MNT 2>/dev/null
58         rm -f $tmp.*
59 }
60 trap "_cleanup; exit \$status" 0 1 2 3 15
61 cp /dev/null $seq.full
62 chmod ugo+rwx $seq.full
63
64 _require_scratch
65
66 _filter_stat()
67 {
68     sed "
69         /^Access:/d;
70         /^Modify:/d;
71         /^Change:/d;
72         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
73         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
74         s,$SCRATCH_MNT,<MOUNT>,;
75     " | tr -s ' '
76 }
77
78 _exercise()
79 {
80         mkfs_xfs $SCRATCH_DEV >/dev/null 2>&1
81         _qmount
82
83         umask 022
84         touch $SCRATCH_MNT/testfile
85         if src/feature -c $SCRATCH_MNT/testfile; then
86                 :
87         else
88                 _notrun "Installed fileutils doesn't support 32 bit uids/gids"
89         fi
90
91         chown 12345 $SCRATCH_MNT/testfile
92         chgrp 54321 $SCRATCH_MNT/testfile
93         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
94
95         chown 34567 $SCRATCH_MNT/testfile
96         chgrp 76543 $SCRATCH_MNT/testfile
97         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
98
99         chown 56789 $SCRATCH_MNT/testfile
100         chgrp 98765 $SCRATCH_MNT/testfile
101         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
102
103         # finally give back to original owners
104         chown 12345 $SCRATCH_MNT/testfile
105         chgrp 54321 $SCRATCH_MNT/testfile
106         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
107
108         echo
109         umount $SCRATCH_MNT 2>/dev/null
110 }
111
112 # real QA test starts here
113 mkfs_xfs $SCRATCH_DEV >/dev/null 2>&1
114 MOUNT_OPTIONS="-o usrquota,grpquota"; export MOUNT_OPTIONS
115 _qmount
116 if src/feature -G $SCRATCH_DEV ; then
117         :
118 else
119         _notrun "No quota support at mount time"
120 fi
121 umount $SCRATCH_MNT 2>/dev/null
122
123 MOUNT_OPTIONS=""; export MOUNT_OPTIONS
124 echo "*** Default mount options"
125 _exercise
126
127 MOUNT_OPTIONS="-o usrquota"; export MOUNT_OPTIONS
128 echo "*** User quota mount option"
129 _exercise
130
131 MOUNT_OPTIONS="-o grpquota"; export MOUNT_OPTIONS
132 echo "*** Group quota mount option"
133 _exercise
134
135 MOUNT_OPTIONS="-o usrquota,grpquota"; export MOUNT_OPTIONS
136 echo "*** User and Group quota mount options"
137 _exercise
138
139 # success, all done
140 status=0
141 exit