linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Zorro Lang <zlang@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Ruiwen Zhao <ruiwen@google.com>,
	linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH v2 1/2] common: add helper _require_chattr_inherit
Date: Thu, 21 Sep 2023 17:31:01 +0300	[thread overview]
Message-ID: <20230921143102.127526-2-amir73il@gmail.com> (raw)
In-Reply-To: <20230921143102.127526-1-amir73il@gmail.com>

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

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 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


  reply	other threads:[~2023-09-21 19:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 14:31 [PATCH v2 0/2] Test for overlayfs fix in v6.6-rc2 Amir Goldstein
2023-09-21 14:31 ` Amir Goldstein [this message]
2023-09-21 15:26   ` [PATCH v2 1/2] common: add helper _require_chattr_inherit Zorro Lang
2023-09-21 15:40     ` Amir Goldstein
2023-09-21 16:23       ` Zorro Lang
2023-09-21 16:46         ` Amir Goldstein
2023-09-21 17:06           ` Zorro Lang
2023-09-21 17:12             ` Amir Goldstein
2023-09-21 14:31 ` [PATCH v2 2/2] overlay: add test for rename of lower symlink with NOATIME attr Amir Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230921143102.127526-2-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=ruiwen@google.com \
    --cc=zlang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).