]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
copy: be more careful when trying to reflink
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Sep 2015 23:19:54 +0000 (01:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Sep 2015 14:30:12 +0000 (16:30 +0200)
src/basic/copy.c

index b8cbe644d443a65e601213d0040f761892070d34..019b2764b95090b6ec71ed5023f6c2c8d5d1852e 100644 (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;