Compare commits

..
251 Commits
Author SHA1 Message Date
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
241 changed files with 26051 additions and 11727 deletions

No files matched your search

+19 -6
View File
@@ -12,9 +12,6 @@ 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.
John Beppu <beppu@lineo.com>
du, head, nslookup, sort, tee, uniq
@@ -28,8 +25,26 @@ 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.
Pavel Roskin <proski@gnu.org>
Lots of bugs fixes and patches.
Linus Torvalds <torvalds@transmeta.com>
mkswap, fsck.minix, mkfs.minix
@@ -40,5 +55,3 @@ Charles P. Wright <cpwright@villagenet.com>
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.
+170 -3
View File
@@ -1,3 +1,170 @@
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
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 +189,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 +214,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 +324,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
+88 -38
View File
@@ -19,7 +19,7 @@
#
PROG := busybox
VERSION := 0.43
VERSION := 0.46
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
export VERSION
@@ -31,55 +31,48 @@ 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/'`
# To compile vs an alternative libc, you may need to use/adjust
# the following lines to meet your needs. This is how I did it...
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
#CFLAGS+=-nostdinc -fno-builtin -I/home/andersen/CVS/uC-libc/include -I$(GCCINCDIR)
#LDFLAGS+=-nostdlib
#LIBRARIES = /home/andersen/CVS/uC-libc/libc.a
CC = gcc
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")
# 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)
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; )
ifeq ($(GCCSUPPORTSOPTSIZE), true)
OPTIMIZATION = -Os
else
OPTIMIZATION = -O2
endif
# Allow alternative stripping tools to be used...
ifndef $(STRIPTOOL)
STRIPTOOL = strip
endif
# -D_GNU_SOURCE is needed because environ is used in init.c
ifeq ($(DODEBUG),true)
CFLAGS += -Wall -g -D_GNU_SOURCE
LDFLAGS =
LDFLAGS +=
STRIP =
else
CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
LDFLAGS = -s
CFLAGS += -Wall $(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
#
#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
endif
@@ -87,7 +80,6 @@ ifndef $(PREFIX)
PREFIX = `pwd`/_install
endif
LIBRARIES =
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
@@ -95,17 +87,62 @@ ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif
all: busybox busybox.links
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/busybox.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/busybox.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.mkll | sort >$@
regexp.o nfsmount.o: %.o: %.h
nfsmount.o cmdedit.o: %.o: %.h
$(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile
test tests:
@@ -115,6 +152,11 @@ clean:
- rm -f busybox.links *~ *.o core
- rm -rf _install
- 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
distclean: clean
- rm -f busybox
@@ -123,8 +165,7 @@ distclean: clean
install: busybox busybox.links
./install.sh $(PREFIX)
dist release: distclean
$(MAKE) -C docs
dist release: distclean doc
cd ..; \
rm -rf busybox-$(VERSION); \
cp -a busybox busybox-$(VERSION); \
@@ -139,4 +180,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 busybox.def.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
+31 -34
View File
@@ -4,12 +4,13 @@ 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 (when it supports network logging)
will remain in BusyBox.
-Erik
@@ -21,49 +22,41 @@ around to it some time. If you have any good ideas, please let me know.
* rdate
* hwclock
* stty
* cut
* expr
* wget (or whatever I call it)
* tftp
* ftp
* group/commonize strings, remove dups (for i18n, l10n)
* consider making a unified option parser (if it can be done
modular, small, etc.)
-----------------------
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.
-----------------------
Compile with debugging on, run 'nm --size-sort ./busybox'
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,
-----------------------
@@ -76,6 +69,10 @@ I'll add this to the TODO list,
------------------------------------------------------------------
An interesting email listing some apps that use /proc. BusyBox
tries to avoid /proc as mush as is possible, so this stuff is
interesting (to me at least):
Date: Fri, 25 Feb 2000 08:23:12 +0000 (GMT)
From: Riley Williams <rhw@MemAlpha.CX>
+161 -35
View File
@@ -30,17 +30,15 @@ int atexit(void (*__func) (void))
void *__libc_stack_end;
#endif
static const struct Applet applets[] = {
const struct BB_applet applets[] = {
#ifdef BB_AR
{"ar", ar_main, _BB_DIR_USR_BIN},
#endif
#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},
#endif
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
@@ -65,9 +63,15 @@ static const struct Applet applets[] = {
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_CUT
{"cut", cut_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
#ifdef BB_DC
{"dc", dc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DD
{"dd", dd_main, _BB_DIR_BIN},
#endif
@@ -83,6 +87,9 @@ static const struct Applet applets[] = {
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUMPKMAP
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
#endif
@@ -134,6 +141,9 @@ static const struct Applet applets[] = {
#ifdef BB_HOSTNAME
{"hostname", hostname_main, _BB_DIR_BIN},
#endif
#ifdef BB_ID
{"id", id_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_INIT
{"init", init_main, _BB_DIR_SBIN},
#endif
@@ -179,8 +189,8 @@ static const struct Applet applets[] = {
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MATH
{"math", math_main, _BB_DIR_USR_BIN},
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
@@ -197,8 +207,11 @@ static const struct Applet applets[] = {
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MNC
{"mnc", mnc_main, _BB_DIR_USR_BIN},
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
#ifdef BB_NC
{"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
@@ -245,12 +258,12 @@ static const struct Applet applets[] = {
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
@@ -311,12 +324,21 @@ static const struct Applet applets[] = {
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUENCODE
{"uuencode", uuencode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUDECODE
{"uudecode", uudecode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_WC
{"wc", wc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHICH
{"which", which_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHOAMI
{"whoami", whoami_main, _BB_DIR_USR_BIN},
#endif
@@ -333,12 +355,119 @@ static const struct Applet applets[] = {
};
#ifdef BB_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, internal.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 {
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
}
/* create (sym)links for each applet */
static int install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
int i;
int rc = 0;
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
);
#if 1
rc |= Link(busybox, command);
#else
puts(command);
#endif
if (rc) {
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
}
}
return rc;
}
#if 0
int uninstall_links() ?
#endif
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
char *s;
char *name;
const struct Applet *a = applets;
const struct BB_applet *a = applets;
#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 = name = argv[0]; *s != '\0';) {
if (*s++ == '/')
@@ -347,20 +476,20 @@ int main(int argc, char **argv)
*argv = name;
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-')
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);
exit(((*(a->main)) (argc, argv)));
}
a++;
}
exit(busybox_main(argc, argv));
return(busybox_main(argc, argv));
}
@@ -372,18 +501,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, "BusyBox v%s (%s) multi-call binary -- GPL2\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", BB_VER, BB_BT);
while (a->name != 0) {
col +=
@@ -396,11 +523,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));
}
/*
+332
View File
@@ -0,0 +1,332 @@
/* 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 10 June 2000
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <sys/types.h>
#include "internal.h"
#define AR_BLOCK_SIZE 60
#define AR_PRESERVE_DATE 1 /* preserve original dates */
#define AR_VERBOSE 2 /* be verbose */
#define AR_DISPLAY 4 /* display contents */
#define AR_EXT_TO_FILE 8 /* extract contents of archive */
#define AR_EXT_TO_STDOUT 16 /* extract to stdout */
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
struct ArHeader { /* Byte Offset */
char ar_name[16]; /* 0-15 */
char ar_date[12]; /* 16-27 */
char ar_uid[6], ar_gid[6]; /* 28-39 */
char ar_mode[8]; /* 40-47 */
char ar_size[10]; /* 48-57 */
char ar_fmag[2]; /* 58-59 */
};
typedef struct ArHeader ArHeader;
struct ArInfo {
char name[17]; /* File name */
time_t date; /* long int, No of seconds since epoch */
uid_t uid; /* unsigned int, Numeric UID */
gid_t gid; /* unsigned int, Numeric GID */
mode_t mode; /* unsigned int, Unix mode */
size_t size; /* int, Size of the file */
};
typedef struct ArInfo ArInfo;
static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nExtract or list files from an ar archive.\n\n"
"Options:\n"
"\to\t\tpreserve original dates\n"
"\tp\t\textract to stdout\n"
"\tt\t\tlist\n"
"\tx\t\textract\n"
"\tv\t\tverbosely list files processed\n"
#endif
;
/*
* Display details of a file, verbosly if funct=2
*/
static void displayEntry(struct ArInfo *entry, int funct)
{
/* TODO convert mode to string */
if ((funct & AR_VERBOSE) == AR_VERBOSE)
printf("%i %i/%i %8i %s ", entry->mode, entry->uid, entry->gid,
entry->size, timeString(entry->date));
printf("%s\n", entry->name);
}
/* this is from tar.c remove later*/
static long getOctal(const char *cp, int size)
{
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
if ((size == 0) || !isOctal(*cp))
return -1;
for(; (size > 0) && isOctal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
if ((size > 0) && *cp)
return -1;
return val;
}
/*
* Converts from the char based struct to a new struct with stricter types
*/
static int processArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
{
int count2;
int count;
/* check end of header marker is valid */
if ((rawHeader->ar_fmag[0]!='`') || (rawHeader->ar_fmag[1]!='\n'))
return(FALSE);
/* convert filename */
for (count = 0; count < 16; count++) {
/* allow spaces in filename except at the end */
if (rawHeader->ar_name[count] == ' ') {
for (count2 = count; count2 < 16; count2++)
if (!isspace(rawHeader->ar_name[count2]))
break;
if (count2 >= 16)
break;
}
/* GNU ar uses '/' as an end of filename marker */
if (rawHeader->ar_name[count] == '/')
break;
header->name[count] = rawHeader->ar_name[count];
}
header->name[count] = '\0';
header->date = atoi(rawHeader->ar_date);
header->uid = atoi(rawHeader->ar_uid);
header->gid = atoi(rawHeader->ar_gid);
header->mode = getOctal(rawHeader->ar_mode, sizeof(rawHeader->ar_mode));
header->size = atoi(rawHeader->ar_size);
return (TRUE);
}
/*
* Copy size bytes from current position if srcFd to current position in dstFd
* taken from tarExtractRegularFile in tar.c, remove later
*/
static int copySubFile(int srcFd, int dstFd, int copySize)
{
int readSize, writeSize, doneSize;
char buffer[BUFSIZ];
while (copySize > 0) {
if (copySize > BUFSIZ)
readSize = BUFSIZ;
else
readSize = copySize;
writeSize = fullRead(srcFd, buffer, readSize);
if (writeSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
doneSize = fullWrite(dstFd, buffer, writeSize);
if (doneSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
copySize -= doneSize;
}
return (TRUE);
}
/*
* Extract the file described in ArInfo to the specified path
* set the new files uid, gid and mode
*/
static int extractToFile(struct ArInfo *file, int funct, int srcFd, const char *path)
{
int dstFd, temp;
struct stat tmpStat;
char *pathname = NULL;
struct utimbuf newtime;
if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
if (!createPath(path, 0777)) {
fatalError("Cannot extract to specified path");
return (FALSE);
}
}
temp = (strlen(path) + 16);
pathname = (char *) xmalloc(temp);
pathname = strcpy(pathname, path);
pathname = strcat(pathname, file->name);
dstFd = device_open(pathname, O_WRONLY | O_CREAT);
temp = copySubFile(srcFd, dstFd, file->size);
fchown(dstFd, file->uid, file->gid);
fchmod(dstFd, file->mode);
close(dstFd);
if ((funct&AR_PRESERVE_DATE)==AR_PRESERVE_DATE)
newtime.modtime=file->date;
else
newtime.modtime=time(0);
newtime.actime=time(0);
temp = utime(pathname, &newtime);
return (TRUE);
}
/*
* Return a file descriptor for the specified file and do error checks
*/
static int getArFd(char *filename)
{
int arFd;
char arVersion[8];
arFd = open(filename, O_RDONLY);
if (arFd < 0) {
errorMsg("Error opening '%s': %s\n", filename, strerror(errno));
return (FALSE);
}
if (fullRead(arFd, arVersion, 8) <= 0) {
errorMsg( "ar: Unexpected EOF in archive\n");
return (FALSE);
}
if (strncmp(arVersion,"!<arch>",7) != 0) {
errorMsg("ar header fails check ");
return(FALSE);
}
return arFd;
}
/*
* Step through the ar file and process it one entry at a time
* fileList[0] is the name of the ar archive
* fileList[1] and up are filenames to extract from the archive
* funct contains flags to specify the actions to be performed
*/
static int readArFile(char *fileList[16], int fileListSize, int funct)
{
int arFd, status, extFileFlag, i, lastOffset=0;
ArHeader rawArHeader;
ArInfo arEntry;
/* open the ar archive */
arFd=getArFd(fileList[0]);
/* read the first header, then loop until ono more headers */
while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
== AR_BLOCK_SIZE) {
/* check the header is valid, if not try reading the header
agian with an offset of 1, needed as some ar archive end
with a '\n' which isnt counted in specified file size */
if ((status=processArHeader(&rawArHeader, &arEntry))==FALSE ) {
if ((i=lseek(arFd, 0, SEEK_CUR))==(lastOffset+60))
lseek(arFd, lastOffset+1, SEEK_SET);
else
return(FALSE);
}
else {
extFileFlag=0;
if (funct&AR_DISPLAY)
displayEntry(&arEntry, funct);
/* check file was specified to be extracted only if
some file were specified */
if ((funct&AR_EXT_TO_FILE) || (funct&AR_EXT_TO_STDOUT)){
if (fileListSize==1)
extFileFlag=1;
else {
for( i=1; i<=fileListSize; i++)
if ((status=(strcmp(fileList[i],arEntry.name)))==0)
extFileFlag=1;
}
}
if (extFileFlag==1) {
if (funct&AR_EXT_TO_FILE)
extractToFile(&arEntry, funct, arFd, "./");
else
copySubFile(arFd,fileno(stdout),arEntry.size);
}
else
lseek(arFd, arEntry.size, SEEK_CUR);
lastOffset=lseek(arFd, 0, SEEK_CUR);
} /* if processArHeader */
} /* while */
return (TRUE);
}
extern int ar_main(int argc, char **argv)
{
int funct = 0, ret=0, i=0;
char *fileList[16], c, *opt_ptr;
if (argc < 2)
usage(ar_usage);
opt_ptr = argv[1];
if (*opt_ptr == '-')
++opt_ptr;
while ((c = *opt_ptr++) != '\0') {
switch (c) {
case 'o':
funct = funct | AR_PRESERVE_DATE;
break;
case 'v':
funct = funct | AR_VERBOSE;
break;
case 't':
funct = funct | AR_DISPLAY;
break;
case 'x':
funct = funct | AR_EXT_TO_FILE;
break;
case 'p':
funct = funct | AR_EXT_TO_STDOUT;
break;
default:
usage(ar_usage);
}
}
for(i=0; i<(argc-2); i++)
fileList[i]=argv[i+2];
if (funct > 3)
ret = readArFile(fileList, (argc-2), funct);
return (ret);
}
+332
View File
@@ -0,0 +1,332 @@
/* 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 10 June 2000
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <sys/types.h>
#include "internal.h"
#define AR_BLOCK_SIZE 60
#define AR_PRESERVE_DATE 1 /* preserve original dates */
#define AR_VERBOSE 2 /* be verbose */
#define AR_DISPLAY 4 /* display contents */
#define AR_EXT_TO_FILE 8 /* extract contents of archive */
#define AR_EXT_TO_STDOUT 16 /* extract to stdout */
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
struct ArHeader { /* Byte Offset */
char ar_name[16]; /* 0-15 */
char ar_date[12]; /* 16-27 */
char ar_uid[6], ar_gid[6]; /* 28-39 */
char ar_mode[8]; /* 40-47 */
char ar_size[10]; /* 48-57 */
char ar_fmag[2]; /* 58-59 */
};
typedef struct ArHeader ArHeader;
struct ArInfo {
char name[17]; /* File name */
time_t date; /* long int, No of seconds since epoch */
uid_t uid; /* unsigned int, Numeric UID */
gid_t gid; /* unsigned int, Numeric GID */
mode_t mode; /* unsigned int, Unix mode */
size_t size; /* int, Size of the file */
};
typedef struct ArInfo ArInfo;
static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nExtract or list files from an ar archive.\n\n"
"Options:\n"
"\to\t\tpreserve original dates\n"
"\tp\t\textract to stdout\n"
"\tt\t\tlist\n"
"\tx\t\textract\n"
"\tv\t\tverbosely list files processed\n"
#endif
;
/*
* Display details of a file, verbosly if funct=2
*/
static void displayEntry(struct ArInfo *entry, int funct)
{
/* TODO convert mode to string */
if ((funct & AR_VERBOSE) == AR_VERBOSE)
printf("%i %i/%i %8i %s ", entry->mode, entry->uid, entry->gid,
entry->size, timeString(entry->date));
printf("%s\n", entry->name);
}
/* this is from tar.c remove later*/
static long getOctal(const char *cp, int size)
{
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
if ((size == 0) || !isOctal(*cp))
return -1;
for(; (size > 0) && isOctal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
if ((size > 0) && *cp)
return -1;
return val;
}
/*
* Converts from the char based struct to a new struct with stricter types
*/
static int processArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
{
int count2;
int count;
/* check end of header marker is valid */
if ((rawHeader->ar_fmag[0]!='`') || (rawHeader->ar_fmag[1]!='\n'))
return(FALSE);
/* convert filename */
for (count = 0; count < 16; count++) {
/* allow spaces in filename except at the end */
if (rawHeader->ar_name[count] == ' ') {
for (count2 = count; count2 < 16; count2++)
if (!isspace(rawHeader->ar_name[count2]))
break;
if (count2 >= 16)
break;
}
/* GNU ar uses '/' as an end of filename marker */
if (rawHeader->ar_name[count] == '/')
break;
header->name[count] = rawHeader->ar_name[count];
}
header->name[count] = '\0';
header->date = atoi(rawHeader->ar_date);
header->uid = atoi(rawHeader->ar_uid);
header->gid = atoi(rawHeader->ar_gid);
header->mode = getOctal(rawHeader->ar_mode, sizeof(rawHeader->ar_mode));
header->size = atoi(rawHeader->ar_size);
return (TRUE);
}
/*
* Copy size bytes from current position if srcFd to current position in dstFd
* taken from tarExtractRegularFile in tar.c, remove later
*/
static int copySubFile(int srcFd, int dstFd, int copySize)
{
int readSize, writeSize, doneSize;
char buffer[BUFSIZ];
while (copySize > 0) {
if (copySize > BUFSIZ)
readSize = BUFSIZ;
else
readSize = copySize;
writeSize = fullRead(srcFd, buffer, readSize);
if (writeSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
doneSize = fullWrite(dstFd, buffer, writeSize);
if (doneSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
copySize -= doneSize;
}
return (TRUE);
}
/*
* Extract the file described in ArInfo to the specified path
* set the new files uid, gid and mode
*/
static int extractToFile(struct ArInfo *file, int funct, int srcFd, const char *path)
{
int dstFd, temp;
struct stat tmpStat;
char *pathname = NULL;
struct utimbuf newtime;
if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
if (!createPath(path, 0777)) {
fatalError("Cannot extract to specified path");
return (FALSE);
}
}
temp = (strlen(path) + 16);
pathname = (char *) xmalloc(temp);
pathname = strcpy(pathname, path);
pathname = strcat(pathname, file->name);
dstFd = device_open(pathname, O_WRONLY | O_CREAT);
temp = copySubFile(srcFd, dstFd, file->size);
fchown(dstFd, file->uid, file->gid);
fchmod(dstFd, file->mode);
close(dstFd);
if ((funct&AR_PRESERVE_DATE)==AR_PRESERVE_DATE)
newtime.modtime=file->date;
else
newtime.modtime=time(0);
newtime.actime=time(0);
temp = utime(pathname, &newtime);
return (TRUE);
}
/*
* Return a file descriptor for the specified file and do error checks
*/
static int getArFd(char *filename)
{
int arFd;
char arVersion[8];
arFd = open(filename, O_RDONLY);
if (arFd < 0) {
errorMsg("Error opening '%s': %s\n", filename, strerror(errno));
return (FALSE);
}
if (fullRead(arFd, arVersion, 8) <= 0) {
errorMsg( "ar: Unexpected EOF in archive\n");
return (FALSE);
}
if (strncmp(arVersion,"!<arch>",7) != 0) {
errorMsg("ar header fails check ");
return(FALSE);
}
return arFd;
}
/*
* Step through the ar file and process it one entry at a time
* fileList[0] is the name of the ar archive
* fileList[1] and up are filenames to extract from the archive
* funct contains flags to specify the actions to be performed
*/
static int readArFile(char *fileList[16], int fileListSize, int funct)
{
int arFd, status, extFileFlag, i, lastOffset=0;
ArHeader rawArHeader;
ArInfo arEntry;
/* open the ar archive */
arFd=getArFd(fileList[0]);
/* read the first header, then loop until ono more headers */
while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
== AR_BLOCK_SIZE) {
/* check the header is valid, if not try reading the header
agian with an offset of 1, needed as some ar archive end
with a '\n' which isnt counted in specified file size */
if ((status=processArHeader(&rawArHeader, &arEntry))==FALSE ) {
if ((i=lseek(arFd, 0, SEEK_CUR))==(lastOffset+60))
lseek(arFd, lastOffset+1, SEEK_SET);
else
return(FALSE);
}
else {
extFileFlag=0;
if (funct&AR_DISPLAY)
displayEntry(&arEntry, funct);
/* check file was specified to be extracted only if
some file were specified */
if ((funct&AR_EXT_TO_FILE) || (funct&AR_EXT_TO_STDOUT)){
if (fileListSize==1)
extFileFlag=1;
else {
for( i=1; i<=fileListSize; i++)
if ((status=(strcmp(fileList[i],arEntry.name)))==0)
extFileFlag=1;
}
}
if (extFileFlag==1) {
if (funct&AR_EXT_TO_FILE)
extractToFile(&arEntry, funct, arFd, "./");
else
copySubFile(arFd,fileno(stdout),arEntry.size);
}
else
lseek(arFd, arEntry.size, SEEK_CUR);
lastOffset=lseek(arFd, 0, SEEK_CUR);
} /* if processArHeader */
} /* while */
return (TRUE);
}
extern int ar_main(int argc, char **argv)
{
int funct = 0, ret=0, i=0;
char *fileList[16], c, *opt_ptr;
if (argc < 2)
usage(ar_usage);
opt_ptr = argv[1];
if (*opt_ptr == '-')
++opt_ptr;
while ((c = *opt_ptr++) != '\0') {
switch (c) {
case 'o':
funct = funct | AR_PRESERVE_DATE;
break;
case 'v':
funct = funct | AR_VERBOSE;
break;
case 't':
funct = funct | AR_DISPLAY;
break;
case 'x':
funct = funct | AR_EXT_TO_FILE;
break;
case 'p':
funct = funct | AR_EXT_TO_STDOUT;
break;
default:
usage(ar_usage);
}
}
for(i=0; i<(argc-2); i++)
fileList[i]=argv[i+2];
if (funct > 3)
ret = readArFile(fileList, (argc-2), funct);
return (ret);
}
+31 -154
View File
@@ -28,13 +28,18 @@
*/
#include "internal.h"
#include <getopt.h>
static const char gunzip_usage[] =
"gunzip [OPTION]... FILE\n\n"
"Uncompress FILE (or standard input if FILE is '-').\n\n"
"gunzip [OPTION]... FILE\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nUncompress FILE (or standard input if FILE is '-').\n\n"
"Options:\n"
"\t-c\tWrite output to standard output\n"
"\t-t\tTest compressed file integrity\n";
"\t-t\tTest compressed file integrity\n"
#endif
;
/* These defines are very important for BusyBox. Without these,
@@ -43,8 +48,9 @@ static const char gunzip_usage[] =
#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"
@@ -102,7 +108,6 @@ static char *license_msg[] = {
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/param.h> /* for PATH_MAX */
/* #include "tailor.h" */
@@ -207,7 +212,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, "gunzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -363,25 +368,23 @@ 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);
static 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 +449,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 +517,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
@@ -716,11 +592,12 @@ int gunzip_main(int argc, char **argv)
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)
if (strcmp(*argv, "zcat") == 0) {
to_stdout = 1;
if (argc == 1) {
fromstdin = 1;
}
}
/* Parse any options */
while (--argc > 0 && **(++argv) == '-') {
@@ -870,7 +747,7 @@ int gunzip_main(int argc, char **argv)
exit(FALSE);
}
}
exit(exit_code);
return(exit_code);
}
@@ -1053,7 +930,7 @@ int in, out; /* input and output file descriptors */
int res = inflate();
if (res == 3) {
errorMsg("out of memory");
errorMsg(memory_exhausted, "gunzip");
} else if (res != 0) {
errorMsg("invalid compressed data--format violated");
}
@@ -1156,7 +1033,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 +1061,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 +1112,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 +1178,7 @@ const char *reject;
/* ========================================================================
* Error handlers.
*/
void read_error()
void read_error_msg()
{
fprintf(stderr, "\n");
if (errno != 0) {
@@ -1312,7 +1189,7 @@ void read_error()
abort_gzip();
}
void write_error()
void write_error_msg()
{
fprintf(stderr, "\n");
perror("");
+18 -16
View File
@@ -30,6 +30,9 @@
*/
#include "internal.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
@@ -39,12 +42,15 @@
static const char gzip_usage[] =
"gzip [OPTION]... FILE\n\n"
"Compress FILE with maximum compression.\n"
"gzip [OPTION]... FILE\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCompress 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";
"\t-c\tWrite output to standard output instead of FILE.gz\n"
#endif
;
/* I don't like nested includes, but the string and io functions are used
@@ -121,7 +127,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, "gzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -276,8 +282,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 +327,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 */
@@ -1778,7 +1782,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) */
@@ -1878,13 +1881,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 +1921,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 +1946,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 +2275,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 +3136,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 +3251,7 @@ char *env; /* name of environment variable */
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
errorMsg("out of memory");
errorMsg(memory_exhausted, "gzip");
oargv = *argvp;
*argvp = nargv;
+28 -13
View File
@@ -49,7 +49,6 @@
#include <utime.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
#include <sys/param.h> /* for PATH_MAX */
static const char tar_usage[] =
@@ -61,8 +60,9 @@ static const char tar_usage[] =
#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"
"[-f tarFile] [FILE] ...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreate, 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
@@ -78,6 +78,7 @@ static const char tar_usage[] =
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
#endif
;
/* Tar file constants */
@@ -172,7 +173,7 @@ extern int tar_main(int argc, char **argv)
#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;
@@ -184,19 +185,21 @@ extern int tar_main(int argc, char **argv)
usage(tar_usage);
/* Parse any options */
while (--argc > 0 && (**(++argv) != '\0')) {
while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
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)
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, "-"))
tostdoutFlag = TRUE;
stopIt=TRUE;
break;
@@ -245,12 +248,16 @@ extern int tar_main(int argc, char **argv)
break;
}
#endif
if (strcmp(*argv, "-help")==0) {
usage(tar_usage);
}
break;
default:
fatalError( "Unknown tar flag '%c'\n"
"Try `tar --help' for more information\n", **argv);
}
++(*argv);
}
}
@@ -264,7 +271,8 @@ extern int tar_main(int argc, char **argv)
#else
exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
#endif
} else {
}
if (listFlag == TRUE || extractFlag == TRUE) {
exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
}
@@ -297,11 +305,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 */
@@ -608,7 +619,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
len1=snprintf(buf, sizeof(buf), "%ld,%-ld ",
header.devmajor, header.devminor);
} else {
len1=snprintf(buf, sizeof(buf), "%d ", header.size);
len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
}
/* Jump through some hoops to make the columns match up */
for(;(len+len1)<31;len++)
@@ -639,7 +650,8 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
}
/* Remove any clutter lying in our way */
unlink( header.name);
if (extractFlag == TRUE) /* .. but only if we are extracting (as */
unlink( header.name); /* opposed to listing) (rob@sysgo.de) */
/* If we got here, we can be certain we have a legitimate
* header to work with. So work with it. */
@@ -815,12 +827,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;
+23 -11
View File
@@ -24,22 +24,34 @@
#include "internal.h"
#include <stdio.h>
const char *basename_usage="basename FILE [SUFFIX]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nStrips directory path and suffixes from FILE.\n"
"If specified, also removes any trailing SUFFIX.\n"
#endif
;
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);
}
+161 -35
View File
@@ -30,17 +30,15 @@ int atexit(void (*__func) (void))
void *__libc_stack_end;
#endif
static const struct Applet applets[] = {
const struct BB_applet applets[] = {
#ifdef BB_AR
{"ar", ar_main, _BB_DIR_USR_BIN},
#endif
#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},
#endif
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
@@ -65,9 +63,15 @@ static const struct Applet applets[] = {
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_CUT
{"cut", cut_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
#ifdef BB_DC
{"dc", dc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DD
{"dd", dd_main, _BB_DIR_BIN},
#endif
@@ -83,6 +87,9 @@ static const struct Applet applets[] = {
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUMPKMAP
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
#endif
@@ -134,6 +141,9 @@ static const struct Applet applets[] = {
#ifdef BB_HOSTNAME
{"hostname", hostname_main, _BB_DIR_BIN},
#endif
#ifdef BB_ID
{"id", id_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_INIT
{"init", init_main, _BB_DIR_SBIN},
#endif
@@ -179,8 +189,8 @@ static const struct Applet applets[] = {
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MATH
{"math", math_main, _BB_DIR_USR_BIN},
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
@@ -197,8 +207,11 @@ static const struct Applet applets[] = {
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MNC
{"mnc", mnc_main, _BB_DIR_USR_BIN},
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
#ifdef BB_NC
{"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
@@ -245,12 +258,12 @@ static const struct Applet applets[] = {
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
@@ -311,12 +324,21 @@ static const struct Applet applets[] = {
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUENCODE
{"uuencode", uuencode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUDECODE
{"uudecode", uudecode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_WC
{"wc", wc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHICH
{"which", which_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHOAMI
{"whoami", whoami_main, _BB_DIR_USR_BIN},
#endif
@@ -333,12 +355,119 @@ static const struct Applet applets[] = {
};
#ifdef BB_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, internal.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 {
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
}
/* create (sym)links for each applet */
static int install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
int i;
int rc = 0;
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
);
#if 1
rc |= Link(busybox, command);
#else
puts(command);
#endif
if (rc) {
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
}
}
return rc;
}
#if 0
int uninstall_links() ?
#endif
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
char *s;
char *name;
const struct Applet *a = applets;
const struct BB_applet *a = applets;
#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 = name = argv[0]; *s != '\0';) {
if (*s++ == '/')
@@ -347,20 +476,20 @@ int main(int argc, char **argv)
*argv = name;
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-')
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);
exit(((*(a->main)) (argc, argv)));
}
a++;
}
exit(busybox_main(argc, argv));
return(busybox_main(argc, argv));
}
@@ -372,18 +501,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, "BusyBox v%s (%s) multi-call binary -- GPL2\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", BB_VER, BB_BT);
while (a->name != 0) {
col +=
@@ -396,11 +523,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));
}
/*
+87 -21
View File
@@ -7,6 +7,7 @@
//
//
// BusyBox Applications
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
@@ -14,7 +15,9 @@
#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
@@ -22,6 +25,7 @@
#define BB_DMESG
#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
#define BB_ECHO
#define BB_FBSET
#define BB_FDFLUSH
@@ -36,12 +40,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 +55,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
@@ -74,7 +77,7 @@
#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,8 +88,7 @@
#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
@@ -94,7 +96,10 @@
#define BB_UPTIME
#define BB_USLEEP
#define BB_WC
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
@@ -110,12 +115,18 @@
// 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, 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 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 /dev on your embedded system:
// mknod /dev/modules c 10 23
// 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
@@ -130,8 +141,9 @@
// 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,8 +160,11 @@
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// 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
@@ -168,6 +183,9 @@
//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
//
//Simple tail implementation (2k vs 6k for the full one). Still
//provides 'tail -f' support -- but for only one file at a time.
#define BB_FEATURE_SIMPLE_TAIL
@@ -178,8 +196,13 @@
// 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
// (This does not yet work with Linux 2.[34].x kernels)
#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
@@ -193,6 +216,11 @@
// 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
//amoung 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 +228,23 @@
//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
//
//
// 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
//
// End of Features List
//
@@ -243,3 +288,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
+8 -7
View File
@@ -1,5 +1,5 @@
Name: busybox
Version: 0.43
Version: 0.46
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 -2
View File
@@ -45,7 +45,11 @@ extern int cat_main(int argc, char **argv)
}
if (**(argv + 1) == '-') {
usage("cat [file ...]\n");
usage("cat [FILE ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nConcatenates FILE(s) and prints them to the standard output.\n"
#endif
);
}
argc--;
@@ -57,7 +61,7 @@ extern int cat_main(int argc, char **argv)
}
print_file(file);
}
exit(TRUE);
return(TRUE);
}
/*
+37 -26
View File
@@ -25,6 +25,7 @@
#include "internal.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_option
#define bb_need_too_few_args
#include "messages.c"
#include <stdio.h>
@@ -32,8 +33,8 @@
#include <pwd.h>
static uid_t uid = -1;
static gid_t gid = -1;
static unsigned long uid = -1;
static unsigned long gid = -1;
static int whichApp;
static char *invocationName = NULL;
static char *theMode = NULL;
@@ -43,21 +44,27 @@ 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 chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChange the group membership of each FILE to GROUP.\n"
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
#endif
;
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";
"chown [OPTION]... OWNER[<.|:>[GROUP] FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChange the owner and/or group of each FILE to OWNER and/or GROUP.\n"
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
#endif
;
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"
"chmod [-R] MODE[,MODE]... FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nEach 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";
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
#endif
;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
@@ -94,8 +101,8 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
int chmod_chown_chgrp_main(int argc, char **argv)
{
int recursiveFlag = FALSE;
char *groupName;
char *p;
char *groupName=NULL;
char *p=NULL;
const char *appUsage;
whichApp = (strcmp(*argv, "chown") == 0)?
@@ -108,24 +115,28 @@ 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 (*++(*argv)) {
switch (**argv) {
case 'R':
recursiveFlag = TRUE;
break;
default:
fprintf(stderr, invalid_option, invocationName, **argv);
usage(appUsage);
case 'R':
recursiveFlag = TRUE;
break;
default:
fprintf(stderr, invalid_option, invocationName, **argv);
usage(appUsage);
}
argc--;
}
argv++;
}
if (argc == 0 || *argv == NULL) {
fprintf(stderr, too_few_args, invocationName);
usage(appUsage);
}
if (whichApp == CHMOD_APP) {
theMode = *argv;
} else {
+12 -11
View File
@@ -28,14 +28,18 @@
#include <errno.h>
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n"
"Run COMMAND with root directory set to NEWROOT.\n";
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRun COMMAND with root directory set to NEWROOT.\n"
#endif
;
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(chroot_usage);
}
@@ -43,27 +47,24 @@ int chroot_main(int argc, char **argv)
argv++;
if (chroot(*argv) || (chdir("/"))) {
fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
fatalError("chroot: cannot change root directory to %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
}
argc--;
argv++;
if (argc >= 1) {
fprintf(stderr, "command: %s\n", *argv);
prog = *argv;
execvp(*argv, argv);
} else {
char *prog;
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
}
fprintf(stderr, "chroot: cannot execute %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
fatalError("chroot: cannot execute %s: %s\n",
prog, strerror(errno));
}
+12 -7
View File
@@ -5,22 +5,27 @@
* busyboxed by Erik Andersen
*/
#include "internal.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
/* From <linux/vt.h> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
extern int getfd(void);
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");
usage ("chvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
#endif
);
}
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
@@ -32,7 +37,7 @@ int chvt_main(int argc, char **argv)
perror("VT_WAITACTIVE");
exit(FALSE);
}
exit(TRUE);
return(TRUE);
}
+1 -1
View File
@@ -29,5 +29,5 @@
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
exit(TRUE);
return(TRUE);
}
+71 -22
View File
@@ -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,7 +53,32 @@
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 */
@@ -84,14 +109,15 @@ 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);
}
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 +143,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;
@@ -233,7 +265,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,7 +278,7 @@ 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.
*/
@@ -379,19 +411,17 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
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 +429,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 +445,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, sizeof(command));
len = cursor = 0;
break;
case 4:
/* Control-d -- Delete one character, or exit
@@ -435,12 +481,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 +540,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 +640,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;
@@ -644,6 +692,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
extern void cmdedit_init(void)
{
atexit(cmdedit_reset_term);
signal(SIGKILL, clean_up_and_die);
signal(SIGINT, clean_up_and_die);
signal(SIGQUIT, clean_up_and_die);
signal(SIGTERM, clean_up_and_die);
+5 -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,7 @@
typedef size_t (*cmdedit_strwidth_proc)(char *);
void cmdedit_init(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 +22,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 +34,4 @@ extern int (*cmdedit_tab_hook)();
#endif /* __STDC__ */
#endif /* GETLINE_H */
#endif /* CMDEDIT_H */
+12 -7
View File
@@ -5,22 +5,27 @@
* busyboxed by Erik Andersen
*/
#include "internal.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
/* From <linux/vt.h> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
extern int getfd(void);
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");
usage ("chvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
#endif
);
}
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
@@ -32,7 +37,7 @@ int chvt_main(int argc, char **argv)
perror("VT_WAITACTIVE");
exit(FALSE);
}
exit(TRUE);
return(TRUE);
}
+1 -1
View File
@@ -29,5 +29,5 @@
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
exit(TRUE);
return(TRUE);
}
+13 -7
View File
@@ -5,13 +5,15 @@
*/
#include "internal.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);
/* From <linux/vt.h> */
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
char *progname;
int deallocvt_main(int argc, char *argv[])
@@ -20,7 +22,11 @@ int deallocvt_main(int argc, char *argv[])
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n");
("deallocvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDeallocate unused virtual terminal /dev/ttyN\n"
#endif
);
}
progname = argv[0];
@@ -31,7 +37,7 @@ int deallocvt_main(int argc, char *argv[])
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
exit(1);
exit( FALSE);
}
} else
for (i = 1; i < argc; i++) {
@@ -45,8 +51,8 @@ int deallocvt_main(int argc, char *argv[])
perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n",
progname, num);
exit(1);
exit( FALSE);
}
}
exit(0);
return( TRUE);
}
+100
View File
@@ -0,0 +1,100 @@
/* 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 "internal.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
static const char dumpkmap_usage[] = "dumpkmap\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints out a binary keyboard translation table to standard input.\n"
#endif
;
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) {
fprintf(stderr, "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) {
fprintf(stderr, "ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,&ke.kb_value,2);
}
}
}
}
close(fd);
return 0;
}
+8 -6
View File
@@ -22,8 +22,11 @@
#include <sys/ioctl.h>
#include <sys/kd.h>
static const char loadacm_usage[] = "loadacm\n\n"
"Loads an acm from standard input.\n";
static const char loadacm_usage[] = "loadacm\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nLoads an acm from standard input.\n"
#endif
;
typedef unsigned short unicode;
@@ -65,7 +68,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) */
@@ -137,10 +140,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);
}
fprintf(stderr, "Error parsing symbolic map\n");
return(1);
}
+5 -2
View File
@@ -30,8 +30,11 @@
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
static const char loadfont_usage[] = "loadfont\n\n"
"Loads a console font from standard input.\n";
static const char loadfont_usage[] = "loadfont\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"Loads a console font from standard input.\n"
#endif
;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
+18 -5
View File
@@ -24,13 +24,26 @@
#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
static const char loadkmap_usage[] = "loadkmap\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nLoads a binary keyboard translation table from standard input.\n"
#endif
;
int loadkmap_main(int argc, char **argv)
@@ -91,5 +104,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);
}
+83
View File
@@ -0,0 +1,83 @@
/* 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 "internal.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 */
static const char setkeycodes_usage[] =
"setkeycodes SCANCODE KEYCODE ...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nSet entries into the kernel's scancode-to-keycode map,\n"
"allowing unusual keyboards to generate usable keycodes.\n\n"
"SCANCODE may be either xx or e0xx (hexadecimal),\n"
"and KEYCODE is given in decimal\n"
#endif
;
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);
}
+23 -11
View File
@@ -24,22 +24,34 @@
#include "internal.h"
#include <stdio.h>
const char *basename_usage="basename FILE [SUFFIX]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nStrips directory path and suffixes from FILE.\n"
"If specified, also removes any trailing SUFFIX.\n"
#endif
;
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 -2
View File
@@ -45,7 +45,11 @@ extern int cat_main(int argc, char **argv)
}
if (**(argv + 1) == '-') {
usage("cat [file ...]\n");
usage("cat [FILE ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nConcatenates FILE(s) and prints them to the standard output.\n"
#endif
);
}
argc--;
@@ -57,7 +61,7 @@ extern int cat_main(int argc, char **argv)
}
print_file(file);
}
exit(TRUE);
return(TRUE);
}
/*
+12 -11
View File
@@ -28,14 +28,18 @@
#include <errno.h>
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n"
"Run COMMAND with root directory set to NEWROOT.\n";
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRun COMMAND with root directory set to NEWROOT.\n"
#endif
;
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(chroot_usage);
}
@@ -43,27 +47,24 @@ int chroot_main(int argc, char **argv)
argv++;
if (chroot(*argv) || (chdir("/"))) {
fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
fatalError("chroot: cannot change root directory to %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
}
argc--;
argv++;
if (argc >= 1) {
fprintf(stderr, "command: %s\n", *argv);
prog = *argv;
execvp(*argv, argv);
} else {
char *prog;
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
}
fprintf(stderr, "chroot: cannot execute %s: %s\n",
*argv, strerror(errno));
exit(FALSE);
fatalError("chroot: cannot execute %s: %s\n",
prog, strerror(errno));
}
+388
View File
@@ -0,0 +1,388 @@
/* vi: set sw=4 ts=4: */
/*
* cut implementation for busybox
*
* Copyright (c) Michael J. Holme
*
* This version of cut is adapted from Minix cut 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.
*/
#include "internal.h"
#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
#define MAX_FIELD 80 /* Pointers to the beginning of each field
* are stored in columns[], if a line holds
* more than MAX_FIELD columns the array
* boundary is exceed. But unlikely at 80 */
#define MAX_ARGS 32 /* Maximum number of fields following -f or
* -c switches */
int args[MAX_ARGS * 2];
int num_args;
/* Lots of new defines, should easen maintainance... */
#define DUMP_STDIN 0 /* define for mode: no options */
#define OPTIONF 1 /* define for mode: option -f */
#define OPTIONC 2 /* define for mode: option -c */
#define OPTIONB 3 /* define for mode: option -b */
#define NOTSET 0 /* option not selected */
#define SET 1 /* option selected */
#define OPTIONS 1 /*define option -s */
/* Defines for the warnings */
#define DELIMITER_NOT_APPLICABLE 0
#define OVERRIDING_PREVIOUS_MODE 1
#define OPTION_NOT_APPLICABLE 2
#define UNKNOWN_OPTION 3
#define FILE_NOT_READABLE 4
/* Defines for the fatal errors */
#define SYNTAX_ERROR 101
#define POSITION_ERROR 102
#define LINE_TO_LONG_ERROR 103
#define RANGE_ERROR 104
#define MAX_FIELDS_EXEEDED_ERROR 105
#define MAX_ARGS_EXEEDED_ERROR 106
int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
char delim = '\t'; /* default delimiting character */
FILE *fd;
char *name;
char line[BUFSIZ];
int exit_status;
int option = 0; /* for -s option */
int cut_main(int argc, char **argv);
void warn(int warn_number, char *option);
void cuterror(int err);
void get_args(void);
void cut(void);
void warn(int warn_number, char *option)
{
static char *warn_msg[] = {
"%s: Option -%s allowed only with -f\n",
"%s: -%s overrides earlier option\n",
"%s: -%s not allowed in current mode\n",
"%s: Cannot open %s\n"
};
fprintf(stderr, warn_msg[warn_number], name, option);
exit_status = warn_number + 1;
}
void cuterror(int err)
{
static char *err_mes[] = {
"%s: syntax error\n",
"%s: position must be >0\n",
"%s: line longer than BUFSIZ\n",
"%s: range must not decrease from left to right\n",
"%s: MAX_FIELD exceeded\n",
"%s: MAX_ARGS exceeded\n"
};
fprintf(stderr, err_mes[err - 101], name);
exit(err);
}
void get_args()
{
int i = 0;
int arg_ptr = 0;
int flag;
num_args = 0;
do {
if (num_args == MAX_ARGS)
cuterror(MAX_ARGS_EXEEDED_ERROR);
if (!isdigit(line[i]) && line[i] != '-')
cuterror(SYNTAX_ERROR);
args[arg_ptr] = 1;
args[arg_ptr + 1] = BUFSIZ;
flag = 1;
while (line[i] != ',' && line[i] != 0) {
if (isdigit(line[i])) {
args[arg_ptr] = 0;
while (isdigit(line[i]))
args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
if (!args[arg_ptr])
cuterror(POSITION_ERROR);
arg_ptr++;
}
if (line[i] == '-') {
arg_ptr |= 1;
i++;
flag = 0;
}
}
if (flag && arg_ptr & 1)
args[arg_ptr] = args[arg_ptr - 1];
if (args[num_args * 2] > args[num_args * 2 + 1])
cuterror(RANGE_ERROR);
num_args++;
arg_ptr = num_args * 2;
}
while (line[i++]);
}
void cut()
{
int i, j, length, maxcol=0;
char *columns[MAX_FIELD];
while (fgets(line, BUFSIZ, fd)) {
maxcol=0;
length = strlen(line) - 1;
*(line + length) = 0;
switch (mode) {
case DUMP_STDIN:
printf("%s", line);
break;
case OPTIONF:
columns[maxcol++] = line;
for (i = 0; i < length; i++) {
if (*(line + i) == delim) {
*(line + i) = 0;
if (maxcol == MAX_FIELD)
cuterror(MAX_FIELDS_EXEEDED_ERROR);
columns[maxcol] = line + i + 1;
maxcol++;
}
}
if (maxcol != 1) {
for (i = 0; i < num_args; i++) {
for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
if (j <= maxcol) {
printf("%s", columns[j - 1]);
if (i != num_args - 1 || j != args[i * 2 + 1])
putchar(delim);
}
}
} else if (option != OPTIONS) {
printf("%s",line);
}
break;
case OPTIONC:
for (i = 0; i < num_args; i++) {
for (j = args[i * 2];
j <= (args[i * 2 + 1] >
length ? length : args[i * 2 + 1]); j++)
putchar(*(line + j - 1));
}
}
if (maxcol != 1)
putchar('\n');
}
}
int cut_main(int argc, char **argv)
{
int i = 1;
int numberFilenames = 0;
name = argv[0];
if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
usage( "cut [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints selected fields from each input FILE to standard output.\n\n"
"Options:\n"
"\t-b LIST\tOutput only bytes from LIST\n"
"\t-c LIST\tOutput only characters from LIST\n"
"\t-d CHAR\tUse CHAR instead of tab as the field delimiter\n"
"\t-s\tOnly output Lines if the include DELIM\n"
"\t-f N\tPrint only these fields\n"
"\t-n\tIgnored\n"
#endif
);
while (i < argc) {
if (argv[i][0] == '-') {
switch (argv[i++][1]) {
case 'd':
if (mode == OPTIONC || mode == OPTIONB)
warn(DELIMITER_NOT_APPLICABLE, "d");
if (argc > i)
delim = argv[i++][0];
else
cuterror(SYNTAX_ERROR);
break;
case 'f':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONC || mode == OPTIONB)
warn(OVERRIDING_PREVIOUS_MODE, "f");
mode = OPTIONF;
break;
case 'b':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONF || mode == OPTIONC)
warn(OVERRIDING_PREVIOUS_MODE, "b");
mode = OPTIONB;
break;
case 'c':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONF || mode == OPTIONB)
warn(OVERRIDING_PREVIOUS_MODE, "c");
mode = OPTIONC;
break;
case 's':
option = OPTIONS;
break;
case '\0': /* - means: read from stdin */
numberFilenames++;
break;
case 'n': /* needed for Posix, but no effect here */
if (mode != OPTIONB)
warn(OPTION_NOT_APPLICABLE, "n");
break;
default:
warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
}
} else {
i++;
numberFilenames++;
}
}
/* Here follow the checks, if the selected options are reasonable. */
if (mode == OPTIONB) /* since in Minix char := byte */
mode = OPTIONC;
if (mode != OPTIONF && option == OPTIONS)
warn(DELIMITER_NOT_APPLICABLE,"s");
get_args();
if (numberFilenames != 0) {
i = 1;
while (i < argc) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'f':
case 'c':
case 'b':
case 'd':
i += 2;
break;
case 'n':
case 'i':
case 's':
i++;
break;
case '\0':
fd = stdin;
i++;
cut();
break;
default:
i++;
}
} else {
if ((fd = fopen(argv[i++], "r")) == NULL) {
warn(FILE_NOT_READABLE, argv[i - 1]);
} else {
cut();
fclose(fd);
}
}
}
} else {
fd = stdin;
cut();
}
return(exit_status);
}
/* cut - extract columns from a file or stdin. Author: Michael J. Holme
*
* Copyright 1989, Michael John Holme, All rights reserved.
* This code may be freely distributed, provided that this notice
* remains intact.
*
* V1.1: 6th September 1989
*
* Bugs, criticisms, etc,
* c/o Mark Powell
* JANET sq79@uk.ac.liv
* ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
* UUCP ...!mcvax!ukc!liv.ac.uk!sq79
*-------------------------------------------------------------------------
* Changed for POSIX1003.2/Draft10 conformance
* Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
* Changes:
* - separation of error messages ( stderr) and output (stdout).
* - support for -b and -n (no effect, -b acts as -c)
* - support for -s
*-------------------------------------------------------------------------
*/
/*
* 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.
*
*/
+12 -11
View File
@@ -40,12 +40,14 @@
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";
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDisplays the current time in the given FORMAT, or sets the system date.\n"
"\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
"\t-s\tSets time described by STRING\n"
"\t-u\tPrints or sets Coordinated Universal Time\n"
#endif
;
/* Input parsing code is always bulky - used heavy duty libc stuff as
@@ -179,18 +181,18 @@ int date_main(int argc, char **argv)
set_time = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted, "date");
/* Look ma, no break. Don't fix it either. */
break;
case 'd':
use_arg = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case '-':
usage(date_usage);
@@ -271,6 +273,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);
}
+10 -8
View File
@@ -41,17 +41,19 @@ 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"
"dd [if=FILE] [of=FILE] [bs=N] [count=N] [skip=N] [seek=N]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCopy 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"
"\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";
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n"
#endif
;
+6 -4
View File
@@ -28,8 +28,11 @@
#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";
static const char df_usage[] = "df [filesystem ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint the filesystem space used and space available.\n"
#endif
;
extern const char mtab_file[]; /* Defined in utility.c */
@@ -48,7 +51,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 */
@@ -106,7 +108,7 @@ extern int df_main(int argc, char **argv)
endmntent(mountTable);
}
exit(TRUE);
return(TRUE);
}
/*
+6 -2
View File
@@ -28,7 +28,11 @@ extern int dirname_main(int argc, char **argv)
char* s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("dirname [file ...]\n");
usage("dirname [FILENAME ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nStrips non-directory suffix from FILENAME\n"
#endif
);
}
argv++;
@@ -41,5 +45,5 @@ extern int dirname_main(int argc, char **argv)
if (s && *s)
*s = '\0';
printf("%s\n", (s)? *argv : ".");
exit(TRUE);
return(TRUE);
}
+10 -8
View File
@@ -32,17 +32,19 @@
#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"
"du [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nSummarizes 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";
"\t-s\tdisplay only a total for each argument\n"
#endif
;
static int du_depth = 0;
static int count_hardlinks = 0;
@@ -97,7 +99,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,7 +107,7 @@ static long du(char *filename)
continue;
}
if (len + strlen(name) + 1 > PATH_MAX) {
if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du");
du_depth--;
return 0;
@@ -179,10 +181,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.20 2000/06/19 17:25:39 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
+12 -27
View File
@@ -26,18 +26,21 @@
#include <stdio.h>
static const char uname_usage[] =
"echo [-neE] [ARG ...]\n\n"
"Prints the specified ARGs to stdout\n\n"
"echo [-neE] [ARG ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints 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";
"\t-E\tdisable interpretation of backslash-escaped characters\n"
#endif
;
extern int
echo_main(int argc, char** argv)
{
register char **ap;
register char *p;
char *p;
register char c;
int nflag = 0;
int eflag = 0;
@@ -62,28 +65,10 @@ echo_main(int argc, char** argv)
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 +78,7 @@ echo_main(int argc, char** argv)
if (! nflag)
putchar('\n');
fflush(stdout);
exit( 0);
return( 0);
}
/*-
+8 -5
View File
@@ -27,12 +27,15 @@
#include <stdio.h>
const char head_usage[] =
"head [OPTION] [FILE]...\n\n"
"Print first 10 lines of each FILE to standard output.\n"
"head [OPTION] [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint 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";
"Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n"
#endif
;
int head(int len, FILE * src)
{
@@ -106,7 +109,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.11 2000/06/19 17:25:39 andersen Exp $ */
+1 -1
View File
@@ -26,5 +26,5 @@
extern int hostid_main(int argc, char **argv)
{
printf("%lx\n", gethostid());
exit(TRUE);
return(TRUE);
}
+96
View File
@@ -0,0 +1,96 @@
/* 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 "internal.h"
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <sys/types.h>
static const char id_usage[] =
"id [OPTIONS]... [USERNAME]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint information for USERNAME or the current user\n\n"
"Options:\n"
"\t-g\tprints only the group ID\n"
"\t-u\tprints only the user ID\n"
"\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"
#endif
;
extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
char *cp, *user, *group;
unsigned long gid;
cp = user = group = NULL;
argc--; argv++;
while (argc > 0) {
cp = *argv;
if (*cp == '-') {
switch (*++cp) {
case 'u': no_group = 1; break;
case 'g': no_user = 1; break;
case 'r': print_real = 1; break;
default: usage(id_usage);
}
} else {
user = cp;
}
argc--; argv++;
}
if (no_user && no_group) usage(id_usage);
if (user == NULL) {
user = xmalloc(9);
group = xmalloc(9);
if (print_real) {
my_getpwuid(user, getuid());
my_getgrgid(group, getgid());
} else {
my_getpwuid(user, geteuid());
my_getgrgid(group, getegid());
}
} else {
group = xmalloc(9);
gid = my_getpwnamegid(user);
my_getgrgid(group, gid);
}
if (no_group) printf("%lu\n", my_getpwnam(user));
else if (no_user) printf("%lu\n", my_getgrnam(group));
else
printf("uid=%lu(%s) gid=%lu(%s)\n",
my_getpwnam(user), user, my_getgrnam(group), group);
return(0);
}
/* END CODE */
+6 -2
View File
@@ -7,8 +7,12 @@
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-') {
usage("length string\n");
usage("length STRING\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints out the length of the specified STRING.\n"
#endif
);
}
printf("%d\n", strlen(argv[1]));
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
}
+56 -48
View File
@@ -30,16 +30,19 @@
#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"
"ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreate a link named LINK_NAME or DIRECTORY to the specified TARGET\n"
"\nYou may use '--' to indicate that all following arguments are non-options.\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";
"\t-n\tno dereference symlinks - treat like normal file\n"
#endif
;
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
@@ -47,65 +50,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");
exit FALSE;
}
linkIntoDirFlag = isDirectory(linkName, TRUE, NULL);
if ((argc > 3) && !linkIntoDirFlag) {
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
if ((argc >= 3) && linkIntoDirFlag == FALSE) {
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 *)malloc(strlen(dirName)+strlen(baseName)+2);
strcpy(linkName, dirName);
if(dirName[strlen(dirName)-1] != '/')
strcat(linkName, "/");
strcat(linkName,baseName);
}
if (removeoldFlag == TRUE) {
@@ -124,8 +127,13 @@ extern int ln_main(int argc, char **argv)
perror(linkName);
exit FALSE;
}
if (linkIntoDirFlag == TRUE)
free(linkName);
argv++;
}
exit TRUE;
return( TRUE);
}
/*
+11 -9
View File
@@ -23,22 +23,24 @@
#include "internal.h"
#include <stdio.h>
static const char logname_usage[] = "logname\n\n"
"Print the name of the current user.\n";
static const char logname_usage[] = "logname\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint the name of the current user.\n"
#endif
;
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);
fprintf(stderr, "no login name\n");
return(FALSE);
}
+52 -14
View File
@@ -49,11 +49,7 @@
/************************************************************************/
#include "internal.h"
#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
# include <linux/types.h>
#else
# include <sys/types.h>
#endif
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
@@ -86,8 +82,9 @@
#define DISP_DOT 8 /* show . and .. */
#define DISP_NUMERIC 16 /* numeric uid and gid */
#define DISP_FULLTIME 32 /* show extended time display */
#define DIR_NOLIST 64 /* show directory as itself, not contents */
#define DIR_NOLIST 64 /* show directory as itself, not contents */
#define DISP_DIRNAME 128 /* show directory name (for internal use) */
#define DISP_RECURSIVE 256 /* Do a recursive listing */
#ifndef MAJOR
#define MAJOR(dev) (((dev)>>8)&0xff)
@@ -183,7 +180,7 @@ static char append_char(mode_t mode)
static void list_single(const char *name, struct stat *info,
const char *fullname)
{
char scratch[PATH_MAX + 1];
char scratch[BUFSIZ + 1];
short len = strlen(name);
#ifdef BB_FEATURE_LS_FILETYPES
@@ -344,7 +341,7 @@ static int list_item(const char *name)
struct stat info;
DIR *dir;
struct dirent *entry;
char fullname[MAXNAMLEN + 1], *fnend;
char fullname[BUFSIZ + 1], *fnend;
if (lstat(name, &info))
goto listerr;
@@ -449,7 +446,12 @@ static const char ls_usage[] = "ls [-1a"
#ifdef BB_FEATURE_LS_FILETYPES
"F"
#endif
"] [filenames...]\n\n"
#ifdef BB_FEATURE_LS_RECURSIVE
"R"
#endif
"] [filenames...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nList directory contents\n\n"
"Options:\n"
"\t-a\tdo not hide entries starting with .\n"
#ifdef BB_FEATURE_LS_TIMESTAMPS
@@ -474,9 +476,25 @@ static const char ls_usage[] = "ls [-1a"
"\t-C\tlist entries by columns\n"
#ifdef BB_FEATURE_LS_FILETYPES
"\t-F\tappend indicator (one of */=@|) to entries\n"
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
"\t-R\tlist subdirectories recursively\n"
#endif
#endif
;
#ifdef BB_FEATURE_LS_RECURSIVE
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{
int i;
fprintf(stdout, "\n%s:\n", fileName);
i = list_item(fileName);
newline();
return (i);
}
#endif
extern int ls_main(int argc, char **argv)
{
int argi = 1, i;
@@ -541,6 +559,13 @@ extern int ls_main(int argc, char **argv)
opts |= DISP_FULLTIME;
break;
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
case 'R':
opts |= DISP_RECURSIVE;
break;
#endif
case 'g': /* ignore -- for ftp servers */
break;
default:
goto print_usage_message;
}
@@ -567,12 +592,25 @@ extern int ls_main(int argc, char **argv)
#endif
/* process files specified, or current directory if none */
i = 0;
if (argi == argc)
i = list_item(".");
while (argi < argc)
i |= list_item(argv[argi++]);
newline();
#ifdef BB_FEATURE_LS_RECURSIVE
if (opts & DISP_RECURSIVE) {
i = 0;
if (argi == argc) {
i = recursiveAction(".", TRUE, FALSE, FALSE, NULL, dirAction, NULL);
}
while (argi < argc) {
i |= recursiveAction(argv[argi++], TRUE, FALSE, FALSE, NULL, dirAction, NULL);
}
} else
#endif
{
i = 0;
if (argi == argc)
i = list_item(".");
while (argi < argc)
i |= list_item(argv[argi++]);
newline();
}
exit(i);
print_usage_message:
+1021
View File
File diff suppressed because it is too large. Load diff
+9 -7
View File
@@ -28,15 +28,17 @@
#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"
"mkdir [OPTION] DIRECTORY...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreate 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";
"\t-p\tno error if existing, make parent directories as needed\n"
#endif
;
static int parentFlag = FALSE;
@@ -86,9 +88,9 @@ 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) {
if (strlen(*argv) > BUFSIZ - 1) {
fprintf(stderr, name_too_long, "mkdir");
exit FALSE;
}
@@ -110,5 +112,5 @@ extern int mkdir_main(int argc, char **argv)
argc--;
argv++;
}
exit TRUE;
return( TRUE);
}
+8 -7
View File
@@ -26,11 +26,13 @@
#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"
static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreates 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";
"\t-m\tcreate the pipe using the specified mode (default a=rw)\n"
#endif
;
extern int mkfifo_main(int argc, char **argv)
{
@@ -58,12 +60,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);
}
+9 -5
View File
@@ -28,14 +28,17 @@
#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"
static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreate 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";
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n"
#endif
;
int mknod_main(int argc, char **argv)
{
@@ -58,6 +61,7 @@ int mknod_main(int argc, char **argv)
argc--;
argv++;
parse_mode(*argv, &perm);
umask(0);
break;
default:
usage(mknod_usage);
@@ -87,13 +91,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);
}
+7 -4
View File
@@ -51,14 +51,12 @@
#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,7 +137,12 @@ 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";
static const char printf_usage[] = "printf FORMAT [ARGUMENT...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nFormats and prints ARGUMENT(s) according to FORMAT,\n"
"Where FORMAT controls the output exactly as in C printf.\n"
#endif
;
int printf_main(int argc, char **argv)
{
@@ -167,7 +170,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
+5 -7
View File
@@ -24,17 +24,15 @@
#include "internal.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("pwd: %s\n", strerror(errno));
printf("%s\n", buf);
exit(TRUE);
return(TRUE);
}
+35 -23
View File
@@ -29,12 +29,15 @@
#include <dirent.h>
#include <errno.h>
static const char *rm_usage = "rm [OPTION]... FILE...\n\n"
"Remove (unlink) the FILE(s).\n\n"
static const char *rm_usage = "rm [OPTION]... FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRemove (unlink) the FILE(s). You may use '--' to\n"
"indicate that all following arguments are non-options.\n\n"
"Options:\n"
"\t-f\t\tremove existing destinations, never prompt\n"
"\t-r or -R\tremove the contents of directories recursively\n";
"\t-r or -R\tremove the contents of directories recursively\n"
#endif
;
static int recursiveFlag = FALSE;
@@ -62,30 +65,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 +112,5 @@ extern int rm_main(int argc, char **argv)
}
}
}
exit(TRUE);
return(TRUE);
}
+6 -2
View File
@@ -31,7 +31,11 @@ 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");
("rmdir [OPTION]... DIRECTORY...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRemove the DIRECTORY(ies), if they are empty.\n"
#endif
);
}
while (--argc > 0) {
@@ -40,5 +44,5 @@ extern int rmdir_main(int argc, char **argv)
exit(FALSE);
}
}
exit(TRUE);
return(TRUE);
}
+7 -3
View File
@@ -24,7 +24,11 @@
#include "internal.h"
#include <stdio.h>
const char sleep_usage[] = "sleep N\n\n" "Pause for N seconds.\n";
const char sleep_usage[] = "sleep N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPause for N seconds.\n"
#endif
;
extern int sleep_main(int argc, char **argv)
{
@@ -35,6 +39,6 @@ extern int sleep_main(int argc, char **argv)
if (sleep(atoi(*(++argv))) != 0) {
perror("sleep");
exit(FALSE);
} else
exit(TRUE);
}
return(TRUE);
}
+8 -4
View File
@@ -33,7 +33,11 @@ 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";
" [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nSorts lines of text in the specified files\n"
#endif
;
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
@@ -80,7 +84,7 @@ 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;
@@ -297,7 +301,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.18 2000/06/28 22:15:26 markw Exp $ */
+6 -2
View File
@@ -27,7 +27,11 @@
extern int sync_main(int argc, char **argv)
{
if (argc > 1 && **(argv + 1) == '-') {
usage("sync\n\nWrite all buffered filesystem blocks to disk.\n");
usage("sync\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nWrite all buffered filesystem blocks to disk.\n"
#endif
);
}
exit(sync());
return(sync());
}
+21 -12
View File
@@ -47,6 +47,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
#define XWRITE(fd, buffer, n_bytes) \
@@ -70,15 +73,18 @@ static int forever;
static int print_headers;
const char tail_usage[] =
"tail [OPTION] [FILE]...\n\n"
"Print last 10 lines of each FILE to standard output.\n"
"tail [OPTION] [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint last 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 last NUM lines instead of first 10\n"
"\t-f\t\tOutput data as the file grows. This version\n"
"\t\t\tof 'tail -f' supports only one file at a time.\n";
"\t\t\tof 'tail -f' supports only one file at a time.\n"
#endif
;
static void write_header(const char *filename)
@@ -330,7 +336,7 @@ static int tail_file(const char *filename, off_t n_units)
/* Not standard input. */
fd = open(filename, O_RDONLY);
if (fd == -1)
fatalError("open error");
perror(filename);
errors = tail_lines(filename, fd, (long) n_units);
close(fd);
@@ -368,8 +374,10 @@ extern int tail_main(int argc, char **argv)
case 'h':
usage(tail_usage);
default:
fprintf(stderr, "tail: invalid option -- %c\n", opt);
usage(tail_usage);
if ((n_units = atoi(&argv[i][1])) < 1) {
fprintf(stderr, "tail: invalid option -- %c\n", opt);
usage(tail_usage);
}
}
} else {
break;
@@ -392,7 +400,7 @@ extern int tail_main(int argc, char **argv)
exit_status |= tail_file(argv[i], n_units);
}
exit(exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
return(exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
@@ -510,9 +518,9 @@ char *program_name;
static int have_read_stdin;
static const char tail_usage[] = "tail [OPTION]... [FILE]...\n\
\n\
Print last 10 lines of each FILE to standard output.\n\
static const char tail_usage[] = "tail [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint last 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
@@ -521,11 +529,12 @@ With no FILE, or when FILE is -, read standard input.\n\
-n=N output the last N lines, instead of last 10\n\
-q never output headers giving file names\n\
-v always output headers giving file names\n\
--help display this help and exit\n\
\n\
If the first character of N (bytes or lines) is a `+', output begins with \n\
the Nth item from the start of each file, otherwise, print the last N items\n\
in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n\n";
in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n"
#endif
;
static void write_header(const char *filename, const char *comment)
{
+6 -4
View File
@@ -27,12 +27,14 @@
#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"
"tee [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCopy 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
#endif
;
@@ -128,7 +130,7 @@ int tee_main(int argc, char **argv)
/* Don't bother to close files Exit does that
* automagically, so we can save a few bytes */
/* free(FileList); */
exit(0);
return(0);
}
/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
/* $Id: tee.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */
+17 -11
View File
@@ -39,6 +39,9 @@
#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 ;
@@ -182,14 +185,17 @@ test_main(int argc, char** argv)
if (strcmp(argv[0], "[") == 0) {
if (strcmp(argv[--argc], "]"))
fatalError("missing ]");
fatalError("missing ]\n");
argv[argc] = NULL;
}
if (strcmp(argv[1], "--help") == 0) {
if (strcmp(argv[1], dash_dash_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");
"or [ EXPRESSION ]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChecks file types and compares values returning an exit\n"
"code determined by the value of EXPRESSION.\n"
#endif
);
}
/* Implement special cases from POSIX.2, section 4.62.4 */
@@ -229,7 +235,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 +244,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
@@ -475,13 +481,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;
}
@@ -561,7 +567,7 @@ initialize_group_array ()
{
ngroups = getgroups(0, NULL);
if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL)
fatalError("Out of space");
fatalError("Out of space\n");
getgroups(ngroups, group_array);
}
+31 -27
View File
@@ -31,10 +31,13 @@
#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";
static const char touch_usage[] = "touch [-c] file [file ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nUpdate the last-modified date on the given file[s].\n\n"
"Options:\n"
"\t-c\tDo not create any files\n"
#endif
;
extern int touch_main(int argc, char **argv)
@@ -42,15 +45,9 @@ 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 +56,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("touch: %s", strerror(errno));
}
}
close(fd);
if (utime(*argv, NULL)) {
fatalError("touch: %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);
}
+210 -544
View File
@@ -1,574 +1,240 @@
/* 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 <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>
const char *tr_usage="tr [-cds] STRING1 [STRING2]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nTranslate, squeeze, and/or delete characters from\n"
"standard input, writing to standard output.\n\n"
"Options:\n"
"\t-c\ttake complement of STRING1\n"
"\t-d\tdelete input characters coded STRING1\n"
"\t-s\tsqueeze multiple output characters of STRING2 into one character\n"
#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;
#include <limits.h>
#define NCHARS (UCHAR_MAX + 1) /* Number of possible characters. */
#define OOBCH (UCHAR_MAX + 1) /* Out of band character value. */
static int next __P((STR *));
#ifdef TRUE
#undef TRUE
#undef FALSE
#define TRUE 1
#define FALSE 0
#endif
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];
#define ASCII 0377
STR s1 = { STRING1, NORMAL, 0, OOBCH, {0, OOBCH}, NULL, NULL };
STR s2 = { STRING2, NORMAL, 0, OOBCH, {0, OOBCH}, NULL, NULL };
/* 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 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, register unsigned char *string2)
{
unsigned char last = '0';
while (*string1) {
if (*string2 == '\0')
vector[*string1] = last;
else
vector[*string1] = last = *string2++;
string1++;
}
}
static void expand(char *arg, register unsigned char *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++;
}
}
static void complement(unsigned char *buffer)
{
register unsigned char *ptr;
register short i, index;
unsigned char conv[ASCII + 2];
index = 0;
for (i = 1; i <= ASCII; i++) {
for (ptr = buffer; *ptr; ptr++)
if (*ptr == i)
break;
if (*ptr == '\0')
conv[index++] = i & ASCII;
}
conv[index] = '\0';
strcpy((char *) buffer, (char *) conv);
}
extern int tr_main(int argc, char **argv)
{
register unsigned char *ptr;
int index = 1;
short 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) {
expand(argv[index++], input);
if (com_fl)
complement(input);
if (argv[index] != NULL) {
if (*argv[index] == '\0')
fatalError("tr: STRING2 cannot be empty\n");
expand(argv[index], output);
map(input, output);
}
for (ptr = input; *ptr; ptr++)
invec[*ptr] = TRUE;
for (ptr = output; *ptr; ptr++)
outvec[*ptr] = 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);
}
}
+7 -4
View File
@@ -24,10 +24,13 @@
#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"
static const char tty_usage[] = "tty\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint the file name of the terminal connected to standard input.\n\n"
"Options:\n"
"\t-s\tprint nothing, only return an exit status\n";
"\t-s\tprint nothing, only return an exit status\n"
#endif
;
extern int tty_main(int argc, char **argv)
{
@@ -43,5 +46,5 @@ extern int tty_main(int argc, char **argv)
else
puts("not a tty");
}
exit(isatty(0) ? TRUE : FALSE);
return(isatty(0) ? TRUE : FALSE);
}
+3 -3
View File
@@ -42,9 +42,9 @@
static const char uname_usage[] =
"uname [OPTION]...\n\n"
"uname [OPTION]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"Print certain system information. With no OPTION, same as -s.\n\n"
"\nPrint 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"
@@ -156,7 +156,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',
+8 -5
View File
@@ -28,9 +28,12 @@
#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";
"uniq [OPTION]... [INPUT [OUTPUT]]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDiscard all but one of successive identical lines from INPUT\n"
"(or standard input), writing to OUTPUT (or standard output).\n"
#endif
;
/* max chars in line */
#define UNIQ_MAX 4096
@@ -181,7 +184,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.11 2000/06/19 17:25:40 andersen Exp $ */
+6 -2
View File
@@ -25,7 +25,11 @@
#include <stdlib.h>
#include <unistd.h>
const char usleep_usage[] = "usleep N\n\n" "Pause for N microseconds.\n";
const char usleep_usage[] = "usleep N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPause for N microseconds.\n"
#endif
;
extern int usleep_main(int argc, char **argv)
{
@@ -34,5 +38,5 @@ extern int usleep_main(int argc, char **argv)
}
usleep(atoi(*(++argv))); /* return void */
exit(TRUE);
return(TRUE);
}
+351
View File
@@ -0,0 +1,351 @@
/* 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 "internal.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("uudeoce %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);
}
static const char uudecode_usage[] =
"uudecode [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nUudecode a file that is uuencoded.\n\n"
"Options:\n"
"\t-o FILE\tdirect output to FILE\n"
#endif
;
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("uudecode: %s: %s\n", argv[optind], strerror(errno));
exit_status = FALSE;
}
optind++;
}
while (optind < argc);
}
return(exit_status);
}
+245
View File
@@ -0,0 +1,245 @@
/* 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 "internal.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');
}
}
static const char uuencode_usage[] =
"uuencode [OPTION] [INFILE] REMOTEFILE\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nUuencode a file.\n\n"
"Options:\n"
"\t-m\tuse base64 encoding as of RFC1521\n"
#endif
;
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("uuencode: %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);
}
+7 -4
View File
@@ -23,15 +23,18 @@
#include "internal.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"
static const char wc_usage[] = "wc [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint 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";
"\t-w\tprint the word counts\n"
#endif
;
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
@@ -163,5 +166,5 @@ int wc_main(int argc, char **argv)
print_counts(total_lines, total_words, total_chars,
max_length, "total");
}
exit(TRUE);
return(TRUE);
}
+11 -9
View File
@@ -24,24 +24,26 @@
#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";
static const char whoami_usage[] = "whoami\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints the user name associated with the current effective user id.\n"
#endif
;
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);
return(FALSE);
}
+6 -3
View File
@@ -27,9 +27,12 @@ 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 [OPTION]... [STRING]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
#endif
);
}
if (argc == 1) {
+37 -24
View File
@@ -49,27 +49,34 @@ 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"
" or: cp [OPTION]... SOURCE... DIRECTORY\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCopies 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",
"\t-a\tSame as -dpR\n"
"\t-d\tPreserves links\n"
"\t-p\tPreserves file attributes if possible\n"
"\t-f\tforce (implied; ignored) - always set\n"
"\t-R\tCopies directories recursively\n"
#endif
,
"mv SOURCE DEST\n"
" or: mv SOURCE... DIRECTORY\n\n"
"Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
" or: mv SOURCE... DIRECTORY\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
#endif
};
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;
@@ -83,7 +90,7 @@ static
void name_too_long__exit (void)
{
fprintf(stderr, name_too_long, dz);
exit FALSE;
exit(FALSE);
}
static void
@@ -92,12 +99,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 +114,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;
@@ -123,7 +130,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
if (destLen + strlen(srcBasename) > PATH_MAX) {
if (destLen + strlen(srcBasename) > BUFSIZ) {
fprintf(stderr, name_too_long, dz);
return FALSE;
}
@@ -161,7 +168,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
@@ -194,9 +201,9 @@ extern int cp_mv_main(int argc, char **argv)
argv++;
if (dz_i == is_cp) {
recursiveFlag = preserveFlag = FALSE;
recursiveFlag = preserveFlag = forceFlag = FALSE;
followLinks = TRUE;
while (**argv == '-') {
while (*argv && **argv == '-') {
while (*++(*argv)) {
switch (**argv) {
case 'a':
@@ -213,6 +220,9 @@ 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]);
}
@@ -220,12 +230,16 @@ extern int cp_mv_main(int argc, char **argv)
argc--;
argv++;
}
if (argc < 2) {
usage(cp_mv_usage[dz_i]);
}
} else { /* (dz_i == is_mv) */
recursiveFlag = preserveFlag = TRUE;
followLinks = FALSE;
}
if (strlen(argv[argc - 1]) > PATH_MAX) {
if (strlen(argv[argc - 1]) > BUFSIZ) {
fprintf(stderr, name_too_long, "cp");
goto exit_false;
}
@@ -247,7 +261,7 @@ extern int cp_mv_main(int argc, char **argv)
baseSrcName = *(argv++);
if ((srcLen = strlen(baseSrcName)) > PATH_MAX)
if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
name_too_long__exit();
if (srcLen == 0) continue; /* "" */
@@ -261,7 +275,7 @@ extern int cp_mv_main(int argc, char **argv)
int state = 0;
char *pushd, *d, *p;
if ((pushd = getcwd(NULL, PATH_MAX + 1)) == NULL) {
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
continue;
}
@@ -269,7 +283,7 @@ extern int cp_mv_main(int argc, char **argv)
fprintf(stderr, "%s: chdir(%s): %s\n", dz, baseSrcName, strerror(errno));
continue;
}
if ((d = getcwd(NULL, PATH_MAX + 1)) == NULL) {
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
continue;
}
@@ -319,10 +333,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);
}
/*
+388
View File
@@ -0,0 +1,388 @@
/* vi: set sw=4 ts=4: */
/*
* cut implementation for busybox
*
* Copyright (c) Michael J. Holme
*
* This version of cut is adapted from Minix cut 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.
*/
#include "internal.h"
#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
#define MAX_FIELD 80 /* Pointers to the beginning of each field
* are stored in columns[], if a line holds
* more than MAX_FIELD columns the array
* boundary is exceed. But unlikely at 80 */
#define MAX_ARGS 32 /* Maximum number of fields following -f or
* -c switches */
int args[MAX_ARGS * 2];
int num_args;
/* Lots of new defines, should easen maintainance... */
#define DUMP_STDIN 0 /* define for mode: no options */
#define OPTIONF 1 /* define for mode: option -f */
#define OPTIONC 2 /* define for mode: option -c */
#define OPTIONB 3 /* define for mode: option -b */
#define NOTSET 0 /* option not selected */
#define SET 1 /* option selected */
#define OPTIONS 1 /*define option -s */
/* Defines for the warnings */
#define DELIMITER_NOT_APPLICABLE 0
#define OVERRIDING_PREVIOUS_MODE 1
#define OPTION_NOT_APPLICABLE 2
#define UNKNOWN_OPTION 3
#define FILE_NOT_READABLE 4
/* Defines for the fatal errors */
#define SYNTAX_ERROR 101
#define POSITION_ERROR 102
#define LINE_TO_LONG_ERROR 103
#define RANGE_ERROR 104
#define MAX_FIELDS_EXEEDED_ERROR 105
#define MAX_ARGS_EXEEDED_ERROR 106
int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
char delim = '\t'; /* default delimiting character */
FILE *fd;
char *name;
char line[BUFSIZ];
int exit_status;
int option = 0; /* for -s option */
int cut_main(int argc, char **argv);
void warn(int warn_number, char *option);
void cuterror(int err);
void get_args(void);
void cut(void);
void warn(int warn_number, char *option)
{
static char *warn_msg[] = {
"%s: Option -%s allowed only with -f\n",
"%s: -%s overrides earlier option\n",
"%s: -%s not allowed in current mode\n",
"%s: Cannot open %s\n"
};
fprintf(stderr, warn_msg[warn_number], name, option);
exit_status = warn_number + 1;
}
void cuterror(int err)
{
static char *err_mes[] = {
"%s: syntax error\n",
"%s: position must be >0\n",
"%s: line longer than BUFSIZ\n",
"%s: range must not decrease from left to right\n",
"%s: MAX_FIELD exceeded\n",
"%s: MAX_ARGS exceeded\n"
};
fprintf(stderr, err_mes[err - 101], name);
exit(err);
}
void get_args()
{
int i = 0;
int arg_ptr = 0;
int flag;
num_args = 0;
do {
if (num_args == MAX_ARGS)
cuterror(MAX_ARGS_EXEEDED_ERROR);
if (!isdigit(line[i]) && line[i] != '-')
cuterror(SYNTAX_ERROR);
args[arg_ptr] = 1;
args[arg_ptr + 1] = BUFSIZ;
flag = 1;
while (line[i] != ',' && line[i] != 0) {
if (isdigit(line[i])) {
args[arg_ptr] = 0;
while (isdigit(line[i]))
args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
if (!args[arg_ptr])
cuterror(POSITION_ERROR);
arg_ptr++;
}
if (line[i] == '-') {
arg_ptr |= 1;
i++;
flag = 0;
}
}
if (flag && arg_ptr & 1)
args[arg_ptr] = args[arg_ptr - 1];
if (args[num_args * 2] > args[num_args * 2 + 1])
cuterror(RANGE_ERROR);
num_args++;
arg_ptr = num_args * 2;
}
while (line[i++]);
}
void cut()
{
int i, j, length, maxcol=0;
char *columns[MAX_FIELD];
while (fgets(line, BUFSIZ, fd)) {
maxcol=0;
length = strlen(line) - 1;
*(line + length) = 0;
switch (mode) {
case DUMP_STDIN:
printf("%s", line);
break;
case OPTIONF:
columns[maxcol++] = line;
for (i = 0; i < length; i++) {
if (*(line + i) == delim) {
*(line + i) = 0;
if (maxcol == MAX_FIELD)
cuterror(MAX_FIELDS_EXEEDED_ERROR);
columns[maxcol] = line + i + 1;
maxcol++;
}
}
if (maxcol != 1) {
for (i = 0; i < num_args; i++) {
for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
if (j <= maxcol) {
printf("%s", columns[j - 1]);
if (i != num_args - 1 || j != args[i * 2 + 1])
putchar(delim);
}
}
} else if (option != OPTIONS) {
printf("%s",line);
}
break;
case OPTIONC:
for (i = 0; i < num_args; i++) {
for (j = args[i * 2];
j <= (args[i * 2 + 1] >
length ? length : args[i * 2 + 1]); j++)
putchar(*(line + j - 1));
}
}
if (maxcol != 1)
putchar('\n');
}
}
int cut_main(int argc, char **argv)
{
int i = 1;
int numberFilenames = 0;
name = argv[0];
if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
usage( "cut [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints selected fields from each input FILE to standard output.\n\n"
"Options:\n"
"\t-b LIST\tOutput only bytes from LIST\n"
"\t-c LIST\tOutput only characters from LIST\n"
"\t-d CHAR\tUse CHAR instead of tab as the field delimiter\n"
"\t-s\tOnly output Lines if the include DELIM\n"
"\t-f N\tPrint only these fields\n"
"\t-n\tIgnored\n"
#endif
);
while (i < argc) {
if (argv[i][0] == '-') {
switch (argv[i++][1]) {
case 'd':
if (mode == OPTIONC || mode == OPTIONB)
warn(DELIMITER_NOT_APPLICABLE, "d");
if (argc > i)
delim = argv[i++][0];
else
cuterror(SYNTAX_ERROR);
break;
case 'f':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONC || mode == OPTIONB)
warn(OVERRIDING_PREVIOUS_MODE, "f");
mode = OPTIONF;
break;
case 'b':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONF || mode == OPTIONC)
warn(OVERRIDING_PREVIOUS_MODE, "b");
mode = OPTIONB;
break;
case 'c':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONF || mode == OPTIONB)
warn(OVERRIDING_PREVIOUS_MODE, "c");
mode = OPTIONC;
break;
case 's':
option = OPTIONS;
break;
case '\0': /* - means: read from stdin */
numberFilenames++;
break;
case 'n': /* needed for Posix, but no effect here */
if (mode != OPTIONB)
warn(OPTION_NOT_APPLICABLE, "n");
break;
default:
warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
}
} else {
i++;
numberFilenames++;
}
}
/* Here follow the checks, if the selected options are reasonable. */
if (mode == OPTIONB) /* since in Minix char := byte */
mode = OPTIONC;
if (mode != OPTIONF && option == OPTIONS)
warn(DELIMITER_NOT_APPLICABLE,"s");
get_args();
if (numberFilenames != 0) {
i = 1;
while (i < argc) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'f':
case 'c':
case 'b':
case 'd':
i += 2;
break;
case 'n':
case 'i':
case 's':
i++;
break;
case '\0':
fd = stdin;
i++;
cut();
break;
default:
i++;
}
} else {
if ((fd = fopen(argv[i++], "r")) == NULL) {
warn(FILE_NOT_READABLE, argv[i - 1]);
} else {
cut();
fclose(fd);
}
}
}
} else {
fd = stdin;
cut();
}
return(exit_status);
}
/* cut - extract columns from a file or stdin. Author: Michael J. Holme
*
* Copyright 1989, Michael John Holme, All rights reserved.
* This code may be freely distributed, provided that this notice
* remains intact.
*
* V1.1: 6th September 1989
*
* Bugs, criticisms, etc,
* c/o Mark Powell
* JANET sq79@uk.ac.liv
* ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
* UUCP ...!mcvax!ukc!liv.ac.uk!sq79
*-------------------------------------------------------------------------
* Changed for POSIX1003.2/Draft10 conformance
* Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
* Changes:
* - separation of error messages ( stderr) and output (stdout).
* - support for -b and -n (no effect, -b acts as -c)
* - support for -s
*-------------------------------------------------------------------------
*/
/*
* 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.
*
*/
+12 -11
View File
@@ -40,12 +40,14 @@
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";
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDisplays the current time in the given FORMAT, or sets the system date.\n"
"\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
"\t-s\tSets time described by STRING\n"
"\t-u\tPrints or sets Coordinated Universal Time\n"
#endif
;
/* Input parsing code is always bulky - used heavy duty libc stuff as
@@ -179,18 +181,18 @@ int date_main(int argc, char **argv)
set_time = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted, "date");
/* Look ma, no break. Don't fix it either. */
break;
case 'd':
use_arg = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case '-':
usage(date_usage);
@@ -271,6 +273,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);
}
+72 -20
View File
@@ -1,5 +1,6 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -7,10 +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"
static const char dc_usage[] = "dc expression ...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nThis 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";
"i.e. 'dc 2 2 add' -> 4, and 'dc 8 8 \\* 2 2 + /' -> 16\n"
#endif
;
static double stack[100];
static unsigned int pointer;
@@ -18,7 +22,7 @@ static unsigned int pointer;
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack))) {
fprintf(stderr, "math: stack overflow\n");
fprintf(stderr, "dc: stack overflow\n");
exit(-1);
} else
stack[pointer++] = a;
@@ -27,7 +31,7 @@ static void push(double a)
static double pop()
{
if (pointer == 0) {
fprintf(stderr, "math: stack underflow\n");
fprintf(stderr, "dc: stack underflow\n");
exit(-1);
}
return stack[--pointer];
@@ -88,15 +92,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 +132,63 @@ static void stack_machine(const char *argument)
}
o++;
}
fprintf(stderr, "math: %s: syntax error.\n", argument);
fprintf(stderr, "dc: %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);
}
+10 -8
View File
@@ -41,17 +41,19 @@ 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"
"dd [if=FILE] [of=FILE] [bs=N] [count=N] [skip=N] [seek=N]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCopy 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"
"\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";
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n"
#endif
;
+13 -7
View File
@@ -5,13 +5,15 @@
*/
#include "internal.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);
/* From <linux/vt.h> */
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
char *progname;
int deallocvt_main(int argc, char *argv[])
@@ -20,7 +22,11 @@ int deallocvt_main(int argc, char *argv[])
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n");
("deallocvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDeallocate unused virtual terminal /dev/ttyN\n"
#endif
);
}
progname = argv[0];
@@ -31,7 +37,7 @@ int deallocvt_main(int argc, char *argv[])
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
exit(1);
exit( FALSE);
}
} else
for (i = 1; i < argc; i++) {
@@ -45,8 +51,8 @@ int deallocvt_main(int argc, char *argv[])
perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n",
progname, num);
exit(1);
exit( FALSE);
}
}
exit(0);
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
+24
View File
@@ -0,0 +1,24 @@
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
+6 -4
View File
@@ -28,8 +28,11 @@
#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";
static const char df_usage[] = "df [filesystem ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint the filesystem space used and space available.\n"
#endif
;
extern const char mtab_file[]; /* Defined in utility.c */
@@ -48,7 +51,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 */
@@ -106,7 +108,7 @@ extern int df_main(int argc, char **argv)
endmntent(mountTable);
}
exit(TRUE);
return(TRUE);
}
/*
+6 -2
View File
@@ -28,7 +28,11 @@ extern int dirname_main(int argc, char **argv)
char* s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("dirname [file ...]\n");
usage("dirname [FILENAME ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nStrips non-directory suffix from FILENAME\n"
#endif
);
}
argv++;
@@ -41,5 +45,5 @@ extern int dirname_main(int argc, char **argv)
if (s && *s)
*s = '\0';
printf("%s\n", (s)? *argv : ".");
exit(TRUE);
return(TRUE);
}
+10 -5
View File
@@ -16,9 +16,7 @@
*/
#include "internal.h"
#include <linux/unistd.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#if __GNU_LIBRARY__ < 5
@@ -34,7 +32,15 @@ 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";
static const char dmesg_usage[] = "dmesg [-c] [-n LEVEL] [-s SIZE]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints or controls the kernel ring buffer\n\n"
"Options:\n"
"\t-c\t\tClears the ring buffer's contents after printing\n"
"\t-n LEVEL\tSets console logging level\n"
"\t-s SIZE\t\tUse a buffer of size SIZE\n"
#endif
;
int dmesg_main(int argc, char **argv)
{
@@ -121,6 +127,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
-21
View File
@@ -1,21 +0,0 @@
# busybox/docs/Makefile - Create the documentation
# ------------------------
# Copyright (C) 2000 Erik Andersen <andersee@debian.org> GPL
all: clean doc
doc:
@echo
@echo BusyBox Documentation
@echo
pod2html busybox.pod > ../BusyBox.html
@rm pod2html-*
pod2man --center=BusyBox --release="version $(VERSION)" busybox.pod > ../BusyBox.1
pod2text busybox.pod > ../BusyBox.txt
@rm -f pod2html*
clean:
@rm -f ../BusyBox.html ../BusyBox.1 ../BusyBox.txt pod2html*
distclean: clean
+1
View File
@@ -0,0 +1 @@
BusyBox.html
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+283
View File
@@ -0,0 +1,283 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>BusyBox</TITLE>
</HEAD>
<body text="#000000" alink="#660000" link="#660000" bgcolor="#dee2de" vlink="#660000">
<basefont face="lucida, helvetica, arial" size="3">
<CENTER>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2>
<TR>
<td bgcolor="#000000">
<FONT FACE="lucida, helvetica" COLOR="#ccccc0">
<B>B&nbsp;u&nbsp;s&nbsp;y&nbsp;B&nbsp;o&nbsp;x</B>
</FONT>
</TD>
</TR>
</TABLE>
<a href="/"><IMG SRC="images/busybox2.jpg" alt="BusyBox" border="0" width="360" height="230"</a><BR>
<!-- Begin Introduction section -->
<TABLE WIDTH=95% CELLSPACING=1 CELLPADDING=4 BORDER=1>
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="intro"> <BIG><B>
The Swiss Army Knife of Embedded Linux
</font>
</A></B></BIG>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
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 embedded system. 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.
<p>
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).
<p>
BusyBox is now maintained by
<a href="http://www.xmission.com/~andersen/erik/erik.html">
Erik Andersen</a>, and its ongoing development is being sponsored by
<a href="http://www.lineo.com/">Lineo</a>.
<p>
BusyBox is licensed under the
<a href="http://www.gnu.org/copyleft/gpl.html">GNU GENERAL PUBLIC LICENSE</a>
<p>
<H3>NEW!</h3>
BusyBox now has a mailing list <a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>!
To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo/busybox">this page</a>.
<!-- Begin Latest News section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="news">
<BIG><B>
Latest News</A>
</B></BIG>
</A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<p> <li> <b>11 July 2000 -- BusyBox 0.46 released</b>
<br>
This release fixes several bugs (including a ugly bug in tar,
and fixes for NFSv3 mount support). Added a dumpkmap to allow
people to dump a binary keymaps for use with 'loadkmap', and a
completely reworked 'grep' and 'sed' with should behave better.
BusyBox shell can now also be used as a login shell.
See the <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a> for complete details.
<p> <li> <b>21 June 2000 -- BusyBox 0.45 released</b>
<br>
This release has been slow in coming, but is very solid at this
point. BusyBox now supports libc5 as well as GNU libc. This
release provides the following new apps: cut, tr, insmod, ar,
mktemp, ,setkeycodes md5sum, uuencode, uudecode, which , and
telnet. There are bug fixes for just about every app as well (see
the <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a> for
details).
<p>
Also, some exciting infrastructure news! Busybox now has its own
<a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>,
publically browsable
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
anonymous
<a href="http://opensource.lineo.com/cvs_anon.html">CVS access</a>, and
for those that are actively contributing there is even
<a href="http://opensource.lineo.com/cvs_write.html">CVS write access</a>.
I think this will be a huge help to the ongoing development of BusyBox.
<p>
Also, for the curious, there is no 0.44 release. Somehow 0.44 got announced
a few weeks ago prior to its actually being released. To avoid any confusion
we are just skipping 0.44.
<p>
Many thanks go out to the many people that have contributed to this release
of BusyBox (esp. Pavel Roskin)!
<p> <li> <b>Old News</b>
<br>
For the old news, visit <a href="http://busybox.lineo.com/oldnews.html">the old news page</a>.
</ul>
<!-- Begin Download section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="download"><BIG><B>
Download
</A></B></BIG>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<li> Source for the latest release can always be downloaded from
<a href="ftp://ftp.lineo.com/pub/busybox">ftp://ftp.lineo.com/pub/busybox</a>.
<li> BusyBox now has its own publically browsable
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
anonymous
<a href="http://opensource.lineo.com/cvs_anon.html">CVS access</a>, and
for those that are actively contributing there is even
<a href="http://opensource.lineo.com/cvs_write.html">CVS write access</a>.
</ul>
<!-- Begin Docs section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="docs"><BIG><B>
Documentation
</A></B></BIG>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
Current documentation for BusyBox includes:
<ul>
<li> <a href="BusyBox.html">BusyBox.html</a>
This is a list of the all the available commands in BusyBox with complete
usage information and examples of how to use each app. I spent
a <em>lot</em> of time updating these docs and trying to make them
fairly comprehensive for the BusyBox 0.43 release. If you find any
errors (factual, grammatical, whatever) please let me know.
<li> <a href="http://bugs.lineo.com/db/pa/lbusybox.html">BusyBoxBugs</a>.
<li> If you need more help, the BusyBox
<a href="http://opensource.lineo.com/lists/busybox/">mailing list</a> is
a good place to start.
</ul>
<!-- Begin Projects section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="projects"><BIG><B>
Projects using BusyBox
</A></B></BIG>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
I know of the following projects that use BusyBox
<ul>
<li> <a href="http://www.lineo.com/products/embedix_linux/">Lineo Embedix Linux</a>
<li> <a href="http://cvs.debian.org/boot-floppies/">Debian boot floppies project</a>
<li> <a href="http://www.linuxrouter.org/">Linux Router Project </a>
<li> <a href="http://linux-embedded.org/">LEM</a>
<li> <a href="http://www.toms.net/rb/">tomsrtbt</a>
<li> <a href="http://www.stormix.com/">Stormix Installer</a>
<li> <a href="http://www.emacinc.com/linux2_sbc.htm">EMAC Linux 2.0 SBC</a>
<li> <a href="http://www.trinux.org/">Trinux</a>
<li> <a href="http://www.suse.com/~peterb/x86/tinynet.html">tinynet</a>
</ul>
Do you use BusyBox? I'd love to know about it and I'd be happy to link to you.
<!-- Begin Links section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="links">
<BIG><B>
Important Links</A>
</B></BIG>
</A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<li> <A HREF="http://perens.com/FreeSoftware/">
Free Software from Bruce Perens</A><br>
The original idea for BusyBox, and all versions up to 0.26 were written
by <A HREF="mailto:bruce@perens.com">Bruce Perens</a>. This is his BusyBox website.
<p>
<li> <A HREF="http://freshmeat.net/appindex/1999/04/11/923859921.html">
Freshmeat AppIndex record for BusyBox</A>
<p>
<li> <a href="http://opensource.lineo.com/software.html">Other cool embedded software</a>.
<p>
<li> <a href="http://opensource.lineo.com/">opensource.lineo.com</a>.
<p>
<li> <A HREF="http://www.lineo.com/">Lineo</A> is sponsoring BusyBox development.
<p>
</ul>
<!-- End of Table -->
</TD></TR>
</TABLE>
</P>
<!-- Footer -->
<HR>
<TABLE WIDTH="100%">
<TR>
<TD>
<font size="-1" face="arial, helvetica, sans-serif">
Mail all comments, insults, suggestions and bribes to
<a href="mailto:andersen@lineo.com">Erik Andersen</a><BR>
The Busybox logo is copyright 1999,2000, Erik Andersen.
</font>
</TD>
<TD>
<a href="http://www.vim.org"><img border=0 width=88 height=32
src="images/anim.written.in.vi.gif"
alt="This site created with the vi editor"></a>
</TD>
<TD>
<a href="http://www.gimp.org/"><img border=0 width=88 height=38
src="images/gfx_by_gimp.gif" alt="Graphics by GIMP"></a>
</TD>
<TD>
<a href="http://www.linuxtoday.com"><img width=90 height=36
src="images/ltbutton2.jpg" alt="Linux Today"></a>
</TD>
<TD>
<p><a href="http://slashdot.org"><img width=90 height=36
src="images/sdsmall.gif" alt="Slashdot"></a>
</TD>
<TD>
<a href="http://freshmeat.net"><img width=90 height=36
src="images/fm.mini.jpg" alt="Freshmeat"></a>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
+286
View File
@@ -0,0 +1,286 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>BusyBox</TITLE>
</HEAD>
<body text="#000000" alink="#660000" link="#660000" bgcolor="#dee2de" vlink="#660000">
<basefont face="lucida, helvetica, arial" size="3">
<CENTER>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2>
<TR>
<td bgcolor="#000000">
<FONT FACE="lucida, helvetica" COLOR="#ccccc0">
<B>B&nbsp;u&nbsp;s&nbsp;y&nbsp;B&nbsp;o&nbsp;x</B>
</FONT>
</TD>
</TR>
</TABLE>
<a href="/"><IMG SRC="images/busybox2.jpg" alt="BusyBox" border="0" width="360" height="230"</a><BR>
<TABLE WIDTH=95% CELLSPACING=1 CELLPADDING=4 BORDER=1>
<!-- Begin Older News section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="news">
<BIG><B>
Older BusyBox News</A>
</B></BIG>
</A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<p> <li> <b>Take me back to the <a href="http://busybox.lineo.com/">BusyBox</a> web site.</b>
<hr>
<p> <li> <b>19 April 2000 -- syslogd bugfix</b>
<br>
Turns out that there was still a bug in busybox syslogd.
For example, with the following test app:
<pre>
#include &lt;syslog.h&gt;
int do_log(char* msg, int delay)
{
openlog("testlog", LOG_PID, LOG_DAEMON);
while(1) {
syslog(LOG_ERR, "%s: testing one, two, three\n", msg);
sleep(delay);
}
closelog();
return(0);
};
int main(void)
{
if (fork()==0)
do_log("A", 2);
do_log("B", 3);
}
</pre>
it should be logging stuff from both "A" and "B". As released in 0.43 only stuff
from "A" would have been logged. This means that if init tries to log something
while say ppp has the syslog open, init would block (which is bad, bad, bad).
<p>
Karl M. Hegbloom has created a
<a href="ftp://ftp.lineo.com/pub/busybox/busybox-0.43-syslog_patch">fix for the problem</a>.
Thanks Karl!
<p> <li> <b>18 April 2000 -- BusyBox 0.43 released (finally!)</b>
<br>
I have finally gotten everything into a state where I feel pretty
good about things. This is definitely the most stable, solid release
so far. A lot of bugs have been fixed, and the following new apps
have been added: sh, basename, dirname, killall, uptime,
freeramdisk, tr, echo, test, and usleep. Tar has been completely
rewritten from scratch. Bss size has also been greatly reduced.
More details are available in the
<a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a>.
Oh, and as a special bonus, I wrote some fairly comprehensive
<em>documentation</em>, complete with examples and full usage information.
<p>
Many thanks go out to the fine people that have helped by submitting patches
and bug reports; particularly instrumental in helping for this release were
Karl Hegbloom, Pavel Roskin, Friedrich Vedder, Emanuele Caratti,
Bob Tinsley, Nicolas Pitre, Avery Pennarun, Arne Bernin, John Beppu, and Jim Gleason.
There were others so if I somehow forgot to mention you, I'm very sorry.
<p>
You can grab BusyBox 0.43 tarballs <a href="ftp://ftp.lineo.com/pub/busybox/">here</a>.
<p> <li> <b>9 April 2000 -- BusyBox 0.43 pre release</b>
<br>
Unfortunately, I have not yet finished all the things I want to
do for BusyBox 0.43, so I am posting this pre-release for people
to poke at. This contains my complete rewrite of tar, which now weighs in at
5k (7k with all options turned on) and works for reading and writing
tarballs (which it does correctly for everything I have been able to throw
at it). Tar also (optionally) supports the "--exclude" option (mainly because
the Linux Router Project folks asked for it). This also has a pre-release
of the micro shell I have been writing. This pre-release should be stable
enough for production use -- it just isn't a release since I have some structural
changes I still want to make.
<p>
The pre-release can be found <a href="ftp://ftp.lineo.com/pub/busybox/">here</a>.
Please let me know ASAP if you find <em>any</em> bugs.
<p> <li> <b>28 March 2000 -- Andersen Baby Boy release</b>
<br>
I am pleased to announce that on Tuesday March 28th at 5:48pm, weighing in at 7
lbs. 12 oz, Micah Erik Andersen was born at LDS Hospital here in Salt Lake City.
He was born in the emergency room less then 5 minutes after we arrived -- and
it was such a relief that we even made it to the hospital at all. Despite the
fact that I was driving at an amazingly unlawful speed and honking at everybody
and thinking decidedly unkind thoughts about the people in our way, my wife
(inconsiderate of my feelings and complete lack of medical training) was lying
down in the back seat saying things like "I think I need to start pushing now"
(which she then proceeded to do despite my best encouraging statements to the
contrary).
<p>
Anyway, I'm glad to note that despite the much-faster-than-we-were-expecting
labor, both Shaunalei and our new baby boy are doing wonderfully.
<p>
So now that I am done with my excuse for the slow release cycle...
Progress on the next release of BusyBox has been slow but steady. I expect
to have a release sometime during the first week of April. This release will
include a number of important changes, including the addition of a shell, a
re-write of tar (to accommodate the Linux Router Project), and syslogd can now
accept multiple concurrent connections, fixing lots of unexpected blocking
problems.
<p> <li> <b>11 February 2000 -- BusyBox 0.42 released</b>
<br>
This is the most solid BusyBox release so far. Many, many
bugs have been fixed. See the
<a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a> for details.
Of particular interest, init will now cleanly unmount
filesystems on reboot, cp and mv have been rewritten and
behave much better, and mount and umount no longer leak
loop devices. Many thanks go out to Randolph Chung,
Karl M. Hegbloom, Taketoshi Sano, and Pavel Roskin for
their hard work on this release of BusyBox. Please pound
on it and let me know if you find any bugs.
<p> <li> <b>19 January 2000 -- BusyBox 0.41 released</b>
<br>
This release includes bugfixes to cp, mv, logger, true, false,
mkdir, syslogd, and init. New apps include wc, hostid,
logname, tty, whoami, and yes. New features include loop device
support in mount and umount, and better TERM handling by init.
The changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>.
<p> <li> <b>7 January 2000 -- BusyBox 0.40 released</b>
<br>
This release includes bugfixes to init (now includes inittab support),
syslogd, head, logger, du, grep, cp, mv, sed, dmesg, ls, kill, gunzip, and mknod.
New apps include sort, uniq, lsmod, rmmod, fbset, and loadacm.
In particular, this release fixes an important bug in tar which
in some cases produced serious security problems.
As always, the changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>.
<p> <li> <b>11 December 1999 -- BusyBox Website</b>
<br>
I have received permission from Bruce Perens (the original author of BusyBox)
to set up this site as the new primary website for BusyBox. This website
will always contain pointers to the latest and greatest, and will also
contain the latest documentation on how to use BusyBox, what it can do,
what arguments its apps support, etc.
<p> <li> <b>10 December 1999 -- BusyBox 0.39 released</b>
<br>
This release includes fixes to init, reboot, halt, kill, and ls, and contains
the new apps ping, hostname, mkfifo, free, tail, du, tee, and head. A full
changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>.
<p> <li> <b>5 December 1999 -- BusyBox 0.38 released</b>
<br>
This release includes fixes to tar, cat, ls, dd, rm, umount, find, df,
and make install, and includes new apps syslogd/klogd and logger.
</ul>
<!-- Begin Links section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="links">
<BIG><B>
Important Links</A>
</B></BIG>
</A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<li> <a href="http://busybox.lineo.com/">Take me back to http://busybox.lineo.com/</a>.
<p>
<li> <A HREF="http://perens.com/FreeSoftware/">
Free Software from Bruce Perens</A><br>
The original idea for BusyBox, and all versions up to 0.26 were written
by <A HREF="mailto:bruce@perens.com">Bruce Perens</a>. This is his BusyBox website.
<p>
<li> <A HREF="http://freshmeat.net/appindex/1999/04/11/923859921.html">
Freshmeat AppIndex record for BusyBox</A>
<p>
<li> <a href="http://opensource.lineo.com/software.html">Other cool embedded software</a>.
<p>
<li> <a href="http://opensource.lineo.com/">opensource.lineo.com</a>.
<p>
<li> <A HREF="http://www.lineo.com/">Lineo</A> is sponsoring BusyBox development.
<p>
</ul>
<!-- End of Table -->
</TD></TR>
</TABLE>
</P>
<!-- Footer -->
<HR>
<TABLE WIDTH="100%">
<TR>
<TD>
<font size="-1" face="arial, helvetica, sans-serif">
Mail all comments, insults, suggestions and bribes to
<a href="mailto:andersen@lineo.com">Erik Andersen</a><BR>
The Busybox logo is copyright 1999,2000, Erik Andersen.
</font>
</TD>
<TD>
<a href="http://www.vim.org"><img border=0 width=88 height=32
src="images/anim.written.in.vi.gif"
alt="This site created with the vi editor"></a>
</TD>
<TD>
<a href="http://www.gimp.org/"><img border=0 width=88 height=38
src="images/gfx_by_gimp.gif" alt="Graphics by GIMP"></a>
</TD>
<TD>
<a href="http://www.linuxtoday.com"><img width=90 height=36
src="images/ltbutton2.jpg" alt="Linux Today"></a>
</TD>
<TD>
<p><a href="http://slashdot.org"><img width=90 height=36
src="images/sdsmall.gif" alt="Slashdot"></a>
</TD>
<TD>
<a href="http://freshmeat.net"><img width=90 height=36
src="images/fm.mini.jpg" alt="Freshmeat"></a>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
+471 -246
View File
File diff suppressed because it is too large. Load diff
+3594
View File
File diff suppressed because it is too large. Load diff
Loaded 100 of 241 files, more files were not shown because too many files have changed in this diff. Show more