export-raw.c revision cf0fbc49e67b55f8d346fc94de28c90113505297
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering This file is part of systemd.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering Copyright 2015 Lennart Poettering
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering systemd is free software; you can redistribute it and/or modify it
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering under the terms of the GNU Lesser General Public License as published by
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering (at your option) any later version.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering systemd is distributed in the hope that it will be useful, but
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering Lesser General Public License for more details.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering You should have received a copy of the GNU Lesser General Public License
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering/* When we include libgen.h because we need dirname() we immediately
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering * undefine basename() since libgen.h defines it as a macro to the POSIX
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering * version which is really broken. We prefer GNU basename(). */
char *path;
int input_fd;
int output_fd;
void *buffer;
unsigned last_percent;
bool eof;
bool tried_reflink;
bool tried_sendfile;
return NULL;
free(e);
return NULL;
int raw_export_new(
void *userdata) {
return -ENOMEM;
if (event)
*ret = e;
e = NULL;
unsigned percent;
assert(e);
ssize_t l;
assert(e);
goto finish;
e->tried_reflink = true;
e->tried_sendfile = true;
goto finish;
e->written_uncompressed += l;
e->written_compressed += l;
while (e->buffer_size <= 0) {
if (e->eof) {
goto finish;
goto finish;
e->eof = true;
e->written_uncompressed += l;
goto finish;
goto finish;
e->buffer_size -= l;
e->written_compressed += l;
if (e->on_finished)
return raw_export_process(i);
return raw_export_process(i);
int new_fd, r;
d = dirname(p);
if (new_fd < 0) {
if (new_fd < 0)
return -errno;
(void) unlink(t);
return new_fd;
assert(e);
if (e->output_fd >= 0)
return -EBUSY;
if (sfd < 0)
return -errno;
return -errno;
return -ENOTTY;
if (tfd >= 0) {
if (r == -EPERM) {