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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 local srcoffset=$(image_part_offset "${src}" "${srcpart}") | 179 local srcoffset=$(image_part_offset "${src}" "${srcpart}") |
180 local dstoffset=$(image_part_offset "${dst}" "${dstpart}") | 180 local dstoffset=$(image_part_offset "${dst}" "${dstpart}") |
181 local length=$(image_part_size "${src}" "${srcpart}") | 181 local length=$(image_part_size "${src}" "${srcpart}") |
182 local dstlength=$(image_part_size "${dst}" "${dstpart}") | 182 local dstlength=$(image_part_size "${dst}" "${dstpart}") |
183 | 183 |
184 if [ "${length}" -gt "${dstlength}" ]; then | 184 if [ "${length}" -gt "${dstlength}" ]; then |
185 exit 1 | 185 exit 1 |
186 fi | 186 fi |
187 | 187 |
| 188 # Try to use larger buffer if offset/size can be re-aligned. |
| 189 # 2M / 512 = 4096 |
| 190 local buffer_ratio=4096 |
| 191 local bs=512 |
| 192 if [ $((dstoffset % buffer_ratio)) -eq 0 -a \ |
| 193 $((length % buffer_ratio)) -eq 0 ]; then |
| 194 dstoffset=$((dstoffset / buffer_ratio)) |
| 195 bs=$((bs * buffer_ratio)) |
| 196 fi |
| 197 |
188 image_dump_partition "${src}" "${srcpart}" | | 198 image_dump_partition "${src}" "${srcpart}" | |
189 dd of="${dst}" bs=512 seek="${dstoffset}" conv=notrunc | 199 dd of="${dst}" bs="${bs}" seek="${dstoffset}" conv=notrunc oflag=dsync |
190 } | 200 } |
OLD | NEW |