summaryrefslogtreecommitdiffstats
path: root/src/import/import.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-01-22 17:10:50 +0100
committerLennart Poettering <lennart@poettering.net>2021-01-22 20:54:51 +0100
commit5183c50add40a89c0f83c0006cc2b50581b1c306 (patch)
treebcf9c51aed2796f8b1229607cf8ba1a5042f27be /src/import/import.c
parentimport: don't apply empty_or_dash_to_null() to stuff we know is NULL anyway (diff)
downloadsystemd-5183c50add40a89c0f83c0006cc2b50581b1c306.tar.xz
systemd-5183c50add40a89c0f83c0006cc2b50581b1c306.zip
import: introduce ImportFlags flags field
This merges the two flags that are passed to the ImportTar/ImportRaw objects into a single flags parameter, which we then can extend more easily later on. No change in behaviour. This is inspired by 133b34f69a72dc90d4e336837d699245390c9f50 which does the same for PullTar/PullRaw.
Diffstat (limited to '')
-rw-r--r--src/import/import.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/import/import.c b/src/import/import.c
index d358eec49c..842e1142f8 100644
--- a/src/import/import.c
+++ b/src/import/import.c
@@ -19,9 +19,8 @@
#include "string-util.h"
#include "verbs.h"
-static bool arg_force = false;
-static bool arg_read_only = false;
static const char *arg_image_root = "/var/lib/machines";
+static ImportFlags arg_import_flags = 0;
static int interrupt_signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
log_notice("Transfer aborted.");
@@ -67,7 +66,7 @@ static int import_tar(int argc, char *argv[], void *userdata) {
"Local image name '%s' is not valid.",
local);
- if (!arg_force) {
+ if (!FLAGS_SET(arg_import_flags, IMPORT_FORCE)) {
r = image_find(IMAGE_MACHINE, local, NULL, NULL);
if (r < 0) {
if (r != -ENOENT)
@@ -110,7 +109,7 @@ static int import_tar(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate importer: %m");
- r = tar_import_start(import, fd, local, arg_force, arg_read_only);
+ r = tar_import_start(import, fd, local, arg_import_flags);
if (r < 0)
return log_error_errno(r, "Failed to import image: %m");
@@ -160,7 +159,7 @@ static int import_raw(int argc, char *argv[], void *userdata) {
"Local image name '%s' is not valid.",
local);
- if (!arg_force) {
+ if (!FLAGS_SET(arg_import_flags, IMPORT_FORCE)) {
r = image_find(IMAGE_MACHINE, local, NULL, NULL);
if (r < 0) {
if (r != -ENOENT)
@@ -203,7 +202,7 @@ static int import_raw(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate importer: %m");
- r = raw_import_start(import, fd, local, arg_force, arg_read_only);
+ r = raw_import_start(import, fd, local, arg_import_flags);
if (r < 0)
return log_error_errno(r, "Failed to import image: %m");
@@ -266,7 +265,7 @@ static int parse_argv(int argc, char *argv[]) {
return version();
case ARG_FORCE:
- arg_force = true;
+ arg_import_flags |= IMPORT_FORCE;
break;
case ARG_IMAGE_ROOT:
@@ -274,7 +273,7 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_READ_ONLY:
- arg_read_only = true;
+ arg_import_flags |= IMPORT_READ_ONLY;
break;
case '?':