2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
7 # Create a filesystem label with emoji and confusing unicode characters
8 # to make sure that these special things actually work on xfs. In
9 # theory it should allow this (labels are a sequence of arbitrary bytes)
10 # even if the user implications are horrifying.
13 _begin_fstest auto quick mkfs label
15 # Import common functions.
19 _require_scratch_nocheck
20 _require_xfs_io_command 'label'
22 echo "Silence is golden."
25 _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV" && want_scrub=yes
28 grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
32 test "$want_scrub" = "yes" || return
34 output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1)"
35 echo "xfs_scrub output:" >> $seqres.full
36 echo "$output" >> $seqres.full
37 echo "$output" >> $tmp.scrub
41 local label="$(echo -e "$1")"
42 local expected_label="label = \"$label\""
44 echo "Formatting label '$1'." >> $seqres.full
45 # First, let's see if we can recover the label when we set it
47 _scratch_mkfs -L "$label" >> $seqres.full 2>&1
48 _scratch_mount >> $seqres.full 2>&1
49 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
50 blkid -d -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
52 # Did it actually stick?
53 local actual_label="$($XFS_IO_PROG -c label $SCRATCH_MNT)"
54 echo "$actual_label" >> $seqres.full
56 if [ "${actual_label}" != "${expected_label}" ]; then
57 echo "Saw '${expected_label}', expected '${actual_label}'."
62 # Now let's try setting the label online to see what happens.
63 echo "Setting label '$1'." >> $seqres.full
64 _scratch_mkfs >> $seqres.full 2>&1
65 _scratch_mount >> $seqres.full 2>&1
66 $XFS_IO_PROG -c "label -s $label" $SCRATCH_MNT >> $seqres.full
67 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
68 blkid -d -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
71 # Did it actually stick?
72 local actual_label="$($XFS_IO_PROG -c label $SCRATCH_MNT)"
73 echo "$actual_label" >> $seqres.full
75 if [ "${actual_label}" != "${expected_label}" ]; then
76 echo "Saw '${expected_label}'; expected '${actual_label}'."
85 # Two different renderings of the same label
86 testlabel "caf\xc3\xa9.fs"
87 testlabel "cafe\xcc\x81.fs"
89 # Arabic code point can expand into a muuuch longer series
90 testlabel "xfs_\xef\xb7\xba.fs"
93 testlabel "urk\xc0\xafmoo"
95 # Emoji: octopus butterfly owl giraffe
96 testlabel "\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89"
98 # unicode rtl widgets too...
99 testlabel "mo\xe2\x80\xaegnp.txt"
100 testlabel "motxt.png"
102 # mixed-script confusables
103 testlabel "mixed_t\xce\xbfp"
104 testlabel "mixed_top"
106 # single-script spoofing
107 testlabel "a\xe2\x80\x90b.fs"
110 testlabel "dz_dze.fs"
111 testlabel "dz_\xca\xa3e.fs"
115 testlabel "_\xe2\x82\xa8.fs"
118 testlabel "moocow.fs"
119 testlabel "moo\xe2\x80\x8dcow.fs"
122 testlabel "\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.fs"
123 testlabel "\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.fs"
126 testlabel ".\xe2\x80\x8d"
127 testlabel "..\xe2\x80\x8d"
129 # Did scrub choke on anything?
130 if [ "$want_scrub" = "yes" ]; then
131 grep -q "^Warning.*gnp.txt.*suspicious text direction" $tmp.scrub || \
132 echo "No complaints about direction overrides?"
133 grep -q "^Warning.*control characters" $tmp.scrub || \
134 echo "No complaints about control characters?"