]> code.ossystems Code Review - openembedded-core.git/commitdiff
filemap: calculate dst size correctly
authorEd Bartosh <ed.bartosh@linux.intel.com>
Tue, 13 Jun 2017 11:22:05 +0000 (14:22 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 14 Jun 2017 09:18:21 +0000 (10:18 +0100)
Fixed calculation of the dst file size using skip, seek and
length parameters. Current code does it incorrectly which
causes sparse_copy API to create unnecessary big output files.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/filemap.py

index 764dbbe588c23b70e74700197668065a17305d9e..6d11355a1844cc5c1cde16d0668a5dfe68697beb 100644 (file)
@@ -549,7 +549,11 @@ def sparse_copy(src_fname, dst_fname, skip=0, seek=0,
         dst_file = open(dst_fname, 'r+b')
     except IOError:
         dst_file = open(dst_fname, 'wb')
-        dst_file.truncate(os.path.getsize(src_fname))
+        if length:
+            dst_size = length + seek
+        else:
+            dst_size = os.path.getsize(src_fname) + seek - skip
+        dst_file.truncate(dst_size)
 
     written = 0
     for first, last in fmap.get_mapped_ranges(0, fmap.blocks_cnt):