aboutsummaryrefslogtreecommitdiff
path: root/modutils/modprobe.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-06-22 10:43:09 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-06-22 10:43:09 +0000
commit1982f08693a7af3a2c6aeca449f5140151c78b4c (patch)
treec819a81d5140817a34d93a383de5ebb0ecb0d278 /modutils/modprobe.c
parenta190629c14338250f04d55f3c1cf213c312b9241 (diff)
downloadbusybox-w32-1982f08693a7af3a2c6aeca449f5140151c78b4c.tar.gz
busybox-w32-1982f08693a7af3a2c6aeca449f5140151c78b4c.tar.bz2
busybox-w32-1982f08693a7af3a2c6aeca449f5140151c78b4c.zip
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 git-svn-id: svn://busybox.net/trunk/busybox@8916 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'modutils/modprobe.c')
-rw-r--r--modutils/modprobe.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index df5d4bbd1..c584d8a61 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -182,7 +182,7 @@ static struct dep_t *build_dep ( void )
182 if (( *(col-2) == '.' ) && ( *(col-1) == 'o' )) 182 if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
183 ext = 2; 183 ext = 2;
184 184
185 mod = bb_xstrndup ( mods, col - mods - ext ); 185 mod = bb_xstrndup ( buffer, col - buffer );
186 186
187 if ( !current ) { 187 if ( !current ) {
188 first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t )); 188 first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
@@ -354,6 +354,28 @@ static struct dep_t *build_dep ( void )
354 return first; 354 return first;
355} 355}
356 356
357/* check if /lib/modules/bar/foo.ko belongs to module foo */
358/* return 1 = found, 0 = not found */
359static int mod_strcmp ( const char *mod_path, const char *mod_name )
360{
361#if defined(CONFIG_FEATURE_2_6_MODULES)
362#define MODULE_EXTENSION ".ko"
363#define MOD_EXTENSION_LEN 3
364#else
365#define MODULE_EXTENSION ".o"
366#define MOD_EXTENSION_LEN 2
367#endif
368 if ((strstr (mod_path, mod_name) ==
369 (mod_path + strlen(mod_path) -
370 strlen(mod_name) - MOD_EXTENSION_LEN))
371 && (!strcmp(mod_path + strlen(mod_path) -
372 MOD_EXTENSION_LEN, MODULE_EXTENSION)))
373 {
374 return 1;
375 }
376 return 0;
377}
378
357/* return 1 = loaded, 0 = not loaded, -1 = can't tell */ 379/* return 1 = loaded, 0 = not loaded, -1 = can't tell */
358static int already_loaded (const char *name) 380static int already_loaded (const char *name)
359{ 381{
@@ -370,7 +392,7 @@ static int already_loaded (const char *name)
370 p = strchr (buffer, ' '); 392 p = strchr (buffer, ' ');
371 if (p) { 393 if (p) {
372 *p = 0; 394 *p = 0;
373 if (strcmp (name, buffer) == 0) { 395 if (mod_strcmp (name, buffer)) {
374 close (fd); 396 close (fd);
375 return 1; 397 return 1;
376 } 398 }
@@ -434,7 +456,8 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
434 456
435 // check dependencies 457 // check dependencies
436 for ( dt = depend; dt; dt = dt-> m_next ) { 458 for ( dt = depend; dt; dt = dt-> m_next ) {
437 if ( strcmp ( dt-> m_module, mod ) == 0 ) { 459 if ( mod_strcmp ( dt-> m_module, mod )) {
460 mod = dt-> m_module;
438 opt = dt-> m_options; 461 opt = dt-> m_options;
439 break; 462 break;
440 } 463 }