summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-06-20 20:54:13 +0000
committerjhb <jhb@FreeBSD.org>2006-06-20 20:54:13 +0000
commit232160a8fb1fdc8bb506f4ae92a5b277314e5b11 (patch)
treed8e5ccc7371d1f67ab824f045af9fcf1f1446b20 /sys/kern/kern_linker.c
parent13b4d6433549f362069fbe0a26fef8d45822616d (diff)
downloadFreeBSD-src-232160a8fb1fdc8bb506f4ae92a5b277314e5b11.zip
FreeBSD-src-232160a8fb1fdc8bb506f4ae92a5b277314e5b11.tar.gz
- Push Giant down into linker_reference_module().
- Add a new function linker_release_module() as a more intuitive complement to linker_reference_module() that wraps linker_file_unload(). linker_release_module() can either take the module name and version info passed to linker_reference_module() or it can accept the linker file object returned by linker_reference_module().
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 003b708..6eb62b6 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -415,14 +415,44 @@ linker_reference_module(const char *modname, struct mod_depend *verinfo,
linker_file_t *result)
{
modlist_t mod;
+ int error;
+ mtx_lock(&Giant);
if ((mod = modlist_lookup2(modname, verinfo)) != NULL) {
*result = mod->container;
(*result)->refs++;
+ mtx_unlock(&Giant);
return (0);
}
- return (linker_load_module(NULL, modname, NULL, verinfo, result));
+ error = linker_load_module(NULL, modname, NULL, verinfo, result);
+ mtx_unlock(&Giant);
+ return (error);
+}
+
+int
+linker_release_module(const char *modname, struct mod_depend *verinfo,
+ linker_file_t lf)
+{
+ modlist_t mod;
+ int error;
+
+ mtx_lock(&Giant);
+ if (lf == NULL) {
+ KASSERT(modname != NULL,
+ ("linker_release_module: no file or name"));
+ mod = modlist_lookup2(modname, verinfo);
+ if (mod == NULL) {
+ mtx_unlock(&Giant);
+ return (ESRCH);
+ }
+ lf = mod->container;
+ } else
+ KASSERT(modname == NULL && verinfo == NULL,
+ ("linker_release_module: both file and name"));
+ error = linker_file_unload(lf, LINKER_UNLOAD_NORMAL);
+ mtx_unlock(&Giant);
+ return (error);
}
static linker_file_t
OpenPOWER on IntegriCloud