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_FDFLUSH //bin
55 {"fdflush", fdflush_main},
57 #ifdef BB_FIND //usr/bin
60 #ifdef BB_FREE //usr/bin
63 #ifdef BB_DEALLOCVT //usr/bin
64 {"deallocvt", deallocvt_main},
66 #ifdef BB_FSCK_MINIX //sbin
67 {"fsck.minix", fsck_minix_main},
69 #ifdef BB_MKFS_MINIX //sbin
70 {"mkfs.minix", mkfs_minix_main},
78 #ifdef BB_HOSTNAME //bin
79 {"hostname", hostname_main},
84 #ifdef BB_FEATURE_LINUXRC //
85 {"linuxrc", init_main},
90 #ifdef BB_LENGTH //usr/bin
91 {"length", length_main},
96 #ifdef BB_LOADFONT //usr/bin
97 {"loadfont", loadfont_main},
99 #ifdef BB_LOADKMAP //sbin
100 {"loadkmap", loadkmap_main},
105 #ifdef BB_MAKEDEVS //sbin
106 {"makedevs", makedevs_main},
108 #ifdef BB_MATH //usr/bin
111 #ifdef BB_MKDIR //bin
112 {"mkdir", mkdir_main},
114 #ifdef BB_MKNOD //bin
115 {"mknod", mknod_main},
117 #ifdef BB_MKSWAP //sbin
118 {"mkswap", mkswap_main},
120 #ifdef BB_MNC //usr/bin
126 #ifdef BB_MOUNT //bin
127 {"mount", mount_main},
138 #ifdef BB_PRINTF //usr/bin
139 {"printf", printf_main},
147 #ifdef BB_REBOOT //sbin
148 {"reboot", reboot_main},
153 #ifdef BB_RMDIR //bin
154 {"rmdir", rmdir_main},
156 #ifdef BB_SFDISK //sbin
157 {"fdisk", sfdisk_main},
158 {"sfdisk", sfdisk_main},
163 #ifdef BB_SLEEP //bin
164 {"sleep", sleep_main},
169 #ifdef BB_SYSLOGD //sbin
170 {"syslogd", syslogd_main},
172 #ifdef BB_LOGGER //usr/bin
173 {"logger", logger_main},
175 #ifdef BB_SWAPONOFF //sbin
176 {"swapon", swap_on_off_main},
177 {"swapoff", swap_on_off_main},
179 #ifdef BB_TAIL //usr/bin
185 #ifdef BB_TOUCH //usr/bin
186 {"touch", touch_main},
188 #ifdef BB_TRUE_FALSE //bin
190 {"false", false_main},
192 #ifdef BB_UNAME //bin
193 {"uname", uname_main},
195 #ifdef BB_UMOUNT //bin
196 {"umount", umount_main},
198 #ifdef BB_UPDATE //sbin
199 {"update", update_main},
201 #ifdef BB_GUNZIP //bin
202 {"zcat", gunzip_main},
203 {"gunzip", gunzip_main},
211 int main(int argc, char **argv)
214 char *name = argv[0];
215 const struct Applet *a = applets;
222 while (a->name != 0) {
223 if (strcmp(name, a->name) == 0) {
226 status = ((*(a->main)) (argc, argv));
228 fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
230 fprintf(stderr, "\n");
235 exit (busybox_main(argc, argv));
239 int busybox_main(int argc, char **argv)
245 if (been_there_done_that == 1 || argc < 1) {
246 const struct Applet *a = applets;
247 fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
249 fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
250 fprintf(stderr, " or: [function] [arguments]...\n\n");
252 "\tMost people will create a symlink to busybox for each\n"
253 "\tfunction name, and busybox will act like whatever you invoke it as.\n");
254 fprintf(stderr, "\nCurrently defined functions:\n");
256 while (a->name != 0) {
257 col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
259 fprintf(stderr, ",\n");
263 fprintf(stderr, "\n\n");
266 /* If we've already been here once, exit now */
267 been_there_done_that = 1;
268 return (main(argc, argv));