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_CHVT //usr/bin
57 #ifdef BB_DEALLOCVT //usr/bin
58 {"deallocvt", deallocvt_main},
60 #ifdef BB_FSCK_MINIX //sbin
61 {"fsck.minix", fsck_minix_main},
63 #ifdef BB_MKFS_MINIX //sbin
64 {"mkfs.minix", mkfs_minix_main},
75 #ifdef BB_FEATURE_LINUXRC //
76 {"linuxrc", init_main},
81 #ifdef BB_LENGTH //usr/bin
82 {"length", length_main},
87 #ifdef BB_LOADFONT //usr/bin
88 {"loadfont", loadfont_main},
90 #ifdef BB_LOADKMAP //sbin
91 {"loadkmap", loadkmap_main},
96 #ifdef BB_MAKEDEVS //sbin
97 {"makedevs", makedevs_main},
99 #ifdef BB_MATH //usr/bin
102 #ifdef BB_MKDIR //bin
103 {"mkdir", mkdir_main},
105 #ifdef BB_MKNOD //bin
106 {"mknod", mknod_main},
108 #ifdef BB_MKSWAP //sbin
109 {"mkswap", mkswap_main},
111 #ifdef BB_MNC //usr/bin
117 #ifdef BB_MOUNT //bin
118 {"mount", mount_main},
126 #ifdef BB_PRINTF //usr/bin
127 {"printf", printf_main},
135 #ifdef BB_REBOOT //sbin
136 {"reboot", reboot_main},
141 #ifdef BB_RMDIR //bin
142 {"rmdir", rmdir_main},
144 #ifdef BB_SFDISK //sbin
145 {"fdisk", sfdisk_main},
146 {"sfdisk", sfdisk_main},
151 #ifdef BB_SLEEP //bin
152 {"sleep", sleep_main},
157 #ifdef BB_SYSLOGD //sbin
158 {"syslogd", syslogd_main},
160 #ifdef BB_LOGGER //usr/bin
161 {"logger", logger_main},
163 #ifdef BB_SWAPONOFF //sbin
164 {"swapon", swap_on_off_main},
165 {"swapoff", swap_on_off_main},
170 #ifdef BB_TOUCH //usr/bin
171 {"touch", touch_main},
173 #ifdef BB_TRUE_FALSE //bin
175 {"false", false_main},
177 #ifdef BB_UNAME //bin
178 {"uname", uname_main},
180 #ifdef BB_UMOUNT //bin
181 {"umount", umount_main},
183 #ifdef BB_UPDATE //sbin
184 {"update", update_main},
186 #ifdef BB_GUNZIP //bin
187 {"zcat", gunzip_main},
188 {"gunzip", gunzip_main},
196 int main(int argc, char **argv)
199 char *name = argv[0];
200 const struct Applet *a = applets;
207 while (a->name != 0) {
208 if (strcmp(name, a->name) == 0) {
211 status = ((*(a->main)) (argc, argv));
213 fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
215 fprintf(stderr, "\n");
220 exit (busybox_main(argc, argv));
224 int busybox_main(int argc, char **argv)
230 if (been_there_done_that == 1 || argc < 1) {
231 const struct Applet *a = applets;
232 fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
234 fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
235 fprintf(stderr, " or: [function] [arguments]...\n\n");
237 "\tMost people will create a symlink to busybox for each\n"
238 "\tfunction name, and busybox will act like whatever you invoke it as.\n");
239 fprintf(stderr, "\nCurrently defined functions:\n");
241 while (a->name != 0) {
242 col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
244 fprintf(stderr, ",\n");
248 fprintf(stderr, "\n\n");
251 /* If we've already been here once, exit now */
252 been_there_done_that = 1;
253 return (main(argc, argv));