Added missing defines and a prototype so that the code compiles.

Removed old code that is neither supported nor working anymore
This commit is contained in:
Joey Schulze 2007-05-25 18:01:26 +00:00
parent 288188d159
commit d9a3b7ff55
2 changed files with 17 additions and 51 deletions

View File

@ -98,39 +98,17 @@
#include "module.h" #include "module.h"
#if !defined(__GLIBC__) #if !defined(__GLIBC__)
#include <linux/time.h> #include <linux/time.h>
#include <linux/linkage.h>
#else /* __GLIBC__ */
#include <linux/linkage.h>
extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
extern int get_kernel_syms __P ((struct kernel_sym *__table));
#endif /* __GLIBC__ */ #endif /* __GLIBC__ */
#include <stdarg.h> #include <stdarg.h>
#include <paths.h> #include <paths.h>
#include <linux/version.h> #include <linux/version.h>
#undef LINUX_VERSION_CODE
#define LINUX_VERSION_CODE 0x20110
#include "klogd.h" #include "klogd.h"
#include "ksyms.h" #include "ksyms.h"
#if !defined(__GLIBC__)
/*
* The following bit uses some kernel/library magic to produce what
* looks like a function call to user level code. This function is
* actually a system call in disguise. The purpose of the getsyms
* call is to return a current copy of the in-kernel symbol table.
*/
#define __LIBRARY__
#include <linux/unistd.h>
#define __NR_getsyms __NR_get_kernel_syms
_syscall1(int, getsyms, struct kernel_sym *, syms);
#undef __LIBRARY__
extern int getsyms(struct kernel_sym *);
#else /* __GLIBC__ */
#define getsyms get_kernel_syms
#endif /* __GLIBC__ */
extern int query_module(const char *, int, void *, size_t, size_t *);
/* Variables static to this module. */ /* Variables static to this module. */
struct sym_table struct sym_table
{ {
@ -145,9 +123,7 @@ struct Module
char *name; char *name;
struct module module; struct module module;
#if LINUX_VERSION_CODE >= 0x20112
struct module_info module_info; struct module_info module_info;
#endif
}; };
static int num_modules = 0; static int num_modules = 0;
@ -191,8 +167,7 @@ extern int InitMsyms()
auto size_t rtn; auto size_t rtn;
auto int tmp; auto int tmp;
auto char **mod_table, auto char **mod_table;
**p;
char *modbuf = NULL, char *modbuf = NULL,
*newbuf; *newbuf;
@ -608,15 +583,9 @@ extern char * LookupModuleSymbol(value, sym)
* If it is in this range we can at least return the * If it is in this range we can at least return the
* name of the module. * name of the module.
*/ */
#if LINUX_VERSION_CODE < 0x20112
if ( (void *) value >= mp->module.addr &&
(void *) value <= (mp->module.addr + \
mp->module.size * 4096) )
#else
if ( value >= mp->module_info.addr && if ( value >= mp->module_info.addr &&
value <= (mp->module_info.addr + \ value <= (mp->module_info.addr + \
mp->module.size * 4096) ) mp->module.size * 4096) )
#endif
{ {
/* /*
* A special case needs to be checked for. The above * A special case needs to be checked for. The above
@ -635,13 +604,8 @@ extern char * LookupModuleSymbol(value, sym)
if ( mp->num_syms > 0 ) if ( mp->num_syms > 0 )
{ {
last = &mp->sym_array[mp->num_syms - 1]; last = &mp->sym_array[mp->num_syms - 1];
#if LINUX_VERSION_CODE < 0x20112
sym->size = (int) mp->module.addr + \
(mp->module.size * 4096) - value;
#else
sym->size = (int) mp->module_info.addr + \ sym->size = (int) mp->module_info.addr + \
(mp->module.size * 4096) - value; (mp->module.size * 4096) - value;
#endif
sym->offset = value - last->value; sym->offset = value - last->value;
return(last->name); return(last->name);
} }
@ -652,11 +616,7 @@ extern char * LookupModuleSymbol(value, sym)
* faulting address in the module. * faulting address in the module.
*/ */
sym->size = mp->module.size * 4096; sym->size = mp->module.size * 4096;
#if LINUX_VERSION_CODE < 0x20112
sym->offset = (void *) value - mp->module.addr;
#else
sym->offset = value - mp->module_info.addr; sym->offset = value - mp->module_info.addr;
#endif
return(mp->name); return(mp->name);
} }
} }

View File

@ -33,15 +33,18 @@
#define MODULE_NAME_LEN 60 #define MODULE_NAME_LEN 60
struct kernel_sym /* Values for query_module's which. */
#define QM_MODULES 1
#define QM_DEPS 2
#define QM_REFS 3
#define QM_SYMBOLS 4
#define QM_INFO 5
struct module_symbol
{ {
unsigned long value; unsigned long value;
char name[MODULE_NAME_LEN]; unsigned long name;
};
struct list_head {
struct list_head *next, *prev;
}; };
@ -89,3 +92,6 @@ struct module
const struct module_persist *persist_end; const struct module_persist *persist_end;
int (*can_unload)(void); int (*can_unload)(void);
}; };
int query_module(const char *, int, void *, size_t, size_t *);