diff mbox series

[2/4] generic/556: add a check to make sure ext4 supports encrypted casefolding

Message ID 20220720164356.4078789-3-tytso@mit.edu (mailing list archive)
State New, archived
Headers show
Series fstests: more random fixes from Ted | expand

Commit Message

Theodore Ts'o July 20, 2022, 4:43 p.m. UTC
Some older kernels support ext4 file systems with encryption enabled,
and with casefold enabled, but not file systems have both encryption
*and* casefolding enabled.  On those kernels, generic/556 will fail.
Fortunately, we can test if ext4 supports encrypted casefold via the
presence of /sys/fs/ext4/features/encrypted_casefold.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 common/casefold   | 17 +++++++++++++++++
 tests/generic/556 |  1 +
 2 files changed, 18 insertions(+)

Comments

Eric Biggers July 21, 2022, 2:40 a.m. UTC | #1
Hi Ted,

On Wed, Jul 20, 2022 at 12:43:54PM -0400, Theodore Ts'o wrote:
> Some older kernels support ext4 file systems with encryption enabled,
> and with casefold enabled, but not file systems have both encryption
> *and* casefolding enabled.  On those kernels, generic/556 will fail.
> Fortunately, we can test if ext4 supports encrypted casefold via the
> presence of /sys/fs/ext4/features/encrypted_casefold.
> 
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>

Please see my previous comments on this same patch:

    * https://lore.kernel.org/fstests/YNDOdrW0cEOhC9rZ@gmail.com
    * https://lore.kernel.org/fstests/YmGcDdLRlfSwUxmZ@sol.localdomain

- Eric
diff mbox series

Patch

diff --git a/common/casefold b/common/casefold
index d9126f4c..e3e89508 100644
--- a/common/casefold
+++ b/common/casefold
@@ -43,6 +43,23 @@  _require_scratch_casefold()
 	_require_command "$LSATTR_PROG" lsattr
 }
 
+_require_encrypted_casefold ()
+{
+    case $FSTYP in
+	ext4)
+	    if test ! -f /sys/fs/ext4/features/casefold ; then
+		_notrun "casefolding not supported"
+	    fi
+	    if test ! -f /sys/fs/ext4/features/encryption ; then
+		_notrun "file system encryption not supported"
+	    fi
+	    if test ! -f /sys/fs/ext4/features/encrypted_casefold ; then
+		_notrun "encrypted casefolding not supported"
+	    fi
+	    ;;
+	esac
+}
+
 _scratch_mkfs_casefold()
 {
 	case $FSTYP in
diff --git a/tests/generic/556 b/tests/generic/556
index 404a3243..80563502 100755
--- a/tests/generic/556
+++ b/tests/generic/556
@@ -13,6 +13,7 @@  _begin_fstest auto quick casefold
 . ./common/attr
 
 _supported_fs generic
+_require_encrypted_casefold
 _require_scratch_nocheck
 _require_scratch_casefold
 _require_symlinks