Compare commits

..
395 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
257 changed files with 57442 additions and 17026 deletions

No files matched your search

+3
View File
@@ -76,3 +76,6 @@ Enrique Zanardi <ezanardi@ull.es>
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
+49 -1
View File
@@ -1,3 +1,51 @@
0.52
Critical Bugfixes:
* Glenn McGrath -- Fixed gunzip, zcat when reading from stdin
* Marc Karasek and Kanoj (kernel serial.c maintainer) -- fixed init
problem on serial consoles with 2.4.3+ kernels.
New Applets:
* Laurence Anderson -- rpm2cpio applet, this obsoletes rpmunpack
which has now been removed from BusyBox
* Laurence Anderson and Glenn McGrath -- cpio applet, currently
only supports unpacking the ascii cpio format.
* Vladimir Oleynik and Erik Andersen -- added ash, the most correct
busybox shell.
* Larry Doolittle -- hush, small shell designed specifically
for busybox. Quite usable but still a work in progress.
* Erik Andersen -- msh, minix shell. A very small but capable shell
that only uses vfork, so it can be used on uClinux systems.
Other Changes:
* Sterling Huxley -- Several bugfixes for the vi applet.
* Glenn McGrath -- Restructure unarchiving code to make more code
common to the ar, cpio, dpkg, dpkg-deb applets.
tar applet has not yet been assimilated...
* Matt Kraai -- Rewrote cp, dirname, mkdir, mv, and rm.
* Paul J.Y. Lahaie <pjlahaie@linuxcare.com> -- Fixed an endian-ness
bug in md5sum (in 0.51, md5sum on big endian machines was broken)
* Mark Whitley -- rewrote cut, major updates to grep and sed.
* Erik Andersen -- bunches of insmod fixes. It should now always
work (no more segfault or missing symbols problems).
* Bernhard Kuhn <kuhn@lpr.e-technik.tu-muenchen.de> and Jinux Kim
added uClinux/m68k insmod support.
* Manuel Novoa III -- rewrote make_human_readable so ls, du, and df
should work as expected. Eliminated use of floats.
* Aaron Lehmann <aaronl@vitelus.com> -- Scrubbed gzip.c
* Alan Modra <amodra@bigpond.net.au> -- fixed an hard to spot
bug breaking gunzip checksum checking.
* Gennady Feldman -- Fixed 'syslog -C'
* Gernot Poerner <gp@it-netservice.de> -- Added mount bind support.
* Adam Heath <doogie@debian.org> -- wget arbitrary header support
* John Beppu -- updated the automagical doc generator
* Zillions of other bugfixes, optimizations, and cleanups.
-Erik Andersen, 7 July 2001
0.51
Critical Bugfixes:
* Erik Andersen -- Fixed a bug that could crash the shell in 0.50
@@ -69,7 +117,7 @@
restarting an aborted download.
-Erik Andersen, not yet released
-Erik Andersen, 10 April 2001
0.50
+96 -67
View File
@@ -2,8 +2,8 @@
// 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
//// This file is parsed by sed. You MUST use single line comments.
// i.e., //#define BB_BLAH
//
//
// BusyBox Applications
@@ -11,12 +11,15 @@
//#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP_MV
#define BB_CP
//#define BB_CPIO
#define BB_CUT
#define BB_DATE
//#define BB_DC
@@ -76,6 +79,7 @@
#define BB_MORE
#define BB_MOUNT
//#define BB_MT
#define BB_MV
//#define BB_NSLOOKUP
//#define BB_PING
//#define BB_PIVOT_ROOT
@@ -92,7 +96,7 @@
#define BB_RMDIR
//#define BB_RMMOD
//#define BB_ROUTE
//#define BB_RPMUNPACK
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SH
@@ -112,6 +116,7 @@
//#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
@@ -138,11 +143,51 @@
// 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
@@ -182,8 +227,8 @@
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
// 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
@@ -203,9 +248,9 @@
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//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_SIMPLE_TAIL
#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
@@ -216,15 +261,12 @@
// 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
//#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// use -i (interactive) flag for rm
//#define BB_FEATURE_RM_INTERACTIVE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
@@ -234,9 +276,12 @@
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
// 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
@@ -263,12 +308,11 @@
// Only relevant if BB_SH is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Some deeply embedded systems don't have usernames or even hostnames,
// and the default prompt can look rather hideous on them. Uncomment
// this option for a simpler, path-only prompt (which was the default until
// around BusyBox-0.48). On by default.
// 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_SIMPLE_PROMPT
//#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -285,6 +329,12 @@
// 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
//
@@ -303,7 +353,7 @@
// 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
//#define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
@@ -352,6 +402,9 @@
// 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
//
//
@@ -370,12 +423,32 @@
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#define BB_FEATURE_SH_SIMPLE_PROMPT
#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_SIMPLE_PROMPT
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
@@ -388,50 +461,10 @@
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#ifdef BB_DPKG
#ifndef BB_DPKG_DEB
#define BB_DPKG_DEB
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_IFCONFIG
#ifdef BB_FEATURE_IFCONFIG_STATUS
#define BB_INTERFACE
#endif
#else
#undef BB_INTERFACE
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
@@ -449,7 +482,3 @@
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_DOS2UNIX
#define BB_UNIX2DOS
#endif
-377
View File
@@ -1,377 +0,0 @@
/* vi: set sw=4 ts=4: */
// NOTE: This file only defines features usefull under the Hurd,
// To compile for the Hurd raname this to Config.h prior to make
// This file defines the feature set to be compiled into busybox.
// When you turn things off here, they won't be compiled in at all.
//
//// This file is parsed by sed. You MUST use single line comments.
// i.e. //#define BB_BLAH
//
//
// BusyBox Applications
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
//#define BB_CHVT /* not needed */
#define BB_CLEAR
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
//#define BB_DEALLOCVT /* inot needed */
//#define BB_DF /* different implementation */
#define BB_DIRNAME
//#define BB_DMESG /* doesnt compile, different implementation */
#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP /* not needed */
#define BB_ECHO
#define BB_EXPR
//#define BB_FBSET /* not needed, doesnt compile */
//#define BB_FDFLUSH /* is this needed? */
#define BB_FIND
//#define BB_FREE /* doesnt compile */
#define BB_FREERAMDISK /* does hurd support ramdisks ? */
#define BB_FSCK_MINIX
#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
#define BB_ID
//#define BB_INIT /* not needed?, doesnt compile */
//#define BB_INSMOD /* not needed, doesnt compile */
#define BB_KILL
#define BB_KILLALL
#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM /* not needed, doesnt compile */
//#define BB_LOADFONT /* not needed, doesnt compile */
//#define BB_LOADKMAP /* not needed */
#define BB_LOGGER
#define BB_LOGNAME
#define BB_LS
//#define BB_LSMOD /* not needed, doesnt compile */
//#define BB_MAKEDEVS /* different implementation */
#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
#define BB_MKNOD
//#define BB_MKSWAP /* different impelementation (i think) */
#define BB_MKTEMP
#define BB_NC
#define BB_MORE
//#define BB_MOUNT /* different implementation */
#define BB_MT
#define BB_NSLOOKUP
//#define BB_PING /* doesnt compile, Hurd uses BSD style ip.h */
//#define BB_POWEROFF /* different implementation i assume */
#define BB_PRINTF
//#define BB_PS /* needs /proc */
#define BB_PWD
#define BB_RDATE
//#define BB_REBOOT /* different implementation */
#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
//#define BB_RMMOD /* not needed, doesnt compile */
#define BB_SED
//#define BB_SETKEYCODES /* is this needed ? */
#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_SWAPONOFF /* different implementation, doesnt compile */
#define BB_SYNC
//#define BB_SYSLOGD /* doesnt compile */
#define BB_TAIL
#define BB_TAR
#define BB_TEE
#define BB_TEST
#define BB_TELNET
#define BB_TOUCH
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UPTIME /* doesnt compile */
#define BB_USLEEP
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
//#define BB_UMOUNT /* different implementation */
#define BB_UNIQ
//#define BB_UNAME /* doesnt compile */
//#define BB_UPDATE /* doesnt compile */
#define BB_YES
// End of Applications List
//
//
//
// ---------------------------------------------------------
// This is where feature definitions go. Generally speaking,
// turning this stuff off makes things a bit smaller (and less
// pretty/useful).
//
//
//
// Turn this on to use Erik's very cool devps and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. You can not use this and
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
// _must_ have patched the kernel to include the devps patch that is included
// in the busybox/kernel-patches directory. You will also need to create some
// device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// enable features that use the /proc filesystem (apps that
// break without this will tell you on compile)...
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
// at the same time...
#define BB_FEATURE_USE_PROCFS
//
// show verbose usage messages
#define BB_FEATURE_VERBOSE_USAGE
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// sort the file names (still a bit buggy)
#define BB_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// Change ping implementation -- simplified, featureless, but really small.
#define BB_FEATURE_SIMPLE_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
//#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f' support (only one file at a time.)
#define BB_FEATURE_SIMPLE_TAIL
//
// Enable support for loop devices in mount
//#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes
//#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// use -i (interactive) flag for rm
//#define BB_FEATURE_RM_INTERACTIVE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox commands as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell
//among other thing.
#define BB_FEATURE_SH_STANDALONE_SHELL
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// You must enable one or both of these features
// Support installing modules from pre 2.1 kernels
//#define BB_FEATURE_INSMOD_OLD_KERNEL
// Support installing modules from kernel versions after 2.1.18
#define BB_FEATURE_INSMOD_NEW_KERNEL
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
// #define BB_FEATURE_INSTALLER
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
#else
#undef BB_MTAB
#endif
//
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#define BB_FEATURE_SH_SIMPLE_PROMPT
#endif
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_SIMPLE_PROMPT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#ifdef BB_DPKG
#ifndef BB_DPKG_DEB
#define BB_DPKG_DEB
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_IFCONFIG
#ifdef BB_FEATURE_IFCONFIG_STATUS
#define BB_INTERFACE
#endif
#else
#undef BB_INTERFACE
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_DOS2UNIX
#define BB_UNIX2DOS
#endif
+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
+50 -33
View File
@@ -18,8 +18,8 @@
#
PROG := busybox
VERSION := 0.51
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
# With a modern GNU make(1) (highly recommended, that's what all the
@@ -37,19 +37,18 @@ DOSTATIC = false
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
# Do not enable this for production builds...
DODEBUG = false
# Setting this to `true' will cause busybox to directly use the system's
# password and group functions. Assuming you use GNU libc, when this is
# `true', you will need to install the /etc/nsswitch.conf configuration file
# and the required libnss_* libraries. This generally makes your embedded
# system quite a bit larger... If you leave this off, busybox will directly
# use the /etc/password, /etc/group files (and your system will be smaller, and
# I will get fewer emails asking about how glibc NSS works). Enabling this adds
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs),
# Most people will want to leave this set to false.
# 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/ )
@@ -212,7 +211,7 @@ endif
# And option 4:
-include applet_source_list
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o messages.o usage.o applets.o
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
@@ -235,24 +234,37 @@ endif
LIBBB = libbb
LIBBB_LIB = libbb.a
LIBBB_CSRC= ask_confirmation.c check_wildcard_match.c chomp.c copy_file.c \
copy_file_chunk.c create_path.c daemon.c device_open.c error_msg.c \
find_mount_point.c find_pid_by_name.c find_root_device.c full_read.c \
full_write.c get_console.c get_last_path_component.c get_line_from_file.c \
human_readable.c inode_hash.c isdirectory.c kernel_version.c loop.c \
mode_string.c parse_mode.c parse_number.c print_file.c process_escape_sequence.c \
my_getgrgid.c my_getpwnamegid.c my_getpwuid.c my_getgrnam.c my_getpwnam.c \
recursive_action.c safe_read.c safe_strncpy.c syscalls.c module_syscalls.c \
syslog_msg_with_name.c time_string.c trim.c vdprintf.c wfopen.c xfuncs.c \
xregcomp.c error_msg_and_die.c perror_msg.c perror_msg_and_die.c \
verror_msg.c vperror_msg.c mtab.c mtab_file.c xgetcwd.c concat_path_file.c
LIBBB_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.
@@ -263,7 +275,7 @@ CFLAGS += $(CFLAGS_EXTRA)
all: applet_source_list busybox busybox.links doc
applet_source_list: busybox.sh Config.h
(echo -n "APPLET_SOURCES := "; $(SHELL) $^ $(BB_SRC_DIR)) > $@
(echo -n "APPLET_SOURCES := "; BB_SRC_DIR=$(BB_SRC_DIR) $(SHELL) $^) > $@
doc: olddoc
@@ -296,7 +308,7 @@ docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
-@ mkdir -p docs/busybox.lineo.com
- pod2html --noindex $< > \
docs/busybox.lineo.com/BusyBox.html
-@ rm -f pod2html*
-@ rm -f pod2htm*
# New docs based on DOCBOOK SGML
@@ -327,7 +339,7 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(PWD_LIB) $(LIBBB_LIB) $(LIBRARIES)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBBB_LIB) $(PWD_LIB) $(LIBRARIES)
$(STRIP)
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
@@ -349,14 +361,24 @@ $(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_OBJS)
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
@@ -375,12 +397,12 @@ clean:
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
- rm -f multibuild.log Config.h.orig
- rm -rf docs/busybox _install libpwd.a libbb.a
- rm -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: install.sh busybox busybox.links
@@ -403,11 +425,6 @@ dist release: distclean doc
-print \
-exec rm -rf {} \; ; \
\
find busybox-$(VERSION)/ -type f \
-name .cvsignore \
-print \
-exec rm -f {} \; ; \
\
find busybox-$(VERSION)/ -type f \
-name .\#* \
-print \
+11 -12
View File
@@ -10,15 +10,6 @@ around to it some time. If you have any good ideas, please let me know.
netkit-tiny. Per discussions on the mailing list, this isn't going
to happen. False alarm. Sorry about the confusion.
* The busybox shell, lash, is really too weak for serious use, although it is
possible to run many simple systems with it. BusyBox 0.49 was supposed to
have a new shell, updated to understand full Bourne grammer. Well, that
simply didn't happen in time for the release. A rewrite is in progress
that will result in a new shell that understands the full Bourne grammar.
This new shell is being championed by Larry Doolittle
<ldoolitt@recycle.lbl.gov>, and could use your help. Please see the work
in progress at http://doolittle.faludi.com/~larry/parser.html and help
us out.
-Erik
@@ -27,12 +18,16 @@ around to it some time. If you have any good ideas, please let me know.
Possible apps to include some time:
* hwclock
* start-stop-daemon
* group/commonize strings, remove dups (for i18n, l10n)
-----------
Write a fixup_globals function to do just that right before calling
non-forking applets. Or, just always fork in the shell...
With sysvinit, reboot, poweroff and halt all used a named pipe,
/dev/initctl, to communicate with the init process. Busybox
currently uses signals to communicate with init. This makes
busybox incompatible with sysvinit. We should probably use
a named pipe as well so we can be compatible.
-----------------------
@@ -41,7 +36,7 @@ Run the following:
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
reveals the list of all external (i.e. libc) things that BusyBox depends on.
reveals the list of all external (i.e., libc) things that BusyBox depends on.
It would be a very nice thing to reduce this list to an absolute minimum, to
reduce the footprint of busybox, especially when staticly linking with
libraries such as uClibc.
@@ -55,4 +50,8 @@ and then start with the biggest things and make them smaller...
du.c probably ought to have an -x switch like GNU du does...
-----------------------
xargs could use a -l option
------------------------------------------------------------------
+11 -6
View File
@@ -35,10 +35,6 @@
#undef PROTOTYPES
#include "applets.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
struct BB_applet *applet_using;
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
@@ -78,7 +74,7 @@ static int applet_name_compare(const void *x, const void *y)
return strcmp(name, applet->name);
}
extern size_t NUM_APPLETS;
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
@@ -88,13 +84,22 @@ struct BB_applet *find_applet_by_name(const char *name)
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
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)
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;
}
+17 -11
View File
@@ -59,14 +59,14 @@
#ifdef BB_CAT
APPLET(cat, cat_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
APPLET(chgrp, chmod_chown_chgrp_main, _BB_DIR_BIN)
#ifdef BB_CHGRP
APPLET(chgrp, chgrp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
APPLET(chmod, chmod_chown_chgrp_main, _BB_DIR_BIN)
#ifdef BB_CHMOD
APPLET(chmod, chmod_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
APPLET(chown, chmod_chown_chgrp_main, _BB_DIR_BIN)
#ifdef BB_CHOWN
APPLET(chown, chown_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHROOT
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
@@ -80,8 +80,11 @@
#ifdef BB_CMP
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CP_MV
APPLET(cp, cp_mv_main, _BB_DIR_BIN)
#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)
@@ -269,8 +272,8 @@
#ifdef BB_MT
APPLET(mt, mt_main, _BB_DIR_BIN)
#endif
#ifdef BB_CP_MV
APPLET(mv, cp_mv_main, _BB_DIR_BIN)
#ifdef BB_MV
APPLET(mv, mv_main, _BB_DIR_BIN)
#endif
#ifdef BB_NC
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
@@ -323,6 +326,9 @@
#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
@@ -396,7 +402,7 @@
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UNIX2DOS
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
APPLET(unix2dos, unix2dos_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UPDATE
APPLET(update, update_main, _BB_DIR_SBIN)
+11 -6
View File
@@ -35,10 +35,6 @@
#undef PROTOTYPES
#include "applets.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
struct BB_applet *applet_using;
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
@@ -78,7 +74,7 @@ static int applet_name_compare(const void *x, const void *y)
return strcmp(name, applet->name);
}
extern size_t NUM_APPLETS;
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
@@ -88,13 +84,22 @@ struct BB_applet *find_applet_by_name(const char *name)
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
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)
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;
}
+8 -26
View File
@@ -5,11 +5,6 @@
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
#ifdef BB_LOCALE_SUPPORT
#include <locale.h>
#endif
@@ -42,21 +37,7 @@ typedef int (*__link_f)(const char *, const char *);
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
@@ -93,17 +74,18 @@ int main(int argc, char **argv)
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
/* Add in a special case hack for a leading hyphen */
if (**argv == '-' && *(*argv+1)!= '-') {
applet_name = "sh";
applet_name = (*argv+1);
}
#endif
#ifdef BB_LOCALE_SUPPORT
#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);
+1 -1
View File
@@ -9,7 +9,7 @@ RAW=` \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
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' ' '
+121 -91
View File
@@ -12,16 +12,15 @@
"\t-p timeconstant\n"
#define ar_trivial_usage \
"-[ovR]{ptx} archive filenames"
"-[ov][ptx] ARCHIVE FILES"
#define ar_full_usage \
"Extract or list files from an ar archive.\n\n" \
"Extract or list FILES from an ar archive.\n\n" \
"Options:\n" \
"\t-o\t\tpreserve original dates\n" \
"\t-p\t\textract to stdout\n" \
"\t-t\t\tlist\n" \
"\t-x\t\textract\n" \
"\t-v\t\tverbosely list files processed\n" \
"\t-R\t\trecursive action"
"\t-v\t\tverbosely list files processed\n"
#define basename_trivial_usage \
"FILE [SUFFIX]"
@@ -75,11 +74,12 @@
"-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n"
#define chown_trivial_usage \
"[OPTION]... OWNER[<.|:>[GROUP]] FILE..."
"[ -Rh ]... 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."
"\t-R\tChanges files and directories recursively.\n" \
"\t-h\tDo not dereference symbolic links."
#define chown_example_usage \
"$ ls -l /tmp/foo\n" \
"-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo\n" \
@@ -115,6 +115,7 @@
#define cmp_trivial_usage \
"FILE1 [FILE2]"
#define cmp_full_usage \
"\t-s\tquiet mode - do not print\n" \
"Compare files."
#define cp_trivial_usage \
@@ -128,6 +129,18 @@
"\t-f\tforce (implied; ignored) - always set\n" \
"\t-R\tCopies directories recursively"
#define cpio_trivial_usage \
"-[dimtuv][F cpiofile]"
#define cpio_full_usage \
"Extract or list files from a cpio archive\n" \
"Main operation mode:\n" \
"\td\t\tmake leading directories\n" \
"\ti\t\textract\n" \
"\tm\t\tpreserve mtime\n" \
"\tt\t\tlist\n" \
"\tu\t\tunconditional overwrite\t" \
"\tF\t\tinput from file\t"
#define cut_trivial_usage \
"[OPTION]... [FILE]..."
#define cut_full_usage \
@@ -163,7 +176,7 @@
#define dc_full_usage \
"This is a Tiny RPN calculator that understands the\n" \
"following operations: +, -, /, *, and, or, not, eor.\n" \
"i.e. 'dc 2 2 add' -> 4, and 'dc 8 8 \\* 2 2 + /' -> 16"
"i.e., 'dc 2 2 add' -> 4, and 'dc 8 8 \\* 2 2 + /' -> 16"
#define dc_example_usage \
"$ dc 2 2 +\n" \
"4\n" \
@@ -211,7 +224,7 @@
#define USAGE_NOT_HUMAN_READABLE(a) a
#endif
#define df_trivial_usage \
"[-" USAGE_HUMAN_READABLE("hm") USAGE_NOT_HUMAN_READABLE("") "k] [filesystem ...]"
"[-" USAGE_HUMAN_READABLE("hm") USAGE_NOT_HUMAN_READABLE("") "k] [FILESYSTEM ...]"
#define df_full_usage \
"Print the filesystem space used and space available.\n\n" \
"Options:\n" \
@@ -219,7 +232,7 @@
"\n\t-h\tprint sizes in human readable format (e.g., 1K 243M 2G )\n" \
"\t-m\tprint sizes in megabytes\n" \
"\t-k\tprint sizes in kilobytes(default)") USAGE_NOT_HUMAN_READABLE( \
"\n\t-k\tprint sizes in kilobytes(compatability)")
"\n\t-k\tprint sizes in kilobytes(compatibility)")
#define df_example_usage \
"$ df\n" \
"Filesystem 1k-blocks Used Available Use% Mounted on\n" \
@@ -249,30 +262,31 @@
"\t-s SIZE\t\tUse a buffer of size SIZE"
#define dos2unix_trivial_usage \
"[option] [file]"
"[option] [FILE]"
#define dos2unix_full_usage \
"Converts a text file to/from dos format to unix format.\n\n" \
"Converts FILE from dos format to unix format. When no option\n" \
"is given, the input is converted to the opposite output format.\n" \
"When no file is given, uses stdin for input and stdout for output.\n\n" \
"Options:\n" \
"\t-u\toutput will be in UNIX format\n" \
"\t-d\toutput will be in DOS format\n\n" \
"- when no option is given then input format will be automaticaly detected\n" \
" and converted to the oposite format on output\n" \
"- when no file is given, then stdin is used as input and stdout as output"
"\t-d\toutput will be in DOS format"
#define dpkg_trivial_usage \
"[-i|-r|--unpack|--configure] my.deb"
#define dpkg_full_usage \
"WORK IN PROGRESS, only usefull for debian-installer"
"WORK IN PROGRESS, only useful for debian-installer"
#define dpkg_deb_trivial_usage \
"[-cexX] file directory"
"[-cefItxX] FILE [argument]"
#define dpkg_deb_full_usage \
"Perform actions on debian packages (.debs)\n\n" \
"Options:\n" \
"\t-c\tList contents of filesystem tree (verbose)\n" \
"\t-l\tList contents of filesystem tree (.list format)\n" \
"\t-e\tExtract control files to directory\n" \
"\t-x\tExctract packages filesystem tree to directory\n" \
"\t-c\tList contents of filesystem tree\n" \
"\t-e\tExtract control files to [argument] directory\n" \
"\t-f\tDisplay control field name starting with [argument]\n" \
"\t-I\tDisplay the control filenamed [argument]\n" \
"\t-t\tExtract filesystem tree to stdout in tar format\n" \
"\t-x\tExtract packages filesystem tree to directory\n" \
"\t-X\tVerbose extract"
#define dpkg_deb_example_usage \
"$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
@@ -289,7 +303,7 @@
"\n\t-h\tprint sizes in human readable format (e.g., 1K 243M 2G )\n" \
"\t-m\tprint sizes in megabytes\n" \
"\t-k\tprint sizes in kilobytes(default)") USAGE_NOT_HUMAN_READABLE( \
"\n\t-k\tprint sizes in kilobytes(compatability)")
"\n\t-k\tprint sizes in kilobytes(compatibility)")
#define du_example_usage \
"$ du\n" \
"16 ./CVS\n" \
@@ -314,7 +328,7 @@
"[FILE]"
#define dutmp_full_usage \
"Dump utmp file format (pipe delimited) from FILE\n" \
"or stdin to stdout. (i.e. 'dutmp /var/run/utmp')"
"or stdin to stdout. (i.e., 'dutmp /var/run/utmp')"
#define dutmp_example_usage \
"$ dutmp /var/run/utmp\n" \
"8|7||si|||0|0|0|955637625|760097|0\n" \
@@ -331,20 +345,20 @@
"Prints 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\tinterpret backslash-escaped characters (i.e., \\t=tab)\n" \
"\t-E\tdisable interpretation of backslash-escaped characters"
#define echo_example_usage \
"$ echo "Erik is cool"\n" \
"Erik is cool\n" \
"$ echo -e "Erik\nis\ncool"\n" \
"$ echo -e "Erik\\nis\\ncool"\n" \
"Erik\n" \
"is\n" \
"cool\n" \
"$ echo "Erik\nis\ncool"\n" \
"Erik\nis\ncool\n"
"$ echo "Erik\\nis\\ncool"\n" \
"Erik\\nis\\ncool\n"
#define env_trivial_usage \
"[-] [-iu] [name=value ...] [command]"
"[-iu] [-] [name=value]... [command]"
#define env_full_usage \
"Prints the current environment or runs a program after setting\n" \
"up the specified environment.\n\n" \
@@ -437,7 +451,7 @@
"the current directory; default EXPRESSION is '-print'\n" \
"\nEXPRESSION may consist of:\n" \
"\t-follow\t\tDereference symbolic links.\n" \
"\t-name PATTERN\tFile name (leading directories removed) matches PATTERN." \
"\t-name PATTERN\tFile name (leading directories removed) matches PATTERN.\n" \
"\t-print\t\tPrint (default and assumed).\n" \
USAGE_FIND_TYPE( \
"\n\t-type X\t\tFiletype matches X (where X is one of: f,d,l,b,c,...)" \
@@ -515,7 +529,7 @@
"done\n"
#define grep_trivial_usage \
"[-ihHnqvs] pattern [files...]"
"[-ihHnqvs] PATTERN [FILEs...]"
#define grep_full_usage \
"Search for PATTERN in each FILE or standard input.\n\n" \
"Options:\n" \
@@ -556,11 +570,11 @@
"\t-c\tWrite output to standard output instead of FILE.gz\n" \
"\t-d\tdecompress"
#define gzip_example_usage \
"$ ls -la /tmp/BusyBox*\n" \
"-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n" \
"$ gzip /tmp/BusyBox-0.43.tar\n" \
"$ ls -la /tmp/BusyBox*\n" \
"-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/BusyBox-0.43.tar.gz\n"
"$ ls -la /tmp/busybox*\n" \
"-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/busybox.tar\n" \
"$ gzip /tmp/busybox.tar\n" \
"$ ls -la /tmp/busybox*\n" \
"-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/busybox.tar.gz\n"
#define halt_trivial_usage \
""
@@ -586,10 +600,10 @@
"Print out a unique 32-bit identifier for the machine."
#define hostname_trivial_usage \
"[OPTION] {hostname | -F file}"
"[OPTION] {hostname | -F FILE}"
#define hostname_full_usage \
"Get or set the hostname or DNS domain name. If a hostname is given\n" \
"(or a file with the -F parameter), the host name will be set.\n\n" \
"(or FILE with the -F parameter), the host name will be set.\n\n" \
"Options:\n" \
"\t-s\t\tShort\n" \
"\t-i\t\tAddresses for the hostname\n" \
@@ -597,7 +611,7 @@
"\t-F, --file FILE\tUse the contents of FILE to specify the hostname"
#define hostname_example_usage \
"$ hostname\n" \
"slag \n"
"sage \n"
#define id_trivial_usage \
"[OPTIONS]... [USERNAME]"
@@ -710,7 +724,7 @@
" sysinit actions are completed before continuing. Following the\n" \
" completion of all sysinit actions, all 'wait' actions are run.\n" \
" 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \
" the specified task completes. 'once' actions are asyncronous,\n" \
" the specified task completes. 'once' actions are asynchronous,\n" \
" therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \
" actions are run when the system detects that someone on the system\n" \
" console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \
@@ -820,7 +834,7 @@
#define length_full_usage \
"Prints out the length of the specified STRING."
#define length_example_usage \
"$ length "Hello"\n" \
"$ length Hello\n" \
"5\n"
#define ln_trivial_usage \
@@ -946,7 +960,7 @@
USAGE_HUMAN_READABLE( \
"\t-h\tprint sizes in human readable format (e.g., 1K 243M 2G )\n" \
"\t-k\tprint sizes in kilobytes(default)") USAGE_NOT_HUMAN_READABLE( \
"\t-k\tprint sizes in kilobytes(compatability)")
"\t-k\tprint sizes in kilobytes(compatibility)")
#define lsmod_trivial_usage \
""
@@ -1000,7 +1014,7 @@
#define mkdir_trivial_usage \
"[OPTION] DIRECTORY..."
#define mkdir_full_usage \
"Create the DIRECTORY(ies), if they do not already exist\n\n" \
"Create the DIRECTORY(ies) if they do not already exist\n\n" \
"Options:\n" \
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" \
"\t-p\tno error if existing, make parent directories as needed"
@@ -1058,7 +1072,7 @@
"[-q] TEMPLATE"
#define mktemp_full_usage \
"Creates a temporary file with its name based on TEMPLATE.\n" \
"TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX)."
"TEMPLATE is any name with six `Xs' (i.e., /tmp/temp.XXXXXX)."
#define mktemp_example_usage \
"$ mktemp /tmp/temp.XXXXXX\n" \
"/tmp/temp.mWiLjM\n" \
@@ -1083,7 +1097,7 @@
#define USAGE_MTAB(a)
#endif
#define mount_trivial_usage \
"[flags] device directory [-o options,more-options]"
"[flags] DEVICE NODE [-o options,more-options]"
#define mount_full_usage \
"Mount a filesystem\n\n" \
"Flags:\n" \
@@ -1108,8 +1122,9 @@
"\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n" \
"\tremount:\tRe-mount a mounted filesystem, changing its flags.\n" \
"\tro/rw:\t\tMount for read-only / read-write.\n" \
"\tbind:\t\tUse the linux 2.4.x \"bind\" feature.\n" \
"\nThere are EVEN MORE flags that are specific to each filesystem.\n" \
"You'll have to see the written documentation for those."
"You'll have to see the written documentation for those filesystems."
#define mount_example_usage \
"$ mount\n" \
"/dev/hda3 on / type minix (rw)\n" \
@@ -1151,9 +1166,10 @@
"221 foobar closing connection\n"
#define nslookup_trivial_usage \
"[HOST]"
"[HOST] [SERVER]"
#define nslookup_full_usage \
"Queries the nameserver for the IP address of the given HOST"
"Queries the nameserver for the IP address of the given HOST\n" \
"optionally using a specified DNS server"
#define nslookup_example_usage \
"$ nslookup localhost\n" \
"Server: default\n" \
@@ -1162,7 +1178,7 @@
"Name: debian\n" \
"Address: 127.0.0.1\n"
#ifdef BB_FEATURE_SIMPLE_PING
#ifndef BB_FEATURE_FANCY_PING
#define ping_trivial_usage "host"
#define ping_full_usage "Send ICMP ECHO_REQUEST packets to network hosts"
#else
@@ -1186,9 +1202,9 @@
"round-trip min/avg/max = 20.1/20.1/20.1 ms\n"
#define pivot_root_trivial_usage \
"new_root put_old"
"NEW_ROOT PUT_OLD"
#define pivot_root_full_usage \
"Move the current root file system to put_old and make new_root\n" \
"Move the current root file system to PUT_OLD and make NEW_ROOT\n" \
"the new root file system."
#define poweroff_trivial_usage \
@@ -1202,7 +1218,7 @@
"Formats and prints ARGUMENT(s) according to FORMAT,\n" \
"Where FORMAT controls the output exactly as in C printf."
#define printf_example_usage \
"$ printf "Val=%d\n" 5\n" \
"$ printf "Val=%d\\n" 5\n" \
"Val=5\n"
#define ps_trivial_usage \
@@ -1261,18 +1277,13 @@
#define reset_full_usage \
"Resets the screen."
#ifdef BB_FEATURE_RM_INTERACTIVE
#define USAGE_RM_INTERACTIVE(a) a
#else
#define USAGE_RM_INTERACTIVE(a)
#endif
#define rm_trivial_usage \
"[OPTION]... FILE..."
#define rm_full_usage \
"Remove (unlink) the FILE(s). You may use '--' to\n" \
"indicate that all following arguments are non-options.\n\n" \
"Options:\n" \
USAGE_RM_INTERACTIVE("\t-i\t\talways prompt before removing each destinations\n") \
"\t-i\t\talways prompt before removing each destination" \
"\t-f\t\tremove existing destinations, never prompt\n" \
"\t-r or -R\tremove the contents of directories recursively"
#define rm_example_usage \
@@ -1299,19 +1310,23 @@
#define route_full_usage \
"Edit the kernel's routing tables"
#define rpm2cpio_trivial_usage \
"package.rpm"
#define rpm2cpio_full_usage \
"Outputs a cpio archive of the rpm file."
#define rpmunpack_trivial_usage \
"< package.rpm | gunzip | cpio -idmuv"
#define rpmunpack_full_usage \
"Extracts an rpm archive."
#define sed_trivial_usage \
"[-Vhnef] pattern [files...]"
"[-nef] pattern [files...]"
#define sed_full_usage \
"Options:\n" \
"\t-n\t\tsuppress automatic printing of pattern space\n" \
"\t-e script\tadd the script to the commands to be executed\n" \
"\t-f scriptfile\tadd the contents of script-file to the commands to be executed\n" \
"\t-h\t\tdisplay this help message\n" \
"\n" \
"If no -e or -f is given, the first non-option argument is taken as the\n" \
"sed script to interpret. All remaining arguments are names of input\n" \
@@ -1354,17 +1369,26 @@
"[2 second delay results]\n"
#ifdef BB_FEATURE_SORT_UNIQUE
#define USAGE_SORT_UNIQUE(a) a
#else
#define USAGE_SORT_UNIQUE(a)
#endif
#ifdef BB_FEATURE_SORT_REVERSE
#define USAGE_SORT_REVERSE(a) a
#else
#define USAGE_SORT_REVERSE(a)
#endif
#define sort_trivial_usage \
"[-n]" USAGE_SORT_REVERSE(" [-r]") " [FILE]..."
"[-n" USAGE_SORT_REVERSE("r") USAGE_SORT_UNIQUE("u") "] [FILE]..."
#define sort_full_usage \
"Sorts lines of text in the specified files"
"Sorts lines of text in the specified files\n\n"\
"Options:\n" \
USAGE_SORT_UNIQUE("\t-u\tsuppress duplicate lines\n") \
USAGE_SORT_REVERSE("\t-r\tsort in reverse order\n") \
"\t-n\tsort numerics"
#define sort_example_usage \
"$ echo -e "e\nf\nb\nd\nc\na" | sort\n" \
"$ echo -e \"e\\nf\\nb\\nd\\nc\\na\" | sort\n" \
"a\n" \
"b\n" \
"c\n" \
@@ -1373,27 +1397,27 @@
"f\n"
#define stty_trivial_usage \
"[-a|g] [-F device] [SETTING]..."
"[-a|g] [-F DEVICE] [SETTING]..."
#define stty_full_usage \
"Without arguments, prints baud rate, line discipline," \
"\nand deviations from stty sane." \
"\n\nOptions:" \
"\n\t-F device\topen device instead of stdin" \
"\n\t-F DEVICE\topen device instead of stdin" \
"\n\t-a\t\tprint all current settings in human-readable form" \
"\n\t-g\t\tprint in stty-readable form" \
"\n\t[SETTING]\tsee documentation"
"\n\t[SETTING]\tsee manpage"
#define swapoff_trivial_usage \
"[OPTION] [device]"
"[OPTION] [DEVICE]"
#define swapoff_full_usage \
"Stop swapping virtual memory pages on the given device.\n\n" \
"Stop swapping virtual memory pages on DEVICE.\n\n" \
"Options:\n" \
"\t-a\tStop swapping on all swap devices"
#define swapon_trivial_usage \
"[OPTION] [device]"
"[OPTION] [DEVICE]"
#define swapon_full_usage \
"Start swapping virtual memory pages on the given device.\n\n" \
"Start swapping virtual memory pages on DEVICE.\n\n" \
"Options:\n" \
"\t-a\tStart swapping on all swap devices"
@@ -1425,7 +1449,7 @@
"$ syslogd -R 192.168.1.1:601\n"
#ifdef BB_FEATURE_SIMPLE_TAIL
#ifndef BB_FEATURE_FANCY_TAIL
#define USAGE_UNSIMPLE_TAIL(a)
#else
#define USAGE_UNSIMPLE_TAIL(a) a
@@ -1462,22 +1486,22 @@
#endif
#define tar_trivial_usage \
"-[" USAGE_TAR_CREATE("c") "xtvO] " \
USAGE_TAR_EXCLUDE("[--exclude File] [-X File]") \
"[-f tarFile] [FILE(s)] ..."
USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \
"[-f TARFILE] [-C DIR] [FILE(s)] ..."
#define tar_full_usage \
"Create, extract, or list files from a tar file.\n\n" \
"Main operation mode:\n" \
"Options:\n" \
USAGE_TAR_CREATE("\tc\t\tcreate\n") \
"\tx\t\textract\n" \
"\tt\t\tlist\n" \
"\nFile selection:\n" \
"\tf\t\tname of tarfile or \"-\" for stdin\n" \
"\tf\t\tname of TARFILE or \"-\" for stdin\n" \
"\tO\t\textract to stdout\n" \
USAGE_TAR_EXCLUDE( \
"\texclude\t\tfile to exclude\n" \
"\tX\t\tfile with names to exclude\n" \
) \
"\nInformative output:\n" \
"\tC\t\tchange to directory DIR before operation\n" \
"\tv\t\tverbosely list files processed"
#define tar_example_usage \
"$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \
@@ -1495,7 +1519,7 @@
"Hello\n"
#define telnet_trivial_usage \
"host [port]"
"HOST [PORT]"
#define telnet_full_usage \
"Telnet is used to establish interactive communication with another\n"\
"computer over a network using the TELNET protocol."
@@ -1541,12 +1565,12 @@
USAGE_TFTP_PUT( \
"\tput\tPut local file SOURCE to server DEST.\n" \
) \
"\nWhen nameing a server, use the syntax \"server:file\"."
"\nWhen naming a server, use the syntax \"server:file\"."
#define touch_trivial_usage \
"[-c] file [file ...]"
"[-c] FILE [FILE ...]"
#define touch_full_usage \
"Update the last-modified date on the given file[s].\n\n" \
"Update the last-modified date on the given FILE[s].\n\n" \
"Options:\n" \
"\t-c\tDo not create any files"
#define touch_example_usage \
@@ -1594,14 +1618,14 @@
#define USAGE_MOUNT_FORCE(a)
#endif
#define umount_trivial_usage \
"[flags] filesystem|directory"
"[flags] FILESYSTEM|DIRECTORY"
#define umount_full_usage \
"Unmount file systems\n" \
"\nFlags:\n" "\t-a:\tUnmount all file systems" \
USAGE_MTAB(" in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries") \
"\n\t-r:\tTry to remount devices as read-only if mount is busy" \
USAGE_MOUNT_FORCE("\n\t-f:\tForce filesystem umount (i.e. unreachable NFS server)") \
USAGE_MOUNT_LOOP("\n\t-l:\tDo not free loop device (if a loop device has been used)")
"\nFlags:\n" "\t-a\tUnmount all file systems" \
USAGE_MTAB(" in /etc/mtab\n\t-n\tDon't erase /etc/mtab entries") \
"\n\t-r\tTry to remount devices as read-only if mount is busy" \
USAGE_MOUNT_FORCE("\n\t-f\tForce umount (i.e., unreachable NFS server)") \
USAGE_MOUNT_LOOP("\n\t-l\tDo not free loop device (if a loop device has been used)")
#define umount_example_usage \
"$ umount /dev/hdc1 \n"
@@ -1631,15 +1655,20 @@
"\t-d\tonly print duplicate lines\n" \
"\t-u\tonly print unique lines"
#define uniq_example_usage \
"$ echo -e "a\na\nb\nc\nc\na" | sort | uniq\n" \
"$ echo -e \"a\\na\\nb\\nc\\nc\\na\" | sort | uniq\n" \
"a\n" \
"b\n" \
"c\n"
#define unix2dos_trivial_usage \
"[option] [file]"
"[option] [FILE]"
#define unix2dos_full_usage \
"See 'dos2unix --help' for help!"
"Converts FILE from unix format to dos format. When no option\n" \
"is given, the input is converted to the opposite output format.\n" \
"When no file is given, uses stdin for input and stdout for output.\n" \
"Options:\n" \
"\t-u\toutput will be in UNIX format\n" \
"\t-d\toutput will be in DOS format"
#define update_trivial_usage \
"[options]"
@@ -1682,7 +1711,7 @@
#define uuencode_full_usage \
"Uuencode a file.\n\n" \
"Options:\n" \
"\t-m\tuse base64 encoding as of RFC1521"
"\t-m\tuse base64 encoding per RFC1521"
#define uuencode_example_usage \
"$ uuencode busybox busybox\n" \
"begin 755 busybox\n" \
@@ -1717,12 +1746,13 @@
" 31 46 1365 /etc/passwd\n"
#define wget_trivial_usage \
"[-c] [-O file] url"
"[-c|--continue] [-q|--quiet] [-O|--output-document file]\n\t[--header 'header: value'] [-P DIR] url"
#define wget_full_usage \
"wget retrieves files via HTTP or FTP\n\n" \
"Options:\n" \
"\t-c\tcontinue retrieval of aborted transfers\n" \
"\t-q\tquiet mode - do not print\n" \
"\t-P\tSet directory prefix to DIR\n" \
"\t-O\tsave to filename ('-' for stdout)"
#define which_trivial_usage \
+31 -169
View File
@@ -23,144 +23,38 @@
*
*/
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
typedef struct ar_headers_s {
char *name;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
/*
* return the headerL_t struct for the filename descriptor
*/
extern ar_headers_t get_ar_headers(int srcFd)
{
typedef struct raw_ar_header_s { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6];
char gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} raw_ar_header_t;
raw_ar_header_t raw_ar_header;
ar_headers_t *head, *entry;
char ar_magic[8];
char *long_name=NULL;
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
/* check ar magic */
if (full_read(srcFd, ar_magic, 8) != 8) {
error_msg_and_die("cannot read magic");
}
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
/* check the end of header markers are valid */
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
char newline;
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, &newline, 1);
if (newline!='\n') {
break;
}
/* fix up the header, we started reading 1 byte too early due to a '\n' */
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
/* dont worry about adding the last '\n', we dont need it now */
}
entry->size = (off_t) atoi(raw_ar_header.size);
/* long filenames have '/' as the first character */
if (raw_ar_header.name[0] == '/') {
if (raw_ar_header.name[1] == '/') {
/* multiple long filenames are stored as data in one entry */
long_name = (char *) xrealloc(long_name, entry->size);
full_read(srcFd, long_name, entry->size);
continue;
}
else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
strcpy(entry->name, &long_name[long_name_offset]);
}
}
else {
/* short filenames */
entry->name = xmalloc(16);
strncpy(entry->name, raw_ar_header.name, 16);
}
entry->name[strcspn(entry->name, " /")]='\0';
/* convert the rest of the now valid char header to its typed struct */
parse_mode(raw_ar_header.mode, &entry->mode);
entry->mtime = atoi(raw_ar_header.date);
entry->uid = atoi(raw_ar_header.uid);
entry->gid = atoi(raw_ar_header.gid);
entry->offset = lseek(srcFd, 0, SEEK_CUR);
/* add this entries header to our combined list */
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*entry->next = *head;
*head = *entry;
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
}
return(*head);
}
extern int ar_main(int argc, char **argv)
{
const int preserve_date = 1; /* preserve original dates */
const int verbose = 2; /* be verbose */
const int display = 4; /* display contents */
const int extract_to_file = 8; /* extract contents of archive */
const int extract_to_stdout = 16; /* extract to stdout */
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
ar_headers_t head, *extract_list=NULL;
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
FILE *src_stream = NULL;
char **extract_names = NULL;
char ar_magic[8];
int extract_function = extract_unconditional;
int opt;
int num_of_entries = 0;
extern off_t archive_offset;
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct |= preserve_date;
extract_function |= extract_preserve_date;
break;
case 'v':
funct |= verbose;
extract_function |= extract_verbose_list;
break;
case 't':
funct |= display;
extract_function |= extract_list;
break;
case 'p':
funct |= extract_to_stdout;
extract_function |= extract_to_stdout;
break;
case 'x':
funct |= extract_to_file;
extract_function |= extract_all_to_fs;
break;
default:
show_usage();
@@ -168,60 +62,28 @@ extern int ar_main(int argc, char **argv)
}
/* check the src filename was specified */
if (optind == argc)
if (optind == argc) {
show_usage();
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s", argv[optind]);
optind++;
head = get_ar_headers(srcFd);
/* find files to extract or display */
/* search through argv and build extract list */
for (;optind<argc; optind++) {
ar_headers_t *ar_entry;
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
ar_entry = &head;
while (ar_entry->next != NULL) {
if (strcmp(argv[optind], ar_entry->name) == 0) {
ar_headers_t *tmp;
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*tmp = *extract_list;
*extract_list = *ar_entry;
extract_list->next = tmp;
break;
}
ar_entry=ar_entry->next;
}
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
src_stream = xfopen(argv[optind++], "r");
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (off_t) extract_list->size);
}
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
(int) extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
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;
}
+31 -169
View File
@@ -23,144 +23,38 @@
*
*/
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
typedef struct ar_headers_s {
char *name;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
/*
* return the headerL_t struct for the filename descriptor
*/
extern ar_headers_t get_ar_headers(int srcFd)
{
typedef struct raw_ar_header_s { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6];
char gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} raw_ar_header_t;
raw_ar_header_t raw_ar_header;
ar_headers_t *head, *entry;
char ar_magic[8];
char *long_name=NULL;
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
/* check ar magic */
if (full_read(srcFd, ar_magic, 8) != 8) {
error_msg_and_die("cannot read magic");
}
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
/* check the end of header markers are valid */
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
char newline;
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, &newline, 1);
if (newline!='\n') {
break;
}
/* fix up the header, we started reading 1 byte too early due to a '\n' */
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
/* dont worry about adding the last '\n', we dont need it now */
}
entry->size = (off_t) atoi(raw_ar_header.size);
/* long filenames have '/' as the first character */
if (raw_ar_header.name[0] == '/') {
if (raw_ar_header.name[1] == '/') {
/* multiple long filenames are stored as data in one entry */
long_name = (char *) xrealloc(long_name, entry->size);
full_read(srcFd, long_name, entry->size);
continue;
}
else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
strcpy(entry->name, &long_name[long_name_offset]);
}
}
else {
/* short filenames */
entry->name = xmalloc(16);
strncpy(entry->name, raw_ar_header.name, 16);
}
entry->name[strcspn(entry->name, " /")]='\0';
/* convert the rest of the now valid char header to its typed struct */
parse_mode(raw_ar_header.mode, &entry->mode);
entry->mtime = atoi(raw_ar_header.date);
entry->uid = atoi(raw_ar_header.uid);
entry->gid = atoi(raw_ar_header.gid);
entry->offset = lseek(srcFd, 0, SEEK_CUR);
/* add this entries header to our combined list */
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*entry->next = *head;
*head = *entry;
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
}
return(*head);
}
extern int ar_main(int argc, char **argv)
{
const int preserve_date = 1; /* preserve original dates */
const int verbose = 2; /* be verbose */
const int display = 4; /* display contents */
const int extract_to_file = 8; /* extract contents of archive */
const int extract_to_stdout = 16; /* extract to stdout */
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
ar_headers_t head, *extract_list=NULL;
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
FILE *src_stream = NULL;
char **extract_names = NULL;
char ar_magic[8];
int extract_function = extract_unconditional;
int opt;
int num_of_entries = 0;
extern off_t archive_offset;
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct |= preserve_date;
extract_function |= extract_preserve_date;
break;
case 'v':
funct |= verbose;
extract_function |= extract_verbose_list;
break;
case 't':
funct |= display;
extract_function |= extract_list;
break;
case 'p':
funct |= extract_to_stdout;
extract_function |= extract_to_stdout;
break;
case 'x':
funct |= extract_to_file;
extract_function |= extract_all_to_fs;
break;
default:
show_usage();
@@ -168,60 +62,28 @@ extern int ar_main(int argc, char **argv)
}
/* check the src filename was specified */
if (optind == argc)
if (optind == argc) {
show_usage();
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s", argv[optind]);
optind++;
head = get_ar_headers(srcFd);
/* find files to extract or display */
/* search through argv and build extract list */
for (;optind<argc; optind++) {
ar_headers_t *ar_entry;
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
ar_entry = &head;
while (ar_entry->next != NULL) {
if (strcmp(argv[optind], ar_entry->name) == 0) {
ar_headers_t *tmp;
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*tmp = *extract_list;
*extract_list = *ar_entry;
extract_list->next = tmp;
break;
}
ar_entry=ar_entry->next;
}
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
src_stream = xfopen(argv[optind++], "r");
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (off_t) extract_list->size);
}
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
(int) extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
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;
}
+245 -239
View File
@@ -1,3 +1,4 @@
#include <ctype.h>
#include <dirent.h>
#include <getopt.h>
#include <stdio.h>
@@ -13,14 +14,13 @@
#include "busybox.h"
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
/* Should we do full dependency checking? */
#define DODEPENDS 1
//#define DODEPENDS 0
/* Should we do debugging? */
//#define DODEBUG 1
//#define DODEBUG 0
#ifdef DODEBUG
#define SYSTEM(x) do_system(x)
@@ -31,64 +31,69 @@
#endif
/* from dpkg-deb.c */
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename);
static const int dpkg_deb_contents = 1;
static const int dpkg_deb_control = 2;
// const int dpkg_deb_info = 4;
static const int dpkg_deb_extract = 8;
static const int dpkg_deb_verbose_extract = 16;
static const int dpkg_deb_list = 32;
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 dpkgcidir[] = "/var/lib/dpkg/tmp.ci/";
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 status_want_install = 2;
//static const int status_want_hold = 3;
//static const int status_want_deinstall = 4;
//static const int status_want_purge = 5;
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 status_flag_ok = 1;
//static const int status_flag_reinstreq = 2;
//static const int status_flag_hold = 3;
//static const int status_flag_holdreinstreq = 4;
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 status_statusnoninstalled = 1;
static const int status_status_unpacked = 2;
static const int status_status_halfconfigured = 3;
static const int status_status_installed = 4;
static const int status_status_halfinstalled = 5;
//static const int status_statusconfigfiles = 6;
//static const int status_statuspostinstfailed = 7;
//static const int status_statusremovalfailed = 8;
//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 *status_words_want[] = { "unknown", "install", "hold", "deinstall", "purge", 0 };
static const char *status_words_flag[] = { "ok", "reinstreq", "hold", "hold-reinstreq", 0 };
static const char *status_words_status[] = { "not-installed", "unpacked", "half-configured", "installed",
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 */
/* data structures */
typedef struct package_s {
char *file;
char *filename;
char *package;
char *version;
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;
unsigned char status_want;
unsigned char status_flag;
unsigned char status_status;
char color; /* for topo-sort */
struct package_s *requiredfor[DEPENDSMAX];
unsigned short requiredcount;
@@ -111,39 +116,7 @@ static int package_compare(const void *p1, const void *p2)
((package_t *)p2)->package);
}
/*
* NOTE: this was handled by a "rm -rf" shell command
* Maybe theis behaviour should be integrated into the rm applet
* (i dont appreciate the rm applets recursive action fn)-bug1
*/
static int remove_dir(const char *dirname)
{
struct dirent *fp;
DIR *dp = opendir(dirname);
while ((fp = readdir(dp)) != NULL) {
struct stat statbuf;
char *filename;
filename = (char *) xcalloc(1, strlen(dirname) + strlen(fp->d_name) + 2);
strcpy(filename, dirname);
strcat(filename, fp->d_name);
lstat(filename, &statbuf);
if ((strcmp(fp->d_name, ".") != 0) && (strcmp(fp->d_name, "..") != 0)) {
if (S_ISDIR(statbuf.st_mode)) {
remove_dir(strcat(filename, "/"));
}
else if (remove(filename) == -1) {
perror_msg(filename);
}
}
}
remove(dirname);
return EXIT_SUCCESS;
}
#ifdef DODEPENDS
#include <ctype.h>
static char **depends_split(const char *dependsstr)
{
@@ -265,8 +238,8 @@ static package_t *depends_resolve(package_t *pkgs, void *status)
/* 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->status_flag & status_flag_ok) &&
(chk->status_status & status_status_installed))) {
((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 */
@@ -328,55 +301,182 @@ static unsigned char status_parse(const char *line, const char **status_words)
}
/*
* Read a control file (or a stanza of a status file) and parse it,
* Read the buffered control file and parse it,
* filling parsed fields into the package structure
*/
static int control_read(FILE *file, package_t *p)
static int fill_package_struct(package_t *package, const char *package_buffer)
{
char *line;
char *field = NULL;
int field_start = 0;
int field_length = 0;
while ((line = get_line_from_file(file)) != NULL) {
line[strlen(line) - 1] = '\0';
while ((field = read_package_field(&package_buffer[field_start])) != NULL) {
field_length = strlen(field);
field_start += (field_length + 1);
if (strlen(line) == 0) {
if (strlen(field) == 0) {
printf("empty line: *this shouldnt happen i dont think*\n");
break;
}
else if (strstr(line, "Package: ") == line) {
p->package = xstrdup(line + 9);
/* these are common to both installed and uninstalled packages */
if (strstr(field, "Package: ") == field) {
package->package = strdup(field + 9);
}
else if (strstr(line, "Status: ") == line) {
char *word_pointer;
word_pointer = strchr(line, ' ') + 1;
p->status_want = status_parse(word_pointer, status_words_want);
word_pointer = strchr(word_pointer, ' ') + 1;
p->status_flag = status_parse(word_pointer, status_words_flag);
word_pointer = strchr(word_pointer, ' ') + 1;
p->status_status = status_parse(word_pointer, status_words_status);
else if (strstr(field, "Depends: ") == field) {
package->depends = strdup(field + 9);
}
else if (strstr(line, "Depends: ") == line) {
p->depends = xstrdup(line + 9);
else if (strstr(field, "Provides: ") == field) {
package->provides = strdup(field + 10);
}
else if (strstr(line, "Provides: ") == line) {
p->provides = xstrdup(line + 10);
}
else if (strstr(line, "Description: ") == line) {
p->description = xstrdup(line + 13);
/* 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(line, "installer-menu-item: ") == line) {
p->installer_menu_item = atoi(line + 21);
else if (strstr(field, "Description: ") == field) {
package->description = strdup(field + 13);
}
/* TODO: localized descriptions */
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);
}
free(line);
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");
@@ -386,9 +486,9 @@ static void *status_read(void)
return(NULL);
}
while (!feof(f)) {
while ( (package_control_buffer = fgets_str(f, "\n\n")) != NULL) {
m = (package_t *)xcalloc(1, sizeof(package_t));
control_read(f, m);
fill_package_struct(m, package_control_buffer);
if (m->package) {
/*
* If there is an item in the tree by this name,
@@ -418,9 +518,9 @@ static void *status_read(void)
* packages of different statuses
* provide it).
*/
t->status_want = m->status_want;
t->status_flag = m->status_flag;
t->status_status = m->status_status;
t->state_want = m->state_want;
t->state_flag = m->state_flag;
t->state_status = m->state_status;
}
}
}
@@ -451,7 +551,7 @@ static int status_merge(void *status, package_t *pkgs)
*/
if ((fin = fopen(statusfile, "r")) != NULL) {
while (((line = get_line_from_file(fin)) != NULL) && !feof(fin)) {
line[strlen(line) - 1] = '\0'; /* trim newline */
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).
@@ -479,9 +579,9 @@ static int status_merge(void *status, package_t *pkgs)
}
if (strstr(line, "Status: ") == line && statpkg != 0) {
snprintf(line, sizeof(line), "Status: %s %s %s",
status_words_want[statpkg->status_want - 1],
status_words_flag[statpkg->status_flag - 1],
status_words_status[statpkg->status_status - 1]);
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);
}
@@ -491,20 +591,7 @@ static int status_merge(void *status, package_t *pkgs)
// Print out packages we processed.
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
fprintf(fout, "Package: %s\nStatus: %s %s %s\n",
pkg->package, status_words_want[pkg->status_want - 1],
status_words_flag[pkg->status_flag - 1],
status_words_status[pkg->status_status - 1]);
if (pkg->depends)
fprintf(fout, "Depends: %s\n", pkg->depends);
if (pkg->provides)
fprintf(fout, "Provides: %s\n", pkg->provides);
if (pkg->installer_menu_item)
fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
if (pkg->description)
fprintf(fout, "Description: %s\n", pkg->description);
fputc('\n', fout);
write_package(fout, pkg);
}
fclose(fout);
@@ -544,144 +631,70 @@ static int dpkg_doconfigure(package_t *pkg)
char buf[1024];
DPRINTF("Configuring %s\n", pkg->package);
pkg->status_status = 0;
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->status_status = status_status_halfconfigured;
pkg->state_status = state_status_halfconfigured;
return 1;
}
}
pkg->status_status = status_status_installed;
pkg->state_status = state_status_installed;
return 0;
}
static int dpkg_dounpack(package_t *pkg)
{
int r = 0, i;
FILE *out_stream;
char *info_prefix;
int status = TRUE;
char *cwd = xgetcwd(0);
char *src_file = NULL;
char *dst_file = NULL;
// char *lst_file = NULL;
char *adminscripts[] = { "prerm", "postrm", "preinst", "postinst",
"conffiles", "md5sums", "shlibs", "templates" };
int r = 0;
DPRINTF("Unpacking %s\n", pkg->package);
if(cwd==NULL)
exit(EXIT_FAILURE);
chdir("/");
deb_extract(dpkg_deb_extract, "/", pkg->file);
/* extract the data file */
deb_extract(pkg->filename, stdout, (extract_data_tar_gz | extract_all_to_fs), "/", NULL);
/* Installs the package scripts into the info directory */
for (i = 0; i < sizeof(adminscripts) / sizeof(adminscripts[0]); i++) {
struct stat src_stat_buf;
int src_fd = 0, dst_fd = 0;
/* 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);
/* The full path of the current location of the admin file */
src_file = xrealloc(src_file, strlen(dpkgcidir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
sprintf(src_file, "%s%s/%s", dpkgcidir, pkg->package, adminscripts[i]);
/* 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);
/* the full path of where we want the file to be copied to */
dst_file = xrealloc(dst_file, strlen(infodir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
sprintf(dst_file, "%s%s.%s", infodir, pkg->package, adminscripts[i]);
/*
* copy admin file to permanent home
* NOTE: Maybe merge this behaviour into libb/copy_file.c
*/
if (lstat(src_file, &src_stat_buf) == 0) {
if ((src_fd = open(src_file, O_RDONLY)) != -1) {
if ((dst_fd = open(dst_file, O_WRONLY | O_CREAT, 0644)) == -1) {
status = FALSE;
perror_msg("Opening %s", dst_file);
}
copy_file_chunk(src_fd, dst_fd, src_stat_buf.st_size);
close(src_fd);
close(dst_fd);
} else {
status = FALSE;
error_msg("couldnt open [%s]\n", src_file);
}
}
}
/*
* create the list file
* FIXME: currently this dumps the lst to stdout instead of a file
*/
/* lst_file = (char *) xmalloc(strlen(infodir) + strlen(pkg->package) + 6);
strcpy(lst_file, infodir);
strcat(lst_file, pkg->package);
strcat(lst_file, ".list");
deb_extract(dpkg_deb_list, NULL, pkg->file);
*/
pkg->status_want = status_want_install;
pkg->status_flag = status_flag_ok;
pkg->state_want = state_want_install;
pkg->state_flag = state_flag_ok;
if (status == TRUE) {
pkg->status_status = status_status_unpacked;
pkg->state_status = state_status_unpacked;
} else {
pkg->status_status = status_status_halfinstalled;
pkg->state_status = state_status_halfinstalled;
}
chdir(cwd);
return r;
}
/*
* Extract and parse the control.tar.gz from the specified package
* Extract and parse the control file from control.tar.gz
*/
static int dpkg_unpackcontrol(package_t *pkg)
static int dpkg_read_control(package_t *pkg)
{
char *tmp_name;
FILE *file;
int length;
FILE *pkg_file;
char *control_buffer = NULL;
/* clean the temp directory (dpkgcidir) be recreating it */
remove_dir(dpkgcidir);
if (create_path(dpkgcidir, S_IRWXU) == FALSE) {
if ((pkg_file = wfopen(pkg->filename, "r")) == NULL) {
return EXIT_FAILURE;
}
/*
* Get the package name from the file name,
* first remove the directories
*/
if ((tmp_name = strrchr(pkg->file, '/')) == NULL) {
tmp_name = pkg->file;
} else {
tmp_name++;
}
/* now remove trailing version numbers etc */
length = strcspn(tmp_name, "_.");
pkg->package = (char *) xcalloc(1, length + 1);
/* store the package name */
strncpy(pkg->package, tmp_name, length);
/* work out the full extraction path */
tmp_name = (char *) xcalloc(1, strlen(dpkgcidir) + strlen(pkg->package) + 9);
strcpy(tmp_name, dpkgcidir);
strcat(tmp_name, pkg->package);
/* extract control.tar.gz to the full extraction path */
deb_extract(dpkg_deb_control, tmp_name, pkg->file);
/* parse the extracted control file */
strcat(tmp_name, "/control");
if ((file = wfopen(tmp_name, "r")) == NULL) {
return EXIT_FAILURE;
}
if (control_read(file, pkg) == EXIT_FAILURE) {
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;
}
@@ -691,15 +704,12 @@ static int dpkg_unpack(package_t *pkgs, void *status)
package_t *pkg;
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
if (dpkg_unpackcontrol(pkg) == EXIT_FAILURE) {
return EXIT_FAILURE;
}
dpkg_read_control(pkg);
if ((r = dpkg_dounpack(pkg)) != 0 ) {
break;
}
}
status_merge(status, pkgs);
remove_dir(dpkgcidir);
return r;
}
@@ -735,9 +745,7 @@ static int dpkg_install(package_t *pkgs, void *status)
/* Stage 1: parse all the control information */
for (p = pkgs; p != 0; p = p->next) {
if (dpkg_unpackcontrol(p) == EXIT_FAILURE) {
return(EXIT_FAILURE);
}
dpkg_read_control(p);
}
/* Stage 2: resolve dependencies */
@@ -749,27 +757,26 @@ static int dpkg_install(package_t *pkgs, void *status)
/* Stage 3: install */
for (p = ordered; p != 0; p = p->next) {
p->status_want = status_want_install;
p->state_want = state_want_install;
/* for now the flag is always set to ok... this is probably
* not what we want
*/
p->status_flag = status_flag_ok;
p->state_flag = state_flag_ok;
DPRINTF("Installing %s\n", p->package);
if (dpkg_dounpack(p) != 0) {
perror_msg(p->file);
perror_msg(p->filename);
}
if (dpkg_doconfigure(p) != 0) {
perror_msg(p->file);
perror_msg(p->filename);
}
}
if (ordered != 0) {
status_merge(status, pkgs);
}
remove_dir(dpkgcidir);
return 0;
}
@@ -798,7 +805,7 @@ extern int dpkg_main(int argc, char **argv)
package_t *p, *packages = NULL;
void *status = NULL;
char opt = 0;
int opt = 0;
int optflag = 0;
while ((opt = getopt(argc, argv, "iruc")) != -1) {
@@ -822,7 +829,7 @@ extern int dpkg_main(int argc, char **argv)
if (optflag & arg_configure) {
p->package = xstrdup(argv[optind]);
} else {
p->file = xstrdup(argv[optind]);
p->filename = xstrdup(argv[optind]);
}
p->next = packages;
packages = p;
@@ -830,8 +837,7 @@ extern int dpkg_main(int argc, char **argv)
optind++;
}
create_path(dpkgcidir, S_IRWXU);
create_path(infodir, S_IRWXU);
make_directory((char *)infodir, S_IRWXU, FILEUTILS_RECUR);
status = status_read();
+79 -142
View File
@@ -14,175 +14,112 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* Merge this applet into dpkg when dpkg becomes more stable
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <getopt.h>
#include "busybox.h"
/* From gunzip.c */
extern int gz_open(FILE *compressed_file, int *pid);
extern void gz_close(int gunzip_pid);
typedef struct ar_headers_s {
char *name;
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
extern ar_headers_t get_ar_headers(int srcFd);
extern int tar_unzip_init(int tarFd);
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** extractList, char** excludeList);
static const int dpkg_deb_contents = 1;
static const int dpkg_deb_control = 2;
// const int dpkg_deb_info = 4;
static const int dpkg_deb_extract = 8;
static const int dpkg_deb_verbose_extract = 16;
static const int dpkg_deb_list = 32;
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename)
{
char **extract_list = NULL;
ar_headers_t *ar_headers = NULL;
char ar_filename[15];
int extract_flag = FALSE;
int list_flag = FALSE;
int verbose_flag = FALSE;
int extract_to_stdout = FALSE;
int srcFd = 0;
int status;
pid_t pid;
FILE *comp_file = NULL;
if (dpkg_deb_contents == (dpkg_deb_contents & optflags)) {
strcpy(ar_filename, "data.tar.gz");
verbose_flag = TRUE;
list_flag = TRUE;
}
if (dpkg_deb_list == (dpkg_deb_list & optflags)) {
strcpy(ar_filename, "data.tar.gz");
list_flag = TRUE;
}
if (dpkg_deb_control == (dpkg_deb_control & optflags)) {
strcpy(ar_filename, "control.tar.gz");
extract_flag = TRUE;
}
if (dpkg_deb_extract == (dpkg_deb_extract & optflags)) {
strcpy(ar_filename, "data.tar.gz");
extract_flag = TRUE;
}
if (dpkg_deb_verbose_extract == (dpkg_deb_verbose_extract & optflags)) {
strcpy(ar_filename, "data.tar.gz");
extract_flag = TRUE;
list_flag = TRUE;
}
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
srcFd = open(deb_filename, O_RDONLY);
*ar_headers = get_ar_headers(srcFd);
if (ar_headers->next == NULL) {
error_msg_and_die("Couldnt find %s in %s", ar_filename, deb_filename);
}
while (ar_headers->next != NULL) {
if (strcmp(ar_headers->name, ar_filename) == 0) {
break;
}
ar_headers = ar_headers->next;
}
lseek(srcFd, ar_headers->offset, SEEK_SET);
/* Uncompress the file */
comp_file = fdopen(srcFd, "r");
if ((srcFd = gz_open(comp_file, &pid)) == EXIT_FAILURE) {
error_msg_and_die("Couldnt unzip file");
}
if ( dir_name != NULL) {
if (is_directory(dir_name, TRUE, NULL)==FALSE) {
mkdir(dir_name, 0755);
}
if (chdir(dir_name)==-1) {
error_msg_and_die("Cannot change to dir %s", dir_name);
}
}
status = readTarFile(srcFd, extract_flag, list_flag,
extract_to_stdout, verbose_flag, NULL, extract_list);
/* we are deliberately terminating the child so we can safely ignore this */
signal(SIGTERM, SIG_IGN);
gz_close(pid);
close(srcFd);
fclose(comp_file);
return status;
}
extern int dpkg_deb_main(int argc, char **argv)
{
char *target_dir = NULL;
char *prefix = NULL;
char *filename = NULL;
char *output_buffer = NULL;
int opt = 0;
int optflag = 0;
int arg_type = 0;
int deb_extract_funct = extract_create_leading_dirs | extract_unconditional;
while ((opt = getopt(argc, argv, "cexXl")) != -1) {
const int arg_type_prefix = 1;
const int arg_type_field = 2;
const int arg_type_filename = 4;
// const int arg_type_un_ar_gz = 8;
while ((opt = getopt(argc, argv, "ceftXxI")) != -1) {
switch (opt) {
case 'c':
optflag |= dpkg_deb_contents;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_verbose_list;
break;
case 'e':
optflag |= dpkg_deb_control;
arg_type = arg_type_prefix;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_all_to_fs;
break;
case 'f':
arg_type = arg_type_field;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_one_to_buffer;
filename = xstrdup("./control");
break;
case 't': /* --fsys-tarfile, i just made up this short name */
/* Integrate the functionality needed with some code from ar.c */
error_msg_and_die("Option disabled");
// arg_type = arg_type_un_ar_gz;
break;
case 'X':
optflag |= dpkg_deb_verbose_extract;
break;
arg_type = arg_type_prefix;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_all_to_fs;
deb_extract_funct |= extract_list;
case 'x':
optflag |= dpkg_deb_extract;
arg_type = arg_type_prefix;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_all_to_fs;
break;
case 'l':
optflag |= dpkg_deb_list;
case 'I':
arg_type = arg_type_filename;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_one_to_buffer;
break;
/* case 'I':
optflag |= dpkg_deb_info;
break;
*/
default:
show_usage();
}
}
if (((optind + 1 ) > argc) || (optflag == 0)) {
if (optind == argc) {
show_usage();
}
if ((optflag & dpkg_deb_control) || (optflag & dpkg_deb_extract) || (optflag & dpkg_deb_verbose_extract)) {
if ( (optind + 1) == argc ) {
target_dir = (char *) xmalloc(7);
strcpy(target_dir, "DEBIAN");
/* Workout where to extract the files */
if (arg_type == arg_type_prefix) {
/* argument is a dir name */
if ((optind + 1) == argc ) {
prefix = xstrdup("./DEBIAN/");
} else {
target_dir = (char *) xmalloc(strlen(argv[optind + 1]));
strcpy(target_dir, argv[optind + 1]);
prefix = (char *) xmalloc(strlen(argv[optind + 1]) + 2);
strcpy(prefix, argv[optind + 1]);
/* Make sure the directory has a trailing '/' */
if (last_char_is(prefix, '/') == NULL) {
strcat(prefix, "/");
}
}
mkdir(prefix, 0777);
}
if (arg_type == arg_type_filename) {
if ((optind + 1) != argc) {
filename = xstrdup(argv[optind + 1]);
} else {
error_msg_and_die("-I currently requires a filename to be specified");
}
}
deb_extract(optflag, target_dir, argv[optind]);
/* else if (optflag & dpkg_deb_info) {
extract_flag = TRUE;
extract_to_stdout = TRUE;
strcpy(ar_filename, "control.tar.gz");
extract_list = argv+optind+1;
printf("list one is [%s]\n",extract_list[0]);
output_buffer = deb_extract(argv[optind], stdout, deb_extract_funct, prefix, filename);
if ((arg_type == arg_type_filename) && (output_buffer != NULL)) {
puts(output_buffer);
}
*/
else if (arg_type == arg_type_field) {
char *field = NULL;
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);
}
+41 -1043
View File
File diff suppressed because it is too large. Load diff
+210 -1154
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;
}
+44 -82
View File
@@ -4,7 +4,7 @@
*
* Note, that as of BusyBox-0.43, tar has been completely rewritten from the
* ground up. It still has remnents of the old code lying about, but it is
* very different now (i.e. cleaner, less global variables, etc)
* very different now (i.e., cleaner, less global variables, etc.)
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
@@ -51,16 +51,6 @@
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#define bb_need_name_longer_than_foo
#include "messages.c"
#ifdef BB_FEATURE_TAR_GZIP
extern int unzip(int in, int out);
extern int gz_open(FILE *compressed_file, int *pid);
extern void gz_close(int gunzip_pid);
#endif
/* Tar file constants */
#ifndef MAJOR
@@ -131,7 +121,7 @@ struct TarInfo
gid_t gid; /* Numeric GID */
size_t size; /* Size of file */
time_t mtime; /* Last-modified time */
enum TarFileType type; /* Regular, directory, link, etc */
enum TarFileType type; /* Regular, directory, link, etc. */
char * linkname; /* Name for symbolic and hard links */
long devmajor; /* Major number for special device */
long devminor; /* Minor number for special device */
@@ -139,7 +129,7 @@ struct TarInfo
typedef struct TarInfo TarInfo;
/* Local procedures to restore files from a tar file. */
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
static int readTarFile(int tarFd, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** extractList,
char** excludeList);
@@ -161,6 +151,7 @@ extern int tar_main(int argc, char **argv)
char** excludeList=NULL;
char** extractList=NULL;
const char *tarName="-";
const char *cwd=NULL;
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
FILE *fileList;
@@ -191,9 +182,9 @@ extern int tar_main(int argc, char **argv)
while (
#ifndef BB_FEATURE_TAR_EXCLUDE
(opt = getopt(argc, argv, "cxtzvOf:"))
(opt = getopt(argc, argv, "cxtzvOf:pC:"))
#else
(opt = getopt_long(argc, argv, "cxtzvOf:X:", longopts, NULL))
(opt = getopt_long(argc, argv, "cxtzvOf:X:pC:", longopts, NULL))
#endif
> 0) {
switch (opt) {
@@ -248,7 +239,16 @@ extern int tar_main(int argc, char **argv)
fclose(fileList);
break;
#endif
default:
case 'p':
break;
case 'C':
cwd = xgetcwd((char *)cwd);
if (chdir(optarg)) {
printf("cd: %s: %s\n", optarg, strerror(errno));
return EXIT_FAILURE;
}
break;
default:
show_usage();
}
}
@@ -284,7 +284,7 @@ extern int tar_main(int argc, char **argv)
/* unzip tarFd in a seperate process */
if (unzipFlag == TRUE) {
comp_file = fdopen(tarFd, "r");
if ((tarFd = gz_open(comp_file, &pid)) == EXIT_FAILURE) {
if ((tarFd = fileno(gz_open(comp_file, &pid))) == EXIT_FAILURE) {
error_msg_and_die("Couldnt unzip file");
}
}
@@ -300,6 +300,8 @@ extern int tar_main(int argc, char **argv)
#endif
}
if (cwd)
chdir(cwd);
if (status == TRUE)
return EXIT_SUCCESS;
else
@@ -313,7 +315,7 @@ static void
fixUpPermissions(TarInfo *header)
{
struct utimbuf t;
/* Now set permissions etc for the new file */
/* Now set permissions etc. for the new file */
chown(header->name, header->uid, header->gid);
chmod(header->name, header->mode);
/* Reset the time */
@@ -336,7 +338,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
/* Create the path to the file, just in case it isn't there...
* This should not screw up path permissions or anything. */
create_path(header->name, 0777);
char *dir = dirname (header->name);
make_directory (dir, -1, FILEUTILS_RECUR);
free (dir);
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
header->mode & ~S_IFMT)) < 0) {
error_msg(io_error, header->name, strerror(errno));
@@ -392,21 +396,11 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
static int
tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
{
if (extractFlag==FALSE || tostdoutFlag==TRUE)
return( TRUE);
if (create_path(header->name, header->mode) != TRUE) {
perror_msg("%s: Cannot mkdir", header->name);
if (make_directory(header->name, header->mode, FILEUTILS_RECUR) < 0)
return( FALSE);
}
/* make the final component, just in case it was
* omitted by create_path() (which will skip the
* directory if it doesn't have a terminating '/') */
if (mkdir(header->name, header->mode) < 0 && errno != EEXIST) {
perror_msg("%s", header->name);
return FALSE;
}
fixUpPermissions(header);
return( TRUE);
@@ -424,7 +418,7 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
return( FALSE);
}
/* Now set permissions etc for the new directory */
/* Now set permissions etc. for the new directory */
fixUpPermissions(header);
return( TRUE);
}
@@ -477,31 +471,11 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
}
}
/* Now set permissions etc for the new directory */
/* Now set permissions etc. for the new directory */
fixUpPermissions(header);
return( TRUE);
}
/* Read an octal value in a field of the specified width, with optional
* spaces on both sides of the number and with an optional null character
* at the end. Returns -1 on an illegal format. */
static long getOctal(const char *cp, int size)
{
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
if ((size == 0) || !is_octal(*cp))
return -1;
for(; (size > 0) && is_octal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
if ((size > 0) && *cp)
return -1;
return val;
}
/* Parse the tar header and fill in the nice struct with the details */
static int
readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
@@ -516,7 +490,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
static int alreadyWarned=FALSE;
while (*(header->name) == '/')
++*(header->name);
header->name++;
if (alreadyWarned == FALSE) {
error_msg("Removing leading '/' from member names");
@@ -524,16 +498,16 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
}
}
header->mode = getOctal(rawHeader->mode, sizeof(rawHeader->mode));
header->uid = getOctal(rawHeader->uid, sizeof(rawHeader->uid));
header->gid = getOctal(rawHeader->gid, sizeof(rawHeader->gid));
header->size = getOctal(rawHeader->size, sizeof(rawHeader->size));
header->mtime = getOctal(rawHeader->mtime, sizeof(rawHeader->mtime));
chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum));
header->mode = strtol(rawHeader->mode, NULL, 8);
header->uid = strtol(rawHeader->uid, NULL, 8);
header->gid = strtol(rawHeader->gid, NULL, 8);
header->size = strtol(rawHeader->size, NULL, 8);
header->mtime = strtol(rawHeader->mtime, NULL, 8);
chksum = strtol(rawHeader->chksum, NULL, 8);
header->type = rawHeader->typeflag;
header->linkname = rawHeader->linkname;
header->devmajor = getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor));
header->devminor = getOctal(rawHeader->devminor, sizeof(rawHeader->devminor));
header->devmajor = strtol(rawHeader->devmajor, NULL, 8);
header->devminor = strtol(rawHeader->devminor, NULL, 8);
/* Check the checksum */
for (i = sizeof(*rawHeader); i-- != 0;) {
@@ -597,7 +571,7 @@ static int extract_file(char **extract_files, const char *file)
* Read a tar file and extract or list the specified files within it.
* If the list is empty than all files are extracted or listed.
*/
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
static int readTarFile(int tarFd, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** extractList,
char** excludeList)
{
@@ -607,10 +581,6 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
TarHeader rawHeader;
TarInfo header;
/* Set the umask for this process so it doesn't
* screw up permission setting for us later. */
umask(0);
/* Read the tar file, and iterate over it one file at a time */
while ( (status = full_read(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
@@ -625,7 +595,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
}
}
if ( *(header.name) == '\0' )
goto endgame;
continue;
header.tarFd = tarFd;
/* Skip funky extra GNU headers that precede long files */
@@ -736,7 +706,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
case REGTYPE0:
/* If the name ends in a '/' then assume it is
* supposed to be a directory, and fall through */
if (header.name[strlen(header.name)-1] != '/') {
if (!last_char_is(header.name,'/')) {
if (tarExtractRegularFile(&header, extractFlag, tostdoutFlag)==FALSE)
errorFlag=TRUE;
break;
@@ -951,16 +921,12 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *header_name,
header.typeflag = LNKTYPE;
strncpy(header.linkname, tbInfo->hlInfo->name, sizeof(header.linkname));
} else if (S_ISLNK(statbuf->st_mode)) {
int link_size=0;
char buffer[BUFSIZ];
header.typeflag = SYMTYPE;
link_size = readlink(real_name, buffer, sizeof(buffer) - 1);
if ( link_size < 0) {
perror_msg("Error reading symlink '%s'", header.name);
char *lpath = xreadlink(real_name);
if (!lpath) /* Already printed err msg inside xreadlink() */
return ( FALSE);
}
buffer[link_size] = '\0';
strncpy(header.linkname, buffer, sizeof(header.linkname));
header.typeflag = SYMTYPE;
strncpy(header.linkname, lpath, sizeof(header.linkname));
free(lpath);
} else if (S_ISDIR(statbuf->st_mode)) {
header.typeflag = DIRTYPE;
strncat(header.name, "/", sizeof(header.name));
@@ -982,7 +948,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *header_name,
return ( FALSE);
}
/* Calculate and store the checksum (i.e. the sum of all of the bytes of
/* Calculate and store the checksum (i.e., the sum of all of the bytes of
* the header). The checksum field must be filled with blanks for the
* calculation. The checksum field is formatted differently from the
* other fields: it has [6] digits, a null, then a space -- rather than
@@ -1144,10 +1110,6 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
error_msg_and_die(io_error, tarName, strerror(errno));
/* Set the umask for this process so it doesn't
* screw up permission setting for us later. */
umask(0);
/* Read the directory/files and iterate over them one at a time */
while (*argv != NULL) {
if (recursive_action(*argv++, TRUE, FALSE, FALSE,
+13205
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -47,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);
puts(s);
return EXIT_SUCCESS;
}
+8 -26
View File
@@ -5,11 +5,6 @@
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
#ifdef BB_LOCALE_SUPPORT
#include <locale.h>
#endif
@@ -42,21 +37,7 @@ typedef int (*__link_f)(const char *, const char *);
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
@@ -93,17 +74,18 @@ int main(int argc, char **argv)
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
/* Add in a special case hack for a leading hyphen */
if (**argv == '-' && *(*argv+1)!= '-') {
applet_name = "sh";
applet_name = (*argv+1);
}
#endif
#ifdef BB_LOCALE_SUPPORT
#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);
+7 -2
View File
@@ -31,6 +31,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
@@ -64,15 +66,18 @@ extern const struct BB_applet applets[];
#include "applets.h"
#undef PROTOTYPES
extern const char *applet_name;
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
#else
#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. */
+1 -1
View File
@@ -9,7 +9,7 @@ RAW=` \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
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.51
Version: 0.52
Release: 1
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
+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:
*/
-167
View File
@@ -1,167 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_option
#define bb_need_too_few_args
#include "messages.c"
static long uid = -1;
static long gid = -1;
static int whichApp;
static char *theMode = NULL;
#define CHGRP_APP 1
#define CHOWN_APP 2
#define CHMOD_APP 3
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
switch (whichApp) {
case CHGRP_APP:
case CHOWN_APP:
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
if (lchown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#else
if (chown
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
(gid == -1) ? statbuf->st_gid : gid) == 0)
#endif
{
return (TRUE);
}
break;
case CHMOD_APP:
/* Parse the specified modes */
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
error_msg_and_die( "unknown mode: %s", theMode);
}
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
break;
}
perror(fileName);
return (FALSE);
}
int chmod_chown_chgrp_main(int argc, char **argv)
{
int stopIt = FALSE;
int recursiveFlag = FALSE;
char *groupName=NULL;
char *p=NULL;
whichApp = (applet_name[2]=='o')? /* chown */
CHOWN_APP : (applet_name[2]=='m')? /* chmod */
CHMOD_APP : CHGRP_APP;
if (argc < 2)
show_usage();
argv++;
/* Parse options */
while (--argc >= 0 && *argv && (**argv == '-')) {
while (stopIt==FALSE && *++(*argv)) {
switch (**argv) {
case 'R':
recursiveFlag = TRUE;
break;
default:
theMode=*argv-1;
stopIt = TRUE;
}
}
if (stopIt==TRUE)
break;
argv++;
}
if (argc == 0 || *argv == NULL) {
error_msg(too_few_args);
}
if (whichApp == CHMOD_APP) {
if (theMode==NULL)
theMode = *argv;
} else {
/* Find the selected group */
if (whichApp == CHGRP_APP) {
groupName = *argv;
gid = strtoul(groupName, &p, 10); /* maybe it's already numeric */
if (groupName == p)
gid = my_getgrnam(groupName);
} else {
groupName = strchr(*argv, '.');
if (groupName == NULL)
groupName = strchr(*argv, ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
} else
gid = -1;
}
/* Find the selected user (if appropriate) */
if (whichApp == CHOWN_APP) {
uid = strtoul(*argv, &p, 10); /* if numeric ... */
if (*argv == p)
uid = my_getpwnam(*argv);
}
}
/* Ok, ready to do the deed now */
if (argc < 1) {
error_msg_and_die(too_few_args);
}
while (argc-- > 1) {
if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE)
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+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:
*/
+4 -1
View File
@@ -54,7 +54,10 @@ int chroot_main(int argc, char **argv)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
shell_main(argc, argv);
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#endif
}
+70 -58
View File
@@ -76,16 +76,16 @@
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#endif
#if defined(BB_FEATURE_COMMAND_USERNAME_COMPLETION) || !defined(BB_FEATURE_SH_SIMPLE_PROMPT)
#if defined(BB_FEATURE_COMMAND_USERNAME_COMPLETION) || defined(BB_FEATURE_SH_FANCY_PROMPT)
#define BB_FEATURE_GETUSERNAME_AND_HOMEDIR
#endif
#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
#ifndef TEST
#include "pwd_grp/pwd.h"
#else
#include <pwd.h>
#endif /* TEST */
# ifndef TEST
# include "pwd_grp/pwd.h"
# else
# include <pwd.h>
# endif /* TEST */
#endif /* advanced FEATURES */
@@ -106,28 +106,14 @@ static struct history *his_front = NULL;
static struct history *his_end = NULL;
/* ED: sparc termios is broken: revert back to old termio handling. */
#if #cpu(sparc)
# include <termio.h>
# define termios termio
# define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp)
# define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp)
#else
# include <termios.h>
# define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
# define getTermSettings(fd,argp) tcgetattr(fd, argp);
#endif
#include <termios.h>
#define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
#define getTermSettings(fd,argp) tcgetattr(fd, argp);
/* Current termio and the previous termio before starting sh */
static struct termios initial_settings, new_settings;
#ifndef _POSIX_VDISABLE
#define _POSIX_VDISABLE '\0'
#endif
static
volatile int cmdedit_termw = 80; /* actual terminal width */
static int history_counter = 0; /* Number of commands in history list */
@@ -151,7 +137,7 @@ static int cursor; /* required global for signal handler */
static int len; /* --- "" - - "" - -"- --""-- --""--- */
static char *command_ps; /* --- "" - - "" - -"- --""-- --""--- */
static
#ifdef BB_FEATURE_SH_SIMPLE_PROMPT
#ifndef BB_FEATURE_SH_FANCY_PROMPT
const
#endif
char *cmdedit_prompt; /* --- "" - - "" - -"- --""-- --""--- */
@@ -166,7 +152,7 @@ static char *home_pwd_buf = "";
static int my_euid;
#endif
#ifndef BB_FEATURE_SH_SIMPLE_PROMPT
#ifdef BB_FEATURE_SH_FANCY_PROMPT
static char *hostname_buf = "";
static int num_ok_lines = 1;
#endif
@@ -335,7 +321,7 @@ static void put_prompt(void)
cursor = 0;
}
#ifdef BB_FEATURE_SH_SIMPLE_PROMPT
#ifndef BB_FEATURE_SH_FANCY_PROMPT
static void parse_prompt(const char *prmt_ptr)
{
cmdedit_prompt = prmt_ptr;
@@ -355,6 +341,10 @@ static void parse_prompt(const char *prmt_ptr)
char c;
char *pbuf;
if (!pwd_buf) {
pwd_buf=(char *)unknown;
}
while (*prmt_ptr) {
pbuf = buf;
pbuf[1] = 0;
@@ -452,7 +442,8 @@ static void parse_prompt(const char *prmt_ptr)
if (flg_not_length == ']')
sub_len++;
}
free(pwd_buf);
if(pwd_buf!=(char *)unknown)
free(pwd_buf);
cmdedit_prompt = prmt_mem_ptr;
cmdedit_prmt_len = prmt_len - sub_len;
put_prompt();
@@ -574,7 +565,6 @@ extern void cmdedit_init(void)
signal(SIGTERM, clean_up_and_die);
handlers_sets |= SET_TERM_HANDLERS;
}
}
#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
@@ -977,17 +967,14 @@ static int find_match(char *matchBuf, int *len_with_quotes)
|| (int_buf[i + 1] & ~QUOT) == '~')) {
i++;
}
if (i) {
collapse_pos(0, i);
}
/* set only match and destroy quotes */
j = 0;
for (i = 0; pos_buf[i] >= 0; i++) {
matchBuf[i] = matchBuf[pos_buf[i]];
for (c = 0; pos_buf[i] >= 0; i++) {
matchBuf[c++] = matchBuf[pos_buf[i]];
j = pos_buf[i] + 1;
}
matchBuf[i] = 0;
matchBuf[c] = 0;
/* old lenght matchBuf with quotes symbols */
*len_with_quotes = j ? j - pos_buf[0] : 0;
@@ -1041,9 +1028,30 @@ static void input_tab(int *lastWasTab)
* in the current working directory that matches. */
if (!matches)
matches =
exe_n_cwd_tab_completion(matchBuf, &num_matches,
find_type);
exe_n_cwd_tab_completion(matchBuf,
&num_matches, find_type);
/* Remove duplicate found */
if(matches) {
int i, j;
/* bubble */
for(i=0; i<(num_matches-1); i++)
for(j=i+1; j<num_matches; j++)
if(matches[i]!=0 && matches[j]!=0 &&
strcmp(matches[i], matches[j])==0) {
free(matches[j]);
matches[j]=0;
}
j=num_matches;
num_matches = 0;
for(i=0; i<j; i++)
if(matches[i]) {
if(!strcmp(matches[i], "./"))
matches[i][1]=0;
else if(!strcmp(matches[i], "../"))
matches[i][2]=0;
matches[num_matches++]=matches[i];
}
}
/* Did we find exactly one match? */
if (!matches || num_matches > 1) {
char *tmp1;
@@ -1091,8 +1099,7 @@ static void input_tab(int *lastWasTab)
/* new len */
len = strlen(command_ps);
/* write out the matched command */
input_end();
input_backward(cursor - recalc_pos);
redraw(cmdedit_y, len - recalc_pos);
}
if (tmp != matches[0])
free(tmp);
@@ -1170,8 +1177,6 @@ enum {
extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
{
int inputFd = fileno(stdin);
int break_out = 0;
int lastWasTab = FALSE;
unsigned char c = 0;
@@ -1182,23 +1187,28 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
len = 0;
command_ps = command;
if (new_settings.c_cc[VMIN] == 0) { /* first call */
if (new_settings.c_cc[VERASE] == 0) { /* first call */
getTermSettings(inputFd, (void *) &initial_settings);
getTermSettings(0, (void *) &initial_settings);
memcpy(&new_settings, &initial_settings, sizeof(struct termios));
new_settings.c_lflag &= ~ICANON; /* unbuffered input */
/* Turn off echoing and CTRL-C, so we can trap it */
new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG);
#ifndef linux
/* Hmm, in linux c_cc[] not parsed if set ~ICANON */
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
/* Turn off CTRL-C, so we can trap it */
# ifndef _POSIX_VDISABLE
# define _POSIX_VDISABLE '\0'
# endif
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
new_settings.c_lflag &= ~ICANON; /* unbuffered input */
/* Turn off echoing */
new_settings.c_lflag &= ~(ECHO | ECHOCTL | ECHONL);
#endif
}
command[0] = 0;
setTermSettings(inputFd, (void *) &new_settings);
setTermSettings(0, (void *) &new_settings);
handlers_sets |= SET_RESET_TERM;
/* Now initialize things */
@@ -1210,8 +1220,9 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
fflush(stdout); /* buffered out to fast */
if (read(inputFd, &c, 1) < 1)
return;
if (read(0, &c, 1) < 1)
/* if we can't read input then exit */
goto prepare_to_die;
switch (c) {
case '\n':
@@ -1243,6 +1254,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
/* Control-d -- Delete one character, or exit
* if the len=0 and no chars to delete */
if (len == 0) {
prepare_to_die:
printf("exit");
clean_up_and_die(0);
} else {
@@ -1295,11 +1307,11 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
case ESC:{
/* escape sequence follows */
if (read(inputFd, &c, 1) < 1)
if (read(0, &c, 1) < 1)
return;
/* different vt100 emulations */
if (c == '[' || c == 'O') {
if (read(inputFd, &c, 1) < 1)
if (read(0, &c, 1) < 1)
return;
}
switch (c) {
@@ -1364,7 +1376,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
}
if (c >= '1' && c <= '9')
do
if (read(inputFd, &c, 1) < 1)
if (read(0, &c, 1) < 1)
return;
while (c != '~');
break;
@@ -1374,7 +1386,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
/* Control-V -- Add non-printable symbol */
if (c == 22) {
if (read(inputFd, &c, 1) < 1)
if (read(0, &c, 1) < 1)
return;
if (c == 0) {
beep();
@@ -1415,7 +1427,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
lastWasTab = FALSE;
}
setTermSettings(inputFd, (void *) &initial_settings);
setTermSettings(0, (void *) &initial_settings);
handlers_sets &= ~SET_RESET_TERM;
/* Handle command history log */
@@ -1461,7 +1473,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
history_counter++;
}
}
#if !defined(BB_FEATURE_SH_SIMPLE_PROMPT)
#if defined(BB_FEATURE_SH_FANCY_PROMPT)
num_ok_lines++;
#endif
}
@@ -1470,7 +1482,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
#if defined(BB_FEATURE_CLEAN_UP) && defined(BB_FEATURE_COMMAND_TAB_COMPLETION)
input_tab(0); /* strong free */
#endif
#if !defined(BB_FEATURE_SH_SIMPLE_PROMPT)
#if defined(BB_FEATURE_SH_FANCY_PROMPT)
free(cmdedit_prompt);
#endif
return;
@@ -1509,7 +1521,7 @@ int main(int argc, char **argv)
{
char buff[BUFSIZ];
char *prompt =
#if !defined(BB_FEATURE_SH_SIMPLE_PROMPT)
#if defined(BB_FEATURE_SH_FANCY_PROMPT)
"\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:\
\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] \
\\!\\[\\e[36;1m\\]\\$ \\[\\E[0m\\]";
-6
View File
@@ -1,14 +1,8 @@
#ifndef CMDEDIT_H
#define CMDEDIT_H
#ifdef BB_FEATURE_COMMAND_EDITING
#include <stddef.h>
#include "busybox.h"
void cmdedit_init(void);
void cmdedit_terminate(void);
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
#endif /* BB_FEATURE_COMMAND_EDITING */
#endif /* CMDEDIT_H */
+23 -9
View File
@@ -26,28 +26,42 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <getopt.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1 = argv[1], *filename2 = "-";
int c1, c2, char_pos = 1, line_pos = 1;
char *filename1, *filename2 = "-";
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
/* parse argv[] */
if (argc < 2 || 3 < argc)
show_usage();
while ((c = getopt(argc, argv, "s")) != EOF) {
switch (c) {
case 's':
silent = TRUE;
break;
default:
show_usage();
}
}
fp1 = xfopen(argv[1], "r");
if (argv[2] != NULL) {
fp2 = xfopen(argv[2], "r");
filename2 = argv[2];
filename1 = argv[optind];
switch (argc - optind) {
case 2:
fp2 = xfopen(filename2 = argv[optind + 1], "r");
case 1:
fp1 = xfopen(filename1, "r");
break;
default:
show_usage();
}
do {
c1 = fgetc(fp1);
c2 = fgetc(fp2);
if (c1 != c2) {
if (silent)
return EXIT_FAILURE;
if (c1 == EOF)
printf("EOF on %s\n", filename1);
else if (c2 == EOF)
+1 -1
View File
@@ -47,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);
puts(s);
return EXIT_SUCCESS;
}
+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:
*/
+4 -1
View File
@@ -54,7 +54,10 @@ int chroot_main(int argc, char **argv)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
shell_main(argc, argv);
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#endif
}
+23 -9
View File
@@ -26,28 +26,42 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <getopt.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1 = argv[1], *filename2 = "-";
int c1, c2, char_pos = 1, line_pos = 1;
char *filename1, *filename2 = "-";
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
/* parse argv[] */
if (argc < 2 || 3 < argc)
show_usage();
while ((c = getopt(argc, argv, "s")) != EOF) {
switch (c) {
case 's':
silent = TRUE;
break;
default:
show_usage();
}
}
fp1 = xfopen(argv[1], "r");
if (argv[2] != NULL) {
fp2 = xfopen(argv[2], "r");
filename2 = argv[2];
filename1 = argv[optind];
switch (argc - optind) {
case 2:
fp2 = xfopen(filename2 = argv[optind + 1], "r");
case 1:
fp1 = xfopen(filename1, "r");
break;
default:
show_usage();
}
do {
c1 = fgetc(fp1);
c2 = fgetc(fp2);
if (c1 != c2) {
if (silent)
return EXIT_FAILURE;
if (c1 == EOF)
printf("EOF on %s\n", filename1);
else if (c2 == EOF)
+114
View File
@@ -0,0 +1,114 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cp implementation for busybox
*
*
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <utime.h>
#include <errno.h>
#include <dirent.h>
#include <stdlib.h>
#include "busybox.h"
extern int cp_main(int argc, char **argv)
{
int status = 0;
int opt;
int flags = 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;
}
+236 -124
View File
@@ -24,8 +24,7 @@
#include <stdlib.h>
#include <unistd.h> /* getopt */
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include "busybox.h"
@@ -34,65 +33,228 @@ extern int optind;
extern char *optarg;
/* globals in this file only */
/* option vars */
static char part = 0; /* (b)yte, (c)har, (f)ields */
static int startpos = 1;
static int endpos = -1;
static char delim = '\t'; /* delimiter, default is tab */
static unsigned int supress_non_delimited_lines = 0;
static char delim = '\t'; /* delimiter, default is tab */
struct cut_list {
int startpos;
int endpos;
};
static const int BOL = 0;
static const int EOL = INT_MAX;
static const int NON_RANGE = -1;
static struct cut_list *cut_lists = NULL; /* growable array holding a series of lists */
static unsigned int nlists = 0; /* number of elements in above list */
static int cmpfunc(const void *a, const void *b)
{
struct cut_list *la = (struct cut_list *)a;
struct cut_list *lb = (struct cut_list *)b;
if (la->startpos > lb->startpos)
return 1;
if (la->startpos < lb->startpos)
return -1;
return 0;
}
/*
* decompose_list() - parses a list and puts values into startpos and endpos.
* parse_lists() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
* more than one list can be seperated by commas
*/
static void decompose_list(const char *list)
static void parse_lists(char *lists)
{
unsigned int nminus = 0;
char *ptr;
char *ltok = NULL;
char *ntok = NULL;
char *junk;
int s = 0, e = 0;
/* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') {
error_msg_and_die("invalid byte or field list");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
/* take apart the lists, one by one (they are seperated with commas */
while ((ltok = strsep(&lists, ",")) != NULL) {
/* it's actually legal to pass an empty list */
if (strlen(ltok) == 0)
continue;
/* get the start pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
fprintf(stderr, "Help ntok is null for starting position! What do I do?\n");
} else if (strlen(ntok) == 0) {
s = BOL;
} else {
s = strtoul(ntok, &junk, 10);
if(*junk != '\0' || s < 0)
error_msg_and_die("invalid byte or field list");
/* account for the fact that arrays are zero based, while the user
* expects the first char on the line to be char # 1 */
if (s != 0)
s--;
}
/* get the end pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
e = NON_RANGE;
} else if (strlen(ntok) == 0) {
e = EOL;
} else {
e = strtoul(ntok, &junk, 10);
if(*junk != '\0' || e < 0)
error_msg_and_die("invalid byte or field list");
/* if the user specified and end position of 0, that means "til the
* end of the line */
if (e == 0)
e = INT_MAX;
e--; /* again, arrays are zero based, lines are 1 based */
if (e == s)
e = NON_RANGE;
}
/* if there's something left to tokenize, the user past an invalid list */
if (ltok)
error_msg_and_die("invalid byte or field list");
/* add the new list */
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
cut_lists[nlists-1].startpos = s;
cut_lists[nlists-1].endpos = e;
}
/* make sure we got some cut positions out of all that */
if (nlists == 0)
error_msg_and_die("missing list of positions");
/* now that the lists are parsed, we need to sort them to make life easier
* on us when it comes time to print the chars / fields / lines */
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
}
static void cut_line_by_chars(const char *line)
{
int c, l;
/* set up a list so we can keep track of what's been printed */
char *printed = xcalloc(strlen(line), sizeof(char));
/* print the chars specified in each cut list */
for (c = 0; c < nlists; c++) {
l = cut_lists[c].startpos;
while (l < strlen(line)) {
if (!printed[l]) {
putchar(line[l]);
printed[l] = 'X';
}
l++;
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos)
break;
}
}
putchar('\n'); /* cuz we were handed a chomped line */
free(printed);
}
static void cut_line_by_fields(char *line)
{
int c, f;
int ndelim = -1; /* zero-based / one-based problem */
int nfields_printed = 0;
char *field = NULL;
char d[2] = { delim, 0 };
char *printed;
/* test the easy case first: does this line contain any delimiters? */
if (strchr(line, delim) == NULL) {
if (!supress_non_delimited_lines)
puts(line);
return;
}
/* set up a list so we can keep track of what's been printed */
printed = xcalloc(strlen(line), sizeof(char));
/* process each list on this line, for as long as we've got a line to process */
for (c = 0; c < nlists && line; c++) {
f = cut_lists[c].startpos;
do {
/* find the field we're looking for */
while (line && ndelim < f) {
field = strsep(&line, d);
ndelim++;
}
/* we found it, and it hasn't been printed yet */
if (field && ndelim == f && !printed[ndelim]) {
/* if this isn't our first time through, we need to print the
* delimiter after the last field that was printed */
if (nfields_printed > 0)
putchar(delim);
fputs(field, stdout);
printed[ndelim] = 'X';
nfields_printed++;
}
f++;
/* keep going as long as we have a line to work with, this is a
* list, and we're not at the end of that list */
} while (line && cut_lists[c].endpos != NON_RANGE && f <= cut_lists[c].endpos);
}
/* if we printed anything at all, we need to finish it with a newline cuz
* we were handed a chomped line */
putchar('\n');
free(printed);
}
static void cut_file_by_lines(const char *line, unsigned int linenum)
{
static int c = 0;
static int l = -1;
/* I can't initialize this above cuz the "initializer isn't
* constant" *sigh* */
if (l == -1)
l = cut_lists[c].startpos;
/* get out if we have no more lists to process or if the lines are lower
* than what we're interested in */
if (c >= nlists || linenum < l)
return;
/* if the line we're looking for is lower than the one we were passed, it
* means we displayed it already, so move on */
while (l < linenum) {
l++;
/* move on to the next list if we're at the end of this one */
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos) {
c++;
/* get out if there's no more lists to process */
if (c >= nlists)
return;
l = cut_lists[c].startpos;
/* get out if the current line is lower than the one we just became
* interested in */
if (linenum < l)
return;
}
}
/* handle single value 'N' case */
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
error_msg_and_die("missing list of fields");
}
endpos = startpos;
}
/* handle multi-value cases */
else if (nminus == 1) {
/* handle 'N-' case */
if (list[strlen(list) - 1] == '-') {
startpos = strtol(list, &ptr, 10);
}
/* handle '-M' case */
else if (list[0] == '-') {
endpos = strtol(&list[1], NULL, 10);
}
/* handle 'N-M' case */
else {
startpos = strtol(list, &ptr, 10);
endpos = strtol(ptr+1, &ptr, 10);
}
/* a sanity check */
if (startpos == 0) {
startpos = 1;
}
}
/* If we made it here, it means we've found the line we're looking for, so print it */
puts(line);
}
@@ -101,82 +263,31 @@ static void decompose_list(const char *list)
*/
static void cut_file(FILE *file)
{
char *line;
unsigned int cr_hits = 0;
char *line = NULL;
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
/* cut based on chars/bytes */
if (part == 'c' || part == 'b') {
int i;
/* a valid end position has been specified */
if (endpos > 0) {
for (i = startpos-1; i < endpos; i++) {
fputc(line[i], stdout);
}
fputc('\n', stdout);
}
/* otherwise, just go to the end of the line */
else {
for (i = startpos-1; line[i]; i++) {
fputc(line[i], stdout);
}
}
}
while ((line = get_line_from_file(file)) != NULL) {
chomp(line);
/* cut based on chars/bytes XXX: only works when sizeof(char) == byte */
if (part == 'c' || part == 'b')
cut_line_by_chars(line);
/* cut based on fields */
else if (part == 'f') {
char *ptr;
char *start = line;
unsigned int delims_hit = 0;
if (delim == '\n') {
cr_hits++;
if (cr_hits >= startpos && cr_hits <= endpos) {
while (*start && *start != '\n') {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
}
else {
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
delims_hit++;
if (delims_hit == (startpos - 1)) {
start = ptr+1;
}
if (delims_hit == endpos) {
break;
}
}
/* we didn't hit any delimeters */
if (delims_hit == 0 && !supress_non_delimited_lines) {
fputs(line, stdout);
}
/* we =did= hit some delimiters */
else if (delims_hit > 0) {
/* we have a fixed end point */
if (ptr) {
while (start < ptr) {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
/* or we're just going til the end of the line */
else {
while (*start) {
fputc(*start, stdout);
start++;
}
}
}
}
if (delim == '\n')
cut_file_by_lines(line, linenum);
else
cut_line_by_fields(line);
}
linenum++;
free(line);
}
}
extern int cut_main(int argc, char **argv)
{
int opt;
@@ -191,7 +302,7 @@ extern int cut_main(int argc, char **argv)
error_msg_and_die("only one type of list may be specified");
}
part = (char)opt;
decompose_list(optarg);
parse_lists(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
@@ -212,14 +323,15 @@ extern int cut_main(int argc, char **argv)
error_msg_and_die("you must specify a list of bytes, characters, or fields");
}
if (supress_non_delimited_lines && part != 'f') {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
/* non-field (char or byte) cutting has some special handling */
if (part != 'f') {
if (supress_non_delimited_lines) {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
}
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
+2 -6
View File
@@ -29,10 +29,6 @@
#include <string.h>
#include <getopt.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
#include "messages.c"
/* This 'date' command supports only 2 time setting formats,
@@ -203,7 +199,7 @@ int date_main(int argc, char **argv)
date_conv_time(&tm_time, date_str);
}
/* Correct any day of week and day of year etc fields */
/* Correct any day of week and day of year etc. fields */
tm = mktime(&tm_time);
if (tm < 0)
error_msg_and_die(invalid_date, date_str);
@@ -245,7 +241,7 @@ int date_main(int argc, char **argv)
/* Print OUTPUT (after ALL that!) */
t_buff = xmalloc(201);
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
puts(t_buff);
return EXIT_SUCCESS;
}
+9 -22
View File
@@ -40,9 +40,6 @@ static int do_df(char *device, const char *mount_point)
struct statfs s;
long blocks_used;
long blocks_percent_used;
#ifdef BB_FEATURE_HUMAN_READABLE
long base;
#endif
if (statfs(mount_point, &s) != 0) {
perror_msg("%s", mount_point);
@@ -60,30 +57,20 @@ static int do_df(char *device, const char *mount_point)
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
find_real_root_device_name( device);
device = find_real_root_device_name(device);
if(device==NULL)
return FALSE;
}
#ifdef BB_FEATURE_HUMAN_READABLE
switch (df_disp_hr) {
case MEGABYTE:
base = KILOBYTE;
break;
case KILOBYTE:
base = 1;
break;
default:
base = 0;
}
printf("%-20s %9s ", device,
make_human_readable_str((unsigned long)(s.f_blocks *
(s.f_bsize/(double)KILOBYTE)), base));
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str((unsigned long)(
(s.f_blocks - s.f_bfree) *
(s.f_bsize/(double)KILOBYTE)), base));
make_human_readable_str( (s.f_blocks - s.f_bfree), s.f_bsize, df_disp_hr));
printf("%9s %3ld%% %s\n",
make_human_readable_str((unsigned long)(s.f_bavail *
(s.f_bsize/(double)KILOBYTE)), base),
blocks_percent_used, mount_point);
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
+2 -12
View File
@@ -30,21 +30,11 @@
extern int dirname_main(int argc, char **argv)
{
char* s;
if ((argc < 2) || (**(argv + 1) == '-'))
show_usage();
argv++;
s=*argv+strlen(*argv)-1;
while (s != *argv && *s == '/') {
*s-- = '\0';
}
s = strrchr(*argv, '/');
if (s != NULL && s == *argv)
s[1] = '\0';
else if (s != NULL)
*s = '\0';
puts(s ? *argv : ".");
puts (dirname (argv[0]));
return EXIT_SUCCESS;
}
+81 -88
View File
@@ -27,18 +27,92 @@
* See the COPYING file for license information.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include "busybox.h"
#define CT_AUTO 0
#define CT_UNIX2DOS 1
#define CT_DOS2UNIX 2
// 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;
int convert(char *fn, int ConvType);
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;
@@ -69,84 +143,3 @@ int dos2unix_main(int argc, char *argv[]) {
return o;
}
// if fn is NULL then input is stdin and output is stdout
int convert(char *fn, int ConvType) {
char c;
char *tempFn = NULL;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = fopen(fn, "r")) == NULL) {
perror_msg(fn);
return -1;
}
tempFn = tmpnam(NULL);
if (tempFn == NULL || (out = fopen(tempFn, "w")) == NULL) {
perror_msg(NULL);
return -2;
}
}
while ((c = fgetc(in)) != EOF) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_DOS2UNIX;
break;
}
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_UNIX2DOS;
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
break;
}
fputc(c, out);
}
if (c != EOF)
while ((c = fgetc(in)) != EOF) {
if (c == '\r')
continue;
if (c == '\n') {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(c, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0 ||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
perror_msg(NULL);
return -2;
}
while ((c = fgetc(in)) != EOF)
fputc(c, out);
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
}
return 0;
}
+81 -26
View File
@@ -31,9 +31,6 @@
#include <string.h>
#include <errno.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#include "messages.c"
#ifdef BB_FEATURE_HUMAN_READABLE
@@ -49,19 +46,8 @@ static Display *print;
static void print_normal(long size, char *filename)
{
unsigned long base;
#ifdef BB_FEATURE_HUMAN_READABLE
switch (disp_hr) {
case MEGABYTE:
base = KILOBYTE;
break;
case KILOBYTE:
base = 1;
break;
default:
base = 0;
}
printf("%s\t%s\n", make_human_readable_str(size, base), filename);
printf("%s\t%s\n", make_human_readable_str(size<<10, 1, disp_hr), filename);
#else
printf("%ld\t%s\n", size, filename);
#endif
@@ -70,17 +56,87 @@ static void print_normal(long size, char *filename)
static void print_summary(long size, char *filename)
{
if (du_depth == 1) {
printf("summary\n");
print_normal(size, filename);
}
}
#define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE)
typedef struct ino_dev_hash_bucket_struct {
struct ino_dev_hash_bucket_struct *next;
ino_t ino;
dev_t dev;
char name[1];
} ino_dev_hashtable_bucket_t;
static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
/*
* Return 1 if statbuf->st_ino && statbuf->st_dev are recorded in
* `ino_dev_hashtable', else return 0
*
* If NAME is a non-NULL pointer to a character pointer, and there is
* a match, then set *NAME to the value of the name slot in that
* bucket.
*/
static int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name)
{
ino_dev_hashtable_bucket_t *bucket;
bucket = ino_dev_hashtable[hash_inode(statbuf->st_ino)];
while (bucket != NULL) {
if ((bucket->ino == statbuf->st_ino) &&
(bucket->dev == statbuf->st_dev))
{
if (name) *name = bucket->name;
return 1;
}
bucket = bucket->next;
}
return 0;
}
/* Add statbuf to statbuf hash table */
static void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name)
{
int i;
size_t s;
ino_dev_hashtable_bucket_t *bucket;
i = hash_inode(statbuf->st_ino);
s = name ? strlen(name) : 0;
bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + s);
bucket->ino = statbuf->st_ino;
bucket->dev = statbuf->st_dev;
if (name)
strcpy(bucket->name, name);
else
bucket->name[0] = '\0';
bucket->next = ino_dev_hashtable[i];
ino_dev_hashtable[i] = bucket;
}
/* Clear statbuf hash table */
static void reset_ino_dev_hashtable(void)
{
int i;
ino_dev_hashtable_bucket_t *bucket;
for (i = 0; i < HASH_SIZE; i++) {
while (ino_dev_hashtable[i] != NULL) {
bucket = ino_dev_hashtable[i]->next;
free(ino_dev_hashtable[i]);
ino_dev_hashtable[i] = bucket;
}
}
}
/* tiny recursive du */
static long du(char *filename)
{
struct stat statbuf;
long sum;
int len;
if ((lstat(filename, &statbuf)) != 0) {
perror_msg("%s", filename);
@@ -93,12 +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) {
@@ -106,12 +163,11 @@ static long du(char *filename)
return 0;
}
len = strlen(filename);
if (filename[len - 1] == '/')
filename[--len] = '\0';
newfile = last_char_is(filename, '/');
if (newfile)
*newfile = '\0';
while ((entry = readdir(dir))) {
char *newfile;
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
@@ -180,8 +236,7 @@ int du_main(int argc, char **argv)
long sum;
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
sum = du(argv[i]);
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
print_normal(sum, argv[i]);
}
@@ -192,7 +247,7 @@ int du_main(int argc, char **argv)
return status;
}
/* $Id: du.c,v 1.44 2001/04/09 22:48:11 andersen Exp $ */
/* $Id: du.c,v 1.50 2001/06/30 17:54:20 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
+16 -7
View File
@@ -35,14 +35,13 @@ extern int env_main(int argc, char** argv)
{
char **ep, *p;
char *cleanenv[1];
int ignore_environment = 0;
int ch;
while ((ch = getopt(argc, argv, "-iu:")) != -1)
while ((ch = getopt(argc, argv, "+iu:")) != -1) {
switch(ch) {
case '-':
case 'i':
environ = cleanenv;
cleanenv[0] = NULL;
ignore_environment = 1;
break;
case 'u':
unsetenv(optarg);
@@ -50,15 +49,25 @@ extern int env_main(int argc, char** argv)
default:
show_usage();
}
}
if (optind != argc && !strcmp(argv[optind], "-")) {
ignore_environment = 1;
argv++;
}
if (ignore_environment) {
environ = cleanenv;
cleanenv[0] = NULL;
}
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
setenv(*argv, ++p, 1);
if (putenv(*argv) < 0)
perror_msg_and_die("%s", *argv);
if (*argv) {
execvp(*argv, argv);
perror_msg_and_die("%s", *argv);
}
for (ep = environ; *ep; ep++)
printf("%s\n", *ep);
exit(EXIT_SUCCESS);
puts(*ep);
return 0;
}
/*
+2 -2
View File
@@ -89,8 +89,8 @@ int expr_main (int argc, char **argv)
if (v->type == integer)
printf ("%d\n", v->u.i);
else
printf ("%s\n", v->u.s);
else
puts (v->u.s);
exit (null (v));
}
+2 -2
View File
@@ -79,12 +79,12 @@ extern int id_main(int argc, char **argv)
if (no_group) {
if(name_not_number && user)
printf("%s\n",user);
puts(user);
else
printf("%ld\n", pwnam);
} else if (no_user) {
if(name_not_number && group)
printf("%s\n", group);
puts(group);
else
printf("%ld\n", grnam);
} else {
-3
View File
@@ -28,9 +28,6 @@
#include <errno.h>
#include <unistd.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_not_a_directory
#include "messages.c"
static const int LN_SYMLINK = 1;
+22 -23
View File
@@ -21,7 +21,7 @@
/*
* To achieve a small memory footprint, this version of 'ls' doesn't do any
* file sorting, and only has the most essential command line switches
* (i.e. the ones I couldn't live without :-) All features which involve
* (i.e., the ones I couldn't live without :-) All features which involve
* linking in substantial chunks of libc can be disabled.
*
* Although I don't really want to add new features to this program to
@@ -543,16 +543,16 @@ static struct dnode **list_dir(char *path)
}
while ((entry = readdir(dir)) != NULL) {
/* are we going to list the file- it may be . or .. or a hidden file */
if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) continue;
if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) continue;
if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) continue;
if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT))
continue;
if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT))
continue;
if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN))
continue;
cur= (struct dnode *)xmalloc(sizeof(struct dnode));
cur->fullname = xmalloc(strlen(path)+1+strlen(entry->d_name)+1);
strcpy(cur->fullname, path);
if (cur->fullname[strlen(cur->fullname)-1] != '/')
strcat(cur->fullname, "/");
cur->name= cur->fullname + strlen(cur->fullname);
strcat(cur->fullname, entry->d_name);
cur->fullname = concat_path_file(path, entry->d_name);
cur->name = cur->fullname +
(strlen(cur->fullname) - strlen(entry->d_name));
if (my_stat(cur))
continue;
cur->next= dn;
@@ -577,7 +577,7 @@ static struct dnode **list_dir(char *path)
/*----------------------------------------------------------------------*/
static int list_single(struct dnode *dn)
{
int i, len;
int i;
char scratch[BUFSIZ + 1];
#ifdef BB_FEATURE_LS_TIMESTAMPS
char *filetime;
@@ -605,13 +605,13 @@ static int list_single(struct dnode *dn)
for (i=0; i<=31; i++) {
switch (list_fmt & (1<<i)) {
case LIST_INO:
printf("%7ld ", dn->dstat.st_ino);
printf("%7ld ", (long int)dn->dstat.st_ino);
column += 8;
break;
case LIST_BLOCKS:
#ifdef BB_FEATURE_HUMAN_READABLE
fprintf(stdout, "%5s ", make_human_readable_str(dn->dstat.st_blocks>>1,
(ls_disp_hr==TRUE)? 0: 1));
fprintf(stdout, "%6s ", make_human_readable_str(dn->dstat.st_blocks>>1,
KILOBYTE, (ls_disp_hr==TRUE)? 0: KILOBYTE));
#else
#if _FILE_OFFSET_BITS == 64
printf("%4lld ", dn->dstat.st_blocks>>1);
@@ -622,7 +622,7 @@ static int list_single(struct dnode *dn)
column += 5;
break;
case LIST_MODEBITS:
printf("%10s", (char *)mode_string(dn->dstat.st_mode));
printf("%-10s ", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
@@ -634,7 +634,7 @@ static int list_single(struct dnode *dn)
my_getpwuid(scratch, dn->dstat.st_uid);
printf("%-8.8s ", scratch);
my_getgrgid(scratch, dn->dstat.st_gid);
printf("%-8.8s", scratch);
printf("%-8.8s ", scratch);
column += 17;
break;
#endif
@@ -649,8 +649,7 @@ static int list_single(struct dnode *dn)
} else {
#ifdef BB_FEATURE_HUMAN_READABLE
if (ls_disp_hr==TRUE) {
fprintf(stdout, "%9s ", make_human_readable_str(
dn->dstat.st_size>>10, 0));
fprintf(stdout, "%8s ", make_human_readable_str(dn->dstat.st_size, 1, 0));
} else
#endif
{
@@ -688,16 +687,16 @@ static int list_single(struct dnode *dn)
break;
case LIST_SYMLINK:
if (S_ISLNK(dn->dstat.st_mode)) {
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
if (len > 0) {
scratch[len]= '\0';
printf(" -> %s", scratch);
char *lpath = xreadlink(dn->fullname);
if (lpath) {
printf(" -> %s", lpath);
#ifdef BB_FEATURE_LS_FILETYPES
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
}
#endif
column += len+4;
column += strlen(lpath) + 4;
free(lpath);
}
}
break;
+202 -15
View File
@@ -20,10 +20,35 @@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
/*
* June 29, 2001 Manuel Novoa III
*
* Added MD5SUM_SIZE_VS_SPEED configuration option.
*
* Current valid values, with data from my system for comparison, are:
* (using uClibc and running on linux-2.4.4.tar.bz2)
* user times (sec) text size (386)
* 0 (fastest) 1.1 6144
* 1 1.4 5392
* 2 3.0 5088
* 3 (smallest) 5.1 4912
*/
#define MD5SUM_SIZE_VS_SPEED 2
/**********************************************************************/
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include <sys/types.h>
#if defined HAVE_LIMITS_H
# include <limits.h>
#endif
#include "busybox.h"
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
@@ -60,12 +85,6 @@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include "busybox.h"
//----------------------------------------------------------------------------
//--------md5.h
//----------------------------------------------------------------------------
@@ -93,12 +112,6 @@
#ifndef _MD5_H
static const int _MD5_H = 1;
#include <stdio.h>
#if defined HAVE_LIMITS_H || defined _LIBC
# include <limits.h>
#endif
/* The following contortions are an attempt to use the C preprocessor
to determine an unsigned integral type that is 32 bits wide. An
alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
@@ -106,7 +119,6 @@ static const int _MD5_H = 1;
the resulting executable. Locally running cross-compiled executables
is usually not possible. */
# include <sys/types.h>
typedef u_int32_t md5_uint32;
/* Structure to save state of computation between the single steps. */
@@ -181,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) */
@@ -232,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);
@@ -368,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;
@@ -389,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
@@ -416,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);
@@ -433,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
@@ -448,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);
@@ -464,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);
@@ -482,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);
@@ -500,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;
+31 -69
View File
@@ -2,8 +2,7 @@
/*
* Mini mkdir implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,82 +20,45 @@
*
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
#include "messages.c"
static int parentFlag = FALSE;
static mode_t mode = 0777;
extern int mkdir_main(int argc, char **argv)
extern int mkdir_main (int argc, char **argv)
{
int i = FALSE;
mode_t mode = -1;
int flags = 0;
int status = 0;
int i, opt;
argc--;
argv++;
/* Parse any options */
while (argc > 0 && **argv == '-') {
while (i == FALSE && *++(*argv)) {
switch (**argv) {
case 'm':
if (--argc == 0)
show_usage();
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
error_msg_and_die("Unknown mode: %s", *argv);
}
/* Set the umask for this process so it doesn't
* screw up whatever the user just entered. */
umask(0);
i = TRUE;
break;
case 'p':
parentFlag = TRUE;
break;
default:
show_usage();
}
while ((opt = getopt (argc, argv, "m:p")) != -1) {
switch (opt) {
case 'm':
mode = 0777;
if (!parse_mode (optarg, &mode))
error_msg_and_die ("invalid mode `%s'", optarg);
break;
case 'p':
flags |= FILEUTILS_RECUR;
break;
default:
show_usage ();
}
argc--;
argv++;
}
if (argc < 1) {
show_usage();
}
if (optind == argc)
show_usage ();
while (argc > 0) {
int status;
struct stat statBuf;
char buf[BUFSIZ + 1];
for (i = optind; i < argc; i++)
if (make_directory (argv[i], mode, flags) < 0)
status = 1;
if (strlen(*argv) > BUFSIZ - 1) {
error_msg_and_die(name_too_long);
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
error_msg_and_die("%s: File exists", buf);
}
if (parentFlag == TRUE) {
strcat(buf, "/");
create_path(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror_msg_and_die(buf);
}
}
argc--;
argv++;
}
return EXIT_SUCCESS;
return status;
}
+168
View File
@@ -0,0 +1,168 @@
/* vi: set sw=4 ts=4: */
/*
* Mini mv implementation for busybox
*
*
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
static int flags;
static int manual_rename(const char *source, const char *dest)
{
struct stat source_stat;
struct stat dest_stat;
int source_exists = 1;
int dest_exists = 1;
if (stat(source, &source_stat) < 0) {
if (errno != ENOENT) {
perror_msg("unable to stat `%s'", source);
return -1;
}
source_exists = 0;
}
if (stat(dest, &dest_stat) < 0) {
if (errno != ENOENT) {
perror_msg("unable to stat `%s'", dest);
return -1;
}
dest_exists = 0;
}
if (dest_exists) {
if (S_ISDIR(dest_stat.st_mode) &&
(!source_exists || !S_ISDIR(source_stat.st_mode))) {
error_msg("cannot overwrite directory with non-directory");
return -1;
}
if (!S_ISDIR(dest_stat.st_mode) && source_exists &&
S_ISDIR(source_stat.st_mode)) {
error_msg("cannot overwrite non-directory with directory");
return -1;
}
if (unlink(dest) < 0) {
perror_msg("cannot remove `%s'", dest);
return -1;
}
}
if (copy_file(source, dest, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS |
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;
}
+31 -92
View File
@@ -3,12 +3,8 @@
* Mini rm implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* INTERACTIVE feature Copyright (C) 2001 by Alcove
* written by Christophe Boyanique <Christophe.Boyanique@fr.alcove.com>
* for Ipanema Technologies
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,106 +29,49 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
static int recursiveFlag = FALSE;
static int forceFlag = FALSE;
#ifdef BB_FEATURE_RM_INTERACTIVE
static int interactiveFlag = FALSE;
#endif
static const char *srcName;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
#ifdef BB_FEATURE_RM_INTERACTIVE
if (interactiveFlag == TRUE) {
printf("rm: remove `%s'? ", fileName);
if (ask_confirmation() == 0)
return (TRUE);
}
#endif
if (unlink(fileName) < 0) {
perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
}
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
perror_msg("%s", fileName);
return (FALSE);
}
#ifdef BB_FEATURE_RM_INTERACTIVE
if (interactiveFlag == TRUE) {
printf("rm: remove directory `%s'? ", fileName);
if (ask_confirmation() == 0)
return (TRUE);
}
#endif
if (rmdir(fileName) < 0) {
perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
}
extern int rm_main(int argc, char **argv)
{
int status = 0;
int opt;
int status = EXIT_SUCCESS;
struct stat statbuf;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Rrf-"
#ifdef BB_FEATURE_RM_INTERACTIVE
"i"
#endif
)) > 0) {
int flags = 0;
int i;
while ((opt = getopt(argc, argv, "fiRr")) != -1) {
switch (opt) {
case 'R':
case 'r':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
#ifdef BB_FEATURE_RM_INTERACTIVE
case 'i':
interactiveFlag = TRUE;
#endif
break;
default:
show_usage();
case 'f':
flags &= ~FILEUTILS_INTERACTIVE;
flags |= FILEUTILS_FORCE;
break;
case 'i':
flags &= ~FILEUTILS_FORCE;
flags |= FILEUTILS_INTERACTIVE;
break;
case 'R':
case 'r':
flags |= FILEUTILS_RECUR;
break;
}
}
if (argc == optind && forceFlag == FALSE) {
if (!(flags & FILEUTILS_FORCE) && optind == argc)
show_usage();
}
#ifdef BB_FEATURE_RM_INTERACTIVE
if (forceFlag == TRUE)
interactiveFlag = FALSE;
#endif
for (i = optind; i < argc; i++) {
char *base = get_last_path_component(argv[i]);
while (optind < argc) {
srcName = argv[optind];
if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0
&& errno == ENOENT) {
/* do not reports errors for non-existent files if -f, just skip them */
} else {
if (recursive_action(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
status = EXIT_FAILURE;
}
if (strcmp(base, ".") == 0 || strcmp(base, "..") == 0) {
error_msg("cannot remove `.' or `..'");
status = 1;
continue;
}
optind++;
if (remove_file(argv[i], flags) < 0)
status = 1;
}
return status;
}
+24 -8
View File
@@ -33,7 +33,8 @@ static int compare_ascii(const void *x, const void *y)
static int compare_numeric(const void *x, const void *y)
{
return atoi(*(char **)x) - atoi(*(char **)y);
int z = atoi(*(char **)x) - atoi(*(char **)y);
return z ? z : strcmp(*(char **)x, *(char **)y);
}
int sort_main(int argc, char **argv)
@@ -45,8 +46,11 @@ int sort_main(int argc, char **argv)
#ifdef BB_FEATURE_SORT_REVERSE
int reverse = FALSE;
#endif
#ifdef BB_FEATURE_SORT_UNIQUE
int unique = FALSE;
#endif
while ((opt = getopt(argc, argv, "nr")) != -1) {
while ((opt = getopt(argc, argv, "nru")) != -1) {
switch (opt) {
case 'n':
compare = compare_numeric;
@@ -55,6 +59,11 @@ int sort_main(int argc, char **argv)
case 'r':
reverse = TRUE;
break;
#endif
#ifdef BB_FEATURE_SORT_UNIQUE
case 'u':
unique = TRUE;
break;
#endif
default:
show_usage();
@@ -70,6 +79,7 @@ int sort_main(int argc, char **argv)
while ((line = get_line_from_file(fp)) != NULL) {
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
chomp(line);
lines[nlines++] = line;
}
}
@@ -79,12 +89,18 @@ int sort_main(int argc, char **argv)
/* print it */
#ifdef BB_FEATURE_SORT_REVERSE
if (reverse)
for (i = nlines - 1; 0 <= i; i--)
fputs(lines[i], stdout);
else
if (reverse) {
for (i = --nlines; 0 <= i; i--)
#ifdef BB_FEATURE_SORT_UNIQUE
if((!unique) || (i == nlines) || (strcmp(lines[i + 1], lines[i])))
#endif
for (i = 0; i < nlines; i++)
fputs(lines[i], stdout);
puts(lines[i]);
} else
#endif
for (i = 0; i < nlines; i++)
#ifdef BB_FEATURE_SORT_UNIQUE
if((!unique) || (!i) || (strcmp(lines[i - 1], lines[i])))
#endif
puts(lines[i]);
return EXIT_SUCCESS;
}
-67
View File
@@ -1362,76 +1362,9 @@ static const char *visible(unsigned int ch)
}
#ifdef TEST
unsigned long parse_number(const char *numstr,
const struct suffix_mult *suffixes)
{
const struct suffix_mult *sm;
unsigned long int ret;
int len;
char *end;
ret = strtoul(numstr, &end, 10);
if (numstr == end)
error_msg_and_die("invalid number `%s'", numstr);
while (end[0] != '\0') {
sm = suffixes;
while ( sm != 0 ) {
if(sm->suffix) {
len = strlen(sm->suffix);
if (strncmp(sm->suffix, end, len) == 0) {
ret *= sm->mult;
end += len;
break;
}
sm++;
} else
sm = 0;
}
if (sm == 0)
error_msg_and_die("invalid number `%s'", numstr);
}
return ret;
}
const char *applet_name = "stty";
static void verror_msg(const char *s, va_list p)
{
fflush(stdout);
fprintf(stderr, "%s: ", applet_name);
vfprintf(stderr, s, p);
}
extern void error_msg_and_die(const char *s, ...)
{
va_list p;
va_start(p, s);
verror_msg(s, p);
va_end(p);
putc('\n', stderr);
exit(EXIT_FAILURE);
}
static void vperror_msg(const char *s, va_list p)
{
int err=errno;
verror_msg(s, p);
if (*s) s = ": ";
fprintf(stderr, "%s%s\n", s, strerror(err));
}
extern void perror_msg_and_die(const char *s, ...)
{
va_list p;
va_start(p, s);
vperror_msg(s, p);
va_end(p);
exit(EXIT_FAILURE);
}
#endif
/*
+10 -6
View File
@@ -73,7 +73,7 @@ int tail_main(int argc, char **argv)
case 'f':
follow = 1;
break;
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef BB_FEATURE_FANCY_TAIL
case 'c':
units = BYTES;
/* FALLS THROUGH */
@@ -85,7 +85,7 @@ int tail_main(int argc, char **argv)
if (optarg[0] == '+')
from_top = 1;
break;
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef BB_FEATURE_FANCY_TAIL
case 'q':
hide_headers = 1;
break;
@@ -118,7 +118,7 @@ int tail_main(int argc, char **argv)
}
}
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef BB_FEATURE_FANCY_TAIL
/* tail the files */
if (!from_top && units == BYTES)
tailbuf = xmalloc(count);
@@ -127,12 +127,16 @@ int tail_main(int argc, char **argv)
for (i = 0; i < nfiles; i++) {
if (fds[i] == -1)
continue;
if (!count) {
lseek(fds[i], 0, SEEK_END);
continue;
}
seen = 0;
if (show_headers || (!hide_headers && nfiles > 1))
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
if (from_top) {
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef BB_FEATURE_FANCY_TAIL
if (units == BYTES) {
if (count - 1 <= seen)
nwrite = nread;
@@ -165,7 +169,7 @@ int tail_main(int argc, char **argv)
break;
}
} else {
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef BB_FEATURE_FANCY_TAIL
if (units == BYTES) {
if (nread < count) {
memmove(tailbuf, tailbuf + nread, count - nread);
@@ -199,7 +203,7 @@ int tail_main(int argc, char **argv)
status = EXIT_FAILURE;
}
#ifndef BB_FEATURE_SIMPLE_TAIL
#ifdef BB_FEATURE_FANCY_TAIL
if (!from_top && units == BYTES) {
if (count < seen)
seen = count;
-3
View File
@@ -38,9 +38,6 @@
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
+9 -6
View File
@@ -30,13 +30,12 @@
#include <unistd.h>
#include <sys/types.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_write_error
#include "messages.c"
static const int ASCII = 0377;
/* This must be a #define, since when DODEBUG and BUFFERS_GO_IN_BSS are
* enabled, we otherwise get a "storage size isn't constant error. */
#define ASCII 0377
/* some glabals shared across this file */
/* some "globals" shared across this file */
static char com_fl, del_fl, sq_fl;
static short in_index, out_index;
/* these last are pointers to static buffers declared in tr_main */
@@ -93,6 +92,10 @@ static void map(register unsigned char *string1, unsigned int string1_len,
}
}
/* supported constructs:
* Ranges, e.g., [0-9] ==> 0123456789
* Escapes, e.g., \a ==> Control-G
*/
static unsigned int expand(const char *arg, register unsigned char *buffer)
{
unsigned char *buffer_start = buffer;
@@ -113,7 +116,7 @@ static unsigned int expand(const char *arg, register unsigned char *buffer)
ac = *arg++;
while (i <= ac)
*buffer++ = i++;
arg++; /* Skip ']' */
arg++; /* Skip the assumed ']' */
} else
*buffer++ = *arg++;
}
+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;
}
-325
View File
@@ -1,325 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini `cp' and `mv' implementation for BusyBox.
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Copyright (C) 2000 by BitterSweet Enterprises, LLC. (GPL)
* Extensively modified and rewritten by Karl M. Hegbloom <karlheg@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <time.h>
#include <utime.h>
#include <dirent.h>
#include <sys/param.h>
#include <setjmp.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#include <stdlib.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_omitting_directory
#define bb_need_not_a_directory
#include "messages.c"
static const int is_cp = 0;
static const int is_mv = 1;
static int dz_i; /* index into cp_mv_usage */
static int recursiveFlag;
static int followLinks;
static int preserveFlag;
static int forceFlag;
static const char *baseSrcName;
static int srcDirFlag;
static struct stat srcStatBuf;
static char *pBaseDestName;
static size_t baseDestLen;
static int destDirFlag;
static struct stat destStatBuf;
static jmp_buf catch;
static volatile int mv_Action_first_time;
static void name_too_long__exit (void) __attribute__((noreturn));
static
void name_too_long__exit (void)
{
error_msg_and_die(name_too_long);
}
static void
fill_baseDest_buf(char *_buf, size_t * _buflen) {
const char *srcBasename;
if ((srcBasename = strrchr(baseSrcName, '/')) == NULL) {
srcBasename = baseSrcName;
if (_buf[*_buflen - 1] != '/') {
if (++(*_buflen) > BUFSIZ)
name_too_long__exit();
strcat(_buf, "/");
}
}
if (*_buflen + strlen(srcBasename) > BUFSIZ)
name_too_long__exit();
strcat(_buf, srcBasename);
return;
}
static int
cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
{
char destName[BUFSIZ + 1];
size_t destLen;
const char *srcBasename;
char *name;
strcpy(destName, pBaseDestName);
destLen = strlen(destName);
if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) {
error_msg(omitting_directory, baseSrcName);
return TRUE;
}
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
if (destLen + strlen(srcBasename) > BUFSIZ) {
error_msg(name_too_long);
return FALSE;
}
strcat(destName, srcBasename);
}
else if (destDirFlag == TRUE) {
fill_baseDest_buf(&destName[0], &destLen);
}
else {
srcBasename = baseSrcName;
}
if (mv_Action_first_time && (dz_i == is_mv)) {
mv_Action_first_time = errno = 0;
if (rename(fileName, destName) < 0 && errno != EXDEV) {
perror_msg("rename(%s, %s)", fileName, destName);
goto do_copyFile; /* Try anyway... */
}
else if (errno == EXDEV)
goto do_copyFile;
else
longjmp(catch, 1); /* succeeded with rename() */
}
do_copyFile:
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
if (is_in_ino_dev_hashtable(statbuf, &name)) {
if (link(name, destName) < 0) {
perror_msg("link(%s, %s)", name, destName);
return FALSE;
}
return TRUE;
}
else {
add_to_ino_dev_hashtable(statbuf, destName);
}
}
return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
}
static int
rm_Action(const char *fileName, struct stat *statbuf, void* junk)
{
int status = TRUE;
if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) {
perror_msg("rmdir(%s)", fileName);
status = FALSE;
}
} else if (unlink(fileName) < 0) {
perror_msg("unlink(%s)", fileName);
status = FALSE;
}
return status;
}
extern int cp_mv_main(int argc, char **argv)
{
volatile int i;
int c;
RESERVE_BB_BUFFER(baseDestName,BUFSIZ + 1);
pBaseDestName = baseDestName; /* available globally */
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
dz_i = is_cp;
else
dz_i = is_mv;
if (argc < 3)
show_usage();
if (dz_i == is_cp) {
recursiveFlag = preserveFlag = forceFlag = FALSE;
followLinks = TRUE;
while ((c = getopt(argc, argv, "adpRf")) != EOF) {
switch (c) {
case 'a':
followLinks = FALSE;
preserveFlag = TRUE;
recursiveFlag = TRUE;
break;
case 'd':
followLinks = FALSE;
break;
case 'p':
preserveFlag = TRUE;
break;
case 'R':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
default:
show_usage();
}
}
if ((argc - optind) < 2) {
show_usage();
}
} else { /* (dz_i == is_mv) */
/* Initialize optind to 1, since in libc5 optind
* is not initialized until getopt() is called
* (or until sneaky programmers force it...). */
optind = 1;
recursiveFlag = preserveFlag = TRUE;
followLinks = FALSE;
}
if (strlen(argv[argc - 1]) > BUFSIZ) {
error_msg(name_too_long);
goto exit_false;
}
strcpy(baseDestName, argv[argc - 1]);
baseDestLen = strlen(baseDestName);
if (baseDestLen == 0)
goto exit_false;
destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
if (argc - optind > 2 && destDirFlag == FALSE) {
error_msg(not_a_directory, baseDestName);
goto exit_false;
}
for (i = optind; i < (argc-1); i++) {
size_t srcLen;
volatile int flags_memo;
int status;
baseSrcName=argv[i];
if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
name_too_long__exit();
if (srcLen == 0) continue; /* "" */
srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
if ((flags_memo = (recursiveFlag == TRUE &&
srcDirFlag == TRUE && destDirFlag == TRUE))) {
struct stat sb;
int state = 0;
char *pushd, *d, *p;
if ((pushd = xgetcwd(0)) == NULL)
continue;
if (chdir(baseDestName) < 0) {
perror_msg("chdir(%s)", baseSrcName);
continue;
}
if ((d = xgetcwd(0)) == NULL)
continue;
while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
perror_msg("stat(%s)", d);
state = -1;
continue;
}
if ((sb.st_ino == srcStatBuf.st_ino) &&
(sb.st_dev == srcStatBuf.st_dev)) {
error_msg("Cannot %s `%s' into a subdirectory of itself, "
"`%s/%s'", applet_name, baseSrcName,
baseDestName, baseSrcName);
state = -1;
continue;
}
if ((p = strrchr(d, '/')) != NULL) {
*p = '\0';
}
}
if (chdir(pushd) < 0) {
perror_msg("chdir(%s)", pushd);
free(pushd);
free(d);
continue;
}
free(pushd);
free(d);
if (state < 0)
continue;
else
fill_baseDest_buf(baseDestName, &baseDestLen);
}
status = setjmp(catch);
if (status == 0) {
mv_Action_first_time = 1;
if (recursive_action(baseSrcName,
recursiveFlag, followLinks, FALSE,
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
if (dz_i == is_mv &&
recursive_action(baseSrcName,
recursiveFlag, followLinks, TRUE,
rm_Action, rm_Action, NULL) == FALSE) goto exit_false;
}
if (flags_memo)
*(baseDestName + baseDestLen) = '\0';
}
return EXIT_SUCCESS;
exit_false:
return EXIT_FAILURE;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+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;
}
+236 -124
View File
@@ -24,8 +24,7 @@
#include <stdlib.h>
#include <unistd.h> /* getopt */
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include "busybox.h"
@@ -34,65 +33,228 @@ extern int optind;
extern char *optarg;
/* globals in this file only */
/* option vars */
static char part = 0; /* (b)yte, (c)har, (f)ields */
static int startpos = 1;
static int endpos = -1;
static char delim = '\t'; /* delimiter, default is tab */
static unsigned int supress_non_delimited_lines = 0;
static char delim = '\t'; /* delimiter, default is tab */
struct cut_list {
int startpos;
int endpos;
};
static const int BOL = 0;
static const int EOL = INT_MAX;
static const int NON_RANGE = -1;
static struct cut_list *cut_lists = NULL; /* growable array holding a series of lists */
static unsigned int nlists = 0; /* number of elements in above list */
static int cmpfunc(const void *a, const void *b)
{
struct cut_list *la = (struct cut_list *)a;
struct cut_list *lb = (struct cut_list *)b;
if (la->startpos > lb->startpos)
return 1;
if (la->startpos < lb->startpos)
return -1;
return 0;
}
/*
* decompose_list() - parses a list and puts values into startpos and endpos.
* parse_lists() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
* more than one list can be seperated by commas
*/
static void decompose_list(const char *list)
static void parse_lists(char *lists)
{
unsigned int nminus = 0;
char *ptr;
char *ltok = NULL;
char *ntok = NULL;
char *junk;
int s = 0, e = 0;
/* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') {
error_msg_and_die("invalid byte or field list");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
/* take apart the lists, one by one (they are seperated with commas */
while ((ltok = strsep(&lists, ",")) != NULL) {
/* it's actually legal to pass an empty list */
if (strlen(ltok) == 0)
continue;
/* get the start pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
fprintf(stderr, "Help ntok is null for starting position! What do I do?\n");
} else if (strlen(ntok) == 0) {
s = BOL;
} else {
s = strtoul(ntok, &junk, 10);
if(*junk != '\0' || s < 0)
error_msg_and_die("invalid byte or field list");
/* account for the fact that arrays are zero based, while the user
* expects the first char on the line to be char # 1 */
if (s != 0)
s--;
}
/* get the end pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
e = NON_RANGE;
} else if (strlen(ntok) == 0) {
e = EOL;
} else {
e = strtoul(ntok, &junk, 10);
if(*junk != '\0' || e < 0)
error_msg_and_die("invalid byte or field list");
/* if the user specified and end position of 0, that means "til the
* end of the line */
if (e == 0)
e = INT_MAX;
e--; /* again, arrays are zero based, lines are 1 based */
if (e == s)
e = NON_RANGE;
}
/* if there's something left to tokenize, the user past an invalid list */
if (ltok)
error_msg_and_die("invalid byte or field list");
/* add the new list */
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
cut_lists[nlists-1].startpos = s;
cut_lists[nlists-1].endpos = e;
}
/* make sure we got some cut positions out of all that */
if (nlists == 0)
error_msg_and_die("missing list of positions");
/* now that the lists are parsed, we need to sort them to make life easier
* on us when it comes time to print the chars / fields / lines */
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
}
static void cut_line_by_chars(const char *line)
{
int c, l;
/* set up a list so we can keep track of what's been printed */
char *printed = xcalloc(strlen(line), sizeof(char));
/* print the chars specified in each cut list */
for (c = 0; c < nlists; c++) {
l = cut_lists[c].startpos;
while (l < strlen(line)) {
if (!printed[l]) {
putchar(line[l]);
printed[l] = 'X';
}
l++;
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos)
break;
}
}
putchar('\n'); /* cuz we were handed a chomped line */
free(printed);
}
static void cut_line_by_fields(char *line)
{
int c, f;
int ndelim = -1; /* zero-based / one-based problem */
int nfields_printed = 0;
char *field = NULL;
char d[2] = { delim, 0 };
char *printed;
/* test the easy case first: does this line contain any delimiters? */
if (strchr(line, delim) == NULL) {
if (!supress_non_delimited_lines)
puts(line);
return;
}
/* set up a list so we can keep track of what's been printed */
printed = xcalloc(strlen(line), sizeof(char));
/* process each list on this line, for as long as we've got a line to process */
for (c = 0; c < nlists && line; c++) {
f = cut_lists[c].startpos;
do {
/* find the field we're looking for */
while (line && ndelim < f) {
field = strsep(&line, d);
ndelim++;
}
/* we found it, and it hasn't been printed yet */
if (field && ndelim == f && !printed[ndelim]) {
/* if this isn't our first time through, we need to print the
* delimiter after the last field that was printed */
if (nfields_printed > 0)
putchar(delim);
fputs(field, stdout);
printed[ndelim] = 'X';
nfields_printed++;
}
f++;
/* keep going as long as we have a line to work with, this is a
* list, and we're not at the end of that list */
} while (line && cut_lists[c].endpos != NON_RANGE && f <= cut_lists[c].endpos);
}
/* if we printed anything at all, we need to finish it with a newline cuz
* we were handed a chomped line */
putchar('\n');
free(printed);
}
static void cut_file_by_lines(const char *line, unsigned int linenum)
{
static int c = 0;
static int l = -1;
/* I can't initialize this above cuz the "initializer isn't
* constant" *sigh* */
if (l == -1)
l = cut_lists[c].startpos;
/* get out if we have no more lists to process or if the lines are lower
* than what we're interested in */
if (c >= nlists || linenum < l)
return;
/* if the line we're looking for is lower than the one we were passed, it
* means we displayed it already, so move on */
while (l < linenum) {
l++;
/* move on to the next list if we're at the end of this one */
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos) {
c++;
/* get out if there's no more lists to process */
if (c >= nlists)
return;
l = cut_lists[c].startpos;
/* get out if the current line is lower than the one we just became
* interested in */
if (linenum < l)
return;
}
}
/* handle single value 'N' case */
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
error_msg_and_die("missing list of fields");
}
endpos = startpos;
}
/* handle multi-value cases */
else if (nminus == 1) {
/* handle 'N-' case */
if (list[strlen(list) - 1] == '-') {
startpos = strtol(list, &ptr, 10);
}
/* handle '-M' case */
else if (list[0] == '-') {
endpos = strtol(&list[1], NULL, 10);
}
/* handle 'N-M' case */
else {
startpos = strtol(list, &ptr, 10);
endpos = strtol(ptr+1, &ptr, 10);
}
/* a sanity check */
if (startpos == 0) {
startpos = 1;
}
}
/* If we made it here, it means we've found the line we're looking for, so print it */
puts(line);
}
@@ -101,82 +263,31 @@ static void decompose_list(const char *list)
*/
static void cut_file(FILE *file)
{
char *line;
unsigned int cr_hits = 0;
char *line = NULL;
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
/* cut based on chars/bytes */
if (part == 'c' || part == 'b') {
int i;
/* a valid end position has been specified */
if (endpos > 0) {
for (i = startpos-1; i < endpos; i++) {
fputc(line[i], stdout);
}
fputc('\n', stdout);
}
/* otherwise, just go to the end of the line */
else {
for (i = startpos-1; line[i]; i++) {
fputc(line[i], stdout);
}
}
}
while ((line = get_line_from_file(file)) != NULL) {
chomp(line);
/* cut based on chars/bytes XXX: only works when sizeof(char) == byte */
if (part == 'c' || part == 'b')
cut_line_by_chars(line);
/* cut based on fields */
else if (part == 'f') {
char *ptr;
char *start = line;
unsigned int delims_hit = 0;
if (delim == '\n') {
cr_hits++;
if (cr_hits >= startpos && cr_hits <= endpos) {
while (*start && *start != '\n') {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
}
else {
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
delims_hit++;
if (delims_hit == (startpos - 1)) {
start = ptr+1;
}
if (delims_hit == endpos) {
break;
}
}
/* we didn't hit any delimeters */
if (delims_hit == 0 && !supress_non_delimited_lines) {
fputs(line, stdout);
}
/* we =did= hit some delimiters */
else if (delims_hit > 0) {
/* we have a fixed end point */
if (ptr) {
while (start < ptr) {
fputc(*start, stdout);
start++;
}
fputc('\n', stdout);
}
/* or we're just going til the end of the line */
else {
while (*start) {
fputc(*start, stdout);
start++;
}
}
}
}
if (delim == '\n')
cut_file_by_lines(line, linenum);
else
cut_line_by_fields(line);
}
linenum++;
free(line);
}
}
extern int cut_main(int argc, char **argv)
{
int opt;
@@ -191,7 +302,7 @@ extern int cut_main(int argc, char **argv)
error_msg_and_die("only one type of list may be specified");
}
part = (char)opt;
decompose_list(optarg);
parse_lists(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
@@ -212,14 +323,15 @@ extern int cut_main(int argc, char **argv)
error_msg_and_die("you must specify a list of bytes, characters, or fields");
}
if (supress_non_delimited_lines && part != 'f') {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
/* non-field (char or byte) cutting has some special handling */
if (part != 'f') {
if (supress_non_delimited_lines) {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
}
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
+2 -6
View File
@@ -29,10 +29,6 @@
#include <string.h>
#include <getopt.h>
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
#include "messages.c"
/* This 'date' command supports only 2 time setting formats,
@@ -203,7 +199,7 @@ int date_main(int argc, char **argv)
date_conv_time(&tm_time, date_str);
}
/* Correct any day of week and day of year etc fields */
/* Correct any day of week and day of year etc. fields */
tm = mktime(&tm_time);
if (tm < 0)
error_msg_and_die(invalid_date, date_str);
@@ -245,7 +241,7 @@ int date_main(int argc, char **argv)
/* Print OUTPUT (after ALL that!) */
t_buff = xmalloc(201);
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
puts(t_buff);
return EXIT_SUCCESS;
}
+116 -76
View File
@@ -2,20 +2,24 @@
// 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
//// This file is parsed by sed. You MUST use single line comments.
// i.e., //#define BB_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP_MV
#define BB_CP
//#define BB_CPIO
#define BB_CUT
#define BB_DATE
//#define BB_DC
@@ -31,8 +35,8 @@
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
//#define BB_ENV
//#define BB_EXPR
#define BB_ENV
#define BB_EXPR
//#define BB_FBSET
//#define BB_FDFLUSH
#define BB_FIND
@@ -75,6 +79,7 @@
#define BB_MORE
#define BB_MOUNT
//#define BB_MT
#define BB_MV
//#define BB_NSLOOKUP
#define BB_PING
//#define BB_PIVOT_ROOT
@@ -91,10 +96,10 @@
#define BB_RMDIR
//#define BB_RMMOD
//#define BB_ROUTE
//#define BB_RPMUNPACK
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SH
//#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
@@ -111,6 +116,7 @@
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
@@ -119,7 +125,7 @@
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
//#define BB_VI
#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
#define BB_WGET
@@ -131,17 +137,57 @@
//
//
//
// ---------------------------------------------------------
// 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
@@ -181,8 +227,8 @@
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
// 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
@@ -202,9 +248,9 @@
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//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_SIMPLE_TAIL
#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
@@ -218,12 +264,9 @@
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// use -i (interactive) flag for rm
//#define BB_FEATURE_RM_INTERACTIVE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
@@ -233,9 +276,12 @@
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
// 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
@@ -251,7 +297,7 @@
//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
//#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
@@ -262,12 +308,11 @@
// Only relevant if BB_SH is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Some deeply embedded systems don't have usernames or even hostnames,
// and the default prompt can look rather hideous on them. Uncomment
// this option for a simpler, path-only prompt (which was the default until
// around BusyBox-0.48). On by default.
// 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_SIMPLE_PROMPT
//#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -284,6 +329,12 @@
// 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
//
@@ -297,7 +348,7 @@
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
//#define BB_FEATURE_IFCONFIG_HW
#define BB_FEATURE_IFCONFIG_HW
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
@@ -337,6 +388,23 @@
#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
//
//
@@ -351,20 +419,36 @@
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#define BB_FEATURE_SH_SIMPLE_PROMPT
#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_COMMAND_EDITING
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_SIMPLE_PROMPT
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
@@ -377,50 +461,10 @@
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#ifdef BB_DPKG
#ifndef BB_DPKG_DEB
#define BB_DPKG_DEB
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_IFCONFIG
#ifdef BB_FEATURE_IFCONFIG_STATUS
#define BB_INTERFACE
#endif
#else
#undef BB_INTERFACE
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
@@ -438,7 +482,3 @@
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_DOS2UNIX
#define BB_UNIX2DOS
#endif
+113 -73
View File
@@ -2,20 +2,24 @@
// 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
//// This file is parsed by sed. You MUST use single line comments.
// i.e., //#define BB_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
#define BB_CMP
#define BB_CP_MV
#define BB_CP
#define BB_CPIO
#define BB_CUT
#define BB_DATE
#define BB_DC
@@ -75,6 +79,7 @@
#define BB_MORE
#define BB_MOUNT
#define BB_MT
#define BB_MV
#define BB_NSLOOKUP
#define BB_PING
#define BB_PIVOT_ROOT
@@ -91,7 +96,7 @@
#define BB_RMDIR
#define BB_RMMOD
#define BB_ROUTE
#define BB_RPMUNPACK
#define BB_RPM2CPIO
#define BB_SED
#define BB_SETKEYCODES
#define BB_SH
@@ -111,6 +116,7 @@
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UNIX2DOS
#define BB_UUENCODE
#define BB_UUDECODE
#define BB_UMOUNT
@@ -131,17 +137,57 @@
//
//
//
// ---------------------------------------------------------
// 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
@@ -181,8 +227,8 @@
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
// 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
@@ -202,9 +248,9 @@
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//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_SIMPLE_TAIL
#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
@@ -218,12 +264,9 @@
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// use -i (interactive) flag for rm
//#define BB_FEATURE_RM_INTERACTIVE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
@@ -233,9 +276,12 @@
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
// 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
@@ -262,12 +308,11 @@
// Only relevant if BB_SH is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Some deeply embedded systems don't have usernames or even hostnames,
// and the default prompt can look rather hideous on them. Uncomment
// this option for a simpler, path-only prompt (which was the default until
// around BusyBox-0.48). On by default.
// 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_SIMPLE_PROMPT
#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -284,6 +329,12 @@
// 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
//
@@ -291,10 +342,10 @@
#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
#define BB_FEATURE_IFCONFIG_SLIP
//#define BB_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
#define BB_FEATURE_IFCONFIG_HW
@@ -302,7 +353,7 @@
// 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
#define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
@@ -337,6 +388,23 @@
#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
//
//
@@ -351,20 +419,36 @@
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#define BB_FEATURE_SH_SIMPLE_PROMPT
#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_COMMAND_EDITING
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_SIMPLE_PROMPT
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
@@ -377,50 +461,10 @@
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#ifdef BB_DPKG
#ifndef BB_DPKG_DEB
#define BB_DPKG_DEB
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_IFCONFIG
#ifdef BB_FEATURE_IFCONFIG_STATUS
#define BB_INTERFACE
#endif
#else
#undef BB_INTERFACE
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
@@ -438,7 +482,3 @@
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_DOS2UNIX
#define BB_UNIX2DOS
#endif
+122 -82
View File
@@ -2,20 +2,24 @@
// 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
//// This file is parsed by sed. You MUST use single line comments.
// i.e., //#define BB_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
//#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP_MV
#define BB_CP
//#define BB_CPIO
#define BB_CUT
#define BB_DATE
//#define BB_DC
@@ -31,8 +35,8 @@
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
//#define BB_ENV
//#define BB_EXPR
#define BB_ENV
#define BB_EXPR
//#define BB_FBSET
//#define BB_FDFLUSH
#define BB_FIND
@@ -58,13 +62,13 @@
#define BB_LN
//#define BB_LOADACM
//#define BB_LOADFONT
//#define BB_LOADKMAP
#define BB_LOADKMAP
#define BB_LOGGER
//#define BB_LOGNAME
#define BB_LS
#define BB_LSMOD
//#define BB_MAKEDEVS
//#define BB_MD5SUM
#define BB_MD5SUM
#define BB_MKDIR
//#define BB_MKFIFO
//#define BB_MKFS_MINIX
@@ -75,8 +79,9 @@
#define BB_MORE
#define BB_MOUNT
//#define BB_MT
#define BB_MV
//#define BB_NSLOOKUP
//#define BB_PING
#define BB_PING
#define BB_PIVOT_ROOT
#define BB_POWEROFF
//#define BB_PRINTF
@@ -91,7 +96,7 @@
#define BB_RMDIR
//#define BB_RMMOD
//#define BB_ROUTE
//#define BB_RPMUNPACK
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
//#define BB_SH
@@ -105,12 +110,13 @@
#define BB_TAR
//#define BB_TEE
//#define BB_TEST
//#define BB_TELNET
#define BB_TELNET
//#define BB_TFTP
#define BB_TOUCH
//#define BB_TR
#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
@@ -119,10 +125,10 @@
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
//#define BB_VI
#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
//#define BB_WGET
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_XARGS
@@ -131,17 +137,57 @@
//
//
//
// ---------------------------------------------------------
// 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
@@ -181,8 +227,8 @@
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
// 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
@@ -202,9 +248,9 @@
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//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_SIMPLE_TAIL
#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
@@ -218,12 +264,9 @@
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e. in case of an unreachable NFS system).
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// use -i (interactive) flag for rm
//#define BB_FEATURE_RM_INTERACTIVE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
@@ -233,9 +276,12 @@
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
// 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
@@ -251,7 +297,7 @@
//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
//#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
@@ -262,12 +308,11 @@
// Only relevant if BB_SH is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Some deeply embedded systems don't have usernames or even hostnames,
// and the default prompt can look rather hideous on them. Uncomment
// this option for a simpler, path-only prompt (which was the default until
// around BusyBox-0.48). On by default.
// 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_SIMPLE_PROMPT
//#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -284,6 +329,12 @@
// 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
//
@@ -297,12 +348,12 @@
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
//#define BB_FEATURE_IFCONFIG_HW
#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
#define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
@@ -337,6 +388,23 @@
#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
//
//
@@ -351,20 +419,36 @@
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#define BB_FEATURE_SH_SIMPLE_PROMPT
#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_COMMAND_EDITING
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_SIMPLE_PROMPT
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
@@ -377,50 +461,10 @@
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#ifdef BB_DPKG
#ifndef BB_DPKG_DEB
#define BB_DPKG_DEB
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_IFCONFIG
#ifdef BB_FEATURE_IFCONFIG_STATUS
#define BB_INTERFACE
#endif
#else
#undef BB_INTERFACE
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
@@ -438,7 +482,3 @@
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_DOS2UNIX
#define BB_UNIX2DOS
#endif
+80
View File
@@ -1,3 +1,83 @@
busybox (1:0.52-1) unstable; urgency=high
* New version released. See changelog for details.
-- Erik Andersen <andersee@debian.org> Sat, 7 Jul 2001 01:23:45 -0600
busybox (1:0.51-10) unstable; urgency=high
* Fix a compile problem with gcc 3.0 on hppa (closes: #102045)
-- Erik Andersen <andersee@debian.org> Sat, 23 Jun 2001 23:55:57 -0600
busybox (1:0.51-9) unstable; urgency=high
* tar was creating leading directories with 0777 permissions as
as reult of faulty umask handling. This fixes it, repairing
a grave security problem in the woody the boot floppies.
(closes: #101169)
-- Erik Andersen <andersee@debian.org> Wed, 20 Jun 2001 16:17:38 -0600
busybox (1:0.51-8) unstable; urgency=high
* Fix cp from /proc, where size=0 (closes: #100369)
* Add some padding to struct sysinfo for m68k.
* Apparently some bugs failed to be closed when master choked
(closes: #99627, #99637, #98571)
* Disable the busybox shell for the .deb, since it is not needed
for the boot floppies.
-- Erik Andersen <andersee@debian.org> Mon, 11 Jun 2001 13:26:07 -0600
busybox (1:0.51-7) unstable; urgency=high
* Fix tar permission setting for existing directories (closes: #99627)
* Do not remove the .cvsignore files on 'make release' (closes: #99637)
-- Erik Andersen <andersee@debian.org> Mon, 4 Jun 2001 10:55:19 -0600
busybox (1:0.51-6) testing unstable; urgency=high
* Update the version in testing so DHCP in the woody boot-floppies will work.
* Enable expr for the boot-floppies (closes: #98433)
* It builds on arm just fine now (closes: #97510)
-- Erik Andersen <andersee@debian.org> Wed, 23 May 2001 14:50:13 -0600
busybox (1:0.51-5) unstable; urgency=low
* Backport a sed fix from 0.52pre
* Backport chroot fix from 0.52pre
-- Erik Andersen <andersee@debian.org> Wed, 16 May 2001 23:50:33 -0600
busybox (1:0.51-4) unstable; urgency=low
* Backport from 0.52pre an endianness bugfix for md5sum
* Backport some updates to grep and sed
* Fix 'wget -O -' so it sets the quiet flag
-- Erik Andersen <andersee@debian.org> Mon, 14 May 2001 14:17:36 -0600
busybox (1:0.51-3) unstable; urgency=low
* This is the "I am an idiot" release.
* Make cp and mv work again (closes: #97290)
* Fix the version number.
-- Erik Andersen <andersee@debian.org> Sat, 12 May 2001 17:35:58 -0600
busybox (0.51-2) unstable; urgency=low
* Backport several release critical fixes into the 0.51 codebase
so the boot-floppies will work again.
* Fix a link ordering problem. (closes: #93362)
* Fixed gunzip (closes: #94331)
* Fixed cp permission setting (closes: #94580)
-- Erik Andersen <andersee@debian.org> Sat, 12 May 2001 11:22:35 -0600
busybox (0.51-1) unstable; urgency=low
* Fixes several critical bugs (see the busybox changelog
+7 -6
View File
@@ -13,8 +13,8 @@ Section: utils
Description: Tiny utilities for small and embedded systems.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for the most common
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
mount, tar, etc). The utilities in BusyBox generally have fewer options than
utilities you would usually find on your desktop system (i.e., ls, cp, mv,
mount, tar, etc.). The utilities in BusyBox generally have fewer options than
their full-featured GNU cousins; however, the options that are included
provide the expected functionality and behave very much like their GNU
counterparts.
@@ -33,8 +33,8 @@ Section: shells
Description: Provides a stand alone rescue shell with tons of builtin utilities.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for the most common
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
mount, tar, etc). The utilities in BusyBox generally have fewer options than
utilities you would usually find on your desktop system (i.e., ls, cp, mv,
mount, tar, etc.). The utilities in BusyBox generally have fewer options than
their full-featured GNU cousins; however, the options that are included
provide the expected functionality and behave very much like their GNU
counterparts.
@@ -50,11 +50,12 @@ Package: busybox-udeb
Architecture: any
Depends: ${shlibs:Depends}
Section: debian-installer
Priority: standard
Description: Tiny utilities for the debian-installer
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for the most common
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
mount, tar, etc). The utilities in BusyBox generally have fewer options than
utilities you would usually find on your desktop system (i.e., ls, cp, mv,
mount, tar, etc.). The utilities in BusyBox generally have fewer options than
their full-featured GNU cousins; however, the options that are included
provide the expected functionality and behave very much like their GNU
counterparts.
+2 -3
View File
@@ -84,10 +84,9 @@ do_static: half_clean build-static install-static
# Now for the .udeb stuff
PACKAGE=busybox-udeb
VERSION=$(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
VERSION=$(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2 | sed -e s/[0-9]://g)
ARCH=$(shell dpkg --print-architecture)
FILENAME=$(PACKAGE)_$(VERSION)_$(ARCH).udeb
PRIORITY=$(shell grep ^Priority: debian/control | cut -d ' ' -f 2)
build-udeb: debian/build-stamp-busybox-udeb
debian/build-stamp-busybox-udeb:
@@ -186,7 +185,7 @@ busybox-udeb: do_udeb
# Don't write your stupid guesses to debian/files.
dh_gencontrol -p$@ -- -fdebian/files~
# Register file manually.
dpkg-distaddfile $(FILENAME) debian-installer $(PRIORITY)
dpkg-distaddfile $(FILENAME) debian-installer standard
dh_md5sums -p$@
dh_builddeb -p$@ --filename=$(FILENAME)
+9 -22
View File
@@ -40,9 +40,6 @@ static int do_df(char *device, const char *mount_point)
struct statfs s;
long blocks_used;
long blocks_percent_used;
#ifdef BB_FEATURE_HUMAN_READABLE
long base;
#endif
if (statfs(mount_point, &s) != 0) {
perror_msg("%s", mount_point);
@@ -60,30 +57,20 @@ static int do_df(char *device, const char *mount_point)
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
find_real_root_device_name( device);
device = find_real_root_device_name(device);
if(device==NULL)
return FALSE;
}
#ifdef BB_FEATURE_HUMAN_READABLE
switch (df_disp_hr) {
case MEGABYTE:
base = KILOBYTE;
break;
case KILOBYTE:
base = 1;
break;
default:
base = 0;
}
printf("%-20s %9s ", device,
make_human_readable_str((unsigned long)(s.f_blocks *
(s.f_bsize/(double)KILOBYTE)), base));
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str((unsigned long)(
(s.f_blocks - s.f_bfree) *
(s.f_bsize/(double)KILOBYTE)), base));
make_human_readable_str( (s.f_blocks - s.f_bfree), s.f_bsize, df_disp_hr));
printf("%9s %3ld%% %s\n",
make_human_readable_str((unsigned long)(s.f_bavail *
(s.f_bsize/(double)KILOBYTE)), base),
blocks_percent_used, mount_point);
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
+2 -12
View File
@@ -30,21 +30,11 @@
extern int dirname_main(int argc, char **argv)
{
char* s;
if ((argc < 2) || (**(argv + 1) == '-'))
show_usage();
argv++;
s=*argv+strlen(*argv)-1;
while (s != *argv && *s == '/') {
*s-- = '\0';
}
s = strrchr(*argv, '/');
if (s != NULL && s == *argv)
s[1] = '\0';
else if (s != NULL)
*s = '\0';
puts(s ? *argv : ".");
puts (dirname (argv[0]));
return EXIT_SUCCESS;
}
+1 -1
View File
@@ -5,4 +5,4 @@ busybox.txt
busybox.ps
busybox.pdf
busybox
busybox.pod
+17 -8
View File
@@ -62,12 +62,12 @@ sub pod_for_usage {
}
my $full = join("\n", @f1);
# prepare notes if they exists
# prepare notes if they exist
my $notes = (defined $usage->{notes})
? "$usage->{notes}\n\n"
: "";
# prepare example if one exists
# prepare examples if they exist
my $example = (defined $usage->{example})
?
"Example:\n\n" .
@@ -107,6 +107,7 @@ sub sgml_for_usage {
# {
# trivial => "...",
# full => "...",
# notes => "...",
# example => "...",
# }
my %docs;
@@ -176,7 +177,13 @@ autodocifier.pl - generate docs for busybox based on usage.h
=head1 SYNOPSIS
autodocifier.pl usage.h > something
autodocifier.pl [OPTION]... [FILE]...
Example:
( cat docs/busybox_header.pod; \
docs/autodocifier.pl usage.h; \
cat docs/busybox_footer.pod ) > docs/busybox.pod
=head1 DESCRIPTION
@@ -186,7 +193,8 @@ Currently, the same content has to be duplicated in 3 places in
slightly different formats -- F<usage.h>, F<docs/busybox.pod>, and
F<docs/busybox.sgml>. This is tedious, so Perl has come to the rescue.
This script was based on a script by Erik Andersen (andersen@lineo.com).
This script was based on a script by Erik Andersen <andersen@lineo.com>
which was in turn based on a script by Mark Whitley <markw@lineo.com>
=head1 OPTIONS
@@ -219,7 +227,7 @@ The following is an example of some data this script might parse.
#define length_full_usage \
"Prints out the length of the specified STRING."
#define length_example_usage \
"$ length "Hello"\n" \
"$ length Hello\n" \
"5\n"
Each entry is a cpp macro that defines a string. The macros are
@@ -249,13 +257,14 @@ is disabled. I<REQUIRED>
=item B<notes>
This is documentation that is intended to go in the POD or SGML, but
not be output when a B<-h> is given to a command. To see an example
not be printed when a B<-h> is given to a command. To see an example
of notes being used, see init_notes_usage. I<OPTIONAL>
=item B<example>
This should be an example of how the command is acutally used.
I<OPTIONAL>
This will not be printed when a B<-h> is given to a command -- it
is inteded only for the POD or SGML documentation. I<OPTIONAL>
=back
@@ -275,4 +284,4 @@ John BEPPU <beppu@lineo.com>
=cut
# $Id: autodocifier.pl,v 1.20 2001/04/10 00:00:05 kraai Exp $
# $Id: autodocifier.pl,v 1.21 2001/04/17 17:09:34 beppu Exp $
+404
View File
@@ -0,0 +1,404 @@
%!PS-Adobe-2.0
%%Title: busybox-growth.ps
%%Creator: gnuplot 3.5 (pre 3.6) patchlevel beta 347
%%CreationDate: Tue Apr 10 14:03:36 2001
%%DocumentFonts: (atend)
%%BoundingBox: 50 40 554 770
%%Orientation: Landscape
%%Pages: (atend)
%%EndComments
/gnudict 120 dict def
gnudict begin
/Color true def
/Solid true def
/gnulinewidth 5.000 def
/userlinewidth gnulinewidth def
/vshift -46 def
/dl {10 mul} def
/hpt_ 31.5 def
/vpt_ 31.5 def
/hpt hpt_ def
/vpt vpt_ def
/M {moveto} bind def
/L {lineto} bind def
/R {rmoveto} bind def
/V {rlineto} bind def
/vpt2 vpt 2 mul def
/hpt2 hpt 2 mul def
/Lshow { currentpoint stroke M
0 vshift R show } def
/Rshow { currentpoint stroke M
dup stringwidth pop neg vshift R show } def
/Cshow { currentpoint stroke M
dup stringwidth pop -2 div vshift R show } def
/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def
/hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def
/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }
{pop pop pop Solid {pop []} if 0 setdash} ifelse } def
/BL { stroke gnulinewidth 2 mul setlinewidth } def
/AL { stroke gnulinewidth 2 div setlinewidth } def
/UL { gnulinewidth mul /userlinewidth exch def } def
/PL { stroke userlinewidth setlinewidth } def
/LTb { BL [] 0 0 0 DL } def
/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def
/LT0 { PL [] 1 0 0 DL } def
/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def
/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def
/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def
/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def
/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def
/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def
/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def
/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def
/Pnt { stroke [] 0 setdash
gsave 1 setlinecap M 0 0 V stroke grestore } def
/Dia { stroke [] 0 setdash 2 copy vpt add M
hpt neg vpt neg V hpt vpt neg V
hpt vpt V hpt neg vpt V closepath stroke
Pnt } def
/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V
currentpoint stroke M
hpt neg vpt neg R hpt2 0 V stroke
} def
/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M
0 vpt2 neg V hpt2 0 V 0 vpt2 V
hpt2 neg 0 V closepath stroke
Pnt } def
/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M
hpt2 vpt2 neg V currentpoint stroke M
hpt2 neg 0 R hpt2 vpt2 V stroke } def
/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M
hpt neg vpt -1.62 mul V
hpt 2 mul 0 V
hpt neg vpt 1.62 mul V closepath stroke
Pnt } def
/Star { 2 copy Pls Crs } def
/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M
0 vpt2 neg V hpt2 0 V 0 vpt2 V
hpt2 neg 0 V closepath fill } def
/TriUF { stroke [] 0 setdash vpt 1.12 mul add M
hpt neg vpt -1.62 mul V
hpt 2 mul 0 V
hpt neg vpt 1.62 mul V closepath fill } def
/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M
hpt neg vpt 1.62 mul V
hpt 2 mul 0 V
hpt neg vpt -1.62 mul V closepath stroke
Pnt } def
/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M
hpt neg vpt 1.62 mul V
hpt 2 mul 0 V
hpt neg vpt -1.62 mul V closepath fill} def
/DiaF { stroke [] 0 setdash vpt add M
hpt neg vpt neg V hpt vpt neg V
hpt vpt V hpt neg vpt V closepath fill } def
/Pent { stroke [] 0 setdash 2 copy gsave
translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
closepath stroke grestore Pnt } def
/PentF { stroke [] 0 setdash gsave
translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
closepath fill grestore } def
/Circle { stroke [] 0 setdash 2 copy
hpt 0 360 arc stroke Pnt } def
/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def
/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450 arc } bind def
/C1 { BL [] 0 setdash 2 copy moveto
2 copy vpt 0 90 arc closepath fill
vpt 0 360 arc closepath } bind def
/C2 { BL [] 0 setdash 2 copy moveto
2 copy vpt 90 180 arc closepath fill
vpt 0 360 arc closepath } bind def
/C3 { BL [] 0 setdash 2 copy moveto
2 copy vpt 0 180 arc closepath fill
vpt 0 360 arc closepath } bind def
/C4 { BL [] 0 setdash 2 copy moveto
2 copy vpt 180 270 arc closepath fill
vpt 0 360 arc closepath } bind def
/C5 { BL [] 0 setdash 2 copy moveto
2 copy vpt 0 90 arc
2 copy moveto
2 copy vpt 180 270 arc closepath fill
vpt 0 360 arc } bind def
/C6 { BL [] 0 setdash 2 copy moveto
2 copy vpt 90 270 arc closepath fill
vpt 0 360 arc closepath } bind def
/C7 { BL [] 0 setdash 2 copy moveto
2 copy vpt 0 270 arc closepath fill
vpt 0 360 arc closepath } bind def
/C8 { BL [] 0 setdash 2 copy moveto
2 copy vpt 270 360 arc closepath fill
vpt 0 360 arc closepath } bind def
/C9 { BL [] 0 setdash 2 copy moveto
2 copy vpt 270 450 arc closepath fill
vpt 0 360 arc closepath } bind def
/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill
2 copy moveto
2 copy vpt 90 180 arc closepath fill
vpt 0 360 arc closepath } bind def
/C11 { BL [] 0 setdash 2 copy moveto
2 copy vpt 0 180 arc closepath fill
2 copy moveto
2 copy vpt 270 360 arc closepath fill
vpt 0 360 arc closepath } bind def
/C12 { BL [] 0 setdash 2 copy moveto
2 copy vpt 180 360 arc closepath fill
vpt 0 360 arc closepath } bind def
/C13 { BL [] 0 setdash 2 copy moveto
2 copy vpt 0 90 arc closepath fill
2 copy moveto
2 copy vpt 180 360 arc closepath fill
vpt 0 360 arc closepath } bind def
/C14 { BL [] 0 setdash 2 copy moveto
2 copy vpt 90 360 arc closepath fill
vpt 0 360 arc } bind def
/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill
vpt 0 360 arc closepath } bind def
/Rec { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto
neg 0 rlineto closepath } bind def
/Square { dup Rec } bind def
/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def
/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def
/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def
/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def
/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill
exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def
/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill
2 copy vpt Square fill
Bsquare } bind def
/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def
/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def
/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill
Bsquare } bind def
/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill
Bsquare } bind def
/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def
/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
2 copy vpt Square fill Bsquare } bind def
/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def
/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def
/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def
/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def
/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def
/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def
/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def
/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def
/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def
/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def
/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def
/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def
/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def
/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def
/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def
/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def
/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def
/DiaE { stroke [] 0 setdash vpt add M
hpt neg vpt neg V hpt vpt neg V
hpt vpt V hpt neg vpt V closepath stroke } def
/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M
0 vpt2 neg V hpt2 0 V 0 vpt2 V
hpt2 neg 0 V closepath stroke } def
/TriUE { stroke [] 0 setdash vpt 1.12 mul add M
hpt neg vpt -1.62 mul V
hpt 2 mul 0 V
hpt neg vpt 1.62 mul V closepath stroke } def
/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M
hpt neg vpt 1.62 mul V
hpt 2 mul 0 V
hpt neg vpt -1.62 mul V closepath stroke } def
/PentE { stroke [] 0 setdash gsave
translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
closepath stroke grestore } def
/CircE { stroke [] 0 setdash
hpt 0 360 arc stroke } def
/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def
/DiaW { stroke [] 0 setdash vpt add M
hpt neg vpt neg V hpt vpt neg V
hpt vpt V hpt neg vpt V Opaque stroke } def
/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M
0 vpt2 neg V hpt2 0 V 0 vpt2 V
hpt2 neg 0 V Opaque stroke } def
/TriUW { stroke [] 0 setdash vpt 1.12 mul add M
hpt neg vpt -1.62 mul V
hpt 2 mul 0 V
hpt neg vpt 1.62 mul V Opaque stroke } def
/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M
hpt neg vpt 1.62 mul V
hpt 2 mul 0 V
hpt neg vpt -1.62 mul V Opaque stroke } def
/PentW { stroke [] 0 setdash gsave
translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
Opaque stroke grestore } def
/CircW { stroke [] 0 setdash
hpt 0 360 arc Opaque stroke } def
/BoxFill { gsave Rec 1 setgray fill grestore } def
end
%%EndProlog
%%Page: 1 1
gnudict begin
gsave
50 50 translate
0.100 0.100 scale
90 rotate
0 -5040 translate
0 setgray
newpath
(Helvetica) findfont 140 scalefont setfont
1.000 UL
LTb
560 420 M
63 0 V
6409 0 R
-63 0 V
476 420 M
(0) Rshow
560 1056 M
63 0 V
6409 0 R
-63 0 V
-6493 0 R
(100) Rshow
560 1692 M
63 0 V
6409 0 R
-63 0 V
-6493 0 R
(200) Rshow
560 2328 M
63 0 V
6409 0 R
-63 0 V
-6493 0 R
(300) Rshow
560 2964 M
63 0 V
6409 0 R
-63 0 V
-6493 0 R
(400) Rshow
560 3600 M
63 0 V
6409 0 R
-63 0 V
-6493 0 R
(500) Rshow
560 4236 M
63 0 V
6409 0 R
-63 0 V
-6493 0 R
(600) Rshow
560 4872 M
63 0 V
6409 0 R
-63 0 V
-6493 0 R
(700) Rshow
1531 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
(400) Cshow
2825 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
(600) Cshow
4120 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
(800) Cshow
5414 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
(1000) Cshow
6708 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
(1200) Cshow
1.000 UL
LTb
560 420 M
6472 0 V
0 4452 V
-6472 0 V
560 420 L
0 2646 M
currentpoint gsave translate 90 rotate 0 0 M
(tar.gz size \(Kb\)) Cshow
grestore
3796 140 M
(time \(days since Jan 1, 1998\)) Cshow
1.000 UL
LT0
696 420 M
0 593 V
1255 0 V
0 15 V
214 0 V
0 6 V
958 0 V
0 1 V
-84 0 V
0 37 V
168 0 V
0 262 V
13 0 V
0 56 V
91 0 V
0 33 V
6 0 V
0 1 V
19 0 V
0 11 V
20 0 V
0 13 V
32 0 V
0 104 V
52 0 V
0 27 V
65 0 V
0 15 V
39 0 V
0 126 V
174 0 V
0 103 V
52 0 V
0 49 V
175 0 V
0 56 V
433 0 V
0 661 V
415 0 V
0 857 V
123 0 V
0 -291 V
498 0 V
0 208 V
505 0 V
0 66 V
291 0 V
0 115 V
311 0 V
0 449 V
162 0 V
0 309 V
stroke
grestore
end
showpage
%%Trailer
%%DocumentFonts: Helvetica
%%Pages: 1
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

+44 -9
View File
@@ -55,14 +55,14 @@ Erik Andersen</a>, and its ongoing development is being sponsored by
<a href="http://www.lineo.com/">Lineo</a>.
<p>
BusyBox is licensed under the
<a href="http://www.gnu.org/copyleft/gpl.html">GNU GENERAL PUBLIC LICENSE</a>
<a href="http://www.gnu.org/copyleft/gpl.html">GNU GENERAL PUBLIC LICENSE</a>.
<p>
<h3> Screenshot </h3>
<p> Because everybody loves screenshots, a screenshot of BusyBox
is now available <a href="screenshot.html"> right here</a>
is now available <a href="screenshot.html">right here</a>.
<H3>Mailing List Information</h3>
@@ -82,6 +82,38 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
<ul>
<li> <b>7 July 2001 -- BusyBox 0.52 released</b>
<br>
I am very pleased to announce the immediate availability of
BusyBox 0.52 (the "new-and-improved rock-solid release"). This
release is the result of <em>many</em> hours of work and has tons
of bugfixes, optimizations, and cleanups. This release adds
several new applets, including several new shells (such as hust, msh,
and ash).
<p>
The
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> covers
some of the more obvious details, but there are many many things that
are not mentioned, but have been improved in subtle ways. As usual,
BusyBox 0.52 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>10 April 2001 - Graph of Busybox Growth </b>
<br>
The illustrious Larry Doolittle has made a PostScript chart of the growth
of the Busybox tarball size over time. It is available for downloading /
viewing <a href= "busybox-growth.ps"> right here</a>.
<p> (Note that while the number of applets in Busybox has increased, you
can still configure Busybox to be as small as you want by selectively
turning off whichever applets you don't need.)
<p>
<li> <b>10 April 2001 -- BusyBox 0.51 released</b>
<br>
@@ -352,6 +384,9 @@ listed in the order I happen to add them to the web page:
"http://www.wired.com/news/technology/0,1282,42399-2,00.html"> this
page</a>
<li> <a href="http://www.ltsp.org/">Linux Terminal Server Project</a>
<li> <a href="http://www.devil-linux.org/">Devil-Linux</a>
</ul>
<p> Do you use BusyBox? I'd love to know about it and I'd be happy to link to
@@ -379,29 +414,29 @@ you.
</TD>
<TD>
<a href="http://www.vim.org"><img border=0 width=88 height=32
src="images/anim.written.in.vi.gif"
<a href="http://www.vim.org"><img border=0 width=90 height=36
src="images/written.in.vi.png"
alt="This site created with the vi editor"></a>
</TD>
<TD>
<a href="http://www.gimp.org/"><img border=0 width=88 height=38
src="images/gfx_by_gimp.gif" alt="Graphics by GIMP"></a>
<a href="http://www.gimp.org/"><img border=0 width=90 height=36
src="images/gfx_by_gimp.png" alt="Graphics by GIMP"></a>
</TD>
<TD>
<a href="http://www.linuxtoday.com"><img width=90 height=36
src="images/ltbutton2.jpg" alt="Linux Today"></a>
src="images/ltbutton2.png" alt="Linux Today"></a>
</TD>
<TD>
<p><a href="http://slashdot.org"><img width=90 height=36
src="images/sdsmall.gif" alt="Slashdot"></a>
src="images/sdsmall.png" alt="Slashdot"></a>
</TD>
<TD>
<a href="http://freshmeat.net"><img width=90 height=36
src="images/fm.mini.jpg" alt="Freshmeat"></a>
src="images/fm.mini.png" alt="Freshmeat"></a>
</TD>
</TR>
-2540
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -805,7 +805,7 @@
<para>
Summarize the disk space used for each FILE or current
directory. Disk space printed in units of 1k (i.e.
directory. Disk space printed in units of 1k (i.e.,
1024 bytes).
</para>
@@ -2285,7 +2285,7 @@
<para>
Creates a temporary file with its name based on
TEMPLATE. TEMPLATE is any name with six `Xs' (i.e.
TEMPLATE. TEMPLATE is any name with six `Xs' (i.e.,
/tmp/temp.XXXXXX).
</para>
@@ -3407,7 +3407,7 @@
<screen>
-a Unmount all file systems
-r Try to remount devices as read-only if mount is busy
-f Force filesystem umount (i.e. unreachable NFS server)
-f Force filesystem umount (i.e., unreachable NFS server)
-l Do not free loop device (if a loop device has been used)
</screen>
</para>
+20 -7
View File
@@ -37,18 +37,19 @@ Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
=for html <br>
John Beppu <beppu@lineo.com>
du, head, nslookup, sort, tee, uniq (so Kraai could rewrite them ;-),
documentation
=for html <br>
Edward Betts <edward@debian.org>
expr, hostid, logname, tty, wc, whoami, yes
=for html <br>
John Beppu <beppu@lineo.com>
du, head, nslookup, sort, tee, uniq
=for html <br>
Brian Candler <B.Candler@pobox.com>
tiny-ls(ls)
@@ -68,12 +69,24 @@ Dave Cinege <dcinege@psychosis.com>
=for html <br>
Larry Doolittle <ldoolitt@recycle.lbl.gov>
various fixes, shell rewrite
=for html <br>
Karl M. Hegbloom <karlheg@debian.org>
cp_mv.c, the test suite, various fixes to utility.c, &c.
=for html <br>
Sterling Huxley <sterling@europa.com>
vi (!!!)
=for html <br>
Daniel Jacobowitz <dan@debian.org>
mktemp.c
@@ -153,4 +166,4 @@ Enrique Zanardi <ezanardi@ull.es>
=cut
# $Id: busybox_footer.pod,v 1.3 2001/04/09 23:27:51 kraai Exp $
# $Id: busybox_footer.pod,v 1.4 2001/04/17 17:09:34 beppu Exp $
+14 -13
View File
@@ -48,25 +48,26 @@ will also cause BusyBox to behave as 'ls'.
=head1 COMMON OPTIONS
Most BusyBox commands support the B<--help> option to provide a
Most BusyBox commands support the B<-h> option to provide a
terse runtime description of their behavior.
=head1 COMMANDS
Currently defined functions include:
ar, basename, busybox, cat, chgrp, chmod, chown, chroot, chvt, clear, cmp, cp,
cut, date, dc, dd, deallocvt, df, dirname, dmesg, dos2unix, dpkg, dpkg-deb, du,
dumpkmap, dutmp, echo, expr, false, fbset, fdflush, find, free, freeramdisk,
fsck.minix, getopt, grep, gunzip, gzip, halt, head, hostid, hostname, id,
ifconfig, init, insmod, kill, killall, klogd, length, ln, loadacm, loadfont,
loadkmap, logger, logname, ls, lsmod, makedevs, md5sum, mkdir, mkfifo,
mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, nslookup, ping,
pivot_root, poweroff, printf, ps, pwd, rdate, readlink, reboot, renice, reset,
rm, rmdir, rmmod, route, rpmunpack, sed, setkeycodes, sh, sleep, sort, stty,
swapoff, swapon, sync, syslogd, tail, tar, tee, telnet, test, tftp, touch, tr,
true, tty, umount, uname, uniq, unix2dos, update, uptime, usleep, uudecode,
uuencode, watchdog, wc, wget, which, whoami, xargs, yes, zcat, [
adjtimex, ar, basename, busybox, cat, chgrp, chmod, chown, chroot, chvt, clear,
cmp, cp, cpio, cut, date, dc, dd, deallocvt, df, dirname, dmesg, dos2unix, dpkg,
dpkg-deb, du, dumpkmap, dutmp, echo, expr, false, fbset, fdflush, find, free,
freeramdisk, fsck.minix, getopt, grep, gunzip, gzip, halt, head, hostid,
hostname, id, ifconfig, init, insmod, kill, killall, klogd, length, ln,
loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, md5sum,
mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc,
nslookup, ping, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, reboot,
renice, reset, rm, rmdir, rmmod, route, rpm2cpio, rpmunpack, sed, setkeycodes,
sh, sleep, sort, stty, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet,
test, tftp, touch, tr, true, tty, umount, uname, uniq, unix2dos, update, uptime,
usleep, uudecode, uuencode, watchdog, wc, wget, which, whoami, xargs, yes, zcat,
[
=over 4
+3 -3
View File
@@ -45,7 +45,7 @@ Archives can be found here:
http://opensource.lineo.com/lists/busybox/
If you have a serious interest in Busybox, i.e. you are using it day-to-day or
If you have a serious interest in Busybox, i.e., you are using it day-to-day or
as part of an embedded project, it would be a good idea to join the mailing
list.
@@ -294,7 +294,7 @@ are some guidelines on how to test your changes.
behavior / output is identical between the two.
- Try several different permutations and combinations of the features you're
adding (i.e. different combinations of command-line switches) and make sure
adding (i.e., different combinations of command-line switches) and make sure
they all work; make sure one feature does not interfere with another.
- Make sure you test compiling against the source both with the feature
@@ -456,7 +456,7 @@ mailing list if:
- Your changes are broad and touch many different files
- You are adding a feature
- Your changes are speculative or experimental (i.e. trying a new algorithm)
- Your changes are speculative or experimental (i.e., trying a new algorithm)
- You are not the maintainer and your changes make the maintainer cringe
The more of the above are true, the better it is to post a patch to the
+15 -20
View File
@@ -70,40 +70,35 @@ you _write_ your applet) please read through the style guide in the docs
directory and make your program compliant.
Some Words on utility.c
-----------------------
Some Words on libbb
-------------------
As you are writing your applet, please be aware of the body of pre-existing
useful functions in utility.c. Use these instead of reinventing the wheel.
If you use functions from utility.c, you may need to add to the preprocessor
conditionals in that file, to make sure the routines you need are included.
So, since your mu implementation used safe_read(), append "|| defined BB_MU" to
the #if instruction that precedes the safe_read() function in utility.c .
useful functions in libbb. Use these instead of reinventing the wheel.
Additionally, if you have any useful, general-purpose functions in your
program that could be useful in another program, consider putting them in
utility.c.
libbb.
Usage String(s)
---------------
Next, add usage information for you applet to usage.c. This should look like
Next, add usage information for you applet to usage.h. This should look like
the following:
#if defined BB_MU
const char mu_usage[] =
"mu\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nReturns an indeterminate value.\n"
#endif
;
#define mu_trivial_usage \
"-[abcde] FILES"
#define mu_full_usage \
"Returns an indeterminate value.\n\n" \
"Options:\n" \
"\t-a\t\tfirst function\n" \
"\t-b\t\tsecond function\n" \
If your program supports flags, the flags should be mentioned on the first
line (mu -[bcRovma]) and a detailed description of each flag should go in the
BB_FEATURE_TRIVIAL_HELP section, one flag per line. (Numerous examples of this
currently exist in usage.c.)
line (-[abcde]) and a detailed description of each flag should go in the
mu_full_usage section, one flag per line. (Numerous examples of this
currently exist in usage.h.)
Header Files
+81 -88
View File
@@ -27,18 +27,92 @@
* See the COPYING file for license information.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include "busybox.h"
#define CT_AUTO 0
#define CT_UNIX2DOS 1
#define CT_DOS2UNIX 2
// 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;
int convert(char *fn, int ConvType);
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;
@@ -69,84 +143,3 @@ int dos2unix_main(int argc, char *argv[]) {
return o;
}
// if fn is NULL then input is stdin and output is stdout
int convert(char *fn, int ConvType) {
char c;
char *tempFn = NULL;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = fopen(fn, "r")) == NULL) {
perror_msg(fn);
return -1;
}
tempFn = tmpnam(NULL);
if (tempFn == NULL || (out = fopen(tempFn, "w")) == NULL) {
perror_msg(NULL);
return -2;
}
}
while ((c = fgetc(in)) != EOF) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_DOS2UNIX;
break;
}
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_UNIX2DOS;
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
break;
}
fputc(c, out);
}
if (c != EOF)
while ((c = fgetc(in)) != EOF) {
if (c == '\r')
continue;
if (c == '\n') {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(c, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0 ||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
perror_msg(NULL);
return -2;
}
while ((c = fgetc(in)) != EOF)
fputc(c, out);
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
perror_msg(NULL);
return -2;
}
}
return 0;
}
+245 -239
View File
@@ -1,3 +1,4 @@
#include <ctype.h>
#include <dirent.h>
#include <getopt.h>
#include <stdio.h>
@@ -13,14 +14,13 @@
#include "busybox.h"
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
/* Should we do full dependency checking? */
#define DODEPENDS 1
//#define DODEPENDS 0
/* Should we do debugging? */
//#define DODEBUG 1
//#define DODEBUG 0
#ifdef DODEBUG
#define SYSTEM(x) do_system(x)
@@ -31,64 +31,69 @@
#endif
/* from dpkg-deb.c */
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename);
static const int dpkg_deb_contents = 1;
static const int dpkg_deb_control = 2;
// const int dpkg_deb_info = 4;
static const int dpkg_deb_extract = 8;
static const int dpkg_deb_verbose_extract = 16;
static const int dpkg_deb_list = 32;
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 dpkgcidir[] = "/var/lib/dpkg/tmp.ci/";
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 status_want_install = 2;
//static const int status_want_hold = 3;
//static const int status_want_deinstall = 4;
//static const int status_want_purge = 5;
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 status_flag_ok = 1;
//static const int status_flag_reinstreq = 2;
//static const int status_flag_hold = 3;
//static const int status_flag_holdreinstreq = 4;
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 status_statusnoninstalled = 1;
static const int status_status_unpacked = 2;
static const int status_status_halfconfigured = 3;
static const int status_status_installed = 4;
static const int status_status_halfinstalled = 5;
//static const int status_statusconfigfiles = 6;
//static const int status_statuspostinstfailed = 7;
//static const int status_statusremovalfailed = 8;
//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 *status_words_want[] = { "unknown", "install", "hold", "deinstall", "purge", 0 };
static const char *status_words_flag[] = { "ok", "reinstreq", "hold", "hold-reinstreq", 0 };
static const char *status_words_status[] = { "not-installed", "unpacked", "half-configured", "installed",
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 */
/* data structures */
typedef struct package_s {
char *file;
char *filename;
char *package;
char *version;
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;
unsigned char status_want;
unsigned char status_flag;
unsigned char status_status;
char color; /* for topo-sort */
struct package_s *requiredfor[DEPENDSMAX];
unsigned short requiredcount;
@@ -111,39 +116,7 @@ static int package_compare(const void *p1, const void *p2)
((package_t *)p2)->package);
}
/*
* NOTE: this was handled by a "rm -rf" shell command
* Maybe theis behaviour should be integrated into the rm applet
* (i dont appreciate the rm applets recursive action fn)-bug1
*/
static int remove_dir(const char *dirname)
{
struct dirent *fp;
DIR *dp = opendir(dirname);
while ((fp = readdir(dp)) != NULL) {
struct stat statbuf;
char *filename;
filename = (char *) xcalloc(1, strlen(dirname) + strlen(fp->d_name) + 2);
strcpy(filename, dirname);
strcat(filename, fp->d_name);
lstat(filename, &statbuf);
if ((strcmp(fp->d_name, ".") != 0) && (strcmp(fp->d_name, "..") != 0)) {
if (S_ISDIR(statbuf.st_mode)) {
remove_dir(strcat(filename, "/"));
}
else if (remove(filename) == -1) {
perror_msg(filename);
}
}
}
remove(dirname);
return EXIT_SUCCESS;
}
#ifdef DODEPENDS
#include <ctype.h>
static char **depends_split(const char *dependsstr)
{
@@ -265,8 +238,8 @@ static package_t *depends_resolve(package_t *pkgs, void *status)
/* 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->status_flag & status_flag_ok) &&
(chk->status_status & status_status_installed))) {
((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 */
@@ -328,55 +301,182 @@ static unsigned char status_parse(const char *line, const char **status_words)
}
/*
* Read a control file (or a stanza of a status file) and parse it,
* Read the buffered control file and parse it,
* filling parsed fields into the package structure
*/
static int control_read(FILE *file, package_t *p)
static int fill_package_struct(package_t *package, const char *package_buffer)
{
char *line;
char *field = NULL;
int field_start = 0;
int field_length = 0;
while ((line = get_line_from_file(file)) != NULL) {
line[strlen(line) - 1] = '\0';
while ((field = read_package_field(&package_buffer[field_start])) != NULL) {
field_length = strlen(field);
field_start += (field_length + 1);
if (strlen(line) == 0) {
if (strlen(field) == 0) {
printf("empty line: *this shouldnt happen i dont think*\n");
break;
}
else if (strstr(line, "Package: ") == line) {
p->package = xstrdup(line + 9);
/* these are common to both installed and uninstalled packages */
if (strstr(field, "Package: ") == field) {
package->package = strdup(field + 9);
}
else if (strstr(line, "Status: ") == line) {
char *word_pointer;
word_pointer = strchr(line, ' ') + 1;
p->status_want = status_parse(word_pointer, status_words_want);
word_pointer = strchr(word_pointer, ' ') + 1;
p->status_flag = status_parse(word_pointer, status_words_flag);
word_pointer = strchr(word_pointer, ' ') + 1;
p->status_status = status_parse(word_pointer, status_words_status);
else if (strstr(field, "Depends: ") == field) {
package->depends = strdup(field + 9);
}
else if (strstr(line, "Depends: ") == line) {
p->depends = xstrdup(line + 9);
else if (strstr(field, "Provides: ") == field) {
package->provides = strdup(field + 10);
}
else if (strstr(line, "Provides: ") == line) {
p->provides = xstrdup(line + 10);
}
else if (strstr(line, "Description: ") == line) {
p->description = xstrdup(line + 13);
/* 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(line, "installer-menu-item: ") == line) {
p->installer_menu_item = atoi(line + 21);
else if (strstr(field, "Description: ") == field) {
package->description = strdup(field + 13);
}
/* TODO: localized descriptions */
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);
}
free(line);
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");
@@ -386,9 +486,9 @@ static void *status_read(void)
return(NULL);
}
while (!feof(f)) {
while ( (package_control_buffer = fgets_str(f, "\n\n")) != NULL) {
m = (package_t *)xcalloc(1, sizeof(package_t));
control_read(f, m);
fill_package_struct(m, package_control_buffer);
if (m->package) {
/*
* If there is an item in the tree by this name,
@@ -418,9 +518,9 @@ static void *status_read(void)
* packages of different statuses
* provide it).
*/
t->status_want = m->status_want;
t->status_flag = m->status_flag;
t->status_status = m->status_status;
t->state_want = m->state_want;
t->state_flag = m->state_flag;
t->state_status = m->state_status;
}
}
}
@@ -451,7 +551,7 @@ static int status_merge(void *status, package_t *pkgs)
*/
if ((fin = fopen(statusfile, "r")) != NULL) {
while (((line = get_line_from_file(fin)) != NULL) && !feof(fin)) {
line[strlen(line) - 1] = '\0'; /* trim newline */
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).
@@ -479,9 +579,9 @@ static int status_merge(void *status, package_t *pkgs)
}
if (strstr(line, "Status: ") == line && statpkg != 0) {
snprintf(line, sizeof(line), "Status: %s %s %s",
status_words_want[statpkg->status_want - 1],
status_words_flag[statpkg->status_flag - 1],
status_words_status[statpkg->status_status - 1]);
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);
}
@@ -491,20 +591,7 @@ static int status_merge(void *status, package_t *pkgs)
// Print out packages we processed.
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
fprintf(fout, "Package: %s\nStatus: %s %s %s\n",
pkg->package, status_words_want[pkg->status_want - 1],
status_words_flag[pkg->status_flag - 1],
status_words_status[pkg->status_status - 1]);
if (pkg->depends)
fprintf(fout, "Depends: %s\n", pkg->depends);
if (pkg->provides)
fprintf(fout, "Provides: %s\n", pkg->provides);
if (pkg->installer_menu_item)
fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
if (pkg->description)
fprintf(fout, "Description: %s\n", pkg->description);
fputc('\n', fout);
write_package(fout, pkg);
}
fclose(fout);
@@ -544,144 +631,70 @@ static int dpkg_doconfigure(package_t *pkg)
char buf[1024];
DPRINTF("Configuring %s\n", pkg->package);
pkg->status_status = 0;
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->status_status = status_status_halfconfigured;
pkg->state_status = state_status_halfconfigured;
return 1;
}
}
pkg->status_status = status_status_installed;
pkg->state_status = state_status_installed;
return 0;
}
static int dpkg_dounpack(package_t *pkg)
{
int r = 0, i;
FILE *out_stream;
char *info_prefix;
int status = TRUE;
char *cwd = xgetcwd(0);
char *src_file = NULL;
char *dst_file = NULL;
// char *lst_file = NULL;
char *adminscripts[] = { "prerm", "postrm", "preinst", "postinst",
"conffiles", "md5sums", "shlibs", "templates" };
int r = 0;
DPRINTF("Unpacking %s\n", pkg->package);
if(cwd==NULL)
exit(EXIT_FAILURE);
chdir("/");
deb_extract(dpkg_deb_extract, "/", pkg->file);
/* extract the data file */
deb_extract(pkg->filename, stdout, (extract_data_tar_gz | extract_all_to_fs), "/", NULL);
/* Installs the package scripts into the info directory */
for (i = 0; i < sizeof(adminscripts) / sizeof(adminscripts[0]); i++) {
struct stat src_stat_buf;
int src_fd = 0, dst_fd = 0;
/* 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);
/* The full path of the current location of the admin file */
src_file = xrealloc(src_file, strlen(dpkgcidir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
sprintf(src_file, "%s%s/%s", dpkgcidir, pkg->package, adminscripts[i]);
/* 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);
/* the full path of where we want the file to be copied to */
dst_file = xrealloc(dst_file, strlen(infodir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
sprintf(dst_file, "%s%s.%s", infodir, pkg->package, adminscripts[i]);
/*
* copy admin file to permanent home
* NOTE: Maybe merge this behaviour into libb/copy_file.c
*/
if (lstat(src_file, &src_stat_buf) == 0) {
if ((src_fd = open(src_file, O_RDONLY)) != -1) {
if ((dst_fd = open(dst_file, O_WRONLY | O_CREAT, 0644)) == -1) {
status = FALSE;
perror_msg("Opening %s", dst_file);
}
copy_file_chunk(src_fd, dst_fd, src_stat_buf.st_size);
close(src_fd);
close(dst_fd);
} else {
status = FALSE;
error_msg("couldnt open [%s]\n", src_file);
}
}
}
/*
* create the list file
* FIXME: currently this dumps the lst to stdout instead of a file
*/
/* lst_file = (char *) xmalloc(strlen(infodir) + strlen(pkg->package) + 6);
strcpy(lst_file, infodir);
strcat(lst_file, pkg->package);
strcat(lst_file, ".list");
deb_extract(dpkg_deb_list, NULL, pkg->file);
*/
pkg->status_want = status_want_install;
pkg->status_flag = status_flag_ok;
pkg->state_want = state_want_install;
pkg->state_flag = state_flag_ok;
if (status == TRUE) {
pkg->status_status = status_status_unpacked;
pkg->state_status = state_status_unpacked;
} else {
pkg->status_status = status_status_halfinstalled;
pkg->state_status = state_status_halfinstalled;
}
chdir(cwd);
return r;
}
/*
* Extract and parse the control.tar.gz from the specified package
* Extract and parse the control file from control.tar.gz
*/
static int dpkg_unpackcontrol(package_t *pkg)
static int dpkg_read_control(package_t *pkg)
{
char *tmp_name;
FILE *file;
int length;
FILE *pkg_file;
char *control_buffer = NULL;
/* clean the temp directory (dpkgcidir) be recreating it */
remove_dir(dpkgcidir);
if (create_path(dpkgcidir, S_IRWXU) == FALSE) {
if ((pkg_file = wfopen(pkg->filename, "r")) == NULL) {
return EXIT_FAILURE;
}
/*
* Get the package name from the file name,
* first remove the directories
*/
if ((tmp_name = strrchr(pkg->file, '/')) == NULL) {
tmp_name = pkg->file;
} else {
tmp_name++;
}
/* now remove trailing version numbers etc */
length = strcspn(tmp_name, "_.");
pkg->package = (char *) xcalloc(1, length + 1);
/* store the package name */
strncpy(pkg->package, tmp_name, length);
/* work out the full extraction path */
tmp_name = (char *) xcalloc(1, strlen(dpkgcidir) + strlen(pkg->package) + 9);
strcpy(tmp_name, dpkgcidir);
strcat(tmp_name, pkg->package);
/* extract control.tar.gz to the full extraction path */
deb_extract(dpkg_deb_control, tmp_name, pkg->file);
/* parse the extracted control file */
strcat(tmp_name, "/control");
if ((file = wfopen(tmp_name, "r")) == NULL) {
return EXIT_FAILURE;
}
if (control_read(file, pkg) == EXIT_FAILURE) {
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;
}
@@ -691,15 +704,12 @@ static int dpkg_unpack(package_t *pkgs, void *status)
package_t *pkg;
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
if (dpkg_unpackcontrol(pkg) == EXIT_FAILURE) {
return EXIT_FAILURE;
}
dpkg_read_control(pkg);
if ((r = dpkg_dounpack(pkg)) != 0 ) {
break;
}
}
status_merge(status, pkgs);
remove_dir(dpkgcidir);
return r;
}
@@ -735,9 +745,7 @@ static int dpkg_install(package_t *pkgs, void *status)
/* Stage 1: parse all the control information */
for (p = pkgs; p != 0; p = p->next) {
if (dpkg_unpackcontrol(p) == EXIT_FAILURE) {
return(EXIT_FAILURE);
}
dpkg_read_control(p);
}
/* Stage 2: resolve dependencies */
@@ -749,27 +757,26 @@ static int dpkg_install(package_t *pkgs, void *status)
/* Stage 3: install */
for (p = ordered; p != 0; p = p->next) {
p->status_want = status_want_install;
p->state_want = state_want_install;
/* for now the flag is always set to ok... this is probably
* not what we want
*/
p->status_flag = status_flag_ok;
p->state_flag = state_flag_ok;
DPRINTF("Installing %s\n", p->package);
if (dpkg_dounpack(p) != 0) {
perror_msg(p->file);
perror_msg(p->filename);
}
if (dpkg_doconfigure(p) != 0) {
perror_msg(p->file);
perror_msg(p->filename);
}
}
if (ordered != 0) {
status_merge(status, pkgs);
}
remove_dir(dpkgcidir);
return 0;
}
@@ -798,7 +805,7 @@ extern int dpkg_main(int argc, char **argv)
package_t *p, *packages = NULL;
void *status = NULL;
char opt = 0;
int opt = 0;
int optflag = 0;
while ((opt = getopt(argc, argv, "iruc")) != -1) {
@@ -822,7 +829,7 @@ extern int dpkg_main(int argc, char **argv)
if (optflag & arg_configure) {
p->package = xstrdup(argv[optind]);
} else {
p->file = xstrdup(argv[optind]);
p->filename = xstrdup(argv[optind]);
}
p->next = packages;
packages = p;
@@ -830,8 +837,7 @@ extern int dpkg_main(int argc, char **argv)
optind++;
}
create_path(dpkgcidir, S_IRWXU);
create_path(infodir, S_IRWXU);
make_directory((char *)infodir, S_IRWXU, FILEUTILS_RECUR);
status = status_read();
Loaded 100 of 257 files, more files were not shown because too many files have changed in this diff. Show more