Compare commits

...
721 Commits
Author SHA1 Message Date
Eric Andersen 4b8a1e89a5 Fix email addr 2001-11-20 11:41:37 +00:00
Eric Andersen f435a918fa S390 wierdness 2001-11-20 05:42:57 +00:00
Eric Andersen 81ee96fe62 Usr get_last_path_component() name basename() 2001-11-20 00:23:48 +00:00
Eric Andersen c36642195c Include time.h 2001-11-20 00:15:27 +00:00
Eric Andersen edc6e0248c Oops. doubled myself 2001-11-19 23:50:18 +00:00
Eric Andersen 372f12678e Note tinylogin TODO items 2001-11-19 22:51:41 +00:00
Matt Kraai efd7f03657 Fix opt type in dpkg (closes: #118975). 2001-11-19 21:07:15 +00:00
Matt Kraai 4e05da89f3 Add a check target. 2001-11-19 19:47:56 +00:00
Matt Kraai 36c613a443 Update usage instructions, and document test case format. 2001-11-19 19:28:56 +00:00
Matt Kraai 9dfe508a3f New. 2001-11-19 19:00:13 +00:00
Matt Kraai c2d6ca0922 Fix misspelling. 2001-11-19 18:44:58 +00:00
Matt Kraai 03bb3088b0 New. 2001-11-19 15:13:12 +00:00
Eric Andersen 6f8b7ea452 oops 2001-11-19 11:45:39 +00:00
Eric Andersen 55805bcba4 More scrubbing 2001-11-19 10:59:37 +00:00
Eric Andersen d81891a2e6 Call xmalloc before realloc 2001-11-19 10:49:30 +00:00
Eric Andersen 43626d7671 Fixup CLEANUP behavior 2001-11-19 10:36:20 +00:00
Eric Andersen cc05ce64e9 Update webpage 2001-11-18 15:49:26 +00:00
Glenn L McGrath fff11f1ab7 bzcat and bunzip -c support from Thomas Lundquist 2001-11-18 14:20:25 +00:00
Eric Andersen fedce06b7f Hide some ifdefs to make it more readible 2001-11-17 07:27:14 +00:00
Eric Andersen 9c6b5fcb0a Minor warning cleanups 2001-11-17 07:23:46 +00:00
Eric Andersen bff7a60f63 Patch from "Andrew Tipton" <andrew@cadre5.com> to enable vi cursor
keys while editing.
2001-11-17 07:15:43 +00:00
Eric Andersen 80f5ac7016 Patch from Steve Merrifield <steve@labyrinth.net.au> to make vi
use xmalloc
2001-11-17 06:57:42 +00:00
Eric Andersen 26f8e95d2d David Kimdon <dwhedon@instant802.com> noticed a thinko
in md5sum where only binary sums were verified.  He also
sent in this patch,
 -Erik
2001-11-17 04:16:15 +00:00
Matt Kraai 5c2bbb55d7 Remove unnecessary errno handling. 2001-11-12 18:44:26 +00:00
Matt Kraai 6c5fdfaf56 New. 2001-11-12 18:42:57 +00:00
Matt Kraai a21c24bf03 Convert strdup call to xstrdup, and calloc calls to xcalloc (patch from
Steve Merrifield).
2001-11-12 16:58:07 +00:00
Matt Kraai c8227639db Change strdup calls to xstrdup (patch from Steve Merrifield). 2001-11-12 16:57:27 +00:00
Matt Kraai 357cfc739e Brag. 2001-11-12 16:45:43 +00:00
Matt Kraai 9fb38f600c Eliminate unused variable warnings. 2001-11-12 16:45:23 +00:00
Matt Kraai a5f09c668e Use fopen wrapper. 2001-11-12 16:44:55 +00:00
Eric Andersen c5f9a9dd0c Add redhat and slackware 2001-11-10 13:38:36 +00:00
Eric Andersen 31ac3b7764 Add in Redhat 2001-11-10 13:35:27 +00:00
Eric Andersen 45784febaf Some more minor build cleanups 2001-11-10 13:08:02 +00:00
Eric Andersen dba4e6f046 Add in grep -E support 2001-11-10 12:54:00 +00:00
Eric Andersen c223ced0ea I forgot to add these. Part of the patch from vodz 2001-11-10 12:18:42 +00:00
Eric Andersen 282671bf76 Cleanup some config problems. Add a sane default config that basically
matches the default old Config.h
2001-11-10 12:07:24 +00:00
Eric Andersen 30fcef430c Only use -mpreferred-stack-boundary with gcc versions that support it 2001-11-10 11:23:47 +00:00
Eric Andersen cd8c436d81 Latest patch from vodz:
-- reverse resolve network name and cache in route and ifconfig
	applets, fix print nslookup server name if compile without
	uClibc, fix route crashe 'route add', fix warnings compile
	networking and pwd_grp applets
2001-11-10 11:22:46 +00:00
Eric Andersen 94f19a8385 oops 2001-11-10 11:17:17 +00:00
Eric Andersen 744a194f53 Can't use RESERVE_CONFIG_BUFFER here since the allocation
size varies meaning BUFFERS_GO_ON_STACK will fail
2001-11-10 11:16:39 +00:00
Eric Andersen c52a6b0f10 |2001-10-08 Rodney Brown <rbrown64@csc.com.au>
|
|       * editors/sed.c: Fix multiline [aic] commands. Make # an endline
|       comment for compatibility. Codespace reduction.
|       * tests/testcases: Cope with move to subdirectories.
|       * testsuite/sed/sed-aic-commands: Add.
|
|   text           data     bss     dec     hex filename
|   3772             16       0    3788     ecc editors/sed.o
|   4516             16       0    4532    11b4 editors/sed.o.bu
2001-11-10 10:49:42 +00:00
Eric Andersen e5d58c3dcc Mention that glibc-2.2 is supported 2001-11-10 10:46:42 +00:00
Eric Andersen 882cbcdfa1 more config.in entries from Giulio Orsero <giulioo@pobox.com>
with some minor edits by me.
2001-11-10 10:43:09 +00:00
Eric Andersen 7131213460 config.in features patch from Giulio Orsero <giulioo@pobox.com>
with some minor edits from me
2001-11-10 09:53:23 +00:00
Eric Andersen df23302cb5 Remove comments about 'make bzImage' 2001-11-07 07:50:08 +00:00
Eric Andersen 5abdaa9a16 Force main to always be included 2001-11-06 18:45:56 +00:00
Eric Andersen 3c513e3858 Fix spelling 2001-11-05 23:10:48 +00:00
Glenn L McGrath 0a25b35c66 Fix create list segfault 2001-11-03 08:29:35 +00:00
Glenn L McGrath 55b2deda08 Required for od and hexdump applets 2001-11-02 11:40:44 +00:00
Glenn L McGrath 60281118d0 Introduce od and hexdump applets 2001-11-02 11:39:46 +00:00
Matt Kraai b89637a037 New. 2001-10-31 16:36:23 +00:00
Matt Kraai 5447f17ef9 Remove completed task. 2001-10-31 16:36:02 +00:00
Matt Kraai f419855300 Mark as unsupported unless CONFIG_FEATURE_TAR_EXCLUDE is defined. 2001-10-31 16:18:48 +00:00
Matt Kraai bb0088e980 Make egrep only set REG_EXTENDED flag. 2001-10-31 16:16:31 +00:00
Eric Andersen 8fc0589777 *** empty log message *** 2001-10-31 11:45:10 +00:00
Eric Andersen f46999f8bc Fix location of Configure.help 2001-10-31 11:12:25 +00:00
Eric Andersen 1552ff7efb Move usage.h to include/usage.h 2001-10-31 11:07:12 +00:00
Eric Andersen ec07469a3e Patch from Aaron Lehmann <aaronl@vitelus.com>;
This diff does 2 things:

    1) removes an unnecessary function. saves 64 bytes on i386

    2) allows you to disable checking of mail (actually, it's now disabled
    by default). this would be a nice CML1 option, but for now it's a
    #(define|undef) in the C file like the other internal ash options.
    this saves an additional 352 bytes if you leave mail disabled.
2001-10-31 11:05:49 +00:00
Eric Andersen 31a0ece3a7 Add netstat applet, submitted by Bart Visscher <magick@linux-fan.com> 2001-10-31 11:00:46 +00:00
Eric Andersen 7d6829096d Add the run-parts applet submitted by Emanuele Aina
<emanuele.aina@tiscali.it>
2001-10-31 10:59:29 +00:00
Eric Andersen eaecbf33f7 Fixup some silly prototype warnings 2001-10-31 10:41:31 +00:00
Eric Andersen 69a20f0aca Patch from ASA <llb@udm.net.ru> to that source files
are properly passed their arguments.
2001-10-31 10:40:37 +00:00
Eric Andersen 6cf47a79ac Run parts applet by Emanuele Aina <faina.mail@tiscalinet.it> 2001-10-31 10:24:36 +00:00
Eric Andersen 2bc4dec7a1 Document CONFIG_RUN_PARTS, patch from Emanuele Aina <faina.mail@tiscalinet.it> 2001-10-31 10:21:17 +00:00
Eric Andersen a58f040a37 Add Gennady Feldman 2001-10-31 10:04:44 +00:00
Eric Andersen 85dd4b3b27 start-stop-deamon is done 2001-10-31 10:04:04 +00:00
Eric Andersen ccd96f1972 Patch from Charles Steinkuehler <charles@steinkuehler.net>
to properly handle extended regexps for egrep
2001-10-31 10:02:46 +00:00
Eric Andersen 3d61b10595 Major cleanup from Charles Steinkuehler <charles@steinkuehler.net>:
- Switched to getopt argument parsing
    - Added -f option to get fully qualified domain name
    - Fixed the -s (short) and -d (domain) options, which were not
      doing a gethostbyname lookup to get the FQDN before trying to
      separate the local and domain portions of the hostname.
    - Fixed probem with 'agressive setting' of the hostname...the
      previous busybox version would try to set the hostname if called
      with a non-option argument, or the -F option, even if another
      option (like -i or -s) was given.  This behavior does not match
      the net-tools hostname, which does not attempt to set anything if
      given a 'display' option, regardless of the presence/absence of
      the -F option or additional command line arguments.
    - When using a file to set the hostname, behavior now matches
      net-tools version...previous busybox version did not handle
      comments, and simply grabbed the first line from the file.
2001-10-31 09:59:57 +00:00
Eric Andersen 950d8b496f patch from vodz:
I reduce 148 bytes from start_stop_daemon.c code. Also reduced
    memory allocated.
2001-10-31 09:55:39 +00:00
Eric Andersen 2c669dd108 patch from Giulio Orsero <giulioo@pobox.com> 2001-10-31 09:54:29 +00:00
John Beppu ce22feea01 - fixed typos
- thinking about how to generate Configure.help...
2001-10-31 04:29:18 +00:00
Matt Kraai 3889078dbe Merge test suite. 2001-10-30 23:11:20 +00:00
Matt Kraai 999623e973 Use extended regular expressions when invoked as egrep (noted and initial
patch by Charles Steinkuehler).
2001-10-29 15:49:03 +00:00
Matt Kraai b5f2516e3f Add killall (noted by Giulio Orsero). 2001-10-29 15:22:42 +00:00
Eric Andersen 813d88cf78 As Aaron Lehmann just pointed out, I forgot a line... 2001-10-28 22:49:48 +00:00
Eric Andersen 4acf8f8481 Use error_msg() instead of fprintf(stderr, ...) 2001-10-28 09:36:48 +00:00
Eric Andersen 72f9a4277f Add in some (theoretical) uClinux support. Some init cleanups 2001-10-28 05:12:20 +00:00
Glenn L McGrath 9af363fe20 include unistd which provides off_t for the header and hence unarchive applets 2001-10-27 14:10:37 +00:00
Glenn L McGrath 7134d6581b Attempt to fix libc compiling error regarding off_t 2001-10-27 13:14:52 +00:00
Eric Andersen 8e392922b0 Be extra pedantic about printing the correct type for an address 2001-10-27 03:28:53 +00:00
Eric Andersen c265b17550 Wrap exclude_file() inside a #ifdef CONFIG_FEATURE_TAR_EXCLUDE block 2001-10-27 03:20:00 +00:00
Gennady Feldman 087bc82bb0 Fix up the configuration rules and update Libc5 piece for Syslogd. (copied code from logread.c) 2001-10-26 16:09:09 +00:00
Glenn L McGrath ee28362597 Menu entry for tar creation support 2001-10-25 18:37:41 +00:00
Glenn L McGrath 107c796e79 Recovery from previous commit 2001-10-25 15:01:10 +00:00
Glenn L McGrath 9f2f8540c5 rEcover from my previous commit 2001-10-25 14:59:48 +00:00
Glenn L McGrath e9fc781570 libunarchive, and recovery from my previous commit 2001-10-25 14:57:14 +00:00
Glenn L McGrath 633f153808 Move libbb/unarchive functions to ./archival/libunarchive 2001-10-25 14:53:50 +00:00
Glenn L McGrath ef0eab514d Recovering from my previous commit 2001-10-25 14:49:48 +00:00
Glenn L McGrath 0d2fb76c11 Modify applets to use libunarchive 2001-10-25 14:26:05 +00:00
Glenn L McGrath 95ebf618b7 *** empty log message *** 2001-10-25 14:18:08 +00:00
Eric Andersen 8eaa7b3698 Oops. I forgot pwd_group/config.in 2001-10-25 05:56:51 +00:00
Eric Andersen 2293b96f42 ignore .menuconfig.log 2001-10-24 20:01:04 +00:00
Eric Andersen 9ae7ebd0fd Ignore lxdialog 2001-10-24 19:59:38 +00:00
Matt Kraai 258bd3d971 Split true and false into separate applets. 2001-10-24 19:00:20 +00:00
Matt Kraai 3c2f27d9f1 Add CONFIG_FEATURE_TAR_EXCLUDE support. 2001-10-24 18:51:27 +00:00
Eric Andersen 99702ab221 Fix variable name -- was stuck at the old RPMUNPACK value. Doh! 2001-10-24 17:37:07 +00:00
Eric Andersen b78d9b56eb Oops. Fix capililization 2001-10-24 17:35:52 +00:00
Eric Andersen 1a10eec178 Fixup the location of pwd.h and grp.h 2001-10-24 17:19:38 +00:00
Eric Andersen bfebd35bea Fix missing BB_VER defines 2001-10-24 16:51:39 +00:00
Eric Andersen a49b025b19 Oops. As Aaron Lehmann <aaronl@vitelus.com> just noticed,
I forgot to add procps to the SUBDIR list
2001-10-24 08:24:41 +00:00
Eric Andersen a3483db55f Patch from vodz:
1) complete true: $ > /tmp/tmpfile
    2) the builtin pwd now does not unwrap symlinks
    3) reduce 680 bytes
2001-10-24 08:01:06 +00:00
Eric Andersen 3cd2760ba1 Fixup the new buildsystem a bit. 2001-10-24 07:58:02 +00:00
Eric Andersen b36e684fd7 Ignore generated files 2001-10-24 06:53:33 +00:00
Eric Andersen 28593a085b ignore generated files 2001-10-24 06:50:42 +00:00
Eric Andersen ca38a29c81 A couple of leftovers 2001-10-24 06:48:42 +00:00
Eric Andersen 9b5a953a98 Add in a mostly content free config help file 2001-10-24 06:33:31 +00:00
Eric Andersen 4bcdd72142 Oops. Forgot these.... 2001-10-24 05:26:42 +00:00
Eric Andersen bdfd0d78bc Major rework of the directory structure and the entire build system.
-Erik
2001-10-24 05:00:29 +00:00
Eric Andersen 9260fc5552 Accomodate older glibc, which also lacks the module syscalls 2001-10-24 00:44:11 +00:00
Matt Kraai 1c9cebc8df Fix empty line substitutions (noted by Joshua Hudson). 2001-10-23 21:18:59 +00:00
Matt Kraai 8470b9a85c Fix empty line substitutions (noted by Joshua Hudson). 2001-10-23 21:12:07 +00:00
Glenn L McGrath 6ccdd8c122 Abort if scripts return value != 0 2001-10-23 17:52:28 +00:00
Matt Kraai c2e5b977ab Add ttylinux. 2001-10-19 15:33:45 +00:00
Eric Andersen 68ca35c90f Add slackware 8 to list 2001-10-19 06:32:15 +00:00
Eric Andersen 9c93721ea5 Add mindi linux 2001-10-19 00:46:06 +00:00
Eric Andersen d63dee4019 Add an option to make the shells not advertise their busybox nature 2001-10-19 00:22:23 +00:00
Eric Andersen f4c208937c Remove the now unused ARITH_* defines
-Erik
2001-10-19 00:08:17 +00:00
Eric Andersen c2af1ee036 Commit the start-stop-daemon applet. This was contributed by David
Kimdon <dwhedon@gordian.com> on october 7th -- the day I was fired from
Lineo.  So it seems I totally forgot about this patch until now.
Sorry about that David!
2001-10-18 19:33:06 +00:00
Matt Kraai bcca3317b5 Return NULL if EOF is encountered before terminating_string. 2001-10-18 17:04:22 +00:00
Matt Kraai a7512d74fa Process extra empty lines correctly. 2001-10-18 17:03:59 +00:00
Matt Kraai 3dd4f5ed69 Remove xmalloc calls. 2001-10-18 15:08:30 +00:00
Eric Andersen a0f0ae5a7a Revert that change. As Matt Kraai rightly points out,
this is not a bug.  What I was I thinking when I committed
this.  Doh!
2001-10-18 06:04:23 +00:00
Eric Andersen 74400ccfd0 Scrub up some function prototypes.
-Erik
2001-10-18 04:11:39 +00:00
Eric Andersen 8acbf1d307 Make mount default to using /proc/filesystems to avoid
ever trying to mount a nodev filesystem.
 -Erik
2001-10-18 04:10:22 +00:00
Eric Andersen 11fdb8a4c7 Fix a nasty bug with variable name shadowing 2001-10-18 04:04:34 +00:00
Eric Andersen 1bf25f0307 Patch from Stefan Soucek <ssoucek@coactive.com> to
ignore extra empty lines in fgets_str
2001-10-18 03:20:41 +00:00
Glenn L McGrath 4bef7b4186 unarchive function changed to support both exclude and include lists, applets that use unarchive changed to match. 2001-10-13 19:43:46 +00:00
Glenn L McGrath 051eee6ed3 Reverse part of previous change.... i think it was the wrong approach... im lost 2001-10-13 07:11:03 +00:00
Glenn L McGrath d642a67928 Match subdirectories of included/excluded files 2001-10-13 06:54:45 +00:00
Glenn L McGrath 527880e5cf match exclude/include names with trailing '/' 2001-10-13 06:53:34 +00:00
Glenn L McGrath b5937d3eea Use fnmatch() to compare excluded/included files 2001-10-13 06:21:32 +00:00
Glenn L McGrath 0e766183ee Superficial changes to make the exclude/include code easier to understand 2001-10-13 05:03:29 +00:00
Matt Kraai f86bbfaddd Fix tar segfault when include list is empty and exclude list is not. 2001-10-12 19:00:15 +00:00
Glenn L McGrath 9b2589dafd Cleanup memory usage properly 2001-10-08 13:10:12 +00:00
Glenn L McGrath dfa7b0eff6 Free some variables after use 2001-10-08 08:22:48 +00:00
Glenn L McGrath 30f68908ef Another part of Stafan's latest patch, when replacing a pre-existing package set its status correctly. 2001-10-06 02:40:20 +00:00
Glenn L McGrath f28d819554 status_package_num should refer to package not status.
Only initialise a new entry in the status hashtable if it really is a new entry.
2001-10-06 02:27:36 +00:00
Glenn L McGrath 3550753445 Remove duplicate tftp -l option help 2001-10-05 10:11:28 +00:00
Glenn L McGrath 1d098cefe2 Use wfopen instead of fopen & error_msg, saves 64 bytes 2001-10-05 05:24:19 +00:00
Glenn L McGrath bf265daa47 Use xfopen, saves 32 bytes ! 2001-10-05 05:03:14 +00:00
Glenn L McGrath ad117d8a21 Apply Magnus Damm's patch, adds tftp blocksize support, and some cleanups. 2001-10-05 04:40:37 +00:00
Glenn L McGrath 24e2833cdf Initial support for for bunzip2....
This code could be improvemed by
 1) supporting more options,
 2) Creating a shared crc table with gunzip, or perhaps generated on the fly.
 3) Removing any remaining unneccessary code (e.g. if (noisy))
2001-10-05 03:48:57 +00:00
Glenn L McGrath 2e772edacf Change extraction/list code to use common unarchive code. 2001-10-05 02:58:48 +00:00
Matt Kraai 4c557bf576 Invert FILEUTILS_PRESERVE_SYMLINKS into FILEUTILS_DEREFERENCE. 2001-10-05 01:35:10 +00:00
Matt Kraai 54a992d81e Fix BB_FEATURE_MTAB_SUPPORT test (report and patch by Magnus Damm). 2001-10-04 15:23:34 +00:00
Eric Andersen b0a0fc8944 Add Magnus Damm and fix alpha sorting 2001-10-04 09:33:40 +00:00
Glenn L McGrath a8412dbf39 Fixes with help from Stefan, Typo in prerm script, and when reinstall a package the old packages status was getting overwritten. 2001-10-04 05:22:42 +00:00
Eric Andersen fd35de564e Always enable BB_TEST when BB_ASH, BB_LASH, or BB_MSH is enabled 2001-10-03 23:37:24 +00:00
Eric Andersen 371ca19f53 Look for either "init" or "linuxrc" processes 2001-10-03 21:26:12 +00:00
Eric Andersen f0a4ac8216 Patch from Magnus Damm <damm@opensource.se> to avoid lash hanging
on serial ports
2001-10-03 11:23:42 +00:00
Glenn L McGrath 35636540ea Extract control.tar.gz and data.tar.gz unconditionally, another one picked up by Stefan 2001-10-03 03:10:35 +00:00
Eric Andersen 5c72104a85 Fix large file support -- 2+ gig files should now actually
work this time...
 -Erik
2001-10-02 07:58:23 +00:00
Matt Kraai c9fc633f9e Use port 37 by default. 2001-10-01 17:52:14 +00:00
Matt Kraai 524fcb9e01 Use xgethostbyname instead of gethostbyname (found by Erik Andersen). 2001-10-01 17:50:25 +00:00
Glenn L McGrath 95bfe631a4 Fix return status, picked up by Stefan 2001-09-29 03:34:38 +00:00
Eric Andersen 63ae66198d use the pedantically correct compiler for preprocessing 2001-09-26 06:20:54 +00:00
Matt Kraai b67adb0d83 Add Cachier. 2001-09-24 22:44:52 +00:00
Glenn L McGrath c5bd149261 List full path instead of relative path if prefix is specified (this was supposed to be in last patch) 2001-09-24 18:34:06 +00:00
Glenn L McGrath dece3c5684 The <package>.list file was prepending "./" to the files, fixed that.
Also fixed a very silly error by me when running postinst (remember to use the variable BEFORE its freed)
2001-09-22 04:16:55 +00:00
Glenn L McGrath b8f5adb64f Dont free everytime getline() is used, fix from Stefan Soucek 2001-09-22 03:24:07 +00:00
Matt Kraai 3be34309e3 Fix tftp usage information (closes: #1216). 2001-09-21 14:42:30 +00:00
Eric Andersen f8f6e624bb Eliminate ldconfig which is no longer built by
default (or needed) with uClibc.
2001-09-21 06:05:35 +00:00
Glenn L McGrath 48cc89b738 Fix to make preinst run when required, from Stefan Soucek 2001-09-21 05:07:47 +00:00
Glenn L McGrath e73866181f Implement dpkg -l option, from Stefan Soucek (slightly modified) 2001-09-21 04:30:51 +00:00
Tim Riker 4c67c596d1 closes bug#1215? 2001-09-16 02:00:09 +00:00
Manuel Novoa III 8d0afde412 Commit my changes to xxreadtoken() to reduce code size. Also set defines
so that the table implementations of copynode, calcsize, and cmdtxt are
used.  Hopefully this will result in wider testing.  ;-)  If it breaks,
just unset the appropriate defines.
2001-09-11 01:14:02 +00:00
Manuel Novoa III 6a9d1f652b Commit my changes to arith.c which fixed a couple of bugs and decreased
code size.  Please read the TODO comments regarding accessing shell
variables from the arith() funciton.
2001-09-11 01:11:31 +00:00
Eric Andersen f6ecaccf92 Fix my email address. 2001-09-08 20:52:33 +00:00
Eric Andersen 886b84211e Lineo is no longer sponsoring busybox 2001-09-08 20:47:19 +00:00
Eric Andersen 5bb1677f1d define IFS_BROKEN 2001-09-06 18:00:41 +00:00
Eric Andersen 88cec25e99 Patch from vodz to make ash cope with leading redirections
(i.e. '2>/dev/null ls rubbish') will now work.
2001-09-06 17:35:20 +00:00
Eric Andersen 1644db9a2b Two patches from Magick <magick@linux-fan.com>:
1st makes init smaller, and fixes a bug with AskFirst. Reading from
    /dev/null gives EOF.
    2nd makes init run the command's in the order of inittab, as in
    FIFO instead of LIFO.
2001-09-05 20:18:15 +00:00
Eric Andersen b9408504f5 Another fix from vodz 2001-09-05 19:32:00 +00:00
Eric Andersen 3b1525e444 Don't automount things as "usbdevfs" -- patch from
Ethan Benson <erbenson@alaska.net>
2001-09-03 16:49:25 +00:00
Matt Kraai 1350666498 Add -p support. 2001-08-29 21:18:47 +00:00
Matt Kraai 5171bf6d40 SUSv2 specifies that if the extension is identical to the basename, it
should not be removed.
2001-08-29 20:19:29 +00:00
Eric Andersen dcbca62e89 Standard typing (u_int16_t instead of u16, u_int32_t instead
of u32, etc) cleanups from Laurence Anderson <laurence@zxmail.com>
2001-08-29 19:02:26 +00:00
Matt Kraai 5078919981 Use the correct buffer when calling dirname, improve an error message, and
plug some memory leaks.  Patch by Laurence Anderson.
2001-08-28 22:57:38 +00:00
Eric Andersen 28d0ac13d1 Add "DutNux" 2001-08-27 19:22:44 +00:00
Matt Kraai 91631011cc Remove traces of rpmunpack (patch by Laurence Anderson). 2001-08-27 18:55:10 +00:00
Eric Andersen 863a3e15d6 patch from vodz -- route cleanup to display all route entries 2001-08-27 17:57:27 +00:00
Matt Kraai ab3d839ef4 Add support for `busybox --help APPLET' by Vladimir Oleynik. 2001-08-27 17:19:38 +00:00
Matt Kraai 861e624e15 Fix ash exec (noted by Arne Bernin). 2001-08-27 15:08:57 +00:00
Matt Kraai 449377aa6a Fix invocation of `-/bin/sh' (bug #1209). 2001-08-27 15:02:32 +00:00
Matt Kraai 80f6d55836 Eliminate improper consts and allow standard version to override. 2001-08-24 20:35:45 +00:00
Matt Kraai ac20ce1924 Canonicalize dirname(3) behavior. 2001-08-24 19:51:54 +00:00
Matt Kraai 2a953aed38 Fix a memory leak if parent directory creation failed. 2001-08-24 19:07:31 +00:00
Matt Kraai a0065d5955 Fix s/[/]// handling (noted by Dumas Patrice). 2001-08-24 14:45:50 +00:00
Eric Andersen 31b35a16e0 Merge with the stable branch 2001-08-23 22:05:55 +00:00
Eric Andersen a3c8481a33 A patch from Jaspreet Singh <jsingh@somanetworks.com>
fixing both a segfault and cosmetic bug in route
2001-08-23 22:05:33 +00:00
Eric Andersen b76cb68979 A patch from Shu-Hao Chang <shuhao_chang@trend.com.tw> to
fixed sed handling of multiple -e commands
2001-08-22 05:58:16 +00:00
Eric Andersen 1071ccfd25 Force BB_FEATURE_NEW_MODULE_INTERFACE and BB_FEATURE_OLD_MODULE_INTERFACE
to be mutually exclusive
2001-08-22 05:41:57 +00:00
Eric Andersen c0f9d0dce7 Add #include <sys/param.h> to ensure PATH_MAX is defined 2001-08-22 05:35:39 +00:00
Eric Andersen 5d60a46269 Fix a warning and potential segfault in lash when BB_FEATURE_CLEAN_UP
is enabled
2001-08-22 05:32:24 +00:00
Eric Andersen ac5dbd193b Fix an _old_ interface problem with a never-used feature. 2001-08-22 05:26:08 +00:00
Eric Andersen 59443965ad Scrub things and ditch uint64_t and use a custom type name
to avoid C lib compatibility problems.
2001-08-22 05:06:29 +00:00
Eric Andersen d36cdd25a5 Bump version to 0.61.pre 2001-08-22 04:16:36 +00:00
Eric Andersen 39eb040757 Patch from Rodney Brown <RDBrown@mira.net>, shrinking 1.5k
from gzip by careful optimization.  Appears to work just fine
(I've tested the changes on x86, ARM, and powerpc).
2001-08-22 04:15:47 +00:00
Eric Andersen a07c902648 Make it compile with uClibc 2001-08-22 00:10:00 +00:00
Eric Andersen 75220b55ff dfp might be used uninitialized. NULL it. 2001-08-21 23:36:32 +00:00
Eric Andersen 994c6ffd3b Disable the tinylogin apps by default. 2001-08-21 23:34:10 +00:00
Eric Andersen c61804ed59 Fix dos2unix compile problem with certain glibc versions 2001-08-21 22:34:05 +00:00
Eric Andersen f349e978c4 Initial merge of all tinylogin applets that do not require crypt.
There is some optimization that can be done to better use libbb in
these applets.  There is also redundancy between stty and getty which
could be eliminated.
 -Erik
2001-08-21 16:18:59 +00:00
Matt Kraai a3e4f455ac Fix a problem with unsatisfied backrefs (noted by Martin Bene). 2001-08-20 21:21:06 +00:00
Eric Andersen 54eceffcae some minor wording changes 2001-08-20 17:48:17 +00:00
Eric Andersen 76fa8ea790 Apply Glenn's tftp rewrite 2001-08-20 17:47:49 +00:00
Glenn L McGrath bac490fe53 Fix version comparision bug 2001-08-15 11:25:01 +00:00
Matt Kraai b6ec78161d Log all messages from a single connection, not just the first. Patch from
matthias@corelatus.com, approved by Gennady Feldman <gena01@cachier.com>.
2001-08-14 17:32:23 +00:00
Matt Kraai 0a68590314 Rewritten by Manuel Novoa III. 2001-08-14 17:10:08 +00:00
Manuel Novoa III c639a35f50 I stupidly forgot one level of pointer indirection in the cmdtxt(), calcsize(),
and copynode() table implementations.  Commit the fix but keep them disabled
until others check them out.  Uncomment "//#define CMDTXT_TABLE",
"//#define CALCSIZE_TABLE", and "//#define COPYNODE_TABLE" to try them out.
Saves over 600 bytes on i386.
2001-08-12 17:32:56 +00:00
Eric Andersen dd9173c07f Fix a merging error 2001-08-10 21:11:56 +00:00
Manuel Novoa III 16815d4b45 A few bug fixes and significant size savings. Combined effort of
Vladimir N. Oleynik dzo@simtreas.ru, Aaron Lehmann aaronl@vitelus.com,
and myself.
2001-08-10 19:36:07 +00:00
Eric Andersen 80dd0863e2 Small size optimization from Aaron Lehmann 2001-08-10 18:42:04 +00:00
Eric Andersen e20b7d844a Fix stupid grammar error. 2001-08-10 15:22:35 +00:00
Matt Kraai a7cecbc917 Commit Vladimir's simplify_path. 2001-08-10 15:05:27 +00:00
Manuel Novoa III 4fb0b51703 This corrects the _really_poor_ implementation of "broadcast +" handling
by ifconfig that someone had submitted.  It fixes 1 bug, gets rid of the
excessive bloating of a structure that is used in a static const array,
and removes the implicit struct copys by keeping only the int type needed.
It also turns this into a configurable feature (off by default).
2001-08-10 06:02:23 +00:00
Matt Kraai 6c4250c0dc Remind people to enable RPC support when using NFS mount and uClibc (thanks
to David Douthitt).
2001-08-09 21:07:10 +00:00
Matt Kraai d0b5be6da8 Remove BB_SH define entirely. 2001-08-09 21:00:15 +00:00
Matt Kraai 2338d3176b Use ferror(3) to check for errors, rather than inspecting errno. Thanks to
David Douthitt for reporting, and shame on me for writing such crappy code.
2001-08-06 16:09:09 +00:00
Matt Kraai 063c1f54ea Simplified version checking. 2001-08-06 14:18:08 +00:00
Matt Kraai 69edfecfb9 Add support for underscores in variable names. 2001-08-06 14:14:18 +00:00
Glenn L McGrath b373a8d0ca Fix exclude list handling 2001-08-04 05:28:29 +00:00
Eric Andersen 0b7d70c822 Fix up some silly messups with the debian packaging, and a dumb
bug with chroot.  I've had the package uploaded but perms set to
000, so I am going to re-tag things and re-cut the release.  Folks
who pulled from CVS in the last 30 minutes with just have to cope.
 -Erik
2001-08-02 20:56:16 +00:00
Matt Kraai 8aa0b62a88 Fix misspelling of `stabilize'. 2001-08-02 20:34:24 +00:00
Eric Andersen 9e6089ee0f Ok, here we go... 2001-08-02 19:31:08 +00:00
Matt Kraai c9dd5f945b Commit NMU changelog. 2001-08-02 15:12:16 +00:00
Eric Andersen be0c36009a More libc5 fixups
-Erik
2001-08-02 10:55:32 +00:00
Eric Andersen 23b1e5c7df Some libc5 cleanups 2001-08-02 09:58:41 +00:00
Eric Andersen 879d6c85af make_directory used mode as if it were an signed entity, but in fact
it was a mode_t which is unsigned.  Fix it to be signed...
 -Erik
2001-08-02 09:58:19 +00:00
Eric Andersen 8a915880e7 Teach libc5 about realpath
-Erik
2001-08-02 09:55:58 +00:00
Eric Andersen 95b520110d Teach libc5 what a sighandler_t is
-Erik
2001-08-02 09:52:40 +00:00
Eric Andersen deba6dea03 multibuild.pl saves us again. unix2dos requires that dos2unix
be enabled.
 -Erik
2001-08-02 09:21:17 +00:00
Eric Andersen 46bf7de5f6 Ok, if no shell is enabled, don't include any of the SH_IS_<name>
options or the build will fail
 -Erik
2001-08-02 08:48:03 +00:00
Eric Andersen ff9b4a8981 Scrub away the last leftovers from BB_FEATURE_<shell>. Good thing
for multibuild.pl -- I would have missed this stupid mess otherwise.
 -Erik
2001-08-02 08:42:58 +00:00
Eric Andersen fdbac35b33 Patch from Robert J. Osborne <rj@resourceinternational.com> that fixes
a bug in vi where the beginning of the text space was not checked
before dot is decremented for delete and escape sequences on an empty
file.
2001-08-02 05:26:41 +00:00
Eric Andersen 842757dc96 Oops. I forgot to commit this part of vodz' patch. 2001-08-02 05:18:55 +00:00
Eric Andersen 3450636169 Latest patch from vodz. Adds a check for divide by zero in the posix
math suport, cleaner math syntax error checking, moves redundant signal
string tables (from kill and ash) into libbb and provides a few
cleanups elsewhere.
2001-08-02 05:02:46 +00:00
Matt Kraai 2d91deba45 Allow multiple shells to be enabled. 2001-08-01 17:21:35 +00:00
Eric Andersen 0034443140 Fix behavior of grep -lc to match GNU grep. SuS2 is ambiguous
on the correct behavior, so acting like GNU grep seems best
 -Erik
2001-07-31 23:18:49 +00:00
Eric Andersen af6b40a1ea Silence some silly warnings 2001-07-31 22:53:36 +00:00
Eric Andersen f672c9e62f Silence a silly warning 2001-07-31 22:51:49 +00:00
Eric Andersen bb9579ffc3 Make formatting match GNU ls (we were including a spare ' ')
-Erik
2001-07-31 22:43:50 +00:00
Eric Andersen fa1c5aac51 Fix the let builtin (so we can close bug #1196) and remove the
nonstandard exp builtin.
 -Erik
2001-07-31 21:38:23 +00:00
Matt Kraai 73f6a1b058 Always write record counts to stderr. 2001-07-31 21:02:19 +00:00
Eric Andersen 221b2ea6c4 I just wrote up a simple pidof applet, closing bug #1197
-Erik
2001-07-31 19:06:07 +00:00
Matt Kraai 9a53feaa76 Give credit to Adam Slattery. 2001-07-31 16:44:16 +00:00
Eric Andersen 57c82fe7c4 I think this should be the final changelog update...
-Erik
2001-07-31 16:11:41 +00:00
Matt Kraai 51038a3f42 Don't save and restore readonly flag if BB_FEATURE_VI_READONLY isn't enabled. 2001-07-31 15:01:12 +00:00
Eric Andersen 74bcd16425 This incorporates Posix math support into ash. The Posix math support
was written by Aaron Lehmann <aaronl@vitelus.com> for busybox.  This
patch makes a few trivial changes to Aaron's code so that it can be
used (in theory) by the other shells as well...
 -Erik
2001-07-30 21:41:37 +00:00
Eric Andersen dc6647201d Simplify/clarify the shell dependant bit of Config.h 2001-07-30 19:33:00 +00:00
Eric Andersen c126f8ffb6 This depmod script will create a modules.dep file, just like the depmod
binary from modutils.  This one, however, can be run on the _host_
system (need not be run on the target) and is fully cross platform, so
even if your target is ARM or powerpc or whatever, this will still
work.  When used to support the new modprobe applet, this allows
busybox to fully supplant modutils for architectures supported by
busybox insmod.
 -Erik
2001-07-30 19:32:03 +00:00
Eric Andersen 3555fd006e Fix up the sample inittab entry per what is current.
-Erik
2001-07-30 19:28:33 +00:00
Matt Kraai 13cb842773 Rework option handling to save space. 2001-07-30 14:43:20 +00:00
Matt Kraai 547e102082 Preserve whether or not the line was previously altered when running a
subst command (discovery and patch by Jim Gleason).
2001-07-30 14:05:58 +00:00
Glenn L McGrath 7499918f30 If filename is a '-' then read from stdin to stdout 2001-07-30 04:48:50 +00:00
Glenn L McGrath 14d7ea460f Note my uuencode work 2001-07-29 06:07:35 +00:00
Glenn L McGrath b6071b6341 Fix permisions when reading from stdin 2001-07-29 06:04:26 +00:00
Glenn L McGrath eba260587a Fix broken logic when wraping encoded data into rows, also simplifies it a bit 2001-07-29 05:47:33 +00:00
Glenn L McGrath 4e664ac51d The src buffer size has to be a multiple of 3 (as i noted, but didnt do). 2001-07-28 21:34:25 +00:00
Glenn L McGrath 089decab65 Rewrite based on wget uuencode function.
Saves aprox. 200 Bytes and in future can use common code between
this and wget if BB_FEATURE_WGET_AUTHENTICATION is defined.
2001-07-28 21:06:13 +00:00
Eric Andersen 220238305f PArtial Changelog update. I'm still on vacation (I'm at a campground
near the Grand Teton Mountains in Montana at the moment and my
connection is terribly slow) so this is a partial update only,
 -Erik
2001-07-28 16:35:51 +00:00
Matt Kraai 26eeb0c9da Shorten static package description. 2001-07-26 14:45:21 +00:00
Matt Kraai f9d6aa0a86 Rename dirname variable to pathname to eliminate namespace conflict. 2001-07-26 14:26:53 +00:00
Russ Dill 4db35647dd char renamed can never be negative on ARM (rp->renamed[i] != EMPTY) 2001-07-26 05:58:40 +00:00
Eric Andersen 2835efe3da Note that m68k is supported 2001-07-25 16:58:58 +00:00
Eric Andersen 1b06419e60 Cleanup some warnings and a really obvious bug.
-Erik
2001-07-25 07:23:38 +00:00
Eric Andersen 655584b07a This fixes dos2unix and unix2dos so they behave as expected. dos2unix
was broken in the 0.52 release, and unix2dos was pretty lame...
 -Erik
2001-07-25 07:22:55 +00:00
Glenn L McGrath 6c7ac21f3a Update my email address and applets 2001-07-24 02:46:35 +00:00
Glenn L McGrath 096b151f76 note dpkg rewrite 2001-07-24 02:41:06 +00:00
Matt Kraai 439e3df653 Add support for devfs device names. 2001-07-23 14:52:08 +00:00
Eric Andersen 0139ca92ff An initial modproble implementation. Quite suboptimal still,
but it does work...
2001-07-22 23:01:03 +00:00
Eric Andersen 8d79ce8320 Some patches to make dietlibc work... 2001-07-22 23:00:15 +00:00
Eric Andersen 20aab260e2 Some adjustments, mostly from David McCullough <davidm@lineo.com> to
make busybox be more uClinux friendly.  I also adjusted Config.h for
uClinux so it will automagically disable apps the arn't going to
work without fork() and such.
 -Erik
2001-07-19 22:28:02 +00:00
Matt Kraai 0382eb8865 The -P prefix should only be prepended to filenames which are not explicitly
specified.
2001-07-19 19:13:55 +00:00
Matt Kraai e92895c038 Note that wget fix is important. 2001-07-19 17:46:17 +00:00
Matt Kraai c8eae6684b The directory name should only be prepended if one was specified. 2001-07-19 17:29:38 +00:00
Matt Kraai c1cda4a609 Add a RELEASE_BB_BUFFER macro and use it to fix a memory leak in syslogd.c
(noted by Adam Slattery).
2001-07-19 15:00:14 +00:00
Glenn L McGrath 81108e7653 Cleanup (most) memory leaks 2001-07-19 12:15:13 +00:00
Glenn L McGrath c3fbec73fb Change read_package_field interface, and rewrite using low level functions
Fixes for a few bugs that have crept into dpkg in the last few days
2001-07-18 15:47:21 +00:00
Glenn L McGrath 8d3b0497a4 Fix extract_archive so it doesnt mangle filenames, dont try and extract "./" and strip leading "./" on other files 2001-07-18 13:22:44 +00:00
Glenn L McGrath 778041f8d1 Use the unofficial -C instead of -c to --configure a package, -c conflicts with another dpkg command 2001-07-18 05:17:39 +00:00
Glenn L McGrath b9e4ce99d8 Update dpkg usage 2001-07-18 05:16:31 +00:00
Glenn L McGrath ed4492a697 More feedback to user 2001-07-18 05:03:49 +00:00
Glenn L McGrath 7b0241579c Be more verbose when configureing package, minor changes 2001-07-18 04:33:31 +00:00
Glenn L McGrath 6fc92a506a Fail silently on failure to read tar header, its unfortunate that many tar implementations must be adding unwanted crap to the end of their archives.
It makes error reporting here more trouble than its worth
2001-07-18 03:23:10 +00:00
Glenn L McGrath 4cdc607f72 Use xfopen to abort on error to prevent segfaulting later. 2001-07-18 03:13:49 +00:00
Eric Andersen bc4c030023 Cleanup from vodz 2001-07-17 01:14:06 +00:00
Eric Andersen 044228d5ec This is vodz' latest patch. Sorry it took so long...
1) ping cleanup (compile fix from this patch already applied).
    2) traceroute call not spare ntohl() now (and reduce size);
    3) Fix for functions not declared static in insmod, ash, vi and mount.
    4) a more simple API cmdedit :))
    5) adds "stopped jobs" warning to ash on Ctrl-D and fixes "ignoreeof" option
    6) reduce exporting library function index->strchr (traceroute), bzero->memset (syslogd)
2001-07-17 01:12:36 +00:00
Glenn L McGrath 51ded05b3b enum entry for unarchive to be used by tar 2001-07-14 12:38:55 +00:00
Glenn L McGrath a868ec89e8 Allow the unarchive() extract_list variable to be NULL, meaning extract all 2001-07-14 08:49:53 +00:00
Glenn L McGrath 58a5bd187d Tolerate fields with no data, e.g. "Depends: " 2001-07-14 06:25:54 +00:00
Matt Kraai 06ef16563b Allow featureless ping to compile, and featureful ping to shrink
(by Adam Slattery).
2001-07-13 20:56:27 +00:00
Glenn L McGrath ccd65c9be6 Total rewrite, uses hash tables for speed and low memory use. 2001-07-13 18:35:24 +00:00
Glenn L McGrath 3d46224b78 Return NULL if file doesnt open in deb_extract 2001-07-13 18:16:57 +00:00
Glenn L McGrath cfeb08a193 Make sure there is a trailing '\0' when extracting to buffer. 2001-07-13 17:59:48 +00:00
Glenn L McGrath 5e66a26eaa Dont setvbuff in here, must be called just after stream is initialised, glibc tolerates using it later, uclibc doesnt 2001-07-13 06:51:56 +00:00
Glenn L McGrath 26a0d9a945 Call setvbuf from here isntead of gz_open for compatability with uclibc 2001-07-13 06:49:18 +00:00
Glenn L McGrath b028e08d35 Move setvbuf calls from gz_open() to calling functions, setvbuf is only supposed to be called prior to opening the stream, glibc tolerates later use, uclibc doesnt. 2001-07-13 06:43:03 +00:00
Eric Andersen 7467c8d3b6 Patch from vodz:
Changed email address
    cmdedit API change
    optimizations for traceroute and md5sum
    added a new shared create_icmp_socket() function
2001-07-12 20:26:32 +00:00
Matt Kraai f69bfc76fa Allow assignments in the export and readonly commands. 2001-07-12 19:39:59 +00:00
Matt Kraai ab6526c8b3 Remove debugging statement. 2001-07-12 18:44:34 +00:00
Glenn L McGrath 3e94f729a5 Quiet mode, sometimes error messages arent wanted 2001-07-12 10:24:57 +00:00
Glenn L McGrath c127008840 Allow unarchive to redirect stdout (tobe used by dpkg applet) 2001-07-11 17:32:14 +00:00
Glenn L McGrath 481d19b38e Fix bug where it wasnt returning the last line of a multiline field 2001-07-11 15:43:03 +00:00
Glenn L McGrath daf0b78e1a Reverse part of my previous changes 2001-07-11 15:32:52 +00:00
Glenn L McGrath 93febe672a free coniditionally, just to make it play nice with dmalloc which is incompatable with standard free() 2001-07-11 07:25:01 +00:00
Eric Andersen c59fa37d40 Make the obj's generated from libbb/unarchive.c depend on the
Makefile, so things like setting DODMALLOC will cause them to
be recompiled
 -Erik
2001-07-11 07:24:05 +00:00
Glenn L McGrath 248c57ca43 minor dmalloc inspired cleanups 2001-07-11 07:22:17 +00:00
Glenn L McGrath 59e50f634a Unpack the filename not the package name 2001-07-11 03:30:11 +00:00
Eric Andersen 8c145dc31b Fix a stupid search and replace bug... 2001-07-10 16:57:09 +00:00
Eric Andersen 55522080c6 Patch for md5sum from Aaron Lehmann <aaronl@vitelus.com> to slim
it down a little bit.
2001-07-10 16:31:29 +00:00
Eric Andersen 5c58d283bb A traceroute applet from vodz. This could probably be slimmed down,
but will do for now...
2001-07-10 16:29:00 +00:00
Eric Andersen 91b84603d3 Cleanup from vodz 2001-07-10 16:25:34 +00:00
Eric Andersen 2a46634617 Make the rev be 0.53pre... 2001-07-10 15:24:16 +00:00
Matt Kraai 5710f9f690 Read 20 512-byte blocks at a time (like GNU tar). 2001-07-10 15:05:39 +00:00
Glenn L McGrath 654944fc36 Reverse my previous change, still cant compile with dmalloc 2001-07-10 14:33:22 +00:00
Glenn L McGrath c3d2f1287e When compiling unarchive objects link to $(LIBRARIES) incase using dmalloc 2001-07-10 14:04:30 +00:00
Matt Kraai 6199fa90e5 Update version number to 0.53pre. 2001-07-10 13:57:30 +00:00
Eric Andersen 6248355c6f vodz' latest update to ash.c 2001-07-10 06:09:16 +00:00
Eric Andersen 5a4a46a251 Patch from vodz to support 'tr a-z A-Z' syntax. 2001-07-09 21:32:29 +00:00
Eric Andersen f52947ba71 Fix the spec file so it works on redhat systems. At least I think
it will work on redhat.  At least it now works on my Debian box...
 -Erik
2001-07-09 18:34:12 +00:00
Eric Andersen aa64ba459f Minor working update 2001-07-07 16:36:29 +00:00
Eric Andersen ceece81414 Move a bit more to the old news section 2001-07-07 09:38:30 +00:00
Eric Andersen d0e5f86a10 Enable APPLETS_ALWAYS_WIN 2001-07-07 09:37:28 +00:00
Eric Andersen d0b4d3dabf Typo fix. 2001-07-07 08:47:21 +00:00
Eric Andersen 7b2dfc623b Move some stuff to the oldnews area 2001-07-07 08:44:25 +00:00
Eric Andersen 40ecf7da88 Update web page... 2001-07-07 08:25:03 +00:00
Eric Andersen 5c3070b29c Update changelogs 2001-07-07 08:13:27 +00:00
Eric Andersen 807bda4a24 Minor update to include file ordering 2001-07-07 08:13:02 +00:00
Eric Andersen 7cd5075908 This is out of date, and Glenn tells me this can be safely deleted.
To be useful on Hurd will really require the new build system...
 -Erik
2001-07-07 05:25:12 +00:00
Eric Andersen 48dfc56b4a This patch from Fabio Ferrari <fabio.ferrari@digitro.com.br> enables
"broadcast +" for deriving the broadcast address automagically.
2001-07-07 05:19:52 +00:00
Eric Andersen d9d75555ba Remove rpmunpack 2001-07-07 04:43:56 +00:00
Eric Andersen 9137f2a2d1 This is obsolete -- replaced by rpm2cpio 2001-07-07 04:33:16 +00:00
Eric Andersen 5a071bcbf2 Avoid a segfault (detected by Fabio Ferrari
<fabio.ferrari@digitro.com.br> in the wget applet) when
concat_path_file() or last_char_is() were fed a NULL.
 -Erik
2001-07-07 04:27:35 +00:00
Eric Andersen 934c8ecb88 Fix sh.c so it works with DMALLOC 2001-07-07 04:24:28 +00:00
Eric Andersen 1c03923b0b Add in a shell tagline (per lash/hush behavior) to make it easier
to know which shell is in use.  Add in 'help' to list available
builtins, and fixup msh so it can do STANDALONE_SHELL.
 -Erik
2001-07-07 00:05:55 +00:00
Eric Andersen b7e6f13b3c Some minor updates. Bump version number in preparation for release.
-Erik
2001-07-07 00:03:00 +00:00
Eric Andersen 0279505e8c Update the debian packaging stuff 2001-07-06 20:36:57 +00:00
Eric Andersen d28cb03819 Forgot this 2001-07-06 19:28:49 +00:00
Matt Kraai c308847274 Remove redundant initialization of lfile to reduce executable size by
8192 bytes (noted by Mike Castle).
2001-07-06 19:28:07 +00:00
Eric Andersen 00e56ada9c Let people select their shell at compile time. 2001-07-06 19:24:27 +00:00
Eric Andersen 3bbcc95ac9 update the ignore list 2001-07-06 19:19:21 +00:00
Eric Andersen d22b78ff05 Fix a stupid bug revealed by multibuild.pl 2001-07-06 18:33:04 +00:00
Eric Andersen 77b68e6f42 Add woukaround for missing struct _res in uClibc 2001-07-06 17:51:29 +00:00
Eric Andersen 3102ac4b58 This is vodz' latest ash update. 2001-07-06 04:26:23 +00:00
Matt Kraai 5009f90ea2 Removed obsolete function, strdup_substr. 2001-07-05 19:00:47 +00:00
Matt Kraai 44edeff025 Note my activities (how immodest of me). 2001-07-05 18:32:01 +00:00
Eric Andersen 8e75f6daa6 Fix a stupid thinko, and fix killall to cope with the updated
find_pid_by_name() interface
 -Erik
2001-07-05 16:27:34 +00:00
Eric Andersen 332394b577 Be extra extra careful about what we dereference. 2001-07-05 16:09:32 +00:00
Eric Andersen d50a61956c Implement suggestion from Adam Slattery, (don't default to killing closing bug #1190. 2001-07-05 15:56:36 +00:00
Matt Kraai 94f3a570e1 Fix a thinko (the symptoms of which were reported by
David Douthitt in bug #1111).
2001-07-05 14:46:07 +00:00
Eric Andersen 8df319b213 A bit of testing today showed that ASH_BBAPPS_AS_BUILTINS was
totally breaking the shell.  Simple thinge like 'FOO=100' caused
it to segfault.  It turns out that disabling "bltincmd" is a very
bad idea.
 -Erik
2001-07-05 05:24:12 +00:00
Glenn L McGrath ed8495990a gunzip, zcat were fixed just after 0.51 was released 2001-07-05 03:46:23 +00:00
Glenn L McGrath bbac261402 ash, hush and msh are new applets to 0.52 2001-07-05 03:42:17 +00:00
Glenn L McGrath 7f3cbdd7fd Added entries for my commits 2001-07-05 03:28:28 +00:00
Matt Kraai 623cfa99e5 Remove a redundant call to mkdir. 2001-07-03 20:55:30 +00:00
Eric Andersen dd8500bce7 Cleanups and sinze reduction for the vi applet from Aaron Lehmann
<aaronl@vitelus.com>
2001-07-02 18:06:14 +00:00
Eric Andersen 3073dfbf30 Patch from Aaron Lehmann <aaronl@vitelus.com> to scrub a ton of
portability junk from gzip.c, making it a zillion times more readable.
2001-07-02 17:57:32 +00:00
Eric Andersen 22ecf049b6 Per patch from vodz, change a couple of consts to defines, since
apparently gcc 2.95.4, at least, is too stupid to realize that a
"static const int" is in fact a constant.
2001-07-02 17:32:40 +00:00
Eric Andersen 2870d964f8 Some updates to ash from vodz. Makes ash smaller. I made a few
changes, esp describing all the current ash configuration options.
Now ash adds 66k in the default configuration.
2001-07-02 17:27:21 +00:00
Eric Andersen 8f6978405d Patch from vodz to fix freeing a static in cmdedit. 2001-07-02 15:36:57 +00:00
Eric Andersen 10175a43ee Simplify a comment 2001-06-30 18:11:52 +00:00
Eric Andersen 0159597bd6 Generalize comment -- no longer ls specific 2001-06-30 18:08:36 +00:00
Eric Andersen 7e516797f9 Pad the human readable output for 'ls -sh' to 6 chars, since we will
have numbers printed as XXX.YU, so we need 6 digits not 4.
 -Erik
2001-06-30 18:00:26 +00:00
Eric Andersen 8fa1bf7cd6 Fix a silly logic error which caused symlinks to be printed twice, and
wrongly caused the return code to be an error.
 -Erik
2001-06-30 17:54:20 +00:00
Manuel Novoa III 8f01839386 Fixed scaling problems involving make_human_readable_str. 2001-06-30 07:48:01 +00:00
Manuel Novoa III a77cfbfd0c ls -s was reporting bytes instead of blocks. 2001-06-30 07:46:50 +00:00
Manuel Novoa III d877d44d12 All-integer version (but it does use an unsigned long long) which fixes
the problems of the previous version (used floating point, overflowed, didn't
round properly).  The comments at the top of the file are worth reading;
especially note 2 concerning "ls -sh".
2001-06-30 07:40:44 +00:00
Eric Andersen db15cb72e2 A really nice patch from Manuel Novoa III for compile time
configurable size/speed tradeoffs.
2001-06-29 20:44:51 +00:00
Manuel Novoa III a2949aa217 Add some missing includes to kill warnings when building with the default
Config.h and using gcc's -fno-builtin.  There are probably other files
with the similar problems.
Also, if building against uClibc, don't include asm/unistd.h in syscalls.c
and module_syscalls.c.
2001-06-29 18:59:32 +00:00
Eric Andersen ff9eee475f This is a busybox port of the Minix shell. It is reasonably capable,
handles all the basic stuff (for, case/esac, while, if/then/else), and
is very small (adds just 38k on x86).  It is not as rigorously correct
about Bourne semantics as bash, but for most things it is quite
workable.  There is still some work to be done to further shrink it (it
has its own globbing functions instead of using the libc ones, for
example), but it is quite usable as is.
 -Erik
2001-06-29 04:57:14 +00:00
Eric Andersen 66ca9480c8 Fix a nasty hard to spot bug found by Ralph Siemsen <ralphs@netwinder.org>.
This would cause it to obliterates the end of the strtab section, so
symbol lookups would fail and then it would crash.  Ugh.  This should
fix things for people having trouble with insmod.
2001-06-28 21:36:06 +00:00
Eric Andersen 029b4a0422 Allow xrealloc to act as a free() when size=0, per SuS2.
-Erik
2001-06-28 21:22:19 +00:00
Eric Andersen ec23c4920f Remove vodz from credits, per his request 2001-06-28 16:43:57 +00:00
Eric Andersen df82f611c8 Scrub up the licensing block
-Erik
2001-06-28 07:46:40 +00:00
Eric Andersen cb57d551a2 This a an ash applet I put together. It is similar to the one put
together by vodz, but uses newer sources, has the removed features
commented out instead of simply deleted (so they could be re-enabled)
and the builtins all work.  This adds 72k.
 -Erik
2001-06-28 07:25:16 +00:00
Eric Andersen 184d73636d Remove unneeded stuff. 2001-06-28 03:22:19 +00:00
Eric Andersen 028b65b060 More thrashing about trying to make hush behave itself wrt job
control...
2001-06-28 01:10:11 +00:00
Eric Andersen 07abfe2092 don't whine if all we need to do is remove a bg job 2001-06-27 17:29:11 +00:00
Eric Andersen 0d8cc1670c Fix a type promotion bug discivered and analyzed by Alan Modra
<amodra@bigpond.net.au>, which caused false checksum errors
2001-06-27 06:15:50 +00:00
Eric Andersen 4b6b5e4314 Re-enable globbing (I'd accidentaly removed it) and finish off the last
of the job control polishing.  Works fine now.
 -Erik
2001-06-27 04:30:11 +00:00
Eric Andersen 5c66d06104 Explicitly call setsid() 2001-06-26 23:16:31 +00:00
Eric Andersen 0392b8638e Minor formatting change 2001-06-26 23:11:44 +00:00
Eric Andersen a90f20b1c3 Don't choke if /etc/profile is not available 2001-06-26 23:00:21 +00:00
Eric Andersen d98337a7b4 Fix ps so it doesn't waste space showing group, as it is pretty much
meaningless anyways.
 -Erik
2001-06-26 22:55:45 +00:00
Eric Andersen 91a6318d55 Make it so we don't segfault when /proc isn't mounted -- guess pid 1...
-Erik
2001-06-26 22:44:09 +00:00
Eric Andersen 5ef5614c31 Don't use void * to pass pointers of known type 2001-06-26 16:36:26 +00:00
Eric Andersen ce98c19dfe A patch from Erik Meusel <erik@wh58-709.st.uni-magdeburg.de>
to fix the behavior of 'tail -f -n 0 FILE'
2001-06-26 15:07:08 +00:00
Glenn L McGrath 78b0e379d7 Vladimir's last_patch_15 2001-06-26 02:06:08 +00:00
Glenn L McGrath addabd6f16 Patch from Gennady Feldman
This should fix "circular buffer" error message shown when running "syslogd -C"
2001-06-26 01:41:59 +00:00
Glenn L McGrath f8736d251e rpm2cpio applet by Laurence Anderson 2001-06-26 01:19:34 +00:00
Eric Andersen 6c947d289f Fix the code for establishing a controlling terminal.
-Erik
2001-06-25 22:24:38 +00:00
Eric Andersen 24982c589b Fix up some warnings that show up on ppc 2001-06-25 19:31:48 +00:00
Eric Andersen 2d848a476a This should finish off the job control issues with lash. Make certain
we have a controlling terminal...
 -Erik
2001-06-25 17:11:54 +00:00
Glenn L McGrath 2e6d3cfa82 Nore unarchive (and doc) fixes from Laurence Anderson 2001-06-24 12:36:54 +00:00
Eric Andersen 1557626897 Make the extern NUM_APPLETS be a extern const NUM_APPLETS, to match
the actual definition.
 -Erik
2001-06-24 06:09:14 +00:00
Eric Andersen e0c0757d09 These were broken when using dmalloc due to include file ordering
problems.  busybox.h must be last.
 -Erik
2001-06-23 13:49:14 +00:00
Eric Andersen d9c8acec37 Leave BB_FEATURE_NFSMOUNT disabled by default.
-Erik
2001-06-22 15:48:19 +00:00
Glenn L McGrath 8f5b63edea cpio applet, and changes to associated code 2001-06-22 09:22:06 +00:00
Eric Andersen 52a97ca00c Some more cleanups. Of special importance, never free a pipe
that still has running jobs.  Instead, we ignore it and expect
it to be cleaned by the background job stuff.
 -Erik
2001-06-22 06:49:26 +00:00
Eric Andersen c798b07762 Some cleanups for hush. Saves about 350bytes.
-Erik
2001-06-22 06:23:03 +00:00
Matt Kraai a0105713e8 Remove obsolete function declaration. 2001-06-22 04:20:24 +00:00
Eric Andersen 764303f980 stdlib.h defined free(), which this needs 2001-06-22 03:07:19 +00:00
Eric Andersen 30f1eafaaa Fix the build process so it does not do the evil #ifdef BB_FOO stuff.
Build exactly one .o file per function, and let the linker throw away
the junk it doesn't want.
 -Erik
2001-06-22 03:00:21 +00:00
Eric Andersen 6b03504441 Add in a missing header file 2001-06-22 02:58:45 +00:00
Glenn L McGrath 76ce7549ce Dont change date or chmod on symlinks, lchown on symlinks if lchown available 2001-06-22 02:55:16 +00:00
Glenn L McGrath 9f832deecf remove defines around unarchive, its always used 2001-06-22 02:27:55 +00:00
Tim Riker 7387240ef0 heh 2001-06-22 00:27:21 +00:00
Tim Riker 837097648e comment cleanup 2001-06-22 00:27:11 +00:00
Tim Riker fbbd360b3c create_path -> make_directory 2001-06-22 00:14:20 +00:00
Eric Andersen 8071c02131 Add wget -P support, finishing off bug #1176
-Erik
2001-06-21 19:45:06 +00:00
Matt Kraai ceeff73819 Rewrote mkdir (and touched lots of things in the process). 2001-06-21 19:41:37 +00:00
Eric Andersen 091781e20e Support tar -C, per bug #1176
-Erik
2001-06-21 19:30:10 +00:00
Eric Andersen 8a646dd293 This commit guts lash, restoring it to what it was originally intended to do,
just be a simple command line interpreter with basic pipe, redirect, and job
control.  For all the more fancy things, people should use hush or ash.
 -Erik
2001-06-21 16:38:11 +00:00
Eric Andersen ea4abff595 Add in (and ignore) tar -p, since we preserver permissions automatically.
closes bug #1185
 -Erik
2001-06-21 15:17:59 +00:00
Matt Kraai 075228a461 Remove documentation of unsupported sed options. 2001-06-21 14:40:55 +00:00
Matt Kraai 02c40a72b8 Always apply commands with no specified range. 2001-06-21 13:57:51 +00:00
Eric Andersen fa2661f2e5 Per a suggestion from Tom Oehser, fix up the leading-hyphen hack to
make it general.  Now all leading single hyphens are ignored for
purposed of applet name matching, while argv[0] is still passed
unaltered to applets, so leading-hyphen sensitive applets (such as sh)
can react accordingly.
 -Erik
2001-06-21 04:56:24 +00:00
Eric Andersen aff5e2eaef it turs out, there was a nasty tar bug where bb tar would create leading dirs
with mode 0777 in all cases due to usask issues.  Thanks to Matt Kraai for
noticing and spotting the culprit.  This makes bb tar behave just like GNU
tar once again.
 -Erik
2001-06-20 20:47:31 +00:00
Glenn L McGrath 06a71cced2 Initialise in_file to stdin, so it wont crash if no source specified 2001-06-20 08:07:34 +00:00
Glenn L McGrath 8e74bf94f3 Changed gz_open to ruturn a stream 2001-06-20 07:54:15 +00:00
Glenn L McGrath eb1c94078f Reorganise unarchiving functions, more code re-use, only does single pass(no more linked lists), basis for supporting a cpio (and cheaper untar) applet, but cpio applet isnt included in this.
It effects ar, dpkg-deb applets only
2001-06-20 07:48:00 +00:00
Eric Andersen b4a26e6fc0 For m68k, use __mc68000__ (not __m68k__ ), since that is what the
various m68k compilers seem to actually use...
 -Erik
2001-06-19 15:00:52 +00:00
Mark Whitley 74c97cdba6 Changed a hard-coded path to a variable defined path. 2001-06-18 16:52:56 +00:00
Eric Andersen 32574a41b4 With a bit of care I was able to save about 100 bytes.
-Erik
2001-06-15 20:10:39 +00:00
Mark Whitley bd4b621e91 Applied patch from Jim Gleason that makes it so busybox will still work even
if you rename it.
2001-06-15 16:54:25 +00:00
Glenn L McGrath 6bad1fa1fd This isnt used anymore, replaced by seek_sub_file() in ./libbb/deb_extract.c 2001-06-15 03:13:00 +00:00
Eric Andersen f429baca86 I reworked make_human_readable_str so it now has a sane interface,
and then fixed up df, du, and ls to use the new interface.  I also
fixed up some formatting issues in ls while I was in there.
 -Erik
2001-06-13 08:02:45 +00:00
Glenn L McGrath 17822cd60a Reorganise unarchive functions, new files, removed some 2001-06-13 07:34:03 +00:00
Glenn L McGrath 9aff903603 Reorganise archive extraction code 2001-06-13 07:26:39 +00:00
Eric Andersen dab3d46b9d A patch from Benjamin Zeckel <bzeckel@cisco.com> to allow
nslookup.c to display the correct default nameservers.
2001-06-12 22:21:24 +00:00
Eric Andersen 583e3ca456 Add in Devil-Linux 2001-06-12 22:04:40 +00:00
Matt Kraai 7bd773c9fe Only use a login shell when it will run on a console. 2001-06-12 20:55:02 +00:00
Mark Whitley 0915c4b985 - Fixed bug where you couldn't mix line number and regexes in two-address cmds
- Fixed bug where you couldn't use two addresses for a 'c' cmd
 - Moved the do_sed_cmd function into process_file to simplify some things
 - Reduced a buncha lines of code in the process
2001-06-11 23:50:06 +00:00
Matt Kraai bf0a010cf7 Copy files until EOF, not the reported file size, to deal with bad sizes in
the proc filesystem.
2001-06-11 13:58:02 +00:00
Matt Kraai 5246225596 Add padding to struct sysinfo needed by m68k (note and patch by Richard
Hirst).
2001-06-08 13:57:27 +00:00
Eric Andersen 04407e522b Another hush update from Larry:
Fixes the interaction between if/then/else/fi syntax and variables.
    I planned to do it right from the beginning, but my implementation
    was buggy.  Also adds the relevant test cases.  Also adds some old
    Matt Kraai variable test cases that got left out somehow.
2001-06-07 16:42:05 +00:00
Eric Andersen 4f3e24979b Add the Linux Terminal Server Project 2001-06-06 18:21:25 +00:00
Eric Andersen 817e73cb63 A patch from Larry to fix pathological things like '>""' 2001-06-06 17:56:09 +00:00
Matt Kraai 12422ffe3e Added a new testcase from Larry Doolittle (inspired by a note from Vadim
Berkgaut).
2001-06-05 17:48:47 +00:00
Matt Kraai c616e53ca2 Don't close file descriptors when we are duplicating them. 2001-06-05 16:50:08 +00:00
Eric Andersen f4dd6e3d1a Do not purge the .cvsignore files on 'make release' so that
people can properly import into their own CVS trees.
 -Erik
2001-06-04 17:26:38 +00:00
Eric Andersen cb2a372c9f Revert the patch from Konstantin Boldyshev <konst@linuxassembly.org> to never
change permissions on existing directories.  This behavior is contrary to SUSv2
and contrary to GNU tar.  Thanks to Matt Kraai for pointing this out.  I should
have been much more careful about accepting such a patch.
 -Erik
2001-06-04 16:54:39 +00:00
Matt Kraai 67a4640333 Loop forever instead of exiting. 2001-06-03 05:55:52 +00:00
Glenn L McGrath 62ebe2e443 Remove space between ar options 2001-06-03 05:41:59 +00:00
Glenn L McGrath cda5cf1c2f Correct ar options 2001-06-03 05:15:04 +00:00
Matt Kraai 9344f7575e Don't whine about already mounted filesystems when invoked with -a. 2001-06-03 02:21:38 +00:00
Eric Andersen 8b113f93b9 Vladimir's last_patch13, containing several bugfixes. 2001-06-01 21:47:15 +00:00
Eric Andersen 4f6753e586 Cope gracefully when people type something, then hit ^C.
-Erik
2001-05-31 17:17:12 +00:00
Eric Andersen 4f990533e3 Patch from Vladimir to fix up autocompletion on a files/dirs with spaces in
them in the presence of a quoting.  Also revert my signal handling patch,
which seems to not solve the problem I thought it solved.
2001-05-31 17:15:57 +00:00
Eric Andersen f12cc4ee68 Make hush the default shell. Ensure the applets_list gets
the axe on a distclean.
2001-05-30 19:09:40 +00:00
Eric Andersen 86f0167e39 grep failed to compile when BB_FEATURE_CLEAN_UP was defined -- types were wrong. 2001-05-29 22:36:39 +00:00
Matt Kraai 6e9e136fcb Use safe_strncpy. 2001-05-27 14:11:52 +00:00
Mark Whitley 4f6aea807b More shell / quoting testcases from Larry. 2001-05-24 23:05:13 +00:00
Mark Whitley 8b7a0d807a Some more patchelttes from Larry Doolittle. 2001-05-24 21:31:09 +00:00
Mark Whitley 0a4f578fdc 'Nother patch from Larry to fix a buglet in how the line gets sed-ified.
Also, more testcases and comments on bugs and formatting differences in some
of the testcases.
2001-05-24 21:24:39 +00:00
Mark Whitley fa43e54b6f Added support for grep -e and grep -f, closes bug #1164. Also added some
testcases for these new features.
2001-05-24 18:36:18 +00:00
Mark Whitley 04052f96e1 Numerous new testcases from Larry Doolittle and a patch to tester.sh to avoid
a bash2-ism and quote variables that contain strings.
2001-05-24 17:15:33 +00:00
Eric Andersen a813afc24f Plug another memory leak 2001-05-24 16:19:36 +00:00
Eric Andersen 5a9d441b2c Fix up some signed char vs int issues that show up on powerpc. 2001-05-24 14:16:28 +00:00
Eric Andersen 1c1f5d3047 Get BB_LASH out of the list... 2001-05-24 14:11:09 +00:00
Eric Andersen a15dc15f12 Plug another memory leak in hush. This one showed up when backticked
commands were run.  This one was sure a bugger to find.
 -Erik
2001-05-23 23:46:09 +00:00
Eric Andersen bf7df04ec1 Fix a massive memory leak in the run_list_test() function.
Rename run_list_test() as free_pipe_list().
Rename run_pipe_test() as free_pipe().
 -Erik
2001-05-23 22:18:35 +00:00
Eric Andersen 77d9268892 Patch from larry to fix some grammar errors. 2001-05-23 20:32:09 +00:00
Matt Kraai bdd4eced84 Commit a patch by Larry Doolittle which fixes recursive calls to file_peek,
and improves some debugging messages.
2001-05-23 17:43:00 +00:00
Matt Kraai 774d135b66 Make more robust (patch by Larry Doolittle). 2001-05-23 14:45:09 +00:00
Eric Andersen 3200f5ac68 It turns out the descriptions of both dos2unix and unix2dos
were broken.  This fixes.
 -Erik
2001-05-22 22:39:10 +00:00
Eric Andersen 57e6a49e5b Excellent. This patch from Larry fixes the behavior of hush
when builtins are included in pipes.
2001-05-22 22:34:51 +00:00
Eric Andersen 9978576f15 Fix this case. No, really this time.
unset FOO
    export FOO=bar
    FOO=baz
    echo "global env: " `env | grep ^FOO`
    echo "local env:  " `set | grep ^FOO`
 -Erik
2001-05-22 21:37:48 +00:00
Eric Andersen aeb44c4da6 Fix a race. Sometimes by the time we got to checkjobs(), the
pipe struct had already been freed.  Return immediately if the
pipe is NULL.
2001-05-22 20:29:00 +00:00
Eric Andersen 816867858b Oops. Remove some debug noise I left in. 2001-05-22 19:23:35 +00:00
Eric Andersen 94ac244dea Updates from both Vladimir and Larry 2001-05-22 19:05:18 +00:00
Matt Kraai 1eb4acfc23 Fixed misnamed rewind command (noted by Tom Oehser). 2001-05-22 14:32:35 +00:00
Matt Kraai edc806507c Fixed extra -- lines (noted by Christophe Boyanique). 2001-05-22 14:29:27 +00:00
Matt Kraai 117231c44f Make - read compressed data from stdin (thanks to Marius Groeger). 2001-05-22 14:23:02 +00:00
Matt Kraai 7f7348b7b2 Correctly remove leading slashes upon extraction (thanks to Marius Groeger). 2001-05-22 14:18:03 +00:00
Mark Whitley 1d9d41150b Fixed mishandling of -c & -l options and accounted for case when we're
grepping only one file.
2001-05-21 21:13:00 +00:00
Eric Andersen 004015e9c4 Patch from Lars Kellogg-Stedman <lars@larsshack.org> to fix bug
#1130 (i.e. When you turn on features it should always ADD features)
2001-05-21 20:30:51 +00:00
Eric Andersen abec344ab7 A couple more minor touchups 2001-05-21 17:58:01 +00:00
Eric Andersen 317827d9e5 Several cleanups for usage messages 2001-05-21 17:50:53 +00:00
Matt Kraai 73991ff925 Fix tell support. 2001-05-21 17:01:32 +00:00
Eric Andersen ada18ff0f5 The latest patch from Larry 2001-05-21 16:18:22 +00:00
Eric Andersen 8ae319a322 This patch from Bernhard Kuhn <kuhn@lpr.e-technik.tu-muenchen.de> is based on
the work of Jinux Kim on his "babobox" (derived from busybox-0.42), and enables
kernel module loading and unloading for uClinux/m68k.
2001-05-21 16:09:18 +00:00
Eric Andersen 2f6e1f880b Patch from Gernot Poerner <gp@it-netservice.de>. Adds in
mount bind support.
2001-05-21 15:59:34 +00:00
Matt Kraai 13a70ac2ab Fix open mode for IOCTLs which write to the tape. 2001-05-21 15:00:39 +00:00
Eric Andersen 9ffb7dd9a4 This is a patch from Vladimir:
> I rewrite *local_variable* function in hush.c with:
    > 1) remove many memory leaks
    > 2) add support read_only protect (require write builtin function for set this,
    > I write this special for variable HUSH_VERION=0.01)
    > 3) commad read set only local variable now
    > 4) remove many error messages if "set unset export" not defined variable
    > (bash syntax not put and set error code). Hmm, if I set result to -1, you hush
    > called waitpid and returned with error "no waitpid" ( i not found place this
    > error).
    > 5) destroy error in new version check xgetcwd()==NULL and set "(unknow)" -
    > this have error: crashe in next call `pwd`, but xgetcwd(not null) called
    > free(arg).
    > 6) next add integraion with libbb

Valdimir's patch missed two cases of local variable handling
    FOO=bar
    export FOO=baz
    unset FOO
and
    export FOO=bar
    FOO=baz
which were working before, so I fixed those two cases.
2001-05-19 03:00:46 +00:00
Eric Andersen 6197c51834 Fix an escape problem in the docs. Some \n's didn't have the '\'
escaped, and so were messsing the out output.
 -Erik
2001-05-18 23:14:53 +00:00
Mark Whitley b6967635eb (Almost) brand-new version of cut that supports muitiple lists of positions,
per feature request from Tom Oehser.
2001-05-18 23:04:51 +00:00
Matt Kraai 1844770fec Changed snprintf copies to use strncpy at the suggestion of Aaron Lehmann. 2001-05-18 21:24:58 +00:00
Matt Kraai d6ef07406d Rewrote copyfd to use library functions, terminate, and copy correct data. 2001-05-18 14:14:55 +00:00
Matt Kraai 6943815400 Fix applet_name. 2001-05-17 20:40:21 +00:00
Matt Kraai 231f998aba Switch from hstrerror to herror for libc5 systems. 2001-05-17 14:19:05 +00:00
Matt Kraai 7cedac567c Remove unused function. If necessary, we can use remove_file instead. 2001-05-17 04:03:22 +00:00
Matt Kraai bc0f783a5f Fix invocation of builtin shell to have proper argc and argv. 2001-05-17 03:54:37 +00:00
Matt Kraai 233817437d Always print a newline after a matching substitution. 2001-05-17 01:02:58 +00:00
Eric Andersen bfae2529b8 It turns out job control in both hush and lash was broken by the
signal handling in cmdedit.c.  Disabling it makes the shells behave
themselves again.  hush isn't quite there, but is getting close...
 -Erik
2001-05-17 00:14:27 +00:00
Eric Andersen 2439a59828 Remove/replace the "div" call. 2001-05-16 18:53:34 +00:00
Matt Kraai 8f7a4ad442 Add missing include, noted by Larry Doolittle. 2001-05-16 17:05:03 +00:00
Matt Kraai bf381a0ad8 Whoops. Forgot the x. 2001-05-16 15:52:23 +00:00
Matt Kraai c55b8d41c1 Add xgethostbyname and herror_msg* functions. 2001-05-16 15:40:51 +00:00
Matt Kraai 59df6f7398 Change 'printf("%s\n", ...)' into 'puts(...)'. Noted and patched in hostname.c
by Larry Doolittle.
2001-05-16 14:21:09 +00:00
Eric Andersen bc604a2f41 Move init of a bunch of globals into main so we are at least
a bit more reentrant.
 -Erik
2001-05-16 05:24:03 +00:00
Eric Andersen f72f562b2f Fix the behavior of local shell variables to match that of bash and ash.
-Erik
2001-05-15 23:21:41 +00:00
Eric Andersen 9abfe85e96 Suggestion from Larry: no format string, use fputs instead. 2001-05-15 20:11:49 +00:00
Eric Andersen 50ae3102fb Patch from Adam Heath <doogie@debian.org> to add arbitrary header support
to wget, so it can now do funky interactive things with cgi scripts.
2001-05-15 17:51:37 +00:00
Eric Andersen 55f9872616 This patch from Adam Heath <doogie@debian.org>, makes print_file
(used by cat, grep, sed, etc) quite a bit faster.
2001-05-15 17:48:09 +00:00
Eric Andersen c911a4389b Patch from Vladimir:
1) fixed a bug that could crash df, mount, and umount applets if the root
    device name was longer then the word "root" (/dev/loop1 vs /dev/root) -
    2) severl functions needed static declaration in the umount applet
    3) update declaration for function in last_char_is() in libbb
2001-05-15 17:42:16 +00:00
Eric Andersen 15649c11f3 Oops. I left in some debug noise. 2001-05-15 17:28:26 +00:00
Eric Andersen 20a69a77d2 Write set_local_var() and fixup lookup_param() so you can now use
shell local variables.
 -Erik
2001-05-15 17:24:44 +00:00
Eric Andersen 78a7c99f7f This patch covers one big part of variable handling.
$ a=b foo
should be handled correctly.
$ a=b
is parsed OK, but the actual variable setting is not
yet written.  Except for some weird exceptions related
to quoting rules, this code passes (matches ash behavior)
all the tests I threw at it.

If someone now writes set_local_var(), and updates lookup_param()
to match, we can claim success!

       - Larry
2001-05-15 16:30:25 +00:00
Matt Kraai be9f44a7df Fix incorrect length passed to accept noted by Larry Doolittle. 2001-05-15 03:05:39 +00:00
Mark Whitley 336480fe6f Added some testcases for grep and sed (many more could still be added) 2001-05-14 21:18:54 +00:00
Mark Whitley d928accbbd ...Need to print just a few more newlines. 2001-05-14 20:44:26 +00:00
Eric Andersen 2416dfc3c9 A compromise solution for insmod 2001-05-14 20:03:04 +00:00
Mark Whitley dd527d3c62 ...And now that we're chomping lines, we need to re-add the newline later... 2001-05-14 19:53:08 +00:00
Mark Whitley 9de2659264 We will chomp() lines so REG_NEWLINE does not break stuff. Thanks, Matt. 2001-05-14 19:44:44 +00:00
Mark Whitley 35e59bed97 Fixed a subtle bug in the handling of -l and -c flags. 2001-05-14 19:40:32 +00:00
Mark Whitley 452cc1f293 Added REG_NEWLINE as cflags to xregcomp for normal addresses so EOL $ will work 2001-05-14 19:23:02 +00:00
Matt Kraai 9496466044 Follow symbolic links when searching for modules. 2001-05-14 18:27:25 +00:00
Eric Andersen 14d354312a Per suggestion from Vladimir, eliminate check_wildcard_match(), which
was only being used by insmod these days.

Also, I spent a minute adjusting insmod so that it first searches
/lib/modules/`uname -r` and then (if that fails) searches /lib/modules,
which makes bb insmod behave much more like the real insmod, and should
avoid nasty surprises (such as the recent "Modutils vs. Busybox..."
thread).
 -Erik
2001-05-14 17:07:32 +00:00
Matt Kraai cb378a5267 Add missing periods and delete superfluous whitespace. 2001-05-14 06:35:15 +00:00
Eric Andersen a17b3631fe Do not ever change permissions on existing directories, only
on directories we created while extracting a tarball.  Fix
based on bug report and patch from Konstantin Boldyshev
<konst@linuxassembly.org>
 -Erik
2001-05-13 15:39:30 +00:00
Eric Andersen 95a349f427 When doing a 'wget -O -' turn on the quiet flag, lest the status bar
noise get mingled with the retrieved webpage.
 -Erik
2001-05-13 00:55:54 +00:00
Eric Andersen ddb00545b7 A patch from Aaron Lehmann <aaronl@vitelus.com> to fix a
crash on a broken regexp.
2001-05-13 00:48:09 +00:00
Eric Andersen 4819c3d477 Make the locale stuff only do the getpid==1 check if BB_INIT is defined 2001-05-13 00:33:16 +00:00
Mark Whitley 1f3b9f297e Added support for 'r' command in sed. 2001-05-11 22:27:13 +00:00
Eric Andersen cfa88ecb72 Fix up some silly warnings 2001-05-11 18:08:16 +00:00
Eric Andersen 5f265b755a Fix a segfault in lash, hush, and cmdedit. Each of these used
xgetcwd, but did not check the return for a NULL, and then continued
to call strlen on the NULL when the cwd had been removed from under it.
 -Erik
2001-05-11 16:58:46 +00:00
Eric Andersen 9d94deabd3 Use xgetcwd 2001-05-11 16:36:03 +00:00
Eric Andersen 238da24620 Fix the chown usage text, also thanks to Lars Kellogg-Stedman <lars@larsshack.org> 2001-05-11 16:31:46 +00:00
Eric Andersen 2b02ab9606 This patch from Lars Kellogg-Stedman, fixes the behavior of
chown to be consistant with GNU chown, so that it follows
symlinks (who cares about the perms on a link anyways?) unless
the -h option is supplied.
 -Erik
2001-05-11 15:55:41 +00:00
Matt Kraai eb5f433736 Check that putenv succeeded, suggested by Jonas Holmberg. 2001-05-11 15:16:28 +00:00
Matt Kraai c96381be40 Fix env usage information. 2001-05-11 14:28:17 +00:00
Matt Kraai 5b44f48afc Fix handling of '-' option and way that variables are added to the
environment from Jonas Holmberg <jonas.holmberg@axis.com>.  Fix
handling of command options by adding + to getopt string.
2001-05-11 14:26:29 +00:00
Matt Kraai f3e79ba6e3 Fix symlink removal problem noted by Erik Andersen. 2001-05-11 02:35:36 +00:00
Matt Kraai 6e91f69a0d Add installation instructions from Tomas Pospisek <tpo_hp@sourcepole.ch>. 2001-05-10 14:12:20 +00:00
Matt Kraai 854125f6e6 Make stdio functions which can be interrupted by the progressmeter timer
recover gracefully from EINTR.
2001-05-09 19:15:46 +00:00
Eric Andersen d283e1cfe9 Bump version to 0.52pre 2001-05-09 17:31:27 +00:00
Eric Andersen 1a6d39b259 A few more structural updates for job control.
-Erik
2001-05-08 05:11:54 +00:00
Eric Andersen 0a36de0580 Fix a stupid segfault caused by dereferencing a NULL ptr.
-Erik
2001-05-08 04:25:46 +00:00
Eric Andersen 45e92ba2ce This patch from Evin Robertson <nitfol@my-deja.com> fixes export so it works.
This way leaks memory, but oh well.  We will probably fix that when we get
around to doing local variables.
2001-05-07 23:53:09 +00:00
Eric Andersen 8cd16d8fd3 This syncs things with Vladimir's latest patches. Also gets
rid of useless 'const int' declarations.
 -Erik
2001-05-07 23:11:23 +00:00
Eric Andersen 186bf1defc This is Vladimir's update to last_char_is(). Since 'char *' is
the least common denominator, I modified it to use that (not const),
which will minimize the need for casting elsewhere.
2001-05-07 23:10:16 +00:00
Eric Andersen de0ca0cd9e Silence cut so it doesn't whine during compilation 2001-05-07 23:07:17 +00:00
Eric Andersen f3f9f3efa7 A patch from Vladimir to simplify chomp() 2001-05-07 23:02:39 +00:00
Eric Andersen 4ad13e5d95 A patch from Vladimir to simplify concat_path_file() and
make it less likely to break.
2001-05-07 23:01:32 +00:00
Eric Andersen c33ebc9741 A patch from Vladimir to use last_char_is(), and a patch from
Larry to fix a silly bug when BB_FEATURE_VI_OPTIMIZE_CURSOR
is not defined.
2001-05-07 22:57:47 +00:00
Eric Andersen 04b0354d8e Patch from Vladimir to use last_char_is to simplify du.c 2001-05-07 22:49:43 +00:00
Eric Andersen 8f3e51b4ad Patch from Vladimir to remove testing stuff from stty 2001-05-07 22:47:45 +00:00
Eric Andersen 8d35134ad8 A bug fix from Vladimir for a memory leak I stupidly
added to which.c.
2001-05-07 22:45:06 +00:00
Eric Andersen 83a2ae2184 More hush updates from Larry:
Update some comments.  Generate partial placeholders for the missing
    builtins.  Write builtin_umask.  Properly treat exec without arguments
    as a means to open/close files within the running script.  Implement
    "4<&-" that encodes for file descriptor closure.
2001-05-07 17:59:25 +00:00
Eric Andersen 7e1273edf7 Patch from Jim McQuillan to pass the terminal type to the remote host. 2001-05-07 17:57:45 +00:00
Eric Andersen 238bc4090d Per comment from Jim McQuillan <jam@mcquil.com>, don't log
syslogd startup/shutdown messages as KERN.EMERG, but use
SYSLOG.INFO instead.
2001-05-07 17:55:05 +00:00
Eric Andersen da7f095c12 Update comment re USE_SYSTEM_PWD_GRP
-Erik
2001-05-07 17:51:34 +00:00
Eric Andersen 28355a36da Per some comments from Lars Kellogg-Stedman <lars@larsshack.org>,
make xreadlink() return NULL on failure, and make sure everyone
uses the interface correctly.
 -Erik
2001-05-07 17:48:28 +00:00
Eric Andersen 822c3837f9 Another vi update from Sterling Huxley:
- All of the ESC sequences are now in variables.  This should make
  re-targeting for other terminals easier.

- The initial screen draw does not force out every single column.
  Should be faster.

- The place_cursor() routine trys to be smarter about moving the
  cursor.  This is optional based on BB_FEATURE_VI_OPTIMIZE_CURSOR.

- The 't' and 'f' intra-line positioning commands were added.
  They can now be used as targets in 'c' and 'd' commands, i.e.,
   dfx - delete from dot to next 'x'
   dtx - delete from dot to the char before next 'x'

- show_status_line() uses a static int checksum to remember what
  is currently displayed on the screen and not re-draw the status
  line unless it has changed.

- Some of the code in refresh() was moved out to format_line().
  refresh() trys to send out the smallest segment containing
  the changed chars rather than the whole line.

- Added "flash" to the :set command to specify if error indication
  should be by flashing the screen or ringing the bell.

- Changed the rawmode() routine so that it turns off the
  NL -> CR NL translation. On output of a NL, the OS will not add
  a CR.

- If vi was started as "view", with global read-only mode,
  and another file is opened, the file is opened read-only
  rather than read+write.
2001-05-07 17:37:43 +00:00
Glenn L McGrath 713b398700 woops, forgot the break statment 2001-05-07 12:06:37 +00:00
Glenn L McGrath 5bcfc9ba1a Tolerate -q argument, if -q is passed give a warning and continue rather than just fail 2001-05-07 12:01:58 +00:00
Glenn L McGrath cc0aa0f2d7 Actually we dont need to check if the device is nfs as it wont be stat'ed 2001-05-07 01:51:24 +00:00
Glenn L McGrath 1b62619446 woops, i shouldnt be so presumtuous? about what the error will be 2001-05-07 01:40:59 +00:00
Glenn L McGrath 3aae10014c Device may not be a real filename 2001-05-07 01:38:03 +00:00
Matt Kraai 2e6c878763 Rewrite -c and -b processing to shrink code and eliminate buffer overrun. 2001-05-05 16:19:13 +00:00
Glenn L McGrath 6b8c550d88 include libbb.h after other includes 2001-05-05 03:19:12 +00:00
Eric Andersen 2dcfba7117 Larry's variant on Evin Robertson's fix to what I messed up
trying to make job control work.  This fix makes it so that
hush doesn't error out when init hasn't set up job control,
as in when init=/bin/sh
2001-05-04 22:13:37 +00:00
Eric Andersen 044a72d0d5 Larry suggested using concat_path_file() would be an even safer bet
for 'which'.  I ageed, so I whipped this up -- which revealed a bug in
concat_path_file.  It turns out that that a '/' can be appended from
either the path _or_ the filename, but only the former was checked.
 -Erik
2001-05-04 22:04:24 +00:00
Mark Whitley a0ba9f45fb Wrote documentation and scripts for creating a busybox boot floppy. Initial revision. 2001-05-04 21:46:00 +00:00
Matt Kraai d24f878546 Don't reset parents context when we encounter an terminator. Fixes
if true; then if true; then true; fi; fi
2001-05-04 21:20:20 +00:00
Eric Andersen 7526f035f4 Fix a buffer overflow. Which accounted for the size of the path, plus the the
'/', plus the size of the test command.  It did not account for the terminating
NULL, which overwrote the end of the string.
 -Erik
2001-05-04 20:47:33 +00:00
Eric Andersen e5ffb911e8 If it fails to run a builtin, let it fall through to
exec the real thing.
 -Erik
2001-05-04 16:30:29 +00:00
Matt Kraai e6bf66eada Fix two bugs reported by Ralph Jones. 2001-05-04 14:49:58 +00:00
Eric Andersen b0aca921be A todo update from larry to acknowledge the existance of hush 2001-05-03 17:35:48 +00:00
Eric Andersen 87d893c04b devfs does not support creation of regular files. So change the
test a bit so as to not possibly create a regular file.
 -Erik
2001-05-03 07:01:41 +00:00
Matt Kraai 6689140597 Remove summary header. Not present in GNU or SUSv2. 2001-05-03 04:45:40 +00:00
Matt Kraai 80abc45182 Move up waitpid error check so that errno isn't clobbered by tcsetpgrp. 2001-05-02 21:48:17 +00:00
Matt Kraai adcbc12d85 Canonicalize path before trying to unmount it. 2001-05-02 21:24:51 +00:00
Matt Kraai 3425111bb9 Fix bug #1108 by always canonicalizing arguments. 2001-05-02 21:17:38 +00:00
Eric Andersen 0fcd447d59 Some more job control updates. It will now sucessfully background
stuff.  Good luck getting things back into the foreground though...
 -Erik
2001-05-02 20:12:03 +00:00
Matt Kraai 20a3069ec0 Don't treat newline as pipe separator when processing substitutions. 2001-05-02 17:52:49 +00:00
Eric Andersen 19ec9ee91e Use .png for images (removing all .gifs) and make them all 90x36
-Erik
2001-05-02 17:19:25 +00:00
Matt Kraai 9f8caf134f Fix $(...) construction. Noted and patched by Larry Doolittle
<ldoolitt@recycle.lbl.gov>.  I'm just a patch whore.  :)
2001-05-02 16:26:12 +00:00
Eric Andersen bafd94f154 First pass at getting job control working. This gets the infrastructure
in place, but something is still missing/wrong in there.  Testing with
'grep foo &' seems to put _hush_ into the background.  Pondering...
 -Erik
2001-05-02 16:11:59 +00:00
Matt Kraai 1c8a59ab95 Use the current pgrp, not pid, when resetting the foreground process group.
Fixes bizarre suspension when executing `echo`.
2001-05-02 15:37:09 +00:00
Matt Kraai f162e7d09d Don't segfault if the first word is the empty string. 2001-05-02 14:48:48 +00:00
Eric Andersen e67c3ce327 Another update from Larry:
Makes hush return code equal to that of the last command executed.
    Fixes the mode where input comes from a file.
2001-05-02 02:09:36 +00:00
Matt Kraai e0244b0642 Skip headers with empty filenames, rather than stopping. 2001-05-01 21:12:31 +00:00
Eric Andersen b9f5b82339 Another refinement, this time from Larry. 2001-05-01 16:24:32 +00:00
Eric Andersen 6d553ef200 Argh. Now we break non-pristine builds. Check a bit more carefully.
-Erik
2001-05-01 14:54:35 +00:00
Eric Andersen abde065935 Oops. The dangers of applying patches by hand... 2001-05-01 14:37:03 +00:00
Eric Andersen 4ed5e37d4b Another hush update from Larry:
Minor improvements.  Something is still broken with running
    scripts via "hush filename".  All the following are now handled
    acceptably (matches ash, not bash).

    if true; then echo foo1; fi
    if
     true; then echo foo2; fi
    if true; false; then echo bar; else echo foo3; fi
    if true || false; then echo foo4; fi

	  - Larry
2001-05-01 01:49:50 +00:00
Eric Andersen 3f99b567b8 A patch from Larry to fix pristine source builds (again).
I just can't seem to _not_ break it.  Sigh.
2001-05-01 01:40:34 +00:00
Eric Andersen aac75e5a78 Some more hush.c updates from Larry Doolittle. 2001-04-30 18:18:45 +00:00
Eric Andersen 0e9aef36fa Oops. I was a bit too hasty and also changed applet_name. 2001-04-30 18:18:02 +00:00
Mark Whitley 8a633268ef Made new xreadlink function for libbb and changed applets to use it instead of
readlink(2).
2001-04-30 18:17:00 +00:00
Eric Andersen 6f34394454 These messages can be .rodata, so make them even more const.
-Erik
2001-04-30 18:08:03 +00:00
Eric Andersen 65504ac12c These do not need initial values. Let them live in the bss.
-Erik
2001-04-30 18:07:24 +00:00
Eric Andersen defa4f93c2 Per suggestion by Matt, make sh.c a real target. There is no
need for the useless sh_link dummy target -- use the real thing.
 -Erik
2001-04-30 17:52:36 +00:00
Matt Kraai 218aa370b4 Fix user permissions of copied directories. 2001-04-30 17:32:43 +00:00
Matt Kraai 43ca13714b Simplify permission handling for FIFOs. 2001-04-30 16:43:21 +00:00
Matt Kraai 24abecc349 Fix exit status when there is an error copying a file. 2001-04-30 16:37:04 +00:00
Glenn L McGrath af166e7ce0 Logic reversal for last_char_is 2001-04-29 00:50:33 +00:00
David Kimdon 2bf4dad7ec fix to applet_source_list rule so Debian package continues to build 2001-04-28 16:37:23 +00:00
Eric Andersen 07e462fd6d Matt was complaining. Hopefully this helps the sh.c link situation 2001-04-27 18:36:43 +00:00
Matt Kraai 72ab975a6b Terminate source correctly when copying symlink. Report and patch by
Brian Webb <webbb@desertscenes.net>.
2001-04-27 15:40:27 +00:00
Eric Andersen 088875fec4 Use BUFSIZ for the_command to match size used in cmdedit 2001-04-27 07:49:41 +00:00
Eric Andersen af44a0e8f4 An update to hush from Larry:
It should recover more smoothly from syntax errors, and it now
    has a decent guess when the reserved word construct is over
    (or not) to control execution and prompting.  I took out all the
    redundant standalone test copies of libbb routines, but left in a
    hook so I can include those for my testing.  I'll post that include
    file on my web site.

	    - Larry
2001-04-27 07:26:12 +00:00
Eric Andersen 0081466925 Be a bit more sneaky about the sh.c symlink so you don't need to
do a mke clean for it to happen.
 -Erik
2001-04-26 23:29:10 +00:00
Eric Andersen 0f9426edb0 Ignore some generated files 2001-04-26 23:23:04 +00:00
Eric Andersen 25f2703015 This is the initial checkin of Larry Doolittle's hush.c, using his
April 25, 2001 snapshot, adjusted a bit by me so it has cmdedit support.

This checkin also removes sh.c.  In the future sh.c will be a symlink to
your shell of choice.  For now, this symlink will default to pointing to
lash.c (as in the past).  If you change the symlink to point to hush.c,
then thats what you will get.  This symlink business is a temporary situation,
which will be cleaned up Real Soon Now(tm).

 -Erik
2001-04-26 23:22:31 +00:00
Eric Andersen a1dbc22469 Disable lash
-Erik
2001-04-26 23:10:22 +00:00
Eric Andersen 924ab5b7d3 These days busybox.pod is autogenerated, so it should be removed
from CVS.
2001-04-26 23:06:39 +00:00
Eric Andersen 7f3b86e7bf A fix from Larry for a corner case where insmod could end up
doing an xrealloc(0).
2001-04-26 19:29:58 +00:00
Matt Kraai 6aabfd5e30 Fix handling of permission addition and removal (e.g., o-r). 2001-04-26 18:55:29 +00:00
Eric Andersen ca85cdbe4c Doh. I never allocated storate for the struct stat I am using.
There was just a never initialized pointer.
 -Erik
2001-04-26 18:43:36 +00:00
Matt Kraai 468f504fd7 Fix handling of -R flag. 2001-04-26 18:27:47 +00:00
Eric Andersen c1bdffe99b Another nice cleanup from Larry. This adds a new last_char_is() function and
uses it to avoid possible buffer underruns whn strlen is zero, and avoid the
possible space-hogging inline of strlen() in several cases.
 -Erik
2001-04-26 15:56:47 +00:00
Eric Andersen 3c3277f0bd As Larry pointed out, this the off by one canbe fixed much more elegantly. 2001-04-26 15:41:51 +00:00
Eric Andersen 30592a5451 Fix a silly off-by-one error noticed by Santiago Garcia Mantinan <manty@debian.org>
-Erik
2001-04-26 14:56:45 +00:00
Mark Whitley e55987896a Applied patch from Larry Doolittle to fix pristine build breakage. 2001-04-25 23:49:43 +00:00
Mark Whitley 2789906aad Removed obsoleted BB_FEATURE_RM_INTERACTIVE 2001-04-25 22:08:56 +00:00
Mark Whitley 207587a9b4 Applied patch from I.Q. to add -s to cmp. 2001-04-25 20:41:02 +00:00
Mark Whitley c29c44c00e libbb.h now includes ../busybox.h. This way, files in libbb that have
BB_[FEATURE] #defines won't be ignored. Credit to Magnus Damm for spotting
this.
2001-04-25 18:06:21 +00:00
Eric Andersen 4f4bcfcd1a Some more cleanups for insmod from Larry.
-Erik
2001-04-25 17:22:32 +00:00
Eric Andersen c57a75d896 Larry noticed that chown and chgrp has the version numbers off a bit
for glibc's lchown support.  Thanks Larry.
2001-04-25 17:12:33 +00:00
Mark Whitley 4b541a8817 Moved some #ifdefs down below #include "busybox.h" where they belong. 2001-04-25 17:10:30 +00:00
Mark Whitley 67d7fe66e7 Sync'ed up the olympus section between this and stock Config.h 2001-04-25 17:05:51 +00:00
Mark Whitley 4f3558af17 Fixed a BB_MTAB #define buglet reported by Magnus Damm. 2001-04-25 17:03:40 +00:00
Eric Andersen 04095e58fb Move messages.c to libbb. Make each string in messages.c be its own .o file.
This way, we can new get rid of all that tedious #define rubbish we used to
need to enable specific messages.  This way is enormously simpler, and as a
bonus also ends up saving us 96 bytes.
 -Erik
2001-04-25 05:39:18 +00:00
Eric Andersen 3676374915 Cleanup more carefully after pod2html 2001-04-24 21:46:07 +00:00
Eric Andersen f227815c3a Several cleanups from Larry. 2001-04-24 21:41:41 +00:00
Matt Kraai 8810bdbba3 Rewrote rm. 2001-04-24 20:04:18 +00:00
Eric Andersen 9f0fedb8f6 Split up chmod_chown_chgrp.c into 3 separate apps. This unfortunately
adds 384 bytes to the overall size.  But having each app be standalone
is the Right Thing(tm) so we will just have to live with it.
 -Erik
2001-04-24 18:07:19 +00:00
Matt Kraai 3a4aef5a4c Update applet define from BB_CP_MV to BB_CP and BB_MV. 2001-04-24 15:19:04 +00:00
Matt Kraai 01441036e9 Use generic flag names. 2001-04-24 01:30:02 +00:00
Matt Kraai 9ff9325e60 Move applet_name declaration from busybox.h to libbb.h. 2001-04-24 01:12:33 +00:00
Mark Whitley af030496fa Applied patch from Larry Doolittle to remove some strlen calls, and add one
paranoia check to avoid  buffer underrun. Saves 120 text bytes.
2001-04-23 23:16:20 +00:00
Matt Kraai de1b262942 Remove file obsoleted by cp/mv rewrite. 2001-04-23 19:48:26 +00:00
Matt Kraai 91b2855ba8 Rewrite cp and mv to be SUSv2 compliant. 2001-04-23 18:53:07 +00:00
Mark Whitley 4e9267d76c Reversed last patch; unnecessary. 2001-04-23 17:56:27 +00:00
Mark Whitley 4b66dabc76 Added a sanity check to fix weird bug exposed when sourcing in commands from a
file with lash. Based on report from Heinz Walter.
2001-04-23 17:04:41 +00:00
Matt Kraai 8a24a65d2f Change link order so that libbb functions use libpwd.a when appropriate. 2001-04-23 16:11:57 +00:00
Eric Andersen ed424dbf1d Some patches from Gennady Feldman. Fixed a glob problem such that
'ls *.h Config.h' works.  Fixed a silly typo with fg/bg process control.
Made cmdedit exit sanely when it cannot read input.
2001-04-23 15:28:28 +00:00
Eric Andersen d8862928c2 A patch from Marc Karasek and Kanoj (kernel serial.c maintainer)
so init will work on serial consoles with 2.4.3+ kernels, thanks
to Fabrice Gautier <gautier@email.enst.fr> for finding this one.
 -Erik
2001-04-23 15:14:11 +00:00
Glenn L McGrath f5c358bc98 Simplify file_prefix handling, and use of *dir variable. 2001-04-23 13:52:02 +00:00
Matt Kraai 782ab3ccf8 Simplify pathname building, in which a bug was noted by Larry Doolittle,
a patch was provided by Vladimir Oleynik, and am improved patch commited
by me.
2001-04-23 01:07:00 +00:00
Glenn L McGrath ee0d93ed04 Fix horrible, horrible memmory leak. I wondered why processes were dying ! 2001-04-21 10:26:15 +00:00
Glenn L McGrath 89dc02d944 Clearly define out exclude list code, as recommended by Larry Doolittle 2001-04-21 02:12:13 +00:00
Mark Whitley 56c14a6473 Fixed a buglet where an extra newline was being added after an insert command
in some cases.
2001-04-20 23:41:44 +00:00
Mark Whitley 497ef46587 Made a correction to a bad test expression. Props to Larry Doolittle for
spotting this one.
2001-04-20 23:27:17 +00:00
Mark Whitley 3e310ac309 Applied patch from Larry Doolittle to give users the third option of putting
buffers in BSS (in addition to stack and heap).
2001-04-20 17:40:33 +00:00
Glenn L McGrath 6ebd633829 Set permissions of created file 2001-04-20 05:16:38 +00:00
Eric Andersen 46cd74b9e3 This has two patches. First it moves interface.c to libbb (it is
support code after all).  It also contains a patch from Larry Doolittle
that removes two instances of "strlen([^)]*) *- *1", un-shadows two
variables, relaxes requirement for a sprintf(3) that returns number of
bytes written, and eliminates a duplicate subroutine.
2001-04-19 16:55:27 +00:00
Matt Kraai 3ce79338e6 Fix buffer underrun noted and solved by Larry Doolittle. 2001-04-19 14:56:23 +00:00
Eric Andersen 0a3bda2c53 Move real_loop.h to libbb, where it belongs.
-Erik
2001-04-18 22:23:22 +00:00
Eric Andersen b5ec61e4f5 Add types for the inline funcs, thanks to Ralph Siemsen <ralphs@netwinder.org> 2001-04-18 20:17:05 +00:00
Matt Kraai 53265546a6 Eliminate spurious warning, convert to getopt, and eliminate redundant check. 2001-04-18 16:05:34 +00:00
Matt Kraai 96dcd19b8a Fix a number of problems with argument handling. 2001-04-18 15:54:09 +00:00
Matt Kraai 54652230d4 Eliminate a segfault when called on an existing file with out an extension:
touch foo && gunzip foo
2001-04-18 15:51:45 +00:00
Matt Kraai b181056e06 Eliminated seeks so that we work correctly on pipes, and removed reliance on
undefined evaluation ordering.  Thanks to Anthony Towns for explanation and
solution.
2001-04-18 14:49:55 +00:00
Glenn L McGrath bcfeb2ac44 Fix zcat/gunzip when reading from stdin 2001-04-18 13:34:09 +00:00
John Beppu 2771d1a574 - updated busybox_header.pod by adding adjtimex to the list.
- a new busybox.pod that reflects my fixes, and todays patches
  to usage.h
2001-04-17 23:57:23 +00:00
Mark Whitley fccaa3629b Applied patch from I.Q. to add sort -u as a feature. 2001-04-17 18:56:18 +00:00
Mark Whitley 6e808ca354 Changed line[strlen(line) - 1] = '\0'; to chomp(line); 2001-04-17 18:26:11 +00:00
Mark Whitley 30ac01cca7 Applied a patch from Laurence Anderson to fix the wget statusbar and a patch
to usage.h to document the -q option.
2001-04-17 18:13:16 +00:00
Mark Whitley 3828dbed57 Applied patch from I.Q. to fix problem with sort -n. 2001-04-17 17:47:33 +00:00
Mark Whitley 31868b85be Added some help messages. 2001-04-17 17:37:47 +00:00
Mark Whitley 59a86cad67 The tiniest of bracket-placement fixes. 2001-04-17 17:30:44 +00:00
John Beppu 5d81768cf1 - usage.h
o echo_example_usage
    needed to escape some backslashes in an inner quote
  o find_full_usage
    missing a \n at the end of the -name line
  ? getopt_full_usage
    the -o line has tab issues, but I didn't fix them.
  o length_example_usage
    removed some double-quotes that were within an inner quotes
  o printf_example_usage
    needed to escape a backslash in an inner quote
  o sort_example_usage
    needed to escape some backslashes and double quotes in an inner quote
  o tftp_full_usage
    s/nameing/naming/;
  o umount_full_usage
    remove colons after options for consistency w/ other full_usage messages
  o uniq_example_usage
    needed to escape some backslashes and double quotes in an inner quote

- TODO                          xargs -l ?
- docs/autodocifier.pl          POD && comment updates
- docs/busybox_footer.pod       added Larry Doolittle and Sterling Huxley
2001-04-17 17:09:34 +00:00
Matt Kraai a3045dfd25 Convert mount to use getopt. 2001-04-17 04:48:51 +00:00
Matt Kraai 1240082e37 Further cleanup of mount option handling. 2001-04-17 04:32:50 +00:00
Matt Kraai 24ed3bee0c Fix -a support (broken by previous patch). 2001-04-17 04:26:05 +00:00
Matt Kraai 3d406da0c9 Fix segfault on `mount -t nfs' reported by Gratien D'haese. 2001-04-17 04:22:22 +00:00
Eric Andersen 1c0d311ff4 Several fixes from Sterling Huxley for the vi applet. 2001-04-16 15:46:44 +00:00
Glenn L McGrath ae1c704c44 Write full status file 2001-04-16 10:26:46 +00:00
Glenn L McGrath 33431ebb9a dpkg improvements, use full package struct, avoid extracting to tmp dir, rename variable.
deb_extract, untar and dpkg_deb modified to make the above possible
2001-04-16 04:52:19 +00:00
Glenn L McGrath 3136904ff6 Document new dpkg-deb funtions 2001-04-15 12:53:24 +00:00
Glenn L McGrath 685f5fd6f4 untar changed to allow deb_extract to extract to memory, allows better operation of dpkg-deb -f 2001-04-15 12:51:59 +00:00
Glenn L McGrath a529d885d2 NEw functions read_package_field and read_text_file_to_buffer 2001-04-15 12:50:15 +00:00
Glenn L McGrath 5faef74bae Reads a field from a debian control (status or available) file, handles multi-line fields. 2001-04-15 12:38:12 +00:00
Glenn L McGrath 65708e4cd1 Read a FILE* till an empty line or eof and return it as a char buffer.
In future maybe add char *end_str to interface to allow calling function
to specify end point.
2001-04-15 12:36:19 +00:00
Eric Andersen 4a2e463525 Handle endian-ness. Patch from Paul J.Y. Lahaie <pjlahaie@linuxcare.com>
-Erik
2001-04-14 03:33:33 +00:00
Matt Kraai 0f50bca9aa Fix infinite loop and reallocate if too many modules. 2001-04-13 14:40:15 +00:00
Glenn L McGrath 445fb952b8 dpkg-deb -f and partial -I commands, adds 600 bytes 2001-04-13 04:02:57 +00:00
Matt Kraai 1e04ea388f Fix dos2unix/tr problem noted by Larry Doolittle. 2001-04-12 21:38:06 +00:00
Matt Kraai d6cde0bcf4 Fix return code and don't output spurious newlines. 2001-04-12 20:51:01 +00:00
Matt Kraai 4ef40c02f4 Another banner consolidation from Larry Doolittle <ldoolitt@recycle.lbl.gov>. 2001-04-12 20:44:21 +00:00
Matt Kraai 8fc364ebd5 Fix comment. 2001-04-12 20:12:16 +00:00
Matt Kraai 6ba1a80c26 Use date -u instead of date --utc and consolidate version string.
Patch by Larry Doolittle <ldoolitt@recycle.lbl.gov>.
2001-04-12 20:11:55 +00:00
Glenn L McGrath 5a65413c04 Updates, fixes for handling contents, verbose extract.
More updates to come
2001-04-12 16:40:21 +00:00
Glenn L McGrath 47fd219c95 Rename variable that shadows global 2001-04-12 16:37:13 +00:00
Matt Kraai be66ad3212 Fix handling of '' and "". 2001-04-12 15:42:17 +00:00
Glenn L McGrath 3e2ab88ee2 New dpkg-deb function -t, stands for --fsys-tarfile 2001-04-12 13:49:09 +00:00
Glenn L McGrath c9cac5be23 Change size to unsinged long long, so if -1 is passed it will read as much as possible. 2001-04-12 13:47:12 +00:00
Glenn L McGrath 6785b51280 dpkg-deb -c works now 2001-04-12 11:48:02 +00:00
Glenn L McGrath 359c106871 Fix dpkg-deb, enum's are cool 2001-04-12 10:19:08 +00:00
Glenn L McGrath 46079a1d77 remove unused clearerr statements 2001-04-12 10:17:22 +00:00
Glenn L McGrath 327175137f This belongs in dos2unix.c 2001-04-12 02:29:34 +00:00
Glenn L McGrath a6ce670a87 use tmpfile() and revert my previous changes... convert() belongs here 2001-04-12 02:26:04 +00:00
Glenn L McGrath 2709297f3b dos2unix and unix2dos are now independent 2001-04-12 00:55:05 +00:00
Glenn L McGrath 50b787cac5 Move convert to libbb 2001-04-12 00:52:29 +00:00
Glenn L McGrath a283157c38 convert() is used by dos2unix and unix2dos 2001-04-12 00:49:26 +00:00
Glenn L McGrath c8d9e0604a Moved from dos2unix 2001-04-12 00:42:53 +00:00
Matt Kraai da160c0da5 Use putc, and write to stderr as the rest of the progressmeter does. 2001-04-11 20:11:51 +00:00
Matt Kraai 90d7f696d6 Only finish with a newline if we are displaying the progress indicator. 2001-04-11 20:07:27 +00:00
Matt Kraai 65317ea27f Fix behavior when extracting to stdout. Report and patch by
Evin Robertson <nitfol@my-deja.com>.
2001-04-11 20:03:01 +00:00
Glenn L McGrath ed897e5415 Vladimir's patch to reverse previous patch 2001-04-11 17:20:44 +00:00
Glenn L McGrath 2975a34f23 readTarFile changed from exter nto static 2001-04-11 16:49:07 +00:00
Glenn L McGrath b3f23d4c6a Seek to start of an entry inside an ar file 2001-04-11 16:31:20 +00:00
Glenn L McGrath 988be100e2 dpkg, dpkg_deb dont depend on any other applets now 2001-04-11 16:25:45 +00:00
Glenn L McGrath 4949faf4b2 copy_file_chunk uses streams now. 2001-04-11 16:23:35 +00:00
Glenn L McGrath 5b20d02ea9 This is primarily to allow deb_extract to be independent of the tar applet.
TODO: This function and its conterpart in tar.c should be merged
2001-04-11 16:14:24 +00:00
Glenn L McGrath 9e966ffed4 Remove unneeded printf statment 2001-04-11 15:11:48 +00:00
Glenn L McGrath f70f6cef39 Disable sigterm 2001-04-11 15:09:30 +00:00
Glenn L McGrath 48081f81bd replace getOctal with strtol( , NULL, 8)
saves 100 Bytes
2001-04-11 05:01:09 +00:00
Glenn L McGrath 7dc8d227a5 dpkg only dependeds on tar 2001-04-11 03:47:45 +00:00
Glenn L McGrath 528ef50a4a Gzip is indepenedent of gunzip 2001-04-11 03:45:37 +00:00
Glenn L McGrath a12131966c Remove dpkg-deb applet dependencies, still depends on tar 2001-04-11 03:27:06 +00:00
Glenn L McGrath 7fd92949d0 Move unzip, gz_open, gz_close to libbb 2001-04-11 03:11:33 +00:00
Glenn L McGrath d22e560ad6 Move deb_extract() to libbb, dpkg now independent of dpkg-deb 2001-04-11 02:12:08 +00:00
Glenn L McGrath 9d53c8ab74 Move get_ar_headers to libbb, make dpkg_deb.c independent of ar.c 2001-04-11 01:37:03 +00:00
Eric Andersen 93ffa950bf Put in a paragraph break 2001-04-10 22:10:42 +00:00
Mark Whitley efcfe874ea Added a chart of busybox's growth by Larry Doolittle and put a news
announcement for it on the main page.
2001-04-10 21:58:32 +00:00
537 changed files with 51226 additions and 64583 deletions

No files matched your search

+2 -1
View File
@@ -1,4 +1,5 @@
busybox
busybox.links
_install
applet_source_list
.config
.menuconfig.log
+22 -7
View File
@@ -8,7 +8,7 @@ incorect, _please_ let me know.
-----------
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Erik Andersen <andersen@codepoet.org>, <andersee@debian.org>
Tons of new stuff, major rewrite of most of the
core apps, tons of new apps as noted in header files.
@@ -28,9 +28,17 @@ Dave Cinege <dcinege@psychosis.com>
more(v2), makedevs, dutmp, modularization, auto links file,
various fixes, Linux Router Project maintenance
Magnus Damm <damm@opensource.se>
tftp client
insmod powerpc support
Larry Doolittle <ldoolitt@recycle.lbl.gov>
pristine source directory compilation, lots of patches and fixes.
Gennady Feldman <gfeldman@cachier.com>
Sysklogd (single threaded syslogd, IPC Circular buffer support,
logread), various fixes.
Karl M. Hegbloom <karlheg@debian.org>
cp_mv.c, the test suite, various fixes to utility.c, &c.
@@ -38,17 +46,24 @@ Daniel Jacobowitz <dan@debian.org>
mktemp.c
Matt Kraai <kraai@alumni.carnegiemellon.edu>
documentation, bugfixes
documentation, bugfixes, test suite
John Lombardo <john@deltanet.com>
dirname, tr
Glenn McGrath <bug1@netconnect.com.au>
ar.c
Glenn McGrath <bug1@optushome.com.au>
ar, dpkg, dpkg-deb
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit; ports: ash, stty, traceroute; locale, various fixes
and irreconcilable critic of everything not perfect.
Bruce Perens <bruce@pixar.com>
Original author of BusyBox. His code is still in many apps.
Tim Riker <Tim@Rikers.org>
bug fixes, member of fan club
Kent Robotti <robotti@metconnect.com>
reset, tons and tons of bug reports and patchs.
@@ -73,6 +88,6 @@ Charles P. Wright <cpwright@villagenet.com>
Enrique Zanardi <ezanardi@ull.es>
tarcat (since removed), loadkmap, various fixes, Debian maintenance
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit, stty-port, locale, various fixes
and irreconcilable critic of everything not perfect.
Emanuele Aina <emanuele.aina@tiscali.it>
run-parts
+256 -29
View File
@@ -1,3 +1,232 @@
0.61.pre
Development Version
New Applets:
* Erik Andersen -- Merged several applets from tinylogin,
namely adduser, addgroup, deluser, delgroup, getty.
Other Changes:
* Vladimir Oleynik, Manuel Novoa III, Aaron Lehmann
-- 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
* Matt Kraai
-- Fix sed s/[/]// handling (closes: #1208).
-- Fix `-/bin/sh' invocation (closes: #1209).
-- Fix ash exec (noted by Arne Bernin).
-- Fix tar segfault when include list is empty and exclude list is
not.
-- Fix sed s/$/@/ handling (noted by Joshua Hudson).
-- Fix opt type in dpkg (closes: #118975).
* Magick
-- made init run inittab command's in the order they show up
in the inittab file (FIFO instead of LIFO).
* Vladimir Oleynik
-- reverse resolve network name and cache in route and ifconfig
applets, fix print nslookup server name if compile without
uClibc, fix route crashe 'route add', fix warnings compile
networking and pwd_grp applets
-Erik Andersen, --not yet released--
0.60.1
Stable Release
New Applets & New Features:
none. :)
Known Problems (to be fixed in 0.60.2)
* msh can segfault on constructs such as
for i in `ls *.c` ; do echo $i ; done
due to a memory allocation problem. This only seems to cause
problems when the backtick expands to be several k in size.
Bugfixes:
* Matt Kraai
-- Fixed msh to support underscores in variable names.
-- Fixed a sed problem with unsatisfied backrefs (the problem was
noted by Martin Bene).
-- Removed CONFIG_SH define entirely. Now one simply picks the shell
or shells they want as CONFIG_<foo> in Config.h
-- Fixed head to use ferror(3) to check for errors, not errno.
* Shu-Hao Chang <shuhao_chang@trend.com.tw>
-- Fixed sed handling of multiple -e commands
* Magick <magick@linux-fan.com>
-- Fixed an init bug with AskFirst and /dev/null
* Jaspreet Singh <jsingh@somanetworks.com>
-- Fixed both a segfault and cosmetic bug in route
* Erik Andersen
-- Made the insmod options CONFIG_FEATURE_NEW_MODULE_INTERFACE and
CONFIG_FEATURE_OLD_MODULE_INTERFACE mutually exclusive
-- xgetcwd.c now includes sys/param.h to ensure PATH_MAX is defined
-- Fixed a potential segfault with lash + CONFIG_FEATURE_CLEAN_UP
-- Removed uint64_t from dos2unix, avoiding C lib compat. problems.
* Glenn McGrath
-- Rewrite of tftp (commands match atftp, accepts -b, can use
non-standard ports, and is smaller).
-- Fixed unarchive exclude list handling
* Manuel Novoa III
-- rewrite of simplify_path so it behaves itself (fixing some
problems with mount and other applets).
-- Fixed ifconfig 'broadcast +' handling and disabled it by default
* Matthias ? <matthias@corelatus.com>
-- Fixed syslogd to log all messages from a single connection, not
just the first.
-Erik Andersen, 23 August 2001
0.60.0
Note:
For this release I have bumped the version number to 0.60.0. 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
stabablize and the new build system is working for everyone, then I
will release that as a new stable release series.
Critical Bugfixes:
* Matt Kraai
-- Fixed wget output file opening (wget failed in 0.52).
-- Fixed a memory leak in syslogd (found by Adam Slattery).
* Vladimir Oleynik, Matt Kraai, Erik Andersen
-- several nasty bugs in ash and msh. msh could not assign
any variables and had debug code still enabled. ash
had several compile errors (depending on selected options)
and variable assignment problems as well.
New Applets:
* David McCullough <davidm@lineo.com> -- modprobe
* Vladimir Oleynik -- traceroute
* Erik Andersen -- pidof
New Scripts:
* David Schleef, Erik Andersen, Stuart Hughes -- depmod.pl
This is a replacement for the depmod program from the modutils
package, but is fully cross platform and is designed to run on
your host system (not on the target).
Other Changes:
* Erik Andersen
-- fixed busybox.spec so it should now work on redhat systems
-- fixed dos2unix and unix2dos so they should work once again
-- Adjustments to make busybox more uClinux friendly. Busybox
should now work on uClinux systems without needing and source
code changes (applets that won't work on uClinux systems are
now automagicaly disabled).
-- various things (cleanups, libc compatibility work, etc, etc)
* Jim Gleason <jimg@lineo.com>
-- Fixed for sed, where it failed to preserve whether or not the
line was previously altered when running a subst command.
* Matt Kraai
-- Made tar read 20 512byte blocks at a time (like GNU tar)
-- Allow msh.c assignments with the export and readonly commands.
-- Added CONFIG_FEATURE_DEVFS to enable devfs device names.
-- Better devfs support
-- Don't save/restore vi readonly flag if vi is compiled read-only.
-- Reworked rdate option handling (is now smaller).
-- Size reduction in ping
-- Always write dd counts to stderr
-- Allow multiple shells to be enabled
* Aaron Lehmann
-- slimmed down md5sum
-- contributed a nice new (hand written, not lex/yacc) Posix math
support for ash, which is once again a full posix shell.
* Felix von Leitner <leitner@convergence.de> -- patches to make busybox
work with dietlibc.
* David McCullough
-- Adjustments to make busybox more uClinux friendly
* Glenn McGrath
-- Fixed gzip so when a filename is '-' it will use stdin/stdout
-- dpkg rewrite. Should now be compatable with the real dpkg,
but needs more testing.
-- Updates to archiving tools (gunzip/gzip/cpio/ar/etc)
-- Rewrote uuencode, will allow base64 encoding to be used by wget
* Vladimir Oleynik
-- Fixed tr to support 'tr a-z A-Z' syntax,
-- Many ash corrections, optimizations, and cleanups.
-- optimizations for traceroute, md5sum, chown, ping
-- cmdedit updates and API change
-- Namespace cleanup (i.e. adding 'static' private function calls)
-- added "stopped jobs" warning to ash on exit
* Adam Slattery
-- Fixed ping compile problem
* Robert J. Osborne <rj@resourceinternational.com>
-- fixed a vi bug with delete and escape sequences on empty files.
-Erik Andersen, 31 July 2001
0.52
Critical Bugfixes:
* Glenn McGrath -- Fixed gunzip, zcat when reading from stdin
* Marc Karasek and Kanoj (kernel serial.c maintainer) -- fixed init
problem on serial consoles with 2.4.3+ kernels.
New Applets:
* Laurence Anderson -- rpm2cpio applet, this obsoletes rpmunpack
which has now been removed from BusyBox
* Laurence Anderson and Glenn McGrath -- cpio applet, currently
only supports unpacking the ascii cpio format.
* Vladimir Oleynik and Erik Andersen -- added ash, the most correct
busybox shell.
* Larry Doolittle -- hush, small shell designed specifically
for busybox. Quite usable but still a work in progress.
* Erik Andersen -- msh, minix shell. A very small but capable shell
that only uses vfork, so it can be used on uClinux systems.
Other Changes:
* Sterling Huxley -- Several bugfixes for the vi applet.
* Glenn McGrath -- Restructure unarchiving code to make more code
common to the ar, cpio, dpkg, dpkg-deb applets.
tar applet has not yet been assimilated...
* Matt Kraai -- Rewrote cp, dirname, mkdir, mv, and rm.
* Paul J.Y. Lahaie <pjlahaie@linuxcare.com> -- Fixed an endian-ness
bug in md5sum (in 0.51, md5sum on big endian machines was broken)
* Mark Whitley -- rewrote cut, major updates to grep and sed.
* Erik Andersen -- bunches of insmod fixes. It should now always
work (no more segfault or missing symbols problems).
* Bernhard Kuhn <kuhn@lpr.e-technik.tu-muenchen.de> and Jinux Kim
added uClinux/m68k insmod support.
* Manuel Novoa III -- rewrote make_human_readable so ls, du, and df
should work as expected. Eliminated use of floats.
* Aaron Lehmann <aaronl@vitelus.com> -- Scrubbed gzip.c
* Alan Modra <amodra@bigpond.net.au> -- fixed an hard to spot
bug breaking gunzip checksum checking.
* Gennady Feldman -- Fixed 'syslog -C'
* Gernot Poerner <gp@it-netservice.de> -- Added mount bind support.
* Adam Heath <doogie@debian.org> -- wget arbitrary header support
* John Beppu -- updated the automagical doc generator
* Zillions of other bugfixes, optimizations, and cleanups.
-Erik Andersen, 7 July 2001
0.51
Critical Bugfixes:
* Erik Andersen -- Fixed a bug that could crash the shell in 0.50
@@ -69,7 +298,7 @@
restarting an aborted download.
-Erik Andersen, not yet released
-Erik Andersen, 10 April 2001
0.50
@@ -93,7 +322,7 @@
* Magnus Damm -- added a tftp applet
* Magnus Damm -- powerpc support for busybox insmod.
* David Douthitt -- fixed a build error in df.c when
BB_FEATURE_HUMAN_READABLE was disabled
CONFIG_FEATURE_HUMAN_READABLE was disabled
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
generate the documentation from the source code, making life
much simpler for all.
@@ -200,7 +429,7 @@
* Mark Whitley -- Updates to style guide
* Mark Whitley -- Big cleanup in utility.c: style guide compliance,
de-macro-ifying some variables and functions
* Erik Andersen -- ls now honors BB_FEATURE_AUTOWIDTH so it can find
* Erik Andersen -- ls now honors CONFIG_FEATURE_AUTOWIDTH so it can find
the width and height of the console.
* Erik Andersen -- insmod now ignores -L and accepts the -o option.
* Erik Andersen -- updates so you can now select from the Makefile
@@ -216,7 +445,7 @@
0.48
* Glenn McGrath -- tar now supports uncompressing tar files,
define BB_FEATURE_TAR_GZIP to use the -z option.
define CONFIG_FEATURE_TAR_GZIP to use the -z option.
* Matt Kraai -- fix all usage of TRUE and FALSE so all apps now
return EXIT_SUCCESS or EXIT_FAILURE to the system.
Now TRUE and FALSE are set to the C standard where TRUE=1.
@@ -248,7 +477,7 @@
GNU-date compatible
* me -- Progress meter (optional) in wget
* Doolittle/me -- programs invoked by full path name take
precedence over applets unless BB_FEATURE_SH_BUILTINS_ALWAYS_WIN
precedence over applets unless CONFIG_FEATURE_SH_BUILTINS_ALWAYS_WIN
* Gaute B Strokkenes <gs234@cam.ac.uk> -- applets found using a
binary search instead of linear search. Much faster!
* new applets: cmp readlink
@@ -381,7 +610,7 @@
0.45
* Now compiles vs libc5 (which can save lots of space for
embedded systems).
* Added BB_FEATURE_TRIVIAL_HELP which compiles out most all of the
* Added CONFIG_FEATURE_TRIVIAL_HELP which compiles out most all of the
help messages (i.e --help). Saves 17k over a full compile.
* Added cut and tr from minix, since due to the license change,
we can now use minix code. Minix tr saves 4k.
@@ -402,7 +631,7 @@
* Replaced the telnet implementation with one written by
Tomi Ollila <too@iki.fi> It works great and costs 3k.
* BusyBox sh (lash) now supports being used as a standalone shell. When
BB_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
CONFIG_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
be invoked as shell internals. Best used when compiling staticly
(i.e. DOSTATIC=true)
* BusyBox sh (lash) internals now behave as expected wrt pipes
@@ -454,7 +683,7 @@
* Fixed exit status for killall - Pavel Roskin
* Fixed 'swapon -a' and 'swapoff -a', which were broken.
* Fixed 'mount -a' so it works as expected.
* Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE)
* Implemented 'ls -R' (enabled by enabling CONFIG_FEATURE_LS_RECURSIVE)
* Implemented "ping -s", fixed error messages and argument parsing -
Pavel Roskin
* Syslogd will not go to background if "-n" is given. Better help
@@ -492,7 +721,7 @@
saving a bunch of memory (kernel /proc support is not thin). This
is done by making use of some nice kernel patches I wrote up to
support the features that busybox requires and that /proc usually
provides. To enable this, turn on BB_FEATURE_USE_DEVPS_PATCH and
provides. To enable this, turn on CONFIG_FEATURE_USE_DEVPS_PATCH and
patch your kernel with the devps patch in the kernel-patches/
directory.
* Wrote basename, dirname, killall, and uptime.
@@ -537,7 +766,7 @@
* An initial telnet implementation was added by
Randolph Chung <tausq@debian.org>.
* Fixed a bug where "sed 's/foo/bar/g'" (i.e. a script w/o a "-e")
* ps now supports BB_FEATURE_AUTOWIDTH, and can adjust its width
* ps now supports CONFIG_FEATURE_AUTOWIDTH, and can adjust its width
to match the terminal (defaults to width=79 when this is off).
* ps now accepts (and ignores) all options except for "--help" (which
as would be expected displays help).
@@ -560,7 +789,7 @@
* Fairly massive restructuring of umount.c to deal with remounting
busy devices read-only. Adds a -r option to control that; it is
optionally compiled in with BB_FEATURE_REMOUNT
optionally compiled in with CONFIG_FEATURE_REMOUNT
* Added a bunch of functions to mtab.c to interact with the
{get,set,end}mntent interface; as it turns out, those functions do
not appear to be re-entrant, and that causes a lot of problems with
@@ -631,7 +860,7 @@
* Created a tiny tail implementation, removing -c, -q, -v, and making
tail -f work only with a single file. This reduced tail from 6k to
2.4k. The bigger/more featured tail can still be had by disabling
BB_FEATURE_SIMPLE_TAIL in busybox.defs.h
CONFIG_FEATURE_SIMPLE_TAIL in busybox.defs.h
* Ping now falls back to doing the right thing if /etc/protocols
turns up missing.
* Fixed mount and umount. Previously they could leak loop device
@@ -683,14 +912,14 @@
devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins
<bcollins@debian.org>
* Several fixes from Marco Pantaleoni <panta@prosa.it> compile in
* fullWrite() not only if BB_TAR is defined, but also
if BB_CP or BB_MV are (fullWrite() is referenced by copyFile())
* fullWrite() not only if CONFIG_TAR is defined, but also
if CONFIG_CP or CONFIG_MV are (fullWrite() is referenced by copyFile())
* add some compiler optimizations to further reduce executable size
(as a side note, on my machines the largest code is generated
by gcc 2.95.2 with -Os ! The smallest by plain gcc 2.7.2.3 with
-O2 -m386 ...)
* Compile now won't fail if busybox.def.h defines
BB_FEATURE_LINUXRC but not BB_INIT. (init_main used to be
CONFIG_FEATURE_INITRD but not CONFIG_INIT. (init_main used to be
referenced, but not compiled)
* Fixed a bug in setting TERM for serial console support. TERM now
defaults to "ansi" for serial consoles.
@@ -750,7 +979,7 @@
to suit my evil purposes. Costs 6k. I'll make it smaller
sometime.
* on reboot, init called 'umount -a -n', which caused errors
when BB_MTAB was not enabled. Changed to 'umount -a', which does
when CONFIG_MTAB was not enabled. Changed to 'umount -a', which does
the right thing.
* init will now try to run /sbin/getty if it is present (for easy
integration with the about-to-be-released tinylogin.)
@@ -785,7 +1014,7 @@
* I've taken a first step to making busybox not need the /proc
filesystem. Most apps don't need it. Those that _require_ it,
will complain if you enable them when you disable
BB_FEATURE_USE_PROCFS.
CONFIG_FEATURE_USE_PROCFS.
-Erik Andersen, Dec 5, 1999
@@ -823,7 +1052,7 @@
* from
Eric Delaunay).
* Made createPath be quiet (again thanks to Eric Delaunay). If
* BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
* CONFIG_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
command you define it as will be run if the init script exits.
* Updated install.sh to make it more robust (thanks to Adam Di Carlo)
* NFS support added to mount by Eric Delaunay. It costs 10k when
@@ -879,7 +1108,7 @@
to Eric Delaunay.
* more started to read from stdin after the last file was finished, and
options were not parsed correctly (fix thanks to Eric Delaunay).
* more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on.
* more will now use the terminal size if CONFIG_FEATURE_AUTOWIDTH is on.
* rm wouldn't remove a symlink unless the symlink was valid. This was
a side effect of the busybox 0.32 recursiveAction() fix. Things
should now work correctly.
@@ -897,7 +1126,7 @@
* Removed some debugging noise from init.c
* Fixed ln so it works now (it was very broken).
* Fixed df so it won't segfault when there is no /etc/fstab,
* If BB_MTAB is not defined, df and mount will whine if /etc/fstab
* If CONFIG_MTAB is not defined, df and mount will whine if /etc/fstab
is not installed (since they cannot fixup "/dev/root" to
state the real root device name)
* merged some redundant code from mtab.c/df.c into utility.c
@@ -905,9 +1134,8 @@
-Erik Andersen, Nov 5, 1999
0.32
* More changes -- many thanks to Lineo for paying me to work on
busybox. If you have any problems please let me know ASAP at
andersen@lineo.com or andersee@debian.org
* More changes -- If you have any problems please let me know ASAP at
andersee@debian.org
* usage() now prints the BusyBox version. This will help folks
realize that they are not in Kansas anymore.
* Fixed mkdir -m option so that it works. kill segfaulted w/o any
@@ -918,11 +1146,11 @@
* with full regular expressions!). Fixed a stupid seg-fault in sync
* Fixed mount -- mount -a failed to parse and apply mount options Fixed
* umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>)
* umount -a no longer umounts /proc Added BB_MTAB, allowing (at the
* umount -a no longer umounts /proc Added CONFIG_MTAB, allowing (at the
* cost of ~1.5k and the need for a rw /etc)
folks to use a real /etc/mtab file instead of a symlink to
/proc/mounts. mount, and umount will add/remove entries and df
will now use /etc/mtab if BB_MTAB is defined.
will now use /etc/mtab if CONFIG_MTAB is defined.
* Fixed a nice bug in recursiveAction() which caused it to infinitely
hunt through /proc/../fd/* creating new file descriptors if it
followed the /dev/fd link over to /proc. recursiveAction() now
@@ -949,10 +1177,9 @@
-Erik Andersen, Oct 21, 1999
0.30
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
paying me to make these updates. If you have any problems with busybox,
or notice any bugs -- please let me know so I can fix it. These
changes include:
Major changes -- lots of stuff rewritten. If you have any problems
with busybox, or notice any bugs -- please let me know so I can fix
it. These changes include:
Core Changes:
* busybox can now invoke apps in two ways: via symlinks to the
-455
View File
@@ -1,455 +0,0 @@
/* vi: set sw=4 ts=4: */
// This file defines the feature set to be compiled into busybox.
// When you turn things off here, they won't be compiled in at all.
//
//// This file is parsed by sed. You MUST use single line comments.
// i.e. //#define BB_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
//#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
//#define BB_DC
#define BB_DD
//#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
//#define BB_DOS2UNIX
//#define BB_DPKG
//#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
//#define BB_EXPR
//#define BB_FBSET
//#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
//#define BB_FREERAMDISK
//#define BB_FSCK_MINIX
//#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
//#define BB_HOSTID
//#define BB_HOSTNAME
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM
//#define BB_LOADFONT
//#define BB_LOADKMAP
#define BB_LOGGER
//#define BB_LOGNAME
#define BB_LS
#define BB_LSMOD
//#define BB_MAKEDEVS
//#define BB_MD5SUM
#define BB_MKDIR
//#define BB_MKFIFO
//#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
//#define BB_MKTEMP
//#define BB_NC
#define BB_MORE
#define BB_MOUNT
//#define BB_MT
//#define BB_NSLOOKUP
//#define BB_PING
//#define BB_PIVOT_ROOT
#define BB_POWEROFF
//#define BB_PRINTF
#define BB_PS
#define BB_PWD
//#define BB_RDATE
//#define BB_READLINK
#define BB_REBOOT
//#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
//#define BB_RMMOD
//#define BB_ROUTE
//#define BB_RPMUNPACK
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
#define BB_TAIL
#define BB_TAR
//#define BB_TEE
//#define BB_TEST
//#define BB_TELNET
//#define BB_TFTP
#define BB_TOUCH
//#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
//#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
//#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_XARGS
#define BB_YES
// End of Applications List
//
//
//
// ---------------------------------------------------------
// This is where feature definitions go. Generally speaking,
// turning this stuff off makes things a bit smaller (and less
// pretty/useful).
//
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
//
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. NOTE: If you enable this
// feature, you _must_ have patched the kernel to include the devps patch that
// is included in the busybox/kernel-patches directory. You will also need to
// create some device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// show verbose usage messages
//#define BB_FEATURE_VERBOSE_USAGE
//
// Use termios to manipulate the screen ('more' is prettier with this on)
//#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// sort the file names
#define BB_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_SIMPLE_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// use -i (interactive) flag for rm
//#define BB_FEATURE_RM_INTERACTIVE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" and "-X" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell.
// Only relevant if BB_SH is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things. Off by default.
// Only relevant if BB_SH is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
//names. This causes applets (i.e., most busybox commands) to override
//real commands on the filesystem. For example, if you run run /bin/cat, it
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if BB_SH is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Some deeply embedded systems don't have usernames or even hostnames,
// and the default prompt can look rather hideous on them. Uncomment
// this option for a simpler, path-only prompt (which was the default until
// around BusyBox-0.48). On by default.
// Only relevant if BB_SH is enabled.
#define BB_FEATURE_SH_SIMPLE_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// Support insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 12k.
//#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
//#define BB_FEATURE_IFCONFIG_HW
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
// #define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
//
// Support for the find -mtine option.
#define BB_FEATURE_FIND_MTIME
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#define BB_FEATURE_SH_SIMPLE_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_SIMPLE_PROMPT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#ifdef BB_DPKG
#ifndef BB_DPKG_DEB
#define BB_DPKG_DEB
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_IFCONFIG
#ifdef BB_FEATURE_IFCONFIG_STATUS
#define BB_INTERFACE
#endif
#else
#undef BB_INTERFACE
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_DOS2UNIX
#define BB_UNIX2DOS
#endif
-377
View File
@@ -1,377 +0,0 @@
/* vi: set sw=4 ts=4: */
// NOTE: This file only defines features usefull under the Hurd,
// To compile for the Hurd raname this to Config.h prior to make
// This file defines the feature set to be compiled into busybox.
// When you turn things off here, they won't be compiled in at all.
//
//// This file is parsed by sed. You MUST use single line comments.
// i.e. //#define BB_BLAH
//
//
// BusyBox Applications
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
//#define BB_CHVT /* not needed */
#define BB_CLEAR
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
//#define BB_DEALLOCVT /* inot needed */
//#define BB_DF /* different implementation */
#define BB_DIRNAME
//#define BB_DMESG /* doesnt compile, different implementation */
#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP /* not needed */
#define BB_ECHO
#define BB_EXPR
//#define BB_FBSET /* not needed, doesnt compile */
//#define BB_FDFLUSH /* is this needed? */
#define BB_FIND
//#define BB_FREE /* doesnt compile */
#define BB_FREERAMDISK /* does hurd support ramdisks ? */
#define BB_FSCK_MINIX
#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
#define BB_ID
//#define BB_INIT /* not needed?, doesnt compile */
//#define BB_INSMOD /* not needed, doesnt compile */
#define BB_KILL
#define BB_KILLALL
#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM /* not needed, doesnt compile */
//#define BB_LOADFONT /* not needed, doesnt compile */
//#define BB_LOADKMAP /* not needed */
#define BB_LOGGER
#define BB_LOGNAME
#define BB_LS
//#define BB_LSMOD /* not needed, doesnt compile */
//#define BB_MAKEDEVS /* different implementation */
#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
#define BB_MKNOD
//#define BB_MKSWAP /* different impelementation (i think) */
#define BB_MKTEMP
#define BB_NC
#define BB_MORE
//#define BB_MOUNT /* different implementation */
#define BB_MT
#define BB_NSLOOKUP
//#define BB_PING /* doesnt compile, Hurd uses BSD style ip.h */
//#define BB_POWEROFF /* different implementation i assume */
#define BB_PRINTF
//#define BB_PS /* needs /proc */
#define BB_PWD
#define BB_RDATE
//#define BB_REBOOT /* different implementation */
#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
//#define BB_RMMOD /* not needed, doesnt compile */
#define BB_SED
//#define BB_SETKEYCODES /* is this needed ? */
#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_SWAPONOFF /* different implementation, doesnt compile */
#define BB_SYNC
//#define BB_SYSLOGD /* doesnt compile */
#define BB_TAIL
#define BB_TAR
#define BB_TEE
#define BB_TEST
#define BB_TELNET
#define BB_TOUCH
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UPTIME /* doesnt compile */
#define BB_USLEEP
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
//#define BB_UMOUNT /* different implementation */
#define BB_UNIQ
//#define BB_UNAME /* doesnt compile */
//#define BB_UPDATE /* doesnt compile */
#define BB_YES
// End of Applications List
//
//
//
// ---------------------------------------------------------
// This is where feature definitions go. Generally speaking,
// turning this stuff off makes things a bit smaller (and less
// pretty/useful).
//
//
//
// Turn this on to use Erik's very cool devps and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. You can not use this and
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
// _must_ have patched the kernel to include the devps patch that is included
// in the busybox/kernel-patches directory. You will also need to create some
// device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// enable features that use the /proc filesystem (apps that
// break without this will tell you on compile)...
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
// at the same time...
#define BB_FEATURE_USE_PROCFS
//
// show verbose usage messages
#define BB_FEATURE_VERBOSE_USAGE
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// sort the file names (still a bit buggy)
#define BB_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// Change ping implementation -- simplified, featureless, but really small.
#define BB_FEATURE_SIMPLE_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
//#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f' support (only one file at a time.)
#define BB_FEATURE_SIMPLE_TAIL
//
// Enable support for loop devices in mount
//#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes
//#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// use -i (interactive) flag for rm
//#define BB_FEATURE_RM_INTERACTIVE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox commands as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell
//among other thing.
#define BB_FEATURE_SH_STANDALONE_SHELL
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// You must enable one or both of these features
// Support installing modules from pre 2.1 kernels
//#define BB_FEATURE_INSMOD_OLD_KERNEL
// Support installing modules from kernel versions after 2.1.18
#define BB_FEATURE_INSMOD_NEW_KERNEL
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
// #define BB_FEATURE_INSTALLER
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
#else
#undef BB_MTAB
#endif
//
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#define BB_FEATURE_SH_SIMPLE_PROMPT
#endif
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_SIMPLE_PROMPT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#ifdef BB_DPKG
#ifndef BB_DPKG_DEB
#define BB_DPKG_DEB
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_IFCONFIG
#ifdef BB_FEATURE_IFCONFIG_STATUS
#define BB_INTERFACE
#endif
#else
#undef BB_INTERFACE
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_DOS2UNIX
#define BB_UNIX2DOS
#endif
+13
View File
@@ -0,0 +1,13 @@
1) Run 'make config' or 'make menuconfig' and select the
functionality that you wish to enable.
2) make dep
3) Check the Makefile for any Makefile setting you wish
to adjust for your system (things like like setting
your cross compiler, adjusting optimizations, etc)
4) make
5) Run 'make install' or 'make PREFIX=/target install' to
install busybox and all the needed links.
+4 -5
View File
@@ -17,15 +17,14 @@ Copyright 1998 Dave Cinege <dcinege@psychosis.com>
mini-gzip(gzip), mini-netcat(mnc)
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
Tons of new stuff as noted in header files
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Tons of new stuff as noted in header files
Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersen@codepoet.org>
<andersee@debian.org>
+167 -176
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
# Copyright (C) 1999,2000,2001 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
@@ -18,14 +18,21 @@
#
PROG := busybox
VERSION := 0.51
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
export VERSION
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- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
# 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.
@@ -37,21 +44,8 @@ DOSTATIC = false
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
# Do not enable this for production builds...
DODEBUG = false
# Setting this to `true' will cause busybox to directly use the system's
# password and group functions. Assuming you use GNU libc, when this is
# `true', you will need to install the /etc/nsswitch.conf configuration file
# and the required libnss_* libraries. This generally makes your embedded
# system quite a bit larger... If you leave this off, busybox will directly
# use the /etc/password, /etc/group files (and your system will be smaller, and
# I will get fewer emails asking about how glibc NSS works). Enabling this adds
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs),
# Most people will want to leave this set to false.
USE_SYSTEM_PWD_GRP = true
# 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
@@ -73,22 +67,28 @@ DOEFENCE = false
# larger than 2GB!
DOLFS = false
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
# 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.
BB_SRC_DIR =
CONFIG_SRC_DIR =
# If you are running a cross compiler, you may want to set this
# to something more interesting, like "powerpc-linux-".
# 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
STRIPTOOL = $(CROSS)strip
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...
# This make things very easy? Everything should compile and work as
# expected these days...
#CC = ../uClibc/extra/gcc-uClibc/i386-uclibc-gcc
# 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...
@@ -109,11 +109,13 @@ STRIPTOOL = $(CROSS)strip
#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)
WARNINGS = -Wall -Wshadow
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
#
@@ -127,7 +129,7 @@ ARFLAGS = -r
ifeq ($(strip $(DOLFS)),true)
# For large file summit support
CFLAGS+=-D_FILE_OFFSET_BITS=64
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64
endif
ifeq ($(strip $(DODMALLOC)),true)
# For testing mem leaks with dmalloc
@@ -145,25 +147,14 @@ endif
ifeq ($(strip $(DODEBUG)),true)
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS += -Wl,-warn-common
STRIP =
STRIPCMD =
else
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
CFLAGS += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
LDFLAGS += -s -Wl,-warn-common
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
STRIPCMD = $(STRIP) --remove-section=.note --remove-section=.comment $(PROG)
endif
ifeq ($(strip $(DOSTATIC)),true)
LDFLAGS += --static
#
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
# work) to try and strip out any unused junk. Doesn't do much for me,
# but you may want to give it a shot...
#
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \
# --gc-sections -v >/dev/null && echo 1),1)
# CFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += --gc-sections
#endif
endif
ifndef $(PREFIX)
@@ -172,107 +163,78 @@ 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
# 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 $(BB_SRC_DIR)),)
VPATH = $(BB_SRC_DIR)
ifneq ($(strip $(CONFIG_SRC_DIR)),)
VPATH = $(CONFIG_SRC_DIR)
endif
#ifneq ($(strip $(VPATH)),)
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
#endif
# We need to set APPLET_SOURCES to something like
# $(shell busybox.sh Config.h)
# but in a manner that works with VPATH and BB_SRC_DIR.
# Possible ways to approach this:
#
# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
#
# 2. Explicity search through .:$(VPATH) for slist.mk,
# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
#
# 3. Create slist.mk in this directory, with commands embedded in
# a $(shell ...) command, and $(MAKE) it immediately.
#
# 4. Use a real rule within this makefile to create a file that sets
# APPLET_SOURCE_LIST, then include that file. Has complications
# with the first trip through the makefile (before processing the
# include) trying to do too much, and a spurious warning the first
# time make is run.
#
# This is option 3:
#
#APPLET_SOURCES = $(shell \
# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
#)
# And option 4:
-include applet_source_list
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o messages.o usage.o applets.o
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
ifdef CONFIG_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(CONFIG_INIT_SCRIPT)"'
endif
ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
PWD_GRP = pwd_grp
PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
PWD_LIB = libpwd.a
PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
initgroups.c setgroups.c
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
PWD_CFLAGS = -I$(PWD_GRP_DIR)
else
CFLAGS += -DUSE_SYSTEM_PWD_GRP
endif
LIBBB = libbb
LIBBB_LIB = libbb.a
LIBBB_CSRC= ask_confirmation.c check_wildcard_match.c chomp.c copy_file.c \
copy_file_chunk.c create_path.c daemon.c device_open.c error_msg.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 \
human_readable.c inode_hash.c isdirectory.c kernel_version.c loop.c \
mode_string.c parse_mode.c parse_number.c print_file.c process_escape_sequence.c \
my_getgrgid.c my_getpwnamegid.c my_getpwuid.c my_getgrnam.c my_getpwnam.c \
recursive_action.c safe_read.c safe_strncpy.c syscalls.c module_syscalls.c \
syslog_msg_with_name.c time_string.c trim.c vdprintf.c wfopen.c xfuncs.c \
xregcomp.c error_msg_and_die.c perror_msg.c perror_msg_and_die.c \
verror_msg.c vperror_msg.c mtab.c mtab_file.c xgetcwd.c concat_path_file.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
LIBBB_CFLAGS = -I$(LIBBB)
ifneq ($(strip $(BB_SRC_DIR)),)
LIBBB_CFLAGS += -I$(BB_SRC_DIR)/$(LIBBB)
endif
# Put user-supplied flags at the end, where they
# have a chance of winning.
CFLAGS += $(CFLAGS_EXTRA)
.EXPORT_ALL_VARIABLES:
all: applet_source_list busybox busybox.links doc
all: do-it-all
applet_source_list: busybox.sh Config.h
(echo -n "APPLET_SOURCES := "; $(SHELL) $^ $(BB_SRC_DIR)) > $@
#
# Make "config" the default target if there is no configuration file or
# "depend" the target if there is no top-level dependency information.
ifeq (.config,$(wildcard .config))
include .config
ifeq (.depend,$(wildcard .depend))
include .depend
do-it-all: busybox busybox.links doc
else
CONFIGURATION = depend
do-it-all: depend
endif
else
CONFIGURATION = menuconfig
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.links: applets/busybox.mkll
- $(SHELL) $^ >$@
install: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX)
install-hardlinks: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX) --hardlinks
# Documentation Targets
doc: olddoc
# Old Docs...
olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.pod : docs/busybox_header.pod usage.h docs/busybox_footer.pod
docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
- ( cat docs/busybox_header.pod; \
docs/autodocifier.pl usage.h; \
docs/autodocifier.pl include/usage.h; \
cat docs/busybox_footer.pod ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
@@ -296,7 +258,7 @@ docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
-@ mkdir -p docs/busybox.lineo.com
- pod2html --noindex $< > \
docs/busybox.lineo.com/BusyBox.html
-@ rm -f pod2html*
-@ rm -f pod2htm*
# New docs based on DOCBOOK SGML
@@ -325,74 +287,103 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
- mkdir -p docs
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
# The nifty new buildsystem stuff
scripts/mkdep: scripts/mkdep.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(PWD_LIB) $(LIBBB_LIB) $(LIBRARIES)
$(STRIP)
scripts/split-include: scripts/split-include.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
# but with VPATH, some or all of those file names are resolved to the
# directories in which they live.
busybox.links: busybox.mkll Config.h applets.h
- $(SHELL) $^ >$@
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;
nfsmount.o cmdedit.o: %.o: %.h
sh.o: cmdedit.h
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
$(CC) -I- $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
- mkdir -p $(PWD_GRP)
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
depend dep: config.h dep-files
@ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
$(LIBBB_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile libbb/libbb.h
- mkdir -p $(LIBBB)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -c $< -o $*.o
CONFIG_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi}
libpwd.a: $(PWD_OBJS)
$(AR) $(ARFLAGS) $@ $^
include/config/MARKER: scripts/split-include include/config.h
scripts/split-include include/config.h include/config
@ touch include/config/MARKER
libbb.a: $(LIBBB_OBJS)
$(AR) $(ARFLAGS) $@ $^
config.h:
@if [ ! -f include/config.h ] ; then \
make oldconfig; \
fi;
usage.o: usage.h
menuconfig:
mkdir -p $(TOPDIR)/include/config
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
libbb/loop.o: libbb/loop.h
config:
mkdir -p $(TOPDIR)/include/config
$(CONFIG_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
libbb/loop.h: mk_loop_h.sh
@ $(SHELL) $< > $@
oldconfig:
mkdir -p $(TOPDIR)/include/config
$(CONFIG_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
ifdef CONFIGURATION
..$(CONFIGURATION):
@echo
@echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
@echo
$(MAKE) $(CONFIGURATION)
@echo
@echo "Successful. Try re-making (ignore the error that follows)"
@echo
exit 1
dummy:
else
dummy:
endif
include Rules.mak
# Testing...
test tests:
# old way of doing it
#cd tests && $(MAKE) all
# new way of doing it
cd tests && ./tester.sh
# Cleanup
clean:
- cd tests && $(MAKE) 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
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
- rm -f multibuild.log Config.h.orig
- rm -rf docs/busybox _install libpwd.a libbb.a
- rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list
docs/busybox.pdf docs/busybox.lineo.com/busybox.html \
docs/busybox _install pod2htm* *.gdb *.elf *~ core
- rm -f 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 \*.o -exec rm -f {} \;
- find -name \*.a -exec rm -f {} \;
distclean: clean
- rm -f busybox
- rm -f busybox
- cd tests && $(MAKE) distclean
install: install.sh busybox busybox.links
$(SHELL) $< $(PREFIX)
install-hardlinks: install.sh busybox busybox.links
$(SHELL) $< $(PREFIX) --hardlinks
debug_pristine:
@ echo VPATH=\"$(VPATH)\"
@ echo OBJECTS=\"$(OBJECTS)\"
dist release: distclean doc
cd ..; \
rm -rf busybox-$(VERSION); \
@@ -403,11 +394,6 @@ dist release: distclean doc
-print \
-exec rm -rf {} \; ; \
\
find busybox-$(VERSION)/ -type f \
-name .cvsignore \
-print \
-exec rm -f {} \; ; \
\
find busybox-$(VERSION)/ -type f \
-name .\#* \
-print \
@@ -415,6 +401,11 @@ dist release: distclean doc
\
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
.PHONY: tags
.PHONY: tags check
tags:
ctags -R .
check: busybox
cd testsuite && ./runtest
+41 -16
View File
@@ -11,9 +11,7 @@ the expected functionality and behave very much like their GNU counterparts.
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, a shell, and a kernel. For
a really minimal system, you can even use the busybox shell (not Bourne
compatible, but very small and quite usable) and the busybox vi editor.
systems. To create a working system, just add /dev, /etc, and a kernel.
BusyBox was originally written to support the Debian Rescue/Install disks, but
it also makes an excellent environment for any small or embedded system.
@@ -36,12 +34,14 @@ 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, and MIPS.
functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k,
and MIPS.
Supported libcs:
glibc-2.0.x, glibc-2.1.x, Linux-libc5, uClibc. People are looking at
newlib and diet-libc, but consider them unsupported, untested, or worse.
glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, Linux-libc5, uClibc. People
are looking at newlib and diet-libc, but consider them unsupported,
untested, or worse.
Supported kernels:
@@ -50,10 +50,40 @@ Supported kernels:
----------------
Shells:
lash is the very smallest shell (adds just 10k) and it is quite usable as
a command prompt, but it is not suitable for any but the most trivial
scripting (such as an initrd that calls insmod a few times) since it does
not understand Bourne shell grammer. It does handle pipes, redirects, and
job control though. Adding in command editing makes it a very nice
lightweight command prompt.
hush is also quite small (just 18k) and it has very complete Bourne shell
grammer. It handles if/then/else/fi just fine, but doesn't handle loops
like for/do/done or case/esac and such. It also currently has a problem
with job control. Using hush is not yet recommended.
msh: The minix shell (adds just 30k) is quite complete and handles things
like for/do/done, case/esac and all the things you expect a Bourne shell to
do. It is not always pedantically correct about Bourne shell grammer (try
running the shell testscript "tests/sh.testcases" on it and compare vs bash)
but for most things it works quite well. It also uses only vfork, so it can
be used on uClinux systems. This was only recently added, so there is still
room to shrink it further...
ash: This adds about 60k in the default configuration and is the most
complete and most pedantically correct shell included with busybox. This
shell was also recently added, and several people (mainly Vladimir and Erik)
have been working on it. There are a number of configurable things at the
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://opensource.lineo.com/lists/busybox/ or even join
archives at http://oss.lineo.com/lists/busybox/ or even join
the mailing list if you are interested.
----------------
@@ -101,23 +131,18 @@ Source for the latest released version can always be downloaded from
CVS:
BusyBox now has its own publicly browsable CVS tree at:
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
http://oss.lineo.com/cgi-bin/cvsweb/busybox/
Anonymous CVS access is available. For instructions, check out:
http://opensource.lineo.com/cvs_anon.html
http://oss.lineo.com/cvs_anon.html
For those that are actively contributing there is even CVS write access:
http://opensource.lineo.com/cvs_write.html
http://oss.lineo.com/cvs_write.html
----------------
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersen@codepoet.org>
<andersee@debian.org>
<andersee@codepoet.org>
<blatant plug>
Many thanks to go to Lineo for paying me to work on busybox.
</blatant plug>
+195
View File
@@ -0,0 +1,195 @@
#
# This file contains rules which are shared between multiple Makefiles.
#
#
# 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-))
#
# Common rules
#
%.s: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@
%.i: %.c
$(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@
%.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
%.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
#
fastdep: dummy
$(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS) -- $(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)
ifdef SUB_DIRS
$(subdir-list) : dummy
$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif
#
# A rule to do nothing
#
dummy:
#
# This is useful for testing
#
script:
$(SCRIPT)
#
# 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
+12 -12
View File
@@ -10,15 +10,6 @@ around to it some time. If you have any good ideas, please let me know.
netkit-tiny. Per discussions on the mailing list, this isn't going
to happen. False alarm. Sorry about the confusion.
* The busybox shell, lash, is really too weak for serious use, although it is
possible to run many simple systems with it. BusyBox 0.49 was supposed to
have a new shell, updated to understand full Bourne grammer. Well, that
simply didn't happen in time for the release. A rewrite is in progress
that will result in a new shell that understands the full Bourne grammar.
This new shell is being championed by Larry Doolittle
<ldoolitt@recycle.lbl.gov>, and could use your help. Please see the work
in progress at http://doolittle.faludi.com/~larry/parser.html and help
us out.
-Erik
@@ -28,11 +19,16 @@ Possible apps to include some time:
* hwclock
* group/commonize strings, remove dups (for i18n, l10n)
* login/sulogin/passwd/etc are part of tinylogin. These are
being merged into busybox as time allows.
-----------
Write a fixup_globals function to do just that right before calling
non-forking applets. Or, just always fork in the shell...
With sysvinit, reboot, poweroff and halt all used a named pipe,
/dev/initctl, to communicate with the init process. Busybox
currently uses signals to communicate with init. This makes
busybox incompatible with sysvinit. We should probably use
a named pipe as well so we can be compatible.
-----------------------
@@ -41,7 +37,7 @@ Run the following:
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
reveals the list of all external (i.e. libc) things that BusyBox depends on.
reveals the list of all external (i.e., libc) things that BusyBox depends on.
It would be a very nice thing to reduce this list to an absolute minimum, to
reduce the footprint of busybox, especially when staticly linking with
libraries such as uClibc.
@@ -55,4 +51,8 @@ and then start with the biggest things and make them smaller...
du.c probably ought to have an -x switch like GNU du does...
-----------------------
xargs could use a -l option
------------------------------------------------------------------
-176
View File
@@ -1,176 +0,0 @@
/*
* adjtimex.c - read, and possibly modify, the Linux kernel `timex' variables.
*
* Originally written: October 1997
* Last hack: March 2001
* Copyright 1997, 2000, 2001 Larry Doolittle <LRDoolittle@lbl.gov>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2,
* June 1991) as published by the Free Software Foundation. At the
* time of writing, that license was published by the FSF with the URL
* http://www.gnu.org/copyleft/gpl.html, and is incorporated herein by
* reference.
*
* 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.
*
* This adjtimex(1) is very similar in intent to adjtimex(8) by Steven
* Dick <ssd@nevets.oau.org> and Jim Van Zandt <jrv@vanzandt.mv.com>
* (see http://metalab.unc.edu/pub/Linux/system/admin/time/adjtimex*).
* That version predates this one, and is _much_ bigger and more
* featureful. My independently written version was very similar to
* Steven's from the start, because they both follow the kernel timex
* structure. I further tweaked this version to be equivalent to Steven's
* where possible, but I don't like getopt_long, so the actual usage
* syntax is incompatible.
*
* Amazingly enough, my Red Hat 5.2 sys/timex (and sub-includes)
* don't actually give a prototype for adjtimex(2), so building
* this code (with -Wall) gives a warning. Later versions of
* glibc fix this issue.
*
* This program is too simple for a Makefile, just build with:
* gcc -Wall -O adjtimex.c -o adjtimex
*
* busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov>
* It will autosense if it is built in a busybox environment, based
* on the BB_VER preprocessor macro.
*/
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#if __GNU_LIBRARY__ < 5
#include <sys/timex.h>
extern int adjtimex(struct timex *buf);
#else
#include <sys/timex.h>
#endif
#ifdef BB_VER
#include "busybox.h"
#endif
static struct {int bit; char *name;} statlist[] = {
{ STA_PLL, "PLL" },
{ STA_PPSFREQ, "PPSFREQ" },
{ STA_PPSTIME, "PPSTIME" },
{ STA_FLL, "FFL" },
{ STA_INS, "INS" },
{ STA_DEL, "DEL" },
{ STA_UNSYNC, "UNSYNC" },
{ STA_FREQHOLD, "FREQHOLD" },
{ STA_PPSSIGNAL, "PPSSIGNAL" },
{ STA_PPSJITTER, "PPSJITTER" },
{ STA_PPSWANDER, "PPSWANDER" },
{ STA_PPSERROR, "PPSERROR" },
{ STA_CLOCKERR, "CLOCKERR" },
{ 0, NULL } };
static char *ret_code_descript[] = {
"clock synchronized",
"insert leap second",
"delete leap second",
"leap second in progress",
"leap second has occurred",
"clock not synchronized" };
#ifdef BB_VER
#define main adjtimex_main
#else
void usage(char *prog)
{
fprintf(stderr,
"Usage: %s [ -q ] [ -o offset ] [ -f frequency ] [ -p timeconstant ] [ -t tick ]\n",
prog);
}
#define show_usage() usage(argv[0])
#endif
int main(int argc, char ** argv)
{
struct timex txc;
int quiet=0;
int c, i, ret, sep;
char *descript;
txc.modes=0;
for (;;) {
c = getopt( argc, argv, "qo:f:p:t:");
if (c == EOF) break;
switch (c) {
case 'q':
quiet=1;
break;
case 'o':
txc.offset = atoi(optarg);
txc.modes |= ADJ_OFFSET_SINGLESHOT;
break;
case 'f':
txc.freq = atoi(optarg);
txc.modes |= ADJ_FREQUENCY;
break;
case 'p':
txc.constant = atoi(optarg);
txc.modes |= ADJ_TIMECONST;
break;
case 't':
txc.tick = atoi(optarg);
txc.modes |= ADJ_TICK;
break;
default:
show_usage();
exit(1);
}
}
if (argc != optind) { /* no valid non-option parameters */
show_usage();
exit(1);
}
ret = adjtimex(&txc);
if (ret < 0) perror("adjtimex");
if (!quiet && ret>=0) {
printf(
" mode: %d\n"
"-o offset: %ld\n"
"-f frequency: %ld\n"
" maxerror: %ld\n"
" esterror: %ld\n"
" status: %d ( ",
txc.modes, txc.offset, txc.freq, txc.maxerror,
txc.esterror, txc.status);
/* representative output of next code fragment:
"PLL | PPSTIME" */
sep=0;
for (i=0; statlist[i].name; i++) {
if (txc.status & statlist[i].bit) {
if (sep) fputs(" | ",stdout);
fputs(statlist[i].name,stdout);
sep=1;
}
}
descript = "error";
if (ret >= 0 && ret <= 5) descript = ret_code_descript[ret];
printf(" )\n"
"-p timeconstant: %ld\n"
" precision: %ld\n"
" tolerance: %ld\n"
"-t tick: %ld\n"
" time.tv_sec: %ld\n"
" time.tv_usec: %ld\n"
" return value: %d (%s)\n",
txc.constant,
txc.precision, txc.tolerance, txc.tick,
(long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
}
return (ret<0);
}
-108
View File
@@ -1,108 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) tons of folks. Tracking down who wrote what
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
*
* 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
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
#include "applets.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
struct BB_applet *applet_using;
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
extern void show_usage(void)
{
const char *format_string;
const char *usage_string = usage_messages;
int i;
/* From busybox.c */
extern int been_there_done_that;
if (strcmp(applet_using->name, "busybox")==0) {
been_there_done_that=1;
busybox_main(0, NULL);
}
for (i = applet_using - applets; i > 0; ) {
if (!*usage_string++) {
--i;
}
}
format_string = "%s\n\nUsage: %s %s\n\n";
if(*usage_string == 0)
format_string = "%s\n\nNo help available.\n\n";
fprintf(stderr, format_string,
full_version, applet_using->name, usage_string);
exit(EXIT_FAILURE);
}
static int applet_name_compare(const void *x, const void *y)
{
const char *name = x;
const struct BB_applet *applet = y;
return strcmp(name, applet->name);
}
extern size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
/* Do a binary search to find the applet entry given the name. */
if ((applet_using = find_applet_by_name(name)) != NULL) {
applet_name = applet_using->name;
if (argv[1] && strcmp(argv[1], "--help") == 0)
show_usage();
exit((*(applet_using->main)) (argc, argv));
}
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-448
View File
@@ -1,448 +0,0 @@
/*
* applets.h - a listing of all busybox applets.
*
* If you write a new applet, you need to add an entry to this list to make
* busybox aware of it.
*
* It is CRUCIAL that this listing be kept in ascii order, otherwise the binary
* search lookup contributed by Gaute B Strokkenes stops working. If you value
* your kneecaps, you'll be sure to *make sure* that any changes made to this
* file result in the listing remaining in ascii order. You have been warned.
*/
#undef APPLET
#undef APPLET_ODDNAME
#undef APPLET_NOUSAGE
#if defined(PROTOTYPES)
#define APPLET(a,b,c) extern int b(int argc, char **argv);
#define APPLET_NOUSAGE(a,b,c) extern int b(int argc, char **argv);
#define APPLET_ODDNAME(a,b,c,d) extern int b(int argc, char **argv);
extern const char usage_messages[];
#elif defined(MAKE_USAGE)
#ifdef BB_FEATURE_VERBOSE_USAGE
#define APPLET(a,b,c) a##_trivial_usage "\n\n" a##_full_usage "\0"
#define APPLET_NOUSAGE(a,b,c) "\0"
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\n\n" d##_full_usage "\0"
#else
#define APPLET(a,b,c) a##_trivial_usage "\0"
#define APPLET_NOUSAGE(a,b,c) "\0"
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\0"
#endif
#elif defined(MAKE_LINKS)
# define APPLET(a,b,c) LINK c a
# define APPLET_NOUSAGE(a,b,c) LINK c a
# define APPLET_ODDNAME(a,b,c,d) LINK c a
#else
const struct BB_applet applets[] = {
#define APPLET(a,b,c) {#a,b,c},
#define APPLET_NOUSAGE(a,b,c) {a,b,c},
#define APPLET_ODDNAME(a,b,c,d) {a,b,c},
#endif
#ifdef BB_TEST
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ADJTIMEX
APPLET(adjtimex, adjtimex_main, _BB_DIR_SBIN)
#endif
#ifdef BB_AR
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_BASENAME
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
#endif
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
#ifdef BB_CAT
APPLET(cat, cat_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
APPLET(chgrp, chmod_chown_chgrp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
APPLET(chmod, chmod_chown_chgrp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
APPLET(chown, chmod_chown_chgrp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHROOT
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_CHVT
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CLEAR
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CMP
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CP_MV
APPLET(cp, cp_mv_main, _BB_DIR_BIN)
#endif
#ifdef BB_CUT
APPLET(cut, cut_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DATE
APPLET(date, date_main, _BB_DIR_BIN)
#endif
#ifdef BB_DC
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DD
APPLET(dd, dd_main, _BB_DIR_BIN)
#endif
#ifdef BB_DEALLOCVT
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DF
APPLET(df, df_main, _BB_DIR_BIN)
#endif
#ifdef BB_DIRNAME
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DMESG
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
#endif
#ifdef BB_DOS2UNIX
APPLET(dos2unix, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DPKG
APPLET(dpkg, dpkg_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DPKG_DEB
APPLET_ODDNAME("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb)
#endif
#ifdef BB_DU
APPLET(du, du_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DUMPKMAP
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
#endif
#ifdef BB_DUTMP
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_ECHO
APPLET(echo, echo_main, _BB_DIR_BIN)
#endif
#if defined(BB_FEATURE_GREP_EGREP_ALIAS) && defined(BB_GREP)
APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN)
#endif
#ifdef BB_ENV
APPLET(env, env_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_EXPR
APPLET(expr, expr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET(false, false_main, _BB_DIR_BIN)
#endif
#ifdef BB_FBSET
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_FDFLUSH
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
#endif
#ifdef BB_FIND
APPLET(find, find_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FREE
APPLET(free, free_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FREERAMDISK
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
#endif
#ifdef BB_FSCK_MINIX
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
#endif
#ifdef BB_GETOPT
APPLET(getopt, getopt_main, _BB_DIR_BIN)
#endif
#ifdef BB_GREP
APPLET(grep, grep_main, _BB_DIR_BIN)
#endif
#ifdef BB_GUNZIP
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
#endif
#ifdef BB_GZIP
APPLET(gzip, gzip_main, _BB_DIR_BIN)
#endif
#ifdef BB_HALT
APPLET(halt, halt_main, _BB_DIR_SBIN)
#endif
#ifdef BB_HEAD
APPLET(head, head_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_HOSTID
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_HOSTNAME
APPLET(hostname, hostname_main, _BB_DIR_BIN)
#endif
#ifdef BB_ID
APPLET(id, id_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_IFCONFIG
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
#endif
#ifdef BB_INIT
APPLET(init, init_main, _BB_DIR_SBIN)
#endif
#ifdef BB_INSMOD
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_KILL
APPLET(kill, kill_main, _BB_DIR_BIN)
#endif
#ifdef BB_KILLALL
APPLET(killall, kill_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_KLOGD
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LENGTH
APPLET(length, length_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FEATURE_LINUXRC
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
#endif
#ifdef BB_LN
APPLET(ln, ln_main, _BB_DIR_BIN)
#endif
#ifdef BB_LOADACM
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOADFONT
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOADKMAP
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LOGGER
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOGNAME
APPLET(logname, logname_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOGREAD
APPLET(logread, logread_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LS
APPLET(ls, ls_main, _BB_DIR_BIN)
#endif
#ifdef BB_LSMOD
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MAKEDEVS
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MD5SUM
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_MKDIR
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
#endif
#ifdef BB_MKFIFO
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_MKFS_MINIX
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
#endif
#ifdef BB_MKNOD
APPLET(mknod, mknod_main, _BB_DIR_BIN)
#endif
#ifdef BB_MKSWAP
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MKTEMP
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
#endif
#ifdef BB_MORE
APPLET(more, more_main, _BB_DIR_BIN)
#endif
#ifdef BB_MOUNT
APPLET(mount, mount_main, _BB_DIR_BIN)
#endif
#ifdef BB_MT
APPLET(mt, mt_main, _BB_DIR_BIN)
#endif
#ifdef BB_CP_MV
APPLET(mv, cp_mv_main, _BB_DIR_BIN)
#endif
#ifdef BB_NC
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_NSLOOKUP
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PING
APPLET(ping, ping_main, _BB_DIR_BIN)
#endif
#ifdef BB_PIVOT_ROOT
APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN)
#endif
#ifdef BB_POWEROFF
APPLET(poweroff, poweroff_main, _BB_DIR_SBIN)
#endif
#ifdef BB_PRINTF
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PS
APPLET(ps, ps_main, _BB_DIR_BIN)
#endif
#ifdef BB_PWD
APPLET(pwd, pwd_main, _BB_DIR_BIN)
#endif
#ifdef BB_RDATE
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_READLINK
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_REBOOT
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
#endif
#ifdef BB_RENICE
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_RESET
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_RM
APPLET(rm, rm_main, _BB_DIR_BIN)
#endif
#ifdef BB_RMDIR
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
#endif
#ifdef BB_RMMOD
APPLET(rmmod, rmmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_ROUTE
APPLET(route, route_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_RPMUNPACK
APPLET(rpmunpack, rpmunpack_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_SED
APPLET(sed, sed_main, _BB_DIR_BIN)
#endif
#ifdef BB_SETKEYCODES
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_SH
APPLET(sh, shell_main, _BB_DIR_BIN)
#endif
#ifdef BB_SLEEP
APPLET(sleep, sleep_main, _BB_DIR_BIN)
#endif
#ifdef BB_SORT
APPLET(sort, sort_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_STTY
APPLET(stty, stty_main, _BB_DIR_BIN)
#endif
#ifdef BB_SWAPONOFF
APPLET(swapoff, swap_on_off_main, _BB_DIR_SBIN)
#endif
#ifdef BB_SWAPONOFF
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
#endif
#ifdef BB_SYNC
APPLET(sync, sync_main, _BB_DIR_BIN)
#endif
#ifdef BB_SYSLOGD
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_TAIL
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TAR
APPLET(tar, tar_main, _BB_DIR_BIN)
#endif
#ifdef BB_TEE
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TELNET
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TEST
APPLET(test, test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TFTP
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TOUCH
APPLET(touch, touch_main, _BB_DIR_BIN)
#endif
#ifdef BB_TR
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET(true, true_main, _BB_DIR_BIN)
#endif
#ifdef BB_TTY
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UMOUNT
APPLET(umount, umount_main, _BB_DIR_BIN)
#endif
#ifdef BB_UNAME
APPLET(uname, uname_main, _BB_DIR_BIN)
#endif
#ifdef BB_UNIQ
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UNIX2DOS
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UPDATE
APPLET(update, update_main, _BB_DIR_SBIN)
#endif
#ifdef BB_UPTIME
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_USLEEP
APPLET(usleep, usleep_main, _BB_DIR_BIN)
#endif
#ifdef BB_UUDECODE
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UUENCODE
APPLET(uuencode, uuencode_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_VI
APPLET(vi, vi_main, _BB_DIR_BIN)
#endif
#ifdef BB_WATCHDOG
APPLET(watchdog, watchdog_main, _BB_DIR_SBIN)
#endif
#ifdef BB_WC
APPLET(wc, wc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WGET
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WHICH
APPLET(which, which_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WHOAMI
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_XARGS
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_YES
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_GUNZIP
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
#endif
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
{ 0,NULL,0 }
};
#endif
+34
View File
@@ -0,0 +1,34 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 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
#
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
clean:
rm -f $(L_TARGET) *.o core
+22 -14
View File
@@ -35,10 +35,6 @@
#undef PROTOTYPES
#include "applets.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
struct BB_applet *applet_using;
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
@@ -49,13 +45,6 @@ extern void show_usage(void)
const char *format_string;
const char *usage_string = usage_messages;
int i;
/* From busybox.c */
extern int been_there_done_that;
if (strcmp(applet_using->name, "busybox")==0) {
been_there_done_that=1;
busybox_main(0, NULL);
}
for (i = applet_using - applets; i > 0; ) {
if (!*usage_string++) {
@@ -78,7 +67,7 @@ static int applet_name_compare(const void *x, const void *y)
return strcmp(name, applet->name);
}
extern size_t NUM_APPLETS;
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
@@ -88,13 +77,32 @@ struct BB_applet *find_applet_by_name(const char *name)
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
extern int been_there_done_that; /* From busybox.c */
recurse_level++;
/* Do a binary search to find the applet entry given the name. */
if ((applet_using = find_applet_by_name(name)) != NULL) {
applet_name = applet_using->name;
if (argv[1] && strcmp(argv[1], "--help") == 0)
show_usage();
if (argv[1] && strcmp(argv[1], "--help") == 0) {
if (strcmp(applet_using->name, "busybox")==0) {
if(argv[2])
applet_using = find_applet_by_name(argv[2]);
else
applet_using = NULL;
}
if(applet_using)
show_usage();
been_there_done_that=1;
busybox_main(0, NULL);
}
exit((*(applet_using->main)) (argc, argv));
}
/* Just in case they have renamed busybox - Check argv[1] */
if (recurse_level == 1) {
run_applet_by_name("busybox", argc, argv);
}
recurse_level--;
}
+17 -35
View File
@@ -5,19 +5,14 @@
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
#ifdef BB_LOCALE_SUPPORT
#ifdef CONFIG_LOCALE_SUPPORT
#include <locale.h>
#endif
int been_there_done_that = 0; /* Also used in applets.c */
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
#ifdef CONFIG_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
@@ -42,21 +37,7 @@ typedef int (*__link_f)(const char *, const char *);
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
@@ -82,28 +63,29 @@ static void install_links(const char *busybox, int use_symbolic_links)
}
}
#endif /* BB_FEATURE_INSTALLER */
#endif /* CONFIG_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
const char *s;
for (s = applet_name = argv[0]; *s != '\0';) {
applet_name = argv[0];
if (applet_name[0] == '-')
applet_name++;
for (s = applet_name; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
applet_name = "sh";
}
#endif
#ifdef BB_LOCALE_SUPPORT
#ifdef CONFIG_LOCALE_SUPPORT
#ifdef CONFIG_INIT
if(getpid()!=1) /* Do not set locale for `init' */
#endif
{
setlocale(LC_ALL, "");
}
#endif
run_applet_by_name(applet_name, argc, argv);
@@ -115,7 +97,7 @@ int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
#ifdef CONFIG_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
@@ -143,7 +125,7 @@ int busybox_main(int argc, char **argv)
}
return rc;
}
#endif /* BB_FEATURE_INSTALLER */
#endif /* CONFIG_FEATURE_INSTALLER */
argc--;
+2 -2
View File
@@ -10,8 +10,8 @@
export LC_ALL=POSIX
export LC_CTYPE=POSIX
CONFIG_H=${1:-Config.h}
APPLETS_H=${2:-applets.h}
CONFIG_H=${1:-include/config.h}
APPLETS_H=${2:-include/applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
dir=substr($2,8)
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh
export LC_ALL=POSIX
export LC_CTYPE=POSIX
RAW=` \
gcc -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
# By running $RAW through "ls", we avoid listing
# source files that don't exist.
ls $RAW 2>/dev/null | tr '\n' ' '
-1757
View File
File diff suppressed because it is too large. Load diff
-227
View File
@@ -1,227 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
typedef struct ar_headers_s {
char *name;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
/*
* return the headerL_t struct for the filename descriptor
*/
extern ar_headers_t get_ar_headers(int srcFd)
{
typedef struct raw_ar_header_s { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6];
char gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} raw_ar_header_t;
raw_ar_header_t raw_ar_header;
ar_headers_t *head, *entry;
char ar_magic[8];
char *long_name=NULL;
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
/* check ar magic */
if (full_read(srcFd, ar_magic, 8) != 8) {
error_msg_and_die("cannot read magic");
}
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
/* check the end of header markers are valid */
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
char newline;
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, &newline, 1);
if (newline!='\n') {
break;
}
/* fix up the header, we started reading 1 byte too early due to a '\n' */
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
/* dont worry about adding the last '\n', we dont need it now */
}
entry->size = (off_t) atoi(raw_ar_header.size);
/* long filenames have '/' as the first character */
if (raw_ar_header.name[0] == '/') {
if (raw_ar_header.name[1] == '/') {
/* multiple long filenames are stored as data in one entry */
long_name = (char *) xrealloc(long_name, entry->size);
full_read(srcFd, long_name, entry->size);
continue;
}
else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
strcpy(entry->name, &long_name[long_name_offset]);
}
}
else {
/* short filenames */
entry->name = xmalloc(16);
strncpy(entry->name, raw_ar_header.name, 16);
}
entry->name[strcspn(entry->name, " /")]='\0';
/* convert the rest of the now valid char header to its typed struct */
parse_mode(raw_ar_header.mode, &entry->mode);
entry->mtime = atoi(raw_ar_header.date);
entry->uid = atoi(raw_ar_header.uid);
entry->gid = atoi(raw_ar_header.gid);
entry->offset = lseek(srcFd, 0, SEEK_CUR);
/* add this entries header to our combined list */
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*entry->next = *head;
*head = *entry;
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
}
return(*head);
}
extern int ar_main(int argc, char **argv)
{
const int preserve_date = 1; /* preserve original dates */
const int verbose = 2; /* be verbose */
const int display = 4; /* display contents */
const int extract_to_file = 8; /* extract contents of archive */
const int extract_to_stdout = 16; /* extract to stdout */
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
ar_headers_t head, *extract_list=NULL;
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct |= preserve_date;
break;
case 'v':
funct |= verbose;
break;
case 't':
funct |= display;
break;
case 'p':
funct |= extract_to_stdout;
break;
case 'x':
funct |= extract_to_file;
break;
default:
show_usage();
}
}
/* check the src filename was specified */
if (optind == argc)
show_usage();
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s", argv[optind]);
optind++;
head = get_ar_headers(srcFd);
/* find files to extract or display */
/* search through argv and build extract list */
for (;optind<argc; optind++) {
ar_headers_t *ar_entry;
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
ar_entry = &head;
while (ar_entry->next != NULL) {
if (strcmp(argv[optind], ar_entry->name) == 0) {
ar_headers_t *tmp;
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*tmp = *extract_list;
*extract_list = *ar_entry;
extract_list->next = tmp;
break;
}
ar_entry=ar_entry->next;
}
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
}
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (off_t) extract_list->size);
}
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
(int) extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
}
return EXIT_SUCCESS;
}
+44
View File
@@ -0,0 +1,44 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 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
#
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
clean:
rm -f $(L_TARGET) *.o core
+33 -170
View File
@@ -23,144 +23,39 @@
*
*/
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include "unarchive.h"
#include "busybox.h"
typedef struct ar_headers_s {
char *name;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
/*
* return the headerL_t struct for the filename descriptor
*/
extern ar_headers_t get_ar_headers(int srcFd)
{
typedef struct raw_ar_header_s { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6];
char gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} raw_ar_header_t;
raw_ar_header_t raw_ar_header;
ar_headers_t *head, *entry;
char ar_magic[8];
char *long_name=NULL;
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
/* check ar magic */
if (full_read(srcFd, ar_magic, 8) != 8) {
error_msg_and_die("cannot read magic");
}
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
/* check the end of header markers are valid */
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
char newline;
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, &newline, 1);
if (newline!='\n') {
break;
}
/* fix up the header, we started reading 1 byte too early due to a '\n' */
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
/* dont worry about adding the last '\n', we dont need it now */
}
entry->size = (off_t) atoi(raw_ar_header.size);
/* long filenames have '/' as the first character */
if (raw_ar_header.name[0] == '/') {
if (raw_ar_header.name[1] == '/') {
/* multiple long filenames are stored as data in one entry */
long_name = (char *) xrealloc(long_name, entry->size);
full_read(srcFd, long_name, entry->size);
continue;
}
else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
strcpy(entry->name, &long_name[long_name_offset]);
}
}
else {
/* short filenames */
entry->name = xmalloc(16);
strncpy(entry->name, raw_ar_header.name, 16);
}
entry->name[strcspn(entry->name, " /")]='\0';
/* convert the rest of the now valid char header to its typed struct */
parse_mode(raw_ar_header.mode, &entry->mode);
entry->mtime = atoi(raw_ar_header.date);
entry->uid = atoi(raw_ar_header.uid);
entry->gid = atoi(raw_ar_header.gid);
entry->offset = lseek(srcFd, 0, SEEK_CUR);
/* add this entries header to our combined list */
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*entry->next = *head;
*head = *entry;
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
}
return(*head);
}
extern int ar_main(int argc, char **argv)
{
const int preserve_date = 1; /* preserve original dates */
const int verbose = 2; /* be verbose */
const int display = 4; /* display contents */
const int extract_to_file = 8; /* extract contents of archive */
const int extract_to_stdout = 16; /* extract to stdout */
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
ar_headers_t head, *extract_list=NULL;
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
FILE *src_stream = NULL;
char **extract_names = NULL;
char ar_magic[8];
int extract_function = extract_unconditional;
int opt;
int num_of_entries = 0;
extern off_t archive_offset;
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct |= preserve_date;
extract_function |= extract_preserve_date;
break;
case 'v':
funct |= verbose;
extract_function |= extract_verbose_list;
break;
case 't':
funct |= display;
extract_function |= extract_list;
break;
case 'p':
funct |= extract_to_stdout;
extract_function |= extract_to_stdout;
break;
case 'x':
funct |= extract_to_file;
extract_function |= extract_all_to_fs;
break;
default:
show_usage();
@@ -168,60 +63,28 @@ extern int ar_main(int argc, char **argv)
}
/* check the src filename was specified */
if (optind == argc)
if (optind == argc) {
show_usage();
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s", argv[optind]);
optind++;
head = get_ar_headers(srcFd);
/* find files to extract or display */
/* search through argv and build extract list */
for (;optind<argc; optind++) {
ar_headers_t *ar_entry;
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
ar_entry = &head;
while (ar_entry->next != NULL) {
if (strcmp(argv[optind], ar_entry->name) == 0) {
ar_headers_t *tmp;
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*tmp = *extract_list;
*extract_list = *ar_entry;
extract_list->next = tmp;
break;
}
ar_entry=ar_entry->next;
}
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
src_stream = xfopen(argv[optind++], "r");
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
archive_offset = 8;
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (off_t) extract_list->size);
}
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
(int) extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
/* Create a list of files to extract */
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, stdout, &get_header_ar, extract_function, "./", extract_names, NULL);
return EXIT_SUCCESS;
}
+2370
View File
File diff suppressed because it is too large. Load diff
+23
View File
@@ -0,0 +1,23 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
mainmenu_option next_comment
comment 'Archival Utilities'
bool 'ar' CONFIG_AR
bool 'bunzip2' CONFIG_BUNZIP2
bool 'cpio' CONFIG_CPIO
bool 'dpkg' CONFIG_DPKG
bool 'dpkg_deb' CONFIG_DPKG_DEB
bool 'gunzip' CONFIG_GUNZIP
bool 'gzip' CONFIG_GZIP
bool 'rpm2cpio' CONFIG_RPM2CPIO
bool 'tar' CONFIG_TAR
if [ "$CONFIG_TAR" = "y" ] ; then
bool ' Enable archive creation' CONFIG_FEATURE_TAR_CREATE
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
endmenu
+96
View File
@@ -0,0 +1,96 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cpio implementation for busybox
*
* Copyright (C) 2001 by Glenn McGrath
*
* 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
*
* Limitations:
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
*
*/
#include <fcntl.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "unarchive.h"
#include "busybox.h"
extern int cpio_main(int argc, char **argv)
{
FILE *src_stream = stdin;
char **extract_names = NULL;
int extract_function = 0;
int num_of_entries = 0;
int opt = 0;
mode_t oldmask = 0;
while ((opt = getopt(argc, argv, "idmuvtF:")) != -1) {
switch (opt) {
case 'i': // extract
extract_function |= extract_all_to_fs;
break;
case 'd': // create _leading_ directories
extract_function |= extract_create_leading_dirs;
oldmask = umask(077); /* Make make_directory act like GNU cpio */
break;
case 'm': // preserve modification time
extract_function |= extract_preserve_date;
break;
case 'v': // verbosly list files
extract_function |= extract_verbose_list;
break;
case 'u': // unconditional
extract_function |= extract_unconditional;
break;
case 't': // list files
extract_function |= extract_list;
break;
case 'F':
src_stream = xfopen(optarg, "r");
break;
default:
show_usage();
}
}
if ((extract_function & extract_all_to_fs) && (extract_function & extract_list)) {
extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/
}
if ((extract_function & extract_all_to_fs) && (extract_function & extract_verbose_list)) {
/* The meaning of v changes on extract */
extract_function ^= extract_verbose_list;
extract_function |= extract_list;
}
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names, NULL);
if (oldmask) {
umask(oldmask); /* Restore umask if we changed it */
}
return EXIT_SUCCESS;
}
+1396 -733
View File
File diff suppressed because it is too large. Load diff
+85 -142
View File
@@ -14,175 +14,118 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* Merge this applet into dpkg when dpkg becomes more stable
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <getopt.h>
#include "unarchive.h"
#include "busybox.h"
/* From gunzip.c */
extern int gz_open(FILE *compressed_file, int *pid);
extern void gz_close(int gunzip_pid);
typedef struct ar_headers_s {
char *name;
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
extern ar_headers_t get_ar_headers(int srcFd);
extern int tar_unzip_init(int tarFd);
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** extractList, char** excludeList);
static const int dpkg_deb_contents = 1;
static const int dpkg_deb_control = 2;
// const int dpkg_deb_info = 4;
static const int dpkg_deb_extract = 8;
static const int dpkg_deb_verbose_extract = 16;
static const int dpkg_deb_list = 32;
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename)
{
char **extract_list = NULL;
ar_headers_t *ar_headers = NULL;
char ar_filename[15];
int extract_flag = FALSE;
int list_flag = FALSE;
int verbose_flag = FALSE;
int extract_to_stdout = FALSE;
int srcFd = 0;
int status;
pid_t pid;
FILE *comp_file = NULL;
if (dpkg_deb_contents == (dpkg_deb_contents & optflags)) {
strcpy(ar_filename, "data.tar.gz");
verbose_flag = TRUE;
list_flag = TRUE;
}
if (dpkg_deb_list == (dpkg_deb_list & optflags)) {
strcpy(ar_filename, "data.tar.gz");
list_flag = TRUE;
}
if (dpkg_deb_control == (dpkg_deb_control & optflags)) {
strcpy(ar_filename, "control.tar.gz");
extract_flag = TRUE;
}
if (dpkg_deb_extract == (dpkg_deb_extract & optflags)) {
strcpy(ar_filename, "data.tar.gz");
extract_flag = TRUE;
}
if (dpkg_deb_verbose_extract == (dpkg_deb_verbose_extract & optflags)) {
strcpy(ar_filename, "data.tar.gz");
extract_flag = TRUE;
list_flag = TRUE;
}
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
srcFd = open(deb_filename, O_RDONLY);
*ar_headers = get_ar_headers(srcFd);
if (ar_headers->next == NULL) {
error_msg_and_die("Couldnt find %s in %s", ar_filename, deb_filename);
}
while (ar_headers->next != NULL) {
if (strcmp(ar_headers->name, ar_filename) == 0) {
break;
}
ar_headers = ar_headers->next;
}
lseek(srcFd, ar_headers->offset, SEEK_SET);
/* Uncompress the file */
comp_file = fdopen(srcFd, "r");
if ((srcFd = gz_open(comp_file, &pid)) == EXIT_FAILURE) {
error_msg_and_die("Couldnt unzip file");
}
if ( dir_name != NULL) {
if (is_directory(dir_name, TRUE, NULL)==FALSE) {
mkdir(dir_name, 0755);
}
if (chdir(dir_name)==-1) {
error_msg_and_die("Cannot change to dir %s", dir_name);
}
}
status = readTarFile(srcFd, extract_flag, list_flag,
extract_to_stdout, verbose_flag, NULL, extract_list);
/* we are deliberately terminating the child so we can safely ignore this */
signal(SIGTERM, SIG_IGN);
gz_close(pid);
close(srcFd);
fclose(comp_file);
return status;
}
extern int dpkg_deb_main(int argc, char **argv)
{
char *target_dir = NULL;
char *prefix = NULL;
char *filename = NULL;
char *output_buffer = NULL;
int opt = 0;
int optflag = 0;
int arg_type = 0;
int deb_extract_funct = extract_create_leading_dirs | extract_unconditional;
while ((opt = getopt(argc, argv, "cexXl")) != -1) {
const int arg_type_prefix = 1;
const int arg_type_field = 2;
const int arg_type_filename = 4;
// const int arg_type_un_ar_gz = 8;
while ((opt = getopt(argc, argv, "ceftXxI")) != -1) {
switch (opt) {
case 'c':
optflag |= dpkg_deb_contents;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_verbose_list;
break;
case 'e':
optflag |= dpkg_deb_control;
arg_type = arg_type_prefix;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_all_to_fs;
break;
case 'f':
arg_type = arg_type_field;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_one_to_buffer;
filename = xstrdup("./control");
break;
case 't': /* --fsys-tarfile, i just made up this short name */
/* Integrate the functionality needed with some code from ar.c */
error_msg_and_die("Option disabled");
// arg_type = arg_type_un_ar_gz;
break;
case 'X':
optflag |= dpkg_deb_verbose_extract;
break;
arg_type = arg_type_prefix;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_all_to_fs;
deb_extract_funct |= extract_list;
case 'x':
optflag |= dpkg_deb_extract;
arg_type = arg_type_prefix;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_all_to_fs;
break;
case 'l':
optflag |= dpkg_deb_list;
case 'I':
arg_type = arg_type_filename;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_one_to_buffer;
break;
/* case 'I':
optflag |= dpkg_deb_info;
break;
*/
default:
show_usage();
}
}
if (((optind + 1 ) > argc) || (optflag == 0)) {
if (optind == argc) {
show_usage();
}
if ((optflag & dpkg_deb_control) || (optflag & dpkg_deb_extract) || (optflag & dpkg_deb_verbose_extract)) {
if ( (optind + 1) == argc ) {
target_dir = (char *) xmalloc(7);
strcpy(target_dir, "DEBIAN");
/* Workout where to extract the files */
if (arg_type == arg_type_prefix) {
/* argument is a dir name */
if ((optind + 1) == argc ) {
prefix = xstrdup("./DEBIAN/");
} else {
target_dir = (char *) xmalloc(strlen(argv[optind + 1]));
strcpy(target_dir, argv[optind + 1]);
prefix = (char *) xmalloc(strlen(argv[optind + 1]) + 2);
strcpy(prefix, argv[optind + 1]);
/* Make sure the directory has a trailing '/' */
if (last_char_is(prefix, '/') == NULL) {
strcat(prefix, "/");
}
}
mkdir(prefix, 0777);
}
if (arg_type == arg_type_filename) {
if ((optind + 1) != argc) {
filename = xstrdup(argv[optind + 1]);
} else {
error_msg_and_die("-I currently requires a filename to be specified");
}
}
deb_extract(optflag, target_dir, argv[optind]);
/* else if (optflag & dpkg_deb_info) {
extract_flag = TRUE;
extract_to_stdout = TRUE;
strcpy(ar_filename, "control.tar.gz");
extract_list = argv+optind+1;
printf("list one is [%s]\n",extract_list[0]);
output_buffer = deb_extract(argv[optind], stdout, deb_extract_funct, prefix, filename);
if ((arg_type == arg_type_filename) && (output_buffer != NULL)) {
puts(output_buffer);
}
*/
else if (arg_type == arg_type_field) {
char *field = NULL;
char *name;
char *value;
int field_start = 0;
while (1) {
field_start += read_package_field(&output_buffer[field_start], &name, &value);
if (name == NULL) {
break;
}
if (strcmp(name, argv[optind + 1]) == 0) {
puts(value);
}
free(field);
}
}
return(EXIT_SUCCESS);
}
+45 -1044
View File
File diff suppressed because it is too large. Load diff
+246 -1172
View File
File diff suppressed because it is too large. Load diff
+57
View File
@@ -0,0 +1,57 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 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
#
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
clean:
rm -f $(L_TARGET) *.o core
+83
View File
@@ -0,0 +1,83 @@
/*
* 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 Library 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"
char *deb_extract(const char *package_filename, FILE *out_stream,
const int extract_function, const char *prefix, const char *filename)
{
FILE *deb_stream;
FILE *uncompressed_stream = NULL;
file_header_t *ar_header = NULL;
char **file_list = NULL;
char *output_buffer = NULL;
char *ared_file = NULL;
char ar_magic[8];
int gunzip_pid;
if (filename != NULL) {
file_list = xmalloc(sizeof(char *) * 2);
file_list[0] = xstrdup(filename);
file_list[1] = NULL;
}
if (extract_function & extract_control_tar_gz) {
ared_file = xstrdup("control.tar.gz");
}
else if (extract_function & extract_data_tar_gz) {
ared_file = xstrdup("data.tar.gz");
}
/* open the debian package to be worked on */
deb_stream = wfopen(package_filename, "r");
if (deb_stream == NULL) {
return(NULL);
}
/* set the buffer size */
setvbuf(deb_stream, NULL, _IOFBF, 0x8000);
/* check ar magic */
fread(ar_magic, 1, 8, deb_stream);
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
archive_offset = 8;
while ((ar_header = get_header_ar(deb_stream)) != NULL) {
if (strcmp(ared_file, ar_header->name) == 0) {
/* open a stream of decompressed data */
uncompressed_stream = gz_open(deb_stream, &gunzip_pid);
archive_offset = 0;
output_buffer = unarchive(uncompressed_stream, out_stream, get_header_tar, extract_function, prefix, file_list, NULL);
}
seek_sub_file(deb_stream, ar_header->size);
free(ar_header->name);
free(ar_header);
}
gz_close(gunzip_pid);
fclose(deb_stream);
fclose(uncompressed_stream);
free(ared_file);
if (filename != NULL) {
free(file_list[0]);
free(file_list);
}
return(output_buffer);
}
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
* Gzip implementation for busybox
* gunzip implementation for busybox
*
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
*
@@ -60,29 +60,19 @@ static char *license_msg[] = {
};
#endif
#include <getopt.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
//#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <time.h>
#include <dirent.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_memory_exhausted
#define bb_need_name_too_long
#include "messages.c"
#include <string.h>
#include "libbb.h"
FILE *in_file, *out_file;
static FILE *in_file, *out_file;
/* these are freed by gz_close */
static unsigned char *window;
static unsigned long *crc_table;
static unsigned long crc = 0xffffffffL; /* shift register contents */
/* Return codes from gzip */
@@ -98,14 +88,12 @@ static const int WSIZE = 0x8000;
static const int BMAX = 16; /* maximum bit length of any code (16 for explode) */
static const int N_MAX = 288; /* maximum number of codes in any set */
static unsigned char *window;
static long bytes_out; /* number of output bytes */
static unsigned long outcnt; /* bytes in output buffer */
unsigned hufts; /* track memory usage */
unsigned long bb; /* bit buffer */
unsigned bk; /* bits in bit buffer */
static unsigned hufts; /* track memory usage */
static unsigned long bb; /* bit buffer */
static unsigned bk; /* bits in bit buffer */
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
@@ -116,7 +104,7 @@ typedef struct huft_s {
} v;
} huft_t;
unsigned short mask_bits[] = {
static const unsigned short mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
@@ -127,13 +115,13 @@ unsigned short mask_bits[] = {
* Signal and error handler.
*/
static void abort_gzip()
static void abort_gzip(void)
{
error_msg("gzip aborted\n");
exit(ERROR);
}
static void make_crc_table()
static void make_crc_table(void)
{
unsigned long table_entry; /* crc shift register */
unsigned long poly = 0; /* polynomial exclusive-or pattern */
@@ -166,7 +154,7 @@ static void make_crc_table()
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
void flush_window()
static void flush_window(void)
{
int n;
@@ -865,7 +853,7 @@ static int inflate_block(int *e)
*
* GLOBAL VARIABLES: outcnt, bk, bb, hufts, inptr
*/
static int inflate()
static int inflate(void)
{
int e; /* last block flag */
int r; /* result code */
@@ -913,6 +901,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
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;
@@ -921,9 +910,9 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
(void) signal(SIGINT, (sig_type) abort_gzip);
}
#ifdef SIGTERM
if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
(void) signal(SIGTERM, (sig_type) abort_gzip);
}
// if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
// (void) signal(SIGTERM, (sig_type) abort_gzip);
// }
#endif
#ifdef SIGHUP
if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
@@ -936,9 +925,6 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
outcnt = 0;
bytes_out = 0L;
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
magic[0] = fgetc(in_file);
magic[1] = fgetc(in_file);
@@ -958,10 +944,16 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
flags = (unsigned char) fgetc(in_file);
/* Ignore time stamp(4), extra flags(1), OS type(1) */
fseek(in_file, 6, SEEK_CUR);
for (i = 0; i < 6; i++)
fgetc(in_file);
if ((flags & extra_field) != 0) {
fseek(in_file, (size_t) fgetc(in_file) + ((size_t)fgetc(in_file) << 8), SEEK_CUR);
size_t extra;
extra = fgetc(in_file);
extra += fgetc(in_file) << 8;
for (i = 0; i < extra; i++)
fgetc(in_file);
}
/* Discard original name if any */
@@ -1003,7 +995,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
fread(buf, 1, 8, in_file);
/* Validate decompression - crc */
if (((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) {
if ((unsigned int)((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) {
error_msg("invalid compressed data--crc error");
}
/* Validate decompression - size */
@@ -1017,34 +1009,9 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
return 0;
}
#ifdef BB_FEATURE_TAR_GZIP
extern int gz_open(FILE *compressed_file, int *pid)
{
int unzip_pipe[2];
if (pipe(unzip_pipe)!=0) {
error_msg("pipe error");
return(EXIT_FAILURE);
}
if ((*pid = fork()) == -1) {
error_msg("fork failured");
return(EXIT_FAILURE);
}
if (*pid==0) {
/* child process */
close(unzip_pipe[0]);
unzip(compressed_file, fdopen(unzip_pipe[1], "w"));
printf("finished unzipping\n");
fflush(NULL);
fclose(compressed_file);
close(unzip_pipe[1]);
exit(EXIT_SUCCESS);
}
close(unzip_pipe[1]);
return(unzip_pipe[0]);
}
/*
* This needs access to global variables wondow and crc_table, so its not in its own file.
*/
extern void gz_close(int gunzip_pid)
{
if (kill(gunzip_pid, SIGTERM) == -1) {
@@ -1054,129 +1021,6 @@ extern void gz_close(int gunzip_pid)
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
free(window);
free(crc_table);
}
#endif
extern int gunzip_main(int argc, char **argv)
{
struct stat stat_buf;
char *if_name = NULL;
char *of_name = NULL;
char *delete_file_name = NULL;
const int gunzip_to_stdout = 1;
const int gunzip_from_stdin = 2;
const int gunzip_force = 4;
const int gunzip_test = 8;
int flags = 0;
int opt = 0;
int delete_old_file = FALSE;
/* if called as zcat */
if (strcmp(applet_name, "zcat") == 0) {
if (argc != 2) {
show_usage();
}
optind = 1;
flags |= (gunzip_force | gunzip_to_stdout);
} else {
/* workout flags as regular gunzip */
/* set default flags */
if (argc == 1) {
flags |= (gunzip_from_stdin | gunzip_to_stdout);
} else {
/* Parse any options */
while ((opt = getopt(argc, argv, "ctfh")) != -1) {
switch (opt) {
case 'c':
flags |= gunzip_to_stdout;
break;
case 'f':
flags |= gunzip_force;
break;
case 't':
flags |= gunzip_test;
break;
case 'h':
default:
show_usage(); /* exit's inside usage */
}
}
}
}
/* Set input filename and number */
if (flags & gunzip_from_stdin) {
in_file = stdin;
if ((flags & gunzip_force) == 0) {
error_msg_and_die("data not written to terminal. Use -f to force it.");
}
} else {
if_name = strdup(argv[optind]);
/* Open input file */
in_file = xfopen(if_name, "r");
/* Get the time stamp on the input file. */
if (stat(if_name, &stat_buf) < 0) {
error_msg_and_die("Couldnt stat file %s",if_name);
}
}
/* Set output filename and number */
if (flags & gunzip_to_stdout) {
out_file = stdout;
/* whats the best way to do this with streams ? */
if (isatty(fileno(out_file)) && ((flags & gunzip_force) == 0)) {
error_msg_and_die("data not written to terminal. Use -f to force it.");
}
} else if (flags & gunzip_test) {
out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
} else {
char *extension;
int length = strlen(if_name);
delete_old_file = TRUE;
extension = strrchr(if_name, '.');
if (strcmp(extension, ".gz") == 0) {
length -= 3;
} else if (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);
/* Open output file */
out_file = xfopen(of_name, "w");
/* Set permissions on the file */
chmod(of_name, stat_buf.st_mode);
}
/* 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;
}
fclose(out_file);
fclose(in_file);
if (delete_old_file == TRUE) {
if (unlink(delete_file_name) < 0) {
error_msg_and_die("Couldnt remove %s", delete_file_name);
}
}
free(of_name);
return(EXIT_SUCCESS);
free(window);
free(crc_table);
}
+106
View File
@@ -0,0 +1,106 @@
/*
* 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 Library 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"
file_header_t *get_header_ar(FILE *src_stream)
{
file_header_t *typed;
union {
char raw[60];
struct {
char name[16];
char date[12];
char uid[6];
char gid[6];
char mode[8];
char size[10];
char magic[2];
} formated;
} ar;
static char *ar_long_names;
if (fread(ar.raw, 1, 60, src_stream) != 60) {
return(NULL);
}
archive_offset += 60;
/* align the headers based on the header magic */
if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) {
/* some version of ar, have an extra '\n' after each data entry,
* this puts the next header out by 1 */
if (ar.formated.magic[1] != '`') {
error_msg("Invalid magic");
return(NULL);
}
/* read the next char out of what would be the data section,
* if its a '\n' then it is a valid header offset by 1*/
archive_offset++;
if (fgetc(src_stream) != '\n') {
error_msg("Invalid magic");
return(NULL);
}
/* fix up the header, we started reading 1 byte too early */
/* raw_header[60] wont be '\n' as it should, but it doesnt matter */
memmove(ar.raw, &ar.raw[1], 59);
}
typed = (file_header_t *) xcalloc(1, sizeof(file_header_t));
typed->size = (size_t) atoi(ar.formated.size);
/* long filenames have '/' as the first character */
if (ar.formated.name[0] == '/') {
if (ar.formated.name[1] == '/') {
/* If the second char is a '/' then this entries data section
* stores long filename for multiple entries, they are stored
* in static variable long_names for use in future entries */
ar_long_names = (char *) xrealloc(ar_long_names, typed->size);
fread(ar_long_names, 1, typed->size, src_stream);
archive_offset += typed->size;
/* This ar entries data section only contained filenames for other records
* they are stored in the static ar_long_names for future reference */
return (get_header_ar(src_stream)); /* Return next header */
} else if (ar.formated.name[1] == ' ') {
/* This is the index of symbols in the file for compilers */
seek_sub_file(src_stream, typed->size);
return (get_header_ar(src_stream)); /* Return next header */
} else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
if (!ar_long_names) {
error_msg("Cannot resolve long file name");
return (NULL);
}
typed->name = xstrdup(ar_long_names + atoi(&ar.formated.name[1]));
}
} else {
/* short filenames */
typed->name = xcalloc(1, 16);
strncpy(typed->name, ar.formated.name, 16);
}
typed->name[strcspn(typed->name, " /")]='\0';
/* convert the rest of the now valid char header to its typed struct */
parse_mode(ar.formated.mode, &typed->mode);
typed->mtime = atoi(ar.formated.date);
typed->uid = atoi(ar.formated.uid);
typed->gid = atoi(ar.formated.gid);
return(typed);
}
+136
View File
@@ -0,0 +1,136 @@
/*
* 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 Library 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"
struct hardlinks {
file_header_t *entry;
int inode;
struct hardlinks *next;
};
file_header_t *get_header_cpio(FILE *src_stream)
{
file_header_t *cpio_entry = NULL;
char cpio_header[110];
int namesize;
char dummy[16];
int major, minor, nlink, inode;
static struct hardlinks *saved_hardlinks = NULL;
static int pending_hardlinks = 0;
if (pending_hardlinks) { /* Deal with any pending hardlinks */
struct hardlinks *tmp = saved_hardlinks, *oldtmp = NULL;
while (tmp) {
if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */
cpio_entry = tmp->entry;
if (oldtmp) oldtmp->next = tmp->next; /* Remove item from linked list */
else saved_hardlinks = tmp->next;
free(tmp);
return (cpio_entry);
}
oldtmp = tmp;
tmp = tmp->next;
}
pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */
}
/* There can be padding before archive header */
seek_sub_file(src_stream, (4 - (archive_offset % 4)) % 4);
if (fread(cpio_header, 1, 110, src_stream) == 110) {
archive_offset += 110;
if (strncmp(cpio_header, "07070", 5) != 0) {
error_msg("Unsupported format or invalid magic");
return(NULL);
}
switch (cpio_header[5]) {
case '2': /* "crc" header format */
/* Doesnt do the crc check yet */
case '1': /* "newc" header format */
cpio_entry = (file_header_t *) xcalloc(1, sizeof(file_header_t));
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, (unsigned int*)&cpio_entry->mode,
(unsigned int*)&cpio_entry->uid, (unsigned int*)&cpio_entry->gid,
&nlink, &cpio_entry->mtime, &cpio_entry->size,
dummy, &major, &minor, &namesize, dummy);
cpio_entry->name = (char *) xcalloc(1, namesize);
fread(cpio_entry->name, 1, namesize, src_stream); /* Read in filename */
archive_offset += namesize;
/* Skip padding before file contents */
seek_sub_file(src_stream, (4 - (archive_offset % 4)) % 4);
if (strcmp(cpio_entry->name, "TRAILER!!!") == 0) {
printf("%d blocks\n", (int) (archive_offset % 512 ? (archive_offset / 512) + 1 : archive_offset / 512)); /* Always round up */
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
struct hardlinks *tmp = saved_hardlinks, *oldtmp = NULL;
while (tmp) {
error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
oldtmp = tmp;
tmp = tmp->next;
free (oldtmp->entry->name);
free (oldtmp->entry);
free (oldtmp);
}
saved_hardlinks = NULL;
pending_hardlinks = 0;
}
return(NULL);
}
if (S_ISLNK(cpio_entry->mode)) {
cpio_entry->link_name = (char *) xcalloc(1, cpio_entry->size + 1);
fread(cpio_entry->link_name, 1, cpio_entry->size, src_stream);
archive_offset += cpio_entry->size;
cpio_entry->size = 0; /* Stop possiable seeks in future */
}
if (nlink > 1 && !S_ISDIR(cpio_entry->mode)) {
if (cpio_entry->size == 0) { /* Put file on a linked list for later */
struct hardlinks *new = xmalloc(sizeof(struct hardlinks));
new->next = saved_hardlinks;
new->inode = inode;
new->entry = cpio_entry;
saved_hardlinks = new;
return(get_header_cpio(src_stream)); /* Recurse to next file */
} else { /* Found the file with data in */
struct hardlinks *tmp = saved_hardlinks;
pending_hardlinks = 1;
while (tmp) {
if (tmp->inode == inode) {
tmp->entry->link_name = xstrdup(cpio_entry->name);
nlink--;
}
tmp = tmp->next;
}
if (nlink > 1) error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
}
}
cpio_entry->device = (major << 8) | minor;
break;
default:
error_msg("Unsupported format");
return(NULL);
}
if (ferror(src_stream) || feof(src_stream)) {
perror_msg("Stream error");
return(NULL);
}
}
return(cpio_entry);
}
+99
View File
@@ -0,0 +1,99 @@
/*
* 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 Library 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"
file_header_t *get_header_tar(FILE *tar_stream)
{
union {
unsigned char raw[512];
struct {
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} formated;
} tar;
file_header_t *tar_entry = NULL;
long sum = 0;
long i;
if (archive_offset % 512 != 0) {
seek_sub_file(tar_stream, 512 - (archive_offset % 512));
}
if (fread(tar.raw, 1, 512, tar_stream) != 512) {
/* Unfortunatly its common for tar files to have all sorts of
* trailing garbage, fail silently */
// error_msg("Couldnt read header");
return(NULL);
}
archive_offset += 512;
/* Check header has valid magic, unfortunately some tar files
* have empty (0'ed) tar entries at the end, which will
* cause this to fail, so fail silently for now
*/
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
return(NULL);
}
/* Do checksum on headers */
for (i = 0; i < 148 ; i++) {
sum += tar.raw[i];
}
sum += ' ' * 8;
for (i = 156; i < 512 ; i++) {
sum += tar.raw[i];
}
if (sum != strtol(tar.formated.chksum, NULL, 8)) {
error_msg("Invalid tar header checksum");
return(NULL);
}
/* convert to type'ed variables */
tar_entry = xcalloc(1, sizeof(file_header_t));
tar_entry->name = xstrdup(tar.formated.name);
parse_mode(tar.formated.mode, &tar_entry->mode);
tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
tar_entry->size = strtol(tar.formated.size, NULL, 8);
tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
tar_entry->link_name = strlen(tar.formated.linkname) ?
xstrdup(tar.formated.linkname) : NULL;
tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) +
strtol(tar.formated.devminor, NULL, 8);
return(tar_entry);
}
+35
View File
@@ -0,0 +1,35 @@
/*
* 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 Library 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 <errno.h>
#include <stdlib.h>
#include <unistd.h>
off_t archive_offset;
void seek_sub_file(FILE *src_stream, const int count)
{
/* Try to fseek as faster */
archive_offset += count;
if (fseek(src_stream, count, SEEK_CUR) != 0 && errno == ESPIPE) {
int i;
for (i = 0; i < count; i++) {
fgetc(src_stream);
}
}
return;
}
+241
View File
@@ -0,0 +1,241 @@
/*
* 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 Library 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 <errno.h>
#include <fnmatch.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <utime.h>
#include "unarchive.h"
#include "libbb.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
*
* prefix doesnt have to be just a directory, it may prefix the filename as well.
*
* e.g. '/var/lib/dpkg/info/dpkg.' will extract all files to the base bath
* '/var/lib/dpkg/info/' and all files/dirs created in that dir will have
* 'dpkg.' as their prefix
*
* For this reason if prefix does point to a dir then it must end with a
* trailing '/' or else the last dir will be assumed to be the file prefix
*/
char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry,
const int function, const char *prefix)
{
FILE *dst_stream = NULL;
char *full_name = NULL;
char *buffer = NULL;
struct utimbuf t;
/* prefix doesnt have to be a proper path it may prepend
* the filename as well */
if (prefix != NULL) {
/* strip leading '/' in filename to extract as prefix may not be dir */
/* Cant use concat_path_file here as prefix might not be a directory */
char *path = file_entry->name;
if (strncmp("./", path, 2) == 0) {
path += 2;
if (strlen(path) == 0) {
return(NULL);
}
}
full_name = xmalloc(strlen(prefix) + strlen(path) + 1);
strcpy(full_name, prefix);
strcat(full_name, path);
} else {
full_name = file_entry->name;
}
if (function & extract_to_stdout) {
if (S_ISREG(file_entry->mode)) {
copy_file_chunk(src_stream, out_stream, file_entry->size);
archive_offset += file_entry->size;
}
}
else if (function & extract_one_to_buffer) {
if (S_ISREG(file_entry->mode)) {
buffer = (char *) xmalloc(file_entry->size + 1);
fread(buffer, 1, file_entry->size, src_stream);
buffer[file_entry->size] = '\0';
archive_offset += file_entry->size;
return(buffer);
}
}
else if (function & extract_all_to_fs) {
struct stat oldfile;
int stat_res;
stat_res = lstat (full_name, &oldfile);
if (stat_res == 0) { /* The file already exists */
if ((function & extract_unconditional) || (oldfile.st_mtime < file_entry->mtime)) {
if (!S_ISDIR(oldfile.st_mode)) {
unlink(full_name); /* Directories might not be empty etc */
}
} else {
if ((function & extract_quiet) != extract_quiet) {
error_msg("%s not created: newer or same age file exists", file_entry->name);
}
seek_sub_file(src_stream, file_entry->size);
return (NULL);
}
}
if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */
char *buf, *parent;
buf = xstrdup(full_name);
parent = dirname(buf);
if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) {
if ((function & extract_quiet) != extract_quiet) {
error_msg("couldn't create leading directories");
}
}
free (buf);
}
switch(file_entry->mode & S_IFMT) {
case S_IFREG:
if (file_entry->link_name) { /* Found a cpio hard link */
if (link(file_entry->link_name, full_name) != 0) {
if ((function & extract_quiet) != extract_quiet) {
perror_msg("Cannot link from %s to '%s'",
file_entry->name, file_entry->link_name);
}
}
} else {
if ((dst_stream = wfopen(full_name, "w")) == NULL) {
seek_sub_file(src_stream, file_entry->size);
return NULL;
}
archive_offset += file_entry->size;
copy_file_chunk(src_stream, dst_stream, file_entry->size);
fclose(dst_stream);
}
break;
case S_IFDIR:
if (stat_res != 0) {
if (mkdir(full_name, file_entry->mode) < 0) {
if ((function & extract_quiet) != extract_quiet) {
perror_msg("extract_archive: %s", full_name);
}
}
}
break;
case S_IFLNK:
if (symlink(file_entry->link_name, full_name) < 0) {
if ((function & extract_quiet) != extract_quiet) {
perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name);
}
return NULL;
}
break;
case S_IFSOCK:
case S_IFBLK:
case S_IFCHR:
case S_IFIFO:
if (mknod(full_name, file_entry->mode, file_entry->device) == -1) {
if ((function & extract_quiet) != extract_quiet) {
perror_msg("Cannot create node %s", file_entry->name);
}
return NULL;
}
break;
}
/* Changing a symlink's properties normally changes the properties of the
* file pointed to, so dont try and change the date or mode, lchown does
* does the right thing, but isnt available in older versions of libc */
if (S_ISLNK(file_entry->mode)) {
#if (__GLIBC__ > 2) && (__GLIBC_MINOR__ > 1)
lchown(full_name, file_entry->uid, file_entry->gid);
#endif
} else {
if (function & extract_preserve_date) {
t.actime = file_entry->mtime;
t.modtime = file_entry->mtime;
utime(full_name, &t);
}
chmod(full_name, file_entry->mode);
chown(full_name, file_entry->uid, file_entry->gid);
}
} else {
/* If we arent extracting data we have to skip it,
* if data size is 0 then then just do it anyway
* (saves testing for it) */
seek_sub_file(src_stream, file_entry->size);
}
/* extract_list and extract_verbose_list can be used in conjunction
* with one of the above four extraction functions, so do this seperately */
if (function & extract_verbose_list) {
fprintf(out_stream, "%s %d/%d %8d %s ", mode_string(file_entry->mode),
file_entry->uid, file_entry->gid,
(int) file_entry->size, time_string(file_entry->mtime));
}
if ((function & extract_list) || (function & extract_verbose_list)){
/* fputs doesnt add a trailing \n, so use fprintf */
fprintf(out_stream, "%s\n", full_name);
}
free(full_name);
return(NULL); /* Maybe we should say if failed */
}
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *),
const int extract_function, const char *prefix, char **include_name, char **exclude_name)
{
file_header_t *file_entry;
int extract_flag = TRUE;
int i;
char *buffer = NULL;
archive_offset = 0;
while ((file_entry = get_headers(src_stream)) != NULL) {
if (include_name != NULL) {
extract_flag = FALSE;
for(i = 0; include_name[i] != 0; i++) {
if (fnmatch(include_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
extract_flag = TRUE;
break;
}
}
} else {
extract_flag = TRUE;
}
/* If the file entry is in the exclude list dont extract it */
if (exclude_name != NULL) {
for(i = 0; exclude_name[i] != 0; i++) {
if (fnmatch(exclude_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
extract_flag = FALSE;
break;
}
}
}
if (extract_flag == TRUE) {
buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
} else {
/* seek past the data entry */
seek_sub_file(src_stream, file_entry->size);
}
free(file_entry->name);
free(file_entry->link_name);
free(file_entry);
}
return(buffer);
}
File diff suppressed because it is too large. Load diff
+90
View File
@@ -0,0 +1,90 @@
/* vi: set sw=4 ts=4: */
/*
* Mini rpm2cpio 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 "busybox.h"
#include <netinet/in.h> /* For ntohl & htonl function */
#include <string.h>
#define RPM_MAGIC "\355\253\356\333"
#define RPM_HEADER_MAGIC "\216\255\350"
struct rpm_lead {
unsigned char magic[4];
u_int8_t major, minor;
u_int16_t type;
u_int16_t archnum;
char name[66];
u_int16_t osnum;
u_int16_t signature_type;
char reserved[16];
};
struct rpm_header {
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
u_int8_t version; /* 1 byte version number */
u_int32_t reserved; /* 4 bytes reserved */
u_int32_t entries; /* Number of entries in header (4 bytes) */
u_int32_t size; /* Size of store (4 bytes) */
};
void skip_header(FILE *rpmfile)
{
struct rpm_header header;
fread(&header, sizeof(struct rpm_header), 1, rpmfile);
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
if (header.version != 1) error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
header.entries = ntohl(header.entries);
header.size = ntohl(header.size);
fseek (rpmfile, 16 * header.entries, SEEK_CUR); /* Seek past index entries */
fseek (rpmfile, header.size, SEEK_CUR); /* Seek past store */
}
/* No getopt required */
extern int rpm2cpio_main(int argc, char **argv)
{
struct rpm_lead lead;
int gunzip_pid;
FILE *rpmfile, *cpiofile;
if (argc == 1) {
rpmfile = stdin;
} else {
rpmfile = xfopen(argv[1], "r");
/* set the buffer size */
setvbuf(rpmfile, NULL, _IOFBF, 0x8000);
}
fread (&lead, sizeof(struct rpm_lead), 1, rpmfile);
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
/* Skip the signature header */
skip_header(rpmfile);
fseek(rpmfile, (8 - (ftell(rpmfile) % 8)) % 8, SEEK_CUR); /* Pad to 8 byte boundary */
/* Skip the main header */
skip_header(rpmfile);
cpiofile = gz_open(rpmfile, &gunzip_pid);
copyfd(fileno(cpiofile), fileno(stdout));
gz_close(gunzip_pid);
fclose(rpmfile);
return 0;
}
+321 -751
View File
File diff suppressed because it is too large. Load diff
-199
View File
@@ -1,199 +0,0 @@
/* vi: set sw=4 ts=4: */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
#ifdef BB_LOCALE_SUPPORT
#include <locale.h>
#endif
int been_there_done_that = 0; /* Also used in applets.c */
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
"/",
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
};
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/*
* Where in the filesystem is this busybox?
* [return]
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
}
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char *fpc;
int i;
int rc;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
fpc = concat_path_file(
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, fpc);
if (rc!=0 && errno!=EEXIST) {
perror_msg("%s", fpc);
}
free(fpc);
}
}
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
const char *s;
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
applet_name = "sh";
}
#endif
#ifdef BB_LOCALE_SUPPORT
if(getpid()!=1) /* Do not set locale for `init' */
setlocale(LC_ALL, "");
#endif
run_applet_by_name(applet_name, argc, argv);
error_msg_and_die("applet not found");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
* If someone has a cleaner approach, by all means implement it.
*/
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
int use_symbolic_links = 0;
int rc = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
if (argc > 2) {
if ((strcmp(argv[2], "-s") == 0)) {
use_symbolic_links = 1;
}
}
/* link */
busybox = busybox_fullpath();
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
} else {
rc = 1;
}
return rc;
}
#endif /* BB_FEATURE_INSTALLER */
argc--;
/* If we've already been here once, exit now */
if (been_there_done_that == 1 || argc < 1) {
const struct BB_applet *a = applets;
fprintf(stderr, "%s\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use, and BusyBox\n"
"\twill act like whatever it was invoked as.\n"
"\nCurrently defined functions:\n", full_version);
while (a->name != 0) {
col +=
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
(a++)->name);
if (col > 60 && a->name != 0) {
fprintf(stderr, ",\n");
col = 0;
}
}
fprintf(stderr, "\n\n");
exit(0);
}
/* Flag that we've been here already */
been_there_done_that = 1;
/* Move the command line down a notch */
len = argv[argc] + strlen(argv[argc]) - argv[1];
memmove(argv[0], argv[1], len);
memset(argv[0] + len, 0, argv[1] - argv[0]);
/* Fix up the argv pointers */
len = argv[1] - argv[0];
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
for (i = 0; i < argc; i++)
argv[i] -= len;
return (main(argc, argv));
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-98
View File
@@ -1,98 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Busybox main internal header 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
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
*/
#ifndef _BB_INTERNAL_H_
#define _BB_INTERNAL_H_ 1
#include "Config.h"
#include <stdio.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#include <features.h>
enum Location {
_BB_DIR_ROOT = 0,
_BB_DIR_BIN,
_BB_DIR_SBIN,
_BB_DIR_USR_BIN,
_BB_DIR_USR_SBIN
};
struct BB_applet {
const char* name;
int (*main)(int argc, char** argv);
enum Location location;
};
/* From busybox.c */
extern const struct BB_applet applets[];
/* Automagically pull in all the applet function prototypes and
* applet usage strings. These are all of the form:
* extern int foo_main(int argc, char **argv);
* extern const char foo_usage[];
* These are all autogenerated from the set of currently defined applets.
*/
#define PROTOTYPES
#include "applets.h"
#undef PROTOTYPES
extern const char *applet_name;
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
#endif
/* Bit map related macros -- libc5 doens't provide these... sigh. */
#ifndef setbit
#define NBBY CHAR_BIT
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
#endif
#ifndef RB_POWER_OFF
/* Stop system and switch power off if possible. */
#define RB_POWER_OFF 0x4321fedc
#endif
/* Pull in the utility routines from libbb */
#include "libbb/libbb.h"
#endif /* _BB_INTERNAL_H_ */
-24
View File
@@ -1,24 +0,0 @@
#!/bin/sh
# Make busybox links list file.
# input $1: full path to Config.h
# input $2: full path to applets.h
# output (stdout): list of pathnames that should be linked to busybox
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
export LC_ALL=POSIX
export LC_CTYPE=POSIX
CONFIG_H=${1:-Config.h}
APPLETS_H=${2:-applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
dir=substr($2,8)
gsub("_","/",dir)
if(dir=="/ROOT") dir=""
file=$3
gsub("\"","",file)
if (file=="busybox") next
print tolower(dir) "/" file
}'
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh
export LC_ALL=POSIX
export LC_CTYPE=POSIX
RAW=` \
gcc -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
# By running $RAW through "ls", we avoid listing
# source files that don't exist.
ls $RAW 2>/dev/null | tr '\n' ' '
-36
View File
@@ -1,36 +0,0 @@
Name: busybox
Version: 0.51
Release: 1
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
Copyright: GPL
Packager : Erik Andersen <andersen@lineo.com>
Conflicts: fileutils grep shellutils
Buildroot: /tmp/%{Name}-%{Version}
Source: %{Name}-%{Version}.tar.gz
%Description
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for most of the utilities
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
tar, etc. BusyBox provides a fairly complete POSIX environment for any small
or emdedded system. The utilities in BusyBox generally have fewer options then
their full featured GNU cousins; however, the options that are provided behave
very much like their GNU counterparts.
%Prep
%setup -q -n %{Name}-%{Version}
%Build
make
%Install
rm -rf $RPM_BUILD_ROOT
make PREFIX=$RPM_BUILD_ROOT install
%Clean
rm -rf $RPM_BUILD_ROOT
%Files
%defattr(-,root,root)
/
-167
View File
@@ -1,167 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_option
#define bb_need_too_few_args
#include "messages.c"
static long uid = -1;
static long gid = -1;
static int whichApp;
static char *theMode = NULL;
#define CHGRP_APP 1
#define CHOWN_APP 2
#define CHMOD_APP 3
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
switch (whichApp) {
case CHGRP_APP:
case CHOWN_APP:
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
if (lchown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#else
if (chown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#endif
{
return (TRUE);
}
break;
case CHMOD_APP:
/* Parse the specified modes */
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
error_msg_and_die( "unknown mode: %s", theMode);
}
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
break;
}
perror(fileName);
return (FALSE);
}
int chmod_chown_chgrp_main(int argc, char **argv)
{
int stopIt = FALSE;
int recursiveFlag = FALSE;
char *groupName=NULL;
char *p=NULL;
whichApp = (applet_name[2]=='o')? /* chown */
CHOWN_APP : (applet_name[2]=='m')? /* chmod */
CHMOD_APP : CHGRP_APP;
if (argc < 2)
show_usage();
argv++;
/* Parse options */
while (--argc >= 0 && *argv && (**argv == '-')) {
while (stopIt==FALSE && *++(*argv)) {
switch (**argv) {
case 'R':
recursiveFlag = TRUE;
break;
default:
theMode=*argv-1;
stopIt = TRUE;
}
}
if (stopIt==TRUE)
break;
argv++;
}
if (argc == 0 || *argv == NULL) {
error_msg(too_few_args);
}
if (whichApp == CHMOD_APP) {
if (theMode==NULL)
theMode = *argv;
} else {
/* Find the selected group */
if (whichApp == CHGRP_APP) {
groupName = *argv;
gid = strtoul(groupName, &p, 10); /* maybe it's already numeric */
if (groupName == p)
gid = my_getgrnam(groupName);
} else {
groupName = strchr(*argv, '.');
if (groupName == NULL)
groupName = strchr(*argv, ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
} else
gid = -1;
}
/* Find the selected user (if appropriate) */
if (whichApp == CHOWN_APP) {
uid = strtoul(*argv, &p, 10); /* if numeric ... */
if (*argv == p)
uid = my_getpwnam(*argv);
}
}
/* Ok, ready to do the deed now */
if (argc < 1) {
error_msg_and_die(too_few_args);
}
while (argc-- > 1) {
if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE)
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-72
View File
@@ -1,72 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include "busybox.h"
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
show_usage();
}
argc--;
argv++;
if (chroot(*argv) || (chdir("/"))) {
perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
argv++;
if (argc >= 1) {
prog = *argv;
execvp(*argv, argv);
} else {
#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
shell_main(argc, argv);
return EXIT_SUCCESS;
#endif
}
perror_msg_and_die("cannot execute %s", prog);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-43
View File
@@ -1,43 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* chvt.c - aeb - 940227 - Change virtual terminal
*
* busyboxed by Erik Andersen
*/
/* getopt not needed */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
static const int VT_ACTIVATE = 0x5606; /* make vt active */
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
int chvt_main(int argc, char **argv)
{
int fd, num;
if ((argc != 2) || (**(argv + 1) == '-'))
show_usage();
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num))
perror_msg_and_die("VT_ACTIVATE");
if (ioctl(fd, VT_WAITACTIVE, num))
perror_msg_and_die("VT_WAITACTIVE");
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-1536
View File
File diff suppressed because it is too large. Load diff
-14
View File
@@ -1,14 +0,0 @@
#ifndef CMDEDIT_H
#define CMDEDIT_H
#ifdef BB_FEATURE_COMMAND_EDITING
#include <stddef.h>
#include "busybox.h"
void cmdedit_init(void);
void cmdedit_terminate(void);
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
#endif /* BB_FEATURE_COMMAND_EDITING */
#endif /* CMDEDIT_H */
-66
View File
@@ -1,66 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cmp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 <string.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1 = argv[1], *filename2 = "-";
int c1, c2, char_pos = 1, line_pos = 1;
/* parse argv[] */
if (argc < 2 || 3 < argc)
show_usage();
fp1 = xfopen(argv[1], "r");
if (argv[2] != NULL) {
fp2 = xfopen(argv[2], "r");
filename2 = argv[2];
}
do {
c1 = fgetc(fp1);
c2 = fgetc(fp2);
if (c1 != c2) {
if (c1 == EOF)
printf("EOF on %s\n", filename1);
else if (c2 == EOF)
printf("EOF on %s\n", filename2);
else
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
char_pos, line_pos);
return EXIT_FAILURE;
}
char_pos++;
if (c1 == '\n')
line_pos++;
} while (c1 != EOF);
return EXIT_SUCCESS;
}
+43
View File
@@ -0,0 +1,43 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 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
#
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
clean:
rm -f $(L_TARGET) *.o core
+2 -3
View File
@@ -2,9 +2,8 @@
/*
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
+18
View File
@@ -0,0 +1,18 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
mainmenu_option next_comment
comment 'Console Utilities'
bool 'chvt' CONFIG_CHVT
bool 'clear' CONFIG_CLEAR
bool 'deallocvt' CONFIG_DEALLOCVT
bool 'dumpkmap' CONFIG_DUMPKMAP
bool 'loadacm' CONFIG_LOADACM
bool 'loadfont' CONFIG_LOADFONT
bool 'loadkmap' CONFIG_LOADKMAP
bool 'reset' CONFIG_RESET
bool 'setkeycodes' CONFIG_SETKEYCODES
endmenu
+2 -2
View File
@@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
show_usage();
}
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
perror_msg("Error opening /dev/tty0");
perror_msg("Error opening " CURRENT_VC);
return EXIT_FAILURE;
}
+2 -2
View File
@@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
show_usage();
}
fd = open("/dev/tty", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
perror_msg_and_die("Error opening /dev/tty1");
perror_msg_and_die("Error opening " CURRENT_VC);
}
if (screen_map_load(fd, stdin)) {
+2 -2
View File
@@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
perror_msg_and_die("Error opening " CURRENT_VC);
loadnewfont(fd);
return EXIT_SUCCESS;
+2 -2
View File
@@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
perror_msg_and_die("Error opening " CURRENT_VC);
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
+3 -4
View File
@@ -2,10 +2,9 @@
/*
* Mini reset implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* and Kent Robotti <robotti@metconnect.com>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+4 -4
View File
@@ -2,8 +2,8 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
@@ -44,9 +44,9 @@ extern int basename_main(int argc, char **argv)
argv++;
n = strlen(*argv);
m = strlen(s);
if (m>=n && strncmp(s+m-n, *argv, n)==0)
if (m>n && strncmp(s+m-n, *argv, n)==0)
s[m-n] = '\0';
}
printf("%s\n", s);
puts(s);
return EXIT_SUCCESS;
}
+2 -2
View File
@@ -2,8 +2,8 @@
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
+90
View File
@@ -0,0 +1,90 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chgrp implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
#define lchown chown
#endif
static long gid;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (lchown(fileName, statbuf->st_uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
return (TRUE);
}
perror(fileName);
return (FALSE);
}
int chgrp_main(int argc, char **argv)
{
int opt;
int recursiveFlag = FALSE;
char *p=NULL;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "R")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
default:
show_usage();
}
}
if (argc > optind && argc > 2 && argv[optind]) {
/* Find the selected group */
gid = strtoul(argv[optind], &p, 10); /* maybe it's already numeric */
if (argv[optind] == p)
gid = my_getgrnam(argv[optind]);
} else {
error_msg_and_die(too_few_args);
}
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+84
View File
@@ -0,0 +1,84 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chmod implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include "busybox.h"
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (!parse_mode((char *)junk, &(statbuf->st_mode)))
error_msg_and_die("internal error");
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
perror(fileName);
return (FALSE);
}
int chmod_main(int argc, char **argv)
{
int i;
int opt;
int recursiveFlag = FALSE;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "R")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
default:
show_usage();
}
}
if (argc > optind && argc > 2 && argv[optind]) {
/* Parse the specified mode */
mode_t mode;
if (parse_mode(argv[optind], &mode) == FALSE) {
error_msg_and_die( "unknown mode: %s", argv[optind]);
}
} else {
error_msg_and_die(too_few_args);
}
/* 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) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+112
View File
@@ -0,0 +1,112 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
#define lchown chown
#endif
static long uid;
static long gid;
static int (*chown_func)(const char *, __uid_t, __gid_t) = chown;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
return (TRUE);
}
perror(fileName);
return (FALSE);
}
int chown_main(int argc, char **argv)
{
int opt;
int recursiveFlag = FALSE,
noderefFlag = FALSE;
char *groupName=NULL;
char *p=NULL;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Rh")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
case 'h':
noderefFlag = TRUE;
break;
default:
show_usage();
}
}
if (noderefFlag) chown_func = lchown;
if (argc > optind && argc > 2 && argv[optind]) {
/* First, check if there is a group name here */
groupName = strchr(argv[optind], '.');
if (groupName == NULL)
groupName = strchr(argv[optind], ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
} else {
gid = -1;
}
/* Now check for the username */
uid = strtoul(argv[optind], &p, 10); /* Is is numeric? */
if (argv[optind] == p) {
uid = my_getpwnam(argv[optind]);
}
} else {
error_msg_and_die(too_few_args);
}
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+9 -7
View File
@@ -2,9 +2,8 @@
/*
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
@@ -48,14 +47,17 @@ int chroot_main(int argc, char **argv)
prog = *argv;
execvp(*argv, argv);
} else {
#ifndef BB_SH
#if defined shell_main && defined CONFIG_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#else
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
shell_main(argc, argv);
return EXIT_SUCCESS;
#endif
}
perror_msg_and_die("cannot execute %s", prog);
+24 -12
View File
@@ -2,9 +2,7 @@
/*
* Mini cmp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
* Copyright (C) 2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,28 +24,42 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <getopt.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1 = argv[1], *filename2 = "-";
int c1, c2, char_pos = 1, line_pos = 1;
char *filename1, *filename2 = "-";
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
/* parse argv[] */
if (argc < 2 || 3 < argc)
show_usage();
while ((c = getopt(argc, argv, "s")) != EOF) {
switch (c) {
case 's':
silent = TRUE;
break;
default:
show_usage();
}
}
fp1 = xfopen(argv[1], "r");
if (argv[2] != NULL) {
fp2 = xfopen(argv[2], "r");
filename2 = argv[2];
filename1 = argv[optind];
switch (argc - optind) {
case 2:
fp2 = xfopen(filename2 = argv[optind + 1], "r");
case 1:
fp1 = xfopen(filename1, "r");
break;
default:
show_usage();
}
do {
c1 = fgetc(fp1);
c2 = fgetc(fp2);
if (c1 != c2) {
if (silent)
return EXIT_FAILURE;
if (c1 == EOF)
printf("EOF on %s\n", filename1);
else if (c2 == EOF)
+114
View File
@@ -0,0 +1,114 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cp implementation for busybox
*
*
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <utime.h>
#include <errno.h>
#include <dirent.h>
#include <stdlib.h>
#include "busybox.h"
extern int cp_main(int argc, char **argv)
{
int status = 0;
int opt;
int flags = FILEUTILS_DEREFERENCE;
int i;
while ((opt = getopt(argc, argv, "adfipR")) != -1)
switch (opt) {
case 'a':
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
/* fallthrough */
case 'd':
flags &= ~FILEUTILS_DEREFERENCE;
break;
case 'f':
flags |= FILEUTILS_FORCE;
break;
case 'i':
flags |= FILEUTILS_INTERACTIVE;
break;
case 'p':
flags |= FILEUTILS_PRESERVE_STATUS;
break;
case 'R':
flags |= FILEUTILS_RECUR;
break;
default:
show_usage();
}
if (optind + 2 > argc)
show_usage();
/* If there are only two arguments and... */
if (optind + 2 == argc) {
struct stat source_stat;
struct stat dest_stat;
int source_exists = 1;
int dest_exists = 1;
if ((!(flags & FILEUTILS_DEREFERENCE) &&
lstat(argv[optind], &source_stat) < 0) ||
((flags & FILEUTILS_DEREFERENCE) &&
stat(argv[optind], &source_stat))) {
if (errno != ENOENT)
perror_msg_and_die("unable to stat `%s'", argv[optind]);
source_exists = 0;
}
if (stat(argv[optind + 1], &dest_stat) < 0) {
if (errno != ENOENT)
perror_msg_and_die("unable to stat `%s'", argv[optind + 1]);
dest_exists = 0;
}
/* ...if neither is a directory or... */
if (((!source_exists || !S_ISDIR(source_stat.st_mode)) &&
(!dest_exists || !S_ISDIR(dest_stat.st_mode))) ||
/* ...recursing, the first is a directory, and the
* second doesn't exist, then... */
((flags & FILEUTILS_RECUR) && S_ISDIR(source_stat.st_mode) &&
!dest_exists)) {
/* ...do a simple copy. */
if (copy_file(argv[optind], argv[optind + 1], flags) < 0)
status = 1;
return status;
}
}
for (i = optind; i < argc - 1; i++) {
char *dest = concat_path_file(argv[argc - 1],
get_last_path_component(argv[i]));
if (copy_file(argv[i], dest, flags) < 0)
status = 1;
free(dest);
}
return status;
}
+238 -128
View File
@@ -24,8 +24,7 @@
#include <stdlib.h>
#include <unistd.h> /* getopt */
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include "busybox.h"
@@ -34,65 +33,228 @@ extern int optind;
extern char *optarg;
/* globals in this file only */
/* option vars */
static char part = 0; /* (b)yte, (c)har, (f)ields */
static int startpos = 1;
static int endpos = -1;
static char delim = '\t'; /* delimiter, default is tab */
static unsigned int supress_non_delimited_lines = 0;
static char delim = '\t'; /* delimiter, default is tab */
struct cut_list {
int startpos;
int endpos;
};
static const int BOL = 0;
static const int EOL = INT_MAX;
static const int NON_RANGE = -1;
static struct cut_list *cut_lists = NULL; /* growable array holding a series of lists */
static unsigned int nlists = 0; /* number of elements in above list */
static int cmpfunc(const void *a, const void *b)
{
struct cut_list *la = (struct cut_list *)a;
struct cut_list *lb = (struct cut_list *)b;
if (la->startpos > lb->startpos)
return 1;
if (la->startpos < lb->startpos)
return -1;
return 0;
}
/*
* decompose_list() - parses a list and puts values into startpos and endpos.
* parse_lists() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
* more than one list can be seperated by commas
*/
static void decompose_list(const char *list)
static void parse_lists(char *lists)
{
unsigned int nminus = 0;
char *ptr;
char *ltok = NULL;
char *ntok = NULL;
char *junk;
int s = 0, e = 0;
/* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') {
error_msg_and_die("invalid byte or field list");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
/* take apart the lists, one by one (they are seperated with commas */
while ((ltok = strsep(&lists, ",")) != NULL) {
/* it's actually legal to pass an empty list */
if (strlen(ltok) == 0)
continue;
/* get the start pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
fprintf(stderr, "Help ntok is null for starting position! What do I do?\n");
} else if (strlen(ntok) == 0) {
s = BOL;
} else {
s = strtoul(ntok, &junk, 10);
if(*junk != '\0' || s < 0)
error_msg_and_die("invalid byte or field list");
/* account for the fact that arrays are zero based, while the user
* expects the first char on the line to be char # 1 */
if (s != 0)
s--;
}
/* get the end pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
e = NON_RANGE;
} else if (strlen(ntok) == 0) {
e = EOL;
} else {
e = strtoul(ntok, &junk, 10);
if(*junk != '\0' || e < 0)
error_msg_and_die("invalid byte or field list");
/* if the user specified and end position of 0, that means "til the
* end of the line */
if (e == 0)
e = INT_MAX;
e--; /* again, arrays are zero based, lines are 1 based */
if (e == s)
e = NON_RANGE;
}
/* if there's something left to tokenize, the user past an invalid list */
if (ltok)
error_msg_and_die("invalid byte or field list");
/* add the new list */
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
cut_lists[nlists-1].startpos = s;
cut_lists[nlists-1].endpos = e;
}
/* make sure we got some cut positions out of all that */
if (nlists == 0)
error_msg_and_die("missing list of positions");
/* now that the lists are parsed, we need to sort them to make life easier
* on us when it comes time to print the chars / fields / lines */
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
}
static void cut_line_by_chars(const char *line)
{
int c, l;
/* set up a list so we can keep track of what's been printed */
char *printed = xcalloc(strlen(line), sizeof(char));
/* print the chars specified in each cut list */
for (c = 0; c < nlists; c++) {
l = cut_lists[c].startpos;
while (l < strlen(line)) {
if (!printed[l]) {
putchar(line[l]);
printed[l] = 'X';
}
l++;
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos)
break;
}
}
putchar('\n'); /* cuz we were handed a chomped line */
free(printed);
}
static void cut_line_by_fields(char *line)
{
int c, f;
int ndelim = -1; /* zero-based / one-based problem */
int nfields_printed = 0;
char *field = NULL;
char d[2] = { delim, 0 };
char *printed;
/* test the easy case first: does this line contain any delimiters? */
if (strchr(line, delim) == NULL) {
if (!supress_non_delimited_lines)
puts(line);
return;
}
/* set up a list so we can keep track of what's been printed */
printed = xcalloc(strlen(line), sizeof(char));
/* process each list on this line, for as long as we've got a line to process */
for (c = 0; c < nlists && line; c++) {
f = cut_lists[c].startpos;
do {
/* find the field we're looking for */
while (line && ndelim < f) {
field = strsep(&line, d);
ndelim++;
}
/* we found it, and it hasn't been printed yet */
if (field && ndelim == f && !printed[ndelim]) {
/* if this isn't our first time through, we need to print the
* delimiter after the last field that was printed */
if (nfields_printed > 0)
putchar(delim);
fputs(field, stdout);
printed[ndelim] = 'X';
nfields_printed++;
}
f++;
/* keep going as long as we have a line to work with, this is a
* list, and we're not at the end of that list */
} while (line && cut_lists[c].endpos != NON_RANGE && f <= cut_lists[c].endpos);
}
/* if we printed anything at all, we need to finish it with a newline cuz
* we were handed a chomped line */
putchar('\n');
free(printed);
}
static void cut_file_by_lines(const char *line, unsigned int linenum)
{
static int c = 0;
static int l = -1;
/* I can't initialize this above cuz the "initializer isn't
* constant" *sigh* */
if (l == -1)
l = cut_lists[c].startpos;
/* get out if we have no more lists to process or if the lines are lower
* than what we're interested in */
if (c >= nlists || linenum < l)
return;
/* if the line we're looking for is lower than the one we were passed, it
* means we displayed it already, so move on */
while (l < linenum) {
l++;
/* move on to the next list if we're at the end of this one */
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos) {
c++;
/* get out if there's no more lists to process */
if (c >= nlists)
return;
l = cut_lists[c].startpos;
/* get out if the current line is lower than the one we just became
* interested in */
if (linenum < l)
return;
}
}
/* handle single value 'N' case */
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
error_msg_and_die("missing list of fields");
}
endpos = startpos;
}
/* handle multi-value cases */
else if (nminus == 1) {
/* handle 'N-' case */
if (list[strlen(list) - 1] == '-') {
startpos = strtol(list, &ptr, 10);
}
/* handle '-M' case */
else if (list[0] == '-') {
endpos = strtol(&list[1], NULL, 10);
}
/* handle 'N-M' case */
else {
startpos = strtol(list, &ptr, 10);
endpos = strtol(ptr+1, &ptr, 10);
}
/* a sanity check */
if (startpos == 0) {
startpos = 1;
}
}
/* If we made it here, it means we've found the line we're looking for, so print it */
puts(line);
}
@@ -101,82 +263,31 @@ static void decompose_list(const char *list)
*/
static void cut_file(FILE *file)
{
char *line;
unsigned int cr_hits = 0;
char *line = NULL;
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
/* cut based on chars/bytes */
if (part == 'c' || part == 'b') {
int i;
/* a valid end position has been specified */
if (endpos > 0) {
for (i = startpos-1; i < endpos; i++) {
fputc(line[i], stdout);
}
fputc('\n', stdout);
}
/* otherwise, just go to the end of the line */
else {
for (i = startpos-1; line[i]; i++) {
fputc(line[i], stdout);
}
}
}
while ((line = get_line_from_file(file)) != NULL) {
chomp(line);
/* cut based on chars/bytes XXX: only works when sizeof(char) == byte */
if (part == 'c' || part == 'b')
cut_line_by_chars(line);
/* cut based on fields */
else if (part == 'f') {
char *ptr;
char *start = line;
unsigned int delims_hit = 0;
if (delim == '\n') {
cr_hits++;
if (cr_hits >= startpos && cr_hits <= endpos) {
while (*start && *start != '\n') {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
}
else {
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
delims_hit++;
if (delims_hit == (startpos - 1)) {
start = ptr+1;
}
if (delims_hit == endpos) {
break;
}
}
/* we didn't hit any delimeters */
if (delims_hit == 0 && !supress_non_delimited_lines) {
fputs(line, stdout);
}
/* we =did= hit some delimiters */
else if (delims_hit > 0) {
/* we have a fixed end point */
if (ptr) {
while (start < ptr) {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
/* or we're just going til the end of the line */
else {
while (*start) {
fputc(*start, stdout);
start++;
}
}
}
}
if (delim == '\n')
cut_file_by_lines(line, linenum);
else
cut_line_by_fields(line);
}
linenum++;
free(line);
}
}
extern int cut_main(int argc, char **argv)
{
int opt;
@@ -191,7 +302,7 @@ extern int cut_main(int argc, char **argv)
error_msg_and_die("only one type of list may be specified");
}
part = (char)opt;
decompose_list(optarg);
parse_lists(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
@@ -212,14 +323,15 @@ extern int cut_main(int argc, char **argv)
error_msg_and_die("you must specify a list of bytes, characters, or fields");
}
if (supress_non_delimited_lines && part != 'f') {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
/* non-field (char or byte) cutting has some special handling */
if (part != 'f') {
if (supress_non_delimited_lines) {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
}
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
@@ -232,10 +344,8 @@ extern int cut_main(int argc, char **argv)
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
perror_msg("%s", argv[i]);
} else {
file = wfopen(argv[i], "r");
if(file) {
cut_file(file);
fclose(file);
}
+2 -6
View File
@@ -29,10 +29,6 @@
#include <string.h>
#include <getopt.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
#include "messages.c"
/* This 'date' command supports only 2 time setting formats,
@@ -203,7 +199,7 @@ int date_main(int argc, char **argv)
date_conv_time(&tm_time, date_str);
}
/* Correct any day of week and day of year etc fields */
/* Correct any day of week and day of year etc. fields */
tm = mktime(&tm_time);
if (tm < 0)
error_msg_and_die(invalid_date, date_str);
@@ -245,7 +241,7 @@ int date_main(int argc, char **argv)
/* Print OUTPUT (after ALL that!) */
t_buff = xmalloc(201);
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
puts(t_buff);
return EXIT_SUCCESS;
}
+2 -6
View File
@@ -50,7 +50,6 @@ int dd_main(int argc, char **argv)
size_t bs = 512, count = -1;
ssize_t n;
off_t seek = 0, skip = 0;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
for (i = 1; i < argc; i++) {
@@ -110,12 +109,9 @@ int dd_main(int argc, char **argv)
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
}
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
if (skip) {
@@ -151,8 +147,8 @@ int dd_main(int argc, char **argv)
out_part++;
}
fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
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);
return EXIT_SUCCESS;
}
+15 -28
View File
@@ -2,8 +2,8 @@
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@
#include "busybox.h"
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
static unsigned long df_disp_hr = KILOBYTE;
#endif
@@ -40,9 +40,6 @@ static int do_df(char *device, const char *mount_point)
struct statfs s;
long blocks_used;
long blocks_percent_used;
#ifdef BB_FEATURE_HUMAN_READABLE
long base;
#endif
if (statfs(mount_point, &s) != 0) {
perror_msg("%s", mount_point);
@@ -60,30 +57,20 @@ static int do_df(char *device, const char *mount_point)
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
find_real_root_device_name( device);
}
#ifdef BB_FEATURE_HUMAN_READABLE
switch (df_disp_hr) {
case MEGABYTE:
base = KILOBYTE;
break;
case KILOBYTE:
base = 1;
break;
default:
base = 0;
device = find_real_root_device_name(device);
if(device==NULL)
return FALSE;
}
#ifdef CONFIG_FEATURE_HUMAN_READABLE
printf("%-20s %9s ", device,
make_human_readable_str((unsigned long)(s.f_blocks *
(s.f_bsize/(double)KILOBYTE)), base));
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str((unsigned long)(
(s.f_blocks - s.f_bfree) *
(s.f_bsize/(double)KILOBYTE)), base));
make_human_readable_str( (s.f_blocks - s.f_bfree), s.f_bsize, df_disp_hr));
printf("%9s %3ld%% %s\n",
make_human_readable_str((unsigned long)(s.f_bavail *
(s.f_bsize/(double)KILOBYTE)), base),
blocks_percent_used, mount_point);
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
@@ -105,13 +92,13 @@ extern int df_main(int argc, char **argv)
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
while ((opt = getopt(argc, argv, "k"
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
"hm"
#endif
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
case 'h':
df_disp_hr = 0;
strcpy(disp_units_hdr, " Size");
+4 -14
View File
@@ -2,8 +2,8 @@
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
@@ -30,21 +30,11 @@
extern int dirname_main(int argc, char **argv)
{
char* s;
if ((argc < 2) || (**(argv + 1) == '-'))
show_usage();
argv++;
s=*argv+strlen(*argv)-1;
while (s != *argv && *s == '/') {
*s-- = '\0';
}
s = strrchr(*argv, '/');
if (s != NULL && s == *argv)
s[1] = '\0';
else if (s != NULL)
*s = '\0';
puts(s ? *argv : ".");
puts (dirname (argv[0]));
return EXIT_SUCCESS;
}
+131 -89
View File
@@ -27,23 +27,146 @@
* See the COPYING file for license information.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/time.h>
#include "busybox.h"
#define CT_AUTO 0
#define CT_UNIX2DOS 1
#define CT_DOS2UNIX 2
/* We are making a lame pseudo-random string generator here. in
* convert(), each pass through the while loop will add more and more
* stuff into value, which is _supposed_ to wrap. We don't care about
* it being accurate. We care about it being messy, since we then mod
* it by the sizeof(letters) and then use that as an index into letters
* to pick a random letter to add to out temporary file. */
typedef unsigned long int bb_uint64_t;
int convert(char *fn, int ConvType);
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int dos2unix_main(int argc, char *argv[]) {
// if fn is NULL then input is stdin and output is stdout
static int convert(char *fn, int ConvType)
{
int c, fd;
struct timeval tv;
char tempFn[BUFSIZ];
static bb_uint64_t value=0;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = wfopen(fn, "rw")) == NULL) {
return -1;
}
strcpy(tempFn, fn);
c = strlen(tempFn);
tempFn[c] = '.';
while(1) {
if (c >=BUFSIZ)
error_msg_and_die("unique name not found");
/* Get some semi random stuff to try and make a
* random filename based (and in the same dir as)
* the input file... */
gettimeofday (&tv, NULL);
value += ((bb_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
tempFn[++c] = letters[value % 62];
tempFn[c+1] = '\0';
value /= 62;
if ((fd = open(tempFn, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0 ) {
continue;
}
out = fdopen(fd, "w+");
if (!out) {
close(fd);
remove(tempFn);
continue;
}
break;
}
}
while ((c = fgetc(in)) != EOF) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
remove(tempFn);
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_DOS2UNIX;
break;
}
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
remove(tempFn);
if ((fclose(in) < 0) || (fclose(out) < 0)) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType) {
ConvType = CT_UNIX2DOS;
}
if (ConvType == CT_UNIX2DOS) {
fputc('\r', out);
}
fputc('\n', out);
break;
}
fputc(c, out);
}
if (c != EOF)
while ((c = fgetc(in)) != EOF) {
if (c == '\r')
continue;
if (c == '\n') {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(c, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
remove(tempFn);
return -2;
}
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(tempFn, fn) < 0) {
perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
return -1;
}
}
return 0;
}
int dos2unix_main(int argc, char *argv[])
{
int ConvType = CT_AUTO;
int o;
//See if we are supposed to be doing dos2unix or unix2dos
if (argv[0][0]=='d') {
ConvType = CT_DOS2UNIX;
}
if (argv[0][0]=='u') {
ConvType = CT_UNIX2DOS;
}
// process parameters
while ((o = getopt(argc, argv, "du")) != EOF) {
switch (o) {
@@ -69,84 +192,3 @@ int dos2unix_main(int argc, char *argv[]) {
return o;
}
// if fn is NULL then input is stdin and output is stdout
int convert(char *fn, int ConvType) {
char c;
char *tempFn = NULL;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = fopen(fn, "r")) == NULL) {
perror_msg(fn);
return -1;
}
tempFn = tmpnam(NULL);
if (tempFn == NULL || (out = fopen(tempFn, "w")) == NULL) {
perror_msg(NULL);
return -2;
}
}
while ((c = fgetc(in)) != EOF) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_DOS2UNIX;
break;
}
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_UNIX2DOS;
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
break;
}
fputc(c, out);
}
if (c != EOF)
while ((c = fgetc(in)) != EOF) {
if (c == '\r')
continue;
if (c == '\n') {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(c, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0 ||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
perror_msg(NULL);
return -2;
}
while ((c = fgetc(in)) != EOF)
fputc(c, out);
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
}
return 0;
}
+87 -33
View File
@@ -2,9 +2,8 @@
/*
* Mini du implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Copyright (C) 1999,2000,2001 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.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
@@ -31,12 +30,9 @@
#include <string.h>
#include <errno.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#include "messages.c"
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
static unsigned long disp_hr = KILOBYTE;
#endif
@@ -49,19 +45,8 @@ static Display *print;
static void print_normal(long size, char *filename)
{
unsigned long base;
#ifdef BB_FEATURE_HUMAN_READABLE
switch (disp_hr) {
case MEGABYTE:
base = KILOBYTE;
break;
case KILOBYTE:
base = 1;
break;
default:
base = 0;
}
printf("%s\t%s\n", make_human_readable_str(size, base), filename);
#ifdef CONFIG_FEATURE_HUMAN_READABLE
printf("%s\t%s\n", make_human_readable_str(size<<10, 1, disp_hr), filename);
#else
printf("%ld\t%s\n", size, filename);
#endif
@@ -70,17 +55,87 @@ static void print_normal(long size, char *filename)
static void print_summary(long size, char *filename)
{
if (du_depth == 1) {
printf("summary\n");
print_normal(size, 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)
{
struct stat statbuf;
long sum;
int len;
if ((lstat(filename, &statbuf)) != 0) {
perror_msg("%s", filename);
@@ -93,12 +148,13 @@ static long du(char *filename)
/* Don't add in stuff pointed to by symbolic links */
if (S_ISLNK(statbuf.st_mode)) {
sum = 0L;
if (du_depth == 1)
print(sum, filename);
if (du_depth == 1) {
}
}
if (S_ISDIR(statbuf.st_mode)) {
DIR *dir;
struct dirent *entry;
char *newfile;
dir = opendir(filename);
if (!dir) {
@@ -106,12 +162,11 @@ static long du(char *filename)
return 0;
}
len = strlen(filename);
if (filename[len - 1] == '/')
filename[--len] = '\0';
newfile = last_char_is(filename, '/');
if (newfile)
*newfile = '\0';
while ((entry = readdir(dir))) {
char *newfile;
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
@@ -151,7 +206,7 @@ int du_main(int argc, char **argv)
/* parse argv[] */
while ((c = getopt(argc, argv, "sl"
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
"hm"
#endif
"k")) != EOF) {
@@ -162,7 +217,7 @@ int du_main(int argc, char **argv)
case 'l':
count_hardlinks = 1;
break;
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
#endif
@@ -180,8 +235,7 @@ int du_main(int argc, char **argv)
long sum;
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
sum = du(argv[i]);
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
print_normal(sum, argv[i]);
}
@@ -192,7 +246,7 @@ int du_main(int argc, char **argv)
return status;
}
/* $Id: du.c,v 1.44 2001/04/09 22:48:11 andersen Exp $ */
/* $Id: du.c,v 1.51 2001/10/24 04:59:27 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
+16 -7
View File
@@ -35,14 +35,13 @@ extern int env_main(int argc, char** argv)
{
char **ep, *p;
char *cleanenv[1];
int ignore_environment = 0;
int ch;
while ((ch = getopt(argc, argv, "-iu:")) != -1)
while ((ch = getopt(argc, argv, "+iu:")) != -1) {
switch(ch) {
case '-':
case 'i':
environ = cleanenv;
cleanenv[0] = NULL;
ignore_environment = 1;
break;
case 'u':
unsetenv(optarg);
@@ -50,15 +49,25 @@ extern int env_main(int argc, char** argv)
default:
show_usage();
}
}
if (optind != argc && !strcmp(argv[optind], "-")) {
ignore_environment = 1;
argv++;
}
if (ignore_environment) {
environ = cleanenv;
cleanenv[0] = NULL;
}
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
setenv(*argv, ++p, 1);
if (putenv(*argv) < 0)
perror_msg_and_die("%s", *argv);
if (*argv) {
execvp(*argv, argv);
perror_msg_and_die("%s", *argv);
}
for (ep = environ; *ep; ep++)
printf("%s\n", *ep);
exit(EXIT_SUCCESS);
puts(*ep);
return 0;
}
/*
+8 -8
View File
@@ -89,8 +89,8 @@ int expr_main (int argc, char **argv)
if (v->type == integer)
printf ("%d\n", v->u.i);
else
printf ("%s\n", v->u.s);
else
puts (v->u.s);
exit (null (v));
}
@@ -194,7 +194,7 @@ nextarg (char *str)
/* The comparison operator handling functions. */
#define cmpf(name, rel) \
static int name (l, r) VALUE *l; VALUE *r; \
static int name (VALUE *l, VALUE *r) \
{ \
if (l->type == string || r->type == string) { \
tostring (l); \
@@ -217,7 +217,7 @@ static int name (l, r) VALUE *l; VALUE *r; \
#define arithf(name, op) \
static \
int name (l, r) VALUE *l; VALUE *r; \
int name (VALUE *l, VALUE *r) \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ("non-numeric argument"); \
@@ -225,7 +225,7 @@ int name (l, r) VALUE *l; VALUE *r; \
}
#define arithdivf(name, op) \
static int name (l, r) VALUE *l; VALUE *r; \
static int name (VALUE *l, VALUE *r) \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ( "non-numeric argument"); \
@@ -414,7 +414,7 @@ static VALUE *eval5 (void)
static VALUE *eval4 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
int (*fxn) (VALUE *, VALUE *), val;
l = eval5 ();
while (1) {
@@ -440,7 +440,7 @@ static VALUE *eval4 (void)
static VALUE *eval3 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
int (*fxn) (VALUE *, VALUE *), val;
l = eval4 ();
while (1) {
@@ -464,7 +464,7 @@ static VALUE *eval3 (void)
static VALUE *eval2 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
int (*fxn) (VALUE *, VALUE *), val;
l = eval3 ();
while (1) {
+3 -10
View File
@@ -1,10 +1,9 @@
/* vi: set sw=4 ts=4: */
/*
* Mini true/false implementation for busybox
* Mini false implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
@@ -27,12 +26,6 @@
#include <stdlib.h>
#include "busybox.h"
extern int true_main(int argc, char **argv)
{
return EXIT_SUCCESS;
}
extern int false_main(int argc, char **argv)
{
return EXIT_FAILURE;
+3 -6
View File
@@ -2,9 +2,8 @@
/*
* Mini head implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Copyright (C) 1999 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.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
@@ -22,7 +21,6 @@
*
*/
#include <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
@@ -82,10 +80,9 @@ int head_main(int argc, char **argv)
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
if (ferror(fp)) {
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
errno = 0;
}
if (optind < argc - 1)
putchar('\n');
+2 -2
View File
@@ -79,12 +79,12 @@ extern int id_main(int argc, char **argv)
if (no_group) {
if(name_not_number && user)
printf("%s\n",user);
puts(user);
else
printf("%ld\n", pwnam);
} else if (no_user) {
if(name_not_number && group)
printf("%s\n", group);
puts(group);
else
printf("%ld\n", grnam);
} else {
+2 -5
View File
@@ -2,8 +2,8 @@
/*
* Mini ln implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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,9 +28,6 @@
#include <errno.h>
#include <unistd.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_not_a_directory
#include "messages.c"
static const int LN_SYMLINK = 1;
+81 -79
View File
@@ -21,7 +21,7 @@
/*
* To achieve a small memory footprint, this version of 'ls' doesn't do any
* file sorting, and only has the most essential command line switches
* (i.e. the ones I couldn't live without :-) All features which involve
* (i.e., the ones I couldn't live without :-) All features which involve
* linking in substantial chunks of libc can be disabled.
*
* Although I don't really want to add new features to this program to
@@ -61,10 +61,11 @@ enum {
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <termios.h>
#include <sys/ioctl.h>
#include "busybox.h"
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
#include <time.h>
#endif
@@ -107,7 +108,7 @@ STYLE_COLUMNS = 3 /* fill columns */
#define DISP_RECURSIVE (1<<4) /* show directory and everything below it */
#define DISP_ROWS (1<<5) /* print across rows */
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
/* how will the files be sorted */
static const int SORT_FORWARD = 0; /* sort in reverse order */
static const int SORT_REVERSE = 1; /* sort in reverse order */
@@ -121,7 +122,7 @@ static const int SORT_EXT = 8; /* sort by file name extension */
static const int SORT_DIR = 9; /* sort by file or directory */
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
/* which of the three times will be used */
static const int TIME_MOD = 0;
static const int TIME_CHANGE = 1;
@@ -141,7 +142,7 @@ static const int SPLIT_SUBDIR = 2;
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
#endif
@@ -163,19 +164,19 @@ static int list_single(struct dnode *);
static unsigned int disp_opts;
static unsigned int style_fmt;
static unsigned int list_fmt;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
static unsigned int sort_opts;
static unsigned int sort_order;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
static unsigned int time_fmt;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
static unsigned int follow_links=FALSE;
#endif
static unsigned short column = 0;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
static unsigned short terminal_width = TERMINAL_WIDTH;
static unsigned short column_width = COLUMN_WIDTH;
static unsigned short tabstops = COLUMN_GAP;
@@ -185,13 +186,13 @@ static unsigned short column_width = COLUMN_WIDTH;
static int status = EXIT_SUCCESS;
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
static unsigned long ls_disp_hr = 0;
#endif
static int my_stat(struct dnode *cur)
{
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) {
perror_msg("%s", cur->fullname);
@@ -221,7 +222,7 @@ static void newline(void)
}
/*----------------------------------------------------------------------*/
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
static char append_char(mode_t mode)
{
if ( !(list_fmt & LIST_FILETYPE))
@@ -303,6 +304,7 @@ static struct dnode **dnalloc(int num)
return(p);
}
#ifdef CONFIG_FEATURE_LS_RECURSIVE
static void dfree(struct dnode **dnp)
{
struct dnode *cur, *next;
@@ -318,6 +320,7 @@ static void dfree(struct dnode **dnp)
}
free(dnp); /* free the array holding the dnode pointers */
}
#endif
static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
{
@@ -358,7 +361,7 @@ static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
}
/*----------------------------------------------------------------------*/
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
static int sortcmp(struct dnode *d1, struct dnode *d2)
{
int cmp, dif;
@@ -423,13 +426,13 @@ static void shellsort(struct dnode **dn, int size)
static void showfiles(struct dnode **dn, int nfiles)
{
int i, ncols, nrows, row, nc;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
int len;
#endif
if(dn==NULL || nfiles < 1) return;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
/* find the longest file name- use that as the column width */
column_width= 0;
for (i=0; i<nfiles; i++) {
@@ -485,7 +488,7 @@ static void showdirs(struct dnode **dn, int ndirs)
{
int i, nfiles;
struct dnode **subdnp;
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
int dndirs;
struct dnode **dnd;
#endif
@@ -500,17 +503,17 @@ static void showdirs(struct dnode **dn, int ndirs)
nfiles= countfiles(subdnp);
if (nfiles > 0) {
/* list all files at this level */
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(subdnp, nfiles);
#endif
showfiles(subdnp, nfiles);
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
if (disp_opts & DISP_RECURSIVE) {
/* recursive- list the sub-dirs */
dnd= splitdnarray(subdnp, nfiles, SPLIT_SUBDIR);
dndirs= countsubdirs(subdnp, nfiles);
if (dndirs > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnd, dndirs);
#endif
showdirs(dnd, dndirs);
@@ -543,16 +546,16 @@ static struct dnode **list_dir(char *path)
}
while ((entry = readdir(dir)) != NULL) {
/* are we going to list the file- it may be . or .. or a hidden file */
if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) continue;
if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) continue;
if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) continue;
if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT))
continue;
if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT))
continue;
if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN))
continue;
cur= (struct dnode *)xmalloc(sizeof(struct dnode));
cur->fullname = xmalloc(strlen(path)+1+strlen(entry->d_name)+1);
strcpy(cur->fullname, path);
if (cur->fullname[strlen(cur->fullname)-1] != '/')
strcat(cur->fullname, "/");
cur->name= cur->fullname + strlen(cur->fullname);
strcat(cur->fullname, entry->d_name);
cur->fullname = concat_path_file(path, entry->d_name);
cur->name = cur->fullname +
(strlen(cur->fullname) - strlen(entry->d_name));
if (my_stat(cur))
continue;
cur->next= dn;
@@ -577,41 +580,41 @@ static struct dnode **list_dir(char *path)
/*----------------------------------------------------------------------*/
static int list_single(struct dnode *dn)
{
int i, len;
int i;
char scratch[BUFSIZ + 1];
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
char *filetime;
time_t ttime, age;
#endif
#if defined (BB_FEATURE_LS_FILETYPES)
#if defined (CONFIG_FEATURE_LS_FILETYPES)
struct stat info;
#endif
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
char append;
#endif
if (dn==NULL || dn->fullname==NULL) return(0);
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
ttime= dn->dstat.st_mtime; /* the default time */
if (time_fmt & TIME_ACCESS) ttime= dn->dstat.st_atime;
if (time_fmt & TIME_CHANGE) ttime= dn->dstat.st_ctime;
filetime= ctime(&ttime);
#endif
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
append = append_char(dn->dstat.st_mode);
#endif
for (i=0; i<=31; i++) {
switch (list_fmt & (1<<i)) {
case LIST_INO:
printf("%7ld ", dn->dstat.st_ino);
printf("%7ld ", (long int)dn->dstat.st_ino);
column += 8;
break;
case LIST_BLOCKS:
#ifdef BB_FEATURE_HUMAN_READABLE
fprintf(stdout, "%5s ", make_human_readable_str(dn->dstat.st_blocks>>1,
(ls_disp_hr==TRUE)? 0: 1));
#ifdef CONFIG_FEATURE_HUMAN_READABLE
fprintf(stdout, "%6s ", make_human_readable_str(dn->dstat.st_blocks>>1,
KILOBYTE, (ls_disp_hr==TRUE)? 0: KILOBYTE));
#else
#if _FILE_OFFSET_BITS == 64
printf("%4lld ", dn->dstat.st_blocks>>1);
@@ -622,7 +625,7 @@ static int list_single(struct dnode *dn)
column += 5;
break;
case LIST_MODEBITS:
printf("%10s", (char *)mode_string(dn->dstat.st_mode));
printf("%-10s ", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
@@ -630,7 +633,7 @@ static int list_single(struct dnode *dn)
column += 10;
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
#ifdef CONFIG_FEATURE_LS_USERNAME
my_getpwuid(scratch, dn->dstat.st_uid);
printf("%-8.8s ", scratch);
my_getgrgid(scratch, dn->dstat.st_gid);
@@ -647,10 +650,9 @@ static int list_single(struct dnode *dn)
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
} else {
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
if (ls_disp_hr==TRUE) {
fprintf(stdout, "%9s ", make_human_readable_str(
dn->dstat.st_size>>10, 0));
fprintf(stdout, "%8s ", make_human_readable_str(dn->dstat.st_size, 1, 0));
} else
#endif
{
@@ -663,7 +665,7 @@ static int list_single(struct dnode *dn)
}
column += 10;
break;
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
case LIST_FULLTIME:
case LIST_DATE_TIME:
if (list_fmt & LIST_FULLTIME) {
@@ -688,20 +690,20 @@ static int list_single(struct dnode *dn)
break;
case LIST_SYMLINK:
if (S_ISLNK(dn->dstat.st_mode)) {
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
if (len > 0) {
scratch[len]= '\0';
printf(" -> %s", scratch);
#ifdef BB_FEATURE_LS_FILETYPES
char *lpath = xreadlink(dn->fullname);
if (lpath) {
printf(" -> %s", lpath);
#ifdef CONFIG_FEATURE_LS_FILETYPES
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
}
#endif
column += len+4;
column += strlen(lpath) + 4;
free(lpath);
}
}
break;
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
case LIST_FILETYPE:
if (append != '\0') {
printf("%1c", append);
@@ -725,21 +727,21 @@ extern int ls_main(int argc, char **argv)
int opt;
int oi, ac;
char **av;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
struct winsize win = { 0, 0, 0, 0 };
#endif
disp_opts= DISP_NORMAL;
style_fmt= STYLE_AUTO;
list_fmt= LIST_SHORT;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_NAME;
sort_order= SORT_FORWARD;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
time_fmt= TIME_MOD;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
if (win.ws_row > 4)
column_width = win.ws_row - 2;
@@ -750,25 +752,25 @@ extern int ls_main(int argc, char **argv)
/* process options */
while ((opt = getopt(argc, argv, "1AaCdgilnsx"
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
"T:w:"
#endif
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
"Fp"
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
"R"
#endif
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
"rSvX"
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
"cetu"
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
"L"
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
"h"
#endif
"k")) > 0) {
@@ -783,54 +785,54 @@ extern int ls_main(int argc, char **argv)
case 'l':
style_fmt = STYLE_LONG;
list_fmt |= LIST_LONG;
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
ls_disp_hr = FALSE;
#endif
break;
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
case 's': list_fmt |= LIST_BLOCKS; break;
case 'x': disp_opts = DISP_ROWS; break;
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
case 'F': list_fmt |= LIST_FILETYPE | LIST_EXEC; break;
case 'p': list_fmt |= LIST_FILETYPE; break;
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
case 'R': disp_opts |= DISP_RECURSIVE; break;
#endif
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
case 'r': sort_order |= SORT_REVERSE; break;
case 'S': sort_opts= SORT_SIZE; break;
case 'v': sort_opts= SORT_VERSION; break;
case 'X': sort_opts= SORT_EXT; break;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
case 'e': list_fmt |= LIST_FULLTIME; break;
case 'c':
time_fmt = TIME_CHANGE;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_CTIME;
#endif
break;
case 'u':
time_fmt = TIME_ACCESS;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_ATIME;
#endif
break;
case 't':
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_MTIME;
#endif
break;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
case 'L': follow_links= TRUE; break;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
case 'T': tabstops= atoi(optarg); break;
case 'w': terminal_width= atoi(optarg); break;
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
case 'h': ls_disp_hr = TRUE; break;
#endif
case 'k': break;
@@ -840,17 +842,17 @@ extern int ls_main(int argc, char **argv)
}
/* sort out which command line options take precedence */
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
if (disp_opts & DISP_NOLIST)
disp_opts &= ~DISP_RECURSIVE; /* no recurse if listing only dir */
#endif
#if defined (BB_FEATURE_LS_TIMESTAMPS) && defined (BB_FEATURE_LS_SORTFILES)
#if defined (CONFIG_FEATURE_LS_TIMESTAMPS) && defined (CONFIG_FEATURE_LS_SORTFILES)
if (time_fmt & TIME_CHANGE) sort_opts= SORT_CTIME;
if (time_fmt & TIME_ACCESS) sort_opts= SORT_ATIME;
#endif
if (style_fmt != STYLE_LONG)
list_fmt &= ~LIST_ID_NUMERIC; /* numeric uid only for long list */
#ifdef BB_FEATURE_LS_USERNAME
#ifdef CONFIG_FEATURE_LS_USERNAME
if (style_fmt == STYLE_LONG && (list_fmt & LIST_ID_NUMERIC))
list_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */
#endif
@@ -906,7 +908,7 @@ extern int ls_main(int argc, char **argv)
if (disp_opts & DISP_NOLIST) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnp, nfiles);
#endif
if (nfiles > 0) showfiles(dnp, nfiles);
@@ -916,13 +918,13 @@ extern int ls_main(int argc, char **argv)
dndirs= countdirs(dnp, nfiles);
dnfiles= nfiles - dndirs;
if (dnfiles > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnf, dnfiles);
#endif
showfiles(dnf, dnfiles);
}
if (dndirs > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnd, dndirs);
#endif
showdirs(dnd, dndirs);
+243 -126
View File
@@ -20,10 +20,35 @@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
/*
* June 29, 2001 Manuel Novoa III
*
* Added MD5SUM_SIZE_VS_SPEED configuration option.
*
* Current valid values, with data from my system for comparison, are:
* (using uClibc and running on linux-2.4.4.tar.bz2)
* user times (sec) text size (386)
* 0 (fastest) 1.1 6144
* 1 1.4 5392
* 2 3.0 5088
* 3 (smallest) 5.1 4912
*/
#define MD5SUM_SIZE_VS_SPEED 2
/**********************************************************************/
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include <sys/types.h>
#if defined HAVE_LIMITS_H
# include <limits.h>
#endif
#include "busybox.h"
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
@@ -38,75 +63,17 @@
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
* according to the definition of MD5 in RFC 1321 from April 1992.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* NOTE: The canonical source of this file is maintained with the GNU C
* Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include "busybox.h"
//----------------------------------------------------------------------------
//--------md5.h
//----------------------------------------------------------------------------
/* md5.h - Declaration of functions and data types used for MD5 sum
computing library functions.
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
computing library functions. */
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
static const int _MD5_H = 1;
#include <stdio.h>
#if defined HAVE_LIMITS_H || defined _LIBC
# include <limits.h>
#endif
/* The following contortions are an attempt to use the C preprocessor
to determine an unsigned integral type that is 32 bits wide. An
alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
doing that would require that the configure script compile and *run*
the resulting executable. Locally running cross-compiled executables
is usually not possible. */
# include <sys/types.h>
typedef u_int32_t md5_uint32;
/* Structure to save state of computation between the single steps. */
@@ -129,20 +96,20 @@ struct md5_ctx
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
extern void md5_init_ctx __P ((struct md5_ctx *ctx));
static void md5_init_ctx __P ((struct md5_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
extern void md5_process_block __P ((const void *buffer, size_t len,
static void md5_process_block __P ((const void *buffer, size_t len,
struct md5_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is NOT required that LEN is a multiple of 64. */
extern void md5_process_bytes __P ((const void *buffer, size_t len,
static void md5_process_bytes __P ((const void *buffer, size_t len,
struct md5_ctx *ctx));
/* Process the remaining bytes in the buffer and put result from CTX
@@ -152,40 +119,40 @@ extern void md5_process_bytes __P ((const void *buffer, size_t len,
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
static void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
/* Put result from CTX in first 16 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
extern int md5_stream __P ((FILE *stream, void *resblock));
static int md5_stream __P ((FILE *stream, void *resblock));
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
#endif
static void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
//----------------------------------------------------------------------------
//--------end of md5.h
//----------------------------------------------------------------------------
#define SWAP(n) (n)
/* Handle endian-ness */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define SWAP(n) (n)
#else
#define SWAP(n) ((n << 24) | ((n&65280)<<8) | ((n&16711680)>>8) | (n>>24))
#endif
#if MD5SUM_SIZE_VS_SPEED == 0
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
#endif
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
@@ -200,27 +167,12 @@ void md5_init_ctx(struct md5_ctx *ctx)
ctx->buflen = 0;
}
/* Put result from CTX in first 16 bytes following RESBUF. The result
must be in little endian byte order.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
{
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
return resbuf;
}
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
static void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
{
/* Take yet unprocessed bytes into account. */
md5_uint32 bytes = ctx->buflen;
@@ -232,23 +184,39 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
++ctx->total[1];
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
#if MD5SUM_SIZE_VS_SPEED > 0
memset(&ctx->buffer[bytes], 0, pad);
ctx->buffer[bytes] = 0x80;
#else
memcpy(&ctx->buffer[bytes], fillbuf, pad);
#endif
/* Put the 64-bit file length in *bits* at the end of the buffer. */
*(md5_uint32 *) & ctx->buffer[bytes + pad] = SWAP(ctx->total[0] << 3);
*(md5_uint32 *) & ctx->buffer[bytes + pad + 4] =
SWAP((ctx->total[1] << 3) | (ctx->total[0] >> 29));
SWAP( ((ctx->total[1] << 3) | (ctx->total[0] >> 29)) );
/* Process last bytes. */
md5_process_block(ctx->buffer, bytes + pad + 8, ctx);
return md5_read_ctx(ctx, resbuf);
/* Put result from CTX in first 16 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
return resbuf;
}
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int md5_stream(FILE *stream, void *resblock)
static int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
static const int BLOCKSIZE = 4096;
@@ -300,7 +268,7 @@ static const int BLOCKSIZE = 4096;
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *md5_buffer(const char *buffer, size_t len, void *resblock)
static void *md5_buffer(const char *buffer, size_t len, void *resblock)
{
struct md5_ctx ctx;
@@ -314,7 +282,7 @@ void *md5_buffer(const char *buffer, size_t len, void *resblock)
return md5_finish_ctx(&ctx, resblock);
}
void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
static void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
{
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
@@ -362,12 +330,55 @@ void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0. */
void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
{
md5_uint32 correct_words[16];
const md5_uint32 *words = buffer;
size_t nwords = len / sizeof(md5_uint32);
const md5_uint32 *endp = words + nwords;
#if MD5SUM_SIZE_VS_SPEED > 0
static const md5_uint32 C_array[] = {
/* round 1 */
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
/* round 2 */
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
/* round 3 */
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
/* round 4 */
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
};
static const char P_array[] = {
#if MD5SUM_SIZE_VS_SPEED > 1
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */
#endif
1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */
5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, /* 3 */
0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */
};
#if MD5SUM_SIZE_VS_SPEED > 1
static const char S_array[] = {
7, 12, 17, 22,
5, 9, 14, 20,
4, 11, 16, 23,
6, 10, 15, 21
};
#endif
#endif
md5_uint32 A = ctx->A;
md5_uint32 B = ctx->B;
md5_uint32 C = ctx->C;
@@ -389,6 +400,78 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
md5_uint32 C_save = C;
md5_uint32 D_save = D;
#if MD5SUM_SIZE_VS_SPEED > 1
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
const md5_uint32 *pc;
const char *pp;
const char *ps;
int i;
md5_uint32 temp;
for ( i=0 ; i < 16 ; i++ ) {
cwp[i] = SWAP(words[i]);
}
words += 16;
#if MD5SUM_SIZE_VS_SPEED > 2
pc = C_array; pp = P_array; ps = S_array - 4;
for ( i = 0 ; i < 64 ; i++ ) {
if ((i&0x0f) == 0) ps += 4;
temp = A;
switch (i>>4) {
case 0:
temp += FF(B,C,D);
break;
case 1:
temp += FG(B,C,D);
break;
case 2:
temp += FH(B,C,D);
break;
case 3:
temp += FI(B,C,D);
}
temp += cwp[(int)(*pp++)] + *pc++;
temp = CYCLIC (temp, ps[i&3]);
temp += B;
A = D; D = C; C = B; B = temp;
}
#else
pc = C_array; pp = P_array; ps = S_array;
for ( i = 0 ; i < 16 ; i++ ) {
temp = A + FF(B,C,D) + cwp[(int)(*pp++)] + *pc++;
temp = CYCLIC (temp, ps[i&3]);
temp += B;
A = D; D = C; C = B; B = temp;
}
ps += 4;
for ( i = 0 ; i < 16 ; i++ ) {
temp = A + FG(B,C,D) + cwp[(int)(*pp++)] + *pc++;
temp = CYCLIC (temp, ps[i&3]);
temp += B;
A = D; D = C; C = B; B = temp;
}
ps += 4;
for ( i = 0 ; i < 16 ; i++ ) {
temp = A + FH(B,C,D) + cwp[(int)(*pp++)] + *pc++;
temp = CYCLIC (temp, ps[i&3]);
temp += B;
A = D; D = C; C = B; B = temp;
}
ps += 4;
for ( i = 0 ; i < 16 ; i++ ) {
temp = A + FI(B,C,D) + cwp[(int)(*pp++)] + *pc++;
temp = CYCLIC (temp, ps[i&3]);
temp += B;
A = D; D = C; C = B; B = temp;
}
#endif
#else
/* First round: using the given function, the context and a constant
the next context is computed. Because the algorithms processing
unit is a 32-bit word and it is determined to work on words in
@@ -408,6 +491,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
/* It is unfortunate that C does not provide an operator for
cyclic rotation. Hope the C compiler is smart enough. */
/* gcc 2.95.4 seems to be --aaronl */
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
/* Before we start, one word to the strange constants.
@@ -416,7 +500,22 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
*/
#if MD5SUM_SIZE_VS_SPEED == 1
const md5_uint32 *pc;
const char *pp;
int i;
#endif
/* Round 1. */
#if MD5SUM_SIZE_VS_SPEED == 1
pc = C_array;
for ( i=0 ; i < 4 ; i++ ) {
OP(A, B, C, D, 7, *pc++);
OP(D, A, B, C, 12, *pc++);
OP(C, D, A, B, 17, *pc++);
OP(B, C, D, A, 22, *pc++);
}
#else
OP(A, B, C, D, 7, 0xd76aa478);
OP(D, A, B, C, 12, 0xe8c7b756);
OP(C, D, A, B, 17, 0x242070db);
@@ -433,6 +532,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
OP(D, A, B, C, 12, 0xfd987193);
OP(C, D, A, B, 17, 0xa679438e);
OP(B, C, D, A, 22, 0x49b40821);
#endif
/* For the second to fourth round we have the possibly swapped words
in CORRECT_WORDS. Redefine the macro to take an additional first
@@ -448,6 +548,15 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
while (0)
/* Round 2. */
#if MD5SUM_SIZE_VS_SPEED == 1
pp = P_array;
for ( i=0 ; i < 4 ; i++ ) {
OP(FG, A, B, C, D, (int)(*pp++), 5, *pc++);
OP(FG, D, A, B, C, (int)(*pp++), 9, *pc++);
OP(FG, C, D, A, B, (int)(*pp++), 14, *pc++);
OP(FG, B, C, D, A, (int)(*pp++), 20, *pc++);
}
#else
OP(FG, A, B, C, D, 1, 5, 0xf61e2562);
OP(FG, D, A, B, C, 6, 9, 0xc040b340);
OP(FG, C, D, A, B, 11, 14, 0x265e5a51);
@@ -464,8 +573,17 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
OP(FG, D, A, B, C, 2, 9, 0xfcefa3f8);
OP(FG, C, D, A, B, 7, 14, 0x676f02d9);
OP(FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
#endif
/* Round 3. */
#if MD5SUM_SIZE_VS_SPEED == 1
for ( i=0 ; i < 4 ; i++ ) {
OP(FH, A, B, C, D, (int)(*pp++), 4, *pc++);
OP(FH, D, A, B, C, (int)(*pp++), 11, *pc++);
OP(FH, C, D, A, B, (int)(*pp++), 16, *pc++);
OP(FH, B, C, D, A, (int)(*pp++), 23, *pc++);
}
#else
OP(FH, A, B, C, D, 5, 4, 0xfffa3942);
OP(FH, D, A, B, C, 8, 11, 0x8771f681);
OP(FH, C, D, A, B, 11, 16, 0x6d9d6122);
@@ -482,8 +600,17 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
OP(FH, D, A, B, C, 12, 11, 0xe6db99e5);
OP(FH, C, D, A, B, 15, 16, 0x1fa27cf8);
OP(FH, B, C, D, A, 2, 23, 0xc4ac5665);
#endif
/* Round 4. */
#if MD5SUM_SIZE_VS_SPEED == 1
for ( i=0 ; i < 4 ; i++ ) {
OP(FI, A, B, C, D, (int)(*pp++), 6, *pc++);
OP(FI, D, A, B, C, (int)(*pp++), 10, *pc++);
OP(FI, C, D, A, B, (int)(*pp++), 15, *pc++);
OP(FI, B, C, D, A, (int)(*pp++), 21, *pc++);
}
#else
OP(FI, A, B, C, D, 0, 6, 0xf4292244);
OP(FI, D, A, B, C, 7, 10, 0x432aff97);
OP(FI, C, D, A, B, 14, 15, 0xab9423a7);
@@ -500,6 +627,8 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
OP(FI, D, A, B, C, 11, 10, 0xbd3af235);
OP(FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
OP(FI, B, C, D, A, 9, 21, 0xeb86d391);
#endif
#endif
/* Add the starting values of the context. */
A += A_save;
@@ -520,11 +649,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
//----------------------------------------------------------------------------
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
#define IN_CTYPE_DOMAIN(c) 1
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
#define TOLOWER(Ch) tolower (Ch)
#define OPENOPTS(BINARY) "r"
#define ISXDIGIT(c) (isxdigit (c))
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
@@ -544,7 +669,6 @@ static int warn = 0; /* With -w, print a message to standard error warning
static int split_3(char *s,
size_t s_len,
unsigned char **u,
int *binary,
char **w)
{
size_t i = 0;
@@ -577,11 +701,10 @@ static int split_3(char *s,
if (s[i] != ' ' && s[i] != '*')
return FALSE;
*binary = (s[i++] == '*');
/* All characters between the type indicator and end of line are
significant -- that includes leading and trailing white space. */
*w = &s[i];
*w = &s[++i];
if (escaped_filename) {
/* Translate each `\n' string in the file name to a NEWLINE,
@@ -625,7 +748,7 @@ static int split_3(char *s,
return TRUE;
}
static int hex_digits(unsigned char const *s)
static inline int hex_digits(unsigned char const *s)
{
while (*s) {
if (!ISXDIGIT(*s))
@@ -639,21 +762,18 @@ static int hex_digits(unsigned char const *s)
put the result in *MD5_RESULT. Return non-zero upon failure, zero
to indicate success. */
static int md5_file(const char *filename,
int binary,
unsigned char *md5_result)
{
FILE *fp;
if (STREQ(filename, "-")) {
if (filename[0] == '-' && filename[1] == '\0') {
have_read_stdin = 1;
fp = stdin;
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
perror_msg("%s", filename);
fp = wfopen(filename, "r");
if (fp == NULL)
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
perror_msg("%s", filename);
@@ -681,22 +801,19 @@ static int md5_check(const char *checkfile_name)
size_t line_number;
char line[BUFSIZ];
if (STREQ(checkfile_name, "-")) {
if (checkfile_name[0] == '-' && checkfile_name[1] == '\0') {
have_read_stdin = 1;
checkfile_stream = stdin;
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
perror_msg("%s", checkfile_name);
checkfile_stream = wfopen(checkfile_name, "r");
if (checkfile_stream == NULL)
return FALSE;
}
}
line_number = 0;
do {
char *filename;
int binary;
unsigned char *md5num;
int line_length;
@@ -716,7 +833,7 @@ static int md5_check(const char *checkfile_name)
if (line[line_length - 1] == '\n')
line[--line_length] = '\0';
if (split_3(line, line_length, &md5num, &binary, &filename)
if (split_3(line, line_length, &md5num, &filename)
|| !hex_digits(md5num)) {
if (warn) {
error_msg("%s: %lu: improperly formatted MD5 checksum line",
@@ -732,7 +849,7 @@ static int md5_check(const char *checkfile_name)
++n_properly_formated_lines;
if (md5_file(filename, binary, md5buffer)) {
if (md5_file(filename, md5buffer)) {
++n_open_or_read_failures;
if (!status_only) {
printf("%s: FAILED open or read\n", filename);
@@ -743,9 +860,9 @@ static int md5_check(const char *checkfile_name)
/* Compare generated binary number with text representation
in check file. Ignore case of hex digits. */
for (cnt = 0; cnt < 16; ++cnt) {
if (TOLOWER(md5num[2 * cnt])
if (tolower(md5num[2 * cnt])
!= bin2hex[md5buffer[cnt] >> 4]
|| (TOLOWER(md5num[2 * cnt + 1])
|| (tolower(md5num[2 * cnt + 1])
!= (bin2hex[md5buffer[cnt] & 0xf])))
break;
}
@@ -810,8 +927,8 @@ int md5sum_main(int argc,
char **string = NULL;
size_t n_strings = 0;
size_t err = 0;
int file_type_specified = 0;
int binary = 0;
char file_type_specified = 0;
char binary = 0;
while ((opt = getopt(argc, argv, "g:bcstw")) != -1) {
switch (opt) {
@@ -897,9 +1014,9 @@ int md5sum_main(int argc,
int fail;
char *file = argv[optind];
fail = md5_file (file, binary, md5buffer);
fail = md5_file (file, md5buffer);
err |= fail;
if (!fail && STREQ(file, "-")) {
if (!fail && file[0]=='-' && file[1] == '\0') {
size_t i;
for (i = 0; i < 16; ++i)
printf ("%02x", md5buffer[i]);
+31 -69
View File
@@ -2,8 +2,7 @@
/*
* Mini mkdir implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,82 +20,45 @@
*
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
#include "messages.c"
static int parentFlag = FALSE;
static mode_t mode = 0777;
extern int mkdir_main(int argc, char **argv)
extern int mkdir_main (int argc, char **argv)
{
int i = FALSE;
mode_t mode = -1;
int flags = 0;
int status = 0;
int i, opt;
argc--;
argv++;
/* Parse any options */
while (argc > 0 && **argv == '-') {
while (i == FALSE && *++(*argv)) {
switch (**argv) {
case 'm':
if (--argc == 0)
show_usage();
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
error_msg_and_die("Unknown mode: %s", *argv);
}
/* Set the umask for this process so it doesn't
* screw up whatever the user just entered. */
umask(0);
i = TRUE;
break;
case 'p':
parentFlag = TRUE;
break;
default:
show_usage();
}
while ((opt = getopt (argc, argv, "m:p")) != -1) {
switch (opt) {
case 'm':
mode = 0777;
if (!parse_mode (optarg, &mode))
error_msg_and_die ("invalid mode `%s'", optarg);
break;
case 'p':
flags |= FILEUTILS_RECUR;
break;
default:
show_usage ();
}
argc--;
argv++;
}
if (argc < 1) {
show_usage();
}
if (optind == argc)
show_usage ();
while (argc > 0) {
int status;
struct stat statBuf;
char buf[BUFSIZ + 1];
for (i = optind; i < argc; i++)
if (make_directory (argv[i], mode, flags) < 0)
status = 1;
if (strlen(*argv) > BUFSIZ - 1) {
error_msg_and_die(name_too_long);
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
error_msg_and_die("%s: File exists", buf);
}
if (parentFlag == TRUE) {
strcat(buf, "/");
create_path(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror_msg_and_die(buf);
}
}
argc--;
argv++;
}
return EXIT_SUCCESS;
return status;
}
+168
View File
@@ -0,0 +1,168 @@
/* vi: set sw=4 ts=4: */
/*
* Mini mv implementation for busybox
*
*
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
static int flags;
static int manual_rename(const char *source, const char *dest)
{
struct stat source_stat;
struct stat dest_stat;
int source_exists = 1;
int dest_exists = 1;
if (stat(source, &source_stat) < 0) {
if (errno != ENOENT) {
perror_msg("unable to stat `%s'", source);
return -1;
}
source_exists = 0;
}
if (stat(dest, &dest_stat) < 0) {
if (errno != ENOENT) {
perror_msg("unable to stat `%s'", dest);
return -1;
}
dest_exists = 0;
}
if (dest_exists) {
if (S_ISDIR(dest_stat.st_mode) &&
(!source_exists || !S_ISDIR(source_stat.st_mode))) {
error_msg("cannot overwrite directory with non-directory");
return -1;
}
if (!S_ISDIR(dest_stat.st_mode) && source_exists &&
S_ISDIR(source_stat.st_mode)) {
error_msg("cannot overwrite non-directory with directory");
return -1;
}
if (unlink(dest) < 0) {
perror_msg("cannot remove `%s'", dest);
return -1;
}
}
if (copy_file(source, dest,
FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) < 0)
return -1;
if (remove_file(source, FILEUTILS_RECUR | FILEUTILS_FORCE) < 0)
return -1;
return 0;
}
static int move_file(const char *source, const char *dest)
{
struct stat dest_stat;
int dest_exists = 1;
if (stat(dest, &dest_stat) < 0) {
if (errno != ENOENT) {
perror_msg("unable to stat `%s'", dest);
return -1;
}
dest_exists = 0;
}
if (dest_exists && !(flags & FILEUTILS_FORCE) &&
((access(dest, W_OK) < 0 && isatty(0)) ||
(flags & FILEUTILS_INTERACTIVE))) {
fprintf(stderr, "mv: overwrite `%s'? ", dest);
if (!ask_confirmation())
return 0;
}
if (rename(source, dest) < 0) {
if (errno == EXDEV)
return manual_rename(source, dest);
perror_msg("unable to rename `%s'", source);
return -1;
}
return 0;
}
extern int mv_main(int argc, char **argv)
{
int status = 0;
int opt;
int i;
while ((opt = getopt(argc, argv, "fi")) != -1)
switch (opt) {
case 'f':
flags &= ~FILEUTILS_INTERACTIVE;
flags |= FILEUTILS_FORCE;
break;
case 'i':
flags &= ~FILEUTILS_FORCE;
flags |= FILEUTILS_INTERACTIVE;
break;
default:
show_usage();
}
if (optind + 2 > argc)
show_usage();
if (optind + 2 == argc) {
struct stat dest_stat;
int dest_exists = 1;
if (stat(argv[optind + 1], &dest_stat) < 0) {
if (errno != ENOENT)
perror_msg_and_die("unable to stat `%s'", argv[optind + 1]);
dest_exists = 0;
}
if (!dest_exists || !S_ISDIR(dest_stat.st_mode)) {
if (move_file(argv[optind], argv[optind + 1]) < 0)
status = 1;
return status;
}
}
for (i = optind; i < argc - 1; i++) {
char *dest = concat_path_file(argv[argc - 1],
get_last_path_component(argv[i]));
if (move_file(argv[i], dest) < 0)
status = 1;
free(dest);
}
return status;
}
+270
View File
@@ -0,0 +1,270 @@
/*
* od implementation for busybox
* Based on code from util-linux v 2.11l
*
* Copyright (c) 1990
* The Regents of the University of California. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice is retained at the end of this file.
*/
#include <ctype.h>
#include <getopt.h>
#include <stdlib.h>
#include "dump.h"
#include "busybox.h"
extern FS *fshead; /* head of format strings */
extern int blocksize; /* data block size */
extern int length; /* max bytes to read */
#define ishexdigit(c) \
((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
static void
odoffset(int argc, char ***argvp)
{
extern off_t skip;
register char *num, *p;
int base;
char *end;
/*
* The offset syntax of od(1) was genuinely bizarre. First, if
* it started with a plus it had to be an offset. Otherwise, if
* there were at least two arguments, a number or lower-case 'x'
* followed by a number makes it an offset. By default it was
* octal; if it started with 'x' or '0x' it was hex. If it ended
* in a '.', it was decimal. If a 'b' or 'B' was appended, it
* multiplied the number by 512 or 1024 byte units. There was
* no way to assign a block count to a hex offset.
*
* We assumes it's a file if the offset is bad.
*/
p = **argvp;
if (*p != '+' && (argc < 2 ||
(!isdigit(p[0]) && (p[0] != 'x' || !ishexdigit(p[1])))))
return;
base = 0;
/*
* skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
* set base.
*/
if (p[0] == '+')
++p;
if (p[0] == 'x' && ishexdigit(p[1])) {
++p;
base = 16;
} else if (p[0] == '0' && p[1] == 'x') {
p += 2;
base = 16;
}
/* skip over the number */
if (base == 16)
for (num = p; ishexdigit(*p); ++p);
else
for (num = p; isdigit(*p); ++p);
/* check for no number */
if (num == p)
return;
/* if terminates with a '.', base is decimal */
if (*p == '.') {
if (base)
return;
base = 10;
}
skip = strtol(num, &end, base ? base : 8);
/* if end isn't the same as p, we got a non-octal digit */
if (end != p)
skip = 0;
else {
if (*p) {
if (*p == 'b')
skip *= 512;
else if (*p == 'B')
skip *= 1024;
++p;
}
if (*p)
skip = 0;
else {
++*argvp;
/*
* If the offset uses a non-octal base, the base of
* the offset is changed as well. This isn't pretty,
* but it's easy.
*/
#define TYPE_OFFSET 7
if (base == 16) {
fshead->nextfu->fmt[TYPE_OFFSET] = 'x';
fshead->nextfs->nextfu->fmt[TYPE_OFFSET] = 'x';
} else if (base == 10) {
fshead->nextfu->fmt[TYPE_OFFSET] = 'd';
fshead->nextfs->nextfu->fmt[TYPE_OFFSET] = 'd';
}
}
}
}
static void odprecede(void)
{
static int first = 1;
if (first) {
first = 0;
add("\"%07.7_Ao\n\"");
add("\"%07.7_ao \"");
} else
add("\" \"");
}
int od_main(int argc, char **argv)
{
int ch;
extern enum _vflag vflag;
vflag = FIRST;
length = -1;
while ((ch = getopt(argc, argv, "aBbcDdeFfHhIiLlOoPpswvXx")) != EOF)
switch (ch) {
case 'a':
odprecede();
add("16/1 \"%3_u \" \"\\n\"");
break;
case 'B':
case 'o':
odprecede();
add("8/2 \" %06o \" \"\\n\"");
break;
case 'b':
odprecede();
add("16/1 \"%03o \" \"\\n\"");
break;
case 'c':
odprecede();
add("16/1 \"%3_c \" \"\\n\"");
break;
case 'd':
odprecede();
add("8/2 \" %05u \" \"\\n\"");
break;
case 'D':
odprecede();
add("4/4 \" %010u \" \"\\n\"");
break;
case 'e': /* undocumented in od */
case 'F':
odprecede();
add("2/8 \" %21.14e \" \"\\n\"");
break;
case 'f':
odprecede();
add("4/4 \" %14.7e \" \"\\n\"");
break;
case 'H':
case 'X':
odprecede();
add("4/4 \" %08x \" \"\\n\"");
break;
case 'h':
case 'x':
odprecede();
add("8/2 \" %04x \" \"\\n\"");
break;
case 'I':
case 'L':
case 'l':
odprecede();
add("4/4 \" %11d \" \"\\n\"");
break;
case 'i':
odprecede();
add("8/2 \" %6d \" \"\\n\"");
break;
case 'O':
odprecede();
add("4/4 \" %011o \" \"\\n\"");
break;
case 'v':
vflag = ALL;
break;
case 'P':
case 'p':
case 's':
case 'w':
case '?':
default:
error_msg("od: od(1) has been deprecated for hexdump(1).\n");
if (ch != '?') {
error_msg("od: hexdump(1) compatibility doesn't support the -%c option%s\n",
ch, ch == 's' ? "; see strings(1)." : ".");
}
show_usage();
}
if (!fshead) {
add("\"%07.7_Ao\n\"");
add("\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
}
argc -= optind;
argv += optind;
odoffset(argc, &argv);
return(dump(argv));
}
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+31 -92
View File
@@ -3,12 +3,8 @@
* Mini rm implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* INTERACTIVE feature Copyright (C) 2001 by Alcove
* written by Christophe Boyanique <Christophe.Boyanique@fr.alcove.com>
* for Ipanema Technologies
*
* 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
@@ -33,106 +29,49 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
static int recursiveFlag = FALSE;
static int forceFlag = FALSE;
#ifdef BB_FEATURE_RM_INTERACTIVE
static int interactiveFlag = FALSE;
#endif
static const char *srcName;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
#ifdef BB_FEATURE_RM_INTERACTIVE
if (interactiveFlag == TRUE) {
printf("rm: remove `%s'? ", fileName);
if (ask_confirmation() == 0)
return (TRUE);
}
#endif
if (unlink(fileName) < 0) {
perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
}
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
perror_msg("%s", fileName);
return (FALSE);
}
#ifdef BB_FEATURE_RM_INTERACTIVE
if (interactiveFlag == TRUE) {
printf("rm: remove directory `%s'? ", fileName);
if (ask_confirmation() == 0)
return (TRUE);
}
#endif
if (rmdir(fileName) < 0) {
perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
}
extern int rm_main(int argc, char **argv)
{
int status = 0;
int opt;
int status = EXIT_SUCCESS;
struct stat statbuf;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Rrf-"
#ifdef BB_FEATURE_RM_INTERACTIVE
"i"
#endif
)) > 0) {
int flags = 0;
int i;
while ((opt = getopt(argc, argv, "fiRr")) != -1) {
switch (opt) {
case 'R':
case 'r':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
#ifdef BB_FEATURE_RM_INTERACTIVE
case 'i':
interactiveFlag = TRUE;
#endif
break;
default:
show_usage();
case 'f':
flags &= ~FILEUTILS_INTERACTIVE;
flags |= FILEUTILS_FORCE;
break;
case 'i':
flags &= ~FILEUTILS_FORCE;
flags |= FILEUTILS_INTERACTIVE;
break;
case 'R':
case 'r':
flags |= FILEUTILS_RECUR;
break;
}
}
if (argc == optind && forceFlag == FALSE) {
if (!(flags & FILEUTILS_FORCE) && optind == argc)
show_usage();
}
#ifdef BB_FEATURE_RM_INTERACTIVE
if (forceFlag == TRUE)
interactiveFlag = FALSE;
#endif
for (i = optind; i < argc; i++) {
char *base = get_last_path_component(argv[i]);
while (optind < argc) {
srcName = argv[optind];
if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0
&& errno == ENOENT) {
/* do not reports errors for non-existent files if -f, just skip them */
} else {
if (recursive_action(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
status = EXIT_FAILURE;
}
if (strcmp(base, ".") == 0 || strcmp(base, "..") == 0) {
error_msg("cannot remove `.' or `..'");
status = 1;
continue;
}
optind++;
if (remove_file(argv[i], flags) < 0)
status = 1;
}
return status;
}
+63 -12
View File
@@ -2,9 +2,8 @@
/*
* Mini rmdir implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
@@ -22,24 +21,76 @@
*
*/
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <unistd.h>
#include <stdlib.h>
#include "busybox.h"
extern int rmdir_main(int argc, char **argv)
/* Return true if a path is composed of multiple components. */
static int
multiple_components_p (const char *path)
{
const char *s = path;
while (s[0] != '\0' && s[0] != '/')
s++;
while (s[0] == '/')
s++;
return (s[0] != '\0');
}
/* Remove a directory. Returns 0 if successful, -1 on error. */
static int
remove_directory (char *path, int flags)
{
if (!(flags & FILEUTILS_RECUR)) {
if (rmdir (path) < 0) {
perror_msg ("unable to remove `%s'", path);
return -1;
}
} else {
if (remove_directory (path, 0) < 0)
return -1;
if (multiple_components_p (path))
if (remove_directory (dirname (path), flags) < 0)
return -1;
}
return 0;
}
extern int
rmdir_main (int argc, char **argv)
{
int status = EXIT_SUCCESS;
int flags = 0;
int i, opt;
if (argc == 1 || **(argv + 1) == '-')
while ((opt = getopt (argc, argv, "p")) != -1)
switch (opt) {
case 'p':
flags |= FILEUTILS_RECUR;
break;
default:
show_usage ();
}
if (optind == argc)
show_usage();
while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
perror_msg("%s", *argv);
for (i = optind; i < argc; i++)
if (remove_directory (argv[i], flags) < 0)
status = EXIT_FAILURE;
}
}
return status;
}
+27 -11
View File
@@ -33,7 +33,8 @@ static int compare_ascii(const void *x, const void *y)
static int compare_numeric(const void *x, const void *y)
{
return atoi(*(char **)x) - atoi(*(char **)y);
int z = atoi(*(char **)x) - atoi(*(char **)y);
return z ? z : strcmp(*(char **)x, *(char **)y);
}
int sort_main(int argc, char **argv)
@@ -42,19 +43,27 @@ int sort_main(int argc, char **argv)
char *line, **lines = NULL;
int i, opt, nlines = 0;
int (*compare)(const void *, const void *) = compare_ascii;
#ifdef BB_FEATURE_SORT_REVERSE
#ifdef CONFIG_FEATURE_SORT_REVERSE
int reverse = FALSE;
#endif
#ifdef CONFIG_FEATURE_SORT_UNIQUE
int unique = FALSE;
#endif
while ((opt = getopt(argc, argv, "nr")) != -1) {
while ((opt = getopt(argc, argv, "nru")) != -1) {
switch (opt) {
case 'n':
compare = compare_numeric;
break;
#ifdef BB_FEATURE_SORT_REVERSE
#ifdef CONFIG_FEATURE_SORT_REVERSE
case 'r':
reverse = TRUE;
break;
#endif
#ifdef CONFIG_FEATURE_SORT_UNIQUE
case 'u':
unique = TRUE;
break;
#endif
default:
show_usage();
@@ -70,6 +79,7 @@ int sort_main(int argc, char **argv)
while ((line = get_line_from_file(fp)) != NULL) {
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
chomp(line);
lines[nlines++] = line;
}
}
@@ -78,13 +88,19 @@ int sort_main(int argc, char **argv)
qsort(lines, nlines, sizeof(char *), compare);
/* print it */
#ifdef BB_FEATURE_SORT_REVERSE
if (reverse)
for (i = nlines - 1; 0 <= i; i--)
fputs(lines[i], stdout);
else
#ifdef CONFIG_FEATURE_SORT_REVERSE
if (reverse) {
for (i = --nlines; 0 <= i; i--)
#ifdef CONFIG_FEATURE_SORT_UNIQUE
if((!unique) || (i == nlines) || (strcmp(lines[i + 1], lines[i])))
#endif
for (i = 0; i < nlines; i++)
fputs(lines[i], stdout);
puts(lines[i]);
} else
#endif
for (i = 0; i < nlines; i++)
#ifdef CONFIG_FEATURE_SORT_UNIQUE
if((!unique) || (!i) || (strcmp(lines[i - 1], lines[i])))
#endif
puts(lines[i]);
return EXIT_SUCCESS;
}
+1 -68
View File
@@ -24,7 +24,7 @@
David MacKenzie <djm@gnu.ai.mit.edu>
Special for busybox ported by Vladimir Oleynik <vodz@usa.net> 2001
Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001
*/
@@ -1362,76 +1362,9 @@ static const char *visible(unsigned int ch)
}
#ifdef TEST
unsigned long parse_number(const char *numstr,
const struct suffix_mult *suffixes)
{
const struct suffix_mult *sm;
unsigned long int ret;
int len;
char *end;
ret = strtoul(numstr, &end, 10);
if (numstr == end)
error_msg_and_die("invalid number `%s'", numstr);
while (end[0] != '\0') {
sm = suffixes;
while ( sm != 0 ) {
if(sm->suffix) {
len = strlen(sm->suffix);
if (strncmp(sm->suffix, end, len) == 0) {
ret *= sm->mult;
end += len;
break;
}
sm++;
} else
sm = 0;
}
if (sm == 0)
error_msg_and_die("invalid number `%s'", numstr);
}
return ret;
}
const char *applet_name = "stty";
static void verror_msg(const char *s, va_list p)
{
fflush(stdout);
fprintf(stderr, "%s: ", applet_name);
vfprintf(stderr, s, p);
}
extern void error_msg_and_die(const char *s, ...)
{
va_list p;
va_start(p, s);
verror_msg(s, p);
va_end(p);
putc('\n', stderr);
exit(EXIT_FAILURE);
}
static void vperror_msg(const char *s, va_list p)
{
int err=errno;
verror_msg(s, p);
if (*s) s = ": ";
fprintf(stderr, "%s%s\n", s, strerror(err));
}
extern void perror_msg_and_die(const char *s, ...)
{
va_list p;
va_start(p, s);
vperror_msg(s, p);
va_end(p);
exit(EXIT_FAILURE);
}
#endif
/*
+11 -7
View File
@@ -51,7 +51,7 @@ static void tailbuf_append(char *buf, int len)
taillen += len;
}
static void tailbuf_trunc()
static void tailbuf_trunc(void)
{
char *s;
s = memchr(tailbuf, '\n', taillen);
@@ -73,7 +73,7 @@ int tail_main(int argc, char **argv)
case 'f':
follow = 1;
break;
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
case 'c':
units = BYTES;
/* FALLS THROUGH */
@@ -85,7 +85,7 @@ int tail_main(int argc, char **argv)
if (optarg[0] == '+')
from_top = 1;
break;
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
case 'q':
hide_headers = 1;
break;
@@ -118,7 +118,7 @@ int tail_main(int argc, char **argv)
}
}
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
/* tail the files */
if (!from_top && units == BYTES)
tailbuf = xmalloc(count);
@@ -127,12 +127,16 @@ int tail_main(int argc, char **argv)
for (i = 0; i < nfiles; i++) {
if (fds[i] == -1)
continue;
if (!count) {
lseek(fds[i], 0, SEEK_END);
continue;
}
seen = 0;
if (show_headers || (!hide_headers && nfiles > 1))
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
if (from_top) {
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
if (units == BYTES) {
if (count - 1 <= seen)
nwrite = nread;
@@ -165,7 +169,7 @@ int tail_main(int argc, char **argv)
break;
}
} else {
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
if (units == BYTES) {
if (nread < count) {
memmove(tailbuf, tailbuf + nread, count - nread);
@@ -199,7 +203,7 @@ int tail_main(int argc, char **argv)
status = EXIT_FAILURE;
}
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
if (!from_top && units == BYTES) {
if (count < seen)
seen = count;
+2 -4
View File
@@ -2,8 +2,7 @@
/*
* Mini tee implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
* Copyright (C) 2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -45,9 +44,8 @@ tee_main(int argc, char **argv)
files = (FILE **)xmalloc(sizeof(FILE *) * (argc - optind + 1));
files[nfiles++] = stdout;
while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
if ((files[nfiles++] = wfopen(argv[optind++], mode)) == NULL) {
nfiles--;
perror_msg("%s", argv[optind-1]);
status = 1;
}
}
+21 -24
View File
@@ -38,9 +38,6 @@
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
@@ -161,21 +158,21 @@ static struct t_op const *t_wp_op;
static gid_t *group_array = NULL;
static int ngroups;
static enum token t_lex();
static int oexpr();
static int aexpr();
static int nexpr();
static int binop();
static int primary();
static int filstat();
static int getn();
static int newerf();
static int olderf();
static int equalf();
static void syntax();
static int test_eaccess();
static int is_a_group_member();
static void initialize_group_array();
static enum token t_lex(char* s);
static int oexpr(enum token n);
static int aexpr(enum token n);
static int nexpr(enum token n);
static int binop(void);
static int primary(enum token n);
static int filstat(char *nm, enum token mode);
static int getn(const char *s);
static int newerf(const char *f1, const char *f2);
static int olderf(const char *f1, const char *f2);
static int equalf(const char *f1, const char *f2);
static void syntax(const char *op, const char *msg);
static int test_eaccess(char *path, int mode);
static int is_a_group_member(gid_t gid);
static void initialize_group_array(void);
extern int
test_main(int argc, char** argv)
@@ -229,8 +226,8 @@ test_main(int argc, char** argv)
static void
syntax(op, msg)
char *op;
char *msg;
const char *op;
const char *msg;
{
if (op && *op)
error_msg_and_die("%s: %s", op, msg);
@@ -461,7 +458,7 @@ t_lex(s)
/* atoi with error detection */
static int
getn(s)
char *s;
const char *s;
{
char *p;
long r;
@@ -483,7 +480,7 @@ getn(s)
static int
newerf (f1, f2)
char *f1, *f2;
const char *f1, *f2;
{
struct stat b1, b2;
@@ -494,7 +491,7 @@ char *f1, *f2;
static int
olderf (f1, f2)
char *f1, *f2;
const char *f1, *f2;
{
struct stat b1, b2;
@@ -505,7 +502,7 @@ char *f1, *f2;
static int
equalf (f1, f2)
char *f1, *f2;
const char *f1, *f2;
{
struct stat b1, b2;
+2 -3
View File
@@ -2,9 +2,8 @@
/*
* Mini touch implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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 -17
View File
@@ -30,13 +30,12 @@
#include <unistd.h>
#include <sys/types.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_write_error
#include "messages.c"
static const int ASCII = 0377;
/* This must be a #define, since when DODEBUG and BUFFERS_GO_IN_BSS are
* enabled, we otherwise get a "storage size isn't constant error. */
#define ASCII 0377
/* some glabals shared across this file */
/* some "globals" shared across this file */
static char com_fl, del_fl, sq_fl;
static short in_index, out_index;
/* these last are pointers to static buffers declared in tr_main */
@@ -45,7 +44,7 @@ static unsigned char *pvector;
static char *pinvec, *poutvec;
static void convert()
static void convert(void)
{
short read_chars = 0;
short c, coded;
@@ -55,7 +54,7 @@ static void convert()
if (in_index == read_chars) {
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
if (write(1, (char *) poutput, out_index) != out_index)
write(2, write_error, strlen(write_error));
error_msg("%s", write_error);
exit(0);
}
in_index = 0;
@@ -68,10 +67,8 @@ static void convert()
continue;
poutput[out_index++] = last = coded;
if (out_index == BUFSIZ) {
if (write(1, (char *) poutput, out_index) != out_index) {
write(2, write_error, strlen(write_error));
exit(1);
}
if (write(1, (char *) poutput, out_index) != out_index)
error_msg_and_die("%s", write_error);
out_index = 0;
}
}
@@ -93,6 +90,10 @@ static void map(register unsigned char *string1, unsigned int string1_len,
}
}
/* supported constructs:
* Ranges, e.g., [0-9] ==> 0123456789
* Escapes, e.g., \a ==> Control-G
*/
static unsigned int expand(const char *arg, register unsigned char *buffer)
{
unsigned char *buffer_start = buffer;
@@ -102,6 +103,16 @@ static unsigned int expand(const char *arg, register unsigned char *buffer)
if (*arg == '\\') {
arg++;
*buffer++ = process_escape_sequence(&arg);
} else if (*(arg+1) == '-') {
ac = *(arg+2);
if(ac == 0) {
*buffer++ = *arg++;
continue;
}
i = *arg;
while (i <= ac)
*buffer++ = i++;
arg += 3; /* Skip the assumed a-z */
} else if (*arg == '[') {
arg++;
i = *arg++;
@@ -113,7 +124,7 @@ static unsigned int expand(const char *arg, register unsigned char *buffer)
ac = *arg++;
while (i <= ac)
*buffer++ = i++;
arg++; /* Skip ']' */
arg++; /* Skip the assumed ']' */
} else
*buffer++ = *arg++;
}
@@ -144,11 +155,11 @@ extern int tr_main(int argc, char **argv)
int output_length=0, input_length;
int idx = 1;
int i;
RESERVE_BB_BUFFER(output, BUFSIZ);
RESERVE_BB_BUFFER(input, BUFSIZ);
RESERVE_BB_UBUFFER(vector, ASCII+1);
RESERVE_BB_BUFFER(invec, ASCII+1);
RESERVE_BB_BUFFER(outvec, ASCII+1);
RESERVE_CONFIG_BUFFER(output, BUFSIZ);
RESERVE_CONFIG_BUFFER(input, BUFSIZ);
RESERVE_CONFIG_UBUFFER(vector, ASCII+1);
RESERVE_CONFIG_BUFFER(invec, ASCII+1);
RESERVE_CONFIG_BUFFER(outvec, ASCII+1);
/* ... but make them available globally */
poutput = output;
+6 -6
View File
@@ -1,8 +1,9 @@
/* vi: set sw=4 ts=4: */
/*
* Mini hostid implementation for busybox
* Mini true implementation for busybox
*
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 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
@@ -20,13 +21,12 @@
*
*/
#include <stdio.h>
/* getopt not needed */
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
extern int hostid_main(int argc, char **argv)
extern int true_main(int argc, char **argv)
{
printf("%lx\n", gethostid());
return EXIT_SUCCESS;
}
+2 -3
View File
@@ -2,9 +2,8 @@
/*
* Mini uniq implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Copyright (C) 1999 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
+15 -12
View File
@@ -29,8 +29,8 @@
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
#include "pwd.h"
#include "grp.h"
/*struct passwd *getpwnam();*/
@@ -201,12 +201,13 @@ static int decode (const char *inname,
const char *forced_outname)
{
struct passwd *pw;
register int n;
register char *p;
int mode, n1;
int mode;
char buf[2 * BUFSIZ];
char *outname;
int do_base64 = 0;
int res;
int dofre;
/* Search for header line. */
@@ -226,6 +227,7 @@ static int decode (const char *inname,
}
/* If the output file name is given on the command line this rules. */
dofre = FALSE;
if (forced_outname != NULL)
outname = (char *) forced_outname;
else {
@@ -246,12 +248,8 @@ static int decode (const char *inname,
error_msg("%s: No user `%s'", inname, buf + 1);
return FALSE;
}
n = strlen (pw->pw_dir);
n1 = strlen (p);
outname = (char *) alloca ((size_t) (n + n1 + 2));
memcpy (outname + n + 1, p, (size_t) (n1 + 1));
memcpy (outname, pw->pw_dir, (size_t) n);
outname[n] = '/';
outname = concat_path_file(pw->pw_dir, p);
dofre = TRUE;
}
}
@@ -261,6 +259,8 @@ static int decode (const char *inname,
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
perror_msg("%s", outname); /* */
if (dofre)
free(outname);
return FALSE;
}
@@ -269,9 +269,12 @@ static int decode (const char *inname,
/* For each input line: */
if (do_base64)
return read_base64 (inname);
res = read_base64 (inname);
else
return read_stduu (inname);
res = read_stduu (inname);
if (dofre)
free(outname);
return res;
}
int uudecode_main (int argc,
+164 -221
View File
@@ -1,237 +1,180 @@
/* uuencode.c -- uuencode utility.
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2000 by Glenn McGrath
*
* This product is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
* based on the function base64_encode from http.c in wget v1.6
* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
*
* This product is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this product; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
* 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 Library General Public License for more details.
*
* Original copyright notice is retained at the end of this file.
* 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.
*/
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
/* Hacked to work with BusyBox by Alfred M. Szmidt */
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "busybox.h"
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
static void encode __P ((void));
/* Pointer to the translation table we currently use. */
static const char *trans_ptr;
/* The two currently defined translation tables. The first is the
standard uuencoding, the second is base64 encoding. */
static const char uu_std[64] = {
'`', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
/* Conversion table. for base 64 */
static char tbl_base64[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
static const char uu_base64[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
static char tbl_std[64] = {
'`', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
};
/* ENC is the basic 1 character encoding function to make a char printing. */
#define ENC(Char) (trans_ptr[(Char) & 077])
/* Copy from IN to OUT, encoding as you go along. */
static void encode()
{
register int ch, n;
char *p = NULL;
char buf[80];
while (1) {
n = 0;
do {
register int m = fread (buf, 1, 45 - n, stdin);
if (m == 0)
break;
n += m;
}
while (n < 45);
if (n == 0)
break;
if (trans_ptr == uu_std)
if (putchar (ENC (n)) == EOF)
break;
for (p = buf; n > 2; n -= 3, p += 3) {
ch = *p >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = p[2] & 077;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
}
if (n != 0)
break;
if (putchar ('\n') == EOF)
break;
}
while (n != 0) {
char c1 = *p;
char c2 = n == 1 ? 0 : p[1];
ch = c1 >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((c1 << 4) & 060) | ((c2 >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
if (n == 1)
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
else {
ch = (c2 << 2) & 074;
ch = ENC (ch);
}
if (putchar (ch) == EOF)
break;
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
if (putchar (ch) == EOF)
break;
putchar ('\n');
break;
}
if (ferror (stdin))
error_msg("Read error");
if (trans_ptr == uu_std) {
putchar (ENC ('\0'));
putchar ('\n');
}
}
int uuencode_main (int argc,
char **argv)
{
int opt;
struct stat sb;
int mode;
trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */
while ((opt = getopt (argc, argv, "m")) > 0) {
switch (opt) {
case 'm':
trans_ptr = uu_base64;
break;
default:
show_usage();
}
}
switch (argc - optind) {
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
perror_msg("%s", argv[optind]);
return EXIT_FAILURE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
optind++;
break;
case 1:
mode = RW & ~umask (RW);
break;
case 0:
default:
show_usage();
}
printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64",
mode, argv[optind]);
encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) {
error_msg("Write error");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* 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.
/*
* Encode the string S of length LENGTH to base64 format and place it
* to STORE. STORE will be 0-terminated, and must point to a writable
* buffer of at least 1+BASE64_LENGTH(length) bytes.
* where BASE64_LENGTH(len) = (4 * ((LENGTH + 2) / 3))
*/
static void uuencode (const char *s, const char *store, const int length, const char *tbl)
{
int i;
unsigned char *p = (unsigned char *)store;
/* Transform the 3x8 bits to 4x6 bits, as required by base64. */
for (i = 0; i < length; i += 3) {
*p++ = tbl[s[0] >> 2];
*p++ = tbl[((s[0] & 3) << 4) + (s[1] >> 4)];
*p++ = tbl[((s[1] & 0xf) << 2) + (s[2] >> 6)];
*p++ = tbl[s[2] & 0x3f];
s += 3;
}
/* Pad the result if necessary... */
if (i == length + 1) {
*(p - 1) = '=';
}
else if (i == length + 2) {
*(p - 1) = *(p - 2) = '=';
}
/* ...and zero-terminate it. */
*p = '\0';
}
int uuencode_main(int argc, char **argv)
{
const int src_buf_size = 60; // This *MUST* be a multiple of 3
const int dst_buf_size = 4 * ((src_buf_size + 2) / 3);
RESERVE_CONFIG_BUFFER(src_buf, src_buf_size + 1);
RESERVE_CONFIG_BUFFER(dst_buf, dst_buf_size + 1);
struct stat stat_buf;
FILE *src_stream = stdin;
char *tbl = tbl_std;
size_t size;
mode_t mode;
int opt;
int column = 0;
int write_size = 0;
int remaining;
int buffer_offset = 0;
while ((opt = getopt(argc, argv, "m")) != -1) {
switch (opt) {
case 'm':
tbl = tbl_base64;
break;
default:
show_usage();
}
}
switch (argc - optind) {
case 2:
src_stream = xfopen(argv[optind], "r");
stat(argv[optind], &stat_buf);
mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
if (src_stream == stdout) {
printf("NULL\n");
}
break;
case 1:
mode = 0666 & ~umask(0666);
break;
default:
show_usage();
}
printf("begin%s %o %s", tbl == tbl_std ? "" : "-base64", mode, argv[argc - 1]);
while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) {
/* Encode the buffer we just read in */
uuencode(src_buf, dst_buf, size, tbl);
/* Write the buffer to stdout, wrapping at 60 chars.
* This looks overly complex, but it gets tricky as
* the line has to continue to wrap correctly if we
* have to refill the buffer
*
* Improvments most welcome
*/
/* Initialise values for the new buffer */
remaining = 4 * ((size + 2) / 3);
buffer_offset = 0;
/* Write the buffer to stdout, wrapping at 60 chars
* starting from the column the last buffer ran out
*/
do {
if (remaining > (60 - column)) {
write_size = 60 - column;
}
else if (remaining < 60) {
write_size = remaining;
} else {
write_size = 60;
}
/* Setup a new row if required */
if (column == 0) {
putchar('\n');
if (tbl == tbl_std) {
putchar('M');
}
}
/* Write to the 60th column */
if (fwrite(&dst_buf[buffer_offset], 1, write_size, stdout) != write_size) {
perror("Couldnt finish writing");
}
/* Update variables based on last write */
buffer_offset += write_size;
remaining -= write_size;
column += write_size;
if (column % 60 == 0) {
column = 0;
}
} while (remaining > 0);
}
printf(tbl == tbl_std ? "\n`\nend\n" : "\n====\n");
return(EXIT_SUCCESS);
}
-325
View File
@@ -1,325 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini `cp' and `mv' implementation for BusyBox.
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Copyright (C) 2000 by BitterSweet Enterprises, LLC. (GPL)
* Extensively modified and rewritten by Karl M. Hegbloom <karlheg@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <time.h>
#include <utime.h>
#include <dirent.h>
#include <sys/param.h>
#include <setjmp.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#include <stdlib.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_omitting_directory
#define bb_need_not_a_directory
#include "messages.c"
static const int is_cp = 0;
static const int is_mv = 1;
static int dz_i; /* index into cp_mv_usage */
static int recursiveFlag;
static int followLinks;
static int preserveFlag;
static int forceFlag;
static const char *baseSrcName;
static int srcDirFlag;
static struct stat srcStatBuf;
static char *pBaseDestName;
static size_t baseDestLen;
static int destDirFlag;
static struct stat destStatBuf;
static jmp_buf catch;
static volatile int mv_Action_first_time;
static void name_too_long__exit (void) __attribute__((noreturn));
static
void name_too_long__exit (void)
{
error_msg_and_die(name_too_long);
}
static void
fill_baseDest_buf(char *_buf, size_t * _buflen) {
const char *srcBasename;
if ((srcBasename = strrchr(baseSrcName, '/')) == NULL) {
srcBasename = baseSrcName;
if (_buf[*_buflen - 1] != '/') {
if (++(*_buflen) > BUFSIZ)
name_too_long__exit();
strcat(_buf, "/");
}
}
if (*_buflen + strlen(srcBasename) > BUFSIZ)
name_too_long__exit();
strcat(_buf, srcBasename);
return;
}
static int
cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
{
char destName[BUFSIZ + 1];
size_t destLen;
const char *srcBasename;
char *name;
strcpy(destName, pBaseDestName);
destLen = strlen(destName);
if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) {
error_msg(omitting_directory, baseSrcName);
return TRUE;
}
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
if (destLen + strlen(srcBasename) > BUFSIZ) {
error_msg(name_too_long);
return FALSE;
}
strcat(destName, srcBasename);
}
else if (destDirFlag == TRUE) {
fill_baseDest_buf(&destName[0], &destLen);
}
else {
srcBasename = baseSrcName;
}
if (mv_Action_first_time && (dz_i == is_mv)) {
mv_Action_first_time = errno = 0;
if (rename(fileName, destName) < 0 && errno != EXDEV) {
perror_msg("rename(%s, %s)", fileName, destName);
goto do_copyFile; /* Try anyway... */
}
else if (errno == EXDEV)
goto do_copyFile;
else
longjmp(catch, 1); /* succeeded with rename() */
}
do_copyFile:
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
if (is_in_ino_dev_hashtable(statbuf, &name)) {
if (link(name, destName) < 0) {
perror_msg("link(%s, %s)", name, destName);
return FALSE;
}
return TRUE;
}
else {
add_to_ino_dev_hashtable(statbuf, destName);
}
}
return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
}
static int
rm_Action(const char *fileName, struct stat *statbuf, void* junk)
{
int status = TRUE;
if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) {
perror_msg("rmdir(%s)", fileName);
status = FALSE;
}
} else if (unlink(fileName) < 0) {
perror_msg("unlink(%s)", fileName);
status = FALSE;
}
return status;
}
extern int cp_mv_main(int argc, char **argv)
{
volatile int i;
int c;
RESERVE_BB_BUFFER(baseDestName,BUFSIZ + 1);
pBaseDestName = baseDestName; /* available globally */
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
dz_i = is_cp;
else
dz_i = is_mv;
if (argc < 3)
show_usage();
if (dz_i == is_cp) {
recursiveFlag = preserveFlag = forceFlag = FALSE;
followLinks = TRUE;
while ((c = getopt(argc, argv, "adpRf")) != EOF) {
switch (c) {
case 'a':
followLinks = FALSE;
preserveFlag = TRUE;
recursiveFlag = TRUE;
break;
case 'd':
followLinks = FALSE;
break;
case 'p':
preserveFlag = TRUE;
break;
case 'R':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
default:
show_usage();
}
}
if ((argc - optind) < 2) {
show_usage();
}
} else { /* (dz_i == is_mv) */
/* Initialize optind to 1, since in libc5 optind
* is not initialized until getopt() is called
* (or until sneaky programmers force it...). */
optind = 1;
recursiveFlag = preserveFlag = TRUE;
followLinks = FALSE;
}
if (strlen(argv[argc - 1]) > BUFSIZ) {
error_msg(name_too_long);
goto exit_false;
}
strcpy(baseDestName, argv[argc - 1]);
baseDestLen = strlen(baseDestName);
if (baseDestLen == 0)
goto exit_false;
destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
if (argc - optind > 2 && destDirFlag == FALSE) {
error_msg(not_a_directory, baseDestName);
goto exit_false;
}
for (i = optind; i < (argc-1); i++) {
size_t srcLen;
volatile int flags_memo;
int status;
baseSrcName=argv[i];
if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
name_too_long__exit();
if (srcLen == 0) continue; /* "" */
srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
if ((flags_memo = (recursiveFlag == TRUE &&
srcDirFlag == TRUE && destDirFlag == TRUE))) {
struct stat sb;
int state = 0;
char *pushd, *d, *p;
if ((pushd = xgetcwd(0)) == NULL)
continue;
if (chdir(baseDestName) < 0) {
perror_msg("chdir(%s)", baseSrcName);
continue;
}
if ((d = xgetcwd(0)) == NULL)
continue;
while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
perror_msg("stat(%s)", d);
state = -1;
continue;
}
if ((sb.st_ino == srcStatBuf.st_ino) &&
(sb.st_dev == srcStatBuf.st_dev)) {
error_msg("Cannot %s `%s' into a subdirectory of itself, "
"`%s/%s'", applet_name, baseSrcName,
baseDestName, baseSrcName);
state = -1;
continue;
}
if ((p = strrchr(d, '/')) != NULL) {
*p = '\0';
}
}
if (chdir(pushd) < 0) {
perror_msg("chdir(%s)", pushd);
free(pushd);
free(d);
continue;
}
free(pushd);
free(d);
if (state < 0)
continue;
else
fill_baseDest_buf(baseDestName, &baseDestLen);
}
status = setjmp(catch);
if (status == 0) {
mv_Action_first_time = 1;
if (recursive_action(baseSrcName,
recursiveFlag, followLinks, FALSE,
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
if (dz_i == is_mv &&
recursive_action(baseSrcName,
recursiveFlag, followLinks, TRUE,
rm_Action, rm_Action, NULL) == FALSE) goto exit_false;
}
if (flags_memo)
*(baseDestName + baseDestLen) = '\0';
}
return EXIT_SUCCESS;
exit_false:
return EXIT_FAILURE;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
Loaded 100 of 537 files, more files were not shown because too many files have changed in this diff. Show more