summaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorEric Andersen2004-06-22 10:43:09 +0000
committerEric Andersen2004-06-22 10:43:09 +0000
commitd943837dab6eb2b2809426c0e81f7b8e8cf82208 (patch)
treec819a81d5140817a34d93a383de5ebb0ecb0d278 /modutils
parent4872ed9737c1349aec2f41b1b8a905a9158da5c1 (diff)
downloadbusybox-d943837dab6eb2b2809426c0e81f7b8e8cf82208.zip
busybox-d943837dab6eb2b2809426c0e81f7b8e8cf82208.tar.gz
Patrick Huesmann writes:
Hi, There was some problem with busybox modprobe. For details see http://www.busybox.net/lists/busybox/2004-May/011507.html I made a patch against busybox-1.00-pre10 to fix that one. This is a slight variant of Patrick's patch with a slightly cleaner implementation of mod_strcmp() -Erik
Diffstat (limited to 'modutils')
-rw-r--r--modutils/Config.in8
-rw-r--r--modutils/modprobe.c29
2 files changed, 30 insertions, 7 deletions
diff --git a/modutils/Config.in b/modutils/Config.in
index faccee8..45569cc 100644
--- a/modutils/Config.in
+++ b/modutils/Config.in
@@ -21,16 +21,16 @@ config CONFIG_FEATURE_2_2_MODULES
config CONFIG_FEATURE_2_4_MODULES
bool " Support version 2.1.x to 2.4.x Linux kernels"
default y
- depends on CONFIG_INSMOD
+ depends on CONFIG_INSMOD && !CONFIG_FEATURE_2_6_MODULES
help
- Support module loading for newer (post 2.1) Linux kernels.
+ Support module loading for 2.2.x and 2.4.x Linux kernels.
config CONFIG_FEATURE_2_6_MODULES
bool " Support version 2.6.x Linux kernels"
default n
- depends on CONFIG_INSMOD
+ depends on CONFIG_INSMOD && !CONFIG_FEATURE_2_4_MODULES
help
- Support module loading for newer (post 2.1) Linux kernels.
+ Support module loading for 2.6.x Linux kernels.
config CONFIG_FEATURE_INSMOD_VERSION_CHECKING
bool " Module version checking"
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index df5d4bb..c584d8a 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -182,7 +182,7 @@ static struct dep_t *build_dep ( void )
if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
ext = 2;
- mod = bb_xstrndup ( mods, col - mods - ext );
+ mod = bb_xstrndup ( buffer, col - buffer );
if ( !current ) {
first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
@@ -354,6 +354,28 @@ static struct dep_t *build_dep ( void )
return first;
}
+/* check if /lib/modules/bar/foo.ko belongs to module foo */
+/* return 1 = found, 0 = not found */
+static int mod_strcmp ( const char *mod_path, const char *mod_name )
+{
+#if defined(CONFIG_FEATURE_2_6_MODULES)
+#define MODULE_EXTENSION ".ko"
+#define MOD_EXTENSION_LEN 3
+#else
+#define MODULE_EXTENSION ".o"
+#define MOD_EXTENSION_LEN 2
+#endif
+ if ((strstr (mod_path, mod_name) ==
+ (mod_path + strlen(mod_path) -
+ strlen(mod_name) - MOD_EXTENSION_LEN))
+ && (!strcmp(mod_path + strlen(mod_path) -
+ MOD_EXTENSION_LEN, MODULE_EXTENSION)))
+ {
+ return 1;
+ }
+ return 0;
+}
+
/* return 1 = loaded, 0 = not loaded, -1 = can't tell */
static int already_loaded (const char *name)
{
@@ -370,7 +392,7 @@ static int already_loaded (const char *name)
p = strchr (buffer, ' ');
if (p) {
*p = 0;
- if (strcmp (name, buffer) == 0) {
+ if (mod_strcmp (name, buffer)) {
close (fd);
return 1;
}
@@ -434,7 +456,8 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
// check dependencies
for ( dt = depend; dt; dt = dt-> m_next ) {
- if ( strcmp ( dt-> m_module, mod ) == 0 ) {
+ if ( mod_strcmp ( dt-> m_module, mod )) {
+ mod = dt-> m_module;
opt = dt-> m_options;
break;
}