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},
123 #ifdef BB_REBOOT //sbin
124 {"reboot", reboot_main},
129 #ifdef BB_RMDIR //bin
130 {"rmdir", rmdir_main},
132 #ifdef BB_SFDISK //sbin
133 {"fdisk", sfdisk_main},
134 {"sfdisk", sfdisk_main},
136 #ifdef BB_SLEEP //bin
137 {"sleep", sleep_main},
142 #ifdef BB_SWAPONOFF //sbin
143 {"swapon", swap_on_off_main},
144 {"swapoff", swap_on_off_main},
149 #ifdef BB_TOUCH //usr/bin
150 {"touch", touch_main},
152 #ifdef BB_TRUE_FALSE //bin
154 {"false", false_main},
156 #ifdef BB_UMOUNT //bin
157 {"umount", umount_main},
159 #ifdef BB_UPDATE //sbin
160 {"update", update_main},
164 {"gunzip", zcat_main},
172 int main(int argc, char **argv)
175 char *name = argv[0];
176 const struct Applet *a = applets;
183 while (a->name != 0) {
184 if (strcmp(name, a->name) == 0) {
187 status = ((*(a->main)) (argc, argv));
189 fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
191 fprintf(stderr, "\n");
196 exit (busybox_main(argc, argv));
200 int busybox_main(int argc, char **argv)
206 if (been_there_done_that == 1 || argc < 1) {
207 const struct Applet *a = applets;
208 fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n",
210 fprintf(stderr, "\nUsage:\t[function] [arguments]...\n");
211 fprintf(stderr, "\tbusybox [function] [arguments]...\n");
213 "\n\tMost people will create a symlink to busybox for each\n"
214 "\tfunction name, and busybox will act like whatever you invoke it as.\n");
215 fprintf(stderr, "\nCurrently defined functions:\n");
217 while (a->name != 0) {
218 col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
220 fprintf(stderr, ",\n");
224 fprintf(stderr, "\n\n");
227 /* If we've already been here once, exit now */
228 been_there_done_that = 1;
229 return (main(argc, argv));