* Restructured (and partly rewritten) by:
* Björn Ekwall <bj0rn@blox.se> February 1999
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#define CONFIG_USE_SINGLE
/* the SH changes have only been tested in =little endian= mode */
/* I'm not sure about big endian, so let's warn: */
-#if defined(__sh__) && defined(__BIG_ENDIAN__)
-#error insmod.c may require changes for use on big endian SH
+#if defined(__sh__) && BB_BIG_ENDIAN
+# error insmod.c may require changes for use on big endian SH
#endif
/* it may or may not work on the SH1/SH2... Error on those also */
#if ((!(defined(__SH3__) || defined(__SH4__) || defined(__SH5__)))) && (defined(__sh__))
#ifndef MODUTILS_MODULE_H
-static const int MODUTILS_MODULE_H = 1;
+/* Why? static const int MODUTILS_MODULE_H = 1;*/
#ident "$Id: insmod.c,v 1.126 2004/12/26 09:13:32 vapier Exp $"
#undef tgt_sizeof_char_p
#undef tgt_sizeof_void_p
#undef tgt_long
-static const int tgt_sizeof_long = 8;
-static const int tgt_sizeof_char_p = 8;
-static const int tgt_sizeof_void_p = 8;
+enum {
+ tgt_sizeof_long = 8,
+ tgt_sizeof_char_p = 8,
+ tgt_sizeof_void_p = 8
+};
#define tgt_long long long
#endif
};
/* Bits of module.flags. */
-static const int NEW_MOD_RUNNING = 1;
-static const int NEW_MOD_DELETED = 2;
-static const int NEW_MOD_AUTOCLEAN = 4;
-static const int NEW_MOD_VISITED = 8;
-static const int NEW_MOD_USED_ONCE = 16;
+enum {
+ NEW_MOD_RUNNING = 1,
+ NEW_MOD_DELETED = 2,
+ NEW_MOD_AUTOCLEAN = 4,
+ NEW_MOD_VISITED = 8,
+ NEW_MOD_USED_ONCE = 16
+};
int init_module(const char *name, const struct new_module *);
int query_module(const char *name, int which, void *buf,
size_t bufsize, size_t *ret);
/* Values for query_module's which. */
-
-static const int QM_MODULES = 1;
-static const int QM_DEPS = 2;
-static const int QM_REFS = 3;
-static const int QM_SYMBOLS = 4;
-static const int QM_INFO = 5;
+enum {
+ QM_MODULES = 1,
+ QM_DEPS = 2,
+ QM_REFS = 3,
+ QM_SYMBOLS = 4,
+ QM_INFO = 5
+};
/*======================================================================*/
/* The system calls unchanged between 2.0 and 2.1. */
#ifndef MODUTILS_OBJ_H
-static const int MODUTILS_OBJ_H = 1;
+/* Why? static const int MODUTILS_OBJ_H = 1; */
#ident "$Id: insmod.c,v 1.126 2004/12/26 09:13:32 vapier Exp $"
#include <elf.h>
#include <endian.h>
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define ELFDATAM ELFDATA2LSB
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define ELFDATAM ELFDATA2MSB
-#endif
-
#ifndef ElfW
# if ELFCLASSM == ELFCLASS32
# define ElfW(x) Elf32_ ## x
ElfW(RelM) *rel, ElfW(Addr) value);
static void arch_create_got (struct obj_file *f);
-
+#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
static int obj_gpl_license(struct obj_file *f, const char **license);
-
+#endif /* ENABLE_FEATURE_CHECK_TAINTED_MODULE */
#endif /* obj.h */
//----------------------------------------------------------------------------
//--------end of modutils obj.h
#define _PATH_MODULES "/lib/modules"
-static const int STRVERSIONLEN = 32;
+enum { STRVERSIONLEN = 32 };
/*======================================================================*/
}
break;
+#elif defined(__powerpc64__)
+ /* PPC64 needs a 2.6 kernel, 2.4 module relocation irrelevant */
+
#elif defined(__powerpc__)
case R_PPC_ADDR16_HA:
return NULL;
}
if (f->header.e_ident[EI_CLASS] != ELFCLASSM
- || f->header.e_ident[EI_DATA] != ELFDATAM
+ || f->header.e_ident[EI_DATA] != (BB_BIG_ENDIAN
+ ? ELFDATA2MSB : ELFDATA2LSB)
|| f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) {
bb_error_msg("ELF file not for this architecture");
#endif
-extern int insmod_main( int argc, char **argv)
+int insmod_main( int argc, char **argv)
{
int opt;
int len;
#ifdef CONFIG_FEATURE_CLEAN_UP
if(fp)
fclose(fp);
- if(tmp1) {
- free(tmp1);
- } else {
+ free(tmp1);
+ if(!tmp1) {
free(m_name);
}
free(m_filename);
}
}
-extern int insmod_ng_main( int argc, char **argv)
+int insmod_ng_main( int argc, char **argv)
{
int i;
int fd;
strcat(options, " ");
}
- if ((fd = open(filename, O_RDONLY, 0)) < 0) {
- bb_perror_msg_and_die("cannot open module `%s'", filename);
- }
+ fd = bb_xopen3(filename, O_RDONLY, 0);
fstat(fd, &st);
len = st.st_size;