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 seqres="$RESULT_DIR/$seq"
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
32 _require_scratch_nocheck
33 _require_xfs_io_command 'label'
35 echo "Silence is golden."
38 _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV" && want_scrub=yes
41 grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
45 test "$want_scrub" = "yes" || return
47 output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1)"
48 echo "xfs_scrub output:" >> $seqres.full
49 echo "$output" >> $seqres.full
50 echo "$output" >> $tmp.scrub
54 local label="$(echo -e "$1")"
55 local expected_label="label = \"$label\""
57 echo "Formatting label '$1'." >> $seqres.full
58 # First, let's see if we can recover the label when we set it
60 _scratch_mkfs -L "$label" >> $seqres.full 2>&1
61 _scratch_mount >> $seqres.full 2>&1
62 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
63 blkid -d -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
65 # Did it actually stick?
66 local actual_label="$($XFS_IO_PROG -c label $SCRATCH_MNT)"
67 echo "$actual_label" >> $seqres.full
69 if [ "${actual_label}" != "${expected_label}" ]; then
70 echo "Saw '${expected_label}', expected '${actual_label}'."
75 # Now let's try setting the label online to see what happens.
76 echo "Setting label '$1'." >> $seqres.full
77 _scratch_mkfs >> $seqres.full 2>&1
78 _scratch_mount >> $seqres.full 2>&1
79 $XFS_IO_PROG -c "label -s $label" $SCRATCH_MNT >> $seqres.full
80 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
81 blkid -d -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" >> $seqres.full
84 # Did it actually stick?
85 local actual_label="$($XFS_IO_PROG -c label $SCRATCH_MNT)"
86 echo "$actual_label" >> $seqres.full
88 if [ "${actual_label}" != "${expected_label}" ]; then
89 echo "Saw '${expected_label}'; expected '${actual_label}'."
98 # Two different renderings of the same label
99 testlabel "caf\xc3\xa9.fs"
100 testlabel "cafe\xcc\x81.fs"
102 # Arabic code point can expand into a muuuch longer series
103 testlabel "xfs_\xef\xb7\xba.fs"
106 testlabel "urk\xc0\xafmoo"
108 # Emoji: octopus butterfly owl giraffe
109 testlabel "\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89"
111 # unicode rtl widgets too...
112 testlabel "mo\xe2\x80\xaegnp.txt"
113 testlabel "motxt.png"
115 # mixed-script confusables
116 testlabel "mixed_t\xce\xbfp"
117 testlabel "mixed_top"
119 # single-script spoofing
120 testlabel "a\xe2\x80\x90b.fs"
123 testlabel "dz_dze.fs"
124 testlabel "dz_\xca\xa3e.fs"
128 testlabel "_\xe2\x82\xa8.fs"
131 testlabel "moocow.fs"
132 testlabel "moo\xe2\x80\x8dcow.fs"
135 testlabel "\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.fs"
136 testlabel "\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.fs"
139 testlabel ".\xe2\x80\x8d"
140 testlabel "..\xe2\x80\x8d"
142 # Did scrub choke on anything?
143 if [ "$want_scrub" = "yes" ]; then
144 grep -q "^Warning.*gnp.txt.*suspicious text direction" $tmp.scrub || \
145 echo "No complaints about direction overrides?"
146 grep -q "^Warning.*control characters" $tmp.scrub || \
147 echo "No complaints about control characters?"