[PATCH] When discovering dirtiness of filesystems, mount the /mnt/sysimage read only Resolves: rhbz#601862

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

 



---
 storage/__init__.py   |    6 +++++-
 storage/formats/fs.py |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/storage/__init__.py b/storage/__init__.py
index 464eebf..c154b41 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -1320,7 +1320,7 @@ def mountExistingSystem(anaconda, rootEnt,
         rootDevice.setup()
         rootDevice.format.mount(chroot=rootPath,
                                 mountpoint="/",
-                                options=readOnly)
+                                options="ro")
 
     fsset.parseFSTab()
 
@@ -1361,6 +1361,10 @@ def mountExistingSystem(anaconda, rootEnt,
         if rc == 0:
             return -1
 
+    log.info("All is well mounting the rest of referenced filesystems")
+    if not readOnly:
+        log.info("Remounting /mnt/sysimage read-write")
+        rootDevice.format.remount(options="rw")
     fsset.mountFilesystems(anaconda, readOnly=readOnly, skipRoot=True)
 
 
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 646194c..77a459c 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -632,6 +632,44 @@ class FS(DeviceFormat):
 
         self._mountpoint = chrootedMountpoint
 
+    def remount(self, *args, **kwargs):
+        """ Remount the filesystem with new options """
+        options = kwargs.get("options", "")
+        log.info("remounting %s on %s", self.device, self._mountpoint)
+
+        if not self.exists:
+            raise FSError("filesystem has not been created")
+
+        if not self._mountpoint:
+            # not mounted
+            return
+
+        if not os.path.exists(self._mountpoint):
+            raise FSError("mountpoint does not exist")
+
+        # passed in options override default options
+        if not options or not isinstance(options, str):
+            options = self.options
+
+        try: 
+            rc = isys.mount(self.device, self._mountpoint, 
+                            fstype=self.mountType,
+                            options=options, remount=True,
+                            bindMount=isinstance(self, BindFS))
+        except Exception as e:
+            raise FSError("mount failed: %s" % e)
+
+        if rc:
+            raise FSError("mount failed: %s" % rc)
+
+        if flags.selinux:
+            ret = isys.resetFileContext(self._mountpoint, "")
+            log.info("set SELinux context for newly mounted filesystem "
+                     "root at %s to %s" %(self._mountpoint, ret))
+            isys.setFileContext("%s/lost+found" % self._mountpoint,
+                                lost_and_found_context, "")
+
+
     def unmount(self):
         """ Unmount this filesystem. """
         if not self.exists:
-- 
1.7.3.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux