Browse Source
Merge pull request #218 from lluiscampos/resubmit-incorrect-part-num
Fix incorrect use of partition number
revert-252-rm-only-tag-2.2.x
Lluis Campos
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
11 additions and
6 deletions
-
mender-convert-extract
-
modules/disk.sh
|
|
@ -76,7 +76,8 @@ if [ ! -f ${MKFS_VFAT} ]; then |
|
|
|
MKFS_VFAT="/sbin/mkfs.vfat" |
|
|
|
fi |
|
|
|
|
|
|
|
declare -i nr_of_parts=$(disk_get_nr_of_parts ${disk_image}) |
|
|
|
declare -a part_nrs=($(disk_get_part_nums ${disk_image})) |
|
|
|
declare -i nr_of_parts=${#part_nrs[@]} |
|
|
|
|
|
|
|
log_info "Validating disk image" |
|
|
|
|
|
|
@ -87,7 +88,7 @@ fi |
|
|
|
log_info "Disk parsed successfully" |
|
|
|
log_info "NUMBER OF PARTS: ${nr_of_parts} TYPE: $(disk_get_part_value ${disk_image} 1 SCHEME)" |
|
|
|
|
|
|
|
for ((n=1;n<=${nr_of_parts};n++)); do |
|
|
|
for n in ${part_nrs[*]} ; do |
|
|
|
part_dst_file="work/part-${n}.fs" |
|
|
|
|
|
|
|
if [ "$(disk_get_part_value ${disk_image} ${n} TYPE)" == "0x8e" ]; then |
|
|
|
|
|
@ -40,15 +40,19 @@ disk_get_part_value() { |
|
|
|
echo "$(partx -o ${3} -g -r --nr ${2} ${1})" |
|
|
|
} |
|
|
|
|
|
|
|
# Prints number of partitions found in disk image |
|
|
|
# Prints the partition numbers of all the partitions |
|
|
|
# |
|
|
|
# Example usage: |
|
|
|
# |
|
|
|
# nr_of_parts=$(disk_get_nr_of_parts ${disk_image_path}) |
|
|
|
# part_nums=$(disk_get_part_nums ${disk_image_path}) |
|
|
|
# |
|
|
|
# $1 - path to disk image |
|
|
|
disk_get_nr_of_parts() { |
|
|
|
echo "$(partx -l ${1} | wc -l)" |
|
|
|
disk_get_part_nums() { |
|
|
|
partx --show $1 | tail -n +2 | |
|
|
|
while read line |
|
|
|
do |
|
|
|
echo $line | awk '{printf "%d\n", $1}' |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
# Extract a file system image from a disk image |
|
|
|