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.
This commit is contained in:
@@ -30,8 +30,8 @@
|
||||
<para><filename>systemd-mkswap@<replaceable>device</replaceable>.service</filename></para>
|
||||
<para><filename>systemd-growfs@<replaceable>mountpoint</replaceable>.service</filename></para>
|
||||
<para><filename>systemd-growfs-root.service</filename></para>
|
||||
<para><filename>/usr/lib/systemd/systemd-makefs</filename></para>
|
||||
<para><filename>/usr/lib/systemd/systemd-growfs</filename></para>
|
||||
<para><filename>/usr/lib/systemd/systemd-makefs</filename> <replaceable>FSTYPE</replaceable> <replaceable>DEVICE</replaceable></para>
|
||||
<para><filename>/usr/lib/systemd/systemd-growfs</filename> <replaceable>MOUNTPOINT</replaceable></para>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
|
||||
+14
-33
@@ -3,6 +3,8 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
#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)
|
||||
|
||||
@@ -30,6 +30,7 @@ INTROSPECTABLE=(
|
||||
systemd-dissect
|
||||
systemd-escape
|
||||
systemd-firstboot
|
||||
systemd-growfs
|
||||
systemd-hwdb
|
||||
systemd-id128
|
||||
systemd-imds
|
||||
|
||||
Reference in New Issue
Block a user