diff options
Diffstat (limited to 'src/import/import.c')
-rw-r--r-- | src/import/import.c | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/src/import/import.c b/src/import/import.c index 454e64e3cb..35c8e6d630 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -1,22 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -/*** - This file is part of systemd. - - Copyright 2015 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ #include <getopt.h> @@ -88,10 +70,11 @@ static int import_tar(int argc, char *argv[], void *userdata) { } if (!arg_force) { - r = image_find(local, NULL); - if (r < 0) - return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local); - else if (r > 0) { + r = image_find(IMAGE_MACHINE, local, NULL); + if (r < 0) { + if (r != -ENOENT) + return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local); + } else { log_error("Image '%s' already exists.", local); return -EEXIST; } @@ -183,10 +166,11 @@ static int import_raw(int argc, char *argv[], void *userdata) { } if (!arg_force) { - r = image_find(local, NULL); - if (r < 0) - return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local); - else if (r > 0) { + r = image_find(IMAGE_MACHINE, local, NULL); + if (r < 0) { + if (r != -ENOENT) + return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local); + } else { log_error("Image '%s' already exists.", local); return -EEXIST; } @@ -208,7 +192,7 @@ static int import_raw(int argc, char *argv[], void *userdata) { fd = STDIN_FILENO; (void) readlink_malloc("/proc/self/fd/0", &pretty); - log_info("Importing '%s', saving as '%s'.", pretty, local); + log_info("Importing '%s', saving as '%s'.", strempty(pretty), local); } r = sd_event_default(&event); |