[BusyBox-cvs] busybox/libbb recursive_action.c,1.11,1.12

Erik Andersen andersen at busybox.net
Tue Apr 6 11:56:28 UTC 2004


Update of /var/cvs/busybox/libbb
In directory nail:/tmp/cvs-serv14677/libbb

Modified Files:
	recursive_action.c 
Log Message:
Christian Grigis, christian.grigis at smartdata dot ch writes:

Hello everyone,

Busybox's insmod fails to locate a module when that module is the only one
existing in the /lib/modules directory (with a unique name).

Example:

# find /lib/modules/ -type f
/lib/modules/kernel/drivers/char/bios.o
# insmod bios
insmod: bios.o: no module by that name found
# touch /lib/modules/dummy
# find /lib/modules/ -type f
/lib/modules/kernel/drivers/char/bios.o
/lib/modules/dummy
# insmod bios
Using /lib/modules/kernel/drivers/char/bios.o

As long as there is another file in the /lib/modules directory, insmod
finds it OK.

I tracked the problem down to 'check_module_name_match()' in insmod.c:

It returns TRUE when a match is found, and FALSE otherwise. In the case
where there is only one module in the /lib/modules directory (or more that
one module, but all with the same name), 'recursive_action()' will return
TRUE and we end up on line 4196 in 'insmod.c' which returns an error.
[The reason it works with more than one module with different
names is that in this case there will always be one not matching,
'recursive_action()' will return FALSE and we end up in line 4189.]

Now, from the implementation of 'recursive_action()' and from other
usages of it (tar.c, etc.), it seems to me that FALSE should be returned
to indicate that we want to stop the recursion, so TRUE and FALSE should
be inverted in 'check_module_name_match()'.

At the same time, 'recursive_action()' continues to recurse even after
the recursive call has returned FALSE; again in my understanding and
other usages of it, we can safely stop recursing at this point.


Here is my patch against 1.00-pre8:


Index: recursive_action.c
===================================================================
RCS file: /var/cvs/busybox/libbb/recursive_action.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- a/recursive_action.c	15 Mar 2004 08:28:43 -0000	1.11
+++ b/recursive_action.c	6 Apr 2004 11:56:25 -0000	1.12
@@ -100,7 +100,7 @@
 			return FALSE;
 		}
 		status = TRUE;
-		while ((next = readdir(dir)) != NULL) {
+		while (status && (next = readdir(dir)) != NULL) {
 			char *nextFile;
 
 			nextFile = concat_subpath_file(fileName, next->d_name);




More information about the busybox-cvs mailing list