[PATCH] Only load a module if the filesystem is supported (#490795, #494108).

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

 



For filesystems that we officially support, there is no change here.  For
those that require a cmdline option for support, module loading has now
moved from within the loader to inside the __init__ methods for the formats
themselves.  The intention here is to avoid kernel errors in modules that
the user never even wants to have involved.
---
 loader/loader.c       |    2 +-
 storage/formats/fs.py |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index 98ea24c..4224268 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2071,7 +2071,7 @@ int main(int argc, char ** argv) {
     stop_fw_loader(&loaderData);
     start_fw_loader(&loaderData);
 
-    mlLoadModuleSet("raid0:raid1:raid5:raid6:raid456:raid10:linear:fat:msdos:gfs2:reiserfs:jfs:xfs:btrfs:dm-mod:dm-zero:dm-mirror:dm-snapshot:dm-multipath:dm-round-robin:dm-crypt:cbc:sha256:lrw:xts");
+    mlLoadModuleSet("raid0:raid1:raid5:raid6:raid456:raid10:linear:fat:msdos:xfs:dm-mod:dm-zero:dm-mirror:dm-snapshot:dm-multipath:dm-round-robin:dm-crypt:cbc:sha256:lrw:xts");
 
     if (!access("/mnt/runtime/usr/lib/libunicode-lite.so.1", R_OK))
         setenv("LD_PRELOAD", "/mnt/runtime/usr/lib/libunicode-lite.so.1", 1);
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 0e155eb..9ee2d55 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -118,6 +118,7 @@ class FS(DeviceFormat):
     _type = "Abstract Filesystem Class"  # fs type name
     _name = None
     _mkfs = ""                           # mkfs utility
+    _module = None                       # kernel module required for support
     _resizefs = ""                       # resize utility
     _labelfs = ""                        # labeling utility
     _fsck = ""                           # fs check utility
@@ -427,6 +428,21 @@ class FS(DeviceFormat):
         if rc >= 4:
             raise FSError("filesystem check failed: %s" % rc)
 
+    def loadModule(self):
+        """Load whatever kernel module is required to support this filesystem."""
+        if not self._module:
+            return
+
+        try:
+            rc = iutil.execWithRedirect("modprobe", [self._module],
+                                        stdout="/dev/tty5", stderr="/dev/tty5",
+                                        searchPath=1)
+        except Exception as e:
+            raise FSError("Could not load %s kernel module: %s" % (self._module, e))
+
+        if rc:
+            raise FSError("Could not load %s kernel module." % self._module)
+
     def mount(self, *args, **kwargs):
         """ Mount this filesystem.
 
@@ -821,6 +837,7 @@ class BTRFS(FS):
     """ btrfs filesystem """
     _type = "btrfs"
     _mkfs = "mkfs.btrfs"
+    _module = "btrfs"
     _resizefs = "btrfsctl"
     _formattable = True
     _linuxNative = True
@@ -832,6 +849,12 @@ class BTRFS(FS):
     _packages = ["btrfs-progs"]
     _maxSize = 16 * 1024 * 1024
 
+    def __init__(self, *args, **kwargs):
+        if self.supported:
+            self.loadModule()
+
+        FS.__init__(self, *args, **kwargs)
+
     def _getFormatOptions(self, options=None):
         argv = []
         if options and isinstance(options, list):
@@ -863,6 +886,7 @@ class GFS2(FS):
     """ gfs2 filesystem. """
     _type = "gfs2"
     _mkfs = "mkfs.gfs2"
+    _module = "gfs2"
     _formattable = True
     _defaultFormatOptions = ["-j", "1", "-p", "lock_nolock", "-O"]
     _linuxNative = True
@@ -871,6 +895,12 @@ class GFS2(FS):
     _check = True
     _packages = ["gfs2-utils"]
 
+    def __init__(self, *args, **kwargs):
+        if self.supported:
+            self.loadModule()
+
+        FS.__init__(self, *args, **kwargs)
+
     @property
     def supported(self):
         """ Is this filesystem a supported type? """
@@ -887,6 +917,7 @@ class JFS(FS):
     """ JFS filesystem """
     _type = "jfs"
     _mkfs = "mkfs.jfs"
+    _module = "jfs"
     _labelfs = "jfs_tune"
     _defaultFormatOptions = ["-q"]
     _defaultLabelOptions = ["-L"]
@@ -898,6 +929,12 @@ class JFS(FS):
     _dump = True
     _check = True
 
+    def __init__(self, *args, **kwargs):
+        if self.supported:
+            self.loadModule()
+
+        FS.__init__(self, *args, **kwargs)
+
     @property
     def supported(self):
         """ Is this filesystem a supported type? """
-- 
1.6.1.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