public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Prusakowski <jprusakowski@google.com>
To: Zorro Lang <zlang@kernel.org>, Eric Biggers <ebiggers@google.com>,
	fstests@vger.kernel.org
Cc: Chao Yu <chao@kernel.org>,
	jaegeuk@kernel.org,  linux-f2fs-devel@lists.sourceforge.net,
	 Jan Prusakowski <jprusakowski@google.com>
Subject: [PATCH v3] common/encrypt: Explicitly set the test file to uncompressed
Date: Mon,  6 Oct 2025 11:58:13 +0200	[thread overview]
Message-ID: <20251006095813.3497619-1-jprusakowski@google.com> (raw)

verify_ciphertext_for_encryption_policy() checks if encryption works
correctly by reading encrypted file's contents directly from a block device and
comparing it to a known good ciphertext.

This, however, won't work if the test file is also compressed. So this patch
adds a check if a test file is compressed and disables its compression in this
case.

Signed-off-by: Jan Prusakowski <jprusakowski@google.com>

---
Changes in v2:
The test file is now created empty first, followed by resetting the
FS_COMP_FL attribute, and then copying the test data.

Changes in v3:
Added explicit FS_NOCOMP_FL attribute to the test file.

---
 common/encrypt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/encrypt b/common/encrypt
index d4f6e3dc..f2687631 100644
--- a/common/encrypt
+++ b/common/encrypt
@@ -790,6 +790,13 @@ _do_verify_ciphertext_for_encryption_policy()
 	_set_encpolicy $dir $keyspec $set_encpolicy_args -f $policy_flags
 	for src in $tmp.testfile_*; do
 		dst=$dir/${src##*.}
+		# To make sure the test file is not compressed we create an empty one
+		# and disable compression first (F2FS won't allow resetting the
+		# compression flag if the file has data already in it).
+		touch $dst
+		if lsattr $dst | grep -qE ".+c.+ $dst" ; then
+			chattr -c +m $dst
+		fi
 		cp $src $dst
 		inode=$(stat -c %i $dst)
 		blocklist=$(_get_ciphertext_block_list $dst)
-- 
2.51.0.618.g983fd99d29-goog


             reply	other threads:[~2025-10-06  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-06  9:58 Jan Prusakowski [this message]
2025-10-06 15:44 ` [PATCH v3] common/encrypt: Explicitly set the test file to uncompressed Eric Biggers
2025-10-11  7:13 ` Chao Yu

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=20251006095813.3497619-1-jprusakowski@google.com \
    --to=jprusakowski@google.com \
    --cc=chao@kernel.org \
    --cc=ebiggers@google.com \
    --cc=fstests@vger.kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=zlang@kernel.org \
    /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