patch-2.0.34 linux/kernel/module.c
Next file: linux/kernel/panic.c
Previous file: linux/kernel/ksyms.c
Back to the patch index
Back to the overall index
- Lines: 64
- Date:
Wed Jun 3 15:17:50 1998
- Orig file:
v2.0.33/linux/kernel/module.c
- Orig date:
Tue May 21 02:00:30 1996
diff -u --recursive --new-file v2.0.33/linux/kernel/module.c linux/kernel/module.c
@@ -86,7 +86,7 @@
int sspace = sizeof(struct module) + MOD_MAX_NAME;
char name[MOD_MAX_NAME];
- if (!suser())
+ if (!suser() || securelevel > 0)
return -EPERM;
if (module_name == NULL || size == 0)
return -EINVAL;
@@ -138,7 +138,7 @@
int error;
struct mod_routines rt;
- if (!suser())
+ if (!suser() || securelevel > 0)
return -EPERM;
#ifdef __i386__
@@ -264,7 +264,7 @@
char name[MOD_MAX_NAME];
int error;
- if (!suser())
+ if (!suser() || securelevel > 0)
return -EPERM;
/* else */
if (module_name != NULL) {
@@ -594,6 +594,36 @@
if (len > length)
len = length;
return len;
+}
+
+/*
+ * Gets the address for a symbol in the given module. If modname is
+ * NULL, it looks for the name in any registered symbol table. If the
+ * modname is an empty string, it looks for the symbol in kernel exported
+ * symbol tables.
+ */
+void *get_module_symbol(char *modname, char *symname)
+{
+ struct module *mp;
+ struct internal_symbol *sym;
+ int i;
+
+ for (mp = module_list; mp; mp = mp->next) {
+ if (((modname == NULL) || (strcmp(mp->name, modname) == 0)) &&
+ (mp->state == MOD_RUNNING) &&
+ (mp->symtab != NULL) &&
+ (mp->symtab->n_symbols > 0)) {
+ for (i = mp->symtab->n_symbols,
+ sym = mp->symtab->symbol;
+ i > 0; --i, ++sym) {
+
+ if (strcmp(sym->name, symname) == 0) {
+ return sym->addr;
+ }
+ }
+ }
+ }
+ return NULL;
}
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov