modules-load: 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 use the imperative
form ("Load …" instead of "Loads …"), consistent with the other
commands.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-17 13:21:31 +02:00
parent 7125bf3ac4
commit c590744048
2 changed files with 15 additions and 28 deletions
+14 -28
View File
@@ -6,6 +6,8 @@
#include <sys/socket.h>
#include <unistd.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "assert.h"
#include "build.h"
@@ -16,18 +18,16 @@
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "log.h"
#include "macro.h"
#include "main-func.h"
#include "module-util.h"
#include "options.h"
#include "ordered-set.h"
#include "parse-util.h"
#include "pretty-print.h"
#include "proc-cmdline.h"
#include "string-util.h"
#include "strv.h"
#include "verbs.h"
#define MODULE_NAME_MAX_LEN (4096UL)
@@ -36,6 +36,13 @@ static const char conf_file_dirs[] = CONF_PATHS_NULSTR("modules-load.d");
STATIC_DESTRUCTOR_REGISTER(arg_proc_cmdline_modules, strv_freep);
COMMAND(
"systemd-modules-load\0",
"Load statically configured kernel modules.",
.argspec = "[CONFIGURATION FILE…]\0",
.man_pages = "systemd-modules-load.service.8\0",
);
static int modules_list_append_suffix(OrderedSet **module_set, char *modp) {
/* take possession of string no matter what */
_cleanup_free_ char *mod = modp;
@@ -332,30 +339,6 @@ static unsigned determine_num_worker_threads(unsigned n_modules) {
return n_threads - 1U;
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
if (terminal_urlify_man("systemd-modules-load.service", "8", &link) < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n"
"Loads statically configured kernel modules.\n\n",
program_invocation_short_name);
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[], char ***ret_args) {
assert(argc >= 0);
assert(argv);
@@ -367,10 +350,13 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-modules-load");
OPTION_COMMON_VERSION:
return version();
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
*ret_args = option_parser_get_args(&opts);
@@ -39,6 +39,7 @@ INTROSPECTABLE=(
systemd-journal-gatewayd
systemd-journal-remote
systemd-journal-upload
systemd-modules-load
systemd-mute-console
systemd-notify
systemd-oomd