Compare commits

..
524 Commits
Author SHA1 Message Date
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
Erik Andersen 1101d23604 Fix email address
-Erik
2000-04-19 05:15:12 +00:00
Erik Andersen eef658068b Minor doc change
-Erik
2000-04-19 05:12:02 +00:00
Erik Andersen 2e397341d9 Some emails I exchanged with Alan Cox and Linus re my /dev/ps
kernel patch.  To summarize, it won't be going into the kernel.
 -Erik
2000-04-19 04:34:06 +00:00
Erik Andersen 262dd039eb Fix the makefile so docs get built
-Erik
2000-04-19 04:26:30 +00:00
Erik Andersen 3fe7f9f20b More minor updates to docs (and making apps behave as the docs
suggest they should)
 -Erik
2000-04-19 03:59:10 +00:00
Erik Andersen a3e57ca700 make ps accept (and ignore) all options (--help works of course).
tar now works with or without the leading "-" on the options.
 -Erik
2000-04-19 03:38:01 +00:00
Erik Andersen f13df3752c More stuff
-Erik
2000-04-18 23:51:51 +00:00
Erik Andersen 9a8195cc03 Fix creation of /linuxrc
-Erik
2000-04-18 23:32:10 +00:00
Erik Andersen b9167cb67f Really fix the killall segfault this time.
-Erik
2000-04-18 22:41:30 +00:00
Erik Andersen 632bb57135 Fix symlink following bug in chmod -R and friends. Allow SYSV style
'chown foo:bar' in addition to 'chown foo.bar', and fix a bug in the
busybox globbing routine such that 'find /dir -name [i]' no longer
segfaults.
 -Erik
2000-04-18 22:09:06 +00:00
Erik Andersen c366050a23 Fix stupid bug (wrong variable)
-Erik
2000-04-18 21:18:57 +00:00
Jim Gleason f29f797f54 Reset DODEBUG to false 2000-04-18 20:40:38 +00:00
Erik Andersen 0a64de9b4f More little stuff.
-Erik
2000-04-18 20:00:03 +00:00
Erik Andersen 229dd2b905 Fix killall
-Erik
2000-04-18 18:38:29 +00:00
Erik Andersen 5d68857b9c Remove debug noise
-Erik
2000-04-18 01:09:29 +00:00
Erik Andersen a6c752201e Updates
-Erik
2000-04-18 00:00:52 +00:00
John Beppu 91e581fa04 - grep -v ^\.PHONY < Makefile
+ busybox.def.h
  BB_FEATURE_TRIVIAL_HELP
+ uname.c has an example of how BB_FEATURE_TRIVIAL_HELP
  is to be applied.
2000-04-17 17:49:44 +00:00
John Beppu 5a50def0f4 - removal of (stray|stealth) spaces 2000-04-17 17:46:46 +00:00
John Beppu 6e703034f4 + no need for comments. 2000-04-17 16:53:45 +00:00
Erik Andersen 26702fe191 Bugfixes.
-Erik
2000-04-17 16:44:46 +00:00
Erik Andersen e5b6c7dd9c More updates to the docs, and fixes to sync things with the docs.
-Erik
2000-04-17 16:16:10 +00:00
John Beppu 4fd10fc73b + added John Lombardo to AUTHORS section 2000-04-17 05:13:59 +00:00
John Beppu 200be97e36 - got rid of the .PHONY: docs, because I didn't want it to
generate the qw(man html txt) documentation every time I
  ran make.

  Unfortunately, "make docs" never amounts to anything, because
  make sees the docs/ directory and thinks, "oh, I don't have
  to do any work".  Maybe the target should be "doc" to make it
  different from "docs"?
2000-04-17 04:41:15 +00:00
John Beppu 5a728cfdfe + in the interest of robustness, I added
utility.c :: cstring_alloc()
  utility.c :: cstring_lineFromFile()	/* they're at the bottom */
  so that I could read in lines of arbitrary length from FILE*s
  (instead of using fgets(huge_ass_buffer,...)).
+ I tested it out on sort, and it seems to be fine.
2000-04-17 04:22:09 +00:00
John Beppu 3becdfc316 + added a .PHONY: docs
target
2000-04-17 03:37:52 +00:00
John Beppu 53642b066c + fixed segfault when no parameters are given to math 2000-04-16 10:55:27 +00:00
John Beppu 9057b6a918 + wrap things in B<> to make pod2man happy 2000-04-16 10:22:28 +00:00
Erik Andersen ab01ed12bd Turn off debugging
-Erik
2000-04-15 16:37:45 +00:00
Erik Andersen 5e1189e187 More documentation updates, and minor fixes to make things sync
up with the docs.
 -Erik
2000-04-15 16:34:54 +00:00
Erik Andersen 95c1c1e05f Fix a tar bug: tar removed leading '/'s for symlink targets.
Fix a syslogd bug: Only the first sizeof(buffer) was read from the
/dev/log socket, causing (for most cases) only every other log item to be logged.
 -Erik
2000-04-14 21:45:29 +00:00
Erik Andersen d5ba77d03e Latest and greatest. Seems there is a bug.
-Erik
2000-04-14 00:40:31 +00:00
John Beppu 50ed0676ad + minor whitespace oddities removed
+ re-alphabetized AUTHORS section
+ added Id tag at bottom
2000-04-13 23:44:04 +00:00
John Beppu cbd6628c8c + VERSION wasn't being propagated to the sub-make happening in docs/
so I exported VERSION and invoked make with a -C docs
2000-04-13 22:57:45 +00:00
Erik Andersen 9cf3bfa7c1 More doc updates for BusyBox, with fixes to apps for bugs revealed
while trying to write docs . :-)
 -Erik
2000-04-13 18:49:43 +00:00
John Beppu b4f8606c05 - the message that comes up when busybox is invoked
w/o parameters was extending beyond the 80th column
2000-04-13 03:36:01 +00:00
John Beppu 08e7f75ba2 + a comment on line 1 w/ suggested pod2man invocation:
pod2man --center=Lineo --release="version 0.43" busybox.pod > busybox.1
2000-04-13 03:22:20 +00:00
John Beppu f17792ca9b + formatting modifications to make pod2man(1p) happy. 2000-04-13 03:16:01 +00:00
Erik Andersen 61677feff7 Upates to include copyright 2000 to everything
-Erik
2000-04-13 01:18:56 +00:00
Erik Andersen 62dc17a3b1 Some docs
-Erik
2000-04-13 01:18:23 +00:00
Erik Andersen f0657d3229 Some enhancements I've been working on over the weekend,
-Erik
2000-04-12 17:49:52 +00:00
Erik Andersen a2685735b1 Make tab completion an option
-Erik
2000-04-09 18:27:46 +00:00
Erik Andersen f3b3d17060 More minor patches
-Erik
2000-04-09 18:24:05 +00:00
Erik Andersen 0817d1372c This makes tar work perfectly, and adds in "--exclude" as an option
-Erik
2000-04-09 15:17:40 +00:00
Erik Andersen 84e09e4437 Fix tar checksum calculation bug.
-Erik
2000-04-08 20:58:35 +00:00
Erik Andersen ecd512453c Latest and greatest
-Erik
2000-04-08 03:08:21 +00:00
Erik Andersen 5dd853ad2a Oops. Left in some debug noise.
-Erik
2000-04-07 16:19:30 +00:00
Erik Andersen 6a34b539db Slightly better fringe case handling and GNU tar like error messages.
-Erik
2000-04-07 06:55:38 +00:00
Erik Andersen 825aead68b Patch to make killall actually kill all PIDs with the specified name,
rather then busylooping trying to kill the first one until it dies.
Should be more efficient now, and will only send one signal to each
specified process.
 -Erik
2000-04-07 06:00:07 +00:00
Erik Andersen 93d6513d93 Some more minor updates to better use some gcc attributes.
-Erik
2000-04-06 08:06:36 +00:00
Erik Andersen 7a4b719486 Fix sed regexp replacement, which I had hosed (thanks to
Jim Gleason for finding and fixing the problem)
 -Erik
2000-04-06 07:37:35 +00:00
Erik Andersen 6bd3602988 Fix time stamp style
-Erik
2000-04-06 07:25:44 +00:00
Erik Andersen c0dac18d6d Turn off static linking. Duh.
-Erik
2000-04-06 07:24:45 +00:00
Erik Andersen e9fee653dc Use gcc -E instead of cpp to enhance portability for brain
damaged platforms (i.e. OpenLinux) that do not have cpp in
the default path but instead hide it under /usr/lib/...
 -Erik
2000-04-06 00:10:39 +00:00
Erik Andersen d4bc1fcad8 Minor noise removal
-Erik
2000-04-05 05:19:03 +00:00
Erik Andersen 5661fe078e Tar now works perfectly. It behaves much better now then it
used to.  Only thing left to do is add in exclude (-X) option.
 -Erik
2000-04-05 01:00:52 +00:00
Erik Andersen cbb0a4b40d Oops. Forgot the usleep.c file.
/me dons a paper bag.
 -Erik
2000-04-04 18:52:02 +00:00
Erik Andersen b99ca13261 usleep contributed by Nicolas Pitre <nico@cam.org>
-Erik
2000-04-04 18:49:18 +00:00
Erik Andersen 68a9ea4208 Update tar so creation of tarballs is much closer to working...
-Erik
2000-04-04 18:39:50 +00:00
Erik Andersen 183da4ade1 Minor structural change to allow core dumping(or not) from init
-Erik
2000-04-04 18:36:37 +00:00
Erik Andersen 983b51b17b minor changes to mount/umount to support-by-ignoring the "-v" flag.
Added optional core dumping as a feature for init, and include a rewrite
of syslogd so that it now supports multiple concurrent connections.
 -Erik
2000-04-04 18:14:25 +00:00
Erik Andersen 3364d78b18 Yet another installment in the ongoing tar saga
-Erik
2000-03-28 00:58:14 +00:00
Erik Andersen 6acaa40f27 First stages of (re-)writing busybox's tar creation support.
-Erik
2000-03-26 14:03:20 +00:00
Erik Andersen deea048bec Latest and greatest
-Erik
2000-03-25 23:09:29 +00:00
Erik Andersen 1ad302ac90 The new tar for busybox is now done, and works just fine
for extracting files.  Creation of tarballs is next...
 -Erik
2000-03-24 00:54:46 +00:00
Erik Andersen e454fb68a3 More changes that are broken. It doesn't compile
yet, but is closer.
 -Erik
2000-03-23 04:27:58 +00:00
Erik Andersen 298854f029 My latest ramblings.
-Erik
2000-03-23 01:09:18 +00:00
Erik Andersen ec5bd90916 Use the nice new find_real_root_device function to find the
name of the root device, instead of having libc read whatever
lies happen to be in /etc/mtab.
 -Erik
2000-03-22 07:12:05 +00:00
Erik Andersen 016ffe9307 Add in a nifty function for mount to use.
-Erik
2000-03-22 00:58:54 +00:00
Erik Andersen 0d068a2067 * all mallocs now use xmalloc (and so are OOM error safe), and
the common error handling saves a few bytes.  Thanks to
Bob Tinsley <bob@earthrise.demon.co.uk> for the patch.
 -Erik
2000-03-21 22:32:57 +00:00
Erik Andersen c053e41fa0 Hmm. Missed this change 2000-03-21 01:31:24 +00:00
Erik Andersen 42094cdad5 Fix bug in memory total checking.
-Erik
2000-03-20 21:34:52 +00:00
Erik Andersen 1dbe340eba more minor fixes
-Erik
2000-03-19 10:46:06 +00:00
Erik Andersen c7c634bd88 Some more stuff.
-Erik
2000-03-19 05:28:55 +00:00
Erik Andersen 6c41c44898 Adjust the termio settings, and don't use octal since it
is impossible to read by mere mortals.
 -Erik
2000-03-19 05:13:49 +00:00
Erik Andersen 531bcb6826 Minor update 2000-03-17 20:49:55 +00:00
Erik Andersen 6273f655c8 Several fixes.
-Erik
2000-03-17 01:12:41 +00:00
Erik Andersen 161220c498 Fix fg bug
-Erik
2000-03-16 08:12:48 +00:00
Erik Andersen 13456d1fcd Forgot these files...
-Erik
2000-03-16 08:09:57 +00:00
Erik Andersen d75af99529 Major build system updates...
-Erik
2000-03-16 08:09:09 +00:00
Erik Andersen a967e3c8f0 Bug fix
-Erik
2000-03-14 16:34:49 +00:00
Erik Andersen ce91732416 Some bug fixes I forgot to check-in the other day.
Mounting loop devices w/o specifying the filesystem
type choked if it didn't guess right the first time.
 -Erik
2000-03-13 04:07:02 +00:00
Erik Andersen 3522eb1ab3 First pass at writing a shell for busybox.
Works fine, full job control support, etc.
No syntax yet (if, then, while, etc).  Handles
pipes and & processes fine.

TODO: add command editing, add syntax suport.

 -Erik
2000-03-12 23:49:18 +00:00
Erik Andersen 269bba2514 Change BB_FEATURE_USE_DEVPS_N_DEVMTAB to the simpler
BB_FEATURE_USE_DEVPS_PATCH.
 -Erik
2000-03-08 14:50:47 +00:00
Erik Andersen 47d3bb3b6d First edition of my Busybox kernel patch. implements devps, devmtab, and
devmodules.  With this patch, you can enable BB_FEATURE_USE_DEVPS_N_DEVMTAB and
have a completely full featured busybox without having to even compile /proc
into the kernel.  I'm pretty proud of this patch.  It has a few loose ends that
should be filled in sometime, but arn't used by busybox (so they arn't very
important).

 -Erik
2000-03-08 06:52:04 +00:00
Erik Andersen 54969a1f64 Fixed up lsmod so it works with my devmodules kernel driver,
and with /proc.
 -Erik
2000-03-08 06:42:34 +00:00
John Beppu 692a4502b0 + changed a static array (FileList) into a dynamically allocated one
in an attempt to make the .bss section smaller.
2000-03-08 00:14:35 +00:00
Erik Andersen 2ac2fae728 Fix bugs related to finding PIDs.
-Erik
2000-03-07 23:32:17 +00:00
Erik Andersen cbd0d625c7 Fix up some #define stuff to ensure the Right Thing(tm)
happens with all combinations of BB_KILL and BB_KILLALL
being defined.
 -Erik
2000-03-07 07:58:57 +00:00
Erik Andersen 06249f24f3 Add some description
-Erik
2000-03-07 07:48:53 +00:00
Erik Andersen ea6b67de65 Add a #define to make init extra quiet on boot.
-Erik
2000-03-07 07:47:10 +00:00
Erik Andersen 246cc6dddd Wrote killall.
Adjusted mount, ps, utility.c, etc to handle my nifty new kernel
patches the allow busybox to run perfectly without /proc.
 -Erik
2000-03-07 07:41:42 +00:00
Erik Andersen e916d24805 Fixed a bug where "sed 's/foo/bar/g'" (i.e. a script w/o a -e)
would go into an infinite loop.
 -Erik
2000-03-06 19:20:35 +00:00
Erik Andersen 9c5c29d442 Oops. I left debugging turned on...
-Erik
2000-03-06 18:34:48 +00:00
Erik Andersen 65fc1c70f7 Oops. Forgot to add in uptime when I added uptime.
Here it is in all its /proc free glory.
 -Erik
2000-03-05 08:16:03 +00:00
Erik Andersen fb002d0df0 Add in tr and dirname
-Erik
2000-03-05 08:07:00 +00:00
Erik Andersen 66be5e7e29 Wrote uptime. Doesn't use /proc. :)
-Erik
2000-03-05 07:52:05 +00:00
Erik Andersen 6437170cb3 Add in freeramdisk.c, which (duh) frees ramdisks. If you have any
ramdisks lying about and want to free up the memory they have used,
this baby is the answar you have been waiting for.
 -Erik
2000-03-04 22:23:27 +00:00
Erik Andersen 029011b9ee A few updates (including the cp fix the Craig has been looking for)
-Erik
2000-03-04 21:19:32 +00:00
Erik Andersen 7c4b2f3fe5 Minor makefile and todo updates
-Erik
2000-02-29 21:49:22 +00:00
Erik Andersen a51ecdd9e4 Minor tweak to argv[0] handling for linuxrc
-Erik
2000-02-24 18:09:58 +00:00
Erik Andersen 5b911ddd57 Fixed rebooting when init runs as /linuxrc
-Erik
2000-02-23 22:49:58 +00:00
John Beppu dc75a739ac + this is a small script for helping TargetWizard auto-generate
busybox.defs.h
2000-02-23 18:17:35 +00:00
Erik Andersen f7c49ef2d1 Sync up a few things. Add in a new telnet implementation (still
not perfect though).
 -Erik
2000-02-22 17:17:45 +00:00
Erik Andersen 3b9522f2af Add in a TODO item,
-Erik
2000-02-22 17:12:00 +00:00
Erik Andersen 6e769df47d Update the changelog
-Erik
2000-02-21 21:35:11 +00:00
Erik Andersen d07ee46919 Removed proc dependancies for init and free (which maintaining exactly
the same functionality).  /proc takes up 90k of kernel space, so it is
nice to avoid using it at all costs.  The only places where it is depended
on is for cetain optional mount/umount features, and for ps and lsmod.
 -Erik
2000-02-21 21:26:32 +00:00
Erik Andersen fa4718efcf Minor update for handling TERM with serial consoles.
-Erik
2000-02-21 19:25:12 +00:00
Erik Andersen 42387e4964 Forgot to add basename. More fixes to du from
Friedrich Vedder <fwv@myrtle.lahn.de>.
 -Erik
2000-02-21 17:27:17 +00:00
Erik Andersen 27fdd081ef Fixed du. Now behaves just like GNU du (only less so).
-Erik
2000-02-19 18:16:49 +00:00
Erik Andersen e272915e1f Some updates for the day,
-Erik
2000-02-18 21:34:17 +00:00
Erik Andersen bf5f009862 Formatting fix
-Erik
2000-02-14 18:44:33 +00:00
John Beppu 08c965a0a1 - I suspect the problem has something to do w/ symlinks.
- It's not completely in agreement w/ GNU/du, but
+ the answer is much closer than before.
- Some of the right-shifts seem to have mysteriously disappeared.
  I put them back in.
2000-02-13 04:10:57 +00:00
Erik Andersen 5e2b96345c Add this in
-Erik
2000-02-11 21:55:41 +00:00
Erik Andersen 9ffdaa647e Updates
-Erik
2000-02-11 21:55:04 +00:00
John Beppu 5e1b2ca116 + memory allocation/deallocation is less tolerant of evil. 2000-02-11 12:52:55 +00:00
John Beppu fa376f8034 fsck_minix.c lost fat. 2000-02-11 12:44:07 +00:00
John Beppu c1dc5d9473 reduced .bss size by dynmaically allocating a certain large
array instead of letting it be static.

objdump -t busybox	    \
| grep .bss		    \
| sed 's/^.*\.bss	//' \
| grep -v ABS		    \
#| perl -e 'while(<>) { @x = split; @y = reverse split(//, $x[0]); for ($i=0; $i<@y; $i++) { $s += $y[$i] * (16 ** $i); if ($y[$i] && $i > 2) { print "> $y[$i] * 16 ** $i $x[1]\n"; } } } print "$s\n";'
2000-02-11 12:43:20 +00:00
Erik Andersen 91f3df3c45 Fixed a bug,
-Erik
2000-02-10 22:58:40 +00:00
Erik Andersen 4d0543138e More minor touchups.
-Erik
2000-02-10 07:31:15 +00:00
Erik Andersen fb1793f03c Fix stupid typos -- thanks to Taketoshi Sano <kgh12351@nifty.ne.jp>
for noticing these bugs.
 -Erik
2000-02-09 16:37:08 +00:00
Erik Andersen 07f5604046 Fix a possible /linuxrc crash.
-Erik
2000-02-09 06:05:01 +00:00
Erik Andersen d7ce5e7802 Update the sample inittab to add the "ctrlaltdel" action.
Note a bug in busybox init that I need to fix.
 -Erik
2000-02-09 04:40:25 +00:00
Erik Andersen e132f4b09e Fixed the init problem where it wouldn't unmount filesystems
on reboot.  Also fixed swapoff -a so it works.
 -Erik
2000-02-09 04:16:43 +00:00
Erik Andersen e49d5ecbbe Some formatting updates (ran the code through indent)
-Erik
2000-02-08 19:58:47 +00:00
Erik Andersen c0bf817bbc mkdir -p had gotten broken. Fixed now.
-Erik
2000-02-08 06:19:29 +00:00
Erik Andersen d0480c26ab Forgot a semicolon.
-Erik
2000-02-07 20:35:14 +00:00
Erik Andersen 31cf8e0056 device_open is common code -- moved into utility.c
-Erik
2000-02-07 20:31:19 +00:00
Erik Andersen 79ac30da83 Forgot cp and mv are now cp_mv
-Erik
2000-02-07 05:53:48 +00:00
Erik Andersen d7cd21aed5 Remove the now obsolete test. Tests now
live in the tests directory.
 -Erik
2000-02-07 05:30:41 +00:00
Erik Andersen fac10d7c59 A few minor updates. ;-)
Seriously though, read the Changelog for busybox 0.42,
which this is about to become...
 -Erik
2000-02-07 05:29:42 +00:00
John Beppu 50bc101b7d made more robust and commented my code. 2000-01-30 09:47:16 +00:00
John Beppu b332e779e6 nslookup -- a work in progress... 2000-01-29 12:59:01 +00:00
Erik Andersen 04e97024e7 Clear up some ambiguity with old style assignments.
-Erik
2000-01-29 07:06:24 +00:00
Erik Andersen a6d0dbc86f Minor change. init now uses dup2.
-Erik
2000-01-29 06:29:32 +00:00
Erik Andersen 8e759aa31f copy fixes to simplify link copying and always do the right thing.
ping could segfault because I'm an idiot, and tried to put a value
in where I hadn't allocated storage.  choke.
 -Erik
2000-01-29 05:52:40 +00:00
Erik Andersen d7a44c76fe Forgot some debugging noise.
-Erik
2000-01-27 23:00:01 +00:00
Erik Andersen ce5b466bcc copyFile could call chmod on a symlink, changing the perms
of the pointed to file.  Minor fix to tar for directory handling.
 -Erik
2000-01-27 19:50:47 +00:00
Erik Andersen ccc7488615 Fixed ls formatting for 8 char user names.
-Erik
2000-01-27 02:40:21 +00:00
Erik Andersen de7965ca7e Shuffle location of generic code into utility.c
-Erik
2000-01-26 23:49:21 +00:00
Erik Andersen 5cbdd712f5 mount and umount could leak loop device allocations causing the system to
quickly run out.  Also disable init's SIGHUP handler during shutdown.
 -Erik
2000-01-26 20:06:48 +00:00
Erik Andersen 3fe39dce5d Some busybox updates. See the changelog for details if you care.
-Erik
2000-01-25 18:13:53 +00:00
John Beppu bf3a838aac put #if's around the lchown, because
older glibc versions don't have it.
2000-01-24 12:06:22 +00:00
Erik Andersen 5509af7073 * added (and documented) "-n" option for head -
contributed Friedrich Vedder <fwv@myrtle.lahn.de>
* Cleanup for a number of usage messages -- also
    contributed Friedrich Vedder <fwv@myrtle.lahn.de>
 -Erik
2000-01-23 18:19:02 +00:00
John Beppu 9bc7e89fc1 Making note of my changes 2000-01-23 13:54:15 +00:00
John Beppu a4a8fd05f4 Went ahead and fixed bug #301 (chown not working on symlinks)
in fileAction(), I changed the chown() to lchown(); Hopefully, that
	doesn't break anything.  (I don't think it does).

	nested ?:?:?: madness in chmod_chown_chgrp.c
2000-01-23 13:38:32 +00:00
Erik Andersen 06936df164 Fix a bug where tar could change perms and ownership of dirs pointed
to by symlink within a tarball.
 -Erik
2000-01-23 02:14:20 +00:00
Erik Andersen de552874d2 Some busybox updates. You no longer _have_ to put a "-" in front of tar
options, logger is better behaved and has a "-t" option now.  init now supports
the kernel chroot patch, so you can chroot to a new device and umount the old
root.
 -Erik
2000-01-23 01:34:05 +00:00
Erik Andersen f4acea8cf5 Better way to check for namespace aliasing.
-Erik
2000-01-22 04:55:32 +00:00
Erik Andersen b2660c703d Tell what I did
-Erik
2000-01-20 19:51:48 +00:00
Erik Andersen 8ad12e32c8 Fix a namespace aliasing problem wereby du and dutmp, or
rm and rmmod symlinks would be created when only du or rm
was included.
 -Erik
2000-01-20 19:32:32 +00:00
John Beppu 4581b4cdd9 foreach (@busybox_command) {
put_help_message_in_busybox_pod($_);
}
2000-01-19 15:04:41 +00:00
John Beppu 08fe43d3f9 added a little more content. 2000-01-19 12:39:16 +00:00
Erik Andersen a2f69e5485 Bug fix. grep wasn't printing file names they way it was supposed to.
-Erik
2000-01-19 04:30:37 +00:00
John Beppu 46a4e76243 fleshed out a bit more... just wanted to put the current
changes under version control.
2000-01-18 22:33:11 +00:00
John Beppu 3a1b6be7d8 the beginnings of a proper man page for busybox. 2000-01-18 15:45:59 +00:00
Erik Andersen 05100cd477 tar creation support is now optional.
-Erik
2000-01-16 01:30:52 +00:00
Erik Andersen 83865e3e90 Ready for release 2000-01-15 22:33:09 +00:00
Erik Andersen 3163821967 Sync up busybox with the latest and greatest. This is not stuff for
the Embedix release.
 -Erik
2000-01-15 22:28:50 +00:00
Erik Andersen b7cc49d992 * Added -o loop option for mount, and support in umount for loop
devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins
    <bcollins@debian.org>

 -Erik
2000-01-13 06:38:14 +00:00
Erik Andersen 05df239ed9 Bug fixes.
-Erik
2000-01-13 04:43:48 +00:00
Erik Andersen 9a9a261569 Fix a logger bug.
-Erik
2000-01-09 06:49:08 +00:00
Erik Andersen ac6e71f0c4 Possible fixes...
-Erik
2000-01-08 22:04:33 +00:00
Erik Andersen 766f9c7a19 Oops. left debug on.
-Erik
2000-01-08 21:20:49 +00:00
Erik Andersen 1dbc17f630 Fix cp and mv so 'cp foo/README bar' where foo and bar are directories,
and README is a file.
 -Erik
2000-01-08 21:16:29 +00:00
Erik Andersen 5338ce19c8 foo 2000-01-07 23:30:07 +00:00
Erik Andersen 5f2df6ccb4 Remove some leftover debug noise.
-Erik
2000-01-07 23:11:00 +00:00
Erik Andersen 9b5c0b7611 More adjustments
-Erik
2000-01-07 18:33:06 +00:00
Erik Andersen 812d46667d More minor fixes.
-Erik
2000-01-07 18:30:40 +00:00
Erik Andersen 96e2abd084 Init is now even more perfect then before.
-Erik
2000-01-07 11:40:44 +00:00
Erik Andersen 286b0de74d Trivial type fix.
-Erik
2000-01-07 09:43:38 +00:00
Erik Andersen d38eaef70b foo 2000-01-07 02:55:55 +00:00
Erik Andersen 0e3782f7c3 Init is now _more_ perfect then before.
-Erik
2000-01-07 02:54:55 +00:00
John Beppu 9324b400ab making note of my changes. 2000-01-07 02:04:58 +00:00
John Beppu 9d83165d9e added uniq_usage message 2000-01-07 01:57:32 +00:00
John Beppu 96f1f33e56 did tedious stuff 2000-01-06 23:49:21 +00:00
Erik Andersen 3695052813 Add in sample inittab file
-Erik
2000-01-06 01:16:59 +00:00
Erik Andersen 9e7372584f inittab is now perfect. The universe will now submit to my
will. muhahahaha!!!  Phear!
 -Erik
2000-01-06 01:16:13 +00:00
Erik Andersen 0b874ed41f Cool. Beppu is doing uniq.
-Erik
2000-01-06 01:14:56 +00:00
John Beppu abb4772b28 i am busybox of borg. unix will be assimilated. 2000-01-06 00:48:21 +00:00
Erik Andersen 0881de706e The latest and greatest. init basically works, though needs
a minor inittab design change to accomodate specifying the device
to run each process on.
 -Erik
2000-01-05 09:34:26 +00:00
Erik Andersen f4a99cc02c heheh. Forgot the fix. Here it is:
* Grep -i previously failed on UPPER CASE patterns due to a silly
    regexp implementation bug that is now fixed.

 -Erik
2000-01-05 05:49:51 +00:00
Erik Andersen fb62e3225f * Grep -i previously failed on UPPER CASE patterns due to a silly
regexp implementation bug that is now fixed.

 -Erik
2000-01-05 05:47:11 +00:00
Erik Andersen 7dc160721e Bunches of fixes. Typos, bugs, etc.
Added 'gunzip -t'.  inittab support _almost_ works (but it isn't
ready for prime time useage yet).
 -Erik
2000-01-04 01:10:25 +00:00
Erik Andersen 9c88cac5cb First pass inittab parser written
-Erik
1999-12-30 09:25:17 +00:00
Erik Andersen 1266a13e1f * sed now supports addresses (numeric or regexp, with negation) and
has an append command, thanks to Marco Pantaleoni <panta@prosa.it>
* Fixed dmesg.  It wasn't parsing its options (-n or -s) properly.
* Some cosmetic fixes to ls output formatting to make it behave more
    like GNU ls.
 -Erik
1999-12-29 22:19:46 +00:00
Erik Andersen a89910829c Add the beginings of some regression testing. Add in the recently
contributed loadacm utility (for dealing with unicode fonts)
 -Erik
1999-12-29 03:34:00 +00:00
Erik Andersen f664c004db Fixed mv so it now does the right thing (same method used in cp). Removed
some cruft from cp.
 -Erik
1999-12-29 02:36:29 +00:00
Erik Andersen 2fe08c7afb Fixed cp so it works as God intended it to.
-Erik
1999-12-29 02:10:35 +00:00
Erik Andersen 00266d3df6 Fixed a bug where tar would not set the user and group on device
special files.
 -Erik
1999-12-28 00:17:46 +00:00
Erik Andersen 69ba6b2956 Added changelog
-Erik
1999-12-27 23:56:17 +00:00
Erik Andersen 98f67e35d8 chown(2) clears S_ISUID and S_ISGID, even when chown is
called as root.  Changed ordering of chown and chmod so
SGID and SUID file permissions don't get munged.
 -Erik
1999-12-27 23:48:33 +00:00
John Beppu 00417a38c1 sort is good to go. 1999-12-23 22:46:10 +00:00
John Beppu ee512a3f86 implemented numeric sort (sort -g) 1999-12-23 00:02:49 +00:00
John Beppu 568cb7b45f oops.. qsort(2) misunderstanding on my part.
it's ok, now.
1999-12-22 23:02:12 +00:00
John Beppu d19385e160 playing w/ $Log$ 1999-12-22 22:27:01 +00:00
John Beppu f3e59041b5 the base is nearly done.
need to implement various comparison functions, now.
1999-12-22 22:24:52 +00:00
John Beppu 019513a59f added hooks for sort 1999-12-22 17:57:31 +00:00
John Beppu 38efa7902e work in progress... 1999-12-22 00:30:29 +00:00
John Beppu c0ca473af9 this is my work in progress. 1999-12-21 20:00:35 +00:00
Erik Andersen 3fe2ecf0d9 Added grep -q, thanks to a patch from "Konstantin Boldyshev" <konst@voshod.com>
-Erik
1999-12-21 08:52:04 +00:00
Erik Andersen d387d01f11 Sync to my local tree 1999-12-21 02:55:11 +00:00
Erik Andersen f294a0288d Fix double quoting bug preventing ininit scripts from running 1999-12-21 02:54:37 +00:00
Erik Andersen 021043205c Add in first draft of insmod. Not yet working (but will Real Soon Now(tm))
-Erik
1999-12-17 18:57:34 +00:00
Erik Andersen 10c341af35 Make head --version do the right thing. Update TODO list
-Erik
1999-12-17 18:52:06 +00:00
Erik Andersen 4d1d0113fd Reworked the source so it will compile and run under glibc 2.0.7
and linux kernel 2.0.36 (though the dubious reasons why someone
would want to do that defy imagination ;)
 -Erik
1999-12-17 18:44:15 +00:00
Erik Andersen 6da0ae8183 Minor fixes to rmmod. First pass at insmod (not yet working).
-Erik
1999-12-17 01:08:27 +00:00
Mark Whitley c144e330c0 Fixed correctness of comment in rmmod.c - MKW 1999-12-17 00:01:46 +00:00
Erik Andersen 2129b146db Added an AUTHORS file to acknowledge the folks that have
done stuff.
 -Erik
1999-12-16 23:26:57 +00:00
Erik Andersen 3d7e3414da Wrote rmmod for busybox.
-Erik
1999-12-16 23:04:20 +00:00
John Beppu 0aa6118167 killed an elusive bug in du -s. 1999-12-16 21:16:47 +00:00
Erik Andersen 1c5b2589d1 Fix bugs in logger and syslogd. Add fbset.
-Erik
1999-12-16 20:59:36 +00:00
Erik Andersen 6f23cec5d0 Added lsmod
-Erik
1999-12-15 22:14:12 +00:00
John Beppu 935fb3886f made note of my recent changes 1999-12-15 19:35:02 +00:00
John Beppu 25ab653457 fixed an embarrasing segfault (head w/ no args
used to die (but now it lives))
1999-12-15 19:29:09 +00:00
John Beppu e1618e42a8 Implemented du -s 1999-12-15 18:52:17 +00:00
Erik Andersen 3cd5d2541f Turn off loadkmap and loadfont. We won't be needing those.
-Erik
1999-12-15 08:20:08 +00:00
Eric Andersen 0f0fcecf7f Added the list of available commands.
-Erik
1999-12-12 05:32:52 +00:00
Eric Andersen 664584b50e Fixed spelling of my name. Geez.
Ah kant evun spel mi nam.
 -Erik
1999-12-11 23:25:59 +00:00
Eric Andersen 19db07b3d4 Ok, so this is reallt 0.38...
-Erik
1999-12-11 08:41:28 +00:00
Eric Andersen 59248bad97 Set version to 0.39
-Erik
1999-12-11 04:21:50 +00:00
Eric Andersen 84b009256f Minor updates 1999-12-11 04:16:51 +00:00
John Beppu b52a218c95 Removed a redundant call du(); Save cpu cycles. 1999-12-10 15:23:47 +00:00
John Beppu 59017e80da damnit.
removed mkfifo from the TODO list.

    I didn't implement it, because I realized (too late) that
    mknod already existed, and it can do anything that mkfifo
    would have done.
1999-12-10 08:44:54 +00:00
Eric Andersen cf53687376 Fixed John's email address again.
John.  Your email address is "john@lineo.com" not @line.com. :)
 -Erik
1999-12-10 08:29:20 +00:00
Eric Andersen 2cb55077e2 Added poweroff (and adjusted init to use it). Inlined function
calls to code only called once in tee.  Made BB_KLOGD and option.
 -Erik
1999-12-10 08:25:07 +00:00
John Beppu c5ff0165ad less TODO 1999-12-10 07:48:34 +00:00
John Beppu 3157b1fba9 Implemented head(1).
tried to mimic GNU behaviour.
1999-12-10 07:42:50 +00:00
John Beppu a3e0d7928b changed tee_usage from being a function to a char[]
that gets used be usage();
1999-12-10 07:41:03 +00:00
John Beppu 9835541c54 Fixed bug when dealing with files specified
on the command line that didn't exist.
1999-12-10 07:40:08 +00:00
Eric Andersen 21818c8a80 Make sure the world knows who "beppu" is.
-Erik
1999-12-10 06:48:10 +00:00
Eric Andersen 70e2f0b111 Fix beppu's email address.
BTW, John, go to sleep.  It is late. :)
 -Erik
1999-12-10 06:45:42 +00:00
John Beppu 14c82b64c9 Fleshed out du_main().
I'm not sure which options to support.
1999-12-10 06:15:27 +00:00
John Beppu 2ad2afd05c less TODO 1999-12-10 06:14:28 +00:00
John Beppu 059f152a7a Implemented tee(1). 1999-12-10 05:27:16 +00:00
John Beppu 29fcc90f3e minor changelog update 1999-12-09 23:33:04 +00:00
Eric Andersen 6805d5d69e Adjustments for Johns init stuff,
-Erik
1999-12-09 22:39:55 +00:00
John Beppu f95ca97d1b findInitPid() has been implemented and it seems to work.
reboot has been changed to take advantage of findInitPid();
1999-12-09 22:10:18 +00:00
John Beppu 395b216a2e du is done 1999-12-09 18:37:56 +00:00
John Beppu 7a98606d85 Modified to include du 1999-12-09 18:29:29 +00:00
John Beppu 0f5e1ab949 This is my preliminary
du implementation.  It
    was written from scratch
    (doesn't use recursiveAction).
    I still need to flesh out
    du_main().
1999-12-09 18:23:54 +00:00
Eric Andersen f0758dd6ba * Fixed rebooting from init. I'd left some debugging code in
which blocked reboots.  Oops.
 -Erik
1999-12-09 07:57:58 +00:00
Eric Andersen 1792f8c489 Tail now works (costs 6k). Several other updates.
-Erik
1999-12-09 06:11:36 +00:00
Eric Andersen c24db7b591 Added an empty line for no reason.
-Erik
1999-12-09 01:29:12 +00:00
Eric Andersen 8cd6a1f9a2 Fixed spelling error
-Erik
1999-12-09 01:26:38 +00:00
Eric Andersen 48091fb3d3 * my_getid was leaking file descriptors, causing 'ls -l' on long
directories to fail
 -Erik
1999-12-09 01:15:52 +00:00
Eric Andersen abc0f4f8f9 Latest and greatest 1999-12-08 23:19:36 +00:00
Eric Andersen 2285f367e2 Stuf 1999-12-08 04:23:30 +00:00
Eric Andersen fcdb57a0fc Fixes 1999-12-08 04:13:59 +00:00
Eric Andersen d29edf34d6 Stuf 1999-12-08 04:13:44 +00:00
Eric Andersen 485b9550fd Stuf 1999-12-07 23:14:59 +00:00
Eric Andersen d00c262847 Stuf 1999-12-07 08:37:31 +00:00
Eric Andersen 0ecb54a0f3 Stuf 1999-12-05 23:24:55 +00:00
Eric Andersen 14ec6cf3c2 syslogd and klogd work now.
-Erik
1999-12-05 22:17:02 +00:00
Eric Andersen de1d61268e Fixes 1999-12-03 15:14:25 +00:00
Eric Andersen b186d980d6 Stuf 1999-12-03 09:19:54 +00:00
Eric Andersen 77619b9dda Sqtuf 1999-11-29 04:31:50 +00:00
Eric Andersen bb58702833 Fix up changelog 1999-11-29 04:30:12 +00:00
Eric Andersen 03018f7551 Fixed tar so uid/gud/permissions on extracted tarballs will be correct.
-Erik
1999-11-29 04:29:13 +00:00
Eric Andersen 1667fb4b63 Fixes 1999-11-27 20:34:28 +00:00
Eric Andersen c054b21f7d Stuf 1999-11-27 17:41:29 +00:00
Eric Andersen 4c78147755 Changes 1999-11-26 08:12:56 +00:00
Eric Andersen ec33d45e89 Stuf 1999-11-26 01:51:02 +00:00
Eric Andersen befda6e4ed Stuf 1999-11-25 08:06:22 +00:00
Eric Andersen 3843e96252 Stuf 1999-11-25 07:30:46 +00:00
Eric Andersen b99df0fd65 First draft 1999-11-24 09:04:33 +00:00
Eric Andersen 394f764e7d Stuf 1999-11-23 21:38:12 +00:00
Eric Andersen cb41c2e83b Bug fixes 1999-11-22 07:41:00 +00:00
Eric Andersen 5d44d1fda5 Stuf 1999-11-22 06:01:01 +00:00
Eric Andersen 0f4c0848c7 Fix bugs 1999-11-22 05:57:09 +00:00
Eric Andersen 0727458a97 Stuf 1999-11-21 21:50:07 +00:00
Eric Andersen fa213cd71e Latest n greatest 1999-11-19 06:24:35 +00:00
Eric Andersen e1850ddde4 Stuf 1999-11-19 05:42:32 +00:00
Eric Andersen 6a76e652aa Stuf 1999-11-19 05:31:45 +00:00
Eric Andersen 08b1034f4f Stuf 1999-11-19 02:38:58 +00:00
Eric Andersen ab746abfc0 Stuf 1999-11-18 20:33:45 +00:00
Eric Andersen 1c43d0c5af Stuff 1999-11-18 07:58:07 +00:00
Eric Andersen b052b47722 Forgot this. 1999-11-18 00:21:59 +00:00
Eric Andersen ded6259f62 Latest and greatest 1999-11-18 00:19:26 +00:00
Eric Andersen d80e851dc0 Stuf 1999-11-16 00:46:00 +00:00
Eric Andersen a9c95ea655 Updates 1999-11-15 17:33:30 +00:00
Eric Andersen 80974fad03 Fix makefile 1999-11-13 04:51:47 +00:00
Eric Andersen b6a44b8d39 updates for the day 1999-11-13 04:47:09 +00:00
Eric Andersen eded54bd96 Adjust install a bit... 1999-11-12 08:03:23 +00:00
Eric Andersen 96bcfd346b Latest and greatest
-Erik
1999-11-12 01:30:18 +00:00
Eric Andersen 0dfac6b9ce Stuff 1999-11-11 05:46:32 +00:00
Eric Andersen c296b54827 Stuf 1999-11-11 01:36:55 +00:00
Eric Andersen d73dc5b073 Updates to usage, and made tar work.
-Erik
1999-11-10 23:13:02 +00:00
Eric Andersen 84d8568071 spelling fixes 1999-11-10 20:17:47 +00:00
Eric Andersen 5556c1874b Maybe works now...
-Erik
1999-11-10 19:27:58 +00:00
Eric Andersen 3e2bb288da Stuf 1999-11-09 03:12:29 +00:00
Eric Andersen add0158554 LAtest and greatest 1999-11-09 03:10:26 +00:00
Eric Andersen 3d8dbe1ca0 Stuf 1999-11-09 01:51:02 +00:00
Eric Andersen 50d6360771 Stuff 1999-11-09 01:47:36 +00:00
Eric Andersen fbb39c83b6 Stuff
-Erik
1999-11-08 17:00:52 +00:00
Eric Andersen 07e5297ca7 init and ls -l fixes 1999-11-07 07:38:08 +00:00
Eric Andersen dc6301e7ca Stuf 1999-11-06 07:34:50 +00:00
Eric Andersen 350577c5a0 Minor stuf 1999-11-06 06:34:20 +00:00
Eric Andersen 29d2e362de Fixed ln, df, and removed redundant stuff from mtab. 1999-11-06 06:07:27 +00:00
Eric Andersen bc34190694 Forgot this file... 1999-11-06 04:56:00 +00:00
Eric Andersen f14937d177 Update 1999-11-06 03:02:42 +00:00
Eric Andersen e18c75a563 Fixed init so it won't hang on reboot... 1999-11-05 04:23:05 +00:00
Eric Andersen 9997685953 Changelog fix 1999-11-05 01:21:49 +00:00
Eric Andersen cf8c9cf7b9 More stuff -- ready for release.
-Erik
1999-11-05 00:31:46 +00:00
Eric Andersen d0246fb72b More stuff. 1999-11-04 21:18:07 +00:00
Eric Andersen 3ae0c78962 Stuf 1999-11-04 01:13:21 +00:00
Eric Andersen be971d6b69 More init fixes. Fixed sync segfault.
-Erik
1999-11-03 16:52:50 +00:00
Eric Andersen 219d6f5e0c Stuf 1999-11-02 19:43:01 +00:00
Eric Andersen 2f6c04f63c Ha! Got init working.
-Erik
1999-11-01 23:59:44 +00:00
Eric Andersen ff719d663e Stuf 1999-10-29 23:36:31 +00:00
Eric Andersen 04579780b7 Fixed it. 1999-10-29 23:12:50 +00:00
Eric Andersen 7f1acfdb89 More stuf. sed works. 1999-10-29 23:09:13 +00:00
Eric Andersen 24d8e7d787 Stuf 1999-10-29 06:50:17 +00:00
Eric Andersen c1525e84dd Stuff 1999-10-29 00:07:31 +00:00
Eric Andersen 6b6b3f6ef2 Stuf 1999-10-28 16:06:25 +00:00
Eric Andersen c7c41d306b Cleanup of init 1999-10-28 00:24:35 +00:00
Eric Andersen a745606df3 Stuf 1999-10-27 02:31:32 +00:00
Eric Andersen c8fdb56389 Stuf 1999-10-26 05:21:02 +00:00
Eric Andersen 8a8fbb87f7 Foo 1999-10-26 00:18:56 +00:00
Eric Andersen 0460ff2e5d Stuf 1999-10-25 23:32:44 +00:00
Eric Andersen d143e8f2bd Stuf 1999-10-23 07:09:58 +00:00
Eric Andersen a709317cea More stuff 1999-10-23 05:42:08 +00:00
Eric Andersen a07f0b0408 More stuff. 1999-10-22 19:49:09 +00:00
Eric Andersen 9922c833ca Removed cruft 1999-10-22 18:22:02 +00:00
Eric Andersen fa0540fb09 Make mkdir -m work 1999-10-22 18:18:31 +00:00
Eric Andersen 8eefd021ca Fixed version number 1999-10-22 05:18:28 +00:00
Eric Andersen 51f8c89040 Stuf 1999-10-22 05:14:44 +00:00
Eric Andersen 63a0e530bd Cosmetic adjustments. 1999-10-22 05:12:14 +00:00
Eric Andersen aa0765e11b Added regexp support, fixed Changelog. 1999-10-22 04:30:20 +00:00
Eric Andersen c49960189a Fixed up copyright notices and such 1999-10-20 22:08:37 +00:00
Eric Andersen 887991c78a Fixed 1999-10-20 20:09:47 +00:00
Eric Andersen d23f9ba0f6 Made ps work. Fixed some stuff. 1999-10-20 19:18:15 +00:00
Eric Andersen ef8b6c757d Add a trivial ps command. 1999-10-20 08:05:35 +00:00
Eric Andersen ce8f3b9933 Fixed chmod and friends. 1999-10-20 07:03:36 +00:00
Eric Andersen b9b421c186 Stuf 1999-10-19 23:41:03 +00:00
Eric Andersen b7a1a75261 *** empty log message *** 1999-10-19 23:37:14 +00:00
Eric Andersen f8d650c4e5 More stuff 1999-10-19 23:27:54 +00:00
Eric Andersen f5a3838e2f More stuff 1999-10-19 22:26:25 +00:00
Eric Andersen e674eb78e4 Made em work. 1999-10-19 20:52:57 +00:00
Eric Andersen e494fdd2c7 More stuff 1999-10-19 20:23:03 +00:00
Eric Andersen e77ae3a2c0 Added sfdisk. Ststic-ified a bunch of stuff. 1999-10-19 20:03:34 +00:00
Eric Andersen a3f09076ef More stuff 1999-10-19 16:39:10 +00:00
Eric Andersen 3e0fbae15e fixes grep, added loadfont from debian bootfloppies.
-Erik
1999-10-19 06:02:44 +00:00
Eric Andersen abc7d597cb More stuff 1999-10-19 00:27:50 +00:00
Eric Andersen b0e9a709ba More stuff.
-Erik
1999-10-18 22:28:26 +00:00
Eric Andersen 703c62da63 More stuff 1999-10-18 21:31:00 +00:00
Eric Andersen 8759006b55 More fixes 1999-10-18 21:22:59 +00:00
Eric Andersen 7f04b5e320 Fixed include 1999-10-18 20:41:33 +00:00
Eric Andersen bed30e9700 More fixes 1999-10-18 19:02:32 +00:00
Eric Andersen 9b58718889 Some fixes and such 1999-10-17 05:43:39 +00:00
Eric Andersen cb6e25655f More stuff 1999-10-16 15:48:40 +00:00
Eric Andersen 3c163822d8 Fixed cp -[aR] and some other stuf. 1999-10-14 22:16:57 +00:00
Eric Andersen 2c1030177e More stuff 1999-10-13 22:56:11 +00:00
Eric Andersen f6be944a6a More stuff 1999-10-13 21:12:06 +00:00
Eric Andersen 305a73f5ea Combined stuff 1999-10-13 19:03:24 +00:00
Eric Andersen 1b61f41f57 More stuff 1999-10-13 18:56:42 +00:00
Eric Andersen 21943ce641 More fixes 1999-10-13 18:04:51 +00:00
Eric Andersen c6cb79dedf More stuff 1999-10-13 18:01:10 +00:00
Eric Andersen 5de3065f58 Fixed dd 1999-10-13 00:53:55 +00:00
Eric Andersen 3cf52d1958 More stuff... 1999-10-12 22:26:06 +00:00
Eric Andersen 2ce1edcf54 Latest and greatest.
-Erik
1999-10-12 15:42:48 +00:00
Eric Andersen f811e07b07 More stuff. 1999-10-09 00:25:00 +00:00
Eric Andersen 8341a15653 Finally mount works properly. Made debugging work (no more -s ld flag
when debugging is on).
1999-10-08 17:14:14 +00:00
Eric Andersen 596e5469d0 more stuff 1999-10-07 08:30:23 +00:00
Eric Andersen 5c3199e0a5 Made df work 1999-10-06 22:06:29 +00:00
Eric Andersen 17d49efd8c More stuff. 1999-10-06 20:25:32 +00:00
Eric Andersen 9d3aba7b37 more stuff 1999-10-06 09:04:55 +00:00
Eric Andersen b09c6b5d4a Forgot this file. 1999-10-06 05:21:54 +00:00
Eric Andersen 4bea32abb5 latest and greatest. 1999-10-06 00:30:51 +00:00
Eric Andersen 2b69c40e80 More stuff works.
-Erik
1999-10-05 22:58:32 +00:00
Eric Andersen cc8ed39b24 Initial revision 1999-10-05 16:24:54 +00:00
1057 changed files with 72055 additions and 212216 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
busybox
busybox.links
Vendored
-33
View File
@@ -1,33 +0,0 @@
--blank-lines-after-declarations
--blank-lines-after-procedures
--break-before-boolean-operator
--no-blank-lines-after-commas
--braces-on-if-line
--braces-on-struct-decl-line
--comment-indentation25
--declaration-comment-column25
--no-comment-delimiters-on-blank-lines
--cuddle-else
--continuation-indentation4
--case-indentation0
--else-endif-column33
--space-after-cast
--line-comments-indentation0
--declaration-indentation1
--dont-format-first-column-comments
--dont-format-comments
--honour-newlines
--indent-level4
/* changed from 0 to 4 */
--parameter-indentation4
--line-length78 /* changed from 75 */
--continue-at-parentheses
--no-space-after-function-call-names
--dont-break-procedure-type
--dont-star-comments
--leave-optional-blank-lines
--dont-space-special-semicolon
--tab-size4
/* additions by Mark */
--case-brace-indentation0
--leave-preprocessor-space
+13 -131
View File
@@ -2,172 +2,54 @@ List of the authors of code contained in BusyBox.
If you have code in BusyBox, you should be listed here. If you should be
listed, or the description of what you have done needs more detail, or is
incorrect, _please_ let me know.
incorect, _please_ let me know.
-Erik
-----------
Peter Willis <psyphreak@phreaker.net>
eject
Emanuele Aina <emanuele.aina@tiscali.it>
run-parts
Erik Andersen <andersen@codepoet.org>
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.
Lots of tedious effort writing these boring docs that
nobody is going to actually read.
Laurence Anderson <l.d.anderson@warwick.ac.uk>
rpm2cpio, unzip, get_header_cpio, read_gz interface, rpm
Jeff Angielski <jeff@theptrgroup.com>
ftpput, ftpget
Enrik Berkhan <Enrik.Berkhan@inka.de>
setconsole
Jim Bauer <jfbauer@nfr.com>
modprobe shell dependency
Edward Betts <edward@debian.org>
expr, hostid, logname, whoami
John Beppu <beppu@codepoet.org>
du, nslookup, sort
David Brownell <dbrownell@users.sourceforge.net>
zcip
John Beppu <beppu@lineo.com>
du, head, nslookup, sort, tee, uniq
Brian Candler <B.Candler@pobox.com>
tiny-ls(ls)
Randolph Chung <tausq@debian.org>
fbset, ping, hostname
fbset, ping, hostname, and mkfifo
Dave Cinege <dcinege@psychosis.com>
more(v2), makedevs, dutmp, modularization, auto links file,
Dave Cinege <dcinege@psychosis.com>
more(v2), makedevs, dutmp, modularization, auto links file,
various fixes, Linux Router Project maintenance
Jordan Crouse <jordan@cosmicpenguin.net>
ipcalc
Magnus Damm <damm@opensource.se>
tftp client
insmod powerpc support
Larry Doolittle <ldoolitt@recycle.lbl.gov>
pristine source directory compilation, lots of patches and fixes.
Glenn Engel <glenne@engel.org>
httpd
Gennady Feldman <gfeldman@gena01.com>
Sysklogd (single threaded syslogd, IPC Circular buffer support,
logread), various fixes.
Robert Griebl <sandman@handhelds.org>
modprobe, hwclock, suid/sgid handling, tinylogin integration
many bugfixes and enhancements
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.cmu.edu>
documentation, bugfixes, test suite
John Lombardo <john@deltanet.com>
dirname, tr
Rob Landley <rob@landley.net>
Became busybox maintainer in 2006.
sed (major rewrite in 2003, and I now maintain the thing)
bunzip2 (complete from-scratch rewrite, then mjn3 optimized the result)
sort (more or less from scratch rewrite in 2004, I now maintain it)
mount (rewrite in 2005, I maintain the new one)
Stephan Linz <linz@li-pro.net>
ipcalc, Red Hat equivalence
John Lombardo <john@deltanet.com>
tr
Glenn McGrath <bug1@iinet.net.au>
Common unarchiving code and unarchiving applets, ifupdown, ftpgetput,
nameif, sed, patch, fold, install, uudecode.
Various bugfixes, review and apply numerous patches.
Manuel Novoa III <mjn3@codepoet.org>
cat, head, mkfifo, mknod, rmdir, sleep, tee, tty, uniq, usleep, wc, yes,
mesg, vconfig, nice, renice,
make_directory, parse_mode, dirname, mode_string,
get_last_path_component, simplify_path, and a number trivial libbb routines
also bug fixes, partial rewrites, and size optimizations in
ash, basename, cal, cmp, cp, df, du, echo, env, ln, logname, md5sum, mkdir,
mv, realpath, rm, sort, tail, touch, uname, watch, arith, human_readable,
interface, dutmp, ifconfig, route
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit; bb_mkdep, xargs(current), httpd(current);
ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute,
top;
locale, various fixes
and irreconcilable critic of everything not perfect.
Glenn McGrath <bug1@netconnect.com.au>
ar.c
Bruce Perens <bruce@pixar.com>
Original author of BusyBox in 1995, 1996. Some of his code can
still be found hiding here and there...
Rodney Radford <rradford@mindspring.com>
ipcs, ipcrm
Tim Riker <Tim@Rikers.org>
bug fixes, member of fan club
Kent Robotti <robotti@metconnect.com>
reset, tons and tons of bug reports and patches.
Chip Rosenthal <chip@unicom.com>, <crosenth@covad.com>
wget - Contributed by permission of Covad Communications
Original author of BusyBox. His code is still in many apps.
Pavel Roskin <proski@gnu.org>
Lots of bugs fixes and patches.
Gyepi Sam <gyepi@praxis-sw.com>
Remote logging feature for syslogd
Rob Sullivan <cogito.ergo.cogito@gmail.com>
comm
Linus Torvalds
Linus Torvalds <torvalds@transmeta.com>
mkswap, fsck.minix, mkfs.minix
Mark Whitley <markw@codepoet.org>
grep, sed, cut, xargs(previous),
style-guide, new-applet-HOWTO, bug fixes, etc.
Charles P. Wright <cpwright@villagenet.com>
gzip, mini-netcat(nc)
Enrique Zanardi <ezanardi@ull.es>
tarcat (since removed), loadkmap, various fixes, Debian maintenance
Tito Ragusa <farmatito@tiscali.it>
devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm,
fdformat, lsattr, chattr, id and eject.
Paul Fox <pgf@foxharp.boston.ma.us>
vi editing mode for ash, various other patches/fixes
Roberto A. Foglietta <me@roberto.foglietta.name>
port: dnsd
Bernhard Fischer <rep.nop@aon.at>
misc
Mike Frysinger <vapier@gentoo.org>
initial e2fsprogs, printenv, setarch, sum, misc
+658
View File
@@ -0,0 +1,658 @@
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_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
additional 2.5 k if you compile in command line editing). Handles
job control, has the usual set of builtins, and does everything
except for handling programming statements (if, while, etc...)
* Busybox can now work perfectly when /proc is disabled, thereby
saving a bunch of memory (kernel /proc support is not thin). This
is done by making use of some nice kernel patches I wrote up to
support the features that busybox requires and that /proc usually
provides. To enable this, turn on BB_FEATURE_USE_DEVPS_PATCH and
patch your kernel with the devps patch in the kernel-patches/
directory.
* Wrote basename, dirname, killall, and uptime.
* tar has been completely rewritten by me. Both tar creation and
extraction are now well behaved. Costs 7.6k with all optional
tar features enabled, and 5k for just tar extraction support.
* Added freeramdisk, which will free up all memory associated
with a ram disk. Contributed by Emanuele Caratti <wiz@iol.it>
and then adjusted a bit by me.
* Added tr from John Lombardo <john@deltanet.com>
* 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 <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.
* nslookup types are now changed to u_int32_t (instead of uint32_t)
changed per a patch from Pascal Bellard <pascal.bellard@ascend.com>
* Fixed "du" so it gives the same answers as GNU "du" (busybox du used
to count hard-linked files more then once). Many thanks to
Friedrich Vedder <fwv@myrtle.lahn.de> for the fix.
* Removed /proc dependancies for init and free (while maintaining
exactly the same functionality). /proc takes up 90k of kernel
space, so it is nice to avoid using it at all costs.
* init no longer tries to mount /proc (unless there is less the 1 meg
free). Use of /proc (or not) is policy that should be set up in
/etc/fstab (or in hardcoded scripts), not in init.
* Fixed rebooting when init runs as an initrd.
* Fixes and updates from Karl M. Hegbloom <karlheg@debian.org>
- update.c rewritten to look more like update-2.11
- moveed the inode hash out of du.c and into utility.c to make
it a common resource that can be used by other apps.
- cp_mv.c now checks inodes to see if a source and dest are
the same, and prints an error (instead of endlessly looping).
- 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 <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
Randolph Chung <tausq@debian.org>.
* Fixed a bug where "sed 's/foo/bar/g'" (i.e. a script w/o a "-e")
* ps now supports BB_FEATURE_AUTOWIDTH, and can adjust its width
to match the terminal (defaults to width=79 when this is off).
* ps now accepts (and ignores) all options except for "--help" (which
as would be expected displays help).
* Fixed mount'ing loop devices when the filesystem type was not
specified. It used to revert to non-loop after the first try.
* all mallocs now use xmalloc (and so are OOM error safe), and
the common error handling saves a few bytes. Thanks to
Bob Tinsley <bob@earthrise.demon.co.uk> for the patch.
* Fix "+" parsing bug in date, from "Merle F. McClelland" <mfm@cts.com>.
* Fix symlink following bug in chmod -R and friends.
* Now allows SYSV style 'chown foo:bar' in addition to 'chown foo.bar'
* Fixed a bug in the busybox globbing routine such that 'find /dir -name [i]'
no longer segfaults.
-Erik Andersen
0.42
* Fairly massive restructuring of umount.c to deal with remounting
busy devices read-only. Adds a -r option to control that; it is
optionally compiled in with BB_FEATURE_REMOUNT
* Added a bunch of functions to mtab.c to interact with the
{get,set,end}mntent interface; as it turns out, those functions do
not appear to be re-entrant, and that causes a lot of problems with
the way umount was originally written.
* Makes init send TERM and KILL (instead of HUP and KILL) on reboot
to be more consistent with sysvinit
* Changes to init.c to use the new -r option to umount. Also increased
the sleep time between the time the TERM and KILL signals are sent
- Randolph Chung
* cp.c, mv.c: removed, replaced by cp_mv.c which has been
extensively rewritten from the original cp.c.
* Fixed cp and mv so if the source and destination are a the
same directory it will print an error and continue.
* Also added a warning message to the `mv' usage string saying that
this is not GNU mv, and it will break hard links. cp also breaks
hard links.
* ln.c: implemented `-n' switch, no-deref symlinks.
* include<sys/param.h>: and use PATH_MAX everywhere. busybox: File
* name buffer overrun guards to prevent future crashes.
- Always check exit status.
- Purge all use of `creat()', replace with `open()'.
* utility.c
- recursiveAction was overriding the value of followLinks thus
ignoring it.
- isDirectory now takes a followLinks boolean, updated all callers
- copyFile had the followLinks logic reversed.
* messages.c: New file. Put common error message strings all in
one place in an attempt to shrink the binary a little.
-Karl M. Hegbloom
* changed fsck_minix.c to reduce its .bss size significantly
-beppu -piptigger
* Made tar creation support in busybox tar optional. You no longer
* _have_ to put a "-" in front of tar options. Tar could inadvertently
* change permissions and ownership on
certain directories pointed to by symlinks.
* Made grep and grep -h do the right thing wrt printing
the file name (it failed to print files names in many cases).
* Fix a namespace aliasing problem wereby if du was built in, the
symlink for both du and dutmp would be installed, or then rm was
built in, the symlinks for both rm and rmmod would be installed.
* Added a closelog() to init.c after loging -- fix thanks to
Taketoshi Sano <kgh12351@nifty.ne.jp>
* Rewrote and simplified logger. Added the "-t" option, and made it
behave itself a bit better.
* Optional support contributed by Ben Collins <bcollins@debian.org>
for the kernel init chroot patch by Werner Almesberger, which
allows init to chroot to a new device, and umount the old one.
* Fixed bug that wouldn't let one chown a symlink -- it would
always dereference before. -beppu
* Fixed a bug where init could have reference already freed memory.
Found and fixed by Taketoshi Sano <kgh12351@nifty.ne.jp>
* Several contributions from Friedrich Vedder <fwv@myrtle.lahn.de>
* Added (and documented) "-n" option for head
* Cleanup for a number of usage messages -- also
contributed Friedrich Vedder <fwv@myrtle.lahn.de>
* Cosmetic fix to busybox.c (Don't print a comma at the
end of line if there are no more application names).
* Fixed a stupid bug in "head" option handling ("head -n"
would segfault).
* Moved commonly used functions "xmalloc()" and "exit()"
to utility.c (with proper #ifdef's).
* Created a tiny tail implementation, removing -c, -q, -v, and making
tail -f work only with a single file. This reduced tail from 6k to
2.4k. The bigger/more featured tail can still be had by disabling
BB_FEATURE_SIMPLE_TAIL in busybox.defs.h
* Ping now falls back to doing the right thing if /etc/protocols
turns up missing.
* Fixed mount and umount. Previously they could leak loop device
allocations, causing the system to quickly run out. Fix for umount
by Ben Collins <bcollins@debian.org>, and mount was fixed by me.
* ls formatting on eight charactor user names fixed by
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 <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
- added "skip" and "seek" to dd.
- ls no longer messus up output when combining files and
directories on the command line
* swapoff -a was not working. Now it is.
* init did not cleanly unmount filesystems on reboot. Now it does.
* "sed -ne s/foo/bar/" worked but "sed -n -e s/foo/bar/" didn't.
Now both work.
* Some architectures (PowerPc) assume chars are unsigned, so they could
not distinguish between EOF and '\0xFF' in sed. Sed now uses ints.
* Began converting error handling to use some common routines
in utility.c
* syslogd now has better message handling and ignores SIGHUP.
* install.sh had a bug preventing installation to the specified
target directory. Fix from Gilbert Coville <gilbert@mvista.com>
* You can now spefify alternative strip commands -- change
also from Gilbert Coville.
-Erik Andersen
0.41
* New Apps: wc, hostid, logname, tty, whoami, yes -- all contributed
by Edward Betts <edward@debian.org>
* Fixed a bug in both cp and mv preventing 'cp foo/README bar'
type commands (file in a directory to another directory) from
working.
* Fixed a logger bug that caused garbage to be written to the syslog
(unless you used busybox syslog, which hid the bug). Thanks to
Alex Holden <alex@linuxhacker.org> for the fix.
* /bin/true and /bin/false were echoing a blank line when run.
Now fixed.
* mkdir -p would print an error when asked to mkdir an existing dir
with no interveining subdirectories.
* Fixed "syslogd -O" so that it works. Added -o loop option for mount,
* and support in umount for loop
devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins
<bcollins@debian.org>
* Several fixes from Marco Pantaleoni <panta@prosa.it> compile in
* fullWrite() not only if BB_TAR is defined, but also
if BB_CP or BB_MV are (fullWrite() is referenced by copyFile())
* add some compiler optimizations to further reduce executable size
(as a side note, on my machines the largest code is generated
by gcc 2.95.2 with -Os ! The smallest by plain gcc 2.7.2.3 with
-O2 -m386 ...)
* Compile now won't fail if busybox.def.h defines
BB_FEATURE_LINUXRC but not BB_INIT. (init_main used to be
referenced, but not compiled)
* Fixed a bug in setting TERM for serial console support. TERM now
defaults to "ansi" for serial consoles.
* Fixed a bug in handling the CONSOLE env. variable for serial
* consoles.
-Erik Andersen, Jan 15, 2000
0.40
* New Apps: sort, uniq. -beppu New Apps: lsmod, rmmod -erik New Apps:
* fbset contributed by Randolph Chung <tausq@debian.org>. New App::
* loadacm contributed by Peter Novodvorsky <petya@logic.ru>
for loading application character maps for Unicode fonts.
* Major init re-work. init now supports inittab (slightly different
but similar to sysvinit), allowing me to get all the policy out of
init and into the conf file. It works just fine without inittab
being present, but if you dont like the defautl behavior you can
now do something about it. Init is much cleaner as a result.
* Fixed an bug in syslogd causing it to stop after 20 minutes. -erik
* Fixed an embarrasing segfault in head -beppu Fixed the embarrasing
* failure of 'logger -p'. -erik Added the -s option to du -beppu
* Re-worked the source tree a bit so it will compile under glibc 2.0.7
with the 2.0.x Linux kernel.
* Added 'grep -q' thanks to a patch from "Konstantin Boldyshev"
<konst@voshod.com>.
* Grep -i previously failed on UPPER CASE patterns due to a silly
regexp implementation bug that is now fixed.
* Fixed a bug where tar would set, and then clear SGID and SUID bits.
* Fixed a bug where tar would not set the user and group on device
special files.
* Fixed a bug where tar would not restore the time to files. Fixed a
* major security problem with tar -- it changed ownership
of any file pointed to by a symlink to 777 (like say libc....)
Ouch!!!
* cp and mv were very broken when moving directories. I have rewritten
them so they should now work as expected.
* sed now supports addresses (numeric or regexp, with negation) and
has an append command, thanks to Marco Pantaleoni <panta@prosa.it>
* Fixed dmesg. It wasn't parsing its options (-n or -s) properly.
* Some cosmetic fixes to ls output formatting to make it behave more
like GNU ls.
* Fixed a stupid segfault in kill. Several fixes from Friedrich Vedder
* <fwv@myrtle.lahn.de>:
- Added gunzip -t, removed gunzip.c dead code,
- fixed several typos
- Glibc 2.0.7 and libc5 compile fixes
* Fixed a bug where 'mknod --help' would segfault.
-Erik Andersen, Jan 07, 2000
0.39
* New Apps: ping, hostname, and mkfifo contributed by Randolph Chung
<tausq@debian.org>. 3 items off the TODO list!
* I wrote free (just calls "cat /proc/meminfo"). Added tail, based on
* tail from GNU textutils-1.19, but adjusted
to suit my evil purposes. Costs 6k. I'll make it smaller
sometime.
* on reboot, init called 'umount -a -n', which caused errors
when BB_MTAB was not enabled. Changed to 'umount -a', which does
the right thing.
* init will now try to run /sbin/getty if it is present (for easy
integration with the about-to-be-released tinylogin.)
* kill now behaves itself properly, added 'kill -l' to list signals 'ls
* -l' was failing on long directories, since my_getid was leaking
one file descriptor per file. Oops.
* Fixed rebooting from init. I'd accidently left some debugging code
* in
which blocked reboots.
* Fixed reboot, halt (and added poweroff) such that they handle it when
init is not at PID 1 (like when running in an initrd).
* Added a prelinary du implementation. Some parameter parsing
stuff still needs to be added. -beppu (John Beppu
<beppu@lineo.com>)
* Implemented tee. -beppu Implemented head. -beppu
-Erik Andersen, Dec 10, 1999
0.38
* Fixed a segfault in 'umount -a' when a badly formed /etc/fstab
file existed.
* df will not exit on error, but will stat all mounted filesystems.
* Fixed tar so uid/gid/permissions on extracted tarballs will be
correct.
* Fixed find -name so it properly uses shell wildcard patterns
(i.e. `*', `?', and `[]') instead of regular expressions, which
was causing some confusing and unexpected behavior.
* Added klogd to syslogd, so now the log will contain both system and
kernel messages.
* syslogd now creates the /dev/log socket to make sure it is there, and
is actually a socket with the right permissions.
* I've taken a first step to making busybox not need the /proc
filesystem. Most apps don't need it. Those that _require_ it,
will complain if you enable them when you disable
BB_FEATURE_USE_PROCFS.
-Erik Andersen, Dec 5, 1999
0.37
* Wrote a micro syslogd, and a logger util (to log things to the syslog
from the command line or scripts) With both compiled in, costs 4k.
* Fixed 'make install' so symlinks are installed in their proper
* locations. Changed the build system slightly so that features can
* now be enabled
or disabled from the busybox.defs.h header file, without trying to
compile in a source file named after that featue (unless that file
exists).
* Several options are now moved into busybox.defs.h Now 'rm -R' and 'rm
* -r' both work. dd now properly handles input beyond 1 block from
* stdin. Fixed a bug where tar unpacked everything a directories.
* Moved some code
from createPath into mkdir where it belonged, thereby making tar
work properly.
* Fixed an off-by-one bug in cat. Given a list of file it wouldn't cat
* out the
last file in the list.
* Fixed 'ls -ln' so numeric group/uid are presented properly, and fixed
* 'ls -l'
so when uid/gid is not in /etc/{passwd,group} the numeric group/uid
are presented properly.
* Also added a TODO.
-Erik Andersen, Nov 25, 1999
0.36
* fixed dd so it properly defaults to stdin and stdout when no
if= and of= are set (fix thanks to Eric Delaunay).
* Don't try to close the file descriptor of a pipein tar. (fix also
* from
Eric Delaunay).
* Made createPath be quiet (again thanks to Eric Delaunay). If
* BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
command you define it as will be run if the init script exits.
* Updated install.sh to make it more robust (thanks to Adam Di Carlo)
* NFS support added to mount by Eric Delaunay. It costs 10k when
* compiled
in, but that is still a big win for those that use NFS.
* Made 'rm -f' be silent for non-existant files (thanks to Eric
* Delaunay). changed zcat.c to gunzip.c. It now obeys the principle
* of least surprise
and acts as god intended gunzip and zcat to act. They answer
--help and obey the '-c' flag.
* Fixed a bug in mv which caused it to not move files when the
* destination
was a directory.
* Fixed a decimal-instead-of-octal bug causing mkdir to make
* directories
with very wrong permissions.
* chmod would overwrite file permissions instead of modifying them.
Now it properly modifies permissions.
* Init now sends warnings destined for the console to /dev/console to
* ensure
they show up on whatever the active console it. Otherwise
important messages (for example that the system is rebooting) were
not seen when switched to a different VT.
-Erik Andersen, Nov 17, 1999
0.35
* gzip now obeys the principle of least surprise and acts like god
* intended
(i.e. it accepts a file name, answers --help, and obeys the '-c'
flag and only then outputs to stdout).
* Fixed more.c to compile autowidth on sparc and set initial winsize
to 0,0 in case the TIOCGWINSZ ioctl fails. Fix thanks to Eric
Delaunay.
* Fixed tar so it now works as expected (it had TRUE/FALSE backwards)
* tar now accepts --help chmod, chown, and chgrp usage now works
* General usage (i.e. --help) cleanups for most apps umount now parses
* options correctly tar can now unpack tarballs containing device
* special files,
sockets, and fifos (though it can't pack them up) thanks to Matt
Porter. Creating archives containing these is still left to the
interested student.
* fixed up the license in more.c to properly point to Bruce Perens.
-Erik Andersen, Nov 11, 1999
0.34
* ls -l now displays link names outside the current directory,
Patch thanks to Eric Delaunay
* init now properly handles sparc serial consoles and does a
better job of finding the real console device rather than using
/dev/console which doesn't support job control. Patch also thanks
to Eric Delaunay.
* more started to read from stdin after the last file was finished, and
options were not parsed correctly (fix thanks to Eric Delaunay).
* more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on.
* rm wouldn't remove a symlink unless the symlink was valid. This was
a side effect of the busybox 0.32 recursiveAction() fix. Things
should now work correctly.
* grep wouldn't grep stdin. Now it does. sed wouldn't sed stdin. Now
* it does. sed was appending a \n to the end of lines with
* replacements.
Now it doesn't do that.
* ls -l now bypasses libc6 nss when displaying user/group names.
Now uses my_getpwuid and my_getgrgid.
-Erik Andersen, Nov 8, 1999
0.33
* Fixed a bug where init could hang instead of rebooting.
* Removed some debugging noise from init.c
* Fixed ln so it works now (it was very broken).
* Fixed df so it won't segfault when there is no /etc/fstab,
* If BB_MTAB is not defined, df and mount will whine if /etc/fstab
is not installed (since they cannot fixup "/dev/root" to
state the real root device name)
* merged some redundant code from mtab.c/df.c into utility.c
-Erik Andersen, Nov 5, 1999
0.32
* More changes -- many thanks to Lineo for paying me to work on
busybox. If you have any problems please let me know ASAP at
andersen@lineo.com or andersee@debian.org
* usage() now prints the BusyBox version. This will help folks
realize that they are not in Kansas anymore.
* Fixed mkdir -m option so that it works. kill segfaulted w/o any
* arguments. Now it doesn't do that. kill wasn't properly accepting
* signal names. It does now. Added new apps chvt and deallocvt (I
* should probably add open) Major rewrite of init.c. Code is now
* readable by mere mortals IMHO. Wrote sed -- weighs only 1.8k (5.8k
* with full regular expressions!). Fixed a stupid seg-fault in sync
* Fixed mount -- mount -a failed to parse and apply mount options Fixed
* umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>)
* umount -a no longer umounts /proc Added BB_MTAB, allowing (at the
* cost of ~1.5k and the need for a rw /etc)
folks to use a real /etc/mtab file instead of a symlink to
/proc/mounts. mount, and umount will add/remove entries and df
will now use /etc/mtab if BB_MTAB is defined.
* Fixed a nice bug in recursiveAction() which caused it to infinitely
hunt through /proc/../fd/* creating new file descriptors if it
followed the /dev/fd link over to /proc. recursiveAction() now
lstat's the file when followLinks==FALSE so it won't follow links
as the name suggests. Fix thanks to Matt Porter
<porter@debian.org>.
-Erik Andersen, Nov 4, 1999
0.31
* I added a changelog for version 0.30. adjusted find internals to
* make it smaller, and removed
some redundancy.
* Fixed a segfault in ps when /etc/passwd or /etc/group
are absent. Now will warn you and carry on.
* Added in optional _real_ regular expression support (to be
the basis for a future sed utility). When compiled in it adds
3.9k, but makes grep much more capable.
* Checked out using nftw(3) for recursive stuff, but unfortunatly
it wasn't supported before GNU libc 2.1, and some folks use glibc
2.0.7 since it is much smaller than that latest and greatest.
-Erik Andersen, Oct 21, 1999
0.30
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
paying me to make these updates. If you have any problems with busybox,
or notice any bugs -- please let me know so I can fix it. These
changes include:
Core Changes:
* busybox can now invoke apps in two ways: via symlinks to the
busybox binary, and as 'busybox [function] [arguments]...'
* When invoked as busybox, the list of currently compiled in
functions is printed out (no this is not bloat -- the list has
to be there anyway to map invocation name to function).
* busybox no longer parses command lines for apps or displays their
usage info. Each app gets to handle (or not handle) this for
itself.
* Eliminated monadic, dyadic, descend, block_device, and
postprocess. It was cumbersome to have so many programs
cobbled together in this way. Without them, the app is much
more granular.
* All shared code now lives in utility.c, and is properly
ifdef'ed to be only included for those apps requiring it.
* Eliminated struct FileInfo (the basis of monadic, dyadic, etc)
so now each app has the function prototype of (da-dum): extern
int foo_main(int argc, char** argv); which speeds integration
of new apps.
* Adjusted the Makefile to make it easier to
{en|dis}able debugging.
* Changed default compiler optimization to -Os
(optimize for smaller binaries).
App Changes:
* To cope with the new app function prototype and the removal of
monadic, dyadic, etc, the following apps were re-written:
* cat - Works same as always. chgrp, chmod, chown -
* rewrite. Combined into a single
source file. Absorbed patches from Enrique Zanardi
<ezanard@debian.org> that removes the dependency on
libc6 libnss* libraries.
* cp - Can now do 'cp -a' can can copy devices,
pipes, symlinks, as well as recursive or non-recursive
dir copies.
* fdflush - adjusted to remove dependancy on struct
* FileInfo. find - Now includes some basic regexp matching
which will be the basic of a future mini-sed.
* ln - Same functionality. mkdir - Added -p flag to
* feature set. mv - rewrite. rm - Added -f flag to
* feature set. rmdir - Same functionality. swapon,
* swapoff - Combined into a single binary. No longer
uses /etc/swaps. swap{on|off} -a uses /etc/fstab
instead.
* touch - Same functionality. date - adjusted with a patch
* from Matthew Grant <grantma@anathoth.gen.nz>
to accomodate glibc timezone support. I then ripped out GNU
getopt.
* mkswap -- new version merged from util-linux. Can now make
>128Meg swaps.
* Replaced the old and star, unstar, and tarcat with the tar
implementation from sash. Now tar behaves as god intended it
to (i.e. tar -xvf <file> and tar -cf <file> <dir> work).
* dd -- rewritten. Can with with files, stdin, stdout. Added the
* following new apps: loadfont -- added from debian boot floppies
* chroot -- added based on a patch from Paolo Molaro
* <lupus@lettere.unipd.it> grep -- I just wrote it. Only matches
* simple strings ps -- I just wrote it. Has _no_ options at all,
* but works. fsck_minix, mkfs_minix -- added from util-linux, but
* I ripped out
internationalization and such to make them smaller.
* sfdisk -- Added from util-linux (minus
* internationalization and such). Probably some other
* changes that I forgot to document...
-Erik Andersen, Oct 20, 1999
0.29
This version was a messy pre-alpha. stay away or it will bite you.
-Erik Andersen, Sep 24, 1999
0.28
mini-netcat (mnc) rewritten.
0.27
Mount now supports -a, and -t auto.
Mount now updates mtab correctly for 'ro'.
More checks screen rows size, outputs bytes percentage.
Printf added as module.
0.26
Touch now creates files. -c option for no create.
-479
View File
@@ -1,479 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
mainmenu "BusyBox Configuration"
config HAVE_DOT_CONFIG
bool
default y
menu "Busybox Settings"
menu "General Configuration"
config NITPICK
bool "See lots more (probably unnecessary) configuration options."
default n
help
Some BusyBox applets have more configuration options than anyone
will ever care about. To avoid drowining people in complexity, most
of the applet features that can be set to a sane default value are
hidden, unless you hit the above switch.
This is better than to telling people to edit the busybox source
code, but not by much.
See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet
You have been warned.
config DESKTOP
bool "Enable options for full-blown desktop systems"
default n
help
Enable options and features which are not essential.
Select this only if you plan to use busybox on full-blown
desktop machine with common Linux distro, not on an embedded box.
choice
prompt "Buffer allocation policy"
default FEATURE_BUFFERS_USE_MALLOC
depends on NITPICK
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
- Put them on stack. For some very small machines with limited stack
space, this can be deadly. For most folks, this works just fine.
- Put them in BSS. This works beautifully for computers with a real
MMU (and OS support), but wastes runtime RAM for uCLinux. This
behavior was the only one available for BusyBox versions 0.48 and
earlier.
config FEATURE_BUFFERS_USE_MALLOC
bool "Allocate with Malloc"
config FEATURE_BUFFERS_GO_ON_STACK
bool "Allocate on the Stack"
config FEATURE_BUFFERS_GO_IN_BSS
bool "Allocate in the .bss section"
endchoice
config SHOW_USAGE
bool "Show terse applet usage messages"
default y
help
All BusyBox applets will show help messages when invoked with
wrong arguments. You can turn off printing these terse usage
messages if you say no here.
This will save you up to 7k.
config FEATURE_VERBOSE_USAGE
bool "Show verbose applet usage messages"
default n
select SHOW_USAGE
help
All BusyBox applets will show more verbose help messages when
busybox is invoked with --help. This will add a lot of text to the
busybox binary. In the default configuration, this will add about
13k, but it can add much more depending on your configuration.
config FEATURE_COMPRESS_USAGE
bool "Store applet usage messages in compressed form"
default y
depends on SHOW_USAGE
help
Store usage messages in compressed form, uncompress them on-the-fly
when <applet> --help is called.
If you have a really tiny busybox with few applets enabled (and
bunzip2 isn't one of them), the overhead of the decompressor might
be noticeable. Also, if you run executables directly from ROM
and have very little memory, this might not be a win. Otherwise,
you probably want this.
config FEATURE_INSTALLER
bool "Support --install [-s] to install applet links at runtime"
default n
help
Enable 'busybox --install [-s]' support. This will allow you to use
busybox at runtime to create hard links or symlinks for all the
applets that are compiled into busybox. This feature requires the
/proc filesystem.
config LOCALE_SUPPORT
bool "Enable locale support (system needs locale for this to work)"
default n
help
Enable this if your system has locale support and you would like
busybox to support locale settings.
config GETOPT_LONG
bool "Enable support for --long-options"
default y
help
Enable this if you want busybox applets to use the gnu --long-option
style, in addition to single character -a -b -c style options.
config FEATURE_DEVPTS
bool "Use the devpts filesystem for Unix98 PTYs"
default y
help
Enable if you want BusyBox to use Unix98 PTY support. If enabled,
busybox will use /dev/ptmx for the master side of the pseudoterminal
and /dev/pts/<number> for the slave side. Otherwise, BSD style
/dev/ttyp<number> will be used. To use this option, you should have
devpts mounted.
config FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
depends on NITPICK
help
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
space since the OS will clean up for us, but it can confuse debuggers
like valgrind, which report tons of memory and resource leaks.
Don't enable this unless you have a really good reason to clean
things up manually.
config FEATURE_SUID
bool "Support for SUID/SGID handling"
default n
help
With this option you can install the busybox binary belonging
to root with the suid bit set, and it'll and it'll automatically drop
priviledges for applets that don't need root access.
If you're really paranoid and don't want to do this, build two
busybox binaries with different applets in them (and the appropriate
symlinks pointing to each binary), and only set the suid bit on the
one that needs it. The applets currently marked to need the suid bit
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
and vlock.
config FEATURE_SYSLOG
bool "Support for syslog"
default n
help
This option is auto-selected when you select any applet which may
send its output to syslog. You do not need to select it manually.
config FEATURE_SUID_CONFIG
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
default n if FEATURE_SUID
depends on FEATURE_SUID
help
Allow the SUID / SGID state of an applet to be determined at runtime
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
The format of this file is as follows:
<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)
An example might help:
[SUID]
su = ssx root.0 # applet su can be run by anyone and runs with euid=0/egid=0
su = ssx # exactly the same
mount = sx- root.disk # applet mount can be run by root and members of group disk
# and runs with euid=0
cp = --- # disable applet cp for everyone
The file has to be owned by user root, group root and has to be
writeable only by root:
(chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
The busybox executable has to be owned by user root, group
root and has to be setuid root for this to work:
(chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
Robert 'sandman' Griebl has more information here:
<url: http://www.softforge.de/bb/suid.html >.
config FEATURE_SUID_CONFIG_QUIET
bool "Suppress warning message if /etc/busybox.conf is not readable"
default y
depends on FEATURE_SUID_CONFIG
help
/etc/busybox.conf should be readable by the user needing the SUID, check
this option to avoid users to be notified about missing permissions.
config FEATURE_HAVE_RPC
bool "RPC support"
default y
help
Select this if you have rpc support.
This automatically turns off all configuration options that rely
on RPC.
config SELINUX
bool "Support NSA Security Enhanced Linux"
default n
help
Enable support for SELinux in applets ls, ps, and id. Also provide
the option of compiling in SELinux applets.
If you do not have a complete SELinux userland installed, this stuff
will not compile. Go visit
http://www.nsa.gov/selinux/index.html
to download the necessary stuff to allow busybox to compile with
this option enabled. Specifially, libselinux 1.28 or better is
directly required by busybox. If the installation is located in a
non-standard directory, provide it by invoking make as follows:
CFLAGS=-I<libselinux-include-path> \
LDFLAGS=-L<libselinux-lib-path> \
make
Most people will leave this set to 'N'.
config BUSYBOX_EXEC_PATH
string "Path to BusyBox executable"
default "/proc/self/exe"
help
When Busybox applets need to run other busybox applets, BusyBox
sometimes needs to exec() itself. When the /proc filesystem is
mounted, /proc/self/exe always points to the currently running
executable. If you haven't got /proc, set this to wherever you
want to run BusyBox from.
endmenu
menu 'Build Options'
config STATIC
bool "Build BusyBox as a static binary (no shared libs)"
default n
help
If you want to build a static BusyBox binary, which does not
use or require any shared libraries, then enable this option.
This can cause BusyBox to be considerably larger, so you should
leave this option false unless you have a good reason (i.e.
your target platform does not support shared libraries, or
you are building an initrd which doesn't need anything but
BusyBox, etc).
Most people will leave this set to 'N'.
config BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
help
Build a shared library libbusybox.so which contains all
libraries used inside busybox.
This is an experimental feature intended to support the upcoming
"make standalone" mode. Enabling it against the one big busybox
binary serves no purpose (and increases the size). You should
almost certainly say "no" to this right now.
config FEATURE_FULL_LIBBUSYBOX
bool "Feature-complete libbusybox"
default n if !FEATURE_SHARED_BUSYBOX
depends on BUILD_LIBBUSYBOX
help
Build a libbusybox with the complete feature-set, disregarding
the actually selected config.
Normally, libbusybox will only contain the features which are
used by busybox itself. If you plan to write a separate
standalone application which uses libbusybox say 'Y'.
Note: libbusybox is GPL, not LGPL, and exports no stable API that
might act as a copyright barrier. We can and will modify the
exported function set between releases (even minor version number
changes), and happily break out-of-tree features.
Say 'N' if in doubt.
config FEATURE_SHARED_BUSYBOX
bool "Use shared libbusybox for busybox"
default y if BUILD_LIBBUSYBOX
depends on !STATIC && BUILD_LIBBUSYBOX
help
Use libbusybox.so also for busybox itself.
You need to have a working dynamic linker to use this variant.
config LFS
bool "Build with Large File Support (for accessing files > 2 GB)"
default n
select FDISK_SUPPORT_LARGE_DISKS
help
If you want to build BusyBox with large file support, then enable
this option. This will have no effect if your kernel or your C
library lacks large file support for large files. Some of the
programs that can benefit from large file support include dd, gzip,
cp, mount, tar, and many others. If you want to access files larger
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
config BUILD_AT_ONCE
bool "Compile all sources at once"
default n
help
Normally each source-file is compiled with one invocation of
the compiler.
If you set this option, all sources are compiled at once.
This gives the compiler more opportunities to optimize which can
result in smaller and/or faster binaries.
Setting this option will consume alot of memory, e.g. if you
enable all applets with all features, gcc uses more than 300MB
RAM during compilation of busybox.
This option is most likely only beneficial for newer compilers
such as gcc-4.1 and above.
Say 'N' unless you know what you are doing.
endmenu
menu 'Debugging Options'
config DEBUG
bool "Build BusyBox with extra Debugging symbols"
default n
help
Say Y here if you wish to examine BusyBox internals while applets are
running. This increases the size of the binary considerably, and
should only be used when doing development. If you are doing
development and want to debug BusyBox, answer Y.
Most people should answer N.
config DEBUG_PESSIMIZE
bool "Disable compiler optimizations."
default n
depends on DEBUG
help
The compiler's optimization of source code can eliminate and reorder
code, resulting in an executable that's hard to understand when
stepping through it with a debugger. This switches it off, resulting
in a much bigger executable that more closely matches the source
code.
choice
prompt "Additional debugging library"
default NO_DEBUG_LIB
depends on DEBUG
help
Using an additional debugging library will make BusyBox become
considerable larger and will cause it to run more slowly. You
should always leave this option disabled for production use.
dmalloc support:
----------------
This enables compiling with dmalloc ( http://dmalloc.com/ )
which is an excellent public domain mem leak and malloc problem
detector. To enable dmalloc, before running busybox you will
want to properly set your environment, for example:
export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
The 'debug=' value is generated using the following command
dmalloc -p log-stats -p log-non-free -p log-bad-space -p log-elapsed-time \
-p check-fence -p check-heap -p check-lists -p check-blank \
-p check-funcs -p realloc-copy -p allow-free-null
Electric-fence support:
-----------------------
This enables compiling with Electric-fence support. Electric
fence is another very useful malloc debugging library which uses
your computer's virtual memory hardware to detect illegal memory
accesses. This support will make BusyBox be considerable larger
and run slower, so you should leave this option disabled unless
you are hunting a hard to find memory problem.
config NO_DEBUG_LIB
bool "None"
config DMALLOC
bool "Dmalloc"
config EFENCE
bool "Electric-fence"
endchoice
config DEBUG_YANK_SUSv2
bool "Disable obsolete features removed before SUSv3?"
default y
help
This option will disable backwards compatibility with SuSv2,
specifically, old-style numeric options ('command -1 <file>')
will not be supported in head, tail, and fold. (Note: should
yank from renice too.)
endmenu
menu 'Installation Options'
config INSTALL_NO_USR
bool "Don't use /usr"
default n
help
Disable use of /usr. Don't activate this option if you don't know
that you really want this behaviour.
choice
prompt "Applets links"
default INSTALL_APPLET_SYMLINKS
help
Choose how you install applets links.
config INSTALL_APPLET_SYMLINKS
bool "as soft-links"
help
Install applets as soft-links to the busybox binary. This needs some
free inodes on the filesystem, but might help with filesystem
generators that can't cope with hard-links.
config INSTALL_APPLET_HARDLINKS
bool "as hard-links"
help
Install applets as hard-links to the busybox binary. This might count
on a filesystem with few inodes.
config INSTALL_APPLET_DONT
bool
prompt "not installed"
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL
help
Do not install applets links. Usefull when using the -install feature
or a standalone shell for rescue pruposes.
endchoice
config PREFIX
string "BusyBox installation prefix"
default "./_install"
help
Define your directory to install BusyBox files/subdirs in.
endmenu
source libbb/Config.in
endmenu
comment "Applets"
source archival/Config.in
source coreutils/Config.in
source console-tools/Config.in
source debianutils/Config.in
source editors/Config.in
source findutils/Config.in
source init/Config.in
source loginutils/Config.in
source e2fsprogs/Config.in
source modutils/Config.in
source util-linux/Config.in
source miscutils/Config.in
source networking/Config.in
source procps/Config.in
source shell/Config.in
source sysklogd/Config.in
source runit/Config.in
-125
View File
@@ -1,125 +0,0 @@
Building:
=========
The BusyBox build process is similar to the Linux kernel build:
make menuconfig # This creates a file called ".config"
make # This creates the "busybox" executable
make install # or make PREFIX=/path/from/root install
The full list of configuration and install options is available by typing:
make help
Quick Start:
============
The easy way to try out BusyBox for the first time, without having to install
it, is to enable all features and then use "standalone shell" mode with a
blank command $PATH.
To enable all features, use "make defconfig", which produces the largest
general-purpose configuration. (It's allyesconfig minus debugging options,
optional packaging choices, and a few special-purpose features requiring
extra configuration to use.)
make defconfig
make
PATH= ./busybox ash
Standalone shell mode causes busybox's built-in command shell to run
any built-in busybox applets directly, without looking for external
programs by that name. Supplying an empty command path (as above) means
the only commands busybox can find are the built-in ones.
Note that the standalone shell requires CONFIG_BUSYBOX_EXEC_PATH
to be set appropriately, depending on whether or not /proc/self/exe is
available or not. If you do not have /proc, then point that config option
to the location of your busybox binary, usually /bin/busybox.
Configuring Busybox:
====================
Busybox is optimized for size, but enabling the full set of functionality
still results in a fairly large executable -- more than 1 megabyte when
statically linked. To save space, busybox can be configured with only the
set of applets needed for each environment. The minimal configuration, with
all applets disabled, produces a 4k executable. (It's useless, but very small.)
The manual configurator "make menuconfig" modifies the existing configuration.
(For systems without ncurses, try "make config" instead.) The two most
interesting starting configurations are "make allnoconfig" (to start with
everything disabled and add just what you need), and "make defconfig" (to
start with everything enabled and remove what you don't need). If menuconfig
is run without an existing configuration, make defconfig will run first to
create a known starting point.
Other starting configurations (mostly used for testing purposes) include
"make allbareconfig" (enables all applets but disables all optional features),
"make allyesconfig" (enables absolutely everything including debug features),
and "make randconfig" (produce a random configuration).
Configuring BusyBox produces a file ".config", which can be saved for future
use. Run "make oldconfig" to bring a .config file from an older version of
busybox up to date.
Installing Busybox:
===================
Busybox is a single executable that can behave like many different commands,
and BusyBox uses the name it was invoked under to determine the desired
behavior. (Try "mv busybox ls" and then "./ls -l".)
Installing busybox consists of creating symlinks (or hardlinks) to the busybox
binary for each applet enabled in busybox, and making sure these symlinks are
in the shell's command $PATH. Running "make install" creates these symlinks,
or "make install-hardlinks" creates hardlinks instead (useful on systems with
a limited number of inodes). This install process uses the file
"busybox.links" (created by make), which contains the list of enabled applets
and the path at which to install them.
Installing links to busybox is not always necessary. The special applet name
"busybox" (or with any optional suffix, such as "busybox-static") uses the
first argument to determine which applet to behave as, for example
"./busybox cat LICENSE". (Running the busybox applet with no arguments gives
a list of all enabled applets.) The standalone shell can also call busybox
applets without links to busybox under other names in the filesystem. You can
also configure a standaone install capability into the busybox base applet,
and then install such links at runtime with one of "busybox --install" (for
hardlinks) or "busybox --install -s" (for symlinks).
If you enabled the busybox shared library feature (libbusybox.so) and want
to run tests without installing, set your LD_LIBRARY_PATH accordingly when
running the executable:
LD_LIBRARY_PATH=`pwd` ./busybox
Building out-of-tree:
=====================
By default, the BusyBox build puts its temporary files in the source tree.
Building from a read-only source tree, or building multiple configurations from
the same source directory, requires the ability to put the temporary files
somewhere else.
To build out of tree, cd to an empty directory and configure busybox from there:
make -f /path/to/source/Makefile defconfig
make
make install
Alternately, use the O=$BUILDPATH option (with an absolute path) during the
configuration step, as in:
make O=/some/empty/directory allyesconfig
cd /some/empty/directory
make
make PREFIX=. install
More Information:
=================
Se also the busybox FAQ, under the questions "How can I get started using
BusyBox" and "How do I build a BusyBox-based system?" The BusyBox FAQ is
available from http://www.busybox.net/FAQ.html or as the file
docs/busybox.net/FAQ.html in this tarball.
+36 -6
View File
@@ -1,11 +1,40 @@
--- A note on GPL versions
Original release code (unless otherwise noted)
Copyright 1995, 1996 Bruce Perens <bruce@pixar.com>
mkswap
Copyright 1991 Linus Torvalds
tiny-ls(ls)
Copyright 1996 Brian Candler <B.Candler@pobox.com>
tarcat, loadkmap, various fixes, Debian maintenance
Copyright 1998 Enrique Zanardi <ezanardi@ull.es>
more(v2), makedevs, dutmp, modularization, auto links file,
various fixes, Linux Router Project maintenance
Copyright 1998 Dave Cinege <dcinege@psychosis.com>
mini-gzip(gzip), mini-netcat(mnc)
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
Tons of new stuff as noted in header files
Copyright (C) 1999 by Lineo, inc. and written by
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersee@debian.org>
Busybox may be used and distributed under the GNU General Public License.
---------------------------------------------------------------------------
BusyBox is distributed under version 2 of the General Public License (included
in its entirety, below). Version 2 is the only version of this license which
this version of BusyBox (or modified versions derived from this one) may be
distributed under.
------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
@@ -346,3 +375,4 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+133 -1269
View File
File diff suppressed because it is too large. Load diff
-145
View File
@@ -1,145 +0,0 @@
# ==========================================================================
# Build system
# ==========================================================================
%.bflt: %_unstripped
$(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h
$(Q)-$(SHELL) $^ >$@
.PHONY: install
ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
INSTALL_OPTS:= --symlinks
endif
ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
INSTALL_OPTS:= --hardlinks
endif
install: $(srctree)/applets/install.sh busybox busybox.links
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
@echo
@echo
@echo --------------------------------------------------
@echo You will probably need to make your busybox binary
@echo setuid root to ensure all configured applets will
@echo work properly.
@echo --------------------------------------------------
@echo
endif
uninstall: busybox.links
rm -f $(CONFIG_PREFIX)/bin/busybox
for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
ifneq ($(strip $(DO_INSTALL_LIBS)),n)
for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
rm -f $(CONFIG_PREFIX)$$i; \
done
endif
check test: busybox
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:1=),-v)
.PHONY: release
release: distclean
cd ..; \
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
-name .svn \
-print \
-exec rm -r -f {} \; ; \
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
-name .\#* \
-print \
-exec rm -f {} \; ; \
tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
.PHONY: checkhelp
checkhelp:
$(Q)$(srctree)/scripts/checkhelp.awk \
$(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
.PHONY: sizes
sizes: busybox_unstripped
$(NM) --size-sort $(<)
.PHONY: bloatcheck
bloatcheck: busybox_old busybox_unstripped
@$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
.PHONY: baseline
baseline: busybox_unstripped
@mv busybox_unstripped busybox_old
.PHONY: objsizes
objsizes: busybox_unstripped
$(srctree)/scripts/objsizes
.PHONY: bigdata
bigdata: busybox_unstripped
nm --size-sort busybox_unstripped | grep -vi ' [tr] ' | tail -20
# Documentation Targets
.PHONY: doc
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
$(srctree)/include/usage.h \
$(srctree)/docs/busybox_footer.pod \
$(srctree)/docs/autodocifier.pl
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-( cat $(srctree)/docs/busybox_header.pod ; \
$(srctree)/docs/autodocifier.pl $(srctree)/include/usage.h ; \
cat $(srctree)/docs/busybox_footer.pod ; ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-pod2text $< > $@
docs/BusyBox.1: docs/busybox.pod
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
$< > $@
docs/BusyBox.html: docs/busybox.net/BusyBox.html
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-rm -f docs/BusyBox.html
$(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
docs/busybox.net/BusyBox.html: docs/busybox.pod
$(Q)-mkdir -p docs/busybox.net
$(Q)-pod2html --noindex $< > \
docs/busybox.net/BusyBox.html
$(Q)-rm -f pod2htm*
# documentation, cross-reference
# Modern distributions already ship synopsis packages (e.g. debian)
# If you have an old distribution go to http://synopsis.fresco.org/
syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
syn = $(patsubst %.c, %.syn, $(syn_tgt))
comma:= ,
brace_open:= (
brace_close:= )
SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
#")
#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
%.syn: %.c
synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
.PHONY: html
html: $(syn)
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
-28
View File
@@ -1,28 +0,0 @@
# ==========================================================================
# Build system
# ==========================================================================
BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
# -std=gnu99 needed for [U]LLONG_MAX on some systems
CPPFLAGS += \
-std=gnu99 \
-Iinclude -Ilibbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
-include include/autoconf.h \
-D_GNU_SOURCE -DNDEBUG \
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
CFLAGS += \
-Wall -Wstrict-prototypes -Wshadow -Werror -Wundef \
-funsigned-char -fno-builtin-strlen -finline-limit=0 -static-libgcc \
-Os -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
-fomit-frame-pointer -ffunction-sections -fdata-sections
ifeq ($(CONFIG_DEBUG),y)
CFLAGS += -g
LDFLAGS += -g
endif
-42
View File
@@ -1,42 +0,0 @@
# ==========================================================================
# Build system
# ==========================================================================
help:
@echo 'Cleaning:'
@echo ' clean - delete temporary files created by build'
@echo ' distclean - delete all non-source files (including .config)'
@echo
@echo 'Build:'
@echo ' all - Executable and documentation'
@echo ' busybox - the swiss-army executable'
@echo ' doc - docs/BusyBox.{txt,html,1}'
@echo ' html - create html-based cross-reference'
@echo
@echo 'Configuration:'
@echo ' allnoconfig - disable all symbols in .config'
@echo ' allyesconfig - enable all symbols in .config (see defconfig)'
@echo ' allbareconfig - enable all applets without any sub-features'
@echo ' config - text based configurator (of last resort)'
@echo ' defconfig - set .config to largest generic configuration'
@echo ' menuconfig - interactive curses-based configurator'
@echo ' oldconfig - resolve any unresolved symbols in .config'
@echo ' hosttools - build sed for the host.'
@echo ' You can use these commands if the commands on the host'
@echo ' is unusable. Afterwards use it like:'
@echo ' make SED="$(objtree)/sed"'
@echo
@echo 'Installation:'
@echo ' install - install busybox into $(PREFIX)'
@echo ' uninstall'
@echo
@echo 'Development:'
@echo ' baseline - create busybox_old for bloatcheck.'
@echo ' bloatcheck - show size difference between old and new versions'
@echo ' check - run the test suite for all applets'
@echo ' checkhelp - check for missing help-entries in Config.in'
@echo ' randconfig - generate a random configuration'
@echo ' release - create a distribution tarball'
@echo ' sizes - show size of all enabled busybox symbols'
@echo ' objsizes - show size of each .o object built'
@echo
+62 -189
View File
@@ -1,198 +1,71 @@
Please see the LICENSE file for details on copying and usage.
Please refer to the INSTALL file for instructions on how to build.
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.
What is busybox:
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).
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 bzip2, coreutils, dhcp, diffutils, e2fsprogs,
file, findutils, gawk, grep, inetutils, less, modutils, net-tools, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The utilities
in BusyBox often have fewer options than their full-featured cousins;
however, the options that are included provide the expected functionality
and behave very much like their larger counterparts.
Busybox was originally written 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, both to produce small binaries and to reduce run-time memory usage.
Busybox is also extremely modular so you can easily include or exclude
commands (or features) at compile time. This makes it easy to customize
embedded systems; to create a working system, just add /dev, /etc, and a
Linux kernel. Busybox (usually together with uClibc) has also been used as
a component of "thin client" desktop systems, live-CD distributions, rescue
disks, installers, and so on.
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
BusyBox provides a fairly complete POSIX environment for any small system,
both embedded environments and more full featured systems concerned about
space. Busybox is slowly working towards implementing the full Single Unix
Specification V3 (http://www.opengroup.org/onlinepubs/009695399/), but isn't
there yet (and for size reasons will probably support at most UTF-8 for
internationalization). We are also interested in passing the Linux Test
Project (http://ltp.sourceforge.net).
----------------
Using busybox:
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersee@debian.org>
BusyBox is extremely configurable. This allows you to include only the
components and options you need, thereby reducing binary size. Run 'make
config' or 'make menuconfig' to select the functionality that you wish to
enable. (See 'make help' for more commands.)
<blatent plug>
Many thanks to go to Lineo for paying me to work on busybox.
</blatent plug>
The behavior of busybox is determined by the name it's called under: as
"cp" it behaves like cp, as "sed" it behaves like sed, and so on. Called
as "busybox" it takes the second argument as the name of the applet to
run (I.E. "./busybox ls -l /proc").
The "standalone shell" mode is an easy way to try out busybox; this is a
command shell that calls the builtin applets without needing them to be
installed in the path. (Note that this requires /proc to be mounted, if
testing from a boot floppy or in a chroot environment.)
The build automatically generates a file "busybox.links", which is used by
'make install' to create symlinks to the BusyBox binary for all compiled in
commands. This uses the PREFIX environment variable to specify where to
install, and installs hardlinks or symlinks depending on the configuration
preferences. (You can also manually run the install script at
"applets/install.sh").
----------------
Downloading the current source code:
Source for the latest released version, as well as daily snapshots, can always
be downloaded from
http://busybox.net/downloads/
You can browse the up to the minute source code and change history online.
http://www.busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/
Anonymous SVN access is available. For instructions, check out:
http://busybox.net/subversion.html
For those that are actively contributing and would like to check files in,
see:
http://busybox.net/developer.html
The developers also have a bug and patch tracking system
(http://bugs.busybox.net) although posting a bug/patch to the mailing list
is generally a faster way of getting it fixed, and the complete archive of
what happened is the subversion changelog.
----------------
getting help:
when you find you need help, you can check out the busybox mailing list
archives at http://busybox.net/lists/busybox/ or even join
the mailing list if you are interested.
----------------
bugs:
if you find bugs, please submit a detailed bug report to the busybox mailing
list at busybox@busybox.net. a well-written bug report should include a
transcript of a shell session that demonstrates the bad behavior and enables
anyone else to duplicate the bug on their own machine. the following is such
an example:
to: busybox@busybox.net
from: diligent@testing.linux.org
subject: /bin/date doesn't work
package: busybox
version: 1.00
when i execute busybox 'date' it produces unexpected results.
with gnu date i get the following output:
$ date
fri oct 8 14:19:41 mdt 2004
but when i use busybox date i get this instead:
$ date
illegal instruction
i am using debian unstable, kernel version 2.4.25-vrs2 on a netwinder,
and the latest uclibc from cvs. thanks for the wonderful program!
-diligent
note the careful description and use of examples showing not only what
busybox does, but also a counter example showing what an equivalent app
does (or pointing to the text of a relevant standard). Bug reports lacking
such detail may never be fixed... Thanks for understanding.
----------------
Portability:
Busybox is developed and tested on Linux 2.4 and 2.6 kernels, compiled
with gcc (the unit-at-a-time optimizations in version 3.4 and later are
worth upgrading to get, but older versions should work), and linked against
uClibc (0.9.27 or greater) or glibc (2.2 or greater). In such an
environment, the full set of busybox features should work, and if
anything doesn't we want to know about it so we can fix it.
There are many other environments out there, in which busybox may build
and run just fine. We just don't test them. Since busybox consists of a
large number of more or less independent applets, portability is a question
of which features work where. Some busybox applets (such as cat and rm) are
highly portable and likely to work just about anywhere, while others (such as
insmod and losetup) require recent Linux kernels with recent C libraries.
Earlier versions of Linux and glibc may or may not work, for any given
configuration. Linux 2.2 or earlier should mostly work (there's still
some support code in things like mount.c) but this is no longer regularly
tested, and inherently won't support certain features (such as long files
and --bind mounts). The same is true for glibc 2.0 and 2.1: expect a higher
testing and debugging burden using such old infrastructure. (The busybox
developers are not very interested in supporting these older versions, but
will probably accept small self-contained patches to fix simple problems.)
Some environments are not recommended. Early versions of uClibc were buggy
and missing many features: upgrade. Linking against libc5 or dietlibc is
not supported and not interesting to the busybox developers. (The first is
obsolete and has no known size or feature advantages over uClibc, the second
has known bugs that its developers have actively refused to fix.) Ancient
Linux kernels (2.0.x and earlier) are similarly uninteresting.
In theory it's possible to use Busybox under other operating systems (such as
MacOS X, Solaris, Cygwin, or the BSD Fork Du Jour). This generally involves
a different kernel and a different C library at the same time. While it
should be possible to port the majority of the code to work in one of
these environments, don't be suprised if it doesn't work out of the box. If
you're into that sort of thing, start small (selecting just a few applets)
and work your way up.
Shaun Jackman has recently (2005) ported busybox to a combination of newlib
and libgloss, and some of his patches have been integrated. This platform
may join glibc/uclibc and Linux as a supported combination with the 1.1
release, but is not supported in 1.0.
Supported hardware:
BusyBox in general will build on any architecture supported by gcc. We
support both 32 and 64 bit platforms, and both big and little endian
systems.
Under 2.4 Linux kernels, kernel module loading was implemented in a
platform-specific manner. Busybox's insmod utility has been reported to
work under ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC, S390,
SH3/4/5, Sparc, v850e, and x86_64. Anything else probably won't work.
The module loading mechanism for the 2.6 kernel is much more generic, and
we believe 2.6.x kernel module loading support should work on all
architectures supported by the kernel.
----------------
Please feed suggestions, bug reports, insults, and bribes back to the busybox
maintainer:
Denis Vlasenko
<vda.linux@googlemail.com>
+474 -294
View File
@@ -1,309 +1,489 @@
Busybox TODO
TODO list for busybox in no particular order. Just because something
is listed here doesn't mean that it is going to be added to busybox,
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.
Stuff that needs to be done. This is organized by who plans to get around to
doing it eventually, but that doesn't mean they "own" the item. If you want to
do one of these bounce an email off the person it's listed under to see if they
have any suggestions how they plan to go about it, and to minimize conflicts
between your work and theirs. But otherwise, all of these are fair game.
* 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 to libcrypt).
Rob Landley <rob@landley.net>:
Add BB_NOMMU to platform.h and migrate __uClinux__ tests to that.
#if defined __UCLIBC__ && !defined __ARCH_USE_MMU__
Add a libbb/platform.c
Implement fdprintf() for platforms that haven't got one.
Implement bb_realpath() that can handle NULL on non-glibc.
Cleanup bb_asprintf()
* Networking apps are probably going to be split out some time soon into a
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.
Migrate calloc() and bb_calloc() occurrences to bb_xzalloc().
Remove obsolete _() wrapper crud for internationalization we don't do.
Figure out where we need utf8 support, and add it.
-Erik
sh
The command shell situation is a big mess. We have three or four different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. I'm writing a new shell (bbsh) to unify the various
shells and configurably add the minimal set of bash features people
actually use. The hardest part is it has to configure down as small as
lash while providing lash's features. The rest is easy in comparison.
bzip2
Compression-side support.
init
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
depmod
busybox lacks a way to update module deps when running from firmware without the
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
modutils. The orig depmod is rather pointless to have to add to a firmware image
in when we already have a insmod/rmmod and friends.
Unify base64 handling.
There's base64 encoding and decoding going on in:
networking/wget.c:base64enc()
coreutils/uudecode.c:read_base64()
coreutils/uuencode.c:tbl_base64[]
networking/httpd.c:decodeBase64()
And probably elsewhere. That needs to be unified into libbb functions.
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
figure out which of our apps are compliant, and what we're missing that
we might actually care about.
-----------
Even better would be some kind of automated compliance test harness that
exercises each command line option and the various corner cases.
Internationalization
How much internationalization should we do?
Bugs that need fixing:
The low hanging fruit is UTF-8 character set support. We should do this.
(Vodz pointed out the shell's cmdedit as needing work here. What else?)
We also have lots of hardwired english text messages. Consolidating this
into some kind of message table not only makes translation easier, but
also allows us to consolidate redundant (or close) strings.
We probably don't want to be bloated with locale support. (Not unless we
can cleanly export it from our underlying C library without having to
concern ourselves with it directly. Perhaps a few specific things like a
config option for "date" are low hanging fruit here?)
What level should things happen at? How much do we care about
internationalizing the text console when X11 and xterms are so much better
at it? (There's some infrastructure here we don't implement: The
"unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a
--unicode option to loadkeys. That implies a real loadkeys/dumpkeys
implementation to replace loadkmap/dumpkmap. Plus messing with console font
loading. Is it worth it, or do we just say "use X"?)
Individual compilation of applets.
It would be nice if busybox had the option to compile to individual applets,
for people who want an alternate implementation less bloated than the gnu
utils (or simply with less political baggage), but without it being one big
executable.
Turning libbb into a real dll is another possibility, especially if libbb
could export some of the other library interfaces we've already more or less
got the code for (like zlib).
buildroot - Make a "dogfood" option
Busybox 1.1 will be capable of replacing most gnu packages for real world
use, such as developing software or in a live CD. It needs wider testing.
Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file,
findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting
system should be self-hosting (I.E. able to rebuild itself from source
code). This means it would need (at least) binutils, gcc, and make, or
equivalents.
It would be a good "eating our own dogfood" test if buildroot had the option
of using a "make allyesconfig" busybox instead of the all of the above
packages. Anything that's wrong with the resulting system, we can fix. (It
would be nice to be able to upgrade busybox to be able to replace bash and
diffutils as well, but we're not there yet.)
One example of an existing system that does this already is Firmware Linux:
http://www.landley.net/code/firmware
initramfs
Busybox should have a sample initramfs build script. This depends on
bbsh, mdev, and switch_root.
mkdep
Write a mkdep that doesn't segfault if there's a directory it doesn't
have permission to read, isn't based on manually editing the output of
lexx and yacc, doesn't make such a mess under include/config, etc.
Group globals into unions of structures.
Go through and turn all the global and static variables into structures,
and have all those structures be in a big union shared between processes,
so busybox uses less bss. (This is a big win on nommu machines.) See
sed.c and mdev.c for examples.
Go through bugs.busybox.net and close out all of that somehow.
This one's open to everybody, but I'll wind up doing it...
- 'ln -n' has been disabled for this release, till we can fix a memory
corruption bug.
- fix 'cp' (or test suite script) so that it passes the last item in
the test suite.
- ps dirent race bug (need to stat the file before attempting chdir)
- Make 'ln -s /tmp/file .' work the way GNU ln does (i.e. makes a link to
/tmp/file in the current directory, rather then trying and failing to create
a symlink named "." in the current working directory).
- Prune sfdisk, graft in std fdisk instead
Bernhard Fischer <busybox@busybox.net> suggests to look at these:
New debug options:
-Wlarger-than-127
Cleanup any big users
-Wunused-parameter
Facilitate applet PROTOTYPES to provide means for having applets that
do a) not take any arguments b) need only one of argc or argv c) need
both argc and argv. All of these three options should go for the most
feature complete denominator.
Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE
make bb_common_bufsiz1 configurable, size wise.
make pipesize configurable, size wise.
Use bb_common_bufsiz1 throughout applets!
Add chrt applet. Please CC Bernhard if you suggest a patch.
As yet unclaimed:
----
find
doesn't understand (), lots of susv3 stuff.
----
diff
Make sure we handle empty files properly:
From the patch man page:
you can remove a file by sending out a context diff that compares
the file to be deleted with an empty file dated the Epoch. The
file will be removed unless patch is conforming to POSIX and the
-E or --remove-empty-files option is not given.
---
patch
Should have simple fuzz factor support to apply patches at an offset which
shouldn't take up too much space.
And while we're at it, a new patch filename quoting format is apparently
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
---
man
It would be nice to have a man command. Not one that handles troff or
anything, just one that can handle preformatted ascii man pages, possibly
compressed. This could probably be a script in the extras directory that
calls cat/zcat/bzcat | less
(How doclifter might work into this is anybody's guess.)
---
ar
Write support?
---
Architectural issues:
bb_close() with fsync()
We should have a bb_close() in place of normal close, with a CONFIG_ option
to not just check the return value of close() for an error, but fsync().
Close can't reliably report anything useful because if write() accepted the
data then it either went out to the network or it's in cache or a pipe
buffer. Either way, there's no guarantee it'll make it to its final
destination before close() gets called, so there's no guarantee that any
error will be reported.
You need to call fsync() if you care about errors that occur after write(),
but that can have a big performance impact. So make it a config option.
---
Unify archivers
Lots of archivers have the same general infrastructure. The directory
traversal code should be factored out, and the guts of each archiver could
be some setup code and a series of callbacks for "add this file",
"add this directory", "add this symlink" and so on.
This could clean up tar and zip, and make it cheaper to add cpio and ar
write support, and possibly even cheaply add things like mkisofs or
mksquashfs someday, if they become relevant.
---
Text buffer support.
Several existing applets (sort, vi, less...) read
a whole file into memory and act on it. There might be an opportunity
for shared code in there that could be moved into libbb...
---
Memory Allocation
We have a CONFIG_BUFFER mechanism that lets us select whether to do memory
allocation on the stack or the heap. Unfortunately, we're not using it much.
We need to audit our memory allocations and turn a lot of malloc/free calls
into RESERVE_CONFIG_BUFFER/RELEASE_CONFIG_BUFFER.
For a start, see e.g. make EXTRA_CFLAGS=-Wlarger-than-64
And while we're at it, many of the CONFIG_FEATURE_CLEAN_UP #ifdefs will be
optimized out by the compiler in the stack allocation case (since there's no
free for an alloca()), and this means that various cleanup loops that just
call free might also be optimized out by the compiler if written right, so
we can yank those #ifdefs too, and generally clean up the code.
---
Switch CONFIG_SYMBOLS to ENABLE_SYMBOLS
In busybox 1.0 and earlier, configuration was done by CONFIG_SYMBOLS
that were either defined or undefined to indicate whether the symbol was
selected in the .config file. They were used with #ifdefs, ala:
#ifdef CONFIG_SYMBOL
if (other_test) {
do_code();
}
#endif
In 1.1, we have new ENABLE_SYMBOLS which are always defined (as 0 or 1),
meaning you can still use them for preprocessor tests by replacing
"#ifdef CONFIG_SYMBOL" with "#if ENABLE_SYMBOL". But more importantly, we
can use them as a true or false test in normal C code:
if (ENABLE_SYMBOL && other_test) {
do_code();
}
(Optimizing away if() statements that resolve to a constant value
is known as "dead code elimination", an optimization so old and simple that
Turbo Pascal for DOS did it twenty years ago. Even modern mini-compilers
like the Tiny C Compiler (tcc) and the Small Device C Compiler (SDCC)
perform dead code elimination.)
Right now, busybox.h is #including both "config.h" (defining the
CONFIG_SYMBOLS) and "bb_config.h" (defining the ENABLE_SYMBOLS). At some
point in the future, it would be nice to wean ourselves off of the
CONFIG versions. (Among other things, some defective build environments
leak the Linux kernel's CONFIG_SYMBOLS into the system's standard #include
files. We've experienced collisions before.)
---
FEATURE_CLEAN_UP
This is more an unresolved issue than a to-do item. More thought is needed.
Normally we rely on exit() to free memory, close files, and unmap segments
for us. This makes most calls to free(), close(), and unmap() optional in
busybox applets that don't intend to run for very long, and optional stuff
can be omitted to save size.
The idea was raised that we could simulate fork/exit with setjmp/longjmp
for _really_ brainless embedded systems, or speed up the standalone shell
by not forking. Doing so would require a reliable FEATURE_CLEAN_UP.
Unfortunately, this isn't as easy as it sounds.
The problem is, lots of things exit(), sometimes unexpectedly (xmalloc())
and sometimes reliably (bb_perror_msg_and_die() or show_usage()). This
jumps out of the normal flow control and bypasses any cleanup code we
put at the end of our applets.
It's possible to add hooks to libbb functions like xmalloc() and xopen()
to add their entries to a linked list, which could be traversed and
freed/closed automatically. (This would need to be able to free just the
entries after a checkpoint to be usable for a forkless standalone shell.
You don't want to free the shell's own resources.)
Right now, FEATURE_CLEAN_UP is more or less a debugging aid, to make things
like valgrind happy. It's also documentation of _what_ we're trusting
exit() to clean up for us. But new infrastructure to auto-free stuff would
render the existing FEATURE_CLEAN_UP code redundant.
For right now, exit() handles it just fine.
We will rework these to use libc regex functions instead (as per the mailing
list discussion):
- 'grep foo$ file' doesn't work
- 'grep *foo file' segfaults
-----------
Minor stuff:
watchdog.c could autodetect the timer duration via:
if(!ioctl (fd, WDIOC_GETTIMEOUT, &tmo)) timer_duration = 1 + (tmo / 2);
Unfortunately, that needs linux/watchdog.h and that contains unfiltered
kernel types on some distros, which breaks the build.
---
use bb_error_msg where appropriate: See
egrep "(printf.*\([[:space:]]*(stderr|2)|[^_]write.*\([[:space:]]*(stderr|2))"
---
use bb_perror_msg where appropriate: See
egrep "[^_]perror"
---
Remove superfluous fmt occurances: e.g.
fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
---
possible code duplication ingroup() and is_a_group_member()
---
Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c
---
Linux 2.4.x kernels
BusyBox 0.45 currently will not work with the Linux 2.4.x kernels.
I know of the following problems:
1) The sysinfo syscall has changed what it does (binary incompatable), breaking
init and free.
2) BusyBox NFS support is broken with 2.4.x (needs to be adjusted for NFSv3 and
kernel header changes).
3) mount,umount,and df are all broken by the "none" entries for fake filesystems
such as the shared mem one. Al Viro claims these will be disappearing soon...
I made a kernel patch that reverts the sysinfo changes
http://kernelnotes.org/lnxlists/linux-kernel/lk_0006_01/msg00619.html
and I have been fighting with Alan Cox to get these changes fixed in a binary
compatable way, but Alan has so far not been very receptive. I am planning on
appealing to Linus (when he gets back from vacation) and then going with
whatever he decides...
So my thought is, 2.4.x just isn't ready for BusyBox to target it, and even if
it was, BusyBox isn't ready yet either. Seems to me like this will not be
ready for a while, and we should just not worry about it yet.
As long as I have BB_FEATURE_NFSMOUNT turned off, everything compiles cleanly
for me with linux2.4.0test1-ac22-riel (i.e. I don't see the freeramdisk.c
problem you reported). I use Debian potato (gcc 2.95.2, GNU libc 2.1.3).
Of course, as noted above, compiling != working.
-----------
* Make insmod actually work
* dnsdomainname
* traceroute/netstat
* rdate
* hwclock
* stty
* 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.)
-----------------------
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).
-----------------------
Code cleanup:
> Have you ever thought of doig network logging in busybox syslogd ? It
> would quite make sense on embedded systems... :)
Replace deprecated functions.
So far I had not considered it. Basically, you wish to have
messages from the embedded box logged to a remote network
syslog box, right? I can see that this would be useful.
I'll add this to the TODO list,
-----------------------
I think that the add_inode &c in utility.c needs to also stow the
st_dev field, and that du.c should NOT call `reset_inode_list'
because there can be hard links from inside one argv/ to inside
another argv/. du.c probably ought to have an -x switch like GNU du
does also...
------------------------------------------------------------------
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>
X-Sender: rhw@moo.cus.org.uk
To: almesber@lrc.di.epfl.ch
Cc: "Albert D. Cahalan" <acahalan@cs.uml.edu>,
Linux Kernel <linux-kernel@vger.rutgers.edu>
Subject: Re: What /proc should contain [was: /proc/driver/microcode]
In-Reply-To: <20000224165245.A29790@lrc.di.epfl.ch>
Message-ID: <Pine.LNX.4.21.0002250806220.8741-100000@moo.cus.org.uk>
Sender: owner-linux-kernel@vger.rutgers.edu
Precedence: bulk
Hi there.
>> Nope, most /proc access is does via programs written in C.
> That varies a lot from file to file. E.g. I haven't seen any
> programs that are specificly designed to read /proc/atm/* yet,
> and I know of only one (fuser) that reads /proc/mounts,
> extracting only partial information (just to pick two examples
> that I'm quite familiar with).
As a point of reference, here's a slightly tweaked analysis of the
programs on the system I'm reading your mail on. Basically, I ran the
following script...
Q> #!/bin/bash
Q> function use() {
Q> for Z in $* ; do
Q> strings $Z | grep /proc | sed "s=^=$Z ="
Q> done
Q> }
Q> use /{,s}bin/* /usr/{,s}bin/* | sort -u | tee proc-usage
...and then went through it removing comments and print format
strings. Replace /proc with /dev and you'd soon have an equivalent
list for that - although I can report that such is MUCH larger...
There are three programs therein that refer to /proc/mounts ...
/bin/mount
/bin/umount
/usr/bin/eject
...and, as you stated, none that refer to /proc/atm on this system.
However, as this is a RedHat Linux 5.0 based system, that's not
necessarily an up to date reference thereto...
Here's the list anyway...
/bin/kill /proc/%d/cmdline
/bin/kill /proc/%d/stat
/bin/mount /proc/devices
/bin/mount /proc/filesystems
/bin/mount /proc/mounts
/bin/netstat /proc/net
/bin/netstat /proc/net/appletalk
/bin/netstat /proc/net/ax25
/bin/netstat /proc/net/ax25_route
/bin/netstat /proc/net/dev
/bin/netstat /proc/net/ip_masquerade
/bin/netstat /proc/net/ipx
/bin/netstat /proc/net/ipx_route
/bin/netstat /proc/net/netstat
/bin/netstat /proc/net/nr
/bin/netstat /proc/net/nr_neigh
/bin/netstat /proc/net/nr_nodes
/bin/netstat /proc/net/raw
/bin/netstat /proc/net/route
/bin/netstat /proc/net/rt_cache
/bin/netstat /proc/net/snmp
/bin/netstat /proc/net/tcp
/bin/netstat /proc/net/udp
/bin/netstat /proc/net/unix
/bin/umount /proc/devices
/bin/umount /proc/mounts
/sbin/arp /proc/net/appletalk
/sbin/arp /proc/net/arp
/sbin/arp /proc/net/ax25
/sbin/arp /proc/net/ipx
/sbin/arp /proc/net/nr
/sbin/arp /proc/net/unix
/sbin/cardctl /proc/devices
/sbin/cardmgr /proc/devices
/sbin/fdisk /proc/ide/%s/media
/sbin/fdisk /proc/scsi/scsi
/sbin/getty /proc/version
/sbin/ifconfig /proc/net
/sbin/ifconfig /proc/net/appletalk
/sbin/ifconfig /proc/net/ax25
/sbin/ifconfig /proc/net/dev
/sbin/ifconfig /proc/net/ipx
/sbin/ifconfig /proc/net/nr
/sbin/ifconfig /proc/net/unix
/sbin/ifup /proc/sys/kernel/modprobe
/sbin/ipchains /proc/net/ip_fwchains
/sbin/ipchains /proc/net/ip_fwnames
/sbin/ipchains /proc/net/ip_masquerade
/sbin/ipchains /proc/sys/net/ipv4/ip_forward
/sbin/ipmaddr /proc/net/dev_mcast
/sbin/ipmaddr /proc/net/igmp
/sbin/ipmaddr /proc/net/igmp6
/sbin/iptunnel /proc/net/dev
/sbin/killall5 /proc/%s/cmdline
/sbin/killall5 /proc/%s/exe
/sbin/killall5 /proc/%s/stat
/sbin/killall5 /proc/version
/sbin/klogd /proc/kmsg
/sbin/lsmod /proc/modules
/sbin/modprobe /proc/modules
/sbin/pidof /proc/%s/cmdline
/sbin/pidof /proc/%s/exe
/sbin/pidof /proc/%s/stat
/sbin/pidof /proc/version
/sbin/probe /proc/pci
/sbin/rarp /proc/net/ax25
/sbin/rarp /proc/net/nr
/sbin/rarp /proc/net/rarp
/sbin/rmmod /proc/modules
/sbin/rmmod.static /proc/modules
/sbin/route /proc/net/appletalk
/sbin/route /proc/net/ax25
/sbin/route /proc/net/ax25_route
/sbin/route /proc/net/ipx
/sbin/route /proc/net/ipx_route
/sbin/route /proc/net/nr
/sbin/route /proc/net/nr_neigh
/sbin/route /proc/net/nr_nodes
/sbin/route /proc/net/route
/sbin/route /proc/net/rt_cache
/sbin/route /proc/net/unix
/sbin/scsi_info /proc/scsi
/sbin/scsi_info /proc/scsi/%s
/sbin/scsi_info /proc/scsi/scsi
/sbin/slattach /proc/net/ax25
/sbin/slattach /proc/net/nr
/sbin/swapoff /proc/swaps
/sbin/swapon /proc/swaps
/sbin/uugetty /proc/version
/usr/bin/dig /proc/
/usr/bin/dig /proc/interrupts
/usr/bin/dig /proc/meminfo
/usr/bin/dig /proc/rtc
/usr/bin/dig /proc/self/status
/usr/bin/dig /proc/stat
/usr/bin/dnsquery /proc/
/usr/bin/dnsquery /proc/interrupts
/usr/bin/dnsquery /proc/meminfo
/usr/bin/dnsquery /proc/rtc
/usr/bin/dnsquery /proc/self/status
/usr/bin/dnsquery /proc/stat
/usr/bin/eject /proc/mounts
/usr/bin/emacs /proc/loadavg
/usr/bin/fetchmail /proc/net/dev
/usr/bin/free /proc/meminfo
/usr/bin/gmake /proc/loadavg
/usr/bin/gpm-root /proc/loadavg
/usr/bin/gpm-root /proc/meminfo
/usr/bin/host /proc/
/usr/bin/host /proc/interrupts
/usr/bin/host /proc/meminfo
/usr/bin/host /proc/rtc
/usr/bin/host /proc/self/status
/usr/bin/host /proc/stat
/usr/bin/hoststat /proc/loadavg
/usr/bin/hwdiag /proc/cpuinfo
/usr/bin/hwdiag /proc/pci
/usr/bin/hwdiag /proc/scsi/scsi
/usr/bin/hwdiag /proc/version
/usr/bin/lsdev /proc/dma
/usr/bin/lsdev /proc/interrupts
/usr/bin/lsdev /proc/ioports
/usr/bin/mailq /proc/loadavg
/usr/bin/make /proc/loadavg
/usr/bin/mcookie /proc/loadavg
/usr/bin/mcookie /proc/stat
/usr/bin/newaliases /proc/loadavg
/usr/bin/nslookup /proc/
/usr/bin/nslookup /proc/interrupts
/usr/bin/nslookup /proc/meminfo
/usr/bin/nslookup /proc/rtc
/usr/bin/nslookup /proc/self/status
/usr/bin/nslookup /proc/stat
/usr/bin/nsupdate /proc/
/usr/bin/nsupdate /proc/interrupts
/usr/bin/nsupdate /proc/meminfo
/usr/bin/nsupdate /proc/rtc
/usr/bin/nsupdate /proc/self/status
/usr/bin/nsupdate /proc/stat
/usr/bin/pgp /proc/version
/usr/bin/pgpe /proc/version
/usr/bin/pgpk /proc/version
/usr/bin/pgps /proc/version
/usr/bin/pgpv /proc/version
/usr/bin/procinfo /proc/cmdline
/usr/bin/procinfo /proc/devices
/usr/bin/procinfo /proc/dma
/usr/bin/procinfo /proc/filesystems
/usr/bin/procinfo /proc/interrupts
/usr/bin/procinfo /proc/loadavg
/usr/bin/procinfo /proc/meminfo
/usr/bin/procinfo /proc/modules
/usr/bin/procinfo /proc/stat
/usr/bin/procinfo /proc/uptime
/usr/bin/procinfo /proc/version
/usr/bin/purgestat /proc/loadavg
/usr/bin/screen /proc/loadavg
/usr/bin/strace /proc/%d/stat
/usr/bin/top /proc/cpuinfo
/usr/bin/top /proc/meminfo
/usr/bin/top /proc/stat
/usr/bin/vmstat /proc/%s/stat
/usr/bin/vmstat /proc/meminfo
/usr/bin/vmstat /proc/stat
/usr/sbin/atd /proc/loadavg
/usr/sbin/dnskeygen /proc/
/usr/sbin/dnskeygen /proc/interrupts
/usr/sbin/dnskeygen /proc/meminfo
/usr/sbin/dnskeygen /proc/rtc
/usr/sbin/dnskeygen /proc/self/status
/usr/sbin/dnskeygen /proc/stat
/usr/sbin/fuser /proc/%d/stat
/usr/sbin/fuser /proc/net/%s
/usr/sbin/fuser /proc/net/unix
/usr/sbin/in.identd /proc/net/tcp
/usr/sbin/irpd /proc/
/usr/sbin/irpd /proc/interrupts
/usr/sbin/irpd /proc/meminfo
/usr/sbin/irpd /proc/rtc
/usr/sbin/irpd /proc/self/status
/usr/sbin/irpd /proc/stat
/usr/sbin/named /proc/
/usr/sbin/named /proc/interrupts
/usr/sbin/named /proc/meminfo
/usr/sbin/named /proc/rtc
/usr/sbin/named /proc/self/status
/usr/sbin/named /proc/stat
/usr/sbin/named-xfer /proc/
/usr/sbin/named-xfer /proc/interrupts
/usr/sbin/named-xfer /proc/meminfo
/usr/sbin/named-xfer /proc/rtc
/usr/sbin/named-xfer /proc/self/status
/usr/sbin/named-xfer /proc/stat
/usr/sbin/readprofile /proc/profile
/usr/sbin/rwhod /proc/loadavg
/usr/sbin/rwhod /proc/uptime
/usr/sbin/sendmail /proc/loadavg
/usr/sbin/setconsole /proc/openprom/options
/usr/sbin/setconsole /proc/openprom/options/${console}-mode
/usr/sbin/setconsole /proc/openprom/options/input-device
/usr/sbin/setconsole /proc/openprom/options/output-device
Best wishes from Riley.
* Copyright (C) 1999, Memory Alpha Systems.
* All rights and wrongs reserved.
+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* http://www.memalpha.cx/Linux/Kernel/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
bzero() -> memset()
---
sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
---
vdprintf() -> similar sized functionality
---
-21
View File
@@ -1,21 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
obj-y:=
obj-y += applets.o
obj-y += busybox.o
# Generated file needs additional love
applets/applets.o: include/usage_compressed.h
hostprogs-y += usage
always := $(hostprogs-y)
HOSTCFLAGS_usage.o = -I$(srctree)/include
include/usage_compressed.h: $(srctree)/include/usage.h applets/usage
@echo ' GEN include/usage_compressed.h'
@$(srctree)/applets/usage_compressed include/usage_compressed.h applets
-483
View File
@@ -1,483 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) tons of folks. Tracking down who wrote what
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
* Licensed under GPLv2 or later, see file License in this tarball for details.
*/
#include "busybox.h"
#include <unistd.h>
#include <string.h>
#include <assert.h>
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
#warning Static linking against glibc produces buggy executables
#warning (glibc does not cope well with ld --gc-sections).
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
#warning Note that glibc is utterly unsuitable for static linking anyway.
#endif
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
static const char usage_messages[] =
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
;
#undef MAKE_USAGE
#else
#define usage_messages 0
#endif /* ENABLE_SHOW_USAGE */
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
#include "applets.h"
static struct BB_applet *applet_using;
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
#ifdef CONFIG_FEATURE_SUID_CONFIG
#include <ctype.h>
#define CONFIG_FILE "/etc/busybox.conf"
/* applets [] is const, so we have to define this "override" structure */
static struct BB_suid_config
{
struct BB_applet *m_applet;
uid_t m_uid;
gid_t m_gid;
mode_t m_mode;
struct BB_suid_config *m_next;
} *suid_config;
static int suid_cfg_readable;
/* check if u is member of group g */
static int ingroup(uid_t u, gid_t g)
{
struct group *grp = getgrgid(g);
if (grp) {
char **mem;
for (mem = grp->gr_mem; *mem; mem++) {
struct passwd *pwd = getpwnam(*mem);
if (pwd && (pwd->pw_uid == u))
return 1;
}
}
return 0;
}
/* This should probably be a libbb routine. In that case,
* I'd probably rename it to something like bb_trimmed_slice.
*/
static char *get_trimmed_slice(char *s, char *e)
{
/* First, consider the value at e to be nul and back up until we
* reach a non-space char. Set the char after that (possibly at
* the original e) to nul. */
while (e-- > s) {
if (!isspace(*e)) {
break;
}
}
e[1] = 0;
/* Next, advance past all leading space and return a ptr to the
* first non-space char; possibly the terminating nul. */
return skip_whitespace(s);
}
#define parse_error(x) { err=x; goto pe_label; }
/* Don't depend on the tools to combine strings. */
static const char config_file[] = CONFIG_FILE;
/* There are 4 chars + 1 nul for each of user/group/other. */
static const char mode_chars[] = "Ssx-\0Ssx-\0Ttx-";
/* We don't supply a value for the nul, so an index adjustment is
* necessary below. Also, we use unsigned short here to save some
* space even though these are really mode_t values. */
static const unsigned short mode_mask[] = {
/* SST sst xxx --- */
S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */
S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */
0, S_IXOTH, S_IXOTH, 0 /* other */
};
static void parse_config_file(void)
{
struct BB_suid_config *sct_head;
struct BB_suid_config *sct;
struct BB_applet *applet;
FILE *f;
char *err;
char *s;
char *e;
int i, lc, section;
char buffer[256];
struct stat st;
assert(!suid_config); /* Should be set to NULL by bss init. */
if ((stat(config_file, &st) != 0) /* No config file? */
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|| (st.st_uid != 0) /* Not owned by root? */
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|| !(f = fopen(config_file, "r")) /* Cannot open? */
) {
return;
}
suid_cfg_readable = 1;
sct_head = NULL;
section = lc = 0;
do {
s = buffer;
if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */
if (ferror(f)) { /* Make sure it wasn't a read error. */
parse_error("reading");
}
fclose(f);
suid_config = sct_head; /* Success, so set the pointer. */
return;
}
lc++; /* Got a (partial) line. */
/* If a line is too long for our buffer, we consider it an error.
* The following test does mistreat one corner case though.
* If the final line of the file does not end with a newline and
* yet exactly fills the buffer, it will be treated as too long
* even though there isn't really a problem. But it isn't really
* worth adding code to deal with such an unlikely situation, and
* we do err on the side of caution. Besides, the line would be
* too long if it did end with a newline. */
if (!strchr(s, '\n') && !feof(f)) {
parse_error("line too long");
}
/* Trim leading and trailing whitespace, ignoring comments, and
* check if the resulting string is empty. */
if (!*(s = get_trimmed_slice(s, strchrnul(s, '#')))) {
continue;
}
/* Check for a section header. */
if (*s == '[') {
/* Unlike the old code, we ignore leading and trailing
* whitespace for the section name. We also require that
* there are no stray characters after the closing bracket. */
if (!(e = strchr(s, ']')) /* Missing right bracket? */
|| e[1] /* Trailing characters? */
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
) {
parse_error("section header");
}
/* Right now we only have one section so just check it.
* If more sections are added in the future, please don't
* resort to cascading ifs with multiple strcasecmp calls.
* That kind of bloated code is all too common. A loop
* and a string table would be a better choice unless the
* number of sections is very small. */
if (strcasecmp(s, "SUID") == 0) {
section = 1;
continue;
}
section = -1; /* Unknown section so set to skip. */
continue;
}
/* Process sections. */
if (section == 1) { /* SUID */
/* Since we trimmed leading and trailing space above, we're
* now looking for strings of the form
* <key>[::space::]*=[::space::]*<value>
* where both key and value could contain inner whitespace. */
/* First get the key (an applet name in our case). */
if (!!(e = strchr(s, '='))) {
s = get_trimmed_slice(s, e);
}
if (!e || !*s) { /* Missing '=' or empty key. */
parse_error("keyword");
}
/* Ok, we have an applet name. Process the rhs if this
* applet is currently built in and ignore it otherwise.
* Note: This can hide config file bugs which only pop
* up when the busybox configuration is changed. */
if ((applet = find_applet_by_name(s))) {
/* Note: We currently don't check for duplicates!
* The last config line for each applet will be the
* one used since we insert at the head of the list.
* I suppose this could be considered a feature. */
sct = xmalloc(sizeof(struct BB_suid_config));
sct->m_applet = applet;
sct->m_mode = 0;
sct->m_next = sct_head;
sct_head = sct;
/* Get the specified mode. */
e = skip_whitespace(e+1);
for (i=0 ; i < 3 ; i++) {
const char *q;
if (!*(q = strchrnul(mode_chars + 5*i, *e++))) {
parse_error("mode");
}
/* Adjust by -i to account for nul. */
sct->m_mode |= mode_mask[(q - mode_chars) - i];
}
/* Now get the the user/group info. */
s = skip_whitespace(e);
/* Note: We require whitespace between the mode and the
* user/group info. */
if ((s == e) || !(e = strchr(s, '.'))) {
parse_error("<uid>.<gid>");
}
*e++ = 0;
/* We can't use get_ug_id here since it would exit()
* if a uid or gid was not found. Oh well... */
{
char *e2;
sct->m_uid = strtoul(s, &e2, 10);
if (*e2 || (s == e2)) {
struct passwd *pwd = getpwnam(s);
if (!pwd) {
parse_error("user");
}
sct->m_uid = pwd->pw_uid;
}
sct->m_gid = strtoul(e, &e2, 10);
if (*e2 || (e == e2)) {
struct group *grp;
if (!(grp = getgrnam(e))) {
parse_error("group");
}
sct->m_gid = grp->gr_gid;
}
}
}
continue;
}
/* Unknown sections are ignored. */
/* Encountering configuration lines prior to seeing a
* section header is treated as an error. This is how
* the old code worked, but it may not be desirable.
* We may want to simply ignore such lines in case they
* are used in some future version of busybox. */
if (!section) {
parse_error("keyword outside section");
}
} while (1);
pe_label:
fprintf(stderr, "Parse error in %s, line %d: %s\n",
config_file, lc, err);
fclose(f);
/* Release any allocated memory before returning. */
while (sct_head) {
sct = sct_head->m_next;
free(sct_head);
sct_head = sct;
}
return;
}
#else
#define parse_config_file()
#endif /* CONFIG_FEATURE_SUID_CONFIG */
#ifdef CONFIG_FEATURE_SUID
static void check_suid(struct BB_applet *applet)
{
uid_t ruid = getuid(); /* real [ug]id */
uid_t rgid = getgid();
#ifdef CONFIG_FEATURE_SUID_CONFIG
if (suid_cfg_readable) {
struct BB_suid_config *sct;
for (sct = suid_config; sct; sct = sct->m_next) {
if (sct->m_applet == applet)
break;
}
if (sct) {
mode_t m = sct->m_mode;
if (sct->m_uid == ruid) /* same uid */
m >>= 6;
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid)) /* same group / in group */
m >>= 3;
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die("you have no permission to run this applet!");
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
xsetgid(sct->m_gid);
} else xsetgid(rgid); /* no sgid -> drop */
if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
else xsetuid(ruid); /* no suid -> drop */
} else {
/* default: drop all privileges */
xsetgid(rgid);
xsetuid(ruid);
}
return;
} else {
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
static int onetime = 0;
if (!onetime) {
onetime = 1;
fprintf(stderr, "Using fallback suid method\n");
}
#endif
}
#endif
if (applet->need_suid == _BB_SUID_ALWAYS) {
if (geteuid()) bb_error_msg_and_die("applet requires root privileges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
xsetgid(rgid); /* drop all privileges */
xsetuid(ruid);
}
}
#else
#define check_suid(x)
#endif /* CONFIG_FEATURE_SUID */
#ifdef CONFIG_FEATURE_COMPRESS_USAGE
#include "usage_compressed.h"
#include "unarchive.h"
static const char *unpack_usage_messages(void)
{
int input[2], output[2], pid;
char *buf;
if(pipe(input) < 0 || pipe(output) < 0)
exit(1);
pid = fork();
switch (pid) {
case -1: /* error */
exit(1);
case 0: /* child */
close(input[1]);
close(output[0]);
uncompressStream(input[0], output[1]);
exit(0);
}
/* parent */
close(input[0]);
close(output[1]);
pid = fork();
switch (pid) {
case -1: /* error */
exit(1);
case 0: /* child */
full_write(input[1], packed_usage, sizeof(packed_usage));
exit(0);
}
/* parent */
close(input[1]);
buf = xmalloc(SIZEOF_usage_messages);
full_read(output[0], buf, SIZEOF_usage_messages);
return buf;
}
#else
#define unpack_usage_messages() usage_messages
#endif /* ENABLE_FEATURE_COMPRESS_USAGE */
void bb_show_usage(void)
{
if (ENABLE_SHOW_USAGE) {
const char *format_string;
const char *usage_string = unpack_usage_messages();
int i;
for (i = applet_using - applets; i > 0;)
if (!*usage_string++) --i;
format_string = "%s\n\nUsage: %s %s\n\n";
if (*usage_string == '\b')
format_string = "%s\n\nNo help available.\n\n";
fprintf(stderr, format_string, bb_msg_full_version,
applet_using->name, usage_string);
}
exit(xfunc_error_retval);
}
static int applet_name_compare(const void *name, const void *vapplet)
{
const struct BB_applet *applet = vapplet;
return strcmp(name, applet->name);
}
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
if (ENABLE_FEATURE_SUID_CONFIG) parse_config_file();
if (!strncmp(name, "busybox", 7)) busybox_main(argc, argv);
/* Do a binary search to find the applet entry given the name. */
applet_using = find_applet_by_name(name);
if (applet_using) {
applet_name = applet_using->name;
if(argc==2 && !strcmp(argv[1], "--help")) bb_show_usage();
if(ENABLE_FEATURE_SUID) check_suid(applet_using);
exit((*(applet_using->main))(argc, argv));
}
}
+405 -126
View File
@@ -1,148 +1,427 @@
/* vi: set sw=4 ts=4: */
/*
* BusyBox' main applet dispatcher.
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
static int been_there_done_that = 0;
/* It has been alledged that doing such things can
* help reduce binary size when staticly linking,
* of course with glibc, this is unlikely as long
* as we use things like printf -- perhaps a printf
* replacement may be in order
*/
#include "busybox.h"
#if 0
void exit(int status) __attribute__ ((noreturn));
void exit(int status)
{
_exit(status);
};
void abort(void) __attribute__ ((__noreturn__));
void abort(void)
{
_exit(0);
};
int atexit(void (*__func) (void))
{
_exit(0);
};
void *__libc_stack_end;
#endif
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
const struct BB_applet applets[] = {
#ifdef CONFIG_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static const char usr_bin [] ="/usr/bin";
static const char usr_sbin[] ="/usr/sbin";
static const char* const install_dir[] = {
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
&usr_bin [4], /* "/bin" */
&usr_sbin[4], /* "/sbin" */
usr_bin,
usr_sbin
#ifdef BB_AR
{"ar", ar_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_BASENAME
{"basename", basename_main, _BB_DIR_USR_BIN},
#endif
{"busybox", busybox_main, _BB_DIR_BIN},
#ifdef BB_BLOCK_DEVICE
{"block_device", block_device_main, _BB_DIR_SBIN},
#endif
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_CLEAR
{"clear", clear_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN},
#endif
#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
#ifdef BB_DF
{"df", df_main, _BB_DIR_BIN},
#endif
#ifdef BB_DIRNAME
{"dirname", dirname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DMESG
{"dmesg", dmesg_main, _BB_DIR_BIN},
#endif
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_FDFLUSH
{"fdflush", fdflush_main, _BB_DIR_BIN},
#endif
#ifdef BB_FIND
{"find", find_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREE
{"free", free_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREERAMDISK
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_DEALLOCVT
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
#endif
#ifdef BB_HEAD
{"head", head_main, _BB_DIR_BIN},
#endif
#ifdef BB_HOSTID
{"hostid", hostid_main, _BB_DIR_USR_BIN},
#endif
#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
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
#endif
#ifdef BB_KILLALL
{"killall", kill_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LINUXRC
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
#endif
#ifdef BB_LOADACM
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADFONT
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
#endif
#ifdef BB_LSMOD
{"lsmod", lsmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
#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},
#endif
#ifdef BB_MOUNT
{"mount", mount_main, _BB_DIR_BIN},
#endif
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PING
{"ping", ping_main, _BB_DIR_BIN},
#endif
#ifdef BB_POWEROFF
{"poweroff", poweroff_main, _BB_DIR_SBIN},
#endif
#ifdef BB_PRINTF
{"printf", printf_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PS
{"ps", ps_main, _BB_DIR_BIN},
#endif
#ifdef BB_PWD
{"pwd", pwd_main, _BB_DIR_BIN},
#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_RM
{"rm", rm_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMDIR
{"rmdir", rmdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMMOD
{"rmmod", rmmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_SORT
{"sort", sort_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYNC
{"sync", sync_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_TAIL
{"tail", tail_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TAR
{"tar", tar_main, _BB_DIR_BIN},
#endif
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEE
{"tee", tee_main, _BB_DIR_BIN},
#endif
#ifdef BB_TOUCH
{"touch", touch_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TR
{"tr", tr_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UMOUNT
{"umount", umount_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
#endif
#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
#ifdef BB_YES
{"yes", yes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
{0}
};
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char *fpc;
int i;
int rc;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
fpc = concat_path_file(
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, fpc);
if (rc!=0 && errno!=EEXIST) {
bb_perror_msg("%s", fpc);
}
free(fpc);
}
}
#else
#define install_links(x,y)
#endif /* CONFIG_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
const char *s;
char *s;
char *name;
const struct BB_applet *a = applets;
applet_name=argv[0];
if (*applet_name == '-') applet_name++;
for (s = applet_name; *s ;)
if (*(s++) == '/') applet_name = s;
for (s = name = argv[0]; *s != '\0';) {
if (*s++ == '/')
name = s;
}
/* Set locale for everybody except 'init' */
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
setlocale(LC_ALL, "");
*argv = name;
run_applet_by_name(applet_name, argc, argv);
bb_error_msg_and_die("applet not found");
while (a->name != 0) {
if (strcmp(name, a->name) == 0) {
exit(((*(a->main)) (argc, argv)));
}
a++;
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
/*
* 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 (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) {
int use_symbolic_links = 0;
int rc = 0;
char *busybox;
int col = 0;
/* to use symlinks, or not to use symlinks... */
if (argc > 2) {
if ((strcmp(argv[2], "-s") == 0)) {
use_symbolic_links = 1;
argc--;
argv++;
if (been_there_done_that == 1 || argc < 1) {
const struct BB_applet *a = applets;
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"
"\nCurrently defined functions:\n", BB_VER, BB_BT);
while (a->name != 0) {
col +=
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
(a++)->name);
if (col > 60 && a->name != 0) {
fprintf(stderr, ",\n");
col = 0;
}
}
/* link */
// XXX: FIXME: this is broken. Why not just use argv[0] ?
busybox = xreadlink("/proc/self/exe");
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
} else {
rc = 1;
}
return rc;
fprintf(stderr, "\n\n");
exit(-1);
}
/* Deal with --help. (Also print help when called with no arguments) */
if (argc==1 || !strcmp(argv[1],"--help") ) {
if (argc>2) {
applet_name = argv[2];
run_applet_by_name(applet_name, 2, argv);
} else {
const struct BB_applet *a;
int col, output_width;
if (ENABLE_FEATURE_AUTOWIDTH) {
/* Obtain the terminal width. */
get_terminal_width_height(0, &output_width, NULL);
/* leading tab and room to wrap */
output_width -= sizeof("start-stop-daemon, ") + 8;
} else output_width = 80 - sizeof("start-stop-daemon, ") - 8;
printf("%s\n"
"Copyright (C) 1998-2006  Erik Andersen, Rob Landley, and others.\n"
"Licensed under GPLv2.  See source distribution for full notice.\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"
"\nCurrently defined functions:\n", bb_msg_full_version);
col=0;
for(a = applets; a->name;) {
col += printf("%s%s", (col ? ", " : "\t"), (a++)->name);
if (col > output_width && a->name) {
printf(",\n");
col = 0;
}
}
printf("\n\n");
exit(0);
}
} else run_applet_by_name(argv[1], argc-1, argv+1);
bb_error_msg_and_die("applet not found");
/* If we've already been here once, exit now */
been_there_done_that = 1;
return (main(argc, argv));
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+14 -19
View File
@@ -1,24 +1,19 @@
#!/bin/sh
# Make busybox links list file.
# input $1: full path to Config.h
# input $2: full path to applets.h
# output (stdout): list of pathnames that should be linked to busybox
DF="busybox.def.h"
MF="busybox.c"
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
export LC_ALL=POSIX
export LC_CTYPE=POSIX
CONFIG_H=${1:-include/autoconf.h}
APPLETS_H=${2:-include/applets.h}
$HOSTCC -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
dir=substr($2,8)
gsub("_","/",dir)
if(dir=="/ROOT") dir=""
file=$3
gsub("\"","",file)
if (file=="busybox") next
print tolower(dir) "/" file
}'
for def in ${LIST}; do
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
for j in $i; do
if [ -z $j ] ; then
continue;
fi;
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
done;
done
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 ` \
gcc -E -dM busybox.def.h | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr [:upper:] [:lower:] | sort
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
-27
View File
@@ -1,27 +0,0 @@
/* Minimal wrapper to build an individual busybox applet.
*
* Copyright 2005 Rob Landley <rob@landley.net
*
* Licensed under GPL version 2, see file LICENSE in this tarball for details
*/
const char *applet_name;
#include <stdio.h>
#include <stdlib.h>
//Ok to remove? #include "bb_config.h"
#include "usage.h"
int main(int argc, char *argv[])
{
applet_name=argv[0];
return APPLET_main(argc,argv);
}
void bb_show_usage(void)
{
printf(APPLET_full_usage "\n");
exit(1);
}
+11 -84
View File
@@ -1,94 +1,21 @@
#!/bin/sh
export LC_ALL=POSIX
export LC_CTYPE=POSIX
set -e
prefix=${1}
if [ -z "$prefix" ]; then
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
exit 1;
if [ "$1" = "" ]; then
echo "No installation directory, aborting."
exit 1;
fi
h=`sort busybox.links | uniq`
cleanup="0"
noclobber="0"
case "$2" in
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
--cleanup) cleanup="1";;
--noclobber) noclobber="1";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
esac
if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
# get the target dir for the libs
# assume it starts with lib
libdir=$($CC -print-file-name=libc.so | \
sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
if test -z "$libdir"; then
libdir=/lib
fi
mkdir -p $prefix/$libdir || exit 1
for i in $DO_INSTALL_LIBS; do
rm -f $prefix/$libdir/$i || exit 1
if [ -f $i ]; then
cp -a $i $prefix/$libdir/ || exit 1
chmod 0644 $prefix/$libdir/$i || exit 1
fi
done
fi
if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
sub_shell_it=`
cd "$prefix"
for d in usr/sbin usr/bin sbin bin ; do
pd=$PWD
if [ -d "$d" ]; then
cd $d
ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
fi
cd "$pd"
done
`
fi
rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
for i in $h ; do
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
else
case "$appdir" in
/)
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
fi
if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
else
echo " $prefix$i already exists"
fi
echo " $1$i -> /bin/busybox"
mkdir -p $1/`echo $i | sed -e 's/\/[^\/]*$//' `
ln -fs /bin/busybox $1$i
done
rm -f $1/bin/busybox
mkdir -p $1/bin
install -m 755 busybox $1/bin/busybox
exit 0
-17
View File
@@ -1,17 +0,0 @@
/* vi: set sw=4 ts=4: */
#include <unistd.h>
#include "../include/autoconf.h"
#include "../include/busybox.h"
static const char usage_messages[] =
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
;
int main(void)
{
write(1, usage_messages, sizeof(usage_messages));
return 0;
}
-19
View File
@@ -1,19 +0,0 @@
#!/bin/sh
target="$1"
loc="$2"
test "$target" || exit 1
test "$loc" || loc=.
test -x "$loc/usage" || exit 1
test "$SED" || SED=sed
sz=`"$loc/usage" | wc -c` || exit 1
exec >"$target"
echo 'static const char packed_usage[] = '
"$loc/usage" | bzip2 -1 | od -v -t x1 \
| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
echo ';'
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
+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
#define AR_VERBOSE 2
#define AR_DISPLAY 4
#define AR_EXT_TO_FILE 8
#define AR_EXT_TO_STDOUT 16
#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': /* preserver original dates */
funct = funct | 1;
break;
case 'p': /* extract to stdout */
funct = funct | 16;
break;
case 't': /* display contents */
funct = funct | 4;
break;
case 'x': /* extract contents of archive */
funct = funct | 8;
break;
case 'v': /* be verbose */
funct = funct | 2;
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);
}
-5
View File
@@ -1,5 +0,0 @@
# ==========================================================================
# Build system
# ==========================================================================
CFLAGS += -march=i386 -mpreferred-stack-boundary=2
-300
View File
@@ -1,300 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
menu "Archival Utilities"
config AR
bool "ar"
default n
help
ar is an archival utility program used to create, modify, and
extract contents from archives. An archive is a single file holding
a collection of other files in a structure that makes it possible to
retrieve the original individual files (called archive members).
The original files' contents, mode (permissions), timestamp, owner,
and group are preserved in the archive, and can be restored on
extraction.
The stored filename is limited to 15 characters. (for more information
see long filename support).
ar has 60 bytes of overheads for every stored file.
This implementation of ar can extract archives, it cannot create or
modify them.
On an x86 system, the ar applet adds about 1K.
Unless you have a specific application which requires ar, you should
probably say N here.
config FEATURE_AR_LONG_FILENAMES
bool "Enable support for long filenames (not need for debs)"
default n
depends on AR
help
By default the ar format can only store the first 15 characters of the
filename, this option removes that limitation.
It supports the GNU ar long filename method which moves multiple long
filenames into a the data section of a new ar entry.
config BUNZIP2
bool "bunzip2"
default n
help
bunzip2 is a compression utility using the Burrows-Wheeler block
sorting text compression algorithm, and Huffman coding. Compression
is generally considerably better than that achieved by more
conventional LZ77/LZ78-based compressors, and approaches the
performance of the PPM family of statistical compressors.
The BusyBox bunzip2 applet is limited to de-compression only.
On an x86 system, this applet adds about 11K.
Unless you have a specific application which requires bunzip2, you
should probably say N here.
config CPIO
bool "cpio"
default n
help
cpio is an archival utility program used to create, modify, and extract
contents from archives.
cpio has 110 bytes of overheads for every stored file.
This implementation of cpio can extract cpio archives created in the
"newc" or "crc" format, it cannot create or modify them.
Unless you have a specific application which requires cpio, you should
probably say N here.
config DPKG
bool "dpkg"
default n
help
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
This implementation of dpkg has a number of limitations, you should use the
official dpkg if possible.
config DPKG_DEB
bool "dpkg_deb"
default n
help
dpkg-deb packs, unpacks and provides information about Debian archives.
This implementation of dpkg-deb cannot pack archives.
Unless you have a specific application which requires dpkg-deb, you should
probably say N here.
config FEATURE_DPKG_DEB_EXTRACT_ONLY
bool "extract only (-x)"
default n
depends on DPKG_DEB
help
This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
However it saves space as none of the extra dpkg-deb, ar or tar options are
needed, they are linked to internally.
config GUNZIP
bool "gunzip"
default n
help
gunzip is used to decompress archives created by gzip.
You can use the `-t' option to test the integrity of
an archive, without decompressing it.
config FEATURE_GUNZIP_UNCOMPRESS
bool "Uncompress support"
default n
depends on GUNZIP
help
Enable if you want gunzip to have the ability to decompress
archives created by the program compress (not much
used anymore).
config GZIP
bool "gzip"
default n
help
gzip is used to compress files.
It's probably the most widely used UNIX compression program.
config RPM2CPIO
bool "rpm2cpio"
default n
help
Converts an RPM file into a CPIO archive.
config RPM
bool "rpm"
default n
help
Mini RPM applet - queries and extracts
config TAR
bool "tar"
default n
help
tar is an archiving program. It's commonly used with gzip to
create compressed archives. It's probably the most widely used
UNIX archive program.
config FEATURE_TAR_CREATE
bool "Enable archive creation"
default y
depends on TAR
help
If you enable this option you'll be able to create
tar archives using the `-c' option.
config FEATURE_TAR_BZIP2
bool "Enable -j option to handle .tar.bz2 files"
default n
depends on TAR
help
If you enable this option you'll be able to extract
archives compressed with bzip2.
config FEATURE_TAR_LZMA
bool "Enable -a option to handle .tar.lzma files"
default n
depends on TAR
help
If you enable this option you'll be able to extract
archives compressed with lzma.
config FEATURE_TAR_FROM
bool "Enable -X (exclude from) and -T (include from) options)"
default n
depends on TAR
help
If you enable this option you'll be able to specify
a list of files to include or exclude from an archive.
config FEATURE_TAR_GZIP
bool "Enable -z option"
default y
depends on TAR
help
If you enable this option tar will be able to call gzip,
when creating or extracting tar gziped archives.
config FEATURE_TAR_COMPRESS
bool "Enable -Z option"
default n
depends on TAR
help
If you enable this option tar will be able to call uncompress,
when extracting .tar.Z archives.
config FEATURE_TAR_OLDGNU_COMPATIBILITY
bool "Enable support for old tar header format"
default N
depends on TAR
help
This option is required to unpack archives created in
the old GNU format; help to kill this old format by
repacking your ancient archives with the new format.
config FEATURE_TAR_GNU_EXTENSIONS
bool "Enable support for some GNU tar extensions"
default y
depends on TAR
help
With this option busybox supports GNU long filenames and
linknames.
config FEATURE_TAR_LONG_OPTIONS
bool "Enable long options"
default n
depends on TAR && GETOPT_LONG
help
Enable use of long options, increases size by about 400 Bytes
config UNCOMPRESS
bool "uncompress"
default n
help
uncompress is used to decompress archives created by compress.
Not much used anymore, replaced by gzip/gunzip.
config UNLZMA
bool "unlzma"
default n
help
unlzma is a compression utility using the Lempel-Ziv-Markov chain
compression algorithm, and range coding. Compression
is generally considerably better than that achieved by the bzip2
compressors.
The BusyBox unlzma applet is limited to de-compression only.
On an x86 system, this applet adds about 4K.
Unless you have a specific application which requires unlzma, you
should probably say N here.
config FEATURE_LZMA_FAST
bool "Optimze unlzma for speed"
default n
depends on UNLZMA
help
This option reduces decompression time by about 33% at the cost of
a 2K bigger binary.
config UNZIP
bool "unzip"
default n
help
unzip will list or extract files from a ZIP archive,
commonly found on DOS/WIN systems. The default behavior
(with no options) is to extract the archive into the
current directory. Use the `-d' option to extract to a
directory of your choice.
comment "Common options for cpio and tar"
depends on CPIO || TAR
config FEATURE_UNARCHIVE_TAPE
bool "Enable tape drive support"
default n
depends on CPIO || TAR
help
I don't think this is needed anymore.
comment "Common options for dpkg and dpkg_deb"
depends on DPKG || DPKG_DEB
config FEATURE_DEB_TAR_GZ
bool "gzip debian packages (normal)"
default y if DPKG || DPKG_DEB
depends on DPKG || DPKG_DEB
help
This is the default compression method inside the debian ar file.
If you want compatibility with standard .deb's you should say yes here.
config FEATURE_DEB_TAR_BZ2
bool "bzip2 debian packages"
default n
depends on DPKG || DPKG_DEB
help
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
with bzip2 instead of gzip.
You only want this if you are creating your own custom debian packages that
use an internal control.tar.bz2 or data.tar.bz2.
config FEATURE_DEB_TAR_LZMA
bool "lzma debian packages"
default n
depends on DPKG || DPKG_DEB
help
This allows dpkg and dpkg-deb to extract deb's that are compressed
internally with lzma instead of gzip.
You only want this if you are creating your own custom debian
packages that use an internal control.tar.lzma or data.tar.lzma.
endmenu
-22
View File
@@ -1,22 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
libs-y += libunarchive/
lib-y:=
lib-$(CONFIG_AR) += ar.o
lib-$(CONFIG_BUNZIP2) += bunzip2.o
lib-$(CONFIG_UNLZMA) += unlzma.o
lib-$(CONFIG_CPIO) += cpio.o
lib-$(CONFIG_DPKG) += dpkg.o
lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
lib-$(CONFIG_GUNZIP) += gunzip.o
lib-$(CONFIG_GZIP) += gzip.o
lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
lib-$(CONFIG_RPM) += rpm.o
lib-$(CONFIG_TAR) += tar.o
lib-$(CONFIG_UNCOMPRESS) += uncompress.o
lib-$(CONFIG_UNZIP) += unzip.o
+304 -65
View File
@@ -1,93 +1,332 @@
/* vi: set sw=4 ts=4: */
/*
* Mini ar implementation for busybox
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@iinet.net.au> 1 June 2000
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* 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.
*
* There is no single standard to adhere to so ar may not portable
* between different systems
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
* 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 "busybox.h"
#include "unarchive.h"
static void header_verbose_list_ar(const file_header_t *file_header)
#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
#define AR_VERBOSE 2
#define AR_DISPLAY 4
#define AR_EXT_TO_FILE 8
#define AR_EXT_TO_STDOUT 16
#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)
{
const char *mode = bb_mode_string(file_header->mode);
char *mtime;
mtime = ctime(&file_header->mtime);
mtime[16] = ' ';
memmove(&mtime[17], &mtime[20], 4);
mtime[21] = '\0';
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid,
(int) file_header->size, &mtime[4], file_header->name);
/* 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);
}
#define AR_CTX_PRINT 0x01
#define AR_CTX_LIST 0x02
#define AR_CTX_EXTRACT 0x04
#define AR_OPT_PRESERVE_DATE 0x08
#define AR_OPT_VERBOSE 0x10
#define AR_OPT_CREATE 0x20
#define AR_OPT_INSERT 0x40
int ar_main(int argc, char **argv)
/* this is from tar.c remove later*/
static long getOctal(const char *cp, int size)
{
archive_handle_t *archive_handle;
unsigned opt;
static const char msg_unsupported_err[] =
"Archive %s not supported. Install binutils 'ar'.";
char magic[8];
long val = 0;
archive_handle = init_handle();
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;
}
/* Prepend '-' to the first argument if required */
opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
opt = getopt32(argc, argv, "ptxovcr");
/*
* 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);
if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
/* 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];
}
if (opt & AR_CTX_LIST) {
archive_handle->action_header = header_list;
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;
}
if (opt & AR_CTX_EXTRACT) {
archive_handle->action_data = data_extract_all;
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);
}
}
if (opt & AR_OPT_PRESERVE_DATE) {
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
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 (opt & AR_OPT_VERBOSE) {
archive_handle->action_header = header_verbose_list_ar;
}
if (opt & AR_OPT_CREATE) {
bb_error_msg_and_die(msg_unsupported_err, "creation");
}
if (opt & AR_OPT_INSERT) {
bb_error_msg_and_die(msg_unsupported_err, "insertion");
}
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);
}
archive_handle->src_fd = xopen(argv[optind++], O_RDONLY);
extern int ar_main(int argc, char **argv)
{
int funct = 0, ret=0, i=0;
char *fileList[16], c, *opt_ptr;
while (optind < argc) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), argv[optind++]);
}
if (argc < 2)
usage(ar_usage);
xread(archive_handle->src_fd, magic, 7);
if (strncmp(magic, "!<arch>", 7) != 0) {
bb_error_msg_and_die("invalid ar magic");
opt_ptr = argv[1];
if (*opt_ptr == '-')
++opt_ptr;
while ((c = *opt_ptr++) != '\0') {
switch (c) {
case 'o': /* preserver original dates */
funct = funct | 1;
break;
case 'p': /* extract to stdout */
funct = funct | 16;
break;
case 't': /* display contents */
funct = funct | 4;
break;
case 'x': /* extract contents of archive */
funct = funct | 8;
break;
case 'v': /* be verbose */
funct = funct | 2;
break;
default:
usage(ar_usage);
}
}
archive_handle->offset += 7;
while (get_header_ar(archive_handle) == EXIT_SUCCESS);
return EXIT_SUCCESS;
for(i=0; i<(argc-2); i++)
fileList[i]=argv[i+2];
if (funct > 3)
ret = readArFile(fileList, (argc-2), funct);
return (ret);
}
-66
View File
@@ -1,66 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "unarchive.h"
#define BUNZIP2_OPT_STDOUT 1
#define BUNZIP2_OPT_FORCE 2
int bunzip2_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
unsigned opt;
int src_fd, dst_fd;
opt = getopt32(argc, argv, "cf");
/* Set input filename and number */
filename = argv[optind];
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
/* Open input file */
src_fd = xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
filename = 0;
}
/* if called as bzcat force the stdout flag */
if ((opt & BUNZIP2_OPT_STDOUT) || applet_name[2] == 'c')
filename = 0;
/* Check that the input is sane. */
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
bb_error_msg_and_die("compressed data not read from terminal, "
"use -f to force it");
}
if (filename) {
struct stat stat_buf;
/* extension = filename+strlen(filename)-4 is buggy:
* strlen may be less than 4 */
char *extension = strrchr(filename, '.');
if (!extension || strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("invalid extension");
}
xstat(filename, &stat_buf);
*extension = '\0';
dst_fd = xopen3(filename, O_WRONLY | O_CREAT | O_TRUNC,
stat_buf.st_mode);
} else dst_fd = STDOUT_FILENO;
status = uncompressStream(src_fd, dst_fd);
if (filename) {
if (status >= 0) filename[strlen(filename)] = '.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("cannot remove %s", filename);
}
}
return status;
}
-86
View File
@@ -1,86 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cpio implementation for busybox
*
* Copyright (C) 2001 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Limitations:
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
*
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "unarchive.h"
#include "busybox.h"
#define CPIO_OPT_EXTRACT 0x01
#define CPIO_OPT_TEST 0x02
#define CPIO_OPT_UNCONDITIONAL 0x04
#define CPIO_OPT_VERBOSE 0x08
#define CPIO_OPT_FILE 0x10
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
#define CPIO_OPT_PRESERVE_MTIME 0x40
int cpio_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename = NULL;
unsigned opt;
/* Initialise */
archive_handle = init_handle();
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
bb_show_usage();
}
if (opt & CPIO_OPT_TEST) {
/* if both extract and test options are given, ignore extract option */
if (opt & CPIO_OPT_EXTRACT) {
opt &= ~CPIO_OPT_EXTRACT;
}
archive_handle->action_header = header_list;
}
if (opt & CPIO_OPT_EXTRACT) {
archive_handle->action_data = data_extract_all;
}
if (opt & CPIO_OPT_UNCONDITIONAL) {
archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
archive_handle->flags &= ~ARCHIVE_EXTRACT_NEWER;
}
if (opt & CPIO_OPT_VERBOSE) {
if (archive_handle->action_header == header_list) {
archive_handle->action_header = header_verbose_list;
} else {
archive_handle->action_header = header_list;
}
}
if (cpio_filename) { /* CPIO_OPT_FILE */
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
archive_handle->seek = seek_by_jump;
}
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
}
while (optind < argc) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), argv[optind]);
optind++;
}
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
return EXIT_SUCCESS;
}
-1819
View File
File diff suppressed because it is too large. Load diff
-96
View File
@@ -1,96 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* dpkg-deb packs, unpacks and provides information about Debian archives.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "unarchive.h"
#define DPKG_DEB_OPT_CONTENTS 1
#define DPKG_DEB_OPT_CONTROL 2
#define DPKG_DEB_OPT_FIELD 4
#define DPKG_DEB_OPT_EXTRACT 8
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
int dpkg_deb_main(int argc, char **argv)
{
archive_handle_t *ar_archive;
archive_handle_t *tar_archive;
llist_t *control_tar_llist = NULL;
unsigned opt;
char *extract_dir = NULL;
short argcount = 1;
/* Setup the tar archive handle */
tar_archive = init_handle();
/* Setup an ar archive handle that refers to the gzip sub archive */
ar_archive = init_handle();
ar_archive->sub_archive = tar_archive;
ar_archive->filter = filter_accept_list_reassign;
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_archive->accept), "data.tar.gz");
llist_add_to(&control_tar_llist, "control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_archive->accept), "data.tar.bz2");
llist_add_to(&control_tar_llist, "control.tar.bz2");
#endif
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = getopt32(argc, argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
}
if (opt & DPKG_DEB_OPT_CONTROL) {
ar_archive->accept = control_tar_llist;
tar_archive->action_data = data_extract_all;
if (optind + 1 == argc) {
extract_dir = "./DEBIAN";
} else {
argcount++;
}
}
if (opt & DPKG_DEB_OPT_FIELD) {
/* Print the entire control file
* it should accept a second argument which specifies a
* specific field to print */
ar_archive->accept = control_tar_llist;
llist_add_to(&(tar_archive->accept), "./control");
tar_archive->filter = filter_accept_list;
tar_archive->action_data = data_extract_to_stdout;
}
if (opt & DPKG_DEB_OPT_EXTRACT) {
tar_archive->action_header = header_list;
}
if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) {
tar_archive->action_data = data_extract_all;
argcount = 2;
}
if ((optind + argcount) != argc) {
bb_show_usage();
}
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY);
/* Workout where to extract the files */
/* 2nd argument is a dir name */
if (argv[optind]) {
extract_dir = argv[optind];
}
if (extract_dir) {
mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */
xchdir(extract_dir);
}
unpack_ar_archive(ar_archive);
/* Cleanup */
close(ar_archive->src_fd);
return EXIT_SUCCESS;
}
+2151 -113
View File
File diff suppressed because it is too large. Load diff
+1437 -516
View File
File diff suppressed because it is too large. Load diff
-59
View File
@@ -1,59 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
lib-y:= \
\
data_skip.o \
data_extract_all.o \
data_extract_to_stdout.o \
data_extract_to_buffer.o \
\
filter_accept_all.o \
filter_accept_list.o \
filter_accept_reject_list.o \
\
header_skip.o \
header_list.o \
header_verbose_list.o \
\
archive_xread_all_eof.o \
\
seek_by_read.o \
seek_by_jump.o \
\
data_align.o \
find_list_entry.o \
open_transformer.o \
init_handle.o
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
DPKG_FILES:= \
get_header_ar.o \
unpack_ar_archive.o \
get_header_tar.o \
filter_accept_list_reassign.o
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
lib-$(CONFIG_CPIO) += get_header_cpio.o
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_TAR) += get_header_tar.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
@@ -1,20 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "unarchive.h"
#include "libbb.h"
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
unsigned char *buf, size_t count)
{
ssize_t size;
size = full_read(archive_handle->src_fd, buf, count);
if (size != 0 && size != count) {
bb_error_msg_and_die("short read: %u of %u",
(unsigned)size, (unsigned)count);
}
return size;
}
-62
View File
@@ -1,62 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h" /* for external decl of check_header_gzip */
void check_header_gzip(int src_fd)
{
union {
unsigned char raw[8];
struct {
unsigned char method;
unsigned char flags;
unsigned int mtime;
unsigned char xtra_flags;
unsigned char os_flags;
} formatted;
} header;
xread(src_fd, header.raw, 8);
/* Check the compression method */
if (header.formatted.method != 8) {
bb_error_msg_and_die("unknown compression method %d",
header.formatted.method);
}
if (header.formatted.flags & 0x04) {
/* bit 2 set: extra field present */
unsigned char extra_short;
extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
while (extra_short > 0) {
/* Ignore extra field */
xread_char(src_fd);
extra_short--;
}
}
/* Discard original name if any */
if (header.formatted.flags & 0x08) {
/* bit 3 set: original file name present */
while(xread_char(src_fd) != 0);
}
/* Discard file comment if any */
if (header.formatted.flags & 0x10) {
/* bit 4 set: file comment present */
while(xread_char(src_fd) != 0);
}
/* Read the header checksum */
if (header.formatted.flags & 0x02) {
xread_char(src_fd);
xread_char(src_fd);
}
return;
}
-22
View File
@@ -1,22 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
{
const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
archive_handle->seek(archive_handle, skip_amount);
archive_handle->offset += skip_amount;
return;
}
-119
View File
@@ -1,119 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
void data_extract_all(archive_handle_t *archive_handle)
{
file_header_t *file_header = archive_handle->file_header;
int dst_fd;
int res;
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
char *name = xstrdup(file_header->name);
bb_make_directory(dirname(name), -1, FILEUTILS_RECUR);
free(name);
}
/* Check if the file already exists */
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the existing entry if it exists */
if (((file_header->mode & S_IFMT) != S_IFDIR)
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
) {
bb_perror_msg_and_die("cannot remove old file");
}
}
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
/* Remove the existing entry if its older than the extracted entry */
struct stat statbuf;
if (lstat(file_header->name, &statbuf) == -1) {
if (errno != ENOENT) {
bb_perror_msg_and_die("cannot stat old file");
}
}
else if (statbuf.st_mtime <= file_header->mtime) {
if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_error_msg("%s not created: newer or "
"same age file exists", file_header->name);
}
data_skip(archive_handle);
return;
}
else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) {
bb_perror_msg_and_die("cannot remove old file %s",
file_header->name);
}
}
/* Handle hard links separately
* We identified hard links as regular files of size 0 with a symlink */
if (S_ISREG(file_header->mode) && (file_header->link_name)
&& (file_header->size == 0)
) {
/* hard link */
res = link(file_header->link_name, file_header->name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("cannot create hard link");
}
} else {
/* Create the filesystem entry */
switch (file_header->mode & S_IFMT) {
case S_IFREG: {
/* Regular file */
dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL,
file_header->mode);
bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
close(dst_fd);
break;
}
case S_IFDIR:
res = mkdir(file_header->name, file_header->mode);
if ((errno != EISDIR) && (res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("extract_archive: %s", file_header->name);
}
break;
case S_IFLNK:
/* Symlink */
res = symlink(file_header->link_name, file_header->name);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create symlink "
"from %s to '%s'",
file_header->name,
file_header->link_name);
}
break;
case S_IFSOCK:
case S_IFBLK:
case S_IFCHR:
case S_IFIFO:
res = mknod(file_header->name, file_header->mode, file_header->device);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create node %s", file_header->name);
}
break;
default:
bb_error_msg_and_die("unrecognized file type");
}
}
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
lchown(file_header->name, file_header->uid, file_header->gid);
}
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
struct utimbuf t;
t.actime = t.modtime = file_header->mtime;
utime(file_header->name, &t);
}
}
@@ -1,18 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright 2002 Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
void data_extract_to_buffer(archive_handle_t *archive_handle)
{
const unsigned int size = archive_handle->file_header->size;
archive_handle->buffer = xzalloc(size + 1);
xread(archive_handle->src_fd, archive_handle->buffer, size);
}
@@ -1,12 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "unarchive.h"
#include <unistd.h>
void data_extract_to_stdout(archive_handle_t *archive_handle)
{
bb_copyfd_size(archive_handle->src_fd, STDOUT_FILENO, archive_handle->file_header->size);
}
-16
View File
@@ -1,16 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "unarchive.h"
#include "libbb.h"
void data_skip(archive_handle_t *archive_handle)
{
archive_handle->seek(archive_handle, archive_handle->file_header->size);
}
-731
View File
@@ -1,731 +0,0 @@
/* vi: set sw=4 ts=4: */
/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
which also acknowledges contributions by Mike Burrows, David Wheeler,
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
Robert Sedgewick, and Jon L. Bentley.
Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/*
Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org).
More efficient reading of Huffman codes, a streamlined read_bunzip()
function, and various other tweaks. In (limited) tests, approximately
20% faster than bzcat on x86 and about 10% faster on arm.
Note that about 2/3 of the time is spent in read_unzip() reversing
the Burrows-Wheeler transformation. Much of that time is delay
resulting from cache misses.
I would ask that anyone benefiting from this work, especially those
using it in commercial products, consider making a donation to my local
non-profit hospice organization (www.hospiceacadiana.com) in the name of
the woman I loved, Toni W. Hagan, who passed away Feb. 12, 2003.
Manuel
*/
#include "libbb.h"
#include "unarchive.h"
/* Constants for Huffman coding */
#define MAX_GROUPS 6
#define GROUP_SIZE 50 /* 64 would have been more efficient */
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
#define SYMBOL_RUNA 0
#define SYMBOL_RUNB 1
/* Status return values */
#define RETVAL_OK 0
#define RETVAL_LAST_BLOCK (-1)
#define RETVAL_NOT_BZIP_DATA (-2)
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
#define RETVAL_DATA_ERROR (-5)
#define RETVAL_OUT_OF_MEMORY (-6)
#define RETVAL_OBSOLETE_INPUT (-7)
/* Other housekeeping constants */
#define IOBUF_SIZE 4096
/* This is what we know about each Huffman coding group */
struct group_data {
/* We have an extra slot at the end of limit[] for a sentinal value. */
int limit[MAX_HUFCODE_BITS+1],base[MAX_HUFCODE_BITS],permute[MAX_SYMBOLS];
int minLen, maxLen;
};
/* Structure holding all the housekeeping data, including IO buffers and
memory that persists between calls to bunzip */
typedef struct {
/* State for interrupting output loop */
int writeCopies,writePos,writeRunCountdown,writeCount,writeCurrent;
/* I/O tracking data (file handles, buffers, positions, etc.) */
int in_fd,out_fd,inbufCount,inbufPos /*,outbufPos*/;
unsigned char *inbuf /*,*outbuf*/;
unsigned int inbufBitCount, inbufBits;
/* The CRC values stored in the block header and calculated from the data */
uint32_t headerCRC, totalCRC, writeCRC;
uint32_t *crc32Table;
/* Intermediate buffer and its size (in bytes) */
unsigned int *dbuf, dbufSize;
/* These things are a bit too big to go on the stack */
unsigned char selectors[32768]; /* nSelectors=15 bits */
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
/* For I/O error handling */
jmp_buf jmpbuf;
} bunzip_data;
/* Return the next nnn bits of input. All reads from the compressed input
are done through this function. All reads are big endian */
static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
{
unsigned int bits=0;
/* If we need to get more data from the byte buffer, do so. (Loop getting
one byte at a time to enforce endianness and avoid unaligned access.) */
while (bd->inbufBitCount<bits_wanted) {
/* If we need to read more data from file into byte buffer, do so */
if(bd->inbufPos==bd->inbufCount) {
if((bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE)) <= 0)
longjmp(bd->jmpbuf,RETVAL_UNEXPECTED_INPUT_EOF);
bd->inbufPos=0;
}
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
if(bd->inbufBitCount>=24) {
bits=bd->inbufBits&((1<<bd->inbufBitCount)-1);
bits_wanted-=bd->inbufBitCount;
bits<<=bits_wanted;
bd->inbufBitCount=0;
}
/* Grab next 8 bits of input from buffer. */
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
bd->inbufBitCount+=8;
}
/* Calculate result */
bd->inbufBitCount-=bits_wanted;
bits|=(bd->inbufBits>>bd->inbufBitCount)&((1<<bits_wanted)-1);
return bits;
}
/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */
static int get_next_block(bunzip_data *bd)
{
struct group_data *hufGroup;
int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector,
i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256];
unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
unsigned int *dbuf,origPtr;
dbuf=bd->dbuf;
dbufSize=bd->dbufSize;
selectors=bd->selectors;
/* Reset longjmp I/O error handling */
i=setjmp(bd->jmpbuf);
if(i) return i;
/* Read in header signature and CRC, then validate signature.
(last block signature means CRC is for whole file, return now) */
i = get_bits(bd,24);
j = get_bits(bd,24);
bd->headerCRC=get_bits(bd,32);
if ((i == 0x177245) && (j == 0x385090)) return RETVAL_LAST_BLOCK;
if ((i != 0x314159) || (j != 0x265359)) return RETVAL_NOT_BZIP_DATA;
/* We can add support for blockRandomised if anybody complains. There was
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
it didn't actually work. */
if(get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT;
if((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
/* mapping table: if some byte values are never used (encoding things
like ascii text), the compression code removes the gaps to have fewer
symbols to deal with, and writes a sparse bitfield indicating which
values were present. We make a translation table to convert the symbols
back to the corresponding bytes. */
t=get_bits(bd, 16);
symTotal=0;
for (i=0;i<16;i++) {
if(t&(1<<(15-i))) {
k=get_bits(bd,16);
for(j=0;j<16;j++)
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
}
}
/* How many different Huffman coding groups does this block use? */
groupCount=get_bits(bd,3);
if (groupCount<2 || groupCount>MAX_GROUPS) return RETVAL_DATA_ERROR;
/* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding
group. Read in the group selector list, which is stored as MTF encoded
bit runs. (MTF=Move To Front, as each value is used it's moved to the
start of the list.) */
if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR;
for(i=0; i<groupCount; i++) mtfSymbol[i] = i;
for(i=0; i<nSelectors; i++) {
/* Get next value */
for(j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
/* Decode MTF to get the next selector */
uc = mtfSymbol[j];
for(;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
mtfSymbol[0]=selectors[i]=uc;
}
/* Read the Huffman coding tables for each group, which code for symTotal
literal symbols, plus two run symbols (RUNA, RUNB) */
symCount=symTotal+2;
for (j=0; j<groupCount; j++) {
unsigned char length[MAX_SYMBOLS],temp[MAX_HUFCODE_BITS+1];
int minLen, maxLen, pp;
/* Read Huffman code lengths for each symbol. They're stored in
a way similar to mtf; record a starting value for the first symbol,
and an offset from the previous value for everys symbol after that.
(Subtracting 1 before the loop and then adding it back at the end is
an optimization that makes the test inside the loop simpler: symbol
length 0 becomes negative, so an unsigned inequality catches it.) */
t=get_bits(bd, 5)-1;
for (i = 0; i < symCount; i++) {
for(;;) {
if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
return RETVAL_DATA_ERROR;
/* If first bit is 0, stop. Else second bit indicates whether
to increment or decrement the value. Optimization: grab 2
bits and unget the second if the first was 0. */
k = get_bits(bd,2);
if (k < 2) {
bd->inbufBitCount++;
break;
}
/* Add one if second bit 1, else subtract 1. Avoids if/else */
t+=(((k+1)&2)-1);
}
/* Correct for the initial -1, to get the final symbol length */
length[i]=t+1;
}
/* Find largest and smallest lengths in this group */
minLen=maxLen=length[0];
for(i = 1; i < symCount; i++) {
if(length[i] > maxLen) maxLen = length[i];
else if(length[i] < minLen) minLen = length[i];
}
/* Calculate permute[], base[], and limit[] tables from length[].
*
* permute[] is the lookup table for converting Huffman coded symbols
* into decoded symbols. base[] is the amount to subtract from the
* value of a Huffman symbol of a given length when using permute[].
*
* limit[] indicates the largest numerical value a symbol with a given
* number of bits can have. This is how the Huffman codes can vary in
* length: each code with a value>limit[length] needs another bit.
*/
hufGroup=bd->groups+j;
hufGroup->minLen = minLen;
hufGroup->maxLen = maxLen;
/* Note that minLen can't be smaller than 1, so we adjust the base
and limit array pointers so we're not always wasting the first
entry. We do this again when using them (during symbol decoding).*/
base=hufGroup->base-1;
limit=hufGroup->limit-1;
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
pp=0;
for(i=minLen;i<=maxLen;i++) {
temp[i]=limit[i]=0;
for(t=0;t<symCount;t++)
if(length[t]==i) hufGroup->permute[pp++] = t;
}
/* Count symbols coded for at each bit length */
for (i=0;i<symCount;i++) temp[length[i]]++;
/* Calculate limit[] (the largest symbol-coding value at each bit
* length, which is (previous limit<<1)+symbols at this level), and
* base[] (number of symbols to ignore at each bit length, which is
* limit minus the cumulative count of symbols coded for already). */
pp=t=0;
for (i=minLen; i<maxLen; i++) {
pp+=temp[i];
/* We read the largest possible symbol size and then unget bits
after determining how many we need, and those extra bits could
be set to anything. (They're noise from future symbols.) At
each level we're really only interested in the first few bits,
so here we set all the trailing to-be-ignored bits to 1 so they
don't affect the value>limit[length] comparison. */
limit[i]= (pp << (maxLen - i)) - 1;
pp<<=1;
base[i+1]=pp-(t+=temp[i]);
}
limit[maxLen+1] = INT_MAX; /* Sentinal value for reading next sym. */
limit[maxLen]=pp+temp[maxLen]-1;
base[minLen]=0;
}
/* We've finished reading and digesting the block header. Now read this
block's Huffman coded symbols from the file and undo the Huffman coding
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
/* Initialize symbol occurrence counters and symbol Move To Front table */
for(i=0;i<256;i++) {
byteCount[i] = 0;
mtfSymbol[i]=(unsigned char)i;
}
/* Loop through compressed symbols. */
runPos=dbufCount=selector=0;
for(;;) {
/* fetch next Huffman coding group from list. */
symCount=GROUP_SIZE-1;
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
hufGroup=bd->groups+selectors[selector++];
base=hufGroup->base-1;
limit=hufGroup->limit-1;
continue_this_group:
/* Read next Huffman-coded symbol. */
/* Note: It is far cheaper to read maxLen bits and back up than it is
to read minLen bits and then an additional bit at a time, testing
as we go. Because there is a trailing last block (with file CRC),
there is no danger of the overread causing an unexpected EOF for a
valid compressed file. As a further optimization, we do the read
inline (falling back to a call to get_bits if the buffer runs
dry). The following (up to got_huff_bits:) is equivalent to
j=get_bits(bd,hufGroup->maxLen);
*/
while (bd->inbufBitCount<hufGroup->maxLen) {
if(bd->inbufPos==bd->inbufCount) {
j = get_bits(bd,hufGroup->maxLen);
goto got_huff_bits;
}
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
bd->inbufBitCount+=8;
};
bd->inbufBitCount-=hufGroup->maxLen;
j = (bd->inbufBits>>bd->inbufBitCount)&((1<<hufGroup->maxLen)-1);
got_huff_bits:
/* Figure how how many bits are in next symbol and unget extras */
i=hufGroup->minLen;
while(j>limit[i]) ++i;
bd->inbufBitCount += (hufGroup->maxLen - i);
/* Huffman decode value to get nextSym (with bounds checking) */
if ((i > hufGroup->maxLen)
|| (((unsigned)(j=(j>>(hufGroup->maxLen-i))-base[i]))
>= MAX_SYMBOLS))
return RETVAL_DATA_ERROR;
nextSym = hufGroup->permute[j];
/* We have now decoded the symbol, which indicates either a new literal
byte, or a repeated run of the most recent literal byte. First,
check if nextSym indicates a repeated run, and if so loop collecting
how many times to repeat the last literal. */
if (((unsigned)nextSym) <= SYMBOL_RUNB) { /* RUNA or RUNB */
/* If this is the start of a new run, zero out counter */
if(!runPos) {
runPos = 1;
t = 0;
}
/* Neat trick that saves 1 symbol: instead of or-ing 0 or 1 at
each bit position, add 1 or 2 instead. For example,
1011 is 1<<0 + 1<<1 + 2<<2. 1010 is 2<<0 + 2<<1 + 1<<2.
You can make any bit pattern that way using 1 less symbol than
the basic or 0/1 method (except all bits 0, which would use no
symbols, but a run of length 0 doesn't mean anything in this
context). Thus space is saved. */
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
if(runPos < dbufSize) runPos <<= 1;
goto end_of_huffman_loop;
}
/* When we hit the first non-run symbol after a run, we now know
how many times to repeat the last literal, so append that many
copies to our buffer of decoded symbols (dbuf) now. (The last
literal used is the one at the head of the mtfSymbol array.) */
if(runPos) {
runPos=0;
if(dbufCount+t>=dbufSize) return RETVAL_DATA_ERROR;
uc = symToByte[mtfSymbol[0]];
byteCount[uc] += t;
while(t--) dbuf[dbufCount++]=uc;
}
/* Is this the terminating symbol? */
if(nextSym>symTotal) break;
/* At this point, nextSym indicates a new literal character. Subtract
one to get the position in the MTF array at which this literal is
currently to be found. (Note that the result can't be -1 or 0,
because 0 and 1 are RUNA and RUNB. But another instance of the
first symbol in the mtf array, position 0, would have been handled
as part of a run above. Therefore 1 unused mtf position minus
2 non-literal nextSym values equals -1.) */
if(dbufCount>=dbufSize) return RETVAL_DATA_ERROR;
i = nextSym - 1;
uc = mtfSymbol[i];
/* Adjust the MTF array. Since we typically expect to move only a
* small number of symbols, and are bound by 256 in any case, using
* memmove here would typically be bigger and slower due to function
* call overhead and other assorted setup costs. */
do {
mtfSymbol[i] = mtfSymbol[i-1];
} while (--i);
mtfSymbol[0] = uc;
uc=symToByte[uc];
/* We have our literal byte. Save it into dbuf. */
byteCount[uc]++;
dbuf[dbufCount++] = (unsigned int)uc;
/* Skip group initialization if we're not done with this group. Done
* this way to avoid compiler warning. */
end_of_huffman_loop:
if(symCount--) goto continue_this_group;
}
/* At this point, we've read all the Huffman-coded symbols (and repeated
runs) for this block from the input stream, and decoded them into the
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
Now undo the Burrows-Wheeler transform on dbuf.
See http://dogma.net/markn/articles/bwt/bwt.htm
*/
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
j=0;
for(i=0;i<256;i++) {
k=j+byteCount[i];
byteCount[i] = j;
j=k;
}
/* Figure out what order dbuf would be in if we sorted it. */
for (i=0;i<dbufCount;i++) {
uc=(unsigned char)(dbuf[i] & 0xff);
dbuf[byteCount[uc]] |= (i << 8);
byteCount[uc]++;
}
/* Decode first byte by hand to initialize "previous" byte. Note that it
doesn't get output, and if the first three characters are identical
it doesn't qualify as a run (hence writeRunCountdown=5). */
if(dbufCount) {
if(origPtr>=dbufCount) return RETVAL_DATA_ERROR;
bd->writePos=dbuf[origPtr];
bd->writeCurrent=(unsigned char)(bd->writePos&0xff);
bd->writePos>>=8;
bd->writeRunCountdown=5;
}
bd->writeCount=dbufCount;
return RETVAL_OK;
}
/* Undo burrows-wheeler transform on intermediate buffer to produce output.
If start_bunzip was initialized with out_fd=-1, then up to len bytes of
data are written to outbuf. Return value is number of bytes written or
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
are ignored, data is written to out_fd and return is RETVAL_OK or error.
*/
static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
{
const unsigned int *dbuf;
int pos,current,previous,gotcount;
/* If last read was short due to end of file, return last block now */
if(bd->writeCount<0) return bd->writeCount;
gotcount = 0;
dbuf=bd->dbuf;
pos=bd->writePos;
current=bd->writeCurrent;
/* We will always have pending decoded data to write into the output
buffer unless this is the very first call (in which case we haven't
Huffman-decoded a block into the intermediate buffer yet). */
if (bd->writeCopies) {
/* Inside the loop, writeCopies means extra copies (beyond 1) */
--bd->writeCopies;
/* Loop outputting bytes */
for(;;) {
/* If the output buffer is full, snapshot state and return */
if(gotcount >= len) {
bd->writePos=pos;
bd->writeCurrent=current;
bd->writeCopies++;
return len;
}
/* Write next byte into output buffer, updating CRC */
outbuf[gotcount++] = current;
bd->writeCRC=(((bd->writeCRC)<<8)
^bd->crc32Table[((bd->writeCRC)>>24)^current]);
/* Loop now if we're outputting multiple copies of this byte */
if (bd->writeCopies) {
--bd->writeCopies;
continue;
}
decode_next_byte:
if (!bd->writeCount--) break;
/* Follow sequence vector to undo Burrows-Wheeler transform */
previous=current;
pos=dbuf[pos];
current=pos&0xff;
pos>>=8;
/* After 3 consecutive copies of the same byte, the 4th is a repeat
count. We count down from 4 instead
* of counting up because testing for non-zero is faster */
if(--bd->writeRunCountdown) {
if(current!=previous) bd->writeRunCountdown=4;
} else {
/* We have a repeated run, this byte indicates the count */
bd->writeCopies=current;
current=previous;
bd->writeRunCountdown=5;
/* Sometimes there are just 3 bytes (run length 0) */
if(!bd->writeCopies) goto decode_next_byte;
/* Subtract the 1 copy we'd output anyway to get extras */
--bd->writeCopies;
}
}
/* Decompression of this block completed successfully */
bd->writeCRC=~bd->writeCRC;
bd->totalCRC=((bd->totalCRC<<1) | (bd->totalCRC>>31)) ^ bd->writeCRC;
/* If this block had a CRC error, force file level CRC error. */
if(bd->writeCRC!=bd->headerCRC) {
bd->totalCRC=bd->headerCRC+1;
return RETVAL_LAST_BLOCK;
}
}
/* Refill the intermediate buffer by Huffman-decoding next block of input */
/* (previous is just a convenient unused temp variable here) */
previous=get_next_block(bd);
if(previous) {
bd->writeCount=previous;
return (previous!=RETVAL_LAST_BLOCK) ? previous : gotcount;
}
bd->writeCRC=~0;
pos=bd->writePos;
current=bd->writeCurrent;
goto decode_next_byte;
}
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
ignored, and data is read from file handle into temporary buffer. */
static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
int len)
{
bunzip_data *bd;
unsigned int i;
const unsigned int BZh0=(((unsigned int)'B')<<24)+(((unsigned int)'Z')<<16)
+(((unsigned int)'h')<<8)+(unsigned int)'0';
/* Figure out how much data to allocate */
i=sizeof(bunzip_data);
if(in_fd!=-1) i+=IOBUF_SIZE;
/* Allocate bunzip_data. Most fields initialize to zero. */
bd=*bdp=xzalloc(i);
/* Setup input buffer */
if(-1==(bd->in_fd=in_fd)) {
bd->inbuf=inbuf;
bd->inbufCount=len;
} else bd->inbuf=(unsigned char *)(bd+1);
/* Init the CRC32 table (big endian) */
bd->crc32Table = crc32_filltable(1);
/* Setup for I/O error handling via longjmp */
i=setjmp(bd->jmpbuf);
if(i) return i;
/* Ensure that file starts with "BZh['1'-'9']." */
i = get_bits(bd,32);
if (((unsigned int)(i-BZh0-1)) >= 9) return RETVAL_NOT_BZIP_DATA;
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
uncompressed data. Allocate intermediate buffer for block. */
bd->dbufSize=100000*(i-BZh0);
bd->dbuf=xmalloc(bd->dbufSize * sizeof(int));
return RETVAL_OK;
}
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data,
not end of file.) */
USE_DESKTOP(long long) int
uncompressStream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
char *outbuf;
bunzip_data *bd;
int i;
outbuf=xmalloc(IOBUF_SIZE);
i=start_bunzip(&bd,src_fd,0,0);
if(!i) {
for(;;) {
if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break;
if(i!=write(dst_fd,outbuf,i)) {
i=RETVAL_UNEXPECTED_OUTPUT_EOF;
break;
}
USE_DESKTOP(total_written += i;)
}
}
/* Check CRC and release memory */
if(i==RETVAL_LAST_BLOCK) {
if (bd->headerCRC!=bd->totalCRC) {
bb_error_msg("data integrity error when decompressing");
} else {
i=RETVAL_OK;
}
} else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
bb_error_msg("compressed file ends unexpectedly");
} else {
bb_error_msg("decompression failed");
}
free(bd->dbuf);
free(bd);
free(outbuf);
return i ? i : USE_DESKTOP(total_written) + 0;
}
#ifdef TESTING
static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data",
"Unexpected input EOF","Unexpected output EOF","Data error",
"Out of memory","Obsolete (pre 0.9.5) bzip format not supported."};
/* Dumb little test thing, decompress stdin to stdout */
int main(int argc, char *argv[])
{
int i=uncompressStream(0,1);
char c;
if(i<0) fprintf(stderr,"%s\n", bunzip_errors[-i]);
else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n");
return -i;
}
#endif
@@ -1,292 +0,0 @@
/* vi: set sw=4 ts=4: */
#include "libbb.h"
/* uncompress for busybox -- (c) 2002 Robert Griebl
*
* based on the original compress42.c source
* (see disclaimer below)
*/
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
*
* Authors:
* Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
* Jim McKie (decvax!mcvax!jim)
* Steve Davies (decvax!vax135!petsd!peora!srd)
* Ken Turkowski (decvax!decwrl!turtlevax!ken)
* James A. Woods (decvax!ihnp4!ames!jaw)
* Joe Orost (decvax!vax135!petsd!joe)
* Dave Mack (csu@alembic.acs.com)
* Peter Jannesen, Network Communication Systems
* (peter@ncs.nl)
*
* marc@suse.de : a small security fix for a buffer overflow
*
* [... History snipped ...]
*
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/* Default input buffer size */
#define IBUFSIZ 2048
/* Default output buffer size */
#define OBUFSIZ 2048
/* Defines for third byte of header */
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
/* Masks 0x20 and 0x40 are free. */
/* I think 0x20 should mean that there is */
/* a fourth header byte (for expansion). */
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
/* compression rate is dropping flush tables */
/* the next two codes should not be changed lightly, as they must not */
/* lie within the contiguous general code space. */
#define FIRST 257 /* first free entry */
#define CLEAR 256 /* table clear output code */
#define INIT_BITS 9 /* initial number of bits/code */
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
#define FAST
#define HBITS 17 /* 50% occupancy */
#define HSIZE (1<<HBITS)
#define HMASK (HSIZE-1)
#define HPRIME 9941
#define BITS 16
#undef MAXSEG_64K
#define MAXCODE(n) (1L << (n))
/* Block compress mode -C compatible with 2.0 */
static int block_mode = BLOCK_MODE;
/* user settable max # bits/code */
static int maxbits = BITS;
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
#define tab_prefixof(i) codetabof(i)
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
#define clear_htab() memset(htab, -1, HSIZE)
#define clear_tab_prefixof() memset(codetab, 0, 256);
/*
* Decompress stdin to stdout. This routine adapts to the codes in the
* file building the "string" table on-the-fly; requiring no table to
* be stored in the compressed file. The tables used herein are shared
* with those of the compress() routine. See the definitions above.
*/
USE_DESKTOP(long long) int
uncompress(int fd_in, int fd_out)
{
USE_DESKTOP(long long total_written = 0;)
unsigned char *stackp;
long int code;
int finchar;
long int oldcode;
long int incode;
int inbits;
int posbits;
int outpos;
int insize;
int bitmask;
long int free_ent;
long int maxcode;
long int maxmaxcode;
int n_bits;
int rsize = 0;
RESERVE_CONFIG_UBUFFER(inbuf, IBUFSIZ + 64);
RESERVE_CONFIG_UBUFFER(outbuf, OBUFSIZ + 2048);
unsigned char htab[HSIZE];
unsigned short codetab[HSIZE];
memset(inbuf, 0, IBUFSIZ + 64);
memset(outbuf, 0, OBUFSIZ + 2048);
insize = 0;
inbuf[0] = xread_char(fd_in);
maxbits = inbuf[0] & BIT_MASK;
block_mode = inbuf[0] & BLOCK_MODE;
maxmaxcode = MAXCODE(maxbits);
if (maxbits > BITS) {
bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
BITS);
return -1;
}
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
bitmask = (1 << n_bits) - 1;
oldcode = -1;
finchar = 0;
outpos = 0;
posbits = 0 << 3;
free_ent = ((block_mode) ? FIRST : 256);
/* As above, initialize the first 256 entries in the table. */
clear_tab_prefixof();
for (code = 255; code >= 0; --code) {
tab_suffixof(code) = (unsigned char) code;
}
do {
resetbuf:;
{
int i;
int e;
int o;
e = insize - (o = (posbits >> 3));
for (i = 0; i < e; ++i)
inbuf[i] = inbuf[i + o];
insize = e;
posbits = 0;
}
if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
insize += rsize;
}
inbits = ((rsize > 0) ? (insize - insize % n_bits) << 3 :
(insize << 3) - (n_bits - 1));
while (inbits > posbits) {
if (free_ent > maxcode) {
posbits =
((posbits - 1) +
((n_bits << 3) -
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
++n_bits;
if (n_bits == maxbits) {
maxcode = maxmaxcode;
} else {
maxcode = MAXCODE(n_bits) - 1;
}
bitmask = (1 << n_bits) - 1;
goto resetbuf;
}
{
unsigned char *p = &inbuf[posbits >> 3];
code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
}
posbits += n_bits;
if (oldcode == -1) {
oldcode = code;
finchar = (int) oldcode;
outbuf[outpos++] = (unsigned char) finchar;
continue;
}
if (code == CLEAR && block_mode) {
clear_tab_prefixof();
free_ent = FIRST - 1;
posbits =
((posbits - 1) +
((n_bits << 3) -
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
bitmask = (1 << n_bits) - 1;
goto resetbuf;
}
incode = code;
stackp = de_stack;
/* Special case for KwKwK string. */
if (code >= free_ent) {
if (code > free_ent) {
unsigned char *p;
posbits -= n_bits;
p = &inbuf[posbits >> 3];
bb_error_msg
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
(posbits & 07));
bb_error_msg("uncompress: corrupt input");
return -1;
}
*--stackp = (unsigned char) finchar;
code = oldcode;
}
/* Generate output characters in reverse order */
while ((long int) code >= (long int) 256) {
*--stackp = tab_suffixof(code);
code = tab_prefixof(code);
}
*--stackp = (unsigned char) (finchar = tab_suffixof(code));
/* And put them out in forward order */
{
int i;
if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) {
do {
if (i > OBUFSIZ - outpos) {
i = OBUFSIZ - outpos;
}
if (i > 0) {
memcpy(outbuf + outpos, stackp, i);
outpos += i;
}
if (outpos >= OBUFSIZ) {
write(fd_out, outbuf, outpos);
USE_DESKTOP(total_written += outpos;)
outpos = 0;
}
stackp += i;
} while ((i = (de_stack - stackp)) > 0);
} else {
memcpy(outbuf + outpos, stackp, i);
outpos += i;
}
}
/* Generate the new entry. */
if ((code = free_ent) < maxmaxcode) {
tab_prefixof(code) = (unsigned short) oldcode;
tab_suffixof(code) = (unsigned char) finchar;
free_ent = code + 1;
}
/* Remember previous code. */
oldcode = incode;
}
} while (rsize > 0);
if (outpos > 0) {
write(fd_out, outbuf, outpos);
USE_DESKTOP(total_written += outpos;)
}
RELEASE_CONFIG_BUFFER(inbuf);
RELEASE_CONFIG_BUFFER(outbuf);
return USE_DESKTOP(total_written) + 0;
}
-478
View File
@@ -1,478 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
* Copyright (C) 1999-2005 Igor Pavlov
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
#ifdef CONFIG_FEATURE_LZMA_FAST
# define speed_inline ATTRIBUTE_ALWAYS_INLINE
#else
# define speed_inline
#endif
typedef struct {
int fd;
uint8_t *ptr;
uint8_t *buffer;
uint8_t *buffer_end;
int buffer_size;
uint32_t code;
uint32_t range;
uint32_t bound;
} rc_t;
#define RC_TOP_BITS 24
#define RC_MOVE_BITS 5
#define RC_MODEL_TOTAL_BITS 11
/* Called twice: once at startup and once in rc_normalize() */
static void rc_read(rc_t * rc)
{
rc->buffer_size = read(rc->fd, rc->buffer, rc->buffer_size);
if (rc->buffer_size <= 0)
bb_error_msg_and_die("unexpected EOF");
rc->ptr = rc->buffer;
rc->buffer_end = rc->buffer + rc->buffer_size;
}
/* Called once */
static void rc_init(rc_t * rc, int fd, int buffer_size)
{
int i;
rc->fd = fd;
rc->buffer = xmalloc(buffer_size);
rc->buffer_size = buffer_size;
rc->buffer_end = rc->buffer + rc->buffer_size;
rc->ptr = rc->buffer_end;
rc->code = 0;
rc->range = 0xFFFFFFFF;
for (i = 0; i < 5; i++) {
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->code = (rc->code << 8) | *rc->ptr++;
}
}
/* Called once. TODO: bb_maybe_free() */
static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc->buffer);
}
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
static void rc_do_normalize(rc_t * rc)
{
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* Called 9 times */
/* Why rc_is_bit_0_helper exists?
* Because we want to always expose (rc->code < rc->bound) to optimizer
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
{
rc_normalize(rc);
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
}
/* Called ~10 times, but very small, thus inlined */
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
{
rc->range = rc->bound;
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
}
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
{
rc->range -= rc->bound;
rc->code -= rc->bound;
*p -= *p >> RC_MOVE_BITS;
}
/* Called 4 times in unlzma loop */
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
{
if (rc_is_bit_0(rc, p)) {
rc_update_bit_0(rc, p);
*symbol *= 2;
return 0;
} else {
rc_update_bit_1(rc, p);
*symbol = *symbol * 2 + 1;
return 1;
}
}
/* Called once */
static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
if (rc->code >= rc->range) {
rc->code -= rc->range;
return 1;
}
return 0;
}
/* Called twice */
static speed_inline void
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
{
int i = num_levels;
*symbol = 1;
while (i--)
rc_get_bit(rc, p + *symbol, symbol);
*symbol -= 1 << num_levels;
}
typedef struct {
uint8_t pos;
uint32_t dict_size;
uint64_t dst_size;
} __attribute__ ((packed)) lzma_header_t;
#define LZMA_BASE_SIZE 1846
#define LZMA_LIT_SIZE 768
#define LZMA_NUM_POS_BITS_MAX 4
#define LZMA_LEN_NUM_LOW_BITS 3
#define LZMA_LEN_NUM_MID_BITS 3
#define LZMA_LEN_NUM_HIGH_BITS 8
#define LZMA_LEN_CHOICE 0
#define LZMA_LEN_CHOICE_2 (LZMA_LEN_CHOICE + 1)
#define LZMA_LEN_LOW (LZMA_LEN_CHOICE_2 + 1)
#define LZMA_LEN_MID (LZMA_LEN_LOW \
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS)))
#define LZMA_LEN_HIGH (LZMA_LEN_MID \
+(1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS)))
#define LZMA_NUM_LEN_PROBS (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS))
#define LZMA_NUM_STATES 12
#define LZMA_NUM_LIT_STATES 7
#define LZMA_START_POS_MODEL_INDEX 4
#define LZMA_END_POS_MODEL_INDEX 14
#define LZMA_NUM_FULL_DISTANCES (1 << (LZMA_END_POS_MODEL_INDEX >> 1))
#define LZMA_NUM_POS_SLOT_BITS 6
#define LZMA_NUM_LEN_TO_POS_STATES 4
#define LZMA_NUM_ALIGN_BITS 4
#define LZMA_MATCH_MIN_LEN 2
#define LZMA_IS_MATCH 0
#define LZMA_IS_REP (LZMA_IS_MATCH + (LZMA_NUM_STATES <<LZMA_NUM_POS_BITS_MAX))
#define LZMA_IS_REP_G0 (LZMA_IS_REP + LZMA_NUM_STATES)
#define LZMA_IS_REP_G1 (LZMA_IS_REP_G0 + LZMA_NUM_STATES)
#define LZMA_IS_REP_G2 (LZMA_IS_REP_G1 + LZMA_NUM_STATES)
#define LZMA_IS_REP_0_LONG (LZMA_IS_REP_G2 + LZMA_NUM_STATES)
#define LZMA_POS_SLOT (LZMA_IS_REP_0_LONG \
+ (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX))
#define LZMA_SPEC_POS (LZMA_POS_SLOT \
+(LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS))
#define LZMA_ALIGN (LZMA_SPEC_POS \
+ LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX)
#define LZMA_LEN_CODER (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS))
#define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS)
#define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS)
USE_DESKTOP(long long) int
unlzma(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
lzma_header_t header;
int lc, pb, lp;
uint32_t pos_state_mask;
uint32_t literal_pos_mask;
uint32_t pos;
uint16_t *p;
uint16_t *prob;
uint16_t *prob_lit;
int num_bits;
int num_probs;
rc_t rc;
int i, mi;
uint8_t *buffer;
uint8_t previous_byte = 0;
size_t buffer_pos = 0, global_pos = 0;
int len = 0;
int state = 0;
uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
if (read(src_fd, &header, sizeof(header)) != sizeof(header))
bb_error_msg_and_die("can't read header");
if (header.pos >= (9 * 5 * 5))
bb_error_msg_and_die("bad header");
mi = header.pos / 9;
lc = header.pos % 9;
pb = mi / 5;
lp = mi % 5;
pos_state_mask = (1 << pb) - 1;
literal_pos_mask = (1 << lp) - 1;
header.dict_size = SWAP_LE32(header.dict_size);
header.dst_size = SWAP_LE64(header.dst_size);
if (header.dict_size == 0)
header.dict_size = 1;
buffer = xmalloc(MIN(header.dst_size, header.dict_size));
num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
p = xmalloc(num_probs * sizeof(*p));
num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp));
for (i = 0; i < num_probs; i++)
p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
rc_init(&rc, src_fd, 0x10000);
while (global_pos + buffer_pos < header.dst_size) {
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
prob =
p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
if (rc_is_bit_0(&rc, prob)) {
mi = 1;
rc_update_bit_0(&rc, prob);
prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
* ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
+ (previous_byte >> (8 - lc)))));
if (state >= LZMA_NUM_LIT_STATES) {
int match_byte;
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
match_byte = buffer[pos];
do {
int bit;
match_byte <<= 1;
bit = match_byte & 0x100;
prob_lit = prob + 0x100 + bit + mi;
if (rc_get_bit(&rc, prob_lit, &mi)) {
if (!bit)
break;
} else {
if (bit)
break;
}
} while (mi < 0x100);
}
while (mi < 0x100) {
prob_lit = prob + mi;
rc_get_bit(&rc, prob_lit, &mi);
}
previous_byte = (uint8_t) mi;
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
// FIXME: error check
write(dst_fd, buffer, header.dict_size);
USE_DESKTOP(total_written += header.dict_size;)
}
if (state < 4)
state = 0;
else if (state < 10)
state -= 3;
else
state -= 6;
} else {
int offset;
uint16_t *prob_len;
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
rep3 = rep2;
rep2 = rep1;
rep1 = rep0;
state = state < LZMA_NUM_LIT_STATES ? 0 : 3;
prob = p + LZMA_LEN_CODER;
} else {
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP_G0 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
prob = (p + LZMA_IS_REP_0_LONG
+ (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
// FIXME: error check
write(dst_fd, buffer, header.dict_size);
USE_DESKTOP(total_written += header.dict_size;)
}
continue;
} else {
rc_update_bit_1(&rc, prob);
}
} else {
uint32_t distance;
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP_G1 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
distance = rep1;
} else {
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP_G2 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
distance = rep2;
} else {
rc_update_bit_1(&rc, prob);
distance = rep3;
rep3 = rep2;
}
rep2 = rep1;
}
rep1 = rep0;
rep0 = distance;
}
state = state < LZMA_NUM_LIT_STATES ? 8 : 11;
prob = p + LZMA_REP_LEN_CODER;
}
prob_len = prob + LZMA_LEN_CHOICE;
if (rc_is_bit_0(&rc, prob_len)) {
rc_update_bit_0(&rc, prob_len);
prob_len = (prob + LZMA_LEN_LOW
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
offset = 0;
num_bits = LZMA_LEN_NUM_LOW_BITS;
} else {
rc_update_bit_1(&rc, prob_len);
prob_len = prob + LZMA_LEN_CHOICE_2;
if (rc_is_bit_0(&rc, prob_len)) {
rc_update_bit_0(&rc, prob_len);
prob_len = (prob + LZMA_LEN_MID
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
offset = 1 << LZMA_LEN_NUM_LOW_BITS;
num_bits = LZMA_LEN_NUM_MID_BITS;
} else {
rc_update_bit_1(&rc, prob_len);
prob_len = prob + LZMA_LEN_HIGH;
offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
+ (1 << LZMA_LEN_NUM_MID_BITS));
num_bits = LZMA_LEN_NUM_HIGH_BITS;
}
}
rc_bit_tree_decode(&rc, prob_len, num_bits, &len);
len += offset;
if (state < 4) {
int pos_slot;
state += LZMA_NUM_LIT_STATES;
prob =
p + LZMA_POS_SLOT +
((len <
LZMA_NUM_LEN_TO_POS_STATES ? len :
LZMA_NUM_LEN_TO_POS_STATES - 1)
<< LZMA_NUM_POS_SLOT_BITS);
rc_bit_tree_decode(&rc, prob, LZMA_NUM_POS_SLOT_BITS,
&pos_slot);
if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
num_bits = (pos_slot >> 1) - 1;
rep0 = 2 | (pos_slot & 1);
if (pos_slot < LZMA_END_POS_MODEL_INDEX) {
rep0 <<= num_bits;
prob = p + LZMA_SPEC_POS + rep0 - pos_slot - 1;
} else {
num_bits -= LZMA_NUM_ALIGN_BITS;
while (num_bits--)
rep0 = (rep0 << 1) | rc_direct_bit(&rc);
prob = p + LZMA_ALIGN;
rep0 <<= LZMA_NUM_ALIGN_BITS;
num_bits = LZMA_NUM_ALIGN_BITS;
}
i = 1;
mi = 1;
while (num_bits--) {
if (rc_get_bit(&rc, prob + mi, &mi))
rep0 |= i;
i <<= 1;
}
} else
rep0 = pos_slot;
if (++rep0 == 0)
break;
}
len += LZMA_MATCH_MIN_LEN;
do {
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
// FIXME: error check
write(dst_fd, buffer, header.dict_size);
USE_DESKTOP(total_written += header.dict_size;)
}
len--;
} while (len != 0 && buffer_pos < header.dst_size);
}
}
// FIXME: error check
write(dst_fd, buffer, buffer_pos);
USE_DESKTOP(total_written += buffer_pos;)
rc_free(&rc);
return USE_DESKTOP(total_written) + 0;
}
-924
View File
@@ -1,924 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* gunzip implementation for busybox
*
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
*
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
* based on gzip sources
*
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support
* files as well as stdin/stdout, and to generally behave itself wrt
* command line handling.
*
* General cleanup to better adhere to the style guide and make use of standard
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
*
* read_gz interface + associated hacking by Laurence Anderson
*
* Fixed huft_build() so decoding end-of-block code does not grab more bits
* than necessary (this is required by unzip applet), added inflate_cleanup()
* to free leaked bytebuffer memory (used in unzip.c), and some minor style
* guide cleanups by Ed Clark
*
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
* Copyright (C) 1992-1993 Jean-loup Gailly
* The unzip code was written and put in the public domain by Mark Adler.
* Portions of the lzw code are derived from the public domain 'compress'
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
* Ken Turkowski, Dave Mack and Peter Jannesen.
*
* See the file algorithm.doc for the compression algorithms and file formats.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
unsigned char b; /* number of bits in this code or subcode */
union {
unsigned short n; /* literal, length base, or distance base */
struct huft_s *t; /* pointer to next level of table */
} v;
} huft_t;
static int gunzip_src_fd;
unsigned int gunzip_bytes_out; /* number of output bytes */
static unsigned int gunzip_outbuf_count; /* bytes in output buffer */
/* gunzip_window size--must be a power of two, and
* at least 32K for zip's deflate method */
enum { gunzip_wsize = 0x8000 };
static unsigned char *gunzip_window;
static uint32_t *gunzip_crc_table;
uint32_t gunzip_crc;
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
#define BMAX 16 /* maximum bit length of any code (16 for explode) */
#define N_MAX 288 /* maximum number of codes in any set */
/* bitbuffer */
static unsigned int gunzip_bb; /* bit buffer */
static unsigned char gunzip_bk; /* bits in bit buffer */
/* These control the size of the bytebuffer */
static unsigned int bytebuffer_max = 0x8000;
static unsigned char *bytebuffer = NULL;
static unsigned int bytebuffer_offset = 0;
static unsigned int bytebuffer_size = 0;
static const unsigned short mask_bits[] = {
0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
/* Copy lengths for literal codes 257..285 */
static const unsigned short cplens[] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
};
/* note: see note #13 above about the 258 in this list. */
/* Extra bits for literal codes 257..285 */
static const unsigned char cplext[] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5,
5, 5, 5, 0, 99, 99
}; /* 99==invalid */
/* Copy offsets for distance codes 0..29 */
static const unsigned short cpdist[] = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
};
/* Extra bits for distance codes */
static const unsigned char cpdext[] = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
11, 11, 12, 12, 13, 13
};
/* Tables for deflate from PKZIP's appnote.txt. */
/* Order of the bit length code lengths */
static const unsigned char border[] = {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current, const unsigned int required)
{
while (*current < required) {
if (bytebuffer_offset >= bytebuffer_size) {
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
* to the front of the bytebuffer, leave 4 bytes free at end of tail
* so we can easily top up buffer in check_trailer_gzip() */
if (1 > (bytebuffer_size = safe_read(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8)))
bb_error_msg_and_die("unexpected end of file");
bytebuffer_size += 4;
bytebuffer_offset = 4;
}
bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current;
bytebuffer_offset++;
*current += 8;
}
return bitbuffer;
}
/*
* Free the malloc'ed tables built by huft_build(), which makes a linked
* list of the tables it made, with the links in a dummy first entry of
* each table.
* t: table to free
*/
static int huft_free(huft_t * t)
{
huft_t *p;
huft_t *q;
/* Go through linked list, freeing from the malloced (t[-1]) address. */
p = t;
while (p != (huft_t *) NULL) {
q = (--p)->v.t;
free((char *) p);
p = q;
}
return 0;
}
/* Given a list of code lengths and a maximum table size, make a set of
* tables to decode that set of codes. Return zero on success, one if
* the given code set is incomplete (the tables are still built in this
* case), two if the input is invalid (all zero length codes or an
* oversubscribed set of lengths), and three if not enough memory.
*
* b: code lengths in bits (all assumed <= BMAX)
* n: number of codes (assumed <= N_MAX)
* s: number of simple-valued codes (0..s-1)
* d: list of base values for non-simple codes
* e: list of extra bits for non-simple codes
* t: result: starting table
* m: maximum lookup bits, returns actual
*/
static
int huft_build(unsigned int *b, const unsigned int n,
const unsigned int s, const unsigned short *d,
const unsigned char *e, huft_t ** t, unsigned int *m)
{
unsigned a; /* counter for codes of length k */
unsigned c[BMAX + 1]; /* bit length count table */
unsigned eob_len; /* length of end-of-block code (value 256) */
unsigned f; /* i repeats in table every f entries */
int g; /* maximum code length */
int htl; /* table level */
unsigned i; /* counter, current code */
unsigned j; /* counter */
int k; /* number of bits in current code */
unsigned *p; /* pointer into c[], b[], or v[] */
huft_t *q; /* points to current table */
huft_t r; /* table entry for structure assignment */
huft_t *u[BMAX]; /* table stack */
unsigned v[N_MAX]; /* values in order of bit length */
int ws[BMAX+1]; /* bits decoded stack */
int w; /* bits decoded */
unsigned x[BMAX + 1]; /* bit offsets, then code stack */
unsigned *xp; /* pointer into x */
int y; /* number of dummy codes added */
unsigned z; /* number of entries in current table */
/* Length of EOB code, if any */
eob_len = n > 256 ? b[256] : BMAX;
/* Generate counts for each bit length */
memset((void *)c, 0, sizeof(c));
p = b;
i = n;
do {
c[*p]++; /* assume all entries <= BMAX */
p++; /* Can't combine with above line (Solaris bug) */
} while (--i);
if (c[0] == n) { /* null input--all zero length codes */
*t = (huft_t *) NULL;
*m = 0;
return 2;
}
/* Find minimum and maximum length, bound *m by those */
for (j = 1; (c[j] == 0) && (j <= BMAX); j++);
k = j; /* minimum code length */
for (i = BMAX; (c[i] == 0) && i; i--);
g = i; /* maximum code length */
*m = (*m < j) ? j : ((*m > i) ? i : *m);
/* Adjust last length count to fill out codes, if needed */
for (y = 1 << j; j < i; j++, y <<= 1) {
if ((y -= c[j]) < 0) {
return 2; /* bad input: more codes than bits */
}
}
if ((y -= c[i]) < 0) {
return 2;
}
c[i] += y;
/* Generate starting offsets into the value table for each length */
x[1] = j = 0;
p = c + 1;
xp = x + 2;
while (--i) { /* note that i == g from above */
*xp++ = (j += *p++);
}
/* Make a table of values in order of bit lengths */
p = b;
i = 0;
do {
if ((j = *p++) != 0) {
v[x[j]++] = i;
}
} while (++i < n);
/* Generate the Huffman codes and for each, make the table entries */
x[0] = i = 0; /* first Huffman code is zero */
p = v; /* grab values in bit order */
htl = -1; /* no tables yet--level -1 */
w = ws[0] = 0; /* bits decoded */
u[0] = (huft_t *) NULL; /* just to keep compilers happy */
q = (huft_t *) NULL; /* ditto */
z = 0; /* ditto */
/* go through the bit lengths (k already is bits in shortest code) */
for (; k <= g; k++) {
a = c[k];
while (a--) {
/* here i is the Huffman code of length k bits for value *p */
/* make tables up to required level */
while (k > ws[htl + 1]) {
w = ws[++htl];
/* compute minimum size table less than or equal to *m bits */
z = (z = g - w) > *m ? *m : z; /* upper limit on table size */
if ((f = 1 << (j = k - w)) > a + 1) { /* try a k-w bit table */
/* too few codes for k-w bit table */
f -= a + 1; /* deduct codes from patterns left */
xp = c + k;
while (++j < z) { /* try smaller tables up to z bits */
if ((f <<= 1) <= *++xp) {
break; /* enough codes to use up j bits */
}
f -= *xp; /* else deduct codes from patterns */
}
}
j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */
z = 1 << j; /* table entries for j-bit table */
ws[htl+1] = w + j; /* set bits decoded in stack */
/* allocate and link in new table */
q = (huft_t *) xzalloc((z + 1) * sizeof(huft_t));
*t = q + 1; /* link to list for huft_free() */
t = &(q->v.t);
u[htl] = ++q; /* table starts after link */
/* connect to last table, if there is one */
if (htl) {
x[htl] = i; /* save pattern for backing up */
r.b = (unsigned char) (w - ws[htl - 1]); /* bits to dump before this table */
r.e = (unsigned char) (16 + j); /* bits in this table */
r.v.t = q; /* pointer to this table */
j = (i & ((1 << w) - 1)) >> ws[htl - 1];
u[htl - 1][j] = r; /* connect to last table */
}
}
/* set up table entry in r */
r.b = (unsigned char) (k - w);
if (p >= v + n) {
r.e = 99; /* out of values--invalid code */
} else if (*p < s) {
r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB code */
r.v.n = (unsigned short) (*p++); /* simple code is just the value */
} else {
r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists */
r.v.n = d[*p++ - s];
}
/* fill code-like entries with r */
f = 1 << (k - w);
for (j = i >> w; j < z; j += f) {
q[j] = r;
}
/* backwards increment the k-bit code i */
for (j = 1 << (k - 1); i & j; j >>= 1) {
i ^= j;
}
i ^= j;
/* backup over finished tables */
while ((i & ((1 << w) - 1)) != x[htl]) {
w = ws[--htl];
}
}
}
/* return actual size of base table */
*m = ws[1];
/* Return true (1) if we were given an incomplete table */
return y != 0 && g != 1;
}
/*
* inflate (decompress) the codes in a deflated (compressed) block.
* Return an error code or zero if it all goes ok.
*
* tl, td: literal/length and distance decoder tables
* bl, bd: number of bits decoded by tl[] and td[]
*/
static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_bl, const unsigned int my_bd, int setup)
{
static unsigned int e; /* table entry flag/number of extra bits */
static unsigned int n, d; /* length and index for copy */
static unsigned int w; /* current gunzip_window position */
static huft_t *t; /* pointer to table entry */
static unsigned int ml, md; /* masks for bl and bd bits */
static unsigned int b; /* bit buffer */
static unsigned int k; /* number of bits in bit buffer */
static huft_t *tl, *td;
static unsigned int bl, bd;
static int resumeCopy = 0;
if (setup) { // 1st time we are called, copy in variables
tl = my_tl;
td = my_td;
bl = my_bl;
bd = my_bd;
/* make local copies of globals */
b = gunzip_bb; /* initialize bit buffer */
k = gunzip_bk;
w = gunzip_outbuf_count; /* initialize gunzip_window position */
/* inflate the coded data */
ml = mask_bits[bl]; /* precompute masks for speed */
md = mask_bits[bd];
return 0; // Don't actually do anything the first time
}
if (resumeCopy) goto do_copy;
while (1) { /* do until end of block */
b = fill_bitbuffer(b, &k, bl);
if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
do {
if (e == 99) {
bb_error_msg_and_die("inflate_codes error 1");
}
b >>= t->b;
k -= t->b;
e -= 16;
b = fill_bitbuffer(b, &k, e);
} while ((e =
(t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
b >>= t->b;
k -= t->b;
if (e == 16) { /* then it's a literal */
gunzip_window[w++] = (unsigned char) t->v.n;
if (w == gunzip_wsize) {
gunzip_outbuf_count = (w);
//flush_gunzip_window();
w = 0;
return 1; // We have a block to read
}
} else { /* it's an EOB or a length */
/* exit if end of block */
if (e == 15) {
break;
}
/* get length of block to copy */
b = fill_bitbuffer(b, &k, e);
n = t->v.n + ((unsigned) b & mask_bits[e]);
b >>= e;
k -= e;
/* decode distance of block to copy */
b = fill_bitbuffer(b, &k, bd);
if ((e = (t = td + ((unsigned) b & md))->e) > 16)
do {
if (e == 99)
bb_error_msg_and_die("inflate_codes error 2");
b >>= t->b;
k -= t->b;
e -= 16;
b = fill_bitbuffer(b, &k, e);
} while ((e =
(t =
t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
b >>= t->b;
k -= t->b;
b = fill_bitbuffer(b, &k, e);
d = w - t->v.n - ((unsigned) b & mask_bits[e]);
b >>= e;
k -= e;
/* do the copy */
do_copy: do {
n -= (e =
(e =
gunzip_wsize - ((d &= gunzip_wsize - 1) > w ? d : w)) > n ? n : e);
/* copy to new buffer to prevent possible overwrite */
if (w - d >= e) { /* (this test assumes unsigned comparison) */
memcpy(gunzip_window + w, gunzip_window + d, e);
w += e;
d += e;
} else {
/* do it slow to avoid memcpy() overlap */
/* !NOMEMCPY */
do {
gunzip_window[w++] = gunzip_window[d++];
} while (--e);
}
if (w == gunzip_wsize) {
gunzip_outbuf_count = (w);
if (n) resumeCopy = 1;
else resumeCopy = 0;
//flush_gunzip_window();
w = 0;
return 1;
}
} while (n);
resumeCopy = 0;
}
}
/* restore the globals from the locals */
gunzip_outbuf_count = w; /* restore global gunzip_window pointer */
gunzip_bb = b; /* restore global bit buffer */
gunzip_bk = k;
/* normally just after call to inflate_codes, but save code by putting it here */
/* free the decoding tables, return */
huft_free(tl);
huft_free(td);
/* done */
return 0;
}
static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup)
{
static unsigned int n, b_stored, k_stored, w;
if (setup) {
n = my_n;
b_stored = my_b_stored;
k_stored = my_k_stored;
w = gunzip_outbuf_count; /* initialize gunzip_window position */
return 0; // Don't do anything first time
}
/* read and output the compressed data */
while (n--) {
b_stored = fill_bitbuffer(b_stored, &k_stored, 8);
gunzip_window[w++] = (unsigned char) b_stored;
if (w == gunzip_wsize) {
gunzip_outbuf_count = (w);
//flush_gunzip_window();
w = 0;
b_stored >>= 8;
k_stored -= 8;
return 1; // We have a block
}
b_stored >>= 8;
k_stored -= 8;
}
/* restore the globals from the locals */
gunzip_outbuf_count = w; /* restore global gunzip_window pointer */
gunzip_bb = b_stored; /* restore global bit buffer */
gunzip_bk = k_stored;
return 0; // Finished
}
/*
* decompress an inflated block
* e: last block flag
*
* GLOBAL VARIABLES: bb, kk,
*/
// Return values: -1 = inflate_stored, -2 = inflate_codes
static int inflate_block(int *e)
{
unsigned t; /* block type */
unsigned int b; /* bit buffer */
unsigned int k; /* number of bits in bit buffer */
/* make local bit buffer */
b = gunzip_bb;
k = gunzip_bk;
/* read in last block bit */
b = fill_bitbuffer(b, &k, 1);
*e = (int) b & 1;
b >>= 1;
k -= 1;
/* read in block type */
b = fill_bitbuffer(b, &k, 2);
t = (unsigned) b & 3;
b >>= 2;
k -= 2;
/* restore the global bit buffer */
gunzip_bb = b;
gunzip_bk = k;
/* inflate that block type */
switch (t) {
case 0: /* Inflate stored */
{
unsigned int n; /* number of bytes in block */
unsigned int b_stored; /* bit buffer */
unsigned int k_stored; /* number of bits in bit buffer */
/* make local copies of globals */
b_stored = gunzip_bb; /* initialize bit buffer */
k_stored = gunzip_bk;
/* go to byte boundary */
n = k_stored & 7;
b_stored >>= n;
k_stored -= n;
/* get the length and its complement */
b_stored = fill_bitbuffer(b_stored, &k_stored, 16);
n = ((unsigned) b_stored & 0xffff);
b_stored >>= 16;
k_stored -= 16;
b_stored = fill_bitbuffer(b_stored, &k_stored, 16);
if (n != (unsigned) ((~b_stored) & 0xffff)) {
return 1; /* error in compressed data */
}
b_stored >>= 16;
k_stored -= 16;
inflate_stored(n, b_stored, k_stored, 1); // Setup inflate_stored
return -1;
}
case 1: /* Inflate fixed
* decompress an inflated type 1 (fixed Huffman codes) block. We should
* either replace this with a custom decoder, or at least precompute the
* Huffman tables.
*/
{
int i; /* temporary variable */
huft_t *tl; /* literal/length code table */
huft_t *td; /* distance code table */
unsigned int bl; /* lookup bits for tl */
unsigned int bd; /* lookup bits for td */
unsigned int l[288]; /* length list for huft_build */
/* set up literal table */
for (i = 0; i < 144; i++) {
l[i] = 8;
}
for (; i < 256; i++) {
l[i] = 9;
}
for (; i < 280; i++) {
l[i] = 7;
}
for (; i < 288; i++) { /* make a complete, but wrong code set */
l[i] = 8;
}
bl = 7;
if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) {
return i;
}
/* set up distance table */
for (i = 0; i < 30; i++) { /* make an incomplete code set */
l[i] = 5;
}
bd = 5;
if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) {
huft_free(tl);
return i;
}
/* decompress until an end-of-block code */
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
/* huft_free code moved into inflate_codes */
return -2;
}
case 2: /* Inflate dynamic */
{
const int dbits = 6; /* bits in base distance lookup table */
const int lbits = 9; /* bits in base literal/length lookup table */
huft_t *tl; /* literal/length code table */
huft_t *td; /* distance code table */
unsigned int i; /* temporary variables */
unsigned int j;
unsigned int l; /* last length */
unsigned int m; /* mask for bit lengths table */
unsigned int n; /* number of lengths to get */
unsigned int bl; /* lookup bits for tl */
unsigned int bd; /* lookup bits for td */
unsigned int nb; /* number of bit length codes */
unsigned int nl; /* number of literal/length codes */
unsigned int nd; /* number of distance codes */
unsigned int ll[286 + 30]; /* literal/length and distance code lengths */
unsigned int b_dynamic; /* bit buffer */
unsigned int k_dynamic; /* number of bits in bit buffer */
/* make local bit buffer */
b_dynamic = gunzip_bb;
k_dynamic = gunzip_bk;
/* read in table lengths */
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5);
nl = 257 + ((unsigned int) b_dynamic & 0x1f); /* number of literal/length codes */
b_dynamic >>= 5;
k_dynamic -= 5;
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5);
nd = 1 + ((unsigned int) b_dynamic & 0x1f); /* number of distance codes */
b_dynamic >>= 5;
k_dynamic -= 5;
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 4);
nb = 4 + ((unsigned int) b_dynamic & 0xf); /* number of bit length codes */
b_dynamic >>= 4;
k_dynamic -= 4;
if (nl > 286 || nd > 30) {
return 1; /* bad lengths */
}
/* read in bit-length-code lengths */
for (j = 0; j < nb; j++) {
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3);
ll[border[j]] = (unsigned int) b_dynamic & 7;
b_dynamic >>= 3;
k_dynamic -= 3;
}
for (; j < 19; j++) {
ll[border[j]] = 0;
}
/* build decoding table for trees--single level, 7 bit lookup */
bl = 7;
i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl);
if (i != 0) {
if (i == 1) {
huft_free(tl);
}
return i; /* incomplete code set */
}
/* read in literal and distance code lengths */
n = nl + nd;
m = mask_bits[bl];
i = l = 0;
while ((unsigned int) i < n) {
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, (unsigned int)bl);
j = (td = tl + ((unsigned int) b_dynamic & m))->b;
b_dynamic >>= j;
k_dynamic -= j;
j = td->v.n;
if (j < 16) { /* length of code in bits (0..15) */
ll[i++] = l = j; /* save last length in l */
} else if (j == 16) { /* repeat last length 3 to 6 times */
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 2);
j = 3 + ((unsigned int) b_dynamic & 3);
b_dynamic >>= 2;
k_dynamic -= 2;
if ((unsigned int) i + j > n) {
return 1;
}
while (j--) {
ll[i++] = l;
}
} else if (j == 17) { /* 3 to 10 zero length codes */
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3);
j = 3 + ((unsigned int) b_dynamic & 7);
b_dynamic >>= 3;
k_dynamic -= 3;
if ((unsigned int) i + j > n) {
return 1;
}
while (j--) {
ll[i++] = 0;
}
l = 0;
} else { /* j == 18: 11 to 138 zero length codes */
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 7);
j = 11 + ((unsigned int) b_dynamic & 0x7f);
b_dynamic >>= 7;
k_dynamic -= 7;
if ((unsigned int) i + j > n) {
return 1;
}
while (j--) {
ll[i++] = 0;
}
l = 0;
}
}
/* free decoding table for trees */
huft_free(tl);
/* restore the global bit buffer */
gunzip_bb = b_dynamic;
gunzip_bk = k_dynamic;
/* build the decoding tables for literal/length and distance codes */
bl = lbits;
if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) {
if (i == 1) {
bb_error_msg_and_die("incomplete literal tree");
huft_free(tl);
}
return i; /* incomplete code set */
}
bd = dbits;
if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) {
if (i == 1) {
bb_error_msg_and_die("incomplete distance tree");
huft_free(td);
}
huft_free(tl);
return i; /* incomplete code set */
}
/* decompress until an end-of-block code */
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
/* huft_free code moved into inflate_codes */
return -2;
}
default:
/* bad block type */
bb_error_msg_and_die("bad block type %d", t);
}
}
static void calculate_gunzip_crc(void)
{
int n;
for (n = 0; n < gunzip_outbuf_count; n++) {
gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
}
gunzip_bytes_out += gunzip_outbuf_count;
}
static int inflate_get_next_window(void)
{
static int method = -1; // Method == -1 for stored, -2 for codes
static int e = 0;
static int needAnotherBlock = 1;
gunzip_outbuf_count = 0;
while(1) {
int ret;
if (needAnotherBlock) {
if(e) {
calculate_gunzip_crc();
e = 0;
needAnotherBlock = 1;
return 0;
} // Last block
method = inflate_block(&e);
needAnotherBlock = 0;
}
switch (method) {
case -1: ret = inflate_stored(0,0,0,0);
break;
case -2: ret = inflate_codes(0,0,0,0,0);
break;
default: bb_error_msg_and_die("inflate error %d", method);
}
if (ret == 1) {
calculate_gunzip_crc();
return 1; // More data left
} else needAnotherBlock = 1; // End of that block
}
/* Doesnt get here */
}
/* Initialise bytebuffer, be careful not to overfill the buffer */
void inflate_init(unsigned int bufsize)
{
/* Set the bytebuffer size, default is same as gunzip_wsize */
bytebuffer_max = bufsize + 8;
bytebuffer_offset = 4;
bytebuffer_size = 0;
}
void inflate_cleanup(void)
{
free(bytebuffer);
}
USE_DESKTOP(long long) int
inflate_unzip(int in, int out)
{
USE_DESKTOP(long long total = 0;)
ssize_t nwrote;
typedef void (*sig_type) (int);
/* Allocate all global buffers (for DYN_ALLOC option) */
gunzip_window = xmalloc(gunzip_wsize);
gunzip_outbuf_count = 0;
gunzip_bytes_out = 0;
gunzip_src_fd = in;
/* initialize gunzip_window, bit buffer */
gunzip_bk = 0;
gunzip_bb = 0;
/* Create the crc table */
gunzip_crc_table = crc32_filltable(0);
gunzip_crc = ~0;
/* Allocate space for buffer */
bytebuffer = xmalloc(bytebuffer_max);
while(1) {
int ret = inflate_get_next_window();
nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
if (nwrote == -1) {
bb_perror_msg("write");
return -1;
}
USE_DESKTOP(total += nwrote;)
if (ret == 0) break;
}
/* Cleanup */
free(gunzip_window);
free(gunzip_crc_table);
/* Store unused bytes in a global buffer so calling applets can access it */
if (gunzip_bk >= 8) {
/* Undo too much lookahead. The next read will be byte aligned
* so we can discard unused bits in the last meaningful byte. */
bytebuffer_offset--;
bytebuffer[bytebuffer_offset] = gunzip_bb & 0xff;
gunzip_bb >>= 8;
gunzip_bk -= 8;
}
return USE_DESKTOP(total) + 0;
}
USE_DESKTOP(long long) int
inflate_gunzip(int in, int out)
{
uint32_t stored_crc = 0;
unsigned int count;
USE_DESKTOP(long long total = )inflate_unzip(in, out);
USE_DESKTOP(if (total < 0) return total;)
/* top up the input buffer with the rest of the trailer */
count = bytebuffer_size - bytebuffer_offset;
if (count < 8) {
xread(in, &bytebuffer[bytebuffer_size], 8 - count);
bytebuffer_size += 8 - count;
}
for (count = 0; count != 4; count++) {
stored_crc |= (bytebuffer[bytebuffer_offset] << (count * 8));
bytebuffer_offset++;
}
/* Validate decompression - crc */
if (stored_crc != (~gunzip_crc)) {
bb_error_msg("crc error");
return -1;
}
/* Validate decompression - size */
if (gunzip_bytes_out !=
(bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) |
(bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
bb_error_msg("incorrect length");
return -1;
}
return USE_DESKTOP(total) + 0;
}
-17
View File
@@ -1,17 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "unarchive.h"
/* Accept any non-null name, its not really a filter at all */
char filter_accept_all(archive_handle_t *archive_handle)
{
if (archive_handle->file_header->name)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
@@ -1,19 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "unarchive.h"
/*
* Accept names that are in the accept list, ignoring reject list.
*/
char filter_accept_list(archive_handle_t *archive_handle)
{
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name))
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
@@ -1,48 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
/*
* Reassign the subarchive metadata parser based on the filename extension
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
*/
char filter_accept_list_reassign(archive_handle_t *archive_handle)
{
/* Check the file entry is in the accept list */
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
const char *name_ptr;
/* Extract the last 2 extensions */
name_ptr = strrchr(archive_handle->file_header->name, '.');
/* Modify the subarchive handler based on the extension */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
if (strcmp(name_ptr, ".gz") == 0) {
archive_handle->action_data_subarchive = get_header_tar_gz;
return EXIT_SUCCESS;
}
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
if (strcmp(name_ptr, ".bz2") == 0) {
archive_handle->action_data_subarchive = get_header_tar_bz2;
return EXIT_SUCCESS;
}
#endif
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) {
archive_handle->action_data_subarchive = get_header_tar_lzma;
return EXIT_SUCCESS;
}
}
return EXIT_FAILURE;
}
@@ -1,33 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "unarchive.h"
/*
* Accept names that are in the accept list and not in the reject list
*/
char filter_accept_reject_list(archive_handle_t *archive_handle)
{
const char *key = archive_handle->file_header->name;
const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key);
const llist_t *accept_entry;
/* If the key is in a reject list fail */
if (reject_entry) {
return EXIT_FAILURE;
}
accept_entry = find_list_entry2(archive_handle->accept, key);
/* Fail if an accept list was specified and the key wasnt in there */
if ((accept_entry == NULL) && archive_handle->accept) {
return EXIT_FAILURE;
}
/* Accepted */
return EXIT_SUCCESS;
}
-54
View File
@@ -1,54 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "unarchive.h"
/* Find a string in a shell pattern list */
const llist_t *find_list_entry(const llist_t *list, const char *filename)
{
while (list) {
if (fnmatch(list->data, filename, 0) == 0) {
return list;
}
list = list->link;
}
return NULL;
}
/* Same, but compares only path components present in pattern
* (extra trailing path components in filename are assumed to match)
*/
const llist_t *find_list_entry2(const llist_t *list, const char *filename)
{
char buf[PATH_MAX];
int pattern_slash_cnt;
const char *c;
char *d;
while (list) {
c = list->data;
pattern_slash_cnt = 0;
while (*c)
if (*c++ == '/') pattern_slash_cnt++;
c = filename;
d = buf;
/* paranoia is better that buffer overflows */
while (*c && d != buf + sizeof(buf)-1) {
if (*c == '/' && --pattern_slash_cnt < 0)
break;
*d++ = *c++;
}
*d = '\0';
if (fnmatch(list->data, buf, 0) == 0) {
return list;
}
list = list->link;
}
return NULL;
}
-121
View File
@@ -1,121 +0,0 @@
/* vi: set sw=4 ts=4: */
/* Copyright 2001 Glenn McGrath.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
char get_header_ar(archive_handle_t *archive_handle)
{
int err;
file_header_t *typed = archive_handle->file_header;
union {
char raw[60];
struct {
char name[16];
char date[12];
char uid[6];
char gid[6];
char mode[8];
char size[10];
char magic[2];
} formatted;
} ar;
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
static char *ar_long_names;
static unsigned int ar_long_name_size;
#endif
/* dont use xread as we want to handle the error ourself */
if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
/* End Of File */
return EXIT_FAILURE;
}
/* ar header starts on an even byte (2 byte aligned)
* '\n' is used for padding
*/
if (ar.raw[0] == '\n') {
/* fix up the header, we started reading 1 byte too early */
memmove(ar.raw, &ar.raw[1], 59);
ar.raw[59] = xread_char(archive_handle->src_fd);
archive_handle->offset++;
}
archive_handle->offset += 60;
/* align the headers based on the header magic */
if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
bb_error_msg_and_die("invalid ar header");
/* FIXME: more thorough routine would be in order here */
/* (we have something like that in tar) */
/* but for now we are lax. This code works because */
/* on misformatted numbers bb_strtou returns all-ones */
typed->mode = err = bb_strtou(ar.formatted.mode, NULL, 8);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->mtime = err = bb_strtou(ar.formatted.date, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->uid = err = bb_strtou(ar.formatted.uid, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->gid = err = bb_strtou(ar.formatted.gid, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->size = err = bb_strtou(ar.formatted.size, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
/* long filenames have '/' as the first character */
if (ar.formatted.name[0] == '/') {
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
if (ar.formatted.name[1] == '/') {
/* If the second char is a '/' then this entries data section
* stores long filename for multiple entries, they are stored
* in static variable long_names for use in future entries */
ar_long_name_size = typed->size;
ar_long_names = xmalloc(ar_long_name_size);
xread(archive_handle->src_fd, ar_long_names, ar_long_name_size);
archive_handle->offset += ar_long_name_size;
/* This ar entries data section only contained filenames for other records
* they are stored in the static ar_long_names for future reference */
return get_header_ar(archive_handle); /* Return next header */
} else if (ar.formatted.name[1] == ' ') {
/* This is the index of symbols in the file for compilers */
data_skip(archive_handle);
archive_handle->offset += typed->size;
return get_header_ar(archive_handle); /* Return next header */
} else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const unsigned int long_offset = atoi(&ar.formatted.name[1]);
if (long_offset >= ar_long_name_size) {
bb_error_msg_and_die("can't resolve long filename");
}
typed->name = xstrdup(ar_long_names + long_offset);
}
#else
bb_error_msg_and_die("long filenames not supported");
#endif
} else {
/* short filenames */
typed->name = xstrndup(ar.formatted.name, 16);
}
typed->name[strcspn(typed->name, " /")] = '\0';
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(typed);
if (archive_handle->sub_archive) {
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS);
} else {
archive_handle->action_data(archive_handle);
}
} else {
data_skip(archive_handle);
}
archive_handle->offset += typed->size;
/* Set the file pointer to the correct spot, we may have been reading a compressed file */
lseek(archive_handle->src_fd, archive_handle->offset, SEEK_SET);
return EXIT_SUCCESS;
}
-160
View File
@@ -1,160 +0,0 @@
/* vi: set sw=4 ts=4: */
/* Copyright 2002 Laurence Anderson
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
typedef struct hardlinks_s {
char *name;
int inode;
struct hardlinks_s *next;
} hardlinks_t;
char get_header_cpio(archive_handle_t *archive_handle)
{
static hardlinks_t *saved_hardlinks = NULL;
static unsigned short pending_hardlinks = 0;
static int inode;
file_header_t *file_header = archive_handle->file_header;
char cpio_header[110];
int namesize;
char dummy[16];
int major, minor, nlink;
if (pending_hardlinks) { /* Deal with any pending hardlinks */
hardlinks_t *tmp, *oldtmp;
tmp = saved_hardlinks;
oldtmp = NULL;
file_header->link_name = file_header->name;
file_header->size = 0;
while (tmp) {
if (tmp->inode != inode) {
tmp = tmp->next;
continue;
}
file_header->name = tmp->name;
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
}
pending_hardlinks--;
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
if (oldtmp == saved_hardlinks)
saved_hardlinks = tmp;
}
file_header->name = file_header->link_name;
if (pending_hardlinks > 1) {
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
}
/* No more pending hardlinks, read next file entry */
pending_hardlinks = 0;
}
/* There can be padding before archive header */
data_align(archive_handle, 4);
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
return EXIT_FAILURE;
}
archive_handle->offset += 110;
if (strncmp(&cpio_header[0], "07070", 5) != 0
|| (cpio_header[5] != '1' && cpio_header[5] != '2')
) {
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
}
{
unsigned long tmpsize;
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, (unsigned int*)&file_header->mode,
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
&nlink, &file_header->mtime, &tmpsize,
dummy, &major, &minor, &namesize, dummy);
file_header->size = tmpsize;
}
free(file_header->name);
file_header->name = xzalloc(namesize + 1);
/* Read in filename */
xread(archive_handle->src_fd, file_header->name, namesize);
archive_handle->offset += namesize;
/* Update offset amount and skip padding before file contents */
data_align(archive_handle, 4);
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
/* Always round up */
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
archive_handle->offset / 512 + 1 :
archive_handle->offset / 512
));
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
hardlinks_t *tmp = saved_hardlinks;
hardlinks_t *oldtmp = NULL;
while (tmp) {
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
}
saved_hardlinks = NULL;
pending_hardlinks = 0;
}
return EXIT_FAILURE;
}
if (S_ISLNK(file_header->mode)) {
file_header->link_name = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, file_header->link_name, file_header->size);
archive_handle->offset += file_header->size;
file_header->size = 0; /* Stop possible seeks in future */
} else {
file_header->link_name = NULL;
}
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
if (file_header->size == 0) { /* Put file on a linked list for later */
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
new->next = saved_hardlinks;
new->inode = inode;
/* name current allocated, freed later */
new->name = file_header->name;
file_header->name = NULL;
saved_hardlinks = new;
return EXIT_SUCCESS; /* Skip this one */
}
/* Found the file with data in */
pending_hardlinks = nlink;
}
file_header->device = makedev(major, minor);
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
} else {
data_skip(archive_handle);
}
archive_handle->offset += file_header->size;
free(file_header->link_name);
return EXIT_SUCCESS;
}
-277
View File
@@ -1,277 +0,0 @@
/* vi: set sw=4 ts=4: */
/* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* FIXME:
* In privileged mode if uname and gname map to a uid and gid then use the
* mapped value instead of the uid/gid values in tar header
*
* References:
* GNU tar and star man pages,
* Opengroup's ustar interchange format,
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
*/
#include "libbb.h"
#include "unarchive.h"
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
static char *longname;
static char *linkname;
#else
enum {
longname = 0,
linkname = 0,
};
#endif
/* NB: _DESTROYS_ str[len] character! */
static unsigned long long getOctal(char *str, int len)
{
unsigned long long v;
/* Actually, tar header allows leading spaces also.
* Oh well, we will be liberal and skip this...
* The only downside probably is that we allow "-123" too :)
if (*str < '0' || *str > '7')
bb_error_msg_and_die("corrupted octal value in tar header");
*/
str[len] = '\0';
v = strtoull(str, &str, 8);
if (*str)
bb_error_msg_and_die("corrupted octal value in tar header");
return v;
}
#define GET_OCTAL(a) getOctal((a), sizeof(a))
void BUG_tar_header_size(void);
char get_header_tar(archive_handle_t *archive_handle)
{
static int end;
file_header_t *file_header = archive_handle->file_header;
struct {
/* ustar header, Posix 1003.1 */
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} tar;
char *cp;
int sum, i;
int parse_names;
if (sizeof(tar) != 512)
BUG_tar_header_size();
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
again:
#endif
/* Align header */
data_align(archive_handle, 512);
again_after_align:
xread(archive_handle->src_fd, &tar, 512);
archive_handle->offset += 512;
/* If there is no filename its an empty header */
if (tar.name[0] == 0) {
if (end) {
/* This is the second consecutive empty header! End of archive!
* Read until the end to empty the pipe from gz or bz2
*/
while (full_read(archive_handle->src_fd, &tar, 512) == 512)
/* repeat */;
return EXIT_FAILURE;
}
end = 1;
return EXIT_SUCCESS;
}
end = 0;
/* Check header has valid magic, "ustar" is for the proper tar
* 0's are for the old tar format
*/
if (strncmp(tar.magic, "ustar", 5) != 0) {
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (memcmp(tar.magic, "\0\0\0\0", 5) != 0)
#endif
bb_error_msg_and_die("invalid tar magic");
}
/* Do checksum on headers */
sum = ' ' * sizeof(tar.chksum);
for (i = 0; i < 148 ; i++) {
sum += ((char*)&tar)[i];
}
for (i = 156; i < 512 ; i++) {
sum += ((char*)&tar)[i];
}
/* This field does not need special treatment (getOctal) */
if (sum != xstrtoul(tar.chksum, 8)) {
bb_error_msg_and_die("invalid tar header checksum");
}
/* 0 is reserved for high perf file, treat as normal file */
if (!tar.typeflag) tar.typeflag = '0';
parse_names = (tar.typeflag >= '0' && tar.typeflag <= '7');
/* getOctal trashes subsequent field, therefore we call it
* on fields in reverse order */
if (tar.devmajor[0]) {
unsigned minor = GET_OCTAL(tar.devminor);
unsigned major = GET_OCTAL(tar.devmajor);
file_header->device = makedev(major, minor);
}
file_header->link_name = NULL;
if (!linkname && parse_names && tar.linkname[0]) {
/* we trash magic[0] here, it's ok */
tar.linkname[sizeof(tar.linkname)] = '\0';
file_header->link_name = xstrdup(tar.linkname);
/* FIXME: what if we have non-link object with link_name? */
/* Will link_name be free()ed? */
}
file_header->mtime = GET_OCTAL(tar.mtime);
file_header->size = GET_OCTAL(tar.size);
file_header->gid = GET_OCTAL(tar.gid);
file_header->uid = GET_OCTAL(tar.uid);
/* Set bits 0-11 of the files mode */
file_header->mode = 07777 & GET_OCTAL(tar.mode);
file_header->name = NULL;
if (!longname && parse_names) {
/* we trash mode[0] here, it's ok */
tar.name[sizeof(tar.name)] = '\0';
if (tar.prefix[0]) {
/* and padding[0] */
tar.prefix[sizeof(tar.prefix)] = '\0';
file_header->name = concat_path_file(tar.prefix, tar.name);
} else
file_header->name = xstrdup(tar.name);
}
/* Set bits 12-15 of the files mode */
/* (typeflag was not trashed because chksum does not use getOctal) */
switch (tar.typeflag) {
/* busybox identifies hard links as being regular files with 0 size and a link name */
case '1':
file_header->mode |= S_IFREG;
break;
case '7':
/* case 0: */
case '0':
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (last_char_is(file_header->name, '/')) {
file_header->mode |= S_IFDIR;
} else
#endif
file_header->mode |= S_IFREG;
break;
case '2':
file_header->mode |= S_IFLNK;
break;
case '3':
file_header->mode |= S_IFCHR;
break;
case '4':
file_header->mode |= S_IFBLK;
break;
case '5':
file_header->mode |= S_IFDIR;
break;
case '6':
file_header->mode |= S_IFIFO;
break;
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
case 'L':
/* free: paranoia: tar with several consecutive longnames */
free(longname);
/* For paranoia reasons we allocate extra NUL char */
longname = xzalloc(file_header->size + 1);
/* We read ASCIZ string, including NUL */
xread(archive_handle->src_fd, longname, file_header->size);
archive_handle->offset += file_header->size;
/* return get_header_tar(archive_handle); */
/* gcc 4.1.1 didn't optimize it into jump */
/* so we will do it ourself, this also saves stack */
goto again;
case 'K':
free(linkname);
linkname = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, linkname, file_header->size);
archive_handle->offset += file_header->size;
/* return get_header_tar(archive_handle); */
goto again;
case 'D': /* GNU dump dir */
case 'M': /* Continuation of multi volume archive */
case 'N': /* Old GNU for names > 100 characters */
case 'S': /* Sparse file */
case 'V': /* Volume header */
#endif
case 'g': /* pax global header */
case 'x': { /* pax extended header */
off_t sz;
bb_error_msg("warning: skipping header '%c'", tar.typeflag);
sz = (file_header->size + 511) & ~(off_t)511;
archive_handle->offset += sz;
sz >>= 9; /* sz /= 512 but w/o contortions for signed div */
while (sz--)
xread(archive_handle->src_fd, &tar, 512);
/* return get_header_tar(archive_handle); */
goto again_after_align;
}
default:
bb_error_msg_and_die("unknown typeflag: 0x%x", tar.typeflag);
}
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
if (longname) {
file_header->name = longname;
longname = NULL;
}
if (linkname) {
file_header->link_name = linkname;
linkname = NULL;
}
#endif
if (!strncmp(file_header->name, "/../"+1, 3)
|| strstr(file_header->name, "/../")
) {
bb_error_msg_and_die("name with '..' encountered: '%s'",
file_header->name);
}
/* Strip trailing '/' in directories */
/* Must be done after mode is set as '/' is used to check if its a directory */
cp = last_char_is(file_header->name, '/');
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(archive_handle->file_header);
/* Note that we kill the '/' only after action_header() */
/* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */
if (cp) *cp = '\0';
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
archive_handle->action_data(archive_handle);
llist_add_to(&(archive_handle->passed), file_header->name);
} else {
data_skip(archive_handle);
free(file_header->name);
}
archive_handle->offset += file_header->size;
free(file_header->link_name);
/* Do not free(file_header->name)! */
return EXIT_SUCCESS;
}
@@ -1,27 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_bz2(archive_handle_t *archive_handle)
{
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
return EXIT_FAILURE;
}
-31
View File
@@ -1,31 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_gz(archive_handle_t *archive_handle)
{
unsigned char magic[2];
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
xread(archive_handle->src_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip(archive_handle->src_fd);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
return EXIT_FAILURE;
}
@@ -1,22 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#include "unarchive.h"
char get_header_tar_lzma(archive_handle_t * archive_handle)
{
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
return EXIT_FAILURE;
}
-11
View File
@@ -1,11 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include "unarchive.h"
void header_list(const file_header_t *file_header)
{
puts(file_header->name);
}
-10
View File
@@ -1,10 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include "unarchive.h"
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
{
}
@@ -1,31 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
void header_verbose_list(const file_header_t *file_header)
{
struct tm *mtime = localtime(&(file_header->mtime));
printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
file_header->uid,
file_header->gid,
file_header->size,
1900 + mtime->tm_year,
1 + mtime->tm_mon,
mtime->tm_mday,
mtime->tm_hour,
mtime->tm_min,
mtime->tm_sec,
file_header->name);
if (file_header->link_name) {
printf(" -> %s", file_header->link_name);
}
/* putchar isnt used anywhere else i dont think */
puts("");
}
-22
View File
@@ -1,22 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
archive_handle_t *init_handle(void)
{
archive_handle_t *archive_handle;
/* Initialize default values */
archive_handle = xzalloc(sizeof(archive_handle_t));
archive_handle->file_header = xzalloc(sizeof(file_header_t));
archive_handle->action_header = header_skip;
archive_handle->action_data = data_skip;
archive_handle->filter = filter_accept_all;
archive_handle->seek = seek_by_jump;
return archive_handle;
}
-44
View File
@@ -1,44 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
/* transformer(), more than meets the eye */
int open_transformer(int src_fd,
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
{
int fd_pipe[2];
int pid;
if (pipe(fd_pipe) != 0) {
bb_perror_msg_and_die("can't create pipe");
}
pid = fork();
if (pid == -1) {
bb_perror_msg_and_die("fork failed");
}
if (pid == 0) {
/* child process */
close(fd_pipe[0]); /* We don't wan't to read from the parent */
// FIXME: error check?
transformer(src_fd, fd_pipe[1]);
close(fd_pipe[1]); /* Send EOF */
close(src_fd);
exit(0);
/* notreached */
}
/* parent process */
close(fd_pipe[1]); /* Don't want to write to the child */
return fd_pipe[0];
}
-24
View File
@@ -1,24 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
if (errno == ESPIPE) {
seek_by_read(archive_handle, amount);
} else
#endif
bb_perror_msg_and_die("seek failure");
}
}
-19
View File
@@ -1,19 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "unarchive.h"
#include "libbb.h"
/* If we are reading through a pipe(), or from stdin then we can't lseek,
* we must read and discard the data to skip over it.
*/
void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size)
{
if (jump_size) {
bb_copyfd_size(archive_handle->src_fd, -1, jump_size);
}
}
-22
View File
@@ -1,22 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include "unarchive.h"
#include "libbb.h"
void unpack_ar_archive(archive_handle_t *ar_archive)
{
char magic[7];
xread(ar_archive->src_fd, magic, 7);
if (strncmp(magic, "!<arch>", 7) != 0) {
bb_error_msg_and_die("invalid ar magic");
}
ar_archive->offset += 7;
while (get_header_ar(ar_archive) == EXIT_SUCCESS);
}
-319
View File
@@ -1,319 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini rpm applet for busybox
*
* Copyright (C) 2001,2002 by Laurence Anderson
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "unarchive.h"
#define RPM_HEADER_MAGIC "\216\255\350"
#define RPM_CHAR_TYPE 1
#define RPM_INT8_TYPE 2
#define RPM_INT16_TYPE 3
#define RPM_INT32_TYPE 4
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */
#define RPM_STRING_TYPE 6
#define RPM_BIN_TYPE 7
#define RPM_STRING_ARRAY_TYPE 8
#define RPM_I18NSTRING_TYPE 9
#define RPMTAG_NAME 1000
#define RPMTAG_VERSION 1001
#define RPMTAG_RELEASE 1002
#define RPMTAG_SUMMARY 1004
#define RPMTAG_DESCRIPTION 1005
#define RPMTAG_BUILDTIME 1006
#define RPMTAG_BUILDHOST 1007
#define RPMTAG_SIZE 1009
#define RPMTAG_VENDOR 1011
#define RPMTAG_LICENSE 1014
#define RPMTAG_PACKAGER 1015
#define RPMTAG_GROUP 1016
#define RPMTAG_URL 1020
#define RPMTAG_PREIN 1023
#define RPMTAG_POSTIN 1024
#define RPMTAG_FILEFLAGS 1037
#define RPMTAG_FILEUSERNAME 1039
#define RPMTAG_FILEGROUPNAME 1040
#define RPMTAG_SOURCERPM 1044
#define RPMTAG_PREINPROG 1085
#define RPMTAG_POSTINPROG 1086
#define RPMTAG_PREFIXS 1098
#define RPMTAG_DIRINDEXES 1116
#define RPMTAG_BASENAMES 1117
#define RPMTAG_DIRNAMES 1118
#define RPMFILE_CONFIG (1 << 0)
#define RPMFILE_DOC (1 << 1)
enum rpm_functions_e {
rpm_query = 1,
rpm_install = 2,
rpm_query_info = 4,
rpm_query_package = 8,
rpm_query_list = 16,
rpm_query_list_doc = 32,
rpm_query_list_config = 64
};
typedef struct {
uint32_t tag; /* 4 byte tag */
uint32_t type; /* 4 byte type */
uint32_t offset; /* 4 byte offset */
uint32_t count; /* 4 byte count */
} rpm_index;
static void *map;
static rpm_index **mytags;
static int tagcount;
static void extract_cpio_gz(int fd);
static rpm_index **rpm_gettags(int fd, int *num_tags);
static int bsearch_rpmtag(const void *key, const void *item);
static char *rpm_getstring(int tag, int itemindex);
static int rpm_getint(int tag, int itemindex);
static int rpm_getcount(int tag);
static void fileaction_dobackup(char *filename, int fileref);
static void fileaction_setowngrp(char *filename, int fileref);
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
int rpm_main(int argc, char **argv)
{
int opt = 0, func = 0, rpm_fd, offset;
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
switch (opt) {
case 'i': // First arg: Install mode, with q: Information
if (!func) func |= rpm_install;
else func |= rpm_query_info;
break;
case 'q': // First arg: Query mode
if (!func) func |= rpm_query;
else bb_show_usage();
break;
case 'p': // Query a package
func |= rpm_query_package;
break;
case 'l': // List files in a package
func |= rpm_query_list;
break;
case 'd': // List doc files in a package (implies list)
func |= rpm_query_list;
func |= rpm_query_list_doc;
break;
case 'c': // List config files in a package (implies list)
func |= rpm_query_list;
func |= rpm_query_list_config;
break;
default:
bb_show_usage();
}
}
if (optind == argc) bb_show_usage();
while (optind < argc) {
rpm_fd = xopen(argv[optind], O_RDONLY);
mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
offset = lseek(rpm_fd, 0, SEEK_CUR);
if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
map = mmap(0, offset > getpagesize() ? (offset + offset % getpagesize()) : getpagesize(), PROT_READ, MAP_PRIVATE, rpm_fd, 0); // Mimimum is one page
if (func & rpm_install) {
loop_through_files(RPMTAG_BASENAMES, fileaction_dobackup); /* Backup any config files */
extract_cpio_gz(rpm_fd); // Extact the archive
loop_through_files(RPMTAG_BASENAMES, fileaction_setowngrp); /* Set the correct file uid/gid's */
} else if (func & rpm_query && func & rpm_query_package) {
if (!((func & rpm_query_info) || (func & rpm_query_list))) { // If just a straight query, just give package name
printf("%s-%s-%s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_RELEASE, 0));
}
if (func & rpm_query_info) {
/* Do the nice printout */
time_t bdate_time;
struct tm *bdate;
char bdatestring[50];
printf("Name : %-29sRelocations: %s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_PREFIXS, 0) ? rpm_getstring(RPMTAG_PREFIXS, 0) : "(not relocateable)");
printf("Version : %-34sVendor: %s\n", rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_VENDOR, 0) ? rpm_getstring(RPMTAG_VENDOR, 0) : "(none)");
bdate_time = rpm_getint(RPMTAG_BUILDTIME, 0);
bdate = localtime((time_t *) &bdate_time);
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate);
printf("Release : %-30sBuild Date: %s\n", rpm_getstring(RPMTAG_RELEASE, 0), bdatestring);
printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstring(RPMTAG_BUILDHOST, 0));
printf("Group : %-30sSource RPM: %s\n", rpm_getstring(RPMTAG_GROUP, 0), rpm_getstring(RPMTAG_SOURCERPM, 0));
printf("Size : %-33dLicense: %s\n", rpm_getint(RPMTAG_SIZE, 0), rpm_getstring(RPMTAG_LICENSE, 0));
printf("URL : %s\n", rpm_getstring(RPMTAG_URL, 0));
printf("Summary : %s\n", rpm_getstring(RPMTAG_SUMMARY, 0));
printf("Description :\n%s\n", rpm_getstring(RPMTAG_DESCRIPTION, 0));
}
if (func & rpm_query_list) {
int count, it, flags;
count = rpm_getcount(RPMTAG_BASENAMES);
for (it = 0; it < count; it++) {
flags = rpm_getint(RPMTAG_FILEFLAGS, it);
switch ((func & rpm_query_list_doc) + (func & rpm_query_list_config))
{
case rpm_query_list_doc: if (!(flags & RPMFILE_DOC)) continue; break;
case rpm_query_list_config: if (!(flags & RPMFILE_CONFIG)) continue; break;
case rpm_query_list_doc + rpm_query_list_config: if (!((flags & RPMFILE_CONFIG) || (flags & RPMFILE_DOC))) continue; break;
}
printf("%s%s\n", rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, it)), rpm_getstring(RPMTAG_BASENAMES, it));
}
}
}
optind++;
free (mytags);
}
return 0;
}
static void extract_cpio_gz(int fd) {
archive_handle_t *archive_handle;
unsigned char magic[2];
/* Initialise */
archive_handle = init_handle();
archive_handle->seek = seek_by_read;
//archive_handle->action_header = header_list;
archive_handle->action_data = data_extract_all;
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
archive_handle->src_fd = fd;
archive_handle->offset = 0;
xread(archive_handle->src_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip(archive_handle->src_fd);
xchdir("/"); // Install RPM's to root
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
archive_handle->offset = 0;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
}
static rpm_index **rpm_gettags(int fd, int *num_tags)
{
rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *)); /* We should never need mode than 200, and realloc later */
int pass, tagindex = 0;
lseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
for (pass = 0; pass < 2; pass++) { /* 1st pass is the signature headers, 2nd is the main stuff */
struct {
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
uint8_t version; /* 1 byte version number */
uint32_t reserved; /* 4 bytes reserved */
uint32_t entries; /* Number of entries in header (4 bytes) */
uint32_t size; /* Size of store (4 bytes) */
} header;
rpm_index *tmpindex;
int storepos;
read(fd, &header, sizeof(header));
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) return NULL; /* Invalid magic */
if (header.version != 1) return NULL; /* This program only supports v1 headers */
header.size = ntohl(header.size);
header.entries = ntohl(header.entries);
storepos = lseek(fd,0,SEEK_CUR) + header.entries * 16;
while (header.entries--) {
tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index));
read(fd, tmpindex, sizeof(rpm_index));
tmpindex->tag = ntohl(tmpindex->tag); tmpindex->type = ntohl(tmpindex->type); tmpindex->count = ntohl(tmpindex->count);
tmpindex->offset = storepos + ntohl(tmpindex->offset);
if (pass==0) tmpindex->tag -= 743;
}
lseek(fd, header.size, SEEK_CUR); /* Seek past store */
if (pass==0) lseek(fd, (8 - (lseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); /* Skip padding to 8 byte boundary after reading signature headers */
}
tags = realloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
*num_tags = tagindex;
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
}
static int bsearch_rpmtag(const void *key, const void *item)
{
int *tag = (int *)key;
rpm_index **tmp = (rpm_index **) item;
return (*tag - tmp[0]->tag);
}
static int rpm_getcount(int tag)
{
rpm_index **found;
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found) return 0;
else return found[0]->count;
}
static char *rpm_getstring(int tag, int itemindex)
{
rpm_index **found;
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found || itemindex >= found[0]->count) return NULL;
if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) {
int n;
char *tmpstr = (char *) (map + found[0]->offset);
for (n=0; n < itemindex; n++) tmpstr = tmpstr + strlen(tmpstr) + 1;
return tmpstr;
} else return NULL;
}
static int rpm_getint(int tag, int itemindex)
{
rpm_index **found;
int n, *tmpint;
/* gcc throws warnings here when sizeof(void*)!=sizeof(int) ...
* it's ok to ignore it because tag won't be used as a pointer */
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found || itemindex >= found[0]->count) return -1;
tmpint = (int *) (map + found[0]->offset);
if (found[0]->type == RPM_INT32_TYPE) {
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 4);
return ntohl(*tmpint);
} else if (found[0]->type == RPM_INT16_TYPE) {
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 2);
return ntohs(*tmpint);
} else if (found[0]->type == RPM_INT8_TYPE) {
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 1);
return ntohs(*tmpint);
} else return -1;
}
static void fileaction_dobackup(char *filename, int fileref)
{
struct stat oldfile;
int stat_res;
char *newname;
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
stat_res = lstat (filename, &oldfile);
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
newname = xasprintf("%s.rpmorig", filename);
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
free(newname);
}
}
}
static void fileaction_setowngrp(char *filename, int fileref)
{
int uid, gid;
uid = bb_xgetpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref));
gid = bb_xgetgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref));
chown(filename, uid, gid);
}
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
{
int count = 0;
while (rpm_getstring(filetag, count)) {
char * filename = xasprintf("%s%s",
rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES,
count)), rpm_getstring(RPMTAG_BASENAMES, count));
fileaction(filename, count++);
free(filename);
}
}
-89
View File
@@ -1,89 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini rpm2cpio implementation for busybox
*
* Copyright (C) 2001 by Laurence Anderson
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "unarchive.h"
#define RPM_MAGIC "\355\253\356\333"
#define RPM_HEADER_MAGIC "\216\255\350"
struct rpm_lead {
unsigned char magic[4];
uint8_t major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
};
struct rpm_header {
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
uint8_t version; /* 1 byte version number */
uint32_t reserved; /* 4 bytes reserved */
uint32_t entries; /* Number of entries in header (4 bytes) */
uint32_t size; /* Size of store (4 bytes) */
};
static void skip_header(int rpm_fd)
{
struct rpm_header header;
xread(rpm_fd, &header, sizeof(struct rpm_header));
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) {
bb_error_msg_and_die("invalid RPM header magic"); /* Invalid magic */
}
if (header.version != 1) {
bb_error_msg_and_die("unsupported RPM header version"); /* This program only supports v1 headers */
}
header.entries = ntohl(header.entries);
header.size = ntohl(header.size);
lseek (rpm_fd, 16 * header.entries, SEEK_CUR); /* Seek past index entries */
lseek (rpm_fd, header.size, SEEK_CUR); /* Seek past store */
}
/* No getopt required */
int rpm2cpio_main(int argc, char **argv)
{
struct rpm_lead lead;
int rpm_fd;
unsigned char magic[2];
if (argc == 1) {
rpm_fd = STDIN_FILENO;
} else {
rpm_fd = xopen(argv[1], O_RDONLY);
}
xread(rpm_fd, &lead, sizeof(struct rpm_lead));
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) {
bb_error_msg_and_die("invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
}
/* Skip the signature header */
skip_header(rpm_fd);
lseek(rpm_fd, (8 - (lseek(rpm_fd, 0, SEEK_CUR) % 8)) % 8, SEEK_CUR);
/* Skip the main header */
skip_header(rpm_fd);
xread(rpm_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip(rpm_fd);
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) {
bb_error_msg("error inflating");
}
close(rpm_fd);
return 0;
}
+889 -783
View File
File diff suppressed because it is too large. Load diff
-94
View File
@@ -1,94 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Uncompress applet for busybox (c) 2002 Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "unarchive.h"
#define GUNZIP_TO_STDOUT 1
#define GUNZIP_FORCE 2
int uncompress_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
unsigned long flags;
flags = getopt32(argc, argv, "cf");
while (optind < argc) {
char *compressed_file = argv[optind++];
char *delete_path = NULL;
char *uncompressed_file = NULL;
int src_fd;
int dst_fd;
if (strcmp(compressed_file, "-") == 0) {
src_fd = STDIN_FILENO;
flags |= GUNZIP_TO_STDOUT;
} else {
src_fd = xopen(compressed_file, O_RDONLY);
}
/* Check that the input is sane. */
if (isatty(src_fd) && ((flags & GUNZIP_FORCE) == 0)) {
bb_error_msg_and_die
("compressed data not read from terminal. Use -f to force it.");
}
/* Set output filename and number */
if (flags & GUNZIP_TO_STDOUT) {
dst_fd = STDOUT_FILENO;
} else {
struct stat stat_buf;
char *extension;
uncompressed_file = xstrdup(compressed_file);
extension = strrchr(uncompressed_file, '.');
if (!extension || (strcmp(extension, ".Z") != 0)) {
bb_error_msg_and_die("invalid extension");
}
*extension = '\0';
/* Open output file */
xstat(compressed_file, &stat_buf);
dst_fd = xopen3(uncompressed_file,
O_WRONLY | O_CREAT | O_TRUNC,
stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = compressed_file;
}
/* do the decompression, and cleanup */
if ((xread_char(src_fd) != 0x1f) || (xread_char(src_fd) != 0x9d)) {
bb_error_msg_and_die("invalid magic");
}
status = uncompress(src_fd, dst_fd);
if ((status != EXIT_SUCCESS) && (uncompressed_file)) {
/* Unzip failed, remove the uncomressed file instead of compressed file */
delete_path = uncompressed_file;
}
if (dst_fd != STDOUT_FILENO) {
close(dst_fd);
}
if (src_fd != STDIN_FILENO) {
close(src_fd);
}
/* delete_path will be NULL if in test mode or from stdin */
if (delete_path && (unlink(delete_path) == -1)) {
bb_error_msg_and_die("cannot remove %s", delete_path);
}
free(uncompressed_file);
}
return status;
}
-64
View File
@@ -1,64 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on bunzip.c from busybox
*
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
/* Why our g[un]zip/bunzip2 are so ugly compared to this beauty? */
#include "busybox.h"
#include "unarchive.h"
#define UNLZMA_OPT_STDOUT 1
int unlzma_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
unsigned opt;
int src_fd, dst_fd;
opt = getopt32(argc, argv, "c");
/* Set input filename and number */
filename = argv[optind];
if (filename && (filename[0] != '-') && (filename[1] != '\0')) {
/* Open input file */
src_fd = xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
filename = 0;
}
/* if called as lzmacat force the stdout flag */
if ((opt & UNLZMA_OPT_STDOUT) || applet_name[4] == 'c')
filename = 0;
if (filename) {
struct stat stat_buf;
/* bug: char *extension = filename + strlen(filename) - 5; */
char *extension = strrchr(filename, '.');
if (!extension || strcmp(extension, ".lzma") != 0) {
bb_error_msg_and_die("invalid extension");
}
xstat(filename, &stat_buf);
*extension = '\0';
dst_fd = xopen3(filename, O_WRONLY | O_CREAT | O_TRUNC,
stat_buf.st_mode);
} else
dst_fd = STDOUT_FILENO;
status = unlzma(src_fd, dst_fd);
if (filename) {
if (status >= 0) /* if success delete src, else delete dst */
filename[strlen(filename)] = '.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("cannot remove %s", filename);
}
}
return (status < 0);
}
-386
View File
@@ -1,386 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini unzip implementation for busybox
*
* Copyright (C) 2004 by Ed Clark
*
* Loosely based on original busybox unzip applet by Laurence Anderson.
* All options and features should work in this version.
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
/* For reference see
* http://www.pkware.com/company/standards/appnote/
* http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip
*/
/* TODO
* Endian issues
* Zip64 + other methods
* Improve handling of zip format, ie.
* - deferred CRC, comp. & uncomp. lengths (zip header flags bit 3)
* - unix file permissions, etc.
* - central directory
*/
#include "busybox.h"
#include "unarchive.h"
#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
#define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50)
#define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50)
#define ZIP_DD_MAGIC SWAP_LE32(0x08074b50)
extern unsigned int gunzip_crc;
extern unsigned int gunzip_bytes_out;
typedef union {
unsigned char raw[26];
struct {
unsigned short version; /* 0-1 */
unsigned short flags; /* 2-3 */
unsigned short method; /* 4-5 */
unsigned short modtime; /* 6-7 */
unsigned short moddate; /* 8-9 */
unsigned int crc32 ATTRIBUTE_PACKED; /* 10-13 */
unsigned int cmpsize ATTRIBUTE_PACKED; /* 14-17 */
unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
unsigned short filename_len; /* 22-23 */
unsigned short extra_len; /* 24-25 */
} formatted ATTRIBUTE_PACKED;
} zip_header_t;
static void unzip_skip(int fd, off_t skip)
{
if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
if ((errno != ESPIPE) || (bb_copyfd_size(fd, -1, skip) != skip)) {
bb_error_msg_and_die("seek failure");
}
}
}
static void unzip_create_leading_dirs(char *fn)
{
/* Create all leading directories */
char *name = xstrdup(fn);
if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */
}
free(name);
}
static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
{
if (zip_header->formatted.method == 0) {
/* Method 0 - stored (not compressed) */
off_t size = zip_header->formatted.ucmpsize;
if (size && (bb_copyfd_size(src_fd, dst_fd, size) != size)) {
bb_error_msg_and_die("cannot complete extraction");
}
} else {
/* Method 8 - inflate */
inflate_init(zip_header->formatted.cmpsize);
inflate_unzip(src_fd, dst_fd);
inflate_cleanup();
/* Validate decompression - crc */
if (zip_header->formatted.crc32 != (gunzip_crc ^ 0xffffffffL)) {
bb_error_msg("invalid compressed data--%s error", "crc");
return 1;
}
/* Validate decompression - size */
if (zip_header->formatted.ucmpsize != gunzip_bytes_out) {
bb_error_msg("invalid compressed data--%s error", "length");
return 1;
}
}
return 0;
}
int unzip_main(int argc, char **argv)
{
zip_header_t zip_header;
enum {v_silent, v_normal, v_list} verbosity = v_normal;
enum {o_prompt, o_never, o_always} overwrite = o_prompt;
unsigned int total_size = 0;
unsigned int total_entries = 0;
int src_fd = -1, dst_fd = -1;
char *src_fn = NULL, *dst_fn = NULL;
llist_t *zaccept = NULL;
llist_t *zreject = NULL;
char *base_dir = NULL;
int failed, i, opt, opt_range = 0, list_header_done = 0;
char key_buf[512];
struct stat stat_buf;
while((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
switch (opt_range) {
case 0: /* Options */
switch (opt) {
case 'l': /* List */
verbosity = v_list;
break;
case 'n': /* Never overwrite existing files */
overwrite = o_never;
break;
case 'o': /* Always overwrite existing files */
overwrite = o_always;
break;
case 'p': /* Extract files to stdout and fall through to set verbosity */
dst_fd = STDOUT_FILENO;
case 'q': /* Be quiet */
verbosity = (verbosity == v_normal) ? v_silent : verbosity;
break;
case 1 : /* The zip file */
src_fn = xstrndup(optarg, strlen(optarg)+4);
opt_range++;
break;
default:
bb_show_usage();
}
break;
case 1: /* Include files */
if (opt == 1) {
llist_add_to(&zaccept, optarg);
} else if (opt == 'd') {
base_dir = optarg;
opt_range += 2;
} else if (opt == 'x') {
opt_range++;
} else {
bb_show_usage();
}
break;
case 2 : /* Exclude files */
if (opt == 1) {
llist_add_to(&zreject, optarg);
} else if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
opt_range++;
} else {
bb_show_usage();
}
break;
default:
bb_show_usage();
}
}
if (src_fn == NULL) {
bb_show_usage();
}
/* Open input file */
if (strcmp("-", src_fn) == 0) {
src_fd = STDIN_FILENO;
/* Cannot use prompt mode since zip data is arriving on STDIN */
overwrite = (overwrite == o_prompt) ? o_never : overwrite;
} else {
static const char *const extn[] = {"", ".zip", ".ZIP"};
int orig_src_fn_len = strlen(src_fn);
for(i = 0; (i < 3) && (src_fd == -1); i++) {
strcpy(src_fn + orig_src_fn_len, extn[i]);
src_fd = open(src_fn, O_RDONLY);
}
if (src_fd == -1) {
src_fn[orig_src_fn_len] = 0;
bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
}
}
/* Change dir if necessary */
if (base_dir)
xchdir(base_dir);
if (verbosity != v_silent)
printf("Archive: %s\n", src_fn);
failed = 0;
while (1) {
unsigned int magic;
/* Check magic number */
xread(src_fd, &magic, 4);
if (magic == ZIP_CDS_MAGIC) {
break;
} else if (magic != ZIP_FILEHEADER_MAGIC) {
bb_error_msg_and_die("invalid zip magic %08X", magic);
}
/* Read the file header */
xread(src_fd, zip_header.raw, 26);
zip_header.formatted.version = SWAP_LE32(zip_header.formatted.version);
zip_header.formatted.flags = SWAP_LE32(zip_header.formatted.flags);
zip_header.formatted.method = SWAP_LE32(zip_header.formatted.method);
zip_header.formatted.modtime = SWAP_LE32(zip_header.formatted.modtime);
zip_header.formatted.moddate = SWAP_LE32(zip_header.formatted.moddate);
zip_header.formatted.crc32 = SWAP_LE32(zip_header.formatted.crc32);
zip_header.formatted.cmpsize = SWAP_LE32(zip_header.formatted.cmpsize);
zip_header.formatted.ucmpsize = SWAP_LE32(zip_header.formatted.ucmpsize);
zip_header.formatted.filename_len = SWAP_LE32(zip_header.formatted.filename_len);
zip_header.formatted.extra_len = SWAP_LE32(zip_header.formatted.extra_len);
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method);
}
/* Read filename */
free(dst_fn);
dst_fn = xzalloc(zip_header.formatted.filename_len + 1);
xread(src_fd, dst_fn, zip_header.formatted.filename_len);
/* Skip extra header bytes */
unzip_skip(src_fd, zip_header.formatted.extra_len);
if ((verbosity == v_list) && !list_header_done){
printf(" Length Date Time Name\n"
" -------- ---- ---- ----\n");
list_header_done = 1;
}
/* Filter zip entries */
if (find_list_entry(zreject, dst_fn) ||
(zaccept && !find_list_entry(zaccept, dst_fn))) { /* Skip entry */
i = 'n';
} else { /* Extract entry */
total_size += zip_header.formatted.ucmpsize;
if (verbosity == v_list) { /* List entry */
unsigned int dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
zip_header.formatted.ucmpsize,
(dostime & 0x01e00000) >> 21,
(dostime & 0x001f0000) >> 16,
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
(dostime & 0x0000f800) >> 11,
(dostime & 0x000007e0) >> 5,
dst_fn);
total_entries++;
i = 'n';
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
i = -1;
} else if (last_char_is(dst_fn, '/')) { /* Extract directory */
if (stat(dst_fn, &stat_buf) == -1) {
if (errno != ENOENT) {
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
}
if (verbosity == v_normal) {
printf(" creating: %s\n", dst_fn);
}
unzip_create_leading_dirs(dst_fn);
if (bb_make_directory(dst_fn, 0777, 0)) {
bb_error_msg_and_die("exiting");
}
} else {
if (!S_ISDIR(stat_buf.st_mode)) {
bb_error_msg_and_die("'%s' exists but is not directory", dst_fn);
}
}
i = 'n';
} else { /* Extract file */
_check_file:
if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
if (errno != ENOENT) {
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
}
i = 'y';
} else { /* File already exists */
if (overwrite == o_never) {
i = 'n';
} else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
if (overwrite == o_always) {
i = 'y';
} else {
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
if (!fgets(key_buf, 512, stdin)) {
bb_perror_msg_and_die("cannot read input");
}
i = key_buf[0];
}
} else { /* File is not regular file */
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
}
}
}
}
switch (i) {
case 'A':
overwrite = o_always;
case 'y': /* Open file and fall into unzip */
unzip_create_leading_dirs(dst_fn);
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
case -1: /* Unzip */
if (verbosity == v_normal) {
printf(" inflating: %s\n", dst_fn);
}
if (unzip_extract(&zip_header, src_fd, dst_fd)) {
failed = 1;
}
if (dst_fd != STDOUT_FILENO) {
/* closing STDOUT is potentially bad for future business */
close(dst_fd);
}
break;
case 'N':
overwrite = o_never;
case 'n':
/* Skip entry data */
unzip_skip(src_fd, zip_header.formatted.cmpsize);
break;
case 'r':
/* Prompt for new name */
printf("new name: ");
if (!fgets(key_buf, 512, stdin)) {
bb_perror_msg_and_die("cannot read input");
}
free(dst_fn);
dst_fn = xstrdup(key_buf);
chomp(dst_fn);
goto _check_file;
default:
printf("error: invalid response [%c]\n",(char)i);
goto _check_file;
}
/* Data descriptor section */
if (zip_header.formatted.flags & 4) {
/* skip over duplicate crc, compressed size and uncompressed size */
unzip_skip(src_fd, 12);
}
}
if (verbosity == v_list) {
printf(" -------- -------\n"
"%9d %d files\n", total_size, total_entries);
}
return failed;
}
+65
View File
@@ -0,0 +1,65 @@
/* vi: set sw=4 ts=4: */
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <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>
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)
{
int m, n;
char *s, *s1;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(basename_usage);
}
argv++;
s1=*argv+strlen(*argv)-1;
while (s1 && *s1 == '/') {
*s1 = '\0';
s1--;
}
s = strrchr(*argv, '/');
if (s==NULL) s=*argv;
else s++;
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);
}
+427
View File
@@ -0,0 +1,427 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
static int been_there_done_that = 0;
/* It has been alledged that doing such things can
* help reduce binary size when staticly linking,
* of course with glibc, this is unlikely as long
* as we use things like printf -- perhaps a printf
* replacement may be in order
*/
#if 0
void exit(int status) __attribute__ ((noreturn));
void exit(int status)
{
_exit(status);
};
void abort(void) __attribute__ ((__noreturn__));
void abort(void)
{
_exit(0);
};
int atexit(void (*__func) (void))
{
_exit(0);
};
void *__libc_stack_end;
#endif
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
{"busybox", busybox_main, _BB_DIR_BIN},
#ifdef BB_BLOCK_DEVICE
{"block_device", block_device_main, _BB_DIR_SBIN},
#endif
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_CLEAR
{"clear", clear_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN},
#endif
#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
#ifdef BB_DF
{"df", df_main, _BB_DIR_BIN},
#endif
#ifdef BB_DIRNAME
{"dirname", dirname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DMESG
{"dmesg", dmesg_main, _BB_DIR_BIN},
#endif
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_FDFLUSH
{"fdflush", fdflush_main, _BB_DIR_BIN},
#endif
#ifdef BB_FIND
{"find", find_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREE
{"free", free_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREERAMDISK
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_DEALLOCVT
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
#endif
#ifdef BB_HEAD
{"head", head_main, _BB_DIR_BIN},
#endif
#ifdef BB_HOSTID
{"hostid", hostid_main, _BB_DIR_USR_BIN},
#endif
#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
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
#endif
#ifdef BB_KILLALL
{"killall", kill_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LINUXRC
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
#endif
#ifdef BB_LOADACM
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADFONT
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
#endif
#ifdef BB_LSMOD
{"lsmod", lsmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
#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},
#endif
#ifdef BB_MOUNT
{"mount", mount_main, _BB_DIR_BIN},
#endif
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PING
{"ping", ping_main, _BB_DIR_BIN},
#endif
#ifdef BB_POWEROFF
{"poweroff", poweroff_main, _BB_DIR_SBIN},
#endif
#ifdef BB_PRINTF
{"printf", printf_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PS
{"ps", ps_main, _BB_DIR_BIN},
#endif
#ifdef BB_PWD
{"pwd", pwd_main, _BB_DIR_BIN},
#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_RM
{"rm", rm_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMDIR
{"rmdir", rmdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMMOD
{"rmmod", rmmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_SORT
{"sort", sort_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYNC
{"sync", sync_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_TAIL
{"tail", tail_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TAR
{"tar", tar_main, _BB_DIR_BIN},
#endif
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEE
{"tee", tee_main, _BB_DIR_BIN},
#endif
#ifdef BB_TOUCH
{"touch", touch_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TR
{"tr", tr_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UMOUNT
{"umount", umount_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
#endif
#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
#ifdef BB_YES
{"yes", yes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
{0}
};
int main(int argc, char **argv)
{
char *s;
char *name;
const struct BB_applet *a = applets;
for (s = name = argv[0]; *s != '\0';) {
if (*s++ == '/')
name = s;
}
*argv = name;
while (a->name != 0) {
if (strcmp(name, a->name) == 0) {
exit(((*(a->main)) (argc, argv)));
}
a++;
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
int col = 0;
argc--;
argv++;
if (been_there_done_that == 1 || argc < 1) {
const struct BB_applet *a = applets;
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"
"\nCurrently defined functions:\n", BB_VER, BB_BT);
while (a->name != 0) {
col +=
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
(a++)->name);
if (col > 60 && a->name != 0) {
fprintf(stderr, ",\n");
col = 0;
}
}
fprintf(stderr, "\n\n");
exit(-1);
}
/* If we've already been here once, exit now */
been_there_done_that = 1;
return (main(argc, argv));
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+295
View File
@@ -0,0 +1,295 @@
/* vi: set sw=4 ts=4: */
// This file defines the feature set to be compiled into busybox.
// When you turn things off here, they won't be compiled in at all.
//
//// This file is parsed by sed. You MUST use single line comments.
// i.e. //#define BB_BLAH
//
//
// BusyBox Applications
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
#define BB_DUTMP
#define BB_DU
#define BB_ECHO
#define BB_FBSET
#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
#define BB_FREERAMDISK
#define BB_FSCK_MINIX
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
#define BB_ID
#define BB_INIT
#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
#define BB_LENGTH
#define BB_LN
#define BB_LOADACM
#define BB_LOADFONT
#define BB_LOADKMAP
#define BB_LOGGER
#define BB_LOGNAME
#define BB_LS
#define BB_LSMOD
#define BB_MAKEDEVS
//#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
#define BB_NC
#define BB_MORE
#define BB_MOUNT
#define BB_MT
#define BB_NSLOOKUP
#define BB_PING
#define BB_POWEROFF
#define BB_PRINTF
#define BB_PS
#define BB_PWD
#define BB_REBOOT
#define BB_RM
#define BB_RMDIR
#define BB_RMMOD
#define BB_SED
#define BB_SETKEYCODES
#define BB_SFDISK
#define BB_SH
#define BB_SLEEP
#define BB_SORT
#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
#define BB_TAIL
#define BB_TAR
#define BB_TEE
#define BB_TEST
#define BB_TELNET
#define BB_TOUCH
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UPTIME
#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
#define BB_UPDATE
#define BB_YES
// End of Applications List
//
//
//
// ---------------------------------------------------------
// This is where feature definitions go. Generally speaking,
// turning this stuff off makes things a bit smaller (and less
// pretty/useful).
//
//
// Turn this on to use Erik's very cool devps, 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)
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// enable features that use the /proc filesystem (apps that
// break without this will tell you on compile)...
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
// at the same time...
#define BB_FEATURE_USE_PROCFS
//
// Enable full regular expressions. This adds about
// 4k. When this is off, things that would normally
// use regualr expressions (like grep) will just use
// normal strings.
#define BB_FEATURE_FULL_REGULAR_EXPRESSIONS
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
//#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_SIMPLE_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
//#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//
//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
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// Enable support for mounting remote NFS volumes
// (This does not yet work with Linux 2.[34].x kernels)
//#define BB_FEATURE_NFSMOUNT
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox commands as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell
//amoung other thing.
#define BB_FEATURE_STANDALONE_SHELL
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
// 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
//
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
//
#if defined BB_FEATURE_FULL_REGULAR_EXPRESSIONS && (defined BB_SED || defined BB_GREP )
#define BB_REGEXP
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#define BB_LINUXRC
#endif
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#endif
#endif
Executable
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# Make busybox links list file.
DF="busybox.def.h"
MF="busybox.c"
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
for def in ${LIST}; do
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
for j in $i; do
if [ -z $j ] ; then
continue;
fi;
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
done;
done
Executable
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 ` \
gcc -E -dM busybox.def.h | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr [:upper:] [:lower:] | sort
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
+36
View File
@@ -0,0 +1,36 @@
Name: busybox
Version: 0.45
Release: 1
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
Copyright: GPL
Packager : Erik Andersen <andersen@lineo.com>
Conflicts: fileutils grep shellutils
Buildroot: /tmp/%{Name}-%{Version}
Source: %{Name}-%{Version}.tar.gz
%Description
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}
%Build
make
%Install
rm -rf $RPM_BUILD_ROOT
make PREFIX=$RPM_BUILD_ROOT install
%Clean
rm -rf $RPM_BUILD_ROOT
%Files
%defattr(-,root,root)
/
+73
View File
@@ -0,0 +1,73 @@
/* vi: set sw=4 ts=4: */
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <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>
static void print_file(FILE * file)
{
int c;
while ((c = getc(file)) != EOF)
putc(c, stdout);
fclose(file);
fflush(stdout);
}
extern int cat_main(int argc, char **argv)
{
FILE *file;
if (argc == 1) {
print_file(stdin);
exit(TRUE);
}
if (**(argv + 1) == '-') {
usage("cat [FILE ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nConcatenates FILE(s) and prints them to the standard output.\n"
#endif
);
}
argc--;
while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
file = fopen(*argv, "r");
if (file == NULL) {
perror(*argv);
exit(FALSE);
}
print_file(file);
}
return(TRUE);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+201
View File
@@ -0,0 +1,201 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <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"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_option
#define bb_need_too_few_args
#include "messages.c"
#include <stdio.h>
#include <grp.h>
#include <pwd.h>
static unsigned long uid = -1;
static unsigned long gid = -1;
static int whichApp;
static char *invocationName = NULL;
static char *theMode = NULL;
#define CHGRP_APP 1
#define CHOWN_APP 2
#define CHMOD_APP 3
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"
#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"
#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\tChanges files and directories recursively.\n"
#endif
;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
switch (whichApp) {
case CHGRP_APP:
case CHOWN_APP:
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
if (lchown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#else
if (chown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#endif
{
return (TRUE);
}
break;
case CHMOD_APP:
/* Parse the specified modes */
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
fatalError( "%s: unknown mode: %s\n", invocationName, theMode);
}
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
break;
}
perror(fileName);
return (FALSE);
}
int chmod_chown_chgrp_main(int argc, char **argv)
{
int recursiveFlag = FALSE;
char *groupName=NULL;
char *p=NULL;
const char *appUsage;
whichApp = (strcmp(*argv, "chown") == 0)?
CHOWN_APP : (strcmp(*argv, "chmod") == 0)?
CHMOD_APP : CHGRP_APP;
appUsage = (whichApp == CHOWN_APP)?
chown_usage : (whichApp == CHMOD_APP) ? chmod_usage : chgrp_usage;
if (argc < 2)
usage(appUsage);
invocationName = *argv;
argv++;
/* Parse options */
while (--argc >= 0 && *argv && (**argv == '-')) {
while (*++(*argv)) {
switch (**argv) {
case 'R':
recursiveFlag = TRUE;
break;
default:
fprintf(stderr, invalid_option, invocationName, **argv);
usage(appUsage);
}
}
argv++;
}
if (argc == 0 || *argv == NULL) {
fprintf(stderr, too_few_args, invocationName);
usage(appUsage);
}
if (whichApp == CHMOD_APP) {
theMode = *argv;
} else {
/* Find the selected group */
if (whichApp == CHGRP_APP) {
groupName = *argv;
gid = strtoul(groupName, &p, 10); /* maybe it's already numeric */
if (groupName == p)
gid = my_getgrnam(groupName);
if (gid == -1)
goto bad_group;
} else {
groupName = strchr(*argv, '.');
if (groupName == NULL)
groupName = strchr(*argv, ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
if (gid == -1)
goto bad_group;
} else
gid = -1;
}
/* Find the selected user (if appropriate) */
if (whichApp == CHOWN_APP) {
uid = strtoul(*argv, &p, 10); /* if numeric ... */
if (*argv == p)
uid = my_getpwnam(*argv);
if (uid == -1) {
fatalError( "%s: unknown user name: %s\n",
invocationName, *argv);
}
}
}
/* Ok, ready to do the deed now */
if (argc <= 1) {
fatalError( "%s: too few arguments\n", invocationName);
}
while (argc-- > 1) {
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE)
exit(FALSE);
}
exit(TRUE);
bad_group:
fatalError( "%s: unknown group name: %s\n", invocationName, groupName);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+77
View File
@@ -0,0 +1,77 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <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 <stdlib.h>
#include <stdio.h>
#include <errno.h>
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);
}
argc--;
argv++;
if (chroot(*argv) || (chdir("/"))) {
fatalError("chroot: cannot change root directory to %s: %s\n",
*argv, strerror(errno));
}
argc--;
argv++;
if (argc >= 1) {
prog = *argv;
execvp(*argv, argv);
} else {
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
}
fatalError("chroot: cannot execute %s: %s\n",
prog, strerror(errno));
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+46
View File
@@ -0,0 +1,46 @@
/* vi: set sw=4 ts=4: */
/*
* chvt.c - aeb - 940227 - Change virtual terminal
*
* 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>
int chvt_main(int argc, char **argv)
{
int fd, num;
if ((argc != 2) || (**(argv + 1) == '-')) {
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]);
if (ioctl(fd, VT_ACTIVATE, num)) {
perror("VT_ACTIVATE");
exit(FALSE);
}
if (ioctl(fd, VT_WAITACTIVE, num)) {
perror("VT_WAITACTIVE");
exit(FALSE);
}
return(TRUE);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+33
View File
@@ -0,0 +1,33 @@
/* vi: set sw=4 ts=4: */
/*
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <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>
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
return(TRUE);
}
+691
View File
@@ -0,0 +1,691 @@
/* vi: set sw=4 ts=4: */
/*
* Termios command line History and Editting, originally
* intended for NetBSD sh (ash)
* Copyright (c) 1999
* Main code: Adam Rogoyski <rogoyski@cs.utexas.edu>
* Etc: Dave Cinege <dcinege@psychosis.com>
* Majorly adjusted/re-written for busybox:
* Erik Andersen <andersee@debian.org>
*
* You may use this code as you wish, so long as the original author(s)
* are attributed in any redistributions of the source code.
* This code is 'as is' with no warranty.
* This code may safely be consumed by a BSD or GPL license.
*
* v 0.5 19990328 Initial release
*
* Future plans: Simple file and path name completion. (like BASH)
*
*/
/*
Usage and Known bugs:
Terminal key codes are not extensive, and more will probably
need to be added. This version was created on Debian GNU/Linux 2.x.
Delete, Backspace, Home, End, and the arrow keys were tested
to work in an Xterm and console. Ctrl-A also works as Home.
Ctrl-E also works as End. The binary size increase is <3K.
Editting will not display correctly for lines greater then the
terminal width. (more then one line.) However, history will.
*/
#include "internal.h"
#ifdef BB_FEATURE_SH_COMMAND_EDITING
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <ctype.h>
#include <signal.h>
#define MAX_HISTORY 15 /* Maximum length of the linked list for the command line history */
#define ESC 27
#define DEL 127
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
static struct history *his_front = NULL; /* First element in command line list */
static struct history *his_end = NULL; /* Last element in command line list */
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS
#if #cpu(sparc)
# include <termio.h>
# define termios termio
# define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp)
# define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp)
#else
# include <termios.h>
# define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
# define getTermSettings(fd,argp) tcgetattr(fd, argp);
#endif
/* Current termio and the previous termio before starting sh */
struct termios initial_settings, new_settings;
#ifndef _POSIX_VDISABLE
#define _POSIX_VDISABLE '\0'
#endif
#endif
static int cmdedit_termw = 80; /* actual terminal width */
static int cmdedit_scroll = 27; /* width of EOL scrolling region */
static int history_counter = 0; /* Number of commands in history list */
static int reset_term = 0; /* Set to true if the terminal needs to be reset upon exit */
struct history {
char *s;
struct history *p;
struct history *n;
};
#define xwrite write
void
cmdedit_setwidth(int w)
{
if (w > 20) {
cmdedit_termw = w;
cmdedit_scroll = w / 3;
} else {
errorMsg("\n*** Error: minimum screen width is 21\n");
}
}
void cmdedit_reset_term(void)
{
if (reset_term)
/* sparc and other have broken termios support: use old termio handling. */
setTermSettings(fileno(stdin), (void*) &initial_settings);
}
void clean_up_and_die(int sig)
{
cmdedit_reset_term();
fprintf(stdout, "\n");
if (sig!=SIGINT)
exit(TRUE);
}
/* Go to HOME position */
void input_home(int outputFd, int *cursor)
{
while (*cursor > 0) {
xwrite(outputFd, "\b", 1);
--*cursor;
}
}
/* Go to END position */
void input_end(int outputFd, int *cursor, int len)
{
while (*cursor < len) {
xwrite(outputFd, "\033[C", 3);
++*cursor;
}
}
/* Delete the char in back of the cursor */
void input_backspace(char* command, int outputFd, int *cursor, int *len)
{
int j = 0;
if (*cursor > 0) {
xwrite(outputFd, "\b \b", 3);
--*cursor;
memmove(command + *cursor, command + *cursor + 1,
BUFSIZ - *cursor + 1);
for (j = *cursor; j < (BUFSIZ - 1); j++) {
if (!*(command + j))
break;
else
xwrite(outputFd, (command + j), 1);
}
xwrite(outputFd, " \b", 2);
while (j-- > *cursor)
xwrite(outputFd, "\b", 1);
--*len;
}
}
/* Delete the char in front of the cursor */
void input_delete(char* command, int outputFd, int cursor, int *len)
{
int j = 0;
if (cursor == *len)
return;
memmove(command + cursor, command + cursor + 1,
BUFSIZ - cursor - 1);
for (j = cursor; j < (BUFSIZ - 1); j++) {
if (!*(command + j))
break;
else
xwrite(outputFd, (command + j), 1);
}
xwrite(outputFd, " \b", 2);
while (j-- > cursor)
xwrite(outputFd, "\b", 1);
--*len;
}
/* Move forward one charactor */
void input_forward(int outputFd, int *cursor, int len)
{
if (*cursor < len) {
xwrite(outputFd, "\033[C", 3);
++*cursor;
}
}
/* Move back one charactor */
void input_backward(int outputFd, int *cursor)
{
if (*cursor > 0) {
xwrite(outputFd, "\033[D", 3);
--*cursor;
}
}
#ifdef BB_FEATURE_SH_TAB_COMPLETION
char** username_tab_completion(char* command, int *num_matches)
{
char **matches = (char **) NULL;
*num_matches=0;
fprintf(stderr, "\nin username_tab_completion\n");
return (matches);
}
#include <dirent.h>
char** exe_n_cwd_tab_completion(char* command, int *num_matches)
{
char *dirName;
char **matches = (char **) NULL;
DIR *dir;
struct dirent *next;
matches = malloc( sizeof(char*)*50);
/* Stick a wildcard onto the command, for later use */
strcat( command, "*");
/* Now wall the current directory */
dirName = get_current_dir_name();
dir = opendir(dirName);
if (!dir) {
/* Don't print an error, just shut up and return */
*num_matches=0;
return (matches);
}
while ((next = readdir(dir)) != NULL) {
/* Some quick sanity checks */
if ((strcmp(next->d_name, "..") == 0)
|| (strcmp(next->d_name, ".") == 0)) {
continue;
}
/* See if this matches */
if (check_wildcard_match(next->d_name, command) == TRUE) {
/* Cool, found a match. Add it to the list */
matches[*num_matches] = malloc(strlen(next->d_name)+1);
strcpy( matches[*num_matches], next->d_name);
++*num_matches;
//matches = realloc( matches, sizeof(char*)*(*num_matches));
}
}
return (matches);
}
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
{
/* Do TAB completion */
static int num_matches=0;
static char **matches = (char **) NULL;
int pos = cursor;
if (lastWasTab == FALSE) {
char *tmp, *tmp1, *matchBuf;
/* For now, we will not bother with trying to distinguish
* whether the cursor is in/at a command extression -- we
* will always try all possible matches. If you don't like
* that then feel free to fix it.
*/
/* Make a local copy of the string -- up
* to the position of the cursor */
matchBuf = (char *) calloc(BUFSIZ, sizeof(char));
strncpy(matchBuf, command, cursor);
tmp=matchBuf;
/* skip past any command seperator tokens */
while (*tmp && (tmp1=strpbrk(tmp, ";|&{(`")) != NULL) {
tmp=++tmp1;
/* skip any leading white space */
while (*tmp && isspace(*tmp))
++tmp;
}
/* skip any leading white space */
while (*tmp && isspace(*tmp))
++tmp;
/* Free up any memory already allocated */
if (matches) {
free(matches);
matches = (char **) NULL;
}
/* If the word starts with `~' and there is no slash in the word,
* then try completing this word as a username. */
/* FIXME -- this check is broken! */
if (*tmp == '~' && !strchr(tmp, '/'))
matches = username_tab_completion(tmp, &num_matches);
/* Try to match any executable in our path and everything
* in the current working directory that matches. */
if (!matches)
matches = exe_n_cwd_tab_completion(tmp, &num_matches);
/* Don't leak memory */
free( matchBuf);
/* Did we find exactly one match? */
if (matches && num_matches==1) {
/* write out the matched command */
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
len=strlen(command);
cursor=len;
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
break;
}
} else {
/* Ok -- the last char was a TAB. Since they
* just hit TAB again, print a list of all the
* available choices... */
if ( matches && num_matches>0 ) {
int i, col;
/* Go to the next line */
xwrite(outputFd, "\n", 1);
/* Print the list of matches */
for (i=0,col=0; i<num_matches; i++) {
char foo[17];
sprintf(foo, "%-14s ", matches[i]);
col += xwrite(outputFd, foo, strlen(foo));
if (col > 60 && matches[i+1] != NULL) {
xwrite(outputFd, "\n", 1);
col = 0;
}
}
/* Go to the next line */
xwrite(outputFd, "\n", 1);
/* Rewrite the prompt */
xwrite(outputFd, prompt, strlen(prompt));
/* Rewrite the command */
xwrite(outputFd, command, len);
/* Put the cursor back to where it used to be */
for (cursor=len; cursor > pos; cursor--)
xwrite(outputFd, "\b", 1);
}
}
}
#endif
void get_previous_history(struct history **hp, char* command)
{
free((*hp)->s);
(*hp)->s = strdup(command);
*hp = (*hp)->p;
}
void get_next_history(struct history **hp, char* command)
{
free((*hp)->s);
(*hp)->s = strdup(command);
*hp = (*hp)->n;
}
/*
* This function is used to grab a character buffer
* from the input file descriptor and allows you to
* a string with full command editing (sortof like
* a mini readline).
*
* The following standard commands are not implemented:
* ESC-b -- Move back one word
* ESC-f -- Move forward one word
* ESC-d -- Delete back one word
* ESC-h -- Delete forward one word
* CTL-t -- Transpose two characters
*
* Furthermore, the "vi" command editing keys are not implemented.
*
* TODO: implement TAB command completion. :)
*/
extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
{
int inputFd=fileno(stdin);
int outputFd=fileno(stdout);
int nr = 0;
int len = 0;
int j = 0;
int cursor = 0;
int break_out = 0;
int ret = 0;
int lastWasTab = FALSE;
char c = 0;
struct history *hp = his_end;
memset(command, 0, sizeof(command));
if (!reset_term) {
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;
}
setTermSettings(inputFd, (void*) &new_settings);
memset(command, 0, BUFSIZ);
while (1) {
if ((ret = read(inputFd, &c, 1)) < 1)
return;
//fprintf(stderr, "got a '%c' (%d)\n", c, c);
switch (c) {
case '\n':
case '\r':
/* Enter */
*(command + len++ + 1) = c;
xwrite(outputFd, &c, 1);
break_out = 1;
break;
case 1:
/* Control-a -- Beginning of line */
input_home(outputFd, &cursor);
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
* if the len=0 and no chars to delete */
if (len == 0) {
xwrite(outputFd, "exit", 4);
clean_up_and_die(0);
} else {
input_delete(command, outputFd, cursor, &len);
}
break;
case 5:
/* Control-e -- End of line */
input_end(outputFd, &cursor, len);
break;
case 6:
/* Control-f -- Move forward one character */
input_forward(outputFd, &cursor, len);
break;
case '\b':
case DEL:
/* Control-h and DEL */
input_backspace(command, outputFd, &cursor, &len);
break;
case '\t':
#ifdef BB_FEATURE_SH_TAB_COMPLETION
input_tab(command, prompt, outputFd, &cursor, &len);
#endif
break;
case 14:
/* Control-n -- Get next command in history */
if (hp && hp->n && hp->n->s) {
get_next_history(&hp, command);
goto rewrite_line;
} else {
xwrite(outputFd, "\007", 1);
}
break;
case 16:
/* Control-p -- Get previous command from history */
if (hp && hp->p) {
get_previous_history(&hp, command);
goto rewrite_line;
} else {
xwrite(outputFd, "\007", 1);
}
break;
case ESC:{
/* escape sequence follows */
if ((ret = read(inputFd, &c, 1)) < 1)
return;
if (c == '[') { /* 91 */
if ((ret = read(inputFd, &c, 1)) < 1)
return;
switch (c) {
case 'A':
/* Up Arrow -- Get previous command from history */
if (hp && hp->p) {
get_previous_history(&hp, command);
goto rewrite_line;
} else {
xwrite(outputFd, "\007", 1);
}
break;
case 'B':
/* Down Arrow -- Get next command in history */
if (hp && hp->n && hp->n->s) {
get_next_history(&hp, command);
goto rewrite_line;
} else {
xwrite(outputFd, "\007", 1);
}
break;
/* Rewrite the line with the selected history item */
rewrite_line:
/* erase old command from command line */
len = strlen(command)-strlen(hp->s);
while (len>0)
input_backspace(command, outputFd, &cursor, &len);
input_home(outputFd, &cursor);
/* write new command */
strcpy(command, hp->s);
len = strlen(hp->s);
xwrite(outputFd, command, len);
cursor = len;
break;
case 'C':
/* Right Arrow -- Move forward one character */
input_forward(outputFd, &cursor, len);
break;
case 'D':
/* Left Arrow -- Move back one character */
input_backward(outputFd, &cursor);
break;
case '3':
/* Delete */
input_delete(command, outputFd, cursor, &len);
break;
case '1':
/* Home (Ctrl-A) */
input_home(outputFd, &cursor);
break;
case '4':
/* End (Ctrl-E) */
input_end(outputFd, &cursor, len);
break;
default:
xwrite(outputFd, "\007", 1);
}
if (c == '1' || c == '3' || c == '4')
if ((ret = read(inputFd, &c, 1)) < 1)
return; /* read 126 (~) */
}
if (c == 'O') {
/* 79 */
if ((ret = read(inputFd, &c, 1)) < 1)
return;
switch (c) {
case 'H':
/* Home (xterm) */
input_home(outputFd, &cursor);
break;
case 'F':
/* End (xterm) */
input_end(outputFd, &cursor, len);
break;
default:
xwrite(outputFd, "\007", 1);
}
}
c = 0;
break;
}
default: /* If it's regular input, do the normal thing */
if (!isprint(c)) { /* Skip non-printable characters */
break;
}
if (len >= (BUFSIZ - 2)) /* Need to leave space for enter */
break;
len++;
if (cursor == (len - 1)) { /* Append if at the end of the line */
*(command + cursor) = c;
} else { /* Insert otherwise */
memmove(command + cursor + 1, command + cursor,
len - cursor - 1);
*(command + cursor) = c;
for (j = cursor; j < len; j++)
xwrite(outputFd, command + j, 1);
for (; j > cursor; j--)
xwrite(outputFd, "\033[D", 3);
}
cursor++;
xwrite(outputFd, &c, 1);
break;
}
if (c == '\t')
lastWasTab = TRUE;
else
lastWasTab = FALSE;
if (break_out) /* Enter is the command terminator, no more input. */
break;
}
nr = len + 1;
setTermSettings(inputFd, (void *) &initial_settings);
reset_term = 0;
/* Handle command history log */
if (*(command)) {
struct history *h = his_end;
if (!h) {
/* No previous history */
h = his_front = malloc(sizeof(struct history));
h->n = malloc(sizeof(struct history));
h->p = NULL;
h->s = strdup(command);
h->n->p = h;
h->n->n = NULL;
h->n->s = NULL;
his_end = h->n;
history_counter++;
} else {
/* Add a new history command */
h->n = malloc(sizeof(struct history));
h->n->p = h;
h->n->n = NULL;
h->n->s = NULL;
h->s = strdup(command);
his_end = h->n;
/* After max history, remove the oldest command */
if (history_counter >= MAX_HISTORY) {
struct history *p = his_front->n;
p->p = NULL;
free(his_front->s);
free(his_front);
his_front = p;
} else {
history_counter++;
}
}
}
return;
}
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);
}
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
+37
View File
@@ -0,0 +1,37 @@
#ifndef GETLINE_H
#define GETLINE_H
/* unix systems can #define POSIX to use termios, otherwise
* the bsd or sysv interface will be used
*/
#ifdef __STDC__
#include <stddef.h>
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 */
void cmdedit_strwidth(cmdedit_strwidth_proc); /* to bind cmdedit_strlen */
extern int (*cmdedit_in_hook)(char *);
extern int (*cmdedit_out_hook)(char *);
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();
void cmdedit_strwidth();
extern int (*cmdedit_in_hook)();
extern int (*cmdedit_out_hook)();
extern int (*cmdedit_tab_hook)();
#endif /* __STDC__ */
#endif /* GETLINE_H */
-105
View File
@@ -1,105 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
menu "Console Utilities"
config CHVT
bool "chvt"
default n
help
This program is used to change to another terminal.
Example: chvt 4 (change to terminal /dev/tty4)
config CLEAR
bool "clear"
default n
help
This program clears the terminal screen.
config DEALLOCVT
bool "deallocvt"
default n
help
This program deallocates unused virtual consoles.
config DUMPKMAP
bool "dumpkmap"
default n
help
This program dumps the kernel's keyboard translation table to
stdout, in binary format. You can then use loadkmap to load it.
config LOADFONT
bool "loadfont"
default n
help
This program loads a console font from standard input.
config LOADKMAP
bool "loadkmap"
default n
help
This program loads a keyboard translation table from
standard input.
config OPENVT
bool "openvt"
default n
help
This program is used to start a command on an unused
virtual terminal.
config RESET
bool "reset"
default n
help
This program is used to reset the terminal screen, if it
gets messed up.
config RESIZE
bool "resize"
default n
help
This program is used to (re)set the width and height of your current
terminal.
config FEATURE_RESIZE_PRINT
bool "print environment variables"
default n
depends on RESIZE
help
Prints the newly set size (number of columns and rows) of
the terminal.
E.g.:
COLUMNS=80;LINES=44;export COLUMNS LINES;
config SETCONSOLE
bool "setconsole"
default n
help
This program redirects the system console to another device,
like the current tty while logged in via telnet.
config FEATURE_SETCONSOLE_LONG_OPTIONS
bool "Enable long options"
default n
depends on SET_CONSOLE && GETOPT_LONG
help
Support long options for the setconsole applet.
config SETKEYCODES
bool "setkeycodes"
default n
help
This program loads entries into the kernel's scancode-to-keycode
map, allowing unusual keyboards to generate usable keycodes.
config SETLOGCONS
bool "setlogcons"
default n
help
This program redirects the output console of kernel messages.
endmenu
-19
View File
@@ -1,19 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
lib-y:=
lib-$(CONFIG_CHVT) += chvt.o
lib-$(CONFIG_CLEAR) += clear.o
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
lib-$(CONFIG_SETCONSOLE) += setconsole.o
lib-$(CONFIG_LOADFONT) += loadfont.o
lib-$(CONFIG_LOADKMAP) += loadkmap.o
lib-$(CONFIG_OPENVT) += openvt.o
lib-$(CONFIG_RESET) += reset.o
lib-$(CONFIG_RESIZE) += resize.o
lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
lib-$(CONFIG_SETLOGCONS) += setlogcons.o
+34 -21
View File
@@ -1,33 +1,46 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chvt implementation for busybox
* chvt.c - aeb - 940227 - Change virtual terminal
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* busyboxed by Erik Andersen
*/
#include "busybox.h"
/* From <linux/vt.h> */
enum {
VT_ACTIVATE = 0x5606, /* make vt active */
VT_WAITACTIVE = 0x5607 /* wait for vt active */
};
#include "internal.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int chvt_main(int argc, char **argv)
{
int fd, num;
if (argc != 2) {
bb_show_usage();
if ((argc != 2) || (**(argv + 1) == '-')) {
usage ("chvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
#endif
);
}
fd = get_console_fd();
num = xatoul_range(argv[1], 1, 63);
if ((-1 == ioctl(fd, VT_ACTIVATE, num))
|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
bb_perror_msg_and_die("ioctl");
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num)) {
perror("VT_ACTIVATE");
exit(FALSE);
}
return EXIT_SUCCESS;
if (ioctl(fd, VT_WAITACTIVE, num)) {
perror("VT_WAITACTIVE");
exit(FALSE);
}
return(TRUE);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+20 -8
View File
@@ -2,20 +2,32 @@
/*
* Mini clear implementation for busybox
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <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
*
*/
/* no options, no getopt */
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include "busybox.h"
int clear_main(int argc, char **argv)
extern int clear_main(int argc, char **argv)
{
return printf("\033[H\033[J") != 6;
printf("\033[H\033[J");
return(TRUE);
}
+44 -26
View File
@@ -1,37 +1,55 @@
/* vi: set sw=4 ts=4: */
/*
* Disallocate virtual terminal(s)
*
* Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
* Renamed deallocvt.
*/
#include "internal.h"
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <stdio.h>
/* no options, no getopt */
#include "busybox.h"
/* From <linux/vt.h> */
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
char *progname;
int deallocvt_main(int argc, char *argv[])
{
/* num = 0 deallocate all unused consoles */
int num = 0;
int fd, num, i;
switch (argc) {
case 2:
num = xatoul_range(argv[1], 1, 63);
/* Fallthrough */
case 1:
break;
default:
bb_show_usage();
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("deallocvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDeallocate unused virtual terminal /dev/ttyN\n"
#endif
);
}
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
bb_perror_msg_and_die("VT_DISALLOCATE");
}
return EXIT_SUCCESS;
progname = argv[0];
fd = get_console_fd("/dev/console");
if (argc == 1) {
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
exit( FALSE);
}
} else
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
fprintf(stderr, "%s: 0: illegal VT number\n", progname);
else if (num == 1)
fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
progname);
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n",
progname, num);
exit( FALSE);
}
}
return( TRUE);
}
-65
View File
@@ -1,65 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dumpkmap implementation for busybox
*
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
#include "busybox.h"
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_table;
unsigned char kb_index;
unsigned short kb_value;
};
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv)
{
struct kbentry ke;
int i, j, fd;
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
if (argc >= 2 && *argv[1] == '-')
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
write(1, magic, 7);
/* Here we want to set everything to 0 except for indexes:
* [0-2] [4-6] [8-10] [12] */
memset(flags, 0x00, MAX_NR_KEYMAPS);
memset(flags, 0x01, 13);
flags[3] = flags[7] = flags[11] = 0;
/* dump flags */
write(1, flags, MAX_NR_KEYMAPS);
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) {
bb_perror_msg("ioctl failed with %s, %s, %p",
(char *)&ke.kb_index,
(char *)&ke.kb_table,
&ke.kb_value);
} else {
write(1, (void*)&ke.kb_value, 2);
}
}
}
}
close(fd);
return EXIT_SUCCESS;
}
+415
View File
@@ -0,0 +1,415 @@
/* vi: set sw=4 ts=4: */
/*
* Derived from
* mapscrn.c - version 0.92
*
* Was taken from console-tools and adapted by
* Peter Novodvorsky <petya@logic.ru>
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
static const char loadacm_usage[] = "loadacm\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nLoads an acm from standard input.\n"
#endif
;
typedef unsigned short unicode;
static long int ctoi(unsigned char *s, int *is_unicode);
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
unicode utf8_to_ucs2(char *buf);
int screen_map_load(int fd, FILE * fp);
int loadacm_main(int argc, char **argv)
{
int fd;
if (argc>=2 && *argv[1]=='-') {
usage(loadacm_usage);
}
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno));
return( FALSE);
}
if (screen_map_load(fd, stdin)) {
fprintf(stderr, "Error loading acm: %s\n", strerror(errno));
return( FALSE);
}
write(fd, "\033(K", 3);
return( TRUE);
}
int screen_map_load(int fd, FILE * fp)
{
struct stat stbuf;
unicode wbuf[E_TABSZ];
unsigned char buf[E_TABSZ];
int parse_failed = 0;
int is_unicode;
if (fstat(fp->_fileno, &stbuf))
perror("Cannot stat map file"), exit(1);
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
(parse_failed =
(-1 == uni_screen_map_read_ascii(fp, wbuf, &is_unicode)))
|| (S_ISREG(stbuf.st_mode) && (stbuf.st_size == (sizeof(unicode) * E_TABSZ)))) { /* test for binary UTF map by size */
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
fprintf(stderr,
"16bit screen-map MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed reading binary 16bit screen-map"),
exit(1);
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
perror("Cannot read [new] map from file"), exit(1);
#if 0
else
fprintf(stderr, "Input screen-map is binary.\n");
#endif
}
/* if it was effectively a 16-bit ASCII, OK, else try to read as 8-bit map */
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
perror("PIO_UNISCRNMAP ioctl"), exit(1);
else
return 0;
}
}
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
fprintf(stderr,
"Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed assuming 8bit screen-map"), exit(1);
}
/* ... and try an old 8-bit screen-map */
if (!(parse_failed = (-1 == old_screen_map_read_ascii(fp, buf))) ||
(S_ISREG(stbuf.st_mode) && (stbuf.st_size == E_TABSZ))) { /* test for binary old 8-bit map by size */
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
fprintf(stderr, "fseek() returned ESPIPE !\n"),
exit(1);
else
perror("fseek for binary 8bit screen-map"), exit(1);
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
perror("Cannot read [old] map from file"), exit(1);
#if 0
else
fprintf(stderr, "Input screen-map is binary.\n");
#endif
}
if (ioctl(fd, PIO_SCRNMAP, buf))
perror("PIO_SCRNMAP ioctl"), exit(1);
else
return 0;
}
fprintf(stderr, "Error parsing symbolic map\n");
return(1);
}
/*
* - reads `fp' as a 16-bit ASCII SFM file.
* - returns -1 on error.
* - returns it in `unicode' in an E_TABSZ-elements array.
* - sets `*is_unicode' flagiff there were any non-8-bit
* (ie. real 16-bit) mapping.
*
* FIXME: ignores everything after second word
*/
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
{
char buffer[256]; /* line buffer reading file */
char *p, *q; /* 1st + 2nd words in line */
int in, on; /* the same, as numbers */
int tmp_is_unicode; /* tmp for is_unicode calculation */
int i; /* loop index - result holder */
int ret_code = 0; /* return code */
sigset_t sigset, old_sigset;
assert(is_unicode);
*is_unicode = 0;
/* first 128 codes defaults to ASCII */
for (i = 0; i < 128; i++)
buf[i] = i;
/* remaining defaults to replacement char (usually E_TABSZ = 256) */
for (; i < E_TABSZ; i++)
buf[i] = 0xfffd;
/* block SIGCHLD */
sigemptyset(&sigset);
sigaddset(&sigset, SIGCHLD);
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
do {
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
else {
perror("uni_screen_map_read_ascii() can't read line");
exit(2);
}
}
/* get "charset-relative charcode", stripping leading spaces */
p = strtok(buffer, " \t\n");
/* skip empty lines and comments */
if (!p || *p == '#')
continue;
/* get unicode mapping */
q = strtok(NULL, " \t\n");
if (q) {
in = ctoi(p, NULL);
if (in < 0 || in > 255) {
ret_code = -1;
break;
}
on = ctoi(q, &tmp_is_unicode);
if (in < 0 && on > 65535) {
ret_code = -1;
break;
}
*is_unicode |= tmp_is_unicode;
buf[in] = on;
} else {
ret_code = -1;
break;
}
}
while (1); /* terminated by break on feof() */
/* restore sig mask */
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
return ret_code;
}
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
{
char buffer[256];
int in, on;
char *p, *q;
for (in = 0; in < 256; in++)
buf[in] = in;
while (fgets(buffer, sizeof(buffer) - 1, fp)) {
p = strtok(buffer, " \t\n");
if (!p || *p == '#')
continue;
q = strtok(NULL, " \t\n#");
if (q) {
in = ctoi(p, NULL);
if (in < 0 || in > 255)
return -1;
on = ctoi(q, NULL);
if (in < 0 && on > 255)
return -1;
buf[in] = on;
} else
return -1;
}
return (0);
}
/*
* - converts a string into an int.
* - supports dec and hex bytes, hex UCS2, single-quoted byte and UTF8 chars.
* - returns the converted value
* - if `is_unicode != NULL', use it to tell whether it was unicode
*
* CAVEAT: will report valid UTF mappings using only 1 byte as 8-bit ones.
*/
long int ctoi(unsigned char *s, int *is_unicode)
{
int i;
size_t ls;
ls = strlen(s);
if (is_unicode)
*is_unicode = 0;
/* hex-specified UCS2 */
if ((strncmp(s, "U+", 2) == 0) &&
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2)) {
sscanf(s + 2, "%x", &i);
if (is_unicode)
*is_unicode = 1;
}
/* hex-specified byte */
else if ((ls <= 4) && (strncmp(s, "0x", 2) == 0) &&
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2))
sscanf(s + 2, "%x", &i);
/* oct-specified number (byte) */
else if ((*s == '0') && (strspn(s, "01234567") == ls))
sscanf(s, "%o", &i);
/* dec-specified number (byte) */
else if (strspn(s, "0123456789") == ls)
sscanf(s, "%d", &i);
/* single-byte quoted char */
else if ((strlen(s) == 3) && (s[0] == '\'') && (s[2] == '\''))
i = s[1];
/* multi-byte UTF8 quoted char */
else if ((s[0] == '\'') && (s[ls - 1] == '\'')) {
s[ls - 1] = 0; /* ensure we'll not "parse UTF too far" */
i = utf8_to_ucs2(s + 1);
if (is_unicode)
*is_unicode = 1;
} else
return (-1);
return (i);
}
void saveoldmap(int fd, char *omfil)
{
FILE *fp;
char buf[E_TABSZ];
#ifdef GIO_UNISCRNMAP
unicode xbuf[E_TABSZ];
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
perror("GIO_UNISCRNMAP ioctl error");
#endif
if (ioctl(fd, GIO_SCRNMAP, buf)) {
perror("GIO_SCRNMAP ioctl error");
exit(1);
} else
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
#endif
if ((fp = fopen(omfil, "w")) == NULL) {
perror(omfil);
exit(1);
}
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
perror("Error writing map to file");
exit(1);
}
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
perror("Error writing map to file");
exit(1);
}
#endif
fclose(fp);
}
unicode utf8_to_ucs2(char *buf)
{
int utf_count = 0;
long utf_char = 0;
unicode tc = 0;
unsigned char c;
do {
c = *buf;
buf++;
/* if byte should be part of multi-byte sequence */
if (c & 0x80) {
/* if we have already started to parse a UTF8 sequence */
if (utf_count > 0 && (c & 0xc0) == 0x80) {
utf_char = (utf_char << 6) | (c & 0x3f);
utf_count--;
if (utf_count == 0)
tc = utf_char;
else
continue;
} else { /* Possibly 1st char of a UTF8 sequence */
if ((c & 0xe0) == 0xc0) {
utf_count = 1;
utf_char = (c & 0x1f);
} else if ((c & 0xf0) == 0xe0) {
utf_count = 2;
utf_char = (c & 0x0f);
} else if ((c & 0xf8) == 0xf0) {
utf_count = 3;
utf_char = (c & 0x07);
} else if ((c & 0xfc) == 0xf8) {
utf_count = 4;
utf_char = (c & 0x03);
} else if ((c & 0xfe) == 0xfc) {
utf_count = 5;
utf_char = (c & 0x01);
} else
utf_count = 0;
continue;
}
} else { /* not part of multi-byte sequence - treat as ASCII
* this makes incomplete sequences to be ignored
*/
tc = c;
utf_count = 0;
}
}
while (utf_count);
return tc;
}
+88 -40
View File
@@ -7,18 +7,34 @@
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
*/
#include "busybox.h"
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <memory.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
#include <endian.h>
enum {
PSF_MAGIC1 = 0x36,
PSF_MAGIC2 = 0x04,
#define PSF_MAGIC1 0x36
#define PSF_MAGIC2 0x04
PSF_MODE512 = 0x01,
PSF_MODEHASTAB = 0x02,
PSF_MAXMODE = 0x03,
PSF_SEPARATOR = 0xFFFF
};
#define PSF_MODE512 0x01
#define PSF_MODEHASTAB 0x02
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
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 */
@@ -30,28 +46,35 @@ struct psf_header {
static void loadnewfont(int fd);
int loadfont_main(int argc, char **argv)
extern int loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
bb_show_usage();
if (argc>=2 && *argv[1]=='-') {
usage(loadfont_usage);
}
fd = xopen(CURRENT_VC, O_RDWR);
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
return( FALSE);
}
loadnewfont(fd);
return EXIT_SUCCESS;
return( TRUE);
}
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
{
char buf[16384];
int i;
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32)
bb_error_msg_and_die("bad character size %d", unit);
if (unit < 1 || unit > 32) {
fprintf(stderr, "Bad character size %d\n", unit);
exit(1);
}
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
@@ -66,11 +89,13 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */
bb_perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
perror("PIO_FONTX ioctl error (trying PIO_FONT)");
}
#endif
if (ioctl(fd, PIO_FONT, buf))
bb_perror_msg_and_die("PIO_FONT ioctl error");
if (ioctl(fd, PIO_FONT, buf)) {
perror("PIO_FONT ioctl error");
exit(1);
}
}
static void
@@ -84,8 +109,12 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
u_short unicode;
maxct = tailsz; /* more than enough */
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
if (!up) {
fprintf(stderr, "Out of memory?\n");
exit(1);
}
for (glyph = 0; glyph < fontsize; glyph++) {
while (tailsz >= 2) {
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
@@ -108,24 +137,31 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
bb_error_msg("it seems this kernel is older than 1.1.92");
bb_error_msg_and_die("no Unicode mapping table loaded");
fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
fprintf(stderr, "No Unicode mapping table loaded.\n");
} else
#endif
bb_perror_msg_and_die("PIO_UNIMAPCLR");
perror("PIO_UNIMAPCLR");
exit(1);
}
ud.entry_ct = ct;
ud.entries = up;
if (ioctl(fd, PIO_UNIMAP, &ud)) {
bb_perror_msg_and_die("PIO_UNIMAP");
#if 0
if (errno == ENOMEM) {
/* change advice parameters */
}
#endif
perror("PIO_UNIMAP");
exit(1);
}
}
static void loadnewfont(int fd)
{
int unit;
unsigned char inbuf[32768]; /* primitive */
unsigned int inputlth, offset;
char inbuf[32768]; /* primitive */
int inputlth, offset;
/*
* We used to look at the length of the input file
@@ -133,21 +169,25 @@ static void loadnewfont(int fd)
* just read the entire file.
*/
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin))
bb_perror_msg_and_die("error reading input font");
if (ferror(stdin)) {
perror("Error reading input font");
exit(1);
}
/* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values
for each font position */
if (!feof(stdin))
bb_perror_msg_and_die("font too large");
if (!feof(stdin)) {
perror("Font too large");
exit(1);
}
/* test for psf first */
{
struct psf_header psfhdr;
int fontsize;
int hastable;
unsigned int head0, head;
int head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
@@ -157,20 +197,26 @@ static void loadnewfont(int fd)
if (!PSF_MAGIC_OK(psfhdr))
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE)
bb_error_msg_and_die("unsupported psf file mode");
if (psfhdr.mode > PSF_MAXMODE) {
fprintf(stderr, "Unsupported psf file mode\n");
exit(1);
}
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256)
bb_error_msg_and_die("only fontsize 256 supported");
if (fontsize != 256) {
fprintf(stderr, "Only fontsize 256 supported\n");
exit(1);
}
#endif
hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize;
head0 = sizeof(struct psf_header);
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth))
bb_error_msg_and_die("input file: bad length");
if (head > inputlth || (!hastable && head != inputlth)) {
fprintf(stderr, "Input file: bad length\n");
exit(1);
}
do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
@@ -184,8 +230,10 @@ static void loadnewfont(int fd)
unit = 16;
} else {
/* bare font */
if (inputlth & 0377)
bb_error_msg_and_die("bad input file size");
if (inputlth & 0377) {
fprintf(stderr, "Bad input file size\n");
exit(1);
}
offset = 0;
unit = inputlth / 256;
}
+66 -29
View File
@@ -4,49 +4,85 @@
*
* Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include "internal.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <linux/kd.h>
#include <linux/keyboard.h>
#include <sys/ioctl.h>
#define BINARY_KEYMAP_MAGIC "bkeymap"
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_table;
unsigned char kb_index;
unsigned short kb_value;
};
/* sets one entry in translation table */
#define KDSKBENT 0x4B47
static const char loadkmap_usage[] = "loadkmap\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"Loads a binary keyboard translation table from standard input.\n"
#endif
;
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv)
{
struct kbentry ke;
int i, j, fd;
u_short ibuff[NR_KEYS];
char flags[MAX_NR_KEYMAPS];
char buff[7];
u_short *ibuff;
int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short);
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap", buff[7];
if (argc != 1)
bb_show_usage();
if (argc>=2 && *argv[1]=='-') {
usage(loadkmap_usage);
}
fd = xopen(CURRENT_VC, O_RDWR);
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
exit(FALSE);
}
xread(0, buff, 7);
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("this is not a valid binary keymap");
read(0, buff, 7);
if (0 != strncmp(buff, magic, 7)) {
fprintf(stderr, "This is not a valid binary keymap.\n");
exit(FALSE);
}
xread(0, flags, MAX_NR_KEYMAPS);
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) {
fprintf(stderr, "Error reading keymap flags: %s\n",
strerror(errno));
exit(FALSE);
}
ibuff = (u_short *) malloc(ibuffsz);
if (!ibuff) {
fprintf(stderr, "Out of memory.\n");
exit(FALSE);
}
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
xread(0, ibuff, NR_KEYS * sizeof(u_short));
pos = 0;
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
< 0) {
fprintf(stderr, "Error reading keymap: %s\n",
strerror(errno));
exit(FALSE);
}
pos += readsz;
}
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
@@ -55,7 +91,8 @@ int loadkmap_main(int argc, char **argv)
}
}
}
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
return 0;
/* Don't bother to close files. Exit does that
* automagically, so we can save a few bytes */
/* close(fd); */
return(TRUE);
}
-45
View File
@@ -1,45 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* openvt.c - open a vt to run a command.
*
* busyboxed by Quy Tonthat <quy@signal3.com>
* hacked by Tito <farmatito@tiscali.it>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* getopt not needed */
#include "busybox.h"
int openvt_main(int argc, char **argv)
{
int fd;
char vtname[sizeof(VC_FORMAT) + 2];
if (argc < 3) {
bb_show_usage();
}
/* check for illegal vt number: < 1 or > 63 */
sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
if (fork() == 0) {
/* leave current vt */
if (setsid() < 0) {
bb_perror_msg_and_die("setsid");
}
close(0); /* so that new vt becomes stdin */
/* and grab new one */
fd = xopen(vtname, O_RDWR);
/* Reassign stdout and sterr */
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
execvp(argv[2], &argv[2]);
_exit(1);
}
return EXIT_SUCCESS;
}
-32
View File
@@ -1,32 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini reset implementation for busybox
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
int reset_main(int argc, char **argv)
{
if (isatty(1)) {
/* See 'man 4 console_codes' for details:
* "ESC c" -- Reset
* "ESC ( K" -- Select user mapping
* "ESC [ J" -- Erase display
* "ESC [ 0 m" -- Reset all display attributes
* "ESC [ ? 25 h" -- Make cursor visible.
*/
printf("\033c\033(K\033[J\033[0m\033[?25h");
}
return EXIT_SUCCESS;
}
-38
View File
@@ -1,38 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* resize - set terminal width and height.
*
* Copyright 2006 Bernhard Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#include "busybox.h"
int resize_main(int argc, char **argv)
{
struct termios old, new;
struct winsize w = {0,0,0,0};
int ret;
tcgetattr(STDOUT_FILENO, &old); /* fiddle echo */
new = old;
new.c_cflag |= (CLOCAL | CREAD);
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
tcsetattr(STDOUT_FILENO, TCSANOW, &new);
/* save_cursor_pos 7
* scroll_whole_screen [r
* put_cursor_waaaay_off [$x;$yH
* get_cursor_pos [6n
* restore_cursor_pos 8
*/
printf("\0337\033[r\033[999;999H\033[6n");
scanf("\033[%hu;%huR", &w.ws_row, &w.ws_col);
ret = ioctl(STDOUT_FILENO, TIOCSWINSZ, &w);
printf("\0338");
tcsetattr(STDOUT_FILENO, TCSANOW, &old);
if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
w.ws_col, w.ws_row);
return ret;
}
-47
View File
@@ -1,47 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* setconsole.c - redirect system console output
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const struct option setconsole_long_options[] = {
{ "reset", 0, NULL, 'r' },
{ 0, 0, 0, 0 }
};
#endif
#define OPT_SETCONS_RESET 1
int setconsole_main(int argc, char **argv)
{
unsigned long flags;
const char *device = CURRENT_TTY;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
applet_long_options = setconsole_long_options;
#endif
flags = getopt32(argc, argv, "r");
if (argc - optind > 1)
bb_show_usage();
if (argc - optind == 1) {
if (flags & OPT_SETCONS_RESET)
bb_show_usage();
device = argv[optind];
} else {
if (flags & OPT_SETCONS_RESET)
device = CONSOLE_DEV;
}
if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) {
bb_perror_msg_and_die("TIOCCONS");
}
return EXIT_SUCCESS;
}
+54 -31
View File
@@ -4,50 +4,73 @@
*
* Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
*
* Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
* 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
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "busybox.h"
#include <linux/kd.h>
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
;
/* From <linux/kd.h> */
struct kbkeycode {
unsigned int scancode, keycode;
};
enum {
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
};
extern int
extern int
setkeycodes_main(int argc, char** argv)
{
int fd, sc;
struct kbkeycode a;
char *ep;
int fd, sc;
struct kbkeycode a;
if (argc % 2 != 1 || argc < 2) {
bb_show_usage();
if (argc % 2 != 1 || argc < 2) {
usage(setkeycodes_usage);
}
fd = get_console_fd("/dev/console");
fd = get_console_fd();
while (argc > 2) {
a.keycode = xatoul_range(argv[2], 0, 127);
a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
if (ioctl(fd, KDSETKEYCODE, &a)) {
bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
}
argc -= 2;
argv += 2;
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]);
}
return EXIT_SUCCESS;
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);
}
-31
View File
@@ -1,31 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* setlogcons: Send kernel messages to the current console or to console N
*
* Copyright (C) 2006 by Jan Kiszka <jan.kiszka@web.de>
*
* Based on setlogcons (kbd-1.12) by Andries E. Brouwer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
extern int setlogcons_main(int argc, char **argv)
{
struct {
char fn;
char subarg;
} arg;
arg.fn = 11; /* redirect kernel messages */
arg.subarg = 0; /* to specified console (current as default) */
if (argc == 2)
arg.subarg = xatoul_range(argv[1], 0, 63);
if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
bb_perror_msg_and_die("TIOCLINUX");
return 0;
}
-782
View File
@@ -1,782 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
menu "Coreutils"
config BASENAME
bool "basename"
default n
help
basename is used to strip the directory and suffix from filenames,
leaving just the filename itself. Enable this option if you wish
to enable the 'basename' utility.
config CAL
bool "cal"
default n
help
cal is used to display a monthly calender.
config CAT
bool "cat"
default n
help
cat is used to concatenate files and print them to the standard
output. Enable this option if you wish to enable the 'cat' utility.
config CATV
bool "catv"
default n
help
Display nonprinting characters as escape sequences (like some
implementations' cat -v option).
config CHGRP
bool "chgrp"
default n
help
chgrp is used to change the group ownership of files.
config CHMOD
bool "chmod"
default n
help
chmod is used to change the access permission of files.
config CHOWN
bool "chown"
default n
help
chown is used to change the user and/or group ownership
of files.
config CHROOT
bool "chroot"
default n
help
chroot is used to change the root directory and run a command.
The default command is `/bin/sh'.
config CKSUM
bool "cksum"
default n
help
cksum is used to calculate the CRC32 checksum of a file.
config CMP
bool "cmp"
default n
help
cmp is used to compare two files and returns the result
to standard output.
config COMM
bool "comm"
default n
help
comm is used to compare two files line by line and return
a three-column output.
config CP
bool "cp"
default n
help
cp is used to copy files and directories.
config CUT
bool "cut"
default n
help
cut is used to print selected parts of lines from
each file to stdout.
config DATE
bool "date"
default n
help
date is used to set the system date or display the
current time in the given format.
config FEATURE_DATE_ISOFMT
bool "Enable ISO date format output (-I)"
default y
depends on DATE
help
Enable option (-I) to output an ISO-8601 compliant
date/time string.
config DD
bool "dd"
default n
help
dd copies a file (from standard input to standard output,
by default) using specific input and output blocksizes,
while optionally performing conversions on it.
config FEATURE_DD_SIGNAL_HANDLING
bool "Enable DD signal handling for status reporting"
default y
depends on DD
help
sending a SIGUSR1 signal to a running `dd' process makes it
print to standard error the number of records read and written
so far, then to resume copying.
$ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
10899206+0 records in 10899206+0 records out
config FEATURE_DD_IBS_OBS
bool "Enable ibs, obs and conv options"
default n
depends on DD
help
Enables support for writing a certain number of bytes in and out,
at a time, and performing conversions on the data stream.
config DF
bool "df"
default n
help
df reports the amount of disk space used and available
on filesystems.
config DIFF
bool "diff"
default n
help
diff compares two files or directories and outputs the
differences between them in a form that can be given to
the patch command.
config FEATURE_DIFF_BINARY
bool "Enable checks for binary files"
default y
depends on DIFF
help
This option enables support for checking for binary files
before a comparison is carried out.
config FEATURE_DIFF_DIR
bool "Enable directory support"
default y
depends on DIFF
help
This option enables support for directory and subdirectory
comparison.
config FEATURE_DIFF_MINIMAL
bool "Enable -d option to find smaller sets of changes"
default n
depends on DIFF
help
Enabling this option allows the use of -d to make diff
try hard to find the smallest possible set of changes.
config DIRNAME
bool "dirname"
default n
help
dirname is used to strip a non-directory suffix from
a file name.
config DOS2UNIX
bool "dos2unix/unix2dos"
default n
help
dos2unix is used to convert a text file from DOS format to
UNIX format, and vice versa.
config UNIX2DOS
bool
default y
depends on DOS2UNIX
help
unix2dos is used to convert a text file from UNIX format to
DOS format, and vice versa.
config DU
bool "du (default blocksize of 512 bytes)"
default n
help
du is used to report the amount of disk space used
for specified files.
config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
bool "Use a default blocksize of 1024 bytes (1K)"
default y
depends on DU
help
Use a blocksize of (1K) instead of the default 512b.
config ECHO
bool "echo (basic SuSv3 version taking no options)"
default n
help
echo is used to print a specified string to stdout.
# this entry also appears in shell/Config.in, next to the echo builtin
config FEATURE_FANCY_ECHO
bool "Enable echo options (-n and -e)"
default y
depends on ECHO
help
This adds options (-n and -e) to echo.
config ENV
bool "env"
default n
help
env is used to set an environment variable and run
a command; without options it displays the current
environment.
config FEATURE_ENV_LONG_OPTIONS
bool "Enable long options"
default n
depends on ENV && GETOPT_LONG
help
Support long options for the env applet.
config EXPR
bool "expr"
default n
help
expr is used to calculate numbers and print the result
to standard output.
config EXPR_MATH_SUPPORT_64
bool "Extend Posix numbers support to 64 bit"
default n
depends on EXPR
help
Enable 64-bit math support in the expr applet. This will make
the applet slightly larger, but will allow computation with very
large numbers.
config FALSE
bool "false"
default n
help
false returns an exit code of FALSE (1).
config FOLD
bool "fold"
default n
help
Wrap text to fit a specific width.
config HEAD
bool "head"
default n
help
head is used to print the first specified number of lines
from files.
config FEATURE_FANCY_HEAD
bool "Enable head options (-c, -q, and -v)"
default n
depends on HEAD
help
This enables the head options (-c, -q, and -v).
config HOSTID
bool "hostid"
default n
help
hostid prints the numeric identifier (in hexadecimal) for
the current host.
config ID
bool "id"
default n
help
id displays the current user and group ID names.
config INSTALL
bool "install"
default n
help
Copy files and set attributes.
config FEATURE_INSTALL_LONG_OPTIONS
bool "Enable long options"
default n
depends on INSTALL && GETOPT_LONG
help
Support long options for the install applet.
config LENGTH
bool "length"
default n
help
length is used to print out the length of a specified string.
config LN
bool "ln"
default n
help
ln is used to create hard or soft links between files.
config LOGNAME
bool "logname"
default n
help
logname is used to print the current user's login name.
config LS
bool "ls"
default n
help
ls is used to list the contents of directories.
config FEATURE_LS_FILETYPES
bool "Enable filetyping options (-p and -F)"
default y
depends on LS
help
Enable the ls options (-p and -F).
config FEATURE_LS_FOLLOWLINKS
bool "Enable symlinks dereferencing (-L)"
default y
depends on LS
help
Enable the ls option (-L).
config FEATURE_LS_RECURSIVE
bool "Enable recursion (-R)"
default y
depends on LS
help
Enable the ls option (-R).
config FEATURE_LS_SORTFILES
bool "Sort the file names"
default y
depends on LS
help
Allow ls to sort file names alphabetically.
config FEATURE_LS_TIMESTAMPS
bool "Show file timestamps"
default y
depends on LS
help
Allow ls to display timestamps for files.
config FEATURE_LS_USERNAME
bool "Show username/groupnames"
default y
depends on LS
help
Allow ls to display username/groupname for files.
config FEATURE_LS_COLOR
bool "Allow use of color to identify file types"
default y
depends on LS && GETOPT_LONG
help
This enables the --color option to ls.
config FEATURE_LS_COLOR_IS_DEFAULT
bool "Produce colored ls output by default"
default n
depends on FEATURE_LS_COLOR
help
Saying yes here will turn coloring on by default,
even if no "--color" option is given to the ls command.
This is not recommended, since the colors are not
configurable, and the output may not be legible on
many output screens.
config MD5SUM
bool "md5sum"
default n
help
md5sum is used to print or check MD5 checksums.
config MKDIR
bool "mkdir"
default n
help
mkdir is used to create directories with the specified names.
config FEATURE_MKDIR_LONG_OPTIONS
bool "Enable long options"
default n
depends on MKDIR && GETOPT_LONG
help
Support long options for the mkdir applet.
config MKFIFO
bool "mkfifo"
default n
help
mkfifo is used to create FIFOs (named pipes).
The `mknod' program can also create FIFOs.
config MKNOD
bool "mknod"
default n
help
mknod is used to create FIFOs or block/character special
files with the specified names.
config MV
bool "mv"
default n
help
mv is used to move or rename files or directories.
config FEATURE_MV_LONG_OPTIONS
bool "Enable long options"
default n
depends on MV && GETOPT_LONG
help
Support long options for the mv applet.
config NICE
bool "nice"
default n
help
nice runs a program with modified scheduling priority.
config NOHUP
bool "nohup"
default n
help
run a command immune to hangups, with output to a non-tty.
config OD
bool "od"
default n
help
od is used to dump binary files in octal and other formats.
config PRINTENV
bool "printenv"
default n
help
printenv is used to print all or part of environment.
config PRINTF
bool "printf"
default n
help
printf is used to format and print specified strings.
It's similar to `echo' except it has more options.
config PWD
bool "pwd"
default n
help
pwd is used to print the current directory.
config REALPATH
bool "realpath"
default n
help
Return the canonicalized absolute pathname.
This isn't provided by GNU shellutils, but where else does it belong.
config RM
bool "rm"
default n
help
rm is used to remove files or directories.
config RMDIR
bool "rmdir"
default n
help
rmdir is used to remove empty directories.
config SEQ
bool "seq"
default n
help
print a sequence of numbers
config SHA1SUM
bool "sha1sum"
default n
help
Compute and check SHA1 message digest
config SLEEP
bool "sleep (single integer arg with no suffix)"
default n
help
sleep is used to pause for a specified number of seconds,
config FEATURE_FANCY_SLEEP
bool "Enable multiple integer args and optional time suffixes"
default n
depends on SLEEP
help
Allow sleep to pause for specified minutes, hours, and days.
config SORT
bool "sort"
default n
help
sort is used to sort lines of text in specified files.
config FEATURE_SORT_BIG
bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
default y
depends on SORT
help
Without this, sort only supports -r, -u, and an integer version
of -n. Selecting this adds sort keys, floating point support, and
more. This adds a little over 3k to a nonstatic build on x86.
The SuSv3 sort standard is available at:
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
config STAT
bool "stat"
default n
help
display file or filesystem status.
config FEATURE_STAT_FORMAT
bool "Enable custom formats (-c)"
default n
depends on STAT
help
Without this, stat will not support the '-c format' option where
users can pass a custom format string for output. This adds about
7k to a nonstatic build on amd64.
config STTY
bool "stty"
default n
help
stty is used to change and print terminal line settings.
config SUM
bool "sum"
default n
help
checksum and count the blocks in a file
config SYNC
bool "sync"
default n
help
sync is used to flush filesystem buffers.
config TAIL
bool "tail"
default n
help
tail is used to print the last specified number of lines
from files.
config FEATURE_FANCY_TAIL
bool "Enable extra tail options (-q, -s, and -v)"
default y
depends on TAIL
help
The options (-q, -s, and -v) are provided by GNU tail, but
are not specific in the SUSv3 standard.
config TEE
bool "tee"
default n
help
tee is used to read from standard input and write
to standard output and files.
config FEATURE_TEE_USE_BLOCK_IO
bool "Enable block i/o (larger/faster) instead of byte i/o."
default n
depends on TEE
help
Enable this option for a faster tee, at expense of size.
config TEST
bool "test"
default n
help
test is used to check file types and compare values,
returning an appropriate exit code. The bash shell
has test built in, ash can build it in optionally.
config FEATURE_TEST_64
bool "Extend test to 64 bit"
default n
depends on TEST
help
Enable 64-bit support in test.
config TOUCH
bool "touch"
default n
help
touch is used to create or change the access and/or
modification timestamp of specified files.
config TR
bool "tr"
default n
help
tr is used to squeeze, and/or delete characters from standard
input, writing to standard output.
config FEATURE_TR_CLASSES
bool "Enable character classes (such as [:upper:])"
default n
depends on TR
help
Enable character classes, enabling commands such as:
tr [:upper:] [:lower:] to convert input into lowercase.
config FEATURE_TR_EQUIV
bool "Enable equivalence classes"
default n
depends on TR
help
Enable equivalence classes, which essentially add the enclosed
character to the current set. For instance, tr [=a=] xyz would
replace all instances of 'a' with 'xyz'. This option is mainly
useful for cases when no other way of expressing a character
is possible.
config TRUE
bool "true"
default n
help
true returns an exit code of TRUE (0).
config TTY
bool "tty"
default n
help
tty is used to print the name of the current terminal to
standard output.
config UNAME
bool "uname"
default n
help
uname is used to print system information.
config UNIQ
bool "uniq"
default n
help
uniq is used to remove duplicate lines from a sorted file.
config USLEEP
bool "usleep"
default n
help
usleep is used to pause for a specified number of microseconds.
config UUDECODE
bool "uudecode"
default n
help
uudecode is used to decode a uuencoded file.
config UUENCODE
bool "uuencode"
default n
help
uuencode is used to uuencode a file.
config WATCH
bool "watch"
default n
select DATE
help
watch is used to execute a program periodically, showing
output to the screen.
config WC
bool "wc"
default n
help
wc is used to print the number of bytes, words, and lines,
in specified files.
config FEATURE_WC_LARGE
bool "Support very large files in wc"
default n
depends on WC
help
Use "unsigned long long" in wc for count variables
config WHO
bool "who"
default n
select FEATURE_UTMP
help
who is used to show who is logged on.
config WHOAMI
bool "whoami"
default n
help
whoami is used to print the username of the current
user id (same as id -un).
config YES
bool "yes"
default n
help
yes is used to repeatedly output a specific string, or
the default string `y'.
comment "Common options for cp and mv"
depends on CP || MV
config FEATURE_PRESERVE_HARDLINKS
bool "Preserve hard links"
default n
depends on CP || MV
help
Allow cp and mv to preserve hard links.
comment "Common options for ls, more and telnet"
depends on LS || MORE || TELNET
config FEATURE_AUTOWIDTH
bool "Calculate terminal & column widths"
default y
depends on LS || MORE || TELNET
help
This option allows utilities such as 'ls', 'more' and 'telnet'
to determine the width of the screen, which can allow them to
display additional text or avoid wrapping text onto the next line.
If you leave this disabled, your utilities will be especially
primitive and will be unable to determine the current screen width.
comment "Common options for df, du, ls"
depends on DF || DU || LS
config FEATURE_HUMAN_READABLE
bool "Support for human readable output (example 13k, 23M, 235G)"
default n
depends on DF || DU || LS
help
Allow df, du, and ls to have human readable output.
comment "Common options for md5sum, sha1sum"
depends on MD5SUM || SHA1SUM
config FEATURE_MD5_SHA1_SUM_CHECK
bool "Enable -c, -s and -w options"
default n
depends on MD5SUM || SHA1SUM
help
Enabling the -c options allows files to be checked
against pre-calculated hash values.
-s and -w are useful options when verifying checksums.
endmenu
-81
View File
@@ -1,81 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
libs-y += libcoreutils/
lib-y:=
lib-$(CONFIG_BASENAME) += basename.o
lib-$(CONFIG_CAL) += cal.o
lib-$(CONFIG_CAT) += cat.o
lib-$(CONFIG_CATV) += catv.o
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
lib-$(CONFIG_CHMOD) += chmod.o
lib-$(CONFIG_CHOWN) += chown.o
lib-$(CONFIG_CHROOT) += chroot.o
lib-$(CONFIG_CKSUM) += cksum.o
lib-$(CONFIG_CMP) += cmp.o
lib-$(CONFIG_COMM) += comm.o
lib-$(CONFIG_CP) += cp.o
lib-$(CONFIG_CUT) += cut.o
lib-$(CONFIG_DATE) += date.o
lib-$(CONFIG_DD) += dd.o
lib-$(CONFIG_DF) += df.o
lib-$(CONFIG_DIFF) += diff.o
lib-$(CONFIG_DIRNAME) += dirname.o
lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ENV) += env.o
lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_FALSE) += false.o
lib-$(CONFIG_FOLD) += fold.o
lib-$(CONFIG_HEAD) += head.o
lib-$(CONFIG_HOSTID) += hostid.o
lib-$(CONFIG_ID) += id.o
lib-$(CONFIG_INSTALL) += install.o
lib-$(CONFIG_LENGTH) += length.o
lib-$(CONFIG_LN) += ln.o
lib-$(CONFIG_LOGNAME) += logname.o
lib-$(CONFIG_LS) += ls.o
lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
lib-$(CONFIG_MKDIR) += mkdir.o
lib-$(CONFIG_MKFIFO) += mkfifo.o
lib-$(CONFIG_MKNOD) += mknod.o
lib-$(CONFIG_MV) += mv.o
lib-$(CONFIG_NICE) += nice.o
lib-$(CONFIG_NOHUP) += nohup.o
lib-$(CONFIG_OD) += od.o
lib-$(CONFIG_PRINTENV) += printenv.o
lib-$(CONFIG_PRINTF) += printf.o
lib-$(CONFIG_PWD) += pwd.o
lib-$(CONFIG_REALPATH) += realpath.o
lib-$(CONFIG_RM) += rm.o
lib-$(CONFIG_RMDIR) += rmdir.o
lib-$(CONFIG_SEQ) += seq.o
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
lib-$(CONFIG_SLEEP) += sleep.o
lib-$(CONFIG_SORT) += sort.o
lib-$(CONFIG_STAT) += stat.o
lib-$(CONFIG_STTY) += stty.o
lib-$(CONFIG_SUM) += sum.o
lib-$(CONFIG_SYNC) += sync.o
lib-$(CONFIG_TAIL) += tail.o
lib-$(CONFIG_TEE) += tee.o
lib-$(CONFIG_TEST) += test.o
lib-$(CONFIG_TOUCH) += touch.o
lib-$(CONFIG_TR) += tr.o
lib-$(CONFIG_TRUE) += true.o
lib-$(CONFIG_TTY) += tty.o
lib-$(CONFIG_UNAME) += uname.o
lib-$(CONFIG_UNIQ) += uniq.o
lib-$(CONFIG_USLEEP) += usleep.o
lib-$(CONFIG_UUDECODE) += uudecode.o
lib-$(CONFIG_UUENCODE) += uuencode.o
lib-$(CONFIG_WATCH) += watch.o
lib-$(CONFIG_WC) += wc.o
lib-$(CONFIG_WHO) += who.o
lib-$(CONFIG_WHOAMI) += whoami.o
lib-$(CONFIG_YES) += yes.o
Loaded 100 of 1057 files, more files were not shown because too many files have changed in this diff. Show more