Skip to content

Attempt at fixing #795, bug in get_disks() for Raspberry Pi 2 image.

Sunil Mohan Adapa requested to merge JoKeyser:playIssue795 into master

Created by: JoKeyser

Hi, this should fix #795 (closed), see there for context.

I've tried to be minimally invasive, and had to make a few compromises. Most importantly, I think lsblk and df deliver complimentary info, so I combined their output, based on the reported mount points. I'm curious what you think.

In case it's interesting, here's a debugging print running on my Pi2 (see also screenshot below): Note that in the first line, _get_diskinfo_df() is just a renamed function get_disks(), just to compare the old and the new versions. The main fix is that get_root_device() now returns /dev/mmcblk0p2 instead of /dev/root (which by the way isn't even visible in the file system).

Output of (old) _get_diskinfo_df():
[{'mount_point': '/', 'size': '7.2G', 'used': '3.8G', 'percentage_used': 56, 'file_system_type': 'ext4', 'device': '/dev/root'}, {'mount_point': '/boot', 'size': '117M', 'used': '20M', 'percentage_used': 18, 'file_system_type': 'vfat', 'device': '/dev/mmcblk0p1'}, {'mount_point': '/mnt/usb16G', 'size': '15G', 'used': '4.0G', 'percentage_used': 30, 'file_system_type': 'ext4', 'device': '/dev/sda1'}]

OLD output of get_root_device():
/dev/root

----------------------------------

Output of (new) _get_diskinfo_lsblk():
[{'pkname': None, 'kname': 'sda', 'type': 'disk', 'mountpoint': None}, {'pkname': 'sda', 'kname': 'sda1', 'type': 'part', 'mountpoint': '/mnt/usb16G'}, {'pkname': None, 'kname': 'mmcblk0', 'type': 'disk', 'mountpoint': None}, {'pkname': 'mmcblk0', 'kname': 'mmcblk0p1', 'type': 'part', 'mountpoint': '/boot'}, {'pkname': 'mmcblk0', 'kname': 'mmcblk0p2', 'type': 'part', 'mountpoint': '/'}]

NEW output of get_root_device2():
/dev/mmcblk0p2

----------------------------------
New, combined output of get_disks():
[{'mountpoint': '/', 'pkname': 'mmcblk0', 'mount_point': '/', 'size': '7.2G', 'kname': 'mmcblk0p2', 'used': '3.8G', 'percentage_used': 56, 'type': 'part', 'file_system_type': 'ext4', 'device': '/dev/root'}, {'mountpoint': '/boot', 'pkname': 'mmcblk0', 'mount_point': '/boot', 'size': '117M', 'kname': 'mmcblk0p1', 'used': '20M', 'percentage_used': 18, 'type': 'part', 'file_system_type': 'vfat', 'device': '/dev/mmcblk0p1'}, {'mountpoint': '/mnt/usb16G', 'pkname': 'sda', 'mount_point': '/mnt/usb16G', 'size': '15G', 'kname': 'sda1', 'used': '4.0G', 'percentage_used': 30, 'type': 'part', 'file_system_type': 'ext4', 'device': '/dev/sda1'}]

Merge request reports

Loading