Skip to content

Commit

Permalink
partitions: Read and parse info from GPT rather than executing shell …
Browse files Browse the repository at this point in the history
…commands, which is restricted on recent devices
  • Loading branch information
tuxuser committed Nov 25, 2017
1 parent 47b3f41 commit 87ec437
Show file tree
Hide file tree
Showing 3 changed files with 519 additions and 64 deletions.
9 changes: 6 additions & 3 deletions extract-partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
help="Immediately send commands, skip HELO message")

def dump_partitions(comm, disk_fd, outdir, max_size):
parts = partitions.get_partitions(comm)
for part_label, part_name in parts.items():
part_offset, part_size = partitions.partition_info(comm, part_name)
diskinfo = partitions.get_partitions(comm, disk_fd)
for part in diskinfo.gpt.partitions:
part_offset = part.first_bla * partitions.BLOCK_SIZE
part_size = (part.last_lba - part.first_bla) * partitions.BLOCK_SIZE
part_name = part.name
part_label = "/dev/mmcblk0p%i" % part.index
if max_size and part_size > max_size:
_logger.info("Ignoring large partition %s (%s) of size %dK",
part_label, part_name, part_size / 1024)
Expand Down
Loading

0 comments on commit 87ec437

Please sign in to comment.