From c62bfac025a11c8653c6cbdf51a666cb4e4fc1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:45:03 +0200 Subject: [PATCH] udev/iocost: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The tool has no man page of its own, so iocost.conf(5), which describes it, is referenced. The test now also looks for commands in /usr/lib/udev, where the udev helpers are installed. --- src/udev/iocost/iocost.c | 43 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 7 +-- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/src/udev/iocost/iocost.c b/src/udev/iocost/iocost.c index a591ba40c0..9da7e1e9a8 100644 --- a/src/udev/iocost/iocost.c +++ b/src/udev/iocost/iocost.c @@ -3,6 +3,7 @@ #include #include "sd-device.h" +#include "sd-json.h" #include "alloc-util.h" #include "build.h" @@ -10,10 +11,7 @@ #include "conf-parser.h" #include "device-util.h" #include "devnum-util.h" -#include "format-table.h" -#include "help-util.h" #include "main-func.h" -#include "options.h" #include "string-util.h" #include "strv.h" #include "udev-util.h" @@ -22,6 +20,12 @@ static char *arg_target_solution = NULL; STATIC_DESTRUCTOR_REGISTER(arg_target_solution, freep); +COMMAND( + "iocost\0", + "Set up iocost model and qos solutions for block devices.", + .man_pages = "iocost.conf.5\0", +); + static int parse_config(void) { static const ConfigTableItem items[] = { { "IOCost", "TargetSolution", config_parse_string, 0, &arg_target_solution }, @@ -51,33 +55,7 @@ static int parse_config(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - r = verbs_get_help_table(&verbs); - if (r < 0) - return r; - - (void) table_sync_column_widths(0, options, verbs); - - help_cmdline("[OPTIONS...] COMMAND"); - help_abstract("Set up iocost model and qos solutions for block devices."); - - help_section("Commands"); - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - help_section("Options"); - return table_print_or_warn(options); -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("iocost"); static int parse_argv(int argc, char *argv[], char ***remaining_args) { assert(argc >= 0); @@ -90,10 +68,13 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("iocost"); OPTION_COMMON_VERSION: return version(); + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } *remaining_args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 8da538ef12..4a9728c886 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -3,9 +3,9 @@ set -eux set -o pipefail -# Some commands are in $PATH, others are in our private directory. -# Check the other location too. -PATH=$PATH:/usr/lib/systemd +# Some commands are in $PATH, others are in our private directories. +# Check the other locations too. +PATH=$PATH:/usr/lib/systemd:/usr/lib/udev export SYSTEMD_PAGER=cat @@ -17,6 +17,7 @@ INTROSPECTABLE=( homectl hostnamectl importctl + iocost journalctl localectl loginctl