diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2006-06-20 20:54:13 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2006-06-20 20:54:13 +0000 |
| commit | aeeb017bd6261c97c3dac20c24c14a8851f595cd (patch) | |
| tree | d8e5ccc7371d1f67ab824f045af9fcf1f1446b20 /sys/kern/kern_linker.c | |
| parent | f05446648bd84e435be17c2d4bd1f8347f10e12c (diff) | |
Notes
Diffstat (limited to 'sys/kern/kern_linker.c')
| -rw-r--r-- | sys/kern/kern_linker.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 003b70816878..6eb62b6cfda5 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 |
