summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/wic/filemap.py15
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py2
2 files changed, 13 insertions, 4 deletions
diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
index 8fe302ab49..8719f443c5 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts/lib/wic/filemap.py
@@ -530,9 +530,18 @@ def filemap(image, log=None):
530 except ErrorNotSupp: 530 except ErrorNotSupp:
531 return FilemapSeek(image, log) 531 return FilemapSeek(image, log)
532 532
533def sparse_copy(src_fname, dst_fname, offset=0, skip=0, 533def sparse_copy(src_fname, dst_fname, skip=0, seek=0,
534 length=0, api=None): 534 length=0, api=None):
535 """Efficiently copy sparse file to or into another file.""" 535 """
536 Efficiently copy sparse file to or into another file.
537
538 src_fname: path to source file
539 dst_fname: path to destination file
540 skip: skip N bytes at thestart of src
541 seek: seek N bytes from the start of dst
542 length: read N bytes from src and write them to dst
543 api: FilemapFiemap or FilemapSeek object
544 """
536 if not api: 545 if not api:
537 api = filemap 546 api = filemap
538 fmap = api(src_fname) 547 fmap = api(src_fname)
@@ -554,7 +563,7 @@ def sparse_copy(src_fname, dst_fname, offset=0, skip=0,
554 start = skip 563 start = skip
555 564
556 fmap._f_image.seek(start, os.SEEK_SET) 565 fmap._f_image.seek(start, os.SEEK_SET)
557 dst_file.seek(offset + start - skip, os.SEEK_SET) 566 dst_file.seek(seek + start - skip, os.SEEK_SET)
558 567
559 chunk_size = 1024 * 1024 568 chunk_size = 1024 * 1024
560 to_read = end - start 569 to_read = end - start
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index f2e6127331..3cdedd1579 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -550,7 +550,7 @@ class PartitionedImage():
550 source = part.source_file 550 source = part.source_file
551 if source: 551 if source:
552 # install source_file contents into a partition 552 # install source_file contents into a partition
553 sparse_copy(source, self.path, part.start * self.sector_size) 553 sparse_copy(source, self.path, seek=part.start * self.sector_size)
554 554
555 logger.debug("Installed %s in partition %d, sectors %d-%d, " 555 logger.debug("Installed %s in partition %d, sectors %d-%d, "
556 "size %d sectors", source, part.num, part.start, 556 "size %d sectors", source, part.num, part.start,