misc: move exit status into trap handler
[xfstests-dev.git] / tests / xfs / 053
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 053
6 #
7 # Ensure that xfs_repair can properly spot SGI_ACL_FILE
8 # and SGI_ACL_DEFAULT in the root attr namespace.
9 #
10 # Due to bugs here and there, we sometimes matched on partial
11 # strings with those names, and threw off xfs_repair.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20
21 # get standard environment, filters and checks
22 . ./common/rc
23 . ./common/filter
24 . ./common/attr
25
26 _cleanup()
27 {
28         cd /
29         rm -f $tmp.*
30 }
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 # real QA test starts here
34
35 _supported_fs xfs
36 _require_scratch
37 _require_attrs
38
39 _scratch_mkfs >/dev/null 2>&1
40 _scratch_mount
41
42 # Create root attr names which are substrings or superstrings
43 # of the reserved ACL names, and make sure xfs_repair copes.
44
45 # Due to various bugs, either the compared length was shorter
46 # than the reserved name (7 chars), so substrings matched, and/or only
47 # the reserved name length was compared, so superstrings matched.
48
49 rm -f $SCRATCH_MNT/$seq.*
50
51 # actual reserved names:
52 #           SGI_ACL_FILE        SGI_ACL_DEFAULT
53 for NAME in SGI_ACL \
54             SGI_ACL_F           SGI_ACL_D \
55             SGI_ACL_FILE_FOO    SGI_ACL_DEFAULT_FOO; do
56         touch $SCRATCH_MNT/${seq}.${NAME}
57         $ATTR_PROG -R -s $NAME -V "Wow, such $NAME" $SCRATCH_MNT/$seq.$NAME \
58                 | _filter_scratch
59 done
60
61 # Older repair failed because it sees the above names as matching
62 # SGI_ACL_FILE / SGI_ACL_DEFAULT but w/o valid acls on them
63
64 # The test harness will catch this (false positive) corruption
65
66 # success, all done
67 status=0
68 exit