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},
43 {"dmesg", dmesg_main},
45 #ifdef BB_DUTMP //usr/sbin
46 {"dutmp", dutmp_main},
48 #ifdef BB_FDFLUSH //bin
49 {"fdflush", fdflush_main},
51 #ifdef BB_FIND //usr/bin
54 #ifdef BB_FSCK_MINIX //sbin
55 {"fsck.minix", fsck_minix_main},
57 #ifdef BB_MKFS_MINIX //sbin
58 {"mkfs.minix", mkfs_minix_main},
72 #ifdef BB_LENGTH //usr/bin
73 {"length", length_main},
78 #ifdef BB_LOADFONT //usr/bin
79 {"loadfont", loadfont_main},
81 #ifdef BB_LOADKMAP //sbin
82 {"loadkmap", loadkmap_main},
87 #ifdef BB_MAKEDEVS //sbin
88 {"makedevs", makedevs_main},
90 #ifdef BB_MATH //usr/bin
94 {"mkdir", mkdir_main},
97 {"mknod", mknod_main},
99 #ifdef BB_MKSWAP //sbin
100 {"mkswap", mkswap_main},
102 #ifdef BB_MNC //usr/bin
108 #ifdef BB_MOUNT //bin
109 {"mount", mount_main},
117 #ifdef BB_PRINTF //usr/bin
118 {"printf", printf_main},
126 #ifdef BB_REBOOT //sbin
127 {"reboot", reboot_main},
132 #ifdef BB_RMDIR //bin
133 {"rmdir", rmdir_main},
135 #ifdef BB_SFDISK //sbin
136 {"fdisk", sfdisk_main},
137 {"sfdisk", sfdisk_main},
139 #ifdef BB_SLEEP //bin
140 {"sleep", sleep_main},
145 #ifdef BB_SWAPONOFF //sbin
146 {"swapon", swap_on_off_main},
147 {"swapoff", swap_on_off_main},
152 #ifdef BB_TOUCH //usr/bin
153 {"touch", touch_main},
155 #ifdef BB_TRUE_FALSE //bin
157 {"false", false_main},
159 #ifdef BB_UMOUNT //bin
160 {"umount", umount_main},
162 #ifdef BB_UPDATE //sbin
163 {"update", update_main},
167 {"gunzip", zcat_main},
175 int main(int argc, char **argv)
178 char *name = argv[0];
179 const struct Applet *a = applets;
186 while (a->name != 0) {
187 if (strcmp(name, a->name) == 0) {
190 status = ((*(a->main)) (argc, argv));
192 fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
194 fprintf(stderr, "\n");
199 exit (busybox_main(argc, argv));
203 int busybox_main(int argc, char **argv)
209 if (been_there_done_that == 1 || argc < 1) {
210 const struct Applet *a = applets;
211 fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n",
213 fprintf(stderr, "\nUsage:\t[function] [arguments]...\n");
214 fprintf(stderr, "\tbusybox [function] [arguments]...\n");
216 "\n\tMost people will create a symlink to busybox for each\n"
217 "\tfunction name, and busybox will act like whatever you invoke it as.\n");
218 fprintf(stderr, "\nCurrently defined functions:\n");
220 while (a->name != 0) {
221 col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
223 fprintf(stderr, ",\n");
227 fprintf(stderr, "\n\n");
230 /* If we've already been here once, exit now */
231 been_there_done_that = 1;
232 return (main(argc, argv));