summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-06-18 15:09:33 +0000
committerbrian <brian@FreeBSD.org>2001-06-18 15:09:33 +0000
commita08eb62a0db12d6362d89519e448d374fdbf107f (patch)
treeaef7cdfd4c4121315b60d9903274c6ae3b414ae6 /sys/kern/kern_linker.c
parent9e23c5414a9864827bcfc597536c8cb987d988dd (diff)
downloadFreeBSD-src-a08eb62a0db12d6362d89519e448d374fdbf107f.zip
FreeBSD-src-a08eb62a0db12d6362d89519e448d374fdbf107f.tar.gz
Add linker_reference_module().
This function loads a module if required, otherwise bumps the reference count -- the opposite of linker_file_unload().
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index abd7fdd..2eb6a9f 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -331,6 +331,31 @@ out:
return error;
}
+int
+linker_reference_module(const char *modname, linker_file_t *result)
+{
+ char *pathname;
+ int res;
+
+ /*
+ * There will be a system to look up or guess a file name from
+ * a module name.
+ * For now we just try to load a file with the same name.
+ */
+ if ((pathname = linker_search_path(modname)) == NULL)
+ return (ENOENT);
+
+ /*
+ * If the module is already loaded or built into the kernel,
+ * linker_load_file() simply bumps it's refcount.
+ */
+ res = linker_load_file(pathname, result);
+
+ free(pathname, M_LINKER);
+
+ return (res);
+}
+
linker_file_t
linker_find_file_by_name(const char* filename)
{
OpenPOWER on IntegriCloud