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 test -f '/sys/fs/f2fs/features/casefold'
16 # defaults to unsupported
22 _require_scratch_casefold()
24 if ! _has_casefold_kernel_support ; then
25 _notrun "$FSTYP does not support casefold feature"
28 if ! _scratch_mkfs_casefold &>>seqres.full; then
29 _notrun "$FSTYP userspace tools do not support casefold"
32 # Make sure the kernel can mount a filesystem with the encoding
33 # defined by the userspace tools. This will fail if
34 # the userspace tool used a more recent encoding than the one
35 # supported in kernel space.
36 if ! _try_scratch_mount &>>seqres.full; then
37 _notrun "kernel can't mount filesystem with the encoding set by userspace"
41 # utilities used by casefold
42 _require_command "$CHATTR_PROG" chattr
43 _require_command "$LSATTR_PROG" lsattr
46 _scratch_mkfs_casefold()
50 _scratch_mkfs -O casefold $*
53 _scratch_mkfs -C utf8 $*
56 _notrun "Don't know how to mkfs with casefold support on $FSTYP"
61 _scratch_mkfs_casefold_strict()
65 _scratch_mkfs -O casefold -E encoding_flags=strict
68 _scratch_mkfs -C utf8:strict
71 _notrun "Don't know how to mkfs with casefold-strict support on $FSTYP"
76 # To get the exact disk name, we need some method that does a
77 # getdents() on the parent directory, such that we don't get
78 # normalized/casefolded results. 'Find' works ok.
79 _casefold_check_exact_name()
83 find ${basedir} | grep -q ${exact_name}
88 $CHATTR_PROG +F "${1}"
91 _casefold_unset_attr()
93 $CHATTR_PROG -F "${1}"
96 _casefold_lsattr_dir()
98 if $LSATTR_PROG -ld "${1}" | grep -q Casefold ; then