diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-26 18:02:09 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-11-26 18:09:01 +0100 |
commit | 82f299e74e19d32b6c99faf3bbb6be0f89d0a8d5 (patch) | |
tree | dbcd202d7ab8e08a4551f89ee76c11f83f59d2a0 /src/import | |
parent | e288e0599ea7cf192c923aa3b05a829263a2f3ba (diff) | |
download | systemd-82f299e74e19d32b6c99faf3bbb6be0f89d0a8d5.tar.gz |
export-tar: check tar result as well
Let's make sure we properly notice when tar doesn't actually work: let's
propagate the error.
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/export-tar.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/import/export-tar.c b/src/import/export-tar.c index 5acb09432a..3aab390637 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -141,6 +141,26 @@ static void tar_export_report_progress(TarExport *e) { e->last_percent = percent; } +static int tar_export_finish(TarExport *e) { + int r; + + assert(e); + assert(e->tar_fd >= 0); + + if (e->tar_pid > 0) { + r = wait_for_terminate_and_check("tar", e->tar_pid, WAIT_LOG); + e->tar_pid = 0; + if (r < 0) + return r; + if (r != EXIT_SUCCESS) + return -EPROTO; + } + + e->tar_fd = safe_close(e->tar_fd); + + return 0; +} + static int tar_export_process(TarExport *e) { ssize_t l; int r; @@ -156,7 +176,7 @@ static int tar_export_process(TarExport *e) { e->tried_splice = true; } else if (l == 0) { - r = 0; + r = tar_export_finish(e); goto finish; } else { e->written_uncompressed += l; @@ -172,7 +192,7 @@ static int tar_export_process(TarExport *e) { uint8_t input[COPY_BUFFER_SIZE]; if (e->eof) { - r = 0; + r = tar_export_finish(e); goto finish; } |