1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2019 Collabora, Ltd. All Rights Reserved.
4 # Common functions for testing filename casefold feature
6 _has_casefold_kernel_support()
10 test -f '/sys/fs/ext4/features/casefold'
13 # defaults to unsupported
19 _require_scratch_casefold()
21 if ! _has_casefold_kernel_support ; then
22 _notrun "$FSTYP does not support casefold feature"
25 if ! _scratch_mkfs_casefold &>>seqres.full; then
26 _notrun "$FSTYP userspace tools do not support casefold"
29 # Make sure the kernel can mount a filesystem with the encoding
30 # defined by the userspace tools. This will fail if
31 # the userspace tool used a more recent encoding than the one
32 # supported in kernel space.
33 if ! _try_scratch_mount &>>seqres.full; then
34 _notrun "kernel can't mount filesystem with the encoding set by userspace"
38 # utilities used by casefold
39 _require_command "$CHATTR_PROG" chattr
40 _require_command "$LSATTR_PROG" lsattr
43 _scratch_mkfs_casefold()
47 _scratch_mkfs -O casefold $*
50 _notrun "Don't know how to mkfs with casefold support on $FSTYP"
55 _scratch_mkfs_casefold_strict()
59 _scratch_mkfs -O casefold -E encoding_flags=strict
62 _notrun "Don't know how to mkfs with casefold-strict support on $FSTYP"
67 # To get the exact disk name, we need some method that does a
68 # getdents() on the parent directory, such that we don't get
69 # normalized/casefolded results. 'Find' works ok.
70 _casefold_check_exact_name()
74 find ${basedir} | grep -q ${exact_name}
79 $CHATTR_PROG +F "${1}"
82 _casefold_unset_attr()
84 $CHATTR_PROG -F "${1}"
87 _casefold_lsattr_dir()
89 $LSATTR_PROG -ld "${1}" | _filter_spaces