summaryrefslogtreecommitdiff
path: root/src/debug-generator
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-04 11:49:42 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-12 21:58:00 +0100
commit7a44c7e31fdeebce82189b134221297919104e7d (patch)
tree2b12fa18720523a3cace0a238ea78b719c1f7356 /src/debug-generator
parentaba311f7ffb1370156f48061a5fdc2da9551e57f (diff)
downloadsystemd-7a44c7e31fdeebce82189b134221297919104e7d.tar.gz
generators: define custom main func definer and use it where applicable
There should be no functional difference, except that the error message is changd from "three or no arguments" to "zero or three arguments". Somehow the inverted form always seemed strange. umask() call is also dropped from run-generator. I think it wasn't dropped in 053254e3cb215df3b8c905bc39b920f8817e1c7d because the run generator was merged around the same time.
Diffstat (limited to 'src/debug-generator')
-rw-r--r--src/debug-generator/debug-generator.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index 2615aa189d..fa4ca57bbf 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -2,7 +2,6 @@
#include "alloc-util.h"
#include "generator.h"
-#include "main-func.h"
#include "mkdir.h"
#include "parse-util.h"
#include "proc-cmdline.h"
@@ -12,8 +11,8 @@
#include "unit-name.h"
#include "util.h"
+static const char *arg_dest = NULL;
static char *arg_default_unit = NULL;
-static const char *arg_dest = "/tmp";
static char **arg_mask = NULL;
static char **arg_wants = NULL;
static bool arg_debug_shell = false;
@@ -142,17 +141,10 @@ static int generate_wants_symlinks(void) {
return r;
}
-static int run(int argc, char *argv[]) {
+static int run(const char *dest, const char *dest_early, const char *dest_late) {
int r, q;
- log_setup_generator();
-
- if (argc > 1 && argc != 4)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "This program takes three or no arguments.");
-
- if (argc > 1)
- arg_dest = argv[2];
+ assert_se(arg_dest = dest_early);
r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_RD_STRICT | PROC_CMDLINE_STRIP_RD_PREFIX);
if (r < 0)
@@ -170,4 +162,4 @@ static int run(int argc, char *argv[]) {
return r < 0 ? r : q;
}
-DEFINE_MAIN_FUNCTION(run);
+DEFINE_MAIN_GENERATOR_FUNCTION(run);