Fix Bug: Cannot get partuuid from loop device
File: lib/disk.py
When installing on a loopback device (a.k.a loop device), function
Filesystem.partuuid_to_index() crashes with a JSON parsing error.
REASON
1) For loop devices, the property BlockDevice.device returns the
actual image file (back-file) of the loop device instead of the
/dev/X device.
2) Function Filesystem.partuuid_to_index() executes `lsblk --json`
against BlockDevice.device .
3) `lsblk` fails and prints the error "not a block device" to stderr.
This causes the output to not be valid JSON.
4) Code crashes when JSON parser tries to parse the output.
SOLUTION
- Make sure property BlockDevice.device only returns a valid block
device.
- Create new function BlockDevice.device_or_backfile that mimics
the present behaviour of BlockDevice.device.
- Use BlockDevice.device_or_backfile in function
BlockDevice.__repr__().
SOLUTION REASONING
I can only see one reason behind BlockDevice.device returning
the back-file of a loop device, and that is to show the back-file
to the user (instead of /dev/X) when printing the string
representation of a BlockDevice.
All other parts of the code can use the /dev/X file just fine.
And IMO it makes more sense that a property named `device` only
returns devices, and not normal files.
0 files changed, 0 insertions, 0 deletions