Skip to content

Instantly share code, notes, and snippets.

@Icenowy

Icenowy/075.sh Secret

Created January 4, 2021 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Icenowy/c7d8decb6812d6e5064d143c57281ad3 to your computer and use it in GitHub Desktop.
Save Icenowy/c7d8decb6812d6e5064d143c57281ad3 to your computer and use it in GitHub Desktop.
075
# Since Linux v5.10, chattr on directories in overlayfs is now supported,
# however the code shipped in Linux v5.10 has some bug that lead to hung
# task.
#
# This test tries to detect whether the affected operation will succeed.
#
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 /
$CHATTR_PROG -i $lowerdir/foo > /dev/null 2>&1
$CHATTR_PROG -i $upperdir/foo > /dev/null 2>&1
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
# remove previous $seqres.full before test
rm -f $seqres.full
# real QA test starts here
_supported_fs overlay
_require_scratch
_require_chattr i
# remove all files from previous runs
_scratch_mkfs
# prepare lower test file
lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
mkdir -p $lowerdir
mkdir $lowerdir/foo
# mounting overlay
_scratch_mount
# Try to add immutable attributes in overlay, it will
# invoke ioctl() on the directory, which will hang
# on unpatched Linux v5.10, and just fail on previous kernels.
$CHATTR_PROG +i $SCRATCH_MNT/foo > /dev/null 2>&1
$UMOUNT_PROG $SCRATCH_MNT
# success, all done
echo "Silence is golden"
status=0
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment