Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 May 2001 14:50:03 +0700 (ALMST)
From:      Boris Popov <bp@butya.kz>
To:        Matthew Emmerton <matt@gsicomp.on.ca>
Cc:        freebsd-stable@freebsd.org, peter@freebsd.org, archie@freebsd.org
Subject:   Re: Broken module loading and kernel dependencies
Message-ID:  <Pine.BSF.4.21.0105151443260.75520-200000@lion.butya.kz>
In-Reply-To: <002101c0d667$b0a7b3d0$1200a8c0@gsicomp.on.ca>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Sun, 6 May 2001, Matthew Emmerton wrote:

> I took a look through a whole bunch of kernel code (hoping to do a MFC on my
> own -STABLE machines), but it looks like the fix for this will involve much
> of the code to be updated to revs that include "First round implementation
> of a fine grain enhanced module to module version dependency system.",
> committed by peter.  Sources that need to be updated include:
[skip]

	These changes are too intrusive (at least Peter don't let get 'em
into 4.3). In addition, -current handles modules in a different way. The
much more simple fix which doesn't break binary compatibility is attached.

P.S. sorry for delay - hard drives likes to die without warnings...
--
Boris Popov
http://www.butya.kz/~bp/

[-- Attachment #2 --]
Index: kern/kern_linker.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_linker.c,v
retrieving revision 1.41.2.2
diff -u -r1.41.2.2 kern_linker.c
--- kern/kern_linker.c	2000/07/16 13:13:32	1.41.2.2
+++ kern/kern_linker.c	2001/05/15 07:42:27
@@ -88,7 +88,7 @@
     return 0;
 }
 
-static void
+static int
 linker_file_sysinit(linker_file_t lf)
 {
     struct linker_set* sysinits;
@@ -106,19 +106,22 @@
 
     KLD_DPF(FILE, ("linker_file_sysinit: SYSINITs %p\n", sysinits));
     if (!sysinits)
-	return;
+	return 0;
 
     /* HACK ALERT! */
     for (sipp = (struct sysinit **)sysinits->ls_items; *sipp; sipp++) {
 	if ((*sipp)->func == module_register_init) {
 	    moddata = (*sipp)->udata;
 	    error = module_register(moddata, lf);
-	    if (error)
+	    if (error) {
 		printf("linker_file_sysinit \"%s\" failed to register! %d\n",
 		    lf->filename, error);
+		return error;
+	    }
 	}
     }
-	    
+    lf->flags |= LINKER_FILE_MODREG;
+
     /*
      * Perform a bubble sort of the system initialization objects by
      * their subsystem (primary key) and order (secondary key).
@@ -150,6 +153,7 @@
 	/* Call function */
 	(*((*sipp)->func))((*sipp)->udata);
     }
+    return 0;
 }
 
 static void
@@ -282,8 +286,11 @@
 	    foundfile = 1;
 	if (lf) {
 	    linker_file_register_sysctls(lf);
-	    linker_file_sysinit(lf);
-
+	    error = linker_file_sysinit(lf);
+	    if (error) {
+		linker_file_unload(lf);
+		goto out;
+	    }
 	    *result = lf;
 	    error = 0;
 	    goto out;
@@ -410,7 +417,8 @@
 	    /*
 	     * Give the module a chance to veto the unload.
 	     */
-	    if ((error = module_unload(mod)) != 0) {
+	    if ((file->flags & LINKER_FILE_MODREG) &&
+		(error = module_unload(mod)) != 0) {
 		KLD_DPF(FILE, ("linker_file_unload: module %x vetoes unload\n",
 			       mod));
 		lockmgr(&lock, LK_RELEASE, 0, curproc);
Index: sys/linker.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/linker.h,v
retrieving revision 1.17
diff -u -r1.17 linker.h
--- sys/linker.h	1999/12/29 04:24:43	1.17
+++ sys/linker.h	2001/05/15 07:42:27
@@ -89,6 +89,7 @@
     int			userrefs;	/* kldload(2) count */
     int			flags;
 #define LINKER_FILE_LINKED	0x1	/* file has been fully linked */
+#define	LINKER_FILE_MODREG	0x2	/* modules registered */
     TAILQ_ENTRY(linker_file) link;	/* list of all loaded files */
     char*		filename;	/* file which was loaded */
     int			id;		/* unique id */

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0105151443260.75520-200000>