OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 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 # Determine script directory | 7 # Determine script directory |
8 SCRIPT_DIR=$(dirname $0) | 8 SCRIPT_DIR=$(dirname $0) |
9 PROG=$(basename $0) | 9 PROG=$(basename $0) |
10 GPT=cgpt | 10 GPT=cgpt |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 # Extract a partition to a file | 40 # Extract a partition to a file |
41 # Args: IMAGE PARTNUM OUTPUTFILE | 41 # Args: IMAGE PARTNUM OUTPUTFILE |
42 extract_image_partition() { | 42 extract_image_partition() { |
43 local image=$1 | 43 local image=$1 |
44 local partnum=$2 | 44 local partnum=$2 |
45 local output_file=$3 | 45 local output_file=$3 |
46 local offset=$(partoffset "$image" "$partnum") | 46 local offset=$(partoffset "$image" "$partnum") |
47 local size=$(partsize "$image" "$partnum") | 47 local size=$(partsize "$image" "$partnum") |
48 dd if=$image of=$output_file bs=512 skip=$offset count=$size conv=notrunc | 48 dd if=$image of=$output_file bs=512 skip=$offset count=$size conv=notrunc >/de
v/null 2>&1 |
49 } | 49 } |
50 | 50 |
51 # Replace a partition in an image from file | 51 # Replace a partition in an image from file |
52 # Args: IMAGE PARTNUM INPUTFILE | 52 # Args: IMAGE PARTNUM INPUTFILE |
53 replace_image_partition() { | 53 replace_image_partition() { |
54 local image=$1 | 54 local image=$1 |
55 local partnum=$2 | 55 local partnum=$2 |
56 local input_file=$3 | 56 local input_file=$3 |
57 local offset=$(partoffset "$image" "$partnum") | 57 local offset=$(partoffset "$image" "$partnum") |
58 local size=$(partsize "$image" "$partnum") | 58 local size=$(partsize "$image" "$partnum") |
59 dd if=$input_file of=$image bs=512 seek=$offset count=$size conv=notrunc | 59 dd if=$input_file of=$image bs=512 seek=$offset count=$size conv=notrunc |
60 } | 60 } |
(...skipping 25 matching lines...) Expand all Loading... |
86 sudo umount -d $i 2>/dev/null | 86 sudo umount -d $i 2>/dev/null |
87 rm -rf $i | 87 rm -rf $i |
88 fi | 88 fi |
89 done | 89 done |
90 set -e | 90 set -e |
91 rm -rf $TEMP_DIR_LIST $TEMP_FILE_LIST | 91 rm -rf $TEMP_DIR_LIST $TEMP_FILE_LIST |
92 } | 92 } |
93 | 93 |
94 trap "cleanup_temps_and_mounts" EXIT | 94 trap "cleanup_temps_and_mounts" EXIT |
95 | 95 |
OLD | NEW |