xfsqa: more sh to bash conversions
[xfstests-dev.git] / 053
1 #! /bin/bash
2 # FS QA Test No. 053
3 #
4 # xfs_repair breaks acls
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, 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 # creator
25 owner=ajag@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38 . ./common.attr
39
40 # real QA test starts here
41 _supported_fs generic
42 _supported_os Linux
43
44 _require_scratch
45 _require_acls
46 _acl_setup_ids
47 _do_die_on_error=y
48 test=$SCRATCH_MNT/test
49
50 # make filesystem on scratch using the defaults
51 _do 'make filesystem on $SCRATCH_DEV' '_scratch_mkfs'
52 _do 'mount filesytem' '_scratch_mount'
53
54 # create test files and set acls
55 acls="
56 u::r--,g::rwx,o::rw-
57 u::r-x,g::---,o::---
58 u::---,g::r-x,o::---
59 u::---,g::---,o::r-x
60 u::---,g::r-x,o::rwx
61 u::---,g::---,o::---,u:$acl2:r-x,m::rwx
62 u::rwx,g::r-x,o::r--
63 u::---,g::---,o::---,g:$acl2:r-x,m::-w-"
64
65 i=0
66 for acl in $acls
67 do
68   _do "touch $test.$i"
69   _do "chacl $acl $test.$i"
70   let i=$i+1
71 done
72
73 list_acls()
74 {
75   i=0
76   for acl in $acls
77   do
78     chacl -l $test.$i | _acl_filter_id | sed -e "s!$SCRATCH_MNT!\$SCRATCH_MNT!"
79     let i=$i+1
80   done
81 }
82
83 echo "acls before repair:"
84 list_acls
85 _do 'unmount $SCRATCH_DEV' 'umount $SCRATCH_DEV'
86 _do 'repair filesystem' '_check_scratch_fs'
87 _do 'mount filesytem' '_scratch_mount'
88 echo "acls after repair: "
89 list_acls
90
91 # success, all done
92 status=0; exit