From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: tytso@mit.edu
Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org,
Gabriel Krisman Bertazi <krisman@collabora.com>
Subject: [PATCH v3 1/2] common/casefold: Add infrastructure to test filename casefold feature
Date: Wed, 12 Jun 2019 14:40:32 -0400 [thread overview]
Message-ID: <20190612184033.21845-1-krisman@collabora.com> (raw)
Add a set of basic helper functions to simplify the testing of
casefolding capable filesystems.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
common/casefold | 92 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
create mode 100644 common/casefold
diff --git a/common/casefold b/common/casefold
new file mode 100644
index 000000000000..df01029a3d44
--- /dev/null
+++ b/common/casefold
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2019 Collabora, Ltd. All Rights Reserved.
+#
+# Common functions for testing filename casefold feature
+
+_has_casefold_kernel_support()
+{
+ case $FSTYP in
+ ext4)
+ test -f '/sys/fs/ext4/features/casefold'
+ ;;
+ *)
+ # defaults to unsupported
+ false
+ ;;
+ esac
+}
+
+_require_scratch_casefold()
+{
+ if ! _has_casefold_kernel_support ; then
+ _notrun "$FSTYP does not support casefold feature"
+ fi
+
+ if ! _scratch_mkfs_casefold &>>seqres.full; then
+ _notrun "$FSTYP userspace tools do not support casefold"
+ fi
+
+ # Make sure the kernel can mount a filesystem with the encoding
+ # defined by the userspace tools. This will fail if
+ # the userspace tool used a more recent encoding than the one
+ # supported in kernel space.
+ if ! _try_scratch_mount &>>seqres.full; then
+ _notrun \
+ "kernel can't mount filesystem with the encoding set by userspace"
+ fi
+ _scratch_unmount
+
+ # utilities used by casefold
+ _require_command "$CHATTR_PROG" chattr
+ _require_command "$LSATTR_PROG" lsattr
+}
+
+_scratch_mkfs_casefold()
+{
+ case $FSTYP in
+ ext4)
+ _scratch_mkfs -O casefold $*
+ ;;
+ *)
+ _notrun "Don't know how to mkfs with casefold support on $FSTYP"
+ ;;
+ esac
+}
+
+_scratch_mkfs_casefold_strict()
+{
+ case $FSTYP in
+ ext4)
+ _scratch_mkfs -O casefold -E encoding_flags=strict
+ ;;
+ *)
+ _notrun \
+ "Don't know how to mkfs with casefold-strict support on $FSTYP"
+ ;;
+ esac
+}
+
+# To get the exact disk name, we need some method that does a
+# getdents() on the parent directory, such that we don't get
+# normalized/casefolded results. 'Find' works ok.
+_casefold_check_exact_name()
+{
+ local basedir=$1
+ local exact_name=$2
+ find ${basedir} | grep -q ${exact_name}
+}
+
+_casefold_set_attr()
+{
+ $CHATTR_PROG +F "${1}"
+}
+
+_casefold_unset_attr()
+{
+ $CHATTR_PROG -F "${1}"
+}
+
+_casefold_lsattr_dir()
+{
+ $LSATTR_PROG -ld "${1}" | _filter_spaces
+}
--
2.20.1
next reply other threads:[~2019-06-12 18:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-12 18:40 Gabriel Krisman Bertazi [this message]
2019-06-12 18:40 ` [PATCH v3 2/2] shared/012: Add tests for filename casefolding feature Gabriel Krisman Bertazi
2019-06-16 14:44 ` Eryu Guan
2019-06-16 20:01 ` Theodore Ts'o
2019-06-20 11:29 ` Eryu Guan
2019-06-20 16:21 ` Removing the shared class of tests Theodore Ts'o
2019-06-20 17:50 ` Darrick J. Wong
2019-06-20 21:46 ` Theodore Ts'o
2019-06-24 7:16 ` Christoph Hellwig
2019-06-24 13:07 ` Theodore Ts'o
2019-06-24 17:05 ` Darrick J. Wong
2019-06-24 17:25 ` Theodore Ts'o
2019-06-26 2:37 ` Eryu Guan
-- strict thread matches above, loose matches on Subject: below --
2019-06-10 17:35 [PATCH v3 1/2] common/casefold: Add infrastructure to test filename casefold feature Gabriel Krisman Bertazi
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=20190612184033.21845-1-krisman@collabora.com \
--to=krisman@collabora.com \
--cc=fstests@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).