Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 2 | #include "internal.h" |
| 3 | #include <stdio.h> |
| 4 | #include <string.h> |
| 5 | #include <errno.h> |
| 6 | |
| 7 | static int been_there_done_that = 0; |
| 8 | |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 9 | /* It has been alledged that doing such things can |
| 10 | * help reduce binary size when staticly linking, |
| 11 | * of course with glibc, this is unlikely as long |
| 12 | * as we use things like printf -- perhaps a printf |
| 13 | * replacement may be in order |
| 14 | */ |
Erik Andersen | 05df239 | 2000-01-13 04:43:48 +0000 | [diff] [blame] | 15 | #if 0 |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 16 | void exit(int status) __attribute__ ((noreturn)); |
| 17 | void exit(int status) |
| 18 | { |
| 19 | _exit(status); |
| 20 | }; |
| 21 | void abort(void) __attribute__ ((__noreturn__)); |
| 22 | void abort(void) |
| 23 | { |
| 24 | _exit(0); |
| 25 | }; |
| 26 | int atexit(void (*__func) (void)) |
| 27 | { |
| 28 | _exit(0); |
| 29 | }; |
Erik Andersen | 05df239 | 2000-01-13 04:43:48 +0000 | [diff] [blame] | 30 | void *__libc_stack_end; |
| 31 | #endif |
| 32 | |
Erik Andersen | bcd6177 | 2000-05-13 06:33:19 +0000 | [diff] [blame] | 33 | const struct BB_applet applets[] = { |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 34 | |
Eric Andersen | 86ab8a3 | 2000-06-02 03:21:42 +0000 | [diff] [blame] | 35 | #ifdef BB_AR |
| 36 | {"ar", ar_main, _BB_DIR_USR_BIN}, |
| 37 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 38 | #ifdef BB_BASENAME |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 39 | {"basename", basename_main, _BB_DIR_USR_BIN}, |
Erik Andersen | e272915 | 2000-02-18 21:34:17 +0000 | [diff] [blame] | 40 | #endif |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 41 | {"busybox", busybox_main, _BB_DIR_BIN}, |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 42 | #ifdef BB_BLOCK_DEVICE |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 43 | {"block_device", block_device_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 44 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 45 | #ifdef BB_CAT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 46 | {"cat", cat_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 47 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 48 | #ifdef BB_CHMOD_CHOWN_CHGRP |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 49 | {"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN}, |
| 50 | #endif |
| 51 | #ifdef BB_CHMOD_CHOWN_CHGRP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 52 | {"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN}, |
| 53 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 54 | #ifdef BB_CHMOD_CHOWN_CHGRP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 55 | {"chown", chmod_chown_chgrp_main, _BB_DIR_BIN}, |
| 56 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 57 | #ifdef BB_CHROOT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 58 | {"chroot", chroot_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 59 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 60 | #ifdef BB_CLEAR |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 61 | {"clear", clear_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 62 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 63 | #ifdef BB_CHVT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 64 | {"chvt", chvt_main, _BB_DIR_USR_BIN}, |
Eric Andersen | abc0f4f | 1999-12-08 23:19:36 +0000 | [diff] [blame] | 65 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 66 | #ifdef BB_CP_MV |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 67 | {"cp", cp_mv_main, _BB_DIR_BIN}, |
| 68 | #endif |
Erik Andersen | 7ab9c7e | 2000-05-12 19:41:47 +0000 | [diff] [blame] | 69 | #ifdef BB_CUT |
| 70 | {"cut", cut_main, _BB_DIR_USR_BIN}, |
| 71 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 72 | #ifdef BB_DATE |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 73 | {"date", date_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 74 | #endif |
John Beppu | 0021679 | 2000-06-21 19:06:16 +0000 | [diff] [blame] | 75 | #ifdef BB_DC |
| 76 | {"dc", dc_main, _BB_DIR_USR_BIN}, |
| 77 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 78 | #ifdef BB_DD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 79 | {"dd", dd_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 80 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 81 | #ifdef BB_DF |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 82 | {"df", df_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 83 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 84 | #ifdef BB_DIRNAME |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 85 | {"dirname", dirname_main, _BB_DIR_USR_BIN}, |
Erik Andersen | fb002d0 | 2000-03-05 08:07:00 +0000 | [diff] [blame] | 86 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 87 | #ifdef BB_DMESG |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 88 | {"dmesg", dmesg_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 89 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 90 | #ifdef BB_DU |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 91 | {"du", du_main, _BB_DIR_BIN}, |
John Beppu | 7a98606 | 1999-12-09 18:29:29 +0000 | [diff] [blame] | 92 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 93 | #ifdef BB_DUTMP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 94 | {"dutmp", dutmp_main, _BB_DIR_USR_SBIN}, |
| 95 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 96 | #ifdef BB_ECHO |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 97 | {"echo", echo_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 98 | #endif |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 99 | #ifdef BB_TRUE_FALSE |
| 100 | {"false", false_main, _BB_DIR_BIN}, |
| 101 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 102 | #ifdef BB_FBSET |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 103 | {"fbset", fbset_main, _BB_DIR_USR_SBIN}, |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 104 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 105 | #ifdef BB_FDFLUSH |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 106 | {"fdflush", fdflush_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 107 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 108 | #ifdef BB_FIND |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 109 | {"find", find_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 110 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 111 | #ifdef BB_FREE |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 112 | {"free", free_main, _BB_DIR_USR_BIN}, |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 113 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 114 | #ifdef BB_FREERAMDISK |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 115 | {"freeramdisk", freeramdisk_main, _BB_DIR_SBIN}, |
Erik Andersen | 6437170 | 2000-03-04 22:23:27 +0000 | [diff] [blame] | 116 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 117 | #ifdef BB_DEALLOCVT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 118 | {"deallocvt", deallocvt_main, _BB_DIR_USR_BIN}, |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 119 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 120 | #ifdef BB_FSCK_MINIX |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 121 | {"fsck.minix", fsck_minix_main, _BB_DIR_SBIN}, |
Eric Andersen | e494fdd | 1999-10-19 20:23:03 +0000 | [diff] [blame] | 122 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 123 | #ifdef BB_GREP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 124 | {"grep", grep_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 125 | #endif |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 126 | #ifdef BB_GUNZIP |
| 127 | {"gunzip", gunzip_main, _BB_DIR_BIN}, |
| 128 | #endif |
| 129 | #ifdef BB_GZIP |
| 130 | {"gzip", gzip_main, _BB_DIR_BIN}, |
| 131 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 132 | #ifdef BB_HALT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 133 | {"halt", halt_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 134 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 135 | #ifdef BB_HEAD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 136 | {"head", head_main, _BB_DIR_BIN}, |
John Beppu | 3157b1f | 1999-12-10 07:42:50 +0000 | [diff] [blame] | 137 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 138 | #ifdef BB_HOSTID |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 139 | {"hostid", hostid_main, _BB_DIR_USR_BIN}, |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 140 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 141 | #ifdef BB_HOSTNAME |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 142 | {"hostname", hostname_main, _BB_DIR_BIN}, |
Eric Andersen | 485b955 | 1999-12-07 23:14:59 +0000 | [diff] [blame] | 143 | #endif |
Erik Andersen | 94f5e0b | 2000-05-01 19:10:52 +0000 | [diff] [blame] | 144 | #ifdef BB_ID |
| 145 | {"id", id_main, _BB_DIR_USR_BIN}, |
| 146 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 147 | #ifdef BB_INIT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 148 | {"init", init_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 149 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 150 | #ifdef BB_INSMOD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 151 | {"insmod", insmod_main, _BB_DIR_SBIN}, |
Erik Andersen | 6da0ae8 | 1999-12-17 01:08:27 +0000 | [diff] [blame] | 152 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 153 | #ifdef BB_KILL |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 154 | {"kill", kill_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 155 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 156 | #ifdef BB_KILLALL |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 157 | {"killall", kill_main, _BB_DIR_USR_BIN}, |
Erik Andersen | 246cc6d | 2000-03-07 07:41:42 +0000 | [diff] [blame] | 158 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 159 | #ifdef BB_LENGTH |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 160 | {"length", length_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 161 | #endif |
Erik Andersen | 9a8195c | 2000-04-18 23:32:10 +0000 | [diff] [blame] | 162 | #ifdef BB_LINUXRC |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 163 | {"linuxrc", init_main, _BB_DIR_ROOT}, |
| 164 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 165 | #ifdef BB_LN |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 166 | {"ln", ln_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 167 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 168 | #ifdef BB_LOADACM |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 169 | {"loadacm", loadacm_main, _BB_DIR_USR_BIN}, |
Eric Andersen | 3e0fbae | 1999-10-19 06:02:44 +0000 | [diff] [blame] | 170 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 171 | #ifdef BB_LOADFONT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 172 | {"loadfont", loadfont_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 173 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 174 | #ifdef BB_LOADKMAP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 175 | {"loadkmap", loadkmap_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 176 | #endif |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 177 | #ifdef BB_LOGGER |
| 178 | {"logger", logger_main, _BB_DIR_USR_BIN}, |
| 179 | #endif |
| 180 | #ifdef BB_LOGNAME |
| 181 | {"logname", logname_main, _BB_DIR_USR_BIN}, |
| 182 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 183 | #ifdef BB_LS |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 184 | {"ls", ls_main, _BB_DIR_BIN}, |
Erik Andersen | 6f23cec | 1999-12-15 22:14:12 +0000 | [diff] [blame] | 185 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 186 | #ifdef BB_LSMOD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 187 | {"lsmod", lsmod_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 188 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 189 | #ifdef BB_MAKEDEVS |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 190 | {"makedevs", makedevs_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 191 | #endif |
Eric Andersen | 2b6ab3c | 2000-06-13 06:54:53 +0000 | [diff] [blame] | 192 | #ifdef BB_MD5SUM |
| 193 | {"md5sum", md5sum_main, _BB_DIR_USR_BIN}, |
| 194 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 195 | #ifdef BB_MKDIR |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 196 | {"mkdir", mkdir_main, _BB_DIR_BIN}, |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 197 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 198 | #ifdef BB_MKFIFO |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 199 | {"mkfifo", mkfifo_main, _BB_DIR_USR_BIN}, |
Eric Andersen | 19db07b | 1999-12-11 08:41:28 +0000 | [diff] [blame] | 200 | #endif |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 201 | #ifdef BB_MKFS_MINIX |
| 202 | {"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN}, |
| 203 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 204 | #ifdef BB_MKNOD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 205 | {"mknod", mknod_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 206 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 207 | #ifdef BB_MKSWAP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 208 | {"mkswap", mkswap_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 209 | #endif |
Erik Andersen | 227a59b | 2000-04-25 23:24:55 +0000 | [diff] [blame] | 210 | #ifdef BB_MKTEMP |
| 211 | {"mktemp", mktemp_main, _BB_DIR_BIN}, |
| 212 | #endif |
Erik Andersen | 7ab9c7e | 2000-05-12 19:41:47 +0000 | [diff] [blame] | 213 | #ifdef BB_NC |
| 214 | {"nc", nc_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 215 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 216 | #ifdef BB_MORE |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 217 | {"more", more_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 218 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 219 | #ifdef BB_MOUNT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 220 | {"mount", mount_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 221 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 222 | #ifdef BB_MT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 223 | {"mt", mt_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 224 | #endif |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 225 | #ifdef BB_CP_MV |
| 226 | {"mv", cp_mv_main, _BB_DIR_BIN}, |
| 227 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 228 | #ifdef BB_NSLOOKUP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 229 | {"nslookup", nslookup_main, _BB_DIR_USR_BIN}, |
John Beppu | b332e77 | 2000-01-29 12:59:01 +0000 | [diff] [blame] | 230 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 231 | #ifdef BB_PING |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 232 | {"ping", ping_main, _BB_DIR_BIN}, |
Eric Andersen | 485b955 | 1999-12-07 23:14:59 +0000 | [diff] [blame] | 233 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 234 | #ifdef BB_POWEROFF |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 235 | {"poweroff", poweroff_main, _BB_DIR_SBIN}, |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 236 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 237 | #ifdef BB_PRINTF |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 238 | {"printf", printf_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 239 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 240 | #ifdef BB_PS |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 241 | {"ps", ps_main, _BB_DIR_BIN}, |
Eric Andersen | ef8b6c7 | 1999-10-20 08:05:35 +0000 | [diff] [blame] | 242 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 243 | #ifdef BB_PWD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 244 | {"pwd", pwd_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 245 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 246 | #ifdef BB_REBOOT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 247 | {"reboot", reboot_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 248 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 249 | #ifdef BB_RM |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 250 | {"rm", rm_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 251 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 252 | #ifdef BB_RMDIR |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 253 | {"rmdir", rmdir_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 254 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 255 | #ifdef BB_RMMOD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 256 | {"rmmod", rmmod_main, _BB_DIR_SBIN}, |
Erik Andersen | 3d7e341 | 1999-12-16 23:04:20 +0000 | [diff] [blame] | 257 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 258 | #ifdef BB_SED |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 259 | {"sed", sed_main, _BB_DIR_BIN}, |
Erik Andersen | 3522eb1 | 2000-03-12 23:49:18 +0000 | [diff] [blame] | 260 | #endif |
Erik Andersen | 4f3f757 | 2000-04-28 00:18:56 +0000 | [diff] [blame] | 261 | #ifdef BB_SETKEYCODES |
| 262 | {"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN}, |
Erik Andersen | 3522eb1 | 2000-03-12 23:49:18 +0000 | [diff] [blame] | 263 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 264 | #ifdef BB_SFDISK |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 265 | {"sfdisk", sfdisk_main, _BB_DIR_SBIN}, |
Eric Andersen | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 266 | #endif |
Erik Andersen | 4f3f757 | 2000-04-28 00:18:56 +0000 | [diff] [blame] | 267 | #ifdef BB_SH |
| 268 | {"sh", shell_main, _BB_DIR_BIN}, |
| 269 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 270 | #ifdef BB_SLEEP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 271 | {"sleep", sleep_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 272 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 273 | #ifdef BB_SORT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 274 | {"sort", sort_main, _BB_DIR_BIN}, |
John Beppu | 019513a | 1999-12-22 17:57:31 +0000 | [diff] [blame] | 275 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 276 | #ifdef BB_SYNC |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 277 | {"sync", sync_main, _BB_DIR_BIN}, |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 278 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 279 | #ifdef BB_SYSLOGD |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 280 | {"syslogd", syslogd_main, _BB_DIR_SBIN}, |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 281 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 282 | #ifdef BB_SWAPONOFF |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 283 | {"swapon", swap_on_off_main, _BB_DIR_SBIN}, |
| 284 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 285 | #ifdef BB_SWAPONOFF |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 286 | {"swapoff", swap_on_off_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 287 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 288 | #ifdef BB_TAIL |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 289 | {"tail", tail_main, _BB_DIR_USR_BIN}, |
Eric Andersen | abc0f4f | 1999-12-08 23:19:36 +0000 | [diff] [blame] | 290 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 291 | #ifdef BB_TAR |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 292 | {"tar", tar_main, _BB_DIR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 293 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 294 | #ifdef BB_TELNET |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 295 | {"telnet", telnet_main, _BB_DIR_USR_BIN}, |
| 296 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 297 | #ifdef BB_TEST |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 298 | {"test", test_main, _BB_DIR_USR_BIN}, |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 299 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 300 | #ifdef BB_TEE |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 301 | {"tee", tee_main, _BB_DIR_BIN}, |
John Beppu | 059f152 | 1999-12-10 05:27:16 +0000 | [diff] [blame] | 302 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 303 | #ifdef BB_TOUCH |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 304 | {"touch", touch_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 305 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 306 | #ifdef BB_TR |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 307 | {"tr", tr_main, _BB_DIR_USR_BIN}, |
Erik Andersen | fb002d0 | 2000-03-05 08:07:00 +0000 | [diff] [blame] | 308 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 309 | #ifdef BB_TRUE_FALSE |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 310 | {"true", true_main, _BB_DIR_BIN}, |
| 311 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 312 | #ifdef BB_TTY |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 313 | {"tty", tty_main, _BB_DIR_USR_BIN}, |
Erik Andersen | 05df239 | 2000-01-13 04:43:48 +0000 | [diff] [blame] | 314 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 315 | #ifdef BB_UMOUNT |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 316 | {"umount", umount_main, _BB_DIR_BIN}, |
Erik Andersen | 66be5e7 | 2000-03-05 07:52:05 +0000 | [diff] [blame] | 317 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 318 | #ifdef BB_UNAME |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 319 | {"uname", uname_main, _BB_DIR_BIN}, |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 320 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 321 | #ifdef BB_UNIQ |
Erik Andersen | a6c7522 | 2000-04-18 00:00:52 +0000 | [diff] [blame] | 322 | {"uniq", uniq_main, _BB_DIR_USR_BIN}, |
John Beppu | abb4772 | 2000-01-06 00:48:21 +0000 | [diff] [blame] | 323 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 324 | #ifdef BB_UPDATE |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 325 | {"update", update_main, _BB_DIR_SBIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 326 | #endif |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 327 | #ifdef BB_UPTIME |
| 328 | {"uptime", uptime_main, _BB_DIR_USR_BIN}, |
| 329 | #endif |
Eric Andersen | 2b6ab3c | 2000-06-13 06:54:53 +0000 | [diff] [blame] | 330 | #ifdef BB_UUENCODE |
| 331 | {"uuencode", uuencode_main, _BB_DIR_USR_BIN}, |
| 332 | #endif |
| 333 | #ifdef BB_UUDECODE |
| 334 | {"uudecode", uudecode_main, _BB_DIR_USR_BIN}, |
| 335 | #endif |
Erik Andersen | b99ca13 | 2000-04-04 18:49:18 +0000 | [diff] [blame] | 336 | #ifdef BB_USLEEP |
| 337 | {"usleep", usleep_main, _BB_DIR_BIN}, |
| 338 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 339 | #ifdef BB_WC |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 340 | {"wc", wc_main, _BB_DIR_USR_BIN}, |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 341 | #endif |
Erik Andersen | 330fd2b | 2000-05-19 05:35:19 +0000 | [diff] [blame] | 342 | #ifdef BB_WHICH |
| 343 | {"which", which_main, _BB_DIR_USR_BIN}, |
| 344 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 345 | #ifdef BB_WHOAMI |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 346 | {"whoami", whoami_main, _BB_DIR_USR_BIN}, |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 347 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 348 | #ifdef BB_YES |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 349 | {"yes", yes_main, _BB_DIR_USR_BIN}, |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 350 | #endif |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 351 | #ifdef BB_GUNZIP |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 352 | {"zcat", gunzip_main, _BB_DIR_BIN}, |
| 353 | #endif |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 354 | #ifdef BB_TEST |
| 355 | {"[", test_main, _BB_DIR_USR_BIN}, |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 356 | #endif |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 357 | {0} |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 358 | }; |
| 359 | |
Erik Andersen | 05df239 | 2000-01-13 04:43:48 +0000 | [diff] [blame] | 360 | |
John Beppu | 8f425db | 2000-06-27 04:50:02 +0000 | [diff] [blame] | 361 | #ifdef BB_FEATURE_INSTALLER |
| 362 | /* |
| 363 | * directory table |
| 364 | * this should be consistent w/ the enum, internal.h::Location, |
| 365 | * or else... |
| 366 | */ |
| 367 | static char* install_dir[] = { |
| 368 | "/", |
| 369 | "/bin", |
| 370 | "/sbin", |
| 371 | "/usr/bin", |
| 372 | "/usr/sbin", |
| 373 | NULL |
| 374 | }; |
| 375 | |
| 376 | /* abstract link() */ |
| 377 | typedef int (*__link_f)(const char *, const char *); |
| 378 | |
| 379 | /* create (sym)links for each applet */ |
| 380 | int install_links(const char *busybox, int use_symbolic_links) |
| 381 | { |
| 382 | __link_f Link = link; |
| 383 | |
| 384 | char command[256]; |
| 385 | int i; |
| 386 | int rc = 0; |
| 387 | |
| 388 | if (use_symbolic_links) Link = symlink; |
| 389 | |
| 390 | for (i = 0; applets[i].name != NULL; i++) { |
| 391 | sprintf ( |
| 392 | command, |
| 393 | "%s/%s", |
| 394 | install_dir[applets[i].location], |
| 395 | applets[i].name |
| 396 | ); |
| 397 | #if 0 |
| 398 | rc |= Link(busybox, command); |
| 399 | #else |
| 400 | puts(command); |
| 401 | #endif |
| 402 | if (rc) { |
| 403 | fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); |
| 404 | break; |
| 405 | } |
| 406 | } |
| 407 | return rc; |
| 408 | } |
| 409 | |
| 410 | #if 0 |
| 411 | int uninstall_links() ? |
| 412 | #endif |
| 413 | #endif /* BB_FEATURE_INSTALLER */ |
| 414 | |
Erik Andersen | 05df239 | 2000-01-13 04:43:48 +0000 | [diff] [blame] | 415 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 416 | int main(int argc, char **argv) |
| 417 | { |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 418 | char *s; |
| 419 | char *name; |
Erik Andersen | bcd6177 | 2000-05-13 06:33:19 +0000 | [diff] [blame] | 420 | const struct BB_applet *a = applets; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 421 | |
John Beppu | 8f425db | 2000-06-27 04:50:02 +0000 | [diff] [blame] | 422 | #ifdef BB_FEATURE_INSTALLER |
John Beppu | 27b5924 | 2000-06-27 04:56:45 +0000 | [diff] [blame^] | 423 | /* |
| 424 | * This style of argument parsing doesn't scale well |
| 425 | * in the event that busybox starts wanting more --options. |
| 426 | * If someone has a cleaner approach, by all means implement it. |
| 427 | */ |
John Beppu | 8f425db | 2000-06-27 04:50:02 +0000 | [diff] [blame] | 428 | if (argc > 1 && (strcmp(argv[1], "--install") == 0)) { |
| 429 | int use_symbolic_links = 0; |
| 430 | |
John Beppu | 27b5924 | 2000-06-27 04:56:45 +0000 | [diff] [blame^] | 431 | /* to use symlinks, or not to use symlinks... */ |
John Beppu | 8f425db | 2000-06-27 04:50:02 +0000 | [diff] [blame] | 432 | if (argc > 2) { |
| 433 | if ((strcmp(argv[2], "-s") == 0)) { |
| 434 | use_symbolic_links = 1; |
| 435 | } |
| 436 | } |
| 437 | /* |
| 438 | * FIXME : |
| 439 | * I need a clever unix trick that'll tell |
| 440 | * me where to find the currently running |
| 441 | * busybox binary |
| 442 | */ |
| 443 | return install_links("/bin/busybox", use_symbolic_links); |
| 444 | } |
| 445 | #endif /* BB_FEATURE_INSTALLER */ |
| 446 | |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 447 | for (s = name = argv[0]; *s != '\0';) { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 448 | if (*s++ == '/') |
| 449 | name = s; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 450 | } |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 451 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 452 | *argv = name; |
| 453 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 454 | while (a->name != 0) { |
| 455 | if (strcmp(name, a->name) == 0) { |
Eric Andersen | b610615 | 2000-06-19 17:25:40 +0000 | [diff] [blame] | 456 | exit(((*(a->main)) (argc, argv))); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 457 | } |
| 458 | a++; |
| 459 | } |
Eric Andersen | b610615 | 2000-06-19 17:25:40 +0000 | [diff] [blame] | 460 | return(busybox_main(argc, argv)); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | |
| 464 | int busybox_main(int argc, char **argv) |
| 465 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 466 | int col = 0; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 467 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 468 | argc--; |
| 469 | argv++; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 470 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 471 | if (been_there_done_that == 1 || argc < 1) { |
Erik Andersen | bcd6177 | 2000-05-13 06:33:19 +0000 | [diff] [blame] | 472 | const struct BB_applet *a = applets; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 473 | |
Erik Andersen | 330fd2b | 2000-05-19 05:35:19 +0000 | [diff] [blame] | 474 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n" |
| 475 | "Usage: busybox [function] [arguments]...\n" |
| 476 | " or: [function] [arguments]...\n\n" |
John Beppu | b4f8606 | 2000-04-13 03:36:01 +0000 | [diff] [blame] | 477 | "\tBusyBox is a multi-call binary that combines many common Unix\n" |
| 478 | "\tutilities into a single executable. Most people will create a\n" |
| 479 | "\tlink to busybox for each function they wish to use, and BusyBox\n" |
Erik Andersen | 330fd2b | 2000-05-19 05:35:19 +0000 | [diff] [blame] | 480 | "\twill act like whatever it was invoked as.\n" |
| 481 | "\nCurrently defined functions:\n", BB_VER, BB_BT); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 482 | |
| 483 | while (a->name != 0) { |
| 484 | col += |
| 485 | fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "), |
| 486 | (a++)->name); |
| 487 | if (col > 60 && a->name != 0) { |
| 488 | fprintf(stderr, ",\n"); |
| 489 | col = 0; |
| 490 | } |
| 491 | } |
| 492 | fprintf(stderr, "\n\n"); |
| 493 | exit(-1); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 494 | } |
Eric Andersen | b610615 | 2000-06-19 17:25:40 +0000 | [diff] [blame] | 495 | /* If we've already been here once, exit now */ |
| 496 | been_there_done_that = 1; |
| 497 | return (main(argc, argv)); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 498 | } |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 499 | |
| 500 | /* |
| 501 | Local Variables: |
| 502 | c-file-style: "linux" |
| 503 | c-basic-offset: 4 |
| 504 | tab-width: 4 |
| 505 | End: |
| 506 | */ |