7 #undef BB_FEATURE_LINUXRC
10 static int been_there_done_that = 0;
12 /* It has been alledged that doing such things can
13 * help reduce binary size when staticly linking,
14 * of course with glibc, this is unlikely as long
15 * as we use things like printf -- perhaps a printf
16 * replacement may be in order
19 void exit (int status) __attribute__ ((noreturn));
20 void exit (int status) { _exit(status); };
21 void abort (void) __attribute__ ((__noreturn__));
22 void abort (void) { _exit(0); };
23 int atexit (void (*__func) (void)) { _exit(0); };
24 void *__libc_stack_end;
28 static const struct Applet applets[] = {
30 #ifdef BB_BUSYBOX //bin
31 {"busybox", busybox_main},
33 #ifdef BB_BLOCK_DEVICE //sbin
34 {"block_device", block_device_main},
39 #ifdef BB_CHMOD_CHOWN_CHGRP //bin
40 {"chmod", chmod_chown_chgrp_main},
41 {"chown", chmod_chown_chgrp_main},
42 {"chgrp", chmod_chown_chgrp_main},
44 #ifdef BB_CHROOT //sbin
45 {"chroot", chroot_main},
47 #ifdef BB_CLEAR //usr/bin
48 {"clear", clear_main},
50 #ifdef BB_CHVT //usr/bin
66 {"dmesg", dmesg_main},
71 #ifdef BB_DUTMP //usr/sbin
72 {"dutmp", dutmp_main},
74 #ifdef BB_FBSET //usr/sbin
75 {"fbset", fbset_main},
77 #ifdef BB_FDFLUSH //bin
78 {"fdflush", fdflush_main},
80 #ifdef BB_FIND //usr/bin
83 #ifdef BB_FREE //usr/bin
86 #ifdef BB_DEALLOCVT //usr/bin
87 {"deallocvt", deallocvt_main},
89 #ifdef BB_FSCK_MINIX //sbin
90 {"fsck.minix", fsck_minix_main},
92 #ifdef BB_MKFS_MINIX //sbin
93 {"mkfs.minix", mkfs_minix_main},
104 #ifdef BB_HOSTID //usr/bin
105 {"hostid", hostid_main},
107 #ifdef BB_HOSTNAME //bin
108 {"hostname", hostname_main},
110 #ifdef BB_INIT //sbin
113 #ifdef BB_INSMOD //sbin
114 {"insmod", insmod_main},
116 #ifdef BB_FEATURE_LINUXRC //
117 {"linuxrc", init_main},
122 #ifdef BB_LENGTH //usr/bin
123 {"length", length_main},
128 #ifdef BB_LOADACM //usr/bin
129 {"loadacm", loadacm_main},
131 #ifdef BB_LOADFONT //usr/bin
132 {"loadfont", loadfont_main},
134 #ifdef BB_LOADKMAP //sbin
135 {"loadkmap", loadkmap_main},
140 #ifdef BB_LSMOD //sbin
141 {"lsmod", lsmod_main},
143 #ifdef BB_MAKEDEVS //sbin
144 {"makedevs", makedevs_main},
146 #ifdef BB_MATH //usr/bin
149 #ifdef BB_MKDIR //bin
150 {"mkdir", mkdir_main},
152 #ifdef BB_MKFIFO //usr/bin
153 {"mkfifo", mkfifo_main},
155 #ifdef BB_MKNOD //bin
156 {"mknod", mknod_main},
158 #ifdef BB_MKSWAP //sbin
159 {"mkswap", mkswap_main},
161 #ifdef BB_MNC //usr/bin
167 #ifdef BB_MOUNT //bin
168 {"mount", mount_main},
179 #ifdef BB_POWEROFF //sbin
180 {"poweroff", poweroff_main},
182 #ifdef BB_PRINTF //usr/bin
183 {"printf", printf_main},
191 #ifdef BB_REBOOT //sbin
192 {"reboot", reboot_main},
197 #ifdef BB_RMDIR //bin
198 {"rmdir", rmdir_main},
200 #ifdef BB_RMMOD //sbin
201 {"rmmod", rmmod_main},
203 #ifdef BB_SFDISK //sbin
204 {"fdisk", sfdisk_main},
205 {"sfdisk", sfdisk_main},
210 #ifdef BB_SLEEP //bin
211 {"sleep", sleep_main},
219 #ifdef BB_SYSLOGD //sbin
220 {"syslogd", syslogd_main},
222 #ifdef BB_LOGGER //usr/bin
223 {"logger", logger_main},
225 #ifdef BB_LOGNAME //usr/bin
226 {"logname", logname_main},
228 #ifdef BB_SWAPONOFF //sbin
229 {"swapon", swap_on_off_main},
230 {"swapoff", swap_on_off_main},
232 #ifdef BB_TAIL //usr/bin
241 #ifdef BB_TOUCH //usr/bin
242 {"touch", touch_main},
244 #ifdef BB_TRUE_FALSE //bin
246 {"false", false_main},
248 #ifdef BB_TTY //usr/bin
251 #ifdef BB_UNAME //bin
252 {"uname", uname_main},
254 #ifdef BB_UMOUNT //bin
255 {"umount", umount_main},
260 #ifdef BB_UPDATE //sbin
261 {"update", update_main},
263 #ifdef BB_WC //usr/bin
266 #ifdef BB_WHOAMI //usr/bin
267 {"whoami", whoami_main},
269 #ifdef BB_YES //usr/bin
272 #ifdef BB_GUNZIP //bin
273 {"zcat", gunzip_main},
274 {"gunzip", gunzip_main},
284 int main(int argc, char **argv)
287 char *name = argv[0];
288 const struct Applet *a = applets;
295 while (a->name != 0) {
296 if (strcmp(name, a->name) == 0) {
299 status = ((*(a->main)) (argc, argv));
301 fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
303 fprintf(stderr, "\n");
308 exit (busybox_main(argc, argv));
312 int busybox_main(int argc, char **argv)
318 if (been_there_done_that == 1 || argc < 1) {
319 const struct Applet *a = applets;
320 fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
322 fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
323 fprintf(stderr, " or: [function] [arguments]...\n\n");
325 "\tMost people will create a symlink to busybox for each\n"
326 "\tfunction name, and busybox will act like whatever you invoke it as.\n");
327 fprintf(stderr, "\nCurrently defined functions:\n");
329 while (a->name != 0) {
330 col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
332 fprintf(stderr, ",\n");
336 fprintf(stderr, "\n\n");
339 /* If we've already been here once, exit now */
340 been_there_done_that = 1;
341 return (main(argc, argv));