diff options
Diffstat (limited to 'src/import/import.c')
-rw-r--r-- | src/import/import.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/import/import.c b/src/import/import.c index 35c8e6d630..f34244acff 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -13,6 +13,7 @@ #include "import-tar.h" #include "import-util.h" #include "machine-image.h" +#include "main-func.h" #include "signal-util.h" #include "string-util.h" #include "verbs.h" @@ -95,7 +96,7 @@ static int import_tar(int argc, char *argv[], void *userdata) { fd = STDIN_FILENO; - (void) readlink_malloc("/proc/self/fd/0", &pretty); + (void) fd_get_path(fd, &pretty); log_info("Importing '%s', saving as '%s'.", strna(pretty), local); } @@ -191,7 +192,7 @@ static int import_raw(int argc, char *argv[], void *userdata) { fd = STDIN_FILENO; - (void) readlink_malloc("/proc/self/fd/0", &pretty); + (void) fd_get_path(fd, &pretty); log_info("Importing '%s', saving as '%s'.", strempty(pretty), local); } @@ -292,7 +293,6 @@ static int parse_argv(int argc, char *argv[]) { } static int import_main(int argc, char *argv[]) { - static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, help }, { "tar", 2, 3, 0, import_tar }, @@ -303,7 +303,7 @@ static int import_main(int argc, char *argv[]) { return dispatch_verb(argc, argv, verbs, NULL); } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { int r; setlocale(LC_ALL, ""); @@ -312,12 +312,11 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return 0; (void) ignore_signals(SIGPIPE, -1); - r = import_main(argc, argv); - -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return import_main(argc, argv); } + +DEFINE_MAIN_FUNCTION(run); |