From: Lennart Poettering Date: Wed, 16 Sep 2015 23:19:54 +0000 (+0200) Subject: copy: be more careful when trying to reflink X-Git-Tag: v227~101^2~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c622fbdb8d37796c35ab1e08240a18b4222e5c9f;p=thirdparty%2Fsystemd.git copy: be more careful when trying to reflink --- diff --git a/src/basic/copy.c b/src/basic/copy.c index b8cbe644d44..019b2764b95 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;