Index: lib/cros_image_common.sh |
diff --git a/lib/cros_image_common.sh b/lib/cros_image_common.sh |
index 86bba755047e612d69916d14876d6df1a6bb0f0e..abfdbc57c9bf7e50f70e2b042220b022c58eda67 100644 |
--- a/lib/cros_image_common.sh |
+++ b/lib/cros_image_common.sh |
@@ -168,3 +168,23 @@ image_umount_partition() { |
umount -d "$mount_point" |
} |
+ |
+# Copy a partition from one image to another. |
+image_partition_copy() { |
+ local src="$1" |
+ local srcpart="$2" |
+ local dst="$3" |
+ local dstpart="$4" |
+ |
+ local srcoffset=$(image_part_offset "${src}" "${srcpart}") |
+ local dstoffset=$(image_part_offset "${dst}" "${dstpart}") |
+ local length=$(image_part_size "${src}" "${srcpart}") |
+ local dstlength=$(image_part_size "${dst}" "${dstpart}") |
+ |
+ if [ "${length}" -gt "${dstlength}" ]; then |
+ exit 1 |
+ fi |
+ |
+ image_dump_partition "${src}" "${srcpart}" | |
+ dd of="${dst}" bs=512 seek="${dstoffset}" conv=notrunc |
+} |