From 0e313315bfc940c0cb96963bfa9a66915d5386da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 16 Aug 2026 13:05:11 +0200 Subject: [PATCH] growfs: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The positional argument is spelled MOUNTPOINT in the synopsis, like the other metavars, instead of /path/to/mountpoint. The man page is adjusted to match. --- man/systemd-makefs@.service.xml | 4 +- src/growfs/growfs.c | 47 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/man/systemd-makefs@.service.xml b/man/systemd-makefs@.service.xml index a084f9d08c..ca5a99d806 100644 --- a/man/systemd-makefs@.service.xml +++ b/man/systemd-makefs@.service.xml @@ -30,8 +30,8 @@ systemd-mkswap@device.service systemd-growfs@mountpoint.service systemd-growfs-root.service - /usr/lib/systemd/systemd-makefs - /usr/lib/systemd/systemd-growfs + /usr/lib/systemd/systemd-makefs FSTYPE DEVICE + /usr/lib/systemd/systemd-growfs MOUNTPOINT diff --git a/src/growfs/growfs.c b/src/growfs/growfs.c index 8b1bb9b759..15077f1bd7 100644 --- a/src/growfs/growfs.c +++ b/src/growfs/growfs.c @@ -3,6 +3,8 @@ #include #include +#include "sd-json.h" + #include "alloc-util.h" #include "blockdev-util.h" #include "btrfs-util.h" @@ -13,19 +15,24 @@ #include "dissect-image.h" #include "dlopen-note.h" #include "fd-util.h" -#include "format-table.h" #include "format-util.h" #include "log.h" #include "main-func.h" #include "mountpoint-util.h" -#include "options.h" -#include "pretty-print.h" #include "resize-fs.h" #include "string-util.h" +#include "verbs.h" static const char *arg_target = NULL; static bool arg_dry_run = false; +COMMAND( + "systemd-growfs\0", + "Grow filesystem or encrypted payload to device size.", + .argspec = "MOUNTPOINT\0", + .man_pages = "systemd-growfs@.service.8\0", +); + #if HAVE_LIBCRYPTSETUP static int resize_crypt_luks_device(dev_t devno, const char *fstype, dev_t main_devno) { _cleanup_free_ char *devpath = NULL, *main_devpath = NULL; @@ -128,35 +135,6 @@ static int maybe_resize_underlying_device( return 0; } -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = terminal_urlify_man("systemd-growfs@.service", "8", &link); - if (r < 0) - return log_oom(); - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - printf("%s [OPTIONS...] /path/to/mountpoint\n\n" - "Grow filesystem or encrypted payload to device size.\n", - program_invocation_short_name); - - printf("\n%sOptions:%s\n", - ansi_underline(), - ansi_normal()); - - 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[]) { assert(argc >= 0); assert(argv); @@ -167,7 +145,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-growfs"); OPTION_COMMON_VERSION: return version(); @@ -175,6 +153,9 @@ static int parse_argv(int argc, char *argv[]) { OPTION('n', "dry-run", NULL, "Just print what would be done"): arg_dry_run = true; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (option_parser_get_n_args(&opts) != 1) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index e9e8de79b8..8a3c2614c5 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -30,6 +30,7 @@ INTROSPECTABLE=( systemd-dissect systemd-escape systemd-firstboot + systemd-growfs systemd-hwdb systemd-id128 systemd-imds