svn commit: trunk/busybox: include libbb scripts shell util-linux

vda at busybox.net vda at busybox.net
Tue Apr 10 23:03:31 UTC 2007


Author: vda
Date: 2007-04-10 16:03:30 -0700 (Tue, 10 Apr 2007)
New Revision: 18394

Log:
Rename two config options:
FEATURE_SH_STANDALONE_SHELL => FEATURE_SH_STANDALONE
FEATURE_EXEC_PREFER_APPLETS => FEATURE_PREFER_APPLETS
Make SH_STANDALONE depend on PREFER_APPLETS.
getopt.c: more randomconfig-induced fixes


Modified:
   trunk/busybox/Config.in
   trunk/busybox/TODO_config_nommu
   trunk/busybox/include/applets.h
   trunk/busybox/include/busybox.h
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/default_error_retval.c
   trunk/busybox/libbb/error_msg_and_die.c
   trunk/busybox/libbb/execable.c
   trunk/busybox/libbb/fflush_stdout_and_exit.c
   trunk/busybox/libbb/vfork_daemon_rexec.c
   trunk/busybox/scripts/defconfig
   trunk/busybox/shell/Config.in
   trunk/busybox/shell/ash.c
   trunk/busybox/shell/hush.c
   trunk/busybox/shell/lash.c
   trunk/busybox/shell/msh.c
   trunk/busybox/util-linux/getopt.c


Changeset:
Modified: trunk/busybox/Config.in
===================================================================
--- trunk/busybox/Config.in	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/Config.in	2007-04-10 23:03:30 UTC (rev 18394)
@@ -238,7 +238,7 @@
 
 	  Most people will leave this set to 'N'.
 
-config FEATURE_EXEC_PREFER_APPLETS
+config FEATURE_PREFER_APPLETS
 	bool "exec prefers applets"
 	default n
 	help
@@ -462,10 +462,10 @@
 
 config INSTALL_APPLET_DONT
 	bool "not installed"
-	depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL || FEATURE_EXEC_PREFER_APPLETS
+	depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE || FEATURE_PREFER_APPLETS
 	help
 	  Do not install applet links. Useful when using the -install feature
-	  or a standalone shell for rescue pruposes.
+	  or a standalone shell for rescue purposes.
 
 endchoice
 

Modified: trunk/busybox/TODO_config_nommu
===================================================================
--- trunk/busybox/TODO_config_nommu	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/TODO_config_nommu	2007-04-10 23:03:30 UTC (rev 18394)
@@ -35,7 +35,7 @@
 # CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
 # CONFIG_FEATURE_HAVE_RPC is not set
 # CONFIG_SELINUX is not set
-# CONFIG_FEATURE_EXEC_PREFER_APPLETS is not set
+# CONFIG_FEATURE_PREFER_APPLETS is not set
 CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
 
 #
@@ -657,7 +657,7 @@
 # Bourne Shell Options
 #
 CONFIG_FEATURE_SH_EXTRA_QUIET=y
-# CONFIG_FEATURE_SH_STANDALONE_SHELL is not set
+# CONFIG_FEATURE_SH_STANDALONE is not set
 
 #
 # System Logging Utilities

Modified: trunk/busybox/include/applets.h
===================================================================
--- trunk/busybox/include/applets.h	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/include/applets.h	2007-04-10 23:03:30 UTC (rev 18394)
@@ -56,8 +56,8 @@
 # define APPLET(name,l,s)                    { #name, name##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) },
 # define APPLET_NOUSAGE(name,main,l,s)       { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) },
 # define APPLET_ODDNAME(name,main,l,s,name2) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) },
-# define APPLET_NOEXEC(name,main,l,s,name2)  { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_EXEC_PREFER_APPLETS(,1) },
-# define APPLET_NOFORK(name,main,l,s,name2)  { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_EXEC_PREFER_APPLETS(,1 ,1) },
+# define APPLET_NOEXEC(name,main,l,s,name2)  { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_PREFER_APPLETS(,1) },
+# define APPLET_NOFORK(name,main,l,s,name2)  { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_PREFER_APPLETS(,1 ,1) },
 #endif
 
 #if ENABLE_INSTALL_NO_USR

Modified: trunk/busybox/include/busybox.h
===================================================================
--- trunk/busybox/include/busybox.h	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/include/busybox.h	2007-04-10 23:03:30 UTC (rev 18394)
@@ -37,7 +37,7 @@
 #if ENABLE_FEATURE_SUID
 	__extension__ enum bb_suid_t need_suid:8;
 #endif
-#if ENABLE_FEATURE_EXEC_PREFER_APPLETS
+#if ENABLE_FEATURE_PREFER_APPLETS
 	/* true if instead if fork(); exec("applet"); waitpid();
 	 * one can do fork(); exit(applet_main(argc,argv)); waitpid(); */
 	unsigned char noexec;

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/include/libbb.h	2007-04-10 23:03:30 UTC (rev 18394)
@@ -502,7 +502,7 @@
 char *find_execable(const char *filename);
 int exists_execable(const char *filename);
 
-#if ENABLE_FEATURE_EXEC_PREFER_APPLETS
+#if ENABLE_FEATURE_PREFER_APPLETS
 int bb_execvp(const char *file, char *const argv[]);
 #define BB_EXECVP(prog,cmd) bb_execvp(prog,cmd)
 #define BB_EXECLP(prog,cmd,...) \
@@ -609,7 +609,8 @@
 int write_pidfile(const char *path);
 #define remove_pidfile(f) ((void)unlink(f))
 #else
-#define write_pidfile(f)  TRUE
+/* Why? #defining it to 1 gives "warning: statement with no effect"... */
+static ATTRIBUTE_ALWAYS_INLINE int write_pidfile(const char *path) { return 1; }
 #define remove_pidfile(f) ((void)0)
 #endif
 

Modified: trunk/busybox/libbb/default_error_retval.c
===================================================================
--- trunk/busybox/libbb/default_error_retval.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/libbb/default_error_retval.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -13,7 +13,6 @@
  * that too seems silly.
  */
 
-#include <stdlib.h>
 #include "libbb.h"
 
 int xfunc_error_retval = EXIT_FAILURE;

Modified: trunk/busybox/libbb/error_msg_and_die.c
===================================================================
--- trunk/busybox/libbb/error_msg_and_die.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/libbb/error_msg_and_die.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -10,14 +10,14 @@
 #include "libbb.h"
 
 int die_sleep;
-#if ENABLE_FEATURE_EXEC_PREFER_APPLETS
+#if ENABLE_FEATURE_PREFER_APPLETS
 jmp_buf die_jmp;
 #endif
 
 void xfunc_die(void)
 {
 	if (die_sleep) {
-		if (ENABLE_FEATURE_EXEC_PREFER_APPLETS && die_sleep < 0) {
+		if (ENABLE_FEATURE_PREFER_APPLETS && die_sleep < 0) {
 			/* Special case. We arrive here if NOFORK applet
 			 * calls xfunc, which then decides to die.
 			 * We don't die, but jump instead back to caller.

Modified: trunk/busybox/libbb/execable.c
===================================================================
--- trunk/busybox/libbb/execable.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/libbb/execable.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -60,7 +60,7 @@
 	return 0;
 }
 
-#if ENABLE_FEATURE_EXEC_PREFER_APPLETS
+#if ENABLE_FEATURE_PREFER_APPLETS
 /* just like the real execvp, but try to launch an applet named 'file' first
  */
 int bb_execvp(const char *file, char *const argv[])

Modified: trunk/busybox/libbb/fflush_stdout_and_exit.c
===================================================================
--- trunk/busybox/libbb/fflush_stdout_and_exit.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/libbb/fflush_stdout_and_exit.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -18,7 +18,7 @@
 	if (fflush(stdout))
 		xfunc_die();
 
-	if (ENABLE_FEATURE_EXEC_PREFER_APPLETS && die_sleep < 0) {
+	if (ENABLE_FEATURE_PREFER_APPLETS && die_sleep < 0) {
 		/* We are in NOFORK applet. Do not exit() directly,
 		 * but use xfunc_die() */
 		xfunc_error_retval = retval;

Modified: trunk/busybox/libbb/vfork_daemon_rexec.c
===================================================================
--- trunk/busybox/libbb/vfork_daemon_rexec.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/libbb/vfork_daemon_rexec.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -102,7 +102,7 @@
 
 int spawn_and_wait(char **argv)
 {
-#if ENABLE_FEATURE_EXEC_PREFER_APPLETS
+#if ENABLE_FEATURE_PREFER_APPLETS
 	int rc;
 	const struct bb_applet *a = find_applet_by_name(argv[0]);
 
@@ -121,9 +121,14 @@
 		{
 			int old_sleep = die_sleep;
 			int old_x = xfunc_error_retval;
-			die_sleep = -1; /* special flag */
-			/* xfunc_die() checks for it */
+			uint32_t old_m = option_mask32;
 
+			xfunc_error_retval = EXIT_FAILURE;
+			/* special flag for xfunc_die(). If xfunc will "die"
+			 * in NOFORK applet, xfunc_die() sees negative
+			 * die_sleep and longjmp here instead. */
+			die_sleep = -1;
+
 			rc = setjmp(die_jmp);
 			if (!rc) {
 				const struct bb_applet *old_a = current_applet;
@@ -144,6 +149,7 @@
 
 			die_sleep = old_sleep;
 			xfunc_error_retval = old_x;
+			option_mask32 = old_m;
 			return rc;
 		}
 #ifndef BB_NOMMU	/* MMU only */
@@ -159,7 +165,7 @@
 	rc = spawn(argv);
  w:
 	return wait4pid(rc);
-#else /* !FEATURE_EXEC_PREFER_APPLETS */
+#else /* !FEATURE_PREFER_APPLETS */
 	return wait4pid(spawn(argv));
 #endif
 }

Modified: trunk/busybox/scripts/defconfig
===================================================================
--- trunk/busybox/scripts/defconfig	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/scripts/defconfig	2007-04-10 23:03:30 UTC (rev 18394)
@@ -29,7 +29,7 @@
 CONFIG_FEATURE_SUID_CONFIG_QUIET=y
 # CONFIG_FEATURE_HAVE_RPC is not set
 # CONFIG_SELINUX is not set
-# CONFIG_FEATURE_EXEC_PREFER_APPLETS is not set
+# CONFIG_FEATURE_PREFER_APPLETS is not set
 CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
 
 #
@@ -658,7 +658,7 @@
 # Bourne Shell Options
 #
 CONFIG_FEATURE_SH_EXTRA_QUIET=y
-# CONFIG_FEATURE_SH_STANDALONE_SHELL is not set
+# CONFIG_FEATURE_SH_STANDALONE is not set
 
 #
 # System Logging Utilities

Modified: trunk/busybox/shell/Config.in
===================================================================
--- trunk/busybox/shell/Config.in	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/shell/Config.in	2007-04-10 23:03:30 UTC (rev 18394)
@@ -216,10 +216,10 @@
 	help
 	  Remove the busybox introduction when starting a shell.
 
-config FEATURE_SH_STANDALONE_SHELL
+config FEATURE_SH_STANDALONE
 	bool "Standalone shell"
 	default n
-	depends on MSH || LASH || HUSH || ASH
+	depends on (MSH || LASH || HUSH || ASH) && FEATURE_PREFER_APPLETS
 	help
 	  This option causes the selected busybox shell to use busybox applets
 	  in preference to executables in the PATH whenever possible.  For

Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/shell/ash.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -6531,7 +6531,7 @@
 {
 	int repeated = 0;
 
-#if ENABLE_FEATURE_SH_STANDALONE_SHELL
+#if ENABLE_FEATURE_SH_STANDALONE
 	if (strchr(cmd, '/') == NULL) {
 		const struct bb_applet *a;
 
@@ -6596,7 +6596,7 @@
 	clearredir(1);
 	envp = environment();
 	if (strchr(argv[0], '/')
-#if ENABLE_FEATURE_SH_STANDALONE_SHELL
+#if ENABLE_FEATURE_SH_STANDALONE
 	 || find_applet_by_name(argv[0])
 #endif
 	) {
@@ -11116,7 +11116,7 @@
 		return;
 	}
 
-#if ENABLE_FEATURE_SH_STANDALONE_SHELL
+#if ENABLE_FEATURE_SH_STANDALONE
 	if (find_applet_by_name(name)) {
 		entry->cmdtype = CMDNORMAL;
 		entry->u.index = -1;
@@ -11341,7 +11341,7 @@
 			col = 0;
 		}
 	}
-#if ENABLE_FEATURE_SH_STANDALONE_SHELL
+#if ENABLE_FEATURE_SH_STANDALONE
 	for (i = 0; i < NUM_APPLETS; i++) {
 		col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '), applets[i].name);
 		if (col > 60) {

Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/shell/hush.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -1112,7 +1112,7 @@
 		 * really dislike relying on /proc for things.  We could exec ourself
 		 * from global_argv[0], but if we are in a chroot, we may not be able
 		 * to find ourself... */
-#if ENABLE_FEATURE_SH_STANDALONE_SHELL
+#if ENABLE_FEATURE_SH_STANDALONE
 		{
 			int argc_l;
 			char** argv_l = child->argv;

Modified: trunk/busybox/shell/lash.c
===================================================================
--- trunk/busybox/shell/lash.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/shell/lash.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -1164,7 +1164,7 @@
 	 * /bin/foo invocation will fork and exec /bin/foo, even if
 	 * /bin/foo is a symlink to busybox.
 	 */
-	if (ENABLE_FEATURE_SH_STANDALONE_SHELL) {
+	if (ENABLE_FEATURE_SH_STANDALONE) {
 		char **argv_l = child->argv;
 		int argc_l;
 

Modified: trunk/busybox/shell/msh.c
===================================================================
--- trunk/busybox/shell/msh.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/shell/msh.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -37,7 +37,7 @@
 # define DEFAULT_SHELL "/proc/self/exe"
 # define CONFIG_BUSYBOX_EXEC_PATH "/proc/self/exe"
 # define BB_BANNER "busybox standalone"
-# define ENABLE_FEATURE_SH_STANDALONE_SHELL 0
+# define ENABLE_FEATURE_SH_STANDALONE 0
 # define bb_msg_memory_exhausted "memory exhausted"
 # define xmalloc(size) malloc(size)
 # define msh_main(argc,argv) main(argc,argv)
@@ -3064,7 +3064,7 @@
 	int eacces = 0, asis = 0;
 	char *name = c;
 
-	if (ENABLE_FEATURE_SH_STANDALONE_SHELL) {
+	if (ENABLE_FEATURE_SH_STANDALONE) {
 		optind = 1;
 		if (find_applet_by_name(name)) {
 			/* We have to exec here since we vforked.  Running
@@ -3195,7 +3195,7 @@
 		}
 		x++;
 	}
-#if ENABLE_FEATURE_SH_STANDALONE_SHELL
+#if ENABLE_FEATURE_SH_STANDALONE
 	{
 		const struct bb_applet *applet = applets;
 

Modified: trunk/busybox/util-linux/getopt.c
===================================================================
--- trunk/busybox/util-linux/getopt.c	2007-04-10 21:41:16 UTC (rev 18393)
+++ trunk/busybox/util-linux/getopt.c	2007-04-10 23:03:30 UTC (rev 18394)
@@ -38,8 +38,10 @@
    mode */
 enum {
 	NON_OPT = 1,
+#if ENABLE_GETOPT_LONG
 /* LONG_OPT is the code that is returned when a long option is found. */
 	LONG_OPT = 2
+#endif
 };
 
 /* For finding activated option flags. Must match getopt32 call! */
@@ -51,8 +53,10 @@
 	OPT_s	= 0x10,	// -s
 	OPT_T	= 0x20,	// -T
 	OPT_u	= 0x40,	// -u
+#if ENABLE_GETOPT_LONG
 	OPT_a	= 0x80,	// -a
 	OPT_l	= 0x100, // -l
+#endif
 	SHELL_IS_TCSH = 0x8000, /* hijack this bit for other purposes */
 };
 
@@ -137,31 +141,45 @@
  * optstr must contain the short options, and longopts the long options.
  * Other settings are found in global variables.
  */
-static int generate_output(char * argv[],int argc,const char *optstr,
-		const struct option *longopts)
+#if !ENABLE_GETOPT_LONG
+#define generate_output(argv,argc,optstr,longopts) generate_output(argv,argc,optstr)
+#endif
+static int generate_output(char **argv, int argc, const char *optstr, const struct option *longopts)
 {
 	int exit_code = 0; /* We assume everything will be OK */
 	unsigned opt;
+#if ENABLE_GETOPT_LONG
 	int longindex;
+#endif
 	const char *charptr;
 
 	if (quiet_errors) /* No error reporting from getopt(3) */
 		opterr = 0;
 	optind = 0; /* Reset getopt(3) */
 
-	while ((opt = (alternative ?
-			getopt_long_only(argc,argv,optstr,longopts,&longindex) :
-			getopt_long(argc,argv,optstr,longopts,&longindex)))
-	       != EOF)
+	while (1) {
+		opt =
+#if ENABLE_GETOPT_LONG
+			alternative ?
+			getopt_long_only(argc, argv, optstr, longopts, &longindex) :
+			getopt_long(argc, argv, optstr, longopts, &longindex);
+#else
+			getopt(argc, argv, optstr);
+#endif
+		if (opt == EOF)
+			break;
 		if (opt == '?' || opt == ':' )
 			exit_code = 1;
 		else if (!quiet_output) {
+#if ENABLE_GETOPT_LONG
 			if (opt == LONG_OPT) {
 				printf(" --%s", longopts[longindex].name);
 				if (longopts[longindex].has_arg)
 					printf(" %s",
 						normalize(optarg ? optarg : ""));
-			} else if (opt == NON_OPT)
+			} else
+#endif
+			if (opt == NON_OPT)
 				printf(" %s", normalize(optarg));
 			else {
 				printf(" -%c", opt);
@@ -171,6 +189,7 @@
 						normalize(optarg ? optarg : ""));
 			}
 		}
+	}
 
 	if (!quiet_output) {
 		printf(" --");
@@ -181,6 +200,7 @@
 	return exit_code;
 }
 
+#if ENABLE_GETOPT_LONG
 /*
  * Register several long options. options is a string of long options,
  * separated by commas or whitespace.
@@ -224,6 +244,7 @@
 	}
 	return long_options;
 }
+#endif
 
 static void set_shell(const char *new_shell)
 {
@@ -262,13 +283,13 @@
 int getopt_main(int argc, char *argv[]);
 int getopt_main(int argc, char *argv[])
 {
-	struct option *long_options = NULL;
 	char *optstr = NULL;
 	char *name = NULL;
 	unsigned opt;
 	const char *compatible;
 	char *s_arg; 
 #if ENABLE_GETOPT_LONG
+	struct option *long_options = NULL;
 	llist_t *l_arg = NULL;
 #endif
 




More information about the busybox-cvs mailing list