mirror of https://git.48k.eu/ogclient
utils: add disk index checks in get_partition_device
Control the possibility of a bad disk index. Handle the checks in a similar fashion to the get_efi_partition function.master
parent
a3ffdf2370
commit
ddf08779ae
|
@ -27,7 +27,11 @@ def get_partition_device(disknum, partnum):
|
|||
"""
|
||||
Returns the device path, given a disk and partition number
|
||||
"""
|
||||
disk = get_disks()[disknum-1]
|
||||
disk_index = disknum - 1
|
||||
if disk_index < 0 or disk_index >= len(get_disks()):
|
||||
raise ValueError(f'Invalid disk number {disknum}, {len(get_disks())} disks available.')
|
||||
|
||||
disk = get_disks()[disk_index]
|
||||
cxt = fdisk.Context(f'/dev/{disk}')
|
||||
|
||||
for pa in cxt.partitions:
|
||||
|
|
Loading…
Reference in New Issue