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 GPT=cgpt | 10 GPT=cgpt |
10 | 11 |
11 # Read GPT table to find the starting location of a specific partition. | 12 # Read GPT table to find the starting location of a specific partition. |
12 # Args: DEVICE PARTNUM | 13 # Args: DEVICE PARTNUM |
13 # Returns: offset (in sectors) of partition PARTNUM | 14 # Returns: offset (in sectors) of partition PARTNUM |
14 partoffset() { | 15 partoffset() { |
15 sudo $GPT show -b -i $2 $1 | 16 sudo $GPT show -b -i $2 $1 |
16 } | 17 } |
17 | 18 |
18 # Read GPT table to find the size of a specific partition. | 19 # Read GPT table to find the size of a specific partition. |
(...skipping 17 matching lines...) Expand all Loading... |
36 # Args: IMAGE PARTNUM OUTPUTFILE | 37 # Args: IMAGE PARTNUM OUTPUTFILE |
37 extract_image_partition() { | 38 extract_image_partition() { |
38 local image=$1 | 39 local image=$1 |
39 local partnum=$2 | 40 local partnum=$2 |
40 local output_file=$3 | 41 local output_file=$3 |
41 local offset=$(partoffset "$image" "$partnum") | 42 local offset=$(partoffset "$image" "$partnum") |
42 local size=$(partsize "$image" "$partnum") | 43 local size=$(partsize "$image" "$partnum") |
43 dd if=$image of=$output_file bs=512 skip=$offset count=$size | 44 dd if=$image of=$output_file bs=512 skip=$offset count=$size |
44 } | 45 } |
45 | 46 |
OLD | NEW |