mirror of
https://github.com/systemd/systemd.git
synced 2026-11-06 05:17:24 +00:00
quotacheck: use common_parse_argv()
Describe the program with COMMAND() and parse the command line with the shared helper, which adds -h/--help, --version, and --introspect-cli. The optional path argument is unchanged. Superfluous arguments are rejected with "Too many arguments." instead of "This program expects one or no arguments.".
This commit is contained in:
1 parent
cdc8108a8b
commit
1500b689a2
2 files changed
+16
-5
No files matched your search
@@ -10,6 +10,15 @@
|
||||
#include "process-util.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
#include "verbs.h"
|
||||
|
||||
COMMAND(
|
||||
"systemd-quotacheck\0",
|
||||
"Check file system quotas.",
|
||||
.argspec = "[PATH]\0",
|
||||
.man_pages = "systemd-quotacheck@.service(8)\0",
|
||||
.option_namespace = "common",
|
||||
);
|
||||
|
||||
typedef enum QuotaCheckMode {
|
||||
QUOTA_CHECK_AUTO,
|
||||
@@ -69,9 +78,10 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
log_setup();
|
||||
|
||||
if (argc > 2)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"This program expects one or no arguments.");
|
||||
char **args = NULL;
|
||||
r = common_parse_argv_full(argc, argv, /* min_args= */ 0, /* max_args= */ 1, &args);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
umask(0022);
|
||||
|
||||
@@ -97,8 +107,8 @@ static int run(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
_cleanup_free_ char *path = NULL;
|
||||
if (argc == 2) {
|
||||
path = strdup(argv[1]);
|
||||
if (args[0]) {
|
||||
path = strdup(args[0]);
|
||||
if (!path)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ INTROSPECTABLE=(
|
||||
systemd-pstore
|
||||
systemd-pty-forward
|
||||
systemd-pull
|
||||
systemd-quotacheck
|
||||
systemd-random-seed
|
||||
systemd-remount-fs
|
||||
systemd-repart
|
||||
|
||||
Reference in new issue
Block a user