#include "rm-rf.h"
#include "string-util.h"
#include "tmpfile-util.h"
-#include "util.h"
struct RawImport {
sd_event *event;
return -ENOMEM;
*i = (RawImport) {
- .input_fd = -1,
- .output_fd = -1,
+ .input_fd = -EBADF,
+ .output_fd = -EBADF,
.on_finished = on_finished,
.userdata = userdata,
.last_percent = UINT_MAX,
}
static int raw_import_maybe_convert_qcow2(RawImport *i) {
- _cleanup_close_ int converted_fd = -1;
+ _cleanup_close_ int converted_fd = -EBADF;
_cleanup_(unlink_and_freep) char *t = NULL;
_cleanup_free_ char *f = NULL;
int r;
if (S_ISREG(i->input_stat.st_mode)) {
(void) copy_times(i->input_fd, i->output_fd, COPY_CRTIME);
- (void) copy_xattr(i->input_fd, i->output_fd, 0);
+ (void) copy_xattr(i->input_fd, NULL, i->output_fd, NULL, 0);
}
}
"Target file is not a regular file or block device");
if (i->offset != UINT64_MAX) {
- if (lseek(i->output_fd, i->offset, SEEK_SET) == (off_t) -1)
+ if (lseek(i->output_fd, i->offset, SEEK_SET) < 0)
return log_error_errno(errno, "Failed to seek to offset: %m");
}
return 0;
p = lseek(i->input_fd, 0, SEEK_CUR);
- if (p == (off_t) -1)
+ if (p < 0)
return log_error_errno(errno, "Failed to read file offset of input file: %m");
/* Let's only try a btrfs reflink, if we are reading from the beginning of the file */
if ((uint64_t) p != (uint64_t) i->buffer_size)
return 0;
- r = btrfs_reflink(i->input_fd, i->output_fd);
+ r = reflink(i->input_fd, i->output_fd);
if (r >= 0)
return 1;
if ((size_t) n < sz)
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write");
} else {
- r = loop_write(i->output_fd, p, sz, false);
+ r = loop_write(i->output_fd, p, sz);
if (r < 0)
return log_error_errno(r, "Failed to write file: %m");
}