#include "fd-util.h"
#include "format-util.h"
#include "fs-util.h"
+#include "import-common.h"
#include "log.h"
#include "pretty-print.h"
#include "ratelimit.h"
#include "time-util.h"
#include "tmpfile-util.h"
-#define COPY_BUFFER_SIZE (16*1024)
-
typedef struct RawExport {
sd_event *event;
if (!e->tried_sendfile && e->compress.type == IMPORT_COMPRESS_UNCOMPRESSED) {
- l = sendfile(e->output_fd, e->input_fd, NULL, COPY_BUFFER_SIZE);
+ l = sendfile(e->output_fd, e->input_fd, NULL, IMPORT_BUFFER_SIZE);
if (l < 0) {
if (errno == EAGAIN)
return 0;
}
while (e->buffer_size <= 0) {
- uint8_t input[COPY_BUFFER_SIZE];
+ uint8_t input[IMPORT_BUFFER_SIZE];
if (e->eof) {
r = 0;
#include "time-util.h"
#include "tmpfile-util.h"
-#define COPY_BUFFER_SIZE (16*1024)
-
typedef struct TarExport {
sd_event *event;
if (!e->tried_splice && e->compress.type == IMPORT_COMPRESS_UNCOMPRESSED) {
- l = splice(e->tar_fd, NULL, e->output_fd, NULL, COPY_BUFFER_SIZE, 0);
+ l = splice(e->tar_fd, NULL, e->output_fd, NULL, IMPORT_BUFFER_SIZE, 0);
if (l < 0) {
if (errno == EAGAIN)
return 0;
}
while (e->buffer_size <= 0) {
- uint8_t input[COPY_BUFFER_SIZE];
+ uint8_t input[IMPORT_BUFFER_SIZE];
if (e->eof) {
r = tar_export_finish(e);
if (pipe2(pipefd, O_CLOEXEC) < 0)
return log_error_errno(errno, "Failed to create pipe for tar: %m");
+ (void) fcntl(pipefd[0], F_SETPIPE_SZ, IMPORT_BUFFER_SIZE);
+
use_selinux = mac_selinux_use();
r = safe_fork_full("(tar)",
if (pipe2(pipefd, O_CLOEXEC) < 0)
return log_error_errno(errno, "Failed to create pipe for tar: %m");
+ (void) fcntl(pipefd[0], F_SETPIPE_SZ, IMPORT_BUFFER_SIZE);
+
use_selinux = mac_selinux_use();
r = safe_fork_full("(tar)",
bool import_validate_local(const char *name, ImportFlags flags);
int import_allocate_event_with_signals(sd_event **ret);
+
+#define IMPORT_BUFFER_SIZE (128U*1024U)
#include <stdlib.h>
#include <string.h>
+#include "import-common.h"
#include "import-compress.h"
#include "log.h"
#include "string-table.h"
c->xz.avail_in = size;
while (c->xz.avail_in > 0) {
- uint8_t buffer[16 * 1024];
+ uint8_t buffer[IMPORT_BUFFER_SIZE];
lzma_ret lzr;
c->xz.next_out = buffer;
c->gzip.avail_in = size;
while (c->gzip.avail_in > 0) {
- uint8_t buffer[16 * 1024];
+ uint8_t buffer[IMPORT_BUFFER_SIZE];
c->gzip.next_out = buffer;
c->gzip.avail_out = sizeof(buffer);
c->bzip2.avail_in = size;
while (c->bzip2.avail_in > 0) {
- uint8_t buffer[16 * 1024];
+ uint8_t buffer[IMPORT_BUFFER_SIZE];
c->bzip2.next_out = (char*) buffer;
c->bzip2.avail_out = sizeof(buffer);
};
while (input.pos < input.size) {
- uint8_t buffer[16 * 1024];
+ uint8_t buffer[IMPORT_BUFFER_SIZE];
ZSTD_outBuffer output = {
.dst = buffer,
.size = sizeof(buffer),
if (*buffer_allocated > *buffer_size)
return 0;
- l = MAX(16*1024U, (*buffer_size * 2));
+ l = MAX(IMPORT_BUFFER_SIZE, (*buffer_size * 2));
p = realloc(*buffer, l);
if (!p)
return -ENOMEM;
sd_event_source *input_event_source;
- uint8_t buffer[16*1024];
+ uint8_t buffer[IMPORT_BUFFER_SIZE];
size_t buffer_size;
uint64_t written_compressed;
sd_event_source *input_event_source;
- uint8_t buffer[16*1024];
+ uint8_t buffer[IMPORT_BUFFER_SIZE];
size_t buffer_size;
uint64_t written_compressed;