Compare commits

...
218 Commits
Author SHA1 Message Date
Eric Andersen 1372780662 Patch from Cliff L. Biffle <cbiffle@safety.net> to display memory
usage in the ps listing
2002-04-27 06:06:11 +00:00
Eric Andersen 3a01f8cae2 uClibc supports struct _res these days... 2002-04-27 04:06:55 +00:00
Eric Andersen ef38b39262 Support noerror option 2002-04-27 01:31:43 +00:00
Eric Andersen aba75460e4 When the .config file is missing, supply a default one
and run menuconfig
2002-04-27 00:06:47 +00:00
Eric Andersen 1323c940fd Add netcat -i option, per patch from Cristian Ionescu-Idbohrn
<cristian.ionescu-idbohrn@axis.com>
2002-04-26 23:59:12 +00:00
Eric Andersen 00a6a75035 Add the who applet, supplied by Da Chen <dchen@ayrnetworks.com> 2002-04-26 23:53:10 +00:00
Eric Andersen 1c31501b1b Ensure that getenv("PATH") stays current, since otherwise cmdedit
(which calls getenv("PATH")) would not operate upon the current
PATH settings, which was really quite iritating.
 -Erik
2002-04-26 23:40:09 +00:00
Eric Andersen 416340642d Fix bugs 2002-04-26 08:44:17 +00:00
Eric Andersen 8db361b3e5 Minor formatting 2002-04-26 08:00:33 +00:00
Tim Riker ed8e036360 add missing void, still has issues though 2002-04-26 07:53:39 +00:00
Tim Riker 86c76a9c2a fix from kergoth 2002-04-26 07:41:22 +00:00
Eric Andersen 0e28e1fa05 Forward port patch from Przemyslaw Czerpak <druzus@polbox.com>:
1. busybox-telnet dosn't inform server about the size of terminal screen.
    In the world of xterminals and frame buffers it's rather horrible
    to use fixed 80x24 region in upper-left corner of screen/window.

 2. If client sends character 0x0d to the server then sends character 0x0a
   the server eat the second byte (0x0a) - it's described in telnet RFC.
    Client should send two bytes ( 0x0d + 0x0a or 0x0d + 0x00 ) insted of
    one 0x0d byte.

 3. busybox telnet implementation wasn't 8bit clean (look at 0xff byte).
    I need it because I have to use binray transfer like rz/sz. So when
    I resloved the problem (2) I corrected this one two.

This also contains a small cleanup patch from vodz, and some minor editing
by me.
2002-04-26 07:20:47 +00:00
Eric Andersen 60e56f5292 Reworked by Robert Griebl <griebl@gmx.de> to support proper
module dependancies.
2002-04-26 06:04:01 +00:00
Eric Andersen 54c14d7850 vodz noted this line (as imported from Debian) is wrong, and has since
been fixed upstream.
2002-04-24 23:14:06 +00:00
Eric Andersen ae1036185e Apply last_patch37 from vodz 2002-04-24 23:08:23 +00:00
Eric Andersen 5f6873621d ls could mis-color certain entries when previous commands
had failed.  Explicitly 0 out errno to prevent that.
2002-04-17 20:21:45 +00:00
Matt Kraai 272a95524f * networking/wget.c (wget_main): Check return value of safe_fwrite. 2002-04-17 15:33:24 +00:00
Matt Kraai a0782684fd * archival/bunzip2.c (bunzip2_main): Do not remove files if writing to standard
output.
* testsuite/bunzip2/bzcat-does-not-remove-compressed-file: New.
2002-04-15 15:01:37 +00:00
Eric Andersen 744ec1d549 Patch from Ben Low <ben@titr.uow.edu.au> to allow tftp to work
with stdin as well as stdout.
2002-04-15 07:40:27 +00:00
Eric Andersen 9fe5f98de4 Patch from Jim Treadway -- fix a missing "\" in usage.h 2002-04-13 14:48:51 +00:00
Eric Andersen c8459a5a8f Silly me 2002-04-13 14:44:42 +00:00
Eric Andersen 19732c6226 Teach makedevs to not segfault quite so much 2002-04-13 14:26:44 +00:00
Eric Andersen 4e116823f4 Patch from Larry Doolittle to teach syslogd to not give up when errno is EINTR 2002-04-13 14:07:32 +00:00
Eric Andersen fb24eb4f47 Cleanup make clean 2002-04-13 13:52:13 +00:00
Eric Andersen defd998c42 Patch from Kevin Hilman <khilman@equator.com> to fix potential
memory corruption from long pathnames in /etc/fstab.
2002-04-13 13:47:39 +00:00
Eric Andersen 1f30a41abe Add a 'make uninstall' target 2002-04-13 13:39:48 +00:00
Eric Andersen 5d8d4a674b Patch from Jim Treadway <jim@stardot-tech.com> to teach
pidof to not add trailing spaces when not needed.
2002-04-13 13:32:30 +00:00
Eric Andersen 65a0730c9f Patch from Jim Treadway and Vladimir Oleynik to Add CTRL-K
and fix CTRL-L support for cmdedit.c
2002-04-13 13:26:49 +00:00
Eric Andersen 3e6908b586 Sed can go into an infinite loop 2002-04-13 13:18:15 +00:00
Eric Andersen db7d5fca5f Stupid gcc always includes its own builtin strlen()... 2002-04-13 13:02:03 +00:00
Eric Andersen 4c9b68f0e0 Nice patch from Wolfgang Denk <wd@denx.de> to provide hush with
shell loops (for, while, until) and control operators (||, &&)
2002-04-13 12:33:41 +00:00
Eric Andersen a66a43e8ef Teach tftp to direct the fetched file to stdout when the
user specifies "-l -"
 -Erik
2002-04-13 09:30:25 +00:00
Eric Andersen d75ac02a4f Rework per how I did things in version in 0.60.3 so it can
properly uncompress multiple files now.
 -Erik
2002-04-13 09:10:34 +00:00
Eric Andersen 114de55668 Patch from Laurence Anderson <L.D.Anderson@warwick.ac.uk> for
better tape drive support in tar/cpio by using an intervening
pipe...
2002-04-13 08:43:01 +00:00
Eric Andersen 1d1d2f9b18 Update some missing copyright notices 2002-04-13 08:31:59 +00:00
Tim Riker 497a88506e make ash prompt the same as other shells if cmdedit and fancyprompt 2002-04-13 05:37:10 +00:00
Eric Andersen 85208e2ab9 Completely rework the config system so that it no longer annoys me to work on
the busybox development tree.  This eliminates the use of recursive make, and
once again allows us to run 'make' in a subdirectory with the expected result.
And things are now much faster too.  Greatly improved IMHO...
 -Erik
2002-04-12 12:05:57 +00:00
Eric Andersen b1591d1f8b Fix handling of endianness.
-Erik
2002-04-12 00:28:59 +00:00
Eric Andersen a3603e845e Oldnews 2002-04-11 20:40:00 +00:00
Eric Andersen 265d229427 Patch from Edward Betts <edward@debian.org> to add -x switch to du.c 2002-04-06 23:16:44 +00:00
Eric Andersen fcffa2cc1a Apply lash_patch35 from vodz, which brings several nice size_optimizations. 2002-04-06 05:17:57 +00:00
Eric Andersen 50e4d660ac Fix email addr 2002-04-06 05:15:46 +00:00
Eric Andersen 45673d2cc0 Add fli4l 2002-04-03 14:30:58 +00:00
Matt Kraai 5c69cd84ff * editors/sed.c (process_file): Stop processing deleted lines.
* testsuite/sed/sed-does-not-substitute-in-delete-line: New.
2002-04-01 16:17:37 +00:00
Miles Bader 75ce8d7c88 Tweak my credit (ah, vanity...) 2002-04-01 14:25:51 +00:00
Miles Bader 130bec5ad8 Add insmod support for the NEC v850e processor. 2002-04-01 09:37:27 +00:00
Miles Bader ae28b04ff2 Add support for the NEC v850e processor. 2002-04-01 09:34:25 +00:00
Eric Andersen c57e42b8f0 Provide a controlling tty to askfirst processes as well
-Erik
2002-03-29 00:59:44 +00:00
Matt Kraai 8a8308f129 * testsuite/which/which-uses-default-path: Remove extra echo. 2002-03-27 23:19:17 +00:00
Matt Kraai 66388f89a5 * testsuite/grep/egrep-supports-extended-regexps: Check exit status instead
of output.
2002-03-27 22:56:19 +00:00
Matt Kraai 50aec98e1c * testsuite/bunzip2/bunzip2-reads-from-standard-input: Remove -c flags.
* testsuite/gunzip/gunzip-reads-from-standard-input: Likewise.
2002-03-27 22:48:39 +00:00
Matt Kraai 6feaeace86 * testsuite/COPYING: Remove. 2002-03-27 22:43:47 +00:00
Matt Kraai cf32ac543c * archival/bunzip2.c (bunzip2_main): Remove compressed file.
* testsuite/bunzip2/bunzip2-removes-compressed-file: New.
2002-03-27 17:46:44 +00:00
Matt Kraai 35d60421b4 * testsuite/runtest (run_applet_testcase): Return test case status, not
process ID.
2002-03-27 17:33:31 +00:00
Matt Kraai 9cdb0601eb * archival/bunzip2.c: Include <unistd.h>.
(bunzip2_main): Read data from standard input if FILE argument is `-' or
  omitted.
* include/usage.h (bunzip2_trivial_usage, bunzip2_full_usage): Rewrite.
* testsuite/bunzip2/bunzip2-reads-from-standard-input: New.
2002-03-27 17:31:01 +00:00
Manuel Novoa III fa15f702d2 Work around compiler/assembler problem and reduce code size at the same time. 2002-03-25 02:37:20 +00:00
Matt Kraai ef8b112d77 * archival/gzip.c (gzip_main): Ensure that the output is a terminal and use
error_msg to display the error message.
2002-03-22 22:55:51 +00:00
Eric Andersen b88868276c Doh! I broke ping when removing the nested function.
This patch from vodz fixes it again.
2002-03-21 14:04:43 +00:00
Matt Kraai 83788da250 * include/applets.h (CONFIG_LOSETUP): New.
* include/usage.h (losetup_trivial_usage, losetup_full_usage): New.
* util-linux/Makefile: Add losetup.o.
* util-linux/config.in: Add losetup prompt.
* util-linux/losetup.c: New.
2002-03-20 17:38:37 +00:00
Eric Andersen 27eff033d2 Eliminate extra trailing space 2002-03-20 16:10:54 +00:00
Eric Andersen c7a3fb96d0 Fix devfs loop device support 2002-03-20 15:25:25 +00:00
Eric Andersen b0cc0a6ca8 Rewind messages to avoid weird formatting, and fix a bug with
CONFIG_FEATURE_EXTRA_QUIET, which was broken
2002-03-20 14:57:50 +00:00
Eric Andersen 889a301a0c Patch from vodz to fix a potential segfault 2002-03-20 14:31:15 +00:00
Eric Andersen 900c24dc4e Patch from Jeff Studer <jstuder@aquilagroup.com> to supply a defaults for
localfilename from remotefilename, and for remotefilename from localfilename
when the other one is not supplied.
2002-03-20 14:25:27 +00:00
Eric Andersen 5a40651046 Update dmalloc options per suggestion from Glenn 2002-03-20 14:16:31 +00:00
Eric Andersen 89de1e7930 Reinitialize initial shift register value for on each pass.
-Erik
2002-03-20 13:30:40 +00:00
Eric Andersen b5474c48b1 Cave to pressure (2 months later). Eliminate using a
nested function, which is a purely unremovable gcc-ism...
 -Erik
2002-03-20 11:59:28 +00:00
Eric Andersen b159146fa6 Add missing " " after the word on, as reported by Jason Luther
back in mid-december.
 -Erik
2002-03-20 09:52:45 +00:00
Eric Andersen 3ad0bd9563 Patch from J.W.Janssen <JanWillem.Janssen@lxtreme.nl> to provide
color ls support, modifed by me to behave properly when not running
output to a terminal (i.e. 'ls | more')
 -Erik
2002-03-20 09:13:48 +00:00
Eric Andersen 3ec5c692ec Bart Visscher noticed some spurious search and replace silliness
-Erik
2002-03-20 01:32:25 +00:00
Matt Kraai aee53f4604 * testsuite/grep/egrep-is-not-case-insensitive: Require
CONFIG_FEATURE_GREP_EGREP_ALIAS.
2002-03-19 23:47:49 +00:00
Matt Kraai b3de66869b * testsuite/grep/grep-handles-binary-files: Read input from a pipe.
* testsuite/grep/grep-matches-NUL: Likewise.
2002-03-19 23:46:16 +00:00
Matt Kraai 0efab3319d * networking/wget.c (parse_url): Allocate a string for the empty path.
* testsuite/wget/wget-handles-empty-path: New.
2002-03-19 15:22:42 +00:00
Matt Kraai 3b1cbd7bec Thomas Lundquist
* docs/new-applet-HOWTO.txt: Update for new directory structure.
2002-03-18 16:03:00 +00:00
Eric Andersen 38ddbed4c1 Try to pull in PATH_MAX properly 2002-03-16 02:12:30 +00:00
Eric Andersen 08ed1a73f1 Don't mention ldconfig 2002-03-13 17:26:39 +00:00
Eric Andersen 806c74fe19 Cleanup a libc5 compatibility hack 2002-03-12 00:35:40 +00:00
Eric Andersen f64c1cd26d Fix broken link 2002-03-10 22:01:51 +00:00
Matt Kraai a1bbde71bf list_single: Declare scratch iff CONFIG_FEATURE_LS_USERNAME is defined. 2002-03-08 16:25:33 +00:00
Matt Kraai 3bd31ebc9a * fileutils/ls.c (showfiles): Display multiple short names on a line. 2002-03-08 16:16:38 +00:00
Eric Andersen 372f91f07c Update 2002-03-06 11:13:51 +00:00
Eric Andersen bc12fb79fd Update webpage to note new mirrors 2002-03-06 10:28:55 +00:00
Eric Andersen 1b17b01584 Now that we are mirrored, remove absolute links 2002-03-05 15:55:59 +00:00
Eric Andersen 0298be88ae Update init.c per my changes in the stable branch
-Erik
2002-03-05 15:12:19 +00:00
Eric Andersen 684d745bf3 Update robots.txt 2002-03-02 16:43:30 +00:00
Eric Andersen 02a4ed9264 A few more little cleanups to simplify mirroring 2002-03-02 16:42:46 +00:00
Eric Andersen 49da8a83ad Update the cvs commit info. Remove the old busybox.lineo.com stuff. 2002-03-02 15:39:06 +00:00
Matt Kraai a99b194336 * libbb/xfuncs.c (xmalloc, xcalloc): Do not exit if a zero-length buffer is
requested.
  (xrealloc): Simplify.
2002-02-26 15:28:22 +00:00
Matt Kraai eed9451cf6 * findutils/grep.c (grep_main): Remove unnecessary use of junk. 2002-02-22 22:08:16 +00:00
Matt Kraai fa144713b8 * testsuite/runtest (show_result): Change UPASS to XPASS.
(run_applet_testcase): Likewise.
2002-02-19 23:54:42 +00:00
Matt Kraai 6b140ea5a9 * testsuite/README: Change "UNSUPPORTED" tag to "FEATURE".
* testsuite/runtest (run_applet_testcase): Likewise.
* testsuite/cp/cp-preserves-hard-links: Likewise.
* testsuite/grep/egrep-supports-extended-regexps: Likewise.
* testsuite/grep/grep-is-also-egrep: Likewise.
* testsuite/tar/tar-archives-multiple-files: Likewise.
* testsuite/tar/tar-handles-empty-include-and-non-empty-exclude-list:
  Likewise.
* testsuite/tar/tar-handles-exclude-and-extract-lists: Likewise.
* testsuite/tar/tar-handles-nested-exclude: Likewise.
2002-02-19 23:43:08 +00:00
Matt Kraai 7c71822809 * testsuite/runtest (run_applet_testcase): Return UNTESTED instead of
UNSUPPORTED for missing applets and features.
2002-02-19 23:38:08 +00:00
Matt Kraai b5b757eb8d * testsuite/README: Fill to 80 columns. 2002-02-19 23:20:52 +00:00
Matt Kraai 6be2319873 * testsuite/README: Update copyright date. 2002-02-19 23:19:46 +00:00
Matt Kraai ad6faf6497 * testsuite/tar/tar-archives-multiple-files: Require
CONFIG_FEATURE_TAR_CREATE.
2002-02-19 23:15:41 +00:00
Matt Kraai 4271d438e2 * docs/busybox.net/index.html (Products/Projects Using BusyBox): Added
Tinfoil Hat Linux.
2002-02-19 22:58:26 +00:00
Eric Andersen d4574f1b61 fix name 2002-02-17 22:42:30 +00:00
Matt Kraai c00e4ff8e5 * testsuite/tar/tar-archives-multiple-files: New. 2002-02-17 18:42:52 +00:00
Eric Andersen 3b7767abe6 Add in tuxscreen 2002-02-16 22:17:33 +00:00
Eric Andersen 796245b554 Update sponsor section 2002-02-16 22:08:28 +00:00
Eric Andersen 8fd6e1fb0f Add in a sponsors link, and update the screenshot. 2002-02-16 21:50:34 +00:00
Eric Andersen d7f7bd0445 Add Partition Image 2002-02-16 18:48:55 +00:00
Glenn L McGrath 02a415606c Parse the include list to writeTarFile rather than argv, fixes a bug where tar files wernt being created. 2002-02-15 05:15:03 +00:00
Glenn L McGrath 8833a51781 Fix condition that prevented creation of compressed files 2002-02-13 03:32:11 +00:00
Matt Kraai 9bd49d6a22 * archival/gzip.c (ifname, ofname): Delete.
(gzip_main): Handle multiple files.
* include/usage.h (gzip_trivial_usage): Allow multiple FILEs.
  (gzip_full_usage): Ditto.
* testsuite/gzip/gzip-accepts-multiple-files: New.
* testsuite/gzip/gzip-removes-original-file: New.
2002-02-05 22:31:48 +00:00
Matt Kraai 592a3e63ee * archival/gzip.c (gzip_main): Display usage if given multiple files. 2002-02-05 19:34:53 +00:00
Matt Kraai 273af73317 * include/usage.h (gzip_trivial_usage): Make FILE optional.
(gzip_full_usage): Note behavior when FILE is unspecified.
2002-02-05 19:25:29 +00:00
Matt Kraai eb83478528 * fileutils/dd.c (dd_main): Ignore ftruncate error if the output is not a
file or directory.
2002-02-05 15:28:54 +00:00
Matt Kraai 369da77d5e 2002-01-30 Neal H Walfield <neal@cs.uml.edu>
* networking/ping.c (hostname): Removed.

        [CONFIG_FEATURE_FANCY_PING] (noresp): Moved from here . . .
        [CONFIG_FEATURE_FANCY_PING] (ping:noresp): . . . to here.
        Use H->h_name, not hostname.
        [CONFIG_FEATURE_FANCY_PING] (ping): Do not copy H->h_name into
        hostname.
        Use H->h_name directly.

        [!CONFIG_FEATURE_FANCY_PING] (hostent): New global variable.
        [!CONFIG_FEATURE_FANCY_PING] (pingstats): Use hostent in favor
        of the now obsolete hostname global variable.
        [!CONFIG_FEATURE_FANCY_PING] (ping): Likewise.
        No need to copy H; use hostent instead.

        [!CONFIG_FEATURE_FANCY_PING] (ntransmitted, nreceived,
        nrepeats, pingcount, myid, options, tmax, tsum): Removed
        superfluous zero initializers.
2002-02-01 16:54:00 +00:00
Eric Andersen 20d739adf7 If PATH_MAX isn't defined, define it outselves 2002-01-26 23:58:22 +00:00
Eric Andersen 53a2299230 Patch from Russ Dill <Russ.Dill@asu.edu>. From the
start-stop-daemon man page:

-b|--background
        Typically used with programs that don't detach on their own.
        This option will force start-stop-daemon to fork before starting
        the process, and force it into the background. WARNING:
        start-stop-daemon cannot check the exit status if the process
        fails to execute for any reason. This is a last resort, and is
        only meant for programs that either make no sense forking on
        their own, or where it's not feasible to add the code for it to
        do this itself.

This is usefull for applets like watchdog
2002-01-26 09:04:45 +00:00
Eric Andersen 467a18b1d9 Teach 'init -q' that init's pid may not equal 1 2002-01-25 23:13:06 +00:00
Matt Kraai a3181dd833 Do not segfault if PATH is unset. 2002-01-14 18:30:10 +00:00
Eric Andersen ba552523fa Remove broken "Other cool embedded software" link 2002-01-13 03:01:02 +00:00
Eric Andersen d35c5df08c Make private ash config options be public 2002-01-09 15:37:36 +00:00
Matt Kraai b75b6e2c35 * archival/tar.c (tar_main): Remove unused variable. 2002-01-08 16:03:41 +00:00
Eric Andersen 038cbc7442 Oops. 2002-01-06 01:10:25 +00:00
Eric Andersen c94e89d81f Do not depend on PATH or getopt arg reordering 2002-01-06 01:08:28 +00:00
Eric Andersen db2b9f37d4 Somehow ttylinux got lost. Put it back.
-Erik
2002-01-05 16:56:43 +00:00
Eric Andersen 8ec99dfa05 Update links to avoid possible lingering DNS problems
(and thereby test if I have the Reply-to thing really
fixed this time)...
 -Erik
2002-01-05 05:34:31 +00:00
Matt Kraai d402f971a5 * docs/busybox.net/index.html: Fix misspelling of `Unfortunately'. 2002-01-04 16:54:39 +00:00
Eric Andersen eeba178d3a More updates 2002-01-04 05:12:14 +00:00
Eric Andersen 7d957c6573 More pics 2002-01-04 05:11:49 +00:00
Eric Andersen 665b4e69ed Update text once again 2002-01-04 05:04:15 +00:00
Eric Andersen 7875f5b72a Fix grammar (thanks to my wife for proof reading) 2002-01-04 04:24:27 +00:00
Eric Andersen 55ed17747f Fix link 2002-01-04 00:34:22 +00:00
Eric Andersen 4fa2bb5e95 Update busybox.net info and donation noise 2002-01-04 00:32:15 +00:00
Matt Kraai 9eaf059d28 * editors/sed.c (parse_cmd_str): Remove redundant code to skip initial
whitespace.
2002-01-03 21:19:19 +00:00
Matt Kraai 5ed78adca5 * editors/sed.c (parse_edit_cmd): Rewrite.
* testsuite/sed/sed-splits-edit-commands-on-command-line: New.
2002-01-03 21:12:34 +00:00
Matt Kraai d299563257 * AUTHORS (Matt Kraai): Update e-mail address. 2002-01-03 18:29:37 +00:00
Matt Kraai 9758e7d58d * include/usage.h: Fix route and unzip usage messages (patch from
Laurence Anderson).
2002-01-03 17:32:29 +00:00
Matt Kraai f3fbe20c35 * cmp/cmp-detects-difference: Simplify return code negation.
* false/false-returns-failure: Likewise.
* tar/tar-demands-at-least-one-ctx: Likewise.
* tar/tar-demands-at-most-one-ctx: Likewise.
2002-01-02 20:45:42 +00:00
Matt Kraai 01d2ea908b * testsuite/README: Document -v option.
* testsuite/runtest: Handle -v option.
  (show_result): New.
  (run_applet_testcase): Call it.
2002-01-02 20:37:59 +00:00
Matt Kraai 39fcb5a750 * archival/dpkg.c (create_list): Use chomp.
* archival/tar.c (append_file_list_to_list): Likewise.
2002-01-02 19:01:41 +00:00
Matt Kraai 0733e840bd chomp should only remove the newline if it occurs at the end of the input.
This was caught by the test suite (in sed/sed-aic-commands).

* libbb/chomp.c: Revert to revision 1.5.
2002-01-02 18:51:23 +00:00
Matt Kraai d21735de2d * editors/sed.c (parse_edit_command): Require a newline after the backslash
after an edit command.
* testsuite/sed/sed-requires-newline-after-edit-command: New.
2002-01-02 17:56:38 +00:00
Glenn L McGrath 87ac7028e0 unzip applet by Laurence Anderson
----------------------------------------------------------------------
2002-01-02 13:52:26 +00:00
Aaron Lehmann 438803311b ash patch: errname-diff 2001-12-31 06:16:54 +00:00
Aaron Lehmann 9a218bf979 ash patch: initvar-diff 2001-12-31 06:13:38 +00:00
Aaron Lehmann 1a6986699f ash patch: forkshell-diff 2001-12-31 06:12:48 +00:00
Aaron Lehmann eec2bbb9bf ash patch: fgcmd-diff 2001-12-31 06:07:57 +00:00
Aaron Lehmann 2aef3a6bb9 ash patch: breakcmd-diff 2001-12-31 06:03:12 +00:00
Aaron Lehmann 95877b6756 ash patch: addfname-diff 2001-12-31 06:00:57 +00:00
Eric Andersen 79a466f128 optimize this a little bit. 2001-12-29 07:26:33 +00:00
Eric Andersen 6d13964714 Silence some silly warnings
-Erik
2001-12-29 04:15:13 +00:00
Eric Andersen e7dd383f67 Link to udhcp 2001-12-22 19:28:24 +00:00
Eric Andersen b9c0b99e51 Update URLs and email addresses 2001-12-22 00:37:54 +00:00
Matt Kraai 70624846fd Ignore blanks before the first address and before the command. 2001-12-21 16:04:12 +00:00
Matt Kraai 1fcc66e685 New. 2001-12-21 15:54:25 +00:00
Eric Andersen ceef50b280 Patch from vodz to fix broken function prototype 2001-12-21 11:22:26 +00:00
Eric Andersen f1f2bd0b0a Patch from vodz to implement ^L (clear screen) 2001-12-21 11:20:15 +00:00
Eric Andersen 9910cd2869 Update TODO. vodz has implemented ^L. Reverse policy on tinylogin.
-Erik
2001-12-21 11:18:36 +00:00
Matt Kraai 1f0c43668a Remove == TRUE' tests and convert != TRUE' and `== FALSE' tests to use !. 2001-12-20 23:13:26 +00:00
Matt Kraai 31c73af656 Perform clean up only if CONFIG_FEATURE_CLEAN_UP is defined. 2001-12-20 22:30:14 +00:00
Matt Kraai 2b1effdbbc Write files when extracting an archive from standard input. 2001-12-20 22:09:31 +00:00
Matt Kraai c5b5cab37d Remove dependence on CONFIG_FEATURE_CLEAN_UP. 2001-12-20 21:13:18 +00:00
Matt Kraai 38c15becf6 Avoid printing a trailing blank character. 2001-12-20 21:11:59 +00:00
Eric Andersen 5a841adf5d Switch from FTP to HTTP for downloads 2001-12-20 08:04:56 +00:00
Eric Andersen fb74a45088 Vodz' last_patch31
Very minimal last corrections:

    1) busybox.c: fix warining
    2) docs/: add applets for list from pwd_grp
    3) usage.h: add -n option for route
    4) run_parts.c: many todo fix for busybox style
    5) addgroup.c: add #ifdef CONFIG_FEATURE_SHADOWPASSWDS, reduce one
    perror_msg
    6) adduser.c: fix bug "variable i not initialize" and
       add #ifdef CONFIG_FEATURE_SHADOWPASSWDS
2001-12-18 14:06:03 +00:00
Eric Andersen f3f9062ecf Things like 'tar -c /tmp/*' and 'tar -cO /tmp/*' where the output
filename was not explicitly specified were segfaulting.
 -Erik
2001-12-18 00:57:55 +00:00
Eric Andersen 730f826f25 Add in a new restart init target, triggered by SIGHUP. Patch from
Russ Dill, with adjustments by me.
 -Erik
2001-12-17 23:13:08 +00:00
Matt Kraai ace02dc9cd Make cp and mv optionally preserve hard links. 2001-12-17 15:26:36 +00:00
Eric Andersen 46ea0e4696 * Add ^L clear to shell 2001-12-16 09:25:57 +00:00
Eric Andersen 6925d50176 Some minor usage cleanups from David Douthitt <ssrat@mailbag.com> 2001-12-16 09:23:09 +00:00
Eric Andersen de2a342289 Add a more verbose non-strip command. 2001-12-16 09:20:08 +00:00
Matt Kraai e62dc86bc7 Add support for big-endian ARM (initial patch by Mike Voytovich). 2001-12-14 16:08:17 +00:00
Matt Kraai 04ae328851 Update uClibc URL. 2001-12-12 19:09:51 +00:00
Matt Kraai 14b7c5d12b Open the source before creating the destination. 2001-12-11 16:43:48 +00:00
Matt Kraai 741f40b58e Use an int to hold the result of fgetc (bug noted by David Kimdon). 2001-12-11 16:06:02 +00:00
Eric Andersen 72812d3143 And a bit more 2001-12-08 02:14:02 +00:00
Eric Andersen a2e6908165 More polish 2001-12-08 02:13:05 +00:00
Eric Andersen 90c2abd212 Oops 2001-12-08 02:10:37 +00:00
Eric Andersen dec43433e5 Add in cvs info 2001-12-08 02:08:31 +00:00
Eric Andersen 2423b12dae Begin moving things to busybox.net
-Erik
2001-12-08 01:56:15 +00:00
Eric Andersen 05b5addcaa Use a local image, not an offsite one. 2001-12-08 00:18:20 +00:00
Matt Kraai 07a37aebf5 New. 2001-12-07 21:27:57 +00:00
Matt Kraai dba11452cb Continue processing files if we are asked to touch, but not create, a file
which doesn't exist.
2001-12-07 21:27:38 +00:00
Matt Kraai 1a781a499f Enable test only if CONFIG_FEATURE_GREP_EGREP_ALIAS is defined. 2001-12-07 21:24:25 +00:00
Eric Andersen 603557b466 Fix link name 2001-12-07 19:01:31 +00:00
Eric Andersen 089db51fbe Fix broken link 2001-12-07 19:00:30 +00:00
Matt Kraai 3eeab3b23f Update copyright and close file descriptors (noted by Axel Kittenberger). 2001-12-07 16:27:37 +00:00
Eric Andersen 6834ee941a Avoid NULL pointer problems. Patch from "Frank P. MacLachlan"
<fpm-plutus@tgs.indyme.com>
2001-12-06 21:33:55 +00:00
Matt Kraai 54805af092 Remove documentation for the --file option to hostname (noted by
David Douthitt).
2001-12-06 17:37:51 +00:00
Eric Andersen c98c06233e Merge in the cal applet from Steve Merrifield <steve@labyrinth.net.au> 2001-12-06 15:16:43 +00:00
Eric Andersen b24d65659f If find_pid_by_name() had an error, it was returning -1, but storing
that into a pid_t, which is unsigned on a number archs.  Furthermore,
find_pid_by_name() would _never_ return an error if the intended proces
was "init", but instead would return 1, meaning we would fail to work
on 2.4.x kernels running an initrd...
 -Erik
2001-12-06 14:52:32 +00:00
Eric Andersen 06656f363d Minor adjustment to the strip command 2001-12-06 14:44:11 +00:00
Eric Andersen db930948a9 More copyright and email addr cleanups 2001-12-06 08:20:14 +00:00
Eric Andersen 463304edfd Silly cosmetic problem in the comment 2001-12-06 08:04:45 +00:00
Eric Andersen 356b6dbf86 Patch from Steve Merrifield <steve@labyrinth.net.au> to
fixup the merge of the time applet, which I messed up.
 -Erik
2001-12-06 07:42:04 +00:00
Eric Andersen 0ee0a8d539 Fix running more on files in the (broken) procfs that claim 0 length
when that isn't actually true.
 -Erik
2001-12-06 07:24:29 +00:00
Aaron Lehmann b6ecbdc07d The ash ansification diff!
Please tell me if you notice any problems resulting from this.
2001-12-06 03:37:38 +00:00
Aaron Lehmann ebd8065f38 Trying to commit Changelog and TODO. cvs is being weird :/ 2001-12-06 03:32:12 +00:00
Aaron Lehmann 2dd2d7a37d Patch to avoid warnings 2001-12-06 03:29:37 +00:00
Aaron Lehmann b9df470c4d Commit my improvement on Rodney Brown's patch to g(un)zip, decreasing
binary size.
2001-12-06 03:22:43 +00:00
Glenn L McGrath 249f39a265 Simplify unzip(), remove unused checks and unneccessary variables 2001-12-05 16:01:02 +00:00
Glenn L McGrath ef03dbcd4d Simplify CRC table generation 2001-12-05 13:08:03 +00:00
Glenn L McGrath aad44fb37a Fix some fegfaults and picket fence 2001-12-05 04:40:52 +00:00
Manuel Novoa III 3280f9a3fc New version to cut size. Includes optional basename() compatibility, but
enabling that would break the basename applet at least for one corner case.
2001-12-05 04:35:32 +00:00
Manuel Novoa III 6509f92a3b Combined size reduction changes by Glenn and myself. Added back in "unknown"
for -p to match normal uname behavior (at a cost of 30-40 bytes).
2001-12-05 04:21:30 +00:00
Glenn L McGrath 1dbbd2fe34 Fail gracefully if package depends on a virtual package. 2001-12-05 04:10:14 +00:00
Eric Andersen ed8a9be287 Patch from Dan Langlois <dan@somanetworks.com> Support SIGSTOP/SIGCONT
for wierd situations when people want init to actualy stop doing
anything for a while...
2001-11-30 19:10:58 +00:00
Eric Andersen c3657428d3 Add in a 'time' applet. Adds 4.5k.
-Erik
2001-11-30 07:54:32 +00:00
Glenn L McGrath 38288bbf4c gunzip was incorrectly reporting a failed crc and length (discovered by
Chang, Shu-Hao).  The bitbuffer needs to be unwound after decompression,
as it was eating into the crc/size field.
2001-11-29 06:36:56 +00:00
Matt Kraai 8a35c9a557 Add space before module name (noted by Ron Yorston). 2001-11-27 17:28:01 +00:00
Glenn L McGrath 9e6c9f7311 Minor space saving improvments 2001-11-21 12:46:36 +00:00
Glenn L McGrath 74afa9aed1 When just counting chars of a file stat file instead of reading the whole file (Fixes Debian bug #103302) 2001-11-21 10:26:28 +00:00
Glenn L McGrath c29ab97094 woops. dotn pass NULL 2001-11-21 10:01:29 +00:00
Glenn L McGrath 1477ad8e83 Simplify print function, prints an extra space if no filename, but saves 4 bytes 2001-11-21 09:58:29 +00:00
Glenn L McGrath 02d090d3d2 Use enums for selected functionality, Reduce the size by nearly 100 Bytes 2001-11-21 09:17:00 +00:00
Eric Andersen 2480e3a30a Fix dangling comma 2001-11-21 09:05:31 +00:00
Matt Kraai 1dbd6ff80f New. 2001-11-20 16:04:22 +00:00
Matt Kraai 585f657e2d Fix undeclared variable error. 2001-11-20 16:00:44 +00:00
Matt Kraai 0c390a76fe Eliminate warning. 2001-11-20 16:00:19 +00:00
Matt Kraai fd3f1be57f New. 2001-11-20 15:49:55 +00:00
Matt Kraai 355a61b56f Treat NUL as the end-of-line. 2001-11-20 15:49:50 +00:00
Eric Andersen 66c22051f9 More grammar fixes 2001-11-20 12:40:37 +00:00
Eric Andersen dbdc0d5da9 grammer error 2001-11-20 12:36:28 +00:00
Eric Andersen 4d7f9c3d99 Update the website 2001-11-20 11:56:51 +00:00
192 changed files with 6219 additions and 3778 deletions

No files matched your search

+1 -1
View File
@@ -45,7 +45,7 @@ Karl M. Hegbloom <karlheg@debian.org>
Daniel Jacobowitz <dan@debian.org>
mktemp.c
Matt Kraai <kraai@alumni.carnegiemellon.edu>
Matt Kraai <kraai@alumni.cmu.edu>
documentation, bugfixes, test suite
John Lombardo <john@deltanet.com>
+1 -1
View File
@@ -15,7 +15,7 @@
-- a whole bunch of ash size optimizations
-- Fix for ash leading redirections (i.e. '2>/dev/null ls rubbish')
* Rodney Brown <RDBrown@mira.net>
-- Optimized gzip.c, shrinking it be ~1.5k
-- Optimized gzip.c, shrinking it by ~1.5k
* Matt Kraai
-- Fix sed s/[/]// handling (closes: #1208).
-- Fix `-/bin/sh' invocation (closes: #1209).
+66 -217
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,171 +17,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
PROG := busybox
VERSION := 0.61.pre
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
TOPDIR := ${shell /bin/pwd}
HOSTCC := gcc
HOSTCFLAGS:= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
# What OS are you compiling busybox for? This allows you to include
# OS specific things, syscall overrides, etc.
TARGET_OS := linux
# With a modern GNU make(1) (highly recommended, that's what all the
# developers use), all of the following configuration values can be
# overridden at the command line. For example:
# make CROSS=powerpc-linux- CONFIG_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
# If you want to add some simple compiler switches (like -march=i686),
# especially from the command line, use this instead of CFLAGS directly.
# For optimization overrides, it's better still to set OPTIMIZATION.
CFLAGS_EXTRA =
# If you want a static binary, turn this on.
DOSTATIC = false
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
DODEBUG = false
# This enables compiling with dmalloc ( http://dmalloc.com/ )
# which is an excellent public domain mem leak and malloc problem
# detector. To enable dmalloc, before running busybox you will
# want to first set up your environment.
# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
# Do not enable this for production builds...
DODMALLOC = false
# Electric-fence is another very useful malloc debugging library.
# Do not enable this for production builds...
DOEFENCE = false
# If you want large file summit support, turn this on.
# This has no effect if you don't have a kernel with lfs
# support, and a system with libc-2.1.3 or later.
# Some of the programs that can benefit from lfs support
# are dd, gzip, mount, tar, and mkfs_minix.
# LFS allows you to use the above programs for files
# larger than 2GB!
DOLFS = false
# If you have a "pristine" source directory, point CONFIG_SRC_DIR to it.
# Experimental and incomplete; tell the mailing list
# <busybox@opensource.lineo.com> if you do or don't like it so far.
CONFIG_SRC_DIR =
# If you are running a cross compiler, you may want to set CROSS
# to something more interesting, like "arm-linux-".
CROSS =
CC = $(CROSS)gcc
AR = $(CROSS)ar
AS = $(CROSS)as
LD = $(CROSS)ld
NM = $(CROSS)nm
STRIP = $(CROSS)strip
CPP = $(CC) -E
MAKEFILES = $(TOPDIR)/.config
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
# Everything should compile and work as expected these days...
#CC = /usr/i386-linux-uclibc/usr/bin/i386-uclibc-gcc
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
#LIBCDIR=/usr/i386-glibc20-linux
#
# The following is used for libc5 (if you install altgcc and libc5-altdev
# on a Debian system).
#LIBCDIR=/usr/i486-linuxlibc1
#
# For other libraries, you are on your own...
#LDFLAGS+=-nostdlib
#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
# use '-Os' optimization if available, else use -O2
OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null \
>/dev/null 2>&1; then echo "-Os"; else echo "-O2" ; fi}
GCC_STACK_BOUNDRY := ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc /dev/null \
>/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; else echo "" ; fi}
OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer $(GCC_STACK_BOUNDRY)
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
CFLAGS = -I$(TOPDIR)/include
ARFLAGS = -r
#
#--------------------------------------------------------
# If you're going to do a lot of builds with a non-vanilla configuration,
# it makes sense to adjust parameters above, so you can type "make"
# by itself, instead of following it by the same half-dozen overrides
# every time. The stuff below, on the other hand, is probably less
# prone to casual user adjustment.
#
ifeq ($(strip $(DOLFS)),true)
# For large file summit support
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64
endif
ifeq ($(strip $(DODMALLOC)),true)
# For testing mem leaks with dmalloc
CFLAGS+=-DDMALLOC
LIBRARIES = -ldmalloc
# Force debug=true, since this is useless when not debugging...
DODEBUG = true
else
ifeq ($(strip $(DOEFENCE)),true)
LIBRARIES = -lefence
# Force debug=true, since this is useless when not debugging...
DODEBUG = true
endif
endif
ifeq ($(strip $(DODEBUG)),true)
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS += -Wl,-warn-common
STRIPCMD =
else
CFLAGS += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
LDFLAGS += -s -Wl,-warn-common
STRIPCMD = $(STRIP) --remove-section=.note --remove-section=.comment $(PROG)
endif
ifeq ($(strip $(DOSTATIC)),true)
LDFLAGS += --static
endif
ifndef $(PREFIX)
PREFIX = `pwd`/_install
endif
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
# the copy in CONFIG_SRC_DIR, both during the compilation phase and the
# shell script that finds the list of object files.
# Work in progress by <ldoolitt@recycle.lbl.gov>.
#
ifneq ($(strip $(CONFIG_SRC_DIR)),)
VPATH = $(CONFIG_SRC_DIR)
endif
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
ifdef CONFIG_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(CONFIG_INIT_SCRIPT)"'
endif
# Put user-supplied flags at the end, where they
# have a chance of winning.
CFLAGS += $(CFLAGS_EXTRA)
.EXPORT_ALL_VARIABLES:
TOPDIR:= $(shell /bin/pwd)/
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
SUBDIRS:=applets archival archival/libunarchive console-tools \
editors fileutils findutils init miscutils modutils networking \
procps pwd_grp pwd_grp/libpwd_grp shell shellutils sysklogd \
textutils util-linux libbb
all: do-it-all
@@ -192,7 +34,8 @@ ifeq (.config,$(wildcard .config))
include .config
ifeq (.depend,$(wildcard .depend))
include .depend
do-it-all: busybox busybox.links doc
do-it-all: busybox busybox.links #doc
include $(patsubst %,%/Makefile.in, $(SUBDIRS))
else
CONFIGURATION = depend
do-it-all: depend
@@ -203,18 +46,9 @@ do-it-all: menuconfig
endif
SUBDIRS =applets archival archival/libunarchive console-tools editors \
fileutils findutils init miscutils modutils networking procps \
pwd_grp shell shellutils sysklogd textutils util-linux libbb
bbsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/config/MARKER
$(MAKE) CFLAGS="$(CFLAGS)" -C $(patsubst _dir_%, %, $@)
busybox: config.h dep-files bbsubdirs
$(CC) $(LDFLAGS) -o $@ applets/busybox.o $(shell find $(SUBDIRS) -name \*.a) $(LIBCONFIG_LIB) $(LIBRARIES)
$(STRIPCMD)
busybox: depend $(libraries-y)
$(CC) $(LDFLAGS) $(libraries-y) $(LIBRARIES) -o $@
$(STRIPCMD) $@
busybox.links: applets/busybox.mkll
- $(SHELL) $^ >$@
@@ -222,6 +56,9 @@ busybox.links: applets/busybox.mkll
install: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX)
uninstall: busybox busybox.links
for i in `cat busybox.links` ; do rm -f $$PREFIX$$i; done
install-hardlinks: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX) --hardlinks
@@ -249,15 +86,15 @@ docs/BusyBox.1: docs/busybox.pod
- pod2man --center=BusyBox --release="version $(VERSION)" \
$< > $@
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
docs/BusyBox.html: docs/busybox.net/BusyBox.html
- mkdir -p docs
-@ rm -f docs/BusyBox.html
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
-@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
-@ mkdir -p docs/busybox.lineo.com
docs/busybox.net/BusyBox.html: docs/busybox.pod
-@ mkdir -p docs/busybox.net
- pod2html --noindex $< > \
docs/busybox.lineo.com/BusyBox.html
docs/busybox.net/BusyBox.html
-@ rm -f pod2htm*
@@ -285,55 +122,61 @@ docs/busybox.pdf: docs/busybox.ps
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
- mkdir -p docs
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
(cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
# The nifty new buildsystem stuff
scripts/mkdep: scripts/mkdep.c
$(TOPDIR)scripts/mkdep: scripts/mkdep.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
scripts/split-include: scripts/split-include.c
$(TOPDIR)scripts/split-include: scripts/split-include.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
dep-files: scripts/mkdep
@if [ ! -f .depend ] ; then \
rm -f .depend .hdepend; \
mkdir -p $(TOPDIR)/include/config; \
scripts/mkdep -I $(TOPDIR)/include -- \
`find $(TOPDIR) -name \*.c -print` >> .depend; \
scripts/mkdep -I $(TOPDIR)/include -- \
`find $(TOPDIR) -name \*.h -print` >> .hdepend; \
$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ; \
fi;
depend dep: config.h dep-files
$(TOPDIR).depend: $(TOPDIR)scripts/mkdep
rm -f .depend .hdepend;
mkdir -p $(TOPDIR)include/config;
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
scripts/mkdep -I $(TOPDIR)include -- \
`find $(TOPDIR) -name \*.c -print` >> .depend;
scripts/mkdep -I $(TOPDIR)include -- \
`find $(TOPDIR) -name \*.h -print` >> .hdepend;
$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ;
@ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
CONFIG_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
depend dep: $(TOPDIR)include/config.h $(TOPDIR).depend
BB_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi}
include/config/MARKER: scripts/split-include include/config.h
include/config/MARKER: depend $(TOPDIR)scripts/split-include
scripts/split-include include/config.h include/config
@ touch include/config/MARKER
config.h:
@if [ ! -f include/config.h ] ; then \
$(TOPDIR)include/config.h:
@if [ ! -f $(TOPDIR)include/config.h ] ; then \
make oldconfig; \
fi;
menuconfig:
mkdir -p $(TOPDIR)/include/config
$(TOPDIR).config:
cp $(TOPDIR)sysdeps/$(TARGET_OS)/defconfig $(TOPDIR).config
mkdir -p $(TOPDIR)include/config
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
$(BB_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
menuconfig:
mkdir -p $(TOPDIR)include/config
$(MAKE) -C scripts/lxdialog all
$(BB_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
config:
mkdir -p $(TOPDIR)/include/config
$(CONFIG_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
mkdir -p $(TOPDIR)include/config
$(BB_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
oldconfig:
mkdir -p $(TOPDIR)/include/config
$(CONFIG_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
mkdir -p $(TOPDIR)include/config
$(BB_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
ifdef CONFIGURATION
@@ -355,7 +198,10 @@ dummy:
endif
include Rules.mak
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
# Testing...
test tests:
@@ -369,14 +215,15 @@ clean:
- $(MAKE) -C tests clean
- $(MAKE) -C scripts/lxdialog clean
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
docs/busybox.lineo.com/BusyBox.html
docs/busybox.net/BusyBox.html
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html \
docs/busybox.pdf docs/busybox.net/busybox.html \
docs/busybox _install pod2htm* *.gdb *.elf *~ core
- rm -f busybox.links libbb/loop.h .config.old .hdepend
- rm -f busybox busybox.links libbb/loop.h .config.old .hdepend
- rm -f scripts/split-include scripts/mkdep .*config.log
- rm -rf include/config include/config.h
- find -name .\*.flags -o -name .depend -exec rm -f {} \;
- find -name .\*.flags -exec rm -f {} \;
- find -name .depend -exec rm -f {} \;
- find -name \*.o -exec rm -f {} \;
- find -name \*.a -exec rm -f {} \;
@@ -403,9 +250,11 @@ dist release: distclean doc
.PHONY: tags check
.PHONY: tags check depend
tags:
ctags -R .
check: busybox
cd testsuite && ./runtest
+11 -10
View File
@@ -35,7 +35,7 @@ Supported architectures:
Busybox in general will build on any architecture supported by gcc. It has
a few specialized features added for __sparc__ and __alpha__. insmod
functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k,
and MIPS.
MIPS, and v850e.
Supported libcs:
@@ -83,7 +83,7 @@ top of ash.c as well, so check those out if you want to tweak things.
Getting help:
When you find you need help, you can check out the BusyBox mailing list
archives at http://oss.lineo.com/lists/busybox/ or even join
archives at http://busybox.net/lists/busybox/ or even join
the mailing list if you are interested.
----------------
@@ -91,12 +91,12 @@ the mailing list if you are interested.
Bugs:
If you find bugs, please submit a bug report. Full instructions on how to
report a bug are found at http://bugs.lineo.com/Reporting.html.
report a bug are found at http://bugs.busybox.net/Reporting.html.
For the impatient: To submit a bug, simply send an email describing the problem
to submit@bugs.lineo.com. Bug reports should look something like this:
to submit@bugs.busybox.net. Bug reports should look something like this:
To: submit@bugs.lineo.com
To: submit@bugs.busybox.net
From: diligent@testing.linux.org
Subject: /bin/true doesn't work
@@ -123,21 +123,22 @@ understanding.
FTP:
Source for the latest released version can always be downloaded from
ftp://ftp.lineo.com/pub/busybox.
Source for the latest released version, as well as daily snapshots, can always
be downloaded from
http://busybox.net/downloads/
----------------
CVS:
BusyBox now has its own publicly browsable CVS tree at:
http://oss.lineo.com/cgi-bin/cvsweb/busybox/
http://busybox.net/cgi-bin/cvsweb/busybox/
Anonymous CVS access is available. For instructions, check out:
http://oss.lineo.com/cvs_anon.html
http://busybox.net/cvs_anon.html
For those that are actively contributing there is even CVS write access:
http://oss.lineo.com/cvs_write.html
http://busybox.net/cvs_write.html
----------------
+185 -172
View File
@@ -1,195 +1,208 @@
# Rules.make for busybox
#
# This file contains rules which are shared between multiple Makefiles.
# Copyright (C) 2002 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
#
#
# False targets.
#
.PHONY: dummy
#
# Special variables which should not be exported
#
unexport EXTRA_AFLAGS
unexport EXTRA_CFLAGS
unexport EXTRA_LDFLAGS
unexport EXTRA_ARFLAGS
unexport SUBDIRS
unexport SUB_DIRS
unexport ALL_SUB_DIRS
unexport O_TARGET
unexport obj-y
unexport obj-n
unexport obj-
unexport export-objs
unexport subdir-y
unexport subdir-n
unexport subdir-
#
# Get things started.
#
first_rule: sub_dirs
$(MAKE) all_targets
SUB_DIRS := $(subdir-y)
ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-n) $(subdir-))
PROG := busybox
VERSION := 0.61.pre
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
HOSTCC := gcc
HOSTCFLAGS:= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
#
# Common rules
#
# What OS are you compiling busybox for? This allows you to include
# OS specific things, syscall overrides, etc.
TARGET_OS:=linux
%.s: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@
# With a modern GNU make(1) (highly recommended, that's what all the
# developers use), all of the following configuration values can be
# overridden at the command line. For example:
# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
%.i: %.c
$(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@
# If you want to add some simple compiler switches (like -march=i686),
# especially from the command line, use this instead of CFLAGS directly.
# For optimization overrides, it's better still to set OPTIMIZATION.
CFLAGS_EXTRA:=
# If you want a static binary, turn this on.
DOSTATIC:=false
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
DODEBUG:=false
# This enables compiling with dmalloc ( http://dmalloc.com/ )
# which is an excellent public domain mem leak and malloc problem
# detector. To enable dmalloc, before running busybox you will
# want to first set up your environment.
# eg: `export DMALLOC_OPTIONS=debug=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
# Do not enable this for production builds...
DODMALLOC:=false
# Electric-fence is another very useful malloc debugging library.
# Do not enable this for production builds...
DOEFENCE:=false
# If you want large file summit support, turn this on.
# This has no effect if you don't have a kernel with lfs
# support, and a system with libc-2.1.3 or later.
# Some of the programs that can benefit from lfs support
# are dd, gzip, mount, tar, and mkfs_minix.
# LFS allows you to use the above programs for files
# larger than 2GB!
DOLFS:=false
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
# Experimental and incomplete; tell the mailing list
# <busybox@busybox.net> if you do or don't like it so far.
BB_SRC_DIR:=
# If you are running a cross compiler, you may want to set CROSS
# to something more interesting, like "arm-linux-".
CROSS:=
CC := $(CROSS)gcc
AR := $(CROSS)ar
AS := $(CROSS)as
LD := $(CROSS)ld
NM := $(CROSS)nm
STRIP := $(CROSS)strip
CPP := $(CC) -E
MAKEFILES := $(TOPDIR).config
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
# Everything should compile and work as expected these days...
#CC:=/usr/i386-linux-uclibc/usr/bin/i386-uclibc-gcc
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
#LIBCDIR:=/usr/i386-glibc20-linux
#
# The following is used for libc5 (if you install altgcc and libc5-altdev
# on a Debian system).
#LIBCDIR:=/usr/i486-linuxlibc1
#
# For other libraries, you are on your own...
#LDFLAGS+=-nostdlib
#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
# use '-Os' optimization if available, else use -O2
OPTIMIZATION:=${shell if $(CC) -Os -S -o /dev/null -xc /dev/null \
>/dev/null 2>&1; then echo "-Os"; else echo "-O2" ; fi}
GCC_STACK_BOUNDRY:=${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc /dev/null \
>/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; else echo "" ; fi}
OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer $(GCC_STACK_BOUNDRY) #-fstrict-aliasing -march=i386 -mcpu=i386 -malign-functions=0 -malign-jumps=0
WARNINGS:=-Wall -Wstrict-prototypes -Wshadow
CFLAGS:=-I$(TOPDIR)include
ARFLAGS:=-r
#
#--------------------------------------------------------
# If you're going to do a lot of builds with a non-vanilla configuration,
# it makes sense to adjust parameters above, so you can type "make"
# by itself, instead of following it by the same half-dozen overrides
# every time. The stuff below, on the other hand, is probably less
# prone to casual user adjustment.
#
ifeq ($(strip $(DOLFS)),true)
# For large file summit support
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64
endif
ifeq ($(strip $(DODMALLOC)),true)
# For testing mem leaks with dmalloc
CFLAGS+=-DDMALLOC
LIBRARIES:=-ldmalloc
# Force debug=true, since this is useless when not debugging...
DODEBUG:=true
else
ifeq ($(strip $(DOEFENCE)),true)
LIBRARIES:=-lefence
# Force debug=true, since this is useless when not debugging...
DODEBUG:=true
endif
endif
ifeq ($(strip $(DODEBUG)),true)
CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS +=-Wl,-warn-common
STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
else
CFLAGS += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
LDFLAGS += -s -Wl,-warn-common
STRIPCMD:=$(STRIP) --remove-section=.note --remove-section=.comment
endif
ifeq ($(strip $(DOSTATIC)),true)
LDFLAGS += --static
endif
ifndef $(PREFIX)
PREFIX:=`pwd`/_install
endif
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
# the copy in BB_SRC_DIR, both during the compilation phase and the
# shell script that finds the list of object files.
# Work in progress by <ldoolitt@recycle.lbl.gov>.
#
ifneq ($(strip $(BB_SRC_DIR)),)
VPATH:=$(BB_SRC_DIR)
endif
CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif
# Put user-supplied flags at the end, where they
# have a chance of winning.
CFLAGS += $(CFLAGS_EXTRA)
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > $(dir $@)/.$(notdir $@).flags
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
%.o: %.s
$(AS) $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
# Old makefiles define their own rules for compiling .S files,
# but these standard rules are available for any Makefile that
# wants to use them. Our plan is to incrementally convert all
# the Makefiles to these standard rules. -- rmk, mec
ifdef USE_STANDARD_AS_RULE
%.s: %.S
$(CPP) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) $< > $@
%.o: %.S
$(CC) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) -c -o $@ $<
endif
%.lst: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
$(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
#
#
#
all_targets: $(O_TARGET) $(L_TARGET)
#
# Rule to compile a set of .o files into one .o file
#
ifdef O_TARGET
$(O_TARGET): $(obj-y)
rm -f $@
ifneq "$(strip $(obj-y))" ""
$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
else
$(AR) rcs $@
endif
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > $(dir $@)/.$(notdir $@).flags
endif # O_TARGET
#
# Rule to compile a set of .o files into one .a file
#
ifdef L_TARGET
$(L_TARGET): $(obj-y)
rm -f $@
$(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > $(dir $@)/.$(notdir $@).flags
endif
#
# This make dependencies quickly
#
ifdef _FASTDEP_ALL_SUB_DIRS
fastdep: dummy
$(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS) -- $(wildcard *.[chS]) > .depend
$(TOPDIR)scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -- $(wildcard *.[chS]) > .depend
ifdef ALL_SUB_DIRS
$(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
endif
ifdef _FASTDEP_ALL_SUB_DIRS
$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
endif
#
# A rule to make subdirectories
#
subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
sub_dirs: dummy $(subdir-list)
.PHONY: dummy
ifdef SUB_DIRS
$(subdir-list) : dummy
$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif
#
# A rule to do nothing
#
dummy:
#
# This is useful for testing
#
script:
$(SCRIPT)
.EXPORT_ALL_VARIABLES:
#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif
ifneq ($(wildcard $(TOPDIR)/.hdepend),)
include $(TOPDIR)/.hdepend
endif
#
# Find files whose flags have changed and force recompilation.
# For safety, this works in the converse direction:
# every file is forced, except those whose flags are positively up-to-date.
#
FILES_FLAGS_UP_TO_DATE :=
# For use in expunging commas from flags, which mung our checking.
comma = ,
FILES_FLAGS_EXIST := $(wildcard .*.flags)
ifneq ($(FILES_FLAGS_EXIST),)
include $(FILES_FLAGS_EXIST)
endif
FILES_FLAGS_CHANGED := $(strip \
$(filter-out $(FILES_FLAGS_UP_TO_DATE), \
$(O_TARGET) $(L_TARGET) $(active-objs) \
))
# A kludge: .S files don't get flag dependencies (yet),
# because that will involve changing a lot of Makefiles. Also
# suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
# This allows handling of assembly files that get translated into
# multiple object files (see arch/ia64/lib/idiv.S, for example).
FILES_FLAGS_CHANGED := $(strip \
$(filter-out $(patsubst %.S, %.o, $(wildcard *.S) $(IGNORE_FLAGS_OBJS)), \
$(FILES_FLAGS_CHANGED)))
ifneq ($(FILES_FLAGS_CHANGED),)
$(FILES_FLAGS_CHANGED): dummy
endif
+9 -3
View File
@@ -3,14 +3,15 @@ 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.
* 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).
* login/sulogin/passwd/etc are part of tinylogin. We are in the
process of merging these applications into busybox, since the
new build system allows us to add Libraries (i.e. libcrypt),
when certain applets are enabled.
* We _were_ going to split networking apps into a new package called
netkit-tiny. Per discussions on the mailing list, this isn't going
to happen. False alarm. Sorry about the confusion.
-Erik
-----------
@@ -56,3 +57,8 @@ and then start with the biggest things and make them smaller...
xargs could use a -l option
------------------------------------------------------------------
libbb/unzip.c and archival/gzip.c have common constant static arrays and
code for initializing the CRC array. Both use CRC-32 and could use
common code for CRC calculation. Within archival/gzip.c, the CRC
array should be malloc-ed as it is in libbb/unzip.c .
+9 -13
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,18 +17,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
TOPDIR :=..
L_TARGET := applets.a
obj-y :=
obj-n :=
obj- :=
obj-y += applets.o busybox.o usage.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
TOPDIR:= ../
APPLETS_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+32
View File
@@ -0,0 +1,32 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
#
APPLETS_AR:=applets.a
ifndef $(APPLETS_DIR)
APPLETS_DIR:=$(TOPDIR)applets/
endif
APPLET_SRC:=applets.c busybox.c usage.c
APPLET_OBJ:= $(patsubst %.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
$(AR) -ro $@ $(APPLET_OBJ)
+10 -7
View File
@@ -18,12 +18,15 @@ const char *applet_name;
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
"/",
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
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
};
/* abstract link() */
@@ -35,7 +38,7 @@ typedef int (*__link_f)(const char *, const char *);
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static char *busybox_fullpath()
static inline char *busybox_fullpath(void)
{
return xreadlink("/proc/self/exe");
}
+9 -23
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,28 +17,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
TOPDIR :=..
L_TARGET := archival.a
obj-y :=
obj-n :=
obj- :=
subdir-y := libunarchive
obj-$(CONFIG_AR) += ar.o
obj-$(CONFIG_BUNZIP2) += bunzip2.o
obj-$(CONFIG_CPIO) += cpio.o
obj-$(CONFIG_DPKG) += dpkg.o
obj-$(CONFIG_DPKG_DEB) += dpkg_deb.o
obj-$(CONFIG_GUNZIP) += gunzip.o
obj-$(CONFIG_GZIP) += gzip.o
obj-$(CONFIG_RPM2CPIO) += rpm2cpio.o
obj-$(CONFIG_TAR) += tar.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
TOPDIR:= ../
ARCHIVAL_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+41
View File
@@ -0,0 +1,41 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
#
ARCHIVAL_AR:=archival.a
ifndef $(ARCHIVAL_DIR)
ARCHIVAL_DIR:=$(TOPDIR)archival/
endif
ARCHIVAL-y:=
ARCHIVAL-$(CONFIG_AR) += ar.o
ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
ARCHIVAL-$(CONFIG_CPIO) += cpio.o
ARCHIVAL-$(CONFIG_DPKG) += dpkg.o
ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o
ARCHIVAL-$(CONFIG_GZIP) += gzip.o
ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o
ARCHIVAL-$(CONFIG_TAR) += tar.o
ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
$(AR) -ro $@ $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
+86 -64
View File
@@ -58,6 +58,7 @@
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <busybox.h>
//#define TRUE 1
@@ -276,7 +277,7 @@ int numFileNames;
int numFilesProcessed;
int exitValue;
unsigned int BZ2_crc32Table[256] = {
const unsigned int BZ2_crc32Table[256] = {
/*-- Ugly, innit? --*/
@@ -626,7 +627,7 @@ int BZ2_decompress(DState *s)
switch (switch_val) {
case BZ_X_MAGIC_1:
s->state = BZ_X_MAGIC_1;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -637,7 +638,7 @@ int BZ2_decompress(DState *s)
case BZ_X_MAGIC_2:
s->state = BZ_X_MAGIC_2;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -648,7 +649,7 @@ int BZ2_decompress(DState *s)
case BZ_X_MAGIC_3:
s->state = BZ_X_MAGIC_3;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -659,7 +660,7 @@ int BZ2_decompress(DState *s)
case BZ_X_MAGIC_4:
s->state = BZ_X_MAGIC_4;
if (get_bits(s, &s->blockSize100k, 8) == FALSE) {
if (! get_bits(s, &s->blockSize100k, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -687,7 +688,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BLKHDR_1:
s->state = BZ_X_BLKHDR_1;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -702,7 +703,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BLKHDR_2:
s->state = BZ_X_BLKHDR_2;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -713,7 +714,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BLKHDR_3:
s->state = BZ_X_BLKHDR_3;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -724,7 +725,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BLKHDR_4:
s->state = BZ_X_BLKHDR_4;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -735,7 +736,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BLKHDR_5:
s->state = BZ_X_BLKHDR_5;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -746,7 +747,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BLKHDR_6:
s->state = BZ_X_BLKHDR_6;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -763,7 +764,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BCRC_1:
s->state = BZ_X_BCRC_1;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -771,7 +772,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BCRC_2:
s->state = BZ_X_BCRC_2;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -779,7 +780,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BCRC_3:
s->state = BZ_X_BCRC_3;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -787,7 +788,7 @@ int BZ2_decompress(DState *s)
case BZ_X_BCRC_4:
s->state = BZ_X_BCRC_4;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -799,7 +800,7 @@ int BZ2_decompress(DState *s)
int tmp = s->blockRandomised;
const int ret = get_bits(s, &tmp, 1);
s->blockRandomised = tmp;
if (ret == FALSE) {
if (! ret) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -809,7 +810,7 @@ int BZ2_decompress(DState *s)
case BZ_X_ORIGPTR_1:
s->state = BZ_X_ORIGPTR_1;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -817,7 +818,7 @@ int BZ2_decompress(DState *s)
case BZ_X_ORIGPTR_2:
s->state = BZ_X_ORIGPTR_2;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -825,7 +826,7 @@ int BZ2_decompress(DState *s)
case BZ_X_ORIGPTR_3:
s->state = BZ_X_ORIGPTR_3;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -844,7 +845,7 @@ int BZ2_decompress(DState *s)
case BZ_X_MAPPING_1:
for (i = 0; i < 16; i++) {
s->state = BZ_X_MAPPING_1;
if (get_bits(s, &uc, 1) == FALSE) {
if (! get_bits(s, &uc, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -864,7 +865,7 @@ int BZ2_decompress(DState *s)
for (j = 0; j < 16; j++) {
case BZ_X_MAPPING_2:
s->state = BZ_X_MAPPING_2;
if (get_bits(s, &uc, 1) == FALSE) {
if (! get_bits(s, &uc, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -891,7 +892,7 @@ int BZ2_decompress(DState *s)
/*--- Now the selectors ---*/
case BZ_X_SELECTOR_1:
s->state = BZ_X_SELECTOR_1;
if (get_bits(s, &nGroups, 3) == FALSE) {
if (! get_bits(s, &nGroups, 3)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -902,7 +903,7 @@ int BZ2_decompress(DState *s)
case BZ_X_SELECTOR_2:
s->state = BZ_X_SELECTOR_2;
if (get_bits(s, &nSelectors, 15) == FALSE) {
if (! get_bits(s, &nSelectors, 15)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -918,7 +919,7 @@ int BZ2_decompress(DState *s)
while (1) {
case BZ_X_SELECTOR_3:
s->state = BZ_X_SELECTOR_3;
if (get_bits(s, &uc, 1) == FALSE) {
if (! get_bits(s, &uc, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -956,7 +957,7 @@ int BZ2_decompress(DState *s)
for (t = 0; t < nGroups; t++) {
case BZ_X_CODING_1:
s->state = BZ_X_CODING_1;
if (get_bits(s, &curr, 5) == FALSE) {
if (! get_bits(s, &curr, 5)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -969,7 +970,7 @@ int BZ2_decompress(DState *s)
case BZ_X_CODING_2:
s->state = BZ_X_CODING_2;
if (get_bits(s, &uc, 1) == FALSE) {
if (! get_bits(s, &uc, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -979,7 +980,7 @@ int BZ2_decompress(DState *s)
case BZ_X_CODING_3:
s->state = BZ_X_CODING_3;
if (get_bits(s, &uc, 1) == FALSE) {
if (! get_bits(s, &uc, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1044,12 +1045,12 @@ int BZ2_decompress(DState *s)
nblock = 0;
if (get_mtf_val_init() == FALSE) {
if (! get_mtf_val_init()) {
goto save_state_and_return;
}
case BZ_X_MTF_1:
s->state = BZ_X_MTF_1;
if (get_bits(s, &zvec, zn) == FALSE) {
if (! get_bits(s, &zvec, zn)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1065,7 +1066,7 @@ int BZ2_decompress(DState *s)
case BZ_X_MTF_2:
s->state = BZ_X_MTF_2;
if (get_bits(s, &zj, 1) == FALSE) {
if (! get_bits(s, &zj, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1094,12 +1095,12 @@ int BZ2_decompress(DState *s)
}
}
N = N * 2;
if (get_mtf_val_init() == FALSE) {
if (! get_mtf_val_init()) {
goto save_state_and_return;
}
case BZ_X_MTF_3:
s->state = BZ_X_MTF_3;
if (get_bits(s, &zvec, zn) == FALSE) {
if (! get_bits(s, &zvec, zn)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1115,7 +1116,7 @@ int BZ2_decompress(DState *s)
case BZ_X_MTF_4:
s->state = BZ_X_MTF_4;
if (get_bits(s, &zj, 1) == FALSE) {
if (! get_bits(s, &zj, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1223,12 +1224,12 @@ int BZ2_decompress(DState *s)
}
nblock++;
if (get_mtf_val_init() == FALSE) {
if (! get_mtf_val_init()) {
goto save_state_and_return;
}
case BZ_X_MTF_5:
s->state = BZ_X_MTF_5;
if (get_bits(s, &zvec, zn) == FALSE) {
if (! get_bits(s, &zvec, zn)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1244,7 +1245,7 @@ int BZ2_decompress(DState *s)
case BZ_X_MTF_6:
s->state = BZ_X_MTF_6;
if (get_bits(s, &zj, 1) == FALSE) {
if (! get_bits(s, &zj, 1)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1366,7 +1367,7 @@ int BZ2_decompress(DState *s)
endhdr_2:
case BZ_X_ENDHDR_2:
s->state = BZ_X_ENDHDR_2;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1377,7 +1378,7 @@ endhdr_2:
case BZ_X_ENDHDR_3:
s->state = BZ_X_ENDHDR_3;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1388,7 +1389,7 @@ endhdr_2:
case BZ_X_ENDHDR_4:
s->state = BZ_X_ENDHDR_4;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1399,7 +1400,7 @@ endhdr_2:
case BZ_X_ENDHDR_5:
s->state = BZ_X_ENDHDR_5;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1410,7 +1411,7 @@ endhdr_2:
case BZ_X_ENDHDR_6:
s->state = BZ_X_ENDHDR_6;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1422,14 +1423,14 @@ endhdr_2:
case BZ_X_CCRC_1:
s->state = BZ_X_CCRC_1;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((unsigned int)uc);
case BZ_X_CCRC_2:
s->state = BZ_X_CCRC_2;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1437,7 +1438,7 @@ endhdr_2:
case BZ_X_CCRC_3:
s->state = BZ_X_CCRC_3;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -1445,7 +1446,7 @@ endhdr_2:
case BZ_X_CCRC_4:
s->state = BZ_X_CCRC_4;
if (get_bits(s, &uc, 8) == FALSE) {
if (! get_bits(s, &uc, 8)) {
retVal = BZ_OK;
goto save_state_and_return;
}
@@ -2319,52 +2320,73 @@ errhandler_io:
int bunzip2_main(int argc, char **argv)
{
const int bunzip_to_stdout = 1;
const int bunzip_force = 2;
int flags = 0;
int opt = 0;
int status;
FILE *src_stream;
FILE *dst_stream;
char *save_name;
char *save_name_ptr;
char *save_name = NULL;
char *delete_name = NULL;
/* if called as bzcat */
if (strcmp(applet_name, "bzcat") == 0)
flags |= bunzip_to_stdout;
while ((opt = getopt(argc, argv, "ch")) != -1) {
while ((opt = getopt(argc, argv, "cfh")) != -1) {
switch (opt) {
case 'c':
flags |= bunzip_to_stdout;
break;
case 'f':
flags |= bunzip_force;
break;
case 'h':
default:
show_usage(); /* exit's inside usage */
}
}
save_name = xstrdup(argv[optind]);
if (save_name == NULL) {
show_usage();
/* Set input filename and number */
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
flags |= bunzip_to_stdout;
src_stream = stdin;
} else {
/* Open input file */
src_stream = xfopen(argv[optind], "r");
save_name = xstrdup(argv[optind]);
if (strcmp(save_name + strlen(save_name) - 4, ".bz2") != 0)
error_msg_and_die("Invalid extension");
save_name[strlen(save_name) - 4] = '\0';
}
src_stream = xfopen(argv[optind], "r");
save_name_ptr = strrchr(save_name, '.');
if (save_name_ptr == NULL) {
return(FALSE);
}
if (strcmp(save_name_ptr, ".bz2") != 0) {
error_msg("Invalid extension, expected .bz2");
}
*save_name_ptr = '\0';
/* Check that the input is sane. */
if (isatty(fileno(src_stream)) && (flags & bunzip_force) == 0)
error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
if (flags & bunzip_to_stdout) {
dst_stream = stdout;
} else {
dst_stream = xfopen(save_name, "w");
}
uncompressStream(src_stream, dst_stream);
return(TRUE);
if (uncompressStream(src_stream, dst_stream)) {
if (!(flags & bunzip_to_stdout))
delete_name = argv[optind];
status = EXIT_SUCCESS;
} else {
if (!(flags & bunzip_to_stdout))
delete_name = save_name;
status = EXIT_FAILURE;
}
if (delete_name) {
if (unlink(delete_name) < 0) {
error_msg_and_die("Couldn't remove %s", delete_name);
}
}
return status;
}
+4
View File
@@ -20,4 +20,8 @@ if [ "$CONFIG_TAR" = "y" ] ; then
bool ' Enable -X and --exclude options (exclude files)' CONFIG_FEATURE_TAR_EXCLUDE
bool ' Enable -z option (currently only for extracting)' CONFIG_FEATURE_TAR_GZIP
fi
if [ "$CONFIG_CPIO" = "y" -o "$CONFIG_TAR" = "y" ] ; then
bool ' Enable tape drive support' CONFIG_FEATURE_UNARCHIVE_TAPE
fi
bool 'unzip' CONFIG_UNZIP
endmenu
+13 -13
View File
@@ -858,7 +858,7 @@ void write_status_file(deb_file_t **deb_file)
}
}
/* If the package from the status file wasnt handle above, do it now*/
if (write_flag == FALSE) {
if (! write_flag) {
fprintf(new_status_file, "%s\n\n", control_buffer);
}
@@ -989,10 +989,14 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
for (j = 0; j < package_hashtable[deb_file[i]->package]->num_of_edges; j++) {
const edge_t *package_edge = package_node->edge[j];
const unsigned int package_num = search_package_hashtable(package_edge->name,
package_edge->version, package_edge->operator);
unsigned int package_num;
package_num = search_package_hashtable(package_edge->name, package_edge->version, package_edge->operator);
if (package_hashtable[package_num] == NULL) {
error_msg_and_die("Dependency checking failed for package %s\nNOTE: This may be due to busybox dpkg's inability to handle the Provides field, you may avoid dependency checking using the \"-F depends\" option ", name_hashtable[package_edge->name]);
}
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
state_status = get_status(status_num, 3);
state_want = get_status(status_num, 1);
switch (package_edge->type) {
@@ -1030,7 +1034,6 @@ char **create_list(const char *filename)
FILE *list_stream;
char **file_list = xmalloc(sizeof(char *));
char *line = NULL;
char *last_char;
int length = 0;
int count = 0;
@@ -1043,10 +1046,7 @@ char **create_list(const char *filename)
while (getline(&line, &length, list_stream) != -1) {
/* +2 as we need to include space for the terminating NULL pointer */
file_list = xrealloc(file_list, sizeof(char *) * (length + 2));
last_char = last_char_is(line, '\n');
if (last_char) {
*last_char = '\0';
}
chomp(line);
file_list[count] = xstrdup(line);
count++;
}
@@ -1202,10 +1202,10 @@ void remove_package(const unsigned int package_num)
exclude_files = create_list(conffile_name);
/* Some directories cant be removed straight away, so do multiple passes */
while (remove_file_array(remove_files, exclude_files) == TRUE);
while (remove_file_array(remove_files, exclude_files));
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = xmalloc(11);
remove_files = xmalloc(sizeof(char *) * 11);
all_control_list(remove_files, package_name);
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
@@ -1246,10 +1246,10 @@ void purge_package(const unsigned int package_num)
exclude_files[0] = NULL;
/* Some directories cant be removed straight away, so do multiple passes */
while (remove_file_array(remove_files, exclude_files) == TRUE);
while (remove_file_array(remove_files, exclude_files));
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = xmalloc(11);
remove_files = xmalloc(sizeof(char *) * 11);
all_control_list(remove_files, package_name);
remove_file_array(remove_files, exclude_files);
@@ -1284,7 +1284,7 @@ void unpack_package(deb_file_t *deb_file)
}
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
info_prefix = (char *) xmalloc(sizeof(package_name) + 20 + 4 + 1);
info_prefix = (char *) xmalloc(sizeof(package_name) + 20 + 4 + 2);
sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name);
deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs | extract_unconditional), info_prefix, NULL);
+92 -73
View File
@@ -7,9 +7,9 @@
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
* based on gzip sources
*
* Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* to support files as well as stdin/stdout, and to generally behave itself wrt
* command line handling.
* Adjusted further by Erik Andersen <andersee@debian.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@optushome.com.au>
@@ -68,27 +68,22 @@ static char *license_msg[] = {
extern int gunzip_main(int argc, char **argv)
{
FILE *in_file = stdin;
FILE *out_file = NULL;
int flags = 0;
int opt = 0;
int delete_old_file, file_count;
struct stat stat_buf;
char *if_name = NULL;
char *of_name = NULL;
char *delete_file_name = NULL;
FILE *in_file, *out_file;
char *if_name, *of_name, *delete_file_name;
const int gunzip_to_stdout = 1;
const int gunzip_force = 2;
const int gunzip_test = 4;
int flags = 0;
int opt = 0;
int delete_old_file = FALSE;
const int gunzip_verbose = 8;
/* if called as zcat */
if (strcmp(applet_name, "zcat") == 0)
flags |= gunzip_to_stdout;
while ((opt = getopt(argc, argv, "ctfhdq")) != -1) {
while ((opt = getopt(argc, argv, "ctfhdqv")) != -1) {
switch (opt) {
case 'c':
flags |= gunzip_to_stdout;
@@ -99,6 +94,9 @@ extern int gunzip_main(int argc, char **argv)
case 't':
flags |= gunzip_test;
break;
case 'v':
flags |= gunzip_verbose;
break;
case 'd': /* Used to convert gzip to gunzip. */
break;
case 'q':
@@ -110,74 +108,95 @@ extern int gunzip_main(int argc, char **argv)
}
}
/* Set input filename and number */
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
flags |= gunzip_to_stdout;
} else {
if_name = xstrdup(argv[optind]);
/* Open input file */
in_file = xfopen(if_name, "r");
file_count = argc - optind;
while (file_count==0 || optind < argc) {
in_file = stdin;
out_file = NULL;
if_name = NULL;
of_name = NULL;
delete_file_name = NULL;
delete_old_file = FALSE;
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
/* Get the time stamp on the input file. */
if (stat(if_name, &stat_buf) < 0) {
error_msg_and_die("Couldn't stat file %s", if_name);
}
}
/* Check that the input is sane. */
if (isatty(fileno(in_file)) && (flags & gunzip_force) == 0)
error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
/* Set output filename and number */
if (flags & gunzip_test) {
out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
} else if (flags & gunzip_to_stdout) {
out_file = stdout;
} else {
char *extension;
int length = strlen(if_name);
delete_old_file = TRUE;
extension = strrchr(if_name, '.');
if (extension && strcmp(extension, ".gz") == 0) {
length -= 3;
} else if (extension && strcmp(extension, ".tgz") == 0) {
length -= 4;
/* Set input filename and number */
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
flags |= gunzip_to_stdout;
/* Skip to the end */
optind = argc;
} else {
error_msg_and_die("Invalid extension");
if_name = strdup(argv[optind]);
/* Open input file */
in_file = xfopen(if_name, "r");
if (flags & gunzip_verbose) {
fprintf(stderr, "%s:\t", if_name);
}
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
/* Get the time stamp on the input file. */
if (stat(if_name, &stat_buf) < 0) {
error_msg_and_die("Couldn't stat file %s", if_name);
}
}
of_name = (char *) xcalloc(sizeof(char), length + 1);
strncpy(of_name, if_name, length);
/* Open output file */
out_file = xfopen(of_name, "w");
/* Check that the input is sane. */
if (isatty(fileno(in_file)) && (flags & gunzip_force) == 0)
error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
/* Set permissions on the file */
chmod(of_name, stat_buf.st_mode);
}
/* Set output filename and number */
if (flags & gunzip_test) {
out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
} else if (flags & gunzip_to_stdout) {
out_file = stdout;
} else {
char *extension;
int length = strlen(if_name);
/* do the decompression, and cleanup */
if (unzip(in_file, out_file) == 0) {
/* Success, remove .gz file */
delete_file_name = if_name;
} else {
/* remove failed attempt */
delete_file_name = of_name;
}
delete_old_file = TRUE;
extension = strrchr(if_name, '.');
if (extension && strcmp(extension, ".gz") == 0) {
length -= 3;
} else if (extension && strcmp(extension, ".tgz") == 0) {
length -= 4;
} else {
error_msg_and_die("Invalid extension");
}
of_name = (char *) xcalloc(sizeof(char), length + 1);
strncpy(of_name, if_name, length);
fclose(out_file);
fclose(in_file);
/* Open output file */
out_file = xfopen(of_name, "w");
if (delete_old_file == TRUE) {
if (unlink(delete_file_name) < 0) {
error_msg_and_die("Couldnt remove %s", delete_file_name);
/* Set permissions on the file */
chmod(of_name, stat_buf.st_mode);
}
}
free(of_name);
/* do the decompression, and cleanup */
if (unzip(in_file, out_file) == 0) {
/* Success, remove .gz file */
delete_file_name = if_name;
if (flags & gunzip_verbose) {
fprintf(stderr, "OK\n");
}
} else {
/* remove failed attempt */
delete_file_name = of_name;
}
fclose(out_file);
fclose(in_file);
if (delete_old_file == TRUE && !(flags & gunzip_test)) {
if (unlink(delete_file_name) < 0) {
error_msg_and_die("Couldnt remove %s", delete_file_name);
}
}
free(of_name);
optind++;
} /* while () */
return(EXIT_SUCCESS);
}
+76 -88
View File
@@ -174,15 +174,6 @@ typedef int file_t; /* Do not use stdio */
#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\
flush_outbuf();}
/* Output a 16 bit value, lsb first */
#define put_short(w) \
{ if (outcnt < OUTBUFSIZ-2) { \
outbuf[outcnt++] = (uch) ((w) & 0xff); \
outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \
} else { \
put_short_when_full(w); \
} \
}
/* Output a 32 bit value to the bit stream, lsb first */
#if 0
@@ -247,9 +238,6 @@ static int (*read_buf) (char *buf, unsigned size);
/* from util.c: */
static void flush_outbuf (void);
static void put_short_when_full (ush);
/* lzw.h -- define the lzw functions.
* Copyright (C) 1992-1993 Jean-loup Gailly.
* This is free software; you can redistribute it and/or modify it under the
@@ -329,13 +317,24 @@ static long ifile_size; /* input file size, -1 for devices (debug only) */
static char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
static int z_len; /* strlen(z_suffix) */
static char ifname[MAX_PATH_LEN]; /* input file name */
static char ofname[MAX_PATH_LEN]; /* output file name */
static int ifd; /* input file descriptor */
static int ofd; /* output file descriptor */
static unsigned insize; /* valid bytes in inbuf */
static unsigned outcnt; /* bytes in output buffer */
/* Output a 16 bit value, lsb first */
static void put_short(ush w)
{
if (outcnt < OUTBUFSIZ-2) {
outbuf[outcnt++] = (uch) ((w) & 0xff);
outbuf[outcnt++] = (uch) ((ush)(w) >> 8);
} else {
put_byte((uch)((w) & 0xff));
put_byte((uch)((ush)(w) >> 8));
}
}
/* ========================================================================
* Signal and error handler.
*/
@@ -1213,7 +1212,6 @@ int gzip_main(int argc, char **argv)
struct stat statBuf;
char *delFileName;
int tostdout = 0;
int fromstdin = 0;
int force = 0;
int opt;
@@ -1240,13 +1238,6 @@ int gzip_main(int argc, char **argv)
show_usage();
}
}
if ((optind == argc) || (strcmp(argv[optind], "-") == 0)) {
fromstdin = 1;
tostdout = 1;
}
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
error_msg_and_die( "compressed data not written to terminal. Use -f to force it.");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
@@ -1273,70 +1264,78 @@ int gzip_main(int argc, char **argv)
ALLOC(uch, window, 2L * WSIZE);
ALLOC(ush, tab_prefix, 1L << BITS);
if (fromstdin == 1) {
strcpy(ofname, "stdin");
clear_bufs();
part_nb = 0;
inFileNum = fileno(stdin);
time_stamp = 0; /* time unknown by default */
ifile_size = -1L; /* convention for unknown size */
if (optind == argc) {
time_stamp = 0;
ifile_size = -1L;
zip(STDIN_FILENO, STDOUT_FILENO);
} else {
/* Open up the input file */
strncpy(ifname, argv[optind], MAX_PATH_LEN);
int i;
/* Open input file */
inFileNum = open(ifname, O_RDONLY);
if (inFileNum < 0 || stat(ifname, &statBuf) < 0)
perror_msg_and_die("%s", ifname);
/* Get the time stamp on the input file. */
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
}
for (i = optind; i < argc; i++) {
char *path = NULL;
if (strcmp(argv[i], "-") == 0) {
time_stamp = 0;
ifile_size = -1L;
inFileNum = STDIN_FILENO;
outFileNum = STDOUT_FILENO;
} else {
inFileNum = open(argv[i], O_RDONLY);
if (inFileNum < 0 || fstat (inFileNum, &statBuf) < 0)
perror_msg_and_die("%s", argv[i]);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
if (tostdout == 1) {
/* And get to work */
strcpy(ofname, "stdout");
outFileNum = fileno(stdout);
if (!tostdout) {
path = xmalloc(strlen(argv[i]) + 4);
strcpy(path, argv[i]);
strcat(path, ".gz");
clear_bufs(); /* clear input and output buffers */
part_nb = 0;
/* Actually do the compression/decompression. */
zip(inFileNum, outFileNum);
} else {
/* And get to work */
strncpy(ofname, ifname, MAX_PATH_LEN - 4);
strcat(ofname, ".gz");
/* Open output fille */
/* Open output file */
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW);
outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW);
#else
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL);
#endif
if (outFileNum < 0)
perror_msg_and_die("%s", ofname);
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
if (outFileNum < 0) {
perror_msg("%s", path);
free(path);
continue;
}
clear_bufs(); /* clear input and output buffers */
part_nb = 0;
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
} else
outFileNum = STDOUT_FILENO;
}
/* Actually do the compression/decompression. */
result = zip(inFileNum, outFileNum);
close(outFileNum);
close(inFileNum);
/* Delete the original file */
if (result == OK)
delFileName = ifname;
else
delFileName = ofname;
if (path == NULL && isatty(outFileNum) && force == 0) {
error_msg("compressed data not written to a terminal. Use -f to force compression.");
free(path);
continue;
}
if (unlink(delFileName) < 0)
perror_msg_and_die("%s", delFileName);
result = zip(inFileNum, outFileNum);
if (path != NULL) {
close (inFileNum);
close (outFileNum);
/* Delete the original file */
if (result == OK)
delFileName = argv[i];
else
delFileName = path;
if (unlink(delFileName) < 0)
perror_msg("%s", delFileName);
}
free(path);
}
}
return(exit_code);
@@ -1481,7 +1480,7 @@ static const extra_bits_t extra_blbits[BL_CODES]
* if we rely on DIST_BUFSIZE == LIT_BUFSIZE.
*/
#if LIT_BUFSIZE > INBUFSIZ
error cannot overlay l_buf and inbuf
#error cannot overlay l_buf and inbuf
#endif
#define REP_3_6 16
/* repeat previous bit length 3-6 times (2 bits of repeat count) */
@@ -2462,21 +2461,10 @@ static void set_file_type()
static ulg crc; /* crc on uncompressed file data */
static long header_bytes; /* number of bytes in gzip header */
static void put_short_when_full(ush w)
{
put_byte((uch)((w) & 0xff));
put_byte((uch)((ush)(w) >> 8));
}
static void put_short_function(ush n)
{
put_short(n);
}
static void put_long(ulg n)
{
put_short_function((n) & 0xffff);
put_short_function(((ulg)(n)) >> 16);
put_short((n) & 0xffff);
put_short(((ulg)(n)) >> 16);
}
/* put_header_byte is used for the compressed output
+9 -36
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,41 +17,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
TOPDIR :=../..
L_TARGET := libunarchive.a
obj-y := unarchive.o seek_sub_file.o
obj-n :=
obj- :=
ifeq ($(CONFIG_DPKG),y)
obj-y += deb_extract.o get_header_ar.o get_header_tar.o
endif
ifeq ($(CONFIG_DPKG_DEB),y)
obj-y += deb_extract.o get_header_ar.o get_header_tar.o
endif
ifeq ($(CONFIG_AR),y)
obj-y += get_header_ar.o
endif
ifeq ($(CONFIG_CPIO),y)
obj-y += get_header_cpio.o
endif
ifeq ($(CONFIG_RPM2CPIO),y)
obj-y += get_header_cpio.o
endif
ifeq ($(CONFIG_TAR),y)
obj-y += get_header_tar.o
endif
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
TOPDIR:= ../../
LIBUNARCHIVE_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+38
View File
@@ -0,0 +1,38 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
#
LIBUNARCHIVE_AR:=libunarchive.a
ifndef $(LIBUNARCHIVE_DIR)
LIBUNARCHIVE_DIR:=$(TOPDIR)archival/libunarchive/
endif
LIBUNARCHIVE-y:=unarchive.o seek_sub_file.o
LIBUNARCHIVE-$(CONFIG_DPKG) += deb_extract.o get_header_ar.o get_header_tar.o
LIBUNARCHIVE-$(CONFIG_DPKG_DEB) += deb_extract.o get_header_ar.o get_header_tar.o
LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o
LIBUNARCHIVE-$(CONFIG_CPIO) += get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
LIBUNARCHIVE-$(CONFIG_UNZIP) += get_header_zip.o
libraries-y+=$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR)
$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
$(AR) -ro $@ $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
+93 -112
View File
@@ -7,8 +7,8 @@
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
* based on gzip sources
*
* Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* to support files as well as stdin/stdout, and to generally behave itself wrt
* Adjusted further by Erik Andersen <andersee@debian.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
@@ -73,14 +73,14 @@ static FILE *in_file, *out_file;
static unsigned char *window;
static unsigned long *crc_table;
static unsigned long crc = 0xffffffffL; /* shift register contents */
static unsigned long crc; /* shift register contents */
/* Return codes from gzip */
static const int ERROR = 1;
/*
* window size--must be a power of two, and
* at least 32K for zip's deflate method
* at least 32K for zip's deflate method
*/
static const int WSIZE = 0x8000;
@@ -123,22 +123,18 @@ static void abort_gzip(void)
static void make_crc_table(void)
{
unsigned long table_entry; /* crc shift register */
unsigned long poly = 0; /* polynomial exclusive-or pattern */
int i; /* counter for all possible eight bit values */
int k; /* byte being shifted into crc apparatus */
/* terms of polynomial defining this crc (except x^32): */
static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
const unsigned long poly = 0xedb88320; /* polynomial exclusive-or pattern */
unsigned short i; /* counter for all possible eight bit values */
/* initial shift register value */
crc = 0xffffffffL;
crc_table = (unsigned long *) malloc(256 * sizeof(unsigned long));
/* Make exclusive-or pattern from polynomial (0xedb88320) */
for (i = 0; i < sizeof(p)/sizeof(int); i++)
poly |= 1L << (31 - p[i]);
/* Compute and print table of CRC's, five per line */
for (i = 0; i < 256; i++) {
unsigned long table_entry; /* crc shift register */
char k; /* byte being shifted into crc apparatus */
table_entry = i;
/* The idea to initialize the register with the byte instead of
* zero was stolen from Haruhiko Okumura's ar002
@@ -192,6 +188,8 @@ static int huft_free(huft_t *t)
return 0;
}
typedef unsigned char extra_bits_t;
/* 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
@@ -207,7 +205,7 @@ static int huft_free(huft_t *t)
* 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 short *e, huft_t **t, int *m)
const unsigned short *d, const extra_bits_t *e, huft_t **t, int *m)
{
unsigned a; /* counter for codes of length k */
unsigned c[BMAX + 1]; /* bit length count table */
@@ -316,12 +314,8 @@ static int huft_build(unsigned int *b, const unsigned int n, const unsigned int
z = 1 << j; /* table entries for j-bit table */
/* allocate and link in new table */
if ((q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t))) == NULL) {
if (h) {
huft_free(u[0]);
}
return 3; /* not enough memory */
}
q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t));
hufts += z + 1; /* track memory usage */
*t = q + 1; /* link to list for huft_free() */
*(t = &(q->v.t)) = NULL;
@@ -499,6 +493,30 @@ static int inflate_codes(huft_t *tl, huft_t *td, int bl, int bd)
return 0;
}
static const unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */
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. */
static const extra_bits_t cplext[] = { /* Extra bits for literal codes 257..285 */
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 */
static const unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */
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
};
static const extra_bits_t cpdext[] = { /* Extra bits for distance codes */
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. */
static const extra_bits_t border[] = { /* Order of the bit length code lengths */
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
/*
* decompress an inflated block
* e: last block flag
@@ -510,25 +528,6 @@ static int inflate_block(int *e)
unsigned t; /* block type */
register unsigned long b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
static unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */
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. */
static unsigned short cplext[] = { /* Extra bits for literal codes 257..285 */
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 */
static unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */
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
};
static unsigned short cpdext[] = { /* Extra bits for distance codes */
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
};
/* make local bit buffer */
b = bb;
@@ -667,12 +666,8 @@ static int inflate_block(int *e)
}
case 2: /* Inflate dynamic */
{
/* Tables for deflate from PKZIP's appnote.txt. */
static unsigned border[] = { /* Order of the bit length code lengths */
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
int dbits = 6; /* bits in base distance lookup table */
int lbits = 9; /* bits in base literal/length lookup table */
const int dbits = 6; /* bits in base distance lookup table */
const int lbits = 9; /* bits in base literal/length lookup table */
int i; /* temporary variables */
unsigned j;
@@ -853,7 +848,7 @@ static int inflate_block(int *e)
*
* GLOBAL VARIABLES: outcnt, bk, bb, hufts, inptr
*/
static int inflate(void)
extern int inflate(FILE *in, FILE *out)
{
int e; /* last block flag */
int r; /* result code */
@@ -864,6 +859,16 @@ static int inflate(void)
bk = 0;
bb = 0;
in_file = in;
out_file = out;
/* Allocate all global buffers (for DYN_ALLOC option) */
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
bytes_out = 0L;
/* Create the crc table */
make_crc_table();
/* decompress until the last block */
do {
hufts = 0;
@@ -875,15 +880,25 @@ static int inflate(void)
}
} while (!e);
/* Undo too much lookahead. The next read will be byte aligned so we
* can discard unused bits in the last meaningful byte.
*/
while (bk >= 8) {
bk -= 8;
ungetc((bb << bk), in_file);
}
/* flush out window */
flush_window();
free(window);
free(crc_table);
/* return success */
return 0;
}
/* ===========================================================================
* Unzip in to out. This routine works on both gzip and pkzip files.
* Unzip in to out. This routine works on gzip files only.
*
* IN assertions: the buffer inbuf contains already the beginning of
* the compressed data, from offsets inptr to insize-1 included.
@@ -892,19 +907,10 @@ static int inflate(void)
*/
extern int unzip(FILE *l_in_file, FILE *l_out_file)
{
const int extra_field = 0x04; /* bit 2 set: extra field present */
const int orig_name = 0x08; /* bit 3 set: original file name present */
const int comment = 0x10; /* bit 4 set: file comment present */
unsigned char buf[8]; /* extended local header */
unsigned char flags; /* compression flags */
char magic[2]; /* magic header */
int method;
typedef void (*sig_type) (int);
int exit_code=0; /* program exit code */
int i;
in_file = l_in_file;
out_file = l_out_file;
unsigned short i;
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
(void) signal(SIGINT, (sig_type) abort_gzip);
@@ -920,79 +926,56 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
}
#endif
/* Allocate all global buffers (for DYN_ALLOC option) */
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
outcnt = 0;
bytes_out = 0L;
magic[0] = fgetc(in_file);
magic[1] = fgetc(in_file);
/* Magic header for gzip files, 1F 8B = \037\213 */
if (memcmp(magic, "\037\213", 2) != 0) {
if ((fgetc(l_in_file) != 0x1F) || (fgetc(l_in_file) != 0x8b)) {
error_msg("Invalid gzip magic");
return EXIT_FAILURE;
}
method = (int) fgetc(in_file);
if (method != 8) {
error_msg("unknown method %d -- get newer version of gzip", method);
exit_code = 1;
return -1;
/* Check the compression method */
if (fgetc(l_in_file) != 8) {
error_msg("Unknown compression method");
return(-1);
}
flags = (unsigned char) fgetc(in_file);
flags = (unsigned char) fgetc(l_in_file);
/* Ignore time stamp(4), extra flags(1), OS type(1) */
for (i = 0; i < 6; i++)
fgetc(in_file);
for (i = 0; i < 6; i++) {
fgetc(l_in_file);
}
if ((flags & extra_field) != 0) {
size_t extra;
extra = fgetc(in_file);
extra += fgetc(in_file) << 8;
if (flags & 0x04) {
/* bit 2 set: extra field present */
const unsigned short extra = fgetc(l_in_file) + (fgetc(l_in_file) << 8);
for (i = 0; i < extra; i++)
fgetc(in_file);
for (i = 0; i < extra; i++) {
fgetc(l_in_file);
}
}
/* Discard original name if any */
if ((flags & orig_name) != 0) {
while (fgetc(in_file) != 0); /* null */
if (flags & 0x08) {
/* bit 3 set: original file name present */
while (fgetc(l_in_file) != 0); /* null */
}
/* Discard file comment if any */
if ((flags & comment) != 0) {
while (fgetc(in_file) != 0); /* null */
if (flags & 0x10) {
/* bit 4 set: file comment present */
while (fgetc(l_in_file) != 0); /* null */
}
if (method < 0) {
printf("it failed\n");
return(exit_code); /* error message already emitted */
}
make_crc_table();
/* Decompress */
if (method == 8) {
int res = inflate();
if (res == 3) {
error_msg(memory_exhausted);
} else if (res != 0) {
error_msg("invalid compressed data--format violated");
}
} else {
error_msg("internal error, invalid method");
if (inflate(l_in_file, l_out_file) != 0) {
error_msg("invalid compressed data--format violated");
}
/* Get the crc and original length
* crc32 (see algorithm.doc)
* uncompressed input size modulo 2^32
*/
fread(buf, 1, 8, in_file);
fread(buf, 1, 8, l_in_file);
/* Validate decompression - crc */
if ((unsigned int)((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) {
@@ -1003,14 +986,11 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
error_msg("invalid compressed data--length error");
}
free(window);
free(crc_table);
return 0;
}
/*
* This needs access to global variables wondow and crc_table, so its not in its own file.
* This needs access to global variables window and crc_table, so its not in its own file.
*/
extern void gz_close(int gunzip_pid)
{
@@ -1021,6 +1001,7 @@ extern void gz_close(int gunzip_pid)
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
free(window);
free(crc_table);
free(window);
free(crc_table);
}
+110
View File
@@ -0,0 +1,110 @@
/* vi: set sw=4 ts=4: */
/*
* get_header_zip for busybox
*
* Copyright (C) 2001 by Laurence Anderson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "unarchive.h"
#include "libbb.h"
#define ZIP_FILEHEADER_MAGIC 0x04034b50
#define ZIP_CDS_MAGIC 0x02014b50
#define ZIP_CDS_END_MAGIC 0x06054b50
#define ZIP_DD_MAGIC 0x8074b50
file_header_t *get_header_zip(FILE *zip_stream)
{
struct {
short version __attribute__ ((packed));
short flags __attribute__ ((packed));
short method __attribute__ ((packed));
short modtime __attribute__ ((packed));
short moddate __attribute__ ((packed));
int crc32 __attribute__ ((packed));
int cmpsize __attribute__ ((packed));
int ucmpsize __attribute__ ((packed));
short filename_len __attribute__ ((packed));
short extra_len __attribute__ ((packed));
} zip_header;
file_header_t *zip_entry = NULL;
int magic;
static int dd_ahead = 0; // If this is true, the we didn't know how long the last extraced file was
fread (&magic, 4, 1, zip_stream);
archive_offset += 4;
if (feof(zip_stream)) return(NULL);
checkmagic:
switch (magic) {
case ZIP_FILEHEADER_MAGIC:
zip_entry = xcalloc(1, sizeof(file_header_t));
fread (&zip_header, sizeof(zip_header), 1, zip_stream);
archive_offset += sizeof(zip_header);
if (!(zip_header.method == 8 || zip_header.method == 0)) { printf("Unsupported compression method %d\n", zip_header.method); return(NULL); }
zip_entry->name = calloc(zip_header.filename_len + 1, sizeof(char));
fread (zip_entry->name, sizeof(char), zip_header.filename_len, zip_stream);
archive_offset += zip_header.filename_len;
seek_sub_file(zip_stream, zip_header.extra_len);
zip_entry->size = zip_header.cmpsize;
if (zip_header.method == 8) zip_entry->extract_func = &inflate;
zip_entry->mode = S_IFREG | 0777;
// Time/Date?
if (*(zip_entry->name + strlen(zip_entry->name) - 1) == '/') { // Files that end in a / are directories
zip_entry->mode ^= S_IFREG;
zip_entry->mode |= S_IFDIR;
*(zip_entry->name + strlen(zip_entry->name) - 1) = '\0'; // Remove trailing / so unarchive doesn't get confused
}
//printf("cmpsize: %d, ucmpsize: %d, method: %d\n", zip_header.cmpsize, zip_header.ucmpsize, zip_header.method);
if (zip_header.flags & 0x8) { // crc32, and sizes are in the data description _after_ the file
if (zip_header.cmpsize == 0) dd_ahead = 1; // As we don't know how long this file it is difficult to skip! but it is compressed, so normally its ok
if (zip_header.ucmpsize != 0) dd_ahead = 2; // Humm... we would otherwise skip this twice - not good!
}
break;
case ZIP_CDS_MAGIC: /* FALLTHRU */
case ZIP_CDS_END_MAGIC:
return(NULL);
break;
case ZIP_DD_MAGIC: {
int cmpsize;
seek_sub_file(zip_stream, 4); // Skip crc32
fread(&cmpsize, 4, 1, zip_stream);
archive_offset += 4;
if (dd_ahead == 1) archive_offset += cmpsize;
seek_sub_file(zip_stream, 4); // Skip uncompressed size
dd_ahead = 0;
return (get_header_zip(zip_stream));
break; }
default:
if (!dd_ahead) error_msg("Invalid magic (%#x): Trying to skip junk", magic);
dd_ahead = 0;
while (!feof(zip_stream)) {
int tmpmagic;
tmpmagic = fgetc(zip_stream);
archive_offset++;
magic = ((magic >> 8) & 0x00ffffff) | ((tmpmagic << 24) & 0xff000000);
if (magic == ZIP_FILEHEADER_MAGIC || magic == ZIP_CDS_MAGIC || magic == ZIP_CDS_END_MAGIC) goto checkmagic;
}
error_msg("End of archive reached: Bad archive");
return(NULL);
}
//if (archive_offset != ftell(zip_stream)) printf("Archive offset out of sync (%d,%d)\n", (int) archive_offset, (int) ftell(zip_stream));
return(zip_entry);
}
+26 -4
View File
@@ -21,8 +21,10 @@
#include <string.h>
#include <unistd.h>
#include <utime.h>
#include <sys/wait.h>
#include <signal.h>
#include "unarchive.h"
#include "libbb.h"
#include "busybox.h"
/* Extract the data postioned at src_stream to either filesystem, stdout or
* buffer depending on the value of 'function' which is defined in libbb.h
@@ -120,7 +122,8 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
return NULL;
}
archive_offset += file_entry->size;
copy_file_chunk(src_stream, dst_stream, file_entry->size);
if (file_entry->extract_func) file_entry->extract_func(src_stream, dst_stream);
else copy_file_chunk(src_stream, dst_stream, file_entry->size);
fclose(dst_stream);
}
break;
@@ -201,7 +204,22 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers
int extract_flag = TRUE;
int i;
char *buffer = NULL;
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
int pid, tape_pipe[2];
if (pipe(tape_pipe) != 0) error_msg_and_die("Can't create pipe\n");
if ((pid = fork()) == -1) error_msg_and_die("Fork failed\n");
if (pid==0) { /* child process */
close(tape_pipe[0]); /* We don't wan't to read from the pipe */
copyfd(fileno(src_stream), tape_pipe[1]);
close(tape_pipe[1]); /* Send EOF */
exit(0);
/* notreached */
}
close(tape_pipe[1]); /* Don't want to write down the pipe */
fclose(src_stream);
src_stream = fdopen(tape_pipe[0], "r");
#endif
archive_offset = 0;
while ((file_entry = get_headers(src_stream)) != NULL) {
@@ -227,7 +245,7 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers
}
}
if (extract_flag == TRUE) {
if (extract_flag) {
buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
} else {
/* seek past the data entry */
@@ -237,5 +255,9 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers
free(file_entry->link_name);
free(file_entry);
}
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
kill(pid, SIGTERM);
waitpid(pid, NULL, 0);
#endif
return(buffer);
}
}
+93 -112
View File
@@ -7,8 +7,8 @@
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
* based on gzip sources
*
* Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* to support files as well as stdin/stdout, and to generally behave itself wrt
* Adjusted further by Erik Andersen <andersee@debian.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
@@ -73,14 +73,14 @@ static FILE *in_file, *out_file;
static unsigned char *window;
static unsigned long *crc_table;
static unsigned long crc = 0xffffffffL; /* shift register contents */
static unsigned long crc; /* shift register contents */
/* Return codes from gzip */
static const int ERROR = 1;
/*
* window size--must be a power of two, and
* at least 32K for zip's deflate method
* at least 32K for zip's deflate method
*/
static const int WSIZE = 0x8000;
@@ -123,22 +123,18 @@ static void abort_gzip(void)
static void make_crc_table(void)
{
unsigned long table_entry; /* crc shift register */
unsigned long poly = 0; /* polynomial exclusive-or pattern */
int i; /* counter for all possible eight bit values */
int k; /* byte being shifted into crc apparatus */
/* terms of polynomial defining this crc (except x^32): */
static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
const unsigned long poly = 0xedb88320; /* polynomial exclusive-or pattern */
unsigned short i; /* counter for all possible eight bit values */
/* initial shift register value */
crc = 0xffffffffL;
crc_table = (unsigned long *) malloc(256 * sizeof(unsigned long));
/* Make exclusive-or pattern from polynomial (0xedb88320) */
for (i = 0; i < sizeof(p)/sizeof(int); i++)
poly |= 1L << (31 - p[i]);
/* Compute and print table of CRC's, five per line */
for (i = 0; i < 256; i++) {
unsigned long table_entry; /* crc shift register */
char k; /* byte being shifted into crc apparatus */
table_entry = i;
/* The idea to initialize the register with the byte instead of
* zero was stolen from Haruhiko Okumura's ar002
@@ -192,6 +188,8 @@ static int huft_free(huft_t *t)
return 0;
}
typedef unsigned char extra_bits_t;
/* 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
@@ -207,7 +205,7 @@ static int huft_free(huft_t *t)
* 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 short *e, huft_t **t, int *m)
const unsigned short *d, const extra_bits_t *e, huft_t **t, int *m)
{
unsigned a; /* counter for codes of length k */
unsigned c[BMAX + 1]; /* bit length count table */
@@ -316,12 +314,8 @@ static int huft_build(unsigned int *b, const unsigned int n, const unsigned int
z = 1 << j; /* table entries for j-bit table */
/* allocate and link in new table */
if ((q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t))) == NULL) {
if (h) {
huft_free(u[0]);
}
return 3; /* not enough memory */
}
q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t));
hufts += z + 1; /* track memory usage */
*t = q + 1; /* link to list for huft_free() */
*(t = &(q->v.t)) = NULL;
@@ -499,6 +493,30 @@ static int inflate_codes(huft_t *tl, huft_t *td, int bl, int bd)
return 0;
}
static const unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */
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. */
static const extra_bits_t cplext[] = { /* Extra bits for literal codes 257..285 */
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 */
static const unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */
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
};
static const extra_bits_t cpdext[] = { /* Extra bits for distance codes */
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. */
static const extra_bits_t border[] = { /* Order of the bit length code lengths */
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
/*
* decompress an inflated block
* e: last block flag
@@ -510,25 +528,6 @@ static int inflate_block(int *e)
unsigned t; /* block type */
register unsigned long b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
static unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */
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. */
static unsigned short cplext[] = { /* Extra bits for literal codes 257..285 */
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 */
static unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */
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
};
static unsigned short cpdext[] = { /* Extra bits for distance codes */
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
};
/* make local bit buffer */
b = bb;
@@ -667,12 +666,8 @@ static int inflate_block(int *e)
}
case 2: /* Inflate dynamic */
{
/* Tables for deflate from PKZIP's appnote.txt. */
static unsigned border[] = { /* Order of the bit length code lengths */
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
int dbits = 6; /* bits in base distance lookup table */
int lbits = 9; /* bits in base literal/length lookup table */
const int dbits = 6; /* bits in base distance lookup table */
const int lbits = 9; /* bits in base literal/length lookup table */
int i; /* temporary variables */
unsigned j;
@@ -853,7 +848,7 @@ static int inflate_block(int *e)
*
* GLOBAL VARIABLES: outcnt, bk, bb, hufts, inptr
*/
static int inflate(void)
extern int inflate(FILE *in, FILE *out)
{
int e; /* last block flag */
int r; /* result code */
@@ -864,6 +859,16 @@ static int inflate(void)
bk = 0;
bb = 0;
in_file = in;
out_file = out;
/* Allocate all global buffers (for DYN_ALLOC option) */
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
bytes_out = 0L;
/* Create the crc table */
make_crc_table();
/* decompress until the last block */
do {
hufts = 0;
@@ -875,15 +880,25 @@ static int inflate(void)
}
} while (!e);
/* Undo too much lookahead. The next read will be byte aligned so we
* can discard unused bits in the last meaningful byte.
*/
while (bk >= 8) {
bk -= 8;
ungetc((bb << bk), in_file);
}
/* flush out window */
flush_window();
free(window);
free(crc_table);
/* return success */
return 0;
}
/* ===========================================================================
* Unzip in to out. This routine works on both gzip and pkzip files.
* Unzip in to out. This routine works on gzip files only.
*
* IN assertions: the buffer inbuf contains already the beginning of
* the compressed data, from offsets inptr to insize-1 included.
@@ -892,19 +907,10 @@ static int inflate(void)
*/
extern int unzip(FILE *l_in_file, FILE *l_out_file)
{
const int extra_field = 0x04; /* bit 2 set: extra field present */
const int orig_name = 0x08; /* bit 3 set: original file name present */
const int comment = 0x10; /* bit 4 set: file comment present */
unsigned char buf[8]; /* extended local header */
unsigned char flags; /* compression flags */
char magic[2]; /* magic header */
int method;
typedef void (*sig_type) (int);
int exit_code=0; /* program exit code */
int i;
in_file = l_in_file;
out_file = l_out_file;
unsigned short i;
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
(void) signal(SIGINT, (sig_type) abort_gzip);
@@ -920,79 +926,56 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
}
#endif
/* Allocate all global buffers (for DYN_ALLOC option) */
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
outcnt = 0;
bytes_out = 0L;
magic[0] = fgetc(in_file);
magic[1] = fgetc(in_file);
/* Magic header for gzip files, 1F 8B = \037\213 */
if (memcmp(magic, "\037\213", 2) != 0) {
if ((fgetc(l_in_file) != 0x1F) || (fgetc(l_in_file) != 0x8b)) {
error_msg("Invalid gzip magic");
return EXIT_FAILURE;
}
method = (int) fgetc(in_file);
if (method != 8) {
error_msg("unknown method %d -- get newer version of gzip", method);
exit_code = 1;
return -1;
/* Check the compression method */
if (fgetc(l_in_file) != 8) {
error_msg("Unknown compression method");
return(-1);
}
flags = (unsigned char) fgetc(in_file);
flags = (unsigned char) fgetc(l_in_file);
/* Ignore time stamp(4), extra flags(1), OS type(1) */
for (i = 0; i < 6; i++)
fgetc(in_file);
for (i = 0; i < 6; i++) {
fgetc(l_in_file);
}
if ((flags & extra_field) != 0) {
size_t extra;
extra = fgetc(in_file);
extra += fgetc(in_file) << 8;
if (flags & 0x04) {
/* bit 2 set: extra field present */
const unsigned short extra = fgetc(l_in_file) + (fgetc(l_in_file) << 8);
for (i = 0; i < extra; i++)
fgetc(in_file);
for (i = 0; i < extra; i++) {
fgetc(l_in_file);
}
}
/* Discard original name if any */
if ((flags & orig_name) != 0) {
while (fgetc(in_file) != 0); /* null */
if (flags & 0x08) {
/* bit 3 set: original file name present */
while (fgetc(l_in_file) != 0); /* null */
}
/* Discard file comment if any */
if ((flags & comment) != 0) {
while (fgetc(in_file) != 0); /* null */
if (flags & 0x10) {
/* bit 4 set: file comment present */
while (fgetc(l_in_file) != 0); /* null */
}
if (method < 0) {
printf("it failed\n");
return(exit_code); /* error message already emitted */
}
make_crc_table();
/* Decompress */
if (method == 8) {
int res = inflate();
if (res == 3) {
error_msg(memory_exhausted);
} else if (res != 0) {
error_msg("invalid compressed data--format violated");
}
} else {
error_msg("internal error, invalid method");
if (inflate(l_in_file, l_out_file) != 0) {
error_msg("invalid compressed data--format violated");
}
/* Get the crc and original length
* crc32 (see algorithm.doc)
* uncompressed input size modulo 2^32
*/
fread(buf, 1, 8, in_file);
fread(buf, 1, 8, l_in_file);
/* Validate decompression - crc */
if ((unsigned int)((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) {
@@ -1003,14 +986,11 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
error_msg("invalid compressed data--length error");
}
free(window);
free(crc_table);
return 0;
}
/*
* This needs access to global variables wondow and crc_table, so its not in its own file.
* This needs access to global variables window and crc_table, so its not in its own file.
*/
extern void gz_close(int gunzip_pid)
{
@@ -1021,6 +1001,7 @@ extern void gz_close(int gunzip_pid)
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
free(window);
free(crc_table);
free(window);
free(crc_table);
}
+18 -29
View File
@@ -10,7 +10,7 @@
* very different now (i.e., cleaner, less global variables, etc.)
*
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* Copyright (C) 1999-2002 by Erik Andersen <andersee@debian.org>
*
* Based in part in the tar implementation in sash
* Copyright (c) 1999 by David I. Bell
@@ -459,7 +459,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
error_msg_and_die("Cowardly refusing to create an empty archive");
/* Open the tar file for writing. */
if (!strcmp(tarName, "-"))
if (tarName == NULL)
tbInfo.tarFd = fileno(stdout);
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
@@ -476,9 +476,9 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
/* Read the directory/files and iterate over them one at a time */
while (*argv != NULL) {
if (recursive_action(*argv++, TRUE, FALSE, FALSE,
if (! recursive_action(*argv++, TRUE, FALSE, FALSE,
writeFileToTarball, writeFileToTarball,
(void*) &tbInfo) == FALSE) {
(void*) &tbInfo)) {
errorFlag = TRUE;
}
}
@@ -494,7 +494,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
/* Hang up the tools, close up shop, head home */
close(tarFd);
if (errorFlag == TRUE) {
if (errorFlag) {
error_msg("Error exit delayed from previous errors");
freeHardLinkInfo(&tbInfo.hlInfoHead);
return(FALSE);
@@ -516,14 +516,10 @@ void append_file_list_to_list(char *filename, char ***name_list, int *num_of_ent
{
FILE *src_stream;
char *line;
char *line_ptr;
src_stream = xfopen(filename, "r");
while ((line = get_line_from_file(src_stream)) != NULL) {
line_ptr = last_char_is(line, '\n');
if (line_ptr) {
*line_ptr = '\0';
}
chomp (line);
append_file_to_list(line, name_list, num_of_entries);
free(line);
}
@@ -556,7 +552,7 @@ char **list_and_not_list(char **include_list, char **exclude_list)
exclude_count++;
}
if (found == FALSE) {
if (! found) {
new_include_list = realloc(new_include_list, sizeof(char *) * (include_count + 2));
new_include_list[new_include_count] = include_list[include_count];
new_include_count++;
@@ -573,14 +569,12 @@ char **list_and_not_list(char **include_list, char **exclude_list)
int tar_main(int argc, char **argv)
{
enum untar_funct_e {
/* These are optional */
untar_from_file = 1,
untar_from_stdin = 2,
untar_unzip = 4,
/* This is optional */
untar_unzip = 1,
/* Require one and only one of these */
untar_list = 8,
untar_create = 16,
untar_extract = 32
untar_list = 2,
untar_create = 4,
untar_extract = 8
};
FILE *src_stream = NULL;
@@ -589,7 +583,6 @@ int tar_main(int argc, char **argv)
char **exclude_list = NULL;
char *src_filename = NULL;
char *dst_prefix = NULL;
char *file_list_name = NULL;
int opt;
unsigned short untar_funct = 0;
unsigned short untar_funct_required = 0;
@@ -649,10 +642,8 @@ int tar_main(int argc, char **argv)
break;
case 'f': // archive filename
if (strcmp(optarg, "-") == 0) {
// Untar from stdin to stdout
untar_funct |= untar_from_stdin;
src_filename = NULL;
} else {
untar_funct |= untar_from_file;
src_filename = xstrdup(optarg);
}
break;
@@ -693,14 +684,13 @@ int tar_main(int argc, char **argv)
append_file_to_list(argv[optind], &include_list, &include_list_count);
optind++;
}
if (extract_function & (extract_list | extract_all_to_fs)) {
if (dst_prefix == NULL) {
dst_prefix = xstrdup("./");
}
/* Setup the source of the tar data */
if (untar_funct & untar_from_file) {
if (src_filename != NULL) {
src_stream = xfopen(src_filename, "r");
} else {
src_stream = stdin;
@@ -723,14 +713,14 @@ int tar_main(int argc, char **argv)
int verboseFlag = FALSE;
#ifdef CONFIG_FEATURE_TAR_GZIP
if (untar_funct && untar_unzip) {
if (untar_funct & untar_unzip) {
error_msg_and_die("Creation of compressed tarfile not internally support by tar, pipe to busybox gunzip");
}
#endif // CONFIG_FEATURE_TAR_GZIP
if (extract_function & extract_verbose_list) {
verboseFlag = TRUE;
}
writeTarFile(src_filename, verboseFlag, &argv[argc - 1], include_list);
writeTarFile(src_filename, verboseFlag, include_list, exclude_list);
}
#endif // CONFIG_FEATURE_TAR_CREATE
@@ -742,11 +732,10 @@ int tar_main(int argc, char **argv)
gz_close(gunzip_pid);
}
#endif // CONFIG_FEATURE_TAR_GZIP
#ifdef CONFIG_FEATURE_CLEAN_UP
if (src_filename) {
free(src_filename);
}
if (file_list_name) {
free(file_list_name);
}
#endif
return(EXIT_SUCCESS);
}
+94
View File
@@ -0,0 +1,94 @@
/* vi: set sw=4 ts=4: */
/*
* Mini unzip implementation for busybox
*
* Copyright (C) 2001 by Laurence Anderson
*
* 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 <fcntl.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "unarchive.h"
#include "busybox.h"
extern int unzip_main(int argc, char **argv)
{
FILE *src_stream;
int extract_function = extract_all_to_fs | extract_create_leading_dirs;
char **extract_names = NULL;
char **exclude_names = NULL;
int opt = 0;
int num_of_entries = 0;
int exclude = 0;
char *outdir = "./";
FILE *msgout = stdout;
while ((opt = getopt(argc, argv, "lnopqxd:")) != -1) {
switch (opt) {
case 'l':
extract_function |= extract_verbose_list;
extract_function ^= extract_all_to_fs;
break;
case 'n':
break;
case 'o':
extract_function |= extract_unconditional;
break;
case 'p':
extract_function |= extract_to_stdout;
extract_function ^= extract_all_to_fs;
/* FALLTHROUGH */
case 'q':
msgout = xfopen("/dev/null", "w");
break;
case 'd':
outdir = xstrdup(optarg);
strcat(outdir, "/");
break;
case 'x':
exclude = 1;
break;
}
}
if (optind == argc) {
show_usage();
}
if (*argv[optind] == '-') src_stream = stdin;
else src_stream = xfopen(argv[optind++], "r");
while (optind < argc) {
if (exclude) {
exclude_names = xrealloc(exclude_names, sizeof(char *) * (num_of_entries + 2));
exclude_names[num_of_entries] = xstrdup(argv[optind]);
} else {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
}
num_of_entries++;
if (exclude) exclude_names[num_of_entries] = NULL;
else extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, msgout, &get_header_zip, extract_function, outdir, extract_names, exclude_names);
return EXIT_SUCCESS;
}
+9 -22
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,27 +17,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
TOPDIR :=..
L_TARGET := console-tools.a
obj-y :=
obj-n :=
obj- :=
obj-$(CONFIG_CHVT) += chvt.o
obj-$(CONFIG_CLEAR) += clear.o
obj-$(CONFIG_DEALLOCVT) += deallocvt.o
obj-$(CONFIG_DUMPKMAP) += dumpkmap.o
obj-$(CONFIG_LOADACM) += loadacm.o
obj-$(CONFIG_LOADFONT) += loadfont.o
obj-$(CONFIG_LOADKMAP) += loadkmap.o
obj-$(CONFIG_RESET) += reset.o
obj-$(CONFIG_SETKEYCODES) += setkeycodes.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
TOPDIR:= ../
CONSOLETOOLS_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+40
View File
@@ -0,0 +1,40 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
#
CONSOLETOOLS_AR:=console-tools.a
ifndef $(CONSOLETOOLS_DIR)
CONSOLETOOLS_DIR:=$(TOPDIR)console-tools/
endif
CONSOLETOOLS_DIR-y:=
CONSOLETOOLS_DIR-$(CONFIG_CHVT) += chvt.o
CONSOLETOOLS_DIR-$(CONFIG_CLEAR) += clear.o
CONSOLETOOLS_DIR-$(CONFIG_DEALLOCVT) += deallocvt.o
CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP) += dumpkmap.o
CONSOLETOOLS_DIR-$(CONFIG_LOADACM) += loadacm.o
CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o
CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o
CONSOLETOOLS_DIR-$(CONFIG_RESET) += reset.o
CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
$(AR) -ro $@ $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
+428
View File
@@ -0,0 +1,428 @@
/*
* Calendar implementation for busybox
*
* Copyright (C) 2001 by Steven J. Merrifield <steve@labyrinth.net.au>
*
* See original copyright at the end of this file
*
* 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 <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#ifdef CONFIG_LOCALE_SUPPORT
#include <locale.h>
#endif
#include "busybox.h"
#define THURSDAY 4 /* for reformation */
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
#define FIRST_MISSING_DAY 639787 /* 3 Sep 1752 */
#define NUMBER_MISSING_DAYS 11 /* 11 day correction */
#define MAXDAYS 42 /* max slots in a month array */
#define SPACE -1 /* used in day array */
static int days_in_month[2][13] = {
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
};
int sep1752[MAXDAYS] = {
SPACE, SPACE, 1, 2, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
}, j_sep1752[MAXDAYS] = {
SPACE, SPACE, 245, 246, 258, 259, 260,
261, 262, 263, 264, 265, 266, 267,
268, 269, 270, 271, 272, 273, 274,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
}, empty[MAXDAYS] = {
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
};
char *month_names[12];
char day_headings[] = " ";
char j_day_headings[] = " ";
/* leap year -- account for gregorian reformation in 1752 */
#define leap_year(yr) \
((yr) <= 1752 ? !((yr) % 4) : \
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
/* number of centuries since 1700, not inclusive */
#define centuries_since_1700(yr) \
((yr) > 1700 ? (yr) / 100 - 17 : 0)
/* number of centuries since 1700 whose modulo of 400 is 0 */
#define quad_centuries_since_1700(yr) \
((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
/* number of leap years between year 1 and this year, not inclusive */
#define leap_years_since_year_1(yr) \
((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
int julian;
void ascii_day __P((char *, int));
void center __P((char *, int, int));
void day_array __P((int, int, int *));
int day_in_week __P((int, int, int));
int day_in_year __P((int, int, int));
void j_yearly __P((int));
void monthly __P((int, int));
void trim_trailing_spaces __P((char *));
void yearly __P((int));
int cal_main(int argc, char **argv)
{
struct tm *local_time;
static struct tm zero_tm;
time_t now;
int ch, month, year, yflag, i;
char buf[40];
#ifdef CONFIG_LOCALE_SUPPORT
setlocale(LC_TIME, "");
#endif
yflag = 0;
while ((ch = getopt(argc, argv, "jy")) != -1)
switch(ch) {
case 'j':
julian = 1;
break;
case 'y':
yflag = 1;
break;
default:
show_usage();
}
argc -= optind;
argv += optind;
month = 0;
switch(argc) {
case 2:
if ((month = atoi(*argv++)) < 1 || month > 12)
error_msg_and_die("Illegal month value: use 1-12");
/* FALLTHROUGH */
case 1:
if ((year = atoi(*argv)) < 1 || year > 9999)
error_msg_and_die("Illegal year value: use 1-9999");
break;
case 0:
time(&now);
local_time = localtime(&now);
year = local_time->tm_year + 1900;
if (!yflag)
month = local_time->tm_mon + 1;
break;
default:
show_usage();
}
for (i = 0; i < 12; i++) {
zero_tm.tm_mon = i;
strftime(buf, sizeof(buf), "%B", &zero_tm);
month_names[i] = xstrdup(buf);
}
for (i = 0; i < 7; i++) {
zero_tm.tm_wday = i;
strftime(buf, sizeof(buf), "%a", &zero_tm);
strncpy(day_headings + i * 3, buf, 2);
strncpy(j_day_headings + i * 4 + 1, buf, 2);
}
if (month)
monthly(month, year);
else if (julian)
j_yearly(year);
else
yearly(year);
exit(0);
}
#define DAY_LEN 3 /* 3 spaces per day */
#define J_DAY_LEN 4 /* 4 spaces per day */
#define WEEK_LEN 20 /* 7 * 3 - one space at the end */
#define J_WEEK_LEN 27 /* 7 * 4 - one space at the end */
#define HEAD_SEP 2 /* spaces between day headings */
#define J_HEAD_SEP 2
void monthly(int month, int year)
{
int col, row, len, days[MAXDAYS];
char *p, lineout[30];
day_array(month, year, days);
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
printf("%*s%s\n%s\n",
((julian ? J_WEEK_LEN : WEEK_LEN) - len) / 2, "",
lineout, julian ? j_day_headings : day_headings);
for (row = 0; row < 6; row++) {
for (col = 0, p = lineout; col < 7; col++,
p += julian ? J_DAY_LEN : DAY_LEN)
ascii_day(p, days[row * 7 + col]);
*p = '\0';
trim_trailing_spaces(lineout);
printf("%s\n", lineout);
}
}
void j_yearly(int year)
{
int col, *dp, i, month, row, which_cal;
int days[12][MAXDAYS];
char *p, lineout[80];
sprintf(lineout, "%d", year);
center(lineout, J_WEEK_LEN * 2 + J_HEAD_SEP, 0);
printf("\n\n");
for (i = 0; i < 12; i++)
day_array(i + 1, year, days[i]);
memset(lineout, ' ', sizeof(lineout) - 1);
lineout[sizeof(lineout) - 1] = '\0';
for (month = 0; month < 12; month += 2) {
center(month_names[month], J_WEEK_LEN, J_HEAD_SEP);
center(month_names[month + 1], J_WEEK_LEN, 0);
printf("\n%s%*s%s\n", j_day_headings, J_HEAD_SEP, "",
j_day_headings);
for (row = 0; row < 6; row++) {
for (which_cal = 0; which_cal < 2; which_cal++) {
p = lineout + which_cal * (J_WEEK_LEN + 2);
dp = &days[month + which_cal][row * 7];
for (col = 0; col < 7; col++, p += J_DAY_LEN)
ascii_day(p, *dp++);
}
*p = '\0';
trim_trailing_spaces(lineout);
printf("%s\n", lineout);
}
}
printf("\n");
}
void yearly(int year)
{
int col, *dp, i, month, row, which_cal;
int days[12][MAXDAYS];
char *p, lineout[80];
sprintf(lineout, "%d", year);
center(lineout, WEEK_LEN * 3 + HEAD_SEP * 2, 0);
printf("\n\n");
for (i = 0; i < 12; i++)
day_array(i + 1, year, days[i]);
memset(lineout, ' ', sizeof(lineout) - 1);
lineout[sizeof(lineout) - 1] = '\0';
for (month = 0; month < 12; month += 3) {
center(month_names[month], WEEK_LEN, HEAD_SEP);
center(month_names[month + 1], WEEK_LEN, HEAD_SEP);
center(month_names[month + 2], WEEK_LEN, 0);
printf("\n%s%*s%s%*s%s\n", day_headings, HEAD_SEP,
"", day_headings, HEAD_SEP, "", day_headings);
for (row = 0; row < 6; row++) {
for (which_cal = 0; which_cal < 3; which_cal++) {
p = lineout + which_cal * (WEEK_LEN + 2);
dp = &days[month + which_cal][row * 7];
for (col = 0; col < 7; col++, p += DAY_LEN)
ascii_day(p, *dp++);
}
*p = '\0';
trim_trailing_spaces(lineout);
printf("%s\n", lineout);
}
}
printf("\n");
}
/*
* day_array --
* Fill in an array of 42 integers with a calendar. Assume for a moment
* that you took the (maximum) 6 rows in a calendar and stretched them
* out end to end. You would have 42 numbers or spaces. This routine
* builds that array for any month from Jan. 1 through Dec. 9999.
*/
void day_array(int month, int year, int *days)
{
int day, dw, dm;
if ((month == 9) && (year == 1752)) {
memmove(days,
julian ? j_sep1752 : sep1752, MAXDAYS * sizeof(int));
return;
}
memmove(days, empty, MAXDAYS * sizeof(int));
dm = days_in_month[leap_year(year)][month];
dw = day_in_week(1, month, year);
day = julian ? day_in_year(1, month, year) : 1;
while (dm--)
days[dw++] = day++;
}
/*
* day_in_year --
* return the 1 based day number within the year
*/
int day_in_year(int day, int month, int year)
{
int i, leap;
leap = leap_year(year);
for (i = 1; i < month; i++)
day += days_in_month[leap][i];
return (day);
}
/*
* day_in_week
* return the 0 based day number for any date from 1 Jan. 1 to
* 31 Dec. 9999. Assumes the Gregorian reformation eliminates
* 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all
* missing days.
*/
int day_in_week(int day, int month, int year)
{
long temp;
temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1)
+ day_in_year(day, month, year);
if (temp < FIRST_MISSING_DAY)
return ((temp - 1 + SATURDAY) % 7);
if (temp >= (FIRST_MISSING_DAY + NUMBER_MISSING_DAYS))
return (((temp - 1 + SATURDAY) - NUMBER_MISSING_DAYS) % 7);
return (THURSDAY);
}
void ascii_day(char *p, int day)
{
int display, val;
static char *aday[] = {
"",
" 1", " 2", " 3", " 4", " 5", " 6", " 7",
" 8", " 9", "10", "11", "12", "13", "14",
"15", "16", "17", "18", "19", "20", "21",
"22", "23", "24", "25", "26", "27", "28",
"29", "30", "31",
};
if (day == SPACE) {
memset(p, ' ', julian ? J_DAY_LEN : DAY_LEN);
return;
}
if (julian) {
if ((val = day / 100) != 0) {
day %= 100;
*p++ = val + '0';
display = 1;
} else {
*p++ = ' ';
display = 0;
}
val = day / 10;
if (val || display)
*p++ = val + '0';
else
*p++ = ' ';
*p++ = day % 10 + '0';
} else {
*p++ = aday[day][0];
*p++ = aday[day][1];
}
*p = ' ';
}
void trim_trailing_spaces(char *s)
{
char *p;
for (p = s; *p; ++p)
continue;
while (p > s && isspace(*--p))
continue;
if (p > s)
++p;
*p = '\0';
}
void center(char *str, int len, int separate)
{
len -= strlen(str);
printf("%*s%s%*s", len / 2, "", str, len / 2 + len % 2, "");
if (separate)
printf("%*s", separate, "");
}
/*
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kim Letkeman.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+1 -1
View File
@@ -37,7 +37,7 @@ extern int cat_main(int argc, char **argv)
while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) {
print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) {
} else if (! print_file_by_name(*argv)) {
status = EXIT_FAILURE;
}
}
+2 -2
View File
@@ -72,8 +72,8 @@ int chgrp_main(int argc, char **argv)
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
if (! recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL)) {
return EXIT_FAILURE;
}
}
+3 -3
View File
@@ -58,7 +58,7 @@ int chmod_main(int argc, char **argv)
if (argc > optind && argc > 2 && argv[optind]) {
/* Parse the specified mode */
mode_t mode;
if (parse_mode(argv[optind], &mode) == FALSE) {
if (! parse_mode(argv[optind], &mode)) {
error_msg_and_die( "unknown mode: %s", argv[optind]);
}
} else {
@@ -67,8 +67,8 @@ int chmod_main(int argc, char **argv)
/* Ok, ready to do the deed now */
for (i = optind + 1; i < argc; i++) {
if (recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction,
fileAction, argv[optind]) == FALSE) {
if (! recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction,
fileAction, argv[optind])) {
return EXIT_FAILURE;
}
}
+2 -2
View File
@@ -94,8 +94,8 @@ int chown_main(int argc, char **argv)
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
if (! recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL)) {
return EXIT_FAILURE;
}
}
+31 -6
View File
@@ -3,7 +3,7 @@
* Mini dd implementation for busybox
*
*
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
* Copyright (C) 2000,2001 Matt Kraai
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -45,7 +46,7 @@ static const struct suffix_mult dd_suffixes[] = {
int dd_main(int argc, char **argv)
{
int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE, noerror = FALSE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
@@ -74,6 +75,9 @@ int dd_main(int argc, char **argv)
} else if (strncmp("sync", buf, 4) == 0) {
sync_flag = TRUE;
buf += 4;
} else if (strncmp("noerror", buf, 7) == 0) {
noerror = TRUE;
buf += 7;
} else {
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
}
@@ -106,8 +110,13 @@ int dd_main(int argc, char **argv)
perror_msg_and_die("%s", outfile);
if (seek && trunc) {
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
if (ftruncate(ofd, seek * bs) < 0) {
struct stat st;
if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
S_ISDIR (st.st_mode))
perror_msg_and_die("%s", outfile);
}
}
} else {
ofd = STDOUT_FILENO;
@@ -125,9 +134,19 @@ int dd_main(int argc, char **argv)
}
while (in_full + in_part != count) {
if (noerror) {
/* Pre-zero the buffer when doing the noerror thing */
memset(buf, '\0', bs);
}
n = safe_read(ifd, buf, bs);
if (n < 0)
perror_msg_and_die("%s", infile);
if (n < 0) {
if (noerror) {
n = bs;
perror_msg("%s", infile);
} else {
perror_msg_and_die("%s", infile);
}
}
if (n == 0)
break;
if (n == bs)
@@ -147,6 +166,12 @@ int dd_main(int argc, char **argv)
out_part++;
}
if (close (ifd) < 0)
perror_msg_and_die("%s", infile);
if (close (ofd) < 0)
perror_msg_and_die("%s", outfile);
fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
+12 -74
View File
@@ -4,6 +4,7 @@
*
* Copyright (C) 1999,2000,2001 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
* Copyright (C) 2002 Edward Betts <edward@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,6 +41,8 @@ typedef void (Display) (long, char *);
static int du_depth = 0;
static int count_hardlinks = 0;
static int one_file_system = 0;
static dev_t dir_dev = 0;
static Display *print;
@@ -59,78 +62,6 @@ static void print_summary(long size, char *filename)
}
}
#define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE)
typedef struct ino_dev_hash_bucket_struct {
struct ino_dev_hash_bucket_struct *next;
ino_t ino;
dev_t dev;
char name[1];
} ino_dev_hashtable_bucket_t;
static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
/*
* Return 1 if statbuf->st_ino && statbuf->st_dev are recorded in
* `ino_dev_hashtable', else return 0
*
* If NAME is a non-NULL pointer to a character pointer, and there is
* a match, then set *NAME to the value of the name slot in that
* bucket.
*/
static int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name)
{
ino_dev_hashtable_bucket_t *bucket;
bucket = ino_dev_hashtable[hash_inode(statbuf->st_ino)];
while (bucket != NULL) {
if ((bucket->ino == statbuf->st_ino) &&
(bucket->dev == statbuf->st_dev))
{
if (name) *name = bucket->name;
return 1;
}
bucket = bucket->next;
}
return 0;
}
/* Add statbuf to statbuf hash table */
static void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name)
{
int i;
size_t s;
ino_dev_hashtable_bucket_t *bucket;
i = hash_inode(statbuf->st_ino);
s = name ? strlen(name) : 0;
bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + s);
bucket->ino = statbuf->st_ino;
bucket->dev = statbuf->st_dev;
if (name)
strcpy(bucket->name, name);
else
bucket->name[0] = '\0';
bucket->next = ino_dev_hashtable[i];
ino_dev_hashtable[i] = bucket;
}
/* Clear statbuf hash table */
static void reset_ino_dev_hashtable(void)
{
int i;
ino_dev_hashtable_bucket_t *bucket;
for (i = 0; i < HASH_SIZE; i++) {
while (ino_dev_hashtable[i] != NULL) {
bucket = ino_dev_hashtable[i]->next;
free(ino_dev_hashtable[i]);
ino_dev_hashtable[i] = bucket;
}
}
}
/* tiny recursive du */
static long du(char *filename)
{
@@ -141,6 +72,10 @@ static long du(char *filename)
perror_msg("%s", filename);
return 0;
}
if (du_depth == 0)
dir_dev = statbuf.st_dev;
else if (one_file_system && dir_dev != statbuf.st_dev)
return 0;
du_depth++;
sum = (statbuf.st_blocks >> 1);
@@ -205,7 +140,7 @@ int du_main(int argc, char **argv)
print = print_normal;
/* parse argv[] */
while ((c = getopt(argc, argv, "sl"
while ((c = getopt(argc, argv, "slx"
#ifdef CONFIG_FEATURE_HUMAN_READABLE
"hm"
#endif
@@ -217,6 +152,9 @@ int du_main(int argc, char **argv)
case 'l':
count_hardlinks = 1;
break;
case 'x':
one_file_system = 1;
break;
#ifdef CONFIG_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
@@ -246,7 +184,7 @@ int du_main(int argc, char **argv)
return status;
}
/* $Id: du.c,v 1.51 2001/10/24 04:59:27 andersen Exp $ */
/* $Id: du.c,v 1.53 2002/04/06 23:16:44 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
+1 -1
View File
@@ -119,7 +119,7 @@ extern int ln_main(int argc, char **argv)
status = EXIT_FAILURE;
optind++;
}
exit(status);
return status;
}
/*
+69 -9
View File
@@ -145,6 +145,14 @@ static const int SPLIT_SUBDIR = 2;
#ifdef CONFIG_FEATURE_LS_FILETYPES
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
#endif
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
#ifdef CONFIG_FEATURE_LS_COLOR
static int show_color = 0;
#define COLOR(mode) ("\000\043\043\043\042\000\043\043"\
"\000\000\044\000\043\000\000\040" [TYPEINDEX(mode)])
#define ATTR(mode) ("\00\00\01\00\01\00\01\00"\
"\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)])
#endif
/*
* a directory entry and its stat info are stored here
@@ -193,7 +201,7 @@ static unsigned long ls_disp_hr = 0;
static int my_stat(struct dnode *cur)
{
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (follow_links) {
if (stat(cur->fullname, &cur->dstat)) {
perror_msg("%s", cur->fullname);
status = EXIT_FAILURE;
@@ -221,6 +229,31 @@ static void newline(void)
}
}
/*----------------------------------------------------------------------*/
#ifdef CONFIG_FEATURE_LS_COLOR
static char fgcolor(mode_t mode)
{
/* Check wheter the file is existing (if so, color it red!) */
if ( errno == ENOENT ) {
errno = 0;
return '\037';
}
if ( LIST_EXEC && S_ISREG( mode )
&& ( mode & ( S_IXUSR | S_IXGRP | S_IXOTH ) ) )
return COLOR(0xF000); /* File is executable ... */
return COLOR(mode);
}
/*----------------------------------------------------------------------*/
static char bgcolor(mode_t mode)
{
if ( LIST_EXEC && S_ISREG( mode )
&& ( mode & ( S_IXUSR | S_IXGRP | S_IXOTH ) ) )
return ATTR(0xF000); /* File is executable ... */
return ATTR(mode);
}
#endif
/*----------------------------------------------------------------------*/
#ifdef CONFIG_FEATURE_LS_FILETYPES
static char append_char(mode_t mode)
@@ -443,12 +476,7 @@ static void showfiles(struct dnode **dn, int nfiles)
if (column_width < len)
column_width= len;
}
if (column_width >= 6)
ncols = (int)(terminal_width / (column_width + COLUMN_GAP));
else {
ncols = 1;
column_width = COLUMN_WIDTH;
}
ncols = (int)(terminal_width / (column_width + COLUMN_GAP));
#else
ncols= TERMINAL_WIDTH;
#endif
@@ -581,7 +609,9 @@ static struct dnode **list_dir(char *path)
static int list_single(struct dnode *dn)
{
int i;
#ifdef CONFIG_FEATURE_LS_USERNAME
char scratch[BUFSIZ + 1];
#endif
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
char *filetime;
time_t ttime, age;
@@ -685,18 +715,43 @@ static int list_single(struct dnode *dn)
break;
#endif
case LIST_FILENAME:
#ifdef CONFIG_FEATURE_LS_COLOR
errno = 0;
if (show_color && !lstat(dn->fullname, &info)) {
printf( "\033[%d;%dm", bgcolor(info.st_mode),
fgcolor(info.st_mode) );
}
#endif
printf("%s", dn->name);
#ifdef CONFIG_FEATURE_LS_COLOR
if (show_color) {
printf( "\033[0m" );
}
#endif
column += strlen(dn->name);
break;
case LIST_SYMLINK:
if (S_ISLNK(dn->dstat.st_mode)) {
char *lpath = xreadlink(dn->fullname);
if (lpath) {
printf(" -> %s", lpath);
#ifdef CONFIG_FEATURE_LS_FILETYPES
printf(" -> ");
#if defined(BB_FEATURE_LS_FILETYPES) || defined(CONFIG_FEATURE_LS_COLOR)
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
}
#endif
#ifdef CONFIG_FEATURE_LS_COLOR
if (show_color) {
errno = 0;
printf( "\033[%d;%dm", bgcolor(info.st_mode),
fgcolor(info.st_mode) );
}
#endif
printf("%s", lpath);
#ifdef CONFIG_FEATURE_LS_COLOR
if (show_color) {
printf( "\033[0m" );
}
#endif
column += strlen(lpath) + 4;
free(lpath);
@@ -750,6 +805,11 @@ extern int ls_main(int argc, char **argv)
#endif
nfiles=0;
#ifdef CONFIG_FEATURE_LS_COLOR
if (isatty(fileno(stdout)))
show_color = 1;
#endif
/* process options */
while ((opt = getopt(argc, argv, "1AaCdgilnsx"
#ifdef CONFIG_FEATURE_AUTOWIDTH
+1
View File
@@ -3,6 +3,7 @@
* Mini mknod implementation for busybox
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
* Copyright (C) 1999-2002 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
-1
View File
@@ -2,7 +2,6 @@
/*
* Mini pwd implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
-1
View File
@@ -2,7 +2,6 @@
/*
* Mini sleep implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
-1
View File
@@ -2,7 +2,6 @@
/*
* Mini sync implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
+6 -4
View File
@@ -53,12 +53,14 @@ extern int touch_main(int argc, char **argv)
}
while (argc > 0) {
fd = open(*argv, (create == FALSE) ? O_RDWR : O_RDWR | O_CREAT,
fd = open(*argv, create ? O_RDWR | O_CREAT : O_RDWR,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0) {
if (create == FALSE && errno == ENOENT)
return EXIT_SUCCESS;
else {
if (! create && errno == ENOENT) {
argc--;
argv++;
continue;
} else {
perror_msg_and_die("%s", *argv);
}
}
+51 -95
View File
@@ -31,126 +31,82 @@
/* Busyboxed by Erik Andersen */
/* Further size reductions by Glenn McGrath and Manuel Novoa III. */
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <sys/utsname.h>
#if defined (HAVE_SYSINFO) && defined (HAVE_SYS_SYSTEMINFO_H)
# include <sys/systeminfo.h>
#endif
#include <getopt.h>
#include "busybox.h"
static void print_element(unsigned int mask, char *element);
/* Values that are bitwise or'd into `toprint'. */
/* Operating system name. */
static const int PRINT_SYSNAME = 1;
/* Node name on a communications network. */
static const int PRINT_NODENAME = 2;
/* Operating system release. */
static const int PRINT_RELEASE = 4;
/* Operating system version. */
static const int PRINT_VERSION = 8;
/* Machine hardware name. */
static const int PRINT_MACHINE = 16;
/* Host processor type. */
static const int PRINT_PROCESSOR = 32;
/* Mask indicating which elements of the name to print. */
static unsigned char toprint;
typedef struct {
struct utsname name;
char processor[8]; /* for "unknown" */
} uname_info_t;
static const char options[] = "snrvmpa";
static const char flags[] = "\x01\x02\x04\x08\x10\x20\x3f";
static const unsigned short int utsname_offset[] = {
offsetof(uname_info_t,name.sysname),
offsetof(uname_info_t,name.nodename),
offsetof(uname_info_t,name.release),
offsetof(uname_info_t,name.version),
offsetof(uname_info_t,name.machine),
offsetof(uname_info_t,processor)
};
int uname_main(int argc, char **argv)
{
struct utsname name;
char processor[256];
uname_info_t uname_info;
#if defined(__sparc__) && defined(__linux__)
char *fake_sparc = getenv("FAKE_SPARC");
#endif
toprint = 0;
const unsigned short int *delta;
int opt;
char toprint = 0;
/* Parse any options */
//fprintf(stderr, "argc=%d, argv=%s\n", argc, *argv);
while (--argc > 0 && **(++argv) == '-') {
while (*(++(*argv))) {
switch (**argv) {
case 's':
toprint |= PRINT_SYSNAME;
break;
case 'n':
toprint |= PRINT_NODENAME;
break;
case 'r':
toprint |= PRINT_RELEASE;
break;
case 'v':
toprint |= PRINT_VERSION;
break;
case 'm':
toprint |= PRINT_MACHINE;
break;
case 'p':
toprint |= PRINT_PROCESSOR;
break;
case 'a':
toprint = (PRINT_SYSNAME | PRINT_NODENAME | PRINT_RELEASE |
PRINT_PROCESSOR | PRINT_VERSION |
PRINT_MACHINE);
break;
default:
show_usage();
}
while ((opt = getopt(argc, argv, options)) != -1) {
const char *p = strchr(options,opt);
if (p == NULL) {
show_usage();
}
toprint |= flags[(int)(p-options)];
}
if (toprint == 0)
toprint = PRINT_SYSNAME;
if (toprint == 0) {
toprint = flags[0]; /* sysname */
}
if (uname(&name) == -1)
perror_msg("cannot get system name");
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
perror_msg("cannot get processor type");
}
#else
strcpy(processor, "unknown");
#endif
if (uname(&uname_info.name) == -1) {
error_msg_and_die("cannot get system name");
}
#if defined(__sparc__) && defined(__linux__)
if (fake_sparc != NULL
&& (fake_sparc[0] == 'y'
|| fake_sparc[0] == 'Y')) strcpy(name.machine, "sparc");
if ((fake_sparc != NULL)
&& ((fake_sparc[0] == 'y')
|| (fake_sparc[0] == 'Y'))) {
strcpy(uname_info.name.machine, "sparc");
}
#endif
print_element(PRINT_SYSNAME, name.sysname);
print_element(PRINT_NODENAME, name.nodename);
print_element(PRINT_RELEASE, name.release);
print_element(PRINT_VERSION, name.version);
print_element(PRINT_MACHINE, name.machine);
print_element(PRINT_PROCESSOR, processor);
strcpy(uname_info.processor, "unknown");
delta=utsname_offset;
do {
if (toprint & 1) {
printf(((char *)(&uname_info)) + *delta);
if (toprint > 1) {
putchar(' ');
}
}
++delta;
} while (toprint >>= 1);
putchar('\n');
return EXIT_SUCCESS;
}
/* If the name element set in MASK is selected for printing in `toprint',
print ELEMENT; then print a space unless it is the last element to
be printed, in which case print a newline. */
static void print_element(unsigned int mask, char *element)
{
if (toprint & mask) {
toprint &= ~mask;
printf("%s%c", element, toprint ? ' ' : '\n');
}
}
-1
View File
@@ -2,7 +2,6 @@
/*
* Mini usleep implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
+79 -57
View File
@@ -26,40 +26,59 @@
#include <stdlib.h>
#include "busybox.h"
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
enum print_e {
print_lines = 1,
print_words = 2,
print_chars = 4,
print_length = 8
};
static void print_counts(int lines, int words, int chars, int length,
const char *name)
static unsigned int total_lines = 0;
static unsigned int total_words = 0;
static unsigned int total_chars = 0;
static unsigned int max_length = 0;
static char print_type = 0;
static void print_counts(const unsigned int lines, const unsigned int words,
const unsigned int chars, const unsigned int length, const char *name)
{
char const *space = "";
int output = 0;
if (print_lines) {
if (print_type & print_lines) {
printf("%7d", lines);
space = " ";
output++;
}
if (print_words) {
printf("%s%7d", space, words);
space = " ";
if (print_type & print_words) {
if (output++)
putchar(' ');
printf("%7d", words);
}
if (print_chars) {
printf("%s%7d", space, chars);
space = " ";
if (print_type & print_chars) {
if (output++)
putchar(' ');
printf("%7d", chars);
}
if (print_length)
printf("%s%7d", space, length);
if (*name)
if (print_type & print_length) {
if (output++)
putchar(' ');
printf("%7d", length);
}
if (*name) {
printf(" %s", name);
}
putchar('\n');
}
static void wc_file(FILE * file, const char *name)
{
int lines, words, chars, length;
int in_word = 0, linepos = 0;
unsigned int lines = 0;
unsigned int words = 0;
unsigned int chars = 0;
unsigned int length = 0;
unsigned int linepos = 0;
char in_word = 0;
int c;
lines = words = chars = length = 0;
while ((c = getc(file)) != EOF) {
chars++;
switch (c) {
@@ -77,7 +96,7 @@ static void wc_file(FILE * file, const char *name)
case ' ':
linepos++;
case '\v':
word_separator:
word_separator:
if (in_word) {
in_word = 0;
words++;
@@ -89,68 +108,71 @@ static void wc_file(FILE * file, const char *name)
break;
}
}
if (linepos > length)
if (linepos > length) {
length = linepos;
if (in_word)
}
if (in_word) {
words++;
}
print_counts(lines, words, chars, length, name);
total_lines += lines;
total_words += words;
total_chars += chars;
if (length > max_length)
if (length > max_length) {
max_length = length;
fclose(file);
fflush(stdout);
}
}
int wc_main(int argc, char **argv)
{
FILE *file;
unsigned int num_files_counted = 0;
int opt, status = EXIT_SUCCESS;
total_lines = total_words = total_chars = max_length = 0;
print_lines = print_words = print_chars = print_length = 0;
int opt;
while ((opt = getopt(argc, argv, "clLw")) > 0) {
switch (opt) {
switch (opt) {
case 'c':
print_chars = 1;
print_type |= print_chars;
break;
case 'l':
print_lines = 1;
print_type |= print_lines;
break;
case 'L':
print_length = 1;
print_type |= print_length;
break;
case 'w':
print_words = 1;
print_type |= print_words;
break;
default:
show_usage();
}
}
if (!print_lines && !print_words && !print_chars && !print_length)
print_lines = print_words = print_chars = 1;
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
wc_file(stdin, "");
return EXIT_SUCCESS;
} else {
while (optind < argc) {
if ((file = wfopen(argv[optind], "r")) != NULL)
wc_file(file, argv[optind]);
else
status = EXIT_FAILURE;
num_files_counted++;
optind++;
}
}
if (num_files_counted > 1)
print_counts(total_lines, total_words, total_chars,
max_length, "total");
if (print_type == 0) {
print_type = print_lines | print_words | print_chars;
}
return status;
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
wc_file(stdin, "");
} else {
unsigned short num_files_counted = 0;
while (optind < argc) {
if (print_type == print_chars) {
struct stat statbuf;
stat(argv[optind], &statbuf);
print_counts(0, 0, statbuf.st_size, 0, argv[optind]);
total_chars += statbuf.st_size;
} else {
FILE *file;
file = xfopen(argv[optind], "r");
wc_file(file, argv[optind]);
fclose(file);
}
optind++;
num_files_counted++;
}
if (num_files_counted > 1) {
print_counts(total_lines, total_words, total_chars, max_length, "total");
}
}
return(EXIT_SUCCESS);
}
+85
View File
@@ -0,0 +1,85 @@
/* vi: set sw=4 ts=4: */
/*----------------------------------------------------------------------
* Mini who is used to display user name, login time,
* idle time and host name.
*
* Author: Da Chen <dchen@ayrnetworks.com>
*
* This is a free document; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation:
* http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2002 AYR Networks, Inc.
*----------------------------------------------------------------------
*/
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <utmp.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <busybox.h>
extern int who_main(int argc, char **argv)
{
struct utmp *ut;
struct stat st;
int devlen, len;
time_t now, idle;
if (argc > 1)
show_usage();
setutent();
devlen = sizeof("/dev/") - 1;
printf("USER TTY IDLE FROM HOST\n");
while ((ut = getutent()) != NULL) {
char name[40];
if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) {
len = strlen(ut->ut_line);
if (ut->ut_line[0] == '/') {
strncpy(name, ut->ut_line, len);
name[len] = '\0';
strcpy(ut->ut_line, ut->ut_line + devlen);
} else {
strcpy(name, "/dev/");
strncpy(name+devlen, ut->ut_line, len);
name[devlen+len] = '\0';
}
printf("%-10s %-8s ", ut->ut_user, ut->ut_line);
if (stat(name, &st) == 0) {
now = time(NULL);
idle = now - st.st_atime;
if (idle < 60)
printf("00:00m ");
else if (idle < (60 * 60))
printf("00:%02dm ", (int)(idle / 60));
else if (idle < (24 * 60 * 60))
printf("%02d:%02dm ", (int)(idle / (60 * 60)),
(int)(idle % (60 * 60)) / 60);
else if (idle < (24 * 60 * 60 * 365))
printf("%03ddays ", (int)(idle / (24 * 60 * 60)));
else
printf("%02dyears ", (int) (idle / (24 * 60 * 60 * 365)));
} else
printf("%-8s ", "?");
printf("%-12.12s %s\n", ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host);
}
}
endutent();
return 0;
}
+2 -2
View File
@@ -1,7 +1,7 @@
This package was debianized by Erik Andersen <andersee@debian.org> on
Sun, 18 Jun 2000 23:31:02 -0600
It was downloaded from ftp://ftp.lineo.com/pub/busybox
HomePage is at: http://busybox.lineo.com/
It was downloaded from ftp://ftp.busybox.net/busybox
HomePage is at: http://busybox.net/
Copyright: GPL
+6 -6
View File
@@ -42,8 +42,8 @@ install: build
#(cd $(bbbd); $(MAKE) "CONFIG_SRC_DIR=../../" "PREFIX=../../$(bb)" install)
mkdir -p $(bb)/bin/
cp $(bbbd)/busybox $(bb)/bin/busybox
mkdir -p $(bb)/usr/share/doc/busybox/busybox.lineo.com
cp $(bbbd)/docs/busybox.lineo.com/BusyBox.html $(bb)/usr/share/doc/busybox/busybox.lineo.com/
mkdir -p $(bb)/usr/share/doc/busybox/busybox.net
cp $(bbbd)/docs/busybox.net/BusyBox.html $(bb)/usr/share/doc/busybox/busybox.net/
mkdir -p $(bb)/usr/share/man/man1
cp $(bbbd)/docs/BusyBox.1 $(bb)/usr/share/man/man1/busybox.1
@@ -67,8 +67,8 @@ install-static: build
#(cd $(bbsbd); $(MAKE) "CONFIG_SRC_DIR=../../" "PREFIX=../../$(bbs)" install)
mkdir -p $(bbs)/bin/
cp $(bbsbd)/busybox $(bbs)/bin/busybox
mkdir -p $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com
cp $(bbsbd)/docs/busybox.lineo.com/BusyBox.html $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/
mkdir -p $(bbs)/usr/share/doc/busybox-static/busybox.net
cp $(bbsbd)/docs/busybox.net/BusyBox.html $(bbs)/usr/share/doc/busybox-static/busybox.net/
mkdir -p $(bbs)/usr/share/man/man1/
cp $(bbsbd)/docs/BusyBox.1 $(bbs)/usr/share/man/man1/busybox.1
@@ -130,7 +130,7 @@ busybox: install
dh_installdirs
dh_installdocs -p$@ $(bbbd)/docs/BusyBox.txt \
$(bbbd)/docs/BusyBox.html docs/style-guide.txt \
docs/busybox.lineo.com AUTHORS README TODO
docs/busybox.net AUTHORS README TODO
rm -rf `find $(bb) -name CVS`
rm -f `find $(bb) -name .cvsignore`
dh_installchangelogs -p$@ Changelog
@@ -152,7 +152,7 @@ busybox-static: do_static
dh_installdirs
dh_installdocs -p$@ $(bbsbd)/docs/BusyBox.txt \
$(bbsbd)/docs/BusyBox.html docs/style-guide.txt \
docs/busybox.lineo.com AUTHORS README TODO
docs/busybox.net AUTHORS README TODO
rm -rf `find $(bbs) -name CVS`
rm -f `find $(bbs) -name .cvsignore`
dh_installchangelogs -p$@ Changelog
+10 -1
View File
@@ -22,6 +22,7 @@
static int start = 0;
static int stop = 0;
static int fork_before_exec = 0;
static int signal_nr = 15;
static int user_id = -1;
static const char *userspec = NULL;
@@ -55,7 +56,7 @@ parse_options(int argc, char * const *argv)
int c;
for (;;) {
c = getopt (argc, argv, "a:n:s:u:x:KS");
c = getopt (argc, argv, "a:n:s:u:x:KSb");
if (c == EOF)
break;
switch (c) {
@@ -81,6 +82,9 @@ parse_options(int argc, char * const *argv)
case 'x':
execname = optarg;
break;
case 'b':
fork_before_exec = 1;
break;
default:
show_usage();
}
@@ -255,6 +259,11 @@ start_stop_daemon_main(int argc, char **argv)
return EXIT_SUCCESS;
}
*--argv = startas;
if (fork_before_exec) {
if (daemon(0, 0) == -1)
perror_msg_and_die ("unable to fork");
}
setsid();
execv(startas, argv);
perror_msg_and_die ("unable to start %s", startas);
}
+1
View File
@@ -1 +1,2 @@
BusyBox.html
busybox.tar.gz
+136
View File
@@ -0,0 +1,136 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<title>BusyBox Anonymous CVS Instructions</title>
</HEAD>
<body text="#000000" alink="#660000" link="#660000" bgcolor="#dee2de" vlink="#660000">
<basefont face="lucida, helvetica, arial" size="3">
<H3>Accessing the Busybox CVS Repository</H3>
<CENTER>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2>
<TR>
<td bgcolor="#000000">
<FONT FACE="lucida, helvetica" COLOR="#ccccc0">
<B>B&nbsp;u&nbsp;s&nbsp;y&nbsp;B&nbsp;o&nbsp;x</B>
</FONT>
</TD>
</TR>
</TABLE>
<a href="/"><IMG SRC="images/busybox2.jpg" alt="BusyBox" border="0" width="360" height="230"></a><BR>
</CENTER>
<TABLE WIDTH="95%" CELLSPACING=1 CELLPADDING=4 BORDER=1>
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="intro"> <BIG><B>
Anonymous CVS
</B></BIG></A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
We allow anonymous (read-only) CVS access to everyone. The first command you
need to run for anonymous CVS access is:
<pre>
cvs -d:pserver:anonymous@busybox.net:/var/cvs login</pre>
<p>
CVS will prompt you for a password. Just press the Enter key (there is no
password for anonymous access). This step only needs to be done once, the first
time you attempt to access CVS.
<p>
Once the login is complete, you can then check the list of available
CVS modules by running the following command (all on one line):
<pre>
cvs -z3 -d:pserver:anonymous@busybox.net:/var/cvs co -c </pre>
<p>
If you wish, you can then check out a local copy of any of the
available modules. The following is an example of how to grab
a copy of busybox and tinylogin:
<pre>
cvs -z3 -d:pserver:anonymous@busybox.net:/var/cvs co -P busybox tinylogin</pre>
This will create a directory called <b>busybox</b> and a directory called
<b>tinylogin</b> in the current directory. These directories contain the
latest and greatest source code for busybox and tinylogin.
<p>
I usually create a ~/.cvsrc file with the following things in it, and I
recommend you should use the same:
<pre>
-z3
update -dP
rdiff -u
diff -ubBwpN
checkout -P</pre>
<p>
Once you've checked out a copy of the source tree, you can update your
source tree at any time so it is in sync with the latest and greatest by
running the command:
<pre>
cvs update</pre>
Because you've only been granted anonymous access to the tree, you won't be
able to commit any changes. Changes can be submitted for inclusion by posting
them to the appropriate <a href="http://busybox.net/mailman/listinfo">mailing list</a>.
<!-- End of Table -->
</TD></TR>
</TABLE>
<!-- Footer -->
<HR>
<TABLE WIDTH="100%">
<TR>
<TD>
<font size="-1" face="arial, helvetica, sans-serif">
Mail all comments, insults, suggestions and bribes to
<a href="mailto:andersen@codepoet.org">Erik Andersen</a><BR>
The Busybox logo is copyright 1999-2002, Erik Andersen.
</font>
</TD>
<TD>
<a href="http://www.vim.org"><img border=0 width=90 height=36
src="images/written.in.vi.png"
alt="This site created with the vi editor"></a>
</TD>
<TD>
<a href="http://www.gimp.org/"><img border=0 width=90 height=36
src="images/gfx_by_gimp.png" alt="Graphics by GIMP"></a>
</TD>
<TD>
<a href="http://www.linuxtoday.com"><img width=90 height=36
src="images/ltbutton2.png" alt="Linux Today"></a>
</TD>
<TD>
<p><a href="http://slashdot.org"><img width=90 height=36
src="images/sdsmall.png" alt="Slashdot"></a>
</TD>
<TD>
<a href="http://freshmeat.net"><img width=90 height=36
src="images/fm.mini.png" alt="Freshmeat"></a>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
+117
View File
@@ -0,0 +1,117 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<title>BusyBox CVS Read/Write Instructions</title>
</HEAD>
<body text="#000000" alink="#660000" link="#660000" bgcolor="#dee2de" vlink="#660000">
<basefont face="lucida, helvetica, arial" size="3">
<H3>Accessing the Busybox CVS Repository</H3>
<CENTER>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2>
<TR>
<td bgcolor="#000000">
<FONT FACE="lucida, helvetica" COLOR="#ccccc0">
<B>B&nbsp;u&nbsp;s&nbsp;y&nbsp;B&nbsp;o&nbsp;x</B>
</FONT>
</TD>
</TR>
</TABLE>
<a href="/"><IMG SRC="images/busybox2.jpg" alt="BusyBox" border="0" width="360" height="230"></a><BR>
</CENTER>
<TABLE WIDTH="95%" CELLSPACING=1 CELLPADDING=4 BORDER=1>
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="intro"> <BIG><B>
CVS Read/Write Access
</B></BIG></A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
If you want to be able to commit things to CVS, first contribute some
stuff to show you are serious. Then, very nicely ask
<a href="mailto:andersen@codepoet.org">Erik Andersen</a> if he will set you up with
an account. To access CVS, you will want to add the following to set up your environment:
<pre>
$ export CVS_RSH=/usr/bin/ssh
$ export CVSROOT='username@cvs.busybox.net:/var/cvs'</pre>
<br>
It goes without saying you must change <em>username</em> to your own
username...
<p>
To obtain commit access, you will need to demonstrate you are
serious by submitting a few good patches first. Then, you will need to
select a user-name to use when committing stuff, and finally, you will
need to send me the username you have selected, an ssh key, and the email
address where you prefer email to be sent (I will forward any email sent
to you, but not store it).
<p>
Note that if you would prefer to keep your communications with me
private, you can encrypt your email using my
<a href="http://www.codepoet.org/~andersen/erik/gpg.asc">public key</a>.
<!-- End of Table -->
</TD></TR>
</TABLE>
<!-- Footer -->
<HR>
<TABLE WIDTH="100%">
<TR>
<TD>
<font size="-1" face="arial, helvetica, sans-serif">
Mail all comments, insults, suggestions and bribes to
<a href="mailto:andersen@codepoet.org">Erik Andersen</a><BR>
The Busybox logo is copyright 1999-2002, Erik Andersen.
</font>
</TD>
<TD>
<a href="http://www.vim.org"><img border=0 width=90 height=36
src="images/written.in.vi.png"
alt="This site created with the vi editor"></a>
</TD>
<TD>
<a href="http://www.gimp.org/"><img border=0 width=90 height=36
src="images/gfx_by_gimp.png" alt="Graphics by GIMP"></a>
</TD>
<TD>
<a href="http://www.linuxtoday.com"><img width=90 height=36
src="images/ltbutton2.png" alt="Linux Today"></a>
</TD>
<TD>
<p><a href="http://slashdot.org"><img width=90 height=36
src="images/sdsmall.png" alt="Slashdot"></a>
</TD>
<TD>
<a href="http://freshmeat.net"><img width=90 height=36
src="images/fm.mini.png" alt="Freshmeat"></a>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

+423 -438
View File
@@ -1,439 +1,424 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>BusyBox</TITLE>
</HEAD>
<body text="#000000" alink="#660000" link="#660000" bgcolor="#dee2de" vlink="#660000">
<basefont face="lucida, helvetica, arial" size="3">
<CENTER>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2>
<TR>
<td bgcolor="#000000">
<FONT FACE="lucida, helvetica" COLOR="#ccccc0">
<B>B&nbsp;u&nbsp;s&nbsp;y&nbsp;B&nbsp;o&nbsp;x</B>
</FONT>
</TD>
</TR>
</TABLE>
<a href="/"><IMG SRC="images/busybox2.jpg" alt="BusyBox" border="0" width="360" height="230"></a><BR>
<!-- Begin Introduction section -->
<TABLE WIDTH="95%" CELLSPACING=1 CELLPADDING=4 BORDER=1>
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="intro"> <BIG><B>
The Swiss Army Knife of Embedded Linux
</B></BIG></A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for most of the utilities
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
tar, etc. BusyBox provides a fairly complete POSIX environment for any small or
embedded system. The utilities in BusyBox generally have fewer options than
their full featured GNU cousins; however, the options that are included provide
the expected functionality and behave very much like their GNU counterparts.
<p>
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add /dev, /etc, and a kernel.
<p>
BusyBox is maintained by
<a href="http://codepoet.org/andersen/erik/erik.html">
Erik Andersen</a>, and licensed under the
<a href="http://www.gnu.org/copyleft/gpl.html">GNU GENERAL PUBLIC LICENSE</a>.
<p>
<h3> Screenshot </h3>
<p> Because everybody loves screenshots, a screenshot of BusyBox
is now available <a href="screenshot.html">right here</a>.
<H3>Mailing List Information</h3>
BusyBox now has a <a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>!
To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo/busybox">this page</a>.
<!-- Begin Latest News section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="news">
<BIG><B>
Latest News
</B></BIG>
</A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<li> <b>18 November 2001 -- Help us buy busybox.net!</b>
<!-- Begin PayPal Logo -->
<center>
Click here to help buy busybox.net!
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="andersen@codepoet.org">
<input type="hidden" name="item_name" value="Support Busybox/Buy busybox.net">
<input type="hidden" name="image_url" value="https://https://busybox.lineo.com/images/busybox2.jpg">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="http://images.paypal.com/images/x-click-butcc-donate.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
</center>
<!-- End PayPal Logo -->
I've contacted the current owner of busybox.net and he is willing
to sell the domain name -- for $250. He also owns busybox.org
but will not part with it... I will then need to pay the
registry fee, so this will initially cost about $300. I would
also like to host busybox.net on my home machine (codepoet.org)
so I have full control over the system, but I would need to
increase the level of bandwidth I am paying for (there have been
over 1 Gigabyte of busybox source downloads for the month of
November alone -- other months have had more).
<p>
I was going to pay it all myself, but my wife didn't like that
idea at all (big surprise). It turns out, she has better ideas
about what we should spend our money on that don't involve
busybox. She suggested I should ask for contributions on the
mailing list and web page. So...
<p>
I am hoping that if everyone could contribute a bit we could pick
up the busybox.net domain name, and cover the bandwidth costs. I
know that busybox is being used by a lot of companies as well as
individuals -- hopefully companies willing to contribute back a
bit. So if everyone could please help out, that would be
wonderful!
<p>
p.s. I plan on updating the Changelog later this evening, and
releasing busybox 0.60.2 later tonight. I will probably just merge
in vodz' msh since it fixes known problems, and since I haven't had
time to make it uClinux safe. Changelog entries for busybox.stable
are welcome.
<p>
<li> <b>23 August 2001 -- BusyBox 0.60.1 released</b>
<br>
This is a relatively minor bug fixing release that fixes
up the bugs that have shown up in the stable release in
the last few weeks. Fortunately, nothing <em>too</em>
serious has shown up. This release only fixes bugs -- no
new features, no new applets. So without further ado,
here it is. Come and get it.
<p>
The
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> has all
the details. As usual BusyBox 0.60.1 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>2 August 2001 -- BusyBox 0.60.0 released</b>
<br>
I am very pleased to announce the immediate availability of
BusyBox 0.60.0. I have personally tested this release with libc5, glibc,
and <a href="http://cvs.uclinux.org/uClibc.html">uClibc</a> on
x86, ARM, and powerpc using linux 2.2 and 2.4, and I know a number
of people using it on everything from ia64 to m68k with great success.
Everything seems to be working very nicely now, so getting a nice
stable bug-free(tm) release out seems to be in order. This releases fixes
a memory leak in syslogd, a number of bugs in the ash and msh shells, and
cleans up a number of things.
<p>
Those wanting an easy way to test the 0.60.0 release with uClibc can
use <a href="http://user-mode-linux.sourceforge.net/">User-Mode Linux</a>
to give it a try by downloading and compiling
<a href="ftp://oss.lineo.com/buildroot.tar.gz">buildroot.tar.gz</a>.
You don't have to be root or reboot your machine to run test this way.
Preconfigured User-Mode Linux kernel source is also on oss.lineo.com.
<p>
Another cool thing is the nifty <a href="ftp://oss.lineo.com/busybox/tutorial/index.html">
BusyBox Tutorial</a> contributed by K Computing. This requires
a ShockWave plugin (or standalone viewer), so you may want to grab the
the GPLed shockwave viewer from <a href="http://www.swift-tools.com/Flash/flash-0.4.10.tgz">here</a>
to view the tutorial.
<p>
Finally, In case you didn't notice anything odd about the
version number of this release, let me point out that this release
is <em>not</em> 0.53, because I bumped the version number up a
bit. This reflects the fact that this release is intended to form
a new stable BusyBox release series. If you need to rely on a
stable version of BusyBox, you should plan on using the stable
0.60.x series. If bugs show up then I will release 0.60.1, then
0.60.2, etc... This is also intended to deal with the fact that
the BusyBox build system will be getting a major overhaul for the
next release and I don't want that to break products that people
are shipping. To avoid that, the new build system will be
released as part of a new BusyBox development series that will
have some not-yet-decided-on odd version number. Once things
stabilize and the new build system is working for everyone, then
I will release that as a new stable release series.
<p>
The
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> has all
the details. As usual BusyBox 0.60.0 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>7 July 2001 -- BusyBox 0.52 released</b>
<br>
I am very pleased to announce the immediate availability of
BusyBox 0.52 (the "new-and-improved rock-solid release"). This
release is the result of <em>many</em> hours of work and has tons
of bugfixes, optimizations, and cleanups. This release adds
several new applets, including several new shells (such as hush, msh,
and ash).
<p>
The
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> covers
some of the more obvious details, but there are many many things that
are not mentioned, but have been improved in subtle ways. As usual,
BusyBox 0.52 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>10 April 2001 - Graph of Busybox Growth </b>
<br>
The illustrious Larry Doolittle has made a PostScript chart of the growth
of the Busybox tarball size over time. It is available for downloading /
viewing <a href= "busybox-growth.ps"> right here</a>.
<p> (Note that while the number of applets in Busybox has increased, you
can still configure Busybox to be as small as you want by selectively
turning off whichever applets you don't need.)
<p>
<li> <b>Old News</b>
<br>
For the old news, visit <a href="http://busybox.lineo.com/oldnews.html">the old news page</a>.
</ul>
<!-- Begin Download section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="download"><BIG><B>
Download
</B></BIG></A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<li> Source for the latest release can always be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<li> A new snapshot of the source is made daily and is available as a GNU
gzipped tarball <a href="busybox.tar.gz"> right here</a>.
<li> BusyBox now has its own publically browsable
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
anonymous
<a href="http://opensource.lineo.com/cvs_anon.html">CVS access</a>, and
for those that are actively contributing there is even
<a href="http://opensource.lineo.com/cvs_write.html">CVS write access</a>.
</ul>
<!-- Begin Docs section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="docs"><BIG><B>
Documentation
</B></BIG></A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
Current documentation for BusyBox includes:
<ul>
<li> <a href="ftp://oss.lineo.com/busybox/BusyBox.html">BusyBox.html</a>.
This is a list of the all the available commands in BusyBox with
complete usage information and examples of how to use each app. I
have spent a <em>lot</em> of time updating these docs and trying to
make them fairly comprehensive. If you find any errors (factual,
grammatical, whatever) please let me know.
<li> <a href="ftp://oss.lineo.com/busybox/README">README</a>.
This is the README file included in the busybox source release.
<li> <a href="http://bugs.lineo.com/db/pa/lbusybox.html">BusyBox Bugs</a>.
Need to report a bug? Need to check if a bug has been filed?
<li> If you need more help, the BusyBox
<a href="http://opensource.lineo.com/lists/busybox/">mailing list</a> is
a good place to start.
</ul>
<!-- Begin Links section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="links">
<BIG><B>
Important Links
</B></BIG>
</A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<li> <A HREF="http://perens.com/FreeSoftware/">
Free Software from Bruce Perens</A><br>
The original idea for BusyBox, and all versions up to 0.26 were written
by <A HREF="mailto:bruce@perens.com">Bruce Perens</a>. This is his BusyBox website.
<p>
<li> <A HREF="http://freshmeat.net/projects/busybox/">
Freshmeat AppIndex record for BusyBox</A>
<p>
<li><a href="http://tinylogin.lineo.com/">TinyLogin</a>
is a nice embedded tool for handling authentication, changing passwords,
and similar tasks which nicely complements BusyBox.
<p>
<li><a href="http://cvs.uclinux.org/uClibc.html">uClibc</a>
is a C library for embedded systems. You can actually statically link
a "Hello World" application under x86 that only takes 4k (as opposed to
200k under GNU libc). It can do dynamic linking too and works nicely with
BusyBox to create very small embedded systems.
<p>
<li> <a href="http://opensource.lineo.com/software.html">Other cool embedded software</a>.
<p>
</ul>
<!-- Begin Projects section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="projects"><BIG><B>
Products/Projects Using BusyBox
</B></BIG></A>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<p> I know of the following products and/or projects that use BusyBox --
listed in the order I happen to add them to the web page:
<ul>
<li> <a href="http://cvs.debian.org/boot-floppies/">Debian installer (boot floppies) project</a>
<li> <a href="http://redhat.com/">Red Hat 7.2 installer</a>
<li> <a
href="http://distro.ibiblio.org/pub/Linux/distributions/slackware/source/rootdsks/">Slackware Installer</a>
<li> <a href="http://www.linuxrouter.org/">Linux Router Project </a>
<li> <a href="http://linux-embedded.org/">LEM</a>
<li> <a href="http://www.toms.net/rb/">tomsrtbt</a>
<li> <a href="http://www.stormix.com/">Stormix Installer</a>
<li> <a href="http://www.emacinc.com/linux2_sbc.htm">EMAC Linux 2.0 SBC</a>
<li> <a href="http://www.trinux.org/">Trinux</a>
<li> <a href="http://oddas.sourceforge.net/">ODDAS project</a>
<li> <a href="http://www.kerbango.com/">The Kerbango Internet Radio</a>
<li> <a href="http://www.linuxmagic.com/vpn/">LinuxMagic VPN Firewall</a>
<li> <a href="http://byld.sourceforge.net/">Build Your Linux Disk</a>
<li> <a href="http://homepages.ihug.co.nz/~ichi/baslinux.html">BasicLinux</a>
<li> <a href="http://ibiblio.org/pub/Linux/system/recovery">Zdisk</a>
<li> <a href="http://www.adtran.com">AdTran - VPN/firewall VPN Linux Distribution</a>
<li> <a href="http://mkcdrec.ota.be/">mkCDrec - make CD-ROM recovery</a>
<li> <a href="http://recycle.lbl.gov/~ldoolitt/bse/">Linux on nanoEngine</a>
<li> <a href="http://www.zelow.no/floppyfw/"> Floppyfw</a>
<li> <a href="http://midori.transmeta.com/"> Midori Linux</a> - <a href=
"http://www.wired.com/news/technology/0,1282,42399,00.html"> Article on
Midori Linux</a> on <a href= "http://www.wired.com"> Wired</a>. Quote from
Erik at the top of <a href=
"http://www.wired.com/news/technology/0,1282,42399-2,00.html"> this
page</a>
<li> <a href="http://www.ltsp.org/">Linux Terminal Server Project</a>
<li> <a href="http://www.devil-linux.org/">Devil-Linux</a>
<li> <a href="http://dutnux.sourceforge.net/">DutNux</a>
<li> <a href="http://www.cachier.com/">Cachier</a>
<li> <a href="http://www.microwerks.net/~hugo/mindi/">Mindi</a>
</ul>
<p> Do you use BusyBox? I'd love to know about it and I'd be happy to link to
you.
<!-- End of Table -->
</TD></TR>
</TABLE>
<!-- Footer -->
<HR>
<TABLE WIDTH="100%">
<TR>
<TD>
<font size="-1" face="arial, helvetica, sans-serif">
Mail all comments, insults, suggestions and bribes to
<a href="mailto:andersen@codepoet.org">Erik Andersen</a><BR>
The Busybox logo is copyright 1999,2000,2001, Erik Andersen.
</font>
</TD>
<TD>
<a href="http://www.vim.org"><img border=0 width=90 height=36
src="images/written.in.vi.png"
alt="This site created with the vi editor"></a>
</TD>
<TD>
<a href="http://www.gimp.org/"><img border=0 width=90 height=36
src="images/gfx_by_gimp.png" alt="Graphics by GIMP"></a>
</TD>
<TD>
<a href="http://www.linuxtoday.com"><img width=90 height=36
src="images/ltbutton2.png" alt="Linux Today"></a>
</TD>
<TD>
<p><a href="http://slashdot.org"><img width=90 height=36
src="images/sdsmall.png" alt="Slashdot"></a>
</TD>
<TD>
<a href="http://freshmeat.net"><img width=90 height=36
src="images/fm.mini.png" alt="Freshmeat"></a>
</TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st February 2002), see www.w3.org">
<title>BusyBox</title>
<style type="text/css">
body {
background-color: #DEE2DE;
color: #000000;
}
:link { color: #660000 }
:visited { color: #660000 }
:active { color: #660000 }
div.c3 {text-align: center}
td.c2 {font-family: arial, helvetica, sans-serif; font-size: 80%}
td.c1 {font-family: lucida, helvetica; font-size: 248%}
</style>
</head>
<body>
<basefont face="lucida, helvetica, arial" size="3">
<div class="c3">
<table border="0" cellspacing="1" cellpadding="2">
<tr>
<td class="c1">BUSYBOX</td>
</tr>
</table>
<a href="/"><img src="images/busybox1.png" alt="BusyBox"
border="0" width="164" height="116"></a><br>
<!-- Begin Introduction section -->
<table width="95%" cellspacing="1" cellpadding="4" border=
"1">
<tr>
<td bgcolor="#CCCCC0" align="center"><a name= "intro"><big>
<b>The Swiss Army Knife of Embedded Linux</b>
</big></a></td>
</tr>
<tr>
<td bgcolor="#EEEEE0">
BusyBox combines tiny versions of many common UNIX
utilities into a single small executable. It provides
minimalist replacements for most of the utilities you
usually find in fileutils, shellutils, findutils,
textutils, grep, gzip, tar, etc. BusyBox provides a
fairly complete POSIX environment for any small or
embedded system. The utilities in BusyBox generally
have fewer options than their full featured GNU
cousins; however, the options that are included provide
the expected functionality and behave very much like
their GNU counterparts.
<p>BusyBox has been written with size-optimization and
limited resources in mind. It is also extremely modular
so you can easily include or exclude commands (or
features) at compile time. This makes it easy to
customize your embedded systems. To create a working
system, just add /dev, /etc, and a kernel.</p>
<p>BusyBox is maintained by <a href=
"http://codepoet.org/andersen/erik/erik.html">Erik
Andersen</a>, and licensed under the <a href=
"http://www.gnu.org/copyleft/gpl.html">GNU GENERAL
PUBLIC LICENSE</a>.</p>
<h3>Screenshot</h3>
<p>Because everybody loves screenshots, a screenshot of
BusyBox is now available <a href=
"screenshot.html">right here</a>.</p>
<h3>Mailing List Information</h3>
BusyBox now has a <a href="/lists/busybox/">mailing
list</a>!<br>
To subscribe, go and visit <a href=
"/mailman/listinfo/busybox">this page</a>.
<!-- Begin Latest News section -->
</td>
</tr>
<tr>
<td bgcolor="#CCCCC0" align="center"><a name=
"news"><big><b>Latest News</b></big></a></td>
</tr>
<tr>
<td bgcolor="#EEEEE0">
<ul>
<li>
<b>6 March 2002 -- busybox.net now has mirrors!</b>
<p>Busybox.net is now much more available, thanks to
the fine folks at <a href= "http://i-netinnovations.com/">http://i-netinnovations.com/</a>
who are providing hosting for busybox.net and
uclibc.org. In addition, we now have two mirrors:
<a href= "http://busybox.linuxmagic.com/">http://busybox.linuxmagic.com/</a>
in Canada and
<a href= "http://busybox.csservers.de/">http://busybox.csservers.de/</a>
in Germany. I hope this makes things much more
accessible for everyone!
<li><b>Old News</b><br>
For the old news, visit <a href="oldnews.html">the
old news page</a>.</li>
</ul>
</td>
</tr>
<!-- Begin Sponsors section -->
<tr>
<td bgcolor="#CCCCC0" align="center"><a name=
"sponsors"><big><b>Sponsors</b></big></a></td>
</tr>
<tr>
<td bgcolor="#EEEEE0">
Please visit our sponsors and thank them for their
support! They have provided money for equipment and
bandwidth. Next time you need help with a project,
consider these fine companies!
<ul>
<li><a href=
"http://opensource.se/">opensource.se</a><br>
Embedded open source consulting in Europe.</li>
<li><a href= "http://i-netinnovations.com/">http://i-netinnovations.com/</a><br>
Web hosting (they host busybox.net and uclibc.org).</li>
<li><a href=
"http://www.codepoet-consulting.com">Codepoet
Consulting</a><br>
Custom Linux, embedded Linux, BusyBox, and uClibc
development.</li>
</ul>
Several individuals have also contributed. If you have
already contributed and would like your name added
here, just let me know. If you would like to be a
BusyBox sponsor, email <a href=
"mailto:andersen@codepoet.org">Erik</a>.
</td>
</tr>
<!-- Begin Download section -->
<p>
<tr>
<td bgcolor="#CCCCC0" align="center"><a name=
"download"><big><b>Download</b></big></a></td>
</tr>
<tr>
<td bgcolor="#EEEEE0">
<ul>
<li>Source for the latest release can always be
downloaded from <a href=
"downloads">http://www.busybox.net/downloads</a>.</li>
<li>A new snapshot of the source is made daily and is
available as a GNU gzipped tarball <a href=
"downloads/snapshots/busybox-snapshot.tar.bz2">right here</a>.</li>
<li>BusyBox now has its own publically browsable <a
href="/cgi-bin/cvsweb/busybox/">CVS tree</a>,
anonymous <a href="cvs_anon.html">CVS access</a>, and
for those that are actively contributing there is
even <a href="cvs_write.html">CVS write
access</a>.</li>
</ul>
</td>
</tr>
<!-- Begin Docs section -->
<tr>
<td bgcolor="#CCCCC0" align="center"><a name=
"docs"><big><b>Documentation</b></big></a></td>
</tr>
<tr>
<td bgcolor="#EEEEE0">
Current documentation for BusyBox includes:
<ul>
<li><a href=
"downloads/BusyBox.html">BusyBox.html</a>. This is a
list of the all the available commands in BusyBox
with complete usage information and examples of how
to use each app. I have spent a <em>lot</em> of time
updating these docs and trying to make them fairly
comprehensive. If you find any errors (factual,
grammatical, whatever) please let me know.</li>
<li><a href="downloads/README">README</a>. This is
the README file included in the busybox source
release.</li>
<li><a href=
"http://bugs.busybox.net/db/pa/lbusybox.html">BusyBox
Bugs</a>. Need to report a bug? Need to check if a
bug has been filed?</li>
<li>If you need more help, the BusyBox <a href=
"lists/busybox/">mailing list</a> is a good place to
start.</li>
</ul>
</td>
</tr>
<!-- Begin Links section -->
<tr>
<td bgcolor="#CCCCC0" align="center"><a name=
"links"><big><b>Important Links</b></big></a></td>
</tr>
<tr>
<td bgcolor="#EEEEE0">
<ul>
<li><a href="http://perens.com/FreeSoftware/">Free
Software from Bruce Perens</a><br>
The original idea for BusyBox, and all versions up
to 0.26 were written by <a href=
"mailto:bruce@perens.com">Bruce Perens</a>. This is
his BusyBox website.</li>
<li><a href=
"http://freshmeat.net/projects/busybox/">Freshmeat
AppIndex record for BusyBox</a></li>
<li><a href=
"http://tinylogin.busybox.net/">TinyLogin</a> is a
nice embedded tool for handling authentication,
changing passwords, and similar tasks which nicely
complements BusyBox.</li>
<li><a href="http://udhcp.busybox.net/">udhcp</a> is
a tiny dhcp client and/or server which is ideal for
embedded systems.</li>
<li><a href="http://www.uclibc.org/">uClibc</a> is a
C library for embedded systems. You can actually
statically link a "Hello World" application under x86
that only takes 4k (as opposed to 200k under GNU
libc). It can do dynamic linking too and works nicely
with BusyBox to create very small embedded
systems.</li>
</ul>
</td>
</tr>
<!-- Begin Projects section -->
<tr>
<td bgcolor="#CCCCC0" align="center"><a name=
"projects"><big><b>Products/Projects Using
BusyBox</b></big></a></td>
</tr>
<tr>
<td bgcolor="#EEEEE0">
<p>I know of the following products and/or projects
that use BusyBox -- listed in the order I happen to add
them to the web page:</p>
<ul>
<li><a href=
"http://cvs.debian.org/boot-floppies/">Debian
installer (boot floppies) project</a></li>
<li><a href="http://redhat.com/">Red Hat 7.2
installer</a></li>
<li><a href=
"http://distro.ibiblio.org/pub/Linux/distributions/slackware/source/rootdsks/">
Slackware Installer</a></li>
<li><a href="http://www.linuxrouter.org/">Linux
Router Project</a></li>
<li><a href="http://linux-embedded.org/">LEM</a></li>
<li><a href=
"http://www.toms.net/rb/">tomsrtbt</a></li>
<li><a href="http://www.stormix.com/">Stormix
Installer</a></li>
<li><a href=
"http://www.emacinc.com/linux2_sbc.htm">EMAC Linux
2.0 SBC</a></li>
<li><a href="http://www.trinux.org/">Trinux</a></li>
<li><a href="http://oddas.sourceforge.net/">ODDAS
project</a></li>
<li><a href="http://www.kerbango.com/">The Kerbango
Internet Radio</a></li>
<li><a href=
"http://www.linuxmagic.com/vpn/">LinuxMagic VPN
Firewall</a></li>
<li><a href="http://byld.sourceforge.net/">Build Your
Linux Disk</a></li>
<li><a href=
"http://homepages.ihug.co.nz/~ichi/baslinux.html">BasicLinux</a></li>
<li><a href=
"http://ibiblio.org/pub/Linux/system/recovery">Zdisk</a></li>
<li><a href="http://www.adtran.com">AdTran -
VPN/firewall VPN Linux Distribution</a></li>
<li><a href="http://mkcdrec.ota.be/">mkCDrec - make
CD-ROM recovery</a></li>
<li><a href=
"http://recycle.lbl.gov/~ldoolitt/bse/">Linux on
nanoEngine</a></li>
<li><a href=
"http://www.zelow.no/floppyfw/">Floppyfw</a></li>
<li><a href="http://midori.transmeta.com/">Midori
Linux</a> - <a href=
"http://www.wired.com/news/technology/0,1282,42399,00.html">
Article on Midori Linux</a> on <a href=
"http://www.wired.com">Wired</a>. Quote from Erik at
the top of <a href=
"http://www.wired.com/news/technology/0,1282,42399-2,00.html">
this page</a></li>
<li><a href="http://www.ltsp.org/">Linux Terminal
Server Project</a></li>
<li><a href=
"http://www.devil-linux.org/">Devil-Linux</a></li>
<li><a href=
"http://dutnux.sourceforge.net/">DutNux</a></li>
<li><a href=
"http://www.cachier.com/">Cachier</a></li>
<li><a href=
"http://www.microwerks.net/~hugo/mindi/">Mindi</a></li>
<li><a href=
"http://www.tzi.de/~pharao90/ttylinux">ttylinux</a></li>
<li><a href="http://www.coyotelinux.com/">Coyote Linux</a></li>
<li><a href="http://www.partimage.org/">Partition
Image</a></li>
<li><a href="http://www.fli4l.de/">fli4l the on(e)-disk-router</a></li>
<li><a href="http://tuxscreen.net">Tuxscreen Linux
Phone</a></li>
<li><a href="http://tinfoilhat.cultists.net/">Tinfoil
Hat Linux</a></li>
<li><a href="http://zaurus.sourceforge.net/">Sharp Zaurus
PDA</a></li>
</ul>
<p>Do you use BusyBox? I'd love to know about it and
I'd be happy to link to you. <!-- End of Table -->
</p>
</td>
</tr>
</table>
<!-- Footer -->
<hr>
<table width="100%">
<tr>
<td class="c2">Mail all comments, insults, suggestions
and bribes to <a href="mailto:andersen@codepoet.org">Erik
Andersen</a><br>
The Busybox logo is copyright 1999-2002, Erik
Andersen.</td>
<td><a href="http://www.vim.org"><img border="0" width=
"90" height="36" src="images/written.in.vi.png" alt=
"This site created with the vi editor"></a></td>
<td><a href="http://www.gimp.org/"><img border="0" width=
"90" height="36" src="images/gfx_by_gimp.png" alt=
"Graphics by GIMP"></a></td>
<td><a href="http://www.linuxtoday.com"><img width="90"
height="36" src="images/ltbutton2.png" alt="Linux Today">
</a></td>
<td>
<p><a href="http://slashdot.org"><img width="90"
height="36" src="images/sdsmall.png" alt="Slashdot">
</a></p>
</td>
<td><a href="http://freshmeat.net"><img width="90"
height="36" src="images/fm.mini.png" alt="Freshmeat">
</a></td>
</tr>
</table>
</div>
</body>
</html>
+271 -32
View File
@@ -38,9 +38,255 @@
<ul>
<p> <li> <b>Take me back to the <a href="http://busybox.lineo.com/">BusyBox</a> web site.</b>
<p> <li> <b>Take me back to the <a href="/">BusyBox</a> web site.</b>
<hr>
<li>
<b>3 January 2002 -- Welcome to busybox.net!</b>
<p>Thanks to the generosity of a number of busybox
users, we have been able to purchase busybox.net
(which is where you are probably reading this).
Right now, busybox.net and uclibc.org are both
living on my home system (at the end of my DSL
line). I apologize for the abrupt move off of
busybox.lineo.com. Unfortunately, I no longer have
the access needed to keep that system updated (for
example, you might notice the daily snapshots there
stopped some time ago).</p>
<p>Busybox.net is currently hosted on my home
server, at the end of a DSL line. Unfortunately,
the load on them is quite heavy. To address this,
I'm trying to make arrangements to get busybox.net
co-located directly at an ISP. To assist in the
co-location effort, <a href=
"http://www.codepoet.org/~markw">Mark Whitley</a>
(author of busybox sed, cut, and grep) has donated
his <a href=
"http://www.netwinder.org/">NetWinder</a> computer
for hosting busybox.net and uclibc.org. Once this
system is co-located, the current speed problems
should be completely eliminated. Hopefully, too,
some of you will volunteer to set up some mirror
sites, to help to distribute the load a bit.</p>
<p><!--
<center>
Click here to help support busybox.net!
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="andersen@codepoet.org">
<input type="hidden" name="item_name" value="Support Busybox">
<input type="hidden" name="image_url" value="https://codepoet-consulting.com/images/busybox2.jpg">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="images/donate.png" border="0" name="submit" alt="Make donation using PayPal">
</form>
</center>
-->
Since some people expressed concern over BusyBox
donations, let me assure you that no one is getting
rich here. All BusyBox and uClibc donations will be
spent paying for bandwidth and needed hardware
upgrades. For example, Mark's NetWinder currently
has just 64Meg of memory. As demonstrated when
google spidered the site the other day, 64 Megs in
not enough, so I'm going to be ordering 256Megs of
ram and a larger hard drive for the box today. So
far, donations received have been sufficient to
cover almost all expenses. In the future, we may
have co-location fees to worry about, but for now
we are ok. A <b>HUGE thank-you</b> goes out to
everyone that has contributed!<br>
-Erik</p>
</li>
<li>
<b>20 November 2001 -- BusyBox 0.60.2 released</b>
<p>We am very pleased to announce that the BusyBox
0.60.2 (stable) is now released to the world. This
one is primarily a bugfix release for the stable
series, and it should take care of most everyone's
needs till we can get the nice new stuff we have
been working on in CVS ready to release (with the
wonderful new buildsystem). The biggest change in
this release (beyond bugfixes) is the fact that msh
(the minix shell) has been re-worked by Vladimir N.
Oleynik (vodz) and so it no longer crashes when
told to do complex things with backticks.</p>
<p>This release has been tested on x86, ARM, and
powerpc using glibc 2.2.4, libc5, and uClibc, so it
should work with just about any Linux system you
throw it at. See the <a href=
"downloads/Changelog">changelog</a> for <small>most
of</small> the details. The last release was
<em>very</em> solid for people, and this one should
be even better.</p>
<p>As usual BusyBox 0.60.2 can be downloaded from
<a href=
"downloads">http://www.busybox.net/downloads</a>.</p>
<p>Have Fun.<br>
-Erik</p>
</li>
<li> <b>18 November 2001 -- Help us buy busybox.net!</b>
<!-- Begin PayPal Logo -->
<center>
Click here to help buy busybox.net!
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="andersen@codepoet.org">
<input type="hidden" name="item_name" value="Support Busybox/Buy busybox.net">
<input type="hidden" name="image_url" value="https://busybox.net/images/busybox2.jpg">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="images/donate.png" border="0" name="submit" alt="Make donation using PayPal">
</form>
</center>
<!-- End PayPal Logo -->
I've contacted the current owner of busybox.net and he is willing
to sell the domain name -- for $250. He also owns busybox.org but
will not part with it... I will then need to pay the registry fee
for a couple of years and start paying for bandwidth, so this will
initially cost about $300. I would like to host busybox.net on my
home machine (codepoet.org) so I have full control over the system,
but to do that would require that I increase the level of bandwidth
I am paying for. Did you know that so far this month, there
have been over 1.4 Gigabytes of busybox ftp downloads? I don't
even <em>know</em> how much CVS bandwidth it requires. For the
time being, Lineo has continued to graciously provide this
bandwidth, despite the fact that I no longer work for them. If I
start running this all on my home machine, paying for the needed bandwidth
will start costing some money.
<p>
I was going to pay it all myself, but my wife didn't like that
idea at all (big surprise). It turns out &lt;insert argument
where she wins and I don't&gt; she has better ideas
about what we should spend our money on that don't involve
busybox. She suggested I should ask for contributions on the
mailing list and web page. So...
<p>
I am hoping that if everyone could contribute a bit, we could pick
up the busybox.net domain name and cover the bandwidth costs. I
know that busybox is being used by a lot of companies as well as
individuals -- hopefully people and companies that are willing to
contribute back a bit. So if everyone could please help out, that
would be wonderful!
<p>
<li> <b>23 August 2001 -- BusyBox 0.60.1 released</b>
<br>
This is a relatively minor bug fixing release that fixes
up the bugs that have shown up in the stable release in
the last few weeks. Fortunately, nothing <em>too</em>
serious has shown up. This release only fixes bugs -- no
new features, no new applets. So without further ado,
here it is. Come and get it.
<p>
The
<a href="downloads/Changelog">changelog</a> has all
the details. As usual BusyBox 0.60.1 can be downloaded from
<a href="downloads">http://busybox.net/downloads</a>.
<p>Have Fun!
<p>
<li> <b>2 August 2001 -- BusyBox 0.60.0 released</b>
<br>
I am very pleased to announce the immediate availability of
BusyBox 0.60.0. I have personally tested this release with libc5, glibc,
and <a href="http://uclibc.org/">uClibc</a> on
x86, ARM, and powerpc using linux 2.2 and 2.4, and I know a number
of people using it on everything from ia64 to m68k with great success.
Everything seems to be working very nicely now, so getting a nice
stable bug-free(tm) release out seems to be in order. This releases fixes
a memory leak in syslogd, a number of bugs in the ash and msh shells, and
cleans up a number of things.
<p>
Those wanting an easy way to test the 0.60.0 release with uClibc can
use <a href="http://user-mode-linux.sourceforge.net/">User-Mode Linux</a>
to give it a try by downloading and compiling
<a href="ftp://busybox.net/buildroot.tar.gz">buildroot.tar.gz</a>.
You don't have to be root or reboot your machine to run test this way.
Preconfigured User-Mode Linux kernel source is also on busybox.net.
<p>
Another cool thing is the nifty <a href="downloads/tutorial/index.html">
BusyBox Tutorial</a> contributed by K Computing. This requires
a ShockWave plugin (or standalone viewer), so you may want to grab the
the GPLed shockwave viewer from <a href="http://www.swift-tools.com/Flash/flash-0.4.10.tgz">here</a>
to view the tutorial.
<p>
Finally, In case you didn't notice anything odd about the
version number of this release, let me point out that this release
is <em>not</em> 0.53, because I bumped the version number up a
bit. This reflects the fact that this release is intended to form
a new stable BusyBox release series. If you need to rely on a
stable version of BusyBox, you should plan on using the stable
0.60.x series. If bugs show up then I will release 0.60.1, then
0.60.2, etc... This is also intended to deal with the fact that
the BusyBox build system will be getting a major overhaul for the
next release and I don't want that to break products that people
are shipping. To avoid that, the new build system will be
released as part of a new BusyBox development series that will
have some not-yet-decided-on odd version number. Once things
stabilize and the new build system is working for everyone, then
I will release that as a new stable release series.
<p>
The
<a href="downloads/Changelog">changelog</a> has all
the details. As usual BusyBox 0.60.0 can be downloaded from
<a href="downloads">http://busybox.net/downloads</a>.
<p>Have Fun!
<p>
<li> <b>7 July 2001 -- BusyBox 0.52 released</b>
<br>
I am very pleased to announce the immediate availability of
BusyBox 0.52 (the "new-and-improved rock-solid release"). This
release is the result of <em>many</em> hours of work and has tons
of bugfixes, optimizations, and cleanups. This release adds
several new applets, including several new shells (such as hush, msh,
and ash).
<p>
The
<a href="downloads/Changelog">changelog</a> covers
some of the more obvious details, but there are many many things that
are not mentioned, but have been improved in subtle ways. As usual,
BusyBox 0.52 can be downloaded from
<a href="downloads">http://busybox.net/downloads</a>.
<p>Have Fun!
<p>
<li> <b>10 April 2001 - Graph of Busybox Growth </b>
<br>
The illustrious Larry Doolittle has made a PostScript chart of the growth
of the Busybox tarball size over time. It is available for downloading /
viewing <a href= "busybox-growth.ps"> right here</a>.
<p> (Note that while the number of applets in Busybox has increased, you
can still configure Busybox to be as small as you want by selectively
turning off whichever applets you don't need.)
<p>
<li> <b>10 April 2001 -- BusyBox 0.51 released</b>
<br>
@@ -65,21 +311,21 @@
for letting me use their system!).
<p>
You can read the
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> for
<a href="downloads/Changelog">changelog</a> for
complete details. BusyBox 0.51 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<a href="downloads">http://busybox.net/downloads</a>.
<p>Have Fun!
<p>
<li> <b>Busybox Boot-Floppy Image</b>
<p>Because you asked for it, we have made available a <a href=
"ftp://oss.lineo.com/busybox/busybox.floppy.img"> Busybox boot floppy
"downloads/busybox.floppy.img"> Busybox boot floppy
image</a>. Here's how you use it:
<ol>
<li> <a href= "ftp://oss.lineo.com/busybox/busybox.floppy.img">
<li> <a href= "downloads/busybox.floppy.img">
Download the image</a>
<li> dd it onto a floppy like so: <tt> dd if=busybox.floppy.img
@@ -108,7 +354,7 @@
shell is now working very well, and the shell's environment variable
expansion was fixed. Tons of other things were fixed or made
smaller. For a fairly complete overview, see the
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<a href="downloads/Changelog">changelog</a>.
<p>
lash (the busybox shell) is still with us, fixed up a bit so it
now behaves itself quite nicely. It really is quite usable as
@@ -129,7 +375,7 @@
Several new applets, lots of bug fixes, cleanups, and many smaller
things made nicer. Several cleanups and improvements to the shell.
For a list of the most interesting changes
you might want to look at the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
you might want to look at the <a href="downloads/Changelog">changelog</a>.
<p>
Special thanks go out to Matt Kraai and Larry Doolittle for all their
work on this release, and for keeping on top of things while I've been
@@ -161,7 +407,7 @@
woody) a .udeb can now be generated.
<p>
The curious can get a list of some of the more interesting changes by reading
the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
the <a href="downloads/Changelog">changelog</a>.
<p>
Many thanks go out to the many many people that have contributed to
this release, especially Matt Kraai, Larry Doolittle, and Kent Robotti.
@@ -175,7 +421,7 @@
renice, xargs, and expr. syslogd now supports network logging.
There are the usual tar updates. Most apps now use getopt for
more correct option parsing.
See the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>
See the <a href="downloads/Changelog">changelog</a>
for complete details.
@@ -187,7 +433,7 @@
people to dump a binary keymaps for use with 'loadkmap', and a
completely reworked 'grep' and 'sed' which should behave better.
BusyBox shell can now also be used as a login shell.
See the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>
See the <a href="downloads/Changelog">changelog</a>
for complete details.
@@ -199,17 +445,17 @@
release provides the following new apps: cut, tr, insmod, ar,
mktemp, setkeycodes, md5sum, uuencode, uudecode, which, and
telnet. There are bug fixes for just about every app as well (see
the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> for
the <a href="downloads/Changelog">changelog</a> for
details).
<p>
Also, some exciting infrastructure news! Busybox now has its own
<a href="http://oss.lineo.com/lists/busybox/">mailing list</a>,
<a href="lists/busybox/">mailing list</a>,
publically browsable
<a href="http://oss.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
<a href="/cgi-bin/cvsweb/busybox/">CVS tree</a>,
anonymous
<a href="http://oss.lineo.com/cvs_anon.html">CVS access</a>, and
<a href="cvs_anon.html">CVS access</a>, and
for those that are actively contributing there is even
<a href="http://oss.lineo.com/cvs_write.html">CVS write access</a>.
<a href="cvs_write.html">CVS write access</a>.
I think this will be a huge help to the ongoing development of BusyBox.
<p>
Also, for the curious, there is no 0.44 release. Somehow 0.44 got announced
@@ -249,8 +495,7 @@
from "A" would have been logged. This means that if init tries to log something
while say ppp has the syslog open, init would block (which is bad, bad, bad).
<p>
Karl M. Hegbloom has created a
<a href="ftp://ftp.lineo.com/pub/busybox/busybox-0.43-syslog_patch">fix for the problem</a>.
Karl M. Hegbloom has created a fix for the problem.
Thanks Karl!
@@ -263,7 +508,7 @@
freeramdisk, tr, echo, test, and usleep. Tar has been completely
rewritten from scratch. Bss size has also been greatly reduced.
More details are available in the
<a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a>.
<a href="downloads/Changelog">changelog</a>.
Oh, and as a special bonus, I wrote some fairly comprehensive
<em>documentation</em>, complete with examples and full usage information.
@@ -275,7 +520,7 @@
There were others so if I somehow forgot to mention you, I'm very sorry.
<p>
You can grab BusyBox 0.43 tarballs <a href="ftp://ftp.lineo.com/pub/busybox/">here</a>.
You can grab BusyBox 0.43 tarballs <a href="downloads">here</a>.
<p> <li> <b>9 April 2000 -- BusyBox 0.43 pre release</b>
<br>
@@ -290,7 +535,7 @@
enough for production use -- it just isn't a release since I have some structural
changes I still want to make.
<p>
The pre-release can be found <a href="ftp://ftp.lineo.com/pub/busybox/">here</a>.
The pre-release can be found <a href="downloads">here</a>.
Please let me know ASAP if you find <em>any</em> bugs.
<p> <li> <b>28 March 2000 -- Andersen Baby Boy release</b>
@@ -323,7 +568,7 @@
This is the most solid BusyBox release so far. Many, many
bugs have been fixed. See the
<a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a> for details.
<a href="downloads/Changelog">changelog</a> for details.
Of particular interest, init will now cleanly unmount
filesystems on reboot, cp and mv have been rewritten and
@@ -340,7 +585,7 @@
mkdir, syslogd, and init. New apps include wc, hostid,
logname, tty, whoami, and yes. New features include loop device
support in mount and umount, and better TERM handling by init.
The changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>.
The changelog can be found <a href="downloads/Changelog">here</a>.
<p> <li> <b>7 January 2000 -- BusyBox 0.40 released</b>
<br>
@@ -350,7 +595,7 @@
New apps include sort, uniq, lsmod, rmmod, fbset, and loadacm.
In particular, this release fixes an important bug in tar which
in some cases produced serious security problems.
As always, the changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>.
As always, the changelog can be found <a href="downloads/Changelog">here</a>.
<p> <li> <b>11 December 1999 -- BusyBox Website</b>
<br>
@@ -364,7 +609,7 @@
<br>
This release includes fixes to init, reboot, halt, kill, and ls, and contains
the new apps ping, hostname, mkfifo, free, tail, du, tee, and head. A full
changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>.
changelog can be found <a href="downloads/Changelog">here</a>.
<p> <li> <b>5 December 1999 -- BusyBox 0.38 released</b>
<br>
This release includes fixes to tar, cat, ls, dd, rm, umount, find, df,
@@ -385,7 +630,7 @@
<ul>
<li> <a href="http://busybox.lineo.com/">Take me back to http://busybox.lineo.com/</a>.
<li> <a href="/">Take me back to http://busybox.net/</a>.
<p>
<li> <A HREF="http://perens.com/FreeSoftware/">
@@ -398,12 +643,6 @@
Freshmeat AppIndex record for BusyBox</A>
<p>
<li> <a href="http://oss.lineo.com/software.html">Cool embedded software</a>.
<p>
<li> <a href="http://oss.lineo.com/">oss.lineo.com</a>.
<p>
</ul>
@@ -423,7 +662,7 @@
<font size="-1" face="arial, helvetica, sans-serif">
Mail all comments, insults, suggestions and bribes to
<a href="mailto:andersen@codepoet.org">Erik Andersen</a><BR>
The Busybox logo is copyright 1999,2000,2001 Erik Andersen.
The Busybox logo is copyright 1999-2002, Erik Andersen.
</font>
</TD>
+3
View File
@@ -0,0 +1,3 @@
# go away
User-agent: *
Disallow: /cgi-bin
+9 -8
View File
@@ -22,7 +22,7 @@ font-family: monospace; font-size: smaller;" width="80%">
$ ./busybox
BusyBox v0.49 (2001.01.30-17:35+0000) multi-call binary -- GPL2
BusyBox v0.60.3-pre (2002.02.13-23:05+0000) multi-call binary
Usage: busybox [function] [arguments]...
or: [function] [arguments]...
@@ -33,13 +33,14 @@ Usage: busybox [function] [arguments]...
will act like whatever it was invoked as.
Currently defined functions:
basename, busybox, cat, chgrp, chmod, chown, chroot, chvt, clear,
cp, cut, date, dd, df, dirname, dmesg, du, echo, false, find,
free, grep, gunzip, gzip, halt, head, id, init, kill, killall,
ln, logger, ls, lsmod, mkdir, mknod, mkswap, more, mount, mv,
poweroff, ps, pwd, reboot, reset, rm, rmdir, sed, sh, sleep, sort,
swapoff, swapon, sync, syslogd, tail, tar, touch, true, tty, umount,
uname, uniq, uptime, wc, which, whoami, xargs, yes, zcat
[, basename, busybox, cat, chgrp, chmod, chown, chroot, chvt,
clear, cp, cut, date, dd, df, dirname, dmesg, du, echo, env, false,
find, free, grep, gunzip, gzip, halt, head, id, init, kill, killall,
klogd, linuxrc, ln, logger, ls, lsmod, mkdir, mknod, mkswap, modprobe,
more, mount, msh, mv, pidof, poweroff, ps, pwd, reboot, reset,
rm, rmdir, sed, sh, sleep, sort, swapoff, swapon, sync, syslogd,
tail, tar, test, touch, true, tty, umount, uname, uniq, uptime,
wc, which, whoami, xargs, yes, zcat
$ <blink>_</blink>
+21 -13
View File
@@ -136,19 +136,23 @@
</para>
<para>
ar, basename, cat, chgrp, chmod, chown, chroot, chvt, clear,
cp, cut, date, dc, dd, deallocvt, df, dirname, dmesg, dpkg-deb,
du, dumpkmap, dutmp, echo, false, fbset, fdflush, find, free,
freeramdisk, fsck.minix, grep, gunzip, gzip, halt, head,
hostid, hostname, id, init, insmod, kill, killall, length, ln,
loadacm, loadfont, loadkmap, logger, logname, ls, lsmod,
makedevs, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp,
more, mount, mt, mv, nc, nslookup, ping, poweroff, printf, ps,
pwd, reboot, renice, reset, rm, rmdir, rmmod, run-parts, sed, setkeycodes, sh, sleep,
sort, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet,
test, touch, tr, true, tty, umount, uname, uniq, update,
uptime, usleep, uudecode, uuencode, wc, which, whoami, yes,
zcat, [
addgroup, adduser, adjtimex, ar, basename, busybox, cat,
chgrp, chmod, chown, chroot, chvt, clear, cmp, cp, cpio, cut,
date, dc, dd, deallocvt, deluser, df, dirname, dmesg,
dos2unix, dpkg, dpkg-deb, du, dumpkmap, dutmp, echo, expr,
false, fbset, fdflush, find, free, freeramdisk, fsck.minix,
getopt, getty, grep, gunzip, gzip, halt, head, hostid,
hostname, id, ifconfig, init, insmod, kill, killall, klogd,
length, ln, loadacm, loadfont, loadkmap, logger, logname, ls,
lsmod, makedevs, md5sum, mkdir, mkfifo, mkfs.minix, mknod,
mkswap, mktemp, more, mount, mt, mv, nc, nslookup, ping,
pivot_root, poweroff, printf, ps, pwd, rdate, readlink,
reboot, renice, reset, rm, rmdir, rmmod, route, rpm2cpio,
sed, setkeycodes, sh, sleep, sort, stty, swapoff, swapon,
sync, syslogd, tail, tar, tee, telnet, test, tftp, touch, tr,
true, tty, umount, uname, uniq, unix2dos, update, uptime,
usleep, uudecode, uuencode, watchdog, wc, wget, which,
whoami, xargs, yes, zcat, [
</para>
</sect1>
@@ -3996,6 +4000,10 @@
Enrique Zanardi &lt;ezanardi@ull.es&gt;
</para>
<para>
Vladimir Oleynik &lt;dzo@simtreas.ru&gt;
</para>
</chapter>
</book> <!-- End of the book -->
+2 -2
View File
@@ -113,7 +113,7 @@ Glenn McGrath <bug1@netconnect.com.au>
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit, stty-port, locale, various fixes
cmdedit; ports: ash, stty, traceroute; locale, various fixes
and irreconcilable critic of everything not perfect.
=for html <br>
@@ -166,4 +166,4 @@ Enrique Zanardi <ezanardi@ull.es>
=cut
# $Id: busybox_footer.pod,v 1.4 2001/04/17 17:09:34 beppu Exp $
# $Id: busybox_footer.pod,v 1.5 2001/12/18 14:06:01 andersen Exp $
+14 -13
View File
@@ -55,19 +55,20 @@ terse runtime description of their behavior.
Currently defined functions include:
adjtimex, ar, basename, busybox, cat, chgrp, chmod, chown, chroot, chvt, clear,
cmp, cp, cpio, cut, date, dc, dd, deallocvt, df, dirname, dmesg, dos2unix, dpkg,
dpkg-deb, du, dumpkmap, dutmp, echo, expr, false, fbset, fdflush, find, free,
freeramdisk, fsck.minix, getopt, grep, gunzip, gzip, halt, head, hostid,
hostname, id, ifconfig, init, insmod, kill, killall, klogd, length, ln,
loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, md5sum,
mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc,
nslookup, ping, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, reboot,
renice, reset, rm, rmdir, rmmod, route, rpm2cpio, sed, setkeycodes,
sh, sleep, sort, stty, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet,
test, tftp, touch, tr, true, tty, umount, uname, uniq, unix2dos, update, uptime,
usleep, uudecode, uuencode, watchdog, wc, wget, which, whoami, xargs, yes, zcat,
[
addgroup, adduser, adjtimex, ar, basename, busybox, cat, chgrp, chmod,
chown, chroot, chvt, clear, cmp, cp, cpio, cut, date, dc, dd, deallocvt,
deluser, df, dirname, dmesg, dos2unix, dpkg, dpkg-deb, du, dumpkmap, dutmp,
echo, expr, false, fbset, fdflush, find, free, freeramdisk, fsck.minix,
getopt, getty, grep, gunzip, gzip, halt, head, hostid, hostname, id,
ifconfig, init, insmod, kill, killall, klogd, length, ln, loadacm,
loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, md5sum, mkdir,
mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc,
nslookup, ping, pivot_root, poweroff, printf, ps, pwd, rdate, readlink,
reboot, renice, reset, rm, rmdir, rmmod, route, rpm2cpio, sed, setkeycodes,
sh, sleep, sort, stty, swapoff, swapon, sync, syslogd, tail, tar, tee,
telnet, test, tftp, touch, tr, true, tty, umount, uname, uniq, unix2dos,
update, uptime, usleep, uudecode, uuencode, watchdog, wc, wget, which,
whoami, xargs, yes, zcat, [
=over 4
+5 -5
View File
@@ -5,7 +5,7 @@ This document describes what you need to do to contribute to Busybox, where
you can help, guidelines on testing, and how to submit a well-formed patch
that is more likely to be accepted.
The Busybox home page is at: http://busybox.lineo.com
The Busybox home page is at: http://busybox.net/
@@ -28,8 +28,8 @@ Don't make your work obsolete before you start!
For information on how to check out Busybox from CVS, please look at the
following links:
http://oss.lineo.com/cvs_anon.html
http://oss.lineo.com/cvs_howto.html
http://busybox.net/cvs_anon.html
http://busybox.net/cvs_howto.html
Read the Mailing List
@@ -43,7 +43,7 @@ know.
Archives can be found here:
http://opensource.lineo.com/lists/busybox/
http://busybox.net/lists/busybox/
If you have a serious interest in Busybox, i.e., you are using it day-to-day or
as part of an embedded project, it would be a good idea to join the mailing
@@ -51,7 +51,7 @@ list.
A web-based sign-up form can be found here:
http://opensource.lineo.com/mailman/listinfo/busybox
http://busybox.net/mailman/listinfo/busybox
Coordinate with the Applet Maintainer
+23 -7
View File
@@ -6,7 +6,7 @@ This document details the steps you must take to add a new applet to BusyBox.
Credits:
Matt Kraai - initial writeup
Mark Whitley - the remix
Thomas Lundquist - Added stuff for the new directory layout.
Initial Write
-------------
@@ -81,11 +81,25 @@ program that could be useful in another program, consider putting them in
libbb.
Placement / Directory
---------------------
Find the appropriate directory for your new applet.
Add the applet to the applet directory Makefile:
obj-$(CONFIG_MU) += mu.o
Add the applet to the applet directory config.in:
bool 'mu' CONFIG_MU
Usage String(s)
---------------
Next, add usage information for you applet to usage.h. This should look like
the following:
Next, add usage information for you applet to include/usage.h.
This should look like the following:
#define mu_trivial_usage \
"-[abcde] FILES"
@@ -104,9 +118,9 @@ currently exist in usage.h.)
Header Files
------------
Next, add an entry to applets.h. Be *sure* to keep the list in alphabetical
order, or else it will break the binary-search lookup algorithm in busybox.c
and the Gods of BusyBox smite you. Yea, verily:
Next, add an entry to include/applets.h. Be *sure* to keep the list
in alphabetical order, or else it will break the binary-search lookup
algorithm in busybox.c and the Gods of BusyBox smite you. Yea, verily:
/* all programs above here are alphabetically "less than" 'mu' */
#ifdef CONFIG_MU
@@ -126,13 +140,15 @@ Documentation
If you're feeling especially nice, you should also document your applet in the
docs directory (but nobody ever does that).
Adding some text to docs/Configure.help is a nice start.
The Grand Announcement
----------------------
Then create a diff -urN of the files you added (<applet>.c, usage.c,
applets.h, Config.h) and send it to the mailing list:
busybox@opensource.lineo.com. Sending patches as attachments is preferred, but
busybox@busybox.net. Sending patches as attachments is preferred, but
not required.
+9 -15
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,20 +17,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
TOPDIR :=..
L_TARGET := editors.a
obj-y :=
obj-n :=
obj- :=
obj-$(CONFIG_SED) += sed.o
obj-$(CONFIG_VI) += vi.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
TOPDIR:= ../
EDITOR_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+35
View File
@@ -0,0 +1,35 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
#
EDITOR_AR:=editors.a
ifndef $(EDITOR_DIR)
EDITOR_DIR:=$(TOPDIR)editors/
endif
EDITOR-y:=
EDITOR-$(CONFIG_SED) += sed.o
EDITOR-$(CONFIG_VI) += vi.o
EDITOR_SRC:= $(EDITOR-y)
EDITOR_OBJ:= $(patsubst %.c,$(EDITOR_DIR)%.o, $(EDITOR_SRC))
libraries-y+=$(EDITOR_DIR)$(EDITOR_AR)
$(EDITOR_DIR)$(EDITOR_AR): $(patsubst %,$(EDITOR_DIR)%, $(EDITOR-y))
$(AR) -ro $@ $(patsubst %,$(EDITOR_DIR)%, $(EDITOR-y))
+24 -36
View File
@@ -3,6 +3,7 @@
*
* Copyright (C) 1999,2000,2001 by Lineo, inc. and Mark Whitley
* Copyright (C) 1999,2000,2001 by Mark Whitley <markw@codepoet.org>
* Copyright (C) 2002 Matt Kraai
*
* 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
@@ -106,7 +107,7 @@ static int ncmds = 0; /* number of sed commands */
const char * const semicolon_whitespace = "; \n\r\t\v\0";
#ifdef CONFIG_FEATURE_CLEAN_UP
static void destroy_cmd_strs()
static void destroy_cmd_strs(void)
{
if (sed_cmds == NULL)
return;
@@ -296,9 +297,7 @@ static void move_back(char *str, int offset)
static int parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr)
{
int idx = 0;
int slashes_eaten = 0;
char *ptr; /* shorthand */
int i, j;
/*
* the string that gets passed to this function should look like this:
@@ -322,48 +321,28 @@ static int parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr)
*
*/
if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r'))
if (editstr[1] != '\\' || (editstr[2] != '\n' && editstr[2] != '\r'))
error_msg_and_die("bad format in edit expression");
/* store the edit line text */
/* make editline big enough to accomodate the extra '\n' we will tack on
* to the end */
sed_cmd->editline = xmalloc(strlen(&editstr[3]) + 2);
strcpy(sed_cmd->editline, &editstr[3]);
ptr = sed_cmd->editline;
/* now we need to go through * and: s/\\[\r\n]$/\n/g on the edit line */
while (ptr[idx]) {
while (ptr[idx] != '\\' || (ptr[idx+1] != '\n' && ptr[idx+1] != '\r')) {
idx++;
if (!ptr[idx]) {
goto out;
}
}
/* move the newline over the '\' before it (effectively eats the '\') */
move_back(&ptr[idx], 1);
slashes_eaten++;
/* substitue \r for \n if needed */
if (ptr[idx] == '\r')
ptr[idx] = '\n';
for (i = 3, j = 0; editstr[i] != '\0' && strchr("\r\n", editstr[i]) == NULL;
i++, j++) {
if (editstr[i] == '\\' && strchr("\n\r", editstr[i+1]) != NULL) {
sed_cmd->editline[j] = '\n';
i++;
} else
sed_cmd->editline[j] = editstr[i];
}
out:
/* figure out if we need to add a newline */
if (ptr[idx-1] != '\n') {
ptr[idx] = '\n';
idx++;
}
if (sed_cmd->editline[j-1] != '\n')
sed_cmd->editline[j++] = '\n';
/* terminate string */
ptr[idx]= 0;
sed_cmd->editline[j] = '\0';
/* this accounts for discrepancies between the modified string and the
* original string passed in to this function */
/* adjust for opening 2 chars [aic]\ */
return idx + slashes_eaten + 2;
return i;
}
@@ -422,6 +401,10 @@ static char *parse_cmd_str(struct sed_cmd * const sed_cmd, const char *const cmd
if (cmdstr[idx] == ',')
idx += get_address(sed_cmd, &cmdstr[++idx], &sed_cmd->end_line, &sed_cmd->end_match);
/* skip whitespace before the command */
while (isspace(cmdstr[idx]))
idx++;
/* last part (mandatory) will be a command */
if (cmdstr[idx] == '\0')
error_msg_and_die("missing command");
@@ -676,6 +659,7 @@ static void process_file(FILE *file)
/* we are currently within the beginning & ending address range */
still_in_range
) {
int deleted = 0;
/*
* actual sedding
@@ -688,6 +672,7 @@ static void process_file(FILE *file)
case 'd':
altered++;
deleted = 1;
break;
case 's':
@@ -789,6 +774,9 @@ static void process_file(FILE *file)
else {
still_in_range = 1;
}
if (deleted)
break;
}
}
+21 -21
View File
@@ -19,7 +19,7 @@
*/
static const char vi_Version[] =
"$Id: vi.c,v 1.19 2001/11/17 07:14:06 andersen Exp $";
"$Id: vi.c,v 1.21 2002/04/26 07:41:22 timr Exp $";
/*
* To compile for standalone use:
@@ -342,7 +342,7 @@ extern int vi_main(int argc, char **argv)
reg[i] = 0;
} // init the yank regs
#endif /* CONFIG_FEATURE_VI_YANKMARK */
#ifdef CONFIG_FEATURE_VI_DOT_CMD
#if defined(CONFIG_FEATURE_VI_DOT_CMD) || defined(CONFIG_FEATURE_VI_YANKMARK)
modifying_cmds = (Byte *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[]
#endif /* CONFIG_FEATURE_VI_DOT_CMD */
@@ -1219,7 +1219,7 @@ key_cmd_mode:
break;
if (strncasecmp((char *) p, "quit", cnt) == 0 ||
strncasecmp((char *) p, "q!", cnt) == 0) { // delete lines
if (file_modified == TRUE && p[1] != '!') {
if (file_modified && p[1] != '!') {
psbs("No write since last change (:quit! overrides)");
} else {
editing = 0;
@@ -1410,10 +1410,10 @@ key_cmd_mode:
indicate_error(c);
break;
}
if (file_modified == TRUE
if (file_modified
#ifdef CONFIG_FEATURE_VI_READONLY
&& vi_readonly == FALSE
&& readonly == FALSE
&& ! vi_readonly
&& ! readonly
#endif /* CONFIG_FEATURE_VI_READONLY */
) {
cnt = file_write(cfn, text, end - 1);
@@ -1829,7 +1829,7 @@ static void colon(Byte * buf)
int sr;
sr= 0;
// don't edit, if the current file has been modified
if (file_modified == TRUE && useforce != TRUE) {
if (file_modified && ! useforce) {
psbs("No write since last change (:edit! overrides)");
goto vc1;
}
@@ -1908,7 +1908,7 @@ static void colon(Byte * buf)
" %dL, %dC", cfn,
(sr < 0 ? " [New file]" : ""),
#ifdef CONFIG_FEATURE_VI_READONLY
((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""),
((vi_readonly || readonly) ? " [Read only]" : ""),
#endif /* CONFIG_FEATURE_VI_READONLY */
li, ch);
} else if (strncasecmp((char *) cmd, "file", i) == 0) { // what File is this
@@ -1961,7 +1961,7 @@ static void colon(Byte * buf)
Hit_Return();
} else if ((strncasecmp((char *) cmd, "quit", i) == 0) || // Quit
(strncasecmp((char *) cmd, "next", i) == 0)) { // edit next file
if (useforce == TRUE) {
if (useforce) {
// force end of argv list
if (*cmd == 'q') {
optind = save_argc;
@@ -1970,7 +1970,7 @@ static void colon(Byte * buf)
goto vc1;
}
// don't exit if the file been modified
if (file_modified == TRUE) {
if (file_modified) {
psbs("No write since last change (:%s! overrides)",
(*cmd == 'q' ? "quit" : "next"));
goto vc1;
@@ -2014,7 +2014,7 @@ static void colon(Byte * buf)
#endif /* CONFIG_FEATURE_VI_READONLY */
" %dL, %dC", fn,
#ifdef CONFIG_FEATURE_VI_READONLY
((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""),
((vi_readonly || readonly) ? " [Read only]" : ""),
#endif /* CONFIG_FEATURE_VI_READONLY */
li, ch);
if (ch > 0) {
@@ -2024,7 +2024,7 @@ static void colon(Byte * buf)
file_modified = TRUE;
}
} else if (strncasecmp((char *) cmd, "rewind", i) == 0) { // rewind cmd line args
if (file_modified == TRUE && useforce != TRUE) {
if (file_modified && ! useforce) {
psbs("No write since last change (:rewind! overrides)");
} else {
// reset the filenames to edit
@@ -2140,7 +2140,7 @@ static void colon(Byte * buf)
fn = args;
}
#ifdef CONFIG_FEATURE_VI_READONLY
if ((vi_readonly == TRUE || readonly == TRUE) && useforce == FALSE) {
if ((vi_readonly || readonly) && ! useforce) {
psbs("\"%s\" File is read only", fn);
goto vc3;
}
@@ -2149,14 +2149,14 @@ static void colon(Byte * buf)
li = count_lines(q, r);
ch = r - q + 1;
// see if file exists- if not, its just a new file request
if (useforce == TRUE) {
if (useforce) {
// if "fn" is not write-able, chmod u+w
// sprintf(syscmd, "chmod u+w %s", fn);
// system(syscmd);
forced = TRUE;
}
l = file_write(fn, q, r);
if (useforce == TRUE && forced == TRUE) {
if (useforce && forced) {
// chmod u-w
// sprintf(syscmd, "chmod u-w %s", fn);
// system(syscmd);
@@ -3527,7 +3527,7 @@ static int file_insert(Byte * fn, Byte * p, int size)
// see if we can open the file
#ifdef CONFIG_FEATURE_VI_READONLY
if (vi_readonly == TRUE) goto fi1; // do not try write-mode
if (vi_readonly) goto fi1; // do not try write-mode
#endif
fd = open((char *) fn, O_RDWR); // assume read & write
if (fd < 0) {
@@ -3623,7 +3623,7 @@ static void place_cursor(int row, int col, int opti)
//----- 1. Try the standard terminal ESC sequence
sprintf((char *) cm1, CMrc, row + 1, col + 1);
cm= cm1;
if (opti == FALSE) goto pc0;
if (! opti) goto pc0;
#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
//----- find the minimum # of chars to move cursor -------------
@@ -3798,9 +3798,9 @@ static void edit_status(void) // show file status on status line
"%s line %d of %d --%d%%--",
(cfn != 0 ? (char *) cfn : "No file"),
#ifdef CONFIG_FEATURE_VI_READONLY
((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""),
((vi_readonly || readonly) ? " [Read only]" : ""),
#endif /* CONFIG_FEATURE_VI_READONLY */
(file_modified == TRUE ? " [modified]" : ""),
(file_modified ? " [modified]" : ""),
cur, tot, percent);
}
@@ -3888,7 +3888,7 @@ static void refresh(int full_screen)
cs= 0;
ce= columns-1;
sp = &screen[li * columns]; // start of screen line
if (full_screen == TRUE) {
if (full_screen) {
// force re-draw of every single column from 0 - columns-1
goto re0;
}
@@ -3921,7 +3921,7 @@ static void refresh(int full_screen)
if (ce > columns-1) ce= columns-1;
if (cs > ce) { cs= 0; ce= columns-1; }
// is there a change between vitual screen and buf
if (changed == TRUE) {
if (changed) {
// copy changed part of buffer to virtual screen
memmove(sp+cs, buf+(cs+offset), ce-cs+1);
+1 -6
View File
@@ -6,7 +6,7 @@ components:
- Linux Kernel (http://www.kernel.org)
- uClibc: C library (http://cvs.uclinux.org/uClibc.html)
- Busybox: Unix utilities (http://busybox.lineo.com)
- Busybox: Unix utilities (http://busybox.net/)
- Syslinux: bootloader (http://syslinux.zytor.com)
It is based heavily on a paper presented by Erik Andersen at the 2001 Embedded
@@ -84,11 +84,6 @@ The following steps will create a root file system.
For this, just cp -a the etc/ directory onto rootfs. Again, if you want
all the details, you can just look at the files in the dir.
- Run ldconfig so busybox and other binaries can have access to the libraries
that they need:
(path to)uClibc/ld.so-1/util/ldconfig -r loop/
- Unmount the rootfs from the mountpoint:
umount loop
+2 -2
View File
@@ -12,8 +12,8 @@ Serial: %{serial}
Copyright: GPL
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
URL: http://busybox.lineo.com/
Source: ftp://oss.lineo.com/busybox/%{name}-%{version}.tar.gz
URL: http://busybox.net/
Source: ftp://busybox.net/busybox/%{name}-%{version}.tar.gz
Buildroot: /var/tmp/%{name}-%{version}
Packager : Erik Andersen <andersen@codepoet.org>
+6 -1
View File
@@ -24,7 +24,7 @@
# <runlevels>: The runlevels field is completely ignored.
#
# <action>: Valid actions include: sysinit, respawn, askfirst, wait, once,
# ctrlaltdel, and shutdown.
# restart, ctrlaltdel, and shutdown.
#
# Note: askfirst acts just like respawn, but before running the specified
# process it displays the line "Please press Enter to activate this
@@ -43,6 +43,8 @@
# ::ctrlaltdel:/sbin/reboot
# ::shutdown:/sbin/swapoff -a
# ::shutdown:/bin/umount -a -r
# ::restart:/sbin/init
#
# if it detects that /dev/console is _not_ a serial console, it will
# also run:
# tty2::askfirst:/bin/sh
@@ -79,6 +81,9 @@ tty5::respawn:/sbin/getty 38400 tty6
# Example how to put a getty on a modem line.
#::respawn:/sbin/getty 57600 ttyS2
# Stuff to do when restarting the init process
::restart:/sbin/init
# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
+9 -18
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,23 +17,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
TOPDIR :=..
L_TARGET := findutils.a
obj-y :=
obj-n :=
obj- :=
obj-$(CONFIG_FIND) += find.o
obj-$(CONFIG_GREP) += grep.o
obj-$(CONFIG_WHICH) += which.o
obj-$(CONFIG_XARGS) += xargs.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
TOPDIR:= ../
FINDUTILS_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+35
View File
@@ -0,0 +1,35 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
#
FINDUTILS_AR:=findutils.a
ifndef $(FINDUTILS_DIR)
FINDUTILS_DIR:=$(TOPDIR)findutils/
endif
FINDUTILS-y:=
FINDUTILS-$(CONFIG_FIND) += find.o
FINDUTILS-$(CONFIG_GREP) += grep.o
FINDUTILS-$(CONFIG_WHICH) += which.o
FINDUTILS-$(CONFIG_XARGS) += xargs.o
libraries-y+=$(FINDUTILS_DIR)$(FINDUTILS_AR)
$(FINDUTILS_DIR)$(FINDUTILS_AR): $(patsubst %,$(FINDUTILS_DIR)%, $(FINDUTILS-y))
$(AR) -ro $@ $(patsubst %,$(FINDUTILS_DIR)%, $(FINDUTILS-y))
+4 -4
View File
@@ -185,13 +185,13 @@ int find_main(int argc, char **argv)
}
if (firstopt == 1) {
if (recursive_action(".", TRUE, dereference, FALSE, fileAction,
fileAction, NULL) == FALSE)
if (! recursive_action(".", TRUE, dereference, FALSE, fileAction,
fileAction, NULL))
status = EXIT_FAILURE;
} else {
for (i = 1; i < firstopt; i++) {
if (recursive_action(argv[i], TRUE, dereference, FALSE, fileAction,
fileAction, NULL) == FALSE)
if (! recursive_action(argv[i], TRUE, dereference, FALSE, fileAction,
fileAction, NULL))
status = EXIT_FAILURE;
}
}
+2 -3
View File
@@ -234,7 +234,7 @@ static void destroy_regexes(void)
extern int grep_main(int argc, char **argv)
{
int opt;
#ifdef CONFIG_FEATURE_GREP_CONTEXT
#if defined (CONFIG_FEATURE_GREP_CONTEXT)
char *junk;
#endif
@@ -244,8 +244,7 @@ extern int grep_main(int argc, char **argv)
#endif
#ifdef CONFIG_FEATURE_GREP_EGREP_ALIAS
junk = get_last_path_component(argv[0]);
if (junk && strcmp(junk, "egrep") == 0)
if (strcmp(get_last_path_component(argv[0]), "egrep") == 0)
reflags |= REG_EXTENDED;
#endif
+10 -9
View File
@@ -38,15 +38,16 @@ extern int which_main(int argc, char **argv)
argc--;
path_list = getenv("PATH");
if (!path_list)
path_list = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";
/* Replace colons with zeros in path_parsed and count them */
for(i=strlen(path_list); i > 0; i--)
if (path_list[i]==':') {
path_list[i]=0;
count++;
}
if (path_list != NULL) {
for(i=strlen(path_list); i > 0; i--)
if (path_list[i]==':') {
path_list[i]=0;
count++;
}
} else {
path_list = "/bin\0/sbin\0/usr/bin\0/usr/sbin\0/usr/local/bin";
count = 5;
}
while(argc-- > 0) {
path_n = path_list;
+15
View File
@@ -71,6 +71,9 @@
#ifdef CONFIG_BUNZIP2
APPLET(bzcat, bunzip2_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_CAL
APPLET(cal, cal_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_CAT
APPLET(cat, cat_main, _BB_DIR_BIN)
#endif
@@ -266,6 +269,9 @@
#ifdef CONFIG_LOGREAD
APPLET(logread, logread_main, _BB_DIR_SBIN)
#endif
#ifdef CONFIG_LOSETUP
APPLET(losetup, losetup_main, _BB_DIR_SBIN)
#endif
#ifdef CONFIG_LS
APPLET(ls, ls_main, _BB_DIR_BIN)
#endif
@@ -437,6 +443,9 @@
#ifdef CONFIG_TFTP
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_TIME
APPLET(time, time_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_TOUCH
APPLET(touch, touch_main, _BB_DIR_BIN)
#endif
@@ -464,6 +473,9 @@
#ifdef CONFIG_UNIX2DOS
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_UNZIP
APPLET(unzip, unzip_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_UPDATE
APPLET(update, update_main, _BB_DIR_SBIN)
#endif
@@ -494,6 +506,9 @@
#ifdef CONFIG_WHICH
APPLET(which, which_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_WHO
APPLET(who, who_main, _BB_DIR_USR_BIN)
#endif
#ifdef CONFIG_WHOAMI
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
#endif
+7 -1
View File
@@ -101,6 +101,12 @@ extern const struct BB_applet applets[];
/* Pull in the utility routines from libbb */
#include "libbb.h"
/* Try to pull in PATH_MAX */
#include <limits.h>
/* for PATH_MAX on systems that don't have it in limits.h */
#include <sys/param.h>
#ifndef PATH_MAX
#define PATH_MAX 256
#endif
#endif /* _BB_INTERNAL_H_ */
+12 -1
View File
@@ -116,7 +116,7 @@ extern void write_mtab(char* blockDevice, char* directory,
char* filesystemType, long flags, char* string_flags);
extern void erase_mtab(const char * name);
extern long atoi_w_units (const char *cp);
extern pid_t* find_pid_by_name( char* pidName);
extern long* find_pid_by_name( char* pidName);
extern char *find_real_root_device_name(const char* name);
extern char *get_line_from_file(FILE *file);
extern void print_file(FILE *file);
@@ -215,6 +215,7 @@ extern long arith (const char *startbuf, int *errcode);
int read_package_field(const char *package_buffer, char **field_name, char **field_value);
char *fgets_str(FILE *file, const char *terminating_string);
extern int inflate(FILE *in, FILE *out);
extern int unzip(FILE *l_in_file, FILE *l_out_file);
extern void gz_close(int gunzip_pid);
extern FILE *gz_open(FILE *compressed_file, int *pid);
@@ -269,6 +270,7 @@ extern const char * const can_not_create_raw_socket;
# define SC_1 "/dev/tts/1"
# define VC_FORMAT "/dev/vc/%d"
# define SC_FORMAT "/dev/tts/%d"
# define LOOP_FORMAT "/dev/loop/%d"
#else
# define CURRENT_VC "/dev/tty0"
# define VC_1 "/dev/tty1"
@@ -280,10 +282,19 @@ extern const char * const can_not_create_raw_socket;
# define SC_1 "/dev/ttyS1"
# define VC_FORMAT "/dev/tty%d"
# define SC_FORMAT "/dev/ttyS%d"
# define LOOP_FORMAT "/dev/loop%d"
#endif
/* The following devices are the same on devfs and non-devfs systems. */
#define CURRENT_TTY "/dev/tty"
#define CONSOLE_DEV "/dev/console"
int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void);
/* Stupid gcc always includes its own builtin strlen()... */
extern size_t xstrlen(const char *string);
#define strlen(x) xstrlen(x)
#endif /* __LIBCONFIG_H__ */
+2
View File
@@ -26,11 +26,13 @@ typedef struct file_headers_s {
mode_t mode;
time_t mtime;
dev_t device;
int (*extract_func)(FILE *, FILE *);
} file_header_t;
file_header_t *get_header_ar(FILE *in_file);
file_header_t *get_header_cpio(FILE *src_stream);
file_header_t *get_header_tar(FILE *tar_stream);
file_header_t *get_header_zip(FILE *zip_stream);
void seek_sub_file(FILE *src_stream, const int count);
+80 -22
View File
@@ -52,17 +52,26 @@
"bar"
#define bunzip2_trivial_usage \
"[-c] FILE"
"[OPTION]... [FILE]"
#define bunzip2_full_usage \
"Uncompress FILE to current directory, stripping its .bz2 extension.\n"\
" -c output to stdout\n"\
" -k is assumed"
"Uncompress FILE (or standard input if FILE is '-' or omitted).\n\n" \
"Options:\n" \
"\t-c\tWrite output to standard output\n" \
"\t-f\tForce"
#define bzcat_trivial_usage \
"FILE"
#define bzcat_full_usage \
"Uncompress to stdout."
#define cal_trivial_usage \
"[-jy] [[month] year]"
#define cal_full_usage \
"Display a calendar.\n" \
"\nOptions:\n" \
"\t-j\tUse julian dates.\n" \
"\t-y\tDisplay the entire year."
#define cat_trivial_usage \
"[FILE]..."
#define cat_full_usage \
@@ -166,8 +175,8 @@
"\ti\t\textract\n" \
"\tm\t\tpreserve mtime\n" \
"\tt\t\tlist\n" \
"\tu\t\tunconditional overwrite\t" \
"\tF\t\tinput from file\t"
"\tu\t\tunconditional overwrite\n" \
"\tF\t\tinput from file"
#define cut_trivial_usage \
"[OPTION]... [FILE]..."
@@ -219,7 +228,7 @@
#define dd_trivial_usage \
"[if=FILE] [of=FILE] [bs=N] [count=N] [skip=N]\n" \
"\t [seek=N] [conv=notrunc|sync]"
"\t [seek=N] [conv=notrunc|noerror|sync]"
#define dd_full_usage \
"Copy a file, converting and formatting according to options\n\n" \
"\tif=FILE\t\tread from FILE instead of stdin\n" \
@@ -229,6 +238,7 @@
"\tskip=N\t\tskip N input blocks\n" \
"\tseek=N\t\tskip N output blocks\n" \
"\tconv=notrunc\tdon't truncate output file\n" \
"\tconv=noerror\tcontinue after read errors\n" \
"\tconv=sync\tpad blocks with zeros\n" \
"\n" \
"Numbers may be suffixed by c (x1), w (x2), b (x512), kD (x1000), k (x1024),\n" \
@@ -309,7 +319,7 @@
"\t-d\toutput will be in DOS format"
#define dpkg_trivial_usage \
"-i package_file\n"
"-i package_file\n" \
"[-CPru] package_name"
#define dpkg_full_usage \
"\t-i\tInstall the package\n" \
@@ -334,7 +344,7 @@
"$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
#define du_trivial_usage \
"[-ls" USAGE_HUMAN_READABLE("hm") USAGE_NOT_HUMAN_READABLE("") "k] [FILE]..."
"[-lsx" USAGE_HUMAN_READABLE("hm") USAGE_NOT_HUMAN_READABLE("") "k] [FILE]..."
#define du_full_usage \
"Summarizes disk space used for each FILE and/or directory.\n" \
"Disk space is printed in units of 1024 bytes.\n\n" \
@@ -344,6 +354,7 @@
USAGE_HUMAN_READABLE( \
"\n\t-h\tprint sizes in human readable format (e.g., 1K 243M 2G )\n" \
"\t-m\tprint sizes in megabytes\n" \
"\t-x\tskip directories on different filesystems\n" \
"\t-k\tprint sizes in kilobytes(default)") USAGE_NOT_HUMAN_READABLE( \
"\n\t-k\tprint sizes in kilobytes(compatibility)")
#define du_example_usage \
@@ -620,10 +631,10 @@
"-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n"
#define gzip_trivial_usage \
"[OPTION]... FILE"
"[OPTION]... [FILE]..."
#define gzip_full_usage \
"Compress FILE with maximum compression.\n" \
"When FILE is '-', reads standard input. Implies -c.\n\n" \
"Compress FILE(s) with maximum compression.\n" \
"When FILE is '-' or unspecified, reads standard input. Implies -c.\n\n" \
"Options:\n" \
"\t-c\tWrite output to standard output instead of FILE.gz\n" \
"\t-d\tdecompress"
@@ -680,11 +691,11 @@
"Get or set the hostname or DNS domain name. If a hostname is given\n" \
"(or FILE with the -F parameter), the host name will be set.\n\n" \
"Options:\n" \
"\t-s\t\tShort\n" \
"\t-i\t\tAddresses for the hostname\n" \
"\t-d\t\tDNS domain name\n" \
"\t-f\t\tFully qualified domain name\n" \
"\t-F, --file FILE\tUse the contents of FILE to specify the hostname"
"\t-s\tShort\n" \
"\t-i\tAddresses for the hostname\n" \
"\t-d\tDNS domain name\n" \
"\t-f\tFully qualified domain name\n" \
"\t-F FILE\tUse the contents of FILE to specify the hostname"
#define hostname_example_usage \
"$ hostname\n" \
"sage \n"
@@ -757,6 +768,7 @@
" ::ctrlaltdel:/sbin/reboot\n" \
" ::shutdown:/sbin/swapoff -a\n" \
" ::shutdown:/bin/umount -a -r\n" \
" ::restart:/sbin/init\n" \
"\n" \
"if it detects that /dev/console is _not_ a serial console, it will also run:\n" \
"\n" \
@@ -788,7 +800,7 @@
" <action>: \n" \
"\n" \
" Valid actions include: sysinit, respawn, askfirst, wait, \n" \
" once, ctrlaltdel, and shutdown.\n" \
" once, restart, ctrlaltdel, and shutdown.\n" \
"\n" \
" The available actions can be classified into two groups: actions\n" \
" that are run only once, and actions that are re-run when the specified\n" \
@@ -801,7 +813,10 @@
" completion of all sysinit actions, all 'wait' actions are run.\n" \
" 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \
" the specified task completes. 'once' actions are asynchronous,\n" \
" therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \
" therefore, init does not wait for them to complete. 'restart' is\n" \
" the action taken to restart the init process. By default this should\n" \
" simply run /sbin/init, but can be a script which runs pivot_root or it\n" \
" can do all sorts of other interesting things. The 'ctrlaltdel' init\n" \
" actions are run when the system detects that someone on the system\n" \
" console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \
" wants to run 'reboot' at this point to cause the system to reboot.\n" \
@@ -857,6 +872,9 @@
" # Example how to put a getty on a modem line.\n" \
" #::respawn:/sbin/getty 57600 ttyS2\n" \
" \n" \
" # Stuff to do when restarting the init process\n" \
" ::restart:/sbin/init\n" \
" \n" \
" # Stuff to do before rebooting\n" \
" ::ctrlaltdel:/sbin/reboot\n" \
" ::shutdown:/bin/umount -a -r\n" \
@@ -974,6 +992,15 @@
#define logread_full_usage \
"Shows the messages from syslogd (using circular buffer)."
#define losetup_trivial_usage \
"[OPTION]... LOOPDEVICE FILE\n" \
"or: losetup [OPTION]... -d LOOPDEVICE"
#define losetup_full_usage \
"Associate LOOPDEVICE with FILE.\n\n" \
"Options:\n" \
"\t-d\t\tDisassociate LOOPDEVICE.\n" \
"\t-o OFFSET\tStart OFFSET bytes into FILE.\n"
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
#define USAGE_LS_TIMESTAMPS(a) a
#else
@@ -1235,9 +1262,14 @@
"$ mv /tmp/foo /bin/bar\n"
#define nc_trivial_usage \
"[IP] [port]"
"[OPTIONS] [IP] [port]"
#define nc_full_usage \
"Netcat opens a pipe to IP:port"
"Netcat opens a pipe to IP:port\n\n" \
"Options:\n" \
"\t-l\t\tlisten mode, for inbound connects\n" \
"\t-p PORT\t\tlocal port number\n" \
"\t-i SECS\t\tdelay interval for lines sent\n" \
"\t-e PROG\t\tprogram to exec after connect (dangerous!)"
#define nc_example_usage \
"$ nc foobar.somedomain.com 25\n" \
"220 foobar ESMTP Exim 3.12 #1 Sat, 15 Apr 2000 00:03:02 -0600\n" \
@@ -1416,7 +1448,9 @@
#define route_trivial_usage \
"[{add|del|flush}]"
#define route_full_usage \
"Edit the kernel's routing tables"
"Edit the kernel's routing tables.\n\n" \
"Options:\n" \
"\t-n\tDont resolve names."
#define rpm2cpio_trivial_usage \
"package.rpm"
@@ -1701,6 +1735,13 @@
USAGE_TFTP_BS( \
"\t-b SIZE\tTransfer blocks of SIZE octets.\n" \
)
#define time_trivial_usage \
"[OPTION]... COMMAND [ARGS...]"
#define time_full_usage \
"Runs the program COMMAND with arguments ARGS. When COMMAND finishes,\n" \
"COMMAND's resource usage information is displayed\n\n" \
"Options:\n" \
"\t-v\tDisplays verbose resource usage information."
#define touch_trivial_usage \
"[-c] FILE [FILE ...]"
@@ -1827,6 +1868,19 @@
"\t-u\toutput will be in UNIX format\n" \
"\t-d\toutput will be in DOS format"
#define unzip_trivial_usage \
"[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]"
#define unzip_full_usage \
"Extracts files from ZIP archives.\n\n" \
"Options:\n" \
"\t-l\tlist archive contents (short form)\n" \
"\t-n\tnever overwrite existing files (default)\n" \
"\t-o\toverwrite files without prompting\n" \
"\t-p\tsend output to stdout\n" \
"\t-q\tbe quiet\n" \
"\t-x\texclude these files\n" \
"\t-d\textract files into this directory"
#define update_trivial_usage \
"[options]"
#define update_full_usage \
@@ -1919,6 +1973,10 @@
#define which_example_usage \
"$ which login\n" \
"/bin/login\n"
#define who_trivial_usage \
" "
#define who_full_usage \
"Prints the current user names and related information"
#define whoami_trivial_usage \
""
+9 -19
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -17,24 +17,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
TOPDIR :=..
L_TARGET := init.a
obj-y :=
obj-n :=
obj- :=
obj-$(CONFIG_HALT) += halt.o
obj-$(CONFIG_INIT) += init.o
obj-$(CONFIG_POWEROFF) += poweroff.o
obj-$(CONFIG_REBOOT) += reboot.o
obj-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
obj-$(CONFIG_RUN_PARTS) += run_parts.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
TOPDIR:= ../
INIT_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+37
View File
@@ -0,0 +1,37 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
#
INIT_AR:=init.a
ifndef $(INIT_DIR)
INIT_DIR:=$(TOPDIR)init/
endif
INIT-y:=
INIT-$(CONFIG_HALT) += halt.o
INIT-$(CONFIG_INIT) += init.o
INIT-$(CONFIG_POWEROFF) += poweroff.o
INIT-$(CONFIG_REBOOT) += reboot.o
INIT-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
INIT-$(CONFIG_RUN_PARTS) += run_parts.o
libraries-y+=$(INIT_DIR)$(INIT_AR)
$(INIT_DIR)$(INIT_AR): $(patsubst %,$(INIT_DIR)%, $(INIT-y))
$(AR) -ro $@ $(patsubst %,$(INIT_DIR)%, $(INIT-y))
+2 -2
View File
@@ -2,8 +2,8 @@
/*
* Mini halt implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
* Copyright (C) 1999-2002 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
@@ -28,7 +28,7 @@ extern int halt_main(int argc, char **argv)
{
#ifdef CONFIG_FEATURE_INITRD
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
long *pid = find_pid_by_name("init");
if (!pid || *pid<=0) {
pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
+334 -218
View File
@@ -2,8 +2,8 @@
/*
* Mini init implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
* Copyright (C) 1999-2002 by Erik Andersen <andersee@debian.org>
* Adjusted by so many folks, it's impossible to keep track.
*
* This program is free software; you can redistribute it and/or modify
@@ -47,6 +47,9 @@
# include <sys/syslog.h>
#endif
#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__)
#define fork vfork
#endif
/* From <linux/vt.h> */
struct vt_stat {
@@ -82,19 +85,10 @@ struct serial_struct {
#define init_reboot(magic) reboot(0xfee1dead, 672274793, magic)
#endif
#ifndef RB_HALT_SYSTEM
static const int RB_HALT_SYSTEM = 0xcdef0123;
static const int RB_ENABLE_CAD = 0x89abcdef;
static const int RB_DISABLE_CAD = 0;
#define RB_POWER_OFF 0x4321fedc
static const int RB_AUTOBOOT = 0x01234567;
#endif
#ifndef _PATH_STDPATH
#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
#endif
#if defined CONFIG_FEATURE_INIT_COREDUMPS
/*
* When a file named CORE_ENABLE_FLAG_FILE exists, setrlimit is called
@@ -115,7 +109,6 @@ static const int RB_AUTOBOOT = 0x01234567;
extern int bdflush (int func, long int data);
#endif
#define SHELL "/bin/sh" /* Default shell */
#define LOGIN_SHELL "-" SHELL /* Default login shell */
#define INITTAB "/etc/inittab" /* inittab file location */
@@ -124,34 +117,24 @@ static const int RB_AUTOBOOT = 0x01234567;
#endif
#define MAXENV 16 /* Number of env. vars */
//static const int MAXENV = 16; /* Number of env. vars */
static const int LOG = 0x1;
static const int CONSOLE = 0x2;
#if defined BB_FEATURE_EXTRA_QUIET
static const int MAYBE_CONSOLE = 0x0;
#else
#define MAYBE_CONSOLE CONSOLE
#endif
/* Allowed init action types */
typedef enum {
SYSINIT = 1,
RESPAWN,
ASKFIRST,
WAIT,
ONCE,
CTRLALTDEL,
SHUTDOWN
} initActionEnum;
#define SYSINIT 0x001
#define RESPAWN 0x002
#define ASKFIRST 0x004
#define WAIT 0x008
#define ONCE 0x010
#define CTRLALTDEL 0x020
#define SHUTDOWN 0x040
#define RESTART 0x080
/* A mapping between "inittab" action name strings and action type codes. */
typedef struct initActionType {
struct init_action_type {
const char *name;
initActionEnum action;
} initActionType;
int action;
};
static const struct initActionType actions[] = {
static const struct init_action_type actions[] = {
{"sysinit", SYSINIT},
{"respawn", RESPAWN},
{"askfirst", ASKFIRST},
@@ -159,21 +142,21 @@ static const struct initActionType actions[] = {
{"once", ONCE},
{"ctrlaltdel", CTRLALTDEL},
{"shutdown", SHUTDOWN},
{"restart", RESTART},
{0, 0}
};
/* Set up a linked list of initActions, to be read from inittab */
typedef struct initActionTag initAction;
struct initActionTag {
/* Set up a linked list of init_actions, to be read from inittab */
struct init_action {
pid_t pid;
char process[256];
char console[256];
initAction *nextPtr;
initActionEnum action;
char command[256];
char terminal[256];
struct init_action *next;
int action;
};
static initAction *initActionList = NULL;
/* Static variables */
static struct init_action *init_action_list = NULL;
static char *secondConsole = VC_2;
static char *thirdConsole = VC_3;
static char *fourthConsole = VC_4;
@@ -181,8 +164,26 @@ static char *log = VC_5;
static int kernelVersion = 0;
static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE;
static sig_atomic_t got_cont = 0;
static const int LOG = 0x1;
static const int CONSOLE = 0x2;
#if defined CONFIG_FEATURE_EXTRA_QUIET
static const int MAYBE_CONSOLE = 0x0;
#else
#define MAYBE_CONSOLE CONSOLE
#endif
#ifndef RB_HALT_SYSTEM
static const int RB_HALT_SYSTEM = 0xcdef0123;
static const int RB_ENABLE_CAD = 0x89abcdef;
static const int RB_DISABLE_CAD = 0;
#define RB_POWER_OFF 0x4321fedc
static const int RB_AUTOBOOT = 0x01234567;
#endif
/* Function prototypes */
static void delete_init_action(struct init_action *a);
static int waitfor(struct init_action *a);
static void delete_initAction(initAction * action);
static void loop_forever(void)
{
@@ -197,8 +198,7 @@ static inline messageND(int device, char *fmt, ...) { }
#else
#define messageND message
#endif
static void message(int device, char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
static void message(int device, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
static void message(int device, char *fmt, ...)
{
va_list arguments;
@@ -213,7 +213,7 @@ static void message(int device, char *fmt, ...)
va_start(arguments, fmt);
vsnprintf(msg, sizeof(msg), fmt, arguments);
va_end(arguments);
syslog_msg(LOG_USER, LOG_USER|LOG_INFO, msg);
syslog_msg(LOG_USER, LOG_INFO, msg);
}
#else
static int log_fd = -1;
@@ -244,8 +244,7 @@ static void message(int device, char *fmt, ...)
/* Always send console messages to /dev/console so people will see them. */
if (
(fd =
device_open(_PATH_CONSOLE,
O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0) {
device_open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0) {
va_start(arguments, fmt);
vdprintf(fd, fmt, arguments);
va_end(arguments);
@@ -380,8 +379,8 @@ static void console_init(void)
/* Perhaps we should panic here? */
safe_strncpy(console, "/dev/null", sizeof(console));
} else {
/* check for serial console and disable logging to tty5 & running a
* shell to tty2-4 */
/* check for serial console and disable logging to tty5 &
* running a shell to tty2-4 */
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
log = NULL;
secondConsole = NULL;
@@ -392,7 +391,7 @@ static void console_init(void)
if (strcmp( termType, "TERM=linux" ) == 0)
safe_strncpy(termType, "TERM=vt102", sizeof(termType));
message(LOG | CONSOLE,
"serial console detected. Disabling virtual terminals.\n");
"\rserial console detected. Disabling virtual terminals.\n");
}
close(fd);
}
@@ -415,23 +414,41 @@ static void fixup_argv(int argc, char **argv, char *new_argv0)
}
}
static pid_t run(char *command, char *terminal, int get_enter)
/* Make sure there is enough memory to do something useful. *
* Calls "swapon -a" if needed so be sure /etc/fstab is present... */
static void check_memory(void)
{
int i, j;
int fd;
pid_t pid;
char *tmpCmd, *s;
char *cmd[255], *cmdpath;
char buf[255];
struct stat sb;
static const char press_enter[] =
struct stat statBuf;
#ifdef CUSTOMIZED_BANNER
#include CUSTOMIZED_BANNER
if (check_free_memory() > 1000)
return;
#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__)
if (stat("/etc/fstab", &statBuf) == 0) {
/* swapon -a requires /proc typically */
system("/bin/mount -t proc proc /proc");
/* Try to turn on swap */
system("/sbin/swapon -a");
if (check_free_memory() < 1000)
goto goodnight;
} else
goto goodnight;
return;
#endif
"\nPlease press Enter to activate this console. ";
goodnight:
message(CONSOLE,
"\rSorry, your computer does not have enough memory.\n");
loop_forever();
}
static pid_t run(struct init_action *a)
{
struct stat sb;
int i, j, fd, junk;
pid_t pid, pgrp, tmp_pid;
char *s, *tmpCmd, *cmd[255], *cmdpath, buf[255];
sigset_t nmask, omask;
char *environment[MAXENV+1] = {
termType,
"HOME=/",
@@ -440,6 +457,11 @@ static pid_t run(char *command, char *terminal, int get_enter)
"USER=root",
NULL
};
static const char press_enter[] =
#ifdef CUSTOMIZED_BANNER
#include CUSTOMIZED_BANNER
#endif
"\nPlease press Enter to activate this console. ";
/* inherit environment to the child, merging our values -andy */
for (i=0; environ[i]; i++) {
@@ -454,54 +476,117 @@ static pid_t run(char *command, char *terminal, int get_enter)
}
}
#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__)
/* Block sigchild while forking. */
sigemptyset(&nmask);
sigaddset(&nmask, SIGCHLD);
sigprocmask(SIG_BLOCK, &nmask, &omask);
if ((pid = fork()) == 0)
#else
if ((pid = vfork()) == 0)
#endif
{
/* Clean up */
ioctl(0, TIOCNOTTY, 0);
close(0);
close(1);
close(2);
sigprocmask(SIG_SETMASK, &omask, NULL);
/* Create a new session and make ourself the process group leader */
setsid();
/* Reset signal handlers set for parent process */
/* Reset signal handlers that were set by the parent process */
signal(SIGUSR1, SIG_DFL);
signal(SIGUSR2, SIG_DFL);
signal(SIGINT, SIG_DFL);
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
signal(SIGHUP, SIG_DFL);
signal(SIGCONT, SIG_DFL);
signal(SIGSTOP, SIG_DFL);
signal(SIGTSTP, SIG_DFL);
if ((fd = device_open(terminal, O_RDWR)) < 0) {
if (stat(terminal, &sb) != 0) {
message(LOG | CONSOLE, "device '%s' does not exist.\n",
terminal);
exit(1);
/* Open the new terminal device */
if ((fd = device_open(a->terminal, O_RDWR|O_NOCTTY)) < 0) {
if (stat(a->terminal, &sb) != 0) {
message(LOG | CONSOLE, "\rdevice '%s' does not exist.\n",
a->terminal);
_exit(1);
}
message(LOG | CONSOLE, "Bummer, can't open %s\n", terminal);
exit(1);
message(LOG | CONSOLE, "\rBummer, can't open %s\n", a->terminal);
_exit(1);
}
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
ioctl(0, TIOCSCTTY, 1);
tcsetpgrp(0, getpgrp());
/* Make sure the terminal will act fairly normal for us */
set_term(0);
/* If the init Action requires up to wait, then force the
* supplied terminal to be the controlling tty. */
if (a->action & (SYSINIT|WAIT|CTRLALTDEL|SHUTDOWN|RESTART|ASKFIRST)) {
/* Take over the controlling tty */
ioctl(fd, TIOCSCTTY, 1);
/* Setup stdin, stdout, stderr for the new process so
* they point to the supplied terminal */
dup(fd);
dup(fd);
/* Now fork off another process to just hang around */
if ((pid = fork()) < 0) {
message(LOG | CONSOLE, "Can't fork!\n");
_exit(1);
}
if (pid > 0) {
/* We are the parent -- wait till the child is done */
signal(SIGINT, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGCHLD, SIG_DFL);
/* Wait for child to exit */
while ((tmp_pid = waitpid(pid, &junk, 0)) != pid) {
if (tmp_pid < 0 && errno == ECHILD)
break;
}
/* See if stealing the controlling tty back is necessary */
pgrp = tcgetpgrp(tmp_pid);
if (pgrp != getpid())
_exit(0);
/* Use a temporary process to steal the controlling tty. */
if ((pid = fork()) < 0) {
message(LOG | CONSOLE, "\rCan't fork!\n");
_exit(1);
}
if (pid == 0) {
setsid();
ioctl(tmp_pid, TIOCSCTTY, 1);
_exit(0);
}
while((tmp_pid = waitpid(pid, &junk, 0)) != pid) {
if (tmp_pid < 0 && errno == ECHILD)
break;
}
_exit(0);
}
/* Now fall though to actually execute things */
} else {
dup(fd);
dup(fd);
}
/* See if any special /bin/sh requiring characters are present */
if (strpbrk(command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) {
if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) {
cmd[0] = SHELL;
cmd[1] = "-c";
strcpy(buf, "exec ");
safe_strncpy(buf + sizeof("exec "), command,
safe_strncpy(buf + sizeof("exec "), a->command,
sizeof(buf) - sizeof("exec "));
cmd[2] = buf;
cmd[3] = NULL;
} else {
/* Convert command (char*) into cmd (char**, one word per string) */
safe_strncpy(buf, command, sizeof(buf));
safe_strncpy(buf, a->command, sizeof(buf));
s = buf;
for (tmpCmd = buf, i = 0;
(tmpCmd = strsep(&s, " \t")) != NULL;) {
@@ -541,7 +626,7 @@ static pid_t run(char *command, char *terminal, int get_enter)
}
}
if (get_enter == TRUE) {
if (a->action & ASKFIRST) {
/*
* Save memory by not exec-ing anything large (like a shell)
* before the user wants it. This is critical if swap is not
@@ -550,15 +635,15 @@ static pid_t run(char *command, char *terminal, int get_enter)
* be allowed to start a shell or whatever an init script
* specifies.
*/
messageND(LOG, "Waiting for enter to start '%s' (pid %d, console %s)\n",
cmd[0], getpid(), terminal);
messageND(LOG, "Waiting for enter to start '%s' (pid %d, terminal %s)\n",
cmdpath, getpid(), a->terminal);
write(fileno(stdout), press_enter, sizeof(press_enter) - 1);
getc(stdin);
}
/* Log the process name and args */
messageND(LOG, "Starting pid %d, console %s: '%s'\n",
getpid(), terminal, command);
getpid(), a->terminal, cmdpath);
#if defined CONFIG_FEATURE_INIT_COREDUMPS
if (stat (CORE_ENABLE_FLAG_FILE, &sb) == 0) {
@@ -574,18 +659,20 @@ static pid_t run(char *command, char *terminal, int get_enter)
execve(cmdpath, cmd, environment);
/* We're still here? Some error happened. */
message(LOG | CONSOLE, "Bummer, could not run '%s': %s\n", cmdpath,
message(LOG | CONSOLE, "\rBummer, could not run '%s': %s\n", cmdpath,
strerror(errno));
exit(-1);
_exit(-1);
}
sigprocmask(SIG_SETMASK, &omask, NULL);
return pid;
}
static int waitfor(char *command, char *terminal, int get_enter)
static int waitfor(struct init_action *a)
{
int pid;
int status, wpid;
int pid = run(command, terminal, get_enter);
pid = run(a);
while (1) {
wpid = wait(&status);
if (wpid > 0 && wpid != pid) {
@@ -597,43 +684,27 @@ static int waitfor(char *command, char *terminal, int get_enter)
return wpid;
}
/* Make sure there is enough memory to do something useful. *
* Calls "swapon -a" if needed so be sure /etc/fstab is present... */
static void check_memory(void)
/* Run all commands of a particular type */
static void run_actions(int action)
{
struct stat statBuf;
struct init_action *a, *tmp;
if (check_free_memory() > 1000)
return;
#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__)
if (stat("/etc/fstab", &statBuf) == 0) {
/* swapon -a requires /proc typically */
waitfor("mount proc /proc -t proc", console, FALSE);
/* Try to turn on swap */
waitfor("swapon -a", console, FALSE);
if (check_free_memory() < 1000)
goto goodnight;
} else
goto goodnight;
return;
#endif
goodnight:
message(CONSOLE,
"Sorry, your computer does not have enough memory.\n");
loop_forever();
}
/* Run all commands to be run right before halt/reboot */
static void run_actions(initActionEnum action)
{
initAction *a, *tmp;
for (a = initActionList; a; a = tmp) {
tmp = a->nextPtr;
for (a = init_action_list; a; a = tmp) {
tmp = a->next;
if (a->action == action) {
waitfor(a->process, a->console, FALSE);
delete_initAction(a);
if (a->action & (SYSINIT|WAIT|CTRLALTDEL|SHUTDOWN|RESTART)) {
waitfor(a);
delete_init_action(a);
} else if (a->action & ONCE) {
run(a);
delete_init_action(a);
} else if (a->action & (RESPAWN|ASKFIRST)) {
/* Only run stuff with pid==0. If they have
* a pid, that means it is still running */
if (a->pid == 0) {
a->pid = run(a);
}
}
}
}
}
@@ -652,21 +723,24 @@ static void shutdown_system(void)
sigaddset(&block_signals, SIGUSR2);
sigaddset(&block_signals, SIGINT);
sigaddset(&block_signals, SIGTERM);
sigaddset(&block_signals, SIGCONT);
sigaddset(&block_signals, SIGSTOP);
sigaddset(&block_signals, SIGTSTP);
sigprocmask(SIG_BLOCK, &block_signals, NULL);
/* Allow Ctrl-Alt-Del to reboot system. */
init_reboot(RB_ENABLE_CAD);
message(CONSOLE|LOG, "\nThe system is going down NOW !!\n");
message(CONSOLE|LOG, "\n\rThe system is going down NOW !!\n");
sync();
/* Send signals to every process _except_ pid 1 */
message(CONSOLE|LOG, "Sending SIGTERM to all processes.\n");
message(CONSOLE|LOG, "\rSending SIGTERM to all processes.\n");
kill(-1, SIGTERM);
sleep(1);
sync();
message(CONSOLE|LOG, "Sending SIGKILL to all processes.\n");
message(CONSOLE|LOG, "\rSending SIGKILL to all processes.\n");
kill(-1, SIGKILL);
sleep(1);
@@ -681,16 +755,36 @@ static void shutdown_system(void)
}
}
static void exec_signal(int sig)
{
struct init_action *a, *tmp;
for (a = init_action_list; a; a = tmp) {
tmp = a->next;
if (a->action & RESTART) {
shutdown_system();
message(CONSOLE|LOG, "\rTrying to re-exec %s\n", a->command);
execl(a->command, a->command, NULL);
message(CONSOLE|LOG, "\rexec of '%s' failed: %s\n",
a->command, sys_errlist[errno]);
sync();
sleep(2);
init_reboot(RB_HALT_SYSTEM);
loop_forever();
}
}
}
static void halt_signal(int sig)
{
shutdown_system();
message(CONSOLE|LOG,
#if #cpu(s390)
/* Seems the s390 console is Wierd(tm). */
"The system is halted. You may reboot now.\n",
"\rThe system is halted. You may reboot now.\n"
#else
/* secondConsole is NULL for a serial console */
"The system is halted. Press %s or turn off power\n",
"\rThe system is halted. Press %s or turn off power\n",
(secondConsole == NULL)? "Reset" : "CTRL-ALT-DEL"
#endif
);
@@ -710,7 +804,7 @@ static void halt_signal(int sig)
static void reboot_signal(int sig)
{
shutdown_system();
message(CONSOLE|LOG, "Please stand by while rebooting the system.\n");
message(CONSOLE|LOG, "\rPlease stand by while rebooting the system.\n");
sync();
/* allow time for last message to reach serial console */
@@ -726,55 +820,73 @@ static void ctrlaltdel_signal(int sig)
run_actions(CTRLALTDEL);
}
/* The SIGSTOP & SIGTSTP handler */
static void stop_handler(int sig)
{
int saved_errno = errno;
got_cont = 0;
while(!got_cont) pause();
got_cont = 0;
errno = saved_errno;
}
/* The SIGCONT handler */
static void cont_handler(int sig)
{
got_cont = 1;
}
#endif /* ! DEBUG_INIT */
static void new_initAction(initActionEnum action, char *process, char *cons)
static void new_init_action(int action, char *command, char *cons)
{
initAction *newAction;
initAction *a;
struct init_action *new_action, *a;
if (*cons == '\0')
cons = console;
/* If BusyBox detects that a serial console is in use,
* then entries not refering to the console or null devices will _not_ be run.
/* If BusyBox detects that a serial console is in use, then entries
* not refering to the console or null devices will _not_ be run.
* The exception to this rule is the null device.
*/
if (secondConsole == NULL && strcmp(cons, console)
&& strcmp(cons, "/dev/null"))
return;
if (strcmp(cons, "/dev/null") == 0 && action == ASKFIRST)
if (strcmp(cons, "/dev/null") == 0 && (action & ASKFIRST))
return;
newAction = calloc((size_t) (1), sizeof(initAction));
if (!newAction) {
message(LOG | CONSOLE, "Memory allocation failure\n");
new_action = calloc((size_t) (1), sizeof(struct init_action));
if (!new_action) {
message(LOG | CONSOLE, "\rMemory allocation failure\n");
loop_forever();
}
for (a = initActionList; a && a->nextPtr; a = a->nextPtr) ;
/* Append to the end of the list */
for (a = init_action_list; a && a->next; a = a->next) ;
if (a) {
a->nextPtr = newAction;
a->next = new_action;
} else {
initActionList = newAction;
init_action_list = new_action;
}
safe_strncpy(newAction->process, process, 255);
newAction->action = action;
safe_strncpy(newAction->console, cons, 255);
newAction->pid = 0;
// message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n",
// newAction->process, newAction->action, newAction->console);
safe_strncpy(new_action->command, command, 255);
new_action->action = action;
safe_strncpy(new_action->terminal, cons, 255);
new_action->pid = 0;
// message(LOG|CONSOLE, "command='%s' action='%d' terminal='%s'\n",
// new_action->command, new_action->action, new_action->terminal);
}
static void delete_initAction(initAction * action)
static void delete_init_action(struct init_action * action)
{
initAction *a, *b = NULL;
struct init_action *a, *b = NULL;
for (a = initActionList; a; b = a, a = a->nextPtr) {
for (a = init_action_list; a; b = a, a = a->next) {
if (a == action) {
if (b == NULL) {
initActionList = a->nextPtr;
init_action_list = a->next;
} else {
b->nextPtr = a->nextPtr;
b->next = a->next;
}
free(a);
break;
@@ -794,8 +906,8 @@ static void parse_inittab(void)
#ifdef CONFIG_FEATURE_USE_INITTAB
FILE *file;
char buf[256], lineAsRead[256], tmpConsole[256];
char *id, *runlev, *action, *process, *eol;
const struct initActionType *a = actions;
char *id, *runlev, *action, *command, *eol;
const struct init_action_type *a = actions;
int foundIt;
@@ -804,26 +916,28 @@ static void parse_inittab(void)
/* No inittab file -- set up some default behavior */
#endif
/* Reboot on Ctrl-Alt-Del */
new_initAction(CTRLALTDEL, "/sbin/reboot", console);
new_init_action(CTRLALTDEL, "/sbin/reboot", console);
/* Umount all filesystems on halt/reboot */
new_initAction(SHUTDOWN, "/bin/umount -a -r", console);
new_init_action(SHUTDOWN, "/bin/umount -a -r", console);
#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__)
/* Swapoff on halt/reboot */
new_initAction(SHUTDOWN, "/sbin/swapoff -a", console);
new_init_action(SHUTDOWN, "/sbin/swapoff -a", console);
#endif
/* Prepare to restart init when a HUP is received */
new_init_action(RESTART, "/sbin/init", console);
/* Askfirst shell on tty1 */
new_initAction(ASKFIRST, LOGIN_SHELL, console);
new_init_action(ASKFIRST, LOGIN_SHELL, console);
/* Askfirst shell on tty2 */
if (secondConsole != NULL)
new_initAction(ASKFIRST, LOGIN_SHELL, secondConsole);
new_init_action(ASKFIRST, LOGIN_SHELL, secondConsole);
/* Askfirst shell on tty3 */
if (thirdConsole != NULL)
new_initAction(ASKFIRST, LOGIN_SHELL, thirdConsole);
new_init_action(ASKFIRST, LOGIN_SHELL, thirdConsole);
/* Askfirst shell on tty4 */
if (fourthConsole != NULL)
new_initAction(ASKFIRST, LOGIN_SHELL, fourthConsole);
new_init_action(ASKFIRST, LOGIN_SHELL, fourthConsole);
/* sysinit */
new_initAction(SYSINIT, INIT_SCRIPT, console);
new_init_action(SYSINIT, INIT_SCRIPT, console);
return;
#ifdef CONFIG_FEATURE_USE_INITTAB
@@ -849,7 +963,7 @@ static void parse_inittab(void)
/* Separate the ID field from the runlevels */
runlev = strchr(id, ':');
if (runlev == NULL || *(runlev + 1) == '\0') {
message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead);
message(LOG | CONSOLE, "\rBad inittab entry: %s\n", lineAsRead);
continue;
} else {
*runlev = '\0';
@@ -859,21 +973,21 @@ static void parse_inittab(void)
/* Separate the runlevels from the action */
action = strchr(runlev, ':');
if (action == NULL || *(action + 1) == '\0') {
message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead);
message(LOG | CONSOLE, "\rBad inittab entry: %s\n", lineAsRead);
continue;
} else {
*action = '\0';
++action;
}
/* Separate the action from the process */
process = strchr(action, ':');
if (process == NULL || *(process + 1) == '\0') {
message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead);
/* Separate the action from the command */
command = strchr(action, ':');
if (command == NULL || *(command + 1) == '\0') {
message(LOG | CONSOLE, "\rBad inittab entry: %s\n", lineAsRead);
continue;
} else {
*process = '\0';
++process;
*command = '\0';
++command;
}
/* Ok, now process it */
@@ -885,7 +999,7 @@ static void parse_inittab(void)
strncat(tmpConsole, id, 200);
id = tmpConsole;
}
new_initAction(a->action, process, id);
new_init_action(a->action, command, id);
foundIt = TRUE;
}
a++;
@@ -894,7 +1008,7 @@ static void parse_inittab(void)
continue;
else {
/* Choke on an unknown action */
message(LOG | CONSOLE, "Bad inittab entry: %s\n", lineAsRead);
message(LOG | CONSOLE, "\rBad inittab entry: %s\n", lineAsRead);
}
}
return;
@@ -905,10 +1019,22 @@ static void parse_inittab(void)
extern int init_main(int argc, char **argv)
{
initAction *a, *tmp;
struct init_action *a;
pid_t wpid;
int status;
if (argc > 1 && !strcmp(argv[1], "-q")) {
/* don't assume init's pid == 1 */
long *pid = find_pid_by_name("init");
if (!pid || *pid<=0) {
pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
}
kill(*pid, SIGHUP);
exit(0);
}
#ifndef DEBUG_INIT
/* Expect to be invoked as init with PID=1 or be invoked as linuxrc */
if (getpid() != 1
@@ -921,10 +1047,14 @@ extern int init_main(int argc, char **argv)
}
/* Set up sig handlers -- be sure to
* clear all of these in run() */
signal(SIGHUP, exec_signal);
signal(SIGUSR1, halt_signal);
signal(SIGUSR2, halt_signal);
signal(SIGINT, ctrlaltdel_signal);
signal(SIGINT, ctrlaltdel_signal);
signal(SIGTERM, reboot_signal);
signal(SIGCONT, cont_handler);
signal(SIGSTOP, stop_handler);
signal(SIGTSTP, stop_handler);
/* Turn off rebooting via CTL-ALT-DEL -- we get a
* SIGINT on CAD so we can shut things down gracefully... */
@@ -950,7 +1080,7 @@ extern int init_main(int argc, char **argv)
putenv("PATH="_PATH_STDPATH);
/* Hello world */
message(MAYBE_CONSOLE|LOG, "init started: %s\n", full_version);
message(MAYBE_CONSOLE|LOG, "\rinit started: %s\n", full_version);
/* Make sure there is enough memory to do something useful. */
check_memory();
@@ -960,13 +1090,13 @@ extern int init_main(int argc, char **argv)
!strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) {
/* Ask first then start a shell on tty2-4 */
if (secondConsole != NULL)
new_initAction(ASKFIRST, LOGIN_SHELL, secondConsole);
new_init_action(ASKFIRST, LOGIN_SHELL, secondConsole);
if (thirdConsole != NULL)
new_initAction(ASKFIRST, LOGIN_SHELL, thirdConsole);
new_init_action(ASKFIRST, LOGIN_SHELL, thirdConsole);
if (fourthConsole != NULL)
new_initAction(ASKFIRST, LOGIN_SHELL, fourthConsole);
new_init_action(ASKFIRST, LOGIN_SHELL, fourthConsole);
/* Start a shell on tty1 */
new_initAction(RESPAWN, LOGIN_SHELL, console);
new_init_action(RESPAWN, LOGIN_SHELL, console);
} else {
/* Not in single user mode -- see what inittab says */
@@ -984,58 +1114,44 @@ extern int init_main(int argc, char **argv)
/* First run the sysinit command */
run_actions(SYSINIT);
/* Next run anything that wants to block */
run_actions(WAIT);
/* Next run anything to be run only once */
for (a = initActionList; a; a = tmp) {
tmp = a->nextPtr;
if (a->action == ONCE) {
run(a->process, a->console, FALSE);
/* Now remove the "once" entry from the list */
delete_initAction(a);
}
}
run_actions(ONCE);
/* If there is nothing else to do, stop */
if (initActionList == NULL) {
message(LOG | CONSOLE,
"No more tasks for init -- sleeping forever.\n");
if (init_action_list == NULL) {
message(LOG | CONSOLE, "\rNo more tasks for init -- sleeping forever.\n");
loop_forever();
}
/* Now run the looping stuff for the rest of forever */
while (1) {
for (a = initActionList; a; a = a->nextPtr) {
/* Only run stuff with pid==0. If they have
* a pid, that means they are still running */
if (a->pid == 0) {
switch (a->action) {
case RESPAWN:
/* run the respawn stuff */
a->pid = run(a->process, a->console, FALSE);
break;
case ASKFIRST:
/* run the askfirst stuff */
a->pid = run(a->process, a->console, TRUE);
break;
/* silence the compiler's incessant whining */
default:
break;
}
}
}
/* run the respawn stuff */
run_actions(RESPAWN);
/* run the askfirst stuff */
run_actions(ASKFIRST);
/* Don't consume all CPU time -- sleep a bit */
sleep(1);
/* Wait for a child process to exit */
wpid = wait(&status);
if (wpid > 0) {
/* Find out who died and clean up their corpse */
for (a = initActionList; a; a = a->nextPtr) {
for (a = init_action_list; a; a = a->next) {
if (a->pid == wpid) {
/* Set the pid to 0 so that the process gets
* restarted by run_actions() */
a->pid = 0;
message(LOG, "Process '%s' (pid %d) exited. Scheduling it for restart.\n",
a->process, wpid);
message(LOG, "Process '%s' (pid %d) exited. "
"Scheduling it for restart.\n", a->command, wpid);
}
}
}
sleep(1);
}
}
+2 -2
View File
@@ -2,8 +2,8 @@
/*
* Mini poweroff implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
* Copyright (C) 1999-2002 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
@@ -28,7 +28,7 @@ extern int poweroff_main(int argc, char **argv)
{
#ifdef CONFIG_FEATURE_INITRD
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
long *pid = find_pid_by_name("init");
if (!pid || *pid<=0) {
pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
+2 -2
View File
@@ -2,8 +2,8 @@
/*
* Mini reboot implementation for busybox
*
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
* Copyright (C) 1999-2002 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
@@ -28,7 +28,7 @@ extern int reboot_main(int argc, char **argv)
{
#ifdef CONFIG_FEATURE_INITRD
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
long *pid = find_pid_by_name("init");
if (!pid || *pid<=0) {
pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
+23 -66
View File
@@ -45,9 +45,9 @@
* done - convert calls to error in perror... and remove error()
* done - convert malloc/realloc to their x... counterparts
* done - remove catch_sigchld
* use bb's isdirectory() ? It seems that no applet use it.
* done - use bb's concat_path_file()
* declare run_parts_main() as extern and any other function as static? */
* done - declare run_parts_main() as extern and any other function as static?
*/
#include <stdio.h>
#include <stdarg.h>
@@ -61,17 +61,14 @@
#include <string.h>
#include <errno.h>
#include <ctype.h>
/* #include <signal.h>
#include <sys/time.h> */
#include "busybox.h"
int test_mode = 0;
int verbose_mode = 0;
int exitstatus = 0;
static int test_mode = 0;
static int exitstatus = 0;
int argcount = 0, argsize = 0;
char **args = 0;
static int argcount = 0, argsize = 0;
static char **args = 0;
/* set_umask */
@@ -80,7 +77,7 @@ char **args = 0;
* 8 and 9 digits under some circumstances. We'll just have to live with it.
*/
void set_umask (void)
static void set_umask (void)
{
int mask, result;
@@ -97,14 +94,14 @@ void set_umask (void)
/* add_argument */
/* Add an argument to the commands that we will call. Called once for
every argument. */
void add_argument (char *newarg)
static void add_argument (char *newarg)
{
if (argcount+1 >= argsize) {
argsize = argsize ? argsize*2 : 4;
/*TODO if we convert to xrealloc we lose the verbose error message */
args = realloc(args, argsize * (sizeof(char*)));
if (!args) {
perror_msg_and_die ("failed to reallocate memory for arguments: %s", strerror(errno));
perror_msg_and_die ("failed to reallocate memory for arguments");
}
}
args[argcount++] = newarg;
@@ -116,7 +113,7 @@ void add_argument (char *newarg)
* underscores, and hyphens only?)
*/
int valid_name (const struct dirent *d)
static int valid_name (const struct dirent *d)
{
char *c = d->d_name;
while (*c) {
@@ -132,19 +129,19 @@ int valid_name (const struct dirent *d)
/* run_part */
/* Execute a file */
void run_part (char *progname)
static void run_part (char *progname)
{
int result;
int pid;
if ((pid=fork()) < 0) {
perror_msg_and_die ("failed to fork: %s", strerror(errno));
perror_msg_and_die ("failed to fork");
}
else if (!pid) {
args[0] = progname;
execv (progname, args);
perror_msg_and_die ("failed to exec %s: %s", progname, strerror (errno));
perror_msg_and_die ("failed to exec %s", progname);
}
if (0) {
@@ -168,70 +165,30 @@ void run_part (char *progname)
/* run_parts */
/* Find the parts to run & call run_part() */
void run_parts (char *dir_name)
static void run_parts (char *dir_name)
{
struct dirent **namelist;
char *filename = NULL;
size_t filename_length, dir_name_length;
int entries, i, result;
struct dirent **namelist = 0;
char *filename;
int entries, i;
struct stat st;
/* dir_name + "/" */
dir_name_length = strlen(dir_name) + 1;
/* dir_name + "/" + ".." + "\0" (This will save one realloc.) */
filename_length = dir_name_length + 2 + 1;
/* --
* Removed this part because I want try to use concat_path_file() */
/* if (! (filename = malloc(filename_length))) {
error ("failed to allocate memory for path: %s", strerror(errno));
exit (1);
} */
/* -- */
/* scandir() isn't POSIX, but it makes things easy. */
entries = scandir (dir_name, &namelist, valid_name, alphasort);
if (entries < 0) {
perror_msg_and_die ("failed to open directory %s: %s", dir_name, strerror (errno));
perror_msg_and_die ("failed to open directory %s", dir_name);
}
for (i = 0; i < entries; i++) {
/* --
* Removed this part because I want try to use concat_path_file() */
/* if (filename_length < dir_name_length + strlen(namelist[i]->d_name) + 1) {
filename_length = dir_name_length + strlen(namelist[i]->d_name) + 1;
if (!(filename = realloc(filename, filename_length))) {
error ("failed to reallocate memory for path: %s", strerror(errno));
exit (1);
}
}
*/
/* -- */
/* --
* Removed for concat_path_file() */
/* strcpy (filename, dir_name);
strcat (filename, "/");
strcat (filename, namelist[i]->d_name); */
/* -- */
filename = concat_path_file (dir_name, namelist[i]->d_name);
result = stat (filename, &st);
if (result < 0) {
perror_msg_and_die ("failed to stat component %s: %s", filename,
strerror (errno));
if (stat (filename, &st) < 0) {
perror_msg_and_die ("failed to stat component %s", filename);
}
if (S_ISREG(st.st_mode) && !access (filename, X_OK)) {
if (test_mode)
@@ -240,17 +197,17 @@ void run_parts (char *dir_name)
run_part (filename);
}
}
/*TODO convert to isdirectory() */
else if (!S_ISDIR(st.st_mode)) {
printf ("run-parts: component %s is not an executable plain file\n",
error_msg ("component %s is not an executable plain file",
filename);
exitstatus = 1;
}
free (namelist[i]);
free (filename);
}
free (namelist);
free (filename);
}
/* run_parts_main */
+10 -1
View File
@@ -22,6 +22,7 @@
static int start = 0;
static int stop = 0;
static int fork_before_exec = 0;
static int signal_nr = 15;
static int user_id = -1;
static const char *userspec = NULL;
@@ -55,7 +56,7 @@ parse_options(int argc, char * const *argv)
int c;
for (;;) {
c = getopt (argc, argv, "a:n:s:u:x:KS");
c = getopt (argc, argv, "a:n:s:u:x:KSb");
if (c == EOF)
break;
switch (c) {
@@ -81,6 +82,9 @@ parse_options(int argc, char * const *argv)
case 'x':
execname = optarg;
break;
case 'b':
fork_before_exec = 1;
break;
default:
show_usage();
}
@@ -255,6 +259,11 @@ start_stop_daemon_main(int argc, char **argv)
return EXIT_SUCCESS;
}
*--argv = startas;
if (fork_before_exec) {
if (daemon(0, 0) == -1)
perror_msg_and_die ("unable to fork");
}
setsid();
execv(startas, argv);
perror_msg_and_die ("unable to start %s", startas);
}
+11 -48
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 2001 Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 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
@@ -15,53 +15,16 @@
# 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
#
TOPDIR :=..
L_TARGET := libbb.a
LIBBB_MSRC=messages.c
LIBBB_OBJ= full_version name_too_long omitting_directory not_a_directory \
memory_exhausted invalid_date invalid_option io_error dash_dash_help \
write_error too_few_args name_longer_than_foo unknown can_not_create_raw_socket
LIBBB_MOBJS=$(patsubst %,%.o, $(LIBBB_OBJ))
obj-y :=
obj-n :=
obj- :=
obj-y += ask_confirmation.o chomp.o concat_path_file.o copy_file.o \
copy_file_chunk.o dump.o libc5.o device_open.o error_msg.o \
error_msg_and_die.o fgets_str.o find_mount_point.o find_pid_by_name.o \
find_root_device.o full_read.o full_write.o get_console.o \
get_last_path_component.o get_line_from_file.o gz_open.o human_readable.o \
isdirectory.o kernel_version.o loop.o mode_string.o module_syscalls.o mtab.o \
mtab_file.o my_getgrnam.o my_getgrgid.o my_getpwnam.o my_getpwnamegid.o \
my_getpwuid.o parse_mode.o parse_number.o perror_msg.o perror_msg_and_die.o \
print_file.o process_escape_sequence.o read_package_field.o recursive_action.o \
safe_read.o safe_strncpy.o syscalls.o syslog_msg_with_name.o time_string.o \
trim.o unzip.o vdprintf.o verror_msg.o vperror_msg.o wfopen.o xfuncs.o \
xgetcwd.o xreadlink.o xregcomp.o interface.o remove_file.o last_char_is.o \
copyfd.o vherror_msg.o herror_msg.o herror_msg_and_die.o xgethostbyname.o \
dirname.o make_directory.o create_icmp_socket.o u_signal_names.o arith.o \
simplify_path.o inet_common.o $(LIBBB_MOBJS) $(LIBBB_AROBJS)
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
$(LIBBB_MOBJS): $(LIBBB_MSRC)
$(CC) $(CFLAGS) -DBB_VER='"$(VERSION)"' -DBB_BT='"$(BUILDTIME)"' \
$(LIBBB_CFLAGS) -DL_$(patsubst %,%,$*) -c $< -o $*.o
$(LIBBB_AROBJS): $(LIBBB_ARCSRC)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst %,%,$*) -c $< -o $*.o
loop.o: loop.h
loop.h: mk_loop_h.sh
@ $(SHELL) $< > $@
TOPDIR:= ../
LIBBB_DIR:=./
include $(TOPDIR).config
include $(TOPDIR)Rules.mak
include Makefile.in
all: $(libraries-y)
-include $(TOPDIR).depend
clean:
rm -f $(L_TARGET) *.o core
rm -f *.o *.a $(AR_TARGET)
+63
View File
@@ -0,0 +1,63 @@
# Makefile for busybox
#
# Copyright (C) 1999-2002 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
LIBBB_AR:=libbb.a
ifndef $(LIBBB_DIR)
LIBBB_DIR:=$(TOPDIR)libbb/
endif
LIBBB_SRC:= \
ask_confirmation.c chomp.c concat_path_file.c copy_file.c \
copy_file_chunk.c dump.c libc5.c device_open.c error_msg.c \
error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \
find_root_device.c full_read.c full_write.c get_console.c \
get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \
isdirectory.c kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c \
mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \
my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \
safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \
simplify_path.c inet_common.c inode_hash.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC))
LIBBB_MSRC:=$(LIBBB_DIR)messages.c
LIBBB_MOBJ:=full_version.o name_too_long.o omitting_directory.o not_a_directory.o \
memory_exhausted.o invalid_date.o invalid_option.o io_error.o dash_dash_help.o \
write_error.o too_few_args.o name_longer_than_foo.o unknown.o can_not_create_raw_socket.o
LIBBB_MOBJS=$(patsubst %,$(LIBBB_DIR)%, $(LIBBB_MOBJ))
libraries-y+=$(LIBBB_DIR)$(LIBBB_AR)
$(LIBBB_DIR)$(LIBBB_AR): $(LIBBB_OBJS) $(LIBBB_MOBJS)
$(AR) -ro $@ $(LIBBB_OBJS) $(LIBBB_MOBJS)
$(LIBBB_MOBJS): $(LIBBB_MSRC)
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DL_$(notdir $*) -c $< -o $@
$(LIBBB_DIR)loop.o: $(LIBBB_DIR)loop.h
$(LIBBB_DIR)loop.h: $(LIBBB_DIR)mk_loop_h.sh
@ $(SHELL) $< > $@
+1 -3
View File
@@ -5,11 +5,9 @@ libbb is BusyBox's utility library. This all used to be in a single file
not carefully fix up the copyright and licensing information. I'll do that for
the next release.
For now, justtrust me that a bunch of people have worked on this stuff,
For now, just trust me that a bunch of people have worked on this stuff,
and it is all GPL'ed.
Erik Andersen
<andersen@lineo.com>
<andersee@debian.org>
<andersee@codepoet.org>
+34 -9
View File
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include "libbb.h"
#include "busybox.h"
int copy_file(const char *source, const char *dest, int flags)
{
@@ -131,22 +131,44 @@ int copy_file(const char *source, const char *dest, int flags)
}
} else if (S_ISREG(source_stat.st_mode)) {
FILE *sfp, *dfp=NULL;
#ifdef CONFIG_FEATURE_PRESERVE_HARDLINKS
char *link_name;
if (!(flags & FILEUTILS_DEREFERENCE) &&
is_in_ino_dev_hashtable(&source_stat, &link_name)) {
if (link(link_name, dest) < 0) {
perror_msg("unable to link `%s'", dest);
return -1;
}
return 0;
}
#endif
if ((sfp = fopen(source, "r")) == NULL) {
perror_msg("unable to open `%s'", source);
return -1;
}
if (dest_exists) {
if (flags & FILEUTILS_INTERACTIVE) {
fprintf(stderr, "%s: overwrite `%s'? ", applet_name, dest);
if (!ask_confirmation())
if (!ask_confirmation()) {
fclose (sfp);
return 0;
}
}
if ((dfp = fopen(dest, "w")) == NULL) {
if (!(flags & FILEUTILS_FORCE)) {
perror_msg("unable to open `%s'", dest);
fclose (sfp);
return -1;
}
if (unlink(dest) < 0) {
perror_msg("unable to remove `%s'", dest);
fclose (sfp);
return -1;
}
@@ -162,17 +184,11 @@ int copy_file(const char *source, const char *dest, int flags)
if (fd >= 0)
close(fd);
perror_msg("unable to open `%s'", dest);
fclose (sfp);
return -1;
}
}
if ((sfp = fopen(source, "r")) == NULL) {
fclose(dfp);
perror_msg("unable to open `%s'", source);
status = -1;
goto end;
}
if (copy_file_chunk(sfp, dfp, -1) < 0)
status = -1;
@@ -209,12 +225,21 @@ int copy_file(const char *source, const char *dest, int flags)
if (lchown(dest, source_stat.st_uid, source_stat.st_gid) < 0)
perror_msg("unable to preserve ownership of `%s'", dest);
#endif
#ifdef CONFIG_FEATURE_PRESERVE_HARDLINKS
add_to_ino_dev_hashtable(&source_stat, dest);
#endif
return 0;
} else {
error_msg("internal error: unrecognized file type");
return -1;
}
#ifdef CONFIG_FEATURE_PRESERVE_HARDLINKS
add_to_ino_dev_hashtable(&source_stat, dest);
#endif
end:
if (flags & FILEUTILS_PRESERVE_STATUS) {
+9 -21
View File
@@ -40,13 +40,13 @@
*
* Returns a list of all matching PIDs
*/
extern pid_t* find_pid_by_name( char* pidName)
extern long* find_pid_by_name( char* pidName)
{
int fd, i, j;
char device[] = "/dev/ps";
pid_t num_pids;
pid_t* pid_array = NULL;
pid_t* pidList=NULL;
long* pidList=NULL;
/* open device */
fd = open(device, O_RDONLY);
@@ -87,20 +87,14 @@ extern pid_t* find_pid_by_name( char* pidName)
if ((strstr(info.command_line, pidName) != NULL)
&& (strlen(pidName) == strlen(info.command_line))) {
pidList=xrealloc( pidList, sizeof(pid_t) * (j+2));
pidList=xrealloc( pidList, sizeof(long) * (j+2));
pidList[j++]=info.pid;
}
}
if (pidList) {
pidList[j]=0;
} else if ( strcmp(pidName, "init")==0) {
/* If we found nothing and they were trying to kill "init",
* guess PID 1 and call it good... Perhaps we should simply
* exit if /proc isn't mounted, but this will do for now. */
pidList=xrealloc( pidList, sizeof(pid_t));
pidList[0]=1;
} else {
pidList=xrealloc( pidList, sizeof(pid_t));
pidList=xrealloc( pidList, sizeof(long));
pidList[0]=-1;
}
@@ -124,11 +118,11 @@ extern pid_t* find_pid_by_name( char* pidName)
*
* Returns a list of all matching PIDs
*/
extern pid_t* find_pid_by_name( char* pidName)
extern long* find_pid_by_name( char* pidName)
{
DIR *dir;
struct dirent *next;
pid_t* pidList=NULL;
long* pidList=NULL;
int i=0;
dir = opendir("/proc");
@@ -162,21 +156,15 @@ extern pid_t* find_pid_by_name( char* pidName)
/* Buffer should contain a string like "Name: binary_name" */
sscanf(buffer, "%*s %s", name);
if (strcmp(name, pidName) == 0) {
pidList=xrealloc( pidList, sizeof(pid_t) * (i+2));
pidList=xrealloc( pidList, sizeof(long) * (i+2));
pidList[i++]=strtol(next->d_name, NULL, 0);
}
}
if (pidList)
if (pidList) {
pidList[i]=0;
else if ( strcmp(pidName, "init")==0) {
/* If we found nothing and they were trying to kill "init",
* guess PID 1 and call it good... Perhaps we should simply
* exit if /proc isn't mounted, but this will do for now. */
pidList=xrealloc( pidList, sizeof(pid_t));
pidList[0]=1;
} else {
pidList=xrealloc( pidList, sizeof(pid_t));
pidList=xrealloc( pidList, sizeof(long));
pidList[0]=-1;
}
return pidList;
+27 -36
View File
@@ -1,8 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
* get_last_path_component implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* Copyright (C) 2001 Manuel Novoa III <mjn3@opensource.lineo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,49 +17,40 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <string.h>
#include "libbb.h"
/* Set to 1 if you want basename() behavior for NULL or "". */
/* WARNING!!! Doing so will break basename applet at least! */
#define EMULATE_BASENAME 0
char *get_last_path_component(char *path)
{
char *s;
register char *ptr = path;
register char *prev = 0;
#if EMULATE_BASENAME
static const char null_or_empty[] = ".";
#endif
char *first = path;
char *last;
while (*ptr)
ptr++;
s = ptr - 1;
#if EMULATE_BASENAME
if (!path || !*path) {
return (char *) null_or_empty;
}
#endif
/* strip trailing slashes */
while (s != path && *s == '/') {
*s-- = '\0';
last = path - 1;
while (*path) {
if ((*path != '/') && (path > ++last)) {
last = first = path;
}
++path;
}
/* find last component */
ptr = path;
while (*ptr != '\0') {
if (*ptr == '/')
prev = ptr;
ptr++;
if (*first == '/') {
last = first;
}
s = prev;
last[1] = 0;
if (s == NULL || s[1] == '\0')
return path;
else
return s+1;
return first;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+1 -1
View File
@@ -45,7 +45,7 @@ extern char *get_line_from_file(FILE *file)
while (idx > linebufsz-2)
linebuf = xrealloc(linebuf, linebufsz += GROWBY);
linebuf[idx++] = (char)ch;
if ((char)ch == '\n')
if (ch == '\n' || ch == '\0')
break;
}
-1
View File
@@ -18,7 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* vi: set sw=4 ts=4: */
#include <stdarg.h>
#include <stdlib.h>
+7
View File
@@ -29,6 +29,13 @@
#define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE)
typedef struct ino_dev_hash_bucket_struct {
struct ino_dev_hash_bucket_struct *next;
ino_t ino;
dev_t dev;
char name[1];
} ino_dev_hashtable_bucket_t;
static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
/*
Loaded 100 of 192 files, more files were not shown because too many files have changed in this diff. Show more