[patch] size optimization for setarch.c, fix personality applet-alias

Bernhard Fischer rep.nop at aon.at
Sat Mar 18 18:34:48 UTC 2006


Hi,

   text	   data	    bss	    dec	    hex	filename
    151	      0	      0	    151	     97	setarch.o.orig
    111	      0	      0	    111	     6f	setarch.o


The aliases for "linux64" and "linux32" were missing from the applet
list (see hunk against Config.in) which is printed when executing plain
./busybox. This snippet maybe something we want also for the stable
branch as it could be considered a documentation fix.

Rob, if you agree then please make sure the part which touches
Config.in makes it into svn before the release. TIA.


I intend to check this in for the new trunk after tuesday unless
somebody objects..

-------------- next part --------------
Index: util-linux/setarch.c
===================================================================
--- util-linux/setarch.c	(revision 14552)
+++ util-linux/setarch.c	(working copy)
@@ -16,7 +16,7 @@
 
 #include "busybox.h"
 
-int setarch_main(int argc, char **argv)
+int setarch_main(int ATTRIBUTE_UNUSED argc, char **argv)
 {
 	int pers = -1;
 
@@ -26,9 +26,9 @@
 	 * argv[0]         -> "personality"
 	 */
 retry:
-	if (!strcmp(argv[0], "linux64"))
+	if (argv[0][5] == '6') /* linux64 */
 		pers = PER_LINUX;
-	else if (!strcmp(argv[0], "linux32"))
+	else if (argv[0][5] == '3') /* linux32 */
 		pers = PER_LINUX32;
 	else if (pers == -1 && argv[1] != NULL) {
 		pers = PER_LINUX32;
@@ -42,12 +42,11 @@
 		bb_show_usage();
 
 	/* Try to set personality */
-	if (personality(pers) < 0)
-		goto failure;
+	if (personality(pers) >= 0) {
 
-	/* Try to execute the program */
-	execvp(argv[0], argv);
+		/* Try to execute the program */
+		execvp(argv[0], argv);
+	}
 
-failure:
 	bb_perror_msg_and_die("%s", argv[0]);
 }
Index: util-linux/Config.in
===================================================================
--- util-linux/Config.in	(revision 14552)
+++ util-linux/Config.in	(working copy)
@@ -354,9 +364,19 @@
 	help
 	  This allows you to parse /proc/profile for basic profiling.
 
+config CONFIG_LINUX32
+	default n
+	depends on CONFIG_SETARCH
+
+config CONFIG_LINUX64
+	default n
+	depends on CONFIG_SETARCH
+
 config CONFIG_SETARCH
 	bool "setarch"
 	default n
+	select CONFIG_LINUX32
+	select CONFIG_LINUX64
 	help
 	  The linux32 utility is used to create a 32bit environment for the
 	  specified program (usually a shell).  It only makes sense to have


More information about the busybox mailing list