]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: fix bug in sparse_copy
authorEd Bartosh <ed.bartosh@linux.intel.com>
Wed, 22 Mar 2017 13:42:28 +0000 (15:42 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 22 Mar 2017 15:07:37 +0000 (15:07 +0000)
sparse_copy creates output file that is smaller than input
file when input file ends with unmapped blocks.

Used truncate(<input file size>) when output file is created
to ensure the size of output file will always be equal to
the size of input file.

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 162603ed0a101d9bf472acb0d45a1e06856b692e..080668e7c28f4d0eb2a93ead12b812fd6bc0430f 100644 (file)
@@ -537,6 +537,7 @@ def sparse_copy(src_fname, dst_fname, offset=0, skip=0):
         dst_file = open(dst_fname, 'r+b')
     except IOError:
         dst_file = open(dst_fname, 'wb')
+        dst_file.truncate(os.path.getsize(src_fname))
 
     for first, last in fmap.get_mapped_ranges(0, fmap.blocks_cnt):
         start = first * fmap.block_size