From 1565fbf8a276ea90c01cdaffc8ac83be2e15e700 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 13 Feb 2018 10:19:32 +0000 Subject: [PATCH] Read mounpoints from / On systems with the new kernel 4.14, /etc/mtab is empty and it is insufficient to only read the first line of this file. Signed-off-by: Michael Tremer --- src/fireinfo/system.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/fireinfo/system.py b/src/fireinfo/system.py index c2ba12e..e3295af 100644 --- a/src/fireinfo/system.py +++ b/src/fireinfo/system.py @@ -401,21 +401,26 @@ class System(object): """ Return the dev node of the root disk. """ - with open("/etc/mtab", "r") as f: - dev, mountpoint, fs, rest = f.readline().split(" ", 3) - if mountpoint == "/" and not fs == "rootfs": - # Cut off /dev - dev = dev[5:] + with open("/proc/mounts", "r") as f: + for line in f.readlines(): + # Skip empty lines + if not line: + continue + + dev, mountpoint, fs, rest = line.split(" ", 3) + if mountpoint == "/" and not fs == "rootfs": + # Cut off /dev + dev = dev[5:] - # Handle raids and MMC cards like (mmcblk0p3). - if dev[-2] == "p": - return dev[:-2] + # Handle raids and MMC cards like (mmcblk0p3). + if dev[-2] == "p": + return dev[:-2] - # Otherwise cut off all digits at end of string - while dev[-1] in string.digits: - dev = dev[:-1] + # Otherwise cut off all digits at end of string + while dev[-1] in string.digits: + dev = dev[:-1] - return dev + return dev @property def root_size(self): -- 2.47.3