[PATCH v2 2/2] Don't show mounts, which are not visible.

Jan Safranek jsafrane at redhat.com
Fri Apr 26 10:33:44 UTC 2013


When two filesystems are mounted to one mount point, only the one
which was mounted later is visible. This mount is listed last in /proc/mounts.
---
 blivet/__init__.py |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index 848c839..d70fcf5 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -1906,7 +1906,10 @@ class Blivet(object):
     def getActiveMounts(self):
         """ Reflect active mounts in the appropriate devices' formats. """
         log.info("collecting information about active mounts")
-        for line in open("/proc/mounts").readlines():
+        # Read /proc/mount from bottom to see visible mounts first and
+        # the replaced mounts later, just in case two filesystems are mounted
+        # to the same directory.
+        for line in reversed(open("/proc/mounts").readlines()):
             try:
                 (devspec, mountpoint, fstype, options, rest) = line.split(None,
                                                                           4)
@@ -1950,8 +1953,14 @@ class Blivet(object):
 
             device = self.devicetree.resolveDevice(devspec, options=options)
             if device is not None:
-                device.format.mountpoint = mountpoint   # for future mounts
-                device.format._mountpoint = mountpoint  # active mountpoint
+                oldmount = self.mountpoints.get(mountpoint)
+                if oldmount:
+                    # The mount is replaced by another mount and is not visible
+                    device.format.mountpoint = None
+                    device.format._mountpoint = None
+                else:
+                    device.format.mountpoint = mountpoint   # for future mounts
+                    device.format._mountpoint = mountpoint  # active mountpoint
                 device.format.mountopts = options
 
 def mountExistingSystem(fsset, rootDevice,



More information about the anaconda-patches mailing list