/* The system calls unchanged between 2.0 and 2.1. */
unsigned long create_module(const char *, size_t);
-int delete_module(const char *);
+int delete_module(const char *module, unsigned int flags);
#endif /* module.h */
#define SPFX ""
#endif
-
-#define _PATH_MODULES "/lib/modules"
enum { STRVERSIONLEN = 64 };
/*======================================================================*/
/*======================================================================*/
-static int check_module_name_match(const char *filename,
- struct stat *statbuf ATTRIBUTE_UNUSED,
- void *userdata, int depth ATTRIBUTE_UNUSED)
+static int FAST_FUNC check_module_name_match(const char *filename,
+ struct stat *statbuf UNUSED_PARAM,
+ void *userdata, int depth UNUSED_PARAM)
{
char *fullname = (char *) userdata;
char *tmp;
int newidx = f->header.e_shnum++;
struct obj_section *sec;
- f->sections = xrealloc(f->sections, (newidx + 1) * sizeof(sec));
+ f->sections = xrealloc_vector(f->sections, 2, newidx);
f->sections[newidx] = sec = arch_new_section();
sec->header.sh_type = SHT_PROGBITS;
{
unsigned long oldsize = sec->header.sh_size;
if (more) {
- sec->contents = xrealloc(sec->contents, sec->header.sh_size += more);
+ sec->header.sh_size += more;
+ sec->contents = xrealloc(sec->contents, sec->header.sh_size);
}
return sec->contents + oldsize;
}
retry_kern_sym_load:
if (query_module(NULL, QM_SYMBOLS, syms, bufsize, &ret)) {
if (errno == ENOSPC && bufsize < ret) {
- syms = xrealloc(syms, bufsize = ret);
+ bufsize = ret;
+ syms = xrealloc(syms, bufsize);
goto retry_kern_sym_load;
}
bb_perror_msg_and_die("kernel: QM_SYMBOLS");
sec = obj_find_section(f, ".this");
if (!sec || !sec->contents) {
- bb_perror_msg_and_die("corrupt module %s?",m_name);
+ bb_perror_msg_and_die("corrupt module %s?", m_name);
}
module = (struct new_module *) sec->contents;
m_addr = sec->header.sh_addr;
if (i == f->header.e_shnum) {
struct obj_section *sec;
- f->sections = xrealloc(f->sections, (i + 1) * sizeof(sec));
+ f->sections = xrealloc_vector(f->sections, 2, i);
f->sections[i] = sec = arch_new_section();
f->header.e_shnum = i + 1;
/*======================================================================*/
-static struct obj_file *obj_load(FILE * fp, int loadprogbits ATTRIBUTE_UNUSED)
+static struct obj_file *obj_load(FILE *fp, int loadprogbits UNUSED_PARAM)
{
struct obj_file *f;
ElfW(Shdr) * section_headers;
* kernel for the module
*/
-static int obj_load_progbits(FILE * fp, struct obj_file* f, char* imagebase)
+static int obj_load_progbits(FILE *fp, struct obj_file *f, char *imagebase)
{
ElfW(Addr) base = f->baseaddr;
struct obj_section* sec;
char *module_dir;
char *tmdn;
- tmdn = concat_path_file(_PATH_MODULES, myuname.release);
+ tmdn = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, myuname.release);
/* Jump through hoops in case /lib/modules/`uname -r`
* is a symlink. We do not want recursive_action to
* follow symlinks, but we do want to follow the
free(m_filename);
m_filename = NULL;
- module_dir = xmalloc_readlink(_PATH_MODULES);
+ module_dir = xmalloc_readlink(CONFIG_DEFAULT_MODULES_DIR);
if (!module_dir)
- module_dir = xstrdup(_PATH_MODULES);
+ module_dir = xstrdup(CONFIG_DEFAULT_MODULES_DIR);
/* No module found under /lib/modules/`uname -r`, this
* time cast the net a bit wider. Search /lib/modules/ */
r = recursive_action(module_dir, ACTION_RECURSE,
* now we can load them directly into the kernel memory
*/
if (!obj_load_progbits(fp, f, (char*)m_addr)) {
- delete_module(m_name);
+ delete_module(m_name, 0);
goto out;
}
#endif
if (!obj_relocate(f, m_addr)) {
- delete_module(m_name);
+ delete_module(m_name, 0);
goto out;
}
if (!new_init_module(m_name, f, m_size)) {
- delete_module(m_name);
+ delete_module(m_name, 0);
goto out;
}
#include <sys/mman.h>
-#ifdef __UCLIBC__
+#if defined __UCLIBC__ && !ENABLE_FEATURE_2_4_MODULES
+/* big time suckage. The old prototype above renders our nice fwd-decl wrong */
extern int init_module(void *module, unsigned long len, const char *options);
#else
#include <asm/unistd.h>
#if !ENABLE_FEATURE_2_4_MODULES
int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int insmod_main(int argc ATTRIBUTE_UNUSED, char **argv)
+int insmod_main(int argc UNUSED_PARAM, char **argv)
#else
-static int insmod_ng_main(int argc ATTRIBUTE_UNUSED, char **argv)
+static int insmod_ng_main(int argc UNUSED_PARAM, char **argv)
#endif
{
size_t len;
}
#if 0
- /* Any special reason why mmap? It isn't performace critical... */
-
- /* yes, xmalloc'ing can use *alot* of RAM. Don't forget that there are
+ /* Any special reason why mmap? It isn't performance critical. -vda */
+ /* Yes, xmalloc'ing can use *alot* of RAM. Don't forget that there are
* modules out there that are half a megabyte! mmap()ing is way nicer
- * for small mem boxes, i guess.
- */
+ * for small mem boxes, i guess. */
+ /* But after load, these modules will take up that 0.5mb in kernel
+ * anyway. Using malloc here causes only a transient spike to 1mb,
+ * after module is loaded, we go back to normal 0.5mb usage
+ * (in kernel). Also, mmap isn't magic - when we touch mapped data,
+ * we use memory. -vda */
int fd;
struct stat st;
unsigned long len;