diff options
author | peter <peter@FreeBSD.org> | 1998-11-03 14:27:05 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1998-11-03 14:27:05 +0000 |
commit | 2b6debf094bac2f5d1036c8beae2f16461481b48 (patch) | |
tree | 5404bb87af44317d2acc901e9fc581aba6948ee3 /sys/kern | |
parent | 5e8da6440f41e58a634a2ab063888e816f80df21 (diff) | |
download | FreeBSD-src-2b6debf094bac2f5d1036c8beae2f16461481b48.zip FreeBSD-src-2b6debf094bac2f5d1036c8beae2f16461481b48.tar.gz |
Have the in-kernel linker try a default extension of .ko. This means that
"kldload nfs" works. We use the same default extension in the /boot/loader
system.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_linker.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 081e99a..d46fe78 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.11 1998/10/24 18:35:09 msmith Exp $ + * $Id: kern_linker.c,v 1.12 1998/11/03 13:09:31 peter Exp $ */ #include "opt_ddb.h" @@ -178,6 +178,7 @@ linker_load_file(const char* filename, linker_file_t* result) linker_class_t lc; linker_file_t lf; int error = 0; + char *koname = NULL; lf = linker_find_file_by_name(filename); if (lf) { @@ -187,22 +188,36 @@ linker_load_file(const char* filename, linker_file_t* result) goto out; } + koname = malloc(strlen(filename) + 4, M_LINKER, M_WAITOK); + if (koname == NULL) { + error = ENOMEM; + goto out; + } + sprintf(koname, "%s.ko", filename); lf = NULL; 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)); - if (error = lc->ops->load_file(filename, &lf)) + 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; if (lf) { linker_file_sysinit(lf); *result = lf; + error = 0; goto out; } } error = ENOEXEC; /* format not recognised */ out: + if (koname) + free(koname, M_LINKER); return error; } @@ -210,13 +225,25 @@ linker_file_t linker_find_file_by_name(const char* filename) { linker_file_t lf = 0; + char *koname; + + koname = malloc(strlen(filename) + 4, M_LINKER, M_WAITOK); + if (koname == NULL) + goto out; + sprintf(koname, "%s.ko", filename); lockmgr(&lock, LK_SHARED, 0, curproc); - for (lf = TAILQ_FIRST(&files); lf; lf = TAILQ_NEXT(lf, link)) + for (lf = TAILQ_FIRST(&files); lf; lf = TAILQ_NEXT(lf, link)) { + if (!strcmp(lf->filename, koname)) + break; if (!strcmp(lf->filename, filename)) break; + } lockmgr(&lock, LK_RELEASE, 0, curproc); +out: + if (koname) + free(koname, M_LINKER); return lf; } |