mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
794f4594fb
When getfattr dumps values of all extended attributes (-d option),
it doesn't print empty extended attributes. e.g: user.name. But from
attr-2.4.48 this behavior is changed, new getfattr prints
user.name="".
The {=""} will break the golden image, so filter the redundant =""
at the end if it has.
Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
128 lines
2.8 KiB
Bash
Executable File
128 lines
2.8 KiB
Bash
Executable File
#! /bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (c) 2018 Huawei. All Rights Reserved.
|
|
#
|
|
# FS QA Test No. 056
|
|
#
|
|
# Test fsck.overlay how to deal with impure xattr in overlayfs.
|
|
#
|
|
seq=`basename $0`
|
|
seqres=$RESULT_DIR/$seq
|
|
echo "QA output created by $seq"
|
|
|
|
here=`pwd`
|
|
tmp=/tmp/$$
|
|
status=1 # failure is the default!
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
_cleanup()
|
|
{
|
|
cd /
|
|
rm -f $tmp.*
|
|
}
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common/rc
|
|
. ./common/filter
|
|
. ./common/attr
|
|
|
|
# remove previous $seqres.full before test
|
|
rm -f $seqres.full
|
|
|
|
# real QA test starts here
|
|
_supported_fs overlay
|
|
_supported_os Linux
|
|
_require_scratch_nocheck
|
|
_require_attrs
|
|
_require_command "$FSCK_OVERLAY_PROG" fsck.overlay
|
|
|
|
OVL_XATTR_IMPURE_VAL=y
|
|
|
|
# remove all files from previous tests
|
|
_scratch_mkfs
|
|
|
|
# Create a redirect directory
|
|
make_redirect_dir()
|
|
{
|
|
local target=$1
|
|
local value=$2
|
|
|
|
mkdir -p $target
|
|
$SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target
|
|
}
|
|
|
|
# Remove impure xattr
|
|
remove_impure()
|
|
{
|
|
local target=$1
|
|
|
|
$SETFATTR_PROG -x $OVL_XATTR_IMPURE $target
|
|
}
|
|
|
|
# Check impure xattr
|
|
check_impure()
|
|
{
|
|
local target=$1
|
|
|
|
value=$(_getfattr --absolute-names --only-values -n \
|
|
$OVL_XATTR_IMPURE $target)
|
|
|
|
[[ "$value" == "$OVL_XATTR_IMPURE_VAL" ]] || echo "Missing impure xattr"
|
|
}
|
|
|
|
# Create test directories
|
|
lowerdir=$OVL_BASE_SCRATCH_MNT/lower
|
|
lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
|
|
upperdir=$OVL_BASE_SCRATCH_MNT/upper
|
|
workdir=$OVL_BASE_SCRATCH_MNT/workdir
|
|
|
|
make_test_dirs()
|
|
{
|
|
rm -rf $lowerdir $lowerdir2 $upperdir $workdir
|
|
mkdir -p $lowerdir $lowerdir2 $upperdir $workdir
|
|
}
|
|
|
|
# Test missing impure xattr in directory which has origin targets, should fix
|
|
echo "+ Missing impure"
|
|
make_test_dirs
|
|
mkdir $lowerdir/{testdir1,testdir2}
|
|
mkdir $upperdir/{testdir1,testdir2}
|
|
touch $lowerdir/testdir1/foo
|
|
mkdir $lowerdir/testdir2/subdir
|
|
_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir
|
|
touch $SCRATCH_MNT/testdir1/foo
|
|
touch $SCRATCH_MNT/testdir2/subdir
|
|
$UMOUNT_PROG $SCRATCH_MNT
|
|
remove_impure $upperdir/testdir1
|
|
remove_impure $upperdir/testdir2
|
|
|
|
_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \
|
|
echo "fsck should not fail"
|
|
check_impure $upperdir/testdir1
|
|
check_impure $upperdir/testdir2
|
|
|
|
# Test missing impure xattr in directory which has redirect directories,
|
|
# should fix
|
|
echo "+ Missing impure(2)"
|
|
make_test_dirs
|
|
mkdir $lowerdir/origin
|
|
make_redirect_dir $upperdir/testdir/subdir "/origin"
|
|
|
|
_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \
|
|
echo "fsck should not fail"
|
|
check_impure $upperdir/testdir
|
|
|
|
# Test missing impure xattr in directory which has merge directories,
|
|
# should fix
|
|
echo "+ Missing impure(3)"
|
|
make_test_dirs
|
|
mkdir $lowerdir/testdir $upperdir/testdir
|
|
|
|
_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \
|
|
echo "fsck should not fail"
|
|
check_impure $upperdir
|
|
|
|
# success, all done
|
|
status=0
|
|
exit
|