[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[rhel6-branch 2/2] rescue mode: fix traceback writing /mnt/sysimage/etc/mtab.



If the /mnt/sysimage is mounted from a systemd distro,
/mnt/sysimage/etc/mtab is linked to /proc/mount and can not be written,
exception is thrown upon close().

Related: rhbz#730714
---
 rescue.py |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/rescue.py b/rescue.py
index f2c9c64..dbae8bd 100644
--- a/rescue.py
+++ b/rescue.py
@@ -138,18 +138,21 @@ class RescueInterface(InstallInterfaceBase):
 
 # XXX grub-install is stupid and uses df output to figure out
 # things when installing grub.  make /etc/mtab be at least
-# moderately useful.  
+# moderately useful.
 def makeMtab(instPath, storage):
     try:
         f = open(instPath + "/etc/mtab", "w+")
-    except IOError, e:
-        log.info("failed to open /etc/mtab for write: %s" % e)
-        return
-
-    try:
         f.write(storage.mtab)
+    except IOError as e:
+        log.info("failed to write /etc/mtab: %s" % e)
     finally:
-        f.close()
+        try:
+            # if this file is a symlink to /proc/mounts, as it is in F16, the
+            # close will raise an exception.
+            f.close()
+        except Exception as  e:
+            log.info("error closing /etc/mtab: %s" % e)
+            pass
 
 def makeFStab(instPath = ""):
     if os.access("/proc/mounts", os.R_OK):
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]