Compare commits

...
1404 Commits
Author SHA1 Message Date
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
Eric Andersen 0958093be6 Doc update for the 0.51 release.
-Erik
2001-04-10 20:10:55 +00:00
Eric Andersen 3c3430502a Fix up changelog for 0.51 release 2001-04-10 20:10:14 +00:00
Eric Andersen b04d744a47 Bring Debian config files into sync with the master one. 2001-04-10 20:07:19 +00:00
Eric Andersen e703f7ed42 Ha. Regression testing found a bug with uClibc support. Fixed.
-Erik
2001-04-10 19:03:03 +00:00
Eric Andersen b9af894264 Fix up the uClibc compiler name (its format was recently changed slightly) 2001-04-10 18:35:02 +00:00
Eric Andersen 6d7fa438a7 This patch from Laurence Anderson <laurence@zxmail.com> fixes
wget HTTP 1.1 support and addes chunked encoding so bb wget
is now fully RFC compliant.
2001-04-10 18:17:05 +00:00
Eric Andersen fd402941a7 Patch from Valdimir to reduce stack usage, since recursive_action
is (as the name implies) is recursive, reducing stack memory usage
is important to avoid exhausting available stack memory.
2001-04-10 17:53:49 +00:00
Matt Kraai 4e853560f5 Fix double quote handling. 2001-04-10 00:00:05 +00:00
Eric Andersen 2f2da90fd4 "I will always compile before I commit" x 100 2001-04-09 23:54:15 +00:00
Eric Andersen b6b519b416 Update how we detect if libc5 is in use.
-Erik
2001-04-09 23:52:18 +00:00
Matt Kraai d3f97f1971 Fix warning generated by pod2html about unterminated list. 2001-04-09 23:27:51 +00:00
Eric Andersen 303dd28bb0 Make 'grep -l' work 2001-04-09 23:26:31 +00:00
Mark Whitley 4391a16c92 Fixed option parsing. Grep would continue grepping, even when given a bad /
invalid option. Closes bug #1146.
2001-04-09 23:00:07 +00:00
Eric Andersen e5dfced23a Apply Vladimir's latest cleanup patch.
-Erik
2001-04-09 22:48:12 +00:00
Eric Andersen a75e286743 Bump version number to 0.51 2001-04-09 22:18:14 +00:00
Eric Andersen 59aa5703ae Enable freeramdisk and pivot_root, disable lash for the Debian .udeb
-Erik
2001-04-09 22:17:10 +00:00
Eric Andersen fc994d1cb4 make sure we auto-close debian bug #91758
-Erik
2001-04-09 22:15:27 +00:00
Eric Andersen 7cf9fed83f update the changelog, prepatory to the 0.51 release. Please review
for correctness!
 -Erik
2001-04-09 22:09:41 +00:00
Eric Andersen 3f8688b406 Update changelog 2001-04-09 19:00:29 +00:00
Eric Andersen 5d6f3440e6 use 'USE_SYSTEM_PWD_GRP=false' for the Debian packages so the boot-floppies
do not need any of the nss crap installed.  As was, things like 'id' would
fail.  Fixed now (with thanks to Matt Kraai for his help).
 -Erik
2001-04-09 18:42:52 +00:00
Glenn L McGrath 305fdfa755 Reorganise status field to use 3 chars instead of one bit shifted long int.
Generates status file properly now, not compatable with full dpkg yet.
2001-04-08 13:27:39 +00:00
Glenn L McGrath 37849f3320 Use create_path instead of mkdir 2001-04-08 07:23:53 +00:00
Glenn L McGrath 13e9c7ad82 It now correctly backs up the (still corrupt) status file 2001-04-08 07:18:08 +00:00
Glenn L McGrath 0e757a2f3f Some fixes, but still broken... (cont)
Make better use of some libbb functions
New remove dir code to avoid depending on the rm applet
dont use copy_file() it doesnt fail elegantly
Use getopt.
Generate correct /var/lib/dpkg/info/ files
Status file is broken, working on it now
2001-04-08 05:27:18 +00:00
Glenn L McGrath f608da4288 Ignore SIGTERM prior to gz_close() 2001-04-07 02:40:59 +00:00
Glenn L McGrath e5f3957665 Fix warning 2001-04-07 02:17:36 +00:00
Eric Andersen 8a9b2c6448 Note that insmod now also supports powerpc and mips. Thanks Larry. 2001-04-06 22:02:49 +00:00
Eric Andersen aa21e0f913 An optimization from Vladimir 2001-04-06 16:02:22 +00:00
Eric Andersen 250a221768 more FILE_OFFSET_BITS == 64 adjustments. 2001-04-05 23:26:44 +00:00
Eric Andersen 83f173b61e A first pass at making D_FILE_OFFSET_BITS=64 work, from
Jari Ruusu <jari.ruusu@pp.inet.fi>
2001-04-05 23:07:25 +00:00
Eric Andersen c270ec1fa2 Add support of /W prompts
-Erik
2001-04-05 23:00:47 +00:00
Eric Andersen 831ed16efc Handle glibc 2.0.7 as well 2001-04-05 22:38:32 +00:00
Eric Andersen 79757c9c37 A patch from Dmitry Zakharov <dmit@crp.bank.gov.ua> which adds
- support for ftp downloads
- HTTP basic authentication support (as an optional feature)
- handling of http redirections
- protocol version changed to 1.0 (to stop servers from requesting
chunked encoding)
- bugfix: in the case when content-length not given, wget didn't
download anything
- when attempting to continue an aborted download but server doesn't
support restarts, reopen output file in write mode
- changed assumption that existing file should restart an aborted
    download.  Now the user must explicitly specify this with -c
2001-04-05 21:45:54 +00:00
Eric Andersen ea9065072c Some cleanups/fixes for the syslogd circular buffer code
from Gennady Feldman.
2001-04-05 20:55:17 +00:00
John Beppu 79359d87e8 - autodocifier.pl :: continuation() was modified such that '#'
is handled correctly.
2001-04-05 20:03:33 +00:00
John Beppu 94e505485e - use docs/autodocifier.pl to merge POD together 2001-04-05 19:42:03 +00:00
John Beppu 5bca0afb31 - split busybox.pod into a header and footer.
the body will be generated by docs/autodocifier.pl
2001-04-05 19:41:23 +00:00
John Beppu 9a1395b9fd - documentation updates and a minor tweak to POD generation 2001-04-05 19:35:17 +00:00
Eric Andersen 4e2439ad27 It seems all the stdout munging was useless anyways, since
deb_extract and all its called functions do nothing with
stdout anyways.  Axe that stuff.
 -Erik
2001-04-05 18:30:38 +00:00
Eric Andersen 911af57ff8 Be more generic for libc5. We don't need to know struct definitions
to make the syscall finction -- use a generic pointer instead.
2001-04-05 07:41:51 +00:00
Eric Andersen 64c8b1762c Another iteration -- adjust the init_module syscall a bit.
-Erik
2001-04-05 07:33:10 +00:00
Eric Andersen acc7757312 *** empty log message *** 2001-04-05 06:24:28 +00:00
Eric Andersen a2a978ae23 Some further syscall adjustments. Split the module syscalls out of
insmod and into libbb. Only enable them for libc5.  glibc and
uClibc don't need them.
 -Erik
2001-04-05 06:08:14 +00:00
Eric Andersen fdefbbbe85 dpkg_deb had not been updated for the new gunzip interface. Fix it.
-Erik
2001-04-05 06:04:11 +00:00
Eric Andersen e76c3b08e1 A number of cleanups. Now compiles with libc5, glibc, and uClibc. Fix a few
shadowed variables.  Move (almost) all syscalls to libbb/syscalls.c, so I can
handle them sanely and all at once.
 -Erik
2001-04-05 03:14:39 +00:00
Eric Andersen 3c0364f391 Patch from Larry Doolittle to eliminate needless thrashing
about when trimming long strings with lots of trailing white
space.
2001-04-04 22:49:01 +00:00
Eric Andersen 4fd382ea29 Remove unused optarg variable 2001-04-04 19:33:32 +00:00
Eric Andersen 06070532ba Failed to name "Electric-fence" explicitly 2001-04-04 19:32:00 +00:00
Eric Andersen d402edfd63 Some cleanups for libc5 support 2001-04-04 19:29:48 +00:00
Eric Andersen 14fe392dde Fix a warning with libc5.
-Erik
2001-04-04 19:26:22 +00:00
Eric Andersen b2e3e9b0c9 Seems that stupid libc5 doesn't implement daemon(), so conditionally
inclde that here.
 -Erik
2001-04-04 19:25:57 +00:00
Matt Kraai 2129f97cd9 Avoid segfault when export is invoked with no arguments. Thanks to
Gennady Feldman.
2001-04-04 17:50:04 +00:00
Eric Andersen 3f98040554 I said no new features till after the 0.51 release. Well, I lied. This is a
vi editor for busybox, contributed by Sterling Huxley <sterling@europa.com>.
It adds 22k to the busybox binary when enabled.  Quite impressive!
2001-04-04 17:31:15 +00:00
Eric Andersen 91c9388715 Place a temporary bandaid on the ls/du/df human-readable issue. This method is
not going to scale up as well as I would like, and Matt Kraai and I have
discussed a better long term solution.  But for now this will at least make all
the human-readable apps give correct answers.

Please test the human readable/non-human readable options on your systems!!!
 -Erik
2001-04-03 23:14:29 +00:00
Eric Andersen 24073c7665 Add in easy-to-use electric-fence support.
-Erik
2001-04-03 22:53:19 +00:00
Eric Andersen 60b2d8d2c8 if strlen(s) was 0, it would then end up using s[-1] as an array index. Bad,
bad, bad.  This was crashing the shell on powerpc boxes, though all other archs
seem to have a much more forgiving malloc implementations.  I finally found
this bug using electric-fence on a powerpc box.
 -Erik
2001-04-03 22:50:52 +00:00
Eric Andersen c97ec34370 A patch from Matt Kraai that adds a new 'shutdown' action to busybox init. Now
you can specify an arbitrary behavior for 'ctrlaltdel' without that behavior
needing to be a reboot.
2001-04-03 18:01:51 +00:00
Eric Andersen 0f0c0b41ce Make 'busybox --help' work as expected, closing bug #1139
-Erik
2001-04-03 17:05:01 +00:00
Eric Andersen c0c502e172 Fix for bug 1143 from Larry Doolittle
-Erik
2001-04-03 16:38:37 +00:00
Eric Andersen c4cef5ab06 Move the mtab support stuff into libbb
-Erik
2001-04-01 16:01:11 +00:00
Eric Andersen f77d88641d Formatting change 2001-04-01 04:49:41 +00:00
Glenn L McGrath 1e117b4752 Dont try and automount devfs, rename some variables 2001-03-30 01:28:13 +00:00
Eric Andersen 84e229cfbe Add in a new standalone env applet for fixing up app's environments
-Erik
2001-03-29 22:48:33 +00:00
Eric Andersen e5c24dfd01 Use daemon() to spawn syslogd and klogd daemons.
-Erik
2001-03-29 21:58:33 +00:00
Eric Andersen 3a6da8c183 gz_open and gz_close were left in, even when BB_FEATURE_TAR_GZIP was disabled.
Fix that.
2001-03-29 14:22:45 +00:00
Glenn L McGrath 5f2ef46d6d Fix zcat 2001-03-29 01:07:54 +00:00
Glenn L McGrath ed7a776538 gunzip -c works again 2001-03-29 00:57:20 +00:00
Glenn L McGrath ae8ad35590 Fixes from Robert Kaiser 2001-03-28 23:57:51 +00:00
Mark Whitley e0a7f917c2 Applied patch from David Douthitt to re-add -print option to find.
Closes bug #1144.
2001-03-28 22:04:42 +00:00
Eric Andersen c835567914 Fix ls so it uses make_human_readable_str() the same way already
used by 'du' and 'df'.  Now we just need to fix make_human_readable_str
so it behaves they way it used to before Matt fixed it.
2001-03-28 20:26:51 +00:00
Matt Kraai d98e574d41 Patch bass ackwards behavior of hr flag. 2001-03-28 20:10:25 +00:00
Matt Kraai 7cd0cfeab6 Rewrite to fix bug #1140 and make it slightly smaller. 2001-03-28 16:42:27 +00:00
Glenn L McGrath f957c77910 Enable tar -z support again by default 2001-03-28 07:48:10 +00:00
Glenn L McGrath 02cebebc3b Remove cruft 2001-03-28 07:37:48 +00:00
Glenn L McGrath 9233959940 Remove tar_unzip_init() not needed any more, uses gz_open instead 2001-03-28 07:31:37 +00:00
Glenn L McGrath 018e9e6799 Fix tar -z, calls gz_open now 2001-03-28 07:27:26 +00:00
Glenn L McGrath ee79ca1ba6 Disable tar -z for now 2001-03-28 06:13:15 +00:00
Glenn L McGrath 0cbc8cf4c9 Gunzip changes broke tar -z support (woops) 2001-03-28 05:47:26 +00:00
Glenn L McGrath 58e42d5356 Major cleanup to better adhere to style guide and use standard busybox functions 2001-03-28 05:38:24 +00:00
Glenn L McGrath f58efb57d1 Add functions that were shared with gunzip.c, gunzip about to change. 2001-03-28 05:35:16 +00:00
Matt Kraai a2e68fc233 Change BB_FEATURE_TRIVIAL_HELP to BB_FEATURE_VERBOSE_USAGE (per bug #1130). 2001-03-27 21:57:29 +00:00
Mark Whitley 5b8939b147 Some more words on sending patches to the bug-tracker. 2001-03-27 21:20:05 +00:00
Mark Whitley 9a2144663a Applied patch from David Douthitt to fix problem where ls reports half the
file size. Should close bug #1140.
2001-03-27 20:59:14 +00:00
Mark Whitley cc7b4f39fc Some more tests for cut. Craig Matsuura said he saw some problems along these
lines. "Works for me", but we'll keep these tests around for regression.
2001-03-27 20:48:01 +00:00
Mark Whitley bff6b18bf9 Applied patch from Gennady Feldman to fix a single-threaded syslogd bug that
turned up. This code needs to be tested on an embedded system, since that's
where the bug turned up in the first place.
2001-03-27 20:17:58 +00:00
Mark Whitley 2b549c3be0 Fixed the Makefile so busybox can link against libc5 again. Putting libbb.a at
the end broke it.
2001-03-27 18:22:41 +00:00
Mark Whitley 5cd2a2d53e In fact, socklen_t *is* defined by libc5. 2001-03-27 18:22:00 +00:00
Mark Whitley a82a00397f Fix to last patch: locale code should be 9, not 7. 2001-03-27 17:07:15 +00:00
Mark Whitley 1c6581a865 Applied patch from Vladimir N. Oleynik to add locale support to the shell per
bug report from Ralph Jones.
2001-03-27 16:35:16 +00:00
Mark Whitley af633757d3 Applied patch from Anthony Towns that he posted to Debian bug tracking. 2001-03-26 16:47:57 +00:00
Manuel Novoa III 049dc25fe7 Fix in_ether bug regarding hex digits reported by Jonas Holmberg <jonas.holmberg@axis.com>. 2001-03-26 16:26:16 +00:00
Eric Andersen 36eff9ac55 Bump version number to 0.51pre 2001-03-24 06:34:59 +00:00
Eric Andersen 6f3240abf9 xstrdup xargs cleanup from Jeff Garzik 2001-03-23 17:11:22 +00:00
Eric Andersen 6b2c23d847 xstrdup tftp cleanup from Jeff Garzik 2001-03-23 17:10:19 +00:00
Eric Andersen 21af752b04 Patch to use xfopen from Jeff Garzik 2001-03-23 17:09:15 +00:00
Eric Andersen f6aa13d403 -Wshadow tr fix from Jeff Garzik 2001-03-23 17:08:21 +00:00
Eric Andersen 82ab8da245 -Wshadow sh fix from Jeff Garzik 2001-03-23 17:06:01 +00:00
Eric Andersen 8ffaf8d139 -Wshadow logread fix from Jeff Garzik 2001-03-23 17:04:47 +00:00
Eric Andersen c54f9530ee -Wshadow loadacm fix from Jeff Garzik 2001-03-23 17:03:28 +00:00
Eric Andersen 08ff8a49ba includes cleanup from Jeff Garzik 2001-03-23 17:02:05 +00:00
Mark Whitley 0b4d73a53c Some minor wordsmithing, an extra item in the list of "things Busybox doesn't
need", example of a testcase, more janitorial items, and a whole new section
with guidelines on committing changes to CVS.
2001-03-22 22:59:33 +00:00
Eric Andersen 82bb8a2bf8 Patch from Dirk Behme <dirk.behme@de.bosch.com> to
add EM_MIPS_RS3_LE for mips
 -Erik
2001-03-22 19:01:16 +00:00
Eric Andersen 851895ab80 Clean up more local vars which shadow globals
-Erik
2001-03-21 21:52:25 +00:00
Eric Andersen 1ca20a7747 A nice patch from Larry Doolittle that adds -Wshadow and
cleans up most of the now-revealed problems.
2001-03-21 07:34:27 +00:00
Mark Whitley 7447642a47 Added a section on the available Busybox boot-floppy image. Also provided some
linkes to a Wired article on Midori Linux.
2001-03-20 19:57:30 +00:00
Mark Whitley 6f93277f56 Added adjtimex applet from Larry Doolittle. 2001-03-20 19:18:10 +00:00
Eric Andersen ba372620c2 Force applet_name to be "sh" when command prefaced by "-" 2001-03-20 17:39:53 +00:00
Eric Andersen 7ef1a5beb2 Fix up command line munging in init. Postpone the askfirst thing till
a bit later in run().
2001-03-20 17:39:08 +00:00
Eric Andersen 4ef37d0c17 chown was missing a ] in its usage msg 2001-03-20 01:06:14 +00:00
Eric Andersen 92d23245c9 Another cleanup patch from Jeff Garzik <jgarzik@mandrakesoft.com> 2001-03-19 23:49:41 +00:00
Eric Andersen 40eaa9f0bb Size optimization for rdate from Vladimir 2001-03-19 19:41:54 +00:00
Eric Andersen 8269396491 Simpify detection of no options. 2001-03-19 19:40:43 +00:00
Eric Andersen 2ccfef2004 Patch from Vladimir to move struct applet from busybox.c to applets.c,
which looks like the right place for such things to live.
2001-03-19 19:30:24 +00:00
Eric Andersen 23c1a18126 Per suggestion from Vladimir, no need to initialize these -- let the bss
do it.
 -Erik
2001-03-19 19:28:24 +00:00
Eric Andersen 7ef54de672 locale correction patch from Vladimir 2001-03-19 19:25:49 +00:00
Eric Andersen b183dfad2d Split error messages into separate files.
Update libbb.h, per suggestion from Vladimir, to include __attribute__((format
(printf ...))) stuff
 -Erik
2001-03-19 19:24:06 +00:00
Eric Andersen cc165b9083 Should exclude "i" option when not enabled. 2001-03-19 18:59:01 +00:00
Eric Andersen 00b0496e69 Doesn't need a "-" option -- getopt does that for us. 2001-03-19 18:57:08 +00:00
Eric Andersen 16f7015722 Patch from Vladimir to force interactiveFlag=FALSE when forceFlag=TRUE 2001-03-19 18:54:38 +00:00
Eric Andersen 7c25441792 getopt-ify rm so that BB_FEATURE_RM_INTERACTIVE will work 2001-03-19 18:52:37 +00:00
Eric Andersen c75586e06d Split libbb/pwd_grp_wrappers.c into 5 different libbb/my_* files.
-Erik
2001-03-19 18:37:42 +00:00
Eric Andersen 61173a5371 Fix to cmdedit.c from Vladimir 2001-03-19 17:48:55 +00:00
Eric Andersen fa513aab48 Some configuration adjustments from Vladimir 2001-03-19 17:25:21 +00:00
Eric Andersen 8b96032139 Fix a bug pointed out by Rob Landley <rlandley@austin.rr.com>, where
setup_sockaddr_in was zeroing the sizeof a pointer, not the sizeof the struct,
which was obviously what was intended.  Thanks Rob,
 -Erik
2001-03-17 05:43:39 +00:00
Eric Andersen 341744781a Patch from Larry and Vladimir to clean up sh.c and fix
shell expansion to work in non POSIX locales.
2001-03-17 00:20:10 +00:00
Eric Andersen 1a6f8cfadf update .cvsignore files to note new location of loop.h 2001-03-17 00:15:02 +00:00
Eric Andersen 8a6dbf6709 Patch from Pierre PEIFFER <pierre.peiffer@sxb.bsf.alcatel.fr>
that copes with the fact that processes may have been swapped
out.
2001-03-17 00:05:42 +00:00
Eric Andersen e2a3cd15a8 Stupid thinko. egrep tried to call init. Sigh. Fix from Christophe Boyanique 2001-03-16 23:49:20 +00:00
Eric Andersen aad1a88c76 Convert utility.c into libbb.a. It is now a whole pile of .c
files.  Clean up the resulting damage and fix up the makefile.
 -Erik
2001-03-16 22:47:14 +00:00
Eric Andersen dfba13d199 A few minor touchups. 2001-03-16 08:30:00 +00:00
Eric Andersen 704b2c2122 There was an unwanted extra newline, which prevented building
uudecode.  How did this sneak through the testing until now?
 -Erik
2001-03-16 08:06:30 +00:00
Eric Andersen 53b55ac08d Fix the make release target. 2001-03-16 07:43:53 +00:00
Eric Andersen c36c2ba598 Update webpage noting 0.50 release. 2001-03-16 07:16:12 +00:00
Eric Andersen 7f1978570f A patch from Andreas Neuhaus to be especially careful to not dup
any env variables when spawning child processes.
2001-03-16 01:14:04 +00:00
Eric Andersen 4aaefc2a50 Fix from Larry for glob problems.
-Erik
2001-03-15 23:01:19 +00:00
Eric Andersen c5b3242d3d Remove the "GPL2" bit, since it hung over the end of the line. 2001-03-15 22:58:11 +00:00
Mark Whitley 056960d8dc Applied patch from Larry Doolittle to fix problem where multibuild.pl would
build the wrong files. Made the same changes to multifeat.pl.
2001-03-15 22:14:26 +00:00
Eric Andersen 0d5051def0 Update files and version number prepratory to cutting a release.
-Erik
2001-03-15 22:12:43 +00:00
Eric Andersen 3a0057e2c5 Fix egrep 2001-03-15 21:33:33 +00:00
Mark Whitley f71378c4ad One tiny little missing newline that confused pod. 2001-03-15 21:20:25 +00:00
Mark Whitley 0a6f1d31e7 One tinly, little, missing newline that confused Pod. 2001-03-15 21:19:09 +00:00
John Beppu e708cb5f9a - generated middle section of busybox.pod w/ autodocifier.pl
- updated autodocifier.pl to use tab to indent example section
2001-03-15 21:08:01 +00:00
Eric Andersen a4edd0e946 A better fix. Read nextPtr before mem gets freed.
-Erik
2001-03-15 21:04:18 +00:00
Eric Andersen f9ff8a7d90 cmdedit.c bugfix patch from Vladimir.
-Erik
2001-03-15 20:51:09 +00:00
John Beppu af9e533a54 - properly indent Examples section in pod generator 2001-03-15 20:49:25 +00:00
Eric Andersen 48dcc16548 Don't confuse people. If the run 'ifconfig' and they didn't
compile with BB_FEATURE_IFCONFIG_STATUS turned on, it will
now print a message telling them as much.
 -Erik
2001-03-15 20:48:45 +00:00
Mark Whitley 730cdb1904 Reversed previous patch. The right way is to fix uClibc. 2001-03-15 19:39:40 +00:00
Eric Andersen 0d4e51d390 Prevent init from potentially using already freed memory when
deleting an initAction, fixing a bug pointed out by Andreas Neuhaus
 -Erik
2001-03-15 19:18:21 +00:00
Mark Whitley 0b57e28373 Applied patch from Andreas Neuhaus to fix namespace conflict that made busybox
not compile with uClibc.
2001-03-15 19:12:06 +00:00
Mark Whitley b0c2b7dfe3 dos2unix logread.c 2001-03-15 19:05:59 +00:00
Eric Andersen 2825ee8c2c Fix linuxrc define 2001-03-15 18:58:06 +00:00
Eric Andersen a8035a51be Move the warning msg after features.h gets pulled in.
-Erik
2001-03-15 18:20:23 +00:00
Mark Whitley 7384d7dce0 Added some tests for some recently found / fixed bugs in the shell. 2001-03-15 18:19:13 +00:00
Eric Andersen 0d3a02eba7 Update the documentation so examples are autoincluded in the output text.
Fix up docs/busybox.pod with the latest autogenerated output.
 -Erik
2001-03-15 18:14:25 +00:00
Eric Andersen 670bea210e Update the changelog, in preparation for making the 0.50 release 2001-03-15 17:56:44 +00:00
Eric Andersen d8adaa279e Update the olympus sections 2001-03-15 17:54:56 +00:00
Mark Whitley 3bf60aa723 If only BB_DPKG was enabled in Config.h, busybox would not build; it'd say:
dpkg.c:18: #error It looks like you are using libc5, which does not support
  dpkg.c:19: #error tfind().  tfind() is used by busybox dpkg.
  dpkg.c:20: #error Please disable BB_DPKG.  Sorry.
This was fixed by changing the || to an && in the preprocessor.
(We've changed the logic in there too many times.)
Found using multibuild.pl.
2001-03-15 17:39:29 +00:00
Mark Whitley e110ccb672 Removed leftover BB_FEATURE_KLOGD per report from Giulio Orsero 2001-03-15 17:30:07 +00:00
Manuel Novoa III 0e0883e0e9 Fix stupid cut-and-paste bug... output RX/TX bytes instead of RX/RX bytes. 2001-03-15 15:37:48 +00:00
Mark Whitley 038c8eb5a9 Applied patch from Erik Habbinga to fix a problem with an uninitialized
substitution delimiter.
2001-03-14 21:11:49 +00:00
Mark Whitley 7ddaf7caae Added a section to describe how to convert variables to K&R style using the
mk2knr.pl script. Also some minor cleanups.
2001-03-14 21:04:53 +00:00
Mark Whitley bac75ac2d5 Script that generates a script that will convert oddball variable names to K&R
style.
2001-03-14 21:04:07 +00:00
Eric Andersen 1ef92685cf Yesterday I make strsep_space include post-token whitespace,
so we should not be adding another " " between tokens.
 -Erik
2001-03-14 19:33:45 +00:00
Eric Andersen ce4a586edb I forgot to malloc space for the NULL.
-Erik
2001-03-14 18:57:54 +00:00
Mark Whitley 40e5e7c7ea Applied patch from Christophe Boyanique to add an egrep alias for grep. 2001-03-14 17:45:45 +00:00
Mark Whitley 20f61d35de The patch I previously applied from Brian Webb was 2 lines off. Oops. 2001-03-14 17:30:44 +00:00
Mark Whitley 44a9914709 Applied patch from Larry Doolittle to fix '>\na\n' bug. Should close bug #1132 2001-03-14 17:26:37 +00:00
Mark Whitley 2892c35bdb Applied patch from Giulio Orsero to fix some preprocessor bugs. 2001-03-14 17:18:52 +00:00
Eric Andersen 82d8502409 Fix from Manuel for a silly thinko on my part. 2001-03-14 17:15:45 +00:00
Eric Andersen 53f5061c7e Fix init so that checking for terminal devices is delayed until the
devices are actually used, thereby allowing devfsd based systems to
work.  This should fix bug #1133
 -Erik
2001-03-14 09:01:11 +00:00
Eric Andersen bdc8db9685 Use the system passwd and group stuff by default 2001-03-14 01:49:10 +00:00
Eric Andersen 741f2c9898 Fix mtab so it works on libc5 2001-03-14 01:48:10 +00:00
Eric Andersen b9a1e56a80 No reason to include fstab. It breaks libc5, does nothing for glibc.
-Erik
2001-03-14 01:43:29 +00:00
Eric Andersen 2b1c367a98 Amazing the difference between an "and" and an "or". 2001-03-14 01:36:52 +00:00
Eric Andersen 3c0b425cde dpkg used tfind, which doesn't work with libc5. Print a friendy error
should someone try to use it...
 -Erik
2001-03-14 01:31:11 +00:00
Eric Andersen 14e9e9d1ca Fix socklen_t for libc5 2001-03-14 01:23:07 +00:00
Eric Andersen 9c09e0eeaa The IPC_SYSLOG stuff should be off by default.
-Erik
2001-03-14 01:16:41 +00:00
Eric Andersen c319601db5 Some updates for libc5 2001-03-14 01:15:06 +00:00
Eric Andersen 4e7244e6b2 libc5 glob is pretty stupid and doesn't do GLOB_BRACE or GLOB_TILDE
-Erik
2001-03-14 00:49:52 +00:00
Mark Whitley 8658816f71 Added a dependency on BB_MKFS_MINIX to xfopen(). 2001-03-14 00:43:16 +00:00
Mark Whitley f594986b37 - Changed name of BB_FEATURE_SIMPLE_PROMPT to BB_FEATURE_SH_SIMPLE_PROMPT
- Set BB_FEATURE_SH_STANDALONE_SHELL and BB_FEATURE_SH_APPLETS_ALWAYS_WIN to
   be off by default
 - Set BB_FEATURE_SH_SIMPLE_PROMPT to be on by default
 - Added some more magic to the Olympus section to make all the dependencies
   on the shell, cmdline editing, tab completion and friend work properly.
 - Tidied up the Olympus section with some whitespace. Checked the various
   scrips that parse through there and the extra whitespace shouldn't break
   anything.
2001-03-14 00:29:14 +00:00
Mark Whitley c75f83d874 Some new testcases, some improvements to the tester.sh script. 2001-03-13 23:30:18 +00:00
Eric Andersen b3d6e2df95 Update the lash shell (hopefully the last time...) so things like
echo "foo   bar" and echo -n "foo\t\\\\\tbar" work as expected.
Merge prompt printing work from Vladimir.
 -Erik
2001-03-13 22:57:56 +00:00
Mark Whitley 798ab301c7 Added Midori Linux to the list of known projects that use Busybox. 2001-03-13 17:08:54 +00:00
Mark Whitley f6ba2da29f Credited Christophe Boyaniqu for interactive patch to rm. 2001-03-13 16:35:55 +00:00
Mark Whitley e0bf91d7c6 Applied patch from Christophe Boyanique to add -i support to rm. 2001-03-13 00:40:19 +00:00
Mark Whitley 53737c5421 Some fixlets that didn't get added in the last 'syslogd split' patch:
- BB_LOGREAD should not be in the applet section
	- BB_FEATURE_IPC_SYSLOG added to the feature section
	- Some voodoo added to the Olympus section
2001-03-12 23:55:56 +00:00
Mark Whitley 6bff9cc487 Added some comment lines in the header indicating that Gennady Feldman is the
maintainer of these three applets.
2001-03-12 23:41:34 +00:00
Mark Whitley bd2e42f162 Applied a patch from Brian Webb to fix a problem with mount on the Agenda PDA.
Apparently, the mount() call does not like taking a stack allocated pointer.
2001-03-12 23:17:26 +00:00
Mark Whitley 94fd480bab Applied patch from John Lombardo to fix OOM in insmod. 2001-03-12 23:08:34 +00:00
Mark Whitley 6317c4baf7 Applied patch from Gennady Feldman to split up syslogd.c into syslogd and
klogd (as it should be).
2001-03-12 22:51:50 +00:00
Eric Andersen 4987bbf979 A fix from Larry Doolittle for some nasty segfaults when sh.c tried to free a
corrupted cmd pointer, and where it would truncate a command line at the first
double space.
 -Erik
2001-03-12 21:36:49 +00:00
Mark Whitley 5ec5415402 Program for testing concurrent access to syslogd. 2001-03-12 20:00:00 +00:00
Mark Whitley 1a49fc5e92 Applied patch from Gennady Feldman to use single-thread instead of forking. 2001-03-12 19:51:09 +00:00
Manuel Novoa III fe4e13fb97 Add missing dependency -- interface.c needs get_kernel_revision. 2001-03-12 10:00:17 +00:00
Manuel Novoa III 22b889a998 Adjust ifconfig usage message for selected options and current functionality. 2001-03-12 09:58:51 +00:00
Manuel Novoa III 68ea1d0325 Reduced code size of interface. Support ifconfig -a and ifconfig interface
display.  Change %llu to %Lu in ifconfig for hacked unsigned long long support
in uClibc scanf.
2001-03-12 09:57:59 +00:00
Eric Andersen 1365bb7861 When using wordexp, only try to use the expand command
when something actually got expanded.  Skip it otherwise.
 -Erik
2001-03-10 07:12:12 +00:00
Manuel Novoa III 78f57460f2 Quick mod to enable option -a for ifconfig. 2001-03-10 02:00:54 +00:00
Mark Whitley d2117e9c82 Created new regression testing framework with a number of testcases (many more
can be added). Also changed 'test' target in makefile to run the new
tester.sh. (Hopefully, we should be able to remove all the tests/*.mk files
soon.)
2001-03-10 00:51:29 +00:00
Mark Whitley 09f4af5afd /* getopt not needed */ 2001-03-10 00:13:20 +00:00
Mark Whitley 827e45c518 Added some more '/* getopt not needed */' lines. 2001-03-09 23:59:51 +00:00
Manuel Novoa III fa45f22e50 Use perror_msg_and_die function where appropriate. 2001-03-09 23:06:15 +00:00
Eric Andersen d92168486b Fixed df.c so that nfs volumes will display properly (fixing bug #1113).
Problem was 512/1024 = 0 if you use longs, so I cast KILOBYTE to a double, then
cast the result back to an int after the math is done, letting C's type
promotion do its magic for the rest.
 -Erik
2001-03-09 22:42:26 +00:00
Eric Andersen 4aaf89f49f Silence a silly warning 2001-03-09 22:17:59 +00:00
Mark Whitley f90c28dd1e Applied patch from Jeff Garzik to getopt-ify rmmod. 2001-03-09 21:49:12 +00:00
Eric Andersen 8d4c397d9d Patch from Jeff Garzik marking a few 'getopt not needed' apps. 2001-03-09 21:28:09 +00:00
Eric Andersen 3e6ff9017f A cleanup patch from Jeff Garzik to static-ify a number of
namespace polluting things that really should be static.
2001-03-09 21:24:12 +00:00
Eric Andersen dd91724aa0 patch from Larry to fix pristine source builds 2001-03-09 20:47:27 +00:00
Eric Andersen 74e056bfc8 Fixed a couple more cases. $FOO/bar ${FOO} and such now work
without wordexp.  Of course for stuff like ${1:-foo} you still
need wordexp for them to work.
 -Erik
2001-03-09 20:34:46 +00:00
Eric Andersen 3c7361f53a Allow wordexp to be used if available 2001-03-09 19:45:26 +00:00
Eric Andersen ce89871ff7 Urg. Remove the debug noise 2001-03-09 19:43:57 +00:00
Eric Andersen 195743f195 Ok, sh.c should be working now. Many thanks to Larry Doolittle
for his timely help -- nearly all of the work in this patch is
his.
 -Erik
2001-03-09 19:21:37 +00:00
Eric Andersen eba8ed71f0 Patchs from Jeff Garzik <jgarzik@mandrakesoft.com> to cleanup
warnings with glibc 2.2 and use always use xfopen
 -Erik
2001-03-09 14:36:42 +00:00
Mark Whitley 9ba5bce06f Added script that tests turning on features in busybox one at a time and
compiling to see if things break. Initial revision.
2001-03-09 01:46:45 +00:00
Eric Andersen 01658a3eec Fix sh.c for the glab case. I was messing things up for
single argument commands.  It should now work as expected...
 -Erik
2001-03-09 01:24:02 +00:00
Eric Andersen 3dbf1e877a A '.' is a legal seperator. 2001-03-09 01:08:06 +00:00
Mark Whitley afffbfe8c4 Fix to trim to make it trim properly. 2001-03-09 00:55:34 +00:00
Eric Andersen b180dd9e50 Cleanup patch from Larry 2001-03-09 00:42:46 +00:00
Eric Andersen 13d1fa1d01 Add in 'trim' routine. Fix up sh.c so it works when wordexp
is not available.
 -Erik
2001-03-08 23:59:45 +00:00
Manuel Novoa III df351d6109 Improved port of ifconfig... smaller and with more features. 2001-03-08 22:57:00 +00:00
Eric Andersen 39eea898c4 Per Vladimir's suggestion, force the locale to POSIX for all
the scripts so busybox will install properly.
2001-03-08 21:42:11 +00:00
Mark Whitley 7e5291f111 Whitespace / formatting / bracket cleanup. 2001-03-08 19:31:12 +00:00
Eric Andersen 32f8c170b0 Remember to delete un-expandable variables, and do a better job of expanding
shell-specific things in case the wordexp implementation is broken (ie. the
stubbed out wordexp in uClibc).
 -Erik
2001-03-08 17:44:37 +00:00
Eric Andersen ca6045955d Rework environment variable handling to use wordexp, per a suggestion from
Larry Doolittle a couple of months ago.  This makes the stuff-expansion in lash
be ever so standards compliant.   This change needs testing by everyone, but
appears to be solid enough to let us close bug #1090.

It works for me; however, please test this change!
 -Erik
2001-03-08 17:17:13 +00:00
Mark Whitley e2c44fc966 Applied patch from Vladimir to fix bug where find would stop as soon as it hit
a perms error. Closes bug 1124.
2001-03-08 16:54:44 +00:00
Matt Kraai 5de909873a Eliminate superfluous test. 2001-03-07 21:45:13 +00:00
Mark Whitley 4cc8f31ffe Changed KILOBYTE, MEGABYTE, and GIGABYTE from #define to enum. 2001-03-07 18:00:44 +00:00
Mark Whitley ae5612ca6e Some minor cleanups to df.c. Also, with Erik's blessing, changed name of
'format' function to 'make_human_readable_str'.
2001-03-07 17:42:07 +00:00
Mark Whitley ae20128e9f Applied patch from Christophe Boyaniqu to remove double-slashes printed in
recursive_action.
2001-03-07 17:27:04 +00:00
Eric Andersen 26d53eb197 This patch by Vladimir and Larry saves a few bytes. 2001-03-07 06:33:01 +00:00
Eric Andersen ec9fad9a49 Static-ify a variable. make du work with all the human-readable variants
since my last pass only fixed 'du -h' but left the others broken.
2001-03-07 06:04:08 +00:00
Eric Andersen a7db19bb81 Fix up du so it behaves itself also.
-Erik
2001-03-07 03:53:40 +00:00
Eric Andersen 11ae573320 remove an unused variable 2001-03-07 03:51:27 +00:00
Eric Andersen 7850f1e2ac Rewrite of format so it behaves itself
-Erik
2001-03-07 03:50:57 +00:00
Eric Andersen 5986f8d1c6 Fix up df so it works properly
-Erik
2001-03-07 03:50:03 +00:00
Eric Andersen 651f8c04ef Fix up ls.c to ensure human readable works properly in all cases 2001-03-07 03:48:02 +00:00
Mark Whitley 6c563bc1a1 Thought of another janitorial item for the list. 2001-03-06 23:16:13 +00:00
Eric Andersen 8b728a25a3 I made these little simplifications a while back, bug forgot to
check this stuff in.
 -Erik
2001-03-06 23:14:43 +00:00
Eric Andersen 702ec5926f Fix the memory leak. No really this time.
-Erik
2001-03-06 22:17:29 +00:00
Mark Whitley 8bb7df49c2 Applied patch from Vladimir Oleynik via Magnus Damm that removes newlines from
error_msg() calls and uses 'return EXIT_SUCCESS' instead of return 0.
2001-03-06 20:58:48 +00:00
Eric Andersen 0f430e34af Fix up some silly macros and use xmalloc and friends exclusively. 2001-03-06 20:54:43 +00:00
Eric Andersen 36278b9576 Fix func prototype 2001-03-06 20:47:31 +00:00
Eric Andersen 54851d3c65 Fixed a memory leak in lash. It seems that close_all was calling close()
directly instead of calling mark_closed(), which allowed the memory allocated
by mark_open() to never be freed.
 -Erik
2001-03-06 20:44:39 +00:00
Eric Andersen 07f2f3917a Close open files before calling builtin_exec(). I've tested this
and it fixes bug #1121.
 -Erik
2001-03-06 20:28:22 +00:00
Eric Andersen 1a046d5f9d Bug 1110 reported that the LOOP_GET_STATUS ioctl apparently returnes non-zero
error messages, contrary to the documentation.  Whatever.  This patch from
zhaoway <zw@debian.org> looks safe enough.
 -Erik
2001-03-06 19:35:58 +00:00
John Beppu 138ece09b5 minor cleanup 2001-03-06 19:25:25 +00:00
Eric Andersen e6c4de03c6 First pass at trying to retrofit a changelog for 0.50. Please everyone
look over this and if I forgot something, misattributed your work, or
spelled something badly, please let me know.
 -Erik
2001-03-06 18:46:10 +00:00
Eric Andersen f15d4dad66 Add in a first pass at ifconfig status reporting. It took a long while
hacking on the mess in net-tools-1.59, but it currently adds 12k and
supports ethernet, loop, ppp, and treats everything else as a generic
interface.  Works ok for me.
 -Erik
2001-03-06 00:48:59 +00:00
Eric Andersen 5efa2291aa Fix up the freshmeat appindex record. 2001-03-05 18:26:50 +00:00
Eric Andersen c27b9544b6 Make sure libpwd.a is linked _last_ so it overrides the system pwd/grp
implementation.  It wasn't doing that as expected...
2001-03-05 17:57:34 +00:00
Eric Andersen 47cdcdd359 Try to do a little better at documenting how to use
alternate C libraries, thanks to David Douthitt.
2001-03-05 17:08:52 +00:00
David Kimdon 21b7459add add wget, tr, telnet, ping, md5sum and loadkmap to .deb 2001-03-05 08:43:26 +00:00
Eric Andersen afbff22e6e Enable INSTALLER for the deb 2001-03-05 04:00:06 +00:00
Eric Andersen 452fd33ffa Patch from Vladimir to make sure PATH is set correctly. 2001-03-04 06:47:33 +00:00
Eric Andersen 076cdc24fc If umount2 is not available, stub it out. 2001-03-04 06:07:34 +00:00
Mark Whitley 9ead68975c Added some words on use of getopt in applets. 2001-03-03 00:44:55 +00:00
Glenn L McGrath 323434be42 Dont try to automount some specific filesystem types 2001-03-02 22:21:34 +00:00
Mark Whitley 446dd27843 Applied patch from Vladimir N. Oleynik that fixes incorrect behaviour in
recovery_mode and changed option processing.
2001-03-02 20:00:54 +00:00
Mark Whitley 42ab250709 Removed section on testing that is now in contributing.txt. 2001-03-02 19:15:01 +00:00
Mark Whitley 3b565cdf91 Added 'How to contribute to Busybox' doc. 2001-03-02 19:14:25 +00:00
Mark Whitley 85adecb668 Whoops! BB_TFTP should prolly be off by default. 2001-03-02 19:11:26 +00:00
Mark Whitley 450736cd3c Added Magnus Damm's tftp applet to Busybox. 2001-03-02 19:08:50 +00:00
Mark Whitley 016771834a Changed exit code from -1 to 0 when busybox is invoked with no args.
(Closes bug #1114.)
2001-03-02 17:47:17 +00:00
Mark Whitley 39842defda Applied patch from David Douthitt to fix build error in df.c when
BB_FEATURE_HUMAN_READABLE was disabled.
2001-03-01 18:51:33 +00:00
Eric Andersen de4406747b Bah. I missed a header file. 2001-03-01 07:55:49 +00:00
Eric Andersen 7b91f02021 Reduce the size of mount (and bypass /proc/filesystems) by using the sysfs
system call, based on work done by Glenn McGrath in December.
 -Erik
2001-03-01 07:50:04 +00:00
Matt Kraai 93ba60f01d Keep trying if an NFS mount fails, and eliminate a call to exit(3). 2001-02-28 15:33:12 +00:00
Eric Andersen 1b6cff3df4 libpwd was getting added twice. 2001-02-27 22:24:45 +00:00
Mark Whitley 4f76bb6f3e Little patchlet to make linking against libc5 work a little better 2001-02-27 19:53:48 +00:00
Eric Andersen 4142d4dc66 Patch from Vladimir N. Oleynik to save 128 bytes by moving error
checking for some my_* functions to utility.c
2001-02-27 18:22:03 +00:00
Mark Whitley e677dfedd1 Applied patch from Magnus Damm <damm@opensource.se> to fix a 'inner scope var
masking outer scope var with same name' bug that was preventing the loopback
device from being unmounted if mount() fails.
2001-02-26 17:45:58 +00:00
John Beppu d11578f916 - changed the way POD is generated such that the dashed
line appears at the bottom instead of the top.  The
  indentation semantics of POD make the first item in
  the (=over,=back) block look weird the other way.
- implemented a way to encode example usage into usage.h
  One would define a macro called "${applet}_example_usage"
  which would expand to the example text.
- The example usage is considered optional, but trivial and
  full usage are not.

  Here's an example using chown.

---- before

#define chown_trivial_usage \
	"[OPTION]...  OWNER[<.|:>[GROUP] FILE..."
#define chown_full_usage \
	"Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" \
	"\nOptions:\n" \
	"\t-R\tChanges files and directories recursively."
#define chown_example_usage \
	"\t$ ls -l /tmp/foo\n" \
	"\t-r--r--r--    1 andersen andersen        0 Apr 12 18:25 /tmp/foo\n" \
	"\t$ chown root /tmp/foo\n" \
	"\t$ ls -l /tmp/foo\n" \
	"\t-r--r--r--    1 root     andersen        0 Apr 12 18:25 /tmp/foo\n" \
	"\t$ chown root.root /tmp/foo\n" \
	"\tls -l /tmp/foo\n" \
	"\t-r--r--r--    1 root     root            0 Apr 12 18:25 /tmp/foo\n"

---- after

=item I<chown>

chown [OPTION]...  OWNER[<.|:>[GROUP] FILE...

Change the owner and/or group of each FILE to OWNER and/or GROUP.

Options:

	-R	Changes files and directories recursively.

Example:

	$ ls -l /tmp/foo
	-r--r--r--    1 andersen andersen        0 Apr 12 18:25 /tmp/foo
	$ chown root /tmp/foo
	$ ls -l /tmp/foo
	-r--r--r--    1 root     andersen        0 Apr 12 18:25 /tmp/foo
	$ chown root.root /tmp/foo
	ls -l /tmp/foo
	-r--r--r--    1 root     root            0 Apr 12 18:25 /tmp/foo


-------------------------------
2001-02-26 02:50:11 +00:00
Eric Andersen 2bf658d5cd This patch, from Quinn Jensen <jensenq@lineo.com>, adds MIPS support
to busybox insmod.  Thanks Quinn!!!
 -Erik
2001-02-24 20:01:53 +00:00
Eric Andersen afeb96547f Make output match the real lsmod -- print (autoclean) type
stuff first not last.
 -Erik
2001-02-24 19:51:54 +00:00
Eric Andersen d160a27ec1 Stub out the syscall, not the whole application. The stubbed
out syscall sets errno properly and whines about missing kernel
support.
 -Erik
2001-02-24 19:17:07 +00:00
Eric Andersen dc12190ba2 The usage message for syslogd had stuff longer then 80 chars and wrapped. 2001-02-24 18:52:36 +00:00
John Beppu 37977622c4 ... 2001-02-24 14:44:25 +00:00
John Beppu 7d597c4833 refinement 2001-02-24 14:37:48 +00:00
John Beppu dbfff6cbde formatting ... 2001-02-23 17:55:03 +00:00
John Beppu e6967b20cb Added some documentation and made --sgml use sgml_from_usage().
pod_from_usage() is the default generator.
2001-02-23 17:51:08 +00:00
Eric Andersen 3757f98d86 Another usage cleanup from kent robotti 2001-02-23 17:47:51 +00:00
John Beppu 8373e70c55 During POD generation, it inserts a blank line before lines
that were intended to be indented.
2001-02-23 17:41:41 +00:00
Eric Andersen 7a9cc2dcdd More cleanups 2001-02-23 16:58:44 +00:00
John Beppu 15f9b92127 forgot to remove some debugging noise 2001-02-23 16:16:08 +00:00
John Beppu df1e9daf30 This one should be able to deal with the USAGE macros a little
more robustly.  I also blow away any USAGE_NOT_\w+ macros.
2001-02-23 16:15:34 +00:00
Eric Andersen ed0d958c3e Make HUMAN_READABLE be single argument like the others. 2001-02-23 13:23:03 +00:00
John Beppu 2498b155fd forgot a comma. 2001-02-23 13:04:39 +00:00
Eric Andersen a0cfe94c4e More usage cleanups from kent robotti. I know some of these were
applied previously but apparently lost with some of the latest changes.
2001-02-23 10:07:09 +00:00
Eric Andersen b83ffafc15 Fix up a stupid mistake caught by David Whedon <dwhedon@gordian.com> 2001-02-23 06:36:53 +00:00
David Kimdon 56082dc2ae space after \ make preprocessor sad 2001-02-23 06:03:22 +00:00
David Kimdon 68c1d8400c utility.c must include stdarg.h 2001-02-23 03:55:24 +00:00
John Beppu b249fbb1dc I can't leave it alone. 2001-02-23 03:12:45 +00:00
John Beppu 8c16bc5012 minor cleanup... all that's left to do is
* make headers and footers for both the POD and SGML content
* make an SGML generator
* finish the command-line handling

Also, some of the documentation in usage.h will have to
be adjusted.  expr needs some lines to be indented, and
ls has a stray comma.  I may have missed some things...
but it looks OK for the most part.
2001-02-23 02:54:31 +00:00
John Beppu 4a25d8c9c3 This is the remixed autodocufier.pl. 2001-02-23 02:33:28 +00:00
Eric Andersen 0ed9923887 Stub out pivot_root so it won't fail to compile.
-Erik
2001-02-23 02:31:03 +00:00
Eric Andersen 3574b70efc Somewhere along the line, MAKE_LINKS got broken, thereby breaking
'make install'.  Fix that.
2001-02-23 02:16:29 +00:00
Eric Andersen 8079b155c2 Argh. I should know to compile first. 2001-02-23 02:04:33 +00:00
Eric Andersen bbc8e4789f Only default to BB_FEATURE_NEW_MODULE_INTERFACE when
BB_FEATURE_OLD_MODULE_INTERFACE is not defined.
 -Erik
2001-02-23 02:00:35 +00:00
Eric Andersen 2f3105725f Make utility.c only define query_module when BB_FEATURE_NEW_MODULE_INTERFACE
is enabled.
 -Erik
2001-02-23 01:58:18 +00:00
Eric Andersen 5723934f7c Yet another fix. I think I got it this time.
-Erik
2001-02-23 01:39:26 +00:00
Eric Andersen 41492d6c23 I should be more careful... 2001-02-23 00:05:56 +00:00
Eric Andersen c163e5107f Turn off the printf attribute for the ?error_msg* functions, since it
is ok to pass them a NULL, unlike printf.  This silences a pointless
warning message.
 -Erik
2001-02-22 23:38:48 +00:00
Eric Andersen 544891dd26 Add in kent robotti's updated dos2unix.c 2001-02-22 23:37:30 +00:00
Eric Andersen adea7a6101 Fix up Makefile -- uClibc nfs works these days 2001-02-22 23:36:30 +00:00
Eric Andersen 4b2e69a1cf Commit a few updates to the usage messages. 2001-02-22 23:32:59 +00:00
Eric Andersen e13bc0bc68 First pass at making up an automagical usage message extractor, which
will be used (when it works) to autogenerate documentation.  Based on
code written by Mark Whitley.
2001-02-22 22:47:06 +00:00
Eric Andersen ffc40bf3de Account for remainder, and reset page_height for each and every page. 2001-02-22 21:49:32 +00:00
Eric Andersen b2007bffc5 Make busybox and busybox-static conflict/replace each other 2001-02-22 05:21:35 +00:00
Eric Andersen 5d9cad0253 Fix malformed build-depends. Update list of bugs to close
-Erik
2001-02-22 05:08:16 +00:00
Eric Andersen 7aa1f5c42a Make md5sum not display filename when reading stdin
-Erik
2001-02-22 04:59:16 +00:00
Eric Andersen dbcd8ce464 Make init compile when DEBUG_INIT is enabled
-Erik
2001-02-22 04:55:33 +00:00
Eric Andersen 7e9276b50a Another update to the way usage messages are done by Evin Robertson
<nitfol@my-deja.com>, which makes things just a little bit smaller, but makes
usage.h more readable/maintainable IMHO.
 -Erik
2001-02-22 01:15:47 +00:00
Eric Andersen 8fc300976f Revert my change to do extra termType checking. That is done elsewhere.
Silly me.
 -Erik
2001-02-22 00:50:20 +00:00
Eric Andersen be30a6b8b0 Adjust the terminal height for any overlap, so that no lines
get lost off the top
 -Erik
2001-02-22 00:22:46 +00:00
Eric Andersen 54006bce25 Oops! I left in my debug noise. 2001-02-21 00:27:22 +00:00
Eric Andersen 7c3e7ac940 df was totally broken. So I fixed it.
-Erik
2001-02-21 00:24:51 +00:00
Mark Whitley 8d7bdc9deb Small patch from Kent Robotti to show megabytes in human-readable output. 2001-02-20 21:57:55 +00:00
Eric Andersen 9e37007edb Minor cleanup. 2001-02-20 21:52:49 +00:00
Eric Andersen 90fe7fea10 Apply a patch from Magnus Damm <damm@opensource.se> to support
powerpc with busybox insmod
 -Erik
2001-02-20 20:47:08 +00:00
Eric Andersen 477aedd77f Commit a patch from Erik Gustavsson <cyrano@algonet.se>, to allow
environment variables set from the kernel command line to be inherited
bu application programs.  Slightly changed to special case handling of
TERM, so that it has sane defaults when on a serial console.
 -Erik
2001-02-20 18:01:50 +00:00
Eric Andersen 5165fbed63 Oops. Since dirent.h depends on BB_FEATURE_SH_TAB_COMPLETION, put it
after busybox.h is included.
2001-02-20 06:42:29 +00:00
Eric Andersen caeeb36784 This fixes lash so it handles environment variable expansion, regardless
of where the environment variables are located in an argument.  This allows
things like 'echo foo$1$SHELL' to expand the same way bash would expand it.
Of course, to make this work I introduced a memory leak, and I am too tired
to find a way to fix it.
 -Erik
2001-02-20 06:38:44 +00:00
Eric Andersen a183f05825 Cleanup the use of 'find' to prevent error msgs.
-Erik
2001-02-20 06:22:54 +00:00
Eric Andersen f1142c5b11 Oops. Put time.h after busybox.h, so we can check for BB_FEATURE_LS_TIMESTAMPS
-Erik
2001-02-20 06:16:29 +00:00
Eric Andersen cbe31dace5 It turns out that DODMALLOC was broken when I reorganized busybox.h
header file usage before the 0.49 release.  To fix it, I had to move
the '#include "busybox.h"' to the end of the list of #include files.
 -Erik
2001-02-20 06:14:08 +00:00
Eric Andersen 94456f5984 Put back Vladimir's testing defines, which I mistakenly removed. 2001-02-18 20:26:48 +00:00
Eric Andersen 12dceb1147 A few more cleanups from Vladimir. 2001-02-18 20:15:36 +00:00
Eric Andersen 963791a9e9 Another patch from Vladimir to eliminate obsolete junk. 2001-02-18 20:13:18 +00:00
Eric Andersen f1bbb22dca A small cleanup by Vladimir 2001-02-18 20:12:25 +00:00
Eric Andersen f57a832063 Remove leftover junk 2001-02-18 20:11:38 +00:00
Eric Andersen b50da53e0c Get rid of long stale usage message code.
-Erik
2001-02-17 16:52:35 +00:00
Eric Andersen 3d20f772c2 A bunch of usage clenups from kent robotti <robotti@metconnect.com>
-Erik
2001-02-17 16:49:00 +00:00
Eric Andersen 966b3a6f79 More updates from Larry Doolittle. Don't use basedir, Don't assume
random makefiles are going to work with busybox.
2001-02-17 15:56:52 +00:00
Eric Andersen 1cf8166329 More updates. 2001-02-17 15:55:15 +00:00
Eric Andersen 47aea4ee71 Ignore applet_source_list 2001-02-17 03:08:32 +00:00
Eric Andersen 19f86207f5 Update the build system for pristine source directory builds. This
update is primarily work done by Larry Doolittle, but I did some
touchups of my own to make it work for me,
 -Erik
2001-02-17 00:42:47 +00:00
Eric Andersen 69c8572f29 Update the debian build stuff
-Erik
2001-02-17 00:41:05 +00:00
Eric Andersen f6a7227fd6 Throw out the obsolete INIT_CHROOT junk 2001-02-17 00:40:32 +00:00
Eric Andersen 28a78ab62c Several features were hard coded on. Stop that. List tab completion
as working (thanks Vladimir!) and taking 4k.
 -Erik
2001-02-16 20:26:50 +00:00
Eric Andersen 6faae7deb4 Commit Vladimir's latest cmdedit. I modified it slightly to ensure
parse_prompt() would be called before cmdedit_init(), since cmdedit_init()
calls cmdedit_setwidth() which uses cmdedit_prmt_len, which is set by
parse_prompt().  Also, added a mod, so very narrow terminals should now wrap
properly...  This is working very nicely for me -- Vladimir has done some
very good work.
2001-02-16 20:09:17 +00:00
Eric Andersen 361ee514c6 Revert multibuild.pl change. 2001-02-16 19:07:21 +00:00
Eric Andersen ca0f458ada Regression testing bugfixes from Larry Doolittle. As an aside,
can I just say how much I am looking forward to having 0.50
released, so we can address this #define stupidness properly
by building a static libbusybox, and then letting the linker
sort out the dependancies....  Ahh, that will be much nicer.
 -Erik
2001-02-16 18:43:54 +00:00
Eric Andersen 733c4ad6eb Do usage messages the same way all other apps fo them.
Skip printing of available options (can't do this easily).
Based on a patch by Larry Doolittle.
 -Erik
2001-02-16 18:41:12 +00:00
Eric Andersen fa4f146d7d Patch from Larry Doolittle to cross things in multibuild.pl 2001-02-16 18:37:00 +00:00
Eric Andersen 5f2c79d8c7 Make ar be crossed. 2001-02-16 18:36:04 +00:00
Eric Andersen af12bc6de4 Make dpkg require dpkg-deb 2001-02-16 18:35:06 +00:00
Glenn L McGrath 3f5bcbfa3c Fix warning for implicit declaration of time() 2001-02-16 10:33:30 +00:00
Glenn L McGrath a9c69762ba Fix compile error, sync() always returns 0 anyway. 2001-02-16 10:21:35 +00:00
Mark Whitley 825ae5a166 Another small formatting change from Larry Doolittle. 2001-02-15 23:31:40 +00:00
Mark Whitley 99806ad2bd Applied patch from Larry Doolittle that does the following:
- style changes
 - It actually returns the code computed by INET_setroute (wasn't being done
   properly before)
 - The displayroute() format string now matches net-tools
2001-02-15 23:00:48 +00:00
Eric Andersen 11b7a1deb7 Acknowledge Kenneth Chalmers ln fix. 2001-02-15 20:13:59 +00:00
Eric Andersen d69d2da165 use perror_msg instead of perror to print the applet name.
-Erik
2001-02-15 20:12:05 +00:00
Eric Andersen b50d707633 fix a few mallocs to be xmallocs.
-Erik
2001-02-15 19:50:11 +00:00
Eric Andersen 02b9f42a27 Patch from Matt Kraai to fix bug #1103. I've tested it,
and it indeed seems to fix things.
 -Erik
2001-02-15 19:07:43 +00:00
Eric Andersen 81bcc92c32 Fixed 'ls -s' so it actually displays block sizes again.
-Erik
2001-02-15 18:59:02 +00:00
Eric Andersen 8305006f7c Make usage.c depend on usage.h
-Erik
2001-02-14 21:52:18 +00:00
Eric Andersen c1c43113b4 Fins find message. 2001-02-14 21:51:54 +00:00
Eric Andersen 3ec8ffb121 I forgot to add usage.h, so here it is, with a few extra cleanups.
Also update show_usage to handle the updated usage.h.  Again,
nearly all the work to get usage.h into shape was done by
Manuel Novoa III.
 -Erik
2001-02-14 21:46:30 +00:00
Eric Andersen 67991cf824 This patch, put together by Manuel Novoa III, is a merge of work
done by Evin Robertson (bug#1105) and work from Manuel to make
usage messages occupy less space and simplify how usage messages
are displayed.
2001-02-14 21:23:06 +00:00
Eric Andersen 68be2ab914 implemented displayroute() based on a patch from Vladimir N. Oleynik,
so now route behaves as expected w/o any arguments.
2001-02-14 19:26:39 +00:00
Eric Andersen 98e599ca06 Commit Vladimir's latest version of stty.c. Nice work.
-Erik
2001-02-14 18:47:33 +00:00
Eric Andersen ec45595300 Add in ifconfig and route 2001-02-14 08:11:27 +00:00
Eric Andersen 88a5ceb450 Bump rev to 0.50pre. 2001-02-14 07:55:19 +00:00
Eric Andersen fc83c4c353 Several cleanups from Manuel Novoa III.
get_kernel_revision --  size reduction
        NOTE: may want to combine with get_kernel_version in insmod???

parse_mode -- size reduction, multiple settings with "," now work correctly,
        sticky-bit setting now implemented

process_escape_sequence -- size reduction, octal code to big for char bug fixed

format -- size reduction, val > LONG_MAX and hr = 1 printing bug fixed (was %ld),
2001-02-14 07:15:30 +00:00
Eric Andersen 6fd8c664c1 Apply a patch from Evin Robertson -- new pivot_root applet.
-Erik
2001-02-13 20:04:30 +00:00
Glenn L McGrath 3af1f88725 Closer integration with dpkg-deb and other busybox functions.
Hopefully simplified some code (works for me).
2001-02-12 11:33:09 +00:00
Glenn L McGrath dadf9c6dcd New dpkg-deb option, warning about dpkg usage 2001-02-12 11:27:45 +00:00
Glenn L McGrath 821fbf0f42 New option 'list' produces output that can be used for the packages .list file.
Will be used be bb dpkg
2001-02-12 11:16:26 +00:00
Glenn L McGrath bc9afadecd New function, deb-extract to be used by dpkg, code cleanups. saves some bytes 2001-02-11 03:32:41 +00:00
Glenn L McGrath 728875f340 Consmetic changes 2001-02-11 03:15:57 +00:00
Glenn L McGrath 631064613f More style changes 2001-02-11 01:40:23 +00:00
Glenn L McGrath 0c9d77ccfd Style changes; use get_line_from_file from utilities 2001-02-11 00:17:22 +00:00
Glenn L McGrath de556615dc BB_DPKG uses copy_file 2001-02-10 14:53:44 +00:00
Glenn L McGrath 510f0ddafa Use copy_file from utilty.c, remove some char defines 2001-02-10 14:53:08 +00:00
Glenn L McGrath 649968ceb1 Bug fix, rename status file, cleanups 2001-02-10 14:26:48 +00:00
Glenn L McGrath af8c65deaa Replace status defines with const int to conform to sytle guide, adds 32 bytes 2001-02-10 03:19:51 +00:00
Glenn L McGrath c900575dc4 Initial import 2001-02-10 02:05:24 +00:00
Glenn L McGrath c30ab0f4a8 New applet: dpkg 2001-02-10 02:04:40 +00:00
Matt Kraai e78fd0f721 Fix typo. 2001-02-09 18:10:53 +00:00
Mark Whitley 2fd52989f7 Implemented -A, -B, and -C flags with BB_FEATURE_GREP_CONTEXT option set. 2001-02-09 00:41:10 +00:00
Mark Whitley d238a7bcc8 Minor cleanups and clarifications. 2001-02-09 00:28:59 +00:00
Matt Kraai 1d70267450 Add listening support. 2001-02-07 04:09:23 +00:00
Matt Kraai df8ccb6350 Added documentation for new find options. 2001-02-07 04:05:35 +00:00
Matt Kraai 096370d349 Reworked find with David Douthitt to support -type, -perm, -mtime, and
other improvements.
2001-02-07 03:52:38 +00:00
Matt Kraai a164c647ac Make suffix_mult structures const. Thanks to Vladimir N. Oleynik. 2001-02-05 17:50:03 +00:00
Mark Whitley 925edb828d Added some more on paren spacing and a section on testing guidelines. 2001-02-03 00:20:14 +00:00
Eric Andersen c3fc3c5e7a It seems I stupidly checked in a silly test I was making.
-Erik
2001-02-02 15:15:36 +00:00
Eric Andersen 29cff26f32 After testing multi-build, I stupidly committed Config.h
with nearly everything turned off.  Doh!
 -Erik
2001-02-02 01:08:22 +00:00
Mark Whitley 76c5e60d54 Patch from Chris Jaeger that makes turning on and off options in the makefile
a bit less error prone by calling 'strip' on makefile vars before performing
truth tests against them.
2001-02-02 01:07:17 +00:00
Eric Andersen af4ac77d9d Apply a patch from Larry Doolittle to add "-all" and "-none" switches
to multibuild.pl.  I did a little formatting adjustments to make it
_very_ obvious when things stop working.  I also removed the USE_PROCFS
config option -- just do the right thing when USE_DEVPS_PATCH is enabled.
 -Erik
2001-02-01 22:43:49 +00:00
Mark Whitley b5c29850e3 Tightened things up a bit, saved 20 bytes, and made the code a bit clearer in
the process.
2001-02-01 21:02:41 +00:00
Mark Whitley 065c7e779a Applied patch from Chris Jaeger <cjaeger@ensim.com> to do better checking for
NFS_MOUNT_VERSION, depending on which kernel you're running.
2001-02-01 19:51:13 +00:00
Mark Whitley 9b300d0b1f Buglet: 'tabstops' is unused if BB_FEATURE_AUTOWIDTH is not defined. 2001-02-01 19:39:43 +00:00
Matt Kraai f2cc2762bb Create find_applet_by_name function. Save 32 bytes. 2001-02-01 19:21:20 +00:00
Matt Kraai 05e782ddd3 Fix wget error message and add (and use) chomp library function. 2001-02-01 16:49:30 +00:00
Eric Andersen bd018b1bab Make old compilers not choke -- define the attribute in the func prototype. 2001-01-31 23:00:46 +00:00
Matt Kraai dd19c69904 Removed trailing \n from error_msg{,_and_die} messages. 2001-01-31 19:00:21 +00:00
Mark Whitley 63ec273245 Added floppyfw to list of known projects using BusyBox. 2001-01-31 18:33:20 +00:00
Eric Andersen 82d5e59ea2 xfopen now used by wget
-Erik
2001-01-31 17:50:35 +00:00
Eric Andersen 79e898ac0e Patch from Vladimir N. Oleynik to simplify wget file opening
using xfopen (which is what everything should be using).
2001-01-31 17:49:47 +00:00
Eric Andersen 65225df2dc Cleanup patch from Vladimir N. Oleynik.
* mkdir: remove 3 lines in source code.
    * mkfs_minix: save 32 bytes, remove 4 bugs.
    * mkswap: save 64 bytes, remove 1 bug.
2001-01-31 17:35:02 +00:00
Eric Andersen 53cfb7e231 Patch from Vladimir N. Oleynik to simplify/cleanup a few things in init.c 2001-01-31 17:29:47 +00:00
Eric Andersen 704d2a6c43 Patch from Vladimir N. Oleynik to simplify how it decides which
app was invoked.  This removes several strcmp calls.
2001-01-31 17:29:12 +00:00
Eric Andersen 39573f7130 Wrap a table (bg set to black, width=80%) around the screenshot
so it doesn't look like crap in Netscape.  Should look fine in
Mozilla either way.  I think.
 -Erik
2001-01-31 17:14:17 +00:00
Matt Kraai 18d5064c47 Make it validate. 2001-01-31 02:13:05 +00:00
Matt Kraai 9ba0daf4ba Close IMG tag. 2001-01-31 01:59:46 +00:00
Eric Andersen 93a8e2e64b Patch from Larry Doolittle to reduce the chance that fussing with VPATH will
break cross-compilation.
 -Erik
2001-01-31 01:38:05 +00:00
Eric Andersen 306f4fe480 If the ioctl fails to tell us the winsize, default to 79.
-Erik
2001-01-31 00:30:45 +00:00
Eric Andersen 22332fd26f Patch from Bryan Rittmeyer -- be more conservative by default
with the lash prompt.
 -Erik
2001-01-30 23:40:39 +00:00
Mark Whitley ac21e93a3f Added a new screenshot of Busybox. :-) 2001-01-30 23:37:15 +00:00
Eric Andersen 4bbdd788e0 Fix the pwd and group functions. The bb_ stuff was a leftover from
a brief past that mercifully (except for this) never made it into CVS.
 -Erik
2001-01-30 22:23:17 +00:00
Eric Andersen 30f64c3aa2 Fix a stupid typo -- bug found by Larry Doolittle. 2001-01-30 19:23:46 +00:00
Mark Whitley 8526067336 Applied patch from Larry Doolittle to use preprocessor for defining
NFS_MOUNT_VERSION.
2001-01-30 18:53:42 +00:00
Eric Andersen e57d54b456 Fix ls behavior for broken or very narrow terminals. Fix my_*
functions so they comply with the original interface (i.e. don't
exit on error, stringify uids and gids when no amtching name found).
 -Erik
2001-01-30 18:03:11 +00:00
Matt Kraai 201dc0d5a9 Test applets containing numbers in their name. Thanks to Larry Doolittle. 2001-01-29 19:00:48 +00:00
Matt Kraai ceade5c856 Fix missing header file. 2001-01-29 18:41:12 +00:00
Eric Andersen 8ec10a9483 Fix up copyright msgs. Bump version to 0.49 in preparation for
a release.  Update the website with release details.
 -Erik
2001-01-27 09:33:39 +00:00
Eric Andersen 90ca2848fd Fix some formatting 2001-01-27 08:32:57 +00:00
Eric Andersen ed3ef50c23 Fix header file usage -- there were many unnecessary header files included in
busybox.h which slowed compiles.  I left only what was needed and then fixed up
all the apps to include their own header files.  I also fixed naming for pwd.h
and grp.h functions.  Tested to compile and run with libc5, glibc, and uClibc.
 -Erik
2001-01-27 08:24:39 +00:00
Eric Andersen ab050f5522 Add in a patch to make busybox use the normal pwd.h and grp.h
functions.  Add in simple implementations of these functions,
which can, optionally, be used instead of the system versions.
 -Erik
2001-01-27 06:01:43 +00:00
Mark Whitley 3654ca56fa Applied patch from Larry Doolittle to list supported arches, libcs and kernels 2001-01-26 20:58:23 +00:00
Mark Whitley 4e33875759 Applied patch from Vladimir N. Oleynik <dzo@simtreas.ru> to do tab-completion
in Busybox shell.  (Thanks, Vlad.)
2001-01-26 20:42:23 +00:00
Eric Andersen a68b21a28e Cleanup patch from larry doolittle
-Erik
2001-01-26 20:31:02 +00:00
Mark Whitley 6e25f92636 Fixed a li'l thinko. 2001-01-26 19:19:23 +00:00
Eric Andersen a528dc7071 Fix my braindamage -- remove termios and sighandling since they are not
needed at all.  My bad.
 -Erik
2001-01-26 18:30:12 +00:00
Eric Andersen 1e4b957ac3 I am an idiot. Looking over my patch, ls doesn't need to do anything
more then the ioctl to get the win size.   None of the termios handling
crap is needed.
 -Erik
2001-01-26 18:09:13 +00:00
Eric Andersen 5c9c8b4b26 Make cin be static 2001-01-26 06:50:46 +00:00
Eric Andersen d5cad14b11 Update the arch-not-yet-supported msg to be more clear. 2001-01-26 02:23:57 +00:00
Eric Andersen dff9d54e32 Add errno.h 2001-01-26 02:04:49 +00:00
Eric Andersen 5307eca7de Make ls understand termios.
-Erik
2001-01-26 01:52:43 +00:00
Eric Andersen 114ad9c753 Fix a stupid bug I introduced yesterday. Doh!
-Erik
2001-01-26 01:52:14 +00:00
Eric Andersen dbb8f8d123 Update some comments to clarify things. 2001-01-26 00:11:54 +00:00
Eric Andersen d35c21587a Commit Larry Doolittle's buffers-on-stack/buffers-via-malloc patch.
-Erik
2001-01-25 23:49:09 +00:00
Eric Andersen ffde8673fe Add in spoon's watchdog timer app.
-Erik
2001-01-25 23:40:32 +00:00
Mark Whitley 8ba1b1120e Because you demanded it, source tree snapshots are made available daily. 2001-01-25 23:29:58 +00:00
Mark Whitley 0bc20caea5 Added Linux on nanoEngine to the list of known users. 2001-01-25 23:00:12 +00:00
Eric Andersen 537d165216 Update contact info. 2001-01-25 22:00:37 +00:00
Eric Andersen c1b8f1224c Apply a patch from Brent Priddy <brent.priddy@adtran.com> to add
'id -n' support.
 -Erik
2001-01-25 05:12:02 +00:00
Eric Andersen 155c89b0c3 I just wrote 'insmod -o' to close bug#1049. 2001-01-25 04:11:06 +00:00
Eric Andersen 15f29e7d86 Tar, by itself, could fail. 2001-01-25 00:53:46 +00:00
Eric Andersen cc2bcdc41d Cleanup from Larry Doolittle 2001-01-25 00:47:31 +00:00
Eric Andersen 39b727f498 Fix for dpkg-deb, courtesy of Larry Doolittle.
-Erik
2001-01-25 00:45:52 +00:00
Eric Andersen 3862423884 Add in Larry's CUSTOMIZED_BANNER patchlet, and let folks know that
BB_FEATURE_INIT_CHROOT needs to be rewritten to use pivot_root.
 -Erik
2001-01-25 00:04:16 +00:00
Eric Andersen 70c6086474 More regression testing found buglets 2001-01-25 00:00:04 +00:00
Eric Andersen 86f3d5bad6 Bug fix and small create_module cleanup from Larry Doolittle to
fix insmod, since I broke var=value args when I getopt'ified it.
2001-01-24 23:59:50 +00:00
Eric Andersen 54e9457920 Oops. I am an idiot. Put CFLAGS_EXTRA back. Sorry 'bout that.
-Erik
2001-01-24 23:53:43 +00:00
Eric Andersen 23a93f52aa More regression-found bug fixes 2001-01-24 23:47:21 +00:00
Eric Andersen f5d5e77321 more bugs fixed -- found doing regression testing
-Erik
2001-01-24 23:34:48 +00:00
Eric Andersen 26439a2991 Cleanup for build problem found using regression script 2001-01-24 22:46:16 +00:00
Eric Andersen 088d9e0f05 Fix _old_ bug so that the regression test actually works.
-Erik
2001-01-24 22:09:46 +00:00
Eric Andersen 7d69701d39 Some behavioral updates to wget so it acts a bit nicer.
-Erik
2001-01-24 20:28:35 +00:00
Eric Andersen 8c5cb31e1b Fix up insmod usage info to mention -L 2001-01-24 19:15:07 +00:00
Eric Andersen a18aaf1b6a Make insmod understand (and ignore) -L, and convert it to use getopt. 2001-01-24 19:07:09 +00:00
Eric Andersen c5cd470fdb Update comments re netkit-tiny...
-Erik
2001-01-24 18:47:30 +00:00
Eric Andersen f6c6d9aacc Remove the warning messages. By consensus, netkit-tiny doesn't
need to happen.
2001-01-24 18:44:54 +00:00
Eric Andersen 24be980004 Fix spelling. s/maintainence/maintenance/ 2001-01-24 17:37:07 +00:00
Mark Whitley a5b55ca8a9 - Added a section on avoiding static buffers, per mailing list discussions
- Added a section on avoiding dangerous, overrun-prone string functions, per
   mailing list comment by David Douthitt
 - Added comment on how to search-and-replace in multiple files per (very old)
   mailing list comment by Larry Doolittle.
2001-01-24 00:18:13 +00:00
Mark Whitley f1b0c77c22 Fixed tiny typo. 2001-01-23 22:31:10 +00:00
Mark Whitley 59ab025363 #define -> static const int. Also got rid of some big static buffers. 2001-01-23 22:30:04 +00:00
Eric Andersen 2b8d07c590 Bug fix. 2001-01-23 00:27:51 +00:00
Eric Andersen 9136e3c84e Remove host* applets from the default build. 2001-01-22 22:51:08 +00:00
Eric Andersen e132119f07 Fix silly typo 2001-01-22 22:50:01 +00:00
Eric Andersen 6705986f27 Warn about apps that will be going away in release 0.50
-Erik
2001-01-22 22:48:42 +00:00
Richard June 6d0921cc0b Add HUMAN_READABLE define for -m and -h support in du, df, and ls
Add support for -k in du, df, and ls(no define, it's for compatibliity with the GNU utils as bb does -k by default)
Fix bug #1084
2001-01-22 22:35:38 +00:00
Matt Kraai 3b3f5c364a Use getopt (or getopt_long). 2001-01-22 20:49:00 +00:00
Matt Kraai 8f8dab94e5 Fixed listed files to extract to be more like GNU. Reported by Deon George. 2001-01-22 05:25:19 +00:00
Eric Andersen 0d5a08ed92 Patch from Larry Doolittle to close bug #1086.
-Erik
2001-01-22 01:05:04 +00:00
Eric Andersen b098b6d74c Update time 2001-01-21 02:59:23 +00:00
Eric Andersen fe9888ad97 Fix naming to reflect reality 2001-01-20 21:51:21 +00:00
Eric Andersen 965fa326a1 Move \n to inside TRIVIAL_HELP, to save a few bytes for the default case.
Patch from Vladimir N. Oleynik <dzo@simtreas.ru>
2001-01-20 21:45:57 +00:00
Eric Andersen e2310b5a91 djust debian build targets 2001-01-20 21:43:43 +00:00
Eric Andersen c73a7f9ba0 lean up a potential error, thanks to Vladimir N. Oleynik <dzo@simtreas.ru>. 2001-01-20 21:41:11 +00:00
Eric Andersen 370fb08e79 Clarify the statusbar config option so it states which applet it applies to. 2001-01-20 20:07:00 +00:00
Eric Andersen 6092680305 Adjust the default feature set a wee bit 2001-01-20 19:48:21 +00:00
Eric Andersen 5f825ee6d6 Apply a patch from Vladimir N. Oleynik <dzo@simtreas.ru>,
and thereby save 64 bytes.
 -Erik
2001-01-20 16:22:58 +00:00
Glenn L McGrath f914a8af2b Close files before exit 2001-01-20 06:23:54 +00:00
Eric Andersen 6f65a3a7e8 More printf cleanups 2001-01-20 01:10:07 +00:00
Glenn L McGrath 1d269432b1 Close unused pipe handle before fork (for tar -z). 2001-01-20 00:12:21 +00:00
Matt Kraai 8392acd8fc All files include busybox.h, which includes applets.h, so the Makefile
should reflect this.  Thanks to Vladimir N. Oleynik for the idea.
2001-01-18 03:03:09 +00:00
Matt Kraai 12f417edbd Eliminate calls of the form "fprintf(stdout,". Thanks for the idea to
Vladimir N. Oleynik.
2001-01-18 02:57:08 +00:00
Matt Kraai c9acf8c766 Complicate truncate behavior. 2001-01-17 00:21:05 +00:00
Matt Kraai fd4c58d7c5 Fix the exit status of umount -a, a casualty of the TRUE/FALSE normalization.
Thanks to Francois-R Boyer <boyerf@IRO.UMontreal.CA> for the report.
2001-01-17 00:12:11 +00:00
Eric Andersen 9aa23ba5a8 Show an example of how to compile with uClibc.
-Erik
2001-01-16 21:20:46 +00:00
Matt Kraai 541ffe30a2 Fix ownership of extracted directories. 2001-01-13 21:46:25 +00:00
Mark Whitley 55787401ea Removed unused, unneeded, Lineo-specific script. 2001-01-09 23:09:45 +00:00
Eric Andersen 744b064a34 Needs to be NULL at init in all cases. 2001-01-05 21:23:44 +00:00
Eric Andersen 59d31b68c3 Changelog update/cleanup from larry. 2001-01-05 21:01:01 +00:00
Eric Andersen 8ea28be6d2 Patch from larry doolittle to be ever so careful to cleanup
all open file descriptors, lest wierdness happen later.
2001-01-05 20:58:22 +00:00
Eric Andersen 0bcc813a34 Better label the globals. 2001-01-05 19:37:32 +00:00
Eric Andersen b0970d4fed Patch from Larry Doolittle to set values to static variables that live in the
bss at runtime, since sh.c can call sh.c, which causes these variables to not
be set to their defaults as god intended.
 -Erik
2001-01-05 19:34:52 +00:00
Mark Whitley eb60d8bcd1 Turned some #define constants into static const ints. 2001-01-05 18:19:30 +00:00
Matt Kraai 55bccf315e Rewrote tail. 2001-01-05 02:57:53 +00:00
Matt Kraai defcd5e75e Fix a segfault by only constructing the prompt when we need to. If we don't
do this we will segfault processing /etc/.profile since cwd isn't yet set.
2001-01-05 02:53:11 +00:00
Mark Whitley 6c6ea6cba2 Changed email address to codepoet.org, updated list of applets / docs I
maintain in AUTHORS.
2001-01-04 22:21:13 +00:00
Mark Whitley 92386561f1 Included name of Larry Doolittle's build test script. Shameless self-crediting
of a few items.
2001-01-04 22:07:50 +00:00
Eric Andersen 05ebdd03d4 Update to changelog -- mostly from Larry Doolittle. 2001-01-04 21:14:15 +00:00
Matt Kraai 0810f723b1 Fixed -qv interaction (thanks to a report and patch from David Douthitt). 2001-01-04 15:11:52 +00:00
Eric Andersen 09acc06c10 Move window size handling to cmdedit.c. Move prompt setup to setup_prompt_string() 2001-01-04 11:10:38 +00:00
Eric Andersen 849083c886 Update interface per what now exists... 2001-01-04 11:09:00 +00:00
Eric Andersen b3dc3b8990 Cleanup -- move win handling to cmdedit.c, static-ify many functions. 2001-01-04 11:08:45 +00:00
Matt Kraai 70a7855980 Fix symbol table manipulation (report and fix by Larry Doolittle). 2001-01-04 02:00:17 +00:00
Mark Whitley 1171c2fcb4 Added new script from Larry Doolittle that builds each applet individually. 2001-01-04 01:05:55 +00:00
Matt Kraai be7499c83c Behave like GNU tar when matching excluded files. 2001-01-03 17:22:10 +00:00
Matt Kraai a9711a5969 Prevent / doubling and shrink parse_url. 2001-01-03 16:15:15 +00:00
Glenn L McGrath 59c09d06e3 Fix warning for unused variable 2001-01-03 01:44:49 +00:00
Glenn L McGrath 5e23e3d631 enable is_direcotry() for dpkg-deb 2001-01-03 01:38:29 +00:00
Glenn L McGrath fa0443216d Add dpkg-deb documentation 2001-01-03 01:06:30 +00:00
Eric Andersen 47b005217e Disable a bunch of less common stuff by default. This produces
a more reasonable sized default build.
2001-01-03 00:14:45 +00:00
Eric Andersen 5e8b3ea19d Logger forgot to NULL terminate strings from stdin. 2001-01-03 00:06:46 +00:00
Glenn L McGrath 58a408512b really add dpkg-deb.c this time 2001-01-02 23:49:26 +00:00
Glenn L McGrath 7541e3a812 add dpkg-deb command 2001-01-02 23:41:50 +00:00
Matt Kraai 004827d715 Update logger usage information. 2001-01-02 22:54:12 +00:00
Matt Kraai 1944f547bd Log stdin when no message given and use getopt. 2001-01-02 18:13:58 +00:00
Eric Andersen 28b3c53f0d I just whipped up support for arbitrary regex delimiters, so
now things such as
    $ echo foo | sed 'sxfooxb\arx'
    bar
will work as expected (and so doogie can stop complaining).
 -Erik
2001-01-02 11:01:31 +00:00
Eric Andersen 01bda5de6b Better dmalloc handling 2001-01-02 01:16:38 +00:00
Eric Andersen 27c7bec4d4 Be more careful about dmalloc handling 2001-01-02 01:16:02 +00:00
Matt Kraai e6e818309e Improvements from Vladimir N. Oleynik. 2000-12-30 07:46:23 +00:00
Matt Kraai e9e182e255 Fix lower casing for weird locales. 2000-12-26 16:36:10 +00:00
Eric Andersen 2d5b64273f Cleanup from Gennady Feldman <gfeldman@mail.com> 2000-12-22 18:02:02 +00:00
Matt Kraai a9819b2908 Use busybox error handling functions wherever possible. 2000-12-22 01:48:07 +00:00
Eric Andersen e9f07fb6e8 Another sh.c patch from Larry Doolittle. This makes redirects work properly
with non-forking shell builtins.  Especially helpful for "read".  This patch
also beautifies builtin_fg_bg, clarifies the problems with
run_command_predicate, makes if/then/else support the default, and corrects the
sense of the BB_FEATURE_SH_ENVIRONMENT comment.
2000-12-21 18:31:36 +00:00
Eric Andersen 16fdbe8b27 Make more things be static (like they are supposed to be). 2000-12-20 23:40:57 +00:00
Eric Andersen a6cd07099d Bump the version number to 0.49pre 2000-12-20 23:22:29 +00:00
Eric Andersen e111d69ca2 Turns out, md5sum was broken anyways. It uses backwards TRUE/FALSE
and wasnever updated when TRUE and FALSE were fixed.  So kludge it
by doing an #undef TRUE, then define it backwards...
2000-12-20 23:19:42 +00:00
Eric Andersen 70da6a66d2 Fix a warning in sh.c. Remove use of getline() in md5sum since
nobody else uses it and it is a GNU extension anyways...
2000-12-20 22:59:16 +00:00
Mark Whitley 3680c58084 Some corrections, some additions, some embellishments. 2000-12-20 22:35:12 +00:00
Matt Kraai 5e8c0ffb75 Rewrote. 2000-12-20 20:49:56 +00:00
Eric Andersen e75f6a972c Fix a stupid naming error. 2000-12-20 20:41:02 +00:00
Matt Kraai e80a2633bc Be sure to read from the given path, not the one used in the header. 2000-12-19 20:45:49 +00:00
Mark Whitley 8eb5985f94 More spelling fixes from Larry Doolittle. 2000-12-19 19:44:35 +00:00
Mark Whitley 8a6b619c96 Added a paragraph from Larry Dolittle, made some more section headers. 2000-12-19 17:54:38 +00:00
Mark Whitley eac2636513 New applet HOWTO. Written by Matt Kraai with some formating and additions by me. 2000-12-19 17:35:24 +00:00
Matt Kraai a1f9775981 Fix tar handling of absolute paths and excluded directories. 2000-12-19 06:24:08 +00:00
Matt Kraai 24ac017961 Rewrote dd. 2000-12-18 21:38:57 +00:00
Eric Andersen 0d2acb0ead Doc update from Matt Kraai, better describing the init process. 2000-12-18 20:36:02 +00:00
Eric Andersen 86349776d0 Ok, this is a pretty major update to sh.c. I renamed all the variables and
function names to conform with the style guide.  I also did a lot of work on
the if-then-alse-fi logic and added prototype (i.e. it segfaults when enabled)
line continuation support.

Furthermore, this patch includes Larry Doolittle's work on restructuring some
of the data structures that represent the job and child_program, allowing
several simplifications and fixing several bugs.

 -Erik
2000-12-18 20:25:50 +00:00
Matt Kraai 1fa1adea2a Change calls to error_msg.* and strerror to use perror_msg.*. 2000-12-18 03:57:16 +00:00
Matt Kraai 0dab829977 Add missing newlines to error messages. 2000-12-18 03:08:29 +00:00
Matt Kraai bfa7967c4a Rewrite nc to be simpler, smaller, and to check syscalls for errors. 2000-12-15 22:34:34 +00:00
Matt Kraai 8677d7b6ec Only say mailing list once. 2000-12-15 15:41:03 +00:00
Glenn L McGrath e699b9f0fb Remove defines for ar that arent needed 2000-12-15 06:50:54 +00:00
Glenn L McGrath 4f1b0124c7 Rewrite, fix a bug with multiple long filenames, simplify structure, remove cruft, make code conform closer to style guide, saves 350 Bytes. 2000-12-15 06:50:09 +00:00
Matt Kraai 8abc78aa84 Rewrite argv munger. 2000-12-15 00:35:22 +00:00
Eric Andersen 1b622ff5ac Add in mkCDrec - make CD-ROM recovery project. 2000-12-14 15:43:57 +00:00
Matt Kraai aefe5629ab Simplify error handling. 2000-12-14 05:44:36 +00:00
Matt Kraai 95fa0ea3d4 Shutdown sending on the socket when stdin closes. 2000-12-14 04:34:58 +00:00
Mark Whitley 6f6aa9b428 Added some necessary brackets, removed debug noise. 2000-12-13 23:23:30 +00:00
Matt Kraai e3a94f7d08 Ran aspell. 2000-12-13 19:50:48 +00:00
Eric Andersen 95d1f6d7c7 Formatting fix 2000-12-13 18:30:59 +00:00
Eric Andersen 4362200712 Website update for the release 2000-12-13 18:30:13 +00:00
Eric Andersen 1e1d232f38 Add a few folks to Authors 2000-12-13 18:14:51 +00:00
Eric Andersen 235f66dea3 A few more updates 2000-12-13 18:07:38 +00:00
Eric Andersen d0fa0a12f1 Document gzip -d 2000-12-13 17:59:37 +00:00
Eric Andersen 02ced93ec2 Add GNU compatibile gzip -d 2000-12-13 17:55:11 +00:00
Eric Andersen 46948366fa Update the version number to 0.48 (no longer pre). 2000-12-13 16:42:24 +00:00
Eric Andersen 21125543e1 A couple of updates to fix some minor cross compiling issues 2000-12-13 16:41:29 +00:00
Eric Andersen 4836fd44f0 Patch from Matt Kraai:
The following patch makes the -X option to tar behave like GNU,
    which reads one file per line.  It also prevents the last file
    from being appended to the list twice (though that has no
    noticeable impact).
2000-12-13 15:28:48 +00:00
Eric Andersen bd193a42a5 Fix from Matt Kraai -- a better way to NULL terminate strings for the
my_* passwd and group routines.  I should have thought of doing it
this way...
2000-12-13 01:52:39 +00:00
Eric Andersen 77508b29fa Fix from Gennady Feldman for error msg 2000-12-12 23:51:43 +00:00
Eric Andersen f361ac29b0 Mem leak fix from Matt Kraai 2000-12-12 23:45:36 +00:00
Eric Andersen 483262f633 Patch from Matt Kraai to fix 'dirname /' 2000-12-12 23:27:48 +00:00
Eric Andersen 4d4b3b1d88 Fix so cross compiling works again... 2000-12-12 23:23:32 +00:00
Eric Andersen e3a48d865a Cleanup for proper compilation with uClibc. 2000-12-12 23:22:35 +00:00
Eric Andersen d9d03b83f8 Mount error return code fix from Kent Robotti -- we must reset the error
code when looping...
2000-12-12 23:20:37 +00:00
Eric Andersen b12e506d8d du.c error msg cleanup from Kent Robotti 2000-12-12 23:17:26 +00:00
Eric Andersen 69a6b2d4ae Fix from Matt Kraai so basename / will work as expected. 2000-12-12 23:13:54 +00:00
Eric Andersen e48eea63d3 Oops. Unmatched #if 2000-12-12 18:20:19 +00:00
Eric Andersen a2d61e761e Some compile fixes found by Larry Doolittle 2000-12-12 16:55:56 +00:00
Eric Andersen 5ec241d3b3 Script updates for better portability 2000-12-12 16:49:12 +00:00
Eric Andersen 2d6282bb37 Matt Kraai pointed out that we can rely on strncpy to NULL
terminate shorter cases, so we can save a few cycles...
2000-12-11 20:33:46 +00:00
Eric Andersen d323d32c5b Patch from larry doolittle to make sure we don't realloc
a pointer that was not yet malloced mem.
2000-12-11 20:29:13 +00:00
Matt Kraai 5a964f9d0b Keep unknown priorities from segfaulting. 2000-12-11 20:13:37 +00:00
Eric Andersen 20c2bdd7f2 Fix spelling error s/defaut/default/g 2000-12-11 19:39:25 +00:00
Eric Andersen 5c365da884 Fix non-NULL terminated strings. 2000-12-11 19:37:19 +00:00
Eric Andersen 4ed17829ac Fix a thinko -- when REMOTE_LOG support is compiled in,
but the user has not specified remote logging, then
be sure to log locally... duh.
2000-12-11 19:28:29 +00:00
Eric Andersen b2356f6de9 Patch from Matt Kraai to fox sh.c escape problem such that
running things like 'echo "\n\tHi\n\t\!"' and 'echo -e "\n\tHi\n\t\!"'
behave as under bash.
2000-12-11 19:14:40 +00:00
Eric Andersen 59ec601b8e Test suite update from Larry Doolittle to disable some problematic
ambiguous cases.  Everything now passes the test suite...
2000-12-11 17:33:08 +00:00
Eric Andersen a293a516ad Patch from kent robotti to fix a buglet where
# du doesn't_exist
    du: doesn't_exist: No such file or directory
    0   doesn't_exist
which was on course wrong.  I simplified it a bit...
2000-12-11 17:08:21 +00:00
Eric Andersen 394cf22668 Fix the option parsing to use getopt, which seems to fix bug #1050 2000-12-11 16:48:50 +00:00
Eric Andersen cf7982e908 Patch from Larry Doolittle, fix up logging across multilple lines, hopefully
fixing bug #1061.
2000-12-11 16:31:11 +00:00
Eric Andersen 70d09ed1cf Reverse logic so when network logging, it by default does not log locally. 2000-12-11 16:24:16 +00:00
Eric Andersen 9962cd9f78 Add a linker warning for symbol conflicts. 2000-12-11 16:20:40 +00:00
Eric Andersen c8eedd56ac Some .deb update 2000-12-10 04:43:49 +00:00
Glenn L McGrath 46f44d24fc Support for tar -z option for uncompressing only 2000-12-10 01:57:30 +00:00
Glenn L McGrath 00732b57c7 Introduce new function gunzip_init()
gunzip_init() will make it easier to use gunzip from other bb functions.
2000-12-10 00:51:42 +00:00
Glenn L McGrath c52a97d79f NFS_PORT and NFS_FHSIZE are not defined in the kernel headers that come with libc6-2.2-5
This just defines that if they arent found in the kernel header
2000-12-09 23:59:04 +00:00
Eric Andersen 9df3833370 Fix problem where 'du file_that_exists' doesn't work. 2000-12-09 17:07:12 +00:00
Eric Andersen 29edd005f9 More wget cleanups I've been working on... 2000-12-09 16:55:35 +00:00
Eric Andersen afdde3e356 Some little cleanups from Larry Doolittle 2000-12-09 16:41:42 +00:00
Eric Andersen 5b5db38a7d Patch from Matt Kraai to implement uniq -[cdu] 2000-12-09 16:37:53 +00:00
Glenn L McGrath 1bca5ed886 add quiet mode support.
If wget compiled without statusbar then -q option is accepted but has no effect.
If wget compiled with statusbar -q turns it off.
2000-12-09 08:12:06 +00:00
Eric Andersen 8c28fd7849 Forget to set final argv entry to NULL, breaking sh.c amoung
other things...
2000-12-09 00:19:30 +00:00
Eric Andersen 7da312058c Some updates. Wrong name was on a patch, plus a spelling fix. 2000-12-08 21:05:58 +00:00
Eric Andersen f21aa84389 Put in i to getopt, so i will work... 2000-12-08 20:50:30 +00:00
Eric Andersen eb4218d0a4 Update inittab docs 2000-12-08 20:38:00 +00:00
Eric Andersen bf2b8ae49a Make no local logging a runtime option for network logging... 2000-12-08 19:52:01 +00:00
Eric Andersen 76fef0a5d0 Patch from Gennady Feldman <gfeldman@mail.com> to make syslogd not log
when compiled for remote logging.  Not the ideal way to fix it (it should
really be a runtime switch), but good enough for now I guess...
2000-12-08 19:41:21 +00:00
Eric Andersen 9cff4fbac9 Patch from Matt Kraai to make logger log all arguments. 2000-12-08 19:35:51 +00:00
Eric Andersen 5e09b6e3a8 when invoked as 'busybox foo args' remove the "busybox"
so ps shows only what we want it to show...
2000-12-08 19:03:12 +00:00
Eric Andersen f3b2b52b58 Patch from Matt Kraai to enable proxy support. 2000-12-07 22:42:11 +00:00
Mark Whitley f57c944e09 Changed names of functions in utility.c and all affected files, to make
compliant with the style guide. Everybody rebuild your tags file!
2000-12-07 19:56:48 +00:00
Matt Kraai 7b5c16ebe5 Fix by Tim Robbins <fyre@box3n.gumbynet.org> to prevent bad format
strings from being passed to syslog(3).
2000-12-07 16:22:04 +00:00
Matt Kraai 87afb526b5 Get rid of redundant TRUE and FALSE definitions. 2000-12-07 16:11:50 +00:00
Randolph Chung 1e1d9d1c95 oops, didn't mean to commit that last one... reverting 2000-12-07 03:56:10 +00:00
Randolph Chung da7b82981b Write progress meter to stderr instead of stdout 2000-12-07 03:55:35 +00:00
Randolph Chung 02553a2a18 Fixed URL parsing bug
Fixed -O - output-to-stdout bug
2000-12-07 03:53:47 +00:00
Eric Andersen 3d957c87b7 Patch from Jim Gleason <jimg@lineo.com> to fix tar so it no longer breaks hard
links, and no longer segfault in a certain wierd case.
2000-12-07 00:34:58 +00:00
Eric Andersen 6b78fe383f Add some more changlog stuff suggested by Larry Doolittle. 2000-12-07 00:29:50 +00:00
Eric Andersen 1e7cea952b Bettwr document the hidden internal sh.c #defines, and which folks
might want to use...
2000-12-06 23:47:38 +00:00
Eric Andersen bc5941a540 Close but #1071... 2000-12-06 23:17:37 +00:00
Eric Andersen bfa54143f6 Ignore the newdocs as well 2000-12-06 23:12:43 +00:00
Eric Andersen 8ffabf5825 Patch from Matt Kraai to fix 'echo "1 2 3" | tr -s " "'
so it properly outputs "1 2 3".
2000-12-06 22:53:06 +00:00
Eric Andersen 1d3523b7aa patch from Larry Doolittle to rename BB_FEATURE_SH_BUILTINS_ALWAYS_WIN
to the more pedantically correct BB_FEATURE_SH_APPLETS_ALWAYS_WIN.
2000-12-06 19:07:39 +00:00
Eric Andersen 21adca750a Added insmod support for ARM, and lsmod support for older kernels,
thanks to Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and
Nicolas Ferre <nicolas.ferre@alcove.fr>.
 -Erik
2000-12-06 18:18:26 +00:00
Matt Kraai e884970c87 Must compile before committing. 2000-12-06 15:56:31 +00:00
Matt Kraai 92ed8a3519 Fix exit status on failure. 2000-12-06 15:55:23 +00:00
Mark Whitley ab147f608d Removed isBlank and isWildCard macros that were totally unused (should anyone
need isBlank, please use isblank() in ctype.h). Converted isDecimal and
isOctal into inline functions. Compiled, tested, worked.
2000-12-05 20:42:48 +00:00
Mark Whitley 26a3adb244 Changed some #define strings to static const char [] variables. Tested ls
after changing, it worked.
2000-12-05 20:10:27 +00:00
Matt Kraai deb9d4d765 Use perrorMsg and clean up exit status. 2000-12-05 20:07:27 +00:00
Mark Whitley 4758368505 Fixed the comments to match the code and renamed the function to a (hopefully)
more descriptive name, and as per the style guide.
2000-12-05 20:03:17 +00:00
Mark Whitley cf61fe14ae Applied patch from Matt Kraai to add v*error functions for handling vararg
lists in a safe 'n sane fashion.
2000-12-05 19:27:13 +00:00
Matt Kraai d27753afd9 Use perrorMsg instead of perror and keep removing files if we encounter
an error.
2000-12-05 05:11:41 +00:00
Eric Andersen 0e836ed8db Changelog update 2000-12-04 23:52:19 +00:00
Eric Andersen 2187adc619 Flag day warning!
Change TRUE and FALSE defines to normal C style TRUE=1, FALSE=0.
 -Erik
2000-12-04 20:31:45 +00:00
Eric Andersen 8cede00b9e Patch to add in the -X option and fix the --exclude bug, originally by
Sebastien Huet, and now ported to the latest and greatest by both Arne Bernin
<ab@netropol.de> and kent robotti <robotti@metconnect.com>.
2000-12-04 18:51:09 +00:00
Eric Andersen f484e7e65c Fix typo 2000-12-02 06:32:14 +00:00
Eric Andersen 868c057d25 Patch from Larry Doolittle so it will build the newdocs right. 2000-12-02 00:44:48 +00:00
Eric Andersen e73fda8311 Update for handling .udebs and building using a pristine source dir... 2000-12-01 22:59:04 +00:00
Eric Andersen 29be79c5f6 More doc handling updates 2000-12-01 22:57:44 +00:00
Eric Andersen 4c45e0991a Update some descriptions 2000-12-01 22:57:09 +00:00
Eric Andersen b8b8d81c24 Fix yet another blunder. Create symlink correctly this time. 2000-12-01 20:26:30 +00:00
Eric Andersen 4d449c42f2 I forgot a "/". Oops. 2000-12-01 20:02:10 +00:00
Eric Andersen e2f6e12213 More pristine source directory updates. It now works
for me (including doing install).  How about you?
 -Erik
2000-12-01 19:55:04 +00:00
Eric Andersen 09a34e5368 More updates for the Makefile to do BB_SRC_DIR. This is
primarily a patch from Larry Doolittle, but with updates
from me to handle docs and link creation properly...
2000-12-01 19:40:18 +00:00
Eric Andersen 02f3b2e0c8 Make tar shutup on compile 2000-12-01 19:04:52 +00:00
Eric Andersen 87559829ff Remove #ifdef __STDC__ junk. We don't do K&R round these parts,
so no point acting like we do.
2000-12-01 19:02:24 +00:00
Matt Kraai 3e856ce428 Stop using TRUE and FALSE for exit status. 2000-12-01 02:55:13 +00:00
Eric Andersen b558e76eb1 Apply some patches from Gennady Feldman <gfeldman@mail.com> to
. /etc/profile, and to emulate bash prompt.  I've cleaned up
his patches a bit and all looks good now...
2000-11-30 22:43:16 +00:00
Matt Kraai cabafae7b0 Note new dependency. 2000-11-30 04:55:40 +00:00
Matt Kraai c119ab9e29 Note an error if we are unable to list/extract specified files. 2000-11-30 04:44:54 +00:00
Eric Andersen 8c725e624a Patch from Larry Doolittle (with minor touchups from me so everything compiles
and works) to use the applet definitions in applets.h to autogenerate the applet
function and usage prototypes.
2000-11-30 00:27:06 +00:00
Eric Andersen 8c2d3f46ab Fix escape char problem. 2000-11-30 00:03:57 +00:00
Eric Andersen 9bd71e8323 Add "\r" to utility.c:process_escape_sequence() (from email about
"echo vs. optarg" from Larry Doolittle Tue, 28 Nov 2000 10:36:04 -0800)
 -Erik
2000-11-29 23:07:57 +00:00
Eric Andersen 8fff78d66e Apply the BSD echo version submitted by Jonas Holmberg <jonas.holmberg@axis.com> 2000-11-29 22:40:59 +00:00
Eric Andersen ddea368dbe Apply rev #2 of dd fix from Gennady Feldman. 2000-11-29 22:33:02 +00:00
Eric Andersen 618e8ed4c4 Update the changelog a bit 2000-11-29 22:30:31 +00:00
Eric Andersen 0730943b49 Moar Speling fickes frum Larry Doolittle 2000-11-29 22:12:19 +00:00
Eric Andersen 20ea5c3352 Patch form Larry Doolittle <ldoolitt@recycle.lbl.gov> (in collaboration
with Matt Kraai <kraai@alumni.carnegiemellon.edu>) to allow for a
pristine source directory -- where all the .o files and such are
not placed into the source tree.  Thanks Larry!
2000-11-29 22:08:35 +00:00
Eric Andersen 7b5d59464f Apply a patch from Larry Doolittle <ldoolitt@recycle.lbl.gov> to close
bug 1069.  This shaves about 100 bytes from the executable, and about
200 bytes of heap usage.  Also document the "-d" option in the usage
message.
2000-11-29 22:01:42 +00:00
Eric Andersen cf1189f5a7 Patch from Matt Kraai to fix an infinate loop with ls -aR 2000-11-29 21:52:06 +00:00
Eric Andersen 4bfb6b7b67 Finish commit of rpmunpack and add in scripts for undeb and unrpm 2000-11-29 21:39:02 +00:00
Eric Andersen e500d20835 Apply a patch fromkent robotti:
Renamed unrpm to original rpmunpack, so you can use an included shell script
    called unrpm as a front end to it.

    There's also a shell script called undeb included for debian packages.

    Change undeb and unrpm scripts to work with the busybox tar and gunzip.
2000-11-29 21:38:11 +00:00
Mark Whitley d58ff8731c Re-organized some sections and added a whole new section on avoiding the
preprocessor. Comments welcome.
2000-11-22 19:25:39 +00:00
Matt Kraai 9a71af54f5 Fix behavior when removal fails. 2000-11-22 01:09:38 +00:00
Matt Kraai ab8f9e286b Check for archive errors even for files we aren't extracting. 2000-11-18 01:28:57 +00:00
Matt Kraai 768a2340b5 Fixed return status (thanks to David Douthitt for the fix). 2000-11-18 01:16:43 +00:00
Matt Kraai e93abf9e69 Fixed user and group name listing. 2000-11-18 01:08:24 +00:00
Mark Whitley 5022d0e55f Added AdTran to the list of products using Busybox. 2000-11-17 22:07:08 +00:00
Mark Whitley 0053087587 Applied patch from Brent Priddy <brent.priddy@adtran.com> to handle the
special-case of using newlines as field delimiters.
2000-11-17 22:02:45 +00:00
Mark Whitley 9028e2c96a Numerous spelling / grammar corrections from Larry Doolittle
<ldoolitt@recycle.lbl.gov>, as well as a few additions / clarifications.
2000-11-17 21:28:39 +00:00
Eric Andersen a683ee81d9 "I will always compile before I commit."
"I will always compile before I commit."
"I will always compile before I commit."
 -Erik
2000-11-17 18:51:45 +00:00
Eric Andersen e5aef92e22 Fix up builtin overrides, and hack in the binary search for finding
matching applets into the shell.
2000-11-17 18:25:26 +00:00
Mark Whitley cf32e23796 Modified help string for xargs. Props to Kent Robotti <robotti@metconnect.com>. 2000-11-17 18:13:09 +00:00
Eric Andersen 50b3113dc2 Add in a new FEATURE (off by default) BB_FEATURE_SH_BUILTINS_ALWAYS_WIN.
Make the sh default to using external commands when a path is provided.
2000-11-17 18:07:30 +00:00
Eric Andersen 337ec1bb32 Fix typo pointed out by Michael Renzmann <renzmann@gmx.de> 2000-11-17 17:23:16 +00:00
Eric Andersen e790ddb2e1 Add BB_CMP to xfopen 2000-11-17 06:50:42 +00:00
Eric Andersen 4e573f4729 Remove the BSD advertising clause, and replace it with a link to how
the advertising clause has been retroactivly declared null and void.
2000-11-14 23:29:24 +00:00
Eric Andersen 8045c08e1c Oops. I kant tipe. 2000-11-14 22:57:46 +00:00
Mark Whitley e2e2c29ea1 Brand new version of xargs. Tested thoroughly by Kent Robotti. (Domo arigato,
Mr. Robotti...) Closes bug #1065.
2000-11-14 22:43:21 +00:00
Eric Andersen 3c5ee9a379 Grammer fix. Changed "longer then" to "longer than". Fix thanks to Jim
Gleason <jimg@lineo.com>.
2000-11-14 22:15:48 +00:00
Eric Andersen 46f0beb167 Patch from Gennady Feldman <gfeldman@tradeline.net> to:
1. Opens redirections w/ the right access.
    2. Doesn't do globbing for every single parameter (so it
	doesn't stat every parameter).
2000-11-14 21:59:22 +00:00
Eric Andersen 2aa1091130 Ulp. "expr" listed as a second "echo" (oops) -- thanks to David Douthitt
for noticing....
2000-11-14 21:28:09 +00:00
Eric Andersen 6d5b73d183 Add in Zdisk 2000-11-14 21:12:39 +00:00
Eric Andersen f61caf0411 Remove unneeded junk 2000-11-14 20:31:45 +00:00
Matt Kraai 7918e1fd54 Move flush_outbuf to the file in which it is used, and by doing so fix a
nasty error dealing with two different variables with the same name.
2000-11-08 06:52:57 +00:00
Matt Kraai d8ad76cb31 Fix some bugs reported by Jim Gleason <jimg@lineo.com> and others I
introduced.
2000-11-08 02:35:47 +00:00
Eric Andersen 63a862272c Cleanup of duplicated symbols -- found by compiling with
LDFLAGS += -Wl,-warn-common
2000-11-07 06:52:13 +00:00
Mark Whitley eb69ead091 Removed REG_NEWLINE from regcomp to fix the same bug found in grep where it
would not match blank lines (bug #1064). Followed Matt Kraii's suit on his
1.42 revision of grep. Tested it, works.
2000-11-03 20:23:49 +00:00
Mark Whitley e7ff2842dd Now, what was that logic block doing up there? 2000-11-03 20:02:35 +00:00
Mark Whitley 2dc192fd99 Re-worked the support for s///p, fixed a backref limit buglet, and cleaned up
a few other ugly places (do_subst_command got a much-needed overhaul). Also
took out BB_FEATURE_SED_PATTERN_SPACE from Config.h[.Hurd] as the 'p' is now a
standard feature (adds almost no bloat).
2000-11-03 19:47:00 +00:00
Eric Andersen a75466e981 Warning cleanup from Gennady Feldman
-Erik
2000-11-02 17:02:26 +00:00
Eric Andersen ef936da7c5 Fix uname problem that was breaking poweroff. 2000-10-30 17:22:04 +00:00
Eric Andersen 3e07541e5f This was redundant 2000-10-29 07:02:47 +00:00
Matt Kraai 269e07cadc Make fbset compile with the readmode feature by pulling defs from fb.h. 2000-10-28 16:56:32 +00:00
Matt Kraai a5bd26831f Make features independent. 2000-10-28 06:40:09 +00:00
Matt Kraai b273d66518 We also need to declare info if the USERNAMES feature is enabled. 2000-10-28 01:21:22 +00:00
Eric Andersen c559d30776 Add in -lgcc to add needed symbold when linking vs uclibc. 2000-10-27 18:26:18 +00:00
Eric Andersen b344c21709 Oops. I never committed this. Update version to 0.48pre... 2000-10-27 18:09:53 +00:00
Eric Andersen d1ee7e39f7 Silence a warning, 2000-10-26 07:57:27 +00:00
Eric Andersen 84bdc75c7e This was broken when applets moved to applets.h. Fix it. 2000-10-26 04:17:49 +00:00
Matt Kraai e8c55f42c1 Fixed error handling and TRUE/FALSE usage. 2000-10-25 19:09:03 +00:00
Matt Kraai 2dab174daa Restore --help handling I mistakenly removed. 2000-10-25 19:05:38 +00:00
Matt Kraai a0428eee9e Avoid reinventing the wheel (and thus save some space). 2000-10-25 19:00:51 +00:00
Matt Kraai ef5529b278 Added a new perrorMsg function, cleanup up error handling, fixed TRUE/FALSE
uses, and other minor fixes.
2000-10-25 17:00:36 +00:00
Matt Kraai 9133c98a9d Cleaned up error handling, TRUE/FALSE usage, and other minor issues. 2000-10-25 16:48:15 +00:00
Matt Kraai 3180413e76 Clean up error handling and uses of TRUE/FALSE. 2000-10-25 16:40:21 +00:00
Matt Kraai ac1169b20f Cleaned up error handling and uses of TRUE/FALSE. 2000-10-25 16:38:00 +00:00
Matt Kraai 97d2612566 Cleaned up error message handling. 2000-10-25 16:25:50 +00:00
Matt Kraai 324a778f31 Added a fatalPerror function to simplify error handling. 2000-10-25 15:10:08 +00:00
Glenn L McGrath b60208dd8f Fix for bug #1068 from Kent Robotti
Call perror and exit instead of fatalError
2000-10-25 03:31:15 +00:00
Mark Whitley 130005cd89 Applied patch from Gaute B Strokkenes <gs234@cam.ac.uk> to use a binary search
to locate applets, rather than a linear search. Also, broke out the listing of
applets into it's own file: applets.h.
2000-10-25 00:28:27 +00:00
Matt Kraai 207061ac0d Fix error messages. 2000-10-23 18:03:46 +00:00
Matt Kraai 2be4797a06 Fix error message. 2000-10-23 17:55:27 +00:00
Mark Whitley 6050618096 Put getopt_usage where it belongs and added *_usage entries in busybox.[ch] 2000-10-19 22:28:06 +00:00
Matt Kraai 69229a6c92 Piss people off by removing [+-][0-9]+ options from tail. 2000-10-19 21:28:32 +00:00
Matt Kraai 4f94e826cf Remove broken error test found by Bryan Rittmeyer <bryan@ixiacom.com>. 2000-10-16 16:22:27 +00:00
Matt Kraai 567cdd1d51 Fix handling of ^$ by removing the newline from input lines and by not
compiling with REG_NEWLINE.
2000-10-13 18:55:06 +00:00
Matt Kraai 9a6e67c960 Consolidate stat(2) and lstat(2) calls and error handling. 2000-10-13 18:03:21 +00:00
Matt Kraai 33fdae54d1 Exit with failure status if we are unable to list any files or
directories.  Patch thanks to Kent Robotti <robotti@metconnect.com>.
2000-10-13 17:59:43 +00:00
Eric Andersen e7e1e2dcad Apply a patch from Matt Kraai to fix buffer overrun and convert to
using synamically allocated storage.
 -Erik
2000-10-12 22:40:14 +00:00
Eric Andersen 0d5835a767 Apply patch from "Orion Poplawski" <OPoplawski@cqg.com> to make
hostname do "--file"
 -Erik
2000-10-12 22:30:31 +00:00
Mark Whitley 872138de50 Added cmp and readlink applets from Matt Kraai. 2000-10-09 18:56:47 +00:00
Eric Andersen 7a86e61a54 Patch from Matt Kraai so wc will return a proper error code
when failing to open a file, and will not use file when it
didn't open the file.
 -Erik
2000-10-09 18:21:44 +00:00
Eric Andersen 62f987e95f Fix a thinko. Patch from Justus Pendleton <justus@acm.org> 2000-10-09 17:54:38 +00:00
Eric Andersen 958c78f9a1 Apply a patch from Matt Kraai:
"The -L option to ls doesn't behave correctly for files listed explicitly
    on the command line, only those in directories that are listed.  The
    appended patch fixes this problem.  Would someone please commit it?"
 -Erik
2000-10-09 17:51:25 +00:00
Eric Andersen 13241dfbdd Patch from Matt Kraai: "When it encounters a problem creating a link, ln
shouldn't give up entirely but instead continue processing the rest of its
arguments.  The attached patch does this."
2000-10-04 16:02:53 +00:00
Glenn L McGrath aa3908d1b7 Rewrite to use getopt and return instead of exit, a seperate function (fs_link) does the actual work. 2000-10-04 09:34:35 +00:00
Eric Andersen b520e083e0 Add a spiffy progress meter.
-Erik
2000-10-03 00:21:45 +00:00
Eric Andersen 25b669c144 Try to guess an output filename 2000-10-02 23:19:38 +00:00
Eric Andersen ba1ff9b4eb Apply patch from Giulio Orsero <giulioo@pobox.com> to ensure
get_last_path_component is defined under all configurations,
 -Erik
2000-10-01 17:01:36 +00:00
Glenn L McGrath c2bf5cad79 General cleanup of comments, defines, includes, and global variables, removed those that arent needed, grouped those remaining at the top.
Re-ordered functions to the order they are called.
Removed static crc table, it now generates the table once for itself.
Results in source reduced by 40%, so it should be a lot easier to work on in the future, binary size only reduced by under 2KB though.
2000-09-29 06:46:59 +00:00
Pavel Roskin 43f3e6114c Fixes to allow compilation on systems with glibc 2.1.92 2000-09-28 20:52:55 +00:00
John Beppu 8d369e98a5 + shortened main() a little, and a few aesthetic cleanups here & there. 2000-09-28 17:49:59 +00:00
Matt Kraai c0321f9bc6 Rewrote head to perservere when it can't open a file, and share code
with cat.
2000-09-27 04:09:22 +00:00
Matt Kraai e7c1af1e0d Continue concatenating files even if we can't open one. 2000-09-27 03:01:40 +00:00
Matt Kraai bbaef66b3f Consolidate handling of some fopen failures. 2000-09-27 02:43:35 +00:00
Matt Kraai e0bcce09ba Rewrote uniq to be less than a third of the size, and fixed some other
minor problems.
2000-09-27 02:29:39 +00:00
Eric Andersen 8ce85ce4e3 Fix up the docs 2000-09-26 22:20:06 +00:00
Eric Andersen bdcc6fbd95 update the docs 2000-09-26 06:15:12 +00:00
Eric Andersen f8263516c2 Log the devps patch update 2000-09-26 05:08:04 +00:00
Eric Andersen db7f2af089 Final touchups for the release...
-Erik
2000-09-26 05:02:50 +00:00
Eric Andersen f6b7139971 Add in busybox.h. I renamed it, and forgot to commit the newky named version.
-Erik
2000-09-26 01:09:18 +00:00
Eric Andersen d266748c76 Yet more polish (thanks again to kent robotti for the bug reports).
-Erik
2000-09-26 01:00:15 +00:00
Eric Andersen 53323695c5 Remove all reference to the now obsolete /dev/modules
-Erik
2000-09-26 00:52:05 +00:00
Eric Andersen 67fdf5e538 Update my devps patch for the latest 2.2 kernel.
-Erik
2000-09-26 00:20:28 +00:00
Eric Andersen ff1ed7215c Fix name 2000-09-25 22:53:33 +00:00
Eric Andersen d89882da16 Some more polish to make xargs act like GNU xargs (thanks to kent robotti
<robotti@metconnect.com> for testing and pointing out the differences)
 -Erik
2000-09-25 22:53:05 +00:00
Eric Andersen 3570a34de4 Renamed "internal.h" to the more sensible "busybox.h".
-Erik
2000-09-25 21:45:58 +00:00
Eric Andersen caffb6eff0 Gratuitously changed the file "busybox.defs.h" to the more
sensible and noticable "Config.h".
 -Erik
2000-09-25 21:28:07 +00:00
Eric Andersen c5949f62e5 Fix from Matt Kraai for the to the "busybox --install prints out on STDERR
"File already exists" messages for all files (including the ones that DON'T
exist)" problem reported by "Bruno L. F. Cabral" <bruno@openline.com.br>.

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

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

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

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

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

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

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

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

Code is structured to better support upcoming recursive extraction
functionality.

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

modified dd.c to use fullWrite

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

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

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

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

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

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

 -Erik
2000-07-12 23:01:04 +00:00
Matt Kraai be84cd4ef6 Always report the applet name when doing error reporting. 2000-07-12 17:02:35 +00:00
Matt Kraai e58771e73c Use global applet_name instead of local versions. 2000-07-12 15:38:49 +00:00
Matt Kraai e714bce003 Use global applet_name instead of local versions. 2000-07-12 00:53:06 +00:00
Matt Kraai 3ecbe9f4dc The applet name isn't constant. 2000-07-12 00:43:28 +00:00
Eric Andersen 97426e082a Changed verbiage.
-Erik
2000-07-11 23:06:48 +00:00
Eric Andersen 8fbaeece53 Replaced projects with products/projects.
-Erik
2000-07-11 23:05:38 +00:00
Eric Andersen 68fda241d2 Added the Kerbango Internet Radio to projects/products using BusyBox.
-Erik
2000-07-11 23:03:40 +00:00
Mark Whitley 858c1adf2b Applied patch from Matt Kraai to call destroy_cmd_strs in atexit(), rather
than peppering it throughout the code.
2000-07-11 21:38:47 +00:00
Matt Kraai 7719008a85 Added applet_name to contain the applet name. 2000-07-11 20:03:24 +00:00
443 changed files with 111757 additions and 33644 deletions

No files matched your search

+2
View File
@@ -1,2 +1,4 @@
busybox
busybox.links
_install
applet_source_list
Vendored
+33
View File
@@ -0,0 +1,33 @@
--blank-lines-after-declarations
--blank-lines-after-procedures
--break-before-boolean-operator
--no-blank-lines-after-commas
--braces-on-if-line
--braces-on-struct-decl-line
--comment-indentation25
--declaration-comment-column25
--no-comment-delimiters-on-blank-lines
--cuddle-else
--continuation-indentation4
--case-indentation0
--else-endif-column33
--space-after-cast
--line-comments-indentation0
--declaration-indentation1
--dont-format-first-column-comments
--dont-format-comments
--honour-newlines
--indent-level4
/* changed from 0 to 4 */
--parameter-indentation4
--line-length78 /* changed from 75 */
--continue-at-parentheses
--no-space-after-function-call-names
--dont-break-procedure-type
--dont-star-comments
--leave-optional-blank-lines
--dont-space-special-semicolon
--tab-size4
/* additions by Mark */
--case-brace-indentation0
--leave-preprocessor-space
+24
View File
@@ -12,6 +12,9 @@ Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Tons of new stuff, major rewrite of most of the
core apps, tons of new apps as noted in header files.
Edward Betts <edward@debian.org>
expr, hostid, logname, tty, wc, whoami, yes
John Beppu <beppu@lineo.com>
du, head, nslookup, sort, tee, uniq
@@ -25,6 +28,9 @@ Dave Cinege <dcinege@psychosis.com>
more(v2), makedevs, dutmp, modularization, auto links file,
various fixes, Linux Router Project maintenance
Larry Doolittle <ldoolitt@recycle.lbl.gov>
pristine source directory compilation, lots of patches and fixes.
Karl M. Hegbloom <karlheg@debian.org>
cp_mv.c, the test suite, various fixes to utility.c, &c.
@@ -43,15 +49,33 @@ Glenn McGrath <bug1@netconnect.com.au>
Bruce Perens <bruce@pixar.com>
Original author of BusyBox. His code is still in many apps.
Kent Robotti <robotti@metconnect.com>
reset, tons and tons of bug reports and patchs.
Chip Rosenthal <chip@unicom.com>, <crosenth@covad.com>
wget - Contributed by permission of Covad Communications
Pavel Roskin <proski@gnu.org>
Lots of bugs fixes and patches.
Gyepi Sam <gyepi@praxis-sw.com>
Remote logging feature for syslogd
Linus Torvalds <torvalds@transmeta.com>
mkswap, fsck.minix, mkfs.minix
Mark Whitley <markw@lineo.com> <markw@codepoet.org>
grep, sed, cut, xargs, style-guide, new-applet-HOWTO, bug fixes, etc.
Charles P. Wright <cpwright@villagenet.com>
gzip, mini-netcat(nc)
Enrique Zanardi <ezanardi@ull.es>
tarcat (since removed), loadkmap, various fixes, Debian maintenance
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit, stty-port, locale, various fixes
and irreconcilable critic of everything not perfect.
Tim Riker <Tim@Rikers.org>
bug fixes, member of fan club
+367 -2
View File
@@ -1,3 +1,368 @@
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
when pressing <Enter> on an empty line.
* Gennady Feldman -- Fixed a bug that could crash the shell in 0.50
when performing an 'export' in the shell.
* Gennady Feldman -- fixed a syslogd bug where syslogd could cause
the init process to block (which can break systems badly).
New Applets:
* Sterling Huxley -- contributed a new vi applet! This is a very
functional vi implementation in Only 22k.
* Erik Andersen -- added env applet
Other changes:
* Erik Andersen -- Split utility.c into libbb, which provides a
much cleaner was for us to include shared functionality.
* Erik Andersen -- Reorganized how and when busybox includes
syscalls, aiding portability and (in this case) making the
busybox work on ia64 systems.
* Erik Andersen -- dpkg.c cleanup to use the updated gunzip interface.
* Erik Andersen -- Cleanups for libc5, glibc, and uClibc.
* Erik Andersen and Matt Kraai -- Cleanups for the human-readable
output from ls, du, and df.
* Laurence Anderson <laurence@zxmail.com> -- Fixed wget HTTP 1.1
support and added chunked encoding so it is now RFC compliant.
* John Beppu -- The busybox.pod documentation is now automagically
generated from the source code. This makes it _much_ simpler.
Now to update the docs, just update the usage message...
* Dirk Behme <dirk.behme@de.bosch.com> -- Adjusted MIPS insmod
support a bit for Mips RS3.
* Christophe Boyanique -- egrep invoked the "init" applet in 0.50!
* Larry Doolittle -- Added -Wshadow and fixed a number of shadowed
variables
* David Douthitt -- fixed 'find -print'
* Gennady Feldman -- fixes for the syslogd circular buffer code
* Jeff Garzik -- a number of structural cleanups, fixes for -Wshadow
bugs, and similar problems.
* Matt Kraai -- Added a new 'shutdown' action to busybox init. Now
you can specify arbitrary behavior for 'ctrlaltdel' so now
pressing CTL-ALT-DEL can do something else (or nothing).
* Andreas Neuhaus <andy@fasta.fh-dortmund.de> -- fix for merging
kernel command line environment variables into child environment
for init.c
* Glenn McGrath -- Fixed problems with dpkg and dpkg-deb applets
* Glenn McGrath -- Don't try to automount devfs
* Vladimir Oleynik -- optimizations for more.c
* Vladimir Oleynik -- Added locale support to the shell, and fixed
locale support in several other places
* Vladimir Oleynik -- moved struct applet from busybox.c to applets.c
* Vladimir Oleynik -- A size optimization for rdate
* Vladimir Oleynik -- Fixed printf applets's locale handling
* Vladimir Oleynik -- More cmdedit updates
* Vladimir Oleynik -- Fixed `du' applet so it continues running
after permission errors.
* Vladimir Oleynik -- Reduced stack usage in recursive_action()
* Pierre Peiffer <pierre.peiffer@sxb.bsf.alcatel.fr> -- made
find_pid_by_name() cope with swapped out processes.
* Jari Ruusu <jari.ruusu@pp.inet.fi> -- updates so that setting
D_FILE_OFFSET_BITS=64 now works as expected.
* Anthony Towns <aj@azure.humbug.org.au> -- fixed a bug with
sed address range handling
* Dmitry Zakharov <dmit@crp.bank.gov.ua> -- a number of updates
to wget: support for ftp downloads, basic HTTP basic auth, handling
of http redirects, when attempting to continue an aborted download
but server doesn't support restarts then reopen output file in
write mode, bugfix: when content-length not given, wget didn't
download anything, if -c is not specified, it no longer default to
restarting an aborted download.
-Erik Andersen, 10 April 2001
0.50
* Erik Andersen -- added ifconfig interface status reporting
* Erik Andersen -- Debian packaging updates
* Erik Andersen -- lash environment variable expansion rewritten,
with lots of help/fixes/testing from Larry Doolittle.
* Erik Andersen -- Fix use of busybox with dmalloc debugging lib
* Erik Andersen -- fixed ls behavior for broken or very narrow terminals
* Erik Andersen -- stub umount2 and pivot_root if they are not available
* Erik Andersen -- libc5 fixes
* Erik Andersen -- make init work with devfsd
* Erik Andersen -- fixed df for nfs and dos where blksize = 512
* Erik Andersen -- Make sure libpwd.a is linked _last_ so it
overrides the system pwd/grp
* Christophe Boyanique -- added an optional egrep alias for grep.
* Christophe Boyanique -- added optional 'rm -i' support.
* Kenneth Chalmers and Erik Andersen -- fixed ln so it
behaves when given no arguments (prints usage) and when
given just one arg (tries to make a link in the cwd).
* 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
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
generate the documentation from the source code, making life
much simpler for all.
* Magnus Damm <damm@opensource.se> -- Fixed an 'inner scope var
masking outer scope var with same name' bug that prevented
the loopback device from being unmounted if mount() failed.
* Larry Doolittle -- rewrote ifconfig to make it smaller
* Larry Doolittle and Erik Andersen -- cleanups to pristine source
* Larry Doolittle -- many bugfixes resulting from regression testing
* Gennady Feldman -- split syslogd.c into syslogd and klogd
* Gennady Feldman -- make syslogd single threaded -- no more forking
* Jeff Garzik -- getopt-ified rmmod.
* Jeff Garzik -- glibc 2.2 warning cleanups
* Jeff Garzik -- namespace pollution cleanup (staticified variables).
* Erik Gustavsson <cyrano@algonet.se> -- allow env variables set on the
kernel command line to be inherited into init and its children.
* Erik Habbinga -- fixed an uninitialized substitution delimiter in sed.
* Chris Jaeger -- Makefile cleanup to make option setting less error-prone
* Chris Jaeger <cjaeger@ensim.com> -- Carefully check NFS_MOUNT_VERSION
depending on what kernel is being used.
* Quinn Jensen <jensenq@lineo.com> -- MIPS support for busybox insmod.
* Evin Robertson -- new pivot_root applet
* Kent Robotti -- usage message cleanups
* Kent Robotti -- reworked dos2unix/unix2dos
* Evin Robertson and Manuel Novoa III -- reworked how usage messages
are stored to save several k of space.
* Matt Kraai -- Keep trying if an NFS mount fails
* Matt Kraai -- fixed insmod so it won't try to insmod directories.
* Matt Kraai -- added nc listening support
* Matt Kraai and David Douthitt -- reworked fine to support -type,
-perm, -mtime, and other improvements.
* Matt Kraai -- added find_applet_by_name and saved some memory thereby
* Matt Kraai -- added chomp to reduce redundant code elsewhere
* Matt Kraai -- Removed trailing \n chars from error_msg{,_and_die} messages.
* John Lombardo -- fixed OOM in insmod.
* Glenn McGrath -- bypass /proc in mount, now uses sysfs.
* Glenn McGrath -- several updates to dpkg and dpkg-deb.
* Manuel Novoa III -- several size optimizations: parse_mode,
process_escape_sequence, format, and get_kernel_revision.
* Manuel Novoa III -- rewrote ifconfig again to make it smaller still
* Manuel Novoa III -- added ifconfig -a, updated interface reporting
* Vladimir N. Oleynik -- Fixed a bug where init set PATH incorrectly
* Vladimir N. Oleynik -- cleanups to route, cmdedit, mkdir,
mkfs_minix, mkswap, chmod_chown_chgrp and utility.c
* Vladimir N. Oleynik -- many fixes to cmdedit. so tab completion
is now working and general editing is much improved, and to
improve complex prompt handling.
* Vladimir N. Oleynik -- added route status reporting.
* Vladimir N. Oleynik -- fixed wget to use xfopen
* Vladimir N. Oleynik -- new stty applet
* Vladimir N. Oleynik -- fixed find, it used to stop on perm errors.
* Vladimir N. Oleynik -- locale forced to posix for scripts
* Vladimir N. Oleynik -- saved 128 bytes by moving error checking
for several my_* functions into utility.c
* Bjorn Wesen -- new ifconfig and route applet (taken from
work done by Axis Communications).
* Mark Whitley -- Added a 'How to contribute to Busybox' doc
and updated the style guide.
* Mark Whitley -- implemented grep -A, -B, and -C
* Mark Whitley -- overhauled the test suite.
-Erik Andersen, 15 March 2001
0.49
* Matt Kraai -- new sort.c
* Matt Kraai -- new tail.c
* Glenn McGrath -- new 'dpkg-deb' applet
* Glenn McGrath -- new ar code
* spoon -- new watchdog applet
* Vladimir N. Oleynik <dzo@simtreas.ru> -- fixed cmdedit.c so now
scrolling and tab completion in lash work properly. Also several
byte saving optimizations.
* Erik Andersen -- disabled many less commonly used applets by default
* Mark Whitley -- more thrashing about to get clean perror_msg usage
* Matt Kraai -- new command line munging
* Larry Doolittle -- keep some locales from messing up busybox.sh
* Matt Kraai -- cleaned up dd and tail with new parse_number routine
* Mark Whitley -- remove debugging messages from deallocvt
* Matt Kraai and Mark Whitley -- new document "How to Add a New Applet
to BusyBox"
* David Douthitt -- fixed "grep -qv" bug
* Larry Doolittle -- fixed insmod bug with old kernels
* Matt Kraai -- logger remixed to use getopt, selection of stdin made
util-linux compatible
* Erik Andersen -- many more internal symbols classified static to
avoid namespace pollution
* Matt Kraai -- nc listening support
* Erik Andersen -- made sed understand arbitrary regexp delimiters
* Matt Kraai et al. -- more tar improvements and bug fixes, now
handles regexp file exclusion
* Larry Doolittle -- new script (multibuild.pl) to automate build rule
checking
* Matt Kraai -- update/cleanup of the docs on how to use init
* Erik Andersen -- renamed all sh.c symbols per the style guide,
better if-then-else-fi handling
* Erik Andersen -- cleaner division of labor between cmdedit.c and sh.c
* Larry Doolittle -- shell data structure cleanup, fixed buglets
in read, exec, and piped builtins
* Erik Andersen -- md5sum was broken in 0.48. Now fixed (and doesn't
use getline, shrinking static compiles (since nothing else used it).
* ?? -- squashed memory leak in shell prompt handling
* 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
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
whether or not to use the system's passwd and group functions.
Since most systems use GNU libc, this can save you from having to
install the /etc/nsswitch.conf configuration file and the required
libnss_* libraries. Adds 1.5k. You can now, also, disable this,
causing busybox to use the system's pwd.h and grp.h functions.
-Erik Andersen, 27 January 2001
0.48
* Glenn McGrath -- tar now supports uncompressing tar files,
define BB_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.
* me -- Fixed uname problem causing the kernel version to be
mis-detected (causing problems with poweroff, init,
and other things).
* Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and
Nicolas Ferre <nicolas.ferre@alcove.fr> -- insmod support on ARM
and StrongArm, and suport for lsmod on older 2.0.x kernels.
* Kent Robotti -- Renamed unrpm to original rpmunpack, so you can use
an included shell script called unrpm as a front end to it. There's
also a shell script called undeb included for debian packages.
* Matt Kraai -- fix an infinite loop with ls -aR
* Larry Doolittle -- Shaved off about 100 bytes and 200 bytes heap
from date.c. Also document the "-d" option in the usage message.
* Gennady Feldman -- fixed dd to use blocksize when reading/writing,
(it was reading the whole thing and then writing it out). Also
updated usage information (was missing conv=notrunc) and added
conv=sync feature.
* Larry Doolittle (in collaboration with Matt Kraai) -- allow for a
pristine source directory -- where all the .o files and such are
not placed into the source tree. Thanks Larry!
* Larry Doolittle -- use the applet definitions in applets.h
to autogenerate the applet function and usage prototypes.
* Sebastien Huet, Arne Bernin, and Kent Robotti -- Add in tar -X and
fixed a bug breaking tar --exclude.
* Jonas Holmberg -- echo option handling made GNU-echo compatible
* Aleksey Demidov <asd@ixcelerator.com> -- date option handling made
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
* Gaute B Strokkenes <gs234@cam.ac.uk> -- applets found using a
binary search instead of linear search. Much faster!
* new applets: cmp readlink
* Mark Whitley -- Removed advertising clause of Berkeley license
according to decision by the Regents of the University of
California; included reference
* tail's confusing special treatment of single digit options removed;
people should use -n instead
* Larry Doolittle -- \r handled now in echo and tr
* Matt Kraai -- rewrite of uniq
* Mark Whitley -- remix of xargs
* Jim Gleason <jimg@lineo.com> -- fixed tar so it no longer breaks
hard links.
* Matt Kraai -- logger now logs all arguments, not just the first
* Gennady Feldman -- syslogd no longer logs to localhost if compiled
for remote logging...
* Richard June <rjune@ims1.imagestream-is.com> -- support for 'gzip -d'
* various artists -- Other good stuff that I forgot to document.
-Erik Andersen, 13 December 2000
0.47
* A bug in syslogd was fixed that allowed it to potentially fork-bomb
your system. Anyone using 0.46 syslogd should upgrade.
* Renamed busybox.defs.h to the more sensible "Config.h"
* Improved portability between different libcs.
* Many apps ported to use getopt()
* Common handling of '--help'
* All usage messages centralized.
* Added a bunch of new commands:
* 'rdate' contributed by Sterling Huxley <sterling@europa.com>
* 'wget' contributed by Chip Rosenthal <chip@unicom.com>,
<crosenth@covad.com> and Covad Communications
* 'getopt' from "Alfred M. Szmidt" <ams@trillian.itslinux.org>
* dos2unix, unix2dos, reset, and unrpm.c (and lots of help
debugging) thanks to Kent Robotti <robotti@metconnect.com>.
* 'renice' command, thanks to Dave Cinege <dcinege@psychosis.com>
* 'xargs' (written by me)
* 'expr' contributed by Edward Betts <edward@debian.org>, based
on GNY expr
* lsmod now uses the query_module syscall, rather then /proc (me)
* syslogd can now log messages to remote hosts -- patch thanks
to Gyepi Sam <gyepi@praxis-sw.com>
* chroot can now call the builtin shell - Pavel Roskin <proski@gnu.org>
* 'make install' now creates relative symlinks, and added a new
'make install-hardlinks' target to (tada) install hardlinks.
* Rewrite of 'tail' to make it simpler, smaller, and more robust.
It now weighs only 2.25k (3k when full featured). The code is
cleaner too, thanks to Allen Soard <esp-software@mail.hypermart.net>
* Add optional ls file sorting, thanks to a patch from
Sterling Huxley <sterling@europa.com>
* Fixed chmod option parsing so things like 'chmod -r /tmp/file'
now work (previously it thought -r was an option). Doh!
* Fixed tar handling of stdin and stdout
* Renamed "internal.h" to the more sensible "busybox.h"
* Preliminary support for GNU HURD.
* Updated my devps and devmtab kernel patches for the latest 2.2.x
kernel, for those wanting to go proc-less.
* Tons of other bugfixes.
-Erik Andersen, 25 September 2000
0.46
* Better portability. Now should compile cleanly with libc5,
@@ -58,7 +423,7 @@
Matt Kraai as well.
-Erik Andersen
-Erik Andersen, 11 July 2000
0.45
@@ -390,7 +755,7 @@
* Major init re-work. init now supports inittab (slightly different
but similar to sysvinit), allowing me to get all the policy out of
init and into the conf file. It works just fine without inittab
being present, but if you dont like the defautl behavior you can
being present, but if you dont like the default behavior you can
now do something about it. Init is much cleaner as a result.
* Fixed an bug in syslogd causing it to stop after 20 minutes. -erik
* Fixed an embarrasing segfault in head -beppu Fixed the embarrasing
+484
View File
@@ -0,0 +1,484 @@
/* 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_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP
//#define BB_CPIO
#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_MV
//#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_RPM2CPIO
#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_UNIX2DOS
//#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).
//
//
// If you enabled BB_SH above, you may select one of the following shells.
// You can only select ONE of the following shells. Sorry.
//
// 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 very nice
// lightweight command prompt.
//#define BB_FEATURE_LASH
//
// 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.
//#define BB_FEATURE_HUSH
//
// 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...
#define BB_FEATURE_MSH
//
// 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. The
// Posix math support is currently disabled (that bit of code was horrible) but
// will be restored for the next BusyBox release.
//#define BB_FEATURE_ASH
//
// 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
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//
// 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
//
// Disable for a smaller (but less functional) ping
#define BB_FEATURE_FANCY_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
//
//Disable for a 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_FANCY_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
//
// 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 uniqe sort
#define BB_FEATURE_SORT_UNIQUE
//
// 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
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if BB_SH is enabled.
//#define BB_FEATURE_SH_FANCY_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 uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//
// 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
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
// 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
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#if ! defined BB_FEATURE_LASH && ! defined BB_FEATURE_HUSH && ! defined BB_FEATURE_MSH && ! defined BB_FEATURE_ASH
#define BB_FEATURE_MSH
#endif
#if defined BB_FEATURE_ASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#elif defined BB_FEATURE_MSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_HUSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_LASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#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
+8
View File
@@ -0,0 +1,8 @@
1) Check Config.h and adjust if you need a different functionality than
defined by default.
2) Check the Makefile
3) make
4) make install
+1 -1
View File
@@ -18,7 +18,7 @@ mini-gzip(gzip), mini-netcat(mnc)
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
Tons of new stuff as noted in header files
Copyright (C) 1999 by Lineo, inc. and written by
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+318 -73
View File
@@ -1,7 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org>
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org>
# Copyright (C) 1999,2000,2001 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
@@ -19,151 +18,402 @@
#
PROG := busybox
VERSION := 0.46
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
VERSION := 0.52
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
export VERSION
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
DODEBUG = false
# 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
# If you want to add some simple compiler switches (like -march=i686),
# especially from the command line, use this instead of CFLAGS directly.
# For optimization overrides, it's better still to set OPTIMIZATION.
CFLAGS_EXTRA =
# If you want a static binary, turn this on.
DOSTATIC = false
# To compile vs an alternative libc, you may need to use/adjust
# the following lines to meet your needs. This is how I did it...
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
#CFLAGS+=-nostdinc -fno-builtin -I/home/andersen/CVS/uC-libc/include -I$(GCCINCDIR)
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
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).
# Note that if you want hostname resolution to work with glibc, you still need
# the libnss_* libraries. 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
# want to first set up your environment.
# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
# Do not enable this for production builds...
DODMALLOC = false
# Electric-fence is another very useful malloc debugging library.
# Do not enable this for production builds...
DOEFENCE = false
# If you want large file summit support, turn this on.
# This has no effect if you don't have a kernel with lfs
# support, and a system with libc-2.1.3 or later.
# Some of the programs that can benefit from lfs support
# are dd, gzip, mount, tar, and mkfs_minix.
# LFS allows you to use the above programs for files
# larger than 2GB!
DOLFS = false
# If you have a "pristine" source directory, point BB_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 =
# If you are running a cross compiler, you may want to set this
# to something more interesting, like "powerpc-linux-".
CROSS =
CC = $(CROSS)gcc
AR = $(CROSS)ar
STRIPTOOL = $(CROSS)strip
# 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
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
#LIBCDIR=/usr/i386-glibc20-linux
#
# The following is used for libc5 (if you install altgcc and libc5-altdev
# on a Debian system).
#LIBCDIR=/usr/i486-linuxlibc1
#
# For other libraries, you are on your own...
#LDFLAGS+=-nostdlib
#LIBRARIES = /home/andersen/CVS/uC-libc/libc.a
CC = gcc
#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
# use '-Os' optimization if available, else use -O2
OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
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
# Allow alternative stripping tools to be used...
ifndef $(STRIPTOOL)
STRIPTOOL = strip
ARFLAGS = -r
#
#--------------------------------------------------------
# If you're going to do a lot of builds with a non-vanilla configuration,
# it makes sense to adjust parameters above, so you can type "make"
# by itself, instead of following it by the same half-dozen overrides
# every time. The stuff below, on the other hand, is probably less
# prone to casual user adjustment.
#
ifeq ($(strip $(DOLFS)),true)
# For large file summit support
CFLAGS+=-D_FILE_OFFSET_BITS=64
endif
# -D_GNU_SOURCE is needed because environ is used in init.c
ifeq ($(DODEBUG),true)
CFLAGS += -Wall -g -D_GNU_SOURCE
LDFLAGS +=
STRIP =
ifeq ($(strip $(DODMALLOC)),true)
# For testing mem leaks with dmalloc
CFLAGS+=-DDMALLOC
LIBRARIES = -ldmalloc
# Force debug=true, since this is useless when not debugging...
DODEBUG = true
else
CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
LDFLAGS += -s
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
#Only staticly link when _not_ debugging
ifeq ($(DOSTATIC),true)
LDFLAGS += --static
#
#use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work
#to try and strip out any unused junk. Doesn't do much for me, but you may
#want to give it a shot...
#
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
# CFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += --gc-sections
#endif
ifeq ($(strip $(DOEFENCE)),true)
LIBRARIES = -lefence
# Force debug=true, since this is useless when not debugging...
DODEBUG = true
endif
endif
ifeq ($(strip $(DODEBUG)),true)
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS += -Wl,-warn-common
STRIP =
else
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
LDFLAGS += -s -Wl,-warn-common
STRIP = $(STRIPTOOL) --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)
PREFIX = `pwd`/_install
endif
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
# the copy in BB_SRC_DIR, both during the compilation phase and the
# shell script that finds the list of object files.
# Work in progress by <ldoolitt@recycle.lbl.gov>.
#
ifneq ($(strip $(BB_SRC_DIR)),)
VPATH = $(BB_SRC_DIR)
endif
#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 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)"'
endif
all: busybox busybox.links doc
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 chomp.c concat_path_file.c copy_file.c \
copy_file_chunk.c daemon.c device_open.c error_msg.c \
error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \
find_root_device.c full_read.c full_write.c get_console.c \
get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \
isdirectory.c kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c \
mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \
my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \
safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c
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
LIBBB_MSRC=libbb/messages.c
LIBBB_MESSAGES= full_version name_too_long omitting_directory not_a_directory \
memory_exhausted invalid_date invalid_option io_error dash_dash_help \
write_error too_few_args name_longer_than_foo unknown
LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES))
LIBBB_ARCSRC=libbb/unarchive.c
LIBBB_ARCOBJ= archive_offset seek_sub_file extract_archive unarchive \
get_header_ar get_header_cpio get_header_tar deb_extract
LIBBB_AROBJS=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_ARCOBJ))
# 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
applet_source_list: busybox.sh Config.h
(echo -n "APPLET_SOURCES := "; BB_SRC_DIR=$(BB_SRC_DIR) $(SHELL) $^) > $@
doc: olddoc
# Old Docs...
olddoc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
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
- ( cat docs/busybox_header.pod; \
docs/autodocifier.pl usage.h; \
cat docs/busybox_footer.pod ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
@echo
@echo BusyBox Documentation
@echo
- pod2text docs/busybox.pod > docs/BusyBox.txt
-mkdir -p docs
-pod2text $< > $@
docs/BusyBox.1: docs/busybox.pod
- pod2man --center=BusyBox --release="version $(VERSION)" docs/busybox.pod > docs/BusyBox.1
- mkdir -p docs
- pod2man --center=BusyBox --release="version $(VERSION)" \
$< > $@
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
- rm -f docs/BusyBox.html
- ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
- mkdir -p docs
-@ rm -f docs/BusyBox.html
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
- pod2html --noindex docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html
- rm -f pod2html*
-@ mkdir -p docs/busybox.lineo.com
- pod2html --noindex $< > \
docs/busybox.lineo.com/BusyBox.html
-@ rm -f pod2htm*
# New docs based on DOCBOOK SGML
newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busybox.html
newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
docs/busybox.txt: docs/busybox.sgml
@echo
@echo BusyBox Documentation
@echo
- mkdir -p docs
(cd docs; sgmltools -b txt busybox.sgml)
docs/busybox.dvi: docs/busybox.sgml
- mkdir -p docs
(cd docs; sgmltools -b dvi busybox.sgml)
docs/busybox.ps: docs/busybox.sgml
- mkdir -p docs
(cd docs; sgmltools -b ps busybox.sgml)
docs/busybox.pdf: docs/busybox.ps
- mkdir -p docs
(cd docs; ps2pdf busybox.ps)
docs/busybox/busybox.html: docs/busybox.sgml
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
- mkdir -p docs
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
busybox: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBBB_LIB) $(PWD_LIB) $(LIBRARIES)
$(STRIP)
busybox.links: busybox.def.h
- ./busybox.mkll | sort >$@
# 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) $^ >$@
nfsmount.o cmdedit.o: %.o: %.h
$(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile
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
$(LIBBB_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile libbb/libbb.h
- mkdir -p $(LIBBB)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -c $< -o $*.o
$(LIBBB_MOBJ): $(LIBBB_MSRC)
- mkdir -p $(LIBBB)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
$(LIBBB_AROBJS): $(LIBBB_ARCSRC)
- mkdir -p $(LIBBB)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
libpwd.a: $(PWD_OBJS)
$(AR) $(ARFLAGS) $@ $^
libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
$(AR) $(ARFLAGS) $@ $^
usage.o: usage.h
sh.o: sh.c lash.c hush.c msh.c ash.c
libbb/loop.o: libbb/loop.h
libbb/loop.h: mk_loop_h.sh
@ $(SHELL) $< > $@
test tests:
cd tests && $(MAKE) all
# old way of doing it
#cd tests && $(MAKE) all
# new way of doing it
cd tests && ./tester.sh
clean:
- rm -f busybox.links *~ *.o core
- rm -rf _install
- cd tests && $(MAKE) clean
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
docs/busybox.lineo.com/BusyBox.html
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
- rm -rf docs/busybox
- rm -f multibuild.log Config.h.orig
- rm -rf docs/busybox _install libpwd.a libbb.a pod2htm*
- rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list
- find -name \*.o -exec rm -f {} \;
distclean: clean
- rm -f busybox
- rm -f busybox applet_source_list
- cd tests && $(MAKE) distclean
install: busybox busybox.links
./install.sh $(PREFIX)
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 ..; \
@@ -173,17 +423,12 @@ dist release: distclean doc
find busybox-$(VERSION)/ -type d \
-name CVS \
-print \
| xargs rm -rf; \
\
find busybox-$(VERSION)/ -type f \
-name .cvsignore \
-print \
| xargs rm -f; \
-exec rm -rf {} \; ; \
\
find busybox-$(VERSION)/ -type f \
-name .\#* \
-print \
| xargs rm -f; \
-exec rm -f {} \; ; \
\
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
+69 -17
View File
@@ -4,51 +4,103 @@ 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
embedded system. The utilities in BusyBox generally have fewer options than
their full featured GNU cousins; however, the options that are included provide
the expected functionality and behave very much like their GNU counterparts.
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add a kernel, a shell (such as ash),
and an editor (such as elvis-tiny or ae).
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.
Busybox was originally written to support the Debian Rescue/Install disks, but
BusyBox was originally written to support the Debian Rescue/Install disks, but
it also makes an excellent environment for any small or embedded system.
As of version 0.20 there is a version number. : ) Also as of version 0.20,
As of version 0.20 there is now a version number. : ) Also as of version 0.20,
BusyBox is now modularized to easily allow you to build only the components you
need, thereby reducing binary size. To turn off unwanted Busybox components,
simply edit the file busybox.def.h and comment out the components you do not
need using C++ style (//) comments.
need, thereby reducing binary size. To turn off unwanted BusyBox components,
simply edit the file "Config.h" and comment out the components you do not need
using C++ style (//) comments.
After the build is complete a busybox.links file is generated which is then
After the build is complete, a busybox.links file is generated. This is
used by 'make install' to create symlinks to the busybox binary for all
compiled in functions. By default, 'make install' will place the symlink
forest into `pwd`/_install unless you have defined the PREFIX environment
variable (i.e. make PREFIX="/tmp/foo" install)
variable (i.e., 'make PREFIX=/tmp/foo install')
----------------
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.
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.
Supported kernels:
Full functionality requires Linux 2.0.x, 2.2.x, or 2.4.x. A large fraction
of the code should run on just about anything.
----------------
Getting help:
When you find you need help, you can check out the BusyBox mailing list
archives at http://opensource.lineo.com/lists/busybox/ or even join
the mailing list if you are interested.
----------------
Bugs:
If you find bugs, follow the instructions at http://bugs.lineo.com/Reporting.html
and submit a bug report. This way, we can be sure nothing falls through the
cracks...
If you find bugs, please submit a bug report. Full instructions on how to
report a bug are found at http://bugs.lineo.com/Reporting.html.
For the impatient: To submit a bug, simply send an email describing the problem
to submit@bugs.lineo.com. Bug reports should look something like this:
To: submit@bugs.lineo.com
From: diligent@testing.linux.org
Subject: /bin/true doesn't work
Package: busybox
Version: 0.51
When I invoke '/bin/true' it doesn't work. I expected it to return
a "0" but it returned a "1" instead. Here is the transcript:
$ /bin/true ; echo $?
1
With GNU /bin/true, I get the following output:
$ /bin/true ; echo $?
0
I am using Debian 2.2r2, kernel version 2.2.18, and the latest
uClibc from CVS. Thanks for the wonderful program!
-Diligent
Note the careful description and use of examples showing not only what BusyBox
does, but also a counter example showing what an equivalent GNU app does. Bug
reports lacking such detail may take a _long_ time to be fixed... Thanks for
understanding.
----------------
FTP:
Source for the latest released version can always be downloaded from
ftp://ftp.lineo.com/pub/busybox.
----------------
CVS:
BusyBox now has its own publically browsable CVS tree at:
BusyBox now has its own publicly browsable CVS tree at:
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
Anonymous CVS access is available. For instructions, check out:
@@ -57,15 +109,15 @@ Anonymous CVS access is available. For instructions, check out:
For those that are actively contributing there is even CVS write access:
http://opensource.lineo.com/cvs_write.html
----------------
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersee@debian.org>
<andersee@codepoet.org>
<blatent plug>
<blatant plug>
Many thanks to go to Lineo for paying me to work on busybox.
</blatent plug>
</blatant plug>
+23 -377
View File
@@ -6,51 +6,40 @@ around to it some time. If you have any good ideas, please let me know.
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
needed or wanted in busybox (or else I'd have to link to libcrypt).
* Networking apps are probably going to be split out some time soon into a
separate package (named perhaps netkit-tiny?). This would remove the
following items from BusyBox: hostid, hostname, nc, nslookup, telnet,
and ping. nfs mounting and syslogd (when it supports network logging)
will remain in BusyBox.
* We _were_ going to split networking apps into a new package called
netkit-tiny. Per discussions on the mailing list, this isn't going
to happen. False alarm. Sorry about the confusion.
-Erik
-----------
* Make insmod actually work
* dnsdomainname
* traceroute/netstat
* rdate
Possible apps to include some time:
* hwclock
* stty
* expr
* wget (or whatever I call it)
* tftp
* ftp
* start-stop-daemon
* group/commonize strings, remove dups (for i18n, l10n)
* consider making a unified option parser (if it can be done
modular, small, etc.)
-----------
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.
-----------------------
Running the following:
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.
It would be a very nice thing to reduce this list to an absolute minimum, and
then create a microLibc to provide these functions. There is no good reason
for GNU libc to be so big. I'm sure it can be a lot better.
(BTW, this is more informative if BB_FEATURE_NFSMOUNT is turned off...)
Most wanted list:
[andersen@slag busybox]$ grep -l getgroups *.[ch]
test.c
Policy violation. getgroups uses libc nss, which is unlikely
to be present in an embedded system.
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.
-----------------------
@@ -59,353 +48,10 @@ and then start with the biggest things and make them smaller...
-----------------------
du.c probably ought to have an -x switch like GNU du does...
I think that the add_inode &c in utility.c needs to also stow the
st_dev field, and that du.c should NOT call `reset_inode_list'
because there can be hard links from inside one argv/ to inside
another argv/. du.c probably ought to have an -x switch like GNU du
does also...
-----------------------
xargs could use a -l option
------------------------------------------------------------------
An interesting email listing some apps that use /proc. BusyBox
tries to avoid /proc as mush as is possible, so this stuff is
interesting (to me at least):
Date: Fri, 25 Feb 2000 08:23:12 +0000 (GMT)
From: Riley Williams <rhw@MemAlpha.CX>
X-Sender: rhw@moo.cus.org.uk
To: almesber@lrc.di.epfl.ch
Cc: "Albert D. Cahalan" <acahalan@cs.uml.edu>,
Linux Kernel <linux-kernel@vger.rutgers.edu>
Subject: Re: What /proc should contain [was: /proc/driver/microcode]
In-Reply-To: <20000224165245.A29790@lrc.di.epfl.ch>
Message-ID: <Pine.LNX.4.21.0002250806220.8741-100000@moo.cus.org.uk>
Sender: owner-linux-kernel@vger.rutgers.edu
Precedence: bulk
Hi there.
>> Nope, most /proc access is does via programs written in C.
> That varies a lot from file to file. E.g. I haven't seen any
> programs that are specificly designed to read /proc/atm/* yet,
> and I know of only one (fuser) that reads /proc/mounts,
> extracting only partial information (just to pick two examples
> that I'm quite familiar with).
As a point of reference, here's a slightly tweaked analysis of the
programs on the system I'm reading your mail on. Basically, I ran the
following script...
Q> #!/bin/bash
Q> function use() {
Q> for Z in $* ; do
Q> strings $Z | grep /proc | sed "s=^=$Z ="
Q> done
Q> }
Q> use /{,s}bin/* /usr/{,s}bin/* | sort -u | tee proc-usage
...and then went through it removing comments and print format
strings. Replace /proc with /dev and you'd soon have an equivalent
list for that - although I can report that such is MUCH larger...
There are three programs therein that refer to /proc/mounts ...
/bin/mount
/bin/umount
/usr/bin/eject
...and, as you stated, none that refer to /proc/atm on this system.
However, as this is a RedHat Linux 5.0 based system, that's not
necessarily an up to date reference thereto...
Here's the list anyway...
/bin/kill /proc/%d/cmdline
/bin/kill /proc/%d/stat
/bin/mount /proc/devices
/bin/mount /proc/filesystems
/bin/mount /proc/mounts
/bin/netstat /proc/net
/bin/netstat /proc/net/appletalk
/bin/netstat /proc/net/ax25
/bin/netstat /proc/net/ax25_route
/bin/netstat /proc/net/dev
/bin/netstat /proc/net/ip_masquerade
/bin/netstat /proc/net/ipx
/bin/netstat /proc/net/ipx_route
/bin/netstat /proc/net/netstat
/bin/netstat /proc/net/nr
/bin/netstat /proc/net/nr_neigh
/bin/netstat /proc/net/nr_nodes
/bin/netstat /proc/net/raw
/bin/netstat /proc/net/route
/bin/netstat /proc/net/rt_cache
/bin/netstat /proc/net/snmp
/bin/netstat /proc/net/tcp
/bin/netstat /proc/net/udp
/bin/netstat /proc/net/unix
/bin/umount /proc/devices
/bin/umount /proc/mounts
/sbin/arp /proc/net/appletalk
/sbin/arp /proc/net/arp
/sbin/arp /proc/net/ax25
/sbin/arp /proc/net/ipx
/sbin/arp /proc/net/nr
/sbin/arp /proc/net/unix
/sbin/cardctl /proc/devices
/sbin/cardmgr /proc/devices
/sbin/fdisk /proc/ide/%s/media
/sbin/fdisk /proc/scsi/scsi
/sbin/getty /proc/version
/sbin/ifconfig /proc/net
/sbin/ifconfig /proc/net/appletalk
/sbin/ifconfig /proc/net/ax25
/sbin/ifconfig /proc/net/dev
/sbin/ifconfig /proc/net/ipx
/sbin/ifconfig /proc/net/nr
/sbin/ifconfig /proc/net/unix
/sbin/ifup /proc/sys/kernel/modprobe
/sbin/ipchains /proc/net/ip_fwchains
/sbin/ipchains /proc/net/ip_fwnames
/sbin/ipchains /proc/net/ip_masquerade
/sbin/ipchains /proc/sys/net/ipv4/ip_forward
/sbin/ipmaddr /proc/net/dev_mcast
/sbin/ipmaddr /proc/net/igmp
/sbin/ipmaddr /proc/net/igmp6
/sbin/iptunnel /proc/net/dev
/sbin/killall5 /proc/%s/cmdline
/sbin/killall5 /proc/%s/exe
/sbin/killall5 /proc/%s/stat
/sbin/killall5 /proc/version
/sbin/klogd /proc/kmsg
/sbin/lsmod /proc/modules
/sbin/modprobe /proc/modules
/sbin/pidof /proc/%s/cmdline
/sbin/pidof /proc/%s/exe
/sbin/pidof /proc/%s/stat
/sbin/pidof /proc/version
/sbin/probe /proc/pci
/sbin/rarp /proc/net/ax25
/sbin/rarp /proc/net/nr
/sbin/rarp /proc/net/rarp
/sbin/rmmod /proc/modules
/sbin/rmmod.static /proc/modules
/sbin/route /proc/net/appletalk
/sbin/route /proc/net/ax25
/sbin/route /proc/net/ax25_route
/sbin/route /proc/net/ipx
/sbin/route /proc/net/ipx_route
/sbin/route /proc/net/nr
/sbin/route /proc/net/nr_neigh
/sbin/route /proc/net/nr_nodes
/sbin/route /proc/net/route
/sbin/route /proc/net/rt_cache
/sbin/route /proc/net/unix
/sbin/scsi_info /proc/scsi
/sbin/scsi_info /proc/scsi/%s
/sbin/scsi_info /proc/scsi/scsi
/sbin/slattach /proc/net/ax25
/sbin/slattach /proc/net/nr
/sbin/swapoff /proc/swaps
/sbin/swapon /proc/swaps
/sbin/uugetty /proc/version
/usr/bin/dig /proc/
/usr/bin/dig /proc/interrupts
/usr/bin/dig /proc/meminfo
/usr/bin/dig /proc/rtc
/usr/bin/dig /proc/self/status
/usr/bin/dig /proc/stat
/usr/bin/dnsquery /proc/
/usr/bin/dnsquery /proc/interrupts
/usr/bin/dnsquery /proc/meminfo
/usr/bin/dnsquery /proc/rtc
/usr/bin/dnsquery /proc/self/status
/usr/bin/dnsquery /proc/stat
/usr/bin/eject /proc/mounts
/usr/bin/emacs /proc/loadavg
/usr/bin/fetchmail /proc/net/dev
/usr/bin/free /proc/meminfo
/usr/bin/gmake /proc/loadavg
/usr/bin/gpm-root /proc/loadavg
/usr/bin/gpm-root /proc/meminfo
/usr/bin/host /proc/
/usr/bin/host /proc/interrupts
/usr/bin/host /proc/meminfo
/usr/bin/host /proc/rtc
/usr/bin/host /proc/self/status
/usr/bin/host /proc/stat
/usr/bin/hoststat /proc/loadavg
/usr/bin/hwdiag /proc/cpuinfo
/usr/bin/hwdiag /proc/pci
/usr/bin/hwdiag /proc/scsi/scsi
/usr/bin/hwdiag /proc/version
/usr/bin/lsdev /proc/dma
/usr/bin/lsdev /proc/interrupts
/usr/bin/lsdev /proc/ioports
/usr/bin/mailq /proc/loadavg
/usr/bin/make /proc/loadavg
/usr/bin/mcookie /proc/loadavg
/usr/bin/mcookie /proc/stat
/usr/bin/newaliases /proc/loadavg
/usr/bin/nslookup /proc/
/usr/bin/nslookup /proc/interrupts
/usr/bin/nslookup /proc/meminfo
/usr/bin/nslookup /proc/rtc
/usr/bin/nslookup /proc/self/status
/usr/bin/nslookup /proc/stat
/usr/bin/nsupdate /proc/
/usr/bin/nsupdate /proc/interrupts
/usr/bin/nsupdate /proc/meminfo
/usr/bin/nsupdate /proc/rtc
/usr/bin/nsupdate /proc/self/status
/usr/bin/nsupdate /proc/stat
/usr/bin/pgp /proc/version
/usr/bin/pgpe /proc/version
/usr/bin/pgpk /proc/version
/usr/bin/pgps /proc/version
/usr/bin/pgpv /proc/version
/usr/bin/procinfo /proc/cmdline
/usr/bin/procinfo /proc/devices
/usr/bin/procinfo /proc/dma
/usr/bin/procinfo /proc/filesystems
/usr/bin/procinfo /proc/interrupts
/usr/bin/procinfo /proc/loadavg
/usr/bin/procinfo /proc/meminfo
/usr/bin/procinfo /proc/modules
/usr/bin/procinfo /proc/stat
/usr/bin/procinfo /proc/uptime
/usr/bin/procinfo /proc/version
/usr/bin/purgestat /proc/loadavg
/usr/bin/screen /proc/loadavg
/usr/bin/strace /proc/%d/stat
/usr/bin/top /proc/cpuinfo
/usr/bin/top /proc/meminfo
/usr/bin/top /proc/stat
/usr/bin/vmstat /proc/%s/stat
/usr/bin/vmstat /proc/meminfo
/usr/bin/vmstat /proc/stat
/usr/sbin/atd /proc/loadavg
/usr/sbin/dnskeygen /proc/
/usr/sbin/dnskeygen /proc/interrupts
/usr/sbin/dnskeygen /proc/meminfo
/usr/sbin/dnskeygen /proc/rtc
/usr/sbin/dnskeygen /proc/self/status
/usr/sbin/dnskeygen /proc/stat
/usr/sbin/fuser /proc/%d/stat
/usr/sbin/fuser /proc/net/%s
/usr/sbin/fuser /proc/net/unix
/usr/sbin/in.identd /proc/net/tcp
/usr/sbin/irpd /proc/
/usr/sbin/irpd /proc/interrupts
/usr/sbin/irpd /proc/meminfo
/usr/sbin/irpd /proc/rtc
/usr/sbin/irpd /proc/self/status
/usr/sbin/irpd /proc/stat
/usr/sbin/named /proc/
/usr/sbin/named /proc/interrupts
/usr/sbin/named /proc/meminfo
/usr/sbin/named /proc/rtc
/usr/sbin/named /proc/self/status
/usr/sbin/named /proc/stat
/usr/sbin/named-xfer /proc/
/usr/sbin/named-xfer /proc/interrupts
/usr/sbin/named-xfer /proc/meminfo
/usr/sbin/named-xfer /proc/rtc
/usr/sbin/named-xfer /proc/self/status
/usr/sbin/named-xfer /proc/stat
/usr/sbin/readprofile /proc/profile
/usr/sbin/rwhod /proc/loadavg
/usr/sbin/rwhod /proc/uptime
/usr/sbin/sendmail /proc/loadavg
/usr/sbin/setconsole /proc/openprom/options
/usr/sbin/setconsole /proc/openprom/options/${console}-mode
/usr/sbin/setconsole /proc/openprom/options/input-device
/usr/sbin/setconsole /proc/openprom/options/output-device
Best wishes from Riley.
* Copyright (C) 1999, Memory Alpha Systems.
* All rights and wrongs reserved.
+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* http://www.memalpha.cx/Linux/Kernel/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
+176
View File
@@ -0,0 +1,176 @@
/*
* 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);
}
+113
View File
@@ -0,0 +1,113 @@
/* 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"
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 const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
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();
}
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 = 0;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+454
View File
@@ -0,0 +1,454 @@
/*
* 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_CHGRP
APPLET(chgrp, chgrp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD
APPLET(chmod, chmod_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHOWN
APPLET(chown, chown_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
APPLET(cp, cp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CPIO
APPLET(cpio, cpio_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_MV
APPLET(mv, 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_RPM2CPIO
APPLET(rpm2cpio, rpm2cpio_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, unix2dos_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
+113
View File
@@ -0,0 +1,113 @@
/* 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"
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 const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
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();
}
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 = 0;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+67 -424
View File
@@ -1,364 +1,21 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
static int been_there_done_that = 0;
/* It has been alledged that doing such things can
* help reduce binary size when staticly linking,
* of course with glibc, this is unlikely as long
* as we use things like printf -- perhaps a printf
* replacement may be in order
*/
#if 0
void exit(int status) __attribute__ ((noreturn));
void exit(int status)
{
_exit(status);
};
void abort(void) __attribute__ ((__noreturn__));
void abort(void)
{
_exit(0);
};
int atexit(void (*__func) (void))
{
_exit(0);
};
void *__libc_stack_end;
#include <stdlib.h>
#include "busybox.h"
#ifdef BB_LOCALE_SUPPORT
#include <locale.h>
#endif
const struct BB_applet applets[] = {
#ifdef BB_AR
{"ar", ar_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_BASENAME
{"basename", basename_main, _BB_DIR_USR_BIN},
#endif
{"busybox", busybox_main, _BB_DIR_BIN},
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_CLEAR
{"clear", clear_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_CUT
{"cut", cut_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
#ifdef BB_DC
{"dc", dc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DD
{"dd", dd_main, _BB_DIR_BIN},
#endif
#ifdef BB_DF
{"df", df_main, _BB_DIR_BIN},
#endif
#ifdef BB_DIRNAME
{"dirname", dirname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DMESG
{"dmesg", dmesg_main, _BB_DIR_BIN},
#endif
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUMPKMAP
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_FDFLUSH
{"fdflush", fdflush_main, _BB_DIR_BIN},
#endif
#ifdef BB_FIND
{"find", find_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREE
{"free", free_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREERAMDISK
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_DEALLOCVT
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
#endif
#ifdef BB_HEAD
{"head", head_main, _BB_DIR_BIN},
#endif
#ifdef BB_HOSTID
{"hostid", hostid_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_HOSTNAME
{"hostname", hostname_main, _BB_DIR_BIN},
#endif
#ifdef BB_ID
{"id", id_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_INIT
{"init", init_main, _BB_DIR_SBIN},
#endif
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
#endif
#ifdef BB_KILLALL
{"killall", kill_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LINUXRC
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
#endif
#ifdef BB_LOADACM
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADFONT
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
#endif
#ifdef BB_LSMOD
{"lsmod", lsmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
#ifdef BB_NC
{"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
#endif
#ifdef BB_MOUNT
{"mount", mount_main, _BB_DIR_BIN},
#endif
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PING
{"ping", ping_main, _BB_DIR_BIN},
#endif
#ifdef BB_POWEROFF
{"poweroff", poweroff_main, _BB_DIR_SBIN},
#endif
#ifdef BB_PRINTF
{"printf", printf_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PS
{"ps", ps_main, _BB_DIR_BIN},
#endif
#ifdef BB_PWD
{"pwd", pwd_main, _BB_DIR_BIN},
#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_RM
{"rm", rm_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMDIR
{"rmdir", rmdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMMOD
{"rmmod", rmmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_SORT
{"sort", sort_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYNC
{"sync", sync_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_TAIL
{"tail", tail_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TAR
{"tar", tar_main, _BB_DIR_BIN},
#endif
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEE
{"tee", tee_main, _BB_DIR_BIN},
#endif
#ifdef BB_TOUCH
{"touch", touch_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TR
{"tr", tr_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UMOUNT
{"umount", umount_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUENCODE
{"uuencode", uuencode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUDECODE
{"uudecode", uudecode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_WC
{"wc", wc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHICH
{"which", which_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHOAMI
{"whoami", whoami_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_YES
{"yes", yes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
{0}
};
int 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, internal.h::Location,
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
@@ -380,64 +37,65 @@ 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 {
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
static int install_links(const char *busybox, int use_symbolic_links)
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
char *fpc;
int i;
int rc = 0;
int rc;
if (use_symbolic_links) Link = symlink;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf (
command,
"%s/%s",
install_dir[applets[i].location],
applets[i].name
);
#if 1
rc |= Link(busybox, command);
#else
puts(command);
#endif
if (rc) {
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
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);
}
return rc;
}
#if 0
int uninstall_links() ?
#endif
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
char *s;
char *name;
const struct BB_applet *a = applets;
const char *s;
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
/* Add in a special case hack for a leading hyphen */
if (**argv == '-' && *(*argv+1)!= '-') {
applet_name = (*argv+1);
}
#ifdef BB_LOCALE_SUPPORT
#ifdef BB_INIT
if(getpid()!=1) /* Do not set locale for `init' */
#endif
{
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
/*
@@ -469,48 +127,20 @@ int main(int argc, char **argv)
}
#endif /* BB_FEATURE_INSTALLER */
for (s = name = argv[0]; *s != '\0';) {
if (*s++ == '/')
name = s;
}
*argv = name;
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-')
exit(((*(shell_main)) (argc, argv)));
#endif
while (a->name != 0) {
if (strcmp(name, a->name) == 0) {
exit(((*(a->main)) (argc, argv)));
}
a++;
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
int col = 0;
argc--;
argv++;
/* 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, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n"
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", BB_VER, BB_BT);
"\nCurrently defined functions:\n", full_version);
while (a->name != 0) {
col +=
@@ -522,10 +152,23 @@ int busybox_main(int argc, char **argv)
}
}
fprintf(stderr, "\n\n");
exit(-1);
exit(0);
}
/* If we've already been here once, exit now */
/* 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));
}
+19 -14
View File
@@ -1,19 +1,24 @@
#!/bin/sh
# Make busybox links list file.
DF="busybox.def.h"
MF="busybox.c"
# 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
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
for def in ${LIST}; do
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
for j in $i; do
if [ -z $j ] ; then
continue;
fi;
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
done;
done
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
}'
+12 -6
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 ` \
gcc -E -dM busybox.def.h | \
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 [:upper:] [:lower:] | sort
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
if [ -d "$BB_SRC_DIR" ]; then cd $BB_SRC_DIR; fi
# By running $RAW through "ls", we avoid listing
# source files that don't exist.
ls $RAW 2>/dev/null | tr '\n' ' '
+40 -9
View File
@@ -1,21 +1,52 @@
#!/bin/sh
set -e
export LC_ALL=POSIX
export LC_CTYPE=POSIX
if [ "$1" = "" ]; then
prefix=$1
if [ "$prefix" = "" ]; then
echo "No installation directory, aborting."
exit 1;
fi
if [ "$2" = "--hardlinks" ]; then
linkopts="-f"
else
linkopts="-fs"
fi
h=`sort busybox.links | uniq`
rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
for i in $h ; do
echo " $1$i -> /bin/busybox"
mkdir -p $1/`echo $i | sed -e 's/\/[^\/]*$//' `
ln -fs /bin/busybox $1$i
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
else
case "$appdir" in
/)
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
fi
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
done
rm -f $1/bin/busybox
mkdir -p $1/bin
install -m 755 busybox $1/bin/busybox
exit 0
+10
View File
@@ -0,0 +1,10 @@
#include "busybox.h"
const char usage_messages[] =
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
;
+1787
View File
File diff suppressed because it is too large. Load diff
+49 -292
View File
@@ -3,8 +3,8 @@
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
*
* 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
@@ -21,312 +21,69 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Last modified 10 June 2000
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <sys/types.h>
#include "internal.h"
#define AR_BLOCK_SIZE 60
#define AR_PRESERVE_DATE 1 /* preserve original dates */
#define AR_VERBOSE 2 /* be verbose */
#define AR_DISPLAY 4 /* display contents */
#define AR_EXT_TO_FILE 8 /* extract contents of archive */
#define AR_EXT_TO_STDOUT 16 /* extract to stdout */
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
struct ArHeader { /* Byte Offset */
char ar_name[16]; /* 0-15 */
char ar_date[12]; /* 16-27 */
char ar_uid[6], ar_gid[6]; /* 28-39 */
char ar_mode[8]; /* 40-47 */
char ar_size[10]; /* 48-57 */
char ar_fmag[2]; /* 58-59 */
};
typedef struct ArHeader ArHeader;
struct ArInfo {
char name[17]; /* File name */
time_t date; /* long int, No of seconds since epoch */
uid_t uid; /* unsigned int, Numeric UID */
gid_t gid; /* unsigned int, Numeric GID */
mode_t mode; /* unsigned int, Unix mode */
size_t size; /* int, Size of the file */
};
typedef struct ArInfo ArInfo;
static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nExtract or list files from an ar archive.\n\n"
"Options:\n"
"\to\t\tpreserve original dates\n"
"\tp\t\textract to stdout\n"
"\tt\t\tlist\n"
"\tx\t\textract\n"
"\tv\t\tverbosely list files processed\n"
#endif
;
/*
* Display details of a file, verbosly if funct=2
*/
static void displayEntry(struct ArInfo *entry, int funct)
{
/* TODO convert mode to string */
if ((funct & AR_VERBOSE) == AR_VERBOSE)
printf("%i %i/%i %8i %s ", entry->mode, entry->uid, entry->gid,
entry->size, timeString(entry->date));
printf("%s\n", entry->name);
}
/* this is from tar.c remove later*/
static long getOctal(const char *cp, int size)
{
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
if ((size == 0) || !isOctal(*cp))
return -1;
for(; (size > 0) && isOctal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
if ((size > 0) && *cp)
return -1;
return val;
}
/*
* Converts from the char based struct to a new struct with stricter types
*/
static int processArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
{
int count2;
int count;
/* check end of header marker is valid */
if ((rawHeader->ar_fmag[0]!='`') || (rawHeader->ar_fmag[1]!='\n'))
return(FALSE);
/* convert filename */
for (count = 0; count < 16; count++) {
/* allow spaces in filename except at the end */
if (rawHeader->ar_name[count] == ' ') {
for (count2 = count; count2 < 16; count2++)
if (!isspace(rawHeader->ar_name[count2]))
break;
if (count2 >= 16)
break;
}
/* GNU ar uses '/' as an end of filename marker */
if (rawHeader->ar_name[count] == '/')
break;
header->name[count] = rawHeader->ar_name[count];
}
header->name[count] = '\0';
header->date = atoi(rawHeader->ar_date);
header->uid = atoi(rawHeader->ar_uid);
header->gid = atoi(rawHeader->ar_gid);
header->mode = getOctal(rawHeader->ar_mode, sizeof(rawHeader->ar_mode));
header->size = atoi(rawHeader->ar_size);
return (TRUE);
}
/*
* Copy size bytes from current position if srcFd to current position in dstFd
* taken from tarExtractRegularFile in tar.c, remove later
*/
static int copySubFile(int srcFd, int dstFd, int copySize)
{
int readSize, writeSize, doneSize;
char buffer[BUFSIZ];
while (copySize > 0) {
if (copySize > BUFSIZ)
readSize = BUFSIZ;
else
readSize = copySize;
writeSize = fullRead(srcFd, buffer, readSize);
if (writeSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
doneSize = fullWrite(dstFd, buffer, writeSize);
if (doneSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
copySize -= doneSize;
}
return (TRUE);
}
/*
* Extract the file described in ArInfo to the specified path
* set the new files uid, gid and mode
*/
static int extractToFile(struct ArInfo *file, int funct, int srcFd, const char *path)
{
int dstFd, temp;
struct stat tmpStat;
char *pathname = NULL;
struct utimbuf newtime;
if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
if (!createPath(path, 0777)) {
fatalError("Cannot extract to specified path");
return (FALSE);
}
}
temp = (strlen(path) + 16);
pathname = (char *) xmalloc(temp);
pathname = strcpy(pathname, path);
pathname = strcat(pathname, file->name);
dstFd = device_open(pathname, O_WRONLY | O_CREAT);
temp = copySubFile(srcFd, dstFd, file->size);
fchown(dstFd, file->uid, file->gid);
fchmod(dstFd, file->mode);
close(dstFd);
if ((funct&AR_PRESERVE_DATE)==AR_PRESERVE_DATE)
newtime.modtime=file->date;
else
newtime.modtime=time(0);
newtime.actime=time(0);
temp = utime(pathname, &newtime);
return (TRUE);
}
/*
* Return a file descriptor for the specified file and do error checks
*/
static int getArFd(char *filename)
{
int arFd;
char arVersion[8];
arFd = open(filename, O_RDONLY);
if (arFd < 0) {
errorMsg("Error opening '%s': %s\n", filename, strerror(errno));
return (FALSE);
}
if (fullRead(arFd, arVersion, 8) <= 0) {
errorMsg( "ar: Unexpected EOF in archive\n");
return (FALSE);
}
if (strncmp(arVersion,"!<arch>",7) != 0) {
errorMsg("ar header fails check ");
return(FALSE);
}
return arFd;
}
/*
* Step through the ar file and process it one entry at a time
* fileList[0] is the name of the ar archive
* fileList[1] and up are filenames to extract from the archive
* funct contains flags to specify the actions to be performed
*/
static int readArFile(char *fileList[16], int fileListSize, int funct)
{
int arFd, status, extFileFlag, i, lastOffset=0;
ArHeader rawArHeader;
ArInfo arEntry;
/* open the ar archive */
arFd=getArFd(fileList[0]);
/* read the first header, then loop until ono more headers */
while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
== AR_BLOCK_SIZE) {
/* check the header is valid, if not try reading the header
agian with an offset of 1, needed as some ar archive end
with a '\n' which isnt counted in specified file size */
if ((status=processArHeader(&rawArHeader, &arEntry))==FALSE ) {
if ((i=lseek(arFd, 0, SEEK_CUR))==(lastOffset+60))
lseek(arFd, lastOffset+1, SEEK_SET);
else
return(FALSE);
}
else {
extFileFlag=0;
if (funct&AR_DISPLAY)
displayEntry(&arEntry, funct);
/* check file was specified to be extracted only if
some file were specified */
if ((funct&AR_EXT_TO_FILE) || (funct&AR_EXT_TO_STDOUT)){
if (fileListSize==1)
extFileFlag=1;
else {
for( i=1; i<=fileListSize; i++)
if ((status=(strcmp(fileList[i],arEntry.name)))==0)
extFileFlag=1;
}
}
if (extFileFlag==1) {
if (funct&AR_EXT_TO_FILE)
extractToFile(&arEntry, funct, arFd, "./");
else
copySubFile(arFd,fileno(stdout),arEntry.size);
}
else
lseek(arFd, arEntry.size, SEEK_CUR);
lastOffset=lseek(arFd, 0, SEEK_CUR);
} /* if processArHeader */
} /* while */
return (TRUE);
}
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
extern int ar_main(int argc, char **argv)
{
int funct = 0, ret=0, i=0;
char *fileList[16], c, *opt_ptr;
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;
if (argc < 2)
usage(ar_usage);
opt_ptr = argv[1];
if (*opt_ptr == '-')
++opt_ptr;
while ((c = *opt_ptr++) != '\0') {
switch (c) {
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct = funct | AR_PRESERVE_DATE;
extract_function |= extract_preserve_date;
break;
case 'v':
funct = funct | AR_VERBOSE;
extract_function |= extract_verbose_list;
break;
case 't':
funct = funct | AR_DISPLAY;
break;
case 'x':
funct = funct | AR_EXT_TO_FILE;
extract_function |= extract_list;
break;
case 'p':
funct = funct | AR_EXT_TO_STDOUT;
extract_function |= extract_to_stdout;
break;
case 'x':
extract_function |= extract_all_to_fs;
break;
default:
usage(ar_usage);
show_usage();
}
}
/* check the src filename was specified */
if (optind == argc) {
show_usage();
}
for(i=0; i<(argc-2); i++)
fileList[i]=argv[i+2];
if (funct > 3)
ret = readArFile(fileList, (argc-2), funct);
return (ret);
src_stream = xfopen(argv[optind++], "r");
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
archive_offset = 8;
extract_names = malloc(sizeof(char *));
extract_names[0] = NULL;
while (optind < argc) {
num_of_entries++;
*extract_names = realloc(*extract_names, num_of_entries);
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
optind++;
}
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
return EXIT_SUCCESS;
}
+49 -292
View File
@@ -3,8 +3,8 @@
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
*
* 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
@@ -21,312 +21,69 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Last modified 10 June 2000
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <sys/types.h>
#include "internal.h"
#define AR_BLOCK_SIZE 60
#define AR_PRESERVE_DATE 1 /* preserve original dates */
#define AR_VERBOSE 2 /* be verbose */
#define AR_DISPLAY 4 /* display contents */
#define AR_EXT_TO_FILE 8 /* extract contents of archive */
#define AR_EXT_TO_STDOUT 16 /* extract to stdout */
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
struct ArHeader { /* Byte Offset */
char ar_name[16]; /* 0-15 */
char ar_date[12]; /* 16-27 */
char ar_uid[6], ar_gid[6]; /* 28-39 */
char ar_mode[8]; /* 40-47 */
char ar_size[10]; /* 48-57 */
char ar_fmag[2]; /* 58-59 */
};
typedef struct ArHeader ArHeader;
struct ArInfo {
char name[17]; /* File name */
time_t date; /* long int, No of seconds since epoch */
uid_t uid; /* unsigned int, Numeric UID */
gid_t gid; /* unsigned int, Numeric GID */
mode_t mode; /* unsigned int, Unix mode */
size_t size; /* int, Size of the file */
};
typedef struct ArInfo ArInfo;
static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nExtract or list files from an ar archive.\n\n"
"Options:\n"
"\to\t\tpreserve original dates\n"
"\tp\t\textract to stdout\n"
"\tt\t\tlist\n"
"\tx\t\textract\n"
"\tv\t\tverbosely list files processed\n"
#endif
;
/*
* Display details of a file, verbosly if funct=2
*/
static void displayEntry(struct ArInfo *entry, int funct)
{
/* TODO convert mode to string */
if ((funct & AR_VERBOSE) == AR_VERBOSE)
printf("%i %i/%i %8i %s ", entry->mode, entry->uid, entry->gid,
entry->size, timeString(entry->date));
printf("%s\n", entry->name);
}
/* this is from tar.c remove later*/
static long getOctal(const char *cp, int size)
{
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
if ((size == 0) || !isOctal(*cp))
return -1;
for(; (size > 0) && isOctal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
if ((size > 0) && *cp)
return -1;
return val;
}
/*
* Converts from the char based struct to a new struct with stricter types
*/
static int processArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
{
int count2;
int count;
/* check end of header marker is valid */
if ((rawHeader->ar_fmag[0]!='`') || (rawHeader->ar_fmag[1]!='\n'))
return(FALSE);
/* convert filename */
for (count = 0; count < 16; count++) {
/* allow spaces in filename except at the end */
if (rawHeader->ar_name[count] == ' ') {
for (count2 = count; count2 < 16; count2++)
if (!isspace(rawHeader->ar_name[count2]))
break;
if (count2 >= 16)
break;
}
/* GNU ar uses '/' as an end of filename marker */
if (rawHeader->ar_name[count] == '/')
break;
header->name[count] = rawHeader->ar_name[count];
}
header->name[count] = '\0';
header->date = atoi(rawHeader->ar_date);
header->uid = atoi(rawHeader->ar_uid);
header->gid = atoi(rawHeader->ar_gid);
header->mode = getOctal(rawHeader->ar_mode, sizeof(rawHeader->ar_mode));
header->size = atoi(rawHeader->ar_size);
return (TRUE);
}
/*
* Copy size bytes from current position if srcFd to current position in dstFd
* taken from tarExtractRegularFile in tar.c, remove later
*/
static int copySubFile(int srcFd, int dstFd, int copySize)
{
int readSize, writeSize, doneSize;
char buffer[BUFSIZ];
while (copySize > 0) {
if (copySize > BUFSIZ)
readSize = BUFSIZ;
else
readSize = copySize;
writeSize = fullRead(srcFd, buffer, readSize);
if (writeSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
doneSize = fullWrite(dstFd, buffer, writeSize);
if (doneSize <= 0) {
errorMsg(io_error, "copySubFile :", strerror(errno));
return (FALSE);
}
copySize -= doneSize;
}
return (TRUE);
}
/*
* Extract the file described in ArInfo to the specified path
* set the new files uid, gid and mode
*/
static int extractToFile(struct ArInfo *file, int funct, int srcFd, const char *path)
{
int dstFd, temp;
struct stat tmpStat;
char *pathname = NULL;
struct utimbuf newtime;
if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
if (!createPath(path, 0777)) {
fatalError("Cannot extract to specified path");
return (FALSE);
}
}
temp = (strlen(path) + 16);
pathname = (char *) xmalloc(temp);
pathname = strcpy(pathname, path);
pathname = strcat(pathname, file->name);
dstFd = device_open(pathname, O_WRONLY | O_CREAT);
temp = copySubFile(srcFd, dstFd, file->size);
fchown(dstFd, file->uid, file->gid);
fchmod(dstFd, file->mode);
close(dstFd);
if ((funct&AR_PRESERVE_DATE)==AR_PRESERVE_DATE)
newtime.modtime=file->date;
else
newtime.modtime=time(0);
newtime.actime=time(0);
temp = utime(pathname, &newtime);
return (TRUE);
}
/*
* Return a file descriptor for the specified file and do error checks
*/
static int getArFd(char *filename)
{
int arFd;
char arVersion[8];
arFd = open(filename, O_RDONLY);
if (arFd < 0) {
errorMsg("Error opening '%s': %s\n", filename, strerror(errno));
return (FALSE);
}
if (fullRead(arFd, arVersion, 8) <= 0) {
errorMsg( "ar: Unexpected EOF in archive\n");
return (FALSE);
}
if (strncmp(arVersion,"!<arch>",7) != 0) {
errorMsg("ar header fails check ");
return(FALSE);
}
return arFd;
}
/*
* Step through the ar file and process it one entry at a time
* fileList[0] is the name of the ar archive
* fileList[1] and up are filenames to extract from the archive
* funct contains flags to specify the actions to be performed
*/
static int readArFile(char *fileList[16], int fileListSize, int funct)
{
int arFd, status, extFileFlag, i, lastOffset=0;
ArHeader rawArHeader;
ArInfo arEntry;
/* open the ar archive */
arFd=getArFd(fileList[0]);
/* read the first header, then loop until ono more headers */
while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
== AR_BLOCK_SIZE) {
/* check the header is valid, if not try reading the header
agian with an offset of 1, needed as some ar archive end
with a '\n' which isnt counted in specified file size */
if ((status=processArHeader(&rawArHeader, &arEntry))==FALSE ) {
if ((i=lseek(arFd, 0, SEEK_CUR))==(lastOffset+60))
lseek(arFd, lastOffset+1, SEEK_SET);
else
return(FALSE);
}
else {
extFileFlag=0;
if (funct&AR_DISPLAY)
displayEntry(&arEntry, funct);
/* check file was specified to be extracted only if
some file were specified */
if ((funct&AR_EXT_TO_FILE) || (funct&AR_EXT_TO_STDOUT)){
if (fileListSize==1)
extFileFlag=1;
else {
for( i=1; i<=fileListSize; i++)
if ((status=(strcmp(fileList[i],arEntry.name)))==0)
extFileFlag=1;
}
}
if (extFileFlag==1) {
if (funct&AR_EXT_TO_FILE)
extractToFile(&arEntry, funct, arFd, "./");
else
copySubFile(arFd,fileno(stdout),arEntry.size);
}
else
lseek(arFd, arEntry.size, SEEK_CUR);
lastOffset=lseek(arFd, 0, SEEK_CUR);
} /* if processArHeader */
} /* while */
return (TRUE);
}
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
extern int ar_main(int argc, char **argv)
{
int funct = 0, ret=0, i=0;
char *fileList[16], c, *opt_ptr;
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;
if (argc < 2)
usage(ar_usage);
opt_ptr = argv[1];
if (*opt_ptr == '-')
++opt_ptr;
while ((c = *opt_ptr++) != '\0') {
switch (c) {
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct = funct | AR_PRESERVE_DATE;
extract_function |= extract_preserve_date;
break;
case 'v':
funct = funct | AR_VERBOSE;
extract_function |= extract_verbose_list;
break;
case 't':
funct = funct | AR_DISPLAY;
break;
case 'x':
funct = funct | AR_EXT_TO_FILE;
extract_function |= extract_list;
break;
case 'p':
funct = funct | AR_EXT_TO_STDOUT;
extract_function |= extract_to_stdout;
break;
case 'x':
extract_function |= extract_all_to_fs;
break;
default:
usage(ar_usage);
show_usage();
}
}
/* check the src filename was specified */
if (optind == argc) {
show_usage();
}
for(i=0; i<(argc-2); i++)
fileList[i]=argv[i+2];
if (funct > 3)
ret = readArFile(fileList, (argc-2), funct);
return (ret);
src_stream = xfopen(argv[optind++], "r");
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
archive_offset = 8;
extract_names = malloc(sizeof(char *));
extract_names[0] = NULL;
while (optind < argc) {
num_of_entries++;
*extract_names = realloc(*extract_names, num_of_entries);
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
optind++;
}
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
return EXIT_SUCCESS;
}
+92
View File
@@ -0,0 +1,92 @@
/* 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 "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;
}
extract_names = malloc(4);
while (optind < argc) {
num_of_entries++;
*extract_names = realloc(*extract_names, num_of_entries);
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
optind++;
}
unarchive(src_stream, &get_header_cpio, extract_function, "./", extract_names);
if (oldmask) umask(oldmask); /* Restore umask if we changed it */
return EXIT_SUCCESS;
}
+854
View File
@@ -0,0 +1,854 @@
#include <ctype.h>
#include <dirent.h>
#include <getopt.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <search.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <utime.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "busybox.h"
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
/* Should we do full dependency checking? */
//#define DODEPENDS 0
/* Should we do debugging? */
//#define DODEBUG 0
#ifdef DODEBUG
#define SYSTEM(x) do_system(x)
#define DPRINTF(fmt,args...) fprintf(stderr, fmt, ##args)
#else
#define SYSTEM(x) system(x)
#define DPRINTF(fmt,args...) /* nothing */
#endif
/* from dpkg-deb.c */
static const char statusfile[] = "/var/lib/dpkg/status.udeb";
static const char new_statusfile[] = "/var/lib/dpkg/status.udeb.new";
static const char bak_statusfile[] = "/var/lib/dpkg/status.udeb.bak";
static const char infodir[] = "/var/lib/dpkg/info/";
static const char udpkg_quiet[] = "UDPKG_QUIET";
//static const int status_want_unknown = 1;
static const int state_want_install = 2;
//static const int state_want_hold = 3;
//static const int state_want_deinstall = 4;
//static const int state_want_purge = 5;
static const int state_flag_ok = 1;
//static const int state_flag_reinstreq = 2;
//static const int state_flag_hold = 3;
//static const int state_flag_holdreinstreq = 4;
//static const int state_statusnoninstalled = 1;
static const int state_status_unpacked = 2;
static const int state_status_halfconfigured = 3;
static const int state_status_installed = 4;
static const int state_status_halfinstalled = 5;
//static const int state_statusconfigfiles = 6;
//static const int state_statuspostinstfailed = 7;
//static const int state_statusremovalfailed = 8;
static const char *state_words_want[] = { "unknown", "install", "hold", "deinstall", "purge", 0 };
static const char *state_words_flag[] = { "ok", "reinstreq", "hold", "hold-reinstreq", 0 };
static const char *state_words_status[] = { "not-installed", "unpacked", "half-configured", "installed",
"half-installed", "config-files", "post-inst-failed", "removal-failed", 0 };
static const int color_white = 0;
static const int color_grey = 1;
static const int color_black = 2;
/* data structures */
typedef struct package_s {
char *filename;
char *package;
unsigned char state_want;
unsigned char state_flag;
unsigned char state_status;
char *depends;
char *provides;
char *description;
char *priority;
char *section;
char *installed_size;
char *maintainer;
char *source;
char *version;
char *pre_depends;
char *replaces;
char *recommends;
char *suggests;
char *conflicts;
char *conffiles;
char *long_description;
char *architecture;
char *md5sum;
int installer_menu_item;
char color; /* for topo-sort */
struct package_s *requiredfor[DEPENDSMAX];
unsigned short requiredcount;
struct package_s *next;
} package_t;
#ifdef DODEBUG
static int do_system(const char *cmd)
{
DPRINTF("cmd is %s\n", cmd);
return system(cmd);
}
#else
#define do_system(cmd) system(cmd)
#endif
static int package_compare(const void *p1, const void *p2)
{
return strcmp(((package_t *)p1)->package,
((package_t *)p2)->package);
}
#ifdef DODEPENDS
static char **depends_split(const char *dependsstr)
{
static char *dependsvec[DEPENDSMAX];
char *p;
int i = 0;
dependsvec[0] = 0;
if (dependsstr == 0) {
goto end;
}
p = xstrdup(dependsstr);
while (*p != 0 && *p != '\n') {
if (*p != ' ') {
if (*p == ',') {
*p = 0;
dependsvec[++i] = 0;
} else {
if (dependsvec[i] == 0) {
dependsvec[i] = p;
}
}
} else {
*p = 0; /* eat the space... */
}
p++;
}
*p = 0;
end:
dependsvec[i+1] = 0;
return dependsvec;
}
/* Topological sort algorithm:
* ordered is the output list, pkgs is the dependency graph, pkg is
* the current node
*
* recursively add all the adjacent nodes to the ordered list, marking
* each one as visited along the way
*
* yes, this algorithm looks a bit odd when all the params have the
* same type :-)
*/
static void depends_sort_visit(package_t **ordered, package_t *pkgs,
package_t *pkg)
{
unsigned short i;
/* mark node as processing */
pkg->color = color_grey;
/* visit each not-yet-visited node */
for (i = 0; i < pkg->requiredcount; i++)
if (pkg->requiredfor[i]->color == color_white)
depends_sort_visit(ordered, pkgs, pkg->requiredfor[i]);
#if 0
/* add it to the list */
newnode = (struct package_t *)xmalloc(sizeof(struct package_t));
/* make a shallow copy */
*newnode = *pkg;
newnode->next = *ordered;
*ordered = newnode;
#endif
pkg->next = *ordered;
*ordered = pkg;
/* mark node as done */
pkg->color = color_black;
}
static package_t *depends_sort(package_t *pkgs)
{
/* TODO: it needs to break cycles in the to-be-installed package
* graph... */
package_t *ordered = NULL;
package_t *pkg;
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
pkg->color = color_white;
}
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
if (pkg->color == color_white) {
depends_sort_visit(&ordered, pkgs, pkg);
}
}
/* Leaks the old list... return the new one... */
return ordered;
}
/* resolve package dependencies --
* for each package in the list of packages to be installed, we parse its
* dependency info to determine if the dependent packages are either
* already installed, or are scheduled to be installed. If both tests fail
* than bail.
*
* The algorithm here is O(n^2*m) where n = number of packages to be
* installed and m is the # of dependencies per package. Not a terribly
* efficient algorithm, but given that at any one time you are unlikely
* to install a very large number of packages it doesn't really matter
*/
static package_t *depends_resolve(package_t *pkgs, void *status)
{
package_t *pkg, *chk;
package_t dependpkg;
char **dependsvec;
int i;
void *found;
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
dependsvec = depends_split(pkg->depends);
i = 0;
while (dependsvec[i] != 0) {
/* Check for dependencies; first look for installed packages */
dependpkg.package = dependsvec[i];
if (((found = tfind(&dependpkg, &status, package_compare)) == 0) ||
((chk = *(package_t **)found) && (chk->state_flag & state_flag_ok) &&
(chk->state_status & state_status_installed))) {
/* if it fails, we look through the list of packages we are going to
* install */
for (chk = pkgs; chk != 0; chk = chk->next) {
if (strcmp(chk->package, dependsvec[i]) == 0 || (chk->provides &&
strncmp(chk->provides, dependsvec[i], strlen(dependsvec[i])) == 0)) {
if (chk->requiredcount >= DEPENDSMAX) {
error_msg("Too many dependencies for %s", chk->package);
return 0;
}
if (chk != pkg) {
chk->requiredfor[chk->requiredcount++] = pkg;
}
break;
}
}
if (chk == 0) {
error_msg("%s depends on %s, but it is not going to be installed", pkg->package, dependsvec[i]);
return 0;
}
}
i++;
}
}
return depends_sort(pkgs);
}
#endif
/* Status file handling routines
*
* This is a fairly minimalistic implementation. there are two main functions
* that are supported:
*
* 1) reading the entire status file:
* the status file is read into memory as a binary-tree, with just the
* package and status info preserved
*
* 2) merging the status file
* control info from (new) packages is merged into the status file,
* replacing any pre-existing entries. when a merge happens, status info
* read using the status_read function is written back to the status file
*/
static unsigned char status_parse(const char *line, const char **status_words)
{
unsigned char status_num;
int i = 0;
while (status_words[i] != 0) {
if (strncmp(line, status_words[i], strlen(status_words[i])) == 0) {
status_num = (char)i;
return(status_num);
}
i++;
}
/* parse error */
error_msg("Invalid status word");
return(0);
}
/*
* Read the buffered control file and parse it,
* filling parsed fields into the package structure
*/
static int fill_package_struct(package_t *package, const char *package_buffer)
{
char *field = NULL;
int field_start = 0;
int field_length = 0;
while ((field = read_package_field(&package_buffer[field_start])) != NULL) {
field_length = strlen(field);
field_start += (field_length + 1);
if (strlen(field) == 0) {
printf("empty line: *this shouldnt happen i dont think*\n");
break;
}
/* these are common to both installed and uninstalled packages */
if (strstr(field, "Package: ") == field) {
package->package = strdup(field + 9);
}
else if (strstr(field, "Depends: ") == field) {
package->depends = strdup(field + 9);
}
else if (strstr(field, "Provides: ") == field) {
package->provides = strdup(field + 10);
}
/* This is specific to the Debian Installer. Ifdef? */
else if (strstr(field, "installer-menu-item: ") == field) {
package->installer_menu_item = atoi(field + 21);
}
else if (strstr(field, "Description: ") == field) {
package->description = strdup(field + 13);
}
else if (strstr(field, "Priority: ") == field) {
package->priority = strdup(field + 10);
}
else if (strstr(field, "Section: ") == field) {
package->section = strdup(field + 9);
}
else if (strstr(field, "Installed-Size: ") == field) {
package->installed_size = strdup(field + 16);
}
else if (strstr(field, "Maintainer: ") == field) {
package->maintainer = strdup(field + 12);
}
else if (strstr(field, "Version: ") == field) {
package->version = strdup(field + 9);
}
else if (strstr(field, "Suggests: ") == field) {
package->suggests = strdup(field + 10);
}
else if (strstr(field, "Recommends: ") == field) {
package->recommends = strdup(field + 12);
}
/* else if (strstr(field, "Conffiles: ") == field) {
package->conffiles = read_block(file);
package->conffiles = xcalloc(1, 1);
while ((field = strtok(NULL, "\n")) != NULL) {
package->long_description = xrealloc(package->conffiles,
strlen(package->conffiles) + strlen(field) + 1);
strcat(package->conffiles, field);
}
}
*/
/* These are only in available file */
else if (strstr(field, "Architecture: ") == field) {
package->architecture = strdup(field + 14);
}
else if (strstr(field, "Filename: ") == field) {
package->filename = strdup(field + 10);
}
else if (strstr(field, "MD5sum ") == field) {
package->md5sum = strdup(field + 7);
}
/* This is only needed for status file */
if (strstr(field, "Status: ") == field) {
char *word_pointer;
word_pointer = strchr(field, ' ') + 1;
package->state_want = status_parse(word_pointer, state_words_want);
word_pointer = strchr(word_pointer, ' ') + 1;
package->state_flag = status_parse(word_pointer, state_words_flag);
word_pointer = strchr(word_pointer, ' ') + 1;
package->state_status = status_parse(word_pointer, state_words_status);
} else {
package->state_want = status_parse("purge", state_words_want);
package->state_flag = status_parse("ok", state_words_flag);
package->state_status = status_parse("not-installed", state_words_status);
}
free(field);
}
return EXIT_SUCCESS;
}
extern void write_package(FILE *out_file, package_t *pkg)
{
if (pkg->package) {
fprintf(out_file, "Package: %s\n", pkg->package);
}
if ((pkg->state_want != 0) || (pkg->state_flag != 0)|| (pkg->state_status != 0)) {
fprintf(out_file, "Status: %s %s %s\n",
state_words_want[pkg->state_want - 1],
state_words_flag[pkg->state_flag - 1],
state_words_status[pkg->state_status - 1]);
}
if (pkg->depends) {
fprintf(out_file, "Depends: %s\n", pkg->depends);
}
if (pkg->provides) {
fprintf(out_file, "Provides: %s\n", pkg->provides);
}
if (pkg->priority) {
fprintf(out_file, "Priority: %s\n", pkg->priority);
}
if (pkg->section) {
fprintf(out_file, "Section: %s\n", pkg->section);
}
if (pkg->section) {
fprintf(out_file, "Installed-Size: %s\n", pkg->installed_size);
}
if (pkg->maintainer) {
fprintf(out_file, "Maintainer: %s\n", pkg->maintainer);
}
if (pkg->source) {
fprintf(out_file, "Source: %s\n", pkg->source);
}
if (pkg->version) {
fprintf(out_file, "Version: %s\n", pkg->version);
}
if (pkg->pre_depends) {
fprintf(out_file, "Pre-depends: %s\n", pkg->pre_depends);
}
if (pkg->replaces) {
fprintf(out_file, "Replaces: %s\n", pkg->replaces);
}
if (pkg->recommends) {
fprintf(out_file, "Recommends: %s\n", pkg->recommends);
}
if (pkg->suggests) {
fprintf(out_file, "Suggests: %s\n", pkg->suggests);
}
if (pkg->conflicts) {
fprintf(out_file, "Conflicts: %s\n", pkg->conflicts);
}
if (pkg->conffiles) {
fprintf(out_file, "Conf-files: %s\n", pkg->conffiles);
}
if (pkg->architecture) {
fprintf(out_file, "Architecture: %s\n", pkg->architecture);
}
if (pkg->filename) {
fprintf(out_file, "Filename: %s\n", pkg->filename);
}
if (pkg->md5sum) {
fprintf(out_file, "MD5sum: %s\n", pkg->md5sum);
}
if (pkg->installer_menu_item) {
fprintf(out_file, "installer-main-menu %d\n", pkg->installer_menu_item);
}
if (pkg->description) {
fprintf(out_file, "Description: %s\n", pkg->description);
}
fputc('\n', out_file);
pkg = pkg->next;
}
static void *status_read(void)
{
FILE *f;
void *status = 0;
package_t *m = 0, *p = 0, *t = 0;
char *package_control_buffer = NULL;
if (getenv(udpkg_quiet) == NULL) {
printf("(Reading database...)\n");
}
if ((f = wfopen(statusfile, "r")) == NULL) {
return(NULL);
}
while ( (package_control_buffer = fgets_str(f, "\n\n")) != NULL) {
m = (package_t *)xcalloc(1, sizeof(package_t));
fill_package_struct(m, package_control_buffer);
if (m->package) {
/*
* If there is an item in the tree by this name,
* it must be a virtual package; insert real
* package in preference.
*/
tdelete(m, &status, package_compare);
tsearch(m, &status, package_compare);
if (m->provides) {
/*
* A "Provides" triggers the insertion
* of a pseudo package into the status
* binary-tree.
*/
p = (package_t *)xcalloc(1, sizeof(package_t));
p->package = xstrdup(m->provides);
t = *(package_t **)tsearch(p, &status, package_compare);
if (t != p) {
free(p->package);
free(p);
} else {
/*
* Pseudo package status is the
* same as the status of the
* package providing it
* FIXME: (not quite right, if 2
* packages of different statuses
* provide it).
*/
t->state_want = m->state_want;
t->state_flag = m->state_flag;
t->state_status = m->state_status;
}
}
}
else {
free(m);
}
}
fclose(f);
return status;
}
static int status_merge(void *status, package_t *pkgs)
{
FILE *fin, *fout;
char *line = NULL;
package_t *pkg = 0, *statpkg = 0;
package_t locpkg;
if ((fout = wfopen(new_statusfile, "w")) == NULL) {
return 0;
}
if (getenv(udpkg_quiet) == NULL) {
printf("(Updating database...)\n");
}
/*
* Dont use wfopen here, handle errors ourself
*/
if ((fin = fopen(statusfile, "r")) != NULL) {
while (((line = get_line_from_file(fin)) != NULL) && !feof(fin)) {
chomp(line); /* trim newline */
/* If we see a package header, find out if it's a package
* that we have processed. if so, we skip that block for
* now (write it at the end).
*
* we also look at packages in the status cache and update
* their status fields
*/
if (strstr(line, "Package: ") == line) {
for (pkg = pkgs; pkg != 0 && strcmp(line + 9,
pkg->package) != 0; pkg = pkg->next) ;
locpkg.package = line + 9;
statpkg = tfind(&locpkg, &status, package_compare);
/* note: statpkg should be non-zero, unless the status
* file was changed while we are processing (no locking
* is currently done...
*/
if (statpkg != 0) {
statpkg = *(package_t **)statpkg;
}
}
if (pkg != 0) {
continue;
}
if (strstr(line, "Status: ") == line && statpkg != 0) {
snprintf(line, sizeof(line), "Status: %s %s %s",
state_words_want[statpkg->state_want - 1],
state_words_flag[statpkg->state_flag - 1],
state_words_status[statpkg->state_status - 1]);
}
fprintf(fout, "%s\n", line);
}
fclose(fin);
}
free(line);
// Print out packages we processed.
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
write_package(fout, pkg);
}
fclose(fout);
/*
* Its ok if renaming statusfile fails becasue it doesnt exist
*/
if (rename(statusfile, bak_statusfile) == -1) {
struct stat stat_buf;
if (stat(statusfile, &stat_buf) == 0) {
error_msg("Couldnt create backup status file");
return(EXIT_FAILURE);
}
error_msg("No status file found, creating new one");
}
if (rename(new_statusfile, statusfile) == -1) {
error_msg("Couldnt create status file");
return(EXIT_FAILURE);
}
return(EXIT_SUCCESS);
}
static int is_file(const char *fn)
{
struct stat statbuf;
if (stat(fn, &statbuf) < 0) {
return 0;
}
return S_ISREG(statbuf.st_mode);
}
static int dpkg_doconfigure(package_t *pkg)
{
int r;
char postinst[1024];
char buf[1024];
DPRINTF("Configuring %s\n", pkg->package);
pkg->state_status = 0;
snprintf(postinst, sizeof(postinst), "%s%s.postinst", infodir, pkg->package);
if (is_file(postinst)) {
snprintf(buf, sizeof(buf), "%s configure", postinst);
if ((r = do_system(buf)) != 0) {
error_msg("postinst exited with status %d\n", r);
pkg->state_status = state_status_halfconfigured;
return 1;
}
}
pkg->state_status = state_status_installed;
return 0;
}
static int dpkg_dounpack(package_t *pkg)
{
FILE *out_stream;
char *info_prefix;
int status = TRUE;
int r = 0;
DPRINTF("Unpacking %s\n", pkg->package);
/* extract the data file */
deb_extract(pkg->filename, stdout, (extract_data_tar_gz | extract_all_to_fs), "/", NULL);
/* extract the control files */
info_prefix = (char *) malloc(strlen(pkg->package) + strlen(infodir) + 2 + 5 + 1);
sprintf(info_prefix, "%s/%s.", infodir, pkg->package);
deb_extract(pkg->package, stdout, (extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL);
/* Create the list file */
strcat(info_prefix, "list");
out_stream = wfopen(info_prefix, "w");
deb_extract(pkg->package, out_stream, (extract_data_tar_gz | extract_list), NULL, NULL);
fclose(out_stream);
pkg->state_want = state_want_install;
pkg->state_flag = state_flag_ok;
if (status == TRUE) {
pkg->state_status = state_status_unpacked;
} else {
pkg->state_status = state_status_halfinstalled;
}
return r;
}
/*
* Extract and parse the control file from control.tar.gz
*/
static int dpkg_read_control(package_t *pkg)
{
FILE *pkg_file;
char *control_buffer = NULL;
if ((pkg_file = wfopen(pkg->filename, "r")) == NULL) {
return EXIT_FAILURE;
}
control_buffer = deb_extract(pkg->filename, stdout, (extract_control_tar_gz | extract_one_to_buffer), NULL, "./control");
fill_package_struct(pkg, control_buffer);
return EXIT_SUCCESS;
}
static int dpkg_unpack(package_t *pkgs, void *status)
{
int r = 0;
package_t *pkg;
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
dpkg_read_control(pkg);
if ((r = dpkg_dounpack(pkg)) != 0 ) {
break;
}
}
status_merge(status, pkgs);
return r;
}
static int dpkg_configure(package_t *pkgs, void *status)
{
int r = 0;
void *found;
package_t *pkg;
for (pkg = pkgs; pkg != 0 && r == 0; pkg = pkg->next) {
found = tfind(pkg, &status, package_compare);
if (found == 0) {
error_msg("Trying to configure %s, but it is not installed", pkg->package);
r = 1;
}
/* configure the package listed in the status file;
* not pkg, as we have info only for the latter
*/
else {
r = dpkg_doconfigure(*(package_t **)found);
}
}
status_merge(status, 0);
return r;
}
static int dpkg_install(package_t *pkgs, void *status)
{
package_t *p, *ordered = 0;
/* Stage 1: parse all the control information */
for (p = pkgs; p != 0; p = p->next) {
dpkg_read_control(p);
}
/* Stage 2: resolve dependencies */
#ifdef DODEPENDS
ordered = depends_resolve(pkgs, status);
#else
ordered = pkgs;
#endif
/* Stage 3: install */
for (p = ordered; p != 0; p = p->next) {
p->state_want = state_want_install;
/* for now the flag is always set to ok... this is probably
* not what we want
*/
p->state_flag = state_flag_ok;
DPRINTF("Installing %s\n", p->package);
if (dpkg_dounpack(p) != 0) {
perror_msg(p->filename);
}
if (dpkg_doconfigure(p) != 0) {
perror_msg(p->filename);
}
}
if (ordered != 0) {
status_merge(status, pkgs);
}
return 0;
}
/*
* Not implemented yet
*
static int dpkg_remove(package_t *pkgs, void *status)
{
package_t *p;
for (p = pkgs; p != 0; p = p->next)
{
}
status_merge(status, 0);
return 0;
}
*/
extern int dpkg_main(int argc, char **argv)
{
const int arg_install = 1;
const int arg_unpack = 2;
const int arg_configure = 4;
package_t *p, *packages = NULL;
void *status = NULL;
int opt = 0;
int optflag = 0;
while ((opt = getopt(argc, argv, "iruc")) != -1) {
switch (opt) {
case 'i':
optflag |= arg_install;
break;
case 'u':
optflag |= arg_unpack;
break;
case 'c':
optflag |= arg_configure;
break;
default:
show_usage();
}
}
while (optind < argc) {
p = (package_t *) xcalloc(1, sizeof(package_t));
if (optflag & arg_configure) {
p->package = xstrdup(argv[optind]);
} else {
p->filename = xstrdup(argv[optind]);
}
p->next = packages;
packages = p;
optind++;
}
make_directory((char *)infodir, S_IRWXU, FILEUTILS_RECUR);
status = status_read();
if (optflag & arg_install) {
return dpkg_install(packages, status);
}
else if (optflag & arg_unpack) {
return dpkg_unpack(packages, status);
}
else if (optflag & arg_configure) {
return dpkg_configure(packages, status);
}
return(EXIT_FAILURE);
}
+125
View File
@@ -0,0 +1,125 @@
/*
* 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 <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
extern int dpkg_deb_main(int argc, char **argv)
{
char *prefix = NULL;
char *filename = NULL;
char *output_buffer = NULL;
int opt = 0;
int arg_type = 0;
int deb_extract_funct = extract_create_leading_dirs | extract_unconditional;
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':
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_verbose_list;
break;
case 'e':
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':
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':
arg_type = arg_type_prefix;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_all_to_fs;
break;
case 'I':
arg_type = arg_type_filename;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_one_to_buffer;
break;
default:
show_usage();
}
}
if (optind == argc) {
show_usage();
}
/* 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 {
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");
}
}
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;
int field_start = 0;
while ((field = read_package_field(&output_buffer[field_start])) != NULL) {
field_start += (strlen(field) + 1);
if (strstr(field, argv[optind + 1]) == field) {
puts(field + strlen(argv[optind + 1]) + 2);
}
free(field);
}
}
return(EXIT_SUCCESS);
}
+93 -2114
View File
File diff suppressed because it is too large. Load diff
+332 -1176
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+92
View File
@@ -0,0 +1,92 @@
/* 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"
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
struct rpm_lead {
unsigned char magic[4];
u8 major, minor;
u16 type;
u16 archnum;
char name[66];
u16 osnum;
u16 signature_type;
char reserved[16];
};
struct rpm_header {
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
u8 version; /* 1 byte version number */
u32 reserved; /* 4 bytes reserved */
u32 entries; /* Number of entries in header (4 bytes) */
u32 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 = fopen(argv[1], "r");
if (!rpmfile) perror_msg_and_die("Can't open rpm file");
}
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;
}
+499 -363
View File
File diff suppressed because it is too large. Load diff
+13205
View File
File diff suppressed because it is too large. Load diff
+8 -13
View File
@@ -2,7 +2,7 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -21,16 +21,11 @@
*
*/
#include "internal.h"
#include <stdio.h>
const char *basename_usage="basename FILE [SUFFIX]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nStrips directory path and suffixes from FILE.\n"
"If specified, also removes any trailing SUFFIX.\n"
#endif
;
/* getopt not needed */
#include <stdlib.h>
#include "busybox.h"
#include <string.h>
extern int basename_main(int argc, char **argv)
{
@@ -38,7 +33,7 @@ extern int basename_main(int argc, char **argv)
char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(basename_usage);
show_usage();
}
argv++;
@@ -52,6 +47,6 @@ extern int basename_main(int argc, char **argv)
if (m>=n && strncmp(s+m-n, *argv, n)==0)
s[m-n] = '\0';
}
printf("%s\n", s);
return(TRUE);
puts(s);
return EXIT_SUCCESS;
}
+67 -424
View File
@@ -1,364 +1,21 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
static int been_there_done_that = 0;
/* It has been alledged that doing such things can
* help reduce binary size when staticly linking,
* of course with glibc, this is unlikely as long
* as we use things like printf -- perhaps a printf
* replacement may be in order
*/
#if 0
void exit(int status) __attribute__ ((noreturn));
void exit(int status)
{
_exit(status);
};
void abort(void) __attribute__ ((__noreturn__));
void abort(void)
{
_exit(0);
};
int atexit(void (*__func) (void))
{
_exit(0);
};
void *__libc_stack_end;
#include <stdlib.h>
#include "busybox.h"
#ifdef BB_LOCALE_SUPPORT
#include <locale.h>
#endif
const struct BB_applet applets[] = {
#ifdef BB_AR
{"ar", ar_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_BASENAME
{"basename", basename_main, _BB_DIR_USR_BIN},
#endif
{"busybox", busybox_main, _BB_DIR_BIN},
#ifdef BB_CAT
{"cat", cat_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
#endif
#ifdef BB_CHROOT
{"chroot", chroot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_CLEAR
{"clear", clear_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_CUT
{"cut", cut_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
#ifdef BB_DC
{"dc", dc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DD
{"dd", dd_main, _BB_DIR_BIN},
#endif
#ifdef BB_DF
{"df", df_main, _BB_DIR_BIN},
#endif
#ifdef BB_DIRNAME
{"dirname", dirname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_DMESG
{"dmesg", dmesg_main, _BB_DIR_BIN},
#endif
#ifdef BB_DU
{"du", du_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUMPKMAP
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN},
#endif
#ifdef BB_DUTMP
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_ECHO
{"echo", echo_main, _BB_DIR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"false", false_main, _BB_DIR_BIN},
#endif
#ifdef BB_FBSET
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
#endif
#ifdef BB_FDFLUSH
{"fdflush", fdflush_main, _BB_DIR_BIN},
#endif
#ifdef BB_FIND
{"find", find_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREE
{"free", free_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FREERAMDISK
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_DEALLOCVT
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_FSCK_MINIX
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_GREP
{"grep", grep_main, _BB_DIR_BIN},
#endif
#ifdef BB_GUNZIP
{"gunzip", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_GZIP
{"gzip", gzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_HALT
{"halt", halt_main, _BB_DIR_SBIN},
#endif
#ifdef BB_HEAD
{"head", head_main, _BB_DIR_BIN},
#endif
#ifdef BB_HOSTID
{"hostid", hostid_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_HOSTNAME
{"hostname", hostname_main, _BB_DIR_BIN},
#endif
#ifdef BB_ID
{"id", id_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_INIT
{"init", init_main, _BB_DIR_SBIN},
#endif
#ifdef BB_INSMOD
{"insmod", insmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_KILL
{"kill", kill_main, _BB_DIR_BIN},
#endif
#ifdef BB_KILLALL
{"killall", kill_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LENGTH
{"length", length_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LINUXRC
{"linuxrc", init_main, _BB_DIR_ROOT},
#endif
#ifdef BB_LN
{"ln", ln_main, _BB_DIR_BIN},
#endif
#ifdef BB_LOADACM
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADFONT
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOADKMAP
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_LOGGER
{"logger", logger_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LOGNAME
{"logname", logname_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_LS
{"ls", ls_main, _BB_DIR_BIN},
#endif
#ifdef BB_LSMOD
{"lsmod", lsmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MAKEDEVS
{"makedevs", makedevs_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MD5SUM
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKDIR
{"mkdir", mkdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKFIFO
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MKFS_MINIX
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKNOD
{"mknod", mknod_main, _BB_DIR_BIN},
#endif
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
#ifdef BB_NC
{"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
#endif
#ifdef BB_MOUNT
{"mount", mount_main, _BB_DIR_BIN},
#endif
#ifdef BB_MT
{"mt", mt_main, _BB_DIR_BIN},
#endif
#ifdef BB_CP_MV
{"mv", cp_mv_main, _BB_DIR_BIN},
#endif
#ifdef BB_NSLOOKUP
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PING
{"ping", ping_main, _BB_DIR_BIN},
#endif
#ifdef BB_POWEROFF
{"poweroff", poweroff_main, _BB_DIR_SBIN},
#endif
#ifdef BB_PRINTF
{"printf", printf_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_PS
{"ps", ps_main, _BB_DIR_BIN},
#endif
#ifdef BB_PWD
{"pwd", pwd_main, _BB_DIR_BIN},
#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN},
#endif
#ifdef BB_RM
{"rm", rm_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMDIR
{"rmdir", rmdir_main, _BB_DIR_BIN},
#endif
#ifdef BB_RMMOD
{"rmmod", rmmod_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
#ifdef BB_SETKEYCODES
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SH
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_SORT
{"sort", sort_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYNC
{"sync", sync_main, _BB_DIR_BIN},
#endif
#ifdef BB_SYSLOGD
{"syslogd", syslogd_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SWAPONOFF
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
#endif
#ifdef BB_TAIL
{"tail", tail_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TAR
{"tar", tar_main, _BB_DIR_BIN},
#endif
#ifdef BB_TELNET
{"telnet", telnet_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEST
{"test", test_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TEE
{"tee", tee_main, _BB_DIR_BIN},
#endif
#ifdef BB_TOUCH
{"touch", touch_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TR
{"tr", tr_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_TRUE_FALSE
{"true", true_main, _BB_DIR_BIN},
#endif
#ifdef BB_TTY
{"tty", tty_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UMOUNT
{"umount", umount_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNAME
{"uname", uname_main, _BB_DIR_BIN},
#endif
#ifdef BB_UNIQ
{"uniq", uniq_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UPDATE
{"update", update_main, _BB_DIR_SBIN},
#endif
#ifdef BB_UPTIME
{"uptime", uptime_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUENCODE
{"uuencode", uuencode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_UUDECODE
{"uudecode", uudecode_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_USLEEP
{"usleep", usleep_main, _BB_DIR_BIN},
#endif
#ifdef BB_WC
{"wc", wc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHICH
{"which", which_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_WHOAMI
{"whoami", whoami_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_YES
{"yes", yes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_GUNZIP
{"zcat", gunzip_main, _BB_DIR_BIN},
#endif
#ifdef BB_TEST
{"[", test_main, _BB_DIR_USR_BIN},
#endif
{0}
};
int 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, internal.h::Location,
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
@@ -380,64 +37,65 @@ 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 {
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
static int install_links(const char *busybox, int use_symbolic_links)
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
char *fpc;
int i;
int rc = 0;
int rc;
if (use_symbolic_links) Link = symlink;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf (
command,
"%s/%s",
install_dir[applets[i].location],
applets[i].name
);
#if 1
rc |= Link(busybox, command);
#else
puts(command);
#endif
if (rc) {
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
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);
}
return rc;
}
#if 0
int uninstall_links() ?
#endif
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
char *s;
char *name;
const struct BB_applet *a = applets;
const char *s;
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
/* Add in a special case hack for a leading hyphen */
if (**argv == '-' && *(*argv+1)!= '-') {
applet_name = (*argv+1);
}
#ifdef BB_LOCALE_SUPPORT
#ifdef BB_INIT
if(getpid()!=1) /* Do not set locale for `init' */
#endif
{
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
/*
@@ -469,48 +127,20 @@ int main(int argc, char **argv)
}
#endif /* BB_FEATURE_INSTALLER */
for (s = name = argv[0]; *s != '\0';) {
if (*s++ == '/')
name = s;
}
*argv = name;
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-')
exit(((*(shell_main)) (argc, argv)));
#endif
while (a->name != 0) {
if (strcmp(name, a->name) == 0) {
exit(((*(a->main)) (argc, argv)));
}
a++;
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
int col = 0;
argc--;
argv++;
/* 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, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n"
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", BB_VER, BB_BT);
"\nCurrently defined functions:\n", full_version);
while (a->name != 0) {
col +=
@@ -522,10 +152,23 @@ int busybox_main(int argc, char **argv)
}
}
fprintf(stderr, "\n\n");
exit(-1);
exit(0);
}
/* If we've already been here once, exit now */
/* 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));
}
-311
View File
@@ -1,311 +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_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
#define BB_ECHO
#define BB_FBSET
#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
#define BB_FREERAMDISK
#define BB_FSCK_MINIX
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
#define BB_ID
#define BB_INIT
#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_LENGTH
#define BB_LN
#define BB_LOADACM
#define BB_LOADFONT
#define BB_LOADKMAP
#define BB_LOGGER
#define BB_LOGNAME
#define BB_LS
#define BB_LSMOD
#define BB_MAKEDEVS
#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
#define BB_NC
#define BB_MORE
#define BB_MOUNT
#define BB_MT
#define BB_NSLOOKUP
#define BB_PING
#define BB_POWEROFF
#define BB_PRINTF
#define BB_PS
#define BB_PWD
#define BB_REBOOT
#define BB_RM
#define BB_RMDIR
#define BB_RMMOD
#define BB_SED
#define BB_SETKEYCODES
#define BB_SH
#define BB_SLEEP
#define BB_SORT
#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
#define BB_TAIL
#define BB_TAR
#define BB_TEE
#define BB_TEST
#define BB_TELNET
#define BB_TOUCH
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UPTIME
#define BB_USLEEP
#define BB_WC
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
#define BB_UPDATE
#define BB_YES
// End of Applications List
//
//
//
// ---------------------------------------------------------
// This is where feature definitions go. Generally speaking,
// turning this stuff off makes things a bit smaller (and less
// pretty/useful).
//
//
//
// Turn this on to use Erik's very cool devps, devmtab, etc kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. You can not use this and
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
// _must_ have patched the kernel to include the devps patch that is included
// in the busybox/kernel-patches directory. You will also need to create some
// device special files /dev on your embedded system:
// mknod /dev/modules c 10 23
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// enable features that use the /proc filesystem (apps that
// break without this will tell you on compile)...
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
// at the same time...
#define BB_FEATURE_USE_PROCFS
//
// Enable full regular expressions. This adds about
// 4k. When this is off, things that would normally
// use regualr expressions (like grep) will just use
// normal strings.
#define BB_FEATURE_FULL_REGULAR_EXPRESSIONS
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
//#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
//#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
//
//Simple tail implementation (2k vs 6k for the full one). Still
//provides 'tail -f' support -- but for only one file at a time.
#define BB_FEATURE_SIMPLE_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes
// (This does not yet work with Linux 2.[34].x kernels)
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox commands as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell
//amoung other thing.
#define BB_FEATURE_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
//
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
// #define BB_FEATURE_INSTALLER
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
//
#if defined BB_FEATURE_FULL_REGULAR_EXPRESSIONS && (defined BB_SED || defined BB_GREP )
#define BB_REGEXP
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#define BB_LINUXRC
#endif
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#endif
#endif
+103
View File
@@ -0,0 +1,103 @@
/* 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>
#define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
#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
#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
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) static 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
#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_ */
+19 -14
View File
@@ -1,19 +1,24 @@
#!/bin/sh
# Make busybox links list file.
DF="busybox.def.h"
MF="busybox.c"
# 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
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
for def in ${LIST}; do
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
for j in $i; do
if [ -z $j ] ; then
continue;
fi;
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
done;
done
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
}'
+12 -6
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 ` \
gcc -E -dM busybox.def.h | \
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 [:upper:] [:lower:] | sort
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
if [ -d "$BB_SRC_DIR" ]; then cd $BB_SRC_DIR; fi
# By running $RAW through "ls", we avoid listing
# source files that don't exist.
ls $RAW 2>/dev/null | tr '\n' ' '
+1 -1
View File
@@ -1,5 +1,5 @@
Name: busybox
Version: 0.46
Version: 0.52
Release: 1
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
+12 -32
View File
@@ -2,7 +2,7 @@
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -21,47 +21,27 @@
*
*/
#include "internal.h"
#include <stdio.h>
static void print_file(FILE * file)
{
int c;
while ((c = getc(file)) != EOF)
putc(c, stdout);
fclose(file);
fflush(stdout);
}
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
extern int cat_main(int argc, char **argv)
{
FILE *file;
int status = EXIT_SUCCESS;
if (argc == 1) {
print_file(stdin);
exit(TRUE);
return status;
}
if (**(argv + 1) == '-') {
usage("cat [FILE ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nConcatenates FILE(s) and prints them to the standard output.\n"
#endif
);
}
argc--;
while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
file = fopen(*argv, "r");
if (file == NULL) {
perror(*argv);
exit(FALSE);
while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) {
print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) {
status = EXIT_FAILURE;
}
print_file(file);
}
return(TRUE);
return status;
}
/*
+91
View File
@@ -0,0 +1,91 @@
/* 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"
/* 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:
*/
+85
View File
@@ -0,0 +1,85 @@
/* 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 <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:
*/
-201
View File
@@ -1,201 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "internal.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_option
#define bb_need_too_few_args
#include "messages.c"
#include <stdio.h>
#include <grp.h>
#include <pwd.h>
static unsigned long uid = -1;
static unsigned long gid = -1;
static int whichApp;
static char *invocationName = NULL;
static char *theMode = NULL;
#define CHGRP_APP 1
#define CHOWN_APP 2
#define CHMOD_APP 3
static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChange the group membership of each FILE to GROUP.\n"
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
#endif
;
static const char chown_usage[] =
"chown [OPTION]... OWNER[<.|:>[GROUP] FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChange the owner and/or group of each FILE to OWNER and/or GROUP.\n"
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
#endif
;
static const char chmod_usage[] =
"chmod [-R] MODE[,MODE]... FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nEach MODE is one or more of the letters ugoa, one of the symbols +-= and\n"
"one or more of the letters rwxst.\n\n"
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
#endif
;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
switch (whichApp) {
case CHGRP_APP:
case CHOWN_APP:
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
if (lchown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#else
if (chown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#endif
{
return (TRUE);
}
break;
case CHMOD_APP:
/* Parse the specified modes */
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
fatalError( "%s: unknown mode: %s\n", invocationName, theMode);
}
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
break;
}
perror(fileName);
return (FALSE);
}
int chmod_chown_chgrp_main(int argc, char **argv)
{
int recursiveFlag = FALSE;
char *groupName=NULL;
char *p=NULL;
const char *appUsage;
whichApp = (strcmp(*argv, "chown") == 0)?
CHOWN_APP : (strcmp(*argv, "chmod") == 0)?
CHMOD_APP : CHGRP_APP;
appUsage = (whichApp == CHOWN_APP)?
chown_usage : (whichApp == CHMOD_APP) ? chmod_usage : chgrp_usage;
if (argc < 2)
usage(appUsage);
invocationName = *argv;
argv++;
/* Parse options */
while (--argc >= 0 && *argv && (**argv == '-')) {
while (*++(*argv)) {
switch (**argv) {
case 'R':
recursiveFlag = TRUE;
break;
default:
fprintf(stderr, invalid_option, invocationName, **argv);
usage(appUsage);
}
}
argv++;
}
if (argc == 0 || *argv == NULL) {
fprintf(stderr, too_few_args, invocationName);
usage(appUsage);
}
if (whichApp == CHMOD_APP) {
theMode = *argv;
} else {
/* Find the selected group */
if (whichApp == CHGRP_APP) {
groupName = *argv;
gid = strtoul(groupName, &p, 10); /* maybe it's already numeric */
if (groupName == p)
gid = my_getgrnam(groupName);
if (gid == -1)
goto bad_group;
} else {
groupName = strchr(*argv, '.');
if (groupName == NULL)
groupName = strchr(*argv, ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
if (gid == -1)
goto bad_group;
} else
gid = -1;
}
/* Find the selected user (if appropriate) */
if (whichApp == CHOWN_APP) {
uid = strtoul(*argv, &p, 10); /* if numeric ... */
if (*argv == p)
uid = my_getpwnam(*argv);
if (uid == -1) {
fatalError( "%s: unknown user name: %s\n",
invocationName, *argv);
}
}
}
/* Ok, ready to do the deed now */
if (argc <= 1) {
fatalError( "%s: too few arguments\n", invocationName);
}
while (argc-- > 1) {
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE)
exit(FALSE);
}
exit(TRUE);
bad_group:
fatalError( "%s: unknown group name: %s\n", invocationName, groupName);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+113
View File
@@ -0,0 +1,113 @@
/* 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"
/* 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)() = 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:
*/
+14 -16
View File
@@ -3,7 +3,7 @@
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,33 +22,24 @@
*
*/
#include "internal.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRun COMMAND with root directory set to NEWROOT.\n"
#endif
;
#include "busybox.h"
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(chroot_usage);
show_usage();
}
argc--;
argv++;
if (chroot(*argv) || (chdir("/"))) {
fatalError("chroot: cannot change root directory to %s: %s\n",
*argv, strerror(errno));
perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
@@ -57,13 +48,20 @@ int chroot_main(int argc, char **argv)
prog = *argv;
execvp(*argv, argv);
} else {
#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#endif
}
fatalError("chroot: cannot execute %s: %s\n",
prog, strerror(errno));
perror_msg_and_die("cannot execute %s", prog);
}
+13 -20
View File
@@ -4,40 +4,33 @@
*
* busyboxed by Erik Andersen
*/
#include "internal.h"
/* 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> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
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) == '-')) {
usage ("chvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
#endif
);
}
if ((argc != 2) || (**(argv + 1) == '-'))
show_usage();
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num)) {
perror("VT_ACTIVATE");
exit(FALSE);
}
if (ioctl(fd, VT_WAITACTIVE, num)) {
perror("VT_WAITACTIVE");
exit(FALSE);
}
return(TRUE);
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;
}
+4 -3
View File
@@ -3,7 +3,7 @@
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,12 +22,13 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include "busybox.h"
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
return(TRUE);
return EXIT_SUCCESS;
}
+1281 -433
View File
File diff suppressed because it is too large. Load diff
+1 -30
View File
@@ -1,37 +1,8 @@
#ifndef CMDEDIT_H
#define CMDEDIT_H
/* unix systems can #define POSIX to use termios, otherwise
* the bsd or sysv interface will be used
*/
#ifdef __STDC__
#include <stddef.h>
typedef size_t (*cmdedit_strwidth_proc)(char *);
void cmdedit_init(void);
void cmdedit_terminate(void);
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
void cmdedit_setwidth(int); /* specify width of screen */
void cmdedit_histadd(char *); /* adds entries to hist */
void cmdedit_strwidth(cmdedit_strwidth_proc); /* to bind cmdedit_strlen */
extern int (*cmdedit_in_hook)(char *);
extern int (*cmdedit_out_hook)(char *);
extern int (*cmdedit_tab_hook)(char *, int, int *);
#else /* not __STDC__ */
void cmdedit_init(void);
void cmdedit_read_input(char* promptStr, char* command);
void cmdedit_setwidth();
void cmdedit_histadd();
void cmdedit_strwidth();
extern int (*cmdedit_in_hook)();
extern int (*cmdedit_out_hook)();
extern int (*cmdedit_tab_hook)();
#endif /* __STDC__ */
#endif /* CMDEDIT_H */
+80
View File
@@ -0,0 +1,80 @@
/* 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 <getopt.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1, *filename2 = "-";
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
while ((c = getopt(argc, argv, "s")) != EOF) {
switch (c) {
case 's':
silent = TRUE;
break;
default:
show_usage();
}
}
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)
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;
}
+13 -20
View File
@@ -4,40 +4,33 @@
*
* busyboxed by Erik Andersen
*/
#include "internal.h"
/* 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> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
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) == '-')) {
usage ("chvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
#endif
);
}
if ((argc != 2) || (**(argv + 1) == '-'))
show_usage();
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num)) {
perror("VT_ACTIVATE");
exit(FALSE);
}
if (ioctl(fd, VT_WAITACTIVE, num)) {
perror("VT_WAITACTIVE");
exit(FALSE);
}
return(TRUE);
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;
}
+4 -3
View File
@@ -3,7 +3,7 @@
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,12 +22,13 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include "busybox.h"
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
return(TRUE);
return EXIT_SUCCESS;
}
+15 -30
View File
@@ -3,56 +3,41 @@
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
* Renamed deallocvt.
*/
#include "internal.h"
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
char *progname;
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
int fd, num, i;
if ((argc != 2) || (**(argv + 1) == '-')) {
usage
("deallocvt N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDeallocate unused virtual terminal /dev/ttyN\n"
#endif
);
}
progname = argv[0];
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
if (argc > 2)
show_usage();
fd = get_console_fd("/dev/console");
if (argc == 1) {
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
exit( FALSE);
}
} else
if (ioctl(fd, VT_DISALLOCATE, 0))
perror_msg_and_die("VT_DISALLOCATE");
} else {
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
fprintf(stderr, "%s: 0: illegal VT number\n", progname);
error_msg("0: illegal VT number");
else if (num == 1)
fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
progname);
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n",
progname, num);
exit( FALSE);
}
error_msg("VT 1 cannot be deallocated");
else if (ioctl(fd, VT_DISALLOCATE, num))
perror_msg_and_die("VT_DISALLOCATE");
}
return( TRUE);
}
return EXIT_SUCCESS;
}
+13 -18
View File
@@ -20,11 +20,14 @@
*
*/
#include "internal.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/kd.h> */
struct kbentry {
@@ -32,19 +35,11 @@ struct kbentry {
unsigned char kb_index;
unsigned short kb_value;
};
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
static const char dumpkmap_usage[] = "dumpkmap\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints out a binary keyboard translation table to standard input.\n"
#endif
;
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
int dumpkmap_main(int argc, char **argv)
{
@@ -53,13 +48,13 @@ int dumpkmap_main(int argc, char **argv)
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
if (argc>=2 && *argv[1]=='-') {
usage(dumpkmap_usage);
show_usage();
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
return 1;
perror_msg("Error opening /dev/tty0");
return EXIT_FAILURE;
}
write(1, magic, 7);
@@ -86,15 +81,15 @@ int dumpkmap_main(int argc, char **argv)
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
fprintf(stderr, "ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,&ke.kb_value,2);
write(1,(void*)&ke.kb_value,2);
}
}
}
}
close(fd);
return 0;
return EXIT_SUCCESS;
}
+36 -94
View File
@@ -7,7 +7,6 @@
* Peter Novodvorsky <petya@logic.ru>
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
@@ -17,50 +16,42 @@
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
static const char loadacm_usage[] = "loadacm\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nLoads an acm from standard input.\n"
#endif
;
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
typedef unsigned short unicode;
static long int ctoi(unsigned char *s, int *is_unicode);
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
unicode utf8_to_ucs2(char *buf);
int screen_map_load(int fd, FILE * fp);
static int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
static int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
static unicode utf8_to_ucs2(char *buf);
static int screen_map_load(int fd, FILE * fp);
int loadacm_main(int argc, char **argv)
{
int fd;
if (argc>=2 && *argv[1]=='-') {
usage(loadacm_usage);
show_usage();
}
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno));
return( FALSE);
perror_msg_and_die("Error opening /dev/tty1");
}
if (screen_map_load(fd, stdin)) {
fprintf(stderr, "Error loading acm: %s\n", strerror(errno));
return( FALSE);
perror_msg_and_die("Error loading acm");
}
write(fd, "\033(K", 3);
return( TRUE);
return EXIT_SUCCESS;
}
int screen_map_load(int fd, FILE * fp)
static int screen_map_load(int fd, FILE * fp)
{
struct stat stbuf;
unicode wbuf[E_TABSZ];
@@ -69,7 +60,7 @@ int screen_map_load(int fd, FILE * fp)
int is_unicode;
if (fstat(fileno(fp), &stbuf))
perror("Cannot stat map file"), exit(1);
perror_msg_and_die("Cannot stat map file");
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
@@ -79,19 +70,16 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
fprintf(stderr,
"16bit screen-map MUST be a regular file.\n"),
exit(1);
error_msg_and_die("16bit screen-map MUST be a regular file.");
else
perror("fseek failed reading binary 16bit screen-map"),
exit(1);
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
perror("Cannot read [new] map from file"), exit(1);
perror_msg_and_die("Cannot read [new] map from file");
#if 0
else
fprintf(stderr, "Input screen-map is binary.\n");
error_msg("Input screen-map is binary.");
#endif
}
@@ -99,7 +87,7 @@ int screen_map_load(int fd, FILE * fp)
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
perror("PIO_UNISCRNMAP ioctl"), exit(1);
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
else
return 0;
}
@@ -108,11 +96,10 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
fprintf(stderr,
"Assuming 8bit screen-map - MUST be a regular file.\n"),
error_msg("Assuming 8bit screen-map - MUST be a regular file."),
exit(1);
else
perror("fseek failed assuming 8bit screen-map"), exit(1);
perror_msg_and_die("fseek failed assuming 8bit screen-map");
}
/* ... and try an old 8-bit screen-map */
@@ -122,26 +109,25 @@ int screen_map_load(int fd, FILE * fp)
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
fprintf(stderr, "fseek() returned ESPIPE !\n"),
exit(1);
error_msg_and_die("fseek() returned ESPIPE !");
else
perror("fseek for binary 8bit screen-map"), exit(1);
perror_msg_and_die("fseek for binary 8bit screen-map");
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
perror("Cannot read [old] map from file"), exit(1);
perror_msg_and_die("Cannot read [old] map from file");
#if 0
else
fprintf(stderr, "Input screen-map is binary.\n");
error_msg("Input screen-map is binary.");
#endif
}
if (ioctl(fd, PIO_SCRNMAP, buf))
perror("PIO_SCRNMAP ioctl"), exit(1);
perror_msg_and_die("PIO_SCRNMAP ioctl");
else
return 0;
}
fprintf(stderr, "Error parsing symbolic map\n");
error_msg("Error parsing symbolic map");
return(1);
}
@@ -155,7 +141,7 @@ int screen_map_load(int fd, FILE * fp)
*
* FIXME: ignores everything after second word
*/
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
static int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
{
char buffer[256]; /* line buffer reading file */
char *p, *q; /* 1st + 2nd words in line */
@@ -163,7 +149,7 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
int tmp_is_unicode; /* tmp for is_unicode calculation */
int i; /* loop index - result holder */
int ret_code = 0; /* return code */
sigset_t sigset, old_sigset;
sigset_t acmsigset, old_sigset;
assert(is_unicode);
@@ -177,18 +163,16 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
buf[i] = 0xfffd;
/* block SIGCHLD */
sigemptyset(&sigset);
sigaddset(&sigset, SIGCHLD);
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
sigemptyset(&acmsigset);
sigaddset(&acmsigset, SIGCHLD);
sigprocmask(SIG_BLOCK, &acmsigset, &old_sigset);
do {
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
else {
perror("uni_screen_map_read_ascii() can't read line");
exit(2);
}
else
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
}
/* get "charset-relative charcode", stripping leading spaces */
@@ -229,7 +213,7 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
}
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
static int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
{
char buffer[256];
int in, on;
@@ -271,7 +255,7 @@ int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
*
* CAVEAT: will report valid UTF mappings using only 1 byte as 8-bit ones.
*/
long int ctoi(unsigned char *s, int *is_unicode)
static long int ctoi(unsigned char *s, int *is_unicode)
{
int i;
size_t ls;
@@ -318,49 +302,7 @@ long int ctoi(unsigned char *s, int *is_unicode)
}
void saveoldmap(int fd, char *omfil)
{
FILE *fp;
char buf[E_TABSZ];
#ifdef GIO_UNISCRNMAP
unicode xbuf[E_TABSZ];
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
perror("GIO_UNISCRNMAP ioctl error");
#endif
if (ioctl(fd, GIO_SCRNMAP, buf)) {
perror("GIO_SCRNMAP ioctl error");
exit(1);
} else
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
#endif
if ((fp = fopen(omfil, "w")) == NULL) {
perror(omfil);
exit(1);
}
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
perror("Error writing map to file");
exit(1);
}
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
perror("Error writing map to file");
exit(1);
}
#endif
fclose(fp);
}
unicode utf8_to_ucs2(char *buf)
static unicode utf8_to_ucs2(char *buf)
{
int utf_count = 0;
long utf_char = 0;
+36 -68
View File
@@ -7,7 +7,6 @@
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
*/
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
@@ -15,26 +14,20 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
#include <endian.h>
#include "busybox.h"
#define PSF_MAGIC1 0x36
#define PSF_MAGIC2 0x04
static const int PSF_MAGIC1 = 0x36;
static const int PSF_MAGIC2 = 0x04;
#define PSF_MODE512 0x01
#define PSF_MODEHASTAB 0x02
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
static const char loadfont_usage[] = "loadfont\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"Loads a console font from standard input.\n"
#endif
;
static const int PSF_MODE512 = 0x01;
static const int PSF_MODEHASTAB = 0x02;
static const int PSF_MAXMODE = 0x03;
static const int PSF_SEPARATOR = 0xFFFF;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
@@ -50,18 +43,15 @@ extern int loadfont_main(int argc, char **argv)
{
int fd;
if (argc>=2 && *argv[1]=='-') {
usage(loadfont_usage);
}
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
return( FALSE);
}
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
loadnewfont(fd);
return( TRUE);
return EXIT_SUCCESS;
}
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
@@ -71,10 +61,8 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) {
fprintf(stderr, "Bad character size %d\n", unit);
exit(1);
}
if (unit < 1 || unit > 32)
error_msg_and_die("Bad character size %d", unit);
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
@@ -89,13 +77,11 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */
perror("PIO_FONTX ioctl error (trying PIO_FONT)");
perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
}
#endif
if (ioctl(fd, PIO_FONT, buf)) {
perror("PIO_FONT ioctl error");
exit(1);
}
if (ioctl(fd, PIO_FONT, buf))
perror_msg_and_die("PIO_FONT ioctl error");
}
static void
@@ -109,12 +95,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
u_short unicode;
maxct = tailsz; /* more than enough */
up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
if (!up) {
fprintf(stderr, "Out of memory?\n");
exit(1);
}
for (glyph = 0; glyph < fontsize; glyph++) {
while (tailsz >= 2) {
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
@@ -137,12 +119,11 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
fprintf(stderr, "No Unicode mapping table loaded.\n");
error_msg("It seems this kernel is older than 1.1.92");
error_msg_and_die("No Unicode mapping table loaded.");
} else
#endif
perror("PIO_UNIMAPCLR");
exit(1);
perror_msg_and_die("PIO_UNIMAPCLR");
}
ud.entry_ct = ct;
ud.entries = up;
@@ -152,8 +133,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
/* change advice parameters */
}
#endif
perror("PIO_UNIMAP");
exit(1);
perror_msg_and_die("PIO_UNIMAP");
}
}
@@ -161,7 +141,7 @@ static void loadnewfont(int fd)
{
int unit;
char inbuf[32768]; /* primitive */
int inputlth, offset;
unsigned int inputlth, offset;
/*
* We used to look at the length of the input file
@@ -169,25 +149,21 @@ static void loadnewfont(int fd)
* just read the entire file.
*/
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin)) {
perror("Error reading input font");
exit(1);
}
if (ferror(stdin))
perror_msg_and_die("Error reading input font");
/* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values
for each font position */
if (!feof(stdin)) {
perror("Font too large");
exit(1);
}
if (!feof(stdin))
perror_msg_and_die("Font too large");
/* test for psf first */
{
struct psf_header psfhdr;
int fontsize;
int hastable;
int head0, head;
unsigned int head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
@@ -197,26 +173,20 @@ static void loadnewfont(int fd)
if (!PSF_MAGIC_OK(psfhdr))
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) {
fprintf(stderr, "Unsupported psf file mode\n");
exit(1);
}
if (psfhdr.mode > PSF_MAXMODE)
error_msg_and_die("Unsupported psf file mode");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) {
fprintf(stderr, "Only fontsize 256 supported\n");
exit(1);
}
if (fontsize != 256)
error_msg_and_die("Only fontsize 256 supported");
#endif
hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize;
head0 = sizeof(struct psf_header);
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) {
fprintf(stderr, "Input file: bad length\n");
exit(1);
}
if (head > inputlth || (!hastable && head != inputlth))
error_msg_and_die("Input file: bad length");
do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
@@ -230,10 +200,8 @@ static void loadnewfont(int fd)
unit = 16;
} else {
/* bare font */
if (inputlth & 0377) {
fprintf(stderr, "Bad input file size\n");
exit(1);
}
if (inputlth & 0377)
error_msg_and_die("Bad input file size");
offset = 0;
unit = inputlth / 256;
}
+22 -41
View File
@@ -20,11 +20,16 @@
*
*/
#include "internal.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include "busybox.h"
#define BINARY_KEYMAP_MAGIC "bkeymap"
/* From <linux/kd.h> */
struct kbentry {
@@ -32,65 +37,41 @@ struct kbentry {
unsigned char kb_index;
unsigned short kb_value;
};
#define KDSKBENT 0x4B47 /* sets one entry in translation table */
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
static const char loadkmap_usage[] = "loadkmap\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nLoads a binary keyboard translation table from standard input.\n"
#endif
;
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
int loadkmap_main(int argc, char **argv)
{
struct kbentry ke;
u_short *ibuff;
int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short);
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap", buff[7];
char flags[MAX_NR_KEYMAPS], buff[7];
if (argc>=2 && *argv[1]=='-') {
usage(loadkmap_usage);
}
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
exit(FALSE);
}
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 7);
if (0 != strncmp(buff, magic, 7)) {
fprintf(stderr, "This is not a valid binary keymap.\n");
exit(FALSE);
}
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
error_msg_and_die("This is not a valid binary keymap.");
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) {
fprintf(stderr, "Error reading keymap flags: %s\n",
strerror(errno));
exit(FALSE);
}
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) malloc(ibuffsz);
if (!ibuff) {
fprintf(stderr, "Out of memory.\n");
exit(FALSE);
}
ibuff = (u_short *) xmalloc(ibuffsz);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
pos = 0;
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
< 0) {
fprintf(stderr, "Error reading keymap: %s\n",
strerror(errno));
exit(FALSE);
}
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
perror_msg_and_die("Error reading keymap");
pos += readsz;
}
for (j = 0; j < NR_KEYS; j++) {
@@ -104,5 +85,5 @@ int loadkmap_main(int argc, char **argv)
/* Don't bother to close files. Exit does that
* automagically, so we can save a few bytes */
/* close(fd); */
return(TRUE);
return EXIT_SUCCESS;
}
+35
View File
@@ -0,0 +1,35 @@
/* vi: set sw=4 ts=4: */
/*
* 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>
*
* 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 "busybox.h"
extern int reset_main(int argc, char **argv)
{
printf("\033c");
return EXIT_SUCCESS;
}
+7 -18
View File
@@ -22,29 +22,18 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/kd.h> */
struct kbkeycode {
unsigned int scancode, keycode;
};
#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
static const char setkeycodes_usage[] =
"setkeycodes SCANCODE KEYCODE ...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nSet entries into the kernel's scancode-to-keycode map,\n"
"allowing unusual keyboards to generate usable keycodes.\n\n"
"SCANCODE may be either xx or e0xx (hexadecimal),\n"
"and KEYCODE is given in decimal\n"
#endif
;
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
extern int
setkeycodes_main(int argc, char** argv)
@@ -54,7 +43,7 @@ setkeycodes_main(int argc, char** argv)
struct kbkeycode a;
if (argc % 2 != 1 || argc < 2) {
usage(setkeycodes_usage);
show_usage();
}
fd = get_console_fd("/dev/console");
@@ -63,21 +52,21 @@ setkeycodes_main(int argc, char** argv)
a.keycode = atoi(argv[2]);
a.scancode = sc = strtol(argv[1], &ep, 16);
if (*ep) {
fatalError("error reading SCANCODE: '%s'\n", argv[1]);
error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
}
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
if (a.scancode > 255 || a.keycode > 127) {
fatalError("SCANCODE or KEYCODE outside bounds\n");
error_msg_and_die("SCANCODE or KEYCODE outside bounds");
}
if (ioctl(fd,KDSETKEYCODE,&a)) {
perror("KDSETKEYCODE");
fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
}
argc -= 2;
argv += 2;
}
return( TRUE);
return EXIT_SUCCESS;
}
+8 -13
View File
@@ -2,7 +2,7 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -21,16 +21,11 @@
*
*/
#include "internal.h"
#include <stdio.h>
const char *basename_usage="basename FILE [SUFFIX]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nStrips directory path and suffixes from FILE.\n"
"If specified, also removes any trailing SUFFIX.\n"
#endif
;
/* getopt not needed */
#include <stdlib.h>
#include "busybox.h"
#include <string.h>
extern int basename_main(int argc, char **argv)
{
@@ -38,7 +33,7 @@ extern int basename_main(int argc, char **argv)
char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(basename_usage);
show_usage();
}
argv++;
@@ -52,6 +47,6 @@ extern int basename_main(int argc, char **argv)
if (m>=n && strncmp(s+m-n, *argv, n)==0)
s[m-n] = '\0';
}
printf("%s\n", s);
return(TRUE);
puts(s);
return EXIT_SUCCESS;
}
+12 -32
View File
@@ -2,7 +2,7 @@
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -21,47 +21,27 @@
*
*/
#include "internal.h"
#include <stdio.h>
static void print_file(FILE * file)
{
int c;
while ((c = getc(file)) != EOF)
putc(c, stdout);
fclose(file);
fflush(stdout);
}
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
extern int cat_main(int argc, char **argv)
{
FILE *file;
int status = EXIT_SUCCESS;
if (argc == 1) {
print_file(stdin);
exit(TRUE);
return status;
}
if (**(argv + 1) == '-') {
usage("cat [FILE ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nConcatenates FILE(s) and prints them to the standard output.\n"
#endif
);
}
argc--;
while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
file = fopen(*argv, "r");
if (file == NULL) {
perror(*argv);
exit(FALSE);
while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) {
print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) {
status = EXIT_FAILURE;
}
print_file(file);
}
return(TRUE);
return status;
}
/*
+91
View File
@@ -0,0 +1,91 @@
/* 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"
/* 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:
*/
+85
View File
@@ -0,0 +1,85 @@
/* 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 <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:
*/
+113
View File
@@ -0,0 +1,113 @@
/* 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"
/* 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)() = 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:
*/
+14 -16
View File
@@ -3,7 +3,7 @@
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,33 +22,24 @@
*
*/
#include "internal.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRun COMMAND with root directory set to NEWROOT.\n"
#endif
;
#include "busybox.h"
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(chroot_usage);
show_usage();
}
argc--;
argv++;
if (chroot(*argv) || (chdir("/"))) {
fatalError("chroot: cannot change root directory to %s: %s\n",
*argv, strerror(errno));
perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
@@ -57,13 +48,20 @@ int chroot_main(int argc, char **argv)
prog = *argv;
execvp(*argv, argv);
} else {
#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#endif
}
fatalError("chroot: cannot execute %s: %s\n",
prog, strerror(errno));
perror_msg_and_die("cannot execute %s", prog);
}
+80
View File
@@ -0,0 +1,80 @@
/* 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 <getopt.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1, *filename2 = "-";
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
while ((c = getopt(argc, argv, "s")) != EOF) {
switch (c) {
case 's':
silent = TRUE;
break;
default:
show_usage();
}
}
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)
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;
}
+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 = 0;
int i;
while ((opt = getopt(argc, argv, "adfipR")) != -1)
switch (opt) {
case 'a':
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
/* fallthrough */
case 'd':
flags |= FILEUTILS_PRESERVE_SYMLINKS;
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_PRESERVE_SYMLINKS) &&
lstat(argv[optind], &source_stat) < 0) ||
(!(flags & FILEUTILS_PRESERVE_SYMLINKS) &&
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;
}
+326 -356
View File
@@ -1,11 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* cut implementation for busybox
* cut.c - minimalist version of cut
*
* Copyright (c) Michael J. Holme
*
* This version of cut is adapted from Minix cut and was modified
* by Erik Andersen <andersee@debian.org> to be used in busybox.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@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
@@ -20,369 +17,342 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice is retained at the end of this file.
*
*/
#include "internal.h"
#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
#define MAX_FIELD 80 /* Pointers to the beginning of each field
* are stored in columns[], if a line holds
* more than MAX_FIELD columns the array
* boundary is exceed. But unlikely at 80 */
#define MAX_ARGS 32 /* Maximum number of fields following -f or
* -c switches */
int args[MAX_ARGS * 2];
int num_args;
/* Lots of new defines, should easen maintainance... */
#define DUMP_STDIN 0 /* define for mode: no options */
#define OPTIONF 1 /* define for mode: option -f */
#define OPTIONC 2 /* define for mode: option -c */
#define OPTIONB 3 /* define for mode: option -b */
#define NOTSET 0 /* option not selected */
#define SET 1 /* option selected */
#define OPTIONS 1 /*define option -s */
/* Defines for the warnings */
#define DELIMITER_NOT_APPLICABLE 0
#define OVERRIDING_PREVIOUS_MODE 1
#define OPTION_NOT_APPLICABLE 2
#define UNKNOWN_OPTION 3
#define FILE_NOT_READABLE 4
/* Defines for the fatal errors */
#define SYNTAX_ERROR 101
#define POSITION_ERROR 102
#define LINE_TO_LONG_ERROR 103
#define RANGE_ERROR 104
#define MAX_FIELDS_EXEEDED_ERROR 105
#define MAX_ARGS_EXEEDED_ERROR 106
#include <stdlib.h>
#include <unistd.h> /* getopt */
#include <string.h>
#include <limits.h>
#include "busybox.h"
int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
char delim = '\t'; /* default delimiting character */
FILE *fd;
char *name;
char line[BUFSIZ];
int exit_status;
int option = 0; /* for -s option */
/* globals from other files */
extern int optind;
extern char *optarg;
int cut_main(int argc, char **argv);
void warn(int warn_number, char *option);
void cuterror(int err);
void get_args(void);
void cut(void);
void warn(int warn_number, char *option)
/* option vars */
static char part = 0; /* (b)yte, (c)har, (f)ields */
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)
{
static char *warn_msg[] = {
"%s: Option -%s allowed only with -f\n",
"%s: -%s overrides earlier option\n",
"%s: -%s not allowed in current mode\n",
"%s: Cannot open %s\n"
};
fprintf(stderr, warn_msg[warn_number], name, option);
exit_status = warn_number + 1;
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;
}
void cuterror(int err)
{
static char *err_mes[] = {
"%s: syntax error\n",
"%s: position must be >0\n",
"%s: line longer than BUFSIZ\n",
"%s: range must not decrease from left to right\n",
"%s: MAX_FIELD exceeded\n",
"%s: MAX_ARGS exceeded\n"
};
fprintf(stderr, err_mes[err - 101], name);
exit(err);
}
void get_args()
{
int i = 0;
int arg_ptr = 0;
int flag;
num_args = 0;
do {
if (num_args == MAX_ARGS)
cuterror(MAX_ARGS_EXEEDED_ERROR);
if (!isdigit(line[i]) && line[i] != '-')
cuterror(SYNTAX_ERROR);
args[arg_ptr] = 1;
args[arg_ptr + 1] = BUFSIZ;
flag = 1;
while (line[i] != ',' && line[i] != 0) {
if (isdigit(line[i])) {
args[arg_ptr] = 0;
while (isdigit(line[i]))
args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
if (!args[arg_ptr])
cuterror(POSITION_ERROR);
arg_ptr++;
}
if (line[i] == '-') {
arg_ptr |= 1;
i++;
flag = 0;
}
}
if (flag && arg_ptr & 1)
args[arg_ptr] = args[arg_ptr - 1];
if (args[num_args * 2] > args[num_args * 2 + 1])
cuterror(RANGE_ERROR);
num_args++;
arg_ptr = num_args * 2;
}
while (line[i++]);
}
void cut()
{
int i, j, length, maxcol=0;
char *columns[MAX_FIELD];
while (fgets(line, BUFSIZ, fd)) {
maxcol=0;
length = strlen(line) - 1;
*(line + length) = 0;
switch (mode) {
case DUMP_STDIN:
printf("%s", line);
break;
case OPTIONF:
columns[maxcol++] = line;
for (i = 0; i < length; i++) {
if (*(line + i) == delim) {
*(line + i) = 0;
if (maxcol == MAX_FIELD)
cuterror(MAX_FIELDS_EXEEDED_ERROR);
columns[maxcol] = line + i + 1;
maxcol++;
}
}
if (maxcol != 1) {
for (i = 0; i < num_args; i++) {
for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
if (j <= maxcol) {
printf("%s", columns[j - 1]);
if (i != num_args - 1 || j != args[i * 2 + 1])
putchar(delim);
}
}
} else if (option != OPTIONS) {
printf("%s",line);
}
break;
case OPTIONC:
for (i = 0; i < num_args; i++) {
for (j = args[i * 2];
j <= (args[i * 2 + 1] >
length ? length : args[i * 2 + 1]); j++)
putchar(*(line + j - 1));
}
}
if (maxcol != 1)
putchar('\n');
}
}
int cut_main(int argc, char **argv)
{
int i = 1;
int numberFilenames = 0;
name = argv[0];
if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
usage( "cut [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints selected fields from each input FILE to standard output.\n\n"
"Options:\n"
"\t-b LIST\tOutput only bytes from LIST\n"
"\t-c LIST\tOutput only characters from LIST\n"
"\t-d CHAR\tUse CHAR instead of tab as the field delimiter\n"
"\t-s\tOnly output Lines if the include DELIM\n"
"\t-f N\tPrint only these fields\n"
"\t-n\tIgnored\n"
#endif
);
while (i < argc) {
if (argv[i][0] == '-') {
switch (argv[i++][1]) {
case 'd':
if (mode == OPTIONC || mode == OPTIONB)
warn(DELIMITER_NOT_APPLICABLE, "d");
if (argc > i)
delim = argv[i++][0];
else
cuterror(SYNTAX_ERROR);
break;
case 'f':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONC || mode == OPTIONB)
warn(OVERRIDING_PREVIOUS_MODE, "f");
mode = OPTIONF;
break;
case 'b':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONF || mode == OPTIONC)
warn(OVERRIDING_PREVIOUS_MODE, "b");
mode = OPTIONB;
break;
case 'c':
sprintf(line, "%s", argv[i++]);
if (mode == OPTIONF || mode == OPTIONB)
warn(OVERRIDING_PREVIOUS_MODE, "c");
mode = OPTIONC;
break;
case 's':
option = OPTIONS;
break;
case '\0': /* - means: read from stdin */
numberFilenames++;
break;
case 'n': /* needed for Posix, but no effect here */
if (mode != OPTIONB)
warn(OPTION_NOT_APPLICABLE, "n");
break;
default:
warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
}
} else {
i++;
numberFilenames++;
}
}
/* Here follow the checks, if the selected options are reasonable. */
if (mode == OPTIONB) /* since in Minix char := byte */
mode = OPTIONC;
if (mode != OPTIONF && option == OPTIONS)
warn(DELIMITER_NOT_APPLICABLE,"s");
get_args();
if (numberFilenames != 0) {
i = 1;
while (i < argc) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'f':
case 'c':
case 'b':
case 'd':
i += 2;
break;
case 'n':
case 'i':
case 's':
i++;
break;
case '\0':
fd = stdin;
i++;
cut();
break;
default:
i++;
}
} else {
if ((fd = fopen(argv[i++], "r")) == NULL) {
warn(FILE_NOT_READABLE, argv[i - 1]);
} else {
cut();
fclose(fd);
}
}
}
} else {
fd = stdin;
cut();
}
return(exit_status);
}
/* cut - extract columns from a file or stdin. Author: Michael J. Holme
*
* Copyright 1989, Michael John Holme, All rights reserved.
* This code may be freely distributed, provided that this notice
* remains intact.
*
* V1.1: 6th September 1989
*
* Bugs, criticisms, etc,
* c/o Mark Powell
* JANET sq79@uk.ac.liv
* ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
* UUCP ...!mcvax!ukc!liv.ac.uk!sq79
*-------------------------------------------------------------------------
* Changed for POSIX1003.2/Draft10 conformance
* Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
* Changes:
* - separation of error messages ( stderr) and output (stdout).
* - support for -b and -n (no effect, -b acts as -c)
* - support for -s
*-------------------------------------------------------------------------
*/
/*
* Copyright (c) 1987,1997, Prentice Hall
* All rights reserved.
*
* Redistribution and use of the MINIX operating system in source and
* binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of Prentice Hall nor the names of the software
* authors or contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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 parse_lists(char *lists)
{
char *ltok = NULL;
char *ntok = NULL;
char *junk;
int s = 0, e = 0;
/* 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;
}
}
/* If we made it here, it means we've found the line we're looking for, so print it */
puts(line);
}
/*
* snippy-snip
*/
static void cut_file(FILE *file)
{
char *line = NULL;
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
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') {
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;
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
switch (opt) {
case 'b':
case 'c':
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
error_msg_and_die("only one type of list may be specified");
}
part = (char)opt;
parse_lists(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
error_msg_and_die("the delimiter must be a single character");
}
delim = optarg[0];
break;
case 'n':
/* no-op */
break;
case 's':
supress_non_delimited_lines++;
break;
}
}
if (part == 0) {
error_msg_and_die("you must specify a list of bytes, characters, or 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
* files were specified or '-' was specified, take input from stdin.
* Otherwise, we process all the files specified. */
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
cut_file(stdin);
}
else {
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
perror_msg("%s", argv[i]);
} else {
cut_file(file);
fclose(file);
}
}
}
return EXIT_SUCCESS;
}
+88 -118
View File
@@ -20,17 +20,15 @@
*
*/
#include "internal.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
#include "messages.c"
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
/* This 'date' command supports only 2 time setting formats,
@@ -39,23 +37,12 @@
an RFC 822 complient date output for shell scripting
mail commands */
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nDisplays the current time in the given FORMAT, or sets the system date.\n"
"\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
"\t-s\tSets time described by STRING\n"
"\t-u\tPrints or sets Coordinated Universal Time\n"
#endif
;
/* Input parsing code is always bulky - used heavy duty libc stuff as
much as possible, missed out a lot of bounds checking */
/* Default input handling to save suprising some people */
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
{
int nr;
@@ -66,7 +53,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
fatalError(invalid_date, "date", t_string);
error_msg_and_die(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
@@ -82,75 +69,59 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
/* The new stuff for LRP */
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
{
struct tm itm_time, jtm_time, ktm_time, ltm_time, mtm_time, ntm_time;
itm_time = *tm_time;
jtm_time = *tm_time;
ktm_time = *tm_time;
ltm_time = *tm_time;
mtm_time = *tm_time;
ntm_time = *tm_time;
struct tm t;
/* Parse input and assign appropriately to tm_time */
if (sscanf(t_string, "%d:%d:%d",
&itm_time.tm_hour, &itm_time.tm_min, &itm_time.tm_sec) == 3) {
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
/* no adjustments needed */
*tm_time = itm_time;
return (tm_time);
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
&t.tm_hour, &t.tm_min) == 2) {
/* no adjustments needed */
} else if (sscanf(t_string, "%d:%d",
&jtm_time.tm_hour, &jtm_time.tm_min) == 2) {
*tm_time = jtm_time;
return (tm_time);
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
&t.tm_mon,
&t.tm_mday,
&t.tm_hour,
&t.tm_min, &t.tm_sec) == 5) {
} else if (sscanf(t_string, "%d.%d-%d:%d:%d",
&ktm_time.tm_mon,
&ktm_time.tm_mday,
&ktm_time.tm_hour,
&ktm_time.tm_min, &ktm_time.tm_sec) == 5) {
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
ktm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
*tm_time = ktm_time;
return (tm_time);
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
&t.tm_mon,
&t.tm_mday,
&t.tm_hour, &t.tm_min) == 4) {
} else if (sscanf(t_string, "%d.%d-%d:%d",
&ltm_time.tm_mon,
&ltm_time.tm_mday,
&ltm_time.tm_hour, &ltm_time.tm_min) == 4) {
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
ltm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
*tm_time = ltm_time;
return (tm_time);
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
&t.tm_year,
&t.tm_mon,
&t.tm_mday,
&t.tm_hour,
&t.tm_min, &t.tm_sec) == 6) {
} else if (sscanf(t_string, "%d.%d.%d-%d:%d:%d",
&mtm_time.tm_year,
&mtm_time.tm_mon,
&mtm_time.tm_mday,
&mtm_time.tm_hour,
&mtm_time.tm_min, &mtm_time.tm_sec) == 6) {
t.tm_year -= 1900; /* Adjust years */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
mtm_time.tm_year -= 1900; /* Adjust years */
mtm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
*tm_time = mtm_time;
return (tm_time);
} else if (sscanf(t_string, "%d.%d.%d-%d:%d",
&ntm_time.tm_year,
&ntm_time.tm_mon,
&ntm_time.tm_mday,
&ntm_time.tm_hour, &ntm_time.tm_min) == 5) {
ntm_time.tm_year -= 1900; /* Adjust years */
ntm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
*tm_time = ntm_time;
return (tm_time);
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
&t.tm_year,
&t.tm_mon,
&t.tm_mday,
&t.tm_hour, &t.tm_min) == 5) {
t.tm_year -= 1900; /* Adjust years */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
error_msg_and_die(invalid_date, t_string);
}
fatalError(invalid_date, "date", t_string);
*tm_time = t;
return (tm_time);
}
@@ -159,7 +130,7 @@ int date_main(int argc, char **argv)
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
int i;
int c;
int set_time = 0;
int rfc822 = 0;
int utc = 0;
@@ -168,49 +139,44 @@ int date_main(int argc, char **argv)
struct tm tm_time;
/* Interpret command line args */
i = --argc;
argv++;
while (i > 0 && **argv) {
if (**argv == '-') {
while (i > 0 && *++(*argv))
switch (**argv) {
case 'R':
rfc822 = 1;
break;
case 's':
set_time = 1;
if (date_str != NULL)
usage(date_usage);
date_str = *argv;
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted, "date");
break;
case 'd':
use_arg = 1;
if (date_str != NULL)
usage(date_usage);
date_str = *argv;
break;
case '-':
usage(date_usage);
}
} else {
if ((date_fmt == NULL) && (**argv == '+'))
date_fmt = *argv + 1; /* Skip over the '+' */
else if (date_str == NULL) {
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
switch (c) {
case 'R':
rfc822 = 1;
break;
case 's':
set_time = 1;
date_str = *argv;
} else {
usage(date_usage);
}
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
show_usage();
}
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
error_msg_and_die(memory_exhausted);
break;
case 'd':
use_arg = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
show_usage();
break;
default:
show_usage();
}
i--;
argv++;
}
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
date_fmt = &argv[optind][1]; /* Skip over the '+' */
else if (date_str == NULL) {
set_time = 1;
date_str = argv[optind];
}
#if 0
else {
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
show_usage();
}
#endif
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
@@ -233,15 +199,19 @@ 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)
fatalError(invalid_date, "date", date_str);
error_msg_and_die(invalid_date, date_str);
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
error_msg_and_die(memory_exhausted);
}
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
fatalError("date: can't set date.\n");
perror_msg("cannot set date");
}
}
}
@@ -259,7 +229,7 @@ int date_main(int argc, char **argv)
} else if (*date_fmt == '\0') {
/* Imitate what GNU 'date' does with NO format string! */
printf("\n");
exit(TRUE);
return EXIT_SUCCESS;
}
/* Handle special conversions */
@@ -271,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(TRUE);
return EXIT_SUCCESS;
}
+114 -163
View File
@@ -2,15 +2,8 @@
/*
* Mini dd implementation for busybox
*
* Copyright (C) 1999, 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Based in part on code taken from sash.
* Copyright (c) 1999 by David I. Bell
* Permission is granted to use, distribute, or modify this source,
* provided that this copyright notice remains intact.
*
* Permission to distribute this code under the GPL has been granted.
* 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
@@ -28,180 +21,138 @@
*
*/
#include "internal.h"
#include <features.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
#include <inttypes.h>
#else
typedef unsigned long long int uintmax_t;
#endif
static const char dd_usage[] =
"dd [if=FILE] [of=FILE] [bs=N] [count=N] [skip=N] [seek=N]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCopy a file, converting and formatting according to options\n\n"
"\tif=FILE\tread from FILE instead of stdin\n"
"\tof=FILE\twrite to FILE instead of stdout\n"
"\tbs=N\tread and write N bytes at a time\n"
"\tcount=N\tcopy only N input blocks\n"
"\tskip=N\tskip N input blocks\n"
"\tseek=N\tskip N output blocks\n"
"\n"
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n"
#endif
;
#include "busybox.h"
static const struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
{ "w", 2 },
{ "b", 512 },
{ "kD", 1000 },
{ "k", 1024 },
{ "MD", 1000000 },
{ "M", 1048576 },
{ "GD", 1000000000 },
{ "G", 1073741824 },
{ NULL, 0 }
};
extern int dd_main(int argc, char **argv)
int dd_main(int argc, char **argv)
{
char *inFile = NULL;
char *outFile = NULL;
char *cp;
int inFd;
int outFd;
int inCc = 0;
int outCc;
long blockSize = 512;
uintmax_t skipBlocks = 0;
uintmax_t seekBlocks = 0;
uintmax_t count = (uintmax_t) - 1;
uintmax_t intotal;
uintmax_t outTotal;
unsigned char *buf;
int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
off_t seek = 0, skip = 0;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
argc--;
argv++;
for (i = 1; i < argc; i++) {
if (strncmp("bs=", argv[i], 3) == 0)
bs = parse_number(argv[i]+3, dd_suffixes);
else if (strncmp("count=", argv[i], 6) == 0)
count = parse_number(argv[i]+6, dd_suffixes);
else if (strncmp("seek=", argv[i], 5) == 0)
seek = parse_number(argv[i]+5, dd_suffixes);
else if (strncmp("skip=", argv[i], 5) == 0)
skip = parse_number(argv[i]+5, dd_suffixes);
else if (strncmp("if=", argv[i], 3) == 0)
infile = argv[i]+3;
else if (strncmp("of=", argv[i], 3) == 0)
outfile = argv[i]+3;
else if (strncmp("conv=", argv[i], 5) == 0) {
buf = argv[i]+5;
while (1) {
if (strncmp("notrunc", buf, 7) == 0) {
trunc = FALSE;
buf += 7;
} else if (strncmp("sync", buf, 4) == 0) {
sync_flag = TRUE;
buf += 4;
} else {
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
}
if (buf[0] == '\0')
break;
if (buf[0] == ',')
buf++;
}
} else
show_usage();
}
/* Parse any options */
while (argc) {
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
inFile = ((strchr(*argv, '=')) + 1);
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1);
if (count <= 0) {
fprintf(stderr, "Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
fprintf(stderr, "Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
fprintf(stderr, "Bad skip value %s\n", *argv);
goto usage;
}
buf = xmalloc(bs);
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
fprintf(stderr, "Bad seek value %s\n", *argv);
goto usage;
}
if (infile != NULL) {
if ((ifd = open(infile, O_RDONLY)) < 0)
perror_msg_and_die("%s", infile);
} else {
ifd = STDIN_FILENO;
infile = "standard input";
}
} else {
goto usage;
if (outfile != NULL) {
oflag = O_WRONLY | O_CREAT;
if (!seek && trunc)
oflag |= O_TRUNC;
if ((ofd = open(outfile, oflag, 0666)) < 0)
perror_msg_and_die("%s", outfile);
if (seek && trunc) {
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
}
argc--;
argv++;
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
buf = xmalloc(blockSize);
intotal = 0;
outTotal = 0;
if (inFile == NULL)
inFd = fileno(stdin);
else
inFd = open(inFile, 0);
if (inFd < 0) {
/* Note that we are not freeing buf or closing
* files here to save a few bytes. This exits
* here anyways... */
/* free(buf); */
fatalError( inFile);
if (skip) {
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", infile);
}
if (outFile == NULL)
outFd = fileno(stdout);
else
outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (outFd < 0) {
/* Note that we are not freeing buf or closing
* files here to save a few bytes. This exits
* here anyways... */
/* close(inFd);
free(buf); */
fatalError( outFile);
if (seek) {
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", outfile);
}
lseek(inFd, skipBlocks * blockSize, SEEK_SET);
lseek(outFd, seekBlocks * blockSize, SEEK_SET);
//
//TODO: Convert to using fullRead & fullWrite
// from utility.c
// -Erik
while (outTotal < count * blockSize) {
inCc = read(inFd, buf, blockSize);
if (inCc < 0) {
perror(inFile);
goto cleanup;
} else if (inCc == 0) {
goto cleanup;
}
intotal += inCc;
cp = buf;
while (intotal > outTotal) {
if (outTotal + inCc > count * blockSize)
inCc = count * blockSize - outTotal;
outCc = write(outFd, cp, inCc);
if (outCc < 0) {
perror(outFile);
goto cleanup;
} else if (outCc == 0) {
goto cleanup;
}
inCc -= outCc;
cp += outCc;
outTotal += outCc;
while (in_full + in_part != count) {
n = safe_read(ifd, buf, bs);
if (n < 0)
perror_msg_and_die("%s", infile);
if (n == 0)
break;
if (n == bs)
in_full++;
else
in_part++;
if (sync_flag) {
memset(buf + n, '\0', bs - n);
n = bs;
}
n = full_write(ofd, buf, n);
if (n < 0)
perror_msg_and_die("%s", outfile);
if (n == bs)
out_full++;
else
out_part++;
}
if (inCc < 0)
perror(inFile);
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);
cleanup:
/* Note that we are not freeing memory or closing
* files here, to save a few bytes. */
#if 0
close(inFd);
close(outFd);
free(buf);
#endif
printf("%ld+%d records in\n", (long) (intotal / blockSize),
(intotal % blockSize) != 0);
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
(outTotal % blockSize) != 0);
exit(TRUE);
usage:
usage(dd_usage);
return EXIT_SUCCESS;
}
+94 -56
View File
@@ -2,7 +2,7 @@
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
@@ -22,47 +22,63 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mntent.h>
#include <sys/stat.h>
#include <sys/vfs.h>
static const char df_usage[] = "df [filesystem ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint the filesystem space used and space available.\n"
#endif
;
#include <getopt.h>
#include "busybox.h"
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
static unsigned long df_disp_hr = KILOBYTE;
#endif
static int df(char *device, const char *mountPoint)
static int do_df(char *device, const char *mount_point)
{
struct statfs s;
long blocks_used;
long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) {
perror(mountPoint);
if (statfs(mount_point, &s) != 0) {
perror_msg("%s", mount_point);
return FALSE;
}
if (s.f_blocks > 0) {
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
if(blocks_used == 0)
blocks_percent_used = 0;
else {
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
}
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);
device = find_real_root_device_name(device);
if(device==NULL)
return FALSE;
}
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
blocks_percent_used, mountPoint);
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%-20s %9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
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(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
(long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
(long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
(long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
blocks_percent_used, mount_point);
#endif
}
return TRUE;
@@ -70,45 +86,67 @@ static int df(char *device, const char *mountPoint)
extern int df_main(int argc, char **argv)
{
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
int status = EXIT_SUCCESS;
int opt = 0;
int i = 0;
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
if (argc > 1) {
struct mntent *mountEntry;
int status;
if (**(argv + 1) == '-') {
usage(df_usage);
while ((opt = getopt(argc, argv, "k"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h':
df_disp_hr = 0;
strcpy(disp_units_hdr, " Size");
break;
case 'm':
df_disp_hr = MEGABYTE;
strcpy(disp_units_hdr, "1M-blocks");
break;
#endif
case 'k':
/* default display is kilobytes */
break;
default:
show_usage();
}
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
exit(FALSE);
}
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
if (status != 0)
exit(status);
argc--;
argv++;
}
exit(TRUE);
} else {
FILE *mountTable;
struct mntent *mountEntry;
mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) {
perror(mtab_file);
exit(FALSE);
}
while ((mountEntry = getmntent(mountTable))) {
df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
}
endmntent(mountTable);
}
return(TRUE);
printf("%-20s %-14s %s %s %s %s\n", "Filesystem", disp_units_hdr,
"Used", "Available", "Use%", "Mounted on");
if(optind < argc) {
struct mntent *mount_entry;
for(i = optind; i < argc; i++)
{
if ((mount_entry = find_mount_point(argv[i], mtab_file)) == 0) {
error_msg("%s: can't find mount point.", argv[i]);
status = EXIT_FAILURE;
} else if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
status = EXIT_FAILURE;
}
} else {
FILE *mount_table;
struct mntent *mount_entry;
mount_table = setmntent(mtab_file, "r");
if (mount_table == 0) {
perror_msg("%s", mtab_file);
return EXIT_FAILURE;
}
while ((mount_entry = getmntent(mount_table))) {
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
status = EXIT_FAILURE;
}
endmntent(mount_table);
}
return status;
}
/*
+12 -21
View File
@@ -2,7 +2,7 @@
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 2000 by Lineo, inc.
* 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
@@ -20,30 +20,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "internal.h"
/* getopt not needed */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
extern int dirname_main(int argc, char **argv)
{
char* s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("dirname [FILENAME ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nStrips non-directory suffix from FILENAME\n"
#endif
);
}
if ((argc < 2) || (**(argv + 1) == '-'))
show_usage();
argv++;
s=*argv+strlen(*argv)-1;
while (s && *s == '/') {
*s = '\0';
s=*argv+strlen(*argv)-1;
}
s = strrchr(*argv, '/');
if (s && *s)
*s = '\0';
printf("%s\n", (s)? *argv : ".");
return(TRUE);
puts (dirname (argv[0]));
return EXIT_SUCCESS;
}
+145
View File
@@ -0,0 +1,145 @@
/*
* dos2unix for BusyBox
*
* dos2unix '\n' convertor 0.5.0
* based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997)
* Copyright 1997,.. by Peter Hanecak <hanecak@megaloman.sk>.
* All rights reserved.
*
* dos2unix filters reading input from stdin and writing output to stdout.
* Without arguments it reverts the format (e.i. if source is in UNIX format,
* output is in DOS format and vice versa).
*
* 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.
*
* See the COPYING file for license information.
*/
#include <string.h>
#include <getopt.h>
#include "busybox.h"
// if fn is NULL then input is stdin and output is stdout
static int convert(char *fn, int ConvType) {
int c;
char *tempFn = NULL;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = wfopen(fn, "r")) == NULL) {
return -1;
}
if ((out = tmpfile()) == 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) {
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)) {
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)) {
perror_msg(NULL);
return -2;
}
}
return 0;
}
int dos2unix_main(int argc, char *argv[]) {
int ConvType = CT_AUTO;
int o;
// process parameters
while ((o = getopt(argc, argv, "du")) != EOF) {
switch (o) {
case 'd':
ConvType = CT_UNIX2DOS;
break;
case 'u':
ConvType = CT_DOS2UNIX;
break;
default:
show_usage();
}
}
if (optind < argc) {
while(optind < argc)
if ((o = convert(argv[optind++], ConvType)) < 0)
break;
}
else
o = convert(NULL, ConvType);
return o;
}
+121 -58
View File
@@ -3,7 +3,7 @@
* Mini du implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,30 +22,23 @@
*
*/
#include "internal.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#include "messages.c"
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <errno.h>
#include "busybox.h"
#ifdef BB_FEATURE_HUMAN_READABLE
static unsigned long disp_hr = KILOBYTE;
#endif
typedef void (Display) (long, char *);
static const char du_usage[] =
"du [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nSummarizes disk space used for each FILE and/or directory.\n"
"Disk space is printed in units of 1024 bytes.\n\n"
"Options:\n"
"\t-l\tcount sizes many times if hard linked\n"
"\t-s\tdisplay only a total for each argument\n"
#endif
;
static int du_depth = 0;
static int count_hardlinks = 0;
@@ -53,7 +46,11 @@ static Display *print;
static void print_normal(long size, char *filename)
{
fprintf(stdout, "%ld\t%s\n", size, filename);
#ifdef BB_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
}
static void print_summary(long size, char *filename)
@@ -63,15 +60,86 @@ static void print_summary(long size, char *filename)
}
}
#define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE)
typedef struct ino_dev_hash_bucket_struct {
struct ino_dev_hash_bucket_struct *next;
ino_t ino;
dev_t dev;
char name[1];
} ino_dev_hashtable_bucket_t;
static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
/*
* Return 1 if statbuf->st_ino && statbuf->st_dev are recorded in
* `ino_dev_hashtable', else return 0
*
* If NAME is a non-NULL pointer to a character pointer, and there is
* a match, then set *NAME to the value of the name slot in that
* bucket.
*/
static int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name)
{
ino_dev_hashtable_bucket_t *bucket;
bucket = ino_dev_hashtable[hash_inode(statbuf->st_ino)];
while (bucket != NULL) {
if ((bucket->ino == statbuf->st_ino) &&
(bucket->dev == statbuf->st_dev))
{
if (name) *name = bucket->name;
return 1;
}
bucket = bucket->next;
}
return 0;
}
/* Add statbuf to statbuf hash table */
static void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name)
{
int i;
size_t s;
ino_dev_hashtable_bucket_t *bucket;
i = hash_inode(statbuf->st_ino);
s = name ? strlen(name) : 0;
bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + s);
bucket->ino = statbuf->st_ino;
bucket->dev = statbuf->st_dev;
if (name)
strcpy(bucket->name, name);
else
bucket->name[0] = '\0';
bucket->next = ino_dev_hashtable[i];
ino_dev_hashtable[i] = bucket;
}
/* Clear statbuf hash table */
static void reset_ino_dev_hashtable(void)
{
int i;
ino_dev_hashtable_bucket_t *bucket;
for (i = 0; i < HASH_SIZE; i++) {
while (ino_dev_hashtable[i] != NULL) {
bucket = ino_dev_hashtable[i]->next;
free(ino_dev_hashtable[i]);
ino_dev_hashtable[i] = bucket;
}
}
}
/* tiny recursive du */
static long du(char *filename)
{
struct stat statbuf;
long sum;
int len;
if ((lstat(filename, &statbuf)) != 0) {
printf("du: %s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
return 0;
}
@@ -81,12 +149,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) {
@@ -94,27 +163,20 @@ 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[BUFSIZ + 1];
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
|| (strcmp(name, ".") == 0)) {
continue;
}
if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du");
du_depth--;
return 0;
}
sprintf(newfile, "%s/%s", filename, name);
newfile = concat_path_file(filename, name);
sum += du(newfile);
free(newfile);
}
closedir(dir);
print(sum, filename);
@@ -136,55 +198,56 @@ static long du(char *filename)
int du_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int i;
char opt;
int c;
/* default behaviour */
print = print_normal;
/* parse argv[] */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
while ((c = getopt(argc, argv, "sl"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k")) != EOF) {
switch (c) {
case 's':
print = print_summary;
break;
print = print_summary;
break;
case 'l':
count_hardlinks = 1;
break;
case 'h':
case '-':
usage(du_usage);
break;
count_hardlinks = 1;
break;
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
#endif
case 'k': break;
default:
fprintf(stderr, "du: invalid option -- %c\n", opt);
usage(du_usage);
show_usage();
}
} else {
break;
}
}
/* go through remaining args (if any) */
if (i >= argc) {
du(".");
if (optind >= argc) {
if (du(".") == 0)
status = EXIT_FAILURE;
} else {
long sum;
for (; i < argc; i++) {
for (i=optind; i < argc; i++) {
sum = du(argv[i]);
if (sum && isDirectory(argv[i], FALSE, NULL)) {
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
}
}
return(0);
return status;
}
/* $Id: du.c,v 1.20 2000/06/19 17:25:39 andersen Exp $ */
/* $Id: du.c,v 1.50 2001/06/30 17:54:20 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
+75 -45
View File
@@ -22,63 +22,94 @@
* Original copyright notice is retained at the end of this file.
*/
#include "internal.h"
#include <stdio.h>
static const char uname_usage[] =
"echo [-neE] [ARG ...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints the specified ARGs to stdout\n\n"
"Options:\n"
"\t-n\tsuppress trailing newline\n"
"\t-e\tinterpret backslash-escaped characters (i.e. \\t=tab etc)\n"
"\t-E\tdisable interpretation of backslash-escaped characters\n"
#endif
;
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
extern int
echo_main(int argc, char** argv)
{
register char **ap;
char *p;
register char c;
int nflag = 0;
int eflag = 0;
ap = argv;
if (argc)
ap++;
while ((p = *ap) != NULL && *p == '-') {
if (strcmp(p, "-n")==0) {
nflag = 1;
} else if (strcmp(p, "-e")==0) {
eflag = 1;
} else if (strcmp(p, "-E")==0) {
eflag = 0;
/* Skip argv[0]. */
argc--;
argv++;
while (argc > 0 && *argv[0] == '-')
{
register char *temp;
register int ix;
/*
* If it appears that we are handling options, then make sure
* that all of the options specified are actually valid.
* Otherwise, the string should just be echoed.
*/
temp = argv[0] + 1;
for (ix = 0; temp[ix]; ix++)
{
if (strrchr("neE", temp[ix]) == 0)
goto just_echo;
}
else if (strncmp(p, "--", 2)==0) {
usage( uname_usage);
}
else break;
ap++;
if (!*temp)
goto just_echo;
/*
* All of the options in temp are valid options to echo.
* Handle them.
*/
while (*temp)
{
if (*temp == 'n')
nflag = 1;
else if (*temp == 'e')
eflag = 1;
else if (*temp == 'E')
eflag = 0;
else
goto just_echo;
temp++;
}
argc--;
argv++;
}
while ((p = *ap++) != NULL) {
while ((c = *p++) != '\0') {
if (c == '\\' && eflag) {
if (*p == 'c')
exit(0);
else
c = process_escape_sequence(&p);
just_echo:
while (argc > 0) {
const char *arg = argv[0];
register int c;
while ((c = *arg++)) {
/* Check for escape sequence. */
if (c == '\\' && eflag && *arg) {
if (*arg == 'c') {
/* '\c' means cancel newline. */
nflag = 1;
arg++;
continue;
} else {
c = process_escape_sequence(&arg);
}
}
putchar(c);
}
if (*ap)
argc--;
argv++;
if (argc > 0)
putchar(' ');
}
if (! nflag)
if (!nflag)
putchar('\n');
fflush(stdout);
return( 0);
return EXIT_SUCCESS;
}
/*-
@@ -96,9 +127,10 @@ echo_main(int argc, char** argv)
* 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
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* 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
@@ -118,5 +150,3 @@ echo_main(int argc, char** argv)
*
* @(#)echo.c 8.1 (Berkeley) 5/31/93
*/
+106
View File
@@ -0,0 +1,106 @@
/* vi: set sw=4 ts=4: */
/*
* env implementation for busybox
*
* Copyright (c) 1988, 1993, 1994
* 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.
*
* Modified for BusyBox by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*/
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
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) {
switch(ch) {
case 'i':
ignore_environment = 1;
break;
case 'u':
unsetenv(optarg);
break;
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)
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++)
puts(*ep);
return 0;
}
/*
* Copyright (c) 1988, 1993, 1994
* 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. <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.
*/
+535
View File
@@ -0,0 +1,535 @@
/* vi: set sw=4 ts=4: */
/*
* Mini expr implementation for busybox
*
* based on GNU expr Mike Parker.
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
*
* Busybox modifications
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
*
* this program is free software; you can redistribute it and/or modify
* it under the terms of the gnu general public license as published by
* the free software foundation; either version 2 of the license, or
* (at your option) any later version.
*
* this program is distributed in the hope that it will be useful,
* but without any warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose. see the gnu
* general public license for more details.
*
* you should have received a copy of the gnu general public license
* along with this program; if not, write to the free software
* foundation, inc., 59 temple place, suite 330, boston, ma 02111-1307 usa
*
*/
/* This program evaluates expressions. Each token (operator, operand,
* parenthesis) of the expression must be a seperate argument. The
* parser used is a reasonably general one, though any incarnation of
* it is language-specific. It is especially nice for expressions.
*
* No parse tree is needed; a new node is evaluated immediately.
* One function can handle multiple operators all of equal precedence,
* provided they all associate ((x op x) op x). */
/* no getopt needed */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <regex.h>
#include <sys/types.h>
#include "busybox.h"
/* The kinds of value we can have. */
enum valtype {
integer,
string
};
typedef enum valtype TYPE;
/* A value is.... */
struct valinfo {
TYPE type; /* Which kind. */
union { /* The value itself. */
int i;
char *s;
} u;
};
typedef struct valinfo VALUE;
/* The arguments given to the program, minus the program name. */
static char **args;
static VALUE *docolon (VALUE *sv, VALUE *pv);
static VALUE *eval (void);
static VALUE *int_value (int i);
static VALUE *str_value (char *s);
static int nextarg (char *str);
static int null (VALUE *v);
static int toarith (VALUE *v);
static void freev (VALUE *v);
static void tostring (VALUE *v);
int expr_main (int argc, char **argv)
{
VALUE *v;
if (argc == 1) {
error_msg_and_die("too few arguments");
}
args = argv + 1;
v = eval ();
if (*args)
error_msg_and_die ("syntax error");
if (v->type == integer)
printf ("%d\n", v->u.i);
else
puts (v->u.s);
exit (null (v));
}
/* Return a VALUE for I. */
static VALUE *int_value (int i)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = integer;
v->u.i = i;
return v;
}
/* Return a VALUE for S. */
static VALUE *str_value (char *s)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strdup (s);
return v;
}
/* Free VALUE V, including structure components. */
static void freev (VALUE *v)
{
if (v->type == string)
free (v->u.s);
free (v);
}
/* Return nonzero if V is a null-string or zero-number. */
static int null (VALUE *v)
{
switch (v->type) {
case integer:
return v->u.i == 0;
case string:
return v->u.s[0] == '\0' || strcmp (v->u.s, "0") == 0;
default:
abort ();
}
}
/* Coerce V to a string value (can't fail). */
static void tostring (VALUE *v)
{
char *temp;
if (v->type == integer) {
temp = xmalloc (4 * (sizeof (int) / sizeof (char)));
sprintf (temp, "%d", v->u.i);
v->u.s = temp;
v->type = string;
}
}
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
static int toarith (VALUE *v)
{
int i;
switch (v->type) {
case integer:
return 1;
case string:
i = 0;
/* Don't interpret the empty string as an integer. */
if (v->u.s == 0)
return 0;
i = atoi(v->u.s);
free (v->u.s);
v->u.i = i;
v->type = integer;
return 1;
default:
abort ();
}
}
/* Return nonzero if the next token matches STR exactly.
STR must not be NULL. */
static int
nextarg (char *str)
{
if (*args == NULL)
return 0;
return strcmp (*args, str) == 0;
}
/* The comparison operator handling functions. */
#define cmpf(name, rel) \
static int name (l, r) VALUE *l; VALUE *r; \
{ \
if (l->type == string || r->type == string) { \
tostring (l); \
tostring (r); \
return strcmp (l->u.s, r->u.s) rel 0; \
} \
else \
return l->u.i rel r->u.i; \
}
cmpf (less_than, <)
cmpf (less_equal, <=)
cmpf (equal, ==)
cmpf (not_equal, !=)
cmpf (greater_equal, >=)
cmpf (greater_than, >)
#undef cmpf
/* The arithmetic operator handling functions. */
#define arithf(name, op) \
static \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ("non-numeric argument"); \
return l->u.i op r->u.i; \
}
#define arithdivf(name, op) \
static int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ( "non-numeric argument"); \
if (r->u.i == 0) \
error_msg_and_die ( "division by zero"); \
return l->u.i op r->u.i; \
}
arithf (plus, +)
arithf (minus, -)
arithf (multiply, *)
arithdivf (divide, /)
arithdivf (mod, %)
#undef arithf
#undef arithdivf
/* Do the : operator.
SV is the VALUE for the lhs (the string),
PV is the VALUE for the rhs (the pattern). */
static VALUE *docolon (VALUE *sv, VALUE *pv)
{
VALUE *v;
const char *errmsg;
struct re_pattern_buffer re_buffer;
struct re_registers re_regs;
int len;
tostring (sv);
tostring (pv);
if (pv->u.s[0] == '^') {
fprintf (stderr, "\
warning: unportable BRE: `%s': using `^' as the first character\n\
of a basic regular expression is not portable; it is being ignored",
pv->u.s);
}
len = strlen (pv->u.s);
memset (&re_buffer, 0, sizeof (re_buffer));
memset (&re_regs, 0, sizeof (re_regs));
re_buffer.allocated = 2 * len;
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
re_buffer.translate = 0;
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) {
error_msg_and_die("%s", errmsg);
}
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
if (len >= 0) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
sv->u.s[re_regs.end[1]] = '\0';
v = str_value (sv->u.s + re_regs.start[1]);
}
else
v = int_value (len);
}
else {
/* Match failed -- return the right kind of null. */
if (re_buffer.re_nsub > 0)
v = str_value ("");
else
v = int_value (0);
}
free (re_buffer.buffer);
return v;
}
/* Handle bare operands and ( expr ) syntax. */
static VALUE *eval7 (void)
{
VALUE *v;
if (!*args)
error_msg_and_die ( "syntax error");
if (nextarg ("(")) {
args++;
v = eval ();
if (!nextarg (")"))
error_msg_and_die ( "syntax error");
args++;
return v;
}
if (nextarg (")"))
error_msg_and_die ( "syntax error");
return str_value (*args++);
}
/* Handle match, substr, index, length, and quote keywords. */
static VALUE *eval6 (void)
{
VALUE *l, *r, *v, *i1, *i2;
if (nextarg ("quote")) {
args++;
if (!*args)
error_msg_and_die ( "syntax error");
return str_value (*args++);
}
else if (nextarg ("length")) {
args++;
r = eval6 ();
tostring (r);
v = int_value (strlen (r->u.s));
freev (r);
return v;
}
else if (nextarg ("match")) {
args++;
l = eval6 ();
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
return v;
}
else if (nextarg ("index")) {
args++;
l = eval6 ();
r = eval6 ();
tostring (l);
tostring (r);
v = int_value (strcspn (l->u.s, r->u.s) + 1);
if (v->u.i == (int) strlen (l->u.s) + 1)
v->u.i = 0;
freev (l);
freev (r);
return v;
}
else if (nextarg ("substr")) {
args++;
l = eval6 ();
i1 = eval6 ();
i2 = eval6 ();
tostring (l);
if (!toarith (i1) || !toarith (i2)
|| i1->u.i > (int) strlen (l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
v = str_value ("");
else {
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1),
l->u.s + i1->u.i - 1, i2->u.i);
v->u.s[i2->u.i] = 0;
}
freev (l);
freev (i1);
freev (i2);
return v;
}
else
return eval7 ();
}
/* Handle : operator (pattern matching).
Calls docolon to do the real work. */
static VALUE *eval5 (void)
{
VALUE *l, *r, *v;
l = eval6 ();
while (nextarg (":")) {
args++;
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
l = v;
}
return l;
}
/* Handle *, /, % operators. */
static VALUE *eval4 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval5 ();
while (1) {
if (nextarg ("*"))
fxn = multiply;
else if (nextarg ("/"))
fxn = divide;
else if (nextarg ("%"))
fxn = mod;
else
return l;
args++;
r = eval5 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle +, - operators. */
static VALUE *eval3 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval4 ();
while (1) {
if (nextarg ("+"))
fxn = plus;
else if (nextarg ("-"))
fxn = minus;
else
return l;
args++;
r = eval4 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle comparisons. */
static VALUE *eval2 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval3 ();
while (1) {
if (nextarg ("<"))
fxn = less_than;
else if (nextarg ("<="))
fxn = less_equal;
else if (nextarg ("=") || nextarg ("=="))
fxn = equal;
else if (nextarg ("!="))
fxn = not_equal;
else if (nextarg (">="))
fxn = greater_equal;
else if (nextarg (">"))
fxn = greater_than;
else
return l;
args++;
r = eval3 ();
toarith (l);
toarith (r);
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle &. */
static VALUE *eval1 (void)
{
VALUE *l, *r;
l = eval2 ();
while (nextarg ("&")) {
args++;
r = eval2 ();
if (null (l) || null (r)) {
freev (l);
freev (r);
l = int_value (0);
}
else
freev (r);
}
return l;
}
/* Handle |. */
static VALUE *eval (void)
{
VALUE *l, *r;
l = eval1 ();
while (nextarg ("|")) {
args++;
r = eval1 ();
if (null (l)) {
freev (l);
l = r;
}
else
freev (r);
}
return l;
}
+49 -65
View File
@@ -3,7 +3,7 @@
* Mini head implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,32 +22,23 @@
*
*/
#include "internal.h"
#include <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
const char head_usage[] =
"head [OPTION] [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint first 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
"Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n"
#endif
;
int head(int len, FILE * src)
static int head(int len, FILE *fp)
{
int i;
char buffer[1024];
char *input;
for (i = 0; i < len; i++) {
fgets(buffer, 1024, src);
if (feof(src)) {
if ((input = get_line_from_file(fp)) == NULL)
break;
}
fputs(buffer, stdout);
fputs(input, stdout);
free(input);
}
return 0;
}
@@ -55,61 +46,54 @@ int head(int len, FILE * src)
/* BusyBoxed head(1) */
int head_main(int argc, char **argv)
{
char opt;
int len = 10, tmplen, i;
FILE *fp;
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
/* parse argv[] */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'n':
tmplen = 0;
if (++i < argc)
tmplen = atoi(argv[i]);
if (tmplen < 1)
usage(head_usage);
len = tmplen;
while ((opt = getopt(argc, argv, "n:")) > 0) {
switch (opt) {
case 'n':
len = atoi(optarg);
if (len >= 1)
break;
case '-':
case 'h':
usage(head_usage);
default:
fprintf(stderr, "head: invalid option -- %c\n", opt);
usage(head_usage);
}
} else {
break;
/* fallthrough */
default:
show_usage();
}
}
/* get rest of argv[] or stdin if nothing's left */
if (i >= argc) {
if (argv[optind] == NULL) {
head(len, stdin);
return status;
}
} else {
int need_headers = ((argc - i) > 1);
for (; i < argc; i++) {
FILE *src;
src = fopen(argv[i], "r");
if (!src) {
fprintf(stderr, "head: %s: %s\n", argv[i],
strerror(errno));
} else {
/* emulating GNU behaviour */
if (need_headers) {
fprintf(stdout, "==> %s <==\n", argv[i]);
}
head(len, src);
if (i < argc - 1) {
fprintf(stdout, "\n");
}
}
need_headers = optind != (argc - 1);
while (argv[optind]) {
if (strcmp(argv[optind], "-") == 0) {
fp = stdin;
argv[optind] = "standard input";
} else {
if ((fp = wfopen(argv[optind], "r")) == NULL)
status = EXIT_FAILURE;
}
if (fp) {
if (need_headers) {
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
errno = 0;
}
if (optind < argc - 1)
putchar('\n');
if (fp != stdin)
fclose(fp);
}
optind++;
}
return(0);
}
/* $Id: head.c,v 1.11 2000/06/19 17:25:39 andersen Exp $ */
return status;
}
+4 -2
View File
@@ -20,11 +20,13 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
extern int hostid_main(int argc, char **argv)
{
printf("%lx\n", gethostid());
return(TRUE);
return EXIT_SUCCESS;
}
+44 -43
View File
@@ -2,7 +2,6 @@
/*
* Mini id implementation for busybox
*
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,54 +20,46 @@
*
*/
#include "internal.h"
#include "busybox.h"
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <getopt.h>
#include <string.h>
#include <sys/types.h>
static const char id_usage[] =
"id [OPTIONS]... [USERNAME]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint information for USERNAME or the current user\n\n"
"Options:\n"
"\t-g\tprints only the group ID\n"
"\t-u\tprints only the user ID\n"
"\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"
#endif
;
extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
char *cp, *user, *group;
unsigned long gid;
int name_not_number = 0;
char user[9], group[9];
long gid;
long pwnam, grnam;
int opt;
cp = user = group = NULL;
gid = 0;
argc--; argv++;
while (argc > 0) {
cp = *argv;
if (*cp == '-') {
switch (*++cp) {
case 'u': no_group = 1; break;
case 'g': no_user = 1; break;
case 'r': print_real = 1; break;
default: usage(id_usage);
}
} else {
user = cp;
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
switch (opt) {
case 'u':
no_group++;
break;
case 'g':
no_user++;
break;
case 'r':
print_real++;
break;
case 'n':
name_not_number++;
break;
default:
show_usage();
}
argc--; argv++;
}
if (no_user && no_group) usage(id_usage);
if (no_user && no_group) show_usage();
if (user == NULL) {
user = xmalloc(9);
group = xmalloc(9);
if (argv[optind] == NULL) {
if (print_real) {
my_getpwuid(user, getuid());
my_getgrgid(group, getgid());
@@ -77,18 +68,28 @@ extern int id_main(int argc, char **argv)
my_getgrgid(group, getegid());
}
} else {
group = xmalloc(9);
strncpy(user, argv[optind], 8);
user[8] = '\0';
gid = my_getpwnamegid(user);
my_getgrgid(group, gid);
}
if (no_group) printf("%lu\n", my_getpwnam(user));
else if (no_user) printf("%lu\n", my_getgrnam(group));
else
printf("uid=%lu(%s) gid=%lu(%s)\n",
my_getpwnam(user), user, my_getgrnam(group), group);
pwnam=my_getpwnam(user);
grnam=my_getgrnam(group);
if (no_group) {
if(name_not_number && user)
puts(user);
else
printf("%ld\n", pwnam);
} else if (no_user) {
if(name_not_number && group)
puts(group);
else
printf("%ld\n", grnam);
} else {
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
}
return(0);
}
+4 -9
View File
@@ -1,18 +1,13 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "busybox.h"
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-') {
usage("length STRING\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrints out the length of the specified STRING.\n"
#endif
);
}
if (argc != 2 || **(argv + 1) == '-')
show_usage();
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
return EXIT_SUCCESS;
}
+86 -100
View File
@@ -2,7 +2,7 @@
/*
* Mini ln implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -21,119 +21,105 @@
*
*/
#include "internal.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_not_a_directory
#include "messages.c"
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "busybox.h"
static const char ln_usage[] =
"ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreate a link named LINK_NAME or DIRECTORY to the specified TARGET\n"
"\nYou may use '--' to indicate that all following arguments are non-options.\n\n"
"Options:\n"
"\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"
"\t-n\tno dereference symlinks - treat like normal file\n"
#endif
;
static const int LN_SYMLINK = 1;
static const int LN_FORCE = 2;
static const int LN_NODEREFERENCE = 4;
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
static int followLinks = TRUE;
/*
* linkDestName is where the link points to,
* linkSrcName is the name of the link to be created.
*/
static int fs_link(const char *link_destname, const char *link_srcname,
const int flag)
{
int status;
int src_is_dir;
char *src_name;
if (link_destname==NULL)
return(FALSE);
src_name = (char *) xmalloc(strlen(link_srcname)+strlen(link_destname)+1);
if (link_srcname==NULL)
strcpy(src_name, link_destname);
else
strcpy(src_name, link_srcname);
if (flag&LN_NODEREFERENCE)
src_is_dir = is_directory(src_name, TRUE, NULL);
else
src_is_dir = is_directory(src_name, FALSE, NULL);
if ((src_is_dir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
char* srcdir_name;
srcdir_name = xstrdup(link_destname);
strcat(src_name, "/");
strcat(src_name, get_last_path_component(srcdir_name));
free(srcdir_name);
}
if (flag&LN_FORCE)
unlink(src_name);
if (flag&LN_SYMLINK)
status = symlink(link_destname, src_name);
else
status = link(link_destname, src_name);
if (status != 0) {
perror_msg(src_name);
return(FALSE);
}
return(TRUE);
}
extern int ln_main(int argc, char **argv)
{
char *linkName, *dirName=NULL;
int linkIntoDirFlag;
int stopIt = FALSE;
argc--;
argv++;
int status = EXIT_SUCCESS;
int flag = 0;
int opt;
/* Parse any options */
while (argc > 0 && stopIt == FALSE) {
if (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 's':
symlinkFlag = TRUE;
break;
case 'f':
removeoldFlag = TRUE;
break;
case 'n':
followLinks = FALSE;
break;
case '-':
stopIt = TRUE;
break;
default:
usage(ln_usage);
}
argc--;
argv++;
while ((opt=getopt(argc, argv, "sfn")) != -1) {
switch(opt) {
case 's':
flag |= LN_SYMLINK;
break;
case 'f':
flag |= LN_FORCE;
break;
case 'n':
flag |= LN_NODEREFERENCE;
break;
default:
show_usage();
}
else
break;
}
if (argc < 2) {
usage(ln_usage);
if (optind > (argc-1)) {
show_usage();
}
if (optind == (argc-1)) {
if (fs_link(argv[optind],
get_last_path_component(argv[optind]), flag)==FALSE)
status = EXIT_FAILURE;
}
linkName = argv[argc - 1];
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
if ((argc >= 3) && linkIntoDirFlag == FALSE) {
fprintf(stderr, not_a_directory, "ln", linkName);
exit FALSE;
while(optind<(argc-1)) {
if (fs_link(argv[optind], argv[argc-1], flag)==FALSE)
status = EXIT_FAILURE;
optind++;
}
if (linkIntoDirFlag == TRUE)
dirName = linkName;
while (argc-- >= 2) {
int status;
if (linkIntoDirFlag == TRUE) {
char *baseName = get_last_path_component(*argv);
linkName = (char *)malloc(strlen(dirName)+strlen(baseName)+2);
strcpy(linkName, dirName);
if(dirName[strlen(dirName)-1] != '/')
strcat(linkName, "/");
strcat(linkName,baseName);
}
if (removeoldFlag == TRUE) {
status = (unlink(linkName) && errno != ENOENT);
if (status != 0) {
perror(linkName);
exit FALSE;
}
}
if (symlinkFlag == TRUE)
status = symlink(*argv, linkName);
else
status = link(*argv, linkName);
if (status != 0) {
perror(linkName);
exit FALSE;
}
if (linkIntoDirFlag == TRUE)
free(linkName);
argv++;
}
return( TRUE);
exit(status);
}
/*
+8 -13
View File
@@ -20,27 +20,22 @@
*
*/
#include "internal.h"
#include <stdio.h>
static const char logname_usage[] = "logname\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint the name of the current user.\n"
#endif
;
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
extern int logname_main(int argc, char **argv)
{
char *user = xmalloc(9);
char user[9];
if (argc > 1)
usage(logname_usage);
show_usage();
my_getpwuid(user, geteuid());
if (user) {
if (*user) {
puts(user);
exit(TRUE);
return EXIT_SUCCESS;
}
fprintf(stderr, "no login name\n");
return(FALSE);
error_msg_and_die("no login name");
}
+798 -483
View File
File diff suppressed because it is too large. Load diff
+244 -121
View File
@@ -20,18 +20,42 @@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
#include "internal.h"
/*
* 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>
/* It turns out that libc5 doesn't have this in its headers
* even though it is actually in the lib. Force it to work */
#if ! defined __GLIBC__ && ! defined __UCLIBC__
#define getline __getline
extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
#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 */
#undef TRUE
#undef FALSE
#define FALSE ((int) 1)
#define TRUE ((int) 0)
//----------------------------------------------------------------------------
//--------md5.c
@@ -61,12 +85,6 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include "internal.h"
//----------------------------------------------------------------------------
//--------md5.h
//----------------------------------------------------------------------------
@@ -92,13 +110,7 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
#define _MD5_H 1
#include <stdio.h>
#if defined HAVE_LIMITS_H || _LIBC
# include <limits.h>
#endif
static const int _MD5_H = 1;
/* The following contortions are an attempt to use the C preprocessor
to determine an unsigned integral type that is 32 bits wide. An
@@ -107,48 +119,7 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
the resulting executable. Locally running cross-compiled executables
is usually not possible. */
#ifdef _LIBC
# include <sys/types.h>
typedef u_int32_t md5_uint32;
#else
# if defined __STDC__ && __STDC__
# define UINT_MAX_32_BITS 4294967295U
# else
# define UINT_MAX_32_BITS 0xFFFFFFFF
# endif
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
This should be valid for all systems GNU cares about because
that doesn't include 16-bit systems, and only modern systems
(that certainly have <limits.h>) have 64+-bit integral types. */
# ifndef UINT_MAX
# define UINT_MAX UINT_MAX_32_BITS
# endif
# if UINT_MAX == UINT_MAX_32_BITS
typedef unsigned int md5_uint32;
# else
# if USHRT_MAX == UINT_MAX_32_BITS
typedef unsigned short md5_uint32;
# else
# if ULONG_MAX == UINT_MAX_32_BITS
typedef unsigned long md5_uint32;
# else
/* The following line is intended to evoke an error.
Using #error is not portable enough. */
"Cannot determine unsigned 32-bit data type."
# endif
# endif
# endif
#endif
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(x) x
#else
#define __P(x) ()
#endif
/* Structure to save state of computation between the single steps. */
struct md5_ctx
@@ -222,11 +193,20 @@ extern 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) */
@@ -273,12 +253,17 @@ 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);
@@ -292,7 +277,7 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
#define BLOCKSIZE 4096
static const int BLOCKSIZE = 4096;
struct md5_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
@@ -409,6 +394,49 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
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;
@@ -430,6 +458,79 @@ 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);
break;
}
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
@@ -457,7 +558,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);
@@ -474,6 +590,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
@@ -489,6 +606,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);
@@ -505,8 +631,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);
@@ -523,8 +658,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);
@@ -541,6 +685,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;
@@ -570,7 +716,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
not include any newline character at the end of a line. */
#define MIN_DIGEST_LINE_LENGTH 35 /* 32 - message digest length
static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
2 - blank and binary indicator
1 - minimum filename length */
@@ -582,23 +728,6 @@ static int status_only = 0; /* With -c, don't generate any output.
static int warn = 0; /* With -w, print a message to standard error warning
about each improperly formatted MD5 checksum line */
static const char md5sum_usage[] =
"md5sum [OPTION] [FILE]...\n"
"or: md5sum [OPTION] -c [FILE]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPrint or check MD5 checksums.\n\n"
"Options:\n"
"With no FILE, or when FILE is -, read standard input.\n\n"
"\t-b\tread files in binary mode\n"
"\t-c\tcheck MD5 sums against given list\n"
"\t-t\tread files in text mode (default)\n"
"\t-g\tread a string\n"
"\nThe following two options are useful only when verifying checksums:\n"
"\t-s,\tdon't output anything, status code shows success\n"
"\t-w,\twarn about improperly formated MD5 checksum lines\n"
#endif
;
static int split_3(char *s,
size_t s_len,
unsigned char **u,
@@ -708,13 +837,13 @@ static int md5_file(const char *filename,
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
if (fp != stdin)
fclose(fp);
@@ -722,7 +851,7 @@ static int md5_file(const char *filename,
}
if (fp != stdin && fclose(fp) == EOF) {
errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
return FALSE;
}
@@ -737,8 +866,7 @@ static int md5_check(const char *checkfile_name)
int n_open_or_read_failures = 0;
unsigned char md5buffer[16];
size_t line_number;
char *line;
size_t line_chars_allocated;
char line[BUFSIZ];
if (STREQ(checkfile_name, "-")) {
have_read_stdin = 1;
@@ -746,14 +874,12 @@ static int md5_check(const char *checkfile_name)
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
perror_msg("%s", checkfile_name);
return FALSE;
}
}
line_number = 0;
line = 0;
line_chars_allocated = 0;
do {
char *filename;
@@ -763,9 +889,10 @@ static int md5_check(const char *checkfile_name)
++line_number;
line_length = getline(&line, &line_chars_allocated, checkfile_stream);
fgets(line, BUFSIZ-1, checkfile_stream);
line_length = strlen(line);
if (line_length <= 0)
if (line_length <= 0 || line==NULL)
break;
/* Ignore comment lines, which begin with a '#' character. */
@@ -779,7 +906,7 @@ static int md5_check(const char *checkfile_name)
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
if (warn) {
errorMsg("%s: %lu: improperly formatted MD5 checksum line\n",
error_msg("%s: %lu: improperly formatted MD5 checksum line",
checkfile_name, (unsigned long) line_number);
}
} else {
@@ -823,22 +950,19 @@ static int md5_check(const char *checkfile_name)
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
if (line)
free(line);
if (ferror(checkfile_stream)) {
errorMsg("%s: read error", checkfile_name); /* */
error_msg("%s: read error", checkfile_name);
return FALSE;
}
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
perror_msg("md5sum: %s", checkfile_name);
return FALSE;
}
if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */
errorMsg("%s: no properly formatted MD5 checksum lines found\n",
error_msg("%s: no properly formatted MD5 checksum lines found",
checkfile_name);
return FALSE;
} else {
@@ -847,13 +971,13 @@ static int md5_check(const char *checkfile_name)
- n_open_or_read_failures);
if (n_open_or_read_failures > 0) {
errorMsg("WARNING: %d of %d listed files could not be read\n",
error_msg("WARNING: %d of %d listed files could not be read",
n_open_or_read_failures, n_properly_formated_lines);
return FALSE;
}
if (n_mismatched_checksums > 0) {
errorMsg("WARNING: %d of %d computed checksums did NOT match\n",
error_msg("WARNING: %d of %d computed checksums did NOT match",
n_mismatched_checksums, n_computed_checkums);
return FALSE;
}
@@ -882,8 +1006,6 @@ int md5sum_main(int argc,
if (string == NULL)
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
if (optarg == NULL)
optarg = "";
string[n_strings++] = optarg;
break;
}
@@ -913,36 +1035,31 @@ int md5sum_main(int argc,
break;
default:
usage(md5sum_usage);
show_usage();
}
}
if (file_type_specified && do_check) {
errorMsg("the -b and -t options are meaningless when verifying checksums\n");
exit FALSE;
error_msg_and_die("the -b and -t options are meaningless when verifying checksums");
}
if (n_strings > 0 && do_check) {
errorMsg("the -g and -c options are mutually exclusive\n");
exit FALSE;
error_msg_and_die("the -g and -c options are mutually exclusive");
}
if (status_only && !do_check) {
errorMsg("the -s option is meaningful only when verifying checksums\n");
exit FALSE;
error_msg_and_die("the -s option is meaningful only when verifying checksums");
}
if (warn && !do_check) {
errorMsg("the -w option is meaningful only when verifying checksums\n");
exit FALSE;
error_msg_and_die("the -w option is meaningful only when verifying checksums");
}
if (n_strings > 0) {
size_t i;
if (optind < argc) {
errorMsg("no files may be specified when using -g\n");
exit FALSE;
error_msg_and_die("no files may be specified when using -g");
}
for (i = 0; i < n_strings; ++i) {
size_t cnt;
@@ -955,7 +1072,7 @@ int md5sum_main(int argc,
}
} else if (do_check) {
if (optind + 1 < argc) {
errorMsg("only one argument may be specified when using -c\n");
error_msg("only one argument may be specified when using -c");
}
err = md5_check ((optind == argc) ? "-" : argv[optind]);
@@ -969,7 +1086,12 @@ int md5sum_main(int argc,
fail = md5_file (file, binary, md5buffer);
err |= fail;
if (!fail) {
if (!fail && STREQ(file, "-")) {
size_t i;
for (i = 0; i < 16; ++i)
printf ("%02x", md5buffer[i]);
putchar ('\n');
} else if (!fail) {
size_t i;
/* Output a leading backslash if the file name contains
a newline or backslash. */
@@ -1008,14 +1130,15 @@ int md5sum_main(int argc,
}
if (fclose (stdout) == EOF) {
errorMsg("write error");
exit FALSE;
error_msg_and_die("write error");
}
if (have_read_stdin && fclose (stdin) == EOF) {
errorMsg("standard input");
exit FALSE;
error_msg_and_die("standard input");
}
exit (err == 0 ? TRUE : FALSE);
if (err == 0)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
}
+32 -84
View File
@@ -2,8 +2,7 @@
/*
* Mini mkdir implementation for busybox
*
* Copyright (C) 1999,2000 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,96 +20,45 @@
*
*/
#include "internal.h"
#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
#include "messages.c"
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
static const char mkdir_usage[] =
"mkdir [OPTION] DIRECTORY...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreate the DIRECTORY(ies), if they do not already exist\n\n"
"Options:\n"
#include "busybox.h"
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
"\t-p\tno error if existing, make parent directories as needed\n"
#endif
;
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)
usage(mkdir_usage);
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
fprintf(stderr, "Unknown mode: %s\n", *argv);
exit FALSE;
}
/* 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:
usage(mkdir_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) {
usage(mkdir_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) {
fprintf(stderr, name_too_long, "mkdir");
exit FALSE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
fprintf(stderr, "%s: File exists\n", buf);
exit FALSE;
}
if (parentFlag == TRUE) {
strcat(buf, "/");
createPath(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf);
exit FALSE;
}
}
argc--;
argv++;
}
return( TRUE);
return status;
}
+8 -18
View File
@@ -20,19 +20,11 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
"\t-m\tcreate the pipe using the specified mode (default a=rw)\n"
#endif
;
#include <stdlib.h>
#include "busybox.h"
extern int mkfifo_main(int argc, char **argv)
{
@@ -45,7 +37,7 @@ extern int mkfifo_main(int argc, char **argv)
/* Parse any options */
while (argc > 1) {
if (**argv != '-')
usage(mkfifo_usage);
show_usage();
thisarg = *argv;
thisarg++;
switch (*thisarg) {
@@ -55,16 +47,14 @@ extern int mkfifo_main(int argc, char **argv)
parse_mode(*argv, &mode);
break;
default:
usage(mkfifo_usage);
show_usage();
}
argc--;
argv++;
}
if (argc < 1 || *argv[0] == '-')
usage(mkfifo_usage);
if (mkfifo(*argv, mode) < 0) {
perror("mkfifo");
exit(255);
}
return(TRUE);
show_usage();
if (mkfifo(*argv, mode) < 0)
perror_msg_and_die("mkfifo");
return EXIT_SUCCESS;
}
+10 -21
View File
@@ -20,25 +20,14 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCreate a special file (block, character, or pipe).\n\n"
"Options:\n"
"\t-m\tcreate the special file using the specified mode (default a=rw)\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n"
#endif
;
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include "busybox.h"
int mknod_main(int argc, char **argv)
{
@@ -64,13 +53,13 @@ int mknod_main(int argc, char **argv)
umask(0);
break;
default:
usage(mknod_usage);
show_usage();
}
argc--;
argv++;
}
if (argc != 4 && argc != 2) {
usage(mknod_usage);
show_usage();
}
switch (argv[1][0]) {
case 'c':
@@ -83,11 +72,11 @@ int mknod_main(int argc, char **argv)
case 'p':
mode = S_IFIFO;
if (argc!=2) {
usage(mknod_usage);
show_usage();
}
break;
default:
usage(mknod_usage);
show_usage();
}
if (mode == S_IFCHR || mode == S_IFBLK) {
@@ -97,7 +86,7 @@ int mknod_main(int argc, char **argv)
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
fatalError("%s: %s\n", argv[0], strerror(errno));
return (TRUE);
perror_msg_and_die("%s", argv[0]);
return EXIT_SUCCESS;
}
+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 |
FILEUTILS_PRESERVE_SYMLINKS) < 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;
}
+4 -31
View File
@@ -47,20 +47,19 @@
// 19990508 Busy Boxed! Dave Cinege
#include "internal.h"
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <ctype.h>
#include "busybox.h"
#ifndef S_IFMT
# define S_IFMT 0170000
static const int S_IFMT = 0170000;
#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
@@ -93,28 +92,9 @@
#define IN_CTYPE_DOMAIN(c) 1
#ifdef isblank
# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
#else
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
#endif
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
#define ISDIGIT(c) (((unsigned char) (c)) - '0' <= 9)
#define isodigit(c) ((c) >= '0' && (c) <= '7')
#define hextobin(c) ((c)>='a'&&(c)<='f' ? (c)-'a'+10 : (c)>='A'&&(c)<='F' ? (c)-'A'+10 : (c)-'0')
@@ -137,13 +117,6 @@ static void verify __P((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
static const char printf_usage[] = "printf FORMAT [ARGUMENT...]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nFormats and prints ARGUMENT(s) according to FORMAT,\n"
"Where FORMAT controls the output exactly as in C printf.\n"
#endif
;
int printf_main(int argc, char **argv)
{
char *format;
@@ -151,7 +124,7 @@ int printf_main(int argc, char **argv)
exit_status = 0;
if (argc <= 1 || **(argv + 1) == '-') {
usage(printf_usage);
show_usage();
}
format = argv[1];
+14 -8
View File
@@ -21,18 +21,24 @@
*
*/
#include "internal.h"
/* getopt not needed */
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "busybox.h"
extern int pwd_main(int argc, char **argv)
{
char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL)
fatalError("pwd: %s\n", strerror(errno));
printf("%s\n", buf);
return(TRUE);
static char *buf;
buf = xgetcwd(buf);
if (buf != NULL) {
puts(buf);
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
+42 -81
View File
@@ -3,8 +3,8 @@
* Mini rm implementation for busybox
*
*
* Copyright (C) 1999,2000 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
@@ -22,95 +22,56 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <time.h>
#include <utime.h>
#include <dirent.h>
#include <errno.h>
static const char *rm_usage = "rm [OPTION]... FILE...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRemove (unlink) the FILE(s). You may use '--' to\n"
"indicate that all following arguments are non-options.\n\n"
"Options:\n"
"\t-f\t\tremove existing destinations, never prompt\n"
"\t-r or -R\tremove the contents of directories recursively\n"
#endif
;
static int recursiveFlag = FALSE;
static int forceFlag = FALSE;
static const char *srcName;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (unlink(fileName) < 0) {
perror(fileName);
return (FALSE);
}
return (TRUE);
}
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (rmdir(fileName) < 0) {
perror(fileName);
return (FALSE);
}
return (TRUE);
}
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
extern int rm_main(int argc, char **argv)
{
int stopIt=FALSE;
struct stat statbuf;
int status = 0;
int opt;
int flags = 0;
int i;
argc--;
argv++;
/* Parse any options */
while (argc > 0 && stopIt == FALSE) {
if (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 'R':
case 'r':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
case '-':
stopIt = TRUE;
break;
default:
usage(rm_usage);
}
argc--;
argv++;
}
else
while ((opt = getopt(argc, argv, "fiRr")) != -1) {
switch (opt) {
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 < 1 && forceFlag == FALSE) {
usage(rm_usage);
}
while (argc-- > 0) {
srcName = *(argv++);
if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0
&& errno == ENOENT) {
/* do not reports errors for non-existent files if -f, just skip them */
} else {
if (recursiveAction(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
exit(FALSE);
}
}
}
return(TRUE);
if (!(flags & FILEUTILS_FORCE) && optind == argc)
show_usage();
for (i = optind; i < argc; i++) {
char *base = get_last_path_component(argv[i]);
if (strcmp(base, ".") == 0 || strcmp(base, "..") == 0) {
error_msg("cannot remove `.' or `..'");
status = 1;
continue;
}
if (remove_file(argv[i], flags) < 0)
status = 1;
}
return status;
}
+11 -14
View File
@@ -3,7 +3,7 @@
* Mini rmdir implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,27 +22,24 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "busybox.h"
extern int rmdir_main(int argc, char **argv)
{
if (argc == 1 || **(argv + 1) == '-') {
usage
("rmdir [OPTION]... DIRECTORY...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRemove the DIRECTORY(ies), if they are empty.\n"
#endif
);
}
int status = EXIT_SUCCESS;
if (argc == 1 || **(argv + 1) == '-')
show_usage();
while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
fprintf(stderr, "%s: %s\n", *argv, strerror(errno));
exit(FALSE);
perror_msg("%s", *argv);
status = EXIT_FAILURE;
}
}
return(TRUE);
return status;
}
+7 -13
View File
@@ -21,24 +21,18 @@
*
*/
#include "internal.h"
#include <stdio.h>
const char sleep_usage[] = "sleep N\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nPause for N seconds.\n"
#endif
;
#include <unistd.h>
#include <stdlib.h>
#include "busybox.h"
extern int sleep_main(int argc, char **argv)
{
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(sleep_usage);
show_usage();
}
if (sleep(atoi(*(++argv))) != 0) {
perror("sleep");
exit(FALSE);
}
return(TRUE);
if (sleep(atoi(*(++argv))) != 0)
perror_msg_and_die("sleep");
return EXIT_SUCCESS;
}
+58 -259
View File
@@ -3,8 +3,7 @@
* Mini sort implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* 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
@@ -22,286 +21,86 @@
*
*/
#include "internal.h"
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
static const char sort_usage[] = "sort [-n]"
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
" [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nSorts lines of text in the specified files\n"
#endif
;
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
static int reverse = 0;
#else
#define APPLY_REVERSE(x) (x)
#endif
/* typedefs _______________________________________________________________ */
/* line node */
typedef struct Line {
char *data; /* line data */
struct Line *next; /* pointer to next line node */
} Line;
/* singly-linked list of lines */
typedef struct {
int len; /* number of Lines */
Line **sorted; /* array fed to qsort */
Line *head; /* head of List */
Line *current; /* current Line */
} List;
/* comparison function */
typedef int (Compare) (const void *, const void *);
/* methods ________________________________________________________________ */
static const int max = 1024;
/* mallocate Line */
static Line *line_alloc()
static int compare_ascii(const void *x, const void *y)
{
Line *self;
self = malloc(1 * sizeof(Line));
return self;
return strcmp(*(char **)x, *(char **)y);
}
/* Construct Line from FILE* */
static Line *line_newFromFile(FILE * src)
static int compare_numeric(const void *x, const void *y)
{
Line *self;
char *cstring = NULL;
if ((cstring = get_line_from_file(src))) {
self = line_alloc();
if (self == NULL) {
return NULL;
}
self->data = cstring;
self->next = NULL;
return self;
}
return NULL;
int z = atoi(*(char **)x) - atoi(*(char **)y);
return z ? z : strcmp(*(char **)x, *(char **)y);
}
/* Line destructor */
static Line *line_release(Line * self)
{
if (self->data) {
free(self->data);
free(self);
}
return self;
}
/* Comparison */
/* ascii order */
static int compare_ascii(const void *a, const void *b)
{
Line **doh;
Line *x, *y;
doh = (Line **) a;
x = *doh;
doh = (Line **) b;
y = *doh;
// fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
return APPLY_REVERSE(strcmp(x->data, y->data));
}
/* numeric order */
static int compare_numeric(const void *a, const void *b)
{
Line **doh;
Line *x, *y;
int xint, yint;
doh = (Line **) a;
x = *doh;
doh = (Line **) b;
y = *doh;
xint = strtoul(x->data, NULL, 10);
yint = strtoul(y->data, NULL, 10);
return APPLY_REVERSE(xint - yint);
}
/* List */
/* */
static List *list_init(List * self)
{
self->len = 0;
self->sorted = NULL;
self->head = NULL;
self->current = NULL;
return self;
}
/* for simplicity, the List gains ownership of the line */
static List *list_insert(List * self, Line * line)
{
if (line == NULL) {
return NULL;
}
/* first insertion */
if (self->head == NULL) {
self->head = line;
self->current = line;
/* all subsequent insertions */
} else {
self->current->next = line;
self->current = line;
}
self->len++;
return self;
}
/* order the list according to compare() */
static List *list_sort(List * self, Compare * compare)
{
int i;
Line *line;
/* mallocate array of Line*s */
self->sorted = (Line **) malloc(self->len * sizeof(Line *));
if (self->sorted == NULL) {
return NULL;
}
/* fill array w/ List's contents */
i = 0;
line = self->head;
while (line) {
self->sorted[i++] = line;
line = line->next;
}
/* apply qsort */
qsort(self->sorted, self->len, sizeof(Line *), compare);
return self;
}
/* precondition: list must be sorted */
static List *list_writeToFile(List * self, FILE * dst)
{
int i;
Line **line = self->sorted;
if (self->sorted == NULL) {
return NULL;
}
for (i = 0; i < self->len; i++) {
fprintf(dst, "%s", line[i]->data);
}
return self;
}
/* deallocate */
static void list_release(List * self)
{
Line *i;
Line *die;
i = self->head;
while (i) {
die = i;
i = die->next;
line_release(die);
}
}
int sort_main(int argc, char **argv)
{
int i;
char opt;
List list;
Line *l;
Compare *compare;
FILE *fp;
char *line, **lines = NULL;
int i, opt, nlines = 0;
int (*compare)(const void *, const void *) = compare_ascii;
#ifdef BB_FEATURE_SORT_REVERSE
int reverse = FALSE;
#endif
#ifdef BB_FEATURE_SORT_UNIQUE
int unique = FALSE;
#endif
/* init */
compare = compare_ascii;
list_init(&list);
/* parse argv[] */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'h':
usage(sort_usage);
break;
while ((opt = getopt(argc, argv, "nru")) != -1) {
switch (opt) {
case 'n':
/* numeric comparison */
compare = compare_numeric;
break;
#ifdef BB_FEATURE_SORT_REVERSE
case 'r':
/* reverse */
reverse = 1;
reverse = TRUE;
break;
#endif
#ifdef BB_FEATURE_SORT_UNIQUE
case 'u':
unique = TRUE;
break;
#endif
default:
fprintf(stderr, "sort: invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
break;
show_usage();
}
}
/* this could be factored better */
/* read the input */
for (i = optind; i == optind || i < argc; i++) {
if (argv[i] == NULL)
fp = stdin;
else
fp = xfopen(argv[i], "r");
/* work w/ stdin */
if (i >= argc) {
while ((l = line_newFromFile(stdin))) {
list_insert(&list, l);
while ((line = get_line_from_file(fp)) != NULL) {
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
chomp(line);
lines[nlines++] = line;
}
list_sort(&list, compare);
list_writeToFile(&list, stdout);
list_release(&list);
/* work w/ what's left in argv[] */
} else {
FILE *src;
for (; i < argc; i++) {
src = fopen(argv[i], "r");
if (src == NULL) {
break;
}
while ((l = line_newFromFile(src))) {
list_insert(&list, l);
}
fclose(src);
}
list_sort(&list, compare);
list_writeToFile(&list, stdout);
list_release(&list);
}
return(0);
/* sort it */
qsort(lines, nlines, sizeof(char *), compare);
/* print it */
#ifdef BB_FEATURE_SORT_REVERSE
if (reverse) {
for (i = --nlines; 0 <= i; i--)
#ifdef BB_FEATURE_SORT_UNIQUE
if((!unique) || (i == nlines) || (strcmp(lines[i + 1], lines[i])))
#endif
puts(lines[i]);
} else
#endif
for (i = 0; i < nlines; i++)
#ifdef BB_FEATURE_SORT_UNIQUE
if((!unique) || (!i) || (strcmp(lines[i - 1], lines[i])))
#endif
puts(lines[i]);
return EXIT_SUCCESS;
}
/* $Id: sort.c,v 1.18 2000/06/28 22:15:26 markw Exp $ */
+1376
View File
File diff suppressed because it is too large. Load diff
+7 -9
View File
@@ -21,17 +21,15 @@
*
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
extern int sync_main(int argc, char **argv)
{
if (argc > 1 && **(argv + 1) == '-') {
usage("sync\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nWrite all buffered filesystem blocks to disk.\n"
#endif
);
}
return(sync());
if (argc > 1 && **(argv + 1) == '-')
show_usage();
sync();
return(EXIT_SUCCESS);
}
+219 -1197
View File
File diff suppressed because it is too large. Load diff
+33 -101
View File
@@ -2,9 +2,8 @@
/*
* Mini tee implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* 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
@@ -22,115 +21,48 @@
*
*/
#include "internal.h"
#include <errno.h>
#include "busybox.h"
#include <getopt.h>
#include <stdio.h>
static const char tee_usage[] =
"tee [OPTION]... [FILE]...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nCopy standard input to each FILE, and also to standard output.\n\n"
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
#if 0
"\t-i\tignore interrupt signals\n"
#endif
#endif
;
/* FileList _______________________________________________________________ */
#define FL_MAX 1024
static FILE **FileList;
static int FL_end;
typedef void (FL_Function) (FILE * file, char c);
/* apply a function to everything in FileList */
static void FL_apply(FL_Function * f, char c)
int
tee_main(int argc, char **argv)
{
int i;
char *mode = "w";
int c, i, status = 0, nfiles = 0;
FILE **files;
for (i = 0; i <= FL_end; i++) {
f(FileList[i], c);
}
}
/* FL_Function for writing to files*/
static void tee_fwrite(FILE * file, char c)
{
fputc(c, file);
}
/* FL_Function for closing files */
static void tee_fclose(FILE * file, char c)
{
fclose(file);
}
/* ________________________________________________________________________ */
/* BusyBoxed tee(1) */
int tee_main(int argc, char **argv)
{
int i;
char c;
char opt;
char opt_fopen[2] = "w";
FILE *file;
/* parse argv[] */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'a':
opt_fopen[0] = 'a';
break;
#if 0
case 'i':
fprintf(stderr, "ignore interrupt not implemented\n");
break;
#endif
default:
usage(tee_usage);
}
} else {
while ((c = getopt(argc, argv, "a")) != EOF) {
switch (c) {
case 'a':
mode = "a";
break;
default:
show_usage();
}
}
/* init FILE pointers */
FileList = calloc(FL_MAX, sizeof(FILE*));
if (!FileList) {
fprintf(stderr, "tee: %s\n", strerror(errno));
exit(1);
}
FL_end = 0;
FileList[0] = stdout;
for (; i < argc; i++) {
/* add a file to FileList */
file = fopen(argv[i], opt_fopen);
if (!file) {
continue;
}
if (FL_end < FL_MAX) {
FileList[++FL_end] = file;
files = (FILE **)xmalloc(sizeof(FILE *) * (argc - optind + 1));
files[nfiles++] = stdout;
while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--;
perror_msg("%s", argv[optind-1]);
status = 1;
}
}
/* read and redirect */
while ((c = (char) getchar()) && (!feof(stdin))) {
FL_apply(tee_fwrite, c);
}
while ((c = getchar()) != EOF)
for (i = 0; i < nfiles; i++)
putc(c, files[i]);
/* clean up */
FL_apply(tee_fclose, 0);
/* Don't bother to close files Exit does that
* automagically, so we can save a few bytes */
/* free(FileList); */
return(0);
return status;
}
/* $Id: tee.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+14 -30
View File
@@ -31,17 +31,13 @@
* "This program is in the Public Domain."
*/
#include "internal.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
#include "busybox.h"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
@@ -111,10 +107,10 @@ enum token_types {
PAREN
};
struct t_op {
static const struct t_op {
const char *op_text;
short op_num, op_type;
} const ops [] = {
} ops [] = {
{"-r", FILRD, UNOP},
{"-w", FILWR, UNOP},
{"-x", FILEX, UNOP},
@@ -157,8 +153,8 @@ struct t_op {
{0, 0, 0}
};
char **t_wp;
struct t_op const *t_wp_op;
static char **t_wp;
static struct t_op const *t_wp_op;
static gid_t *group_array = NULL;
static int ngroups;
@@ -183,21 +179,11 @@ test_main(int argc, char** argv)
{
int res;
if (strcmp(argv[0], "[") == 0) {
if (strcmp(applet_name, "[") == 0) {
if (strcmp(argv[--argc], "]"))
fatalError("missing ]\n");
error_msg_and_die("missing ]");
argv[argc] = NULL;
}
if (strcmp(argv[1], dash_dash_help) == 0) {
usage("test EXPRESSION\n"
"or [ EXPRESSION ]\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nChecks file types and compares values returning an exit\n"
"code determined by the value of EXPRESSION.\n"
#endif
);
}
/* Implement special cases from POSIX.2, section 4.62.4 */
switch (argc) {
case 1:
@@ -244,9 +230,9 @@ syntax(op, msg)
char *msg;
{
if (op && *op)
fatalError("%s: %s\n", op, msg);
error_msg_and_die("%s: %s", op, msg);
else
fatalError("%s\n", msg);
error_msg_and_die("%s", msg);
}
static int
@@ -372,7 +358,7 @@ filstat(nm, mode)
enum token mode;
{
struct stat s;
int i;
unsigned int i;
if (mode == FILSYM) {
#ifdef S_IFLNK
@@ -481,13 +467,13 @@ getn(s)
r = strtol(s, &p, 10);
if (errno != 0)
fatalError("%s: out of range\n", s);
error_msg_and_die("%s: out of range", s);
while (isspace(*p))
p++;
if (*p)
fatalError("%s: bad number\n", s);
error_msg_and_die("%s: bad number", s);
return (int) r;
}
@@ -535,7 +521,7 @@ char *path;
int mode;
{
struct stat st;
int euid = geteuid();
unsigned int euid = geteuid();
if (stat (path, &st) < 0)
return (-1);
@@ -566,9 +552,7 @@ static void
initialize_group_array ()
{
ngroups = getgroups(0, NULL);
if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL)
fatalError("Out of space\n");
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
getgroups(ngroups, group_array);
}
Loaded 100 of 443 files, more files were not shown because too many files have changed in this diff. Show more