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
35 _require_scratch_nocheck
37 _require_command "$FSCK_OVERLAY_PROG" fsck.overlay
39 OVL_XATTR_IMPURE_VAL=y
41 # remove all files from previous tests
44 # Create a redirect directory
51 $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target
59 $SETFATTR_PROG -x $OVL_XATTR_IMPURE $target
67 value=$(_getfattr --absolute-names --only-values -n \
68 $OVL_XATTR_IMPURE $target)
70 [[ "$value" == "$OVL_XATTR_IMPURE_VAL" ]] || echo "Missing impure xattr"
73 # Create test directories
74 lowerdir=$OVL_BASE_SCRATCH_MNT/lower
75 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
76 upperdir=$OVL_BASE_SCRATCH_MNT/upper
77 workdir=$OVL_BASE_SCRATCH_MNT/workdir
81 rm -rf $lowerdir $lowerdir2 $upperdir $workdir
82 mkdir -p $lowerdir $lowerdir2 $upperdir $workdir
85 # Test missing impure xattr in directory which has origin targets, should fix
86 echo "+ Missing impure"
88 mkdir $lowerdir/{testdir1,testdir2}
89 mkdir $upperdir/{testdir1,testdir2}
90 touch $lowerdir/testdir1/foo
91 mkdir $lowerdir/testdir2/subdir
92 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir
93 touch $SCRATCH_MNT/testdir1/foo
94 touch $SCRATCH_MNT/testdir2/subdir
95 $UMOUNT_PROG $SCRATCH_MNT
96 remove_impure $upperdir/testdir1
97 remove_impure $upperdir/testdir2
99 _overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p
100 check_impure $upperdir/testdir1
101 check_impure $upperdir/testdir2
103 # Test missing impure xattr in directory which has redirect directories,
105 echo "+ Missing impure(2)"
107 mkdir $lowerdir/origin
108 make_redirect_dir $upperdir/testdir/subdir "/origin"
110 _overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p
111 check_impure $upperdir/testdir
113 # Test missing impure xattr in directory which has merge directories,
115 echo "+ Missing impure(3)"
117 mkdir $lowerdir/testdir $upperdir/testdir
119 _overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p
120 check_impure $upperdir