[PATCH 1/5] Try a test mount and keep fstab mismatches if it succeeds. (#649171)

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

 



---
 pyanaconda/storage/__init__.py   |   10 +++++++---
 pyanaconda/storage/formats/fs.py |   25 ++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 387f3d4..62c66b3 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1917,7 +1917,7 @@ class FSSet(object):
                                                                 fstype))
             raise UnrecognizedFSTabEntryError()
 
-        fmt = getFormat(fstype, device=device.path)
+        fmt = getFormat(fstype, device=device.path, exists=True)
         if fstype != "auto" and None in (device.format.type, fmt.type):
             log.info("Unrecognized filesystem type for %s (%s)"
                      % (device.name, fstype))
@@ -1928,8 +1928,12 @@ class FSSet(object):
         ftype = getattr(fmt, "mountType", fmt.type)
         dtype = getattr(device.format, "mountType", device.format.type)
         if fstype != "auto" and ftype != dtype:
-            raise StorageError("scanned format (%s) differs from fstab "
-                        "format (%s)" % (dtype, ftype))
+            if fmt.testMount():
+                # XXX FIXME: disallow migration for this FS instance
+                device.format = fmt
+            else:
+                raise StorageError("scanned format (%s) differs from fstab "
+                                   "format (%s)" % (dtype, ftype))
         del ftype
         del dtype
 
diff --git a/pyanaconda/storage/formats/fs.py b/pyanaconda/storage/formats/fs.py
index 90d97e7..bb2dddc 100644
--- a/pyanaconda/storage/formats/fs.py
+++ b/pyanaconda/storage/formats/fs.py
@@ -24,7 +24,6 @@
 """ Filesystem classes for use by anaconda.
 
     TODO:
-        - migration
         - bug 472127: allow creation of tmpfs filesystems (/tmp, /var/tmp, &c)
 """
 import math
@@ -575,6 +574,30 @@ class FS(DeviceFormat):
         # also need to update the list of supported filesystems.
         kernel_filesystems = get_kernel_filesystems()
 
+    def testMount(self, options=None):
+        """ Try to mount the fs and return True if successful. """
+        ret = False
+
+        if self.status:
+            raise RuntimeError("filesystem is already mounted")
+
+        # create a temp dir
+        prefix = "%s.%s" % (os.path.basename(self.device), self.type)
+        mountpoint = tempfile.mkdtemp(prefix=prefix)
+
+        # try the mount
+        try:
+            self.mount(mountpoint=mountpoint)
+        except Exception as e:
+            log.info("test mount failed: %s" % e)
+        else:
+            self.unmount()
+            ret = True
+        finally:
+            os.rmdir(mountpoint)
+
+        return ret
+
     def mount(self, *args, **kwargs):
         """ Mount this filesystem.
 
-- 
1.7.3.4

_______________________________________________
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