+ Check if the compiled module matches the currently running kernel.
[lufs.git] / kernel / Linux / prepmod.in
index 2f9eb4e..7183d2c 100755 (executable)
@@ -156,6 +156,12 @@ else {
                if (build($kernel,$uname_r,$_)) {
                        do { cluck "Failed to symlink $_"; next; }
                                        if _system "/bin/rm -rf $moduledir; /bin/mkdir -p $moduledir; /bin/ln -s $_ $moduledir/$lufs_o";
+                       # Check if the compiled module matches the currently running kernel.
+                       # We may found some unspecific sources ('/usr/src/linux/'?) not matching the current kernel.
+                       # It still may be worth to try precompiled modules and/or give suggestive error messages.
+                       # Do not: /sbin/insmod -o lufs -p $_ 2>/dev/null
+                       # as 2.6 insmod has no options at all.
+                       next if _system "/sbin/rmmod lufs 2>/dev/null; /sbin/insmod $moduledir/$lufs_o 2>/dev/null";
                        _pass 1;
                        }
                }