summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-01-17 17:58:52 +0000
committerpeter <peter@FreeBSD.org>1999-01-17 17:58:52 +0000
commit66afdef4692b6a9f8e4865b0000b63c776b03473 (patch)
tree0f38461300f770684eca75c05a33f7039e752aac /sys/kern/kern_linker.c
parentd94a9bb5f67ca36540c58fd2ee2dd1e127c59734 (diff)
downloadFreeBSD-src-66afdef4692b6a9f8e4865b0000b63c776b03473.zip
FreeBSD-src-66afdef4692b6a9f8e4865b0000b63c776b03473.tar.gz
Try and clean up the multiple formal loading support a bit, based on
suggestions from Greg Lehey some time ago. In the face of multiple potential file formats, try and give a more sensible error than just ENOEXEC. XXX a good case can be made that the loading process is wrong - the linker should locate the file first (using the search paths etc), then run the loaders to see if they recognize it. While the present system allows for the possibility of different search paths for different formats, we do not use it and it just makes things more complicated than they need to be.
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 6eb229e..4900784 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: kern_linker.c,v 1.17 1998/11/11 13:04:39 peter Exp $
+ * $Id: kern_linker.c,v 1.18 1999/01/05 20:24:28 msmith Exp $
*/
#include "opt_ddb.h"
@@ -237,7 +237,7 @@ linker_load_file(const char* filename, linker_file_t* result)
{
linker_class_t lc;
linker_file_t lf;
- int error = 0;
+ int foundfile, error = 0;
char *koname = NULL;
lf = linker_find_file_by_name(filename);
@@ -255,16 +255,20 @@ linker_load_file(const char* filename, linker_file_t* result)
}
sprintf(koname, "%s.ko", filename);
lf = NULL;
+ foundfile = 0;
for (lc = TAILQ_FIRST(&classes); lc; lc = TAILQ_NEXT(lc, link)) {
KLD_DPF(FILE, ("linker_load_file: trying to load %s as %s\n",
filename, lc->desc));
- error = lc->ops->load_file(koname, &lf);
- if (lf == NULL && error && error != ENOENT)
- goto out;
- if (lf == NULL)
- error = lc->ops->load_file(filename, &lf);
- if (lf == NULL && error && error != ENOENT)
- goto out;
+
+ error = lc->ops->load_file(koname, &lf); /* First with .ko */
+ if (lf == NULL && error == ENOENT)
+ error = lc->ops->load_file(filename, &lf); /* Then try without */
+ /*
+ * If we got something other than ENOENT, then it exists but we cannot
+ * load it for some other reason.
+ */
+ if (error != ENOENT)
+ foundfile = 1;
if (lf) {
linker_file_sysinit(lf);
@@ -273,7 +277,14 @@ linker_load_file(const char* filename, linker_file_t* result)
goto out;
}
}
- error = ENOEXEC; /* format not recognised */
+ /*
+ * Less than ideal, but tells the user whether it failed to load or
+ * the module was not found.
+ */
+ if (foundfile)
+ error = ENOEXEC; /* Format not recognised (or unloadable) */
+ else
+ error = ENOENT; /* Nothing found */
out:
if (koname)
OpenPOWER on IntegriCloud