]> git.ipfire.org Git - oddments/fireinfo.git/commitdiff
Read mounpoints from /
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Feb 2018 10:19:32 +0000 (10:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Feb 2018 10:19:32 +0000 (10:19 +0000)
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 <michael.tremer@ipfire.org>
src/fireinfo/system.py

index c2ba12e818f04737633c8c79b42cd09c8f2ffac4..e3295af8534973702135d3055a036e2a64374267 100644 (file)
@@ -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):