diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-09-17 01:19:54 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-09-22 16:30:12 +0200 |
commit | c622fbdb8d37796c35ab1e08240a18b4222e5c9f (patch) | |
tree | 125e884577262330a8297dd99364ddec6027068e | |
parent | c97e586d8a18db5dc505d76059ed1d9add234925 (diff) |
copy: be more careful when trying to reflink
-rw-r--r-- | src/basic/copy.c | 6 |
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; |