common/rc: fix unicode checker detection in xfs_scrub
authorDarrick J. Wong <djwong@kernel.org>
Tue, 11 Jan 2022 21:50:19 +0000 (13:50 -0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 16 Jan 2022 04:56:18 +0000 (12:56 +0800)
_check_xfs_scrub_does_unicode is still less than adequate -- if running
ldd to report the xfs_scrub binary's dynamic library dependencies
doesn't work, we could still detect support by grepping for strings that
only appear when the unicode checker is built.

Note that this isn't the final word on all of this; I will make this
easier to discover in a future xfs_scrub release.

Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc

index c63add750a1baab9ef21135bce9b29d6a6f03f9e..b3289de985d80f6c8d40f533c00ae76d6ce90416 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -4726,13 +4726,22 @@ _check_xfs_scrub_does_unicode() {
 
        _supports_xfs_scrub "${mount}" "${dev}" || return 1
 
-       # We only care if xfs_scrub has unicode string support...
-       if ! type ldd > /dev/null 2>&1 || \
-          ! ldd "${XFS_SCRUB_PROG}" 2> /dev/null | grep -q libicui18n; then
-               return 1
+       # If the xfs_scrub binary contains the string "Unicode name.*%s", then
+       # we know that it has the ability to complain about improper Unicode
+       # names.
+       if strings "${XFS_SCRUB_PROG}" | grep -q 'Unicode name.*%s'; then
+               return 0
        fi
 
-       return 0
+       # If the xfs_scrub binary is linked against the libicui18n Unicode
+       # library, then we surmise that it contains the Unicode name checker.
+       if type ldd > /dev/null 2>&1 && \
+          ldd "${XFS_SCRUB_PROG}" 2> /dev/null | grep -q libicui18n; then
+               return 0
+       fi
+
+       # We could not establish that xfs_scrub supports unicode names.
+       return 1
 }
 
 # exfat timestamps start at 1980 and cannot be prior to epoch