summaryrefslogtreecommitdiff
path: root/src/gpt-auto-generator
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-04 11:52:26 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-12 21:58:00 +0100
commitec6e959750f10c2916d62801d476907e599f9668 (patch)
tree3d508936d60e9f0472facb5f12fe9b885e2842fc /src/gpt-auto-generator
parentbd020018f24791275ad8d7a8a909ea8a2540a5b5 (diff)
downloadsystemd-ec6e959750f10c2916d62801d476907e599f9668.tar.gz
gpt-auto-generator: use the new main function definer
The first error is now returned.
Diffstat (limited to 'src/gpt-auto-generator')
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 80e7bb671f..a6d7bcc755 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -36,7 +36,7 @@
#include "util.h"
#include "virt.h"
-static const char *arg_dest = "/tmp";
+static const char *arg_dest = NULL;
static bool arg_enabled = true;
static bool arg_root_enabled = true;
static bool arg_root_rw = false;
@@ -668,22 +668,14 @@ static int add_mounts(void) {
return enumerate_partitions(devno);
}
-int main(int argc, char *argv[]) {
+static int run(const char *dest, const char *dest_early, const char *dest_late) {
int r, k;
- log_setup_generator();
-
- if (argc > 1 && argc != 4) {
- log_error("This program takes three or no arguments.");
- return EXIT_FAILURE;
- }
-
- if (argc > 1)
- arg_dest = argv[3];
+ assert_se(arg_dest = dest_late);
if (detect_container() > 0) {
log_debug("In a container, exiting.");
- return EXIT_SUCCESS;
+ return 0;
}
r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0);
@@ -692,19 +684,19 @@ int main(int argc, char *argv[]) {
if (!arg_enabled) {
log_debug("Disabled, exiting.");
- return EXIT_SUCCESS;
+ return 0;
}
if (arg_root_enabled)
r = add_root_mount();
- else
- r = 0;
if (!in_initrd()) {
k = add_mounts();
- if (k < 0)
+ if (r >= 0)
r = k;
}
- return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ return r;
}
+
+DEFINE_MAIN_GENERATOR_FUNCTION(run);