aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-28 06:49:03 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-28 06:49:03 +0000
commit1aa7e477b1b727db77cac2d717f0fcca40587f78 (patch)
tree247171517f0e01d32a71a5e96f4bef462cc0e9c6 /libbb/vfork_daemon_rexec.c
parent79c6904faff1ebd4bf4b7d9cd0c20ca70f4cec75 (diff)
downloadbusybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.tar.gz
busybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.tar.bz2
busybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.zip
reorganize applet table. Eliminates pointers to names.
Should be a big win for libbusybox. busybox wins too: text data bss dec hex filename 776524 929 9100 786553 c0079 busybox_old 775903 929 9100 785932 bfe0c busybox_unstripped
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r--libbb/vfork_daemon_rexec.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index a01065d69..1d6817ee6 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -16,7 +16,7 @@
16 */ 16 */
17 17
18#include <paths.h> 18#include <paths.h>
19#include "busybox.h" /* for struct bb_applet */ 19#include "busybox.h" /* uses applet tables */
20 20
21/* This does a fork/exec in one call, using vfork(). Returns PID of new child, 21/* This does a fork/exec in one call, using vfork(). Returns PID of new child,
22 * -1 for failure. Runs argv[0], searching path if that has no / in it. */ 22 * -1 for failure. Runs argv[0], searching path if that has no / in it. */
@@ -120,11 +120,11 @@ void restore_nofork_data(struct nofork_save_area *save)
120 die_sleep = save->die_sleep; 120 die_sleep = save->die_sleep;
121} 121}
122 122
123int run_nofork_applet_prime(struct nofork_save_area *old, const struct bb_applet *a, char **argv) 123int run_nofork_applet_prime(struct nofork_save_area *old, int applet_no, char **argv)
124{ 124{
125 int rc, argc; 125 int rc, argc;
126 126
127 applet_name = a->name; 127 applet_name = APPLET_NAME(applet_no);
128 xfunc_error_retval = EXIT_FAILURE; 128 xfunc_error_retval = EXIT_FAILURE;
129 /*option_mask32 = 0; - not needed */ 129 /*option_mask32 = 0; - not needed */
130 /* special flag for xfunc_die(). If xfunc will "die" 130 /* special flag for xfunc_die(). If xfunc will "die"
@@ -143,7 +143,7 @@ int run_nofork_applet_prime(struct nofork_save_area *old, const struct bb_applet
143 char *tmp_argv[argc+1]; 143 char *tmp_argv[argc+1];
144 memcpy(tmp_argv, argv, (argc+1) * sizeof(tmp_argv[0])); 144 memcpy(tmp_argv, argv, (argc+1) * sizeof(tmp_argv[0]));
145 /* Finally we can call NOFORK applet's main() */ 145 /* Finally we can call NOFORK applet's main() */
146 rc = a->main(argc, tmp_argv); 146 rc = applet_mains[applet_no](argc, tmp_argv);
147 } else { /* xfunc died in NOFORK applet */ 147 } else { /* xfunc died in NOFORK applet */
148 /* in case they meant to return 0... */ 148 /* in case they meant to return 0... */
149 if (rc == -2222) 149 if (rc == -2222)
@@ -155,13 +155,13 @@ int run_nofork_applet_prime(struct nofork_save_area *old, const struct bb_applet
155 return rc; 155 return rc;
156} 156}
157 157
158int run_nofork_applet(const struct bb_applet *a, char **argv) 158int run_nofork_applet(int applet_no, char **argv)
159{ 159{
160 struct nofork_save_area old; 160 struct nofork_save_area old;
161 161
162 /* Saving globals */ 162 /* Saving globals */
163 save_nofork_data(&old); 163 save_nofork_data(&old);
164 return run_nofork_applet_prime(&old, a, argv); 164 return run_nofork_applet_prime(&old, applet_no, argv);
165} 165}
166#endif /* FEATURE_PREFER_APPLETS */ 166#endif /* FEATURE_PREFER_APPLETS */
167 167
@@ -169,15 +169,15 @@ int spawn_and_wait(char **argv)
169{ 169{
170 int rc; 170 int rc;
171#if ENABLE_FEATURE_PREFER_APPLETS 171#if ENABLE_FEATURE_PREFER_APPLETS
172 const struct bb_applet *a = find_applet_by_name(argv[0]); 172 int a = find_applet_by_name(argv[0]);
173 173
174 if (a && (a->nofork 174 if (a >= 0 && (APPLET_IS_NOFORK(a)
175#if BB_MMU 175#if BB_MMU
176 || a->noexec /* NOEXEC trick needs fork() */ 176 || APPLET_IS_NOEXEC(a) /* NOEXEC trick needs fork() */
177#endif 177#endif
178 )) { 178 )) {
179#if BB_MMU 179#if BB_MMU
180 if (a->nofork) 180 if (APPLET_IS_NOFORK(a))
181#endif 181#endif
182 { 182 {
183 return run_nofork_applet(a, argv); 183 return run_nofork_applet(a, argv);
@@ -190,7 +190,7 @@ int spawn_and_wait(char **argv)
190 return wait4pid(rc); 190 return wait4pid(rc);
191 /* child */ 191 /* child */
192 xfunc_error_retval = EXIT_FAILURE; 192 xfunc_error_retval = EXIT_FAILURE;
193 run_appletstruct_and_exit(a, argv); 193 run_applet_no_and_exit(a, argv);
194#endif 194#endif
195 } 195 }
196#endif /* FEATURE_PREFER_APPLETS */ 196#endif /* FEATURE_PREFER_APPLETS */