summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-17 01:19:54 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-22 16:30:12 +0200
commitc622fbdb8d37796c35ab1e08240a18b4222e5c9f (patch)
tree125e884577262330a8297dd99364ddec6027068e /src
parentc97e586d8a18db5dc505d76059ed1d9add234925 (diff)
copy: be more careful when trying to reflink
Diffstat (limited to 'src')
-rw-r--r--src/basic/copy.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/copy.c b/src/basic/copy.c
index b8cbe644d4..019b2764b9 100644
--- a/src/basic/copy.c
+++ b/src/basic/copy.c
@@ -37,7 +37,11 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
assert(fdt >= 0);
/* Try btrfs reflinks first. */
- if (try_reflink && max_bytes == (uint64_t) -1) {
+ if (try_reflink &&
+ max_bytes == (uint64_t) -1 &&
+ lseek(fdf, 0, SEEK_CUR) == 0 &&
+ lseek(fdt, 0, SEEK_CUR) == 0) {
+
r = btrfs_reflink(fdf, fdt);
if (r >= 0)
return r;