chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
importd: add API for exporting container/VM images
[elogind.git]
/
src
/
import
/
import-tar.c
diff --git
a/src/import/import-tar.c
b/src/import/import-tar.c
index d5b6dadddb2751b979c4e641e85247de2a1db030..dd95575660b6ebac2f4a2bc841e64507eb81b690 100644
(file)
--- a/
src/import/import-tar.c
+++ b/
src/import/import-tar.c
@@
-78,7
+78,7
@@
TarImport* tar_import_unref(TarImport *i) {
if (!i)
return NULL;
if (!i)
return NULL;
- sd_event_
unref(i->event
);
+ sd_event_
source_unref(i->input_event_source
);
if (i->tar_pid > 1) {
(void) kill_and_sigcont(i->tar_pid, SIGKILL);
if (i->tar_pid > 1) {
(void) kill_and_sigcont(i->tar_pid, SIGKILL);
@@
-93,7
+93,7
@@
TarImport* tar_import_unref(TarImport *i) {
import_compress_free(&i->compress);
import_compress_free(&i->compress);
- sd_event_
source_unref(i->input_event_source
);
+ sd_event_
unref(i->event
);
safe_close(i->tar_fd);
safe_close(i->tar_fd);
@@
-125,7
+125,7
@@
int tar_import_new(
i->on_finished = on_finished;
i->userdata = userdata;
i->on_finished = on_finished;
i->userdata = userdata;
- RATELIMIT_INIT(i->progress_rate_limit,
5
00 * USEC_PER_MSEC, 1);
+ RATELIMIT_INIT(i->progress_rate_limit,
1
00 * USEC_PER_MSEC, 1);
i->last_percent = (unsigned) -1;
i->image_root = strdup(image_root ?: "/var/lib/machines");
i->last_percent = (unsigned) -1;
i->image_root = strdup(image_root ?: "/var/lib/machines");
@@
-236,7
+236,7
@@
static int tar_import_fork_tar(TarImport *i) {
} else if (r < 0)
return log_error_errno(errno, "Failed to create subvolume %s: %m", i->temp_path);
} else if (r < 0)
return log_error_errno(errno, "Failed to create subvolume %s: %m", i->temp_path);
- i->tar_fd = import_fork_tar(i->temp_path, &i->tar_pid);
+ i->tar_fd = import_fork_tar
_x
(i->temp_path, &i->tar_pid);
if (i->tar_fd < 0)
return i->tar_fd;
if (i->tar_fd < 0)
return i->tar_fd;
@@
-271,6
+271,9
@@
static int tar_import_process(TarImport *i) {
l = read(i->input_fd, i->buffer + i->buffer_size, sizeof(i->buffer) - i->buffer_size);
if (l < 0) {
l = read(i->input_fd, i->buffer + i->buffer_size, sizeof(i->buffer) - i->buffer_size);
if (l < 0) {
+ if (errno == EAGAIN)
+ return 0;
+
r = log_error_errno(errno, "Failed to read input file: %m");
goto finish;
}
r = log_error_errno(errno, "Failed to read input file: %m");
goto finish;
}
@@
-348,6
+351,10
@@
int tar_import_start(TarImport *i, int fd, const char *local, bool force_local,
if (i->input_fd >= 0)
return -EBUSY;
if (i->input_fd >= 0)
return -EBUSY;
+ r = fd_nonblock(fd, true);
+ if (r < 0)
+ return r;
+
r = free_and_strdup(&i->local, local);
if (r < 0)
return r;
r = free_and_strdup(&i->local, local);
if (r < 0)
return r;