[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.
---
 liveinst/liveinst.sh  |    2 +-
 loader/loader.c       |    4 ++--
 storage/formats/fs.py |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/liveinst/liveinst.sh b/liveinst/liveinst.sh
index cdba58f..844ca06 100644
--- a/liveinst/liveinst.sh
+++ b/liveinst/liveinst.sh
@@ -32,7 +32,7 @@ if [ ! -b $LIVE_BLOCK ]; then
 fi
 
 # load modules that would get loaded by the loader... (#230945)
-for i in raid0 raid1 raid5 raid6 raid456 raid10 fat msdos gfs2 reiserfs ext2 ext3 ext4 jfs xfs btrfs dm-mod dm-zero dm-mirror dm-snapshot dm-multipath dm-round-robin vfat dm-crypt cbc sha256 lrw xts ; do /sbin/modprobe $i 2>/dev/null ; done
+for i in raid0 raid1 raid5 raid6 raid456 raid10 dm-mod dm-zero dm-mirror dm-snapshot dm-multipath dm-round-robin vfat dm-crypt cbc sha256 lrw xts ; do /sbin/modprobe $i 2>/dev/null ; done
 
 export ANACONDA_PRODUCTNAME=$( cat /etc/system-release | cut -d ' ' -f 1 )
 export ANACONDA_PRODUCTVERSION=$( cat /etc/system-release | sed -r -e 's/^.*([0-9]+) *\(.*$/\1/' )
diff --git a/loader/loader.c b/loader/loader.c
index 98ea24c..7b3eb0c 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1919,7 +1919,7 @@ int main(int argc, char ** argv) {
     if (isVioConsole())
         setenv("TERM", "vt100", 1);
 
-    mlLoadModuleSet("cramfs:vfat:nfs:floppy:edd:pcspkr:squashfs:ext4:ext2:iscsi_tcp:iscsi_ibft");
+    mlLoadModuleSet("cramfs:floppy:edd:pcspkr:squashfs:iscsi_tcp:iscsi_ibft");
 
 #ifdef ENABLE_IPV6
     if (!FL_NOIPV6(flags))
@@ -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: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..a14d565 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
@@ -147,6 +148,9 @@ class FS(DeviceFormat):
         if self.__class__ is FS:
             raise TypeError("FS is an abstract class.")
 
+        if self.supported:
+            self.loadModule()
+
         DeviceFormat.__init__(self, *args, **kwargs)
         # TODO: fsprofiles and other ways to add format args
         self.mountpoint = kwargs.get("mountpoint")
@@ -427,6 +431,23 @@ 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 or self._module in kernel_filesystems:
+            return
+
+        try:
+            rc = iutil.execWithRedirect("modprobe", [self._module],
+                                        stdout="/dev/tty5", stderr="/dev/tty5",
+                                        searchPath=1)
+        except Exception as e:
+            log.error("Could not load kernel module %s: %s" % (self._module, e))
+            self._supported = False
+
+        if rc:
+            log.error("Could not load kernel module %s" % self._module)
+            self._supported = False
+
     def mount(self, *args, **kwargs):
         """ Mount this filesystem.
 
@@ -699,6 +720,7 @@ class Ext2FS(FS):
     """ ext2 filesystem. """
     _type = "ext2"
     _mkfs = "mke2fs"
+    _module = "ext2"
     _resizefs = "resize2fs"
     _labelfs = "e2label"
     _fsck = "e2fsck"
@@ -764,6 +786,7 @@ class Ext3FS(Ext2FS):
     _type = "ext3"
     _defaultFormatOptions = ["-t", "ext3"]
     _migrationTarget = "ext4"
+    _module = "ext2"
     _defaultMigrateOptions = ["-O", "extents"]
 
     @property
@@ -781,6 +804,7 @@ class Ext4FS(Ext3FS):
     _bootable = False
     _defaultFormatOptions = ["-t", "ext4"]
     _migratable = False
+    _module = "ext4"
 
 register_device_format(Ext4FS)
 
@@ -789,6 +813,7 @@ class FATFS(FS):
     """ FAT filesystem. """
     _type = "vfat"
     _mkfs = "mkdosfs"
+    _module = "vfat"
     _labelfs = "dosfslabel"
     _fsck = "dosfsck"
     _formattable = True
@@ -801,6 +826,7 @@ register_device_format(FATFS)
 
 class EFIFS(FATFS):
     _type = "efi"
+    _module = "vfat"
     _name = "EFI System Partition"
     _minSize = 50
     _maxSize = 256
@@ -821,6 +847,7 @@ class BTRFS(FS):
     """ btrfs filesystem """
     _type = "btrfs"
     _mkfs = "mkfs.btrfs"
+    _module = "btrfs"
     _resizefs = "btrfsctl"
     _formattable = True
     _linuxNative = True
@@ -863,6 +890,7 @@ class GFS2(FS):
     """ gfs2 filesystem. """
     _type = "gfs2"
     _mkfs = "mkfs.gfs2"
+    _module = "gfs2"
     _formattable = True
     _defaultFormatOptions = ["-j", "1", "-p", "lock_nolock", "-O"]
     _linuxNative = True
@@ -887,6 +915,7 @@ class JFS(FS):
     """ JFS filesystem """
     _type = "jfs"
     _mkfs = "mkfs.jfs"
+    _module = "jfs"
     _labelfs = "jfs_tune"
     _defaultFormatOptions = ["-q"]
     _defaultLabelOptions = ["-L"]
@@ -914,6 +943,7 @@ class XFS(FS):
     """ XFS filesystem """
     _type = "xfs"
     _mkfs = "mkfs.xfs"
+    _module = "xfs"
     _labelfs = "xfs_admin"
     _defaultFormatOptions = ["-f"]
     _defaultLabelOptions = ["-L"]
@@ -932,6 +962,7 @@ register_device_format(XFS)
 class HFS(FS):
     _type = "hfs"
     _mkfs = "hformat"
+    _module = "hfs"
     _formattable = True
 
 register_device_format(HFS)
@@ -956,6 +987,7 @@ register_device_format(AppleBootstrapFS)
 # this doesn't need to be here
 class HFSPlus(FS):
     _type = "hfs+"
+    _module = "hfsplus"
     _udevTypes = ["hfsplus"]
 
 register_device_format(HFSPlus)
@@ -1015,6 +1047,7 @@ register_device_format(NTFS)
 class NFS(FS):
     """ NFS filesystem. """
     _type = "nfs"
+    _module = "nfs"
 
     def _deviceCheck(self, devspec):
         if devspec is not None and ":" not in devspec:
@@ -1041,6 +1074,7 @@ register_device_format(NFS)
 class NFSv4(NFS):
     """ NFSv4 filesystem. """
     _type = "nfs4"
+    _module = "nfs4"
 
 register_device_format(NFSv4)
 
-- 
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