]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/encrypt: Explicitly set the test file to uncompressed
authorJan Prusakowski <jprusakowski@google.com>
Mon, 6 Oct 2025 09:58:13 +0000 (11:58 +0200)
committerZorro Lang <zlang@kernel.org>
Fri, 17 Oct 2025 19:32:50 +0000 (03:32 +0800)
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>
Reviewed-by: Chao Yu <chao@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/encrypt

index d4f6e3dc864abc8b5e44de3afb874c080fc42dc6..f2687631b214cf80d979a4c22850235f2294f533 100644 (file)
@@ -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)