[PATCH v2 1/2] common: add helper _require_chattr_inherit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Similar to _require_chattr, but also checks if an attribute is
inheritted from parent dir to children.

Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
 common/rc | 52 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 43 insertions(+), 9 deletions(-)

diff --git a/common/rc b/common/rc
index 1618ded5..00cfd434 100644
--- a/common/rc
+++ b/common/rc
@@ -4235,23 +4235,57 @@ _require_test_lsattr()
 		_notrun "lsattr not supported by test filesystem type: $FSTYP"
 }
 
+_check_chattr_inherit()
+{
+	local attribute=$1
+	local path=$2
+	local inherit=$3
+
+	touch $path
+	$CHATTR_PROG "+$attribute" $path > $tmp.chattr 2>&1
+	local ret=$?
+	if [ -n "$inherit" ]; then
+		touch "$path/$inherit"
+	fi
+	$CHATTR_PROG "-$attribute" $path > $tmp.chattr 2>&1
+	if [ "$ret" -ne 0 ]; then
+		_notrun "file system doesn't support chattr +$attribute"
+	fi
+	cat $tmp.chattr >> $seqres.full
+	rm -f $tmp.chattr
+	return $ret
+}
+
 _require_chattr()
 {
 	if [ -z "$1" ]; then
 		echo "Usage: _require_chattr <attr>"
 		exit 1
 	fi
-	local attribute=$1
+	_check_chattr_inherit $1 $TEST_DIR/syscalltest
+}
 
-	touch $TEST_DIR/syscalltest
-	chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
-	local ret=$?
-	chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
-	if [ "$ret" -ne 0 ]; then
-		_notrun "file system doesn't support chattr +$attribute"
+_require_chattr_inherit()
+{
+	if [ -z "$1" ]; then
+		echo "Usage: _require_chattr_inherit <attr>"
+		exit 1
 	fi
-	cat $TEST_DIR/syscalltest.out >> $seqres.full
-	rm -f $TEST_DIR/syscalltest.out
+	local attribute=$1
+	local testdir="$TEST_DIR/chattrtest"
+	mkdir -p $testdir
+	_check_chattr_inherit $attribute $testdir testfile || \
+		return
+
+	local testfile="$TEST_DIR/chattrtest/testfile"
+	local lsattrout=($($LSATTR_PROG $testfile 2>> $seqres.full))
+	echo ${lsattrout[*]} >> $seqres.full
+	echo ${lsattrout[0]} | grep -q $attribute || \
+		_notrun "file system doesn't inherit chattr +$attribute"
+
+	$CHATTR_PROG "-$attribute" $testfile >> $seqres.full 2>&1
+	rm -f $testfile
+	rmdir $testdir
 }
 
 _get_total_inode()
-- 
2.34.1




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux