4 # Test fsck.overlay how to deal with impure xattr in overlayfs.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2018 Huawei. All Rights Reserved.
8 # Author: zhangyi (F) <yi.zhang@huawei.com>
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.
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.
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 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
45 # remove previous $seqres.full before test
48 # real QA test starts here
51 _require_scratch_nocheck
53 _require_command "$FSCK_OVERLAY_PROG" fsck.overlay
55 OVL_XATTR_IMPURE_VAL=y
57 # remove all files from previous tests
60 # Create a redirect directory
67 $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target
75 $SETFATTR_PROG -x $OVL_XATTR_IMPURE $target
83 value=$($GETFATTR_PROG --absolute-names --only-values -n \
84 $OVL_XATTR_IMPURE $target)
86 [[ "$value" == "$OVL_XATTR_IMPURE_VAL" ]] || echo "Missing impure xattr"
89 # Create test directories
90 lowerdir=$OVL_BASE_SCRATCH_MNT/lower
91 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
92 upperdir=$OVL_BASE_SCRATCH_MNT/upper
93 workdir=$OVL_BASE_SCRATCH_MNT/workdir
97 rm -rf $lowerdir $lowerdir2 $upperdir $workdir
98 mkdir -p $lowerdir $lowerdir2 $upperdir $workdir
101 # Test missing impure xattr in directory which has origin targets, should fix
102 echo "+ Missing impure"
104 mkdir $lowerdir/{testdir1,testdir2}
105 mkdir $upperdir/{testdir1,testdir2}
106 touch $lowerdir/testdir1/foo
107 mkdir $lowerdir/testdir2/subdir
108 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir
109 touch $SCRATCH_MNT/testdir1/foo
110 touch $SCRATCH_MNT/testdir2/subdir
111 $UMOUNT_PROG $SCRATCH_MNT
112 remove_impure $upperdir/testdir1
113 remove_impure $upperdir/testdir2
115 _overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \
116 echo "fsck should not fail"
117 check_impure $upperdir/testdir1
118 check_impure $upperdir/testdir2
120 # Test missing impure xattr in directory which has redirect directories,
122 echo "+ Missing impure(2)"
124 mkdir $lowerdir/origin
125 make_redirect_dir $upperdir/testdir/subdir "/origin"
127 _overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \
128 echo "fsck should not fail"
129 check_impure $upperdir/testdir
131 # Test missing impure xattr in directory which has merge directories,
133 echo "+ Missing impure(3)"
135 mkdir $lowerdir/testdir $upperdir/testdir
137 _overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \
138 echo "fsck should not fail"
139 check_impure $upperdir