From df618014a59aabdb753ec4fa40bbbdfe90dcbc18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:46:33 +0200 Subject: [PATCH] udev/scsi_id: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The abstract is changed to the imperative. There is no man page for this udev helper, so none is referenced. --- src/udev/scsi_id/scsi_id.c | 32 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index 93b65816e4..bee527962b 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -8,16 +8,15 @@ #include #include +#include "sd-json.h" + #include "alloc-util.h" #include "build.h" #include "device-nodes.h" #include "extract-word.h" #include "fd-util.h" #include "fileio.h" -#include "format-table.h" -#include "help-util.h" #include "main-func.h" -#include "options.h" #include "parse-util.h" #include "scsi_id.h" #include "string-util.h" @@ -25,6 +24,7 @@ #include "strxcpyx.h" #include "udev-util.h" #include "utf8.h" +#include "verbs.h" static bool all_good = false; static bool dev_specified = false; @@ -40,6 +40,12 @@ static char model_enc_str[256]; static char revision_str[16]; static char type_str[16]; +COMMAND( + "scsi_id\0", + "Identify SCSI devices.", + .argspec = "[DEVICE]\0", +); + static void set_type(unsigned type_num, char *to, size_t len) { const char *type; @@ -206,21 +212,6 @@ static int parse_page_code(const char *value, enum page_code *ret) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTION...] DEVICE"); - help_abstract("SCSI device identification."); - help_section("Options"); - - return table_print_or_warn(options); -} - static int set_options(int argc, char **argv, char *maj_min_dev) { assert(argc >= 0); assert(argv); @@ -232,7 +223,7 @@ static int set_options(int argc, char **argv, char *maj_min_dev) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("scsi_id"); OPTION_COMMON_VERSION_WITH_HIDDEN_V: return version(); @@ -284,6 +275,9 @@ static int set_options(int argc, char **argv, char *maj_min_dev) { OPTION('x', "export", NULL, "Print values as environment keys"): export = true; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } char **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 2ca370c8a1..3f47151538 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -32,6 +32,7 @@ INTROSPECTABLE=( portablectl resolvectl run0 + scsi_id storagectl systemd-ac-power systemd-analyze