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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-18 23:04:06 +02:00
parent 92a97a2b9d
commit c62bfac025
2 changed files with 16 additions and 34 deletions
+12 -31
View File
@@ -3,6 +3,7 @@
#include <stdio.h>
#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);
@@ -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