summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1999-01-05 20:24:28 +0000
committermsmith <msmith@FreeBSD.org>1999-01-05 20:24:28 +0000
commit4fdc7a54c77192cc93106348a874f979a04adddd (patch)
treed60a0a88ae17106858108a798cf8efcf3b552093 /sys/kern
parentffaaca5874a2e0b773197f6c600449c2e383d5d8 (diff)
downloadFreeBSD-src-4fdc7a54c77192cc93106348a874f979a04adddd.zip
FreeBSD-src-4fdc7a54c77192cc93106348a874f979a04adddd.tar.gz
Don't allow more than one module with the same name to be loaded.
Make kldfind ignore the path when searching for a loaded module. Submitted by: John Birrell (jb@freebsd.org)
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_linker.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 04bd206..6eb229e 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.16 1998/11/10 08:49:28 peter Exp $
+ * $Id: kern_linker.c,v 1.17 1998/11/11 13:04:39 peter Exp $
*/
#include "opt_ddb.h"
@@ -596,7 +596,7 @@ linker_ddb_symbol_values(linker_sym_t sym, linker_symval_t *symval)
int
kldload(struct proc* p, struct kldload_args* uap)
{
- char* filename = NULL;
+ char* filename = NULL, *modulename;
linker_file_t lf;
int error = 0;
@@ -612,6 +612,15 @@ kldload(struct proc* p, struct kldload_args* uap)
if (error = copyinstr(SCARG(uap, file), filename, MAXPATHLEN, NULL))
goto out;
+ /* Can't load more than one module with the same name */
+ modulename = rindex(filename, '/');
+ if (modulename == NULL)
+ modulename = filename;
+ if (linker_find_file_by_name(modulename)) {
+ error = EEXIST;
+ goto out;
+ }
+
if (error = linker_load_file(filename, &lf))
goto out;
@@ -656,7 +665,7 @@ out:
int
kldfind(struct proc* p, struct kldfind_args* uap)
{
- char* filename = NULL;
+ char* filename = NULL, *modulename;
linker_file_t lf;
int error = 0;
@@ -666,7 +675,11 @@ kldfind(struct proc* p, struct kldfind_args* uap)
if (error = copyinstr(SCARG(uap, file), filename, MAXPATHLEN, NULL))
goto out;
- lf = linker_find_file_by_name(filename);
+ modulename = rindex(filename, '/');
+ if (modulename == NULL)
+ modulename = filename;
+
+ lf = linker_find_file_by_name(modulename);
if (lf)
p->p_retval[0] = lf->id;
else
OpenPOWER on IntegriCloud