copy: be more careful when trying to reflink

This commit is contained in:
Lennart Poettering
2015-09-22 16:30:12 +02:00
parent c97e586d8a
commit c622fbdb8d
+5 -1
View File
@@ -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;