svn commit: trunk/busybox: include libbb modutils
landley at busybox.net
landley at busybox.net
Wed Jun 14 01:24:41 UTC 2006
Author: landley
Date: 2006-06-13 18:24:33 -0700 (Tue, 13 Jun 2006)
New Revision: 15380
Log:
Attempt at fixing bug 815 by upgrading bb_spawn() so that builtins are at
the start of the path. (This should be under the same config option as
the standalone shell, but right now that's buried in the shell menu.)
Also add the ability to specify CONFIG_BUSYBOX_EXEC_PATH with /proc/self/exe
as an overrideable default.
Modified:
trunk/busybox/Config.in
trunk/busybox/include/libbb.h
trunk/busybox/libbb/xfuncs.c
trunk/busybox/modutils/modprobe.c
Changeset:
Modified: trunk/busybox/Config.in
===================================================================
--- trunk/busybox/Config.in 2006-06-13 21:30:09 UTC (rev 15379)
+++ trunk/busybox/Config.in 2006-06-14 01:24:33 UTC (rev 15380)
@@ -32,6 +32,7 @@
choice
prompt "Buffer allocation policy"
default CONFIG_FEATURE_BUFFERS_USE_MALLOC
+ depends on CONFIG_NITPICK
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
@@ -75,11 +76,17 @@
config CONFIG_FEATURE_COMPRESS_USAGE
bool "Store applet usage messages in compressed form"
default y
- depends on CONFIG_SHOW_USAGE
+ depends on CONFIG_SHOW_USAGE && CONFIG_NITPICK
help
Store usage messages in compressed form, uncompress them on-the-fly
when <applet> --help is called.
+ If you have a really tiny busybox with few applets enabled (and
+ bunzip2 isn't one of them), the overhead of the decompressor might
+ be noticeable. Also, if you run executables directly from ROM
+ and have very little memory, this might not be a win. Otherwise,
+ you probably want this.
+
config CONFIG_FEATURE_INSTALLER
bool "Support --install [-s] to install applet links at runtime"
default n
@@ -99,14 +106,13 @@
config CONFIG_GETOPT_LONG
bool "Enable support for --long-options"
default n
- depends on !CONFIG_NO_GETOPT_LONG
help
Enable this if you want busybox applets to use the gnu --long-option
style, in addition to single character -a -b -c style options.
config CONFIG_FEATURE_DEVPTS
bool "Use the devpts filesystem for Unix98 PTYs"
- default y if CONFIG_FEATURE_DEVFS
+ default y
help
Enable if you want BusyBox to use Unix98 PTY support. If enabled,
busybox will use /dev/ptmx for the master side of the pseudoterminal
@@ -117,6 +123,7 @@
config CONFIG_FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
+ depends on CONFIG_NITPICK
help
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
@@ -201,6 +208,16 @@
Most people will leave this set to 'N'.
+config CONFIG_BUSYBOX_EXEC_PATH
+ string "Path to BusyBox executable"
+ default "/proc/self/exe"
+ help
+ When Busybox applets need to run other busybox applets, BusyBox
+ sometimes needs to exec() itself. When the /proc filesystem is
+ mounted, /proc/self/exe always points to the currently running
+ executable. If you haven't got /proc, set this to wherever you
+ want to run BusyBox from.
+
endmenu
menu 'Build Options'
@@ -221,7 +238,8 @@
config CONFIG_BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
- default y
+ depends on CONFIG_STANDALONE
+ default n
help
Build a shared library libbusybox.so which contains all
libraries used inside busybox.
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2006-06-13 21:30:09 UTC (rev 15379)
+++ trunk/busybox/include/libbb.h 2006-06-14 01:24:33 UTC (rev 15380)
@@ -171,6 +171,7 @@
extern int bb_xsocket(int domain, int type, int protocol);
extern pid_t bb_spawn(char **argv);
extern pid_t bb_xspawn(char **argv);
+extern int wait4pid(int pid);
extern void bb_xdaemon(int nochdir, int noclose);
extern void bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern void bb_xlisten(int s, int backlog);
Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c 2006-06-13 21:30:09 UTC (rev 15379)
+++ trunk/busybox/libbb/xfuncs.c 2006-06-14 01:24:33 UTC (rev 15380)
@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -189,13 +190,14 @@
{
static int failed;
pid_t pid;
+ void *app = find_applet_by_name(argv[0]);
// Be nice to nommu machines.
failed = 0;
pid = vfork();
if (pid < 0) return pid;
if (!pid) {
- execvp(*argv, argv);
+ execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv);
// We're sharing a stack with blocked parent, let parent know we failed
// and then exit to unblock parent (but don't run atexit() stuff, which
@@ -216,3 +218,15 @@
return pid;
}
#endif
+
+#ifdef L_wait4
+int wait4pid(int pid)
+{
+ int status;
+
+ if (pid == -1 || waitpid(pid, &status, 0) == -1) return -1;
+ if (WIFEXITED(status)) return WEXITSTATUS(status);
+ if (WIFSIGNALED(status)) return WTERMSIG(status);
+ return 0;
+}
+#endif
Modified: trunk/busybox/modutils/modprobe.c
===================================================================
--- trunk/busybox/modutils/modprobe.c 2006-06-13 21:30:09 UTC (rev 15379)
+++ trunk/busybox/modutils/modprobe.c 2006-06-14 01:24:33 UTC (rev 15380)
@@ -666,27 +666,8 @@
printf("%s module %s\n", do_insert?"Loading":"Unloading", list-> m_name );
}
if (!show_only) {
- int rc2 = 0;
- int status;
- switch (fork()) {
- case -1:
- rc2 = 1;
- break;
- case 0: //child
- execvp(argv[0], argv);
- bb_perror_msg_and_die("exec of %s", argv[0]);
- /* NOTREACHED */
- default:
- if (wait(&status) == -1) {
- rc2 = 1;
- break;
- }
- if (WIFEXITED(status))
- rc2 = WEXITSTATUS(status);
- if (WIFSIGNALED(status))
- rc2 = WTERMSIG(status);
- break;
- }
+ int rc2 = wait4pid(bb_spawn(argv));
+
if (do_insert) {
rc = rc2; /* only last module matters */
}
More information about the busybox-cvs
mailing list