validatefs: 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, and the man page synopsis, which said "[DEVICE]", is fixed to match: the argument is required and it is a mount point.
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<para><filename>systemd-validatefs@.service</filename></para>
|
<para><filename>systemd-validatefs@.service</filename></para>
|
||||||
<para><filename>/usr/lib/systemd/systemd-validatefs</filename> <optional><replaceable>DEVICE</replaceable></optional></para>
|
<para><filename>/usr/lib/systemd/systemd-validatefs</filename> <replaceable>MOUNTPOINT</replaceable></para>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
|||||||
+12
-30
@@ -1,6 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
#include "sd-device.h"
|
#include "sd-device.h"
|
||||||
|
#include "sd-json.h"
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "blkid-util.h"
|
#include "blkid-util.h"
|
||||||
@@ -11,19 +12,17 @@
|
|||||||
#include "dlopen-note.h"
|
#include "dlopen-note.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "format-table.h"
|
|
||||||
#include "gpt.h"
|
#include "gpt.h"
|
||||||
#include "initrd-util.h"
|
#include "initrd-util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "main-func.h"
|
#include "main-func.h"
|
||||||
#include "mountpoint-util.h"
|
#include "mountpoint-util.h"
|
||||||
#include "options.h"
|
|
||||||
#include "parse-argument.h"
|
#include "parse-argument.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
#include "pretty-print.h"
|
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
#include "verbs.h"
|
||||||
#include "xattr-util.h"
|
#include "xattr-util.h"
|
||||||
|
|
||||||
static char *arg_target = NULL;
|
static char *arg_target = NULL;
|
||||||
@@ -32,32 +31,12 @@ static char *arg_root = NULL;
|
|||||||
STATIC_DESTRUCTOR_REGISTER(arg_target, freep);
|
STATIC_DESTRUCTOR_REGISTER(arg_target, freep);
|
||||||
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
|
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
|
||||||
|
|
||||||
static int help(void) {
|
COMMAND(
|
||||||
_cleanup_free_ char *link = NULL;
|
"systemd-validatefs\0",
|
||||||
_cleanup_(table_unrefp) Table *options = NULL;
|
"Check file system validation constraints.",
|
||||||
int r;
|
.argspec = "MOUNTPOINT\0",
|
||||||
|
.man_pages = "systemd-validatefs@.service.8\0",
|
||||||
r = terminal_urlify_man("systemd-validatefs@.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%sCheck file system validation constraints.%s\n"
|
|
||||||
"\nOptions:\n",
|
|
||||||
program_invocation_short_name,
|
|
||||||
ansi_highlight(),
|
|
||||||
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[]) {
|
static int parse_argv(int argc, char *argv[]) {
|
||||||
int r;
|
int r;
|
||||||
@@ -70,7 +49,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
FOREACH_OPTION_OR_RETURN(c, &opts)
|
FOREACH_OPTION_OR_RETURN(c, &opts)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
OPTION_COMMON_HELP:
|
OPTION_COMMON_HELP:
|
||||||
return help();
|
return command_print_help("systemd-validatefs");
|
||||||
|
|
||||||
OPTION_COMMON_VERSION:
|
OPTION_COMMON_VERSION:
|
||||||
return version();
|
return version();
|
||||||
@@ -88,6 +67,9 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
OPTION_COMMON_INTROSPECT_CLI:
|
||||||
|
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **args = option_parser_get_args(&opts);
|
char **args = option_parser_get_args(&opts);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ INTROSPECTABLE=(
|
|||||||
systemd-tpm2-setup
|
systemd-tpm2-setup
|
||||||
systemd-tty-ask-password-agent
|
systemd-tty-ask-password-agent
|
||||||
systemd-update-done
|
systemd-update-done
|
||||||
|
systemd-validatefs
|
||||||
systemd-veritysetup
|
systemd-veritysetup
|
||||||
timedatectl
|
timedatectl
|
||||||
varlinkctl
|
varlinkctl
|
||||||
|
|||||||
Reference in New Issue
Block a user