diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-05-31 02:42:49 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-05-31 02:44:34 +0200 |
commit | 8e95068c7f28fe2a1e31b01636e3ed29eed09ef8 (patch) | |
tree | 366721e86423370093b64989a215bee4ab1790ff | |
parent | 877dedb8251be47b3614a371434081ae9b7b358b (diff) | |
download | busybox-w32-8e95068c7f28fe2a1e31b01636e3ed29eed09ef8.tar.gz busybox-w32-8e95068c7f28fe2a1e31b01636e3ed29eed09ef8.tar.bz2 busybox-w32-8e95068c7f28fe2a1e31b01636e3ed29eed09ef8.zip |
Make busybox an optional applet
If it's disabled, code shrinks by about 900 bytes:
function old new delta
usr_bin 10 - -10
usr_sbin 11 - -11
install_dir 20 - -20
applet_install_loc 184 - -184
run_applet_and_exit 686 21 -665
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 0/1 up/down: 0/-890) Total: -890 bytes
text data bss dec hex filename
911327 493 7336 919156 e0674 busybox_old
909848 493 7336 917677 e00ad busybox_unstripped
but busybox executable by itself does not say anything useful:
$ busybox
busybox: applet not found
Based on the patch by Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | Config.in | 12 | ||||
-rw-r--r-- | libbb/appletlib.c | 10 |
2 files changed, 19 insertions, 3 deletions
@@ -116,9 +116,21 @@ config FEATURE_COMPRESS_USAGE | |||
116 | and have very little memory, this might not be a win. Otherwise, | 116 | and have very little memory, this might not be a win. Otherwise, |
117 | you probably want this. | 117 | you probably want this. |
118 | 118 | ||
119 | config BUSYBOX | ||
120 | bool "Include busybox applet" | ||
121 | default y | ||
122 | help | ||
123 | The busybox applet provides general help regarding busybox and | ||
124 | allows the included applets to be listed. It's also required | ||
125 | if applet links are to be installed at runtime. | ||
126 | |||
127 | If you can live without these features disabling this will save | ||
128 | some space. | ||
129 | |||
119 | config FEATURE_INSTALLER | 130 | config FEATURE_INSTALLER |
120 | bool "Support --install [-s] to install applet links at runtime" | 131 | bool "Support --install [-s] to install applet links at runtime" |
121 | default y | 132 | default y |
133 | depends on BUSYBOX | ||
122 | help | 134 | help |
123 | Enable 'busybox --install [-s]' support. This will allow you to use | 135 | Enable 'busybox --install [-s]' support. This will allow you to use |
124 | busybox at runtime to create hard links or symlinks for all the | 136 | busybox at runtime to create hard links or symlinks for all the |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index b682e6b85..281123c37 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -701,7 +701,7 @@ static void install_links(const char *busybox, int use_symbolic_links, | |||
701 | continue; | 701 | continue; |
702 | } | 702 | } |
703 | } | 703 | } |
704 | # else | 704 | # elif ENABLE_BUSYBOX |
705 | static void install_links(const char *busybox UNUSED_PARAM, | 705 | static void install_links(const char *busybox UNUSED_PARAM, |
706 | int use_symbolic_links UNUSED_PARAM, | 706 | int use_symbolic_links UNUSED_PARAM, |
707 | char *custom_install_dir UNUSED_PARAM) | 707 | char *custom_install_dir UNUSED_PARAM) |
@@ -709,6 +709,7 @@ static void install_links(const char *busybox UNUSED_PARAM, | |||
709 | } | 709 | } |
710 | # endif | 710 | # endif |
711 | 711 | ||
712 | # if ENABLE_BUSYBOX | ||
712 | /* If we were called as "busybox..." */ | 713 | /* If we were called as "busybox..." */ |
713 | static int busybox_main(char **argv) | 714 | static int busybox_main(char **argv) |
714 | { | 715 | { |
@@ -784,10 +785,10 @@ static int busybox_main(char **argv) | |||
784 | const char *a = applet_names; | 785 | const char *a = applet_names; |
785 | dup2(1, 2); | 786 | dup2(1, 2); |
786 | while (*a) { | 787 | while (*a) { |
787 | # if ENABLE_FEATURE_INSTALLER | 788 | # if ENABLE_FEATURE_INSTALLER |
788 | if (argv[1][6]) /* --list-full? */ | 789 | if (argv[1][6]) /* --list-full? */ |
789 | full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); | 790 | full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); |
790 | # endif | 791 | # endif |
791 | full_write2_str(a); | 792 | full_write2_str(a); |
792 | full_write2_str("\n"); | 793 | full_write2_str("\n"); |
793 | i++; | 794 | i++; |
@@ -843,6 +844,7 @@ static int busybox_main(char **argv) | |||
843 | /* POSIX: "If a command is not found, the exit status shall be 127" */ | 844 | /* POSIX: "If a command is not found, the exit status shall be 127" */ |
844 | exit(127); | 845 | exit(127); |
845 | } | 846 | } |
847 | # endif | ||
846 | 848 | ||
847 | void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) | 849 | void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) |
848 | { | 850 | { |
@@ -886,8 +888,10 @@ void FAST_FUNC run_applet_and_exit(const char *name, char **argv) | |||
886 | { | 888 | { |
887 | int applet; | 889 | int applet; |
888 | 890 | ||
891 | # if ENABLE_BUSYBOX | ||
889 | if (is_prefixed_with(name, "busybox")) | 892 | if (is_prefixed_with(name, "busybox")) |
890 | exit(busybox_main(argv)); | 893 | exit(busybox_main(argv)); |
894 | # endif | ||
891 | /* find_applet_by_name() search is more expensive, so goes second */ | 895 | /* find_applet_by_name() search is more expensive, so goes second */ |
892 | applet = find_applet_by_name(name); | 896 | applet = find_applet_by_name(name); |
893 | if (applet >= 0) | 897 | if (applet >= 0) |