Compare commits

...
530 Commits
Author SHA1 Message Date
Eric Andersen f8263516c2 Log the devps patch update 2000-09-26 05:08:04 +00:00
Eric Andersen db7f2af089 Final touchups for the release...
-Erik
2000-09-26 05:02:50 +00:00
Eric Andersen f6b7139971 Add in busybox.h. I renamed it, and forgot to commit the newky named version.
-Erik
2000-09-26 01:09:18 +00:00
Eric Andersen d266748c76 Yet more polish (thanks again to kent robotti for the bug reports).
-Erik
2000-09-26 01:00:15 +00:00
Eric Andersen 53323695c5 Remove all reference to the now obsolete /dev/modules
-Erik
2000-09-26 00:52:05 +00:00
Eric Andersen 67fdf5e538 Update my devps patch for the latest 2.2 kernel.
-Erik
2000-09-26 00:20:28 +00:00
Eric Andersen ff1ed7215c Fix name 2000-09-25 22:53:33 +00:00
Eric Andersen d89882da16 Some more polish to make xargs act like GNU xargs (thanks to kent robotti
<robotti@metconnect.com> for testing and pointing out the differences)
 -Erik
2000-09-25 22:53:05 +00:00
Eric Andersen 3570a34de4 Renamed "internal.h" to the more sensible "busybox.h".
-Erik
2000-09-25 21:45:58 +00:00
Eric Andersen caffb6eff0 Gratuitously changed the file "busybox.defs.h" to the more
sensible and noticable "Config.h".
 -Erik
2000-09-25 21:28:07 +00:00
Eric Andersen c5949f62e5 Fix from Matt Kraai for the to the "busybox --install prints out on STDERR
"File already exists" messages for all files (including the ones that DON'T
exist)" problem reported by "Bruno L. F. Cabral" <bruno@openline.com.br>.

Thanks Matt!
 -Erik
2000-09-25 20:35:54 +00:00
Eric Andersen e081eae7a4 Final (I think) version of xargs. Throw away all that tedious string
scrubbing, and quit using system.  Instead, use fork() and exec(), which
yields and smaller, simpler, and cleaner design.
 -Erik
2000-09-25 20:23:21 +00:00
Eric Andersen bf73909f23 Be ever so pedantic about escaping chars that the shell might not like... 2000-09-25 18:41:18 +00:00
Eric Andersen 944be90b21 Remove a now unneeded check 2000-09-25 16:58:39 +00:00
Eric Andersen fe4208fe93 modified by Bryan Rittmeyer <bryan@ixiacom.com> to support SH4 2000-09-24 03:44:29 +00:00
Eric Andersen 488aac2e2a Update newdoc dependancy 2000-09-24 02:42:48 +00:00
Eric Andersen 896fa4ea1d Update a few entries for 0.47... 2000-09-24 02:42:18 +00:00
Eric Andersen 57f83fffd8 Doc update 2000-09-24 02:41:44 +00:00
Eric Andersen 6f283c2f77 Fix up xargs so that things like 'cat cat.c | xargs echo' will
work properly.
 -Erik
2000-09-24 02:40:56 +00:00
Eric Andersen 9ae3838657 Fix xargs option parsing 2000-09-24 01:12:54 +00:00
Eric Andersen 1b1cfde1f8 Fix bug#1043 -- hanlde long filenames and links (in this case, by complaining
that thay exist and skipping such files when extracting and when archiving.
 -Erik
2000-09-24 00:54:37 +00:00
Eric Andersen 0102a9fd48 Fix an obscure option parsing bug. 2000-09-23 22:36:24 +00:00
Eric Andersen 2da90d3b58 Force optind=1 for libc5 when doing cp in cp_mv.c 2000-09-23 20:55:59 +00:00
Eric Andersen 285b446d17 Fix potential memory overrun... 2000-09-23 19:56:46 +00:00
Eric Andersen 32e95f988d Fix the bandaid. 2000-09-23 19:55:59 +00:00
Eric Andersen 96bdde97fb Fix memory problems, and make behavior correct. 2000-09-23 19:53:31 +00:00
Eric Andersen 6d66817b6b update docs for xargs 2000-09-23 06:12:34 +00:00
Eric Andersen 82e0614101 update usage for xargs 2000-09-23 06:11:03 +00:00
Eric Andersen a37d5b772b rewrite, so it should be firly clean now 2000-09-23 06:10:14 +00:00
Eric Andersen 5b17693f0a Use minix xargs instead, and update docs accordingly
-Erik
2000-09-22 20:22:28 +00:00
Eric Andersen ebc0dd7a8a Comment on xargs choice. 2000-09-22 20:02:34 +00:00
Eric Andersen 92a61c1206 Add in xargs 2000-09-22 20:01:23 +00:00
Matt Kraai 90f580ad5b Start the great EXIT_{SUCCESS,FAILURE} migration. 2000-09-22 03:45:34 +00:00
Matt Kraai d995493987 Clean up error messages. 2000-09-22 03:36:27 +00:00
Matt Kraai a2f2a8f8c0 Add support for the -L option to ls. 2000-09-22 03:11:47 +00:00
Matt Kraai 810d38f850 Fix loop.h dependencies. 2000-09-22 02:33:29 +00:00
Eric Andersen a1b35c4512 Apply a bandaid suggested by Jon McClintock <jonm@bluemug.com>, since deallocvt
has code for handling no arguments, but the usage checking code aborted if
there are any other than two arguments.
 -Erik
2000-09-22 00:40:39 +00:00
Eric Andersen 8c185f9600 Fix for bug #1042 -- applied the patch from Larry Doolittle
<ldoolitt@recycle.lbl.gov> to fix the bug.
 -Erik
2000-09-22 00:38:07 +00:00
Eric Andersen 75610e18b3 Better cross libc compatibility (so Dave Cinege can stop complaining
that I broke it).
 -Erik
2000-09-22 00:22:10 +00:00
Eric Andersen 2c1faecba7 Decouple DODEBUG and DOSTATIC 2000-09-21 22:26:02 +00:00
Eric Andersen c873d61008 Remove all the kernel headers so it will compile under libc5
-Erik
2000-09-21 04:09:58 +00:00
Eric Andersen ba35b98444 Fix a potential warning 2000-09-21 04:05:38 +00:00
Eric Andersen d2f5677762 Add in exec support (patch from Torbj?rn Axelsson <torax@cendio.se>)
and disable backticks (since they are still wierdly broken in some
cases.
2000-09-21 02:48:07 +00:00
Eric Andersen d1de4a16ad Handle 'cat -' 2000-09-21 02:39:50 +00:00
Eric Andersen f34aa4c378 Hard code the name of init. 2000-09-21 02:32:11 +00:00
Eric Andersen 8a2e56c5df Large file >2Gib support. 2000-09-21 02:23:30 +00:00
Eric Andersen 350b3f9236 Typo fix. 2000-09-21 02:06:35 +00:00
Eric Andersen ae22612792 Ignore loop.h 2000-09-21 02:05:43 +00:00
Eric Andersen 624cc771da More portable handling of loop header files, as done in util-linux 2000-09-21 02:04:51 +00:00
Eric Andersen 8847b9a03a Remove a warning. Patch from Bryan Rittmeyer <bryan@ixiacom.com> 2000-09-21 01:33:05 +00:00
Matt Kraai 7c22b77162 Only remove directories when removing recursively. 2000-09-20 23:10:21 +00:00
Eric Andersen cff3fe3ae9 Added dos2unix, unix2dos, and unrpm.c thanks to robotti@metconnect.com.
-Erik
2000-09-20 19:22:26 +00:00
Eric Andersen 0cccdfaf36 When mounting a ro fs rw, print warning and then mount it ro. Patch
from Dave Cinege.
 -Erik
2000-09-20 06:23:36 +00:00
Matt Kraai b938e2ff99 Return failure if ping gets no response. 2000-09-20 04:33:30 +00:00
Eric Andersen 46a98dfb13 Reverted my conversion of tar to getopt to ensure tar can
handle traditional semantics (i.e. 'tar -xvf -' or 'tar xvf'
now both work).
 -Erik
2000-09-19 21:35:14 +00:00
Eric Andersen 56f3e353da Both of these commands were subtly broken. Fortunately when used together the
damage was only ugly fscks.  Reverted to the static inline code so they work
correctly again,
 -Erik
2000-09-19 21:13:55 +00:00
Eric Andersen 06f64b2370 I think these featires are fairly safe...
-Erik
2000-09-19 07:16:39 +00:00
Matt Kraai 0b2da467a8 Avoid segfaults by not using snprintf to copy strings. 2000-09-19 06:46:44 +00:00
Matt Kraai 721119e1db Clean up output. 2000-09-19 05:25:12 +00:00
Glenn L McGrath cd26ff4eac Only defines functions that will compile and are usefull under the 2000-09-19 02:25:36 +00:00
Eric Andersen 252bacc9ea Apply a patch from Chip Rosenthal <chip@unicom.com> to fix NFS mounting,
which had been inadvertantly broken...
 -Erik
2000-09-19 01:21:13 +00:00
Glenn L McGrath fd3741d712 Remove definition of basename.
It was defined out so that it would never be seen, and if it was ever seen it wasnt used for anything. It also stops gunzip compiling under the Hurd.
2000-09-18 10:20:16 +00:00
Glenn L McGrath 38c8551cf2 Path count was out by one, fixed it 2000-09-18 09:52:03 +00:00
Glenn L McGrath 63dde9d4ce Simplify and remove dependence on PATH_MAX
buf[PATH_MAX] now defined using strlen to the exact size to be used.
removed output that was displayed if which didnt find the command, this makes itmatch the behaviour of GNU's which.
These modifications result in a slight size decrease.
2000-09-18 09:37:40 +00:00
Matt Kraai b2f36af157 Updated stdin/stdout treatment to match that of gnu tar. 2000-09-15 22:47:34 +00:00
Matt Kraai 6fc2a7d04d Reorganize listing code. 2000-09-15 22:23:41 +00:00
Matt Kraai 82cfbad216 Allow non-verbose listing to work. 2000-09-15 21:18:43 +00:00
Pavel Roskin c9db2e8665 Updated to be in sync with the current sample inittab 2000-09-15 17:24:13 +00:00
Pavel Roskin d2d3aa39ef Fixed compliance with the DTD 2000-09-15 17:16:40 +00:00
John Beppu 2aee993118 + credit markw@lineo.com for his contributions 2000-09-15 08:04:42 +00:00
Pavel Roskin f5cf8c6c65 Don't suppress output of umount and swapoff - it is both unwise
and incompatible with lash that doesn't support >&1 yet.
2000-09-15 01:34:17 +00:00
Pavel Roskin 33bee33af0 Don't suppress output of umount and swapoff - it is both unwise
and incompatible with lash that doesn't support >&1 yet.
2000-09-15 01:02:50 +00:00
Pavel Roskin 5f84fd7066 "exit NUMBER" should exit, not return 2000-09-15 00:46:51 +00:00
Pavel Roskin cbe05e45db For "askfirst" don't just read one char from stdin,
read the whole line using getc(), so that everything before Enter
gets discarded.
2000-09-14 22:47:29 +00:00
Eric Andersen 7e3bf6e339 Add in a patch from robotti@metconnect.com and Chip Rosenthal to make
init do login shell stuff.
 -Erik
2000-09-14 22:01:31 +00:00
Eric Andersen ce40fc044b Note the syslogd bug fix 2000-09-14 21:56:18 +00:00
Eric Andersen 5d63884a8f Bug fix for wget, and proper attribution of Chip Rosenthal and
Covad Communications for the contribution of wget.
 -Erik
2000-09-14 21:46:30 +00:00
Eric Andersen 31e6829bd8 Fix the halt/reboot/poweroff segfault when used from within an initrd...
-Erik
2000-09-14 21:12:20 +00:00
Matt Kraai 131241f71c Backslashes shouldn't be treated as backticks. 2000-09-14 00:43:20 +00:00
Matt Kraai cbbe4d6bc2 Copy the string terminator. 2000-09-14 00:26:50 +00:00
Glenn L McGrath 56a328810b Fix looping bug, use fullRead 2000-09-13 23:08:07 +00:00
Eric Andersen b4c3c59a45 Add in BasicLinux by request 2000-09-13 23:06:41 +00:00
Pavel Roskin f8e04f7113 Added _install 2000-09-13 16:52:32 +00:00
Eric Andersen fb6a50820c Ensure forked processes always are on a controlling tty, so the
^C can be properly sent to /dev/console.
 -Erik
2000-09-13 16:15:29 +00:00
Pavel Roskin d39d120998 Make syslogd ignore SIGCLD only if SIGCLD is defined. This should fix SPARC.
Also ignore SIGCHLD - it must have been meant.
2000-09-13 14:14:29 +00:00
Pavel Roskin 5d513f7256 List of signals updated from util-linux-2.10o
Architecture names are no longer used - should now compile on SPARC
2000-09-13 14:03:48 +00:00
Matt Kraai dd450a0ded Don't fork for the . (source) command so that environment settings are
preserved.
2000-09-13 03:43:36 +00:00
Matt Kraai 322ae93a5e Fix calls to {m,c,re}alloc so that they use x{m,c,re}alloc instead of
segfaulting or handling errors the same way themselves.
2000-09-13 02:46:14 +00:00
Matt Kraai b89075298e Fix unchecked calls to {m,c,re}alloc so that they print an error and
exit rather than segfaulting (what an improvement).
2000-09-13 02:08:21 +00:00
Pavel Roskin 23ad7f7f06 Typo fix: resolv -> resolve 2000-09-12 22:05:17 +00:00
Eric Andersen ccb0a9ba88 Formatting cleanup patch from Bryan Rittmeyer <bryan@ixiacom.com>.
-Erik
2000-09-12 16:20:49 +00:00
Glenn L McGrath fca8050f0f Fix .deb unpack and experimental TAR support
The previous ar.c fialed to recognise one record in .debs

Experimental tar support, this is currently *very* cheap because ar and
tar are functionally similar. It  will need lots of testing so by
default tar support code is defined out.
To test uncomment the line "#define BB_AR_EXPERIMENTAL_UNTAR"
2000-09-11 05:25:39 +00:00
Glenn L McGrath ac19b7e032 Extra defines for ar 2000-09-11 05:06:13 +00:00
Eric Andersen 49352adf9c Simplify a few little things, and merge in a patch from
robotti@metconnect.com so that 'ar -xv' and 'ar -x -v'
both work.
 -Erik
2000-09-11 04:55:31 +00:00
Glenn L McGrath 605a819a17 New dd behaviour 2000-09-11 00:33:09 +00:00
Glenn L McGrath f0b073f55a dd now truncates files at the end its write, this can be turned of by
specifying conv=notrunc in the command line

This conforms to GNU dd behaviour
2000-09-11 00:32:13 +00:00
Eric Andersen de34e43755 MAke lsmod act just like modutils lsmod, by printing which modules use
other modules, and state info like (deleted) and such.
 -Erik
2000-09-10 16:16:00 +00:00
Eric Andersen cbb61c78ae Make init handle current 2.4.x sysinfo behavior
-Erik
2000-09-10 16:13:41 +00:00
Eric Andersen 73de6561ca Update free for current 2.4.x behavior...
-Erik
2000-09-10 16:10:41 +00:00
Glenn L McGrath 729216cb11 Remove some debugging code 2000-09-10 04:42:20 +00:00
Glenn L McGrath 18310f1ce3 Using seek=? used to cause part of the original file to be zero'ed, i
think this was caused by opening the file in truncate mode.
2000-09-10 04:39:37 +00:00
Glenn L McGrath 0ae8e5a645 My previous attempt to make dd use fullRead, fullWrite was very broken,
this should actually work.
2000-09-10 01:54:27 +00:00
Glenn L McGrath bd7c67136a remove some printf statements i forgot about 2000-09-09 15:04:34 +00:00
Glenn L McGrath 1c6917d2c4 Updated to match new -R ar functionality 2000-09-09 14:57:15 +00:00
Glenn L McGrath e2b345a6d8 Implemented new ar functionality unique to busybox ar (i think), the -R
option enable a Recursive extraction (or listing) to take place.

i.e. if any files being extracted are themselves ar archives then
busybox ar will extract their contents as well.

e.g. take bar.deb and do (with GNU ar) ar -q foo.deb b.ar
then with busybox ar can do ar -x b.ar data.tar.gz

-R isnt used for anything in GNU ar so i think it should be ok, could
have used long options

This functionality will become (more) usufull with tar, gz support.
2000-09-09 14:50:04 +00:00
Glenn L McGrath 437bf72785 Changed getopt so that options can be grouped together, the source
archive is now assumed to be the first non parameter.

This is how GNU ar behaves.
2000-09-09 13:38:26 +00:00
Glenn L McGrath 6fb88e73f7 Fix permisions 2000-09-09 12:48:40 +00:00
Glenn L McGrath 8324b9f1aa Now supports GNU style long filenames.
If no filenames are specifed to be (extracted/listed) it will act on
all files in the archive (i dont think the old version did this)

Code is structured to better support upcoming recursive extraction
functionality.

The old code was a bit strange in places, dont know what i was thinking.
2000-09-09 08:35:45 +00:00
Eric Andersen 11c655295c New ls sorting patch, as written by Sterling Huxley, and then updated
by kent robotti.  I then updated it to use my_getpwuid and my_getgrgid
(per busybox policy).
 -Erik
2000-09-07 17:24:47 +00:00
Matt Kraai 44e3840343 Stop leaking file handles. 2000-09-07 04:34:17 +00:00
Matt Kraai 17c8851813 Fix more typos. 2000-09-06 03:59:49 +00:00
Matt Kraai 6085c72b6e Reset optind so that getopt works in busybox applets called directly by sh.
Change the behavior of -c to correctly handle $1..$9.
2000-09-06 01:46:18 +00:00
Matt Kraai 9dd79791c8 Fixed a grammatical error. 2000-09-06 00:50:51 +00:00
Eric Andersen ebee301c8b Fixed for when BB_CP_MV is enabled. 2000-09-05 22:17:22 +00:00
Eric Andersen d13ebff163 Add BB_SH to get_last_path_component()... Fix thanks to
Bj�rn Eriksson.
2000-09-05 21:50:52 +00:00
Eric Andersen 1eec89df4c Apply segfault on no-args fix from robotti@metconnect.com 2000-09-05 18:21:53 +00:00
Eric Andersen 3639c5d950 Set environment variable to make ash happy. ash is a frequent enough
target....
2000-09-05 17:57:52 +00:00
Eric Andersen 1b355ebba6 Added expr, from Edward Betts <edward@debian.org>, with some fixups
and docs added by me.
 -Erik
2000-09-05 17:37:48 +00:00
Matt Kraai 43c8c38bbf Allow compilation when not using BB_FEATURE_TAR_EXCLUDE, and fix
handling of --exclude option.
2000-09-04 16:51:55 +00:00
Eric Andersen 61a9d8d145 Forgot this part of wget 2000-09-04 15:16:51 +00:00
Eric Andersen 9670083818 Initial implementation of wget, from Chip Rosenthal <chip@laserlink.net>.
Very cool.  Still lacks "chunked" transfer-coding, so not totally RFC
compliant for HTTP1.1, but very nice nonethe less, and very small.
 -Erik
2000-09-04 15:15:55 +00:00
Matt Kraai b92223b6f5 Allow selective extraction and listing of files. And fix an unchecked
return value of realloc (with xrealloc).
2000-09-04 08:25:42 +00:00
Eric Andersen fd50c3d2f9 Add in byld 2000-09-01 22:24:03 +00:00
Eric Andersen cb91d69b3f Fix compile when BB_FEATURE_LINUXRC is defined
-Erik
2000-09-01 18:43:02 +00:00
Eric Andersen 73bdf13d35 Fixed a stupid thinko preventing zcat from doing its job, thanks
to Torbj�rn Axelsson <torax@cendio.se> for the fix.
 -Erik
2000-09-01 16:25:33 +00:00
Eric Andersen 3a957b9d4c Turned off ls file-sorting till it can be fixed. 2000-09-01 16:15:51 +00:00
Eric Andersen 18a1014c95 updated some usage info from a patch from robotti@metconnect.com
-Erik
2000-09-01 16:12:57 +00:00
Matt Kraai da542f3a0c Argh. I *will* compile before checking in. 2000-09-01 02:53:01 +00:00
Matt Kraai f446297afd Don't unlink files if we are extracting to stdout. 2000-09-01 02:50:48 +00:00
Eric Andersen e99674a70f Correct the stdin/stdout behavior when no args are provided.
-Erik
2000-09-01 00:41:10 +00:00
Eric Andersen 5eb5912790 Sigh. Seems I screwed up last time. This fixed detecting
when on a console or not, and make default behavior compatible
with GNU gzip...
 -Erik
2000-09-01 00:33:06 +00:00
Eric Andersen 4e61db2284 Add an extra sanity check in parse_mode
-Erik
2000-09-01 00:06:17 +00:00
Eric Andersen ad3d90f91e Fix a spelling error
-Erik
2000-08-31 23:53:58 +00:00
Eric Andersen a3de24e85d Fix spelling error
-Erik
2000-08-31 23:52:46 +00:00
Matt Kraai 1638488d26 Rewritten by mistake. 2000-08-28 03:53:27 +00:00
Matt Kraai ab60f6987a Removed dead regular expression code. 2000-08-28 03:12:30 +00:00
Matt Kraai 88cc3057fd Compile xstrdup and xstrndup iff they are needed. 2000-08-26 16:52:28 +00:00
Glenn L McGrath 06aeb6c417 ar.c now uses a linked list to process headers, uses getopt, new internal function extractAr(srcFD, dstFd, filename) to make it easily accessable to other busybox functions.
moved copySubFile from ar.c to utilities.c

modified dd.c to use fullWrite

modified copyFile in utilities.c to use copySubFile
2000-08-25 03:50:10 +00:00
Eric Andersen 4d5ac2f346 Fix tab stops for sed usage. 2000-08-25 00:23:36 +00:00
Pavel Roskin 3a0f4baf2f Fixed a warning about a label not being used 2000-08-22 15:47:57 +00:00
Pavel Roskin 8237add8d0 Fixed misuse of type "char" 2000-08-22 15:38:16 +00:00
Pavel Roskin 32f2769800 From Ken Chalmers <chalmers@norscan.com>:
The current CVS mount.c is missing a semicolon, causing building to fail
if NFS is enabled (#define BB_NFSMOUNT).
2000-08-22 15:35:31 +00:00
Eric Andersen 089d12d762 Fix a unterminated string.
-Erik
2000-08-22 05:18:30 +00:00
Eric Andersen aaa94fb8a9 Note the chmod fix.
-Erik
2000-08-22 01:02:05 +00:00
Eric Andersen ce82c8ab77 Fix an option parsing bug where things like
chmod -r /tmp/file
wholdn't work (since it thought -r was an option).  Doh!
 -Erik
2000-08-22 01:00:56 +00:00
Mark Whitley 2368a387ed Some additional tips and formatting changes. 2000-08-22 00:20:21 +00:00
Eric Andersen e4c4d69c04 Fix a silly bug so it compiles up properly
-Erik
2000-08-21 23:29:45 +00:00
Eric Andersen 6ab22027d0 Oops. Forgot to commit rdate.c.
-Erik
2000-08-21 23:04:00 +00:00
Eric Andersen fba9c00071 Script to do regression test, by combining all possible options.
-Erik
2000-08-21 23:01:39 +00:00
Eric Andersen acf5551099 Script to do regression test, by combining all possible options.
Run this to check for combinitorial type build errors.
 -Erik
2000-08-21 23:01:20 +00:00
Eric Andersen 918507edda Added the 'rdate' command, thanks to Sterling Huxley <sterling@europa.com>.
I added the docs, and made behavior identical to the GNU version.
 -Erik
2000-08-21 22:46:33 +00:00
Eric Andersen 851ce895bd Turn off some debug noise.
-Erik
2000-08-21 22:34:23 +00:00
Eric Andersen a1f16bba72 Added getopt(1) from "Alfred M. Szmidt" <ams@trillian.itslinux.org>
-Erik
2000-08-21 22:02:34 +00:00
Eric Andersen e2205f093b Removed since this patch is now in the current 2.4.x kernel
tree.
 -Erik
2000-08-21 21:44:52 +00:00
Mark Whitley 0e4cec0be8 Applied patch from Mark Ferrell <mferrell@mvista.com> to use the 'p' option in
substitution expressions.
2000-08-21 21:29:20 +00:00
Eric Andersen dc746169cf Oops. Forgot to add in reset.c. Doh!
-Erik
2000-08-21 21:26:33 +00:00
Eric Andersen 282c364148 Fix a thinko, thanks to Klaasjan <klaasjan@europe.com>
-Erik
2000-08-21 21:23:48 +00:00
Eric Andersen fa405d0cb2 Add in the "reset" command.
-Erik
2000-08-21 21:18:52 +00:00
Eric Andersen 202995c612 Yet another patch to fixup lsmod
-Erik
2000-08-21 19:40:42 +00:00
Eric Andersen c86e5e6145 Some leftover stuff I forgot to commit for the lsmod change.
-Erik
2000-08-21 19:38:49 +00:00
Eric Andersen be0dc0d06a lsmod now uses the query_module syscall, rather then /proc
-Erik
2000-08-21 19:25:16 +00:00
Eric Andersen b2fc5a0647 syslogd was leaking processes that could forever busyloop. Fixed.
-Erik
2000-08-20 06:11:32 +00:00
Eric Andersen e89267c8b3 Minor fixups.
-Erik
2000-08-19 20:16:16 +00:00
Eric Andersen 8cbac440d6 Better 'mt' docs, thanks to Kent Robotti <robotti@metconnect.com>
-Erik
2000-08-11 20:14:11 +00:00
Eric Andersen 6ac18a3d83 Fix to make 'ar xv' work, thanks to Kent Robotti <robotti@metconnect.com>
-Erik
2000-08-11 20:11:35 +00:00
Eric Andersen bb39a31e33 Minor link update
-Erik
2000-08-11 18:13:21 +00:00
Eric Andersen 79565b6c91 Add optional ls file sorting, thanks to a patch from
Sterling Huxley <sterling@europa.com>
 -Erik
2000-08-11 18:10:21 +00:00
Eric Andersen f9ca653faa Added fix from David Vrabel <dvrabel@arcom.co.uk> for a
buffer overrun in find_real_root_device(), fixing bug #1019
 -Erik
2000-08-11 17:45:02 +00:00
Eric Andersen 88f50b6bf5 Some #include updates.
-Erik
2000-08-10 17:59:11 +00:00
Mark Whitley 40406e6bad Applied patch from Mark Ferrell <mferrell@mvista.com> to fix sed '1,$p' where
sed was only printing the first line and then exiting.
2000-08-10 00:09:47 +00:00
Matt Kraai adbf018dc4 We complained if the total number of arguments was greater than 3 and
the destination wasn't a directory.  We should only complain if the
there are multiple sources and target isn't a directory.
2000-08-06 15:36:50 +00:00
Matt Kraai deb95f69b6 Exit with the appropriate value when grepping multiple files. 2000-08-06 15:25:53 +00:00
Eric Andersen 46ade97983 Cleaner way to handle -NUM and +NUM, reduces the mem usage as well.
-Erik
2000-08-02 19:57:18 +00:00
Eric Andersen 0c8e2a6580 Fixed the "-f" option.
-Erik
2000-08-02 18:56:25 +00:00
Eric Andersen fdd5103348 Merge in two patches from Dave Cinege:
the first is a cleanup of tar --exclude
    the second changes mount so mtab works more as it should, and
    also allows mount to use the traditional short form (i.e.
    'mount / -o remount,rw' now works.

While inside tar, I changed it to use getopt...
 -Erik
2000-08-02 18:48:26 +00:00
Mark Whitley 5ae166813f Minor cleanup thingy. fprintf(stderr, ...) -> errorMsg(). 2000-08-02 18:34:41 +00:00
Mark Whitley 807f0fd637 Brand, new version of cut. This fixes the bugs in the old cut, is smaller, and
is a sight easier to understand than the Minix cut.
2000-08-02 18:30:11 +00:00
Eric Andersen d5fa3e3e9a Update to the tail rewrite by "Allen Soard" <esp-software@mail.hypermart.net>
-Erik
2000-08-02 16:42:58 +00:00
Eric Andersen 080d51bf45 Minor fix to clean target
-Erik
2000-08-01 22:44:32 +00:00
Matt Kraai 0f8f7b8a35 Fix bug 1017, which reports that insmod segfaults when /lib/modules doesn't
exist.  Also allow early search termination (per the comments).
2000-08-01 18:16:56 +00:00
Eric Andersen 98bbd688a8 Commit the rewrite of tail by Allen Soard
<esp-software@mail.hypermart.net>.  Thanks Allen for
you work at getting this into shape,
 -Erik
2000-07-31 17:05:58 +00:00
Pavel Roskin 43c17b3d96 New variable WARNINGS to hold all warning options 2000-07-28 19:41:32 +00:00
Pavel Roskin 616d13bcd1 Fixed to pass -Wundef 2000-07-28 19:38:27 +00:00
Pavel Roskin 259972e565 Disabled debugging output
Fine-grained checks for possible errors instead of "set -e"
The standard output shows what is being linked to what
2000-07-28 19:34:02 +00:00
Eric Andersen 9cf306d55e Fix for a potential uninitialized variable, thx to
Ken Chalmers <chalmers@norscan.com>
 -Erik
2000-07-28 19:05:20 +00:00
Eric Andersen 6a4c33c5c0 Clean up the nasty blunder I'd made of how different behaviors happen.
-Erik
2000-07-28 17:08:36 +00:00
Eric Andersen 6150df320a Some cleanups, based on a patch from Ken Chalmers
-Erik
2000-07-28 16:22:51 +00:00
Eric Andersen d5704686b1 Fix from Robert Kaiser for stdin behavior.
-Erik
2000-07-28 15:20:24 +00:00
Eric Andersen 1428c4f136 Oops. Forgot an ifdef
-Erik
2000-07-28 15:19:30 +00:00
Eric Andersen a5716d3029 Fix from Arne Bernin for return code -- now reflects whether the rmmod
failed or not.
 -Erik
2000-07-28 15:16:37 +00:00
Eric Andersen 501c88b245 More sh updates (with related changes to everything else). Switched
to using getopt and cleaned up the resulting mess.  if-then-else-fi
is now basically working (given a bunch of constraints).
 -Erik
2000-07-28 15:14:45 +00:00
Eric Andersen 6a99aaf020 More shell features.... if-then-else-fi is now basically usable (disable
by default pending further debugging).  Added in some basic shell environment
support (i.e. $?, $0-$9, $$, $!, $#).
 -Erik
2000-07-27 00:15:20 +00:00
Mark Whitley 7ce41ad692 Fixed a syntax error & superfluous param decl that was causing the build to
fail.
2000-07-26 18:09:22 +00:00
Eric Andersen e92108ae6d Minor style cleanups. 2000-07-26 00:53:56 +00:00
Eric Andersen 0d49dd53cf Better description 2000-07-26 00:53:34 +00:00
Eric Andersen cc10a5b42b Fix some bitrot.
-Erik
2000-07-26 00:52:04 +00:00
Mark Whitley 83e85f6a08 Modified print_subst_w_backrefs() so it will print backslash escaped
characters properly, just like GNU sed.
2000-07-25 20:48:44 +00:00
Mark Whitley 52681b48dc Added a note in the "Tips and Pointer" section on the correct way to test for
string equivalence with strcmp().
2000-07-25 20:30:00 +00:00
Eric Andersen fad9c1198a Finish off fixing up the memleaks (I think). Added the beginnings of
some if-then-else-fi support (nonfunctional and turned off)
 -Erik
2000-07-25 18:06:52 +00:00
Eric Andersen b040d4f3da Use BB_FEATURE_CLEAN_UP where appropriate
-Erik
2000-07-25 18:01:20 +00:00
Eric Andersen b9ea02c04b Add in BB_FEATURE_CLEAN_UP, which is whether to clean up mem leaks and close
files, or not.  Usually safe to leave it off and let the OS clean up...
 -Erik
2000-07-25 17:59:37 +00:00
Eric Andersen d34595d857 Remove some noise.
-Erik
2000-07-25 17:58:01 +00:00
Eric Andersen e5db406690 Clean up $1=$prefix
-Erik
2000-07-25 16:47:03 +00:00
Mark Whitley 40bfc76385 First revision of the Busybox Style Guide and an accompanying .indent.pro
file.
2000-07-24 22:36:06 +00:00
Pavel Roskin e99f7500e0 chroot can now call the builtin shell 2000-07-24 20:15:30 +00:00
Eric Andersen ea824fb937 Fixed stdin/stdout paths so things like
tar cvf - /etc/* | gzip -c9 >test.tgz
will now work.  Fix thanks to Dave Cinege <dcinege@psychosis.com>
with some adjustments by me to be mroe GNU-like.
 -Erik
2000-07-21 22:17:39 +00:00
Eric Andersen bf960f58e2 Added 'renice' command, thanks to Dave Cinege <dcinege@psychosis.com>
-Erik
2000-07-21 21:32:12 +00:00
Eric Andersen 7df345e149 Bump version number.
-Erik
2000-07-21 21:27:11 +00:00
Eric Andersen ec8d60f0f8 Add in the LinuxMagic VPN Firewall
-Erik
2000-07-21 17:22:19 +00:00
Pavel Roskin 0010ee45e3 Fixed usage info for "cut" 2000-07-21 15:10:57 +00:00
Mark Whitley c768ab490e Took -V out of the sed_usage string. 2000-07-20 23:54:42 +00:00
Eric Andersen ced2cefcca * syslogd can now log messages to a remote host -- patch thanks
to Gyepi Sam <gyepi@praxis-sw.com>
 -Erik
2000-07-20 23:41:24 +00:00
Mark Whitley 1f45b268cb As per a discussion on the mailing list between Matt and Pavel. I have removed
the -V (version) flag from busybox sed. It is unnecessary because sed is not a
standalone and should therefore be independently reporting a version number.
Moreover, it is extra code that we just don't need.
2000-07-20 23:08:40 +00:00
Mark Whitley 1ac435c15e Converted option parsing to getopt(). Also added some explanatory comments. 2000-07-20 23:06:27 +00:00
Eric Andersen 51154bacbe Adjusted install.sh to use relative symlinks, and to optionally
create hardlinks.  Added a makefile target to create hardlinks.
 -Erik
2000-07-20 21:57:11 +00:00
Mark Whitley 3950596e1e Converted option parsing to using getopt(). Also managed to remove an
extraneous logic loop that existed only for the purpose of the special case of
only one file. I replaced it with a variable to keep track of the number of
files read.
2000-07-20 00:08:10 +00:00
Mark Whitley 99e370f0c6 Whoops. Forgot to #include <getopt.h>. 2000-07-20 00:03:38 +00:00
Mark Whitley aa4f108338 Converted option parsing to getopt() and made some minor formatting changes. 2000-07-19 19:38:13 +00:00
Matt Kraai 27a804246a Centralize handling of --help. 2000-07-19 19:24:01 +00:00
Matt Kraai 869057238b Added some missing declarations and fixed some typos. I have to
remember to compile *before* committing.
2000-07-19 18:20:02 +00:00
Matt Kraai 2f46b664b7 Add usage messages for applets without them. 2000-07-19 18:01:00 +00:00
Eric Andersen 91a4400fd5 Avoid trying to free NULL ptrs. Comment on malloc usages.
-Erik
2000-07-19 17:37:57 +00:00
Eric Andersen a16c66335e Use FatalError()
-Erik
2000-07-19 17:36:27 +00:00
Eric Andersen ae6eae02dd Moved some code and add a coupld #defines to support use of dmalloc.
-Erik
2000-07-19 17:35:54 +00:00
Eric Andersen 52d6fa3bb3 Funny. Head was getting installed to the wrong spot.
-Erik
2000-07-19 17:34:40 +00:00
Eric Andersen 1d255be78d Updated to add support for dmalloc, and adjusted for better cross
compiler support.
 -Erik
2000-07-19 17:33:54 +00:00
Mark Whitley 2ef880b236 Consolodated some common code into print_matched_line to make 'grep_file' a
little more terse & clean. Also made a few minor formatting changes.
2000-07-18 21:02:06 +00:00
Eric Andersen a9d69fb568 Removed now incorrect message about NFS not working with
Linux 2.[34].x kernels.  It does work now,
 -Erik
2000-07-18 18:54:08 +00:00
Mark Whitley 8f122431f5 Added support for the -c (count matches) option. Made it so it works just like
GNU grep.
2000-07-18 18:37:01 +00:00
Eric Andersen 6efc48c1ae Sigh -- can't sleep. Clean up some mem leaks, fixed some bugs.
-Erik
2000-07-18 08:16:39 +00:00
Pavel Roskin 9c5fcc3408 New message added to messages.c: full_version
Used where possible
2000-07-17 23:45:12 +00:00
Pavel Roskin cc8a66b113 Moved functions used by "lsmod" from cat.c to utility.c
Adjusted to make lsmod and sh compilable as standalone apps.
Comment fixes
2000-07-17 20:18:42 +00:00
Mark Whitley 97562bd9d7 - Added support for backreferences in substitution expressions up to nine
(\1, \2...\9). This touched a lot of places in this file and I added a new
   function 'print_subst_w_backrefs' in order to keep 'do_subst_command' a
   little more tidy.

	* I tested this good 'n hard, but will always appreciate more testing from
	  other, willing folks.

 - Noticed that the index_of_next_unescaped_slash was subtly wrong so I
   changed both the functionality and behavior (it used to skip over the first
   char in the string you passed it, assuming it was a leading '/'--this
   assumption is no longer made) this necessitated changing the lines that
   call this function just slightly.
2000-07-17 20:06:42 +00:00
Pavel Roskin 21ddb38fcf Now it's possible to compile Busybox with only one app defined
(unless it's lsmod, to be fixed by the next commit)
2000-07-17 19:31:54 +00:00
Eric Andersen a1d187a8a8 Backtick support to infinite (memory limited) levels of nesting is
now implemented...  So now busybox shell can do cool stuff like:

    /home/andersen/CVS/busybox # echo foo `wc README` bar
    foo 71 422 2951 README bar

I love writing cool new features....  Muhahahaha...  (I think this is
leaking a little bit of memory every time it expands a backtick process,
so I still needs to do a bit of cleanup...)
 -Erik
2000-07-17 19:14:41 +00:00
Pavel Roskin bc0aed79a8 It is now possible to select in busybox.def.h whether minixfs version 2
is to be supported.
2000-07-17 17:52:00 +00:00
Pavel Roskin 47d4926244 The result of getopt() is "int" and should be treated as such 2000-07-17 16:17:19 +00:00
Matt Kraai bf181b9338 Extract usage information into a separate file. 2000-07-16 20:57:15 +00:00
Matt Kraai 3bd8bd89ee Don't use strings directly in calls to usage(). This is in preparation
for their extraction to a separate file.
2000-07-14 23:28:47 +00:00
Mark Whitley 464c5de00d Fixed a couple of buglets:
- add_cmd_str: segv's were being generated if there was a '# comment' line
   (and probably other kinds of lines, too) that was not followed by a
   semi-colon or whitespace
 - parse_edit_cmd: was returning a wrong number (too low) for the index; it
   was not accounting for backslashes eaten, for the fact that we start at the
   3rd index in the string, or for the fact that we add an extra newline.
 - parse_cmd_str: was returning a wrong number (again, too low) for the index
   in the case of single-letter commands (p,d). There was some
   over-compensation for this in the 'return' stmt at the end which also
   needed some help.
 - load_cmd_file: was not eating trailing newlines off the line read from the
   command file. This had the deleterious effect of printing an extra newlines
   after text displayed from edit (i,a,c) commands.
2000-07-14 23:24:00 +00:00
Mark Whitley 70705d7c96 - Added support for semicolon delimited command lines. (woo-hoo!)
- Obsoleted the trim_str function (#if 0'ed out -- maybedelete later) in
   favor of strrspn.
 - Obsoleted the strrspn function (#if 0'ed out as well) as soon as I
   discovered that it wasn't needed either.
 - Fixed a subtle bug in parse_subst_cmd where it would choke with an error if
   there was any trailing space after the s/match/replace/ expression.
2000-07-14 19:06:30 +00:00
Eric Andersen add09fd558 Getopt'ed by Marc Nijdam <marc_nijdam@hp.com>
-Erik
2000-07-14 18:39:08 +00:00
Eric Andersen 17ad45aace Getopt'rd by Marc Nijdam <marc_nijdam@hp.com>
-Erik
2000-07-14 18:38:26 +00:00
Pavel Roskin df4532bfa3 More fixes for "signed vs. unsigned" warnings. 2000-07-14 17:24:58 +00:00
Pavel Roskin ff5a9033f9 Reduced the number of "signed vs. unsigned" warnings.
Sometimes such warnings matter (esp. on PPC with char default to unsigned)
2000-07-14 16:23:32 +00:00
Pavel Roskin f626dcbc84 More fixes for "missing initializers" 2000-07-14 15:55:41 +00:00
Pavel Roskin 9027bcf2f4 Fixed a warning about missing initializer 2000-07-14 15:44:25 +00:00
Pavel Roskin 93c0d9f090 The result of getopt() should not be converted to "char" - it breaks on PPC 2000-07-14 15:18:57 +00:00
Eric Andersen fad04fdd12 More cleanups.
-Erik
2000-07-14 06:49:52 +00:00
Matt Kraai b870af09ae Fix argument parsing. 2000-07-14 06:47:33 +00:00
Eric Andersen d6912c97de Be more pedantic aboutthe terminating null applet.
-Erik
2000-07-14 06:29:10 +00:00
Eric Andersen 58361a44b5 uid and gid were unsigned, but were compared vs signed values (-1)
-Erik
2000-07-14 06:27:54 +00:00
Eric Andersen e7413a9cde A couple of minor warning cleanups.
-Erik
2000-07-14 06:19:41 +00:00
Matt Kraai d537a95fdb Use errorMsg rather than fprintf. 2000-07-14 01:51:25 +00:00
Eric Andersen 4ac6cb534d Fix some stupid memory bugs.
-Erik
2000-07-14 01:13:37 +00:00
Eric Andersen ec10b9d534 Add in redimentary backtick suport (doesn't work properly yet, but is
close).
 -Erik
2000-07-14 01:13:11 +00:00
Mark Whitley 34623db618 It dawned on me that I would need to grow a char buffer one extra char bigger
to accomodate a trailing '\n'ewline that I append to it later one. This is
only necessary for the case of one inserted, appended, or changed line, but
it's still necessary.
2000-07-14 00:49:59 +00:00
Mark Whitley 02008346c0 Added error checking for edit commands; only a beginning address can be
specified.
2000-07-14 00:13:52 +00:00
Mark Whitley 94074a980c Added support for (a)ppend, (i)nsert, and (c)hange commands to sed. 2000-07-14 00:00:15 +00:00
Mark Whitley 496e33feeb Fixed bug where sed '/foo/p' was printing "invalid command". 2000-07-13 22:52:02 +00:00
Mark Whitley 4f7fe77d07 (Something I should have done in the previous checkin...) Also broke out
substitution command execution from do_sed_command() and put it in it's own
do_subst_command() function.
2000-07-13 20:01:58 +00:00
Mark Whitley 06f3529ada Minor code reorg: Changed the interface to index_of_next_unescaped_slash to an
interface that seems a little more sensible to me. Also broke out s///
expression parsing into it's own subroutine.
2000-07-13 19:58:04 +00:00
Eric Andersen 156959ea93 Fix uninitialized variable.
-Erik
2000-07-13 19:49:12 +00:00
Eric Andersen f4c022649b Patch from Marc Nijdam <marc_nijdam@hp.com>
> First (of many more) patch of cp_mv to getopt use. I'm using the most
> simplistic approach, just get getopt used,  then worry about a cleaner
> option parsing style using getopt later.
>
> Marc
2000-07-13 18:42:58 +00:00
Mark Whitley 55380700d8 Added a smallish TODO comment. 2000-07-13 17:20:23 +00:00
Eric Andersen 00143ba921 From Matt Kraai <kraai@alumni.carnegiemellon.edu>
> Here is a patch so that tr can handle NULL characters as well.  Give it
> a shot and let me know what you think.  It is against the latest CVS
> version.
>
> In my tests, the following now works as expected.
>
> tr '\0' '\n'
>
> Later,
> Matt
2000-07-13 16:40:41 +00:00
Matt Kraai ac48461da9 Correct argument parsing and other minor cleanups. 2000-07-13 06:33:12 +00:00
Mark Whitley 37653aaf9c Added some smallish comments to help folks understand why we have two tables
of builtins and the reasoning behind it.
2000-07-12 23:36:17 +00:00
Mark Whitley c41e8c840f Changed bb_regcomp to xregcomp and #if 0'ed out destroy_cmd_strs in sed.c
(maybe I'll remove it later).
2000-07-12 23:35:21 +00:00
Eric Andersen 6f96e674b9 Patch from Jon McClintock <jonm@bluemug.com>
>The attached patch adds the ability to parse the actual mode specifier in
>fbset. So now
>
>    fbset -n 640x480-72
>
>Will actually work. I don't know if I've reinvented the wheel though...

 -Erik
2000-07-12 23:01:04 +00:00
Matt Kraai be84cd4ef6 Always report the applet name when doing error reporting. 2000-07-12 17:02:35 +00:00
Matt Kraai e58771e73c Use global applet_name instead of local versions. 2000-07-12 15:38:49 +00:00
Matt Kraai e714bce003 Use global applet_name instead of local versions. 2000-07-12 00:53:06 +00:00
Matt Kraai 3ecbe9f4dc The applet name isn't constant. 2000-07-12 00:43:28 +00:00
Eric Andersen 97426e082a Changed verbiage.
-Erik
2000-07-11 23:06:48 +00:00
Eric Andersen 8fbaeece53 Replaced projects with products/projects.
-Erik
2000-07-11 23:05:38 +00:00
Eric Andersen 68fda241d2 Added the Kerbango Internet Radio to projects/products using BusyBox.
-Erik
2000-07-11 23:03:40 +00:00
Mark Whitley 858c1adf2b Applied patch from Matt Kraai to call destroy_cmd_strs in atexit(), rather
than peppering it throughout the code.
2000-07-11 21:38:47 +00:00
Matt Kraai 7719008a85 Added applet_name to contain the applet name. 2000-07-11 20:03:24 +00:00
Eric Andersen aec27bca98 Final updates for release.
-Erik
2000-07-11 18:18:40 +00:00
Eric Andersen 960be79964 Final update for the release. 2000-07-11 18:06:01 +00:00
Eric Andersen be909b1cd5 Forgot to commit these cleanups it seems.
-Erik
2000-07-11 17:52:22 +00:00
Eric Andersen d006c9e630 More changelog updates
-Erik
2000-07-11 17:45:42 +00:00
Mark Whitley 9ebccb2891 Added changelog entries for grep/sed/regex changes. 2000-07-11 17:43:42 +00:00
Eric Andersen f1f6d58598 Some changelog updates.
-Erik
2000-07-11 17:42:56 +00:00
Eric Andersen 0c838af50b Re-enable ln -n in the help.
-Erik
2000-07-11 17:38:27 +00:00
Eric Andersen 195fa15caf Another patch from Matt Kraai <kraai@alumni.carnegiemellon.edu>:
>
> The following patch allows ln -n to function like GNU.  It also fixes a
> typo with my previous patch to add support for ln FILE DIRECTORY.  And
> it removes some code that checks the maximum length of the filenames.  I
> can't figure out why that code is necessary.  Anyone know?
>
> Matt
2000-07-11 17:35:32 +00:00
Eric Andersen 61dc057183 Added 'dumpkmap' to allow people to dump a binary keymap, which can then be
loaded in by 'loadkmap' -- submitted by Arne Bernin <arne@matrix.loopback.org>
 -Erik
2000-07-11 17:29:36 +00:00
Mark Whitley df5f6ba115 Applied patch from Matt Kraai which does the following:
- adds case-insensitive matching in sed s/// epxressions
 - consolodates common regcomp code in grep & sed into bb_regcomp and put in
   utility.c
 - cleans up a bunch of cruft
2000-07-11 16:53:56 +00:00
Matt Kraai da9841efc1 Fix dead link.
-Matt
2000-07-11 16:09:01 +00:00
Eric Andersen da1d1e763d Fixed NFS so it supports 2.4.x kernels and NFSv3. Should close bug #1009.
-Erik
2000-07-10 23:39:44 +00:00
Mark Whitley cc54d12ef7 Removed all trace of hand-tooled regexp routines. Bye bye, baby. 2000-07-10 23:07:54 +00:00
Mark Whitley dd23b8bb43 Added a rule to make tags files for vi(m). 2000-07-10 23:00:47 +00:00
Eric Andersen c674d70699 Comment on kernel stuff
-Erik
2000-07-10 22:57:14 +00:00
Mark Whitley 6315ce603b Brand, new sed that uses libc regex routines.
There is some common code used by both sed & grep that should be put into
utility.c as per Mat Kraai's suggestions/patch on the mailing list.
Specifically, a common regex_compile() and a regex_subst() function need to be
made.
2000-07-10 22:55:51 +00:00
Eric Andersen 85c552035e More linux kernel header file removal.
-Erik
2000-07-10 22:46:55 +00:00
Eric Andersen 9b2297a34e Remove yet more kernel header dependancies.
-Erik
2000-07-10 20:08:44 +00:00
Eric Andersen a0053735dc Remove unused variable.
-Erik
2000-07-10 20:08:09 +00:00
Eric Andersen 3849f9bfcc Remove the problematic CTRLCHAR macro.
-Erik
2000-07-10 19:56:47 +00:00
Mark Whitley 9a8243aa1e Put the GROWBY variable inside the get_line_from_file function, as that is the
only function where it's used and it's always good to keep the namespace
clean. :-)
2000-07-10 19:31:31 +00:00
Mark Whitley 928faac503 Removed unnecessary #include "regexp.h" line from find.c as per Matt Kraai's
suggestion on the mailing list.
2000-07-10 19:29:09 +00:00
Eric Andersen 34e1941c32 Function name cleanup.
-Erik
2000-07-10 18:47:24 +00:00
Eric Andersen 0b4551faf5 From Matt Kraai <kraai@alumni.carnegiemellon.edu>:
Howdy,

Bug #1006 reports that

ln -s /tmp/foo .

does not work correctly.  In fact, it appears that any instantiation of

ln -s FILE... DIRECTORY

does not work.  The following patch adds support for this form, which
then fixes the particular instance noted in the bug report.

In the process, I needed the basename function.  This appears in the
string.h provided by glibc, but not uC-libc.  So I wrote my own to go in
utility.c, called get_last_path_component.  I also modified the basename
utility to use this function.

At some point it might be desirous to use the basename from the library
if it exists, and otherwise compile our own.  But I don't know how to do
this.

Matt
2000-07-10 16:44:03 +00:00
Eric Andersen a03d86cf54 Patch from Matt Kraai <kraai@alumni.carnegiemellon.edu>:
GNU tr complains on the following:

$ tr a ''
tr: when not truncating set1, string2 must be non-empty

BusyBox tr does not complain:

$ tr a ''
a
^D
0

It should result in an error, not in some spurious output.  The attached
patch generates an error.

Matt
2000-07-10 16:38:50 +00:00
Mark Whitley 44735f8744 Applied patch from Matt Kraai as per his email:
However, the case of

	grep foo$ file

didn't work, due to a problem with the flags used in regular expression
compilation.  The attached patch fixes this problem.

---patch-------
Index: grep.c
===================================================================
RCS file: /var/cvs/busybox/grep.c,v
retrieving revision 1.30
diff -u -r1.30 grep.c
--- grep.c      2000/07/04 22:17:01     1.30
+++ grep.c      2000/07/10 08:57:04
@@ -141,8 +141,10 @@
        if (argv[optind] == NULL)
                usage(grep_usage);

-       /* compile the regular expression */
-       reflags = REG_NOSUB; /* we're not going to mess with sub-expressions
        */
+       /* compile the regular expression
+        * we're not going to mess with sub-expressions, and we need to
+        * treat newlines right. */
+       reflags = REG_NOSUB | REG_NEWLINE;
        if (ignore_case)
                reflags |= REG_ICASE;
        if ((ret = regcomp(&regex, argv[optind], reflags)) != 0) {
---patch-------

Thanks, Matt, it works great.
2000-07-10 15:50:26 +00:00
Eric Andersen 999bf72f49 More portability updates. Now compiles cleanly vs glibc, libc5, and uclibc
(except for mkfs_minix and fsck_minix -- and it doesn't yet link vs uclibc due
to missing stuff in the library).
 -Erik
2000-07-09 06:59:58 +00:00
Eric Andersen e9b527ae48 include getopt.h
-Erik
2000-07-09 05:56:14 +00:00
Eric Andersen 161cf93404 Fix a bug in get_line_from_file. If the length of the line is (GROWBY * n) +
GROWBY - 1, then it writes the null character just after the buffer.  Yipe.
Fix thanks to Matt Kraai <kraai@alumni.carnegiemellon.edu> Thanks Matt!
 -Erik
2000-07-09 02:38:01 +00:00
Eric Andersen f12724c21a The build depends were too strict. I depended on on debhelper (>= 2.0.80)
while debhelper 1.1.24 is available for slink.  Just forget the dependancy --
it isn't needed.
 -Erik
2000-07-09 01:54:33 +00:00
Eric Andersen a57ba4db64 Argh. More cross libc cleanup. Should be ok now...
-Erik
2000-07-08 19:20:49 +00:00
Eric Andersen 2cd439f7f0 More cleanup on umount
-Erik
2000-07-08 19:10:29 +00:00
Eric Andersen bd22ed8067 Update files to reduce dependance on kernel version...
-Erik
2000-07-08 18:55:24 +00:00
Eric Andersen 877a71bbf0 Add in tinynet
-Erik
2000-07-08 16:19:10 +00:00
Eric Andersen 9cf44e79aa Doc updates to remove sfdisk.
-Erik
2000-07-08 00:09:30 +00:00
Eric Andersen 8f282f1b02 Better description of the BB_FEATURE_USE_DEVPS_PATCH option.
-Erik
2000-07-07 23:51:37 +00:00
Eric Andersen acecc47261 Add in my fix for 2.4.x kernels so /proc/mounts will not have useless
deg entries which break mount, df, and friends.  Renamed WillThisGoIntoTheKernel
to avoid any confision.
 -Erik
2000-07-07 21:22:19 +00:00
Eric Andersen e6b9dfa967 Removed sfdisk from BusyBox. It was buggy, fat, and we really couldn't
maintain it very well, so including it was not very appropriate.  Those wanting
an fdisk are invited to grab a copy from util-linux.
 -Erik
2000-07-07 20:54:30 +00:00
Eric Andersen 53a955786d Added in Matt Kraai.
-Erik
2000-07-07 20:53:16 +00:00
Eric Andersen a2c83d885e Fix a dependancy bug for the docs.
-Erik
2000-07-07 20:52:56 +00:00
Eric Andersen 03f9c81cec Naming fix
-Erik
2000-07-07 20:37:12 +00:00
Eric Andersen bb374a6935 Recognize Matt's poweroff fix.
-Erik
2000-07-07 19:33:35 +00:00
Eric Andersen 4c95a28461 Fix for bug #1003 -- BusyBox should now poweroff when asked to
do so...  Fix thanks to Matt Kraai <kraai@alumni.carnegiemellon.edu>
 -Erik
2000-07-07 19:30:28 +00:00
Eric Andersen 3312b0b626 Web page update from Matt Kraai <kraai@alumni.carnegiemellon.edu>
-Erik
2000-07-07 19:23:10 +00:00
Eric Andersen 2158092344 This patch finishes the cleanup of all the commands. It also cleans up
the remaining chapters -- Matt Kraai <kraai@alumni.carnegiemellon.edu>
 -Erik
2000-07-07 19:07:47 +00:00
Eric Andersen b9eb0233a9 Yet another busybox documentation update from Matt Kraai <kraai@alumni.carnegiemellon.edu>
-Erik
2000-07-07 05:04:24 +00:00
Eric Andersen b0b732bfe4 Update 'make release' to remove all the .#filename files
the CVS leaves lying about...
 -Erik
2000-07-06 23:17:16 +00:00
Eric Andersen 03f4c27bd6 Turned some stuff into features that really are features, not apps.
-Erik
2000-07-06 23:10:29 +00:00
Eric Andersen 67536ffa43 Fix doc building so the dependancies work properly.
-Erik
2000-07-06 22:53:22 +00:00
Eric Andersen 8845adc545 * Fixed tar creation support when reading from stdin ('tar -cf - . ')
thanks to Daniel Quinlan <quinlan@transmeta.com>
 -Erik
2000-07-06 22:51:35 +00:00
Eric Andersen 02bc25be56 Fixed backspace and delete so they work properly again -- broken
since 0.44.
 -Erik
2000-07-06 21:29:32 +00:00
Eric Andersen e5cec4e3ac More doc patches from Matt Kraai <kraai@alumni.carnegiemellon.edu>.
Thanks Matt!
 -Erik
2000-07-06 19:59:22 +00:00
Eric Andersen 62bb2d02b6 Remove leftovers of block_device, which disapperared around
busybox 0.28.
 -Erik
2000-07-06 19:46:22 +00:00
Eric Andersen a5dbb39dac Change order.
-Erik
2000-07-06 19:11:34 +00:00
Eric Andersen c8c10c5715 Added (fixed) the '-n' option to fbset. Renumbered the command parameters to
put a gap between the normal commands and the fancy commands. This makes it
cleaner to add normal commands.  Patch from Jon McClintock <jonm@bluemug.com>.
 -Erik
2000-07-06 17:23:23 +00:00
Eric Andersen f86aee74ce setkeycodes needs get_console_fd(), so if you disable chvt and deallocvt, but
leave setkeycodes active, busybox will not link.  Also fix a trivial
use-before-initialize warning.  Both fixes from Jon McClintock
<jonm@bluemug.com>.

 -Erik
2000-07-06 17:20:46 +00:00
Eric Andersen b1e379f7f3 Remove some warning with glibc.
-Erik
2000-07-06 17:08:38 +00:00
Eric Andersen 78eab2f6c6 Comment on kill.c change.
-Erik
2000-07-06 17:06:08 +00:00
Eric Andersen 3cfa9ec09c Reorganized signal names for better architecture support -- patch
thanks to simon wood <simon@mungewell.uklinux.net>
 -Erik
2000-07-06 17:05:33 +00:00
Eric Andersen 6f5e281479 DocBook documentation update from Matt Kraai <kraai@alumni.carnegiemellon.edu>
-Erik
2000-07-06 16:58:45 +00:00
Eric Andersen b2731b11ef Had an extra tcsetpgrp.
-Erik
2000-07-06 16:56:56 +00:00
Eric Andersen 1e03add675 a few minor cleanups.
-Erik
2000-07-06 09:56:35 +00:00
Eric Andersen 5d893b6beb Remove MAXNAMLEN and use BUFSIZ instead.
-Erik
2000-07-06 01:57:20 +00:00
Eric Andersen 89bc256c94 Remove misguided klude around for 2.4.x-test* brokenness. Al Viro
will be removing this stuff from /proc/mounts real soon now I am assured.
 -Erik
2000-07-05 19:29:59 +00:00
Eric Andersen f7cf2f7ef9 * Fix to tr so it recognizes standard escape sequences. Merged common
escape seq. code from tr and echo into utility.c.  Fix thanks to
    Matt Kraai <kraai@alumni.carnegiemellon.edu>.
* This should close Bug #1015.  Please test.
 -Erik
2000-07-05 17:26:35 +00:00
Eric Andersen 57ebebfb01 Patch from Matt Kraai <kraai@alumni.carnegiemellon.edu> to
simplify ar.c and make it more readable.
 -Erik
2000-07-05 17:21:58 +00:00
Eric Andersen 2086e3d679 Some cosmetic updates. Changed "OPTIONS" to "Options".
-Erik
2000-07-04 22:17:01 +00:00
Eric Andersen 028fb625f5 More doc updates
-Erik
2000-07-04 20:07:13 +00:00
Eric Andersen 5331025f79 A first pass at integrating the SGML docs into the Makefile.
A first pass a cleaning up the current SGML (lots more cleanup
is needed though).
 -Erik
2000-07-04 19:42:23 +00:00
Eric Andersen b02c54ebee * Fix to init.c from Stuart Menefy <Stuart.Menefy@st.com> so that
it always sets the controlling terminal before running any programs
 -Erik
2000-07-04 19:41:23 +00:00
Eric Andersen 72965e3454 Fixed a potential infinite loop. First delete any chars after the
cursor, then delete everything before it.  Before this, we would just
delete everything before the cursor and freak out if there were still
chars left (i.e. stuff after the cursor).
 -Erik
2000-07-04 06:22:18 +00:00
Eric Andersen b54833cde0 sh fixes from Marius Groeger <mag@sysgo.de>
-Erik
2000-07-03 23:56:26 +00:00
Eric Andersen 7c31ea4e29 Added support for ignoring '-g' per GNU ls, thanks to David Vrabel
<dvrabel@arcom.co.uk>.  Seems some ftp clients expect the '-g' option
to exist.
 -Erik
2000-07-03 14:55:49 +00:00
Eric Andersen 5d41d60f1e Added support for being a login shell, so things like '-su' or '-sh' (stuff
where argv[0][0]=='-') will now always invoke the shell.  Now you can use
BusyBox as a login shell.
 -Erik
2000-06-29 20:20:14 +00:00
Mark Whitley 2e1148b239 Fixed comment. 2000-06-28 22:59:30 +00:00
Mark Whitley 8bd891cbec Added support for reading from stdin with '-' as file name arg. 2000-06-28 22:55:59 +00:00
Mark Whitley 1ca41775bb Yanked out the cstring_alloc() and cstring_lineFromFile() functions from
utility.c and replaced them with get_line_from_file() from the new grep.c.
Also changed declaration in internal.h and replaced instances of
cstring_lineFromFile() in dc.c and sort.c with get_line_from_file(). Tested
them and they worked fine.
2000-06-28 22:15:26 +00:00
Mark Whitley d37218941c Brand, spankin', new grep that uses libc regex routines instead of the
hand-rolled ones. Sed still needs to be replaced and then the regexp stuff can
be axed.
2000-06-28 22:00:26 +00:00
Mark Whitley 268b8c4f38 Moved some function decls, a struct, and a #define from regexp.h into here.
Also static-ified said functions so they do not have namespace conflicts with
the libc regex functions.
2000-06-28 21:59:31 +00:00
Mark Whitley 0c96eba3de Removed some function decls (regex, regcomp, etc.) and put them in regexp.c 2000-06-28 21:58:31 +00:00
Eric Andersen a44790f539 Better cross libc support.
-Erik
2000-06-28 20:11:28 +00:00
Eric Andersen a2db097d66 Forgot -- targeted the wrong release.
-Erik
2000-06-28 17:07:19 +00:00
Eric Andersen 1c314ad655 * Fixed a _horrible_ bug where 'tar -tvf' could unlink
local files!!!  Fix thanks to Marius Groeger <mgroeger@sysgo.de>
* Added support for "sh -c command args...", also thanks to
    Marius Groeger <mgroeger@sysgo.de>

 -Erik
2000-06-28 16:56:25 +00:00
Eric Andersen 47cac6779a Updates for the .deb
-Erik
2000-06-28 02:25:18 +00:00
John Beppu eb0283333b = minor formatting issues 2000-06-28 00:55:31 +00:00
John Beppu 7cdc76dfbf + busybox --install [-s]
is functional (but disabled in busybox.def.h by default)
  Someone email the guy who originally wanted this.
2000-06-28 00:41:26 +00:00
Eric Andersen d0edef3cbe Remove stuff now moved into the bug tracking system.
-Erik
2000-06-27 18:12:19 +00:00
John Beppu 495869f59a + s/int install_links/static int install_links/
? Did you want "busybox --install" or "busybox install" ?
  The TODO and mailing-list conflict on this issue.
  I would recommend against "busybox install", because
  people might confuse it w/ /usr/bin/install that does
  something different.
2000-06-27 07:54:33 +00:00
Eric Andersen cb1d841f09 This kernel patch is no longer needed, with the change I made to init
and free...
 -Erik
2000-06-27 06:22:09 +00:00
John Beppu 27b5924b96 + littering my code w/ comments about what troubles me. 2000-06-27 04:56:45 +00:00
John Beppu 8f425dbf9a + busybox --install [-s]
is almost good to go.  Here is my work in progress.

+ Look at the FIXME in busybox.c
  to see what I need.  The actual (sym)linking is disabled
  for now, although I'm sure it works ;)
  (Am I going to have to dig through /proc to find
  out where the currently running busybox is sitting?)

+ I put an #ifdef BB_FEATURE_INSTALLER around
  the new bits of code in busybox.c, and I have a
  #define BB_FEATURE_INSTALLER in busybox.def.h
  towards the bottom.
2000-06-27 04:50:02 +00:00
Mark Whitley 83a949cb22 Just converted busybox.pod to busybox.sgml using the Pod::DocBook Perl module.
The resulting file needs some massaging and once it gets presentable, I'll
edit the Makefile to use the SGML file as the "authoritative" file; the plan
here is to generate other file formats from the SGML.
2000-06-26 13:31:53 +00:00
Eric Andersen 1386e70210 Fixed segfault with 'cut -f 1 -d:' and added 'cut -s' suport.
Fix thanks to Arne Bernin <arne@matrix.loopback.org>
 -Erik
2000-06-26 12:14:30 +00:00
Eric Andersen ef40aa81c5 * Fixed insmod module option parsing for options lacking an '='.
Fix thanks to Marc Nijdam <marc_nijdam@hp.com>
 -Erik
2000-06-26 11:16:22 +00:00
Eric Andersen 3adffb7fc8 readlink(2) does not NULL terminate the buffer it reads in, but tar expected it
to do so.  This caused symlinks stored in tarballs to likely have trailing
crap in the stored symlink named.  Oops.
 -Erik
2000-06-26 10:54:06 +00:00
Eric Andersen 10dc9d4d17 Updates to handle Linux 2.4.0 kernels (kludged around the "none" entries in
/proc/mounts, added a hack to make sysinfo work with both old and new kernels).
 -Erik
2000-06-26 10:45:52 +00:00
Eric Andersen 8a24a6783a Better error checking in insmod. Remove left over %m's
-Erik
2000-06-22 18:19:31 +00:00
Eric Andersen 4a971aef59 Minor web page update.
-Erik
2000-06-22 01:27:11 +00:00
Eric Andersen 3c37598dc2 Fix version #
-Erik
2000-06-22 00:23:09 +00:00
Eric Andersen a29dec28cb More doc updates
-Erik
2000-06-22 00:19:33 +00:00
Mark Whitley ccd32cbb61 Merged two TODO items into one 2000-06-22 00:16:37 +00:00
Eric Andersen 9d9610b8de Update the list.
-Erik
2000-06-22 00:04:12 +00:00
Eric Andersen 6f9985e2f2 Pavel Roskin <proski@gnu.org> just found a nasty memory
corruption bug.  Disabling 'ln -n' till it is fixed.
 -Erik
2000-06-22 00:02:56 +00:00
Eric Andersen addc9c28ad Document 'ln --'
-Erik
2000-06-21 22:53:24 +00:00
Mark Whitley 4fa84e6b54 Cleaned up some #ifdef spiderwebs. 2000-06-21 22:53:16 +00:00
Eric Andersen c6cdf58747 Bump version number to 0.45
-Erik
2000-06-21 22:50:59 +00:00
Mark Whitley 07edff4ba4 Added an implicit rule for #defining BB_FEATURE_USE_TERMIOS if
BB_FEATURE_AUTOWIDTH is #defined.
2000-06-21 22:46:32 +00:00
Eric Andersen 45087b1010 More doc updates.
-Erik
2000-06-21 22:44:33 +00:00
Eric Andersen 766c012975 Web site updates.
-Erik
2000-06-21 22:43:07 +00:00
Eric Andersen c5c5e3d144 Add in my little patch for 2.4.x to make sysinfo binary compatable (again)
-Erik
2000-06-21 22:06:56 +00:00
Pavel Roskin afa0662860 Documented "which" 2000-06-21 21:43:24 +00:00
Pavel Roskin 1a804e4b3c Removed trailing spaces 2000-06-21 21:38:00 +00:00
Eric Andersen f929641c51 Add in telnet docs.
-Erik
2000-06-21 21:04:01 +00:00
Eric Andersen feb47c024a Add insmod docs
-Erik
2000-06-21 21:03:13 +00:00
Pavel Roskin f7a01951fb Updated the list of supported commands 2000-06-21 20:25:07 +00:00
Pavel Roskin 7ac06a3ff1 Removed all vestiges of "math" 2000-06-21 20:17:29 +00:00
John Beppu 0021679b0d + added dc (aka the function formerly known as math)
+ did all the housekeeping that this change requires.
2000-06-21 19:06:16 +00:00
Eric Andersen b405dfa54d 'tar --help' wasn't working. Fixed it.
-Erik
2000-06-21 18:37:36 +00:00
John Beppu c03525475e + made it so that you can use the mnemonics
(add, sub, mul, div) in lieu of (+, -, *, /)
2000-06-21 18:00:46 +00:00
Eric Andersen e63ad9ba06 Special case the memcopy stuff so it isn't enabled for uclibc
-Erik
2000-06-20 21:04:03 +00:00
Eric Andersen 28c88a9430 Some makefile fixes to allow compiling with ucLibc (stuff turned off
by default of course).
 -Erik
2000-06-20 21:03:24 +00:00
Pavel Roskin 339b892313 Updated e-mail address of Pavel Roskin to proski@gnu.org 2000-06-20 00:11:07 +00:00
Eric Andersen 4eb1b30411 Mention libc support, Pavel's rm fix is already merged.
-Erik
2000-06-19 20:19:04 +00:00
Eric Andersen bd4a75f6c8 Finish off the libc5 porting effort. Everything now works with libc5
except for md5sum, which uses the GNU libc addition getline().
 -Erik
2000-06-19 20:03:48 +00:00
Eric Andersen bb245ba0c2 Made insmod work with both libc5 and libc6.
-Erik
2000-06-19 19:53:30 +00:00
Eric Andersen 9ca57d377e Made ping work with libc5 and libc6.
-Erik
2000-06-19 18:51:53 +00:00
Eric Andersen e1e23eecab Make umount work and compile cleanly under libc5 and libc6.
-Erik
2000-06-19 18:38:51 +00:00
Eric Andersen 5e29c6ffce Make swaponoff compile cleanly under both libc5 and libc6.
-Erik
2000-06-19 18:25:49 +00:00
Eric Andersen a15cd0be34 Make syslogd.c, init.c, and update.c compile error/warning free under both libc5 and libc6.
-Erik
2000-06-19 18:14:20 +00:00
Eric Andersen b7362e36a8 printf now compiles cleanly under both libc5 and libc6.
-Erik
2000-06-19 17:52:17 +00:00
Eric Andersen 67e32304b1 Updated to compile and work with libc5.
-Erik
2000-06-19 17:48:02 +00:00
Eric Andersen be5023a84d Update internal.h to conditionally include asm/string.h
-Erik
2000-06-19 17:30:07 +00:00
Eric Andersen b610615be9 Updates to a number of apps to remove warnings/compile errors under libc5.
Tested under both libc5 and libc6 and all seems well with these fixes.
 -Erik
2000-06-19 17:25:40 +00:00
Mark Whitley dbb3019d0d Added a note to the "maybe by 0.44" list to prune sfdisk and graft fdisk. 2000-06-19 17:03:32 +00:00
Eric Andersen 30f0f2d040 Fix a stupid bug, where I cleaned things as the last makefile target. duh.
-Erik
2000-06-19 09:29:32 +00:00
Eric Andersen b108a5b780 Added support for building debian packages.
-Erik
2000-06-19 09:21:34 +00:00
Pavel Roskin 110fc0cacc Check for 3 and more arguments was incorrect
It is only allowed for linking to a directory
But linking to a directory still fails and may be removed
2000-06-18 00:02:24 +00:00
Eric Andersen 74c66ad06e Fix some spelling errors in the source as well.
-Erik
2000-06-16 19:57:44 +00:00
Eric Andersen 98cd53e86d Ran it through a spell checker and fixed the spelling errors.
-Erik
2000-06-16 19:56:44 +00:00
Eric Andersen 852ff13fc4 Update to ar.c from Glenn McGrath. His comments follow:
------------------------------

the attached diff applies to the ar.c i originally submitted

Changes

Preserve dates now works.
Extracted files are set to the uid, gid and mode specified in the
archive.
Checks for valid end of header marker.
Correctly unpacks newer debian files. (has a '\n' character between
entries)
Added more comments.
Cleaned up code.
Added a last modified date to help keep track of versions.


TODO

Common functionality in ar.c are in tar.c should be merged, in
particular getOctal and extractSubFile.

Should all functions that are used by multiple file go in utilities.c ?
2000-06-16 04:56:40 +00:00
Mark Whitley b991395405 Added some comments and changed a variable name to be more meaningful. No
fixes yet for the space bug, but should be coming soon.
2000-06-16 00:26:51 +00:00
Pavel Roskin 2e965239ee ln: fixed command line parser. Added support for "--" 2000-06-15 18:04:40 +00:00
Eric Andersen 3f75503fa0 Remove trailing space char.
-Erik
2000-06-14 22:16:59 +00:00
Eric Andersen 28c70b3a16 Integrate Tomi Ollila's telnet. Costs 3k. :)
-Erik
2000-06-14 20:42:57 +00:00
Pavel Roskin e97da40079 Fixed "rm foo" that had been broken while implementing "rm -- foo" 2000-06-14 17:39:41 +00:00
Mark Whitley 1af7ed5573 Modified status of some TODO items, added some others in preparation for the
0.44 release.
2000-06-14 17:35:54 +00:00
John Beppu 3c709b45b3 + minor typo fix
s/&gt/&gt;/
2000-06-14 09:11:05 +00:00
John Beppu d84990eb1f + removed some cruft left over from when lines could be too long. 2000-06-14 00:19:14 +00:00
Eric Andersen 854e11581f Urgh. revert Makefile. again. Forgot to do the 'cvs update -d now' trick
on my home box.
2000-06-13 06:57:56 +00:00
Eric Andersen 2b6ab3cbf8 Add new apps md5sum uudecode uuencode, fix some minor formatting things.
-Erik
2000-06-13 06:54:53 +00:00
Eric Andersen 053b1462b7 Fix a bug pointed out by Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
where you used to see:
      ./grep -q -i B some_file
      B: No such file or directory
This is now fixed.
 -Erik
2000-06-13 06:24:53 +00:00
Eric Andersen baf22bff21 Give beppu credit for fixing grep "Line too long" bug.
-Erik
2000-06-13 00:49:41 +00:00
John Beppu c7ccfc99fc + utility.c
CSTRING_BUFFER_LENGTH = 1024 /* so it recurses less often */
+ grep.c
  uses cstring_lineFromFile(), and doesn't ever say
  Line is too long, anymore
2000-06-12 23:39:04 +00:00
Eric Andersen 9f16d61408 Added a slightly modified version of Ron Alder's insmod patch.
Very cool stuff.
 -Erik
2000-06-12 23:11:16 +00:00
John Beppu 44760d058c + updated docs to reflect math's filter capabilities. 2000-06-12 23:04:55 +00:00
John Beppu 5db60a7a7a + works as a filter, now!
- I have a feeling I could have used strtok, but the
  2 functions I added are really small, so it shouldn't
  be a big deal.  (They were just laying around, and I
  wanted to use them, again).
2000-06-12 22:59:12 +00:00
Eric Andersen 0c6a970eb2 * Fixed a small bug that could cause tar to emit warning messages
and not extract the first file in a directory in some cases
    of nested directories.  Thanks to Kevin Traas <kevin@netmaster.com>
    for helping track this one down.
 -Erik
2000-06-09 20:51:50 +00:00
Pavel Roskin b3d235f63b Fixed parsing of arguments for cp 2000-06-08 18:06:37 +00:00
Eric Andersen b3cf9baeb9 Formatting change.
-Erik
2000-06-08 15:25:39 +00:00
Pavel Roskin 049b706591 My pod2man (perl-5.00503) complains if there is no newline after "Options:" 2000-06-07 21:19:49 +00:00
Pavel Roskin da10ec0eaa Syslogd will not go to background if "-n" is given. Better help
and argument checking
2000-06-07 21:08:25 +00:00
Pavel Roskin 0024abcbbc Implemented "ping -s", fixed error messages and argument parsing 2000-06-07 20:38:15 +00:00
Eric Andersen 0b66577368 Debug should be off in the Makefile. I will now do (per Pavel's
suggestion) a "cvs up -D now Makefile" so I stop updating the
Makefile by accident.
 -Erik
2000-06-07 17:33:30 +00:00
Eric Andersen a42982e8f5 * Fixed 'swapon -a' and 'swapoff -a', which were broken.
* Fixed 'mount -a' so it works as expected.
* Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE)
 -Erik
2000-06-07 17:28:53 +00:00
Eric Andersen 1f6262b8e2 Fix 'date -u'
-Erik
2000-06-06 22:17:43 +00:00
Eric Andersen fb8ba506bb Oops. Remove the debugging noise.
-Erik
2000-06-06 22:13:39 +00:00
Eric Andersen 3232203226 mkfs.minix rev 1.7 completely broke the option parser. This fixes it.
-Erik
2000-06-06 22:12:35 +00:00
Mark Whitley d05e3ce5c2 Removed chmod,chown,chgrp from the "Bugs that need fixing" list. 2000-06-06 18:12:47 +00:00
Mark Whitley eec2f63b3f Fixed segfaults for "chown -R" and "chgrp -R". Also added a message for "too
few arguments".
2000-06-06 18:11:46 +00:00
Pavel Roskin 700a5aed75 Fixed exit status for killall 2000-06-06 18:10:17 +00:00
Mark Whitley 517cab761f Added considering making a unified option parser someday. 2000-06-06 18:05:47 +00:00
Mark Whitley 6ca28ba65c Fixed segfault when you type "chmod -R". "chown -R" and "chgrp -R" are still
having problems...
2000-06-06 17:40:32 +00:00
Pavel Roskin 680d65a646 "mount" now reports errors from nfsmount() and assumes NFS mount
if ':' is present in the device name - Pavel Roskin
2000-06-06 17:03:55 +00:00
Mark Whitley 68480dc30f Updated TODO item re: 'cp -a /tmp/*' not producing the right error message
(it's been fixed).
2000-06-06 17:03:54 +00:00
Eric Andersen 815e904470 Fixed a bunch of stuff:
* Fixed segfault caused by "touch -c"
	* Fixed segfault caused by "rm -f"
	* Fixed segfault caused by "ln -s -s" and similar abuses.
	* Fixed segfault caused by "cp -a -a" and similar abuses.
	* Implemented "rm -- <foo>"
updated docs accordingly.
 -Erik
2000-06-06 16:15:23 +00:00
Pavel Roskin c389d91181 "which" rewritten to use stat(). Fixes to improve its compatability
with traditional implementations
2000-06-05 23:41:27 +00:00
Pavel Roskin 82c0ac7e4f Fix more spelling errors. 2000-06-05 20:19:47 +00:00
Eric Andersen f2fffefe49 Fix spelling error
-Erik
2000-06-05 17:23:06 +00:00
Eric Andersen 36fe1a30b1 Fix spelling errors.
-Erik
2000-06-05 17:22:37 +00:00
Eric Andersen 926e0e3465 More TODO items. Fix a dependancy bug on busybox.def.h
-Erik
2000-06-05 05:33:00 +00:00
Eric Andersen afeb683459 "nc" exits silently on errors. This patch makes it print something before
exit().

Note that calling perror() after gethostbyname() will most likely return
"No such file or directory" which is quite confusing, so I decided to use
fatalError instead.

Regards,
Pavel Roskin
2000-06-04 05:21:49 +00:00
Eric Andersen 46a38dbb9b Don't allow mkfifo to create files such as "--help"
This patch checks if the name of FIFO to be created begins with "-" and
calls usage() if it does.

Regards,
Pavel Roskin
2000-06-04 05:17:35 +00:00
Eric Andersen ef4268efa7 This patch
- eliminates the need to have a buffer and strcpy to it
- makes freeramdisk complain if it's given more than one argument

Regards,
Pavel Roskin
2000-06-04 05:08:29 +00:00
Eric Andersen 832000f7f3 Turn off debugging in the Makefile.
-Erik
2000-06-03 05:22:31 +00:00
Eric Andersen f0c30b71be Note that I broke mkfs_minix's parser in rev 1.7.
-Erik
2000-06-03 00:27:00 +00:00
Eric Andersen 5a0a2aa00b Fix touch so it behaves itself (it could segfault in some cases).
Fix uname help info formatting.
 -Erik
2000-06-02 23:26:44 +00:00
Eric Andersen 808d03ec19 This is a fix for chroot
- Fixed error message when the command is not specified (possibly crash on
libc5 systems!)
- Debugging output removed
- Using fatalError() whenever appropriate

Regards,
Pavel Roskin
2000-06-02 17:56:45 +00:00
Eric Andersen 9c8ffa02f4 Pavel fixed a segfault in yes.
-Erik
2000-06-02 17:51:39 +00:00
Eric Andersen 3199bda52e Fix /etc/passwd misspelling.
-Erik
2000-06-02 17:38:18 +00:00
Eric Andersen 6082917e34 Some Makefile fixes for the docs.
-Erik
2000-06-02 03:35:22 +00:00
Eric Andersen 380e58a05f Note the addition of ar.
-Erik
2000-06-02 03:25:00 +00:00
Eric Andersen ec480c49c2 oops. Don't commit autogenerated stuff.
-Erik
2000-06-02 03:23:28 +00:00
Eric Andersen 86ab8a32bd A number of additional fixed from Pavel Roskin, note some more bugs in the
TODO list.  Add Glenn to the Authors list for writing a mini ar for BusyBox,
which is now included.
 -Erik
2000-06-02 03:21:42 +00:00
Eric Andersen 4062268bc7 Acknowledge contributions of Pavel Roskin, and fix doc building
so the html goes into the website directory.
 -Erik
2000-06-02 03:21:41 +00:00
Eric Andersen 08e9289ab3 Acknowledge contributions of Pavel Roskin, and fix doc building
so the html goes into the website directory.
 -Erik
2000-06-02 03:21:36 +00:00
Eric Andersen b6c6d87a99 More stuff to do...
-Erik
2000-06-02 03:21:32 +00:00
Eric Andersen 77bd2db325 Acknowledge contributions of Pavel Roskin, and fix doc building
so the html goes into the website directory.
 -Erik
2000-06-02 03:21:32 +00:00
Eric Andersen 1624813459 Point to the local BusyBox.html docs.
-Erik
2000-06-02 03:20:22 +00:00
Eric Andersen b83e0ed3a1 Forgot to checkin the busybox website graphics. Here they are...
-Erik
2000-06-02 02:33:24 +00:00
Eric Andersen 89960b8af2 More stuff.
-Erik
2000-05-31 20:08:30 +00:00
Eric Andersen b5966368d7 Minor doc fix. Added several bugs to the todo list. Fixed the way init
scans /etc/inittab entries so that commands can contain ":"s.
 -Erik
2000-05-31 20:04:38 +00:00
Eric Andersen deb0331eb6 Remove the now-fixed tar segfault from the TODO list.
-Erik
2000-05-30 19:11:50 +00:00
Eric Andersen 108a44345c Fixed tar option parsing segfault, and make "tar xv" and "tar -xv"
both work (i.e. it works with or w/o the "-").
 -Erik
2000-05-30 19:05:57 +00:00
Eric Andersen e511e7c116 Minor update to web page.
-Erik
2000-05-25 00:18:59 +00:00
Erik Andersen 8ea7d8cdaf First pass at fixing tar segfault, and more portability updates.
-Erik
2000-05-20 00:40:08 +00:00
Erik Andersen 330fd2b576 More libc portability updates, add in the website (which has not been
archived previously).  Wrote 'which' during the meeting today.
 -Erik
2000-05-19 05:35:19 +00:00
Erik Andersen d356c6e9d1 Another bug to fix...
-Erik
2000-05-17 05:28:05 +00:00
Erik Andersen 5b46d792f1 Some more portability updates
-Erik
2000-05-17 05:24:24 +00:00
Erik Andersen 499f65fb98 Some updates for better portability.
-Erik
2000-05-16 20:07:38 +00:00
Erik Andersen 969f9b0486 TODO update
-Erik
2000-05-13 19:08:58 +00:00
Erik Andersen 67a0dd8f3c Change a description
-Erik
2000-05-13 19:08:42 +00:00
Erik Andersen c3f5c9c2ee Minor fixes to being a standalone shell.
-Erik
2000-05-13 19:00:07 +00:00
Erik Andersen bcd6177853 BusyBox shell (lash) can now be used as a standalone shell when
BB_FEATURE_STANDALONE_SHELL is defined (i.e. BusyBox can now completely replace
sash).  Also fixed it so shell builtins now respect pipes and redirects.
 -Erik
2000-05-13 06:33:19 +00:00
Erik Andersen 73c8c9cf9a More doc updates
-Erik
2000-05-13 05:36:13 +00:00
Erik Andersen 23dea9b712 So much for my evil optimization. Doesn't seem to work. Will test
more on it later.
 -Erik
2000-05-13 00:28:25 +00:00
Erik Andersen 7ab9c7ee52 Lots of updates. Finished implementing BB_FEATURE_TRIVIAL_HELP
which lets you compile out most of the "--help" output, saving
up to 17k.

Renamed mnc to nc.
 -Erik
2000-05-12 19:41:47 +00:00
Erik Andersen 3d427ac5ef Some experimental stuff (work in progress). heheh.
-Erik
2000-05-12 19:38:40 +00:00
Erik Andersen 59b9e87024 * cp -fa now works as expected for symlinks (it didn't before)
* zcat works again (wasn't working since option parsing was broken)
* more doc updates/more support for BB_FEATURE_SIMPLE_HELP
 -Erik
2000-05-10 05:05:45 +00:00
Erik Andersen ac130e1dca Add suffix stripping support to basename
-Erik
2000-05-10 05:00:31 +00:00
Mark Whitley 0a027e6880 Added some bugs / TODOs. 2000-05-08 23:25:59 +00:00
Erik Andersen 691f49d3c1 Fix umount dependency on find_real_root_device_name
-Erik
2000-05-08 17:56:25 +00:00
Erik Andersen 0e713cef9d Doc updates
-Erik
2000-05-05 19:50:32 +00:00
Erik Andersen 6c5f2c6021 Add support for "noatime" and "nodiratime" mount flags to mount.
Change umount "-f" to mean force, and actually use umount2.
Change umount "-l" to mean "Do not free loop device".
Updates docs accordingly.
 -Erik
2000-05-05 19:49:33 +00:00
Erik Andersen 9b15e50835 Tell cvs to never checkin the resultant docs.
-Erik
2000-05-03 03:25:43 +00:00
Erik Andersen a59d7094a6 Sensibly put the docs under the docs directory.
-Erik
2000-05-03 03:24:21 +00:00
Erik Andersen 0a704e8ff6 Remove BB_FEATURE_REMOUNT (small, and should always be present)
and fix documentation dependancy checks, so it is only built when
it should be built.
 -Erik
2000-05-03 03:19:06 +00:00
Erik Andersen a19bc64653 More formatting bugs fixed
-Erik
2000-05-02 06:40:02 +00:00
Erik Andersen e31c06608e Bug fixes in the docs
-Erik
2000-05-02 05:32:07 +00:00
Erik Andersen 03ccce6e30 Make the dependancies on the docs work properly
-Erik
2000-05-02 05:31:00 +00:00
Erik Andersen 5afc864422 More stuff
-Erik
2000-05-02 00:07:56 +00:00
Erik Andersen 3c1217cfad Document tr change
-Erik
2000-05-01 22:34:24 +00:00
Erik Andersen 8f8d6d5f2d Due to the license change I can now use Minix code. Minix tr
(adapted) now replaces BSD tr.  Goes from 5k to 1k, and eliminates
bsearch from the list of libc symbols.
 -Erik
2000-05-01 22:30:37 +00:00
Mark Whitley d16665810d Minor source modifications to improve readability. 2000-05-01 22:08:54 +00:00
Erik Andersen 12d1b378be Minor doc change 2000-05-01 19:50:37 +00:00
Erik Andersen 9b7d964581 My little adventure of analyzing lib usage has already rooted out
a big "P" Policy violator -- logname was using getlogin(3), which uses
utmp under the hood.  We don't need no stinkin' utmp (and if we
are using tinylogin, it is unlikely to be useful trying).
 -Erik
2000-05-01 19:49:20 +00:00
Erik Andersen f378fced43 Note how to find list of BusyBox libc dependancies, the ide being to
limit them much more.
 -Erik
2000-05-01 19:27:17 +00:00
Erik Andersen 4625240674 Oops.
-Erik
2000-05-01 19:11:16 +00:00
Erik Andersen 94f5e0ba7c Some accrued fixes/updates.
* cp/mv now accepts (and ignores) the -f flag, since it always
	does force anyway
    * tail can now accept -<num> commands (e.g. -10) for better
	compatibility with the standard tail command
    * added a simple id implementation; doesn't support supp. groups yet
2000-05-01 19:10:52 +00:00
Erik Andersen 28c49b6c9c Foo 2000-04-28 22:51:49 +00:00
Erik Andersen 25c44c623d Fix changelog
-Erik
2000-04-28 22:49:08 +00:00
Erik Andersen 923ef599f3 Fix tarball creation. In an attempt to accomodate the whiners
that wanted "tar cf foo.tar foo" (i.e. no "-" before options)
I broke creation of tarballs.  Now fixed.
 -Erik
2000-04-28 22:32:13 +00:00
Erik Andersen 6ed02a0ee0 Fix stupid bugs. update was segfaulting. mknod minor # was always 0
due to a parsing bug.  Oops.
 -Erik
2000-04-28 22:10:34 +00:00
Erik Andersen abc199eb0c Forgot this file...
-Erik
2000-04-28 01:26:31 +00:00
Erik Andersen 4f3f757d56 Latest and greatest. Some effort at libc5 (aiming towards newlib)
compatability.
 -Erik
2000-04-28 00:18:56 +00:00
Erik Andersen 227a59b05d Several more updates
-Erik
2000-04-25 23:24:55 +00:00
John Beppu f93a95de69 + grep -v # yay! 2000-04-24 18:07:30 +00:00
Erik Andersen e90f4045af Some more updates and such...
-Erik
2000-04-21 21:53:58 +00:00
Erik Andersen 1d1d95051a More Doc updates. cmdedit and more termio fixes. 2000-04-21 01:26:49 +00:00
Erik Andersen cf8d38a3eb Doc updates
-Erik
2000-04-21 01:23:36 +00:00
Erik Andersen 7d6ba57bba Add #include <sys/param.h> to syslogd.
-Erik
2000-04-19 20:02:50 +00:00
Erik Andersen e3ed156eeb Make the sys logger for so that concurrent logging will work
properly (see tests/syslog_test.c for example).
 -Erik
2000-04-19 18:52:56 +00:00
279 changed files with 40967 additions and 20264 deletions

No files matched your search

+2
View File
@@ -1,2 +1,4 @@
busybox
busybox.links
_install
loop.h
Vendored
+33
View File
@@ -0,0 +1,33 @@
--blank-lines-after-declarations
--blank-lines-after-procedures
--break-before-boolean-operator
--no-blank-lines-after-commas
--braces-on-if-line
--braces-on-struct-decl-line
--comment-indentation25
--declaration-comment-column25
--no-comment-delimiters-on-blank-lines
--cuddle-else
--continuation-indentation4
--case-indentation0
--else-endif-column33
--space-after-cast
--line-comments-indentation0
--declaration-indentation1
--dont-format-first-column-comments
--dont-format-comments
--honour-newlines
--indent-level4
/* changed from 0 to 4 */
--parameter-indentation4
--line-length78 /* changed from 75 */
--continue-at-parentheses
--no-space-after-function-call-names
--dont-break-procedure-type
--dont-star-comments
--leave-optional-blank-lines
--dont-space-special-semicolon
--tab-size4
/* additions by Mark */
--case-brace-indentation0
--leave-preprocessor-space
+31 -6
View File
@@ -12,9 +12,9 @@ Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Tons of new stuff, major rewrite of most of the
core apps, tons of new apps as noted in header files.
Bruce Perens <bruce@pixar.com>
Original author of BusyBox. His code is still in many apps.
Edward Betts <edward@debian.org>
expr, hostid, logname, tty, wc, whoami, yes
John Beppu <beppu@lineo.com>
du, head, nslookup, sort, tee, uniq
@@ -28,17 +28,42 @@ Dave Cinege <dcinege@psychosis.com>
more(v2), makedevs, dutmp, modularization, auto links file,
various fixes, Linux Router Project maintenance
Karl M. Hegbloom <karlheg@debian.org>
cp_mv.c, the test suite, various fixes to utility.c, &c.
Daniel Jacobowitz <dan@debian.org>
mktemp.c
Matt Kraai <kraai@alumni.carnegiemellon.edu>
documentation, bugfixes
John Lombardo <john@deltanet.com>
dirname, tr
dirname, tr
Glenn McGrath <bug1@netconnect.com.au>
ar.c
Bruce Perens <bruce@pixar.com>
Original author of BusyBox. His code is still in many apps.
Chip Rosenthal <chip@unicom.com>, <crosenth@covad.com>
wget - Contributed by permission of Covad Communications
Pavel Roskin <proski@gnu.org>
Lots of bugs fixes and patches.
Gyepi Sam <gyepi@praxis-sw.com>
Remote logging feature for syslogd
Linus Torvalds <torvalds@transmeta.com>
mkswap, fsck.minix, mkfs.minix
Mark Whitley <markw@lineo.com>
sed remix, bug fixes, style-guide, etc.
Charles P. Wright <cpwright@villagenet.com>
gzip, mini-netcat(nc)
Enrique Zanardi <ezanardi@ull.es>
tarcat (since removed), loadkmap, various fixes, Debian maintenance
Karl M. Hegbloom <karlheg@debian.org>
cp_mv.c, the test suite, various fixes to utility.c, &c.
+214 -3
View File
@@ -1,3 +1,214 @@
0.47
* A bug in syslogd was fixed that allowed it to potentially fork-bomb
your system. Anyone using 0.46 syslogd should upgrade.
* Renamed busybox.defs.h to the more sensible "Config.h"
* Improved portability between different libcs.
* Many apps ported to use getopt()
* Common handling of '--help'
* All usage messages centralized.
* Added a bunch of new commands:
* 'rdate' contributed by Sterling Huxley <sterling@europa.com>
* 'wget' contributed by Chip Rosenthal <chip@unicom.com>,
<crosenth@covad.com> and Covad Communications
* 'getopt' from "Alfred M. Szmidt" <ams@trillian.itslinux.org>
* dos2unix, unix2dos, reset, and unrpm.c (and lots of help
debugging) thanks to Kent Robotti <robotti@metconnect.com>.
* 'renice' command, thanks to Dave Cinege <dcinege@psychosis.com>
* 'xargs' (written by me)
* 'expr' contributed by Edward Betts <edward@debian.org>, based
on GNY expr
* lsmod now uses the query_module syscall, rather then /proc (me)
* syslogd can now log messages to remote hosts -- patch thanks
to Gyepi Sam <gyepi@praxis-sw.com>
* chroot can now call the builtin shell - Pavel Roskin <proski@gnu.org>
* 'make install' now creates relative symlinks, and added a new
'make install-hardlinks' target to (tada) install hardlinks.
* Rewrite of 'tail' to make it simpler, smaller, and more robust.
It now weighs only 2.25k (3k when full featured). The code is
cleaner too, thanks to Allen Soard <esp-software@mail.hypermart.net>
* Add optional ls file sorting, thanks to a patch from
Sterling Huxley <sterling@europa.com>
* Fixed chmod option parsing so things like 'chmod -r /tmp/file'
now work (previously it thought -r was an option). Doh!
* Fixed tar handling of stdin and stdout
* Renamed "internal.h" to the more sensible "busybox.h"
* Preliminary support for GNU HURD.
* Updated my devps and devmtab kernel patches for the latest 2.2.x
kernel, for those wanting to go proc-less.
* Tons of other bugfixes.
-Erik Andersen, 25 September 2000
0.46
* Better portability. Now should compile cleanly with libc5,
GNU libc 2.0 and 2.1, and various Linux kernels including
2.0.x, 2.2.x, and to 2.4.0-test*. (patch for 2.4.x kernels
to make /proc/mounts behave included in the kernel-patches dir).
* Fixed a _horrible_ bug where 'tar -tvf' could unlink
local files that matched tarball contents!!! Fix thanks
to Marius Groeger <mgroeger@sysgo.de>
* Fixed a nasty bug in tar when could mess up saved symlinks.
* Fixed tar creation support when reading from stdin ('tar -cf - . ')
thanks to Daniel Quinlan <quinlan@transmeta.com>
* Updates to handle Linux 2.4.0 kernels (kludged around the
"none" entries in /proc/mounts, added a hack to make sysinfo
work with both old and new kernels).
* Fixed insmod module option parsing for options lacking an '='.
Fix thanks to Marc Nijdam <marc_nijdam@hp.com>
* Fixed segfault with 'cut -f 1 -d:' and added 'cut -s' suport.
Fix thanks to Arne Bernin <arne@matrix.loopback.org>
* Several fixes from Marius Groeger <mag@sysgo.de>
- Added support for "sh -c command args..."
- Fixed globbing, i.e. 'echo * *' and 'echo "******"' now work.
- Added shell environment variable substitution
- Added the "read" shell builtin.
* Fixed cursor editing in cmdedit.c. The following keyboard sequence
used to create an infinite loop: ls, cursor up, left, down.
* Added support for being a login shell, so things like
'-su' or '-sh' (stuff where argv[0][0]=='-') will now always
invoke the shell. Now you can use BusyBox as a login shell.
* ls.c now ignores '-g', since some ftp clients like that sort
of thing. Patch thanks to David Vrabel <dvrabel@arcom.co.uk>
* Fix to init.c from Stuart Menefy <Stuart.Menefy@st.com> so that
it always sets the controlling terminal before running any programs
* Several fixes from Matt Kraai <kraai@alumni.carnegiemellon.edu>
- Fixed tr so it recognizes standard escape sequences.
Merged common escape seq. code from tr and echo into utility.c.
- Major work in updating/cleaning up the docs, and getting the
new SGML based docs into shape.
- cleanup of ar.c
- BusyBox should now poweroff when asked to do so.
- Fixed 'ln -n' and 'ln -s' so they both work properly.
* Reorganized signal names in kill.c for better architecture support
-- patch thanks to simon wood <simon@mungewell.uklinux.net>
* In 0.43, backspace and delete worked properly, but with 0.45,
it just echoed a ^? for backspace, and ^H for control-h. This
was due to a broken macro in init.c, that is now fixed.
* Removed sfdisk from BusyBox. It was buggy, fat, and we really
couldn't maintain it very well, so including it was not really
very appropriate. Those wanting an fdisk are invited to
grab a copy from util-linux.
* Added 'dumpkmap' to allow people to dump a binary keymap, which can
then be loaded in by 'loadkmap' -- submitted by
Arne Bernin <arne@matrix.loopback.org>
* Fixed NFS so it supports 2.4.x kernels and NFSv3.
* Brand, new versions of grep and sed which use libc regex routines,
thanks to Mark Whitley <markw@lineo.com>. The hand-tooled
"regexp.[ch]" files have been removed. Much help on these from
Matt Kraai as well.
-Erik Andersen, 11 July 2000
0.45
* Now compiles vs libc5 (which can save lots of space for
embedded systems).
* Added BB_FEATURE_TRIVIAL_HELP which compiles out most all of the
help messages (i.e --help). Saves 17k over a full compile.
* Added cut and tr from minix, since due to the license change,
we can now use minix code. Minix tr saves 4k.
* insmod now works. It costs 29k, but imagine an initrd with a
staticly linked busybox containing only insmod and sh, a few /dev
entries, and a kernel module or two... It doesn't get smaller
then this folks (I pity the fool that writes insmod in asm ;-).
Many kudos go to Ron Alder <alder@lineo.com> for finishing this off!
* Added a mini ar archive utility, especially written for BusyBox by
Glenn McGrath <bug1@netconnect.com.au>
* Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org>
* Added setkeycodes, for those that have wierd keyboard buttons.
* Added md5sum, uuencode and uudecode -- thanks to Alfred M. Szmidt
<ams@trillian.itslinux.org> for contributing these.
* Added 'grep -v' option (inverted search) and updated
docs accordingly. -beppu
* Wrote which
* Replaced the telnet implementation with one written by
Tomi Ollila <too@iki.fi> It works great and costs 3k.
* BusyBox sh (lash) now supports being used as a standalone shell. When
BB_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
be invoked as shell internals. Best used when compiling staticly
(i.e. DOSTATIC=true)
* BusyBox sh (lash) internals now behave as expected wrt pipes
and redirects.
* Fixed ping warnings -- fix from Sascha Ziemann <szi@aibon.ping.de>
* Fixed update segfault
* Fixed mknod -- minor number was always 0
* Fixed tar option parsing, so both "tar xvf foo.tar" and
"tar -xvf foo.tar" now work (i.e. no "-" before options)
(this was very broken in 0.43).
* Several contributions from Randolph Chung <tausq@debian.org>.
* cp/mv now accepts the -f flag
* tail can now accept -<num> commands (e.g. -10) for better
compatibility with the standard tail command
* added a simple id implementation; doesn't support sup. groups yet
* logname used getlogin(3) which uses utmp. Now it doesn't.
* whoami used getpwuid(3) which uses libc NSS. Now it behaves.
* Add support for "noatime" and "nodiratime" mount flags to mount.
* Changed 'umount -f' to mean force, and actually use umount2.
* Changed 'umount -l' to mean "Do not free loop device".
* Fixed basename to support stripping of suffixes. Patch thanks
to xiong jianxin <jxiong@uiuc.edu>
* cp -fa now works as expected for symlinks (it didn't before)
* zcat now works (wasn't working since option parsing was broken)
* Renamed "mnc" to the more correct "nc" (for netcat).
* Makefile intelligence updates
* Changed the way init parses /etc/inittab entries to avoid problems
with commands that contain colons in them. Fix thanks to
Pavel Roskin <proski@gnu.org>
* Fixed a warning in utility.c due to char being unsigned on Linux/PPC,
Fix thanks to Pavel Roskin <proski@gnu.org>
* Made "killall" complain (not error and exit) about processes that it
cannot find by name -- Pavel Roskin <proski@gnu.org>
* Fixed more and ps to have sensible terminal width defaults, thanks
to Pavel Roskin.
* Fixed all fatalError() calls lacking a "\n", thanks to Pavel Roskin.
* Fixed a segfault in yes when no args were given -- Pavel Roskin.
* Simplified freeramdisk and added argument checking -- Pavel Roskin.
* Fixed segfault caused by "touch -c"
* Fixed segfault caused by "rm -f"
* Fixed segfault caused by "ln -s -s" and similar abuses. Further fixes
and "--" support from Pavel Roskin.
* Fixed segfault caused by "cp -a -a" and similar abuses.
* Implemented "rm -- <foo>". Implementation fixed by Pavel Roskin.
* "which" rewritten to use stat(). Fixes to improve its compatability
with traditional implementations -- Pavel Roskin.
* "mount" now reports errors from nfsmount() and assumes NFS mount
if ':' is present in the device name - Pavel Roskin
* Fixed exit status for killall - Pavel Roskin
* Fixed 'swapon -a' and 'swapoff -a', which were broken.
* Fixed 'mount -a' so it works as expected.
* Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE)
* Implemented "ping -s", fixed error messages and argument parsing -
Pavel Roskin
* Syslogd will not go to background if "-n" is given. Better help
and argument checking -- Pavel Roskin
* Fixed a small bug that could cause tar to emit warning messages
and not extract the first file in a directory in some cases
of nested directories. Thanks to Kevin Traas <kevin@netmaster.com>
for helping track this one down.
* More doc updates
* Fixed grep "Line too long" problem -- John Beppu
* Fixed 'grep -q -i B some_file' so it works
* math takes input from stdin if no args are given. -- John Beppu
* math was renamed to dc. Although it deviates from dc's behaviour,
this will probably be remedied in the future. -- John Beppu
-Erik Andersen, June 21, 2000
0.44
Previously, an erronous announcement of BusyBox 0.44 was made, so to
avoid possible confusion, we are skipping straight to 0.45, and calling
it good.
-Erik Andersen
0.43
* Major update to the provided documentation.
* Busybox now includes a shell! It currently costs 7.5 k (plus an
@@ -22,7 +233,7 @@
* Added echo and test (from me).
* Added usleep contributed by Nicolas Pitre <nico@cam.org>
* BusyBox's bss size has been majorly reduced (was 384668, is now 28740).
* Several fixes from Pavel Roskin <pavel_roskin@geocities.com>:
* Several fixes from Pavel Roskin <proski@gnu.org>:
- When `tail' fails to open a file it now exits.
- When `syslogd' is given the `-n' option it should still use
fork() for running klogd.
@@ -47,7 +258,7 @@
- mv now attempts to do a rename, and will fall back to doing
a copy only if the rename fails.
- Syslogd now supports multiple concurrent connections
* Several fixes from Pavel Roskin <pavel_roskin@geocities.com>:
* Several fixes from Pavel Roskin <proski@gnu.org>:
- Fixes to sort. Removed "-g", fixed and added "-r"
- Fixes to the makefile for handling "strip"
* An initial telnet implementation was added by
@@ -157,7 +368,7 @@
Randolph Chung <tausq@debian.org>.
* cp could, when copying symlinks, change permissions of the
files pointed to by the symlinks.
* Several fixes from Pavel Roskin <pavel_roskin@geocities.com>:
* Several fixes from Pavel Roskin <proski@gnu.org>:
- `chown' with 1 argument displayed the error incorrectly
- `fdflush', `length' and `printf' crashed if run without arguments
- `fdflush' tried to flush itself using *argv
+119 -35
View File
@@ -7,6 +7,7 @@
//
//
// BusyBox Applications
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
@@ -14,21 +15,27 @@
#define BB_CHVT
#define BB_CLEAR
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
#define BB_DOS2UNIX
#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
#define BB_ECHO
#define BB_EXPR
#define BB_FBSET
#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
#define BB_FREERAMDISK
#define BB_FSCK_MINIX
#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
@@ -36,12 +43,11 @@
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
#define BB_ID
#define BB_INIT
// Don't bother turning BB_INSMOD on. It doesn't work yet.
//#define BB_INSMOD
#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
#define BB_LENGTH
#define BB_LN
#define BB_LOADACM
@@ -52,16 +58,16 @@
#define BB_LS
#define BB_LSMOD
#define BB_MAKEDEVS
#define BB_MKFS_MINIX
#define BB_MATH
#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MNC
#define BB_MKTEMP
#define BB_NC
#define BB_MORE
#define BB_MOUNT
#define BB_NFSMOUNT
#define BB_MT
#define BB_NSLOOKUP
#define BB_PING
@@ -69,12 +75,15 @@
#define BB_PRINTF
#define BB_PS
#define BB_PWD
#define BB_RDATE
#define BB_REBOOT
#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
#define BB_RMMOD
#define BB_SED
#define BB_SFDISK
#define BB_SETKEYCODES
#define BB_SH
#define BB_SLEEP
#define BB_SORT
@@ -85,20 +94,26 @@
#define BB_TAR
#define BB_TEE
#define BB_TEST
// Don't bother turning BB_TELNET on. It doesn't work properly yet.
//#define BB_TELNET
#define BB_TELNET
#define BB_TOUCH
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UNRPM
#define BB_UPTIME
#define BB_USLEEP
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
#define BB_UNIX2DOS
#define BB_UPDATE
#define BB_XARGS
#define BB_YES
// End of Applications List
//
@@ -110,12 +125,17 @@
// pretty/useful).
//
//
// Turn this on to use Erik's very cool devps, devmtab,
// etc kernel drivers, thereby eliminating the need for
// the /proc filesystem and thereby saving lots and lots
// memory for more important things.
// You can't use this and USE_PROCFS at the same time...
// (BTW, I emailed Linus and this patch will not be going into the stock kernel)
//
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. You can not use this and
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
// _must_ have patched the kernel to include the devps patch that is included
// in the busybox/kernel-patches directory. You will also need to create some
// device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// enable features that use the /proc filesystem (apps that
@@ -124,14 +144,9 @@
// at the same time...
#define BB_FEATURE_USE_PROCFS
//
// Enable full regular expressions. This adds about
// 4k. When this is off, things that would normally
// use regualr expressions (like grep) will just use
// normal strings.
#define BB_FEATURE_FULL_REGULAR_EXPRESSIONS
//
// Use only simple command help
#define BB_FEATURE_TRIVIAL_HELP
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
//#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
@@ -148,14 +163,23 @@
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// sort the file names (still a bit buggy)
#define BB_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_SIMPLE_PING
//#define BB_FEATURE_SIMPLE_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
//#define BB_FEATURE_LINUXRC
#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
@@ -168,8 +192,14 @@
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//
//Simple tail implementation (2k vs 6k for the full one). Still
//provides 'tail -f' support -- but for only one file at a time.
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f' support (only one file at a time.)
#define BB_FEATURE_SIMPLE_TAIL
//
// Enable support for loop devices in mount
@@ -178,8 +208,12 @@
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//
// Enable support for remounting filesystems
#define BB_FEATURE_REMOUNT
// Enable support for mounting remote NFS volumes
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
@@ -187,12 +221,20 @@
// Enable support for "--exclude" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
// Enable support for s///p pattern matching
#define BB_FEATURE_SED_PATTERN_SPACE
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox commands as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell
//among other thing.
#define BB_FEATURE_SH_STANDALONE_SHELL
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
@@ -200,6 +242,31 @@
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// You must enable one or both of these features
// Support installing modules from pre 2.1 kernels
//#define BB_FEATURE_INSMOD_OLD_KERNEL
// Support installing modules from kernel versions after 2.1.18
#define BB_FEATURE_INSMOD_NEW_KERNEL
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
// #define BB_FEATURE_INSTALLER
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// End of Features List
//
@@ -216,10 +283,6 @@
#define BB_MTAB
#endif
//
#if defined BB_FEATURE_FULL_REGULAR_EXPRESSIONS && (defined BB_SED || defined BB_GREP )
#define BB_REGEXP
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#endif
@@ -233,8 +296,8 @@
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#define BB_LINUXRC
#endif
#define BB_LINUXRC
#endif
//
#ifdef BB_GZIP
@@ -243,3 +306,24 @@
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#endif
#endif
+326
View File
@@ -0,0 +1,326 @@
/* vi: set sw=4 ts=4: */
// NOTE: This file only defines features usefull under the Hurd,
// To compile for the Hurd raname this to Config.h prior to make
// This file defines the feature set to be compiled into busybox.
// When you turn things off here, they won't be compiled in at all.
//
//// This file is parsed by sed. You MUST use single line comments.
// i.e. //#define BB_BLAH
//
//
// BusyBox Applications
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
//#define BB_CHVT /* not needed */
#define BB_CLEAR
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
//#define BB_DEALLOCVT /* inot needed */
//#define BB_DF /* different implementation */
#define BB_DIRNAME
//#define BB_DMESG /* doesnt compile, different implementation */
#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP /* not needed */
#define BB_ECHO
#define BB_EXPR
//#define BB_FBSET /* not needed, doesnt compile */
//#define BB_FDFLUSH /* is this needed? */
#define BB_FIND
//#define BB_FREE /* doesnt compile */
#define BB_FREERAMDISK /* does hurd support ramdisks ? */
#define BB_FSCK_MINIX
#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
#define BB_ID
//#define BB_INIT /* not needed?, doesnt compile */
//#define BB_INSMOD /* not needed, doesnt compile */
#define BB_KILL
#define BB_KILLALL
#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM /* not needed, doesnt compile */
//#define BB_LOADFONT /* not needed, doesnt compile */
//#define BB_LOADKMAP /* not needed */
#define BB_LOGGER
#define BB_LOGNAME
#define BB_LS
//#define BB_LSMOD /* not needed, doesnt compile */
//#define BB_MAKEDEVS /* different implementation */
#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
#define BB_MKNOD
//#define BB_MKSWAP /* different impelementation (i think) */
#define BB_MKTEMP
#define BB_NC
#define BB_MORE
//#define BB_MOUNT /* different implementation */
#define BB_MT
#define BB_NSLOOKUP
//#define BB_PING /* doesnt compile, Hurd uses BSD style ip.h */
//#define BB_POWEROFF /* different implementation i assume */
#define BB_PRINTF
//#define BB_PS /* needs /proc */
#define BB_PWD
#define BB_RDATE
//#define BB_REBOOT /* different implementation */
#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
//#define BB_RMMOD /* not needed, doesnt compile */
#define BB_SED
//#define BB_SETKEYCODES /* is this needed ? */
#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_SWAPONOFF /* different implementation, doesnt compile */
#define BB_SYNC
//#define BB_SYSLOGD /* doesnt compile */
#define BB_TAIL
#define BB_TAR
#define BB_TEE
#define BB_TEST
#define BB_TELNET
#define BB_TOUCH
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UPTIME /* doesnt compile */
#define BB_USLEEP
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
//#define BB_UMOUNT /* different implementation */
#define BB_UNIQ
//#define BB_UNAME /* doesnt compile */
//#define BB_UPDATE /* doesnt compile */
#define BB_YES
// End of Applications List
//
//
//
// ---------------------------------------------------------
// This is where feature definitions go. Generally speaking,
// turning this stuff off makes things a bit smaller (and less
// pretty/useful).
//
//
//
// Turn this on to use Erik's very cool devps and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. You can not use this and
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
// _must_ have patched the kernel to include the devps patch that is included
// in the busybox/kernel-patches directory. You will also need to create some
// device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// enable features that use the /proc filesystem (apps that
// break without this will tell you on compile)...
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
// at the same time...
#define BB_FEATURE_USE_PROCFS
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
//#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// sort the file names (still a bit buggy)
#define BB_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// Change ping implementation -- simplified, featureless, but really small.
#define BB_FEATURE_SIMPLE_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
//#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f' support (only one file at a time.)
#define BB_FEATURE_SIMPLE_TAIL
//
// Enable support for loop devices in mount
//#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes
//#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
// Enable support for s///p pattern matching
#define BB_FEATURE_SED_PATTERN_SPACE
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox commands as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell
//among other thing.
#define BB_FEATURE_SH_STANDALONE_SHELL
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// You must enable one or both of these features
// Support installing modules from pre 2.1 kernels
//#define BB_FEATURE_INSMOD_OLD_KERNEL
// Support installing modules from kernel versions after 2.1.18
#define BB_FEATURE_INSMOD_NEW_KERNEL
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
// #define BB_FEATURE_INSTALLER
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#endif
#define BB_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#endif
#endif
+147 -56
View File
@@ -19,102 +19,182 @@
#
PROG := busybox
VERSION := 0.43
VERSION := 0.47
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
export VERSION
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
DODEBUG = false
# If you want a static binary, turn this on.
DOSTATIC = false
# This will choke on a non-debian system
ARCH =`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
# Do not enable this for production builds...
DODEBUG = false
CC = gcc
# This enables compiling with dmalloc ( http://dmalloc.com/ )
# which is an excellent public domain mem leak and malloc problem
# detector. To enable dmalloc, before running busybox you will
# want to first set up your environment.
# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
# Do not enable this for production builds...
DODMALLOC = false
GCCMAJVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\1/p")
GCCMINVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\2/p")
# If you want large file summit support, turn this on.
# This has no effect if you don't have a kernel with lfs
# support, and a system with libc-2.1.3 or later.
# Some of the programs that can benefit from lfs support
# are dd, gzip, mount, tar, and mkfs_minix.
# LFS allows you to use the above programs for files
# larger than 2GB!
DOLFS = false
GCCSUPPORTSOPTSIZE = $(shell \
if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
if ( test $(GCCMINVERSION) -ge 66 ) ; then \
echo "true"; \
else \
echo "false"; \
fi; \
else \
if ( test $(GCCMAJVERSION) -gt 2 ) ; then \
echo "true"; \
else \
echo "false"; \
fi; \
fi; )
# If you are running a cross compiler, you may want to set this
# to something more interesting...
CROSS = #powerpc-linux-
CC = $(CROSS)gcc
STRIPTOOL = $(CROSS)strip
# To compile vs an alternative libc, you may need to use/adjust
# the following lines to meet your needs. This is how I make
# busybox compile with uC-Libc...
#LIBCDIR=/home/andersen/CVS/uC-libc
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
#CFLAGS+=-nostdinc -fno-builtin -I$(LIBCDIR)/include -I$(GCCINCDIR)
#LDFLAGS+=-nostdlib
#LIBRARIES = $(LIBCDIR)/libc.a
ifeq ($(GCCSUPPORTSOPTSIZE), true)
OPTIMIZATION = -Os
else
OPTIMIZATION = -O2
#--------------------------------------------------------
# use '-Os' optimization if available, else use -O2
OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "-Os"; else echo "-O2" ; fi)
WARNINGS = -Wall
ifeq ($(DOLFS),true)
# For large file summit support
CFLAGS+=-D_FILE_OFFSET_BITS=64
endif
# Allow alternative stripping tools to be used...
ifndef $(STRIPTOOL)
STRIPTOOL = strip
ifeq ($(DODMALLOC),true)
# For testing mem leaks with dmalloc
CFLAGS+=-DDMALLOC
LIBRARIES = -ldmalloc
# Force debug=true, since this is useless when not debugging...
DODEBUG = true
endif
# -D_GNU_SOURCE is needed because environ is used in init.c
ifeq ($(DODEBUG),true)
CFLAGS += -Wall -g -D_GNU_SOURCE
LDFLAGS =
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS +=
STRIP =
else
CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
LDFLAGS = -s
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
LDFLAGS += -s
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
#Only staticly link when _not_ debugging
ifeq ($(DOSTATIC),true)
LDFLAGS += --static
endif
endif
ifeq ($(DOSTATIC),true)
LDFLAGS += --static
#
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
# work) to try and strip out any unused junk. Doesn't do much for me,
# but you may want to give it a shot...
#
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \
# --gc-sections -v >/dev/null && echo 1),1)
# CFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += --gc-sections
#endif
endif
ifndef $(PREFIX)
PREFIX = `pwd`/_install
endif
LIBRARIES =
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o usage.o utility.o
CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif
all: busybox busybox.links
busybox: $(OBJECTS)
all: busybox busybox.links doc
doc: olddoc
# Old Docs...
olddoc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/BusyBox.txt: docs/busybox.pod
@echo
@echo BusyBox Documentation
@echo
- pod2text docs/busybox.pod > docs/BusyBox.txt
docs/BusyBox.1: docs/busybox.pod
- pod2man --center=BusyBox --release="version $(VERSION)" docs/busybox.pod > docs/BusyBox.1
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
- rm -f docs/BusyBox.html
- ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
- pod2html --noindex docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html
- rm -f pod2html*
# New docs based on DOCBOOK SGML
newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
docs/busybox.txt: docs/busybox.sgml
@echo
@echo BusyBox Documentation
@echo
(cd docs; sgmltools -b txt busybox.sgml)
docs/busybox.dvi: docs/busybox.sgml
(cd docs; sgmltools -b dvi busybox.sgml)
docs/busybox.ps: docs/busybox.sgml
(cd docs; sgmltools -b ps busybox.sgml)
docs/busybox.pdf: docs/busybox.ps
(cd docs; ps2pdf busybox.ps)
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
busybox: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
$(STRIP)
$(MAKE) -C docs
busybox.links: busybox.def.h
busybox.links: Config.h
- ./busybox.mkll | sort >$@
regexp.o nfsmount.o: %.o: %.h
$(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile
nfsmount.o cmdedit.o: %.o: %.h
$(OBJECTS): %.o: Config.h busybox.h %.c Makefile
utility.o: loop.h
loop.h:
@./mk_loop_h.sh
test tests:
cd tests && $(MAKE) all
clean:
cd tests && $(MAKE) clean
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
docs/busybox.lineo.com/BusyBox.html
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
- rm -rf docs/busybox _install
- rm -f busybox.links *~ *.o core
- rm -rf _install
- cd tests && $(MAKE) clean
distclean: clean
- rm -f busybox
@@ -123,8 +203,10 @@ distclean: clean
install: busybox busybox.links
./install.sh $(PREFIX)
dist release: distclean
$(MAKE) -C docs
install-hardlinks: busybox busybox.links
./install.sh $(PREFIX) --hardlinks
dist release: distclean doc
cd ..; \
rm -rf busybox-$(VERSION); \
cp -a busybox busybox-$(VERSION); \
@@ -139,4 +221,13 @@ dist release: distclean
-print \
| xargs rm -f; \
\
find busybox-$(VERSION)/ -type f \
-name .\#* \
-print \
| xargs rm -f; \
\
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
.PHONY: tags
tags:
ctags -R .
+57 -16
View File
@@ -1,23 +1,64 @@
Please see the LICENSE file for copyright information.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for most of the utilities
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
tar, etc. BusyBox provides a fairly complete POSIX environment for any small or
emdedded system. The utilities in BusyBox generally have fewer options then
their full featured GNU cousins; however, the options that are included provide
the expected functionality and behave very much like their GNU counterparts.
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
provides a pretty complete POSIX environment in a very small package.
Just add a kernel, "ash" (Keith Almquists tiny Bourne shell clone), and
an editor such as "elvis-tiny" or "ae", and you have a working system.
Busybox was begun to support the Debian Rescue/Install disks, but it
also makes an excellent environment for any small or embedded system.
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add a kernel, a shell (such as ash),
and an editor (such as elvis-tiny or ae).
As of version 0.20 there is a version number. : ) Also as of version 0.20, BB
is now modularized to easily allow you to build only the BB parts you need,
thereby reducing binary size. To turn off unwanted Busybox components, simply
edit the file busybox.def.h and comment out the parts you do not need using C++
style (//) comments.
Busybox was originally written to support the Debian Rescue/Install disks, but
it also makes an excellent environment for any small or embedded system.
After the build is complete a busybox.links file is generated which is
then used by 'make install' to create symlinks to the busybox binary
for all compiled in functions. By default, 'make install' will place
the symlink forest into `pwd`/_install unless you have defined the
PREFIX environment variable (i.e. make PREFIX="/tmp/foo" install)
As of version 0.20 there is a version number. : ) Also as of version 0.20,
BusyBox is now modularized to easily allow you to build only the components you
need, thereby reducing binary size. To turn off unwanted Busybox components,
simply edit the file "Config.h" and comment out the components you do not
need using C++ style (//) comments.
After the build is complete a busybox.links file is generated which is then
used by 'make install' to create symlinks to the busybox binary for all
compiled in functions. By default, 'make install' will place the symlink
forest into `pwd`/_install unless you have defined the PREFIX environment
variable (i.e. make PREFIX="/tmp/foo" install)
----------------
Getting help:
When you find you need help, you can check out the BusyBox mailing list
archives at http://opensource.lineo.com/lists/busybox/ or even join
the mailing list if you are interested.
----------------
Bugs:
If you find bugs, follow the instructions at http://bugs.lineo.com/Reporting.html
and submit a bug report. This way, we can be sure nothing falls through the
cracks...
----------------
FTP:
Source for the latest released version can always be downloaded from
ftp://ftp.lineo.com/pub/busybox.
----------------
CVS:
BusyBox now has its own publically browsable CVS tree at:
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
Anonymous CVS access is available. For instructions, check out:
http://opensource.lineo.com/cvs_anon.html
For those that are actively contributing there is even CVS write access:
http://opensource.lineo.com/cvs_write.html
----------------
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
+25 -382
View File
@@ -4,34 +4,46 @@ or that doing so is even a good idea. It just means that I _might_ get
around to it some time. If you have any good ideas, please let me know.
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
needed or wanted in busybox (or else I'd have to link in libcrypt).
needed or wanted in busybox (or else I'd have to link to libcrypt).
* Networking apps are probably going to be split out some time soon into a
separate package (named perhaps tiny-netkit?). This currently includes
hostid, hostname, mnc, and ping.
separate package (named perhaps netkit-tiny?). This would remove the
following items from BusyBox: hostid, hostname, nc, nslookup, telnet, and
ping. nfs mounting and syslogd (network logging) will remain in BusyBox.
-Erik
-----------
* Make insmod actually work
* dnsdomainname
* traceroute/netstat
* rdate
* hwclock
* stty
* cut
* expr
* wget (or whatever I call it)
* tftp
* ftp
* group/commonize strings, remove dups (for i18n, l10n)
-----------------------
Add a compile option to turn off all the compiled in help
and usage information. Some folks don't need or want it...
Running the following:
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
reveals the list of all external (i.e. libc) things that BusyBox depends on.
It would be a very nice thing to reduce this list to an absolute minimum, and
then create a microLibc to provide these functions. There is no good reason
for GNU libc to be so big. I'm sure it can be a lot better.
(BTW, this is more informative if BB_FEATURE_NFSMOUNT is turned off...)
Most wanted list:
[andersen@slag busybox]$ grep -l getgroups *.[ch]
test.c
Policy violation. getgroups uses libc nss, which is unlikely
to be present in an embedded system.
-----------------------
@@ -40,375 +52,6 @@ and then start with the biggest things and make them smaller...
-----------------------
busybox.defs.h is too big and hard to follow.
Perhaps I need to add a better build system (like the Linux kernel?)
-----------------------
Feature request:
/bin/busybox --install -s which makes all links to commands that it
can support (an optionnal -s should be used for symbolic links instead
of hard links).
-----------------------
> Have you ever thought of doig network logging in busybox syslogd ? It
> would quite make sense on embedded systems... :)
So far I had not considered it. Basically, you wish to have
messages from the embedded box logged to a remote network
syslog box, right? I can see that this would be useful.
I'll add this to the TODO list,
-----------------------
I think that the add_inode &c in utility.c needs to also stow the
st_dev field, and that du.c should NOT call `reset_inode_list'
because there can be hard links from inside one argv/ to inside
another argv/. du.c probably ought to have an -x switch like GNU du
does also...
du.c probably ought to have an -x switch like GNU du does...
------------------------------------------------------------------
Date: Fri, 25 Feb 2000 08:23:12 +0000 (GMT)
From: Riley Williams <rhw@MemAlpha.CX>
X-Sender: rhw@moo.cus.org.uk
To: almesber@lrc.di.epfl.ch
Cc: "Albert D. Cahalan" <acahalan@cs.uml.edu>,
Linux Kernel <linux-kernel@vger.rutgers.edu>
Subject: Re: What /proc should contain [was: /proc/driver/microcode]
In-Reply-To: <20000224165245.A29790@lrc.di.epfl.ch>
Message-ID: <Pine.LNX.4.21.0002250806220.8741-100000@moo.cus.org.uk>
Sender: owner-linux-kernel@vger.rutgers.edu
Precedence: bulk
Hi there.
>> Nope, most /proc access is does via programs written in C.
> That varies a lot from file to file. E.g. I haven't seen any
> programs that are specificly designed to read /proc/atm/* yet,
> and I know of only one (fuser) that reads /proc/mounts,
> extracting only partial information (just to pick two examples
> that I'm quite familiar with).
As a point of reference, here's a slightly tweaked analysis of the
programs on the system I'm reading your mail on. Basically, I ran the
following script...
Q> #!/bin/bash
Q> function use() {
Q> for Z in $* ; do
Q> strings $Z | grep /proc | sed "s=^=$Z ="
Q> done
Q> }
Q> use /{,s}bin/* /usr/{,s}bin/* | sort -u | tee proc-usage
...and then went through it removing comments and print format
strings. Replace /proc with /dev and you'd soon have an equivalent
list for that - although I can report that such is MUCH larger...
There are three programs therein that refer to /proc/mounts ...
/bin/mount
/bin/umount
/usr/bin/eject
...and, as you stated, none that refer to /proc/atm on this system.
However, as this is a RedHat Linux 5.0 based system, that's not
necessarily an up to date reference thereto...
Here's the list anyway...
/bin/kill /proc/%d/cmdline
/bin/kill /proc/%d/stat
/bin/mount /proc/devices
/bin/mount /proc/filesystems
/bin/mount /proc/mounts
/bin/netstat /proc/net
/bin/netstat /proc/net/appletalk
/bin/netstat /proc/net/ax25
/bin/netstat /proc/net/ax25_route
/bin/netstat /proc/net/dev
/bin/netstat /proc/net/ip_masquerade
/bin/netstat /proc/net/ipx
/bin/netstat /proc/net/ipx_route
/bin/netstat /proc/net/netstat
/bin/netstat /proc/net/nr
/bin/netstat /proc/net/nr_neigh
/bin/netstat /proc/net/nr_nodes
/bin/netstat /proc/net/raw
/bin/netstat /proc/net/route
/bin/netstat /proc/net/rt_cache
/bin/netstat /proc/net/snmp
/bin/netstat /proc/net/tcp
/bin/netstat /proc/net/udp
/bin/netstat /proc/net/unix
/bin/umount /proc/devices
/bin/umount /proc/mounts
/sbin/arp /proc/net/appletalk
/sbin/arp /proc/net/arp
/sbin/arp /proc/net/ax25
/sbin/arp /proc/net/ipx
/sbin/arp /proc/net/nr
/sbin/arp /proc/net/unix
/sbin/cardctl /proc/devices
/sbin/cardmgr /proc/devices
/sbin/fdisk /proc/ide/%s/media
/sbin/fdisk /proc/scsi/scsi
/sbin/getty /proc/version
/sbin/ifconfig /proc/net
/sbin/ifconfig /proc/net/appletalk
/sbin/ifconfig /proc/net/ax25
/sbin/ifconfig /proc/net/dev
/sbin/ifconfig /proc/net/ipx
/sbin/ifconfig /proc/net/nr
/sbin/ifconfig /proc/net/unix
/sbin/ifup /proc/sys/kernel/modprobe
/sbin/ipchains /proc/net/ip_fwchains
/sbin/ipchains /proc/net/ip_fwnames
/sbin/ipchains /proc/net/ip_masquerade
/sbin/ipchains /proc/sys/net/ipv4/ip_forward
/sbin/ipmaddr /proc/net/dev_mcast
/sbin/ipmaddr /proc/net/igmp
/sbin/ipmaddr /proc/net/igmp6
/sbin/iptunnel /proc/net/dev
/sbin/killall5 /proc/%s/cmdline
/sbin/killall5 /proc/%s/exe
/sbin/killall5 /proc/%s/stat
/sbin/killall5 /proc/version
/sbin/klogd /proc/kmsg
/sbin/lsmod /proc/modules
/sbin/modprobe /proc/modules
/sbin/pidof /proc/%s/cmdline
/sbin/pidof /proc/%s/exe
/sbin/pidof /proc/%s/stat
/sbin/pidof /proc/version
/sbin/probe /proc/pci
/sbin/rarp /proc/net/ax25
/sbin/rarp /proc/net/nr
/sbin/rarp /proc/net/rarp
/sbin/rmmod /proc/modules
/sbin/rmmod.static /proc/modules
/sbin/route /proc/net/appletalk
/sbin/route /proc/net/ax25
/sbin/route /proc/net/ax25_route
/sbin/route /proc/net/ipx
/sbin/route /proc/net/ipx_route
/sbin/route /proc/net/nr
/sbin/route /proc/net/nr_neigh
/sbin/route /proc/net/nr_nodes
/sbin/route /proc/net/route
/sbin/route /proc/net/rt_cache
/sbin/route /proc/net/unix
/sbin/scsi_info /proc/scsi
/sbin/scsi_info /proc/scsi/%s
/sbin/scsi_info /proc/scsi/scsi
/sbin/slattach /proc/net/ax25
/sbin/slattach /proc/net/nr
/sbin/swapoff /proc/swaps
/sbin/swapon /proc/swaps
/sbin/uugetty /proc/version
/usr/bin/dig /proc/
/usr/bin/dig /proc/interrupts
/usr/bin/dig /proc/meminfo
/usr/bin/dig /proc/rtc
/usr/bin/dig /proc/self/status
/usr/bin/dig /proc/stat
/usr/bin/dnsquery /proc/
/usr/bin/dnsquery /proc/interrupts
/usr/bin/dnsquery /proc/meminfo
/usr/bin/dnsquery /proc/rtc
/usr/bin/dnsquery /proc/self/status
/usr/bin/dnsquery /proc/stat
/usr/bin/eject /proc/mounts
/usr/bin/emacs /proc/loadavg
/usr/bin/fetchmail /proc/net/dev
/usr/bin/free /proc/meminfo
/usr/bin/gmake /proc/loadavg
/usr/bin/gpm-root /proc/loadavg
/usr/bin/gpm-root /proc/meminfo
/usr/bin/host /proc/
/usr/bin/host /proc/interrupts
/usr/bin/host /proc/meminfo
/usr/bin/host /proc/rtc
/usr/bin/host /proc/self/status
/usr/bin/host /proc/stat
/usr/bin/hoststat /proc/loadavg
/usr/bin/hwdiag /proc/cpuinfo
/usr/bin/hwdiag /proc/pci
/usr/bin/hwdiag /proc/scsi/scsi
/usr/bin/hwdiag /proc/version
/usr/bin/lsdev /proc/dma
/usr/bin/lsdev /proc/interrupts
/usr/bin/lsdev /proc/ioports
/usr/bin/mailq /proc/loadavg
/usr/bin/make /proc/loadavg
/usr/bin/mcookie /proc/loadavg
/usr/bin/mcookie /proc/stat
/usr/bin/newaliases /proc/loadavg
/usr/bin/nslookup /proc/
/usr/bin/nslookup /proc/interrupts
/usr/bin/nslookup /proc/meminfo
/usr/bin/nslookup /proc/rtc
/usr/bin/nslookup /proc/self/status
/usr/bin/nslookup /proc/stat
/usr/bin/nsupdate /proc/
/usr/bin/nsupdate /proc/interrupts
/usr/bin/nsupdate /proc/meminfo
/usr/bin/nsupdate /proc/rtc
/usr/bin/nsupdate /proc/self/status
/usr/bin/nsupdate /proc/stat
/usr/bin/pgp /proc/version
/usr/bin/pgpe /proc/version
/usr/bin/pgpk /proc/version
/usr/bin/pgps /proc/version
/usr/bin/pgpv /proc/version
/usr/bin/procinfo /proc/cmdline
/usr/bin/procinfo /proc/devices
/usr/bin/procinfo /proc/dma
/usr/bin/procinfo /proc/filesystems
/usr/bin/procinfo /proc/interrupts
/usr/bin/procinfo /proc/loadavg
/usr/bin/procinfo /proc/meminfo
/usr/bin/procinfo /proc/modules
/usr/bin/procinfo /proc/stat
/usr/bin/procinfo /proc/uptime
/usr/bin/procinfo /proc/version
/usr/bin/purgestat /proc/loadavg
/usr/bin/screen /proc/loadavg
/usr/bin/strace /proc/%d/stat
/usr/bin/top /proc/cpuinfo
/usr/bin/top /proc/meminfo
/usr/bin/top /proc/stat
/usr/bin/vmstat /proc/%s/stat
/usr/bin/vmstat /proc/meminfo
/usr/bin/vmstat /proc/stat
/usr/sbin/atd /proc/loadavg
/usr/sbin/dnskeygen /proc/
/usr/sbin/dnskeygen /proc/interrupts
/usr/sbin/dnskeygen /proc/meminfo
/usr/sbin/dnskeygen /proc/rtc
/usr/sbin/dnskeygen /proc/self/status
/usr/sbin/dnskeygen /proc/stat
/usr/sbin/fuser /proc/%d/stat
/usr/sbin/fuser /proc/net/%s
/usr/sbin/fuser /proc/net/unix
/usr/sbin/in.identd /proc/net/tcp
/usr/sbin/irpd /proc/
/usr/sbin/irpd /proc/interrupts
/usr/sbin/irpd /proc/meminfo
/usr/sbin/irpd /proc/rtc
/usr/sbin/irpd /proc/self/status
/usr/sbin/irpd /proc/stat
/usr/sbin/named /proc/
/usr/sbin/named /proc/interrupts
/usr/sbin/named /proc/meminfo
/usr/sbin/named /proc/rtc
/usr/sbin/named /proc/self/status
/usr/sbin/named /proc/stat
/usr/sbin/named-xfer /proc/
/usr/sbin/named-xfer /proc/interrupts
/usr/sbin/named-xfer /proc/meminfo
/usr/sbin/named-xfer /proc/rtc
/usr/sbin/named-xfer /proc/self/status
/usr/sbin/named-xfer /proc/stat
/usr/sbin/readprofile /proc/profile
/usr/sbin/rwhod /proc/loadavg
/usr/sbin/rwhod /proc/uptime
/usr/sbin/sendmail /proc/loadavg
/usr/sbin/setconsole /proc/openprom/options
/usr/sbin/setconsole /proc/openprom/options/${console}-mode
/usr/sbin/setconsole /proc/openprom/options/input-device
/usr/sbin/setconsole /proc/openprom/options/output-device
Best wishes from Riley.
* Copyright (C) 1999, Memory Alpha Systems.
* All rights and wrongs reserved.
+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* http://www.memalpha.cx/Linux/Kernel/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
+292 -162
View File
@@ -1,366 +1,499 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
static int been_there_done_that = 0;
/* It has been alledged that doing such things can
* help reduce binary size when staticly linking,
* of course with glibc, this is unlikely as long
* as we use things like printf -- perhaps a printf
* replacement may be in order
*/
#if 0
void exit(int status) __attribute__ ((noreturn));
void exit(int status)
{
_exit(status);
};
void abort(void) __attribute__ ((__noreturn__));
void abort(void)
{
_exit(0);
};
int atexit(void (*__func) (void))
{
_exit(0);
};
void *__libc_stack_end;
const struct BB_applet applets[] = {
#ifdef BB_AR
{"ar", ar_main, _BB_DIR_USR_BIN, ar_usage},
#endif
static const struct Applet applets[] = {
#ifdef BB_BASENAME
{"basename", basename_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_BUSYBOX
{"busybox", busybox_main, _BB_DIR_BIN},
#endif
#ifdef BB_BLOCK_DEVICE
{"block_device", block_device_main, _BB_DIR_SBIN},
{"basename", basename_main, _BB_DIR_USR_BIN, basename_usage},
#endif
{"busybox", busybox_main, _BB_DIR_BIN, NULL},
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
{"cat", cat_main, _BB_DIR_BIN, cat_usage},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
{"chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage},
#endif
#ifdef BB_CLEAR
{"clear", clear_main, _BB_DIR_USR_BIN},
{"clear", clear_main, _BB_DIR_USR_BIN, clear_usage},
#endif
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN},
{"chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage},
#endif
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
{"cp", cp_mv_main, _BB_DIR_BIN, cp_usage},
#endif
#ifdef BB_CUT
{"cut", cut_main, _BB_DIR_USR_BIN, cut_usage},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
{"date", date_main, _BB_DIR_BIN, date_usage},
#endif
#ifdef BB_DC
{"dc", dc_main, _BB_DIR_USR_BIN, dc_usage},
#endif
#ifdef BB_DD
{"dd", dd_main, _BB_DIR_BIN},
{"dd", dd_main, _BB_DIR_BIN, dd_usage},
#endif
#ifdef BB_DF
{"df", df_main, _BB_DIR_BIN},
{"df", df_main, _BB_DIR_BIN, df_usage},
#endif
#ifdef BB_DIRNAME
{"dirname", dirname_main, _BB_DIR_USR_BIN},
{"dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage},
#endif
#ifdef BB_DMESG
{"dmesg", dmesg_main, _BB_DIR_BIN},
{"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage},
#endif
#ifdef BB_DOS2UNIX
{"dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage},
#endif
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
{"du", du_main, _BB_DIR_USR_BIN, du_usage},
#endif
#ifdef BB_DUMPKMAP
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage},
#endif
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
{"echo", echo_main, _BB_DIR_BIN, echo_usage},
#endif
#ifdef BB_EXPR
{"expr", expr_main, _BB_DIR_USR_BIN, expr_usage},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
{"false", false_main, _BB_DIR_BIN, false_usage},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
{"fbset", fbset_main, _BB_DIR_USR_SBIN, NULL},
#endif
#ifdef BB_FDFLUSH
{"fdflush", fdflush_main, _BB_DIR_BIN},
{"fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage},
#endif
#ifdef BB_FIND
{"find", find_main, _BB_DIR_USR_BIN},
{"find", find_main, _BB_DIR_USR_BIN, find_usage},
#endif
#ifdef BB_FREE
{"free", free_main, _BB_DIR_USR_BIN},
{"free", free_main, _BB_DIR_USR_BIN, free_usage},
#endif
#ifdef BB_FREERAMDISK
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage},
#endif
#ifdef BB_DEALLOCVT
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage},
#endif
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage},
#endif
#ifdef BB_GETOPT
{"getopt", getopt_main, _BB_DIR_BIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
{"grep", grep_main, _BB_DIR_BIN, grep_usage},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
{"gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
{"gzip", gzip_main, _BB_DIR_BIN, gzip_usage},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
{"halt", halt_main, _BB_DIR_SBIN, halt_usage},
#endif
#ifdef BB_HEAD
{"head", head_main, _BB_DIR_BIN},
{"head", head_main, _BB_DIR_USR_BIN, head_usage},
#endif
#ifdef BB_HOSTID
{"hostid", hostid_main, _BB_DIR_USR_BIN},
{"hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage},
#endif
#ifdef BB_HOSTNAME
{"hostname", hostname_main, _BB_DIR_BIN},
{"hostname", hostname_main, _BB_DIR_BIN, hostname_usage},
#endif
#ifdef BB_ID
{"id", id_main, _BB_DIR_USR_BIN, id_usage},
#endif
#ifdef BB_INIT
{"init", init_main, _BB_DIR_SBIN},
{"init", init_main, _BB_DIR_SBIN, NULL},
#endif
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
{"insmod", insmod_main, _BB_DIR_SBIN, insmod_usage},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
{"kill", kill_main, _BB_DIR_BIN, kill_usage},
#endif
#ifdef BB_KILLALL
{"killall", kill_main, _BB_DIR_USR_BIN},
{"killall", kill_main, _BB_DIR_USR_BIN, kill_usage},
#endif
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
{"length", length_main, _BB_DIR_USR_BIN, length_usage},
#endif
#ifdef BB_LINUXRC
{"linuxrc", init_main, _BB_DIR_ROOT},
{"linuxrc", init_main, _BB_DIR_ROOT, NULL},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
{"ln", ln_main, _BB_DIR_BIN, ln_usage},
#endif
#ifdef BB_LOADACM
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
{"loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage},
#endif
#ifdef BB_LOADFONT
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
{"loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage},
#endif
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
{"loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
{"logger", logger_main, _BB_DIR_USR_BIN, logger_usage},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
{"logname", logname_main, _BB_DIR_USR_BIN, logname_usage},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
{"ls", ls_main, _BB_DIR_BIN, ls_usage},
#endif
#ifdef BB_LSMOD
{"lsmod", lsmod_main, _BB_DIR_SBIN},
{"lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage},
#endif
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
{"makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage},
#endif
#ifdef BB_MATH
{"math", math_main, _BB_DIR_USR_BIN},
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
{"mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage},
#endif
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
{"mknod", mknod_main, _BB_DIR_BIN, mknod_usage},
#endif
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
{"mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage},
#endif
#ifdef BB_MNC
{"mnc", mnc_main, _BB_DIR_USR_BIN},
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage},
#endif
#ifdef BB_NC
{"nc", nc_main, _BB_DIR_USR_BIN, nc_usage},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
{"more", more_main, _BB_DIR_BIN, more_usage},
#endif
#ifdef BB_MOUNT
{"mount", mount_main, _BB_DIR_BIN},
{"mount", mount_main, _BB_DIR_BIN, mount_usage},
#endif
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
{"mt", mt_main, _BB_DIR_BIN, mt_usage},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
{"mv", cp_mv_main, _BB_DIR_BIN, mv_usage},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
{"nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage},
#endif
#ifdef BB_PING
{"ping", ping_main, _BB_DIR_BIN},
{"ping", ping_main, _BB_DIR_BIN, ping_usage},
#endif
#ifdef BB_POWEROFF
{"poweroff", poweroff_main, _BB_DIR_SBIN},
{"poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage},
#endif
#ifdef BB_PRINTF
{"printf", printf_main, _BB_DIR_USR_BIN},
{"printf", printf_main, _BB_DIR_USR_BIN, printf_usage},
#endif
#ifdef BB_PS
{"ps", ps_main, _BB_DIR_BIN},
{"ps", ps_main, _BB_DIR_BIN, ps_usage},
#endif
#ifdef BB_PWD
{"pwd", pwd_main, _BB_DIR_BIN},
{"pwd", pwd_main, _BB_DIR_BIN, pwd_usage},
#endif
#ifdef BB_RDATE
{"rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage},
#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN},
{"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage},
#endif
#ifdef BB_RENICE
{"renice", renice_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_RESET
{"reset", reset_main, _BB_DIR_USR_BIN, reset_usage},
#endif
#ifdef BB_RM
{"rm", rm_main, _BB_DIR_BIN},
{"rm", rm_main, _BB_DIR_BIN, rm_usage},
#endif
#ifdef BB_RMDIR
{"rmdir", rmdir_main, _BB_DIR_BIN},
{"rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage},
#endif
#ifdef BB_RMMOD
{"rmmod", rmmod_main, _BB_DIR_SBIN},
{"rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage},
#endif
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
{"sed", sed_main, _BB_DIR_BIN, sed_usage},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
{"sh", shell_main, _BB_DIR_BIN, shell_usage},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
{"sleep", sleep_main, _BB_DIR_BIN, sleep_usage},
#endif
#ifdef BB_SORT
{"sort", sort_main, _BB_DIR_BIN},
{"sort", sort_main, _BB_DIR_USR_BIN, sort_usage},
#endif
#ifdef BB_SYNC
{"sync", sync_main, _BB_DIR_BIN},
{"sync", sync_main, _BB_DIR_BIN, sync_usage},
#endif
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
{"syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
{"swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage},
#endif
#ifdef BB_SWAPONOFF
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
{"swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage},
#endif
#ifdef BB_TAIL
{"tail", tail_main, _BB_DIR_USR_BIN},
{"tail", tail_main, _BB_DIR_USR_BIN, tail_usage},
#endif
#ifdef BB_TAR
{"tar", tar_main, _BB_DIR_BIN},
{"tar", tar_main, _BB_DIR_BIN, tar_usage},
#endif
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
{"telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
{"test", test_main, _BB_DIR_USR_BIN, test_usage},
#endif
#ifdef BB_TEE
{"tee", tee_main, _BB_DIR_BIN},
{"tee", tee_main, _BB_DIR_USR_BIN, tee_usage},
#endif
#ifdef BB_TOUCH
{"touch", touch_main, _BB_DIR_USR_BIN},
{"touch", touch_main, _BB_DIR_BIN, touch_usage},
#endif
#ifdef BB_TR
{"tr", tr_main, _BB_DIR_USR_BIN},
{"tr", tr_main, _BB_DIR_USR_BIN, tr_usage},
#endif
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
{"true", true_main, _BB_DIR_BIN, true_usage},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
{"tty", tty_main, _BB_DIR_USR_BIN, tty_usage},
#endif
#ifdef BB_UMOUNT
{"umount", umount_main, _BB_DIR_BIN},
{"umount", umount_main, _BB_DIR_BIN, umount_usage},
#endif
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
{"uname", uname_main, _BB_DIR_BIN, uname_usage},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_USR_BIN},
{"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage},
#endif
#ifdef BB_UNIX2DOS
{"unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage},
#endif
#ifdef BB_UNRPM
{"unrpm", unrpm_main, _BB_DIR_USR_BIN, unrpm_usage},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
{"update", update_main, _BB_DIR_SBIN, update_usage},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
{"uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage},
#endif
#ifdef BB_UUENCODE
{"uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage},
#endif
#ifdef BB_UUDECODE
{"uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
{"usleep", usleep_main, _BB_DIR_BIN, usleep_usage},
#endif
#ifdef BB_WC
{"wc", wc_main, _BB_DIR_USR_BIN},
{"wc", wc_main, _BB_DIR_USR_BIN, wc_usage},
#endif
#ifdef BB_WGET
{"wget", wget_main, _BB_DIR_USR_BIN, wget_usage},
#endif
#ifdef BB_WHICH
{"which", which_main, _BB_DIR_USR_BIN, which_usage},
#endif
#ifdef BB_WHOAMI
{"whoami", whoami_main, _BB_DIR_USR_BIN},
{"whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage},
#endif
#ifdef BB_XARGS
{"xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage},
#endif
#ifdef BB_YES
{"yes", yes_main, _BB_DIR_USR_BIN},
{"yes", yes_main, _BB_DIR_USR_BIN, yes_usage},
#endif
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
{"zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
{"[", test_main, _BB_DIR_USR_BIN, test_usage},
#endif
{0}
{0,NULL,0,NULL}
};
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
"/",
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
};
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/*
* Where in the filesystem is this busybox?
* [return]
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
errorMsg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
}
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
int i;
int rc;
if (use_symbolic_links) Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf ( command, "%s/%s",
install_dir[applets[i].location],
applets[i].name);
rc = Link(busybox, command);
if (rc) {
errorMsg("%s: %s\n", command, strerror(errno));
}
}
}
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
char *s;
char *name;
const struct Applet *a = applets;
const char *s;
const struct BB_applet *a = applets;
applet_name = "busybox";
for (s = name = argv[0]; *s != '\0';) {
#ifdef BB_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
* If someone has a cleaner approach, by all means implement it.
*/
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
int use_symbolic_links = 0;
int rc = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
if (argc > 2) {
if ((strcmp(argv[2], "-s") == 0)) {
use_symbolic_links = 1;
}
}
/* link */
busybox = busybox_fullpath();
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
} else {
rc = 1;
}
return rc;
}
#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
name = s;
applet_name = s;
}
*argv = name;
*argv = (char*)applet_name;
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
while (a->name != 0) {
if (strcmp(name, a->name) == 0) {
int status;
status = ((*(a->main)) (argc, argv));
if (status < 0) {
fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
}
fprintf(stderr, "\n");
exit(status);
if (strcmp(applet_name, a->name) == 0) {
if (a->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(a->usage);
exit(((*(a->main)) (argc, argv)));
}
a++;
}
exit(busybox_main(argc, argv));
return(busybox_main(argc, argv));
}
@@ -372,18 +505,16 @@ int busybox_main(int argc, char **argv)
argv++;
if (been_there_done_that == 1 || argc < 1) {
const struct Applet *a = applets;
const struct BB_applet *a = applets;
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
fprintf(stderr, " or: [function] [arguments]...\n\n");
fprintf(stderr,
fprintf(stderr, "%s\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use, and BusyBox\n"
"\twill act like whatever it was invoked as.\n");
fprintf(stderr, "\nCurrently defined functions:\n");
"\twill act like whatever it was invoked as.\n"
"\nCurrently defined functions:\n", full_version);
while (a->name != 0) {
col +=
@@ -396,11 +527,10 @@ int busybox_main(int argc, char **argv)
}
fprintf(stderr, "\n\n");
exit(-1);
} else {
/* If we've already been here once, exit now */
been_there_done_that = 1;
return (main(argc, argv));
}
/* If we've already been here once, exit now */
been_there_done_that = 1;
return (main(argc, argv));
}
/*
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Make busybox links list file.
DF="busybox.def.h"
DF="Config.h"
MF="busybox.c"
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
+2 -2
View File
@@ -3,8 +3,8 @@
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 ` \
gcc -E -dM busybox.def.h | \
gcc -E -dM Config.h | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr [:upper:] [:lower:] | sort
| tr '[:upper:]' '[:lower:]' | sort
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
+38 -10
View File
@@ -1,21 +1,49 @@
#!/bin/sh
set -e
if [ "$1" = "" ]; then
prefix=$1
if [ "$prefix" = "" ]; then
echo "No installation directory, aborting."
exit 1;
fi
if [ "$2" = "--hardlinks" ]; then
linkopts="-f"
else
linkopts="-fs"
fi
h=`sort busybox.links | uniq`
rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
for i in $h ; do
echo " $1$i -> /bin/busybox"
mkdir -p $1/`echo $i | sed -e 's/\/[^\/]*$//' `
ln -fs /bin/busybox $1$i
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
else
case "$appdir" in
/)
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
fi
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
done
rm -f $1/bin/busybox
mkdir -p $1/bin
install -m 755 busybox $1/bin/busybox
exit 0
+1458
View File
File diff suppressed because it is too large. Load diff
+391
View File
@@ -0,0 +1,391 @@
/* vi: set sw=4 ts=4: */
/*
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Last modified 20 September 2000
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <malloc.h>
#include "busybox.h"
#define BLOCK_SIZE 60
#define PRESERVE_DATE 1 /* preserve original dates */
#define VERBOSE 2 /* be verbose */
#define DISPLAY 4 /* display contents */
#define EXT_TO_FILE 8 /* extract contents of archive */
#define EXT_TO_STDOUT 16 /* extract to stdout */
#define RECURSIVE 32
#define MAX_NAME_LENGTH 100
//#define BB_DECLARE_EXTERN
//#define bb_need_io_error
//#include "messages.c"
//#define BB_AR_EXPERIMENTAL_UNTAR
#if defined BB_AR_EXPERIMENTAL_UNTAR
typedef struct rawTarHeader {
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} rawTarHeader_t;
#endif
typedef struct rawArHeader { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6], gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} rawArHeader_t;
typedef struct headerL {
char name[MAX_NAME_LENGTH];
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct headerL *next;
} headerL_t;
#if defined BB_AR_EXPERIMENTAL_UNTAR
/*
* identify Tar header (magic field) and reset srcFd to entry position
*/
static int checkTarMagic(int srcFd)
{
off_t headerStart;
char magic[6];
headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR);
fullRead(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
return(TRUE);
}
static int readTarHeader(int srcFd, headerL_t *current)
{
rawTarHeader_t rawTarHeader;
unsigned char *temp = (unsigned char *) &rawTarHeader;
long sum = 0;
int i;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
for (i = 0; i < 148 ; i++)
sum += temp[i];
sum += ' ' * 8;
for (i = 156; i < 512 ; i++)
sum += temp[i];
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
return(FALSE);
sscanf(rawTarHeader.name, "%s", current->name);
current->size = strtol(rawTarHeader.size, NULL, 8);
current->uid = strtol(rawTarHeader.uid, NULL, 8);
current->gid = strtol(rawTarHeader.gid, NULL, 8);
current->mode = strtol(rawTarHeader.mode, NULL, 8);
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
current->offset = lseek(srcFd, 0 , SEEK_CUR);
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
current = current->next;
return(TRUE);
}
#endif
/*
* identify Ar header (magic) and reset srcFd to entry position
*/
static int checkArMagic(int srcFd)
{
off_t headerStart;
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, arMagic, 8) != 8) {
errorMsg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(arMagic,"!<arch>",7) != 0)
return(FALSE);
return(TRUE);
}
/*
* get, check and correct the converted header
*/
static int readArEntry(int srcFd, headerL_t *entry)
{
size_t nameLength;
rawArHeader_t rawArHeader;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
strncpy(entry->name, rawArHeader.name, 16);
nameLength=strcspn(entry->name, " \\");
entry->name[nameLength]='\0';
parse_mode(rawArHeader.mode, &entry->mode);
entry->mtime = atoi(rawArHeader.date);
entry->uid = atoi(rawArHeader.uid);
entry->gid = atoi(rawArHeader.gid);
entry->size = (size_t) atoi(rawArHeader.size);
entry->offset = initialOffset + (off_t) 60;
nameLength = strcspn(entry->name, "/");
/* handle GNU style short filenames, strip trailing '/' */
if (nameLength > 0)
entry->name[nameLength]='\0';
/* handle GNU style long filenames */
if (nameLength == 0) {
/* escape from recursive call */
if (entry->name[1]=='0')
return(TRUE);
/* the data section contains the real filename */
if (entry->name[1]=='/') {
char tempName[MAX_NAME_LENGTH];
if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH;
fullRead(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0';
/* read the second header for this entry */
/* be carefull, this is recursive */
if (readArEntry(srcFd, entry)==FALSE)
return(FALSE);
if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName);
else {
errorMsg("Invalid long filename\n");
return(FALSE);
}
}
}
return(TRUE);
}
/*
* return the headerL_t struct for the specified filename
*/
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
{
#if defined BB_AR_EXPERIMENTAL_UNTAR
int tar=FALSE;
#endif
int ar=FALSE;
headerL_t *list;
off_t initialOffset;
list = (headerL_t *) xmalloc(sizeof(headerL_t));
initialOffset=lseek(srcFd, 0, SEEK_CUR);
if (checkArMagic(srcFd)==TRUE)
ar=TRUE;
#if defined BB_AR_EXPERIMENTAL_UNTAR
if (checkTarMagic(srcFd)==TRUE)
tar=TRUE;
if (tar==TRUE) {
while(readTarHeader(srcFd, list)==TRUE) {
off_t tarOffset;
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if ((funct & RECURSIVE) == RECURSIVE)
head = getHeaders(srcFd, head, funct);
tarOffset = (off_t) head->size/512;
if ( head->size % 512 > 0)
tarOffset++;
tarOffset=tarOffset*512;
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
}
}
#endif
if (ar==TRUE) {
lseek(srcFd, 8, SEEK_CUR);
while(1) {
if (readArEntry(srcFd, list) == FALSE) {
lseek(srcFd, ++initialOffset, SEEK_CUR);
if (readArEntry(srcFd, list) == FALSE)
return(head);
}
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if (funct & RECURSIVE)
head = getHeaders(srcFd, head, funct);
lseek(srcFd, head->offset + head->size, SEEK_SET);
}
}
return(head);
}
/*
* find an entry in the linked list matching the filename
*/
static headerL_t *findEntry(headerL_t *head, const char *filename)
{
while(head->next != NULL) {
if (strcmp(filename, head->name)==0)
return(head);
head=head->next;
}
return(NULL);
}
extern int ar_main(int argc, char **argv)
{
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
headerL_t *header, *entry, *extractList;
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
switch (opt) {
case 'o':
funct |= PRESERVE_DATE;
break;
case 'v':
funct |= VERBOSE;
break;
case 't':
funct |= DISPLAY;
break;
case 'x':
funct |= EXT_TO_FILE;
break;
case 'p':
funct |= EXT_TO_STDOUT;
break;
case 'R':
funct |= RECURSIVE;
break;
default:
usage(ar_usage);
}
}
/* check the src filename was specified */
if (optind == argc)
usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
fatalError("Cannot read %s\n", argv[optind]);
optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
header = (headerL_t *) xmalloc(sizeof(headerL_t));
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
header = getHeaders(srcFd, header, funct);
/* find files to extract or display */
if (optind<argc) {
/* only handle specified files */
while(optind < argc) {
if ( (entry = findEntry(header, argv[optind])) != NULL) {
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*entry->next = *extractList;
*extractList = *entry;
}
optind++;
}
}
else
extractList = header;
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
createPath(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
copySubFile(srcFd, dstFd, (size_t) extractList->size);
}
if (funct & EXT_TO_STDOUT) {
lseek(srcFd, extractList->offset, SEEK_SET);
copySubFile(srcFd, fileno(stdout), (size_t) extractList->size);
}
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE)
printf("%s %d/%d %8d %s ", modeString(extractList->mode),
extractList->uid, extractList->gid,
extractList->size, timeString(extractList->mtime));
printf("%s\n", extractList->name);
}
extractList=extractList->next;
}
return (TRUE);
}
+391
View File
@@ -0,0 +1,391 @@
/* vi: set sw=4 ts=4: */
/*
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Last modified 20 September 2000
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <malloc.h>
#include "busybox.h"
#define BLOCK_SIZE 60
#define PRESERVE_DATE 1 /* preserve original dates */
#define VERBOSE 2 /* be verbose */
#define DISPLAY 4 /* display contents */
#define EXT_TO_FILE 8 /* extract contents of archive */
#define EXT_TO_STDOUT 16 /* extract to stdout */
#define RECURSIVE 32
#define MAX_NAME_LENGTH 100
//#define BB_DECLARE_EXTERN
//#define bb_need_io_error
//#include "messages.c"
//#define BB_AR_EXPERIMENTAL_UNTAR
#if defined BB_AR_EXPERIMENTAL_UNTAR
typedef struct rawTarHeader {
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} rawTarHeader_t;
#endif
typedef struct rawArHeader { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6], gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} rawArHeader_t;
typedef struct headerL {
char name[MAX_NAME_LENGTH];
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct headerL *next;
} headerL_t;
#if defined BB_AR_EXPERIMENTAL_UNTAR
/*
* identify Tar header (magic field) and reset srcFd to entry position
*/
static int checkTarMagic(int srcFd)
{
off_t headerStart;
char magic[6];
headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR);
fullRead(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
return(TRUE);
}
static int readTarHeader(int srcFd, headerL_t *current)
{
rawTarHeader_t rawTarHeader;
unsigned char *temp = (unsigned char *) &rawTarHeader;
long sum = 0;
int i;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
for (i = 0; i < 148 ; i++)
sum += temp[i];
sum += ' ' * 8;
for (i = 156; i < 512 ; i++)
sum += temp[i];
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
return(FALSE);
sscanf(rawTarHeader.name, "%s", current->name);
current->size = strtol(rawTarHeader.size, NULL, 8);
current->uid = strtol(rawTarHeader.uid, NULL, 8);
current->gid = strtol(rawTarHeader.gid, NULL, 8);
current->mode = strtol(rawTarHeader.mode, NULL, 8);
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
current->offset = lseek(srcFd, 0 , SEEK_CUR);
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
current = current->next;
return(TRUE);
}
#endif
/*
* identify Ar header (magic) and reset srcFd to entry position
*/
static int checkArMagic(int srcFd)
{
off_t headerStart;
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, arMagic, 8) != 8) {
errorMsg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(arMagic,"!<arch>",7) != 0)
return(FALSE);
return(TRUE);
}
/*
* get, check and correct the converted header
*/
static int readArEntry(int srcFd, headerL_t *entry)
{
size_t nameLength;
rawArHeader_t rawArHeader;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
strncpy(entry->name, rawArHeader.name, 16);
nameLength=strcspn(entry->name, " \\");
entry->name[nameLength]='\0';
parse_mode(rawArHeader.mode, &entry->mode);
entry->mtime = atoi(rawArHeader.date);
entry->uid = atoi(rawArHeader.uid);
entry->gid = atoi(rawArHeader.gid);
entry->size = (size_t) atoi(rawArHeader.size);
entry->offset = initialOffset + (off_t) 60;
nameLength = strcspn(entry->name, "/");
/* handle GNU style short filenames, strip trailing '/' */
if (nameLength > 0)
entry->name[nameLength]='\0';
/* handle GNU style long filenames */
if (nameLength == 0) {
/* escape from recursive call */
if (entry->name[1]=='0')
return(TRUE);
/* the data section contains the real filename */
if (entry->name[1]=='/') {
char tempName[MAX_NAME_LENGTH];
if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH;
fullRead(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0';
/* read the second header for this entry */
/* be carefull, this is recursive */
if (readArEntry(srcFd, entry)==FALSE)
return(FALSE);
if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName);
else {
errorMsg("Invalid long filename\n");
return(FALSE);
}
}
}
return(TRUE);
}
/*
* return the headerL_t struct for the specified filename
*/
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
{
#if defined BB_AR_EXPERIMENTAL_UNTAR
int tar=FALSE;
#endif
int ar=FALSE;
headerL_t *list;
off_t initialOffset;
list = (headerL_t *) xmalloc(sizeof(headerL_t));
initialOffset=lseek(srcFd, 0, SEEK_CUR);
if (checkArMagic(srcFd)==TRUE)
ar=TRUE;
#if defined BB_AR_EXPERIMENTAL_UNTAR
if (checkTarMagic(srcFd)==TRUE)
tar=TRUE;
if (tar==TRUE) {
while(readTarHeader(srcFd, list)==TRUE) {
off_t tarOffset;
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if ((funct & RECURSIVE) == RECURSIVE)
head = getHeaders(srcFd, head, funct);
tarOffset = (off_t) head->size/512;
if ( head->size % 512 > 0)
tarOffset++;
tarOffset=tarOffset*512;
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
}
}
#endif
if (ar==TRUE) {
lseek(srcFd, 8, SEEK_CUR);
while(1) {
if (readArEntry(srcFd, list) == FALSE) {
lseek(srcFd, ++initialOffset, SEEK_CUR);
if (readArEntry(srcFd, list) == FALSE)
return(head);
}
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if (funct & RECURSIVE)
head = getHeaders(srcFd, head, funct);
lseek(srcFd, head->offset + head->size, SEEK_SET);
}
}
return(head);
}
/*
* find an entry in the linked list matching the filename
*/
static headerL_t *findEntry(headerL_t *head, const char *filename)
{
while(head->next != NULL) {
if (strcmp(filename, head->name)==0)
return(head);
head=head->next;
}
return(NULL);
}
extern int ar_main(int argc, char **argv)
{
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
headerL_t *header, *entry, *extractList;
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
switch (opt) {
case 'o':
funct |= PRESERVE_DATE;
break;
case 'v':
funct |= VERBOSE;
break;
case 't':
funct |= DISPLAY;
break;
case 'x':
funct |= EXT_TO_FILE;
break;
case 'p':
funct |= EXT_TO_STDOUT;
break;
case 'R':
funct |= RECURSIVE;
break;
default:
usage(ar_usage);
}
}
/* check the src filename was specified */
if (optind == argc)
usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
fatalError("Cannot read %s\n", argv[optind]);
optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
header = (headerL_t *) xmalloc(sizeof(headerL_t));
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
header = getHeaders(srcFd, header, funct);
/* find files to extract or display */
if (optind<argc) {
/* only handle specified files */
while(optind < argc) {
if ( (entry = findEntry(header, argv[optind])) != NULL) {
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*entry->next = *extractList;
*extractList = *entry;
}
optind++;
}
}
else
extractList = header;
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
createPath(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
copySubFile(srcFd, dstFd, (size_t) extractList->size);
}
if (funct & EXT_TO_STDOUT) {
lseek(srcFd, extractList->offset, SEEK_SET);
copySubFile(srcFd, fileno(stdout), (size_t) extractList->size);
}
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE)
printf("%s %d/%d %8d %s ", modeString(extractList->mode),
extractList->uid, extractList->gid,
extractList->size, timeString(extractList->mtime));
printf("%s\n", extractList->name);
}
extractList=extractList->next;
}
return (TRUE);
}
+48 -177
View File
@@ -27,24 +27,18 @@
*
*/
#include "internal.h"
static const char gunzip_usage[] =
"gunzip [OPTION]... FILE\n\n"
"Uncompress FILE (or standard input if FILE is '-').\n\n"
"Options:\n"
#include "busybox.h"
#include <getopt.h>
"\t-c\tWrite output to standard output\n"
"\t-t\tTest compressed file integrity\n";
/* These defines are very important for BusyBox. Without these,
/* These defines are very important for BusyBox. Without these,
* huge chunks of ram are pre-allocated making the BusyBox bss
* size Freaking Huge(tm), which is a bad thing.*/
#define SMALL_MEM
#define DYN_ALLOC
#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
#define bb_need_memory_exhausted
#define bb_need_name_too_long
#include "messages.c"
@@ -100,9 +94,7 @@ static char *license_msg[] = {
#include <ctype.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/param.h> /* for PATH_MAX */
/* #include "tailor.h" */
@@ -207,7 +199,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) errorMsg("insufficient memory"); \
if (array == NULL) errorMsg(memory_exhausted); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -363,25 +355,20 @@ void send_bits (int value, int length);
unsigned bi_reverse (unsigned value, int length);
void bi_windup (void);
void copy_block (char *buf, unsigned len, int header);
extern int (*read_buf) (char *buf, unsigned size);
/* in util.c: */
extern int copy (int in, int out);
extern ulg updcrc (uch * s, unsigned n);
extern void clear_bufs (void);
extern int fill_inbuf (int eof_ok);
static int fill_inbuf (int eof_ok);
extern void flush_outbuf (void);
extern void flush_window (void);
static void flush_window (void);
extern void write_buf (int fd, void * buf, unsigned cnt);
#ifndef __linux__
extern char *basename (char *fname);
#endif /* not __linux__ */
extern void read_error (void);
extern void write_error (void);
void read_error_msg (void);
void write_error_msg (void);
/* in inflate.c */
extern int inflate (void);
static int inflate (void);
/* #include "lzw.h" */
@@ -446,133 +433,6 @@ extern int unlzw (int in, int out);
# undef LZW
#endif
/* #include "getopt.h" */
/* Declarations for getopt.
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option {
#if __STDC__
const char *name;
#else
char *name;
#endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if __STDC__ || defined(PROTO)
#if defined(__GNU_LIBRARY__)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt(int argc, char *const *argv, const char *shortopts);
#endif /* not __GNU_LIBRARY__ */
extern int getopt_long(int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only(int argc, char *const *argv,
const char *shortopts,
const struct option *longopts,
int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal(int argc, char *const *argv,
const char *shortopts,
const struct option *longopts,
int *longind, int long_only);
#else /* not __STDC__ */
extern int getopt();
extern int getopt_long();
extern int getopt_long_only();
extern int _getopt_internal();
#endif /* not __STDC__ */
#ifdef __cplusplus
}
#endif
#endif /* _GETOPT_H */
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
@@ -641,8 +501,8 @@ typedef RETSIGTYPE(*sig_type) (int);
#define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */
#ifndef MAX_PATH_LEN /* max pathname length */
# ifdef PATH_MAX
# define MAX_PATH_LEN PATH_MAX
# ifdef BUFSIZ
# define MAX_PATH_LEN BUFSIZ
# else
# define MAX_PATH_LEN 1024
# endif
@@ -705,44 +565,56 @@ local int get_method (int in);
int gunzip_main(int argc, char **argv)
{
int file_count; /* number of files to precess */
int to_stdout = 0;
int tostdout = 0;
int fromstdin = 0;
int result;
int inFileNum;
int outFileNum;
int delInputFile = 0;
int force = 0;
struct stat statBuf;
char *delFileName;
char ifname[MAX_PATH_LEN + 1]; /* input file name */
char ofname[MAX_PATH_LEN + 1]; /* output file name */
if (argc == 1)
usage(gunzip_usage);
if (strcmp(*argv, "zcat") == 0)
to_stdout = 1;
if (strcmp(applet_name, "zcat") == 0) {
force = 1;
tostdout = 1;
}
/* Parse any options */
while (--argc > 0 && **(++argv) == '-') {
if (*((*argv) + 1) == '\0') {
fromstdin = 1;
to_stdout = 1;
tostdout = 1;
}
while (*(++(*argv))) {
switch (**argv) {
case 'c':
to_stdout = 1;
tostdout = 1;
break;
case 't':
test_mode = 1;
break;
case 'f':
force = 1;
break;
default:
usage(gunzip_usage);
}
}
}
if (argc <= 0) {
tostdout = 1;
fromstdin = 1;
}
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
fatalError( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
fatalError( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
(void) signal(SIGINT, (sig_type) abort_gzip);
@@ -779,10 +651,10 @@ int gunzip_main(int argc, char **argv)
ifile_size = -1L; /* convention for unknown size */
} else {
/* Open up the input file */
if (*argv == '\0')
if (argc <= 0)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
fprintf(stderr, name_too_long, "gunzip");
errorMsg(name_too_long);
exit(WARNING);
}
strcpy(ifname, *argv);
@@ -802,7 +674,7 @@ int gunzip_main(int argc, char **argv)
ifile_size = statBuf.st_size;
}
if (to_stdout == 1) {
if (tostdout == 1) {
/* And get to work */
strcpy(ofname, "stdout");
outFileNum = fileno(stdout);
@@ -821,7 +693,7 @@ int gunzip_main(int argc, char **argv)
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
fprintf(stderr, name_too_long, "gunzip");
errorMsg(name_too_long);
exit(WARNING);
}
strcpy(ofname, ifname);
@@ -870,13 +742,13 @@ int gunzip_main(int argc, char **argv)
exit(FALSE);
}
}
exit(exit_code);
return(exit_code);
}
/* ========================================================================
* Check the magic number of the input file and update ofname if an
* original name was given and to_stdout is not set.
* original name was given and tostdout is not set.
* Return the compression method, -1 for error, -2 for warning.
* Set inptr to the offset of the next byte to be processed.
* Updates time_stamp if there is one and --no-time is not used.
@@ -903,8 +775,7 @@ int in; /* input file descriptor */
method = (int) get_byte();
if (method != DEFLATED) {
fprintf(stderr,
"unknown method %d -- get newer version of gzip\n",
errorMsg("unknown method %d -- get newer version of gzip\n",
method);
exit_code = ERROR;
return -1;
@@ -1053,7 +924,7 @@ int in, out; /* input and output file descriptors */
int res = inflate();
if (res == 3) {
errorMsg("out of memory");
errorMsg(memory_exhausted);
} else if (res != 0) {
errorMsg("invalid compressed data--format violated");
}
@@ -1156,7 +1027,7 @@ unsigned n; /* number of bytes in s[] */
/* ===========================================================================
* Clear input and output buffers
*/
void clear_bufs()
void clear_bufs(void)
{
outcnt = 0;
insize = inptr = 0;
@@ -1184,7 +1055,7 @@ int eof_ok; /* set if EOF acceptable as a result */
if (insize == 0) {
if (eof_ok)
return EOF;
read_error();
read_error_msg();
}
bytes_in += (ulg) insize;
inptr = 1;
@@ -1235,7 +1106,7 @@ unsigned cnt;
while ((n = write(fd, buf, cnt)) != cnt) {
if (n == (unsigned) (-1)) {
write_error();
write_error_msg();
}
cnt -= n;
buf = (void *) ((char *) buf + n);
@@ -1301,7 +1172,7 @@ const char *reject;
/* ========================================================================
* Error handlers.
*/
void read_error()
void read_error_msg()
{
fprintf(stderr, "\n");
if (errno != 0) {
@@ -1312,7 +1183,7 @@ void read_error()
abort_gzip();
}
void write_error()
void write_error_msg()
{
fprintf(stderr, "\n");
perror("");
+31 -30
View File
@@ -29,7 +29,10 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_memory_exhausted
#include "messages.c"
/* These defines are very important for BusyBox. Without these,
* huge chunks of ram are pre-allocated making the BusyBox bss
@@ -37,16 +40,6 @@
#define SMALL_MEM
#define DYN_ALLOC
static const char gzip_usage[] =
"gzip [OPTION]... FILE\n\n"
"Compress FILE with maximum compression.\n"
"When FILE is '-', reads standard input. Implies -c.\n\n"
"Options:\n"
"\t-c\tWrite output to standard output instead of FILE.gz\n";
/* I don't like nested includes, but the string and io functions are used
* too often
*/
@@ -121,7 +114,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) errorMsg("insufficient memory"); \
if (array == NULL) errorMsg(memory_exhausted); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -276,8 +269,6 @@ extern int save_orig_name; /* set if original name must be saved */
#define WARN(msg) {if (!quiet) fprintf msg ; \
if (exit_code == OK) exit_code = WARNING;}
#define do_exit(c) exit(c)
/* in zip.c: */
extern int zip (int in, int out);
@@ -323,8 +314,8 @@ extern void flush_window (void);
extern void write_buf (int fd, void * buf, unsigned cnt);
extern char *strlwr (char *s);
extern char *add_envopt (int *argcp, char ***argvp, char *env);
extern void read_error (void);
extern void write_error (void);
extern void read_error_msg (void);
extern void write_error_msg (void);
extern void display_ratio (long num, long den, FILE * file);
/* in inflate.c */
@@ -1618,7 +1609,6 @@ ulg deflate()
#include <ctype.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
/* configuration */
@@ -1778,7 +1768,6 @@ int part_nb; /* number of parts in .gz file */
long time_stamp; /* original time stamp (modification time) */
long ifile_size; /* input file size, -1 for devices (debug only) */
char *env; /* contents of GZIP env variable */
char **args = NULL; /* argv pointer if GZIP env variable defined */
char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
int z_len; /* strlen(z_suffix) */
@@ -1811,14 +1800,11 @@ int gzip_main(int argc, char **argv)
char *delFileName;
int tostdout = 0;
int fromstdin = 0;
if (argc == 1)
usage(gzip_usage);
int force = 0;
/* Parse any options */
while (--argc > 0 && **(++argv) == '-') {
if (*((*argv) + 1) == '\0') {
fromstdin = 1;
tostdout = 1;
}
while (*(++(*argv))) {
@@ -1826,11 +1812,27 @@ int gzip_main(int argc, char **argv)
case 'c':
tostdout = 1;
break;
case 'f':
force = 1;
break;
/* Ignore 1-9 (compression level) options */
case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
break;
default:
usage(gzip_usage);
}
}
}
if (argc <= 0 ) {
fromstdin = 1;
tostdout = 1;
}
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
fatalError( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
fatalError( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
@@ -1870,7 +1872,7 @@ int gzip_main(int argc, char **argv)
ifile_size = -1L; /* convention for unknown size */
} else {
/* Open up the input file */
if (*argv == '\0')
if (argc <= 0)
usage(gzip_usage);
strncpy(ifname, *argv, MAX_PATH_LEN);
@@ -1878,13 +1880,13 @@ int gzip_main(int argc, char **argv)
inFileNum = open(ifname, O_RDONLY);
if (inFileNum < 0) {
perror(ifname);
do_exit(WARNING);
exit(WARNING);
}
/* Get the time stamp on the input file. */
result = stat(ifname, &statBuf);
if (result < 0) {
perror(ifname);
do_exit(WARNING);
exit(WARNING);
}
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
@@ -1918,7 +1920,7 @@ int gzip_main(int argc, char **argv)
#endif
if (outFileNum < 0) {
perror(ofname);
do_exit(WARNING);
exit(WARNING);
}
SET_BINARY_MODE(outFileNum);
/* Set permissions on the file */
@@ -1943,7 +1945,7 @@ int gzip_main(int argc, char **argv)
}
}
do_exit(exit_code);
return(exit_code);
}
/* trees.c -- output deflated data using Huffman coding
@@ -2272,7 +2274,6 @@ local void set_file_type (void);
* used.
*/
#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
/* ===========================================================================
@@ -3134,7 +3135,7 @@ int in, out; /* input and output file descriptors */
insize = read(in, (char *) inbuf, INBUFSIZ);
}
if ((int) insize == EOF && errno != 0) {
read_error();
read_error_msg();
}
bytes_in = bytes_out;
return OK;
@@ -3249,7 +3250,7 @@ char *env; /* name of environment variable */
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
errorMsg("out of memory");
errorMsg(memory_exhausted);
oargv = *argvp;
*argvp = nargv;
+192 -154
View File
@@ -36,9 +36,10 @@
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#define bb_need_name_longer_then_foo
#include "messages.c"
#include <stdio.h>
#include <dirent.h>
@@ -49,36 +50,7 @@
#include <utime.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
#include <sys/param.h> /* for PATH_MAX */
static const char tar_usage[] =
#ifdef BB_FEATURE_TAR_CREATE
"tar -[cxtvO] "
#else
"tar -[xtvO] "
#endif
#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
#endif
"[-f tarFile] [FILE] ...\n\n"
"Create, extract, or list files from a tar file. Note that\n"
"this version of tar treats hard links as separate files.\n\n"
"Main operation mode:\n"
#ifdef BB_FEATURE_TAR_CREATE
"\tc\t\tcreate\n"
#endif
"\tx\t\textract\n"
"\tt\t\tlist\n"
"\nFile selection:\n"
"\tf\t\tname of tarfile or \"-\" for stdin\n"
"\tO\t\textract to stdout\n"
#if defined BB_FEATURE_TAR_EXCLUDE
"\t--exclude\tfile to exclude\n"
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
;
#include <getopt.h>
/* Tar file constants */
#ifndef MAJOR
@@ -86,12 +58,13 @@ static const char tar_usage[] =
#define MINOR(dev) ((dev)&0xff)
#endif
#define NAME_SIZE 100
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
struct TarHeader
{
/* byte offset */
char name[100]; /* 0-99 */
char name[NAME_SIZE]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
@@ -99,7 +72,7 @@ struct TarHeader
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char linkname[NAME_SIZE]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
@@ -131,6 +104,8 @@ enum TarFileType
DIRTYPE = '5', /* directory */
FIFOTYPE = '6', /* FIFO special */
CONTTYPE = '7', /* reserved */
GNULONGLINK = 'K', /* GNU long (>100 chars) link name */
GNULONGNAME = 'L', /* GNU long (>100 chars) file name */
};
typedef enum TarFileType TarFileType;
@@ -155,7 +130,8 @@ typedef struct TarInfo TarInfo;
/* Local procedures to restore files from a tar file. */
static int readTarFile(const char* tarName, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** excludeList);
int tostdoutFlag, int verboseFlag, char** extractList,
char** excludeList);
@@ -165,92 +141,90 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
int verboseFlag, int argc, char **argv, char** excludeList);
#endif
extern int tar_main(int argc, char **argv)
{
char** excludeList=NULL;
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
#endif
const char *tarName=NULL;
const char *tarName="-";
int listFlag = FALSE;
int extractFlag = FALSE;
int createFlag = FALSE;
int verboseFlag = FALSE;
int tostdoutFlag = FALSE;
int firstOpt = TRUE;
int stopIt;
if (argc <= 1)
usage(tar_usage);
/* Parse any options */
while (--argc > 0 && (**(++argv) != '\0')) {
/* do normal option parsing */
while (--argc > 0 && ((*argv && **(++argv) == '-') ||
(firstOpt==TRUE && strspn(*argv, "-cxt") ))) {
firstOpt=FALSE;
stopIt=FALSE;
while (stopIt==FALSE && *(++(*argv))) {
while (stopIt==FALSE && *argv && **argv) {
switch (**argv) {
case 'f':
if (--argc == 0) {
fatalError( "Option requires an argument: No file specified\n");
}
if (tarName != NULL)
fatalError( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
fatalError( "Option requires an argument: No file specified\n");
stopIt=TRUE;
break;
case 't':
if (extractFlag == TRUE || createFlag == TRUE)
goto flagError;
listFlag = TRUE;
break;
case 'x':
if (listFlag == TRUE || createFlag == TRUE)
goto flagError;
extractFlag = TRUE;
break;
case 'c':
if (extractFlag == TRUE || listFlag == TRUE)
goto flagError;
createFlag = TRUE;
break;
case 'x':
if (listFlag == TRUE || createFlag == TRUE)
goto flagError;
extractFlag = TRUE;
break;
case 't':
if (extractFlag == TRUE || createFlag == TRUE)
goto flagError;
listFlag = TRUE;
break;
case 'v':
verboseFlag = TRUE;
break;
case 'O':
tostdoutFlag = TRUE;
tarName = "-";
break;
case 'f':
if (--argc == 0) {
fatalError( "Option requires an argument: No file specified\n");
}
if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
fatalError( "Option requires an argument: No file specified\n");
if (!strcmp(tarName, "-") && createFlag == TRUE)
tostdoutFlag = TRUE;
stopIt=TRUE;
break;
case '-':
#if defined BB_FEATURE_TAR_EXCLUDE
case 'e':
if (strcmp(*argv, "-exclude")==0) {
if (--argc == 0) {
fatalError( "Option requires an argument: No file specified\n");
}
excludeList=realloc( excludeList, sizeof(char**) * (excludeListSize+2));
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
excludeList[excludeListSize] = *(++argv);
/* Remove leading "/"s */
if (*excludeList[excludeListSize] =='/') {
if (*excludeList[excludeListSize] =='/')
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
}
if (excludeList[excludeListSize++] == NULL)
fatalError( "Option requires an argument: No file specified\n");
/* Tack a NULL onto the end of the list */
excludeList[excludeListSize] = NULL;
excludeList[++excludeListSize] = NULL;
stopIt=TRUE;
break;
}
#endif
break;
case '-':
break;
default:
fatalError( "Unknown tar flag '%c'\n"
"Try `tar --help' for more information\n", **argv);
usage(tar_usage);
}
++(*argv);
}
}
@@ -264,8 +238,9 @@ extern int tar_main(int argc, char **argv)
#else
exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
#endif
} else {
exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
}
if (listFlag == TRUE || extractFlag == TRUE) {
exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, &argv[optind], excludeList));
}
flagError:
@@ -297,11 +272,14 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
/* Open the file to be written, if a file is supposed to be written */
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, header->mode & ~S_IFMT)) < 0)
errorMsg(io_error, header->name, strerror(errno));
/* Create the path to the file, just in case it isn't there...
* This should not screw up path permissions or anything. */
createPath(header->name, 0777);
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
header->mode & ~S_IFMT)) < 0) {
errorMsg(io_error, header->name, strerror(errno));
return( FALSE);
}
}
/* Write out the file, if we are supposed to be doing that */
@@ -319,7 +297,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
}
if ( (readSize = fullRead(header->tarFd, buffer, readSize)) <= 0 ) {
/* Tarball seems to have a problem */
errorMsg("tar: Unexpected EOF in archive\n");
errorMsg("Unexpected EOF in archive\n");
return( FALSE);
}
if ( readSize < writeSize )
@@ -357,7 +335,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE);
if (createPath(header->name, header->mode) != TRUE) {
errorMsg("tar: %s: Cannot mkdir: %s\n",
errorMsg("%s: Cannot mkdir: %s\n",
header->name, strerror(errno));
return( FALSE);
}
@@ -377,7 +355,7 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE);
if (link(header->linkname, header->name) < 0) {
errorMsg("tar: %s: Cannot create hard link to '%s': %s\n",
errorMsg("%s: Cannot create hard link to '%s': %s\n",
header->name, header->linkname, strerror(errno));
return( FALSE);
}
@@ -395,7 +373,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
#ifdef S_ISLNK
if (symlink(header->linkname, header->name) < 0) {
errorMsg("tar: %s: Cannot create symlink to '%s': %s\n",
errorMsg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname, strerror(errno));
return( FALSE);
}
@@ -410,7 +388,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
/* Do not change permissions or date on symlink,
* since it changes the pointed to file instead. duh. */
#else
errorMsg("tar: %s: Cannot create symlink to '%s': %s\n",
errorMsg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname,
"symlinks not supported");
#endif
@@ -425,13 +403,13 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
errorMsg("tar: %s: Cannot mknod: %s\n",
errorMsg("%s: Cannot mknod: %s\n",
header->name, strerror(errno));
return( FALSE);
}
} else if (S_ISFIFO(header->mode)) {
if (mkfifo(header->name, header->mode) < 0) {
errorMsg("tar: %s: Cannot mkfifo: %s\n",
errorMsg("%s: Cannot mkfifo: %s\n",
header->name, strerror(errno));
return( FALSE);
}
@@ -479,7 +457,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
++*(header->name);
if (alreadyWarned == FALSE) {
errorMsg("tar: Removing leading '/' from member names\n");
errorMsg("Removing leading '/' from member names\n");
alreadyWarned = TRUE;
}
}
@@ -517,15 +495,15 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
* If the list is empty than all files are extracted or listed.
*/
static int readTarFile(const char* tarName, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** excludeList)
int tostdoutFlag, int verboseFlag, char** extractList,
char** excludeList)
{
int status, tarFd=-1;
int errorFlag=FALSE;
int skipNextHeaderFlag=FALSE;
TarHeader rawHeader;
TarInfo header;
#if defined BB_FEATURE_TAR_EXCLUDE
char** tmpList;
#endif
/* Open the tar file for reading. */
if (!strcmp(tarName, "-"))
@@ -544,7 +522,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
/* Read the tar file, and iterate over it one file at a time */
while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
/* First, try to read the header */
/* Try to read the header */
if ( readTarHeader(&rawHeader, &header) == FALSE ) {
if ( *(header.name) == '\0' ) {
goto endgame;
@@ -558,6 +536,19 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
goto endgame;
header.tarFd = tarFd;
/* Skip funky extra GNU headers that precede long files */
if ( (header.type == GNULONGNAME) || (header.type == GNULONGLINK) ) {
skipNextHeaderFlag=TRUE;
tarExtractRegularFile(&header, FALSE, FALSE);
continue;
}
if ( skipNextHeaderFlag == TRUE ) {
skipNextHeaderFlag=FALSE;
errorMsg(name_longer_then_foo, NAME_SIZE);
tarExtractRegularFile(&header, FALSE, FALSE);
continue;
}
#if defined BB_FEATURE_TAR_EXCLUDE
{
int skipFlag=FALSE;
@@ -584,62 +575,89 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
continue;
}
#endif
/* Special treatment if the list (-t) flag is on */
if (verboseFlag == TRUE && extractFlag == FALSE) {
int len, len1;
char buf[35];
struct tm *tm = localtime (&(header.mtime));
len=printf("%s ", modeString(header.mode));
memset(buf, 0, 8*sizeof(char));
my_getpwuid(buf, header.uid);
if (! *buf)
len+=printf("%d", header.uid);
else
len+=printf("%s", buf);
memset(buf, 0, 8*sizeof(char));
my_getgrgid(buf, header.gid);
if (! *buf)
len+=printf("/%-d ", header.gid);
else
len+=printf("/%-s ", buf);
if (header.type==CHRTYPE || header.type==BLKTYPE) {
len1=snprintf(buf, sizeof(buf), "%ld,%-ld ",
header.devmajor, header.devminor);
} else {
len1=snprintf(buf, sizeof(buf), "%d ", header.size);
if (*extractList != NULL) {
int skipFlag = TRUE;
for (tmpList = extractList; *tmpList != NULL; tmpList++) {
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
header.name[strlen(header.name)-1]=='/'
&& strncmp( *tmpList, header.name,
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
/* If it is a regular file, pretend to extract it with
* the extractFlag set to FALSE, so the junk in the tarball
* is properly skipped over */
skipFlag = FALSE;
break;
}
}
/* Jump through some hoops to make the columns match up */
for(;(len+len1)<31;len++)
printf(" ");
printf(buf);
/* Use ISO 8610 time format */
if (tm) {
printf ("%04d-%02d-%02d %02d:%02d:%02d ",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
/* There are not the droids you're looking for, move along */
if (skipFlag == TRUE) {
if ( header.type==REGTYPE || header.type==REGTYPE0 )
tarExtractRegularFile(&header, FALSE, FALSE);
continue;
}
}
/* List contents if we are supposed to do that */
if (verboseFlag == TRUE || listFlag == TRUE) {
/* Now the normal listing */
if (listFlag == TRUE) {
/* Special treatment if the list (-t) flag is on */
if (verboseFlag == TRUE) {
int len, len1;
char buf[35];
struct tm *tm = localtime (&(header.mtime));
len=printf("%s ", modeString(header.mode));
memset(buf, 0, 8*sizeof(char));
my_getpwuid(buf, header.uid);
if (! *buf)
len+=printf("%d", header.uid);
else
len+=printf("%s", buf);
memset(buf, 0, 8*sizeof(char));
my_getgrgid(buf, header.gid);
if (! *buf)
len+=printf("/%-d ", header.gid);
else
len+=printf("/%-s ", buf);
if (header.type==CHRTYPE || header.type==BLKTYPE) {
len1=snprintf(buf, sizeof(buf), "%ld,%-ld ",
header.devmajor, header.devminor);
} else {
len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
}
/* Jump through some hoops to make the columns match up */
for(;(len+len1)<31;len++)
printf(" ");
printf(buf);
/* Use ISO 8610 time format */
if (tm) {
printf ("%04d-%02d-%02d %02d:%02d:%02d ",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
}
printf("%s", header.name);
}
if (verboseFlag == TRUE && listFlag == TRUE) {
/* If this is a link, say so */
if (header.type==LNKTYPE)
printf(" link to %s", header.linkname);
else if (header.type==SYMTYPE)
printf(" -> %s", header.linkname);
}
if (verboseFlag == TRUE || listFlag == TRUE) {
if (verboseFlag == TRUE) {
if (header.type==LNKTYPE) /* If this is a link, say so */
printf(" link to %s", header.linkname);
else if (header.type==SYMTYPE)
printf(" -> %s", header.linkname);
}
printf("\n");
}
/* Remove any clutter lying in our way */
unlink( header.name);
/* List contents if we are supposed to do that */
if (verboseFlag == TRUE && extractFlag == TRUE) {
/* Now the normal listing */
FILE *vbFd = stdout;
if (tostdoutFlag == TRUE) // If the archive goes to stdout, verbose to stderr
vbFd = stderr;
fprintf(vbFd, "%s\n", header.name);
}
/* Remove files if we would overwrite them */
if (extractFlag == TRUE && tostdoutFlag == FALSE)
unlink(header.name);
/* If we got here, we can be certain we have a legitimate
* header to work with. So work with it. */
@@ -671,7 +689,15 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
if (tarExtractSpecial( &header, extractFlag, tostdoutFlag)==FALSE)
errorFlag=TRUE;
break;
#if 0
/* Handled earlier */
case GNULONGNAME:
case GNULONGLINK:
skipNextHeaderFlag=TRUE;
break;
#endif
default:
errorMsg("Unknown file type '%c' in tar file\n", header.type);
close( tarFd);
return( FALSE);
}
@@ -683,7 +709,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
return ( FALSE);
}
else if (errorFlag==TRUE) {
errorMsg( "tar: Error exit delayed from previous errors\n");
errorMsg( "Error exit delayed from previous errors\n");
return( FALSE);
} else
return( status);
@@ -693,7 +719,7 @@ endgame:
close( tarFd);
if ( *(header.name) == '\0' ) {
if (errorFlag==TRUE)
errorMsg( "tar: Error exit delayed from previous errors\n");
errorMsg( "Error exit delayed from previous errors\n");
else
return( TRUE);
}
@@ -764,13 +790,13 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
#endif
const unsigned char *cp = (const unsigned char *) &header;
ssize_t size = sizeof(struct TarHeader);
memset( &header, 0, size);
if (*fileName=='/') {
static int alreadyWarned=FALSE;
if (alreadyWarned==FALSE) {
errorMsg("tar: Removing leading '/' from member names\n");
errorMsg("Removing leading '/' from member names\n");
alreadyWarned=TRUE;
}
strncpy(header.name, fileName+1, sizeof(header.name));
@@ -815,12 +841,15 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
/* WARNING/NOTICE: I break Hard Links */
if (S_ISLNK(statbuf->st_mode)) {
int link_size=0;
char buffer[BUFSIZ];
header.typeflag = SYMTYPE;
if ( readlink(fileName, buffer, sizeof(buffer) - 1) < 0) {
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
if ( link_size < 0) {
errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
return ( FALSE);
}
buffer[link_size] = '\0';
strncpy(header.linkname, buffer, sizeof(header.linkname));
} else if (S_ISDIR(statbuf->st_mode)) {
header.typeflag = DIRTYPE;
@@ -839,7 +868,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
header.typeflag = REGTYPE;
putOctal(header.size, sizeof(header.size), statbuf->st_size);
} else {
errorMsg("tar: %s: Unknown file type\n", fileName);
errorMsg("%s: Unknown file type\n", fileName);
return ( FALSE);
}
@@ -864,8 +893,12 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
write(tbInfo->tarFd, "\0", 1);
}
/* Now do the verbose thing (or not) */
if (tbInfo->verboseFlag==TRUE)
fprintf(stdout, "%s\n", header.name);
if (tbInfo->verboseFlag==TRUE) {
FILE *vbFd = stdout;
if (tbInfo->tarFd == fileno(stdout)) // If the archive goes to stdout, verbose to stderr
vbFd = stderr;
fprintf(vbFd, "%s\n", header.name);
}
return ( TRUE);
}
@@ -877,7 +910,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
/* It is against the rules to archive a socket */
if (S_ISSOCK(statbuf->st_mode)) {
errorMsg("tar: %s: socket ignored\n", fileName);
errorMsg("%s: socket ignored\n", fileName);
return( TRUE);
}
@@ -886,10 +919,15 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
* the new tarball */
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
tbInfo->statBuf.st_ino == statbuf->st_ino) {
errorMsg("tar: %s: file is the archive; skipping\n", fileName);
errorMsg("%s: file is the archive; skipping\n", fileName);
return( TRUE);
}
if (strlen(fileName) >= NAME_SIZE) {
errorMsg(name_longer_then_foo, NAME_SIZE);
return ( TRUE);
}
if (writeTarHeader(tbInfo, fileName, statbuf)==FALSE) {
return( FALSE);
}
@@ -902,7 +940,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
/* open the file we want to archive, and make sure all is well */
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
errorMsg("tar: %s: Cannot open: %s\n", fileName, strerror(errno));
errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno));
return( FALSE);
}
@@ -940,7 +978,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
/* Make sure there is at least one file to tar up. */
if (argc <= 0)
fatalError("tar: Cowardly refusing to create an empty archive\n");
fatalError("Cowardly refusing to create an empty archive\n");
/* Open the tar file for writing. */
if (tostdoutFlag == TRUE)
@@ -948,7 +986,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (tbInfo.tarFd < 0) {
errorMsg( "tar: Error opening '%s': %s\n", tarName, strerror(errno));
errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
return ( FALSE);
}
tbInfo.excludeList=excludeList;
@@ -982,7 +1020,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
/* Hang up the tools, close up shop, head home */
close(tarFd);
if (errorFlag == TRUE) {
errorMsg("tar: Error exit delayed from previous errors\n");
errorMsg("Error exit delayed from previous errors\n");
return(FALSE);
}
return( TRUE);
+16 -12
View File
@@ -21,25 +21,29 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int basename_main(int argc, char **argv)
{
char* s, *s1;
int m, n;
char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("basename [file ...]\n");
usage(basename_usage);
}
argv++;
s1=*argv+strlen(*argv)-1;
while (s1 && *s1 == '/') {
*s1 = '\0';
s1=*argv+strlen(*argv)-1;
}
s = strrchr(*argv, '/');
printf("%s\n", (s)? s + 1 : *argv);
exit(TRUE);
}
s = get_last_path_component(*argv);
if (argc>2) {
argv++;
n = strlen(*argv);
m = strlen(s);
if (m>=n && strncmp(s+m-n, *argv, n)==0)
s[m-n] = '\0';
}
printf("%s\n", s);
return(TRUE);
}
+292 -162
View File
@@ -1,366 +1,499 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
static int been_there_done_that = 0;
/* It has been alledged that doing such things can
* help reduce binary size when staticly linking,
* of course with glibc, this is unlikely as long
* as we use things like printf -- perhaps a printf
* replacement may be in order
*/
#if 0
void exit(int status) __attribute__ ((noreturn));
void exit(int status)
{
_exit(status);
};
void abort(void) __attribute__ ((__noreturn__));
void abort(void)
{
_exit(0);
};
int atexit(void (*__func) (void))
{
_exit(0);
};
void *__libc_stack_end;
const struct BB_applet applets[] = {
#ifdef BB_AR
{"ar", ar_main, _BB_DIR_USR_BIN, ar_usage},
#endif
static const struct Applet applets[] = {
#ifdef BB_BASENAME
{"basename", basename_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_BUSYBOX
{"busybox", busybox_main, _BB_DIR_BIN},
#endif
#ifdef BB_BLOCK_DEVICE
{"block_device", block_device_main, _BB_DIR_SBIN},
{"basename", basename_main, _BB_DIR_USR_BIN, basename_usage},
#endif
{"busybox", busybox_main, _BB_DIR_BIN, NULL},
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
{"cat", cat_main, _BB_DIR_BIN, cat_usage},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
{"chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage},
#endif
#ifdef BB_CLEAR
{"clear", clear_main, _BB_DIR_USR_BIN},
{"clear", clear_main, _BB_DIR_USR_BIN, clear_usage},
#endif
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN},
{"chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage},
#endif
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
{"cp", cp_mv_main, _BB_DIR_BIN, cp_usage},
#endif
#ifdef BB_CUT
{"cut", cut_main, _BB_DIR_USR_BIN, cut_usage},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
{"date", date_main, _BB_DIR_BIN, date_usage},
#endif
#ifdef BB_DC
{"dc", dc_main, _BB_DIR_USR_BIN, dc_usage},
#endif
#ifdef BB_DD
{"dd", dd_main, _BB_DIR_BIN},
{"dd", dd_main, _BB_DIR_BIN, dd_usage},
#endif
#ifdef BB_DF
{"df", df_main, _BB_DIR_BIN},
{"df", df_main, _BB_DIR_BIN, df_usage},
#endif
#ifdef BB_DIRNAME
{"dirname", dirname_main, _BB_DIR_USR_BIN},
{"dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage},
#endif
#ifdef BB_DMESG
{"dmesg", dmesg_main, _BB_DIR_BIN},
{"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage},
#endif
#ifdef BB_DOS2UNIX
{"dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage},
#endif
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
{"du", du_main, _BB_DIR_USR_BIN, du_usage},
#endif
#ifdef BB_DUMPKMAP
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage},
#endif
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
{"echo", echo_main, _BB_DIR_BIN, echo_usage},
#endif
#ifdef BB_EXPR
{"expr", expr_main, _BB_DIR_USR_BIN, expr_usage},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
{"false", false_main, _BB_DIR_BIN, false_usage},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
{"fbset", fbset_main, _BB_DIR_USR_SBIN, NULL},
#endif
#ifdef BB_FDFLUSH
{"fdflush", fdflush_main, _BB_DIR_BIN},
{"fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage},
#endif
#ifdef BB_FIND
{"find", find_main, _BB_DIR_USR_BIN},
{"find", find_main, _BB_DIR_USR_BIN, find_usage},
#endif
#ifdef BB_FREE
{"free", free_main, _BB_DIR_USR_BIN},
{"free", free_main, _BB_DIR_USR_BIN, free_usage},
#endif
#ifdef BB_FREERAMDISK
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage},
#endif
#ifdef BB_DEALLOCVT
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage},
#endif
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage},
#endif
#ifdef BB_GETOPT
{"getopt", getopt_main, _BB_DIR_BIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
{"grep", grep_main, _BB_DIR_BIN, grep_usage},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
{"gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
{"gzip", gzip_main, _BB_DIR_BIN, gzip_usage},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
{"halt", halt_main, _BB_DIR_SBIN, halt_usage},
#endif
#ifdef BB_HEAD
{"head", head_main, _BB_DIR_BIN},
{"head", head_main, _BB_DIR_USR_BIN, head_usage},
#endif
#ifdef BB_HOSTID
{"hostid", hostid_main, _BB_DIR_USR_BIN},
{"hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage},
#endif
#ifdef BB_HOSTNAME
{"hostname", hostname_main, _BB_DIR_BIN},
{"hostname", hostname_main, _BB_DIR_BIN, hostname_usage},
#endif
#ifdef BB_ID
{"id", id_main, _BB_DIR_USR_BIN, id_usage},
#endif
#ifdef BB_INIT
{"init", init_main, _BB_DIR_SBIN},
{"init", init_main, _BB_DIR_SBIN, NULL},
#endif
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
{"insmod", insmod_main, _BB_DIR_SBIN, insmod_usage},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
{"kill", kill_main, _BB_DIR_BIN, kill_usage},
#endif
#ifdef BB_KILLALL
{"killall", kill_main, _BB_DIR_USR_BIN},
{"killall", kill_main, _BB_DIR_USR_BIN, kill_usage},
#endif
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
{"length", length_main, _BB_DIR_USR_BIN, length_usage},
#endif
#ifdef BB_LINUXRC
{"linuxrc", init_main, _BB_DIR_ROOT},
{"linuxrc", init_main, _BB_DIR_ROOT, NULL},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
{"ln", ln_main, _BB_DIR_BIN, ln_usage},
#endif
#ifdef BB_LOADACM
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
{"loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage},
#endif
#ifdef BB_LOADFONT
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
{"loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage},
#endif
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
{"loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
{"logger", logger_main, _BB_DIR_USR_BIN, logger_usage},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
{"logname", logname_main, _BB_DIR_USR_BIN, logname_usage},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
{"ls", ls_main, _BB_DIR_BIN, ls_usage},
#endif
#ifdef BB_LSMOD
{"lsmod", lsmod_main, _BB_DIR_SBIN},
{"lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage},
#endif
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
{"makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage},
#endif
#ifdef BB_MATH
{"math", math_main, _BB_DIR_USR_BIN},
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
{"mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage},
#endif
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
{"mknod", mknod_main, _BB_DIR_BIN, mknod_usage},
#endif
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
{"mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage},
#endif
#ifdef BB_MNC
{"mnc", mnc_main, _BB_DIR_USR_BIN},
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage},
#endif
#ifdef BB_NC
{"nc", nc_main, _BB_DIR_USR_BIN, nc_usage},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
{"more", more_main, _BB_DIR_BIN, more_usage},
#endif
#ifdef BB_MOUNT
{"mount", mount_main, _BB_DIR_BIN},
{"mount", mount_main, _BB_DIR_BIN, mount_usage},
#endif
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
{"mt", mt_main, _BB_DIR_BIN, mt_usage},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
{"mv", cp_mv_main, _BB_DIR_BIN, mv_usage},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
{"nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage},
#endif
#ifdef BB_PING
{"ping", ping_main, _BB_DIR_BIN},
{"ping", ping_main, _BB_DIR_BIN, ping_usage},
#endif
#ifdef BB_POWEROFF
{"poweroff", poweroff_main, _BB_DIR_SBIN},
{"poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage},
#endif
#ifdef BB_PRINTF
{"printf", printf_main, _BB_DIR_USR_BIN},
{"printf", printf_main, _BB_DIR_USR_BIN, printf_usage},
#endif
#ifdef BB_PS
{"ps", ps_main, _BB_DIR_BIN},
{"ps", ps_main, _BB_DIR_BIN, ps_usage},
#endif
#ifdef BB_PWD
{"pwd", pwd_main, _BB_DIR_BIN},
{"pwd", pwd_main, _BB_DIR_BIN, pwd_usage},
#endif
#ifdef BB_RDATE
{"rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage},
#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN},
{"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage},
#endif
#ifdef BB_RENICE
{"renice", renice_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_RESET
{"reset", reset_main, _BB_DIR_USR_BIN, reset_usage},
#endif
#ifdef BB_RM
{"rm", rm_main, _BB_DIR_BIN},
{"rm", rm_main, _BB_DIR_BIN, rm_usage},
#endif
#ifdef BB_RMDIR
{"rmdir", rmdir_main, _BB_DIR_BIN},
{"rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage},
#endif
#ifdef BB_RMMOD
{"rmmod", rmmod_main, _BB_DIR_SBIN},
{"rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage},
#endif
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
{"sed", sed_main, _BB_DIR_BIN, sed_usage},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
{"sh", shell_main, _BB_DIR_BIN, shell_usage},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
{"sleep", sleep_main, _BB_DIR_BIN, sleep_usage},
#endif
#ifdef BB_SORT
{"sort", sort_main, _BB_DIR_BIN},
{"sort", sort_main, _BB_DIR_USR_BIN, sort_usage},
#endif
#ifdef BB_SYNC
{"sync", sync_main, _BB_DIR_BIN},
{"sync", sync_main, _BB_DIR_BIN, sync_usage},
#endif
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
{"syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
{"swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage},
#endif
#ifdef BB_SWAPONOFF
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
{"swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage},
#endif
#ifdef BB_TAIL
{"tail", tail_main, _BB_DIR_USR_BIN},
{"tail", tail_main, _BB_DIR_USR_BIN, tail_usage},
#endif
#ifdef BB_TAR
{"tar", tar_main, _BB_DIR_BIN},
{"tar", tar_main, _BB_DIR_BIN, tar_usage},
#endif
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
{"telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
{"test", test_main, _BB_DIR_USR_BIN, test_usage},
#endif
#ifdef BB_TEE
{"tee", tee_main, _BB_DIR_BIN},
{"tee", tee_main, _BB_DIR_USR_BIN, tee_usage},
#endif
#ifdef BB_TOUCH
{"touch", touch_main, _BB_DIR_USR_BIN},
{"touch", touch_main, _BB_DIR_BIN, touch_usage},
#endif
#ifdef BB_TR
{"tr", tr_main, _BB_DIR_USR_BIN},
{"tr", tr_main, _BB_DIR_USR_BIN, tr_usage},
#endif
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
{"true", true_main, _BB_DIR_BIN, true_usage},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
{"tty", tty_main, _BB_DIR_USR_BIN, tty_usage},
#endif
#ifdef BB_UMOUNT
{"umount", umount_main, _BB_DIR_BIN},
{"umount", umount_main, _BB_DIR_BIN, umount_usage},
#endif
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
{"uname", uname_main, _BB_DIR_BIN, uname_usage},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_USR_BIN},
{"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage},
#endif
#ifdef BB_UNIX2DOS
{"unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage},
#endif
#ifdef BB_UNRPM
{"unrpm", unrpm_main, _BB_DIR_USR_BIN, unrpm_usage},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
{"update", update_main, _BB_DIR_SBIN, update_usage},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
{"uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage},
#endif
#ifdef BB_UUENCODE
{"uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage},
#endif
#ifdef BB_UUDECODE
{"uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
{"usleep", usleep_main, _BB_DIR_BIN, usleep_usage},
#endif
#ifdef BB_WC
{"wc", wc_main, _BB_DIR_USR_BIN},
{"wc", wc_main, _BB_DIR_USR_BIN, wc_usage},
#endif
#ifdef BB_WGET
{"wget", wget_main, _BB_DIR_USR_BIN, wget_usage},
#endif
#ifdef BB_WHICH
{"which", which_main, _BB_DIR_USR_BIN, which_usage},
#endif
#ifdef BB_WHOAMI
{"whoami", whoami_main, _BB_DIR_USR_BIN},
{"whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage},
#endif
#ifdef BB_XARGS
{"xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage},
#endif
#ifdef BB_YES
{"yes", yes_main, _BB_DIR_USR_BIN},
{"yes", yes_main, _BB_DIR_USR_BIN, yes_usage},
#endif
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
{"zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
{"[", test_main, _BB_DIR_USR_BIN, test_usage},
#endif
{0}
{0,NULL,0,NULL}
};
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
"/",
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
};
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/*
* Where in the filesystem is this busybox?
* [return]
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
errorMsg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
}
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
int i;
int rc;
if (use_symbolic_links) Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf ( command, "%s/%s",
install_dir[applets[i].location],
applets[i].name);
rc = Link(busybox, command);
if (rc) {
errorMsg("%s: %s\n", command, strerror(errno));
}
}
}
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
char *s;
char *name;
const struct Applet *a = applets;
const char *s;
const struct BB_applet *a = applets;
applet_name = "busybox";
for (s = name = argv[0]; *s != '\0';) {
#ifdef BB_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
* If someone has a cleaner approach, by all means implement it.
*/
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
int use_symbolic_links = 0;
int rc = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
if (argc > 2) {
if ((strcmp(argv[2], "-s") == 0)) {
use_symbolic_links = 1;
}
}
/* link */
busybox = busybox_fullpath();
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
} else {
rc = 1;
}
return rc;
}
#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
name = s;
applet_name = s;
}
*argv = name;
*argv = (char*)applet_name;
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
while (a->name != 0) {
if (strcmp(name, a->name) == 0) {
int status;
status = ((*(a->main)) (argc, argv));
if (status < 0) {
fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
}
fprintf(stderr, "\n");
exit(status);
if (strcmp(applet_name, a->name) == 0) {
if (a->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(a->usage);
exit(((*(a->main)) (argc, argv)));
}
a++;
}
exit(busybox_main(argc, argv));
return(busybox_main(argc, argv));
}
@@ -372,18 +505,16 @@ int busybox_main(int argc, char **argv)
argv++;
if (been_there_done_that == 1 || argc < 1) {
const struct Applet *a = applets;
const struct BB_applet *a = applets;
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
fprintf(stderr, " or: [function] [arguments]...\n\n");
fprintf(stderr,
fprintf(stderr, "%s\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use, and BusyBox\n"
"\twill act like whatever it was invoked as.\n");
fprintf(stderr, "\nCurrently defined functions:\n");
"\twill act like whatever it was invoked as.\n"
"\nCurrently defined functions:\n", full_version);
while (a->name != 0) {
col +=
@@ -396,11 +527,10 @@ int busybox_main(int argc, char **argv)
}
fprintf(stderr, "\n\n");
exit(-1);
} else {
/* If we've already been here once, exit now */
been_there_done_that = 1;
return (main(argc, argv));
}
/* If we've already been here once, exit now */
been_there_done_that = 1;
return (main(argc, argv));
}
/*
+241 -47
View File
@@ -24,15 +24,24 @@
#ifndef _BB_INTERNAL_H_
#define _BB_INTERNAL_H_ 1
#include "busybox.def.h"
#include "Config.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
//#include <sys/param.h>
#include <sys/param.h>
#include <mntent.h>
#include <regex.h>
/* for the _syscall() macros */
#include <sys/syscall.h>
#include <linux/unistd.h>
/* Some useful definitions */
@@ -52,6 +61,36 @@
#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7'))
#define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '['))
/* Macros for min/max. */
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
/* I don't like nested includes, but the string and io functions are used
* too often
*/
#include <stdio.h>
#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
# include <string.h>
# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
# include <memory.h>
# endif
# define memzero(s, n) memset ((void *)(s), 0, (n))
#else
# include <strings.h>
# define strchr index
# define strrchr rindex
# define memcpy(d, s, n) bcopy((s), (d), (n))
# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
# define memzero(s, n) bzero((s), (n))
#endif
enum Location {
_BB_DIR_ROOT = 0,
_BB_DIR_BIN,
@@ -60,30 +99,39 @@ enum Location {
_BB_DIR_USR_SBIN
};
struct Applet {
struct BB_applet {
const char* name;
int (*main)(int argc, char** argv);
enum Location location;
const char* usage;
};
/* From busybox.c */
extern const struct BB_applet applets[];
extern int ar_main(int argc, char **argv);
extern int basename_main(int argc, char **argv);
extern int bogomips_main(int argc, char **argv);
extern int busybox_main(int argc, char** argv);
extern int block_device_main(int argc, char** argv);
extern int cat_main(int argc, char** argv);
extern int cp_mv_main(int argc, char** argv);
extern int chmod_chown_chgrp_main(int argc, char** argv);
extern int chroot_main(int argc, char** argv);
extern int chvt_main(int argc, char** argv);
extern int clear_main(int argc, char** argv);
extern int cp_mv_main(int argc, char** argv);
extern int cut_main(int argc, char** argv);
extern int date_main(int argc, char** argv);
extern int dc_main(int argc, char** argv);
extern int dd_main(int argc, char** argv);
extern int dirname_main(int argc, char** argv);
extern int deallocvt_main(int argc, char** argv);
extern int df_main(int argc, char** argv);
extern int dmesg_main(int argc, char** argv);
extern int dos2unix_main(int argc, char** argv);
extern int du_main(int argc, char** argv);
extern int dumpkmap_main(int argc, char** argv);
extern int dutmp_main(int argc, char** argv);
extern int echo_main(int argc, char** argv);
extern int expr_main(int argc, char** argv);
extern int false_main(int argc, char** argv);
extern int fbset_main(int argc, char** argv);
extern int fdisk_main(int argc, char** argv);
@@ -92,6 +140,7 @@ extern int fsck_minix_main(int argc, char **argv);
extern int find_main(int argc, char** argv);
extern int free_main(int argc, char** argv);
extern int freeramdisk_main(int argc, char** argv);
extern int getopt_main(int argc, char** argv);
extern int grep_main(int argc, char** argv);
extern int gunzip_main (int argc, char** argv);
extern int gzip_main(int argc, char** argv);
@@ -99,6 +148,7 @@ extern int halt_main(int argc, char** argv);
extern int head_main(int argc, char** argv);
extern int hostid_main(int argc, char** argv);
extern int hostname_main(int argc, char** argv);
extern int id_main(int argc, char** argv);
extern int init_main(int argc, char** argv);
extern int insmod_main(int argc, char** argv);
extern int kill_main(int argc, char** argv);
@@ -113,13 +163,14 @@ extern int logname_main(int argc, char **argv);
extern int ls_main(int argc, char** argv);
extern int lsmod_main(int argc, char** argv);
extern int makedevs_main(int argc, char** argv);
extern int math_main(int argc, char** argv);
extern int md5sum_main(int argc, char** argv);
extern int mkdir_main(int argc, char** argv);
extern int mkfifo_main(int argc, char **argv);
extern int mkfs_minix_main(int argc, char **argv);
extern int mknod_main(int argc, char** argv);
extern int mkswap_main(int argc, char** argv);
extern int mnc_main(int argc, char** argv);
extern int mktemp_main(int argc, char **argv);
extern int nc_main(int argc, char** argv);
extern int more_main(int argc, char** argv);
extern int mount_main(int argc, char** argv);
extern int mt_main(int argc, char** argv);
@@ -129,12 +180,16 @@ extern int poweroff_main(int argc, char **argv);
extern int printf_main(int argc, char** argv);
extern int ps_main(int argc, char** argv);
extern int pwd_main(int argc, char** argv);
extern int rdate_main(int argc, char** argv);
extern int reboot_main(int argc, char** argv);
extern int renice_main(int argc, char** argv);
extern int reset_main(int argc, char** argv);
extern int rm_main(int argc, char** argv);
extern int rmdir_main(int argc, char **argv);
extern int rmmod_main(int argc, char** argv);
extern int sed_main(int argc, char** argv);
extern int sfdisk_main(int argc, char** argv);
extern int setkeycodes_main(int argc, char** argv);
extern int shell_main(int argc, char** argv);
extern int sleep_main(int argc, char** argv);
extern int sort_main(int argc, char** argv);
@@ -154,14 +209,133 @@ extern int tryopen_main(int argc, char** argv);
extern int tty_main(int argc, char** argv);
extern int umount_main(int argc, char** argv);
extern int uname_main(int argc, char** argv);
extern int uptime_main(int argc, char** argv);
extern int uniq_main(int argc, char** argv);
extern int unix2dos_main(int argc, char** argv);
extern int unrpm_main(int argc, char** argv);
extern int update_main(int argc, char** argv);
extern int uptime_main(int argc, char** argv);
extern int usleep_main(int argc, char** argv);
extern int uuencode_main(int argc, char** argv);
extern int uudecode_main(int argc, char** argv);
extern int wc_main(int argc, char** argv);
extern int wget_main(int argc, char** argv);
extern int which_main(int argc, char** argv);
extern int whoami_main(int argc, char** argv);
extern int xargs_main(int argc, char** argv);
extern int yes_main(int argc, char** argv);
extern const char ar_usage[];
extern const char basename_usage[];
extern const char cat_usage[];
extern const char chgrp_usage[];
extern const char chmod_usage[];
extern const char chown_usage[];
extern const char chroot_usage[];
extern const char chvt_usage[];
extern const char clear_usage[];
extern const char cp_usage[];
extern const char cut_usage[];
extern const char date_usage[];
extern const char dc_usage[];
extern const char dd_usage[];
extern const char deallocvt_usage[];
extern const char df_usage[];
extern const char dirname_usage[];
extern const char dmesg_usage[];
extern const char dos2unix_usage[];
extern const char du_usage[];
extern const char dumpkmap_usage[];
extern const char dutmp_usage[];
extern const char echo_usage[];
extern const char expr_usage[];
extern const char false_usage[];
extern const char fdflush_usage[];
extern const char find_usage[];
extern const char free_usage[];
extern const char freeramdisk_usage[];
extern const char fsck_minix_usage[];
extern const char grep_usage[];
extern const char gunzip_usage[];
extern const char gzip_usage[];
extern const char halt_usage[];
extern const char head_usage[];
extern const char hostid_usage[];
extern const char hostname_usage[];
extern const char id_usage[];
extern const char insmod_usage[];
extern const char kill_usage[];
extern const char killall_usage[];
extern const char length_usage[];
extern const char ln_usage[];
extern const char loadacm_usage[];
extern const char loadfont_usage[];
extern const char loadkmap_usage[];
extern const char logger_usage[];
extern const char logname_usage[];
extern const char ls_usage[];
extern const char lsmod_usage[];
extern const char makedevs_usage[];
extern const char md5sum_usage[];
extern const char mkdir_usage[];
extern const char mkfifo_usage[];
extern const char mkfs_minix_usage[];
extern const char mknod_usage[];
extern const char mkswap_usage[];
extern const char mktemp_usage[];
extern const char more_usage[];
extern const char mount_usage[];
extern const char mt_usage[];
extern const char mv_usage[];
extern const char nc_usage[];
extern const char nslookup_usage[];
extern const char ping_usage[];
extern const char poweroff_usage[];
extern const char printf_usage[];
extern const char ps_usage[];
extern const char pwd_usage[];
extern const char rdate_usage[];
extern const char reboot_usage[];
extern const char renice_usage[];
extern const char reset_usage[];
extern const char rm_usage[];
extern const char rmdir_usage[];
extern const char rmmod_usage[];
extern const char sed_usage[];
extern const char setkeycodes_usage[];
extern const char shell_usage[];
extern const char sleep_usage[];
extern const char sort_usage[];
extern const char swapoff_usage[];
extern const char swapon_usage[];
extern const char sync_usage[];
extern const char syslogd_usage[];
extern const char tail_usage[];
extern const char tar_usage[];
extern const char tee_usage[];
extern const char telnet_usage[];
extern const char test_usage[];
extern const char touch_usage[];
extern const char tr_usage[];
extern const char true_usage[];
extern const char tty_usage[];
extern const char umount_usage[];
extern const char uname_usage[];
extern const char uniq_usage[];
extern const char unix2dos_usage[];
extern const char unrpm_usage[];
extern const char update_usage[];
extern const char uptime_usage[];
extern const char usleep_usage[];
extern const char uudecode_usage[];
extern const char uuencode_usage[];
extern const char wc_usage[];
extern const char wget_usage[];
extern const char which_usage[];
extern const char whoami_usage[];
extern const char xargs_usage[];
extern const char yes_usage[];
extern const char *applet_name;
extern void usage(const char *usage) __attribute__ ((noreturn));
extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
@@ -182,8 +356,9 @@ int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void);
int copyFile(const char *srcName, const char *destName, int setModes,
int followLinks);
int copyFile(const char *srcName, const char *destName,
int setModes, int followLinks, int forceFlag);
int copySubFile(int srcFd, int dstFd, size_t remaining);
char *buildName(const char *dirName, const char *fileName);
int makeString(int argc, const char **argv, char *buf, int bufLen);
char *getChunk(int size);
@@ -195,16 +370,12 @@ int recursiveAction(const char *fileName, int recurse, int followLinks, int dept
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
void* userData);
const char* timeString(time_t timeVal);
extern int createPath (const char *name, int mode);
extern int parse_mode( const char* s, mode_t* theMode);
extern int get_kernel_revision(void);
extern uid_t my_getpwnam(char *name);
extern gid_t my_getgrnam(char *name);
extern void my_getpwuid(char* name, uid_t uid);
extern void my_getgrgid(char* group, gid_t gid);
extern int get_console_fd(char* tty_name);
extern struct mntent *findMountPoint(const char *name, const char *table);
extern void write_mtab(char* blockDevice, char* directory,
@@ -217,14 +388,34 @@ extern char *mtab_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern);
extern long getNum (const char *cp);
extern pid_t* findPidByName( char* pidName);
extern void *xmalloc (size_t size);
extern int find_real_root_device_name(char* name);
extern char *cstring_lineFromFile(FILE *f);
extern char *get_line_from_file(FILE *file);
extern void print_file(FILE *file);
extern int print_file_by_name(char *filename);
extern char process_escape_sequence(char **ptr);
extern char *get_last_path_component(char *path);
extern void xregcomp(regex_t *preg, const char *regex, int cflags);
#if defined BB_INIT || defined BB_SYSLOGD
extern int device_open(char *device, int mode);
#ifndef DMALLOC
extern void *xmalloc (size_t size);
extern void *xrealloc(void *old, size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
extern char *xstrdup (const char *s);
#endif
extern char *xstrndup (const char *s, int n);
/* These parse entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed embedded systems. */
extern long my_getpwnam(char *name);
extern long my_getgrnam(char *name);
extern void my_getpwuid(char *name, long uid);
extern void my_getgrgid(char *group, long gid);
extern long my_getpwnamegid(char *name);
extern int device_open(char *device, int mode);
#if defined BB_FEATURE_MOUNT_LOOP
extern int del_loop(const char *device);
extern int set_loop(const char *device, const char *file, int offset, int *loopro);
@@ -237,38 +428,41 @@ extern int vdprintf(int d, const char *format, va_list ap);
#endif
#if defined BB_NFSMOUNT
int nfsmount(const char *spec, const char *node, unsigned long *flags,
char **extra_opts, char **mount_opts, int running_bg);
int nfsmount(const char *spec, const char *node, int *flags,
char **extra_opts, char **mount_opts, int running_bg);
#endif
#if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX)
static inline int bit(char * addr,unsigned int nr)
{
return (addr[nr >> 3] & (1<<(nr & 7))) != 0;
}
static inline int setbit(char * addr,unsigned int nr)
{
int __res = bit(addr, nr);
addr[nr >> 3] |= (1<<(nr & 7));
return __res != 0;
}
static inline int clrbit(char * addr,unsigned int nr)
{
int __res = bit(addr, nr);
addr[nr >> 3] &= ~(1<<(nr & 7));
return __res != 0;
}
#endif /* inline bitops junk */
#ifndef RB_POWER_OFF
/* Stop system and switch power off if possable. */
/* Stop system and switch power off if possible. */
#define RB_POWER_OFF 0x4321fedc
#endif
/* Include our own copy of struct sysinfo to avoid binary compatability
* problems with Linux 2.4, which changed things. Grumble, grumble. */
struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
unsigned long totalhigh; /* Total high memory size */
unsigned long freehigh; /* Available high memory size */
unsigned int mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
};
extern int sysinfo (struct sysinfo* info);
/* Bit map related macros -- libc5 doens't provide these... sigh. */
#ifndef setbit
#define NBBY CHAR_BIT
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
#endif
#endif /* _BB_INTERNAL_H_ */
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Make busybox links list file.
DF="busybox.def.h"
DF="Config.h"
MF="busybox.c"
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
+2 -2
View File
@@ -3,8 +3,8 @@
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 ` \
gcc -E -dM busybox.def.h | \
gcc -E -dM Config.h | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr [:upper:] [:lower:] | sort
| tr '[:upper:]' '[:lower:]' | sort
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
+8 -7
View File
@@ -1,5 +1,5 @@
Name: busybox
Version: 0.43
Version: 0.47
Release: 1
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
@@ -10,12 +10,13 @@ Buildroot: /tmp/%{Name}-%{Version}
Source: %{Name}-%{Version}.tar.gz
%Description
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
provides a pretty complete POSIX environment in a very small package.
Just add a kernel, "ash" (Keith Almquists tiny Bourne shell clone), and
an editor such as "elvis-tiny" or "ae", and you have a full system. This
is makes an excellent environment for a "rescue" disk or any small or
embedded system.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for most of the utilities
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
tar, etc. BusyBox provides a fairly complete POSIX environment for any small
or emdedded system. The utilities in BusyBox generally have fewer options then
their full featured GNU cousins; however, the options that are provided behave
very much like their GNU counterparts.
%Prep
%setup -q -n %{Name}-%{Version}
+6 -24
View File
@@ -21,43 +21,25 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
static void print_file(FILE * file)
{
int c;
while ((c = getc(file)) != EOF)
putc(c, stdout);
fclose(file);
fflush(stdout);
}
extern int cat_main(int argc, char **argv)
{
FILE *file;
if (argc == 1) {
print_file(stdin);
exit(TRUE);
}
if (**(argv + 1) == '-') {
usage("cat [file ...]\n");
}
argc--;
while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
file = fopen(*argv, "r");
if (file == NULL) {
while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) {
print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) {
perror(*argv);
exit(FALSE);
}
print_file(file);
}
exit(TRUE);
return(TRUE);
}
/*
+31 -43
View File
@@ -22,9 +22,10 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_option
#define bb_need_too_few_args
#include "messages.c"
#include <stdio.h>
@@ -32,10 +33,9 @@
#include <pwd.h>
static uid_t uid = -1;
static gid_t gid = -1;
static long uid = -1;
static long gid = -1;
static int whichApp;
static char *invocationName = NULL;
static char *theMode = NULL;
@@ -43,23 +43,6 @@ static char *theMode = NULL;
#define CHOWN_APP 2
#define CHMOD_APP 3
static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n\n"
"Change the group membership of each FILE to GROUP.\n"
"\nOptions:\n\t-R\tchange files and directories recursively\n";
static const char chown_usage[] =
"chown [OPTION]... OWNER[<.|:>[GROUP] FILE...\n\n"
"Change the owner and/or group of each FILE to OWNER and/or GROUP.\n"
"\nOptions:\n\t-R\tchange files and directories recursively\n";
static const char chmod_usage[] =
"chmod [-R] MODE[,MODE]... FILE...\n\n"
"Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n"
"one or more of the letters rwxst.\n\n"
"\nOptions:\n\t-R\tchange files and directories recursively.\n";
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
switch (whichApp) {
@@ -81,7 +64,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
case CHMOD_APP:
/* Parse the specified modes */
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
fatalError( "%s: unknown mode: %s\n", invocationName, theMode);
fatalError( "unknown mode: %s\n", theMode);
}
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
@@ -93,13 +76,14 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
int chmod_chown_chgrp_main(int argc, char **argv)
{
int stopIt = FALSE;
int recursiveFlag = FALSE;
char *groupName;
char *p;
char *groupName=NULL;
char *p=NULL;
const char *appUsage;
whichApp = (strcmp(*argv, "chown") == 0)?
CHOWN_APP : (strcmp(*argv, "chmod") == 0)?
whichApp = (strcmp(applet_name, "chown") == 0)?
CHOWN_APP : (strcmp(applet_name, "chmod") == 0)?
CHMOD_APP : CHGRP_APP;
appUsage = (whichApp == CHOWN_APP)?
@@ -107,27 +91,32 @@ int chmod_chown_chgrp_main(int argc, char **argv)
if (argc < 2)
usage(appUsage);
invocationName = *argv;
argc--;
argv++;
/* Parse options */
while (**argv == '-') {
while (*++(*argv))
while (--argc >= 0 && *argv && (**argv == '-')) {
while (stopIt==FALSE && *++(*argv)) {
switch (**argv) {
case 'R':
recursiveFlag = TRUE;
break;
default:
fprintf(stderr, invalid_option, invocationName, **argv);
usage(appUsage);
case 'R':
recursiveFlag = TRUE;
break;
default:
theMode=*argv-1;
stopIt = TRUE;
}
argc--;
}
if (stopIt==TRUE)
break;
argv++;
}
if (argc == 0 || *argv == NULL) {
errorMsg(too_few_args);
}
if (whichApp == CHMOD_APP) {
theMode = *argv;
if (theMode==NULL)
theMode = *argv;
} else {
/* Find the selected group */
@@ -160,15 +149,14 @@ int chmod_chown_chgrp_main(int argc, char **argv)
if (*argv == p)
uid = my_getpwnam(*argv);
if (uid == -1) {
fatalError( "%s: unknown user name: %s\n",
invocationName, *argv);
fatalError( "unknown user name: %s\n", *argv);
}
}
}
/* Ok, ready to do the deed now */
if (argc <= 1) {
fatalError( "%s: too few arguments\n", invocationName);
if (argc < 1) {
fatalError(too_few_args);
}
while (argc-- > 1) {
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
@@ -178,7 +166,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
exit(TRUE);
bad_group:
fatalError( "%s: unknown group name: %s\n", invocationName, groupName);
fatalError( "unknown group name: %s\n", groupName);
}
/*
+12 -17
View File
@@ -22,20 +22,15 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n"
"Run COMMAND with root directory set to NEWROOT.\n";
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(chroot_usage);
}
@@ -43,27 +38,27 @@ int chroot_main(int argc, char **argv)
argv++;
if (chroot(*argv) || (chdir("/"))) {
fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno));
}
argc--;
argv++;
if (argc >= 1) {
fprintf(stderr, "command: %s\n", *argv);
prog = *argv;
execvp(*argv, argv);
} else {
char *prog;
#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
shell_main(argc, argv);
exit (0);
#endif
}
fprintf(stderr, "chroot: cannot execute %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
fatalError("cannot execute %s: %s\n", prog, strerror(errno));
}
+9 -10
View File
@@ -4,24 +4,23 @@
*
* busyboxed by Erik Andersen
*/
#include "internal.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
extern int getfd(void);
/* From <linux/vt.h> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
int chvt_main(int argc, char **argv)
{
int fd, num;
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n");
}
if ((argc != 2) || (**(argv + 1) == '-'))
usage (chvt_usage);
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num)) {
@@ -32,7 +31,7 @@ int chvt_main(int argc, char **argv)
perror("VT_WAITACTIVE");
exit(FALSE);
}
exit(TRUE);
return(TRUE);
}
+2 -2
View File
@@ -22,12 +22,12 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
exit(TRUE);
return(TRUE);
}
+126 -36
View File
@@ -31,7 +31,7 @@
terminal width. (more then one line.) However, history will.
*/
#include "internal.h"
#include "busybox.h"
#ifdef BB_FEATURE_SH_COMMAND_EDITING
#include <stdio.h>
@@ -39,7 +39,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <termio.h>
#include <sys/ioctl.h>
#include <ctype.h>
#include <signal.h>
@@ -53,12 +53,38 @@
static struct history *his_front = NULL; /* First element in command line list */
static struct history *his_end = NULL; /* Last element in command line list */
static struct termio old_term, new_term; /* Current termio and the previous termio before starting ash */
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS
#if #cpu(sparc)
# include <termio.h>
# define termios termio
# define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp)
# define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp)
#else
# include <termios.h>
# define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
# define getTermSettings(fd,argp) tcgetattr(fd, argp);
#endif
/* Current termio and the previous termio before starting sh */
struct termios initial_settings, new_settings;
#ifndef _POSIX_VDISABLE
#define _POSIX_VDISABLE '\0'
#endif
#endif
static int cmdedit_termw = 80; /* actual terminal width */
static int cmdedit_scroll = 27; /* width of EOL scrolling region */
static int history_counter = 0; /* Number of commands in history list */
static int reset_term = 0; /* Set to true if the terminal needs to be reset upon exit */
static int exithandler_set = 0; /* Set to true when atexit() has been called */
struct history {
char *s;
@@ -68,6 +94,11 @@ struct history {
#define xwrite write
/*
* TODO: Someday we want to implement 'horizontal scrolling' of the
* command-line when the user has typed more than the current width. This
* would allow the user to see a 'window' of what he has typed.
*/
void
cmdedit_setwidth(int w)
{
@@ -84,14 +115,27 @@ void cmdedit_reset_term(void)
{
if (reset_term)
/* sparc and other have broken termios support: use old termio handling. */
ioctl(fileno(stdin), TCSETA, (void *) &old_term);
setTermSettings(fileno(stdin), (void*) &initial_settings);
#ifdef BB_FEATURE_CLEAN_UP
if (his_front) {
struct history *n;
//while(his_front!=his_end) {
while(his_front!=his_end) {
n = his_front->n;
free(his_front->s);
free(his_front);
his_front=n;
}
}
#endif
}
void clean_up_and_die(int sig)
{
cmdedit_reset_term();
fprintf(stdout, "\n");
exit(TRUE);
if (sig!=SIGINT)
exit(TRUE);
}
/* Go to HOME position */
@@ -117,6 +161,12 @@ void input_backspace(char* command, int outputFd, int *cursor, int *len)
{
int j = 0;
/* Debug crap */
//fprintf(stderr, "\nerik: len=%d, cursor=%d, strlen(command)='%d'\n", *len, *cursor, strlen(command));
//xwrite(outputFd, command, *len);
//*cursor = *len;
if (*cursor > 0) {
xwrite(outputFd, "\b \b", 3);
--*cursor;
@@ -196,11 +246,11 @@ char** username_tab_completion(char* command, int *num_matches)
char** exe_n_cwd_tab_completion(char* command, int *num_matches)
{
char *dirName;
char **matches = (char **) NULL;
char **matches;
DIR *dir;
struct dirent *next;
matches = malloc( sizeof(char*)*50);
matches = xmalloc( sizeof(char*)*50);
/* Stick a wildcard onto the command, for later use */
strcat( command, "*");
@@ -223,7 +273,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
/* See if this matches */
if (check_wildcard_match(next->d_name, command) == TRUE) {
/* Cool, found a match. Add it to the list */
matches[*num_matches] = malloc(strlen(next->d_name)+1);
matches[*num_matches] = xmalloc(strlen(next->d_name)+1);
strcpy( matches[*num_matches], next->d_name);
++*num_matches;
//matches = realloc( matches, sizeof(char*)*(*num_matches));
@@ -233,7 +283,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
return (matches);
}
void input_tab(char* command, int outputFd, int *cursor, int *len)
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
{
/* Do TAB completion */
static int num_matches=0;
@@ -246,13 +296,13 @@ void input_tab(char* command, int outputFd, int *cursor, int *len)
/* For now, we will not bother with trying to distinguish
* whether the cursor is in/at a command extression -- we
* will always try all possable matches. If you don't like
* will always try all possible matches. If you don't like
* that then feel free to fix it.
*/
/* Make a local copy of the string -- up
* to the position of the cursor */
matchBuf = (char *) calloc(BUFSIZ, sizeof(char));
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
strncpy(matchBuf, command, cursor);
tmp=matchBuf;
@@ -333,14 +383,16 @@ void input_tab(char* command, int outputFd, int *cursor, int *len)
void get_previous_history(struct history **hp, char* command)
{
free((*hp)->s);
if ((*hp)->s)
free((*hp)->s);
(*hp)->s = strdup(command);
*hp = (*hp)->p;
}
void get_next_history(struct history **hp, char* command)
{
free((*hp)->s);
if ((*hp)->s)
free((*hp)->s);
(*hp)->s = strdup(command);
*hp = (*hp)->n;
}
@@ -377,21 +429,18 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
char c = 0;
struct history *hp = his_end;
memset(command, 0, sizeof(command));
if (!reset_term) {
/* sparc and other have broken termios support: use old termio handling. */
ioctl(inputFd, TCGETA, (void *) &old_term);
memcpy(&new_term, &old_term, sizeof(struct termio));
new_term.c_cc[VMIN] = 1;
new_term.c_cc[VTIME] = 0;
new_term.c_lflag &= ~ICANON; /* unbuffered input */
new_term.c_lflag &= ~ECHO;
getTermSettings(inputFd, (void*) &initial_settings);
memcpy(&new_settings, &initial_settings, sizeof(struct termios));
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
new_settings.c_cc[VINTR] = _POSIX_VDISABLE; /* Turn off CTRL-C, so we can trap it */
new_settings.c_lflag &= ~ICANON; /* unbuffered input */
new_settings.c_lflag &= ~(ECHO|ECHOCTL|ECHONL); /* Turn off echoing */
reset_term = 1;
ioctl(inputFd, TCSETA, (void *) &new_term);
} else {
ioctl(inputFd, TCSETA, (void *) &new_term);
}
setTermSettings(inputFd, (void*) &new_settings);
memset(command, 0, BUFSIZ);
@@ -399,6 +448,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
if ((ret = read(inputFd, &c, 1)) < 1)
return;
//fprintf(stderr, "got a '%c' (%d)\n", c, c);
switch (c) {
case '\n':
@@ -414,6 +464,21 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
case 2:
/* Control-b -- Move back one character */
input_backward(outputFd, &cursor);
break;
case 3:
/* Control-c -- leave the current line,
* and start over on the next line */
/* Go to the next line */
xwrite(outputFd, "\n", 1);
/* Rewrite the prompt */
xwrite(outputFd, prompt, strlen(prompt));
/* Reset the command string */
memset(command, 0, BUFSIZ);
len = cursor = 0;
break;
case 4:
/* Control-d -- Delete one character, or exit
@@ -435,12 +500,12 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
break;
case '\b':
case DEL:
/* control-h and DEL */
/* Control-h and DEL */
input_backspace(command, outputFd, &cursor, &len);
break;
case '\t':
#ifdef BB_FEATURE_SH_TAB_COMPLETION
input_tab(command, outputFd, &cursor, &len);
input_tab(command, prompt, outputFd, &cursor, &len);
#endif
break;
case 14:
@@ -494,7 +559,10 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
rewrite_line:
/* erase old command from command line */
len = strlen(command)-strlen(hp->s);
while (len>0)
while (len>cursor)
input_delete(command, outputFd, cursor, &len);
while (cursor>0)
input_backspace(command, outputFd, &cursor, &len);
input_home(outputFd, &cursor);
@@ -591,8 +659,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
}
nr = len + 1;
/* sparc and other have broken termios support: use old termio handling. */
ioctl(inputFd, TCSETA, (void *) &old_term);
setTermSettings(inputFd, (void *) &initial_settings);
reset_term = 0;
@@ -602,9 +669,9 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
struct history *h = his_end;
if (!h) {
/* No previous history */
h = his_front = malloc(sizeof(struct history));
h->n = malloc(sizeof(struct history));
/* No previous history -- this memory is never freed */
h = his_front = xmalloc(sizeof(struct history));
h->n = xmalloc(sizeof(struct history));
h->p = NULL;
h->s = strdup(command);
@@ -614,8 +681,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
his_end = h->n;
history_counter++;
} else {
/* Add a new history command */
h->n = malloc(sizeof(struct history));
/* Add a new history command -- this memory is never freed */
h->n = xmalloc(sizeof(struct history));
h->n->p = h;
h->n->n = NULL;
@@ -643,9 +710,32 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
extern void cmdedit_init(void)
{
atexit(cmdedit_reset_term);
if(exithandler_set == 0) {
atexit(cmdedit_reset_term); /* be sure to do this only once */
exithandler_set = 1;
}
signal(SIGKILL, clean_up_and_die);
signal(SIGINT, clean_up_and_die);
signal(SIGQUIT, clean_up_and_die);
signal(SIGTERM, clean_up_and_die);
}
/*
** Undo the effects of cmdedit_init() as good as we can:
** I am not aware of a way to revoke an atexit() handler,
** but, fortunately, our particular handler can be made
** a no-op by setting reset_term = 0.
*/
extern void cmdedit_terminate(void)
{
cmdedit_reset_term();
reset_term = 0;
signal(SIGKILL, SIG_DFL);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
}
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
+6 -3
View File
@@ -1,5 +1,5 @@
#ifndef GETLINE_H
#define GETLINE_H
#ifndef CMDEDIT_H
#define CMDEDIT_H
/* unix systems can #define POSIX to use termios, otherwise
* the bsd or sysv interface will be used
@@ -10,6 +10,8 @@
typedef size_t (*cmdedit_strwidth_proc)(char *);
void cmdedit_init(void);
void cmdedit_terminate(void);
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
void cmdedit_setwidth(int); /* specify width of screen */
void cmdedit_histadd(char *); /* adds entries to hist */
@@ -21,6 +23,7 @@ extern int (*cmdedit_tab_hook)(char *, int, int *);
#else /* not __STDC__ */
void cmdedit_init(void);
void cmdedit_read_input(char* promptStr, char* command);
void cmdedit_setwidth();
void cmdedit_histadd();
@@ -32,4 +35,4 @@ extern int (*cmdedit_tab_hook)();
#endif /* __STDC__ */
#endif /* GETLINE_H */
#endif /* CMDEDIT_H */
+9 -10
View File
@@ -4,24 +4,23 @@
*
* busyboxed by Erik Andersen
*/
#include "internal.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
extern int getfd(void);
/* From <linux/vt.h> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
int chvt_main(int argc, char **argv)
{
int fd, num;
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n");
}
if ((argc != 2) || (**(argv + 1) == '-'))
usage (chvt_usage);
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num)) {
@@ -32,7 +31,7 @@ int chvt_main(int argc, char **argv)
perror("VT_WAITACTIVE");
exit(FALSE);
}
exit(TRUE);
return(TRUE);
}
+2 -2
View File
@@ -22,12 +22,12 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
exit(TRUE);
return(TRUE);
}
+15 -19
View File
@@ -3,50 +3,46 @@
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
* Renamed deallocvt.
*/
#include "internal.h"
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <stdio.h>
extern int getfd(void);
char *progname;
/* From <linux/vt.h> */
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
int fd, num, i;
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n");
}
progname = argv[0];
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
if (argc > 2)
usage(deallocvt_usage);
fd = get_console_fd("/dev/console");
if (argc == 1) {
printf("erik: A\n");
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
exit(1);
exit( FALSE);
}
} else
printf("erik: B\n");
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
fprintf(stderr, "%s: 0: illegal VT number\n", progname);
errorMsg("0: illegal VT number\n");
else if (num == 1)
fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
progname);
errorMsg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n",
progname, num);
exit(1);
fatalError("could not deallocate console %d\n", num);
}
}
exit(0);
printf("erik: C\n");
return( TRUE);
}
+92
View File
@@ -0,0 +1,92 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dumpkmap implementation for busybox
*
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_table;
unsigned char kb_index;
unsigned short kb_value;
};
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv)
{
struct kbentry ke;
int i, j, fd;
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
if (argc>=2 && *argv[1]=='-') {
usage(dumpkmap_usage);
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return 1;
}
write(1, magic, 7);
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
flags[0]=1;
flags[1]=1;
flags[2]=1;
flags[4]=1;
flags[5]=1;
flags[6]=1;
flags[8]=1;
flags[9]=1;
flags[10]=1;
flags[12]=1;
/* dump flags */
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,(void*)&ke.kb_value,2);
}
}
}
}
close(fd);
return 0;
}
+11 -18
View File
@@ -7,7 +7,7 @@
* Peter Novodvorsky <petya@logic.ru>
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
@@ -18,13 +18,9 @@
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
static const char loadacm_usage[] = "loadacm\n\n"
"Loads an acm from standard input.\n";
typedef unsigned short unicode;
static long int ctoi(unsigned char *s, int *is_unicode);
@@ -43,12 +39,12 @@ int loadacm_main(int argc, char **argv)
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno));
errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
return( FALSE);
}
if (screen_map_load(fd, stdin)) {
fprintf(stderr, "Error loading acm: %s\n", strerror(errno));
errorMsg("Error loading acm: %s\n", strerror(errno));
return( FALSE);
}
@@ -65,7 +61,7 @@ int screen_map_load(int fd, FILE * fp)
int parse_failed = 0;
int is_unicode;
if (fstat(fp->_fileno, &stbuf))
if (fstat(fileno(fp), &stbuf))
perror("Cannot stat map file"), exit(1);
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
@@ -76,8 +72,7 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
fprintf(stderr,
"16bit screen-map MUST be a regular file.\n"),
errorMsg("16bit screen-map MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed reading binary 16bit screen-map"),
@@ -88,7 +83,7 @@ int screen_map_load(int fd, FILE * fp)
perror("Cannot read [new] map from file"), exit(1);
#if 0
else
fprintf(stderr, "Input screen-map is binary.\n");
errorMsg("Input screen-map is binary.\n");
#endif
}
@@ -105,8 +100,7 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
fprintf(stderr,
"Assuming 8bit screen-map - MUST be a regular file.\n"),
errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed assuming 8bit screen-map"), exit(1);
@@ -119,7 +113,7 @@ int screen_map_load(int fd, FILE * fp)
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
fprintf(stderr, "fseek() returned ESPIPE !\n"),
errorMsg("fseek() returned ESPIPE !\n"),
exit(1);
else
perror("fseek for binary 8bit screen-map"), exit(1);
@@ -129,7 +123,7 @@ int screen_map_load(int fd, FILE * fp)
perror("Cannot read [old] map from file"), exit(1);
#if 0
else
fprintf(stderr, "Input screen-map is binary.\n");
errorMsg("Input screen-map is binary.\n");
#endif
}
@@ -137,10 +131,9 @@ int screen_map_load(int fd, FILE * fp)
perror("PIO_SCRNMAP ioctl"), exit(1);
else
return 0;
} else {
fprintf(stderr, "Error parsing symbolic map\n");
exit(1);
}
errorMsg("Error parsing symbolic map\n");
return(1);
}
+12 -20
View File
@@ -7,7 +7,7 @@
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
@@ -15,7 +15,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -30,9 +29,6 @@
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
static const char loadfont_usage[] = "loadfont\n\n"
"Loads a console font from standard input.\n";
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
unsigned char mode; /* PSF font mode */
@@ -53,7 +49,7 @@ extern int loadfont_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return( FALSE);
}
loadnewfont(fd);
@@ -69,7 +65,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) {
fprintf(stderr, "Bad character size %d\n", unit);
errorMsg("Bad character size %d\n", unit);
exit(1);
}
@@ -106,12 +102,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
u_short unicode;
maxct = tailsz; /* more than enough */
up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
if (!up) {
fprintf(stderr, "Out of memory?\n");
exit(1);
}
for (glyph = 0; glyph < fontsize; glyph++) {
while (tailsz >= 2) {
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
@@ -134,8 +126,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
fprintf(stderr, "No Unicode mapping table loaded.\n");
errorMsg("It seems this kernel is older than 1.1.92\n");
errorMsg("No Unicode mapping table loaded.\n");
} else
#endif
perror("PIO_UNIMAPCLR");
@@ -158,7 +150,7 @@ static void loadnewfont(int fd)
{
int unit;
char inbuf[32768]; /* primitive */
int inputlth, offset;
unsigned int inputlth, offset;
/*
* We used to look at the length of the input file
@@ -184,7 +176,7 @@ static void loadnewfont(int fd)
struct psf_header psfhdr;
int fontsize;
int hastable;
int head0, head;
unsigned int head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
@@ -195,13 +187,13 @@ static void loadnewfont(int fd)
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) {
fprintf(stderr, "Unsupported psf file mode\n");
errorMsg("Unsupported psf file mode\n");
exit(1);
}
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) {
fprintf(stderr, "Only fontsize 256 supported\n");
errorMsg("Only fontsize 256 supported\n");
exit(1);
}
#endif
@@ -211,7 +203,7 @@ static void loadnewfont(int fd)
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) {
fprintf(stderr, "Input file: bad length\n");
errorMsg("Input file: bad length\n");
exit(1);
}
do_loadfont(fd, inbuf + head0, unit, fontsize);
@@ -228,7 +220,7 @@ static void loadnewfont(int fd)
} else {
/* bare font */
if (inputlth & 0377) {
fprintf(stderr, "Bad input file size\n");
errorMsg("Bad input file size\n");
exit(1);
}
offset = 0;
+17 -16
View File
@@ -20,18 +20,23 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <linux/kd.h>
#include <linux/keyboard.h>
#include <sys/ioctl.h>
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_table;
unsigned char kb_index;
unsigned short kb_value;
};
#define KDSKBENT 0x4B47 /* sets one entry in translation table */
static const char loadkmap_usage[] = "loadkmap\n\n"
"Loads a binary keyboard translation table from standard input.\n";
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv)
{
@@ -46,27 +51,23 @@ int loadkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
exit(FALSE);
}
read(0, buff, 7);
if (0 != strncmp(buff, magic, 7)) {
fprintf(stderr, "This is not a valid binary keymap.\n");
errorMsg("This is not a valid binary keymap.\n");
exit(FALSE);
}
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) {
fprintf(stderr, "Error reading keymap flags: %s\n",
errorMsg("Error reading keymap flags: %s\n",
strerror(errno));
exit(FALSE);
}
ibuff = (u_short *) malloc(ibuffsz);
if (!ibuff) {
fprintf(stderr, "Out of memory.\n");
exit(FALSE);
}
ibuff = (u_short *) xmalloc(ibuffsz);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
@@ -74,7 +75,7 @@ int loadkmap_main(int argc, char **argv)
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
< 0) {
fprintf(stderr, "Error reading keymap: %s\n",
errorMsg("Error reading keymap: %s\n",
strerror(errno));
exit(FALSE);
}
@@ -91,5 +92,5 @@ int loadkmap_main(int argc, char **argv)
/* Don't bother to close files. Exit does that
* automagically, so we can save a few bytes */
/* close(fd); */
exit(TRUE);
return(TRUE);
}
+34
View File
@@ -0,0 +1,34 @@
/* vi: set sw=4 ts=4: */
/*
* Mini reset implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* and Kent Robotti <robotti@metconnect.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include <stdio.h>
extern int reset_main(int argc, char **argv)
{
printf("\033c");
return(TRUE);
}
+72
View File
@@ -0,0 +1,72 @@
/* vi: set sw=4 ts=4: */
/*
* setkeycodes
*
* Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
*
* Adjusted for BusyBox by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
/* From <linux/kd.h> */
struct kbkeycode {
unsigned int scancode, keycode;
};
#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
extern int
setkeycodes_main(int argc, char** argv)
{
char *ep;
int fd, sc;
struct kbkeycode a;
if (argc % 2 != 1 || argc < 2) {
usage(setkeycodes_usage);
}
fd = get_console_fd("/dev/console");
while (argc > 2) {
a.keycode = atoi(argv[2]);
a.scancode = sc = strtol(argv[1], &ep, 16);
if (*ep) {
fatalError("error reading SCANCODE: '%s'\n", argv[1]);
}
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
if (a.scancode > 255 || a.keycode > 127) {
fatalError("SCANCODE or KEYCODE outside bounds\n");
}
if (ioctl(fd,KDSETKEYCODE,&a)) {
perror("KDSETKEYCODE");
fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
}
argc -= 2;
argv += 2;
}
return( TRUE);
}
+16 -12
View File
@@ -21,25 +21,29 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int basename_main(int argc, char **argv)
{
char* s, *s1;
int m, n;
char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("basename [file ...]\n");
usage(basename_usage);
}
argv++;
s1=*argv+strlen(*argv)-1;
while (s1 && *s1 == '/') {
*s1 = '\0';
s1=*argv+strlen(*argv)-1;
}
s = strrchr(*argv, '/');
printf("%s\n", (s)? s + 1 : *argv);
exit(TRUE);
}
s = get_last_path_component(*argv);
if (argc>2) {
argv++;
n = strlen(*argv);
m = strlen(s);
if (m>=n && strncmp(s+m-n, *argv, n)==0)
s[m-n] = '\0';
}
printf("%s\n", s);
return(TRUE);
}
+6 -24
View File
@@ -21,43 +21,25 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
static void print_file(FILE * file)
{
int c;
while ((c = getc(file)) != EOF)
putc(c, stdout);
fclose(file);
fflush(stdout);
}
extern int cat_main(int argc, char **argv)
{
FILE *file;
if (argc == 1) {
print_file(stdin);
exit(TRUE);
}
if (**(argv + 1) == '-') {
usage("cat [file ...]\n");
}
argc--;
while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
file = fopen(*argv, "r");
if (file == NULL) {
while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) {
print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) {
perror(*argv);
exit(FALSE);
}
print_file(file);
}
exit(TRUE);
return(TRUE);
}
/*
+12 -17
View File
@@ -22,20 +22,15 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n"
"Run COMMAND with root directory set to NEWROOT.\n";
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(chroot_usage);
}
@@ -43,27 +38,27 @@ int chroot_main(int argc, char **argv)
argv++;
if (chroot(*argv) || (chdir("/"))) {
fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno));
}
argc--;
argv++;
if (argc >= 1) {
fprintf(stderr, "command: %s\n", *argv);
prog = *argv;
execvp(*argv, argv);
} else {
char *prog;
#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
shell_main(argc, argv);
exit (0);
#endif
}
fprintf(stderr, "chroot: cannot execute %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
fatalError("cannot execute %s: %s\n", prog, strerror(errno));
}
+232
View File
@@ -0,0 +1,232 @@
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@enol.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* getopt */
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "busybox.h"
/* globals from other files */
extern int optind;
extern char *optarg;
/* globals in this file only */
static char part = 0; /* (b)yte, (c)har, (f)ields */
static int startpos = 1;
static int endpos = -1;
static char delim = '\t'; /* delimiter, default is tab */
static unsigned int supress_non_delimited_lines = 0;
/*
* decompose_list() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
*/
static void decompose_list(const char *list)
{
unsigned int nminus = 0;
char *ptr;
/* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') {
fatalError("invalid byte or field list\n");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
fatalError("invalid byte or field list\n");
}
}
}
/* handle single value 'N' case */
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
fatalError("missing list of fields\n");
}
endpos = startpos;
}
/* handle multi-value cases */
else if (nminus == 1) {
/* handle 'N-' case */
if (list[strlen(list) - 1] == '-') {
startpos = strtol(list, &ptr, 10);
}
/* handle '-M' case */
else if (list[0] == '-') {
endpos = strtol(&list[1], NULL, 10);
}
/* handle 'N-M' case */
else {
startpos = strtol(list, &ptr, 10);
endpos = strtol(ptr+1, &ptr, 10);
}
/* a sanity check */
if (startpos == 0) {
startpos = 1;
}
}
}
/*
* snippy-snip
*/
static void cut_file(FILE *file)
{
char *line;
/* go through every line in the file */
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
/* cut based on chars/bytes */
if (part == 'c' || part == 'b') {
int i;
/* a valid end position has been specified */
if (endpos > 0) {
for (i = startpos-1; i < endpos; i++) {
fputc(line[i], stdout);
}
fputc('\n', stdout);
}
/* otherwise, just go to the end of the line */
else {
for (i = startpos-1; line[i]; i++) {
fputc(line[i], stdout);
}
}
}
/* cut based on fields */
else if (part == 'f') {
char *ptr;
char *start = line;
unsigned int delims_hit = 0;
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
delims_hit++;
if (delims_hit == (startpos - 1)) {
start = ptr+1;
}
if (delims_hit == endpos) {
break;
}
}
/* we didn't hit any delimeters */
if (delims_hit == 0 && !supress_non_delimited_lines) {
fputs(line, stdout);
}
/* we =did= hit some delimiters */
else if (delims_hit > 0) {
/* we have a fixed end point */
if (ptr) {
while (start < ptr) {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
/* or we're just going til the end of the line */
else {
while (*start) {
fputc(*start, stdout);
start++;
}
}
}
}
}
}
extern int cut_main(int argc, char **argv)
{
int opt;
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
switch (opt) {
case 'b':
case 'c':
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
fatalError("only one type of list may be specified");
}
part = (char)opt;
decompose_list(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
fatalError("the delimiter must be a single character\n");
}
delim = optarg[0];
break;
case 'n':
/* no-op */
break;
case 's':
supress_non_delimited_lines++;
break;
}
}
if (part == 0) {
fatalError("you must specify a list of bytes, characters, or fields\n");
}
if (supress_non_delimited_lines && part != 'f') {
fatalError("suppressing non-delimited lines makes sense
only when operating on fields\n");
}
if (delim != '\t' && part != 'f') {
fatalError("a delimiter may be specified only when operating on fields\n");
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
* files were specified or '-' was specified, take input from stdin.
* Otherwise, we process all the files specified. */
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
cut_file(stdin);
}
else {
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
errorMsg("%s: %s\n", argv[i], strerror(errno));
} else {
cut_file(file);
fclose(file);
}
}
}
return 0;
}
+37 -56
View File
@@ -20,7 +20,7 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
@@ -31,6 +31,7 @@
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <getopt.h>
/* This 'date' command supports only 2 time setting formats,
@@ -39,15 +40,6 @@
an RFC 822 complient date output for shell scripting
mail commands */
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\n"
"Display the current time in the given FORMAT, or set the system date.\n"
"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
"\t-s\t\tset time described by STRING\n"
"\t-u\t\tprint or set Coordinated Universal Time\n";
/* Input parsing code is always bulky - used heavy duty libc stuff as
much as possible, missed out a lot of bounds checking */
@@ -64,7 +56,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
fatalError(invalid_date, "date", t_string);
fatalError(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
@@ -148,7 +140,7 @@ struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
}
fatalError(invalid_date, "date", t_string);
fatalError(invalid_date, t_string);
}
@@ -157,7 +149,7 @@ int date_main(int argc, char **argv)
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
int i;
int c;
int set_time = 0;
int rfc822 = 0;
int utc = 0;
@@ -166,49 +158,39 @@ int date_main(int argc, char **argv)
struct tm tm_time;
/* Interpret command line args */
i = --argc;
argv++;
while (i > 0 && **argv) {
if (**argv == '-') {
while (i > 0 && *++(*argv))
switch (**argv) {
case 'R':
rfc822 = 1;
break;
case 's':
set_time = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted, "date");
/* Look ma, no break. Don't fix it either. */
case 'd':
use_arg = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
break;
case '-':
usage(date_usage);
}
} else {
if ((date_fmt == NULL) && (**argv == '+'))
date_fmt = *argv + 1; /* Skip over the '+' */
else if (date_str == NULL) {
set_time = 1;
date_str = *argv;
} else {
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
switch (c) {
case 'R':
rfc822 = 1;
break;
case 's':
set_time = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
usage(date_usage);
}
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted);
break;
case 'd':
use_arg = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
usage(date_usage);
break;
default:
usage(date_usage);
}
i--;
argv++;
}
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
date_fmt = &argv[optind][1]; /* Skip over the '+' */
else if (date_str == NULL) {
set_time = 1;
date_str = argv[optind];
} else {
usage(date_usage);
}
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
@@ -234,12 +216,12 @@ int date_main(int argc, char **argv)
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
fatalError(invalid_date, "date", date_str);
fatalError(invalid_date, date_str);
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
fatalError("date: can't set date.\n");
fatalError("can't set date.\n");
}
}
}
@@ -271,6 +253,5 @@ int date_main(int argc, char **argv)
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
exit(TRUE);
return(TRUE);
}
+35 -73
View File
@@ -29,7 +29,7 @@
*/
#include "internal.h"
#include "busybox.h"
#include <features.h>
#include <stdio.h>
#include <fcntl.h>
@@ -40,37 +40,25 @@
typedef unsigned long long int uintmax_t;
#endif
static const char dd_usage[] =
"dd [if=name] [of=name] [bs=n] [count=n] [skip=n] [seek=n]\n\n"
"Copy a file, converting and formatting according to options\n\n"
"\tif=FILE\tread from FILE instead of stdin\n"
"\tof=FILE\twrite to FILE instead of stdout\n"
"\tbs=n\tread and write n bytes at a time\n"
"\tcount=n\tcopy only n input blocks\n"
"\tskip=n\tskip n input blocks\n"
"\tseek=n\tskip n output blocks\n"
"\n"
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n";
extern int dd_main(int argc, char **argv)
{
char *inFile = NULL;
char *outFile = NULL;
char *cp;
int inFd;
int outFd;
int inCc = 0;
int outCc;
int trunc=TRUE;
long blockSize = 512;
uintmax_t skipBlocks = 0;
uintmax_t seekBlocks = 0;
uintmax_t count = (uintmax_t) - 1;
uintmax_t intotal;
uintmax_t outTotal;
unsigned char *buf;
uintmax_t inTotal = 0;
uintmax_t outTotal = 0;
uintmax_t totalSize;
uintmax_t readSize;
unsigned char buf[BUFSIZ];
char *keyword = NULL;
argc--;
argv++;
@@ -83,30 +71,33 @@ extern int dd_main(int argc, char **argv)
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1);
if (count <= 0) {
fprintf(stderr, "Bad count value %s\n", *argv);
if (count < 0) {
errorMsg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
fprintf(stderr, "Bad block size value %s\n", *argv);
errorMsg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
fprintf(stderr, "Bad skip value %s\n", *argv);
errorMsg("Bad skip value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
fprintf(stderr, "Bad seek value %s\n", *argv);
errorMsg("Bad seek value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "conv", 4) == 0) {
keyword = (strchr(*argv, '=') + 1);
if (strcmp(keyword, "notrunc") == 0)
trunc=FALSE;
} else {
goto usage;
}
@@ -114,11 +105,6 @@ extern int dd_main(int argc, char **argv)
argv++;
}
buf = xmalloc(blockSize);
intotal = 0;
outTotal = 0;
if (inFile == NULL)
inFd = fileno(stdin);
else
@@ -136,7 +122,7 @@ extern int dd_main(int argc, char **argv)
if (outFile == NULL)
outFd = fileno(stdout);
else
outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
outFd = open(outFile, O_WRONLY | O_CREAT, 0666);
if (outFd < 0) {
/* Note that we are not freeing buf or closing
@@ -148,54 +134,30 @@ extern int dd_main(int argc, char **argv)
fatalError( outFile);
}
lseek(inFd, skipBlocks * blockSize, SEEK_SET);
lseek(outFd, seekBlocks * blockSize, SEEK_SET);
//
//TODO: Convert to using fullRead & fullWrite
// from utility.c
// -Erik
while (outTotal < count * blockSize) {
inCc = read(inFd, buf, blockSize);
if (inCc < 0) {
perror(inFile);
goto cleanup;
} else if (inCc == 0) {
goto cleanup;
}
intotal += inCc;
cp = buf;
while (intotal > outTotal) {
if (outTotal + inCc > count * blockSize)
inCc = count * blockSize - outTotal;
outCc = write(outFd, cp, inCc);
if (outCc < 0) {
perror(outFile);
goto cleanup;
} else if (outCc == 0) {
goto cleanup;
}
inCc -= outCc;
cp += outCc;
outTotal += outCc;
}
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
totalSize=count*blockSize;
while ((readSize = totalSize - inTotal) > 0) {
if (readSize > BUFSIZ)
readSize=BUFSIZ;
inCc = fullRead(inFd, buf, readSize);
inTotal += inCc;
if ((outCc = fullWrite(outFd, buf, inCc)) < 1)
break;
outTotal += outCc;
}
if (trunc == TRUE) {
ftruncate(outFd, lseek(outFd, 0, SEEK_CUR));
}
if (inCc < 0)
perror(inFile);
cleanup:
/* Note that we are not freeing memory or closing
* files here, to save a few bytes. */
#if 0
#ifdef BB_FEATURE_CLEAN_UP
close(inFd);
close(outFd);
free(buf);
#endif
printf("%ld+%d records in\n", (long) (intotal / blockSize),
(intotal % blockSize) != 0);
printf("%ld+%d records in\n", (long) (inTotal / blockSize),
(inTotal % blockSize) != 0);
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
(outTotal % blockSize) != 0);
exit(TRUE);
+3 -8
View File
@@ -22,15 +22,11 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <mntent.h>
#include <sys/stat.h>
#include <sys/vfs.h>
static const char df_usage[] = "df [filesystem ...]\n\n"
"Print the filesystem space used and space available.\n";
extern const char mtab_file[]; /* Defined in utility.c */
static int df(char *device, const char *mountPoint)
@@ -48,7 +44,6 @@ static int df(char *device, const char *mountPoint)
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
/* Note that if /etc/fstab is missing, libc can't fix up /dev/root for us */
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
@@ -80,7 +75,7 @@ extern int df_main(int argc, char **argv)
}
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
errorMsg("%s: can't find mount point.\n", argv[1]);
exit(FALSE);
}
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
@@ -106,7 +101,7 @@ extern int df_main(int argc, char **argv)
endmntent(mountTable);
}
exit(TRUE);
return(TRUE);
}
/*
+4 -5
View File
@@ -20,16 +20,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int dirname_main(int argc, char **argv)
{
char* s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("dirname [file ...]\n");
}
if ((argc < 2) || (**(argv + 1) == '-'))
usage(dirname_usage);
argv++;
s=*argv+strlen(*argv)-1;
@@ -41,5 +40,5 @@ extern int dirname_main(int argc, char **argv)
if (s && *s)
*s = '\0';
printf("%s\n", (s)? *argv : ".");
exit(TRUE);
return(TRUE);
}
+45
View File
@@ -0,0 +1,45 @@
/*
Mini dos2unix implementation for busybox
Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA
All rights reserved.
Redistribution and use of this source code, with or without modification, is
permitted provided that the following condition is met:
1. Redistributions of this source code must retain the above copyright
notice, this condition, and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "busybox.h"
#include <stdio.h>
int dos2unix_main( int argc, char **argv ) {
int c;
if (argc > 1) {
c = *argv[1];
if (c == '-') {
usage(dos2unix_usage);
}
}
c = getchar();
while (c != EOF) {
/* Eat any \r's... they shouldn't be here */
while (c == '\r') c = getchar();
if (c == EOF) break;
putchar(c);
c = getchar();
}
return 0;
}
+16 -35
View File
@@ -22,7 +22,7 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#include "messages.c"
@@ -32,18 +32,9 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
#include <sys/param.h> /* for PATH_MAX */
typedef void (Display) (long, char *);
static const char du_usage[] =
"du [OPTION]... [FILE]...\n\n"
"Summarize disk space used for each FILE and/or directory.\n"
"Disk space is printed in units of 1024 bytes.\n\n"
"Options:\n"
"\t-l\tcount sizes many times if hard linked\n"
"\t-s\tdisplay only a total for each argument\n";
static int du_depth = 0;
static int count_hardlinks = 0;
@@ -97,7 +88,7 @@ static long du(char *filename)
filename[--len] = '\0';
while ((entry = readdir(dir))) {
char newfile[PATH_MAX + 1];
char newfile[BUFSIZ + 1];
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
@@ -105,8 +96,8 @@ static long du(char *filename)
continue;
}
if (len + strlen(name) + 1 > PATH_MAX) {
fprintf(stderr, name_too_long, "du");
if (len + strlen(name) + 1 > BUFSIZ) {
errorMsg(name_too_long);
du_depth--;
return 0;
}
@@ -135,42 +126,32 @@ static long du(char *filename)
int du_main(int argc, char **argv)
{
int i;
char opt;
int c;
/* default behaviour */
print = print_normal;
/* parse argv[] */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
while ((c = getopt(argc, argv, "sl")) != EOF) {
switch (c) {
case 's':
print = print_summary;
break;
print = print_summary;
break;
case 'l':
count_hardlinks = 1;
break;
case 'h':
case '-':
usage(du_usage);
break;
count_hardlinks = 1;
break;
default:
fprintf(stderr, "du: invalid option -- %c\n", opt);
usage(du_usage);
usage(du_usage);
}
} else {
break;
}
}
/* go through remaining args (if any) */
if (i >= argc) {
if (optind >= argc) {
du(".");
} else {
long sum;
for (; i < argc; i++) {
for (i=optind; i < argc; i++) {
sum = du(argv[i]);
if (sum && isDirectory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]);
@@ -179,10 +160,10 @@ int du_main(int argc, char **argv)
}
}
exit(0);
return(0);
}
/* $Id: du.c,v 1.17 2000/04/13 01:18:56 erik Exp $ */
/* $Id: du.c,v 1.25 2000/09/25 21:45:57 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
+21 -46
View File
@@ -22,68 +22,43 @@
* Original copyright notice is retained at the end of this file.
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
static const char uname_usage[] =
"echo [-neE] [ARG ...]\n\n"
"Prints the specified ARGs to stdout\n\n"
"Options:\n"
"\t-n\tsuppress trailing newline\n"
"\t-e\tinterpret backslash-escaped characters (i.e. \\t=tab etc)\n"
"\t-E\tdisable interpretation of backslash-escaped characters\n";
extern int
echo_main(int argc, char** argv)
{
register char **ap;
register char *p;
register char c;
char *p;
int c;
int nflag = 0;
int eflag = 0;
ap = argv;
if (argc)
ap++;
while ((p = *ap) != NULL && *p == '-') {
if (strcmp(p, "-n")==0) {
while ((c = getopt(argc, argv, "neE")) != EOF) {
switch (c) {
case 'n':
nflag = 1;
} else if (strcmp(p, "-e")==0) {
break;
case 'e':
eflag = 1;
} else if (strcmp(p, "-E")==0) {
break;
case 'E':
eflag = 0;
break;
default:
usage(echo_usage);
}
else if (strncmp(p, "--", 2)==0) {
usage( uname_usage);
}
else break;
ap++;
}
ap = &argv[optind];
while ((p = *ap++) != NULL) {
while ((c = *p++) != '\0') {
if (c == '\\' && eflag) {
switch (c = *p++) {
case 'a': c = '\007'; break;
case 'b': c = '\b'; break;
case 'c': exit( 0); /* exit */
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\t'; break;
case 'v': c = '\v'; break;
case '\\': break; /* c = '\\' */
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
c -= '0';
if (*p >= '0' && *p <= '7')
c = c * 8 + (*p++ - '0');
if (*p >= '0' && *p <= '7')
c = c * 8 + (*p++ - '0');
break;
default:
p--;
break;
}
if (*p == 'c')
exit(0);
else
c = process_escape_sequence(&p);
}
putchar(c);
}
@@ -93,7 +68,7 @@ echo_main(int argc, char** argv)
if (! nflag)
putchar('\n');
fflush(stdout);
exit( 0);
return( 0);
}
/*-
+531
View File
@@ -0,0 +1,531 @@
/* vi: set sw=4 ts=4: */
/*
* Mini expr implementation for busybox
*
* based on GNU expr Mike Parker.
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
*
* Busybox modifications
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
*
* this program is free software; you can redistribute it and/or modify
* it under the terms of the gnu general public license as published by
* the free software foundation; either version 2 of the license, or
* (at your option) any later version.
*
* this program is distributed in the hope that it will be useful,
* but without any warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose. see the gnu
* general public license for more details.
*
* you should have received a copy of the gnu general public license
* along with this program; if not, write to the free software
* foundation, inc., 59 temple place, suite 330, boston, ma 02111-1307 usa
*
*/
/* This program evaluates expressions. Each token (operator, operand,
* parenthesis) of the expression must be a seperate argument. The
* parser used is a reasonably general one, though any incarnation of
* it is language-specific. It is especially nice for expressions.
*
* No parse tree is needed; a new node is evaluated immediately.
* One function can handle multiple operators all of equal precedence,
* provided they all associate ((x op x) op x). */
#include "busybox.h"
#include <stdio.h>
#include <sys/types.h>
#include <regex.h>
/* The kinds of value we can have. */
enum valtype {
integer,
string
};
typedef enum valtype TYPE;
/* A value is.... */
struct valinfo {
TYPE type; /* Which kind. */
union { /* The value itself. */
int i;
char *s;
} u;
};
typedef struct valinfo VALUE;
/* The arguments given to the program, minus the program name. */
static char **args;
static VALUE *docolon (VALUE *sv, VALUE *pv);
static VALUE *eval (void);
static VALUE *int_value (int i);
static VALUE *str_value (char *s);
static int nextarg (char *str);
static int null (VALUE *v);
static int toarith (VALUE *v);
static void freev (VALUE *v);
static void tostring (VALUE *v);
int expr_main (int argc, char **argv)
{
VALUE *v;
if (argc == 1) {
fatalError("too few arguments\n");
}
args = argv + 1;
v = eval ();
if (*args)
fatalError ("syntax error\n");
if (v->type == integer)
printf ("%d\n", v->u.i);
else
printf ("%s\n", v->u.s);
exit (null (v));
}
/* Return a VALUE for I. */
static VALUE *int_value (int i)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = integer;
v->u.i = i;
return v;
}
/* Return a VALUE for S. */
static VALUE *str_value (char *s)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strdup (s);
return v;
}
/* Free VALUE V, including structure components. */
static void freev (VALUE *v)
{
if (v->type == string)
free (v->u.s);
free (v);
}
/* Return nonzero if V is a null-string or zero-number. */
static int null (VALUE *v)
{
switch (v->type) {
case integer:
return v->u.i == 0;
case string:
return v->u.s[0] == '\0' || strcmp (v->u.s, "0") == 0;
default:
abort ();
}
}
/* Coerce V to a string value (can't fail). */
static void tostring (VALUE *v)
{
char *temp;
if (v->type == integer) {
temp = xmalloc (4 * (sizeof (int) / sizeof (char)));
sprintf (temp, "%d", v->u.i);
v->u.s = temp;
v->type = string;
}
}
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
static int toarith (VALUE *v)
{
int i;
switch (v->type) {
case integer:
return 1;
case string:
i = 0;
/* Don't interpret the empty string as an integer. */
if (v->u.s == 0)
return 0;
i = atoi(v->u.s);
free (v->u.s);
v->u.i = i;
v->type = integer;
return 1;
default:
abort ();
}
}
/* Return nonzero if the next token matches STR exactly.
STR must not be NULL. */
static int
nextarg (char *str)
{
if (*args == NULL)
return 0;
return strcmp (*args, str) == 0;
}
/* The comparison operator handling functions. */
#define cmpf(name, rel) \
static int name (l, r) VALUE *l; VALUE *r; \
{ \
if (l->type == string || r->type == string) { \
tostring (l); \
tostring (r); \
return strcmp (l->u.s, r->u.s) rel 0; \
} \
else \
return l->u.i rel r->u.i; \
}
cmpf (less_than, <)
cmpf (less_equal, <=)
cmpf (equal, ==)
cmpf (not_equal, !=)
cmpf (greater_equal, >=)
cmpf (greater_than, >)
#undef cmpf
/* The arithmetic operator handling functions. */
#define arithf(name, op) \
static \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
fatalError ("non-numeric argument\n"); \
return l->u.i op r->u.i; \
}
#define arithdivf(name, op) \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
fatalError ( "non-numeric argument\n"); \
if (r->u.i == 0) \
fatalError ( "division by zero\n"); \
return l->u.i op r->u.i; \
}
arithf (plus, +)
arithf (minus, -)
arithf (multiply, *)
arithdivf (divide, /)
arithdivf (mod, %)
#undef arithf
#undef arithdivf
/* Do the : operator.
SV is the VALUE for the lhs (the string),
PV is the VALUE for the rhs (the pattern). */
static VALUE *docolon (VALUE *sv, VALUE *pv)
{
VALUE *v;
const char *errmsg;
struct re_pattern_buffer re_buffer;
struct re_registers re_regs;
int len;
tostring (sv);
tostring (pv);
if (pv->u.s[0] == '^') {
fprintf (stderr, "\
warning: unportable BRE: `%s': using `^' as the first character\n\
of a basic regular expression is not portable; it is being ignored",
pv->u.s);
}
len = strlen (pv->u.s);
memset (&re_buffer, 0, sizeof (re_buffer));
memset (&re_regs, 0, sizeof (re_regs));
re_buffer.allocated = 2 * len;
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
re_buffer.translate = 0;
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) {
fatalError("%s\n", errmsg);
}
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
if (len >= 0) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
sv->u.s[re_regs.end[1]] = '\0';
v = str_value (sv->u.s + re_regs.start[1]);
}
else
v = int_value (len);
}
else {
/* Match failed -- return the right kind of null. */
if (re_buffer.re_nsub > 0)
v = str_value ("");
else
v = int_value (0);
}
free (re_buffer.buffer);
return v;
}
/* Handle bare operands and ( expr ) syntax. */
static VALUE *eval7 (void)
{
VALUE *v;
if (!*args)
fatalError ( "syntax error\n");
if (nextarg ("(")) {
args++;
v = eval ();
if (!nextarg (")"))
fatalError ( "syntax error\n");
args++;
return v;
}
if (nextarg (")"))
fatalError ( "syntax error\n");
return str_value (*args++);
}
/* Handle match, substr, index, length, and quote keywords. */
static VALUE *eval6 (void)
{
VALUE *l, *r, *v, *i1, *i2;
if (nextarg ("quote")) {
args++;
if (!*args)
fatalError ( "syntax error\n");
return str_value (*args++);
}
else if (nextarg ("length")) {
args++;
r = eval6 ();
tostring (r);
v = int_value (strlen (r->u.s));
freev (r);
return v;
}
else if (nextarg ("match")) {
args++;
l = eval6 ();
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
return v;
}
else if (nextarg ("index")) {
args++;
l = eval6 ();
r = eval6 ();
tostring (l);
tostring (r);
v = int_value (strcspn (l->u.s, r->u.s) + 1);
if (v->u.i == (int) strlen (l->u.s) + 1)
v->u.i = 0;
freev (l);
freev (r);
return v;
}
else if (nextarg ("substr")) {
args++;
l = eval6 ();
i1 = eval6 ();
i2 = eval6 ();
tostring (l);
if (!toarith (i1) || !toarith (i2)
|| i1->u.i > (int) strlen (l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
v = str_value ("");
else {
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1),
l->u.s + i1->u.i - 1, i2->u.i);
v->u.s[i2->u.i] = 0;
}
freev (l);
freev (i1);
freev (i2);
return v;
}
else
return eval7 ();
}
/* Handle : operator (pattern matching).
Calls docolon to do the real work. */
static VALUE *eval5 (void)
{
VALUE *l, *r, *v;
l = eval6 ();
while (nextarg (":")) {
args++;
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
l = v;
}
return l;
}
/* Handle *, /, % operators. */
static VALUE *eval4 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval5 ();
while (1) {
if (nextarg ("*"))
fxn = multiply;
else if (nextarg ("/"))
fxn = divide;
else if (nextarg ("%"))
fxn = mod;
else
return l;
args++;
r = eval5 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle +, - operators. */
static VALUE *eval3 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval4 ();
while (1) {
if (nextarg ("+"))
fxn = plus;
else if (nextarg ("-"))
fxn = minus;
else
return l;
args++;
r = eval4 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle comparisons. */
static VALUE *eval2 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval3 ();
while (1) {
if (nextarg ("<"))
fxn = less_than;
else if (nextarg ("<="))
fxn = less_equal;
else if (nextarg ("=") || nextarg ("=="))
fxn = equal;
else if (nextarg ("!="))
fxn = not_equal;
else if (nextarg (">="))
fxn = greater_equal;
else if (nextarg (">"))
fxn = greater_than;
else
return l;
args++;
r = eval3 ();
toarith (l);
toarith (r);
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle &. */
static VALUE *eval1 (void)
{
VALUE *l, *r;
l = eval2 ();
while (nextarg ("&")) {
args++;
r = eval2 ();
if (null (l) || null (r)) {
freev (l);
freev (r);
l = int_value (0);
}
else
freev (r);
}
return l;
}
/* Handle |. */
static VALUE *eval (void)
{
VALUE *l, *r;
l = eval1 ();
while (nextarg ("|")) {
args++;
r = eval1 ();
if (null (l)) {
freev (l);
l = r;
}
else
freev (r);
}
return l;
}
+5 -14
View File
@@ -22,18 +22,10 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <errno.h>
#include <stdio.h>
const char head_usage[] =
"head [OPTION] [FILE]...\n\n"
"Print first 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
"Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
int head(int len, FILE * src)
{
int i;
@@ -72,7 +64,7 @@ int head_main(int argc, char **argv)
case 'h':
usage(head_usage);
default:
fprintf(stderr, "head: invalid option -- %c\n", opt);
errorMsg("invalid option -- %c\n", opt);
usage(head_usage);
}
} else {
@@ -92,8 +84,7 @@ int head_main(int argc, char **argv)
src = fopen(argv[i], "r");
if (!src) {
fprintf(stderr, "head: %s: %s\n", argv[i],
strerror(errno));
errorMsg("%s: %s\n", argv[i], strerror(errno));
} else {
/* emulating GNU behaviour */
if (need_headers) {
@@ -106,7 +97,7 @@ int head_main(int argc, char **argv)
}
}
}
exit(0);
return(0);
}
/* $Id: head.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
/* $Id: head.c,v 1.14 2000/09/25 21:45:57 andersen Exp $ */
+2 -2
View File
@@ -20,11 +20,11 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int hostid_main(int argc, char **argv)
{
printf("%lx\n", gethostid());
exit(TRUE);
return(TRUE);
}
+93
View File
@@ -0,0 +1,93 @@
/* vi: set sw=4 ts=4: */
/*
* Mini id implementation for busybox
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <getopt.h>
#include <sys/types.h>
extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
char *cp, *user, *group;
long gid;
long pwnam, grnam;
int opt;
cp = user = group = NULL;
gid = 0;
while ((opt = getopt(argc, argv, "ugr")) > 0) {
switch (opt) {
case 'u':
no_group++;
break;
case 'g':
no_user++;
break;
case 'r':
print_real++;
break;
default:
usage(id_usage);
}
}
if (no_user && no_group) usage(id_usage);
user = argv[optind];
if (user == NULL) {
user = xcalloc(9, sizeof(char));
group = xcalloc(9, sizeof(char));
if (print_real) {
my_getpwuid(user, getuid());
my_getgrgid(group, getgid());
} else {
my_getpwuid(user, geteuid());
my_getgrgid(group, getegid());
}
} else {
group = xcalloc(9, sizeof(char));
gid = my_getpwnamegid(user);
my_getgrgid(group, gid);
}
pwnam=my_getpwnam(user);
grnam=my_getgrnam(group);
if (gid == -1 || pwnam==-1 || grnam==-1) {
fatalError("%s: No such user\n", user);
}
if (no_group)
printf("%ld\n", pwnam);
else if (no_user)
printf("%ld\n", grnam);
else
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
return(0);
}
/* END CODE */
+4 -5
View File
@@ -1,14 +1,13 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include "busybox.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-') {
usage("length string\n");
}
printf("%d\n", strlen(argv[1]));
if (argc != 2 || **(argv + 1) == '-')
usage(length_usage);
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
}
+50 -56
View File
@@ -21,25 +21,14 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_not_a_directory
#include "messages.c"
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <sys/param.h> /* for PATH_MAX */
static const char ln_usage[] =
"ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
"Options:\n"
"\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"
"\t-n\tno dereference symlinks - treat like normal file\n";
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
@@ -47,65 +36,65 @@ static int followLinks = TRUE;
extern int ln_main(int argc, char **argv)
{
char *linkName;
char *linkName, *dirName=NULL;
int linkIntoDirFlag;
int stopIt = FALSE;
if (argc < 3) {
usage(ln_usage);
}
argc--;
argv++;
/* Parse any options */
while (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 's':
symlinkFlag = TRUE;
break;
case 'f':
removeoldFlag = TRUE;
break;
case 'n':
followLinks = FALSE;
break;
default:
usage(ln_usage);
}
argc--;
argv++;
while (argc > 0 && stopIt == FALSE) {
if (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 's':
symlinkFlag = TRUE;
break;
case 'f':
removeoldFlag = TRUE;
break;
case 'n':
followLinks = FALSE;
break;
case '-':
stopIt = TRUE;
break;
default:
usage(ln_usage);
}
argc--;
argv++;
}
else
break;
}
if (argc < 2) {
usage(ln_usage);
}
linkName = argv[argc - 1];
if (strlen(linkName) > PATH_MAX) {
fprintf(stderr, name_too_long, "ln");
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
if ((argc >= 3) && linkIntoDirFlag == FALSE) {
errorMsg(not_a_directory, linkName);
exit FALSE;
}
linkIntoDirFlag = isDirectory(linkName, TRUE, NULL);
if ((argc > 3) && !linkIntoDirFlag) {
fprintf(stderr, not_a_directory, "ln", linkName);
exit FALSE;
}
if (linkIntoDirFlag == TRUE)
dirName = linkName;
while (argc-- >= 2) {
char srcName[PATH_MAX + 1];
int nChars, status;
int status;
if (strlen(*argv) > PATH_MAX) {
fprintf(stderr, name_too_long, "ln");
exit FALSE;
}
if (followLinks == FALSE) {
strcpy(srcName, *argv);
} else {
/* Warning! This can silently truncate if > PATH_MAX, but
I don't think that there can be one > PATH_MAX anyway. */
nChars = readlink(*argv, srcName, PATH_MAX);
srcName[nChars] = '\0';
if (linkIntoDirFlag == TRUE) {
char *baseName = get_last_path_component(*argv);
linkName = (char *)xmalloc(strlen(dirName)+strlen(baseName)+2);
strcpy(linkName, dirName);
if(dirName[strlen(dirName)-1] != '/')
strcat(linkName, "/");
strcat(linkName,baseName);
}
if (removeoldFlag == TRUE) {
@@ -124,8 +113,13 @@ extern int ln_main(int argc, char **argv)
perror(linkName);
exit FALSE;
}
if (linkIntoDirFlag == TRUE)
free(linkName);
argv++;
}
exit TRUE;
return( TRUE);
}
/*
+7 -11
View File
@@ -20,25 +20,21 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
static const char logname_usage[] = "logname\n\n"
"Print the name of the current user.\n";
extern int logname_main(int argc, char **argv)
{
char *cp;
char *user = xmalloc(9);
if (argc > 1)
usage(logname_usage);
cp = getlogin();
if (cp) {
puts(cp);
my_getpwuid(user, geteuid());
if (user) {
puts(user);
exit(TRUE);
}
fprintf(stderr, "%s: no login name\n", argv[0]);
exit(FALSE);
errorMsg("no login name\n");
return(FALSE);
}
+714 -451
View File
File diff suppressed because it is too large. Load diff
+1004
View File
File diff suppressed because it is too large. Load diff
+7 -17
View File
@@ -21,23 +21,13 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
#include "messages.c"
#include <stdio.h>
#include <errno.h>
#include <sys/param.h> /* for PATH_MAX */
static const char mkdir_usage[] =
"mkdir [OPTION] DIRECTORY...\n\n"
"Create the DIRECTORY(ies), if they do not already exist\n\n"
"Options:\n"
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
"\t-p\tno error if existing, make parent directories as needed\n";
static int parentFlag = FALSE;
static mode_t mode = 0777;
@@ -60,7 +50,7 @@ extern int mkdir_main(int argc, char **argv)
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
fprintf(stderr, "Unknown mode: %s\n", *argv);
errorMsg("Unknown mode: %s\n", *argv);
exit FALSE;
}
/* Set the umask for this process so it doesn't
@@ -86,16 +76,16 @@ extern int mkdir_main(int argc, char **argv)
while (argc > 0) {
int status;
struct stat statBuf;
char buf[PATH_MAX + 1];
char buf[BUFSIZ + 1];
if (strlen(*argv) > PATH_MAX - 1) {
fprintf(stderr, name_too_long, "mkdir");
if (strlen(*argv) > BUFSIZ - 1) {
errorMsg(name_too_long);
exit FALSE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
fprintf(stderr, "%s: File exists\n", buf);
errorMsg("%s: File exists\n", buf);
exit FALSE;
}
if (parentFlag == TRUE) {
@@ -110,5 +100,5 @@ extern int mkdir_main(int argc, char **argv)
argc--;
argv++;
}
exit TRUE;
return( TRUE);
}
+3 -11
View File
@@ -20,18 +20,11 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
"Creates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
"\t-m\tcreate the pipe using the specified mode (default a=rw)\n";
extern int mkfifo_main(int argc, char **argv)
{
char *thisarg;
@@ -58,12 +51,11 @@ extern int mkfifo_main(int argc, char **argv)
argc--;
argv++;
}
if (argc < 1)
if (argc < 1 || *argv[0] == '-')
usage(mkfifo_usage);
if (mkfifo(*argv, mode) < 0) {
perror("mkfifo");
exit(255);
} else {
exit(TRUE);
}
return(TRUE);
}
+4 -13
View File
@@ -20,23 +20,13 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n"
"Create a special file (block, character, or pipe).\n\n"
"Options:\n"
"\t-m\tcreate the special file using the specified mode (default a=rw)\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n";
int mknod_main(int argc, char **argv)
{
char *thisarg;
@@ -58,6 +48,7 @@ int mknod_main(int argc, char **argv)
argc--;
argv++;
parse_mode(*argv, &perm);
umask(0);
break;
default:
usage(mknod_usage);
@@ -87,13 +78,13 @@ int mknod_main(int argc, char **argv)
}
if (mode == S_IFCHR || mode == S_IFBLK) {
dev = (atoi(argv[2]) << 8) | atoi(argv[1]);
dev = (atoi(argv[2]) << 8) | atoi(argv[3]);
}
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
fatalError("%s: %s\n", argv[0], strerror(errno));
exit (TRUE);
return (TRUE);
}
+2 -7
View File
@@ -47,18 +47,15 @@
// 19990508 Busy Boxed! Dave Cinege
#include "internal.h"
#include "busybox.h"
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <getopt.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <ctype.h>
#include <libintl.h>
#ifndef S_IFMT
@@ -139,8 +136,6 @@ static void verify __P((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n";
int printf_main(int argc, char **argv)
{
char *format;
@@ -167,7 +162,7 @@ int printf_main(int argc, char **argv)
fprintf(stderr, "excess args ignored");
*/
exit(exit_status);
return(exit_status);
}
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
+6 -8
View File
@@ -21,20 +21,18 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <dirent.h>
#include <sys/param.h>
#include <errno.h>
extern int pwd_main(int argc, char **argv)
{
char buf[PATH_MAX + 1];
char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL) {
perror("get working directory");
exit(FALSE);
}
if (getcwd(buf, sizeof(buf)) == NULL)
fatalError("%s\n", strerror(errno));
printf("%s\n", buf);
exit(TRUE);
return(TRUE);
}
+34 -28
View File
@@ -22,21 +22,13 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <time.h>
#include <utime.h>
#include <dirent.h>
#include <errno.h>
static const char *rm_usage = "rm [OPTION]... FILE...\n\n"
"Remove (unlink) the FILE(s).\n\n"
"Options:\n"
"\t-f\t\tremove existing destinations, never prompt\n"
"\t-r or -R\tremove the contents of directories recursively\n";
static int recursiveFlag = FALSE;
static int forceFlag = FALSE;
static const char *srcName;
@@ -53,6 +45,11 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
perror(fileName);
return (FALSE);
}
if (rmdir(fileName) < 0) {
perror(fileName);
return (FALSE);
@@ -62,30 +59,39 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
extern int rm_main(int argc, char **argv)
{
int stopIt=FALSE;
struct stat statbuf;
if (argc < 2) {
usage(rm_usage);
}
argc--;
argv++;
/* Parse any options */
while (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 'R':
case 'r':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
default:
usage(rm_usage);
}
argc--;
argv++;
while (argc > 0 && stopIt == FALSE) {
if (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 'R':
case 'r':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
case '-':
stopIt = TRUE;
break;
default:
usage(rm_usage);
}
argc--;
argv++;
}
else
break;
}
if (argc < 1 && forceFlag == FALSE) {
usage(rm_usage);
}
while (argc-- > 0) {
@@ -100,5 +106,5 @@ extern int rm_main(int argc, char **argv)
}
}
}
exit(TRUE);
return(TRUE);
}
+5 -8
View File
@@ -22,23 +22,20 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
extern int rmdir_main(int argc, char **argv)
{
if (argc == 1 || **(argv + 1) == '-') {
usage
("rmdir [OPTION]... DIRECTORY...\n\nRemove the DIRECTORY(ies), if they are empty.\n");
}
if (argc == 1 || **(argv + 1) == '-')
usage(rmdir_usage);
while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
fprintf(stderr, "%s: %s\n", *argv, strerror(errno));
errorMsg("%s\n", strerror(errno));
exit(FALSE);
}
}
exit(TRUE);
return(TRUE);
}
+3 -5
View File
@@ -21,11 +21,9 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
const char sleep_usage[] = "sleep N\n\n" "Pause for N seconds.\n";
extern int sleep_main(int argc, char **argv)
{
if ((argc < 2) || (**(argv + 1) == '-')) {
@@ -35,6 +33,6 @@ extern int sleep_main(int argc, char **argv)
if (sleep(atoi(*(++argv))) != 0) {
perror("sleep");
exit(FALSE);
} else
exit(TRUE);
}
return(TRUE);
}
+7 -19
View File
@@ -22,19 +22,13 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
static const char sort_usage[] = "sort [-n]"
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
" [FILE]...\n\nSorts lines of text in the specified files\n";
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
static int reverse = 0;
@@ -70,7 +64,7 @@ static const int max = 1024;
static Line *line_alloc()
{
Line *self;
self = malloc(1 * sizeof(Line));
self = xmalloc(1 * sizeof(Line));
return self;
}
@@ -80,11 +74,8 @@ static Line *line_newFromFile(FILE * src)
Line *self;
char *cstring = NULL;
if ((cstring = cstring_lineFromFile(src))) {
if ((cstring = get_line_from_file(src))) {
self = line_alloc();
if (self == NULL) {
return NULL;
}
self->data = cstring;
self->next = NULL;
return self;
@@ -179,10 +170,7 @@ static List *list_sort(List * self, Compare * compare)
Line *line;
/* mallocate array of Line*s */
self->sorted = (Line **) malloc(self->len * sizeof(Line *));
if (self->sorted == NULL) {
return NULL;
}
self->sorted = (Line **) xmalloc(self->len * sizeof(Line *));
/* fill array w/ List's contents */
i = 0;
@@ -259,7 +247,7 @@ int sort_main(int argc, char **argv)
break;
#endif
default:
fprintf(stderr, "sort: invalid option -- %c\n", opt);
errorMsg("invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
@@ -297,7 +285,7 @@ int sort_main(int argc, char **argv)
list_release(&list);
}
exit(0);
return(0);
}
/* $Id: sort.c,v 1.15 2000/04/17 04:22:09 beppu Exp $ */
/* $Id: sort.c,v 1.22 2000/09/25 21:45:58 andersen Exp $ */
+4 -5
View File
@@ -21,13 +21,12 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int sync_main(int argc, char **argv)
{
if (argc > 1 && **(argv + 1) == '-') {
usage("sync\n\nWrite all buffered filesystem blocks to disk.\n");
}
exit(sync());
if (argc > 1 && **(argv + 1) == '-')
usage(sync_usage);
return(sync());
}
+274 -1155
View File
File diff suppressed because it is too large. Load diff
+32 -98
View File
@@ -2,9 +2,8 @@
/*
* Mini tee implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,113 +21,48 @@
*
*/
#include "internal.h"
#include <errno.h>
#include "busybox.h"
#include <getopt.h>
#include <stdio.h>
static const char tee_usage[] =
"tee [OPTION]... [FILE]...\n\n"
"Copy standard input to each FILE, and also to standard output.\n\n"
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
#if 0
"\t-i\tignore interrupt signals\n"
#endif
;
/* FileList _______________________________________________________________ */
#define FL_MAX 1024
static FILE **FileList;
static int FL_end;
typedef void (FL_Function) (FILE * file, char c);
/* apply a function to everything in FileList */
static void FL_apply(FL_Function * f, char c)
int
tee_main(int argc, char **argv)
{
int i;
char *mode = "w";
int c, i, status = 0, nfiles = 0;
FILE **files;
for (i = 0; i <= FL_end; i++) {
f(FileList[i], c);
}
}
/* FL_Function for writing to files*/
static void tee_fwrite(FILE * file, char c)
{
fputc(c, file);
}
/* FL_Function for closing files */
static void tee_fclose(FILE * file, char c)
{
fclose(file);
}
/* ________________________________________________________________________ */
/* BusyBoxed tee(1) */
int tee_main(int argc, char **argv)
{
int i;
char c;
char opt;
char opt_fopen[2] = "w";
FILE *file;
/* parse argv[] */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'a':
opt_fopen[0] = 'a';
break;
#if 0
case 'i':
fprintf(stderr, "ignore interrupt not implemented\n");
break;
#endif
default:
usage(tee_usage);
}
} else {
while ((c = getopt(argc, argv, "a")) != EOF) {
switch (c) {
case 'a':
mode = "a";
break;
default:
usage(tee_usage);
}
}
/* init FILE pointers */
FileList = calloc(FL_MAX, sizeof(FILE*));
if (!FileList) {
fprintf(stderr, "tee: %s\n", strerror(errno));
exit(1);
}
FL_end = 0;
FileList[0] = stdout;
for (; i < argc; i++) {
/* add a file to FileList */
file = fopen(argv[i], opt_fopen);
if (!file) {
continue;
}
if (FL_end < FL_MAX) {
FileList[++FL_end] = file;
files = (FILE **)xmalloc(sizeof(FILE *) * (argc - optind + 1));
files[nfiles++] = stdout;
while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--;
errorMsg("%s: %s\n", argv[optind-1], strerror(errno));
status = 1;
}
}
/* read and redirect */
while ((c = (char) getchar()) && (!feof(stdin))) {
FL_apply(tee_fwrite, c);
}
while ((c = getchar()) != EOF)
for (i = 0; i < nfiles; i++)
putc(c, files[i]);
/* clean up */
FL_apply(tee_fclose, 0);
/* Don't bother to close files Exit does that
* automagically, so we can save a few bytes */
/* free(FileList); */
exit(0);
return status;
}
/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+14 -21
View File
@@ -31,14 +31,16 @@
* "This program is in the Public Domain."
*/
#include "internal.h"
#include "busybox.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
@@ -180,18 +182,11 @@ test_main(int argc, char** argv)
{
int res;
if (strcmp(argv[0], "[") == 0) {
if (strcmp(applet_name, "[") == 0) {
if (strcmp(argv[--argc], "]"))
fatalError("missing ]");
fatalError("missing ]\n");
argv[argc] = NULL;
}
if (strcmp(argv[1], "--help") == 0) {
usage("test EXPRESSION\n"
"or [ EXPRESSION ]\n\n"
"Checks file types and compares values returning an exit\n"
"code determined by the value of EXPRESSION.\n");
}
/* Implement special cases from POSIX.2, section 4.62.4 */
switch (argc) {
case 1:
@@ -229,7 +224,7 @@ test_main(int argc, char** argv)
if (*t_wp != NULL && *++t_wp != NULL)
syntax(*t_wp, "unknown operand");
exit( res);
return( res);
}
static void
@@ -238,9 +233,9 @@ syntax(op, msg)
char *msg;
{
if (op && *op)
fatalError("%s: %s", op, msg);
fatalError("%s: %s\n", op, msg);
else
fatalError("%s", msg);
fatalError("%s\n", msg);
}
static int
@@ -366,7 +361,7 @@ filstat(nm, mode)
enum token mode;
{
struct stat s;
int i;
unsigned int i;
if (mode == FILSYM) {
#ifdef S_IFLNK
@@ -475,13 +470,13 @@ getn(s)
r = strtol(s, &p, 10);
if (errno != 0)
fatalError("%s: out of range", s);
fatalError("%s: out of range\n", s);
while (isspace(*p))
p++;
if (*p)
fatalError("%s: bad number", s);
fatalError("%s: bad number\n", s);
return (int) r;
}
@@ -529,7 +524,7 @@ char *path;
int mode;
{
struct stat st;
int euid = geteuid();
unsigned int euid = geteuid();
if (stat (path, &st) < 0)
return (-1);
@@ -560,9 +555,7 @@ static void
initialize_group_array ()
{
ngroups = getgroups(0, NULL);
if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL)
fatalError("Out of space");
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
getgroups(ngroups, group_array);
}
+25 -32
View File
@@ -22,35 +22,21 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <utime.h>
#include <errno.h>
static const char touch_usage[] = "touch [-c] file [file ...]\n\n"
"Update the last-modified date on the given file[s].\n";
extern int touch_main(int argc, char **argv)
{
int fd;
int create = TRUE;
if (argc < 2) {
usage(touch_usage);
}
argc--;
argv++;
/* Parse options */
while (**argv == '-') {
while (*++(*argv))
while (--argc > 0 && **(++argv) == '-') {
while (*(++(*argv))) {
switch (**argv) {
case 'c':
create = FALSE;
@@ -59,23 +45,30 @@ extern int touch_main(int argc, char **argv)
usage(touch_usage);
exit(FALSE);
}
}
}
if (argc < 1) {
usage(touch_usage);
}
while (argc > 0) {
fd = open(*argv, (create == FALSE) ? O_RDWR : O_RDWR | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0) {
if (create == FALSE && errno == ENOENT)
exit(TRUE);
else {
fatalError("%s", strerror(errno));
}
}
close(fd);
if (utime(*argv, NULL)) {
fatalError("%s", strerror(errno));
}
argc--;
argv++;
}
fd = open(*argv, (create == FALSE) ? O_RDWR : O_RDWR | O_CREAT, 0644);
if (fd < 0) {
if (create == FALSE && errno == ENOENT)
exit(TRUE);
else {
perror("touch");
exit(FALSE);
}
}
close(fd);
if (utime(*argv, NULL)) {
perror("touch");
exit(FALSE);
} else
exit(TRUE);
return(TRUE);
}
+204 -547
View File
@@ -1,574 +1,231 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
* Mini tr implementation for busybox
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Copyright (c) Michiel Huisjes
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* This version of tr is adapted from Minix tr and was modified
* by Erik Andersen <andersee@debian.org> to be used in busybox.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice is retained at the end of this file.
*/
#if 0
#ifndef lint
static const char copyright[] = "@(#) Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$Id: tr.c,v 1.4 2000/04/17 16:44:46 erik Exp $";
#endif /* not lint */
#endif /* #if 0 */
#include "internal.h"
#include <locale.h>
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <err.h>
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#define BB_DECLARE_EXTERN
#define bb_need_write_error
#include "messages.c"
#include <ctype.h>
#include <err.h>
#include <stddef.h>
#ifdef TRUE
#undef TRUE
#undef FALSE
#define TRUE 1
#define FALSE 0
#endif
typedef struct {
enum { STRING1, STRING2 } which;
enum { EOS, INFINITE, NORMAL, RANGE, SEQUENCE, SET } state;
int cnt; /* character count */
int lastch; /* last character */
int equiv[2]; /* equivalence set */
int *set; /* set of characters */
char *str; /* user's string */
} STR;
#define ASCII 0377
#include <limits.h>
#define NCHARS (UCHAR_MAX + 1) /* Number of possible characters. */
#define OOBCH (UCHAR_MAX + 1) /* Out of band character value. */
/* some glabals shared across this file */
static char com_fl, del_fl, sq_fl;
static unsigned char output[BUFSIZ], input[BUFSIZ];
static unsigned char vector[ASCII + 1];
static char invec[ASCII + 1], outvec[ASCII + 1];
static short in_index, out_index;
static int next __P((STR *));
static int string1[NCHARS] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* ASCII */
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
}, string2[NCHARS];
STR s1 = { STRING1, NORMAL, 0, OOBCH, {0, OOBCH}, NULL, NULL };
STR s2 = { STRING2, NORMAL, 0, OOBCH, {0, OOBCH}, NULL, NULL };
static void setup(string, arg, str, cflag)
int *string;
char *arg;
STR *str;
int cflag;
static void convert()
{
register int cnt, *p;
short read_chars = 0;
short c, coded;
short last = -1;
str->str = arg;
bzero(string, NCHARS * sizeof(int));
while (next(str))
string[str->lastch] = 1;
if (cflag)
for (p = string, cnt = NCHARS; cnt--; ++p)
*p = !*p;
}
static void tr_usage()
{
usage( "\ttr [-cdsu] string1 [string2]\n\n"
"Translate, squeeze, and/or delete characters from standard\n"
"input, writing to standard output.\n");
}
extern int tr_main(argc, argv)
int argc;
char **argv;
{
register int ch, cnt, lastch, *p;
int cflag, dflag, sflag, isstring2;
(void) setlocale(LC_CTYPE, "");
cflag = dflag = sflag = 0;
while ((ch = getopt(argc, argv, "cdsu")) != -1)
switch ((char) ch) {
case 'c':
cflag = 1;
break;
case 'd':
dflag = 1;
break;
case 's':
sflag = 1;
break;
case 'u':
setbuf(stdout, (char *) NULL);
break;
case '?':
default:
tr_usage();
}
argc -= optind;
argv += optind;
switch (argc) {
case 0:
default:
tr_usage();
/* NOTREACHED */
case 1:
isstring2 = 0;
break;
case 2:
isstring2 = 1;
break;
}
/*
* tr -ds [-c] string1 string2
* Delete all characters (or complemented characters) in string1.
* Squeeze all characters in string2.
*/
if (dflag && sflag) {
if (!isstring2)
tr_usage();
setup(string1, argv[0], &s1, cflag);
setup(string2, argv[1], &s2, 0);
for (lastch = OOBCH; (ch = getchar()) != EOF;)
if (!string1[ch] && (!string2[ch] || lastch != ch)) {
lastch = ch;
(void) putchar(ch);
for (;;) {
if (in_index == read_chars) {
if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) {
if (write(1, (char *) output, out_index) != out_index)
write(2, write_error, strlen(write_error));
exit(0);
}
exit(0);
}
/*
* tr -d [-c] string1
* Delete all characters (or complemented characters) in string1.
*/
if (dflag) {
if (isstring2)
tr_usage();
setup(string1, argv[0], &s1, cflag);
while ((ch = getchar()) != EOF)
if (!string1[ch])
(void) putchar(ch);
exit(0);
}
/*
* tr -s [-c] string1
* Squeeze all characters (or complemented characters) in string1.
*/
if (sflag && !isstring2) {
setup(string1, argv[0], &s1, cflag);
for (lastch = OOBCH; (ch = getchar()) != EOF;)
if (!string1[ch] || lastch != ch) {
lastch = ch;
(void) putchar(ch);
in_index = 0;
}
c = input[in_index++];
coded = vector[c];
if (del_fl && invec[c])
continue;
if (sq_fl && last == coded && outvec[coded])
continue;
output[out_index++] = last = coded;
if (out_index == BUFSIZ) {
if (write(1, (char *) output, out_index) != out_index) {
write(2, write_error, strlen(write_error));
exit(1);
}
exit(0);
out_index = 0;
}
}
/*
* tr [-cs] string1 string2
* Replace all characters (or complemented characters) in string1 with
* the character in the same position in string2. If the -s option is
* specified, squeeze all the characters in string2.
*/
if (!isstring2)
tr_usage();
s1.str = argv[0];
s2.str = argv[1];
if (cflag)
for (cnt = NCHARS, p = string1; cnt--;)
*p++ = OOBCH;
if (!next(&s2))
errx(1, "empty string2");
/* If string2 runs out of characters, use the last one specified. */
if (sflag)
while (next(&s1)) {
string1[s1.lastch] = ch = s2.lastch;
string2[ch] = 1;
(void) next(&s2);
} else
while (next(&s1)) {
string1[s1.lastch] = ch = s2.lastch;
(void) next(&s2);
}
if (cflag)
for (cnt = 0, p = string1; cnt < NCHARS; ++p, ++cnt)
*p = *p == OOBCH ? ch : cnt;
if (sflag)
for (lastch = OOBCH; (ch = getchar()) != EOF;) {
ch = string1[ch];
if (!string2[ch] || lastch != ch) {
lastch = ch;
(void) putchar(ch);
}
} else
while ((ch = getchar()) != EOF)
(void) putchar(string1[ch]);
exit(0);
}
static int backslash __P((STR *));
static int bracket __P((STR *));
static int c_class __P((const void *, const void *));
static void genclass __P((STR *));
static void genequiv __P((STR *));
static int genrange __P((STR *));
static void genseq __P((STR *));
static int next(s)
register STR *s;
{
register int ch;
switch (s->state) {
case EOS:
return (0);
case INFINITE:
return (1);
case NORMAL:
switch (ch = (u_char) * s->str) {
case '\0':
s->state = EOS;
return (0);
case '\\':
s->lastch = backslash(s);
break;
case '[':
if (bracket(s))
return (next(s));
/* FALLTHROUGH */
default:
++s->str;
s->lastch = ch;
break;
}
/* We can start a range at any time. */
if (s->str[0] == '-' && genrange(s))
return (next(s));
return (1);
case RANGE:
if (s->cnt-- == 0) {
s->state = NORMAL;
return (next(s));
}
++s->lastch;
return (1);
case SEQUENCE:
if (s->cnt-- == 0) {
s->state = NORMAL;
return (next(s));
}
return (1);
case SET:
if ((s->lastch = s->set[s->cnt++]) == OOBCH) {
s->state = NORMAL;
return (next(s));
}
return (1);
}
/* NOTREACHED */
}
static void map(register unsigned char *string1, unsigned int string1_len,
register unsigned char *string2, unsigned int string2_len)
{
unsigned char last = '0';
unsigned int i, j;
for (j = 0, i = 0; i < string1_len; i++) {
if (string2_len <= j)
vector[string1[i]] = last;
else
vector[string1[i]] = last = string2[j++];
}
}
static unsigned int expand(char *arg, register unsigned char *buffer)
{
unsigned char *buffer_start = buffer;
int i, ac;
while (*arg) {
if (*arg == '\\') {
arg++;
*buffer++ = process_escape_sequence(&arg);
} else if (*arg == '[') {
arg++;
i = *arg++;
if (*arg++ != '-') {
*buffer++ = '[';
arg -= 2;
continue;
}
ac = *arg++;
while (i <= ac)
*buffer++ = i++;
arg++; /* Skip ']' */
} else
*buffer++ = *arg++;
}
return (buffer - buffer_start);
}
static int complement(unsigned char *buffer, int buffer_len)
{
register short i, j, index;
char conv[ASCII + 2];
index = 0;
for (i = 0; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++)
if (buffer[j] == i)
break;
if (j == buffer_len)
conv[index++] = i & ASCII;
}
memcpy(buffer, conv, index);
return index;
}
extern int tr_main(int argc, char **argv)
{
register unsigned char *ptr;
int output_length=0, input_length;
int index = 1;
int i;
if (argc > 1 && argv[index][0] == '-') {
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
switch (*ptr) {
case 'c':
com_fl = TRUE;
break;
case 'd':
del_fl = TRUE;
break;
case 's':
sq_fl = TRUE;
break;
default:
usage(tr_usage);
}
}
index++;
}
for (i = 0; i <= ASCII; i++) {
vector[i] = i;
invec[i] = outvec[i] = FALSE;
}
if (argv[index] != NULL) {
input_length = expand(argv[index++], input);
if (com_fl)
input_length = complement(input, input_length);
if (argv[index] != NULL) {
if (*argv[index] == '\0')
fatalError("STRING2 cannot be empty\n");
output_length = expand(argv[index], output);
map(input, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)
invec[input[i]] = TRUE;
for (i = 0; i < output_length; i++)
outvec[output[i]] = TRUE;
}
convert();
return (0);
}
static int bracket(s)
register STR *s;
{
register char *p;
switch (s->str[1]) {
case ':': /* "[:class:]" */
if ((p = strstr(s->str + 2, ":]")) == NULL)
return (0);
*p = '\0';
s->str += 2;
genclass(s);
s->str = p + 2;
return (1);
case '=': /* "[=equiv=]" */
if ((p = strstr(s->str + 2, "=]")) == NULL)
return (0);
s->str += 2;
genequiv(s);
return (1);
default: /* "[\###*n]" or "[#*n]" */
if ((p = strpbrk(s->str + 2, "*]")) == NULL)
return (0);
if (p[0] != '*' || index(p, ']') == NULL)
return (0);
s->str += 1;
genseq(s);
return (1);
}
/* NOTREACHED */
}
typedef struct {
char *name;
int (*func) __P((int));
int *set;
} CLASS;
static CLASS classes[] = {
#undef isalnum
{"alnum", isalnum,},
#undef isalpha
{"alpha", isalpha,},
/*#undef isblank
{ "blank", isblank, },*/
#undef iscntrl
{"cntrl", iscntrl,},
#undef isdigit
{"digit", isdigit,},
#undef isgraph
{"graph", isgraph,},
#undef islower
{"lower", islower,},
#undef isprint
{"print", isprint,},
#undef ispunct
{"punct", ispunct,},
#undef isspace
{"space", isspace,},
#undef isupper
{"upper", isupper,},
#undef isxdigit
{"xdigit", isxdigit,},
};
static void genclass(s)
STR *s;
{
register int cnt, (*func) __P((int));
CLASS *cp, tmp;
int *p;
tmp.name = s->str;
if ((cp = (CLASS *) bsearch(&tmp, classes, sizeof(classes) /
sizeof(CLASS), sizeof(CLASS),
c_class)) == NULL) errx(1,
"unknown class %s",
s->str);
cp->set = p = xmalloc((NCHARS + 1) * sizeof(int));
bzero(p, (NCHARS + 1) * sizeof(int));
for (cnt = 0, func = cp->func; cnt < NCHARS; ++cnt)
if ((func) (cnt))
*p++ = cnt;
*p = OOBCH;
s->cnt = 0;
s->state = SET;
s->set = cp->set;
}
static int c_class(a, b)
const void *a, *b;
{
return (strcmp(((CLASS *) a)->name, ((CLASS *) b)->name));
}
/*
* English doesn't have any equivalence classes, so for now
* we just syntax check and grab the character.
* Copyright (c) 1987,1997, Prentice Hall
* All rights reserved.
*
* Redistribution and use of the MINIX operating system in source and
* binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of Prentice Hall nor the names of the software
* authors or contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
static void genequiv(s)
STR *s;
{
if (*s->str == '\\') {
s->equiv[0] = backslash(s);
if (*s->str != '=')
errx(1, "misplaced equivalence equals sign");
} else {
s->equiv[0] = s->str[0];
if (s->str[1] != '=')
errx(1, "misplaced equivalence equals sign");
}
s->str += 2;
s->cnt = 0;
s->state = SET;
s->set = s->equiv;
}
static int genrange(s)
STR *s;
{
int stopval;
char *savestart;
savestart = s->str;
stopval = *++s->str == '\\' ? backslash(s) : (u_char) * s->str++;
if (stopval < (u_char) s->lastch) {
s->str = savestart;
return (0);
}
s->cnt = stopval - s->lastch + 1;
s->state = RANGE;
--s->lastch;
return (1);
}
static void genseq(s)
STR *s;
{
char *ep;
if (s->which == STRING1)
errx(1, "sequences only valid in string2");
if (*s->str == '\\')
s->lastch = backslash(s);
else
s->lastch = *s->str++;
if (*s->str != '*')
errx(1, "misplaced sequence asterisk");
switch (*++s->str) {
case '\\':
s->cnt = backslash(s);
break;
case ']':
s->cnt = 0;
++s->str;
break;
default:
if (isdigit((u_char) * s->str)) {
s->cnt = strtol(s->str, &ep, 0);
if (*ep == ']') {
s->str = ep + 1;
break;
}
}
errx(1, "illegal sequence count");
/* NOTREACHED */
}
s->state = s->cnt ? SEQUENCE : INFINITE;
}
/*
* Translate \??? into a character. Up to 3 octal digits, if no digits either
* an escape code or a literal character.
*/
static int backslash(s)
register STR *s;
{
register int ch, cnt, val;
for (cnt = val = 0;;) {
ch = (u_char) * ++s->str;
if (!isascii(ch) || !isdigit(ch))
break;
val = val * 8 + ch - '0';
if (++cnt == 3) {
++s->str;
break;
}
}
if (cnt)
return (val);
if (ch != '\0')
++s->str;
switch (ch) {
case 'a': /* escape characters */
return ('\7');
case 'b':
return ('\b');
case 'f':
return ('\f');
case 'n':
return ('\n');
case 'r':
return ('\r');
case 't':
return ('\t');
case 'v':
return ('\13');
case '\0': /* \" -> \ */
s->state = EOS;
return ('\\');
default: /* \x" -> x */
return (ch);
}
}
+2 -7
View File
@@ -20,15 +20,10 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <sys/types.h>
static const char tty_usage[] = "tty\n\n"
"Print the file name of the terminal connected to standard input.\n\n"
"Options:\n"
"\t-s\tprint nothing, only return an exit status\n";
extern int tty_main(int argc, char **argv)
{
char *tty;
@@ -43,5 +38,5 @@ extern int tty_main(int argc, char **argv)
else
puts("not a tty");
}
exit(isatty(0) ? TRUE : FALSE);
return(isatty(0) ? TRUE : FALSE);
}
+2 -20
View File
@@ -31,7 +31,7 @@
/* Busyboxed by Erik Andersen */
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/utsname.h>
@@ -40,24 +40,6 @@
# include <sys/systeminfo.h>
#endif
static const char uname_usage[] =
"uname [OPTION]...\n\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"Print certain system information. With no OPTION, same as -s.\n\n"
"Options:\n"
"\t-a\tprint all information\n"
"\t-m\tthe machine (hardware) type\n"
"\t-n\tprint the machine's network node hostname\n"
"\t-r\tprint the operating system release\n"
"\t-s\tprint the operating system name\n"
"\t-p\tprint the host processor type\n"
"\t-v\tprint the operating system version\n"
#endif
;
static void print_element(unsigned int mask, char *element);
/* Values that are bitwise or'd into `toprint'. */
@@ -156,7 +138,7 @@ int uname_main(int argc, char **argv)
print_element(PRINT_MACHINE, name.machine);
print_element(PRINT_PROCESSOR, processor);
exit(TRUE);
return(TRUE);
}
/* If the name element set in MASK is selected for printing in `toprint',
+5 -10
View File
@@ -22,16 +22,11 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
static const char uniq_usage[] =
"uniq [OPTION]... [INPUT [OUTPUT]]\n\n"
"Discard all but one of successive identical lines from INPUT\n"
"(or standard input), writing to OUTPUT (or standard output).\n";
/* max chars in line */
#define UNIQ_MAX 4096
@@ -124,11 +119,11 @@ set_file_pointers(int schema, FILE ** in, FILE ** out, char **argv)
break;
}
if (*in == NULL) {
fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno));
errorMsg("%s: %s\n", argv[0], strerror(errno));
return errno;
}
if (*out == NULL) {
fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno));
errorMsg("%s: %s\n", argv[1], strerror(errno));
return errno;
}
return 0;
@@ -181,7 +176,7 @@ int uniq_main(int argc, char **argv)
subject_last(&s);
subject_study(&s);
exit(0);
return(0);
}
/* $Id: uniq.c,v 1.9 2000/04/17 16:16:10 erik Exp $ */
/* $Id: uniq.c,v 1.14 2000/09/25 21:45:58 andersen Exp $ */
+2 -4
View File
@@ -21,12 +21,10 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdlib.h>
#include <unistd.h>
const char usleep_usage[] = "usleep N\n\n" "Pause for N microseconds.\n";
extern int usleep_main(int argc, char **argv)
{
if ((argc < 2) || (**(argv + 1) == '-')) {
@@ -34,5 +32,5 @@ extern int usleep_main(int argc, char **argv)
}
usleep(atoi(*(++argv))); /* return void */
exit(TRUE);
return(TRUE);
}
+342
View File
@@ -0,0 +1,342 @@
/* uudecode.c -- uudecode utility.
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
*
* This product is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This product is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this product; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
/* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <pwd.h>
/*struct passwd *getpwnam();*/
/* Single character decode. */
#define DEC(Char) (((Char) - ' ') & 077)
static int read_stduu (const char *inname)
{
char buf[2 * BUFSIZ];
while (1) {
int n;
char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
errorMsg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
/* N is used to avoid writing out all the characters at the end of
the file. */
n = DEC (*p);
if (n <= 0)
break;
for (++p; n > 0; p += 4, n -= 3) {
char ch;
if (n >= 3) {
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
putchar (ch);
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
putchar (ch);
ch = DEC (p[2]) << 6 | DEC (p[3]);
putchar (ch);
} else {
if (n >= 1) {
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
putchar (ch);
}
if (n >= 2) {
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
putchar (ch);
}
}
}
}
if (fgets (buf, sizeof(buf), stdin) == NULL
|| strcmp (buf, "end\n")) {
errorMsg("%s: No `end' line\n", inname);
return FALSE;
}
return TRUE;
}
static int read_base64 (const char *inname)
{
static const char b64_tab[256] = {
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*000-007*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*010-017*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*020-027*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*030-037*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*040-047*/
'\177', '\177', '\177', '\76', '\177', '\177', '\177', '\77', /*050-057*/
'\64', '\65', '\66', '\67', '\70', '\71', '\72', '\73', /*060-067*/
'\74', '\75', '\177', '\177', '\177', '\100', '\177', '\177', /*070-077*/
'\177', '\0', '\1', '\2', '\3', '\4', '\5', '\6', /*100-107*/
'\7', '\10', '\11', '\12', '\13', '\14', '\15', '\16', /*110-117*/
'\17', '\20', '\21', '\22', '\23', '\24', '\25', '\26', /*120-127*/
'\27', '\30', '\31', '\177', '\177', '\177', '\177', '\177', /*130-137*/
'\177', '\32', '\33', '\34', '\35', '\36', '\37', '\40', /*140-147*/
'\41', '\42', '\43', '\44', '\45', '\46', '\47', '\50', /*150-157*/
'\51', '\52', '\53', '\54', '\55', '\56', '\57', '\60', /*160-167*/
'\61', '\62', '\63', '\177', '\177', '\177', '\177', '\177', /*170-177*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*200-207*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*210-217*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*220-227*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*230-237*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*240-247*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*250-257*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*260-267*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*270-277*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*300-307*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*310-317*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*320-327*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*330-337*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*340-347*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*350-357*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*360-367*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*370-377*/
};
unsigned char buf[2 * BUFSIZ];
while (1) {
int last_data = 0;
unsigned char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
errorMsg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
if (memcmp (buf, "====", 4) == 0)
break;
if (last_data != 0) {
errorMsg("%s: data following `=' padding character\n", inname);
return FALSE;
}
/* The following implementation of the base64 decoding might look
a bit clumsy but I only try to follow the POSIX standard:
``All line breaks or other characters not found in the table
[with base64 characters] shall be ignored by decoding
software.'' */
while (*p != '\n') {
char c1, c2, c3;
while ((b64_tab[*p] & '\100') != 0)
if (*p == '\n' || *p++ == '=')
break;
if (*p == '\n')
/* This leaves the loop. */
continue;
c1 = b64_tab[*p++];
while ((b64_tab[*p] & '\100') != 0)
if (*p == '\n' || *p++ == '=') {
errorMsg("%s: illegal line\n", inname);
return FALSE;
}
c2 = b64_tab[*p++];
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
errorMsg("%s: illegal line\n", inname);
return FALSE;
}
if (*p == '=') {
putchar (c1 << 2 | c2 >> 4);
last_data = 1;
break;
}
c3 = b64_tab[*p++];
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
errorMsg("%s: illegal line\n", inname);
return FALSE;
}
putchar (c1 << 2 | c2 >> 4);
putchar (c2 << 4 | c3 >> 2);
if (*p == '=') {
last_data = 1;
break;
}
else
putchar (c3 << 6 | b64_tab[*p++]);
}
}
return TRUE;
}
static int decode (const char *inname,
const char *forced_outname)
{
struct passwd *pw;
register int n;
register char *p;
int mode, n1;
char buf[2 * BUFSIZ];
char *outname;
int do_base64 = 0;
/* Search for header line. */
while (1) {
if (fgets (buf, sizeof (buf), stdin) == NULL) {
errorMsg("%s: No `begin' line\n", inname);
return FALSE;
}
if (strncmp (buf, "begin", 5) == 0) {
if (sscanf (buf, "begin-base64 %o %s", &mode, buf) == 2) {
do_base64 = 1;
break;
} else if (sscanf (buf, "begin %o %s", &mode, buf) == 2)
break;
}
}
/* If the output file name is given on the command line this rules. */
if (forced_outname != NULL)
outname = (char *) forced_outname;
else {
/* Handle ~user/file format. */
if (buf[0] != '~')
outname = buf;
else {
p = buf + 1;
while (*p != '/')
++p;
if (*p == '\0') {
errorMsg("%s: Illegal ~user\n", inname);
return FALSE;
}
*p++ = '\0';
pw = getpwnam (buf + 1);
if (pw == NULL) {
errorMsg("%s: No user `%s'\n", inname, buf + 1);
return FALSE;
}
n = strlen (pw->pw_dir);
n1 = strlen (p);
outname = (char *) alloca ((size_t) (n + n1 + 2));
memcpy (outname + n + 1, p, (size_t) (n1 + 1));
memcpy (outname, pw->pw_dir, (size_t) n);
outname[n] = '/';
}
}
/* Create output file and set mode. */
if (strcmp (outname, "/dev/stdout") != 0 && strcmp (outname, "-") != 0
&& (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
errorMsg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
return FALSE;
}
/* We differenciate decoding standard UU encoding and base64. A
common function would only slow down the program. */
/* For each input line: */
if (do_base64)
return read_base64 (inname);
else
return read_stduu (inname);
}
int uudecode_main (int argc,
char **argv)
{
int opt;
int exit_status;
const char *outname;
outname = NULL;
while ((opt = getopt(argc, argv, "o:")) != EOF) {
switch (opt) {
case 0:
break;
case 'o':
outname = optarg;
break;
default:
usage(uudecode_usage);
}
}
if (optind == argc)
exit_status = decode ("stdin", outname) == 0 ? TRUE : FALSE;
else {
exit_status = TRUE;
do {
if (freopen (argv[optind], "r", stdin) != NULL) {
if (decode (argv[optind], outname) != 0)
exit_status = FALSE;
} else {
errorMsg("%s: %s\n", argv[optind], strerror(errno));
exit_status = FALSE;
}
optind++;
}
while (optind < argc);
}
return(exit_status);
}
+236
View File
@@ -0,0 +1,236 @@
/* uuencode.c -- uuencode utility.
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
*
* This product is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This product is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this product; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
/* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
/* Hacked to work with BusyBox by Alfred M. Szmidt */
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <pwd.h>
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
static void encode __P ((void));
/* Pointer to the translation table we currently use. */
const char *trans_ptr;
/* The two currently defined translation tables. The first is the
standard uuencoding, the second is base64 encoding. */
const char uu_std[64] = {
'`', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
};
const char uu_base64[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
/* ENC is the basic 1 character encoding function to make a char printing. */
#define ENC(Char) (trans_ptr[(Char) & 077])
/* Copy from IN to OUT, encoding as you go along. */
static void encode()
{
register int ch, n;
char *p = NULL;
char buf[80];
while (1) {
n = 0;
do {
register int m = fread (buf, 1, 45 - n, stdin);
if (m == 0)
break;
n += m;
}
while (n < 45);
if (n == 0)
break;
if (trans_ptr == uu_std)
if (putchar (ENC (n)) == EOF)
break;
for (p = buf; n > 2; n -= 3, p += 3) {
ch = *p >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = p[2] & 077;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
}
if (n != 0)
break;
if (putchar ('\n') == EOF)
break;
}
while (n != 0) {
char c1 = *p;
char c2 = n == 1 ? 0 : p[1];
ch = c1 >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((c1 << 4) & 060) | ((c2 >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
if (n == 1)
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
else {
ch = (c2 << 2) & 074;
ch = ENC (ch);
}
if (putchar (ch) == EOF)
break;
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
if (putchar (ch) == EOF)
break;
putchar ('\n');
break;
}
if (ferror (stdin))
errorMsg("Read error\n");
if (trans_ptr == uu_std) {
putchar (ENC ('\0'));
putchar ('\n');
}
}
int uuencode_main (int argc,
char **argv)
{
int opt;
struct stat sb;
int mode;
trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */
while ((opt = getopt (argc, argv, "m")) != EOF) {
switch (opt) {
case 'm':
trans_ptr = uu_base64;
break;
case 0:
break;
default:
usage(uuencode_usage);
}
}
switch (argc - optind) {
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
errorMsg("%s: %s\n", argv[optind], strerror(errno));
exit FALSE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
optind++;
break;
case 1:
mode = RW & ~umask (RW);
break;
case 0:
default:
usage(uuencode_usage);
}
printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64",
mode, argv[optind]);
encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) {
errorMsg("Write error\n");
exit FALSE;
}
return( TRUE);
}
+19 -31
View File
@@ -2,7 +2,7 @@
/*
* Mini wc implementation for busybox
*
* by Edward Betts <edward@debian.org>
* Copyright (C) 2000 Edward Betts <edward@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,18 +20,9 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
"Print line, word, and byte counts for each FILE, and a total line if\n"
"more than one FILE is specified. With no FILE, read standard input.\n\n"
"Options:\n"
"\t-c\tprint the byte counts\n"
"\t-l\tprint the newline counts\n"
"\t-L\tprint the length of the longest line\n"
"\t-w\tprint the word counts\n";
#include <getopt.h>
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
@@ -113,13 +104,14 @@ static void wc_file(FILE * file, const char *name)
int wc_main(int argc, char **argv)
{
FILE *file;
unsigned int num_files_counted = 0;
int opt;
total_lines = total_words = total_chars = max_length = 0;
print_lines = print_words = print_chars = print_length = 0;
while (--argc && **(++argv) == '-') {
while (*++(*argv))
switch (**argv) {
while ((opt = getopt(argc, argv, "clLw")) > 0) {
switch (opt) {
case 'c':
print_chars = 1;
break;
@@ -140,28 +132,24 @@ int wc_main(int argc, char **argv)
if (!print_lines && !print_words && !print_chars && !print_length)
print_lines = print_words = print_chars = 1;
if (argc == 0) {
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
wc_file(stdin, "");
exit(TRUE);
} else if (argc == 1) {
file = fopen(*argv, "r");
if (file == NULL) {
perror(*argv);
exit(FALSE);
}
wc_file(file, *argv);
} else {
while (argc-- > 0 && *argv != '\0' && strlen(*argv)) {
file = fopen(*argv, "r");
while (optind < argc) {
file = fopen(argv[optind], "r");
if (file == NULL) {
perror(*argv);
exit(FALSE);
fatalError(argv[optind]);
}
wc_file(file, *argv);
argv++;
wc_file(file, argv[optind]);
num_files_counted++;
optind++;
}
}
if (num_files_counted > 1)
print_counts(total_lines, total_words, total_chars,
max_length, "total");
}
exit(TRUE);
return 0 ;
}
+8 -13
View File
@@ -20,28 +20,23 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <pwd.h>
static const char whoami_usage[] = "whoami\n\n"
"Prints the user name associated with the current effective user id.\n";
extern int whoami_main(int argc, char **argv)
{
struct passwd *pw;
uid_t uid;
char *user = xmalloc(9);
uid_t uid = geteuid();
if (argc > 1)
usage(whoami_usage);
uid = geteuid();
pw = getpwuid(uid);
if (pw) {
puts(pw->pw_name);
my_getpwuid(user, uid);
if (user) {
puts(user);
exit(TRUE);
}
fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0],
(unsigned) uid);
exit(FALSE);
errorMsg("cannot find username for UID %u\n", (unsigned) uid);
return(FALSE);
}
+7 -8
View File
@@ -20,23 +20,21 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int yes_main(int argc, char **argv)
{
int i;
if (argc >=1 && *argv[1]=='-') {
usage("yes [OPTION]... [STRING]...\n\n"
"Repeatedly outputs a line with all specified STRING(s), or `y'.\n");
}
if (argc >= 2 && *argv[1] == '-')
usage(yes_usage);
if (argc == 1) {
while (1)
if (puts("y") == EOF) {
perror("yes");
exit(FALSE);
return EXIT_FAILURE;
}
}
@@ -45,7 +43,8 @@ extern int yes_main(int argc, char **argv)
if (fputs(argv[i], stdout) == EOF
|| putchar(i == argc - 1 ? '\n' : ' ') == EOF) {
perror("yes");
exit(FALSE);
return EXIT_FAILURE;
}
exit(TRUE);
return EXIT_SUCCESS;
}
+57 -61
View File
@@ -25,7 +25,7 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_omitting_directory
@@ -41,35 +41,28 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#define is_cp 0
#define is_mv 1
static int dz_i; /* index into cp_mv_usage */
static const char *dz; /* dollar zero, .bss */
static const char *cp_mv_usage[] = /* .rodata */
{
"cp [OPTION]... SOURCE DEST\n"
" or: cp [OPTION]... SOURCE... DIRECTORY\n\n"
"Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
"\n"
"\t-a\tsame as -dpR\n"
"\t-d\tpreserve links\n"
"\t-p\tpreserve file attributes if possible\n"
"\t-R\tcopy directories recursively\n",
"mv SOURCE DEST\n"
" or: mv SOURCE... DIRECTORY\n\n"
"Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
cp_usage,
mv_usage
};
static int recursiveFlag;
static int followLinks;
static int preserveFlag;
static int forceFlag;
static const char *baseSrcName;
static int srcDirFlag;
static struct stat srcStatBuf;
static char baseDestName[PATH_MAX + 1];
static char baseDestName[BUFSIZ + 1];
static size_t baseDestLen;
static int destDirFlag;
static struct stat destStatBuf;
@@ -82,8 +75,7 @@ static void name_too_long__exit (void) __attribute__((noreturn));
static
void name_too_long__exit (void)
{
fprintf(stderr, name_too_long, dz);
exit FALSE;
fatalError(name_too_long);
}
static void
@@ -92,12 +84,12 @@ fill_baseDest_buf(char *_buf, size_t * _buflen) {
if ((srcBasename = strrchr(baseSrcName, '/')) == NULL) {
srcBasename = baseSrcName;
if (_buf[*_buflen - 1] != '/') {
if (++(*_buflen) > PATH_MAX)
if (++(*_buflen) > BUFSIZ)
name_too_long__exit();
strcat(_buf, "/");
}
}
if (*_buflen + strlen(srcBasename) > PATH_MAX)
if (*_buflen + strlen(srcBasename) > BUFSIZ)
name_too_long__exit();
strcat(_buf, srcBasename);
return;
@@ -107,7 +99,7 @@ fill_baseDest_buf(char *_buf, size_t * _buflen) {
static int
cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
{
char destName[PATH_MAX + 1];
char destName[BUFSIZ + 1];
size_t destLen;
const char *srcBasename;
char *name;
@@ -117,14 +109,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) {
fprintf(stderr, omitting_directory, dz, baseSrcName);
errorMsg(omitting_directory, baseSrcName);
return TRUE;
}
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
if (destLen + strlen(srcBasename) > PATH_MAX) {
fprintf(stderr, name_too_long, dz);
if (destLen + strlen(srcBasename) > BUFSIZ) {
errorMsg(name_too_long);
return FALSE;
}
strcat(destName, srcBasename);
@@ -138,8 +130,8 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (mv_Action_first_time && (dz_i == is_mv)) {
mv_Action_first_time = errno = 0;
if (rename(fileName, destName) < 0 && errno != EXDEV) {
fprintf(stderr, "%s: rename(%s, %s): %s\n",
dz, fileName, destName, strerror(errno));
errorMsg("rename(%s, %s): %s\n", fileName, destName,
strerror(errno));
goto do_copyFile; /* Try anyway... */
}
else if (errno == EXDEV)
@@ -151,8 +143,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
if (is_in_ino_dev_hashtable(statbuf, &name)) {
if (link(name, destName) < 0) {
fprintf(stderr, "%s: link(%s, %s): %s\n",
dz, name, destName, strerror(errno));
errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno));
return FALSE;
}
return TRUE;
@@ -161,7 +152,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
add_to_ino_dev_hashtable(statbuf, destName);
}
}
return copyFile(fileName, destName, preserveFlag, followLinks);
return copyFile(fileName, destName, preserveFlag, followLinks, forceFlag);
}
static int
@@ -171,11 +162,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) {
fprintf(stderr, "%s: rmdir(%s): %s\n", dz, fileName, strerror(errno));
errorMsg("rmdir(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
} else if (unlink(fileName) < 0) {
fprintf(stderr, "%s: unlink(%s): %s\n", dz, fileName, strerror(errno));
errorMsg("unlink(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
return status;
@@ -183,22 +174,21 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
extern int cp_mv_main(int argc, char **argv)
{
dz = *argv; /* already basename'd by busybox.c:main */
if (*dz == 'c' && *(dz + 1) == 'p')
volatile int i;
int c;
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
dz_i = is_cp;
else
dz_i = is_mv;
if (argc < 3)
usage(cp_mv_usage[dz_i]);
argc--;
argv++;
if (dz_i == is_cp) {
recursiveFlag = preserveFlag = FALSE;
recursiveFlag = preserveFlag = forceFlag = FALSE;
followLinks = TRUE;
while (**argv == '-') {
while (*++(*argv)) {
switch (**argv) {
while ((c = getopt(argc, argv, "adpRf")) != EOF) {
switch (c) {
case 'a':
followLinks = FALSE;
preserveFlag = TRUE;
@@ -213,20 +203,28 @@ extern int cp_mv_main(int argc, char **argv)
case 'R':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
default:
usage(cp_mv_usage[is_cp]);
}
}
argc--;
argv++;
}
if ((argc - optind) < 2) {
usage(cp_mv_usage[dz_i]);
}
} else { /* (dz_i == is_mv) */
/* Initialize optind to 1, since in libc5 optind
* is not initialized until getopt() is called
* (or until sneaky programmers force it...). */
optind = 1;
recursiveFlag = preserveFlag = TRUE;
followLinks = FALSE;
}
if (strlen(argv[argc - 1]) > PATH_MAX) {
fprintf(stderr, name_too_long, "cp");
if (strlen(argv[argc - 1]) > BUFSIZ) {
errorMsg(name_too_long);
goto exit_false;
}
strcpy(baseDestName, argv[argc - 1]);
@@ -235,19 +233,19 @@ extern int cp_mv_main(int argc, char **argv)
goto exit_false;
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
if ((argc > 3) && destDirFlag == FALSE) {
fprintf(stderr, not_a_directory, "cp", baseDestName);
if (argc - optind > 2 && destDirFlag == FALSE) {
errorMsg(not_a_directory, baseDestName);
goto exit_false;
}
while (argc-- > 1) {
for (i = optind; i < (argc-1); i++) {
size_t srcLen;
volatile int flags_memo;
int status;
baseSrcName = *(argv++);
baseSrcName=argv[i];
if ((srcLen = strlen(baseSrcName)) > PATH_MAX)
if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
name_too_long__exit();
if (srcLen == 0) continue; /* "" */
@@ -261,30 +259,29 @@ extern int cp_mv_main(int argc, char **argv)
int state = 0;
char *pushd, *d, *p;
if ((pushd = getcwd(NULL, PATH_MAX + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
errorMsg("getcwd(): %s\n", strerror(errno));
continue;
}
if (chdir(baseDestName) < 0) {
fprintf(stderr, "%s: chdir(%s): %s\n", dz, baseSrcName, strerror(errno));
errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno));
continue;
}
if ((d = getcwd(NULL, PATH_MAX + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
errorMsg("getcwd(): %s\n", strerror(errno));
continue;
}
while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
fprintf(stderr, "%s: stat(%s) :%s\n", dz, d, strerror(errno));
errorMsg("stat(%s): %s\n", d, strerror(errno));
state = -1;
continue;
}
if ((sb.st_ino == srcStatBuf.st_ino) &&
(sb.st_dev == srcStatBuf.st_dev)) {
fprintf(stderr,
"%s: Cannot %s `%s' "
"into a subdirectory of itself, `%s/%s'\n",
dz, dz, baseSrcName, baseDestName, baseSrcName);
errorMsg("Cannot %s `%s' into a subdirectory of itself, "
"`%s/%s'\n", applet_name, baseSrcName,
baseDestName, baseSrcName);
state = -1;
continue;
}
@@ -293,7 +290,7 @@ extern int cp_mv_main(int argc, char **argv)
}
}
if (chdir(pushd) < 0) {
fprintf(stderr, "%s: chdir(%s): %s\n", dz, pushd, strerror(errno));
errorMsg("chdir(%s): %s\n", pushd, strerror(errno));
free(pushd);
free(d);
continue;
@@ -319,10 +316,9 @@ extern int cp_mv_main(int argc, char **argv)
if (flags_memo)
*(baseDestName + baseDestLen) = '\0';
}
// exit_true:
exit TRUE;
return( TRUE);
exit_false:
exit FALSE;
return( FALSE);
}
/*
+232
View File
@@ -0,0 +1,232 @@
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@enol.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* getopt */
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "busybox.h"
/* globals from other files */
extern int optind;
extern char *optarg;
/* globals in this file only */
static char part = 0; /* (b)yte, (c)har, (f)ields */
static int startpos = 1;
static int endpos = -1;
static char delim = '\t'; /* delimiter, default is tab */
static unsigned int supress_non_delimited_lines = 0;
/*
* decompose_list() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
*/
static void decompose_list(const char *list)
{
unsigned int nminus = 0;
char *ptr;
/* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') {
fatalError("invalid byte or field list\n");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
fatalError("invalid byte or field list\n");
}
}
}
/* handle single value 'N' case */
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
fatalError("missing list of fields\n");
}
endpos = startpos;
}
/* handle multi-value cases */
else if (nminus == 1) {
/* handle 'N-' case */
if (list[strlen(list) - 1] == '-') {
startpos = strtol(list, &ptr, 10);
}
/* handle '-M' case */
else if (list[0] == '-') {
endpos = strtol(&list[1], NULL, 10);
}
/* handle 'N-M' case */
else {
startpos = strtol(list, &ptr, 10);
endpos = strtol(ptr+1, &ptr, 10);
}
/* a sanity check */
if (startpos == 0) {
startpos = 1;
}
}
}
/*
* snippy-snip
*/
static void cut_file(FILE *file)
{
char *line;
/* go through every line in the file */
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
/* cut based on chars/bytes */
if (part == 'c' || part == 'b') {
int i;
/* a valid end position has been specified */
if (endpos > 0) {
for (i = startpos-1; i < endpos; i++) {
fputc(line[i], stdout);
}
fputc('\n', stdout);
}
/* otherwise, just go to the end of the line */
else {
for (i = startpos-1; line[i]; i++) {
fputc(line[i], stdout);
}
}
}
/* cut based on fields */
else if (part == 'f') {
char *ptr;
char *start = line;
unsigned int delims_hit = 0;
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
delims_hit++;
if (delims_hit == (startpos - 1)) {
start = ptr+1;
}
if (delims_hit == endpos) {
break;
}
}
/* we didn't hit any delimeters */
if (delims_hit == 0 && !supress_non_delimited_lines) {
fputs(line, stdout);
}
/* we =did= hit some delimiters */
else if (delims_hit > 0) {
/* we have a fixed end point */
if (ptr) {
while (start < ptr) {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
/* or we're just going til the end of the line */
else {
while (*start) {
fputc(*start, stdout);
start++;
}
}
}
}
}
}
extern int cut_main(int argc, char **argv)
{
int opt;
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
switch (opt) {
case 'b':
case 'c':
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
fatalError("only one type of list may be specified");
}
part = (char)opt;
decompose_list(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
fatalError("the delimiter must be a single character\n");
}
delim = optarg[0];
break;
case 'n':
/* no-op */
break;
case 's':
supress_non_delimited_lines++;
break;
}
}
if (part == 0) {
fatalError("you must specify a list of bytes, characters, or fields\n");
}
if (supress_non_delimited_lines && part != 'f') {
fatalError("suppressing non-delimited lines makes sense
only when operating on fields\n");
}
if (delim != '\t' && part != 'f') {
fatalError("a delimiter may be specified only when operating on fields\n");
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
* files were specified or '-' was specified, take input from stdin.
* Otherwise, we process all the files specified. */
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
cut_file(stdin);
}
else {
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
errorMsg("%s: %s\n", argv[i], strerror(errno));
} else {
cut_file(file);
fclose(file);
}
}
}
return 0;
}
+37 -56
View File
@@ -20,7 +20,7 @@
*
*/
#include "internal.h"
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
@@ -31,6 +31,7 @@
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <getopt.h>
/* This 'date' command supports only 2 time setting formats,
@@ -39,15 +40,6 @@
an RFC 822 complient date output for shell scripting
mail commands */
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\n"
"Display the current time in the given FORMAT, or set the system date.\n"
"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
"\t-s\t\tset time described by STRING\n"
"\t-u\t\tprint or set Coordinated Universal Time\n";
/* Input parsing code is always bulky - used heavy duty libc stuff as
much as possible, missed out a lot of bounds checking */
@@ -64,7 +56,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
fatalError(invalid_date, "date", t_string);
fatalError(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
@@ -148,7 +140,7 @@ struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
}
fatalError(invalid_date, "date", t_string);
fatalError(invalid_date, t_string);
}
@@ -157,7 +149,7 @@ int date_main(int argc, char **argv)
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
int i;
int c;
int set_time = 0;
int rfc822 = 0;
int utc = 0;
@@ -166,49 +158,39 @@ int date_main(int argc, char **argv)
struct tm tm_time;
/* Interpret command line args */
i = --argc;
argv++;
while (i > 0 && **argv) {
if (**argv == '-') {
while (i > 0 && *++(*argv))
switch (**argv) {
case 'R':
rfc822 = 1;
break;
case 's':
set_time = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted, "date");
/* Look ma, no break. Don't fix it either. */
case 'd':
use_arg = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
break;
case '-':
usage(date_usage);
}
} else {
if ((date_fmt == NULL) && (**argv == '+'))
date_fmt = *argv + 1; /* Skip over the '+' */
else if (date_str == NULL) {
set_time = 1;
date_str = *argv;
} else {
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
switch (c) {
case 'R':
rfc822 = 1;
break;
case 's':
set_time = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
usage(date_usage);
}
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted);
break;
case 'd':
use_arg = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
usage(date_usage);
break;
default:
usage(date_usage);
}
i--;
argv++;
}
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
date_fmt = &argv[optind][1]; /* Skip over the '+' */
else if (date_str == NULL) {
set_time = 1;
date_str = argv[optind];
} else {
usage(date_usage);
}
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
@@ -234,12 +216,12 @@ int date_main(int argc, char **argv)
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
fatalError(invalid_date, "date", date_str);
fatalError(invalid_date, date_str);
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
fatalError("date: can't set date.\n");
fatalError("can't set date.\n");
}
}
}
@@ -271,6 +253,5 @@ int date_main(int argc, char **argv)
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
exit(TRUE);
return(TRUE);
}
+67 -23
View File
@@ -1,5 +1,6 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include "busybox.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -7,18 +8,13 @@
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
static const char math_usage[] = "math expression ...\n\n"
"This is a Tiny RPN calculator that understands the\n"
"following operations: +, -, /, *, and, or, not, eor.\n"
"i.e. 'math 2 2 add' -> 4, and 'math 8 8 \\* 2 2 + /' -> 16\n";
static double stack[100];
static unsigned int pointer;
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack))) {
fprintf(stderr, "math: stack overflow\n");
errorMsg("stack overflow\n");
exit(-1);
} else
stack[pointer++] = a;
@@ -27,7 +23,7 @@ static void push(double a)
static double pop()
{
if (pointer == 0) {
fprintf(stderr, "math: stack underflow\n");
errorMsg("stack underflow\n");
exit(-1);
}
return stack[--pointer];
@@ -88,15 +84,19 @@ struct op {
};
static const struct op operators[] = {
{"+", add},
{"-", sub},
{"*", mul},
{"/", divide},
{"+", add},
{"add", add},
{"-", sub},
{"sub", sub},
{"*", mul},
{"mul", mul},
{"/", divide},
{"div", divide},
{"and", and},
{"or", or},
{"or", or},
{"not", not},
{"eor", eor},
{0, 0}
{0, 0}
};
static void stack_machine(const char *argument)
@@ -124,19 +124,63 @@ static void stack_machine(const char *argument)
}
o++;
}
fprintf(stderr, "math: %s: syntax error.\n", argument);
errorMsg("%s: syntax error.\n", argument);
exit(-1);
}
int math_main(int argc, char **argv)
/* return pointer to next token in buffer and set *buffer to one char
* past the end of the above mentioned token
*/
static char *get_token(char **buffer)
{
if (argc <= 1 || *argv[1]=='-')
usage(math_usage);
while (argc >= 2) {
stack_machine(argv[1]);
argv++;
argc--;
char *start = NULL;
char *current = *buffer;
while (isspace(*current)) { current++; }
if (*current != 0) {
start = current;
while (!isspace(*current) && current != 0) { current++; }
*buffer = current;
}
return start;
}
/* In Perl one might say, scalar m|\s*(\S+)\s*|g */
static int number_of_tokens(char *buffer)
{
int i = 0;
char *b = buffer;
while (get_token(&b)) { i++; }
return i;
}
int dc_main(int argc, char **argv)
{
/* take stuff from stdin if no args are given */
if (argc <= 1) {
int i, len;
char *line = NULL;
char *cursor = NULL;
char *token = NULL;
while ((line = get_line_from_file(stdin))) {
cursor = line;
len = number_of_tokens(line);
for (i = 0; i < len; i++) {
token = get_token(&cursor);
*cursor++ = 0;
stack_machine(token);
}
free(line);
}
} else {
if (*argv[1]=='-')
usage(dc_usage);
while (argc >= 2) {
stack_machine(argv[1]);
argv++;
argc--;
}
}
stack_machine(0);
exit( TRUE);
return( TRUE);
}
+35 -73
View File
@@ -29,7 +29,7 @@
*/
#include "internal.h"
#include "busybox.h"
#include <features.h>
#include <stdio.h>
#include <fcntl.h>
@@ -40,37 +40,25 @@
typedef unsigned long long int uintmax_t;
#endif
static const char dd_usage[] =
"dd [if=name] [of=name] [bs=n] [count=n] [skip=n] [seek=n]\n\n"
"Copy a file, converting and formatting according to options\n\n"
"\tif=FILE\tread from FILE instead of stdin\n"
"\tof=FILE\twrite to FILE instead of stdout\n"
"\tbs=n\tread and write n bytes at a time\n"
"\tcount=n\tcopy only n input blocks\n"
"\tskip=n\tskip n input blocks\n"
"\tseek=n\tskip n output blocks\n"
"\n"
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n";
extern int dd_main(int argc, char **argv)
{
char *inFile = NULL;
char *outFile = NULL;
char *cp;
int inFd;
int outFd;
int inCc = 0;
int outCc;
int trunc=TRUE;
long blockSize = 512;
uintmax_t skipBlocks = 0;
uintmax_t seekBlocks = 0;
uintmax_t count = (uintmax_t) - 1;
uintmax_t intotal;
uintmax_t outTotal;
unsigned char *buf;
uintmax_t inTotal = 0;
uintmax_t outTotal = 0;
uintmax_t totalSize;
uintmax_t readSize;
unsigned char buf[BUFSIZ];
char *keyword = NULL;
argc--;
argv++;
@@ -83,30 +71,33 @@ extern int dd_main(int argc, char **argv)
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1);
if (count <= 0) {
fprintf(stderr, "Bad count value %s\n", *argv);
if (count < 0) {
errorMsg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
fprintf(stderr, "Bad block size value %s\n", *argv);
errorMsg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
fprintf(stderr, "Bad skip value %s\n", *argv);
errorMsg("Bad skip value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
fprintf(stderr, "Bad seek value %s\n", *argv);
errorMsg("Bad seek value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "conv", 4) == 0) {
keyword = (strchr(*argv, '=') + 1);
if (strcmp(keyword, "notrunc") == 0)
trunc=FALSE;
} else {
goto usage;
}
@@ -114,11 +105,6 @@ extern int dd_main(int argc, char **argv)
argv++;
}
buf = xmalloc(blockSize);
intotal = 0;
outTotal = 0;
if (inFile == NULL)
inFd = fileno(stdin);
else
@@ -136,7 +122,7 @@ extern int dd_main(int argc, char **argv)
if (outFile == NULL)
outFd = fileno(stdout);
else
outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
outFd = open(outFile, O_WRONLY | O_CREAT, 0666);
if (outFd < 0) {
/* Note that we are not freeing buf or closing
@@ -148,54 +134,30 @@ extern int dd_main(int argc, char **argv)
fatalError( outFile);
}
lseek(inFd, skipBlocks * blockSize, SEEK_SET);
lseek(outFd, seekBlocks * blockSize, SEEK_SET);
//
//TODO: Convert to using fullRead & fullWrite
// from utility.c
// -Erik
while (outTotal < count * blockSize) {
inCc = read(inFd, buf, blockSize);
if (inCc < 0) {
perror(inFile);
goto cleanup;
} else if (inCc == 0) {
goto cleanup;
}
intotal += inCc;
cp = buf;
while (intotal > outTotal) {
if (outTotal + inCc > count * blockSize)
inCc = count * blockSize - outTotal;
outCc = write(outFd, cp, inCc);
if (outCc < 0) {
perror(outFile);
goto cleanup;
} else if (outCc == 0) {
goto cleanup;
}
inCc -= outCc;
cp += outCc;
outTotal += outCc;
}
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
totalSize=count*blockSize;
while ((readSize = totalSize - inTotal) > 0) {
if (readSize > BUFSIZ)
readSize=BUFSIZ;
inCc = fullRead(inFd, buf, readSize);
inTotal += inCc;
if ((outCc = fullWrite(outFd, buf, inCc)) < 1)
break;
outTotal += outCc;
}
if (trunc == TRUE) {
ftruncate(outFd, lseek(outFd, 0, SEEK_CUR));
}
if (inCc < 0)
perror(inFile);
cleanup:
/* Note that we are not freeing memory or closing
* files here, to save a few bytes. */
#if 0
#ifdef BB_FEATURE_CLEAN_UP
close(inFd);
close(outFd);
free(buf);
#endif
printf("%ld+%d records in\n", (long) (intotal / blockSize),
(intotal % blockSize) != 0);
printf("%ld+%d records in\n", (long) (inTotal / blockSize),
(inTotal % blockSize) != 0);
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
(outTotal % blockSize) != 0);
exit(TRUE);
+15 -19
View File
@@ -3,50 +3,46 @@
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
* Renamed deallocvt.
*/
#include "internal.h"
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <stdio.h>
extern int getfd(void);
char *progname;
/* From <linux/vt.h> */
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
int fd, num, i;
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n");
}
progname = argv[0];
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
if (argc > 2)
usage(deallocvt_usage);
fd = get_console_fd("/dev/console");
if (argc == 1) {
printf("erik: A\n");
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
exit(1);
exit( FALSE);
}
} else
printf("erik: B\n");
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
fprintf(stderr, "%s: 0: illegal VT number\n", progname);
errorMsg("0: illegal VT number\n");
else if (num == 1)
fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
progname);
errorMsg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n",
progname, num);
exit(1);
fatalError("could not deallocate console %d\n", num);
}
}
exit(0);
printf("erik: C\n");
return( TRUE);
}
+10
View File
@@ -0,0 +1,10 @@
BusyBox for Debian
----------------------
BusyBox is being developed and maintained by Erik Andersen
<andersee@debian.org>.
If you have a problem with BusyBox, send email to the Debian bug tracking
system that lives at <submit@bugs.lineo.com>
Erik Andersen <andersee@debian.org>, Sun, 18 Jun 2000 21:52:00 -0600
+30
View File
@@ -0,0 +1,30 @@
busybox (0.47-1) unstable; urgency=low
* New version released. See changelog for details.
-- Erik Andersen <andersee@debian.org> Mon, 25 Sep 2000 23:00:56 -0600
busybox (0.46-1) unstable; urgency=low
* New version released. See changelog for details.
-- Erik Andersen <andersee@debian.org> Tue, 11 Jul 2000 12:15:44 -0600
busybox (0.45-1) unstable; urgency=low
* First attempt at packaging BusyBox as a .deb. This has been in
in the Debian boot-floppies CVS tree forever. Hopefully, having it as a
standalone app will make life easier for me, the debian-installer team, and
everyone else as well...
* I have created a busybox-static that can be used as a rescue shell when you
hose your system. Just invoke "busybox sh" to fir up the shell. This has
every app provided by busybox staically linked in. There have been several
times in the past that I would have loved to have this sitting on my system
(i.e. when libc gets screwed up.)
-- Erik Andersen <andersee@debian.org> Tue, 27 Jun 2000 12:26:41 -0600
Local variables:
mode: debian-changelog
add-log-mailing-address: "andersee@debian.org"
End:
+46
View File
@@ -0,0 +1,46 @@
Source: busybox
Priority: optional
Maintainer: Erik Andersen <andersee@debian.org>
Build-Depends: debhelper
Standards-Version: 3.1.1
Package: busybox
Architecture: any
Depends: ${shlibs:Depends}
Conflicts: binutils, bsdutils, console-tools, cpio, debianutils, dnsutils, dpkg, fbset, fdflush, fileutils, grep, gzip, hostname, modutils, mount, netbase, procps, psmisc, sed, sharutils, shellutils, sysklogd, sysvinit, tar, textutils, update, util-linux
Replaces: netbase
Section: utils
Description: Tiny utilities for the debian-installer and for embedded systems.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for the most common
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
mount, tar, etc). The utilities in BusyBox generally have fewer options than
their full-featured GNU cousins; however, the options that are included
provide the expected functionality and behave very much like their GNU
counterparts.
.
BusyBox is used by the debian-installer. Installing BusyBox onto your Debian
system is not recommended, unless you are intended to make a very small
embedded system. Chances are good that for embedded systems, you will want to
recompile to only include the tools and utilities you wish to include.
Package: busybox-static
Architecture: any
Depends: ${shlibs:Depends}
Section: shells
Description: Provides a stand alone rescue shell with tons of builtin utilities.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for the most common
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
mount, tar, etc). The utilities in BusyBox generally have fewer options than
their full-featured GNU cousins; however, the options that are included
provide the expected functionality and behave very much like their GNU
counterparts.
.
BusyBox-static provides you with a statically linked simple stand alone shell
that provides all the utilities available in BusyBox. This package is
intended to be used as a rescue shell, in the event that you screw up your
system. Invoke "busybox sh" and you have a standalone shell ready to save
your system from certain destruction. Invoke "busybox", and it will list the
available builtin commands.
+7
View File
@@ -0,0 +1,7 @@
This package was debianized by Erik Andersen <andersee@debian.org> on
Sun, 18 Jun 2000 23:31:02 -0600
It was downloaded from ftp://ftp.lineo.com/pub/busybox
HomePage is at: http://busybox.lineo.com/
Copyright: GPL
Vendored Executable
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/make -f
# This is a bit unusual, in that I have to completely recompile everything
# twice. The first is the normal, dynamically linked package. The second is
# for the statically linked package. This file has been adjusted accordingly.
# This is the debhelper compatability version to use.
export DH_COMPAT=1
bb=debian/tmp
bbs=debian/busybox-static
clean:
dh_testdir
dh_testroot
rm -f build-stamp-busybox build-stamp-busybox-static
-$(MAKE) clean
-rm -rf $(bb) $(bbs)
dh_clean
half_clean:
dh_testdir
dh_testroot
rm -rf $(bbs) build-stamp-busybox-static
-$(MAKE) clean
build: build-stamp-busybox
build-stamp-busybox:
dh_testdir
$(MAKE)
touch build-stamp-busybox
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
$(MAKE) "PREFIX=$(bb)" install
mkdir -p $(bb)/usr/share/man/man1
cp docs/BusyBox.1 $(bb)/usr/share/man/man1/busybox.1
# Now for the statically linked stuff
build-static: build-stamp-busybox-static
build-stamp-busybox-static:
dh_testdir
$(MAKE) DOSTATIC=true
touch build-stamp-busybox-static
install-static: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Do not run 'make install', since we do not want all the symlinks.
# This just installes the busybox binary...
#$(MAKE) "PREFIX=$(bbs)" install
mkdir -p $(bbs)/bin/
cp busybox $(bbs)/bin/busybox
mkdir -p $(bbs)/usr/share/man/man1/
cp docs/BusyBox.1 $(bbs)/usr/share/man/man1/busybox.1
do_static: half_clean build-static install-static
# Build architecture-independent files here.
binary-indep:
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: busybox busybox-static
busybox: install
@echo "--- Building: $@"
dh_testdir
dh_testroot
dh_installdirs
#
#Note that for busybox, we do not install any docs,
# or man apges or anything else. This is in blatent violation of every
# Debian policy out there, since this package is intended to be used
# _only_ by the debian-installer.
#
#dh_installdocs -p$@ docs/BusyBox.txt \
# docs/BusyBox.html docs/busybox.lineo.com AUTHORS README TODO
#rm -rf $(bb)/usr/share/doc/busybox/busybox.lineo.com/CVS \
# $(bb)/usr/share/doc/busybox/busybox.lineo.com/.cvsignore \
# $(bb)/usr/share/doc/busybox/busybox.lineo.com/images/CVS \
# $(bb)/usr/share/doc/busybox/busybox.lineo.com/images/.cvsignore
#dh_undocumented -p$@
dh_installchangelogs -p$@ Changelog
dh_strip -p$@
dh_compress -p$@
dh_fixperms -p$@
dh_installdeb -p$@
dh_shlibdeps -p$@
#
#Make _very_ sure there are no docs lurking about.
#
rm -rf $(bb)/usr/share/doc
rm -rf $(bb)/usr/share/man
dh_gencontrol -p$@
dh_md5sums -p$@
dh_builddeb -p$@
busybox-static: do_static
@echo "--- Building: $@"
dh_testdir
dh_testroot
dh_installdirs
dh_installdocs -p$@ docs/BusyBox.txt \
docs/BusyBox.html docs/busybox.lineo.com AUTHORS README TODO
rm -rf $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/CVS \
$(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/.cvsignore \
$(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/images/CVS \
$(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/images/.cvsignore
dh_undocumented -p$@
dh_installchangelogs -p$@ Changelog
dh_strip -p$@
dh_compress -p$@
dh_fixperms -p$@
dh_installdeb -p$@
dh_shlibdeps -p$@
dh_gencontrol -p$@
dh_md5sums -p$@
dh_builddeb -p$@
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
+3 -8
View File
@@ -22,15 +22,11 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <mntent.h>
#include <sys/stat.h>
#include <sys/vfs.h>
static const char df_usage[] = "df [filesystem ...]\n\n"
"Print the filesystem space used and space available.\n";
extern const char mtab_file[]; /* Defined in utility.c */
static int df(char *device, const char *mountPoint)
@@ -48,7 +44,6 @@ static int df(char *device, const char *mountPoint)
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
/* Note that if /etc/fstab is missing, libc can't fix up /dev/root for us */
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
@@ -80,7 +75,7 @@ extern int df_main(int argc, char **argv)
}
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
errorMsg("%s: can't find mount point.\n", argv[1]);
exit(FALSE);
}
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
@@ -106,7 +101,7 @@ extern int df_main(int argc, char **argv)
endmntent(mountTable);
}
exit(TRUE);
return(TRUE);
}
/*
+4 -5
View File
@@ -20,16 +20,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
extern int dirname_main(int argc, char **argv)
{
char* s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("dirname [file ...]\n");
}
if ((argc < 2) || (**(argv + 1) == '-'))
usage(dirname_usage);
argv++;
s=*argv+strlen(*argv)-1;
@@ -41,5 +40,5 @@ extern int dirname_main(int argc, char **argv)
if (s && *s)
*s = '\0';
printf("%s\n", (s)? *argv : ".");
exit(TRUE);
return(TRUE);
}
+23 -41
View File
@@ -15,10 +15,8 @@
* Support, replaced getopt, added some gotos for redundant stuff.
*/
#include "internal.h"
#include <linux/unistd.h>
#include "busybox.h"
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#if __GNU_LIBRARY__ < 5
@@ -34,54 +32,39 @@ static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
# include <sys/klog.h>
#endif
static const char dmesg_usage[] = "dmesg [-c] [-n level] [-s bufsize]\n";
int dmesg_main(int argc, char **argv)
{
char *buf;
int c;
int bufsize = 8196;
int i;
int n;
int level = 0;
int lastc;
int cmd = 3;
int stopDoingThat;
argc--;
argv++;
/* Parse any options */
while (argc && **argv == '-') {
stopDoingThat = FALSE;
while (stopDoingThat == FALSE && *++(*argv)) {
switch (**argv) {
case 'c':
cmd = 4;
break;
case 'n':
cmd = 8;
if (--argc == 0)
goto end;
level = atoi(*(++argv));
if (--argc > 0)
++argv;
stopDoingThat = TRUE;
break;
case 's':
if (--argc == 0)
goto end;
bufsize = atoi(*(++argv));
if (--argc > 0)
++argv;
stopDoingThat = TRUE;
break;
default:
goto end;
}
while ((c = getopt(argc, argv, "cn:s:")) != EOF) {
switch (c) {
case 'c':
cmd = 4;
break;
case 'n':
cmd = 8;
if (optarg == NULL)
usage(dmesg_usage);
level = atoi(optarg);
break;
case 's':
if (optarg == NULL)
usage(dmesg_usage);
bufsize = atoi(optarg);
break;
default:
usage(dmesg_usage);
}
}
}
if (argc > 1) {
if (optind < argc) {
goto end;
}
@@ -121,6 +104,5 @@ int dmesg_main(int argc, char **argv)
exit(FALSE);
klogctl_error:
perror("klogctl");
exit(FALSE);
return(FALSE);
}
+3
View File
@@ -0,0 +1,3 @@
BusyBox.txt
BusyBox.1
BusyBox.html
Loaded 100 of 279 files, more files were not shown because too many files have changed in this diff. Show more