6 static int been_there_done_that = 0;
8 static const struct Applet applets[] = {
10 #ifdef BB_BUSYBOX //bin
11 {"busybox", busybox_main},
13 #ifdef BB_BLOCK_DEVICE //sbin
14 {"block_device", block_device_main},
19 #ifdef BB_CHMOD_CHOWN_CHGRP //bin
20 {"chmod", chmod_chown_chgrp_main},
21 {"chown", chmod_chown_chgrp_main},
22 {"chgrp", chmod_chown_chgrp_main},
24 #ifdef BB_CHROOT //sbin
25 {"chroot", chroot_main},
27 #ifdef BB_CLEAR //usr/bin
28 {"clear", clear_main},
30 #ifdef BB_CHVT //usr/bin
46 {"dmesg", dmesg_main},
51 #ifdef BB_DUTMP //usr/sbin
52 {"dutmp", dutmp_main},
54 #ifdef BB_FBSET //usr/sbin
55 {"fbset", fbset_main},
57 #ifdef BB_FDFLUSH //bin
58 {"fdflush", fdflush_main},
60 #ifdef BB_FIND //usr/bin
63 #ifdef BB_FREE //usr/bin
66 #ifdef BB_DEALLOCVT //usr/bin
67 {"deallocvt", deallocvt_main},
69 #ifdef BB_FSCK_MINIX //sbin
70 {"fsck.minix", fsck_minix_main},
72 #ifdef BB_MKFS_MINIX //sbin
73 {"mkfs.minix", mkfs_minix_main},
84 #ifdef BB_HOSTNAME //bin
85 {"hostname", hostname_main},
90 #ifdef BB_INSMOD //sbin
91 {"insmod", insmod_main},
93 #ifdef BB_FEATURE_LINUXRC //
94 {"linuxrc", init_main},
99 #ifdef BB_LENGTH //usr/bin
100 {"length", length_main},
105 #ifdef BB_LOADACM //usr/bin
106 {"loadacm", loadacm_main},
108 #ifdef BB_LOADFONT //usr/bin
109 {"loadfont", loadfont_main},
111 #ifdef BB_LOADKMAP //sbin
112 {"loadkmap", loadkmap_main},
117 #ifdef BB_LSMOD //sbin
118 {"lsmod", lsmod_main},
120 #ifdef BB_MAKEDEVS //sbin
121 {"makedevs", makedevs_main},
123 #ifdef BB_MATH //usr/bin
126 #ifdef BB_MKDIR //bin
127 {"mkdir", mkdir_main},
129 #ifdef BB_MKFIFO //usr/bin
130 {"mkfifo", mkfifo_main},
132 #ifdef BB_MKNOD //bin
133 {"mknod", mknod_main},
135 #ifdef BB_MKSWAP //sbin
136 {"mkswap", mkswap_main},
138 #ifdef BB_MNC //usr/bin
144 #ifdef BB_MOUNT //bin
145 {"mount", mount_main},
156 #ifdef BB_POWEROFF //sbin
157 {"poweroff", poweroff_main},
159 #ifdef BB_PRINTF //usr/bin
160 {"printf", printf_main},
168 #ifdef BB_REBOOT //sbin
169 {"reboot", reboot_main},
174 #ifdef BB_RMDIR //bin
175 {"rmdir", rmdir_main},
177 #ifdef BB_RMMOD //sbin
178 {"rmmod", rmmod_main},
180 #ifdef BB_SFDISK //sbin
181 {"fdisk", sfdisk_main},
182 {"sfdisk", sfdisk_main},
187 #ifdef BB_SLEEP //bin
188 {"sleep", sleep_main},
196 #ifdef BB_SYSLOGD //sbin
197 {"syslogd", syslogd_main},
199 #ifdef BB_LOGGER //usr/bin
200 {"logger", logger_main},
202 #ifdef BB_SWAPONOFF //sbin
203 {"swapon", swap_on_off_main},
204 {"swapoff", swap_on_off_main},
206 #ifdef BB_TAIL //usr/bin
215 #ifdef BB_TOUCH //usr/bin
216 {"touch", touch_main},
218 #ifdef BB_TRUE_FALSE //bin
220 {"false", false_main},
222 #ifdef BB_UNAME //bin
223 {"uname", uname_main},
225 #ifdef BB_UMOUNT //bin
226 {"umount", umount_main},
231 #ifdef BB_UPDATE //sbin
232 {"update", update_main},
234 #ifdef BB_GUNZIP //bin
235 {"zcat", gunzip_main},
236 {"gunzip", gunzip_main},
244 int main(int argc, char **argv)
247 char *name = argv[0];
248 const struct Applet *a = applets;
255 while (a->name != 0) {
256 if (strcmp(name, a->name) == 0) {
259 status = ((*(a->main)) (argc, argv));
261 fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
263 fprintf(stderr, "\n");
268 exit (busybox_main(argc, argv));
272 int busybox_main(int argc, char **argv)
278 if (been_there_done_that == 1 || argc < 1) {
279 const struct Applet *a = applets;
280 fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
282 fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
283 fprintf(stderr, " or: [function] [arguments]...\n\n");
285 "\tMost people will create a symlink to busybox for each\n"
286 "\tfunction name, and busybox will act like whatever you invoke it as.\n");
287 fprintf(stderr, "\nCurrently defined functions:\n");
289 while (a->name != 0) {
290 col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
292 fprintf(stderr, ",\n");
296 fprintf(stderr, "\n\n");
299 /* If we've already been here once, exit now */
300 been_there_done_that = 1;
301 return (main(argc, argv));