chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nspawn: fix invocation of the raw clone() system call on s390 and cris
[elogind.git]
/
src
/
shared
/
copy.c
diff --git
a/src/shared/copy.c
b/src/shared/copy.c
index 4c41f2fdd4c24bb7dcf57ac300d7bfc88f23a84f..b4a85c7bff0a12f76835a7cce3f867be37951b30 100644
(file)
--- a/
src/shared/copy.c
+++ b/
src/shared/copy.c
@@
-25,7
+25,7
@@
#include "btrfs-util.h"
#include "copy.h"
#include "btrfs-util.h"
#include "copy.h"
-int copy_bytes(int fdf, int fdt, off_t max_bytes) {
+int copy_bytes(int fdf, int fdt, off_t max_bytes
, bool try_reflink
) {
bool try_sendfile = true;
int r;
bool try_sendfile = true;
int r;
@@
-33,10
+33,10
@@
int copy_bytes(int fdf, int fdt, off_t max_bytes) {
assert(fdt >= 0);
/* Try btrfs reflinks first. */
assert(fdt >= 0);
/* Try btrfs reflinks first. */
- if (max_bytes == (off_t) -1) {
+ if (
try_reflink &&
max_bytes == (off_t) -1) {
r = btrfs_reflink(fdf, fdt);
if (r >= 0)
r = btrfs_reflink(fdf, fdt);
if (r >= 0)
- return
0
;
+ return
r
;
}
for (;;) {
}
for (;;) {
@@
-82,7
+82,6
@@
int copy_bytes(int fdf, int fdt, off_t max_bytes) {
r = loop_write(fdt, buf, (size_t) n, false);
if (r < 0)
return r;
r = loop_write(fdt, buf, (size_t) n, false);
if (r < 0)
return r;
-
}
next:
}
next:
@@
-132,7
+131,7
@@
static int fd_copy_regular(int df, const char *from, const struct stat *st, int
if (fdt < 0)
return -errno;
if (fdt < 0)
return -errno;
- r = copy_bytes(fdf, fdt, (off_t) -1);
+ r = copy_bytes(fdf, fdt, (off_t) -1
, true
);
if (r < 0) {
unlinkat(dt, to, 0);
return r;
if (r < 0) {
unlinkat(dt, to, 0);
return r;
@@
-319,7
+318,7
@@
int copy_tree_fd(int dirfd, const char *to, bool merge) {
return fd_copy_directory(dirfd, NULL, &st, AT_FDCWD, to, st.st_dev, merge);
}
return fd_copy_directory(dirfd, NULL, &st, AT_FDCWD, to, st.st_dev, merge);
}
-int copy_file_fd(const char *from, int fdt) {
+int copy_file_fd(const char *from, int fdt
, bool try_reflink
) {
_cleanup_close_ int fdf = -1;
assert(from);
_cleanup_close_ int fdf = -1;
assert(from);
@@
-329,7
+328,7
@@
int copy_file_fd(const char *from, int fdt) {
if (fdf < 0)
return -errno;
if (fdf < 0)
return -errno;
- return copy_bytes(fdf, fdt, (off_t) -1);
+ return copy_bytes(fdf, fdt, (off_t) -1
, try_reflink
);
}
int copy_file(const char *from, const char *to, int flags, mode_t mode) {
}
int copy_file(const char *from, const char *to, int flags, mode_t mode) {
@@
-342,7
+341,7
@@
int copy_file(const char *from, const char *to, int flags, mode_t mode) {
if (fdt < 0)
return -errno;
if (fdt < 0)
return -errno;
- r = copy_file_fd(from, fdt);
+ r = copy_file_fd(from, fdt
, true
);
if (r < 0) {
close(fdt);
unlink(to);
if (r < 0) {
close(fdt);
unlink(to);