]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: report optional features in version string
authorDarrick J. Wong <djwong@kernel.org>
Mon, 10 Jan 2022 22:41:18 +0000 (14:41 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 20 Jan 2022 00:02:51 +0000 (16:02 -0800)
Ted T'so reported brittleness in the fstests logic in generic/45[34] to
detect whether or not xfs_scrub is capable of detecting Unicode mischief
in directory and xattr names.  This is a compile-time feature, since we
do not assume that all distros will want to ship xfsprogs with libicu.

Rather than relying on ldd tests (which don't work at all if xfs_scrub
is compiled statically), let's have -V print whether or not the feature
is built into the tool.  Phase 5 still requires the presence of "UTF-8"
in LC_MESSAGES to enable Unicode confusable detection; this merely makes
the feature easier to discover.

Reported-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
scrub/xfs_scrub.c

index bc2e84a73aa07c8ff82e70ee9c5991ca231687cc..45e5872795f74447409a785c0d796b7d509b5200 100644 (file)
@@ -582,6 +582,13 @@ report_outcome(
        }
 }
 
+/* Compile-time features discoverable via version strings */
+#ifdef HAVE_LIBICU
+# define XFS_SCRUB_HAVE_UNICODE        "+"
+#else
+# define XFS_SCRUB_HAVE_UNICODE        "-"
+#endif
+
 int
 main(
        int                     argc,
@@ -670,8 +677,9 @@ main(
                        verbose = true;
                        break;
                case 'V':
-                       fprintf(stdout, _("%s version %s\n"), progname,
-                                       VERSION);
+                       fprintf(stdout, _("%s version %s %sUnicode\n"),
+                                       progname, VERSION,
+                                       XFS_SCRUB_HAVE_UNICODE);
                        fflush(stdout);
                        return SCRUB_RET_SUCCESS;
                case 'x':