2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Huawei. All Rights Reserved.
7 # Test fsck.overlay how to deal with impure xattr in overlayfs.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # real QA test starts here
34 _require_scratch_nocheck
35 _require_attrs trusted
36 _require_command "$FSCK_OVERLAY_PROG" fsck.overlay
38 OVL_XATTR_IMPURE_VAL=y
40 # remove all files from previous tests
43 # Create a redirect directory
50 $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target
58 $SETFATTR_PROG -x $OVL_XATTR_IMPURE $target
66 value=$(_getfattr --absolute-names --only-values -n \
67 $OVL_XATTR_IMPURE $target)
69 [[ "$value" == "$OVL_XATTR_IMPURE_VAL" ]] || echo "Missing impure xattr"
72 # Create test directories
73 lowerdir=$OVL_BASE_SCRATCH_MNT/lower
74 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
75 upperdir=$OVL_BASE_SCRATCH_MNT/upper
76 workdir=$OVL_BASE_SCRATCH_MNT/workdir
80 rm -rf $lowerdir $lowerdir2 $upperdir $workdir
81 mkdir -p $lowerdir $lowerdir2 $upperdir $workdir
84 # Test missing impure xattr in directory which has origin targets, should fix
85 echo "+ Missing impure"
87 mkdir $lowerdir/{testdir1,testdir2}
88 mkdir $upperdir/{testdir1,testdir2}
89 touch $lowerdir/testdir1/foo
90 mkdir $lowerdir/testdir2/subdir
91 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir
92 touch $SCRATCH_MNT/testdir1/foo
93 touch $SCRATCH_MNT/testdir2/subdir
94 $UMOUNT_PROG $SCRATCH_MNT
95 remove_impure $upperdir/testdir1
96 remove_impure $upperdir/testdir2
98 _overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p
99 check_impure $upperdir/testdir1
100 check_impure $upperdir/testdir2
102 # Test missing impure xattr in directory which has redirect directories,
104 echo "+ Missing impure(2)"
106 mkdir $lowerdir/origin
107 make_redirect_dir $upperdir/testdir/subdir "/origin"
109 _overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p
110 check_impure $upperdir/testdir
112 # Test missing impure xattr in directory which has merge directories,
114 echo "+ Missing impure(3)"
116 mkdir $lowerdir/testdir $upperdir/testdir
118 _overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p
119 check_impure $upperdir