partitions: make partition_info faster

This commit is contained in:
Peter Wu 2015-12-27 11:25:04 +01:00
parent c8e27d445d
commit 6f078543ca

View file

@ -51,8 +51,8 @@ def partition_info(comm, part_name):
disk_path = "/sys/class/block/%s" % part_name disk_path = "/sys/class/block/%s" % part_name
try: try:
# Convert sector sizes to bytes. # Convert sector sizes to bytes.
start = 512 * int(cat_file(comm, "%s/start" % disk_path)) output = cat_file(comm, '{0}/start {0}/size'.format(disk_path)).split()
size = 512 * int(cat_file(comm, "%s/size" % disk_path)) start, size = (512 * int(x) for x in output)
except ValueError: except ValueError:
raise RuntimeError("Partition %s not found" % part_name) raise RuntimeError("Partition %s not found" % part_name)
return start, size return start, size