OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script contains common utility function to deal with disk images, | 7 # This script contains common utility function to deal with disk images, |
8 # especially for being redistributed into platforms without complete Chromium OS | 8 # especially for being redistributed into platforms without complete Chromium OS |
9 # developing environment. | 9 # developing environment. |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 "$file" \ | 161 "$file" \ |
162 "$mount_point" | 162 "$mount_point" |
163 } | 163 } |
164 | 164 |
165 # Unmounts a partition mount point by mount_partition | 165 # Unmounts a partition mount point by mount_partition |
166 image_umount_partition() { | 166 image_umount_partition() { |
167 local mount_point="$1" | 167 local mount_point="$1" |
168 | 168 |
169 umount -d "$mount_point" | 169 umount -d "$mount_point" |
170 } | 170 } |
| 171 |
| 172 # Copy a partition from one image to another. |
| 173 image_partition_copy() { |
| 174 local src="$1" |
| 175 local srcpart="$2" |
| 176 local dst="$3" |
| 177 local dstpart="$4" |
| 178 |
| 179 local srcoffset=$(image_part_offset "${src}" "${srcpart}") |
| 180 local dstoffset=$(image_part_offset "${dst}" "${dstpart}") |
| 181 local length=$(image_part_size "${src}" "${srcpart}") |
| 182 local dstlength=$(image_part_size "${dst}" "${dstpart}") |
| 183 |
| 184 if [ "${length}" -gt "${dstlength}" ]; then |
| 185 exit 1 |
| 186 fi |
| 187 |
| 188 image_dump_partition "${src}" "${srcpart}" | |
| 189 dd of="${dst}" bs=512 seek="${dstoffset}" conv=notrunc |
| 190 } |
OLD | NEW |