Compare commits

..
51 Commits
Author SHA1 Message Date
Eric Andersen 267b925bb4 Clone the busybox_0_60_stable branch from the old busybox.stable CVS tree 2005-07-16 01:57:20 +00:00
Eric Andersen aad0c53aa2 Accomodate older glibc's which also do not have the module
syscalls.
2001-10-24 00:42:44 +00:00
Eric Andersen eb2a21f68d Backport sed 's/$/@/' bugfix, thanks to Matt Kraai 2001-10-24 00:22:11 +00:00
Eric Andersen ce998051b4 Thanks to Glenn McGrath, clean applet_source_list last
-Erik
2001-10-24 00:20:27 +00:00
Eric Andersen 2ecdbd9eb8 update apps enabled in the .deb 2001-10-19 06:14:16 +00:00
Eric Andersen fe5bc552e6 Update udeb contents 2001-10-19 06:13:06 +00:00
Eric Andersen d9ffc9caa6 Revert mount -t auto to using /proc/filesystems, so we can
avoid automounting any nodev filesystems.
 -Erik
2001-10-18 04:15:26 +00:00
Eric Andersen 62fda96120 Fix a nasty bug resulting from variable name shadowing 2001-10-18 04:05:28 +00:00
Matt Kraai 75851b363b Backport fix. 2001-10-04 18:44:28 +00:00
Eric Andersen a97ef8eed4 Always enable BB_TEST when BB_ASH, BB_LASH, or BB_MSH is enabled 2001-10-03 23:35:05 +00:00
Eric Andersen 41a82698c3 Fix lash behavior on serial consoles 2001-10-03 22:10:02 +00:00
Eric Andersen 9019ed994f Route is supposed to be in /sbin 2001-10-03 21:44:28 +00:00
Eric Andersen 0eaef54878 Look for "init" or "linuxrc" when rebooting 2001-10-03 21:38:18 +00:00
Eric Andersen f8d5b031c2 Use the padantically correct compiler for preprocessing 2001-09-26 06:35:10 +00:00
Matt Kraai e5a1a23577 Backport tftp usage message fix. 2001-09-21 20:20:46 +00:00
Eric Andersen 37ded2819b define IFS_BROKEN 2001-09-06 17:59:36 +00:00
Eric Andersen 7f65e78f5c Note vodz ash fix 2001-09-06 17:40:57 +00:00
Eric Andersen f295db8fbd Patch from vodz for ash leading redirections (i.e. '2>/dev/null
ls rubbish')
2001-09-06 17:39:23 +00:00
Eric Andersen 9959ef4e2c Backport vodz' route fix 2001-09-05 23:31:44 +00:00
Matt Kraai cf969517dc Backport the rest of dirname(3) interface change. 2001-09-05 19:45:39 +00:00
Eric Andersen 64ef2d4cfa Update stable's changelog and bump stable version to 0.60.2.pre 2001-09-03 19:46:55 +00:00
Eric Andersen 6a18de72c4 Teacvh 'mount -t auto' to ignore usbdevfs 2001-09-03 19:45:47 +00:00
Eric Andersen bf31a8c450 SuS2 says rmdir must provide -p -- backport patch from Matt 2001-09-03 19:39:36 +00:00
Eric Andersen 3f6bb561db SUSv2 specifies that if the extension is identical to the basename, it
should not be removed.  Patch backport from Matt Kraai
2001-09-03 19:37:15 +00:00
Eric Andersen 2fd475509a Patch from Laurence Anderson to use more standard typing 2001-09-03 19:34:29 +00:00
Eric Andersen 93fc393486 Use the correct buffer when calling dirname, improve an error message,
and plug some memory leaks.  Patch by Laurence Anderson.
2001-09-03 19:32:18 +00:00
Eric Andersen 6b4d645722 remove traces of rpmunpack 2001-09-03 19:30:08 +00:00
Eric Andersen 8ccef78172 Backport vodz' route fix 2001-09-03 19:26:27 +00:00
Eric Andersen 018e9e8c0f Backport fix for exec'ing ash 2001-09-03 19:23:30 +00:00
Eric Andersen 9b2afe6dd6 Backport fix from Matt, for when applet names contain a leading dash
and a full pathname.
2001-09-03 19:21:07 +00:00
Eric Andersen 3cba82678b Eliminate improper consts and allow standard version to override. 2001-09-03 19:17:48 +00:00
Eric Andersen b7090fda30 Backport sed fix for s/[/]// handling from Matt Kraai 2001-09-03 19:16:23 +00:00
Eric Andersen 61a37e248d Oops. Forgot to bump the version number. 2001-08-23 22:45:40 +00:00
Eric Andersen c960eda2eb Fix up the debian stuff for release 2001-08-23 22:16:22 +00:00
Eric Andersen c83f8e765d Update the web page 2001-08-23 21:51:58 +00:00
Eric Andersen 8fdaace1d9 Update the changelog for release 2001-08-23 21:39:49 +00:00
Eric Andersen 43a6ed1171 Part of a patch from Magick <magick@linux-fan.com> tha fixes a bug
AskFirst where reading from /dev/null gives EOF.
2001-08-23 19:18:06 +00:00
Eric Andersen 170e4a7395 A patch from Jaspreet Singh to fix a segfault and display nothing wher
there is nothing to display.
2001-08-23 19:10:52 +00:00
Eric Andersen c4174b1b30 A patch from Shu-Hao Chang <shuhao_chang@trend.com.tw> to
fixed sed handling of multiple -e commands
2001-08-22 06:00:26 +00:00
Eric Andersen 3b8b434e53 Force BB_FEATURE_NEW_MODULE_INTERFACE and BB_FEATURE_OLD_MODULE_INTERFACE
to be mutually exclusive (stable branch)
2001-08-22 05:43:14 +00:00
Eric Andersen 27656e1868 Add #include <sys/param.h> to ensure PATH_MAX is defined 2001-08-22 05:36:12 +00:00
Eric Andersen df73587122 Backport lash fix 2001-08-22 05:32:45 +00:00
Eric Andersen 59feb4b9bb Backport Matt's non-existent backreference sed fix to stable 2001-08-22 05:31:15 +00:00
Eric Andersen b3d5dd7220 Merge some safe fixes into stable 2001-08-22 05:29:19 +00:00
Eric Andersen 82c22aa311 Fix stable as well 2001-08-21 22:34:58 +00:00
Eric Andersen afe07daf34 Apply Glenn's tftp rewrite for the stable branch 2001-08-20 17:47:14 +00:00
Eric Andersen 435680426e Backport Manuel Novoa III's rewrite to the stable branch 2001-08-20 17:46:09 +00:00
Eric Andersen 686a24b2f5 Minor wording changes 2001-08-20 17:44:32 +00:00
Matt Kraai d85117bb85 Backported syslogd fix. 2001-08-14 18:05:40 +00:00
Eric Andersen 6c8c51a470 Merge the CVS changes so far into the stable branch. 2001-08-10 18:22:16 +00:00
nobody 4a5360b97e This commit was manufactured by cvs2svn to create branch
'busybox_0_60_stable'.
2001-08-10 15:05:27 +00:00
401 changed files with 60521 additions and 55716 deletions

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
busybox
busybox.links
_install
loop.h
applet_source_list
+24 -6
View File
@@ -8,14 +8,14 @@ incorect, _please_ let me know.
-----------
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Erik Andersen <andersen@codepoet.org>, <andersee@debian.org>
Tons of new stuff, major rewrite of most of the
core apps, tons of new apps as noted in header files.
Edward Betts <edward@debian.org>
expr, hostid, logname, tty, wc, whoami, yes
John Beppu <beppu@lineo.com>
John Beppu <beppu@codepoet.org>
du, head, nslookup, sort, tee, uniq
Brian Candler <B.Candler@pobox.com>
@@ -28,9 +28,17 @@ Dave Cinege <dcinege@psychosis.com>
more(v2), makedevs, dutmp, modularization, auto links file,
various fixes, Linux Router Project maintenance
Magnus Damm <damm@opensource.se>
tftp client
insmod powerpc support
Larry Doolittle <ldoolitt@recycle.lbl.gov>
pristine source directory compilation, lots of patches and fixes.
Gennady Feldman <gfeldman@cachier.com>
Sysklogd (single threaded syslogd, IPC Circular buffer support,
logread), various fixes.
Karl M. Hegbloom <karlheg@debian.org>
cp_mv.c, the test suite, various fixes to utility.c, &c.
@@ -38,17 +46,24 @@ Daniel Jacobowitz <dan@debian.org>
mktemp.c
Matt Kraai <kraai@alumni.carnegiemellon.edu>
documentation, bugfixes
documentation, bugfixes, test suite
John Lombardo <john@deltanet.com>
dirname, tr
Glenn McGrath <bug1@netconnect.com.au>
ar.c
Glenn McGrath <bug1@optushome.com.au>
ar, dpkg, dpkg-deb
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit; ports: ash, stty, traceroute; locale, various fixes
and irreconcilable critic of everything not perfect.
Bruce Perens <bruce@pixar.com>
Original author of BusyBox. His code is still in many apps.
Tim Riker <Tim@Rikers.org>
bug fixes, member of fan club
Kent Robotti <robotti@metconnect.com>
reset, tons and tons of bug reports and patchs.
@@ -64,7 +79,7 @@ Gyepi Sam <gyepi@praxis-sw.com>
Linus Torvalds <torvalds@transmeta.com>
mkswap, fsck.minix, mkfs.minix
Mark Whitley <markw@lineo.com> <markw@codepoet.org>
Mark Whitley <markw@codepoet.org>
grep, sed, cut, xargs, style-guide, new-applet-HOWTO, bug fixes, etc.
Charles P. Wright <cpwright@villagenet.com>
@@ -73,3 +88,6 @@ Charles P. Wright <cpwright@villagenet.com>
Enrique Zanardi <ezanardi@ull.es>
tarcat (since removed), loadkmap, various fixes, Debian maintenance
Emanuele Aina <emanuele.aina@tiscali.it>
run-parts
+578 -4
View File
@@ -1,3 +1,577 @@
0.60.5
Stable Release
Bugfixes:
* Fixed a race that could cause init to hang
* Fixed init orphan process reaping
* Fixed init to always attempt to provide a controlling tty.
This should fix most cases where ash would print
"job control disabled" -- the other cases are user error.
* Fixed 'gunzip -c' to not delete the source source file
* Fixed a silly math problem in the time applet
* Fixed 'cp -a' so it will once again copy symlinks properly
* Fixed a long standing problem in tftp with freeing memory
* Fixed Makefile largefile settings
* Fixed a buffer overflow in vi
* Cosmetic cleanups in lsmod, lash, init, swapon/off, and hostname
* Set the close-on-exec flag on files opened by init
* The updated top applet was backported from unstable
* Several ash bugfixes were backported from unstable
* Several warnings in ash, md5sum, and ifconfig
-Erik Andersen, 26 October 2002
0.60.4
Stable Release
New Applets & New Features:
* Added new a 'top' applet (by special request)
* Lots of small uClinux adjustments
Bugfixes:
* This release has _lots_ of bugfixes. See Changelog.full
for the complete list of what was changed.
-Erik Andersen, 18 September 2002
0.60.3
Stable Release
New Applets & New Features:
* Added new a 'time' applet (by special request)
* Added new a 'losetup' applet
* The tftp has been fixed to work
* Default shell is now ash.
* msh shell should work properly on mmu-less systems again
* ls can now do color
Bugfixes:
* Erik Andersen
-- Hacked together a new time applet
-- Fixed dangling comma in init.c (s390 arch only)
-- Fixed more so when it is run on files in the procfs that
claim 0 length, it will not do weird things i.e. more /proc/pci
-- Copyright message cleanups. Fixed sash attributions.
-- Backporting of fixes and general maintenance.
-- Fixed several cases where reboot, halt, and poweroff would fail
to function properly when Linux is booted into an initrd.
-- Fixed a silly compile bug in cpio
-- nslookup now works properly with uClibc, remove old workaround
-- Added conv=noerror support to dd
-- Fixed ash and msh cmdedit to properly account for the current
PATH setting
-- Document netcat options and add -e support
-- Fixed insanely broken insmod endianness handling
-- Update init.c for better syle conformance, properly detach from
terminal when necessary, better code reuse, FIFO inittab file
reading/executing, allow init to be halted and restarted, etc.
-- Allow gunzip to work on multiple archives, add -v option
-- Updated x86 optimizations to save over 10k.
* Edward Betts
-- added -x switch to du.c
* Cliff L. Biffle
-- Added memory usage to the ps listings
* Przemyslaw Czerpak
-- Made telnet 8-bit clean, handle screen size, and is now RFC
compliant. Works nicely now.
* Wolfgang Denk
-- hush now supports shell loops (for, while, until) and control
operators (||, &&)
* Russ Dill
-- Added an 'restart' inittab action, allowing init to re-exec
itself (or call a script which calls pivot_root then exec...)
* Larry Doolittle
-- Made syslogd not give up when errno is EINTR
* Geoffrey Espin
-- support find -newer <file>
* Robert Griebl
-- Reworked modprobe so it now reads and uses modules.dep
* Karl M. Hegbloom
-- Fixed a silly bug where CONTEXT and EGREP_ALIAS were coupled.
* Kevin Hilman
-- Fixed memory corruption from long pathnames in /etc/fstab
* J.W.Janssen
-- color ls support!
* Matt Kraai
-- Fixed get_line_from_file() so that NULL is treated as end of
line, thereby fixing cut, grep, sed, etc. when working on binary
files or anything that might contain a NULL.
-- Fixed wget to do DNS initial DNS lookups, and do that only once
to avoid skipping to a different server when round-robin DNS is
in use (bug found by Mike Coleman <mkc@mathdogs.com>)
-- Several sed fixes
-- Added new losetup applet
* Ben Low
-- allow tftp to work with stdin as well as stdout.
* Frank P. MacLachlan <fpm-plutus@tgs.indyme.com> avoid a potential
NULL pointer problem in mount.
* Glenn McGrath
-- gunzip was incorrectly reporting a failed crc and length
(Discovered by Change, Shu-Hao). The problem was the bitbuffer
needs to be unwound after decompression as it was eating into the
crc/size field.
-- Reworked wc.c to fix severe efficiency problems and make it
smaller. When just counting file chars, simply stat the file
instead of reading the whole thing. (Fixes Debian bug #103302)
-- Updated dmalloc options
* Manuel Novoa III
-- rewrote get_last_path_component() so it would not be so
horrible, and would behave correctly in several important corner
cases.
* Vladimir Oleynik
-- Fixed ash problem where ^C could be blocked
-- Several command line editing updates (cmdedit now supports
CTRL-K and CTRL-L, fixed a segfault, etc)
-- Fixed ash problem where ^C could be blocked
-- Several size optimizations for various applets
* Tim Riker
-- make ash prompt the same as other shells if cmdedit and
fancyprompt are enabled.
* Jeff Studer
-- tftp now generates default values for localfilename and
remotefilename based on provided file names when possible.
* Stefan Soucek and Miles Bader
-- Re-add mmu-less support to msh
* Jim Treadway
-- Fixed a buffer overflow in the local group handling code.
-- Fixed a missing "\" in usage.h
-- Made pidof not add trailing spaces
-- Fixed msh bugs so things like "A = 1; B = `eval $A`; echo $B"
can now work.
* Mike Voytovich
-- insmod big endian ARM support
-Erik Andersen, 27 April 2002
0.60.2
Stable Release
* Please support busybox and help us buy busybox.net. See the
(current) busybox webpage for details.
New Applets & New Features:
* msh was reworked by Vladimir Oleynik's so it can handle things like
for i in `ls *.c` ; do echo $i ; done
unfortunately, this also means that msh is no-longer uClinux safe,
and will require some surgery to make it use vfork() again.
* Charles Steinkuehler <charles@steinkuehler.net> -- reworked hostname
so it behaves as expected (backport from busybox unstable)
Known Problems
none. :)
Bugfixes:
* Erik Andersen
-- Fixed grep -E and egrep so they actually behave as expected
-- init cleanups and (theoretical) uClinux support
-- Fixed large file (>2Gig) support (enable in the Makefile)
-- Always enable test when a shell is enabled (least surprise)
-- Made 'mount -a' use proc to avoid a static noauto list
-- lots of source tree cleanups
* Laurence Anderson
-- Removed some traces of no-longer existant rpmunpack (which
has been obsoleted by the rpm2cpio applet).
-- Fixed unarchive.c to use the correct buffer when calling
dirname, improve an error message, and plug some memory leaks.
-- Fixed rpm2cpio.c mkfs_minix.c fsck_minix.c fbset.c to use
standard types (s/u16/u_int16_t/g s/u32/u_int32_t/g etc)
* ASA <llb@udm.net.ru> -- fixed ash handling of command line args
when sourcing ('.') commands.
* Ethan Benson <erbenson@alaska.net>
-- Fix mount's noauto option to not automount as "usbdevfs"
* David Kimdon <dwhedon@instant802.com> -- fixed md5sum binary sums
* Matt Kraai
-- Fix sed s/[/]// handling (noted by Dumas Patrice).
-- Fix dirname(3) improper consts, allow libc version to override.
-- Fixed invoking applets when their names contain a leading dash
and a full pathname.
-- Fix ash exec
-- Fixed basename to be SUSv2 compliant (which specifies that the
extension should stay if it is identical to the basename.
-- Fixed rmdir, since SuS2 says rmdir must provide -p
-- Fixed sed empty line substitutions (noted by Joshua Hudson).
* Steve Merrifield <steve@labyrinth.net.au> -- make vi use xmalloc
* Glenn McGrath
-- dpkg cleanups, various bugfixes
* Vladimir Oleynik
-- Add support for `busybox --help APPLET'
-- Fixed route so it properly displays all route entries
-- Fix for ash leading redirections (i.e. '2>/dev/null ls rubbish')
* Andrew Tipton <andrew@cadre5.com> -- enable vi cursor keys when in
edit mode as vim does.
-Erik Andersen, 20 November 2001
0.60.1
Stable Release
New Applets & New Features:
none. :)
Known Problems (to be fixed in 0.60.2)
* msh can segfault on constructs such as
for i in `ls *.c` ; do echo $i ; done
due to a memory allocation problem. This only seems to cause
problems when the backtick expands to be several k in size.
Bugfixes:
* Matt Kraai
-- Fixed msh to support underscores in variable names.
-- Fixed a sed problem with unsatisfied backrefs (the problem was
noted by Martin Bene).
-- Removed BB_SH define entirely. Now one simply picks the shell
or shells they want as BB_<foo> in Config.h
-- Fixed head to use ferror(3) to check for errors, not errno.
* Shu-Hao Chang <shuhao_chang@trend.com.tw>
-- Fixed sed handling of multiple -e commands
* Magick <magick@linux-fan.com>
-- Fixed an init bug with AskFirst and /dev/null
* Jaspreet Singh <jsingh@somanetworks.com>
-- Fixed both a segfault and cosmetic bug in route
* Erik Andersen
-- Made the insmod options BB_FEATURE_NEW_MODULE_INTERFACE and
BB_FEATURE_OLD_MODULE_INTERFACE mutually exclusive
-- xgetcwd.c now includes sys/param.h to ensure PATH_MAX is defined
-- Fixed a potential segfault with lash + BB_FEATURE_CLEAN_UP
-- Removed uint64_t from dos2unix, avoiding C lib compat. problems.
* Glenn McGrath
-- Rewrite of tftp (commands match atftp, accepts -b, can use
non-standard ports, and is smaller).
-- Fixed unarchive exclude list handling
* Manuel Novoa III
-- rewrite of simplify_path so it behaves itself (fixing some
problems with mount and other applets).
-- Fixed ifconfig 'broadcast +' handling and disabled it by default
* Matthias ? <matthias@corelatus.com>
-- Fixed syslogd to log all messages from a single connection, not
just the first.
-Erik Andersen, 23 August 2001
0.60.0
Note:
For this release I have bumped the version number to 0.60.0. This
reflects the fact that this release is intended to form a new stable
BusyBox release series. If you need to rely on a stable version of
BusyBox, you should plan on using the stable 0.60.x series. If bugs
show up then I will release 0.60.1, then 0.60.2, etc... This is also
intended to deal with the fact that the BusyBox build system will be
getting a major overhaul for the next release and I don't want that to
break products that people are shipping. To avoid that, the new build
system will be released as part of a new BusyBox development series
that will have some not-yet-decided-on odd version number. Once things
stabablize and the new build system is working for everyone, then I
will release that as a new stable release series.
Critical Bugfixes:
* Matt Kraai
-- Fixed wget output file opening (wget failed in 0.52).
-- Fixed a memory leak in syslogd (found by Adam Slattery).
* Vladimir Oleynik, Matt Kraai, Erik Andersen
-- several nasty bugs in ash and msh. msh could not assign
any variables and had debug code still enabled. ash
had several compile errors (depending on selected options)
and variable assignment problems as well.
New Applets:
* David McCullough <davidm@lineo.com> -- modprobe
* Vladimir Oleynik -- traceroute
* Erik Andersen -- pidof
New Scripts:
* David Schleef, Erik Andersen, Stuart Hughes -- depmod.pl
This is a replacement for the depmod program from the modutils
package, but is fully cross platform and is designed to run on
your host system (not on the target).
Other Changes:
* Erik Andersen
-- fixed busybox.spec so it should now work on redhat systems
-- fixed dos2unix and unix2dos so they should work once again
-- Adjustments to make busybox more uClinux friendly. Busybox
should now work on uClinux systems without needing and source
code changes (applets that won't work on uClinux systems are
now automagicaly disabled).
-- various things (cleanups, libc compatibility work, etc, etc)
* Jim Gleason <jimg@lineo.com>
-- Fixed for sed, where it failed to preserve whether or not the
line was previously altered when running a subst command.
* Matt Kraai
-- Made tar read 20 512byte blocks at a time (like GNU tar)
-- Allow msh.c assignments with the export and readonly commands.
-- Added BB_FEATURE_DEVFS to enable devfs device names.
-- Better devfs support
-- Don't save/restore vi readonly flag if vi is compiled read-only.
-- Reworked rdate option handling (is now smaller).
-- Size reduction in ping
-- Always write dd counts to stderr
-- Allow multiple shells to be enabled
* Aaron Lehmann
-- slimmed down md5sum
-- contributed a nice new (hand written, not lex/yacc) Posix math
support for ash, which is once again a full posix shell.
* Felix von Leitner <leitner@convergence.de> -- patches to make busybox
work with dietlibc.
* David McCullough
-- Adjustments to make busybox more uClinux friendly
* Glenn McGrath
-- Fixed gzip so when a filename is '-' it will use stdin/stdout
-- dpkg rewrite. Should now be compatable with the real dpkg,
but needs more testing.
-- Updates to archiving tools (gunzip/gzip/cpio/ar/etc)
-- Rewrote uuencode, will allow base64 encoding to be used by wget
* Vladimir Oleynik
-- Fixed tr to support 'tr a-z A-Z' syntax,
-- Many ash corrections, optimizations, and cleanups.
-- optimizations for traceroute, md5sum, chown, ping
-- cmdedit updates and API change
-- Namespace cleanup (i.e. adding 'static' private function calls)
-- added "stopped jobs" warning to ash on exit
* Adam Slattery
-- Fixed ping compile problem
* Robert J. Osborne <rj@resourceinternational.com>
-- fixed a vi bug with delete and escape sequences on empty files.
-Erik Andersen, 31 July 2001
0.52
Critical Bugfixes:
* Glenn McGrath -- Fixed gunzip, zcat when reading from stdin
* Marc Karasek and Kanoj (kernel serial.c maintainer) -- fixed init
problem on serial consoles with 2.4.3+ kernels.
New Applets:
* Laurence Anderson -- rpm2cpio applet, this obsoletes rpmunpack
which has now been removed from BusyBox
* Laurence Anderson and Glenn McGrath -- cpio applet, currently
only supports unpacking the ascii cpio format.
* Vladimir Oleynik and Erik Andersen -- added ash, the most correct
busybox shell.
* Larry Doolittle -- hush, small shell designed specifically
for busybox. Quite usable but still a work in progress.
* Erik Andersen -- msh, minix shell. A very small but capable shell
that only uses vfork, so it can be used on uClinux systems.
Other Changes:
* Sterling Huxley -- Several bugfixes for the vi applet.
* Glenn McGrath -- Restructure unarchiving code to make more code
common to the ar, cpio, dpkg, dpkg-deb applets.
tar applet has not yet been assimilated...
* Matt Kraai -- Rewrote cp, dirname, mkdir, mv, and rm.
* Paul J.Y. Lahaie <pjlahaie@linuxcare.com> -- Fixed an endian-ness
bug in md5sum (in 0.51, md5sum on big endian machines was broken)
* Mark Whitley -- rewrote cut, major updates to grep and sed.
* Erik Andersen -- bunches of insmod fixes. It should now always
work (no more segfault or missing symbols problems).
* Bernhard Kuhn <kuhn@lpr.e-technik.tu-muenchen.de> and Jinux Kim
added uClinux/m68k insmod support.
* Manuel Novoa III -- rewrote make_human_readable so ls, du, and df
should work as expected. Eliminated use of floats.
* Aaron Lehmann <aaronl@vitelus.com> -- Scrubbed gzip.c
* Alan Modra <amodra@bigpond.net.au> -- fixed an hard to spot
bug breaking gunzip checksum checking.
* Gennady Feldman -- Fixed 'syslog -C'
* Gernot Poerner <gp@it-netservice.de> -- Added mount bind support.
* Adam Heath <doogie@debian.org> -- wget arbitrary header support
* John Beppu -- updated the automagical doc generator
* Zillions of other bugfixes, optimizations, and cleanups.
-Erik Andersen, 7 July 2001
0.51
Critical Bugfixes:
* Erik Andersen -- Fixed a bug that could crash the shell in 0.50
when pressing <Enter> on an empty line.
* Gennady Feldman -- Fixed a bug that could crash the shell in 0.50
when performing an 'export' in the shell.
* Gennady Feldman -- fixed a syslogd bug where syslogd could cause
the init process to block (which can break systems badly).
New Applets:
* Sterling Huxley -- contributed a new vi applet! This is a very
functional vi implementation in Only 22k.
* Erik Andersen -- added env applet
Other changes:
* Erik Andersen -- Split utility.c into libbb, which provides a
much cleaner was for us to include shared functionality.
* Erik Andersen -- Reorganized how and when busybox includes
syscalls, aiding portability and (in this case) making the
busybox work on ia64 systems.
* Erik Andersen -- dpkg.c cleanup to use the updated gunzip interface.
* Erik Andersen -- Cleanups for libc5, glibc, and uClibc.
* Erik Andersen and Matt Kraai -- Cleanups for the human-readable
output from ls, du, and df.
* Laurence Anderson <laurence@zxmail.com> -- Fixed wget HTTP 1.1
support and added chunked encoding so it is now RFC compliant.
* John Beppu -- The busybox.pod documentation is now automagically
generated from the source code. This makes it _much_ simpler.
Now to update the docs, just update the usage message...
* Dirk Behme <dirk.behme@de.bosch.com> -- Adjusted MIPS insmod
support a bit for Mips RS3.
* Christophe Boyanique -- egrep invoked the "init" applet in 0.50!
* Larry Doolittle -- Added -Wshadow and fixed a number of shadowed
variables
* David Douthitt -- fixed 'find -print'
* Gennady Feldman -- fixes for the syslogd circular buffer code
* Jeff Garzik -- a number of structural cleanups, fixes for -Wshadow
bugs, and similar problems.
* Matt Kraai -- Added a new 'shutdown' action to busybox init. Now
you can specify arbitrary behavior for 'ctrlaltdel' so now
pressing CTL-ALT-DEL can do something else (or nothing).
* Andreas Neuhaus <andy@fasta.fh-dortmund.de> -- fix for merging
kernel command line environment variables into child environment
for init.c
* Glenn McGrath -- Fixed problems with dpkg and dpkg-deb applets
* Glenn McGrath -- Don't try to automount devfs
* Vladimir Oleynik -- optimizations for more.c
* Vladimir Oleynik -- Added locale support to the shell, and fixed
locale support in several other places
* Vladimir Oleynik -- moved struct applet from busybox.c to applets.c
* Vladimir Oleynik -- A size optimization for rdate
* Vladimir Oleynik -- Fixed printf applets's locale handling
* Vladimir Oleynik -- More cmdedit updates
* Vladimir Oleynik -- Fixed `du' applet so it continues running
after permission errors.
* Vladimir Oleynik -- Reduced stack usage in recursive_action()
* Pierre Peiffer <pierre.peiffer@sxb.bsf.alcatel.fr> -- made
find_pid_by_name() cope with swapped out processes.
* Jari Ruusu <jari.ruusu@pp.inet.fi> -- updates so that setting
D_FILE_OFFSET_BITS=64 now works as expected.
* Anthony Towns <aj@azure.humbug.org.au> -- fixed a bug with
sed address range handling
* Dmitry Zakharov <dmit@crp.bank.gov.ua> -- a number of updates
to wget: support for ftp downloads, basic HTTP basic auth, handling
of http redirects, when attempting to continue an aborted download
but server doesn't support restarts then reopen output file in
write mode, bugfix: when content-length not given, wget didn't
download anything, if -c is not specified, it no longer default to
restarting an aborted download.
-Erik Andersen, 10 April 2001
0.50
* Erik Andersen -- added ifconfig interface status reporting
* Erik Andersen -- Debian packaging updates
* Erik Andersen -- lash environment variable expansion rewritten,
with lots of help/fixes/testing from Larry Doolittle.
* Erik Andersen -- Fix use of busybox with dmalloc debugging lib
* Erik Andersen -- fixed ls behavior for broken or very narrow terminals
* Erik Andersen -- stub umount2 and pivot_root if they are not available
* Erik Andersen -- libc5 fixes
* Erik Andersen -- make init work with devfsd
* Erik Andersen -- fixed df for nfs and dos where blksize = 512
* Erik Andersen -- Make sure libpwd.a is linked _last_ so it
overrides the system pwd/grp
* Christophe Boyanique -- added an optional egrep alias for grep.
* Christophe Boyanique -- added optional 'rm -i' support.
* Kenneth Chalmers and Erik Andersen -- fixed ln so it
behaves when given no arguments (prints usage) and when
given just one arg (tries to make a link in the cwd).
* Magnus Damm -- added a tftp applet
* Magnus Damm -- powerpc support for busybox insmod.
* David Douthitt -- fixed a build error in df.c when
BB_FEATURE_HUMAN_READABLE was disabled
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
generate the documentation from the source code, making life
much simpler for all.
* Magnus Damm <damm@opensource.se> -- Fixed an 'inner scope var
masking outer scope var with same name' bug that prevented
the loopback device from being unmounted if mount() failed.
* Larry Doolittle -- rewrote ifconfig to make it smaller
* Larry Doolittle and Erik Andersen -- cleanups to pristine source
* Larry Doolittle -- many bugfixes resulting from regression testing
* Gennady Feldman -- split syslogd.c into syslogd and klogd
* Gennady Feldman -- make syslogd single threaded -- no more forking
* Jeff Garzik -- getopt-ified rmmod.
* Jeff Garzik -- glibc 2.2 warning cleanups
* Jeff Garzik -- namespace pollution cleanup (staticified variables).
* Erik Gustavsson <cyrano@algonet.se> -- allow env variables set on the
kernel command line to be inherited into init and its children.
* Erik Habbinga -- fixed an uninitialized substitution delimiter in sed.
* Chris Jaeger -- Makefile cleanup to make option setting less error-prone
* Chris Jaeger <cjaeger@ensim.com> -- Carefully check NFS_MOUNT_VERSION
depending on what kernel is being used.
* Quinn Jensen <jensenq@lineo.com> -- MIPS support for busybox insmod.
* Evin Robertson -- new pivot_root applet
* Kent Robotti -- usage message cleanups
* Kent Robotti -- reworked dos2unix/unix2dos
* Evin Robertson and Manuel Novoa III -- reworked how usage messages
are stored to save several k of space.
* Matt Kraai -- Keep trying if an NFS mount fails
* Matt Kraai -- fixed insmod so it won't try to insmod directories.
* Matt Kraai -- added nc listening support
* Matt Kraai and David Douthitt -- reworked fine to support -type,
-perm, -mtime, and other improvements.
* Matt Kraai -- added find_applet_by_name and saved some memory thereby
* Matt Kraai -- added chomp to reduce redundant code elsewhere
* Matt Kraai -- Removed trailing \n chars from error_msg{,_and_die} messages.
* John Lombardo -- fixed OOM in insmod.
* Glenn McGrath -- bypass /proc in mount, now uses sysfs.
* Glenn McGrath -- several updates to dpkg and dpkg-deb.
* Manuel Novoa III -- several size optimizations: parse_mode,
process_escape_sequence, format, and get_kernel_revision.
* Manuel Novoa III -- rewrote ifconfig again to make it smaller still
* Manuel Novoa III -- added ifconfig -a, updated interface reporting
* Vladimir N. Oleynik -- Fixed a bug where init set PATH incorrectly
* Vladimir N. Oleynik -- cleanups to route, cmdedit, mkdir,
mkfs_minix, mkswap, chmod_chown_chgrp and utility.c
* Vladimir N. Oleynik -- many fixes to cmdedit. so tab completion
is now working and general editing is much improved, and to
improve complex prompt handling.
* Vladimir N. Oleynik -- added route status reporting.
* Vladimir N. Oleynik -- fixed wget to use xfopen
* Vladimir N. Oleynik -- new stty applet
* Vladimir N. Oleynik -- fixed find, it used to stop on perm errors.
* Vladimir N. Oleynik -- locale forced to posix for scripts
* Vladimir N. Oleynik -- saved 128 bytes by moving error checking
for several my_* functions into utility.c
* Bjorn Wesen -- new ifconfig and route applet (taken from
work done by Axis Communications).
* Mark Whitley -- Added a 'How to contribute to Busybox' doc
and updated the style guide.
* Mark Whitley -- implemented grep -A, -B, and -C
* Mark Whitley -- overhauled the test suite.
-Erik Andersen, 15 March 2001
0.49
* Matt Kraai -- new sort.c
@@ -210,7 +784,7 @@
Arne Bernin <arne@matrix.loopback.org>
* Fixed NFS so it supports 2.4.x kernels and NFSv3.
* Brand, new versions of grep and sed which use libc regex routines,
thanks to Mark Whitley <markw@lineo.com>. The hand-tooled
thanks to Mark Whitley <markw@codepoet.org>. The hand-tooled
"regexp.[ch]" files have been removed. Much help on these from
Matt Kraai as well.
@@ -233,7 +807,7 @@
* Added a mini ar archive utility, especially written for BusyBox by
Glenn McGrath <bug1@netconnect.com.au>
* Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org>
* Added setkeycodes, for those that have wierd keyboard buttons.
* Added setkeycodes, for those that have weird keyboard buttons.
* Added md5sum, uuencode and uudecode -- thanks to Alfred M. Szmidt
<ams@trillian.itslinux.org> for contributing these.
* Added 'grep -v' option (inverted search) and updated
@@ -604,7 +1178,7 @@
init is not at PID 1 (like when running in an initrd).
* Added a prelinary du implementation. Some parameter parsing
stuff still needs to be added. -beppu (John Beppu
<beppu@lineo.com>)
<beppu@codepoet.org>)
* Implemented tee. -beppu Implemented head. -beppu
-Erik Andersen, Dec 10, 1999
@@ -747,7 +1321,7 @@
0.32
* More changes -- many thanks to Lineo for paying me to work on
busybox. If you have any problems please let me know ASAP at
andersen@lineo.com or andersee@debian.org
andersee@debian.org
* usage() now prints the BusyBox version. This will help folks
realize that they are not in Kansas anymore.
* Fixed mkdir -m option so that it works. kill segfaulted w/o any
+138
View File
@@ -0,0 +1,138 @@
2002-10-27 Erik Andersen <andersen@dillweed>
* Makefile: Increment version number
* debian/control, debian/changelog: Update packaging info
2002-10-26 Erik Andersen <andersen@dillweed>
* debian/Config.h-udeb:
Don't support init being run as /linux in the debian installer
-Erik
* swaponoff.c: last_patch64 from vodz:
The following usage from original user:
$ ./busybox swapon -a
Have typo problem:
swapon: swapon: Operation not permitted
But regular version:
swapon: /dev/hda5: Operation not permitted
Patch attached, reduced 9 bytes and advanced
exit code also.
* vi.c:
A patch from Jouni Malinen to avoid some buffer overflows in vi,
closing bug #1270
* Makefile: Ivan Popov noticed that handling of PREFIX was bad.
-Erik
2002-10-25 Erik Andersen <andersen@dillweed>
* tftp.c: This patch from Magnus Damm fixed a long standing problem
with freeing memory.
2002-10-23 Erik Andersen <andersen@dillweed>
* top.c: Backport vodz' reworked top applet from unstable
2002-10-22 Erik Andersen <andersen@dillweed>
* ash.c, ifconfig.c: Fix warnings
* md5sum.c: Fix undefined operation (temp = temp = <stuff>) and remove
double definition.
-Erik
* init.c: I committed the fflush in the wrong spot. I should go to bed
earlier so I don't screw up such easy stuff.
-Erik
* ash.c: Apply last_patch51_3 from vodz
* init.c: Be absurdly careful about flushing stdout.
2002-10-18 Erik Andersen <andersen@dillweed>
* tests/sh.testcases: Missed a spot
* tests/sh.testcases: disambiguate a test
* lsmod.c: Fixup some needless formatting differences vs modutils
* hostname.c:
Fixup slight difference in 'hostname -d' behavior vs GNU hostname
2002-10-12 Erik Andersen <andersen@dillweed>
* init.c:
After thinking about it, I think this patch from Matt Kraai is probably the
best way to go. Sysvinit does not provide a controlling tty since it doesn't
even try to open ttys for apps. We do. We we should _try_ to provide a
controlling tty if possible, but we needn't freak out if it doesn't work. So
we won't need to use openvt or similar, we'll just have init do the Right
Thing(tm).
2002-10-08 Erik Andersen <andersen@dillweed>
* docs/.cvsignore: oops
* docs/.cvsignore, Makefile: Remove docs/busybox.pod on 'make clean'
* init.c:
Patch from Ben Gamsa <ben@somanetworks.com> to handle it when orphaned
processes are created faster than busybox init reaps them.
* lsmod.c: Fix missing \n noticed by Robert Schwebel
* debian/Config.h-udeb: Enable pidof
* libbb/copy_file.c:
Doh! It turns out I broke 'cp -a' symlink handling. Oops. This fix, from
Tollef Fog Heen <tollef@add.no> fixes my stupid thinko so that 'cp -a' once
again copies symlinks properly.
2002-09-30 Erik Andersen <andersen@dillweed>
* usage.h: Fix docs
* lash.c:
Use %m, not strerror (changing since strerror(err) was broken anyways)
* init.c: Set the close-on-exec flag, just to be safe
* time.c: Doh. We divide microseconds by 60?
2002-09-27 Erik Andersen <andersen@dillweed>
* time.c: Bug fix from Nitin Gupta <gupta@equator.com>
2002-09-26 Erik Andersen <andersen@dillweed>
* lash.c: Avoid calling exit() from within fork/vfork'ed processes.
-Erik
2002-09-25 Erik Andersen <andersen@dillweed>
* init.c:
Ignoring SIGCHLD causes a race leading to the occasional hang of init
when init will wait() on itself in waitfor() when the child exits before
init is scheduled to run. Letting init hang is very seriously bad.
-Erik
2002-09-22 Erik Andersen <andersen@dillweed>
* Makefile: Fixup largefile settings.
-Erik
2002-09-20 Erik Andersen <andersen@dillweed>
* gunzip.c: Doh! As noted by K.-P. Kirchdörfer" <kapeka@epost.de>,
gunzip -c deletes the source source file! This fixes it.
-Erik
* top.c: Don't leak FILEs
+217 -107
View File
@@ -2,20 +2,25 @@
// 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_ASH
#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
@@ -25,11 +30,13 @@
#define BB_DIRNAME
#define BB_DMESG
//#define BB_DOS2UNIX
//#define BB_DPKG
//#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
//#define BB_EXPR
//#define BB_FBSET
//#define BB_FDFLUSH
@@ -45,11 +52,15 @@
#define BB_HEAD
//#define BB_HOSTID
//#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM
@@ -57,6 +68,7 @@
//#define BB_LOADKMAP
#define BB_LOGGER
//#define BB_LOGNAME
//#define BB_LOSETUP
#define BB_LS
#define BB_LSMOD
//#define BB_MAKEDEVS
@@ -67,12 +79,17 @@
#define BB_MKNOD
#define BB_MKSWAP
//#define BB_MKTEMP
//#define BB_NC
#define BB_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
#define BB_PIDOF
//#define BB_PING
//#define BB_PIVOT_ROOT
#define BB_POWEROFF
//#define BB_PRINTF
#define BB_PS
@@ -85,12 +102,13 @@
#define BB_RM
#define BB_RMDIR
//#define BB_RMMOD
//#define BB_RPMUNPACK
//#define BB_ROUTE
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
@@ -99,19 +117,24 @@
//#define BB_TEE
//#define BB_TEST
//#define BB_TELNET
//#define BB_TFTP
//#define BB_TIME
//#define BB_TOP
#define BB_TOUCH
//#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
//#define BB_UNIX2DOS
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
//#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
//#define BB_WGET
@@ -129,41 +152,45 @@
// pretty/useful).
//
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
//#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. 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:
// lots and lots memory for more important things. NOTE: If you enable this
// feature, you _must_ have patched the kernel to include the devps patch that
// is included in the busybox/kernel-patches directory. You will also need to
// create some device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// 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
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
//#define BB_FEATURE_TRIVIAL_HELP
// 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
//#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
// calculate terminal & column widths (for more, ls, and telnet)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
@@ -181,8 +208,11 @@
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
// Use color to identify different file types
#define BB_FEATURE_LS_COLOR
//
// 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
@@ -193,37 +223,35 @@
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_SIMPLE_TAIL
#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//#define BB_FEATURE_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
#define BB_FEATURE_NFSMOUNT
//
// If you are using uClibc, be sure that you've already compiled
// uClibc with INCLUDE_RPC=true (contained in the Config file)
//#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
//
// Enable support for creation of tar files.
@@ -235,18 +263,28 @@
// 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.
#define BB_FEATURE_SH_COMMAND_EDITING
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things.
// Only relevant if BB_SH is enabled.
#define BB_FEATURE_SH_STANDALONE_SHELL
//among other things. Off by default.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
//names. This causes applets (i.e., most busybox commands) to override
@@ -254,17 +292,21 @@
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if BB_SH is enabled.
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
// Only relevant if BB_SH is enabled.
#define BB_FEATURE_SH_TAB_COMPLETION
// 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 a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//
// Attempts to match usernames in a ~-prefixed path
// XXX: Doesn't work without NSS, off by default
//#define BB_FEATURE_USERNAME_COMPLETION /* require NSS */
// Uncomment this option to disable job control. Job control lets you
// run jobs in the background (which completely useless for is all you
// are doing is running scripts). Disabing this is bad for interactive
// use, since when you hit ^C in an application, it will also kill the
// shell. This adds about 2.5k on an x86 system.
#define BB_FEATURE_ASH_JOB_CONTROL
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -273,7 +315,7 @@
//#define BB_FEATURE_FBSET_READMODE
//
// Support insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
@@ -281,18 +323,42 @@
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 7k.
//#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
//#define BB_FEATURE_IFCONFIG_HW
//
// Allows "broadcast +" to set broadcast automatically based on hostaddr
// and netmask, at a cost of about 100 bytes of code (i386).
//#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS
//
// 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
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
@@ -301,6 +367,48 @@
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
//
// Support for the find -mtime option.
#define BB_FEATURE_FIND_MTIME
//
//// Support for the find -newer option.
#define BB_FEATURE_FIND_NEWER
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
// Support for devfs.
//#define BB_FEATURE_DEVFS
//
// End of Features List
//
//
@@ -312,73 +420,75 @@
// 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
#include <features.h>
#if defined(__uClinux__)
#undef BB_ASH /* Not even a chance it will work */
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_MTAB
#endif
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#if (defined BB_ASH || defined BB_HUSH || defined BB_MSH) && ! defined BB_TEST
#define BB_TEST
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_LINUXRC
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#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
#undef BB_FEATURE_LINUXRC
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#ifndef BB_FEATURE_NEW_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
-323
View File
@@ -1,323 +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
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
//#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// 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
//
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
//
// 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
//
// 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.
//
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#endif
#define BB_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#endif
#endif
+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
+4 -5
View File
@@ -17,15 +17,14 @@ Copyright 1998 Dave Cinege <dcinege@psychosis.com>
mini-gzip(gzip), mini-netcat(mnc)
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
Tons of new stuff as noted in header files
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Tons of new stuff as noted in header files
Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersen@codepoet.org>
<andersee@debian.org>
+278 -102
View File
@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
# Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,8 +18,8 @@
#
PROG := busybox
VERSION := 0.49
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
VERSION := 0.60.5
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,29 +37,40 @@ DOSTATIC = false
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
# Do not enable this for production builds...
DODEBUG = false
# Setting this to `true' will cause busybox to directly use the system's
# password and group functions. Assuming you use GNU libc, when this is
# `true', you will need to install the /etc/nsswitch.conf configuration file
# and the required libnss_* libraries. This generally makes your embedded
# system quite a bit larger... If you leave this off, busybox will directly
# use the /etc/password, /etc/group files (and your system will be smaller, and
# I will get fewer emails asking about how glibc NSS works). Enabling this adds
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs),
# Most people will want to leave this set to false.
USE_SYSTEM_PWD_GRP = false
# If you enable this option, busybox will use the system's password
# and group functions. And if you are using the GNU C library
# (glibc), you will then need to install the /etc/nsswitch.conf
# configuration file and the required /lib/libnss_* libraries in
# order for the password and group functions to work. This generally
# makes your embedded system quite a bit larger.
# Disabling this option will cause busybox to directly access the
# system's /etc/password, /etc/group files (and your system will be
# smaller, and I will get fewer emails asking about how glibc NSS
# works). When this option is disabled, you will not be able to use
# PAM to access remote LDAP password servers and whatnot. And if you
# want hostname resolution to work with glibc, you still need the
# /lib/libnss_* libraries.
# If you disable this option, it will add about 1.5k to busybox.
USE_SYSTEM_PWD_GRP = true
# This enables compiling with dmalloc ( http://dmalloc.com/ )
# which is an excellent public domain mem leak and malloc problem
# detector. To enable dmalloc, before running busybox you will
# want to first set up your environment.
# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
# eg: `export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile`
# The debug= value is generated using the following command
# dmalloc -p log-stats -p log-non-free -p log-bad-space -p log-elapsed-time \
# -p check-fence -p check-heap -p check-lists -p check-blank \
# -p check-funcs -p realloc-copy -p allow-free-null
# Do not enable this for production builds...
DODMALLOC = false
# Electric-fence is another very useful malloc debugging library.
# Do not enable this for production builds...
DOEFENCE = false
# If you want large file summit support, turn this on.
# This has no effect if you don't have a kernel with lfs
# support, and a system with libc-2.1.3 or later.
@@ -71,57 +82,114 @@ DOLFS = false
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
# Experimental and incomplete; tell the mailing list
# <busybox@opensource.lineo.com> if you do or don't like it so far.
BB_SRC_DIR = .
# <busybox@busybox.net> if you do or don't like it so far.
BB_SRC_DIR =
# If you are running a cross compiler, you may want to set this
# to something more interesting, like "powerpc-linux-".
CROSS =
CC = $(CROSS)gcc
STRIPTOOL = $(CROSS)strip
AR = $(CROSS)ar
STRIP = $(CROSS)strip
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
# Isn't that easy? Right now, uClibc needs BB_FEATURE_NFSMOUNT disabled
# since uClibc's nfs support isn't ready yet.
#CC = ../uClibc/extra/gcc-uClibc/gcc-uClibc-i386
# Everything should compile and work as expected these days...
#CC=/usr/i386-linux-uclibc/bin/i386-uclibc-gcc
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#LIBCDIR=/usr/i486-linuxlibc1/
#
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
#LIBCDIR=/usr/i386-glibc20-linux
#
# The following is used for libc5 (if you install altgcc and libc5-altdev
# on a Debian system).
#LIBCDIR=/usr/i486-linuxlibc1
#
# For other libraries, you are on your own...
#LDFLAGS+=-nostdlib
#LIBRARIES = $(LIBCDIR)/libc.a -lgcc
#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS = -Wall -Wshadow
ARFLAGS = -r
TARGET_ARCH:=${shell $(CC) -dumpmachine | sed -e s'/-.*//' \
-e 's/i.86/i386/' \
-e 's/sparc.*/sparc/' \
-e 's/arm.*/arm/g' \
-e 's/m68k.*/m68k/' \
-e 's/ppc/powerpc/g' \
-e 's/v850.*/v850/g' \
-e 's/sh[234]/sh/' \
-e 's/mips.*/mips/' \
}
#--------------------------------------------------------
# Arch specific compiler optimization stuff should go here.
# Unless you want to override the defaults, do not set anything
# for OPTIMIZATION...
# use '-Os' optimization if available, else use -O2
OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "-Os"; else echo "-O2" ; fi)
OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "-Os"; else echo "-O2" ; fi}
WARNINGS = -Wall
ifeq ($(DOLFS),true)
# For large file summit support
CFLAGS+=-D_FILE_OFFSET_BITS=64
# Some nice architecture specific optimizations
ifeq ($(strip $(TARGET_ARCH)),arm)
OPTIMIZATION+=-fstrict-aliasing
endif
ifeq ($(DODMALLOC),true)
ifeq ($(strip $(TARGET_ARCH)),i386)
OPTIMIZATION+=-march=i386
OPTIMIZATION+=${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
/dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
OPTIMIZATION+=${shell if $(CC) -falign-functions=1 -falign-jumps=0 -falign-loops=0 \
-S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo \
"-falign-functions=1 -falign-jumps=0 -falign-loops=0"; else \
if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
/dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi; fi}
endif
OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer
#--------------------------------------------------------
# If you're going to do a lot of builds with a non-vanilla configuration,
# it makes sense to adjust parameters above, so you can type "make"
# by itself, instead of following it by the same half-dozen overrides
# every time. The stuff below, on the other hand, is probably less
# prone to casual user adjustment.
#
ifeq ($(strip $(DOLFS)),true)
# For large file support
CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
endif
ifeq ($(strip $(DODMALLOC)),true)
# For testing mem leaks with dmalloc
CFLAGS+=-DDMALLOC
LIBRARIES = -ldmalloc
# Force debug=true, since this is useless when not debugging...
DODEBUG = true
else
ifeq ($(strip $(DOEFENCE)),true)
LIBRARIES = -lefence
# Force debug=true, since this is useless when not debugging...
DODEBUG = true
endif
endif
ifeq ($(DODEBUG),true)
ifeq ($(strip $(DODEBUG)),true)
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS += -Wl,-warn-common
STRIP =
STRIPCMD = /bin/true -Since_we_are_debugging
else
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
CFLAGS += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
LDFLAGS += -s -Wl,-warn-common
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
endif
ifeq ($(DOSTATIC),true)
ifeq ($(strip $(DOSTATIC)),true)
LDFLAGS += --static
#
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
@@ -136,39 +204,110 @@ ifeq ($(DOSTATIC),true)
#endif
endif
ifndef $(PREFIX)
ifeq ($(strip $(PREFIX)),)
PREFIX = `pwd`/_install
endif
# Additional complications due to support for pristine source dir.
# Config.h in the build directory should take precedence over the
# copy in BB_SRC_DIR, both during the compilation phase and the
# Include files in the build directory should take precedence over
# the copy in BB_SRC_DIR, both during the compilation phase and the
# shell script that finds the list of object files.
#
# Work in progress by <ldoolitt@recycle.lbl.gov>.
# If it gets in your way, set DISABLE_VPATH=yes
ifeq ($(DISABLE_VPATH),yes)
CONFIG_H = Config.h
else
VPATH = .:$(BB_SRC_DIR)
CONFIG_LIST = $(addsuffix /Config.h,$(subst :, ,$(VPATH)))
CONFIG_H = $(word 1,$(shell ls -f -1 $(CONFIG_LIST) 2>/dev/null))
CFLAGS += -I- $(patsubst %,-I%,$(subst :, ,$(VPATH))) $(CROSS_CFLAGS)
#
ifneq ($(strip $(BB_SRC_DIR)),)
VPATH = $(BB_SRC_DIR)
endif
#ifneq ($(strip $(VPATH)),)
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
#endif
OBJECTS = $(shell $(BB_SRC_DIR)/busybox.sh $(CONFIG_H) $(BB_SRC_DIR)) busybox.o messages.o usage.o utility.o
# We need to set APPLET_SOURCES to something like
# $(shell busybox.sh Config.h)
# but in a manner that works with VPATH and BB_SRC_DIR.
# Possible ways to approach this:
#
# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
#
# 2. Explicity search through .:$(VPATH) for slist.mk,
# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
#
# 3. Create slist.mk in this directory, with commands embedded in
# a $(shell ...) command, and $(MAKE) it immediately.
#
# 4. Use a real rule within this makefile to create a file that sets
# APPLET_SOURCE_LIST, then include that file. Has complications
# with the first trip through the makefile (before processing the
# include) trying to do too much, and a spurious warning the first
# time make is run.
#
# This is option 3:
#
#APPLET_SOURCES = $(shell \
# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
#)
# And option 4:
-include applet_source_list
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif
ifneq ($(USE_SYSTEM_PWD_GRP),true)
PWD_LIB = pwd_grp/libpwd.a
LIBRARIES += $(PWD_LIB)
ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
PWD_GRP = pwd_grp
PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
PWD_LIB = libpwd.a
PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
initgroups.c setgroups.c
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
ifneq ($(strip $(BB_SRC_DIR)),)
PWD_CFLAGS = -I- -I.
endif
PWD_CFLAGS += -I$(PWD_GRP_DIR)
else
CFLAGS += -DUSE_SYSTEM_PWD_GRP
endif
LIBBB = libbb
LIBBB_LIB = libbb.a
LIBBB_CSRC= ask_confirmation.c chomp.c concat_path_file.c copy_file.c \
copy_file_chunk.c libc5.c device_open.c error_msg.c inode_hash.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_write.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \
simplify_path.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
ifeq ($(strip $(BB_SRC_DIR)),)
LIBBB_CFLAGS += -I$(LIBBB)
else
LIBBB_CFLAGS = -I- -I. -I./$(LIBBB) -I$(BB_SRC_DIR)/$(LIBBB) -I$(BB_SRC_DIR)
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 can_not_create_raw_socket
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
@@ -177,34 +316,37 @@ CFLAGS += $(CFLAGS_EXTRA)
.EXPORT_ALL_VARIABLES:
all: busybox busybox.links doc
all: applet_source_list busybox busybox.links doc
applet_source_list: busybox.sh Config.h
(echo -n "APPLET_SOURCES := "; CC="$(CC)" BB_SRC_DIR="$(BB_SRC_DIR)" $(SHELL) $^) > $@
doc: olddoc
# Old Docs...
olddoc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.pod : docs/busybox_header.pod usage.h docs/busybox_footer.pod
- ( cat docs/busybox_header.pod; \
docs/autodocifier.pl usage.h; \
cat docs/busybox_footer.pod ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
@echo
@echo BusyBox Documentation
@echo
-mkdir -p docs
-pod2text $(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.txt
-pod2text $< > $@
docs/BusyBox.1: docs/busybox.pod
- mkdir -p docs
- pod2man --center=BusyBox --release="version $(VERSION)" \
$(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.1
$< > $@
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
-@ rm -f docs/BusyBox.html
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
-@ mkdir -p docs/busybox.lineo.com
- pod2html --noindex $(BB_SRC_DIR)/docs/busybox.pod > \
docs/busybox.lineo.com/BusyBox.html
-@ rm -f pod2html*
docs/BusyBox.html: docs/busybox.pod
-@ mkdir -p docs
- pod2html --noindex $< > docs/BusyBox.html
-@ rm -f pod2htm*
# New docs based on DOCBOOK SGML
@@ -231,57 +373,96 @@ docs/busybox.pdf: docs/busybox.ps
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
- mkdir -p docs
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
(cd docs; sgmltools -b html ../busybox.sgml)
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBBB_LIB) $(PWD_LIB) $(LIBRARIES)
$(STRIPCMD) $(PROG)
busybox: $(PWD_LIB) $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
$(STRIP)
$(PWD_LIB):
$(MAKE) -eC pwd_grp
busybox.links: Config.h applets.h
- $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
# but with VPATH, some or all of those file names are resolved to the
# directories in which they live.
busybox.links: busybox.mkll Config.h applets.h
- $(SHELL) $^ >$@
nfsmount.o cmdedit.o: %.o: %.h
ash.o hush.o lash.o msh.o: cmdedit.h
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
$(CC) $(CFLAGS) -c $*.c -o $*.o
ifeq ($(strip $(BB_SRC_DIR)),)
$(CC) $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
else
$(CC) $(CFLAGS) -I- -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
endif
utility.o: loop.h
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
ifneq ($(strip $(BB_SRC_DIR)),)
-mkdir -p $(PWD_GRP)
endif
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
loop.h: mk_loop_h.sh
@ sh $<
$(LIBBB_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile libbb/libbb.h
ifneq ($(strip $(BB_SRC_DIR)),)
-mkdir -p $(LIBBB)
endif
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -c $< -o $*.o
$(LIBBB_MOBJ): $(LIBBB_MSRC)
ifneq ($(strip $(BB_SRC_DIR)),)
-mkdir -p $(LIBBB)
endif
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
$(LIBBB_AROBJS): $(LIBBB_ARCSRC)
ifneq ($(strip $(BB_SRC_DIR)),)
-mkdir -p $(LIBBB)
endif
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
libpwd.a: $(PWD_OBJS)
$(AR) $(ARFLAGS) $@ $^
libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
$(AR) $(ARFLAGS) $@ $^
usage.o: usage.h
libbb/loop.o: libbb/loop.h
libbb/loop.h: mk_loop_h.sh
@ $(SHELL) $< > $@
test tests:
cd tests && $(MAKE) all
# old way of doing it
#cd tests && $(MAKE) all
# new way of doing it
cd tests && ./tester.sh
clean:
- cd tests && $(MAKE) clean
- cd pwd_grp && $(MAKE) clean
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
docs/busybox.lineo.com/BusyBox.html
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html docs/BusyBox.html
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
- rm -f Config.h.ORG bb.def.h busybox.REGRESS.sh.results bb.OptionsAndFeatures
- rm -rf docs/busybox _install
- rm -f busybox.links loop.h *~ *.o core
docs/busybox.pdf docs/busybox.html docs/busybox.pod
- rm -f multibuild.log Config.h.orig *.gdb *.elf
- rm -rf docs/busybox _install libpwd.a libbb.a pod2htm*
- rm -f busybox busybox.links libbb/loop.h *~ slist.mk core applet_source_list
- find . -name \*.o -exec rm -f {} \;
distclean: clean
- rm -f busybox
- cd tests && $(MAKE) distclean
- rm -f busybox applet_source_list
install: busybox busybox.links
$(BB_SRC_DIR)/install.sh $(PREFIX)
install: install.sh busybox busybox.links
$(SHELL) $< $(PREFIX)
install-hardlinks: busybox busybox.links
$(BB_SRC_DIR)/install.sh $(PREFIX) --hardlinks
uninstall: busybox busybox.links
for i in `cat busybox.links` ; do rm -f $$PREFIX$$i; done
install-hardlinks: install.sh busybox busybox.links
$(SHELL) $< $(PREFIX) --hardlinks
debug_pristine:
@ echo VPATH=\"$(VPATH)\"
@ echo CONFIG_LIST=\"$(CONFIG_LIST)\"
@ echo CONFIG_H=\"$(CONFIG_H)\"
@ echo OBJECTS=\"$(OBJECTS)\"
dist release: distclean doc
@@ -292,17 +473,12 @@ dist release: distclean doc
find busybox-$(VERSION)/ -type d \
-name CVS \
-print \
| xargs rm -rf; \
\
find busybox-$(VERSION)/ -type f \
-name .cvsignore \
-print \
| xargs rm -f; \
-exec rm -rf {} \; ; \
\
find busybox-$(VERSION)/ -type f \
-name .\#* \
-print \
| xargs rm -f; \
-exec rm -f {} \; ; \
\
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
+46 -20
View File
@@ -11,9 +11,7 @@ the expected functionality and behave very much like their GNU counterparts.
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add /dev, a kernel, and an editor,
such as nano, e3, or elvis-tiny. For a really minimal system, you can even use
the busybox shell (not Bourne compatible, but very small and quite usable).
systems. To create a working system, just add /dev, /etc, and a kernel.
BusyBox was originally written to support the Debian Rescue/Install disks, but
it also makes an excellent environment for any small or embedded system.
@@ -36,12 +34,14 @@ Supported architectures:
Busybox in general will build on any architecture supported by gcc. It has
a few specialized features added for __sparc__ and __alpha__. insmod
functionality is currently limited to x86, ARM, and SH3/4.
functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k,
and MIPS.
Supported libcs:
glibc-2.0.x, glibc-2.1.x, Linux-libc5, uClibc. People are looking at
newlib and diet-libc, but consider them unsupported, untested, or worse.
glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, Linux-libc5, uClibc. People
are looking at newlib and diet-libc, but consider them unsupported,
untested, or worse.
Supported kernels:
@@ -50,10 +50,40 @@ Supported kernels:
----------------
Shells:
lash is the very smallest shell (adds just 10k) and it is quite usable as
a command prompt, but it is not suitable for any but the most trivial
scripting (such as an initrd that calls insmod a few times) since it does
not understand Bourne shell grammer. It does handle pipes, redirects, and
job control though. Adding in command editing makes it a very nice
lightweight command prompt.
hush is also quite small (just 18k) and it has very complete Bourne shell
grammer. It handles if/then/else/fi just fine, but doesn't handle loops
like for/do/done or case/esac and such. It also currently has a problem
with job control. Using hush is not yet recommended.
msh: The minix shell (adds just 30k) is quite complete and handles things
like for/do/done, case/esac and all the things you expect a Bourne shell to
do. It is not always pedantically correct about Bourne shell grammer (try
running the shell testscript "tests/sh.testcases" on it and compare vs bash)
but for most things it works quite well. It also uses only vfork, so it can
be used on uClinux systems. This was only recently added, so there is still
room to shrink it further...
ash: This adds about 60k in the default configuration and is the most
complete and most pedantically correct shell included with busybox. This
shell was also recently added, and several people (mainly Vladimir and Erik)
have been working on it. There are a number of configurable things at the
top of ash.c as well, so check those out if you want to tweak things.
----------------
Getting help:
When you find you need help, you can check out the BusyBox mailing list
archives at http://opensource.lineo.com/lists/busybox/ or even join
archives at http://busybox.net/lists/busybox/ or even join
the mailing list if you are interested.
----------------
@@ -61,17 +91,17 @@ the mailing list if you are interested.
Bugs:
If you find bugs, please submit a bug report. Full instructions on how to
report a bug are found at http://bugs.lineo.com/Reporting.html.
report a bug are found at http://bugs.busybox.net/Reporting.html.
For the impatient: To submit a bug, simply send an email describing the problem
to submit@bugs.lineo.com. Bug reports should look something like this:
to submit@bugs.busybox.net. Bug reports should look something like this:
To: submit@bugs.lineo.com
To: submit@bugs.busybox.net
From: diligent@testing.linux.org
Subject: /bin/true doesn't work
Package: busybox
Version: 0.48
Version: 0.51
When I invoke '/bin/true' it doesn't work. I expected it to return
a "0" but it returned a "1" instead. Here is the transcript:
@@ -94,29 +124,25 @@ understanding.
FTP:
Source for the latest released version can always be downloaded from
ftp://ftp.lineo.com/pub/busybox.
http://busybox.net/downloads/
----------------
CVS:
BusyBox now has its own publicly browsable CVS tree at:
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
http://busybox.net/cgi-bin/cvsweb/busybox/
Anonymous CVS access is available. For instructions, check out:
http://opensource.lineo.com/cvs_anon.html
http://busybox.net/cvs_anon.html
For those that are actively contributing there is even CVS write access:
http://opensource.lineo.com/cvs_write.html
http://busybox.net/cvs_write.html
----------------
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersen@codepoet.org>
<andersee@debian.org>
<blatant plug>
Many thanks to go to Lineo for paying me to work on busybox.
</blatant plug>
+11 -12
View File
@@ -10,14 +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 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
-Erik
@@ -26,17 +18,24 @@ around to it some time. If you have any good ideas, please let me know.
Possible apps to include some time:
* hwclock
* stty
* group/commonize strings, remove dups (for i18n, l10n)
-----------
With sysvinit, reboot, poweroff and halt all used a named pipe,
/dev/initctl, to communicate with the init process. Busybox
currently uses signals to communicate with init. This makes
busybox incompatible with sysvinit. We should probably use
a named pipe as well so we can be compatible.
-----------------------
Running the following:
Run the following:
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
reveals the list of all external (i.e. libc) things that BusyBox depends on.
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.
@@ -48,6 +47,6 @@ and then start with the biggest things and make them smaller...
-----------------------
du.c probably ought to have an -x switch like GNU du does...
xargs could use a -l option
------------------------------------------------------------------
+176
View File
@@ -0,0 +1,176 @@
/*
* adjtimex.c - read, and possibly modify, the Linux kernel `timex' variables.
*
* Originally written: October 1997
* Last hack: March 2001
* Copyright 1997, 2000, 2001 Larry Doolittle <LRDoolittle@lbl.gov>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2,
* June 1991) as published by the Free Software Foundation. At the
* time of writing, that license was published by the FSF with the URL
* http://www.gnu.org/copyleft/gpl.html, and is incorporated herein by
* reference.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This adjtimex(1) is very similar in intent to adjtimex(8) by Steven
* Dick <ssd@nevets.oau.org> and Jim Van Zandt <jrv@vanzandt.mv.com>
* (see http://metalab.unc.edu/pub/Linux/system/admin/time/adjtimex*).
* That version predates this one, and is _much_ bigger and more
* featureful. My independently written version was very similar to
* Steven's from the start, because they both follow the kernel timex
* structure. I further tweaked this version to be equivalent to Steven's
* where possible, but I don't like getopt_long, so the actual usage
* syntax is incompatible.
*
* Amazingly enough, my Red Hat 5.2 sys/timex (and sub-includes)
* don't actually give a prototype for adjtimex(2), so building
* this code (with -Wall) gives a warning. Later versions of
* glibc fix this issue.
*
* This program is too simple for a Makefile, just build with:
* gcc -Wall -O adjtimex.c -o adjtimex
*
* busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov>
* It will autosense if it is built in a busybox environment, based
* on the BB_VER preprocessor macro.
*/
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#if __GNU_LIBRARY__ < 5
#include <sys/timex.h>
extern int adjtimex(struct timex *buf);
#else
#include <sys/timex.h>
#endif
#ifdef BB_VER
#include "busybox.h"
#endif
static struct {int bit; char *name;} statlist[] = {
{ STA_PLL, "PLL" },
{ STA_PPSFREQ, "PPSFREQ" },
{ STA_PPSTIME, "PPSTIME" },
{ STA_FLL, "FFL" },
{ STA_INS, "INS" },
{ STA_DEL, "DEL" },
{ STA_UNSYNC, "UNSYNC" },
{ STA_FREQHOLD, "FREQHOLD" },
{ STA_PPSSIGNAL, "PPSSIGNAL" },
{ STA_PPSJITTER, "PPSJITTER" },
{ STA_PPSWANDER, "PPSWANDER" },
{ STA_PPSERROR, "PPSERROR" },
{ STA_CLOCKERR, "CLOCKERR" },
{ 0, NULL } };
static char *ret_code_descript[] = {
"clock synchronized",
"insert leap second",
"delete leap second",
"leap second in progress",
"leap second has occurred",
"clock not synchronized" };
#ifdef BB_VER
#define main adjtimex_main
#else
void usage(char *prog)
{
fprintf(stderr,
"Usage: %s [ -q ] [ -o offset ] [ -f frequency ] [ -p timeconstant ] [ -t tick ]\n",
prog);
}
#define show_usage() usage(argv[0])
#endif
int main(int argc, char ** argv)
{
struct timex txc;
int quiet=0;
int c, i, ret, sep;
char *descript;
txc.modes=0;
for (;;) {
c = getopt( argc, argv, "qo:f:p:t:");
if (c == EOF) break;
switch (c) {
case 'q':
quiet=1;
break;
case 'o':
txc.offset = atoi(optarg);
txc.modes |= ADJ_OFFSET_SINGLESHOT;
break;
case 'f':
txc.freq = atoi(optarg);
txc.modes |= ADJ_FREQUENCY;
break;
case 'p':
txc.constant = atoi(optarg);
txc.modes |= ADJ_TIMECONST;
break;
case 't':
txc.tick = atoi(optarg);
txc.modes |= ADJ_TICK;
break;
default:
show_usage();
exit(1);
}
}
if (argc != optind) { /* no valid non-option parameters */
show_usage();
exit(1);
}
ret = adjtimex(&txc);
if (ret < 0) perror("adjtimex");
if (!quiet && ret>=0) {
printf(
" mode: %d\n"
"-o offset: %ld\n"
"-f frequency: %ld\n"
" maxerror: %ld\n"
" esterror: %ld\n"
" status: %d ( ",
txc.modes, txc.offset, txc.freq, txc.maxerror,
txc.esterror, txc.status);
/* representative output of next code fragment:
"PLL | PPSTIME" */
sep=0;
for (i=0; statlist[i].name; i++) {
if (txc.status & statlist[i].bit) {
if (sep) fputs(" | ",stdout);
fputs(statlist[i].name,stdout);
sep=1;
}
}
descript = "error";
if (ret >= 0 && ret <= 5) descript = ret_code_descript[ret];
printf(" )\n"
"-p timeconstant: %ld\n"
" precision: %ld\n"
" tolerance: %ld\n"
"-t tick: %ld\n"
" time.tv_sec: %ld\n"
" time.tv_usec: %ld\n"
" return value: %d (%s)\n",
txc.constant,
txc.precision, txc.tolerance, txc.tick,
(long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
}
return (ret<0);
}
+116
View File
@@ -0,0 +1,116 @@
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) tons of folks. Tracking down who wrote what
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
#include "applets.h"
struct BB_applet *applet_using;
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
extern void show_usage(void)
{
const char *format_string;
const char *usage_string = usage_messages;
int i;
for (i = applet_using - applets; i > 0; ) {
if (!*usage_string++) {
--i;
}
}
format_string = "%s\n\nUsage: %s %s\n\n";
if(*usage_string == 0)
format_string = "%s\n\nNo help available.\n\n";
fprintf(stderr, format_string,
full_version, applet_using->name, usage_string);
exit(EXIT_FAILURE);
}
static int applet_name_compare(const void *x, const void *y)
{
const char *name = x;
const struct BB_applet *applet = y;
return strcmp(name, applet->name);
}
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
extern int been_there_done_that; /* From busybox.c */
recurse_level++;
/* Do a binary search to find the applet entry given the name. */
if ((applet_using = find_applet_by_name(name)) != NULL) {
applet_name = applet_using->name;
if (argv[1] && strcmp(argv[1], "--help") == 0) {
if (strcmp(applet_using->name, "busybox")==0) {
if(argv[2])
applet_using = find_applet_by_name(argv[2]);
else
applet_using = NULL;
}
if(applet_using)
show_usage();
been_there_done_that=1;
busybox_main(0, NULL);
}
exit((*(applet_using->main)) (argc, argv));
}
/* Just in case they have renamed busybox - Check argv[1] */
if (recurse_level == 1) {
run_applet_by_name("busybox", argc, argv);
}
recurse_level--;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+232 -142
View File
@@ -10,388 +10,478 @@
* file result in the listing remaining in ascii order. You have been warned.
*/
#undef APPLET
#undef APPLET_ODDNAME
#undef APPLET_NOUSAGE
#if defined(PROTOTYPES)
#define APPLET(a,b,c,d) \
extern int b(int argc, char **argv); \
extern const char d[];
#define APPLET_NOUSAGE(a,b,c) \
extern int b(int argc, char **argv);
#define APPLET(a,b,c) extern int b(int argc, char **argv);
#define APPLET_NOUSAGE(a,b,c) extern int b(int argc, char **argv);
#define APPLET_ODDNAME(a,b,c,d) extern int b(int argc, char **argv);
extern const char usage_messages[];
#elif defined(MAKE_USAGE)
#ifdef BB_FEATURE_VERBOSE_USAGE
#define APPLET(a,b,c) a##_trivial_usage "\n\n" a##_full_usage "\0"
#define APPLET_NOUSAGE(a,b,c) "\0"
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\n\n" d##_full_usage "\0"
#else
#define APPLET(a,b,c) a##_trivial_usage "\0"
#define APPLET_NOUSAGE(a,b,c) "\0"
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\0"
#endif
#elif defined(MAKE_LINKS)
#define APPLET(a,b,c,d) LINK c a
#define APPLET_NOUSAGE(a,b,c) LINK c a
# define APPLET(a,b,c) LINK c a
# define APPLET_NOUSAGE(a,b,c) LINK c a
# define APPLET_ODDNAME(a,b,c,d) LINK c a
#else
const struct BB_applet applets[] = {
#define APPLET(a,b,c,d) {a,b,c,d},
#define APPLET_NOUSAGE(a,b,c) {a,b,c,NULL},
const struct BB_applet applets[] = {
#define APPLET(a,b,c) {#a,b,c},
#define APPLET_NOUSAGE(a,b,c) {a,b,c},
#define APPLET_ODDNAME(a,b,c,d) {a,b,c},
#endif
#ifdef BB_TEST
APPLET("[", test_main, _BB_DIR_USR_BIN, test_usage)
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ADJTIMEX
APPLET(adjtimex, adjtimex_main, _BB_DIR_SBIN)
#endif
#ifdef BB_AR
APPLET("ar", ar_main, _BB_DIR_USR_BIN, ar_usage)
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ASH
APPLET_NOUSAGE("ash", ash_main, _BB_DIR_BIN)
#endif
#ifdef BB_BASENAME
APPLET("basename", basename_main, _BB_DIR_USR_BIN, basename_usage)
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
#endif
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
#ifdef BB_CAT
APPLET("cat", cat_main, _BB_DIR_BIN, cat_usage)
APPLET(cat, cat_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP
APPLET("chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage)
#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, chmod_usage)
#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, chown_usage)
#ifdef BB_CHOWN
APPLET(chown, chown_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHROOT
APPLET("chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage)
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_CHVT
APPLET("chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage)
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CLEAR
APPLET("clear", clear_main, _BB_DIR_USR_BIN, clear_usage)
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CMP
APPLET("cmp", cmp_main, _BB_DIR_USR_BIN, cmp_usage)
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CP_MV
APPLET("cp", cp_mv_main, _BB_DIR_BIN, cp_usage)
#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, cut_usage)
APPLET(cut, cut_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DATE
APPLET("date", date_main, _BB_DIR_BIN, date_usage)
APPLET(date, date_main, _BB_DIR_BIN)
#endif
#ifdef BB_DC
APPLET("dc", dc_main, _BB_DIR_USR_BIN, dc_usage)
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DD
APPLET("dd", dd_main, _BB_DIR_BIN, dd_usage)
APPLET(dd, dd_main, _BB_DIR_BIN)
#endif
#ifdef BB_DEALLOCVT
APPLET("deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage)
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DF
APPLET("df", df_main, _BB_DIR_BIN, df_usage)
APPLET(df, df_main, _BB_DIR_BIN)
#endif
#ifdef BB_DIRNAME
APPLET("dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage)
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DMESG
APPLET("dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage)
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
#endif
#ifdef BB_DOS2UNIX
APPLET("dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage)
APPLET(dos2unix, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DPKG
APPLET(dpkg, dpkg_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DPKG_DEB
APPLET("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb_usage)
APPLET_ODDNAME("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb)
#endif
#ifdef BB_DU
APPLET("du", du_main, _BB_DIR_USR_BIN, du_usage)
APPLET(du, du_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DUMPKMAP
APPLET("dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage)
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
#endif
#ifdef BB_DUTMP
APPLET("dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage)
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_ECHO
APPLET("echo", echo_main, _BB_DIR_BIN, echo_usage)
APPLET(echo, echo_main, _BB_DIR_BIN)
#endif
#if defined(BB_FEATURE_GREP_EGREP_ALIAS) && defined(BB_GREP)
APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN)
#endif
#ifdef BB_ENV
APPLET(env, env_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_EXPR
APPLET("expr", expr_main, _BB_DIR_USR_BIN, expr_usage)
APPLET(expr, expr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET("false", false_main, _BB_DIR_BIN, false_usage)
APPLET(false, false_main, _BB_DIR_BIN)
#endif
#ifdef BB_FBSET
APPLET_NOUSAGE("fbset", fbset_main, _BB_DIR_USR_SBIN)
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_FDFLUSH
APPLET("fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage)
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
#endif
#ifdef BB_FIND
APPLET("find", find_main, _BB_DIR_USR_BIN, find_usage)
APPLET(find, find_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FREE
APPLET("free", free_main, _BB_DIR_USR_BIN, free_usage)
APPLET(free, free_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FREERAMDISK
APPLET("freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage)
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
#endif
#ifdef BB_FSCK_MINIX
APPLET("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage)
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
#endif
#ifdef BB_GETOPT
APPLET("getopt", getopt_main, _BB_DIR_BIN, getopt_usage)
APPLET(getopt, getopt_main, _BB_DIR_BIN)
#endif
#ifdef BB_GREP
APPLET("grep", grep_main, _BB_DIR_BIN, grep_usage)
APPLET(grep, grep_main, _BB_DIR_BIN)
#endif
#ifdef BB_GUNZIP
APPLET("gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage)
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
#endif
#ifdef BB_GZIP
APPLET("gzip", gzip_main, _BB_DIR_BIN, gzip_usage)
APPLET(gzip, gzip_main, _BB_DIR_BIN)
#endif
#ifdef BB_HALT
APPLET("halt", halt_main, _BB_DIR_SBIN, halt_usage)
APPLET(halt, halt_main, _BB_DIR_SBIN)
#endif
#ifdef BB_HEAD
APPLET("head", head_main, _BB_DIR_USR_BIN, head_usage)
APPLET(head, head_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_HOSTID
APPLET("hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage)
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_HOSTNAME
APPLET("hostname", hostname_main, _BB_DIR_BIN, hostname_usage)
APPLET(hostname, hostname_main, _BB_DIR_BIN)
#endif
#ifdef BB_HUSH
APPLET_NOUSAGE("hush", hush_main, _BB_DIR_BIN)
#endif
#ifdef BB_ID
APPLET("id", id_main, _BB_DIR_USR_BIN, id_usage)
APPLET(id, id_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_IFCONFIG
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
#endif
#ifdef BB_INIT
APPLET_NOUSAGE("init", init_main, _BB_DIR_SBIN)
APPLET(init, init_main, _BB_DIR_SBIN)
#endif
#ifdef BB_INSMOD
APPLET("insmod", insmod_main, _BB_DIR_SBIN, insmod_usage)
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_KILL
APPLET("kill", kill_main, _BB_DIR_BIN, kill_usage)
APPLET(kill, kill_main, _BB_DIR_BIN)
#endif
#ifdef BB_KILLALL
APPLET("killall", kill_main, _BB_DIR_USR_BIN, killall_usage)
APPLET(killall, kill_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_KLOGD
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LASH
APPLET(lash, lash_main, _BB_DIR_BIN)
#endif
#ifdef BB_LENGTH
APPLET("length", length_main, _BB_DIR_USR_BIN, length_usage)
APPLET(length, length_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LINUXRC
#ifdef BB_FEATURE_LINUXRC
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
#endif
#ifdef BB_LN
APPLET("ln", ln_main, _BB_DIR_BIN, ln_usage)
APPLET(ln, ln_main, _BB_DIR_BIN)
#endif
#ifdef BB_LOADACM
APPLET("loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage)
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOADFONT
APPLET("loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage)
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOADKMAP
APPLET("loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage)
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LOGGER
APPLET("logger", logger_main, _BB_DIR_USR_BIN, logger_usage)
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOGNAME
APPLET("logname", logname_main, _BB_DIR_USR_BIN, logname_usage)
APPLET(logname, logname_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOGREAD
APPLET(logread, logread_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LOSETUP
APPLET(losetup, losetup_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LS
APPLET("ls", ls_main, _BB_DIR_BIN, ls_usage)
APPLET(ls, ls_main, _BB_DIR_BIN)
#endif
#ifdef BB_LSMOD
APPLET("lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage)
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MAKEDEVS
APPLET("makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage)
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MD5SUM
APPLET("md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage)
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_MKDIR
APPLET("mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage)
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
#endif
#ifdef BB_MKFIFO
APPLET("mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage)
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_MKFS_MINIX
APPLET("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage)
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
#endif
#ifdef BB_MKNOD
APPLET("mknod", mknod_main, _BB_DIR_BIN, mknod_usage)
APPLET(mknod, mknod_main, _BB_DIR_BIN)
#endif
#ifdef BB_MKSWAP
APPLET("mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage)
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MKTEMP
APPLET("mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage)
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
#endif
#ifdef BB_MODPROBE
APPLET(modprobe, modprobe_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MORE
APPLET("more", more_main, _BB_DIR_BIN, more_usage)
APPLET(more, more_main, _BB_DIR_BIN)
#endif
#ifdef BB_MOUNT
APPLET("mount", mount_main, _BB_DIR_BIN, mount_usage)
APPLET(mount, mount_main, _BB_DIR_BIN)
#endif
#ifdef BB_MSH
APPLET_NOUSAGE("msh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_MT
APPLET("mt", mt_main, _BB_DIR_BIN, mt_usage)
APPLET(mt, mt_main, _BB_DIR_BIN)
#endif
#ifdef BB_CP_MV
APPLET("mv", cp_mv_main, _BB_DIR_BIN, mv_usage)
#ifdef BB_MV
APPLET(mv, mv_main, _BB_DIR_BIN)
#endif
#ifdef BB_NC
APPLET("nc", nc_main, _BB_DIR_USR_BIN, nc_usage)
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_NSLOOKUP
APPLET("nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage)
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PIDOF
APPLET(pidof, pidof_main, _BB_DIR_BIN)
#endif
#ifdef BB_PING
APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage)
APPLET(ping, ping_main, _BB_DIR_BIN)
#endif
#ifdef BB_PIVOT_ROOT
APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN)
#endif
#ifdef BB_POWEROFF
APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage)
APPLET(poweroff, poweroff_main, _BB_DIR_SBIN)
#endif
#ifdef BB_PRINTF
APPLET("printf", printf_main, _BB_DIR_USR_BIN, printf_usage)
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PS
APPLET("ps", ps_main, _BB_DIR_BIN, ps_usage)
APPLET(ps, ps_main, _BB_DIR_BIN)
#endif
#ifdef BB_PWD
APPLET("pwd", pwd_main, _BB_DIR_BIN, pwd_usage)
APPLET(pwd, pwd_main, _BB_DIR_BIN)
#endif
#ifdef BB_RDATE
APPLET("rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage)
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_READLINK
APPLET("readlink", readlink_main, _BB_DIR_USR_BIN, readlink_usage)
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_REBOOT
APPLET("reboot", reboot_main, _BB_DIR_SBIN, reboot_usage)
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
#endif
#ifdef BB_RENICE
APPLET("renice", renice_main, _BB_DIR_USR_BIN, renice_usage)
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_RESET
APPLET("reset", reset_main, _BB_DIR_USR_BIN, reset_usage)
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_RM
APPLET("rm", rm_main, _BB_DIR_BIN, rm_usage)
APPLET(rm, rm_main, _BB_DIR_BIN)
#endif
#ifdef BB_RMDIR
APPLET("rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage)
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
#endif
#ifdef BB_RMMOD
APPLET("rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage)
APPLET(rmmod, rmmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_RPMUNPACK
APPLET("rpmunpack", rpmunpack_main, _BB_DIR_USR_BIN, rpmunpack_usage)
#ifdef BB_ROUTE
APPLET(route, route_main, _BB_DIR_SBIN)
#endif
#ifdef BB_RPM2CPIO
APPLET(rpm2cpio, rpm2cpio_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_SED
APPLET("sed", sed_main, _BB_DIR_BIN, sed_usage)
APPLET(sed, sed_main, _BB_DIR_BIN)
#endif
#ifdef BB_SETKEYCODES
APPLET("setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage)
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_SH
APPLET("sh", shell_main, _BB_DIR_BIN, shell_usage)
#if defined(BB_FEATURE_SH_IS_ASH) && defined(BB_ASH)
APPLET_NOUSAGE("sh", ash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_HUSH) && defined(BB_HUSH)
APPLET_NOUSAGE("sh", hush_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_LASH) && defined(BB_LASH)
APPLET_NOUSAGE("sh", lash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_MSH) && defined(BB_MSH)
APPLET_NOUSAGE("sh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_SLEEP
APPLET("sleep", sleep_main, _BB_DIR_BIN, sleep_usage)
APPLET(sleep, sleep_main, _BB_DIR_BIN)
#endif
#ifdef BB_SORT
APPLET("sort", sort_main, _BB_DIR_USR_BIN, sort_usage)
APPLET(sort, sort_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_STTY
APPLET(stty, stty_main, _BB_DIR_BIN)
#endif
#ifdef BB_SWAPONOFF
APPLET("swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage)
APPLET(swapoff, swap_on_off_main, _BB_DIR_SBIN)
#endif
#ifdef BB_SWAPONOFF
APPLET("swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage)
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
#endif
#ifdef BB_SYNC
APPLET("sync", sync_main, _BB_DIR_BIN, sync_usage)
APPLET(sync, sync_main, _BB_DIR_BIN)
#endif
#ifdef BB_SYSLOGD
APPLET("syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage)
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_TAIL
APPLET("tail", tail_main, _BB_DIR_USR_BIN, tail_usage)
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TAR
APPLET("tar", tar_main, _BB_DIR_BIN, tar_usage)
APPLET(tar, tar_main, _BB_DIR_BIN)
#endif
#ifdef BB_TEE
APPLET("tee", tee_main, _BB_DIR_USR_BIN, tee_usage)
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TELNET
APPLET("telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage)
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TEST
APPLET("test", test_main, _BB_DIR_USR_BIN, test_usage)
APPLET(test, test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TFTP
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TIME
APPLET(time, time_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TOP
APPLET(top, top_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TOUCH
APPLET("touch", touch_main, _BB_DIR_BIN, touch_usage)
APPLET(touch, touch_main, _BB_DIR_BIN)
#endif
#ifdef BB_TR
APPLET("tr", tr_main, _BB_DIR_USR_BIN, tr_usage)
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRACEROUTE
APPLET(traceroute, traceroute_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET("true", true_main, _BB_DIR_BIN, true_usage)
APPLET(true, true_main, _BB_DIR_BIN)
#endif
#ifdef BB_TTY
APPLET("tty", tty_main, _BB_DIR_USR_BIN, tty_usage)
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UMOUNT
APPLET("umount", umount_main, _BB_DIR_BIN, umount_usage)
APPLET(umount, umount_main, _BB_DIR_BIN)
#endif
#ifdef BB_UNAME
APPLET("uname", uname_main, _BB_DIR_BIN, uname_usage)
APPLET(uname, uname_main, _BB_DIR_BIN)
#endif
#ifdef BB_UNIQ
APPLET("uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage)
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UNIX2DOS
APPLET("unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage)
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UPDATE
APPLET("update", update_main, _BB_DIR_SBIN, update_usage)
APPLET(update, update_main, _BB_DIR_SBIN)
#endif
#ifdef BB_UPTIME
APPLET("uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage)
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_USLEEP
APPLET("usleep", usleep_main, _BB_DIR_BIN, usleep_usage)
APPLET(usleep, usleep_main, _BB_DIR_BIN)
#endif
#ifdef BB_UUDECODE
APPLET("uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage)
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UUENCODE
APPLET("uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage)
APPLET(uuencode, uuencode_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_VI
APPLET(vi, vi_main, _BB_DIR_BIN)
#endif
#ifdef BB_WATCHDOG
APPLET("watchdog", watchdog_main, _BB_DIR_SBIN, watchdog_usage)
APPLET(watchdog, watchdog_main, _BB_DIR_SBIN)
#endif
#ifdef BB_WC
APPLET("wc", wc_main, _BB_DIR_USR_BIN, wc_usage)
APPLET(wc, wc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WGET
APPLET("wget", wget_main, _BB_DIR_USR_BIN, wget_usage)
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WHICH
APPLET("which", which_main, _BB_DIR_USR_BIN, which_usage)
APPLET(which, which_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WHOAMI
APPLET("whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage)
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_XARGS
APPLET("xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage)
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_YES
APPLET("yes", yes_main, _BB_DIR_USR_BIN, yes_usage)
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_GUNZIP
APPLET("zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage)
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
#endif
#if !defined(PROTOTYPES) && !defined(MAKE_LINKS)
{ 0,NULL,0,NULL}
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
{ 0,NULL,0 }
};
/* The -1 arises because of the {0,NULL,0,NULL} entry above. */
size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
#endif
-205
View File
@@ -1,205 +0,0 @@
/* vi: set sw=4 ts=4: */
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
#include "applets.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
static int been_there_done_that = 0;
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
"/",
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
};
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/*
* Where in the filesystem is this busybox?
* [return]
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
}
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
int i;
int rc;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf ( command, "%s/%s",
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, command);
if (rc) {
perror_msg("%s", command);
}
}
}
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
error_msg_and_die("applet not found\n");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
* If someone has a cleaner approach, by all means implement it.
*/
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
int use_symbolic_links = 0;
int rc = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
if (argc > 2) {
if ((strcmp(argv[2], "-s") == 0)) {
use_symbolic_links = 1;
}
}
/* link */
busybox = busybox_fullpath();
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
} else {
rc = 1;
}
return rc;
}
#endif /* BB_FEATURE_INSTALLER */
argc--;
/* If we've already been here once, exit now */
if (been_there_done_that == 1 || argc < 1) {
const struct BB_applet *a = applets;
fprintf(stderr, "%s\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use, and BusyBox\n"
"\twill act like whatever it was invoked as.\n"
"\nCurrently defined functions:\n", full_version);
while (a->name != 0) {
col +=
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
(a++)->name);
if (col > 60 && a->name != 0) {
fprintf(stderr, ",\n");
col = 0;
}
}
fprintf(stderr, "\n\n");
exit(-1);
}
/* Flag that we've been here already */
been_there_done_that = 1;
/* Move the command line down a notch */
len = argv[argc] + strlen(argv[argc]) - argv[1];
memmove(argv[0], argv[1], len);
memset(argv[0] + len, 0, argv[1] - argv[0]);
/* Fix up the argv pointers */
len = argv[1] - argv[0];
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
for (i = 0; i < argc; i++)
argv[i] -= len;
return (main(argc, argv));
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-21
View File
@@ -1,21 +0,0 @@
#!/bin/sh
# Make busybox links list file.
# input $1: full path to Config.h
# input $2: full path to applets.h
# output (stdout): list of pathnames that should be linked to busybox
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
CONFIG_H=${1:-Config.h}
APPLETS_H=${2:-applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
dir=substr($2,8)
gsub("_","/",dir)
if(dir=="/ROOT") dir=""
file=$3
gsub("\"","",file)
if (file=="busybox") next
print tolower(dir) "/" file
}'
-13
View File
@@ -1,13 +0,0 @@
#!/bin/sh
RAW=` \
gcc -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
-49
View File
@@ -1,49 +0,0 @@
#!/bin/sh
prefix=$1
if [ "$prefix" = "" ]; then
echo "No installation directory, aborting."
exit 1;
fi
if [ "$2" = "--hardlinks" ]; then
linkopts="-f"
else
linkopts="-fs"
fi
h=`sort busybox.links | uniq`
rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
for i in $h ; do
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
else
case "$appdir" in
/)
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
fi
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
done
exit 0
-1560
View File
File diff suppressed because it is too large. Load diff
+33 -167
View File
@@ -23,201 +23,67 @@
*
*/
#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;
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;
/*
* return the headerL_t struct for the filename descriptor
*/
extern ar_headers_t get_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\n");
if (strncmp(ar_magic,"!<arch>",7) != 0)
error_msg_and_die("invalid magic\n");
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[1];
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, newline, 1);
if (newline[0]!='\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 = (size_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:
usage(ar_usage);
show_usage();
}
}
/* check the src filename was specified */
if (optind == argc)
usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++;
head = get_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 (optind == argc) {
show_usage();
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
src_stream = xfopen(argv[optind++], "r");
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
archive_offset = 8;
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
}
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
/* Create a list of files to extract */
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, stdout, &get_header_ar, extract_function, "./", extract_names);
return EXIT_SUCCESS;
}
-223
View File
@@ -1,223 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
typedef struct ar_headers_s {
char *name;
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;
/*
* return the headerL_t struct for the filename descriptor
*/
extern ar_headers_t get_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\n");
if (strncmp(ar_magic,"!<arch>",7) != 0)
error_msg_and_die("invalid magic\n");
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[1];
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, newline, 1);
if (newline[0]!='\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 = (size_t) atoi(raw_ar_header.size);
/* long filenames have '/' as the first character */
if (raw_ar_header.name[0] == '/') {
if (raw_ar_header.name[1] == '/') {
/* multiple long filenames are stored as data in one entry */
long_name = (char *) xrealloc(long_name, entry->size);
full_read(srcFd, long_name, entry->size);
continue;
}
else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
strcpy(entry->name, &long_name[long_name_offset]);
}
}
else {
/* short filenames */
entry->name = xmalloc(16);
strncpy(entry->name, raw_ar_header.name, 16);
}
entry->name[strcspn(entry->name, " /")]='\0';
/* convert the rest of the now valid char header to its typed struct */
parse_mode(raw_ar_header.mode, &entry->mode);
entry->mtime = atoi(raw_ar_header.date);
entry->uid = atoi(raw_ar_header.uid);
entry->gid = atoi(raw_ar_header.gid);
entry->offset = lseek(srcFd, 0, SEEK_CUR);
/* add this entries header to our combined list */
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*entry->next = *head;
*head = *entry;
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
}
return(*head);
}
extern int ar_main(int argc, char **argv)
{
const int preserve_date = 1; /* preserve original dates */
const int verbose = 2; /* be verbose */
const int display = 4; /* display contents */
const int extract_to_file = 8; /* extract contents of archive */
const int extract_to_stdout = 16; /* extract to stdout */
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
ar_headers_t head, *extract_list=NULL;
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct |= preserve_date;
break;
case 'v':
funct |= verbose;
break;
case 't':
funct |= display;
break;
case 'p':
funct |= extract_to_stdout;
break;
case 'x':
funct |= extract_to_file;
break;
default:
usage(ar_usage);
}
}
/* check the src filename was specified */
if (optind == argc)
usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++;
head = get_headers(srcFd);
/* find files to extract or display */
/* search through argv and build extract list */
for (;optind<argc; optind++) {
ar_headers_t *ar_entry;
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
ar_entry = &head;
while (ar_entry->next != NULL) {
if (strcmp(argv[optind], ar_entry->name) == 0) {
ar_headers_t *tmp;
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*tmp = *extract_list;
*extract_list = *ar_entry;
extract_list->next = tmp;
break;
}
ar_entry=ar_entry->next;
}
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
}
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
}
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
}
return EXIT_SUCCESS;
}
-163
View File
@@ -1,163 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
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_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);
extern int dpkg_deb_main(int argc, char **argv)
{
const int dpkg_deb_contents = 1;
const int dpkg_deb_control = 2;
// const int dpkg_deb_info = 4;
const int dpkg_deb_extract = 8;
const int dpkg_deb_verbose_extract = 16;
int opt=0;
int optflag=0;
int extract_flag = FALSE;
int list_flag = FALSE;
int verbose_flag = FALSE;
int extract_to_stdout = FALSE;
char ar_filename[15];
int srcFd=0;
int status=0;
ar_headers_t *ar_headers = NULL;
char **extract_list=NULL;
char *target_dir=NULL;
while ((opt = getopt(argc, argv, "cexX")) != -1) {
switch (opt) {
case 'c':
optflag |= dpkg_deb_contents;
break;
case 'e':
optflag |= dpkg_deb_control;
break;
/* case 'I':
optflag |= dpkg_deb_info;
break;
*/
case 'x':
optflag |= dpkg_deb_extract;
break;
case 'X':
optflag |= dpkg_deb_verbose_extract;
break;
default:
usage(dpkg_deb_usage);
return EXIT_FAILURE;
}
}
if (((optind + 1 ) > argc) || (optflag == 0)) {
usage(dpkg_deb_usage);
return(EXIT_FAILURE);
}
if (optflag & dpkg_deb_contents) {
list_flag = TRUE;
verbose_flag = TRUE;
strcpy(ar_filename, "data.tar.gz");
}
else if (optflag & dpkg_deb_control) {
extract_flag = TRUE;
strcpy(ar_filename, "control.tar.gz");
if ( (optind + 1) == argc ) {
target_dir = (char *) xmalloc(7);
strcpy(target_dir, "DEBIAN");
}
else {
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
strcpy(target_dir, argv[optind+1]);
}
}
/* 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]);
}
*/
else if (optflag & dpkg_deb_extract) {
extract_flag = TRUE;
strcpy(ar_filename, "data.tar.gz");
if ( (optind + 2) > argc ) {
error_msg_and_die("No directory specified\n");
}
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
strcpy(target_dir, argv[optind+1]);
}
else if (optflag & dpkg_deb_verbose_extract) {
extract_flag = TRUE;
list_flag = TRUE;
strcpy(ar_filename, "data.tar.gz");
if ( (optind + 2) > argc ) {
error_msg_and_die("No directory specified\n");
}
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
strcpy(target_dir, argv[optind+1]);
}
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
srcFd = open(argv[optind], O_RDONLY);
*ar_headers = get_headers(srcFd);
if (ar_headers->next==NULL)
error_msg_and_die("Couldnt find %s in %s\n",ar_filename, argv[optind]);
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);
srcFd = tar_unzip_init(srcFd);
if ( target_dir != NULL) {
if (is_directory(target_dir, TRUE, NULL)==FALSE) {
mkdir(target_dir, 0755);
}
if (chdir(target_dir)==-1) {
error_msg_and_die("Cannot change to dir %s\n",argv[optind+1]);
}
}
status = readTarFile(srcFd, extract_flag, list_flag, extract_to_stdout, verbose_flag, NULL, extract_list);
close (srcFd);
return(EXIT_SUCCESS);
}
-1363
View File
File diff suppressed because it is too large. Load diff
-3390
View File
File diff suppressed because it is too large. Load diff
-1206
View File
File diff suppressed because it is too large. Load diff
+13528
View File
File diff suppressed because it is too large. Load diff
+8 -6
View File
@@ -2,8 +2,8 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,8 +21,10 @@
*
*/
#include "busybox.h"
/* getopt not needed */
#include <stdlib.h>
#include "busybox.h"
#include <string.h>
extern int basename_main(int argc, char **argv)
@@ -31,7 +33,7 @@ extern int basename_main(int argc, char **argv)
char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(basename_usage);
show_usage();
}
argv++;
@@ -42,9 +44,9 @@ extern int basename_main(int argc, char **argv)
argv++;
n = strlen(*argv);
m = strlen(s);
if (m>=n && strncmp(s+m-n, *argv, n)==0)
if (m>n && strncmp(s+m-n, *argv, n)==0)
s[m-n] = '\0';
}
printf("%s\n", s);
puts(s);
return EXIT_SUCCESS;
}
+38 -71
View File
@@ -1,21 +1,15 @@
/* vi: set sw=4 ts=4: */
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#ifdef BB_LOCALE_SUPPORT
#include <locale.h>
#endif
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
#include "applets.h"
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
static int been_there_done_that = 0;
int been_there_done_that = 0; /* Also used in applets.c */
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
@@ -24,48 +18,25 @@ const char *applet_name;
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
"/",
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
};
static const char usr_bin [] ="/usr/bin";
static const char usr_sbin[] ="/usr/sbin";
static const char* const install_dir[] = {
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
&usr_bin [4], /* "/bin" */
&usr_sbin[4], /* "/sbin" */
usr_bin,
usr_sbin
};
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/*
* Where in the filesystem is this busybox?
* [return]
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static char *busybox_fullpath()
{
pid_t pid;
char path[256];
char proc[256];
int len;
pid = getpid();
sprintf(proc, "/proc/%d/exe", pid);
len = readlink(proc, path, 256);
if (len != -1) {
path[len] = 0;
} else {
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
}
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char command[256];
char *fpc;
int i;
int rc;
@@ -73,13 +44,13 @@ static void install_links(const char *busybox, int use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf ( command, "%s/%s",
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, command);
if (rc) {
perror_msg("%s", command);
fpc = concat_path_file(
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, fpc);
if (rc!=0 && errno!=EEXIST) {
perror_msg("%s", fpc);
}
free(fpc);
}
}
@@ -87,33 +58,29 @@ static void install_links(const char *busybox, int use_symbolic_links)
int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
const char *s;
for (s = applet_name = argv[0]; *s != '\0';) {
applet_name = argv[0];
if (applet_name[0] == '-')
applet_name++;
for (s = applet_name; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
#ifdef BB_LOCALE_SUPPORT
#ifdef BB_INIT
if(getpid()!=1) /* Do not set locale for `init' */
#endif
{
setlocale(LC_ALL, "");
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
error_msg_and_die("applet not found\n");
run_applet_by_name(applet_name, argc, argv);
error_msg_and_die("applet not found");
}
@@ -140,7 +107,7 @@ int busybox_main(int argc, char **argv)
}
/* link */
busybox = busybox_fullpath();
busybox = xreadlink("/proc/self/exe");
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
@@ -176,7 +143,7 @@ int busybox_main(int argc, char **argv)
}
}
fprintf(stderr, "\n\n");
exit(-1);
exit(0);
}
/* Flag that we've been here already */
+29 -164
View File
@@ -31,33 +31,13 @@
#include <sys/stat.h>
#include <sys/types.h>
#define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/* Some useful definitions */
#define FALSE ((int) 0)
#define TRUE ((int) 1)
#define SKIP ((int) 2)
/* for mtab.c */
#define MTAB_GETMOUNTPT '1'
#define MTAB_GETDEVICE '2'
#define BUF_SIZE 8192
#define EXPAND_ALLOC 1024
static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
/* Macros for min/max. */
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
#include <features.h>
enum Location {
@@ -72,7 +52,6 @@ struct BB_applet {
const char* name;
int (*main)(int argc, char** argv);
enum Location location;
const char* usage;
};
/* From busybox.c */
extern const struct BB_applet applets[];
@@ -87,139 +66,23 @@ extern const struct BB_applet applets[];
#include "applets.h"
#undef PROTOTYPES
extern const char *applet_name;
extern int applet_name_compare(const void *x, const void *y);
extern void usage(const char *usage) __attribute__ ((noreturn));
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
const char *mode_string(int mode);
const char *time_string(time_t timeVal);
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
int isDevice(const char *name);
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;
int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void);
int copy_file(const char *srcName, const char *destName,
int setModes, int followLinks, int forceFlag);
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
char *buildName(const char *dirName, const char *fileName);
int makeString(int argc, const char **argv, char *buf, int bufLen);
char *getChunk(int size);
char *chunkstrdup(const char *str);
void freeChunks(void);
ssize_t safe_read(int fd, void *buf, size_t count);
int full_write(int fd, const char *buf, int len);
int full_read(int fd, char *buf, int len);
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
void* userData);
extern int create_path (const char *name, int mode);
extern int parse_mode( const char* s, mode_t* theMode);
extern int get_kernel_revision(void);
extern int get_console_fd(char* tty_name);
extern struct mntent *find_mount_point(const char *name, const char *table);
extern void write_mtab(char* blockDevice, char* directory,
char* filesystemType, long flags, char* string_flags);
extern void erase_mtab(const char * name);
extern void mtab_read(void);
extern char *mtab_first(void **iter);
extern char *mtab_next(void **iter);
extern char *mtab_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern);
extern long atoi_w_units (const char *cp);
extern pid_t* find_pid_by_name( char* pidName);
extern int find_real_root_device_name(char* name);
extern char *get_line_from_file(FILE *file);
extern void print_file(FILE *file);
extern int print_file_by_name(char *filename);
extern char process_escape_sequence(char **ptr);
extern char *get_last_path_component(char *path);
extern FILE *wfopen(const char *path, const char *mode);
extern FILE *xfopen(const char *path, const char *mode);
#ifndef DMALLOC
extern void *xmalloc (size_t size);
extern void *xrealloc(void *old, size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
extern char *xstrdup (const char *s);
#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]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#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]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
#define RELEASE_BB_BUFFER(buffer) free (buffer)
#endif
extern char *xstrndup (const char *s, int n);
struct suffix_mult {
char *suffix;
int mult;
};
extern unsigned long parse_number(const char *numstr, struct suffix_mult *suffixes);
/* These parse entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed embedded systems. */
extern long my_getpwnam(char *name);
extern long my_getgrnam(char *name);
extern void my_getpwuid(char *name, long uid);
extern void my_getgrgid(char *group, long gid);
extern long my_getpwnamegid(char *name);
extern int device_open(char *device, int mode);
#if defined BB_FEATURE_MOUNT_LOOP
extern int del_loop(const char *device);
extern int set_loop(const char *device, const char *file, int offset, int *loopro);
extern char *find_unused_loop_device (void);
#endif
#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
extern int vdprintf(int d, const char *format, va_list ap);
#endif
#if defined BB_NFSMOUNT
int nfsmount(const char *spec, const char *node, int *flags,
char **extra_opts, char **mount_opts, int running_bg);
#endif
#ifndef RB_POWER_OFF
/* Stop system and switch power off if possible. */
#define RB_POWER_OFF 0x4321fedc
#endif
/* Include our own copy of struct sysinfo to avoid binary compatability
* problems with Linux 2.4, which changed things. Grumble, grumble. */
struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
unsigned long totalhigh; /* Total high memory size */
unsigned long freehigh; /* Available high memory size */
unsigned int mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
};
extern int sysinfo (struct sysinfo* info);
/* Bit map related macros -- libc5 doens't provide these... sigh. */
#ifndef setbit
#define NBBY CHAR_BIT
@@ -229,19 +92,21 @@ extern int sysinfo (struct sysinfo* info);
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
char *format(unsigned long val, unsigned long hr);
#define KILOBYTE 1024
#define MEGABYTE (KILOBYTE*1024)
#define GIGABYTE (MEGABYTE*1024)
#ifndef RB_POWER_OFF
/* Stop system and switch power off if possible. */
#define RB_POWER_OFF 0x4321fedc
#endif
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
/* Pull in the utility routines from libbb */
#include "libbb/libbb.h"
/* Try to pull in PATH_MAX */
#include <limits.h>
/* for PATH_MAX on systems that don't have it in limits.h */
#include <sys/param.h>
#ifndef PATH_MAX
#define PATH_MAX 256
#endif
#endif /* _BB_INTERNAL_H_ */
+3
View File
@@ -7,6 +7,9 @@
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
export LC_ALL=POSIX
export LC_CTYPE=POSIX
CONFIG_H=${1:-Config.h}
APPLETS_H=${2:-applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
+8 -5
View File
@@ -1,13 +1,16 @@
#!/bin/sh
export LC_ALL=POSIX
export LC_CTYPE=POSIX
RAW=` \
gcc -E -dM ${1:-Config.h} | \
$CC -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
# I added in the extra "ls" so only source files that
# actually exist will show up in the compile list.
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
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' ' '
+17 -9
View File
@@ -1,13 +1,21 @@
Name: busybox
Version: 0.49
Release: 1
%define name busybox
%define epoch 0
%define version 0.60.3
%define release %(date -I | sed -e 's/-/_/g')
%define serial 1
Name: %{name}
#Epoch: %{epoch}
Version: %{version}
Release: %{release}
Serial: %{serial}
Copyright: GPL
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
Copyright: GPL
Packager : Erik Andersen <andersen@lineo.com>
Conflicts: fileutils grep shellutils
Buildroot: /tmp/%{Name}-%{Version}
Source: %{Name}-%{Version}.tar.gz
URL: http://busybox.net/
Source: ftp://busybox.net/busybox/%{name}-%{version}.tar.gz
Buildroot: /var/tmp/%{name}-%{version}
Packager : Erik Andersen <andersen@codepoet.org>
%Description
BusyBox combines tiny versions of many common UNIX utilities into a single
@@ -19,7 +27,7 @@ their full featured GNU cousins; however, the options that are provided behave
very much like their GNU counterparts.
%Prep
%setup -q -n %{Name}-%{Version}
%setup -q -n %{name}-%{version}
%Build
make
+4 -3
View File
@@ -2,8 +2,8 @@
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,8 +21,9 @@
*
*/
#include "busybox.h"
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
extern int cat_main(int argc, char **argv)
{
+91
View File
@@ -0,0 +1,91 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
#define lchown chown
#endif
static long gid;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (lchown(fileName, statbuf->st_uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
return (TRUE);
}
perror(fileName);
return (FALSE);
}
int chgrp_main(int argc, char **argv)
{
int opt;
int recursiveFlag = FALSE;
char *p=NULL;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "R")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
default:
show_usage();
}
}
if (argc > optind && argc > 2 && argv[optind]) {
/* Find the selected group */
gid = strtoul(argv[optind], &p, 10); /* maybe it's already numeric */
if (argv[optind] == p)
gid = my_getgrnam(argv[optind]);
} else {
error_msg_and_die(too_few_args);
}
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+97
View File
@@ -0,0 +1,97 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <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;
int opt_eq_modeFlag = FALSE;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Rrwxst")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
case 'r':
case 'w':
case 'x':
case 's':
case 't':
opt_eq_modeFlag = TRUE;
break;
default:
show_usage();
}
}
if (opt_eq_modeFlag == TRUE) {
optind--;
}
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:
*/
-179
View File
@@ -1,179 +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 "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_option
#define bb_need_too_few_args
#include "messages.c"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
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:
#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\n", 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;
const char *appUsage;
whichApp = (strcmp(applet_name, "chown") == 0)?
CHOWN_APP : (strcmp(applet_name, "chmod") == 0)?
CHMOD_APP : CHGRP_APP;
appUsage = (whichApp == CHOWN_APP)?
chown_usage : (whichApp == CHMOD_APP) ? chmod_usage : chgrp_usage;
if (argc < 2)
usage(appUsage);
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);
if (gid == -1)
goto bad_group;
} else {
groupName = strchr(*argv, '.');
if (groupName == NULL)
groupName = strchr(*argv, ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
if (gid == -1)
goto bad_group;
} else
gid = -1;
}
/* Find the selected user (if appropriate) */
if (whichApp == CHOWN_APP) {
uid = strtoul(*argv, &p, 10); /* if numeric ... */
if (*argv == p)
uid = my_getpwnam(*argv);
if (uid == -1) {
error_msg_and_die( "unknown user name: %s\n", *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;
bad_group:
error_msg_and_die( "unknown group name: %s\n", groupName);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+113
View File
@@ -0,0 +1,113 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
#define lchown chown
#endif
static long uid;
static long gid;
static int (*chown_func)(const char *, __uid_t, __gid_t) = chown;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
return (TRUE);
}
perror(fileName);
return (FALSE);
}
int chown_main(int argc, char **argv)
{
int opt;
int recursiveFlag = FALSE,
noderefFlag = FALSE;
char *groupName=NULL;
char *p=NULL;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Rh")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
case 'h':
noderefFlag = TRUE;
break;
default:
show_usage();
}
}
if (noderefFlag) chown_func = lchown;
if (argc > optind && argc > 2 && argv[optind]) {
/* First, check if there is a group name here */
groupName = strchr(argv[optind], '.');
if (groupName == NULL)
groupName = strchr(argv[optind], ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
} else {
gid = -1;
}
/* Now check for the username */
uid = strtoul(argv[optind], &p, 10); /* Is is numeric? */
if (argv[optind] == p) {
uid = my_getpwnam(argv[optind]);
}
} else {
error_msg_and_die(too_few_args);
}
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+11 -8
View File
@@ -3,8 +3,8 @@
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,18 +22,18 @@
*
*/
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include "busybox.h"
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(chroot_usage);
show_usage();
}
argc--;
argv++;
@@ -48,14 +48,17 @@ int chroot_main(int argc, char **argv)
prog = *argv;
execvp(*argv, argv);
} else {
#ifndef BB_SH
#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#else
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
shell_main(argc, argv);
return EXIT_SUCCESS;
#endif
}
perror_msg_and_die("cannot execute %s", prog);
+6 -3
View File
@@ -4,12 +4,15 @@
*
* busyboxed by Erik Andersen
*/
#include "busybox.h"
/* getopt not needed */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
static const int VT_ACTIVATE = 0x5606; /* make vt active */
@@ -20,8 +23,8 @@ int chvt_main(int argc, char **argv)
int fd, num;
if ((argc != 2) || (**(argv + 1) == '-'))
usage (chvt_usage);
fd = get_console_fd("/dev/console");
show_usage();
fd = get_console_fd();
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num))
perror_msg_and_die("VT_ACTIVATE");
+3 -3
View File
@@ -3,8 +3,8 @@
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,9 +22,9 @@
*
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include "busybox.h"
extern int clear_main(int argc, char **argv)
+1307 -662
View File
File diff suppressed because it is too large. Load diff
+5 -7
View File
@@ -1,13 +1,11 @@
#ifndef CMDEDIT_H
#define CMDEDIT_H
#ifdef BB_FEATURE_SH_COMMAND_EDITING
#include <stddef.h>
int cmdedit_read_input(char* promptStr, char* command);
void cmdedit_init(void);
void cmdedit_terminate(void);
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
#ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY
void load_history ( const char *fromfile );
void save_history ( const char *tofile );
#endif
#endif /* CMDEDIT_H */
+25 -13
View File
@@ -2,9 +2,7 @@
/*
* Mini cmp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
* Copyright (C) 1999,2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,32 +20,46 @@
*
*/
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <getopt.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1 = 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)
usage(cmp_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)
-40
View File
@@ -1,40 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* chvt.c - aeb - 940227 - Change virtual terminal
*
* busyboxed by Erik Andersen
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
/* From <linux/vt.h> */
static const int VT_ACTIVATE = 0x5606; /* make vt active */
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
int chvt_main(int argc, char **argv)
{
int fd, num;
if ((argc != 2) || (**(argv + 1) == '-'))
usage (chvt_usage);
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num))
perror_msg_and_die("VT_ACTIVATE");
if (ioctl(fd, VT_WAITACTIVE, num))
perror_msg_and_die("VT_WAITACTIVE");
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-43
View File
@@ -1,43 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
* Renamed deallocvt.
*/
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
/* From <linux/vt.h> */
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
int fd, num, i;
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
if (argc > 2)
usage(deallocvt_usage);
fd = get_console_fd("/dev/console");
if (argc == 1) {
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0))
perror_msg_and_die("VT_DISALLOCATE");
} else {
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
error_msg("0: illegal VT number\n");
else if (num == 1)
error_msg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num))
perror_msg_and_die("VT_DISALLOCATE");
}
}
return EXIT_SUCCESS;
}
-95
View File
@@ -1,95 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dumpkmap implementation for busybox
*
* Copyright (C) Arne Bernin <arne@matrix.loopback.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 "busybox.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_table;
unsigned char kb_index;
unsigned short kb_value;
};
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
/* From <linux/keyboard.h> */
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
int dumpkmap_main(int argc, char **argv)
{
struct kbentry ke;
int i, j, fd;
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
if (argc>=2 && *argv[1]=='-') {
usage(dumpkmap_usage);
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
perror_msg("Error opening /dev/tty0");
return EXIT_FAILURE;
}
write(1, magic, 7);
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
flags[0]=1;
flags[1]=1;
flags[2]=1;
flags[4]=1;
flags[5]=1;
flags[6]=1;
flags[8]=1;
flags[9]=1;
flags[10]=1;
flags[12]=1;
/* dump flags */
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,(void*)&ke.kb_value,2);
}
}
}
}
close(fd);
return EXIT_SUCCESS;
}
-392
View File
@@ -1,392 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Derived from
* mapscrn.c - version 0.92
*
* Was taken from console-tools and adapted by
* Peter Novodvorsky <petya@logic.ru>
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
typedef unsigned short unicode;
static long int ctoi(unsigned char *s, int *is_unicode);
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
unicode utf8_to_ucs2(char *buf);
int screen_map_load(int fd, FILE * fp);
int loadacm_main(int argc, char **argv)
{
int fd;
if (argc>=2 && *argv[1]=='-') {
usage(loadacm_usage);
}
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
perror_msg_and_die("Error opening /dev/tty1");
}
if (screen_map_load(fd, stdin)) {
perror_msg_and_die("Error loading acm");
}
write(fd, "\033(K", 3);
return EXIT_SUCCESS;
}
int screen_map_load(int fd, FILE * fp)
{
struct stat stbuf;
unicode wbuf[E_TABSZ];
unsigned char buf[E_TABSZ];
int parse_failed = 0;
int is_unicode;
if (fstat(fileno(fp), &stbuf))
perror_msg_and_die("Cannot stat map file");
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
(parse_failed =
(-1 == uni_screen_map_read_ascii(fp, wbuf, &is_unicode)))
|| (S_ISREG(stbuf.st_mode) && (stbuf.st_size == (sizeof(unicode) * E_TABSZ)))) { /* test for binary UTF map by size */
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
error_msg_and_die("16bit screen-map MUST be a regular file.\n");
else
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
perror_msg_and_die("Cannot read [new] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
#endif
}
/* if it was effectively a 16-bit ASCII, OK, else try to read as 8-bit map */
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
else
return 0;
}
}
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
perror_msg_and_die("fseek failed assuming 8bit screen-map");
}
/* ... and try an old 8-bit screen-map */
if (!(parse_failed = (-1 == old_screen_map_read_ascii(fp, buf))) ||
(S_ISREG(stbuf.st_mode) && (stbuf.st_size == E_TABSZ))) { /* test for binary old 8-bit map by size */
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
error_msg_and_die("fseek() returned ESPIPE !\n");
else
perror_msg_and_die("fseek for binary 8bit screen-map");
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
perror_msg_and_die("Cannot read [old] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
#endif
}
if (ioctl(fd, PIO_SCRNMAP, buf))
perror_msg_and_die("PIO_SCRNMAP ioctl");
else
return 0;
}
error_msg("Error parsing symbolic map\n");
return(1);
}
/*
* - reads `fp' as a 16-bit ASCII SFM file.
* - returns -1 on error.
* - returns it in `unicode' in an E_TABSZ-elements array.
* - sets `*is_unicode' flagiff there were any non-8-bit
* (ie. real 16-bit) mapping.
*
* FIXME: ignores everything after second word
*/
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
{
char buffer[256]; /* line buffer reading file */
char *p, *q; /* 1st + 2nd words in line */
int in, on; /* the same, as numbers */
int tmp_is_unicode; /* tmp for is_unicode calculation */
int i; /* loop index - result holder */
int ret_code = 0; /* return code */
sigset_t sigset, old_sigset;
assert(is_unicode);
*is_unicode = 0;
/* first 128 codes defaults to ASCII */
for (i = 0; i < 128; i++)
buf[i] = i;
/* remaining defaults to replacement char (usually E_TABSZ = 256) */
for (; i < E_TABSZ; i++)
buf[i] = 0xfffd;
/* block SIGCHLD */
sigemptyset(&sigset);
sigaddset(&sigset, SIGCHLD);
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
do {
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
else
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
}
/* get "charset-relative charcode", stripping leading spaces */
p = strtok(buffer, " \t\n");
/* skip empty lines and comments */
if (!p || *p == '#')
continue;
/* get unicode mapping */
q = strtok(NULL, " \t\n");
if (q) {
in = ctoi(p, NULL);
if (in < 0 || in > 255) {
ret_code = -1;
break;
}
on = ctoi(q, &tmp_is_unicode);
if (in < 0 && on > 65535) {
ret_code = -1;
break;
}
*is_unicode |= tmp_is_unicode;
buf[in] = on;
} else {
ret_code = -1;
break;
}
}
while (1); /* terminated by break on feof() */
/* restore sig mask */
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
return ret_code;
}
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
{
char buffer[256];
int in, on;
char *p, *q;
for (in = 0; in < 256; in++)
buf[in] = in;
while (fgets(buffer, sizeof(buffer) - 1, fp)) {
p = strtok(buffer, " \t\n");
if (!p || *p == '#')
continue;
q = strtok(NULL, " \t\n#");
if (q) {
in = ctoi(p, NULL);
if (in < 0 || in > 255)
return -1;
on = ctoi(q, NULL);
if (in < 0 && on > 255)
return -1;
buf[in] = on;
} else
return -1;
}
return (0);
}
/*
* - converts a string into an int.
* - supports dec and hex bytes, hex UCS2, single-quoted byte and UTF8 chars.
* - returns the converted value
* - if `is_unicode != NULL', use it to tell whether it was unicode
*
* CAVEAT: will report valid UTF mappings using only 1 byte as 8-bit ones.
*/
long int ctoi(unsigned char *s, int *is_unicode)
{
int i;
size_t ls;
ls = strlen(s);
if (is_unicode)
*is_unicode = 0;
/* hex-specified UCS2 */
if ((strncmp(s, "U+", 2) == 0) &&
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2)) {
sscanf(s + 2, "%x", &i);
if (is_unicode)
*is_unicode = 1;
}
/* hex-specified byte */
else if ((ls <= 4) && (strncmp(s, "0x", 2) == 0) &&
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2))
sscanf(s + 2, "%x", &i);
/* oct-specified number (byte) */
else if ((*s == '0') && (strspn(s, "01234567") == ls))
sscanf(s, "%o", &i);
/* dec-specified number (byte) */
else if (strspn(s, "0123456789") == ls)
sscanf(s, "%d", &i);
/* single-byte quoted char */
else if ((strlen(s) == 3) && (s[0] == '\'') && (s[2] == '\''))
i = s[1];
/* multi-byte UTF8 quoted char */
else if ((s[0] == '\'') && (s[ls - 1] == '\'')) {
s[ls - 1] = 0; /* ensure we'll not "parse UTF too far" */
i = utf8_to_ucs2(s + 1);
if (is_unicode)
*is_unicode = 1;
} else
return (-1);
return (i);
}
void saveoldmap(int fd, char *omfil)
{
FILE *fp;
char buf[E_TABSZ];
#ifdef GIO_UNISCRNMAP
unicode xbuf[E_TABSZ];
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
perror_msg("GIO_UNISCRNMAP ioctl error");
#endif
if (ioctl(fd, GIO_SCRNMAP, buf))
perror_msg_and_die("GIO_SCRNMAP ioctl error");
else
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
#endif
fp = xfopen(omfil, "w");
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
if (fwrite(buf, E_TABSZ, 1, fp) != 1)
perror_msg_and_die("Error writing map to file");
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
perror_msg_and_die("Error writing map to file");
}
#endif
fclose(fp);
}
unicode utf8_to_ucs2(char *buf)
{
int utf_count = 0;
long utf_char = 0;
unicode tc = 0;
unsigned char c;
do {
c = *buf;
buf++;
/* if byte should be part of multi-byte sequence */
if (c & 0x80) {
/* if we have already started to parse a UTF8 sequence */
if (utf_count > 0 && (c & 0xc0) == 0x80) {
utf_char = (utf_char << 6) | (c & 0x3f);
utf_count--;
if (utf_count == 0)
tc = utf_char;
else
continue;
} else { /* Possibly 1st char of a UTF8 sequence */
if ((c & 0xe0) == 0xc0) {
utf_count = 1;
utf_char = (c & 0x1f);
} else if ((c & 0xf0) == 0xe0) {
utf_count = 2;
utf_char = (c & 0x0f);
} else if ((c & 0xf8) == 0xf0) {
utf_count = 3;
utf_char = (c & 0x07);
} else if ((c & 0xfc) == 0xf8) {
utf_count = 4;
utf_char = (c & 0x03);
} else if ((c & 0xfe) == 0xfc) {
utf_count = 5;
utf_char = (c & 0x01);
} else
utf_count = 0;
continue;
}
} else { /* not part of multi-byte sequence - treat as ASCII
* this makes incomplete sequences to be ignored
*/
tc = c;
utf_count = 0;
}
}
while (utf_count);
return tc;
}
-209
View File
@@ -1,209 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* loadfont.c - Eugene Crosser & Andries Brouwer
*
* Version 0.96bb
*
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
*/
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <memory.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
#include <endian.h>
static const int PSF_MAGIC1 = 0x36;
static const int PSF_MAGIC2 = 0x04;
static const int PSF_MODE512 = 0x01;
static const int PSF_MODEHASTAB = 0x02;
static const int PSF_MAXMODE = 0x03;
static const int PSF_SEPARATOR = 0xFFFF;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
unsigned char mode; /* PSF font mode */
unsigned char charsize; /* Character size */
};
#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
static void loadnewfont(int fd);
extern int loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
usage(loadfont_usage);
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
loadnewfont(fd);
return EXIT_SUCCESS;
}
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
{
char buf[16384];
int i;
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32)
error_msg_and_die("Bad character size %d\n", unit);
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
#if defined( PIO_FONTX ) && !defined( __sparc__ )
{
struct consolefontdesc cfd;
cfd.charcount = fontsize;
cfd.charheight = unit;
cfd.chardata = buf;
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */
perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
}
#endif
if (ioctl(fd, PIO_FONT, buf))
perror_msg_and_die("PIO_FONT ioctl error");
}
static void
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
{
struct unimapinit advice;
struct unimapdesc ud;
struct unipair *up;
int ct = 0, maxct;
int glyph;
u_short unicode;
maxct = tailsz; /* more than enough */
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
for (glyph = 0; glyph < fontsize; glyph++) {
while (tailsz >= 2) {
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
tailsz -= 2;
inbuf += 2;
if (unicode == PSF_SEPARATOR)
break;
up[ct].unicode = unicode;
up[ct].fontpos = glyph;
ct++;
}
}
/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
this printf did not work on many kernels */
advice.advised_hashsize = 0;
advice.advised_hashstep = 0;
advice.advised_hashlevel = 0;
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
error_msg("It seems this kernel is older than 1.1.92\n");
error_msg_and_die("No Unicode mapping table loaded.\n");
} else
#endif
perror_msg_and_die("PIO_UNIMAPCLR");
}
ud.entry_ct = ct;
ud.entries = up;
if (ioctl(fd, PIO_UNIMAP, &ud)) {
#if 0
if (errno == ENOMEM) {
/* change advice parameters */
}
#endif
perror_msg_and_die("PIO_UNIMAP");
}
}
static void loadnewfont(int fd)
{
int unit;
char inbuf[32768]; /* primitive */
unsigned int inputlth, offset;
/*
* We used to look at the length of the input file
* with stat(); now that we accept compressed files,
* just read the entire file.
*/
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin))
perror_msg_and_die("Error reading input font");
/* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values
for each font position */
if (!feof(stdin))
perror_msg_and_die("Font too large");
/* test for psf first */
{
struct psf_header psfhdr;
int fontsize;
int hastable;
unsigned int head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
psfhdr = *(struct psf_header *) &inbuf[0];
if (!PSF_MAGIC_OK(psfhdr))
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE)
error_msg_and_die("Unsupported psf file mode\n");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256)
error_msg_and_die("Only fontsize 256 supported\n");
#endif
hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize;
head0 = sizeof(struct psf_header);
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth))
error_msg_and_die("Input file: bad length\n");
do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
return;
}
no_psf:
/* file with three code pages? */
if (inputlth == 9780) {
offset = 40;
unit = 16;
} else {
/* bare font */
if (inputlth & 0377)
error_msg_and_die("Bad input file size\n");
offset = 0;
unit = inputlth / 256;
}
do_loadfont(fd, inbuf + offset, unit, 256);
}
-89
View File
@@ -1,89 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini loadkmap implementation for busybox
*
* Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
*
* 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 <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define BINARY_KEYMAP_MAGIC "bkeymap"
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_table;
unsigned char kb_index;
unsigned short kb_value;
};
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
/* From <linux/keyboard.h> */
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
int loadkmap_main(int argc, char **argv)
{
struct kbentry ke;
u_short *ibuff;
int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short);
char flags[MAX_NR_KEYMAPS], buff[7];
if (argc != 1)
usage(loadkmap_usage);
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
error_msg_and_die("This is not a valid binary keymap.\n");
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) xmalloc(ibuffsz);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
pos = 0;
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
perror_msg_and_die("Error reading keymap");
pos += readsz;
}
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
ke.kb_value = ibuff[j];
ioctl(fd, KDSKBENT, &ke);
}
}
}
/* Don't bother to close files. Exit does that
* automagically, so we can save a few bytes */
/* close(fd); */
return EXIT_SUCCESS;
}
-72
View File
@@ -1,72 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* setkeycodes
*
* Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
*
* Adjusted for BusyBox by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
/* From <linux/kd.h> */
struct kbkeycode {
unsigned int scancode, keycode;
};
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
extern int
setkeycodes_main(int argc, char** argv)
{
char *ep;
int fd, sc;
struct kbkeycode a;
if (argc % 2 != 1 || argc < 2) {
usage(setkeycodes_usage);
}
fd = get_console_fd("/dev/console");
while (argc > 2) {
a.keycode = atoi(argv[2]);
a.scancode = sc = strtol(argv[1], &ep, 16);
if (*ep) {
error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
}
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
if (a.scancode > 255 || a.keycode > 127) {
error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
}
if (ioctl(fd,KDSETKEYCODE,&a)) {
perror("KDSETKEYCODE");
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
}
argc -= 2;
argv += 2;
}
return EXIT_SUCCESS;
}
-66
View File
@@ -1,66 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cmp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1 = argv[1], *filename2 = "-";
int c1, c2, char_pos = 1, line_pos = 1;
/* parse argv[] */
if (argc < 2 || 3 < argc)
usage(cmp_usage);
fp1 = xfopen(argv[1], "r");
if (argv[2] != NULL) {
fp2 = xfopen(argv[2], "r");
filename2 = argv[2];
}
do {
c1 = fgetc(fp1);
c2 = fgetc(fp2);
if (c1 != c2) {
if (c1 == EOF)
printf("EOF on %s\n", filename1);
else if (c2 == EOF)
printf("EOF on %s\n", filename2);
else
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
char_pos, line_pos);
return EXIT_FAILURE;
}
char_pos++;
if (c1 == '\n')
line_pos++;
} while (c1 != EOF);
return EXIT_SUCCESS;
}
-246
View File
@@ -1,246 +0,0 @@
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 <unistd.h> /* getopt */
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "busybox.h"
/* globals from other files */
extern int optind;
extern char *optarg;
/* globals in this file only */
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;
/*
* decompose_list() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
*/
static void decompose_list(const char *list)
{
unsigned int nminus = 0;
char *ptr;
/* 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\n");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
error_msg_and_die("invalid byte or field list\n");
}
}
}
/* handle single value 'N' case */
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
error_msg_and_die("missing list of fields\n");
}
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;
}
}
}
/*
* snippy-snip
*/
static void cut_file(FILE *file)
{
char *line;
unsigned int cr_hits = 0;
/* 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);
}
}
}
/* 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++;
}
}
}
}
}
}
}
extern int cut_main(int argc, char **argv)
{
int opt;
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
switch (opt) {
case 'b':
case 'c':
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
error_msg_and_die("only one type of list may be specified\n");
}
part = (char)opt;
decompose_list(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
error_msg_and_die("the delimiter must be a single character\n");
}
delim = optarg[0];
break;
case 'n':
/* no-op */
break;
case 's':
supress_non_delimited_lines++;
break;
}
}
if (part == 0) {
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
}
if (supress_non_delimited_lines && part != 'f') {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields\n");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields\n");
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
* files were specified or '-' was specified, take input from stdin.
* Otherwise, we process all the files specified. */
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
cut_file(stdin);
}
else {
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
perror_msg("%s", argv[i]);
} else {
cut_file(file);
fclose(file);
}
}
}
return EXIT_SUCCESS;
}
-251
View File
@@ -1,251 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini date implementation for busybox
*
* by Matthew Grant <grantma@anathoth.gen.nz>
*
* 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"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
#include "messages.c"
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
setting time using UTC and displaying int, as well as
an RFC 822 complient date output for shell scripting
mail commands */
/* Input parsing code is always bulky - used heavy duty libc stuff as
much as possible, missed out a lot of bounds checking */
/* Default input handling to save suprising some people */
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
{
int nr;
nr = sscanf(t_string, "%2d%2d%2d%2d%d",
&(tm_time->tm_mon),
&(tm_time->tm_mday),
&(tm_time->tm_hour),
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
error_msg_and_die(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
if (tm_time->tm_year >= 1900)
tm_time->tm_year -= 1900;
/* adjust date */
tm_time->tm_mon -= 1;
return (tm_time);
}
/* The new stuff for LRP */
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
{
struct tm t;
/* Parse input and assign appropriately to tm_time */
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
/* no adjustments needed */
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
&t.tm_hour, &t.tm_min) == 2) {
/* no adjustments needed */
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
&t.tm_mon,
&t.tm_mday,
&t.tm_hour,
&t.tm_min, &t.tm_sec) == 5) {
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
&t.tm_mon,
&t.tm_mday,
&t.tm_hour, &t.tm_min) == 4) {
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
&t.tm_year,
&t.tm_mon,
&t.tm_mday,
&t.tm_hour,
&t.tm_min, &t.tm_sec) == 6) {
t.tm_year -= 1900; /* Adjust years */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
&t.tm_year,
&t.tm_mon,
&t.tm_mday,
&t.tm_hour, &t.tm_min) == 5) {
t.tm_year -= 1900; /* Adjust years */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
error_msg_and_die(invalid_date, t_string);
}
*tm_time = t;
return (tm_time);
}
int date_main(int argc, char **argv)
{
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
int c;
int set_time = 0;
int rfc822 = 0;
int utc = 0;
int use_arg = 0;
time_t tm;
struct tm tm_time;
/* Interpret command line args */
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
switch (c) {
case 'R':
rfc822 = 1;
break;
case 's':
set_time = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
usage(date_usage);
}
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
error_msg_and_die(memory_exhausted);
break;
case 'd':
use_arg = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
usage(date_usage);
break;
default:
usage(date_usage);
}
}
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
date_fmt = &argv[optind][1]; /* Skip over the '+' */
else if (date_str == NULL) {
set_time = 1;
date_str = argv[optind];
}
#if 0
else {
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
usage(date_usage);
}
#endif
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
time(&tm);
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
/* Zero out fields - take her back to midnight! */
if (date_str != NULL) {
tm_time.tm_sec = 0;
tm_time.tm_min = 0;
tm_time.tm_hour = 0;
}
/* Process any date input to UNIX time since 1 Jan 1970 */
if (date_str != NULL) {
if (strchr(date_str, ':') != NULL) {
date_conv_ftime(&tm_time, date_str);
} else {
date_conv_time(&tm_time, date_str);
}
/* 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);
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
error_msg_and_die(memory_exhausted);
}
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
perror_msg("cannot set date");
}
}
}
/* Display output */
/* Deal with format string */
if (date_fmt == NULL) {
date_fmt = (rfc822
? (utc
? "%a, %_d %b %Y %H:%M:%S GMT"
: "%a, %_d %b %Y %H:%M:%S %z")
: "%a %b %e %H:%M:%S %Z %Y");
} else if (*date_fmt == '\0') {
/* Imitate what GNU 'date' does with NO format string! */
printf("\n");
return EXIT_SUCCESS;
}
/* Handle special conversions */
if (strncmp(date_fmt, "%f", 2) == 0) {
date_fmt = "%Y.%m.%d-%H:%M:%S";
}
/* Print OUTPUT (after ALL that!) */
t_buff = xmalloc(201);
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
return EXIT_SUCCESS;
}
-158
View File
@@ -1,158 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dd 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 "busybox.h"
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
static struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
{ "w", 2 },
{ "b", 512 },
{ "kD", 1000 },
{ "k", 1024 },
{ "MD", 1000000 },
{ "M", 1048576 },
{ "GD", 1000000000 },
{ "G", 1073741824 },
{ NULL, 0 }
};
int dd_main(int argc, char **argv)
{
int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
off_t seek = 0, skip = 0;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
for (i = 1; i < argc; i++) {
if (strncmp("bs=", argv[i], 3) == 0)
bs = parse_number(argv[i]+3, dd_suffixes);
else if (strncmp("count=", argv[i], 6) == 0)
count = parse_number(argv[i]+6, dd_suffixes);
else if (strncmp("seek=", argv[i], 5) == 0)
seek = parse_number(argv[i]+5, dd_suffixes);
else if (strncmp("skip=", argv[i], 5) == 0)
skip = parse_number(argv[i]+5, dd_suffixes);
else if (strncmp("if=", argv[i], 3) == 0)
infile = argv[i]+3;
else if (strncmp("of=", argv[i], 3) == 0)
outfile = argv[i]+3;
else if (strncmp("conv=", argv[i], 5) == 0) {
buf = argv[i]+5;
while (1) {
if (strncmp("notrunc", buf, 7) == 0) {
trunc = FALSE;
buf += 7;
} else if (strncmp("sync", buf, 4) == 0) {
sync = TRUE;
buf += 4;
} else {
error_msg_and_die("invalid conversion `%s'\n", argv[i]+5);
}
if (buf[0] == '\0')
break;
if (buf[0] == ',')
buf++;
}
} else
usage(dd_usage);
}
buf = xmalloc(bs);
if (infile != NULL) {
if ((ifd = open(infile, O_RDONLY)) < 0)
perror_msg_and_die("%s", infile);
} else {
ifd = STDIN_FILENO;
infile = "standard input";
}
if (outfile != NULL) {
oflag = O_WRONLY | O_CREAT;
if (!seek && trunc)
oflag |= O_TRUNC;
if ((ofd = open(outfile, oflag, 0666)) < 0)
perror_msg_and_die("%s", outfile);
if (seek && trunc) {
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
}
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
if (skip) {
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", infile);
}
if (seek) {
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", outfile);
}
while (in_full + in_part != count) {
n = safe_read(ifd, buf, bs);
if (n < 0)
perror_msg_and_die("%s", infile);
if (n == 0)
break;
if (n == bs)
in_full++;
else
in_part++;
if (sync) {
memset(buf + n, '\0', bs - n);
n = bs;
}
n = full_write(ofd, buf, n);
if (n < 0)
perror_msg_and_die("%s", outfile);
if (n == bs)
out_full++;
else
out_part++;
}
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
return EXIT_SUCCESS;
}
-156
View File
@@ -1,156 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
* 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 <stdio.h>
#include <stdlib.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <getopt.h>
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long disp_hr = KILOBYTE;
#endif
static int df(char *device, const char *mountPoint)
{
struct statfs s;
long blocks_used;
long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) {
perror_msg("%s", mountPoint);
return FALSE;
}
if (s.f_blocks > 0) {
blocks_used = s.f_blocks - s.f_bfree;
if(0 == blocks_used)
blocks_percent_used = 0;
else
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
find_real_root_device_name( device);
}
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%-20s %9s",
device,
format((s.f_blocks * s.f_bsize), disp_hr));
printf(" %9s", format((s.f_blocks - s.f_bfree) * s.f_bsize, disp_hr));
printf(" %9s %3ld%% %s\n",
format(s.f_bavail * s.f_bsize, disp_hr),
blocks_percent_used, mountPoint);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
blocks_percent_used, mountPoint);
#endif
}
return TRUE;
}
extern int df_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int opt = 0;
int i = 0;
while ((opt = getopt(argc, argv, "?"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k"
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
case 'k': disp_hr = KILOBYTE; break;
#else
case 'k': break;
#endif
case '?': goto print_df_usage; break;
}
}
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
#ifdef BB_FEATURE_HUMAN_READABLE
(KILOBYTE == disp_hr) ? "1k-blocks" : " Size",
#else
"1k-blocks",
#endif
"Used", "Available", "Use%", "Mounted on");
if(optind < argc) {
struct mntent *mountEntry;
for(i = optind; i < argc; i++)
{
if ((mountEntry = find_mount_point(argv[i], mtab_file)) == 0) {
error_msg("%s: can't find mount point.\n", argv[i]);
status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE;
}
} else {
FILE *mountTable;
struct mntent *mountEntry;
mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) {
perror_msg("%s", mtab_file);
return EXIT_FAILURE;
}
while ((mountEntry = getmntent(mountTable))) {
if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE;
}
endmntent(mountTable);
}
return status;
print_df_usage:
usage(df_usage);
return(FALSE);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-45
View File
@@ -1,45 +0,0 @@
/*
Mini dos2unix implementation for busybox
Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA
All rights reserved.
Redistribution and use of this source code, with or without modification, is
permitted provided that the following condition is met:
1. Redistributions of this source code must retain the above copyright
notice, this condition, and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "busybox.h"
#include <stdio.h>
int dos2unix_main( int argc, char **argv ) {
int c;
if (argc > 1) {
c = *argv[1];
if (c == '-') {
usage(dos2unix_usage);
}
}
c = getchar();
while (c != EOF) {
/* Eat any \r's... they shouldn't be here */
while (c == '\r') c = getchar();
if (c == EOF) break;
putchar(c);
c = getchar();
}
return EXIT_SUCCESS;
}
-197
View File
@@ -1,197 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini du implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
* 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"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#include "messages.c"
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <errno.h>
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long du_disp_hr = KILOBYTE;
#endif
typedef void (Display) (long, char *);
static int du_depth = 0;
static int count_hardlinks = 0;
static Display *print;
static void print_normal(long size, char *filename)
{
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%s\t%s\n", format((size * KILOBYTE), du_disp_hr), filename);
#else
printf("%ld\t%s\n", size, filename);
#endif
}
static void print_summary(long size, char *filename)
{
if (du_depth == 1) {
printf("summary\n");
print_normal(size, filename);
}
}
/* tiny recursive du */
static long du(char *filename)
{
struct stat statbuf;
long sum;
int len;
if ((lstat(filename, &statbuf)) != 0) {
perror_msg_and_die("%s", filename);
}
du_depth++;
sum = (statbuf.st_blocks >> 1);
/* 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 (S_ISDIR(statbuf.st_mode)) {
DIR *dir;
struct dirent *entry;
dir = opendir(filename);
if (!dir) {
du_depth--;
return 0;
}
len = strlen(filename);
if (filename[len - 1] == '/')
filename[--len] = '\0';
while ((entry = readdir(dir))) {
char newfile[BUFSIZ + 1];
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
|| (strcmp(name, ".") == 0)) {
continue;
}
if (len + strlen(name) + 1 > BUFSIZ) {
error_msg(name_too_long);
du_depth--;
return 0;
}
sprintf(newfile, "%s/%s", filename, name);
sum += du(newfile);
}
closedir(dir);
print(sum, filename);
}
else if (statbuf.st_nlink > 1 && !count_hardlinks) {
/* Add files with hard links only once */
if (is_in_ino_dev_hashtable(&statbuf, NULL)) {
sum = 0L;
if (du_depth == 1)
print(sum, filename);
}
else {
add_to_ino_dev_hashtable(&statbuf, NULL);
}
}
du_depth--;
return sum;
}
int du_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int i;
int c;
/* default behaviour */
print = print_normal;
/* parse argv[] */
while ((c = getopt(argc, argv, "sl"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k")) != EOF) {
switch (c) {
case 's':
print = print_summary;
break;
case 'l':
count_hardlinks = 1;
break;
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': du_disp_hr = 0; break;
case 'm': du_disp_hr = MEGABYTE; break;
case 'k': du_disp_hr = KILOBYTE; break;
#else
case 'k': break;
#endif
default:
usage(du_usage);
}
}
/* go through remaining args (if any) */
if (optind >= argc) {
if (du(".") == 0)
status = EXIT_FAILURE;
} else {
long sum;
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
}
}
return status;
}
/* $Id: du.c,v 1.36 2001/01/27 09:33:38 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-533
View File
@@ -1,533 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini expr implementation for busybox
*
* based on GNU expr Mike Parker.
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
*
* Busybox modifications
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
*
* this program is free software; you can redistribute it and/or modify
* it under the terms of the gnu general public license as published by
* the free software foundation; either version 2 of the license, or
* (at your option) any later version.
*
* this program is distributed in the hope that it will be useful,
* but without any warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose. see the gnu
* general public license for more details.
*
* you should have received a copy of the gnu general public license
* along with this program; if not, write to the free software
* foundation, inc., 59 temple place, suite 330, boston, ma 02111-1307 usa
*
*/
/* This program evaluates expressions. Each token (operator, operand,
* parenthesis) of the expression must be a seperate argument. The
* parser used is a reasonably general one, though any incarnation of
* it is language-specific. It is especially nice for expressions.
*
* No parse tree is needed; a new node is evaluated immediately.
* One function can handle multiple operators all of equal precedence,
* provided they all associate ((x op x) op x). */
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <regex.h>
#include <sys/types.h>
/* The kinds of value we can have. */
enum valtype {
integer,
string
};
typedef enum valtype TYPE;
/* A value is.... */
struct valinfo {
TYPE type; /* Which kind. */
union { /* The value itself. */
int i;
char *s;
} u;
};
typedef struct valinfo VALUE;
/* The arguments given to the program, minus the program name. */
static char **args;
static VALUE *docolon (VALUE *sv, VALUE *pv);
static VALUE *eval (void);
static VALUE *int_value (int i);
static VALUE *str_value (char *s);
static int nextarg (char *str);
static int null (VALUE *v);
static int toarith (VALUE *v);
static void freev (VALUE *v);
static void tostring (VALUE *v);
int expr_main (int argc, char **argv)
{
VALUE *v;
if (argc == 1) {
error_msg_and_die("too few arguments\n");
}
args = argv + 1;
v = eval ();
if (*args)
error_msg_and_die ("syntax error\n");
if (v->type == integer)
printf ("%d\n", v->u.i);
else
printf ("%s\n", v->u.s);
exit (null (v));
}
/* Return a VALUE for I. */
static VALUE *int_value (int i)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = integer;
v->u.i = i;
return v;
}
/* Return a VALUE for S. */
static VALUE *str_value (char *s)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strdup (s);
return v;
}
/* Free VALUE V, including structure components. */
static void freev (VALUE *v)
{
if (v->type == string)
free (v->u.s);
free (v);
}
/* Return nonzero if V is a null-string or zero-number. */
static int null (VALUE *v)
{
switch (v->type) {
case integer:
return v->u.i == 0;
case string:
return v->u.s[0] == '\0' || strcmp (v->u.s, "0") == 0;
default:
abort ();
}
}
/* Coerce V to a string value (can't fail). */
static void tostring (VALUE *v)
{
char *temp;
if (v->type == integer) {
temp = xmalloc (4 * (sizeof (int) / sizeof (char)));
sprintf (temp, "%d", v->u.i);
v->u.s = temp;
v->type = string;
}
}
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
static int toarith (VALUE *v)
{
int i;
switch (v->type) {
case integer:
return 1;
case string:
i = 0;
/* Don't interpret the empty string as an integer. */
if (v->u.s == 0)
return 0;
i = atoi(v->u.s);
free (v->u.s);
v->u.i = i;
v->type = integer;
return 1;
default:
abort ();
}
}
/* Return nonzero if the next token matches STR exactly.
STR must not be NULL. */
static int
nextarg (char *str)
{
if (*args == NULL)
return 0;
return strcmp (*args, str) == 0;
}
/* The comparison operator handling functions. */
#define cmpf(name, rel) \
static int name (l, r) VALUE *l; VALUE *r; \
{ \
if (l->type == string || r->type == string) { \
tostring (l); \
tostring (r); \
return strcmp (l->u.s, r->u.s) rel 0; \
} \
else \
return l->u.i rel r->u.i; \
}
cmpf (less_than, <)
cmpf (less_equal, <=)
cmpf (equal, ==)
cmpf (not_equal, !=)
cmpf (greater_equal, >=)
cmpf (greater_than, >)
#undef cmpf
/* The arithmetic operator handling functions. */
#define arithf(name, op) \
static \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ("non-numeric argument\n"); \
return l->u.i op r->u.i; \
}
#define arithdivf(name, op) \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ( "non-numeric argument\n"); \
if (r->u.i == 0) \
error_msg_and_die ( "division by zero\n"); \
return l->u.i op r->u.i; \
}
arithf (plus, +)
arithf (minus, -)
arithf (multiply, *)
arithdivf (divide, /)
arithdivf (mod, %)
#undef arithf
#undef arithdivf
/* Do the : operator.
SV is the VALUE for the lhs (the string),
PV is the VALUE for the rhs (the pattern). */
static VALUE *docolon (VALUE *sv, VALUE *pv)
{
VALUE *v;
const char *errmsg;
struct re_pattern_buffer re_buffer;
struct re_registers re_regs;
int len;
tostring (sv);
tostring (pv);
if (pv->u.s[0] == '^') {
fprintf (stderr, "\
warning: unportable BRE: `%s': using `^' as the first character\n\
of a basic regular expression is not portable; it is being ignored",
pv->u.s);
}
len = strlen (pv->u.s);
memset (&re_buffer, 0, sizeof (re_buffer));
memset (&re_regs, 0, sizeof (re_regs));
re_buffer.allocated = 2 * len;
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
re_buffer.translate = 0;
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) {
error_msg_and_die("%s\n", errmsg);
}
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
if (len >= 0) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
sv->u.s[re_regs.end[1]] = '\0';
v = str_value (sv->u.s + re_regs.start[1]);
}
else
v = int_value (len);
}
else {
/* Match failed -- return the right kind of null. */
if (re_buffer.re_nsub > 0)
v = str_value ("");
else
v = int_value (0);
}
free (re_buffer.buffer);
return v;
}
/* Handle bare operands and ( expr ) syntax. */
static VALUE *eval7 (void)
{
VALUE *v;
if (!*args)
error_msg_and_die ( "syntax error\n");
if (nextarg ("(")) {
args++;
v = eval ();
if (!nextarg (")"))
error_msg_and_die ( "syntax error\n");
args++;
return v;
}
if (nextarg (")"))
error_msg_and_die ( "syntax error\n");
return str_value (*args++);
}
/* Handle match, substr, index, length, and quote keywords. */
static VALUE *eval6 (void)
{
VALUE *l, *r, *v, *i1, *i2;
if (nextarg ("quote")) {
args++;
if (!*args)
error_msg_and_die ( "syntax error\n");
return str_value (*args++);
}
else if (nextarg ("length")) {
args++;
r = eval6 ();
tostring (r);
v = int_value (strlen (r->u.s));
freev (r);
return v;
}
else if (nextarg ("match")) {
args++;
l = eval6 ();
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
return v;
}
else if (nextarg ("index")) {
args++;
l = eval6 ();
r = eval6 ();
tostring (l);
tostring (r);
v = int_value (strcspn (l->u.s, r->u.s) + 1);
if (v->u.i == (int) strlen (l->u.s) + 1)
v->u.i = 0;
freev (l);
freev (r);
return v;
}
else if (nextarg ("substr")) {
args++;
l = eval6 ();
i1 = eval6 ();
i2 = eval6 ();
tostring (l);
if (!toarith (i1) || !toarith (i2)
|| i1->u.i > (int) strlen (l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
v = str_value ("");
else {
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1),
l->u.s + i1->u.i - 1, i2->u.i);
v->u.s[i2->u.i] = 0;
}
freev (l);
freev (i1);
freev (i2);
return v;
}
else
return eval7 ();
}
/* Handle : operator (pattern matching).
Calls docolon to do the real work. */
static VALUE *eval5 (void)
{
VALUE *l, *r, *v;
l = eval6 ();
while (nextarg (":")) {
args++;
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
l = v;
}
return l;
}
/* Handle *, /, % operators. */
static VALUE *eval4 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval5 ();
while (1) {
if (nextarg ("*"))
fxn = multiply;
else if (nextarg ("/"))
fxn = divide;
else if (nextarg ("%"))
fxn = mod;
else
return l;
args++;
r = eval5 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle +, - operators. */
static VALUE *eval3 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval4 ();
while (1) {
if (nextarg ("+"))
fxn = plus;
else if (nextarg ("-"))
fxn = minus;
else
return l;
args++;
r = eval4 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle comparisons. */
static VALUE *eval2 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval3 ();
while (1) {
if (nextarg ("<"))
fxn = less_than;
else if (nextarg ("<="))
fxn = less_equal;
else if (nextarg ("=") || nextarg ("=="))
fxn = equal;
else if (nextarg ("!="))
fxn = not_equal;
else if (nextarg (">="))
fxn = greater_equal;
else if (nextarg (">"))
fxn = greater_than;
else
return l;
args++;
r = eval3 ();
toarith (l);
toarith (r);
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle &. */
static VALUE *eval1 (void)
{
VALUE *l, *r;
l = eval2 ();
while (nextarg ("&")) {
args++;
r = eval2 ();
if (null (l) || null (r)) {
freev (l);
freev (r);
l = int_value (0);
}
else
freev (r);
}
return l;
}
/* Handle |. */
static VALUE *eval (void)
{
VALUE *l, *r;
l = eval1 ();
while (nextarg ("|")) {
args++;
r = eval1 ();
if (null (l)) {
freev (l);
l = r;
}
else
freev (r);
}
return l;
}
-98
View File
@@ -1,98 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini head implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
* 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 <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
int head(int len, FILE *fp)
{
int i;
char *input;
for (i = 0; i < len; i++) {
if ((input = get_line_from_file(fp)) == NULL)
break;
fputs(input, stdout);
free(input);
}
return 0;
}
/* BusyBoxed head(1) */
int head_main(int argc, char **argv)
{
FILE *fp;
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
/* parse argv[] */
while ((opt = getopt(argc, argv, "n:")) > 0) {
switch (opt) {
case 'n':
len = atoi(optarg);
if (len >= 1)
break;
/* fallthrough */
default:
usage(head_usage);
}
}
/* get rest of argv[] or stdin if nothing's left */
if (argv[optind] == NULL) {
head(len, stdin);
return status;
}
need_headers = optind != (argc - 1);
while (argv[optind]) {
if (strcmp(argv[optind], "-") == 0) {
fp = stdin;
argv[optind] = "standard input";
} else {
if ((fp = wfopen(argv[optind], "r")) == NULL)
status = EXIT_FAILURE;
}
if (fp) {
if (need_headers) {
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
errno = 0;
}
if (optind < argc - 1)
putchar('\n');
if (fp != stdin)
fclose(fp);
}
optind++;
}
return status;
}
-100
View File
@@ -1,100 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini id implementation for busybox
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* 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 <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include <string.h>
#include <sys/types.h>
extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
int name_not_number = 0;
char user[9], group[9];
long gid;
long pwnam, grnam;
int opt;
gid = 0;
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
switch (opt) {
case 'u':
no_group++;
break;
case 'g':
no_user++;
break;
case 'r':
print_real++;
break;
case 'n':
name_not_number++;
break;
default:
usage(id_usage);
}
}
if (no_user && no_group) usage(id_usage);
if (argv[optind] == NULL) {
if (print_real) {
my_getpwuid(user, getuid());
my_getgrgid(group, getgid());
} else {
my_getpwuid(user, geteuid());
my_getgrgid(group, getegid());
}
} else {
strncpy(user, argv[optind], 8);
user[8] = '\0';
gid = my_getpwnamegid(user);
my_getgrgid(group, gid);
}
pwnam=my_getpwnam(user);
grnam=my_getgrnam(group);
if (gid == -1 || pwnam==-1 || grnam==-1) {
error_msg_and_die("%s: No such user\n", user);
}
if (no_group) {
if(name_not_number && user)
printf("%s\n",user);
else
printf("%ld\n", pwnam);
} else if (no_user) {
if(name_not_number && group)
printf("%s\n", group);
else
printf("%ld\n", grnam);
} else {
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
}
return(0);
}
/* END CODE */
-13
View File
@@ -1,13 +0,0 @@
/* vi: set sw=4 ts=4: */
#include "busybox.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-')
usage(length_usage);
printf("%lu\n", (long)strlen(argv[1]));
return EXIT_SUCCESS;
}
-121
View File
@@ -1,121 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini ln 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 "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_not_a_directory
#include "messages.c"
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
static const int LN_SYMLINK = 1;
static const int LN_FORCE = 2;
static const int LN_NODEREFERENCE = 4;
/*
* linkDestName is where the link points to,
* linkSrcName is the name of the link to be created.
*/
static int fs_link(const char *link_DestName, const char *link_SrcName, const int flag)
{
int status;
int srcIsDir;
char *srcName;
if (link_DestName==NULL)
return(FALSE);
srcName = (char *) malloc(strlen(link_SrcName)+strlen(link_DestName)+1);
if (link_SrcName==NULL)
strcpy(srcName, link_DestName);
else
strcpy(srcName, link_SrcName);
if (flag&LN_NODEREFERENCE)
srcIsDir = is_directory(srcName, TRUE, NULL);
else
srcIsDir = is_directory(srcName, FALSE, NULL);
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
strcat(srcName, "/");
strcat(srcName, link_DestName);
}
if (flag&LN_FORCE)
unlink(srcName);
if (flag&LN_SYMLINK)
status = symlink(link_DestName, srcName);
else
status = link(link_DestName, srcName);
if (status != 0) {
perror(srcName);
return(FALSE);
}
return(TRUE);
}
extern int ln_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int flag = 0;
int opt;
/* Parse any options */
while ((opt=getopt(argc, argv, "sfn")) != -1) {
switch(opt) {
case 's':
flag |= LN_SYMLINK;
break;
case 'f':
flag |= LN_FORCE;
break;
case 'n':
flag |= LN_NODEREFERENCE;
break;
default:
usage(ln_usage);
}
}
while(optind<(argc-1)) {
if (fs_link(argv[optind], argv[argc-1], flag)==FALSE)
status = EXIT_FAILURE;
optind++;
}
return(status);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-925
View File
@@ -1,925 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* tiny-ls.c version 0.1.0: A minimalist 'ls'
* Copyright (C) 1996 Brian Candler <B.Candler@pobox.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* 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
* linking in substantial chunks of libc can be disabled.
*
* Although I don't really want to add new features to this program to
* keep it small, I *am* interested to receive bug fixes and ways to make
* it more portable.
*
* KNOWN BUGS:
* 1. ls -l of a directory doesn't give "total <blocks>" header
* 2. ls of a symlink to a directory doesn't list directory contents
* 3. hidden files can make column width too large
*
* NON-OPTIMAL BEHAVIOUR:
* 1. autowidth reads directories twice
* 2. if you do a short directory listing without filetype characters
* appended, there's no need to stat each one
* PORTABILITY:
* 1. requires lstat (BSD) - how do you do it without?
*/
static const int TERMINAL_WIDTH = 80; /* use 79 if your terminal has linefold bug */
static const int COLUMN_WIDTH = 14; /* default if AUTOWIDTH not defined */
static const int COLUMN_GAP = 2; /* includes the file type char, if present */
/************************************************************************/
#include "busybox.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#ifdef BB_FEATURE_LS_TIMESTAMPS
#include <time.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
#ifndef NAJOR
#define MAJOR(dev) (((dev)>>8)&0xff)
#define MINOR(dev) ((dev)&0xff)
#endif
/* what is the overall style of the listing */
enum {
STYLE_AUTO = 0,
STYLE_LONG = 1, /* one record per line, extended info */
STYLE_SINGLE = 2, /* one record per line */
STYLE_COLUMNS = 3 /* fill columns */
};
/* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */
/* what file information will be listed */
#define LIST_INO (1<<0)
#define LIST_BLOCKS (1<<1)
#define LIST_MODEBITS (1<<2)
#define LIST_NLINKS (1<<3)
#define LIST_ID_NAME (1<<4)
#define LIST_ID_NUMERIC (1<<5)
#define LIST_SIZE (1<<6)
#define LIST_DEV (1<<7)
#define LIST_DATE_TIME (1<<8)
#define LIST_FULLTIME (1<<9)
#define LIST_FILENAME (1<<10)
#define LIST_SYMLINK (1<<11)
#define LIST_FILETYPE (1<<12)
#define LIST_EXEC (1<<13)
/* what files will be displayed */
#define DISP_NORMAL (0) /* show normal filenames */
#define DISP_DIRNAME (1<<0) /* 2 or more items? label directories */
#define DISP_HIDDEN (1<<1) /* show filenames starting with . */
#define DISP_DOT (1<<2) /* show . and .. */
#define DISP_NOLIST (1<<3) /* show directory as itself, not contents */
#define DISP_RECURSIVE (1<<4) /* show directory and everything below it */
#define DISP_ROWS (1<<5) /* print across rows */
#ifdef BB_FEATURE_LS_SORTFILES
/* how will the files be sorted */
static const int SORT_FORWARD = 0; /* sort in reverse order */
static const int SORT_REVERSE = 1; /* sort in reverse order */
static const int SORT_NAME = 2; /* sort by file name */
static const int SORT_SIZE = 3; /* sort by file size */
static const int SORT_ATIME = 4; /* sort by last access time */
static const int SORT_CTIME = 5; /* sort by last change time */
static const int SORT_MTIME = 6; /* sort by last modification time */
static const int SORT_VERSION = 7; /* sort by version */
static const int SORT_EXT = 8; /* sort by file name extension */
static const int SORT_DIR = 9; /* sort by file or directory */
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
/* which of the three times will be used */
static const int TIME_MOD = 0;
static const int TIME_CHANGE = 1;
static const int TIME_ACCESS = 2;
#endif
#define LIST_SHORT (LIST_FILENAME)
#define LIST_ISHORT (LIST_INO | LIST_FILENAME)
#define LIST_LONG (LIST_MODEBITS | LIST_NLINKS | LIST_ID_NAME | \
LIST_SIZE | LIST_DATE_TIME | LIST_FILENAME | \
LIST_SYMLINK)
#define LIST_ILONG (LIST_INO | LIST_LONG)
static const int SPLIT_DIR = 0;
static const int SPLIT_FILE = 1;
static const int SPLIT_SUBDIR = 2;
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
#ifdef BB_FEATURE_LS_FILETYPES
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
#endif
/*
* a directory entry and its stat info are stored here
*/
struct dnode { /* the basic node */
char *name; /* the dir entry name */
char *fullname; /* the dir entry name */
struct stat dstat; /* the file stat info */
struct dnode *next; /* point at the next node */
};
typedef struct dnode dnode_t;
struct dnode **list_dir(char *);
struct dnode **dnalloc(int);
int list_single(struct dnode *);
static unsigned int disp_opts;
static unsigned int style_fmt;
static unsigned int list_fmt;
#ifdef BB_FEATURE_LS_SORTFILES
static unsigned int sort_opts;
static unsigned int sort_order;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
static unsigned int time_fmt;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
static unsigned int follow_links=FALSE;
#endif
static unsigned short column = 0;
#ifdef BB_FEATURE_AUTOWIDTH
static unsigned short terminal_width;
static unsigned short column_width;
static unsigned short tabstops;
#else
static unsigned short column_width = COLUMN_WIDTH;
#endif
static int status = EXIT_SUCCESS;
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long ls_disp_hr = KILOBYTE;
#endif
static int my_stat(struct dnode *cur)
{
#ifdef BB_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) {
perror_msg("%s", cur->fullname);
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
return -1;
}
} else
#endif
if (lstat(cur->fullname, &cur->dstat)) {
perror_msg("%s", cur->fullname);
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
return -1;
}
return 0;
}
static void newline(void)
{
if (column > 0) {
putchar('\n');
column = 0;
}
}
/*----------------------------------------------------------------------*/
#ifdef BB_FEATURE_LS_FILETYPES
static char append_char(mode_t mode)
{
if ( !(list_fmt & LIST_FILETYPE))
return '\0';
if ((list_fmt & LIST_EXEC) && S_ISREG(mode)
&& (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return '*';
return APPCHAR(mode);
}
#endif
/*----------------------------------------------------------------------*/
static void nexttabstop( void )
{
static short nexttab= 0;
int n=0;
if (column > 0) {
n= nexttab - column;
if (n < 1) n= 1;
while (n--) {
putchar(' ');
column++;
}
}
nexttab= column + column_width + COLUMN_GAP;
}
/*----------------------------------------------------------------------*/
static int is_subdir(struct dnode *dn)
{
return (S_ISDIR(dn->dstat.st_mode) && strcmp(dn->name, ".") != 0 &&
strcmp(dn->name, "..") != 0);
}
int countdirs(struct dnode **dn, int nfiles)
{
int i, dirs;
if (dn==NULL || nfiles < 1) return(0);
dirs= 0;
for (i=0; i<nfiles; i++) {
if (S_ISDIR(dn[i]->dstat.st_mode)) dirs++;
}
return(dirs);
}
int countsubdirs(struct dnode **dn, int nfiles)
{
int i, subdirs;
if (dn == NULL || nfiles < 1) return 0;
subdirs = 0;
for (i = 0; i < nfiles; i++)
if (is_subdir(dn[i]))
subdirs++;
return subdirs;
}
int countfiles(struct dnode **dnp)
{
int nfiles;
struct dnode *cur;
if (dnp == NULL) return(0);
nfiles= 0;
for (cur= dnp[0]; cur->next != NULL ; cur= cur->next) nfiles++;
nfiles++;
return(nfiles);
}
/* get memory to hold an array of pointers */
struct dnode **dnalloc(int num)
{
struct dnode **p;
if (num < 1) return(NULL);
p= (struct dnode **)xcalloc((size_t)num, (size_t)(sizeof(struct dnode *)));
return(p);
}
void dfree(struct dnode **dnp)
{
struct dnode *cur, *next;
if(dnp == NULL) return;
cur=dnp[0];
while (cur != NULL) {
if (cur->fullname != NULL) free(cur->fullname); /* free the filename */
next= cur->next;
free(cur); /* free the dnode */
cur= next;
}
free(dnp); /* free the array holding the dnode pointers */
}
struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
{
int dncnt, i, d;
struct dnode **dnp;
if (dn==NULL || nfiles < 1) return(NULL);
/* count how many dirs and regular files there are */
if (which == SPLIT_SUBDIR)
dncnt = countsubdirs(dn, nfiles);
else {
dncnt= countdirs(dn, nfiles); /* assume we are looking for dirs */
if (which == SPLIT_FILE)
dncnt= nfiles - dncnt; /* looking for files */
}
/* allocate a file array and a dir array */
dnp= dnalloc(dncnt);
/* copy the entrys into the file or dir array */
for (d= i=0; i<nfiles; i++) {
if (which == SPLIT_DIR) {
if (S_ISDIR(dn[i]->dstat.st_mode)) {
dnp[d++]= dn[i];
} /* else skip the file */
} else if (which == SPLIT_SUBDIR) {
if (is_subdir(dn[i])) {
dnp[d++]= dn[i];
} /* else skip the file or dir */
} else {
if (!(S_ISDIR(dn[i]->dstat.st_mode))) {
dnp[d++]= dn[i];
} /* else skip the dir */
}
}
return(dnp);
}
/*----------------------------------------------------------------------*/
#ifdef BB_FEATURE_LS_SORTFILES
int sortcmp(struct dnode *d1, struct dnode *d2)
{
int cmp, dif;
cmp= 0;
if (sort_opts == SORT_SIZE) {
dif= (int)(d1->dstat.st_size - d2->dstat.st_size);
} else if (sort_opts == SORT_ATIME) {
dif= (int)(d1->dstat.st_atime - d2->dstat.st_atime);
} else if (sort_opts == SORT_CTIME) {
dif= (int)(d1->dstat.st_ctime - d2->dstat.st_ctime);
} else if (sort_opts == SORT_MTIME) {
dif= (int)(d1->dstat.st_mtime - d2->dstat.st_mtime);
} else if (sort_opts == SORT_DIR) {
dif= S_ISDIR(d1->dstat.st_mode) - S_ISDIR(d2->dstat.st_mode);
/* } else if (sort_opts == SORT_VERSION) { */
/* } else if (sort_opts == SORT_EXT) { */
} else { /* assume SORT_NAME */
dif= 0;
}
if (dif > 0) cmp= -1;
if (dif < 0) cmp= 1;
if (dif == 0) {
/* sort by name- may be a tie_breaker for time or size cmp */
dif= strcmp(d1->name, d2->name);
if (dif > 0) cmp= 1;
if (dif < 0) cmp= -1;
}
if (sort_order == SORT_REVERSE) {
cmp= -1 * cmp;
}
return(cmp);
}
/*----------------------------------------------------------------------*/
void shellsort(struct dnode **dn, int size)
{
struct dnode *temp;
int gap, i, j;
/* shell short the array */
if(dn==NULL || size < 2) return;
for (gap= size/2; gap>0; gap /=2) {
for (i=gap; i<size; i++) {
for (j= i-gap; j>=0; j-=gap) {
if (sortcmp(dn[j], dn[j+gap]) <= 0)
break;
/* they are out of order, swap them */
temp= dn[j];
dn[j]= dn[j+gap];
dn[j+gap]= temp;
}
}
}
}
#endif
/*----------------------------------------------------------------------*/
void showfiles(struct dnode **dn, int nfiles)
{
int i, ncols, nrows, row, nc;
#ifdef BB_FEATURE_AUTOWIDTH
int len;
#endif
if(dn==NULL || nfiles < 1) return;
#ifdef BB_FEATURE_AUTOWIDTH
/* find the longest file name- use that as the column width */
column_width= 0;
for (i=0; i<nfiles; i++) {
len= strlen(dn[i]->name) +
((list_fmt & LIST_INO) ? 8 : 0) +
((list_fmt & LIST_BLOCKS) ? 5 : 0)
;
if (column_width < len) column_width= len;
}
ncols= (int)(terminal_width / (column_width + COLUMN_GAP));
#else
ncols= TERMINAL_WIDTH;
#endif
switch (style_fmt) {
case STYLE_LONG: /* one record per line, extended info */
case STYLE_SINGLE: /* one record per line */
ncols= 1;
break;
}
nrows= nfiles / ncols;
if ((nrows * ncols) < nfiles) nrows++; /* round up fractionals */
if (nrows > nfiles) nrows= nfiles;
for (row=0; row<nrows; row++) {
for (nc=0; nc<ncols; nc++) {
/* reach into the array based on the column and row */
i= (nc * nrows) + row; /* assume display by column */
if (disp_opts & DISP_ROWS)
i= (row * ncols) + nc; /* display across row */
if (i < nfiles) {
nexttabstop();
list_single(dn[i]);
}
}
newline();
}
}
/*----------------------------------------------------------------------*/
void showdirs(struct dnode **dn, int ndirs)
{
int i, nfiles;
struct dnode **subdnp;
#ifdef BB_FEATURE_LS_RECURSIVE
int dndirs;
struct dnode **dnd;
#endif
if (dn==NULL || ndirs < 1) return;
for (i=0; i<ndirs; i++) {
if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) {
printf("\n%s:\n", dn[i]->fullname);
}
subdnp= list_dir(dn[i]->fullname);
nfiles= countfiles(subdnp);
if (nfiles > 0) {
/* list all files at this level */
#ifdef BB_FEATURE_LS_SORTFILES
shellsort(subdnp, nfiles);
#endif
showfiles(subdnp, nfiles);
#ifdef BB_FEATURE_LS_RECURSIVE
if (disp_opts & DISP_RECURSIVE) {
/* recursive- list the sub-dirs */
dnd= splitdnarray(subdnp, nfiles, SPLIT_SUBDIR);
dndirs= countsubdirs(subdnp, nfiles);
if (dndirs > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
shellsort(dnd, dndirs);
#endif
showdirs(dnd, dndirs);
free(dnd); /* free the array of dnode pointers to the dirs */
}
}
dfree(subdnp); /* free the dnodes and the fullname mem */
#endif
}
}
}
/*----------------------------------------------------------------------*/
struct dnode **list_dir(char *path)
{
struct dnode *dn, *cur, **dnp;
struct dirent *entry;
DIR *dir;
int i, nfiles;
if (path==NULL) return(NULL);
dn= NULL;
nfiles= 0;
dir = opendir(path);
if (dir == NULL) {
perror_msg("%s", path);
status = EXIT_FAILURE;
return(NULL); /* could not open the dir */
}
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;
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);
if (my_stat(cur))
continue;
cur->next= dn;
dn= cur;
nfiles++;
}
closedir(dir);
/* now that we know how many files there are
** allocate memory for an array to hold dnode pointers
*/
if (nfiles < 1) return(NULL);
dnp= dnalloc(nfiles);
for (i=0, cur=dn; i<nfiles; i++) {
dnp[i]= cur; /* save pointer to node in array */
cur= cur->next;
}
return(dnp);
}
/*----------------------------------------------------------------------*/
int list_single(struct dnode *dn)
{
int i, len;
char scratch[BUFSIZ + 1];
#ifdef BB_FEATURE_LS_TIMESTAMPS
char *filetime;
time_t ttime, age;
#endif
#if defined (BB_FEATURE_LS_FILETYPES)
struct stat info;
#endif
#ifdef BB_FEATURE_LS_FILETYPES
char append;
#endif
if (dn==NULL || dn->fullname==NULL) return(0);
#ifdef BB_FEATURE_LS_TIMESTAMPS
ttime= dn->dstat.st_mtime; /* the default time */
if (time_fmt & TIME_ACCESS) ttime= dn->dstat.st_atime;
if (time_fmt & TIME_CHANGE) ttime= dn->dstat.st_ctime;
filetime= ctime(&ttime);
#endif
#ifdef BB_FEATURE_LS_FILETYPES
append = append_char(dn->dstat.st_mode);
#endif
for (i=0; i<=31; i++) {
switch (list_fmt & (1<<i)) {
case LIST_INO:
printf("%7ld ", dn->dstat.st_ino);
column += 8;
break;
case LIST_BLOCKS:
#ifdef BB_FEATURE_HUMAN_READABLE
fprintf(stdout, "%5s ", format(dn->dstat.st_size, ls_disp_hr));
#else
#if _FILE_OFFSET_BITS == 64
printf("%4lld ", dn->dstat.st_blocks>>1);
#else
printf("%4ld ", dn->dstat.st_blocks>>1);
#endif
#endif
column += 5;
break;
case LIST_MODEBITS:
printf("%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
printf("%4d ", dn->dstat.st_nlink);
column += 10;
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
my_getpwuid(scratch, dn->dstat.st_uid);
if (*scratch)
printf("%-8.8s ", scratch);
else
printf("%-8d ", dn->dstat.st_uid);
my_getgrgid(scratch, dn->dstat.st_gid);
if (*scratch)
printf("%-8.8s", scratch);
else
printf("%-8d", dn->dstat.st_gid);
column += 17;
break;
#endif
case LIST_ID_NUMERIC:
printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
column += 17;
break;
case LIST_SIZE:
case LIST_DEV:
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
} else {
#ifdef BB_FEATURE_HUMAN_READABLE
fprintf(stdout, "%9s ", format(dn->dstat.st_size, ls_disp_hr));
#else
#if _FILE_OFFSET_BITS == 64
printf("%9lld ", dn->dstat.st_size);
#else
printf("%9ld ", dn->dstat.st_size);
#endif
#endif
}
column += 10;
break;
#ifdef BB_FEATURE_LS_TIMESTAMPS
case LIST_FULLTIME:
case LIST_DATE_TIME:
if (list_fmt & LIST_FULLTIME) {
printf("%24.24s ", filetime);
column += 25;
break;
}
age = time(NULL) - ttime;
printf("%6.6s ", filetime+4);
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
/* hh:mm if less than 6 months old */
printf("%5.5s ", filetime+11);
} else {
printf(" %4.4s ", filetime+20);
}
column += 13;
break;
#endif
case LIST_FILENAME:
printf("%s", dn->name);
column += strlen(dn->name);
break;
case LIST_SYMLINK:
if (S_ISLNK(dn->dstat.st_mode)) {
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
if (len > 0) {
scratch[len]= '\0';
printf(" -> %s", scratch);
#ifdef BB_FEATURE_LS_FILETYPES
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
}
#endif
column += len+4;
}
}
break;
#ifdef BB_FEATURE_LS_FILETYPES
case LIST_FILETYPE:
if (append != '\0') {
printf("%1c", append);
column++;
}
break;
#endif
}
}
return(0);
}
/*----------------------------------------------------------------------*/
extern int ls_main(int argc, char **argv)
{
struct dnode **dnf, **dnd;
int dnfiles, dndirs;
struct dnode *dn, *cur, **dnp;
int i, nfiles;
int opt;
int oi, ac;
char **av;
#ifdef BB_FEATURE_AUTOWIDTH
struct winsize win = { 0, 0, 0, 0 };
#endif
disp_opts= DISP_NORMAL;
style_fmt= STYLE_AUTO;
list_fmt= LIST_SHORT;
#ifdef BB_FEATURE_LS_SORTFILES
sort_opts= SORT_NAME;
sort_order= SORT_FORWARD;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
time_fmt= TIME_MOD;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
if (win.ws_row > 4)
column_width = win.ws_row - 2;
if (win.ws_col > 0)
terminal_width = win.ws_col - 1;
#endif
tabstops = 8;
nfiles=0;
/* process options */
while ((opt = getopt(argc, argv, "1AaCdgilnsx"
#ifdef BB_FEATURE_AUTOWIDTH
"T:w:"
#endif
#ifdef BB_FEATURE_LS_FILETYPES
"Fp"
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
"R"
#endif
#ifdef BB_FEATURE_LS_SORTFILES
"rSvX"
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
"cetu"
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
"L"
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
"h"
#endif
"k")) > 0) {
switch (opt) {
case '1': style_fmt = STYLE_SINGLE; break;
case 'A': disp_opts |= DISP_HIDDEN; break;
case 'a': disp_opts |= DISP_HIDDEN | DISP_DOT; break;
case 'C': style_fmt = STYLE_COLUMNS; break;
case 'd': disp_opts |= DISP_NOLIST; break;
case 'g': /* ignore -- for ftp servers */ break;
case 'i': list_fmt |= LIST_INO; break;
case 'l':
style_fmt = STYLE_LONG;
list_fmt |= LIST_LONG;
#ifdef BB_FEATURE_HUMAN_READABLE
ls_disp_hr = 1;
#endif
break;
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
case 's': list_fmt |= LIST_BLOCKS; break;
case 'x': disp_opts = DISP_ROWS; break;
#ifdef BB_FEATURE_LS_FILETYPES
case 'F': list_fmt |= LIST_FILETYPE | LIST_EXEC; break;
case 'p': list_fmt |= LIST_FILETYPE; break;
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
case 'R': disp_opts |= DISP_RECURSIVE; break;
#endif
#ifdef BB_FEATURE_LS_SORTFILES
case 'r': sort_order |= SORT_REVERSE; break;
case 'S': sort_opts= SORT_SIZE; break;
case 'v': sort_opts= SORT_VERSION; break;
case 'X': sort_opts= SORT_EXT; break;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
case 'e': list_fmt |= LIST_FULLTIME; break;
case 'c':
time_fmt = TIME_CHANGE;
#ifdef BB_FEATURE_LS_SORTFILES
sort_opts= SORT_CTIME;
#endif
break;
case 'u':
time_fmt = TIME_ACCESS;
#ifdef BB_FEATURE_LS_SORTFILES
sort_opts= SORT_ATIME;
#endif
break;
case 't':
#ifdef BB_FEATURE_LS_SORTFILES
sort_opts= SORT_MTIME;
#endif
break;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
case 'L': follow_links= TRUE; break;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
case 'T': tabstops= atoi(optarg); break;
case 'w': terminal_width= atoi(optarg); break;
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': ls_disp_hr = 0; break;
case 'k': ls_disp_hr = KILOBYTE; break;
#else
case 'k': break;
#endif
default:
goto print_usage_message;
}
}
/* sort out which command line options take precedence */
#ifdef BB_FEATURE_LS_RECURSIVE
if (disp_opts & DISP_NOLIST)
disp_opts &= ~DISP_RECURSIVE; /* no recurse if listing only dir */
#endif
#if defined (BB_FEATURE_LS_TIMESTAMPS) && defined (BB_FEATURE_LS_SORTFILES)
if (time_fmt & TIME_CHANGE) sort_opts= SORT_CTIME;
if (time_fmt & TIME_ACCESS) sort_opts= SORT_ATIME;
#endif
if (style_fmt != STYLE_LONG)
list_fmt &= ~LIST_ID_NUMERIC; /* numeric uid only for long list */
#ifdef BB_FEATURE_LS_USERNAME
if (style_fmt == STYLE_LONG && (list_fmt & LIST_ID_NUMERIC))
list_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */
#endif
/* choose a display format */
if (style_fmt == STYLE_AUTO)
style_fmt = isatty(fileno(stdout)) ? STYLE_COLUMNS : STYLE_SINGLE;
/*
* when there are no cmd line args we have to supply a default "." arg.
* we will create a second argv array, "av" that will hold either
* our created "." arg, or the real cmd line args. The av array
* just holds the pointers- we don't move the date the pointers
* point to.
*/
ac= argc - optind; /* how many cmd line args are left */
if (ac < 1) {
av= (char **)xcalloc((size_t)1, (size_t)(sizeof(char *)));
av[0]= xstrdup(".");
ac=1;
} else {
av= (char **)xcalloc((size_t)ac, (size_t)(sizeof(char *)));
for (oi=0 ; oi < ac; oi++) {
av[oi]= argv[optind++]; /* copy pointer to real cmd line arg */
}
}
/* now, everything is in the av array */
if (ac > 1)
disp_opts |= DISP_DIRNAME; /* 2 or more items? label directories */
/* stuff the command line file names into an dnode array */
dn=NULL;
for (oi=0 ; oi < ac; oi++) {
cur= (struct dnode *)xmalloc(sizeof(struct dnode));
cur->fullname= xstrdup(av[oi]);
cur->name= cur->fullname;
if (my_stat(cur))
continue;
cur->next= dn;
dn= cur;
nfiles++;
}
/* now that we know how many files there are
** allocate memory for an array to hold dnode pointers
*/
dnp= dnalloc(nfiles);
for (i=0, cur=dn; i<nfiles; i++) {
dnp[i]= cur; /* save pointer to node in array */
cur= cur->next;
}
if (disp_opts & DISP_NOLIST) {
#ifdef BB_FEATURE_LS_SORTFILES
shellsort(dnp, nfiles);
#endif
if (nfiles > 0) showfiles(dnp, nfiles);
} else {
dnd= splitdnarray(dnp, nfiles, SPLIT_DIR);
dnf= splitdnarray(dnp, nfiles, SPLIT_FILE);
dndirs= countdirs(dnp, nfiles);
dnfiles= nfiles - dndirs;
if (dnfiles > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
shellsort(dnf, dnfiles);
#endif
showfiles(dnf, dnfiles);
}
if (dndirs > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
shellsort(dnd, dndirs);
#endif
showdirs(dnd, dndirs);
}
}
return(status);
print_usage_message:
usage(ls_usage);
}
-954
View File
@@ -1,954 +0,0 @@
/* md5sum.c - Compute MD5 checksum of files or strings according to the
* definition of MD5 in RFC 1321 from April 1992.
* Copyright (C) 1995-1999 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
#undef TRUE
#undef FALSE
#define FALSE ((int) 1)
#define TRUE ((int) 0)
//----------------------------------------------------------------------------
//--------md5.c
//----------------------------------------------------------------------------
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
* according to the definition of MD5 in RFC 1321 from April 1992.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* NOTE: The canonical source of this file is maintained with the GNU C
* Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include "busybox.h"
//----------------------------------------------------------------------------
//--------md5.h
//----------------------------------------------------------------------------
/* md5.h - Declaration of functions and data types used for MD5 sum
computing library functions.
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
static const int _MD5_H = 1;
#include <stdio.h>
#if defined HAVE_LIMITS_H || defined _LIBC
# include <limits.h>
#endif
/* The following contortions are an attempt to use the C preprocessor
to determine an unsigned integral type that is 32 bits wide. An
alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
doing that would require that the configure script compile and *run*
the resulting executable. Locally running cross-compiled executables
is usually not possible. */
# include <sys/types.h>
typedef u_int32_t md5_uint32;
/* Structure to save state of computation between the single steps. */
struct md5_ctx
{
md5_uint32 A;
md5_uint32 B;
md5_uint32 C;
md5_uint32 D;
md5_uint32 total[2];
md5_uint32 buflen;
char buffer[128];
};
/*
* The following three functions are build up the low level used in
* the functions `md5_stream' and `md5_buffer'.
*/
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
extern void md5_init_ctx __P ((struct md5_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
extern void md5_process_block __P ((const void *buffer, size_t len,
struct md5_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is NOT required that LEN is a multiple of 64. */
extern void md5_process_bytes __P ((const void *buffer, size_t len,
struct md5_ctx *ctx));
/* Process the remaining bytes in the buffer and put result from CTX
in first 16 bytes following RESBUF. The result is always in little
endian byte order, so that a byte-wise output yields to the wanted
ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
/* Put result from CTX in first 16 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
extern int md5_stream __P ((FILE *stream, void *resblock));
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
#endif
//----------------------------------------------------------------------------
//--------end of md5.h
//----------------------------------------------------------------------------
#define SWAP(n) (n)
/* 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, ... */ };
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
void md5_init_ctx(struct md5_ctx *ctx)
{
ctx->A = 0x67452301;
ctx->B = 0xefcdab89;
ctx->C = 0x98badcfe;
ctx->D = 0x10325476;
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
}
/* Put result from CTX in first 16 bytes following RESBUF. The result
must be in little endian byte order.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
{
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
return resbuf;
}
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
{
/* Take yet unprocessed bytes into account. */
md5_uint32 bytes = ctx->buflen;
size_t pad;
/* Now count remaining bytes. */
ctx->total[0] += bytes;
if (ctx->total[0] < bytes)
++ctx->total[1];
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
memcpy(&ctx->buffer[bytes], fillbuf, pad);
/* 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));
/* Process last bytes. */
md5_process_block(ctx->buffer, bytes + pad + 8, ctx);
return md5_read_ctx(ctx, resbuf);
}
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
static const int BLOCKSIZE = 4096;
struct md5_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
/* Initialize the computation context. */
md5_init_ctx(&ctx);
/* Iterate over full file contents. */
while (1) {
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
computation function processes the whole buffer so that with the
next round of the loop another block can be read. */
size_t n;
sum = 0;
/* Read block. Take care for partial reads. */
do {
n = fread(buffer + sum, 1, BLOCKSIZE - sum, stream);
sum += n;
}
while (sum < BLOCKSIZE && n != 0);
if (n == 0 && ferror(stream))
return 1;
/* If end of file is reached, end the loop. */
if (n == 0)
break;
/* Process buffer with BLOCKSIZE bytes. Note that
BLOCKSIZE % 64 == 0
*/
md5_process_block(buffer, BLOCKSIZE, &ctx);
}
/* Add the last bytes if necessary. */
if (sum > 0)
md5_process_bytes(buffer, sum, &ctx);
/* Construct result in desired memory. */
md5_finish_ctx(&ctx, resblock);
return 0;
}
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *md5_buffer(const char *buffer, size_t len, void *resblock)
{
struct md5_ctx ctx;
/* Initialize the computation context. */
md5_init_ctx(&ctx);
/* Process whole buffer but last len % 64 bytes. */
md5_process_bytes(buffer, len, &ctx);
/* Put result in desired memory area. */
return md5_finish_ctx(&ctx, resblock);
}
void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
{
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
if (ctx->buflen != 0) {
size_t left_over = ctx->buflen;
size_t add = 128 - left_over > len ? len : 128 - left_over;
memcpy(&ctx->buffer[left_over], buffer, add);
ctx->buflen += add;
if (left_over + add > 64) {
md5_process_block(ctx->buffer, (left_over + add) & ~63, ctx);
/* The regions in the following copy operation cannot overlap. */
memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
(left_over + add) & 63);
ctx->buflen = (left_over + add) & 63;
}
buffer = (const char *) buffer + add;
len -= add;
}
/* Process available complete blocks. */
if (len > 64) {
md5_process_block(buffer, len & ~63, ctx);
buffer = (const char *) buffer + (len & ~63);
len &= 63;
}
/* Move remaining bytes in internal buffer. */
if (len > 0) {
memcpy(ctx->buffer, buffer, len);
ctx->buflen = len;
}
}
/* These are the four functions used in the four steps of the MD5 algorithm
and defined in the RFC 1321. The first function is a little bit optimized
(as found in Colin Plumbs public domain implementation). */
/* #define FF(b, c, d) ((b & c) | (~b & d)) */
#define FF(b, c, d) (d ^ (b & (c ^ d)))
#define FG(b, c, d) FF (d, b, c)
#define FH(b, c, d) (b ^ c ^ d)
#define FI(b, c, d) (c ^ (b | ~d))
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0. */
void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
{
md5_uint32 correct_words[16];
const md5_uint32 *words = buffer;
size_t nwords = len / sizeof(md5_uint32);
const md5_uint32 *endp = words + nwords;
md5_uint32 A = ctx->A;
md5_uint32 B = ctx->B;
md5_uint32 C = ctx->C;
md5_uint32 D = ctx->D;
/* First increment the byte count. RFC 1321 specifies the possible
length of the file up to 2^64 bits. Here we only compute the
number of bytes. Do a double word increment. */
ctx->total[0] += len;
if (ctx->total[0] < len)
++ctx->total[1];
/* Process all bytes in the buffer with 64 bytes in each round of
the loop. */
while (words < endp) {
md5_uint32 *cwp = correct_words;
md5_uint32 A_save = A;
md5_uint32 B_save = B;
md5_uint32 C_save = C;
md5_uint32 D_save = D;
/* 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
little endian byte order we perhaps have to change the byte order
before the computation. To reduce the work for the next steps
we store the swapped words in the array CORRECT_WORDS. */
#define OP(a, b, c, d, s, T) \
do \
{ \
a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \
++words; \
CYCLIC (a, s); \
a += b; \
} \
while (0)
/* It is unfortunate that C does not provide an operator for
cyclic rotation. Hope the C compiler is smart enough. */
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
/* Before we start, one word to the strange constants.
They are defined in RFC 1321 as
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
*/
/* Round 1. */
OP(A, B, C, D, 7, 0xd76aa478);
OP(D, A, B, C, 12, 0xe8c7b756);
OP(C, D, A, B, 17, 0x242070db);
OP(B, C, D, A, 22, 0xc1bdceee);
OP(A, B, C, D, 7, 0xf57c0faf);
OP(D, A, B, C, 12, 0x4787c62a);
OP(C, D, A, B, 17, 0xa8304613);
OP(B, C, D, A, 22, 0xfd469501);
OP(A, B, C, D, 7, 0x698098d8);
OP(D, A, B, C, 12, 0x8b44f7af);
OP(C, D, A, B, 17, 0xffff5bb1);
OP(B, C, D, A, 22, 0x895cd7be);
OP(A, B, C, D, 7, 0x6b901122);
OP(D, A, B, C, 12, 0xfd987193);
OP(C, D, A, B, 17, 0xa679438e);
OP(B, C, D, A, 22, 0x49b40821);
/* For the second to fourth round we have the possibly swapped words
in CORRECT_WORDS. Redefine the macro to take an additional first
argument specifying the function to use. */
#undef OP
#define OP(f, a, b, c, d, k, s, T) \
do \
{ \
a += f (b, c, d) + correct_words[k] + T; \
CYCLIC (a, s); \
a += b; \
} \
while (0)
/* Round 2. */
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);
OP(FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
OP(FG, A, B, C, D, 5, 5, 0xd62f105d);
OP(FG, D, A, B, C, 10, 9, 0x02441453);
OP(FG, C, D, A, B, 15, 14, 0xd8a1e681);
OP(FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
OP(FG, A, B, C, D, 9, 5, 0x21e1cde6);
OP(FG, D, A, B, C, 14, 9, 0xc33707d6);
OP(FG, C, D, A, B, 3, 14, 0xf4d50d87);
OP(FG, B, C, D, A, 8, 20, 0x455a14ed);
OP(FG, A, B, C, D, 13, 5, 0xa9e3e905);
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);
/* Round 3. */
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);
OP(FH, B, C, D, A, 14, 23, 0xfde5380c);
OP(FH, A, B, C, D, 1, 4, 0xa4beea44);
OP(FH, D, A, B, C, 4, 11, 0x4bdecfa9);
OP(FH, C, D, A, B, 7, 16, 0xf6bb4b60);
OP(FH, B, C, D, A, 10, 23, 0xbebfbc70);
OP(FH, A, B, C, D, 13, 4, 0x289b7ec6);
OP(FH, D, A, B, C, 0, 11, 0xeaa127fa);
OP(FH, C, D, A, B, 3, 16, 0xd4ef3085);
OP(FH, B, C, D, A, 6, 23, 0x04881d05);
OP(FH, A, B, C, D, 9, 4, 0xd9d4d039);
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);
/* Round 4. */
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);
OP(FI, B, C, D, A, 5, 21, 0xfc93a039);
OP(FI, A, B, C, D, 12, 6, 0x655b59c3);
OP(FI, D, A, B, C, 3, 10, 0x8f0ccc92);
OP(FI, C, D, A, B, 10, 15, 0xffeff47d);
OP(FI, B, C, D, A, 1, 21, 0x85845dd1);
OP(FI, A, B, C, D, 8, 6, 0x6fa87e4f);
OP(FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
OP(FI, C, D, A, B, 6, 15, 0xa3014314);
OP(FI, B, C, D, A, 13, 21, 0x4e0811a1);
OP(FI, A, B, C, D, 4, 6, 0xf7537e82);
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);
/* Add the starting values of the context. */
A += A_save;
B += B_save;
C += C_save;
D += D_save;
}
/* Put checksum in context given as argument. */
ctx->A = A;
ctx->B = B;
ctx->C = C;
ctx->D = D;
}
//----------------------------------------------------------------------------
//--------end of md5.c
//----------------------------------------------------------------------------
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
#define IN_CTYPE_DOMAIN(c) 1
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
#define TOLOWER(Ch) tolower (Ch)
#define OPENOPTS(BINARY) "r"
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
not include any newline character at the end of a line. */
static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
2 - blank and binary indicator
1 - minimum filename length */
static int have_read_stdin; /* Nonzero if any of the files read were
the standard input. */
static int status_only = 0; /* With -c, don't generate any output.
The exit code indicates success or failure */
static int warn = 0; /* With -w, print a message to standard error warning
about each improperly formatted MD5 checksum line */
static int split_3(char *s,
size_t s_len,
unsigned char **u,
int *binary,
char **w)
{
size_t i = 0;
int escaped_filename = 0;
while (ISWHITE(s[i]))
++i;
/* The line must have at least 35 (36 if the first is a backslash)
more characters to contain correct message digest information.
Ignore this line if it is too short. */
if (!(s_len - i >= MIN_DIGEST_LINE_LENGTH
|| (s[i] == '\\' && s_len - i >= 1 + MIN_DIGEST_LINE_LENGTH)))
return FALSE;
if (s[i] == '\\') {
++i;
escaped_filename = 1;
}
*u = (unsigned char *) &s[i];
/* The first field has to be the 32-character hexadecimal
representation of the message digest. If it is not followed
immediately by a white space it's an error. */
i += 32;
if (!ISWHITE(s[i]))
return FALSE;
s[i++] = '\0';
if (s[i] != ' ' && s[i] != '*')
return FALSE;
*binary = (s[i++] == '*');
/* All characters between the type indicator and end of line are
significant -- that includes leading and trailing white space. */
*w = &s[i];
if (escaped_filename) {
/* Translate each `\n' string in the file name to a NEWLINE,
and each `\\' string to a backslash. */
char *dst = &s[i];
while (i < s_len) {
switch (s[i]) {
case '\\':
if (i == s_len - 1) {
/* A valid line does not end with a backslash. */
return FALSE;
}
++i;
switch (s[i++]) {
case 'n':
*dst++ = '\n';
break;
case '\\':
*dst++ = '\\';
break;
default:
/* Only `\' or `n' may follow a backslash. */
return FALSE;
}
break;
case '\0':
/* The file name may not contain a NUL. */
return FALSE;
break;
default:
*dst++ = s[i++];
break;
}
}
*dst = '\0';
}
return TRUE;
}
static int hex_digits(unsigned char const *s)
{
while (*s) {
if (!ISXDIGIT(*s))
return TRUE;
++s;
}
return FALSE;
}
/* An interface to md5_stream. Operate on FILENAME (it may be "-") and
put the result in *MD5_RESULT. Return non-zero upon failure, zero
to indicate success. */
static int md5_file(const char *filename,
int binary,
unsigned char *md5_result)
{
FILE *fp;
if (STREQ(filename, "-")) {
have_read_stdin = 1;
fp = stdin;
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
perror_msg("%s", filename);
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
perror_msg("%s", filename);
if (fp != stdin)
fclose(fp);
return FALSE;
}
if (fp != stdin && fclose(fp) == EOF) {
perror_msg("%s", filename);
return FALSE;
}
return TRUE;
}
static int md5_check(const char *checkfile_name)
{
FILE *checkfile_stream;
int n_properly_formated_lines = 0;
int n_mismatched_checksums = 0;
int n_open_or_read_failures = 0;
unsigned char md5buffer[16];
size_t line_number;
char line[BUFSIZ];
if (STREQ(checkfile_name, "-")) {
have_read_stdin = 1;
checkfile_stream = stdin;
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
perror_msg("%s", checkfile_name);
return FALSE;
}
}
line_number = 0;
do {
char *filename;
int binary;
unsigned char *md5num;
int line_length;
++line_number;
fgets(line, BUFSIZ-1, checkfile_stream);
line_length = strlen(line);
if (line_length <= 0 || line==NULL)
break;
/* Ignore comment lines, which begin with a '#' character. */
if (line[0] == '#')
continue;
/* Remove any trailing newline. */
if (line[line_length - 1] == '\n')
line[--line_length] = '\0';
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
if (warn) {
error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
checkfile_name, (unsigned long) line_number);
}
} else {
static const char bin2hex[] = {
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f'
};
++n_properly_formated_lines;
if (md5_file(filename, binary, md5buffer)) {
++n_open_or_read_failures;
if (!status_only) {
printf("%s: FAILED open or read\n", filename);
fflush(stdout);
}
} else {
size_t cnt;
/* Compare generated binary number with text representation
in check file. Ignore case of hex digits. */
for (cnt = 0; cnt < 16; ++cnt) {
if (TOLOWER(md5num[2 * cnt])
!= bin2hex[md5buffer[cnt] >> 4]
|| (TOLOWER(md5num[2 * cnt + 1])
!= (bin2hex[md5buffer[cnt] & 0xf])))
break;
}
if (cnt != 16)
++n_mismatched_checksums;
if (!status_only) {
printf("%s: %s\n", filename,
(cnt != 16 ? "FAILED" : "OK"));
fflush(stdout);
}
}
}
}
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
if (ferror(checkfile_stream)) {
error_msg("%s: read error\n", checkfile_name); /* */
return FALSE;
}
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
perror_msg("md5sum: %s", checkfile_name);
return FALSE;
}
if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */
error_msg("%s: no properly formatted MD5 checksum lines found\n",
checkfile_name);
return FALSE;
} else {
if (!status_only) {
int n_computed_checkums = (n_properly_formated_lines
- n_open_or_read_failures);
if (n_open_or_read_failures > 0) {
error_msg("WARNING: %d of %d listed files could not be read\n",
n_open_or_read_failures, n_properly_formated_lines);
return FALSE;
}
if (n_mismatched_checksums > 0) {
error_msg("WARNING: %d of %d computed checksums did NOT match\n",
n_mismatched_checksums, n_computed_checkums);
return FALSE;
}
}
}
return ((n_properly_formated_lines > 0 && n_mismatched_checksums == 0
&& n_open_or_read_failures == 0) ? 0 : 1);
}
int md5sum_main(int argc,
char **argv)
{
unsigned char md5buffer[16];
int do_check = 0;
int opt;
char **string = NULL;
size_t n_strings = 0;
size_t err = 0;
int file_type_specified = 0;
int binary = 0;
while ((opt = getopt(argc, argv, "g:bcstw")) != -1) {
switch (opt) {
case 'g': { /* read a string */
if (string == NULL)
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
if (optarg == NULL)
optarg = "";
string[n_strings++] = optarg;
break;
}
case 'b': /* read files in binary mode */
file_type_specified = 1;
binary = 1;
break;
case 'c': /* check MD5 sums against given list */
do_check = 1;
break;
case 's': /* don't output anything, status code shows success */
status_only = 1;
warn = 0;
break;
case 't': /* read files in text mode (default) */
file_type_specified = 1;
binary = 0;
break;
case 'w': /* warn about improperly formated MD5 checksum lines */
status_only = 0;
warn = 1;
break;
default:
usage(md5sum_usage);
}
}
if (file_type_specified && do_check) {
error_msg_and_die("the -b and -t options are meaningless when verifying checksums\n");
}
if (n_strings > 0 && do_check) {
error_msg_and_die("the -g and -c options are mutually exclusive\n");
}
if (status_only && !do_check) {
error_msg_and_die("the -s option is meaningful only when verifying checksums\n");
}
if (warn && !do_check) {
error_msg_and_die("the -w option is meaningful only when verifying checksums\n");
}
if (n_strings > 0) {
size_t i;
if (optind < argc) {
error_msg_and_die("no files may be specified when using -g\n");
}
for (i = 0; i < n_strings; ++i) {
size_t cnt;
md5_buffer (string[i], strlen (string[i]), md5buffer);
for (cnt = 0; cnt < 16; ++cnt)
printf ("%02x", md5buffer[cnt]);
printf (" \"%s\"\n", string[i]);
}
} else if (do_check) {
if (optind + 1 < argc) {
error_msg("only one argument may be specified when using -c\n");
}
err = md5_check ((optind == argc) ? "-" : argv[optind]);
} else {
if (optind == argc)
argv[argc++] = "-";
for (; optind < argc; ++optind) {
int fail;
char *file = argv[optind];
fail = md5_file (file, binary, md5buffer);
err |= fail;
if (!fail) {
size_t i;
/* Output a leading backslash if the file name contains
a newline or backslash. */
if (strchr (file, '\n') || strchr (file, '\\'))
putchar ('\\');
for (i = 0; i < 16; ++i)
printf ("%02x", md5buffer[i]);
putchar (' ');
if (binary)
putchar ('*');
else
putchar (' ');
/* Translate each NEWLINE byte to the string, "\\n",
and each backslash to "\\\\". */
for (i = 0; i < strlen (file); ++i) {
switch (file[i]) {
case '\n':
fputs ("\\n", stdout);
break;
case '\\':
fputs ("\\\\", stdout);
break;
default:
putchar (file[i]);
break;
}
}
putchar ('\n');
}
}
}
if (fclose (stdout) == EOF) {
error_msg_and_die("write error\n");
}
if (have_read_stdin && fclose (stdin) == EOF) {
error_msg_and_die("standard input\n");
}
if (err == 0)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
}
-106
View File
@@ -1,106 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini mkdir 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 "busybox.h"
#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
#include "messages.c"
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
static int parentFlag = FALSE;
static mode_t mode = 0777;
extern int mkdir_main(int argc, char **argv)
{
int i = FALSE;
argc--;
argv++;
/* Parse any options */
while (argc > 0 && **argv == '-') {
while (i == FALSE && *++(*argv)) {
switch (**argv) {
case 'm':
if (--argc == 0)
usage(mkdir_usage);
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
error_msg("Unknown mode: %s\n", *argv);
return EXIT_FAILURE;
}
/* Set the umask for this process so it doesn't
* screw up whatever the user just entered. */
umask(0);
i = TRUE;
break;
case 'p':
parentFlag = TRUE;
break;
default:
usage(mkdir_usage);
}
}
argc--;
argv++;
}
if (argc < 1) {
usage(mkdir_usage);
}
while (argc > 0) {
int status;
struct stat statBuf;
char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) {
error_msg(name_too_long);
return EXIT_FAILURE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
error_msg("%s: File exists\n", buf);
return EXIT_FAILURE;
}
if (parentFlag == TRUE) {
strcat(buf, "/");
create_path(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf);
return EXIT_FAILURE;
}
}
argc--;
argv++;
}
return EXIT_SUCCESS;
}
-60
View File
@@ -1,60 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini mkfifo implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@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 "busybox.h"
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
extern int mkfifo_main(int argc, char **argv)
{
char *thisarg;
mode_t mode = 0666;
argc--;
argv++;
/* Parse any options */
while (argc > 1) {
if (**argv != '-')
usage(mkfifo_usage);
thisarg = *argv;
thisarg++;
switch (*thisarg) {
case 'm':
argc--;
argv++;
parse_mode(*argv, &mode);
break;
default:
usage(mkfifo_usage);
}
argc--;
argv++;
}
if (argc < 1 || *argv[0] == '-')
usage(mkfifo_usage);
if (mkfifo(*argv, mode) < 0)
perror_msg_and_die("mkfifo");
return EXIT_SUCCESS;
}
-92
View File
@@ -1,92 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini mknod implementation for busybox
*
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
* 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 <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
int mknod_main(int argc, char **argv)
{
char *thisarg;
mode_t mode = 0;
mode_t perm = 0666;
dev_t dev = 0;
argc--;
argv++;
/* Parse any options */
while (argc > 1) {
if (**argv != '-')
break;
thisarg = *argv;
thisarg++;
switch (*thisarg) {
case 'm':
argc--;
argv++;
parse_mode(*argv, &perm);
umask(0);
break;
default:
usage(mknod_usage);
}
argc--;
argv++;
}
if (argc != 4 && argc != 2) {
usage(mknod_usage);
}
switch (argv[1][0]) {
case 'c':
case 'u':
mode = S_IFCHR;
break;
case 'b':
mode = S_IFBLK;
break;
case 'p':
mode = S_IFIFO;
if (argc!=2) {
usage(mknod_usage);
}
break;
default:
usage(mknod_usage);
}
if (mode == S_IFCHR || mode == S_IFBLK) {
dev = (atoi(argv[2]) << 8) | atoi(argv[3]);
}
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
perror_msg_and_die("%s", argv[0]);
return EXIT_SUCCESS;
}
-474
View File
@@ -1,474 +0,0 @@
/* vi: set sw=4 ts=4: */
/* printf - format and print data
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Usage: printf format [argument...]
A front end to the printf function that lets it be used from the shell.
Backslash escapes:
\" = double quote
\\ = backslash
\a = alert (bell)
\b = backspace
\c = produce no further output
\f = form feed
\n = new line
\r = carriage return
\t = horizontal tab
\v = vertical tab
\0ooo = octal number (ooo is 0 to 3 digits)
\xhhh = hexadecimal number (hhh is 1 to 3 digits)
Additional directive:
%b = print an argument string, interpreting backslash escapes
The `format' argument is re-used as many times as necessary
to convert all of the given arguments.
David MacKenzie <djm@gnu.ai.mit.edu> */
// 19990508 Busy Boxed! Dave Cinege
#include "busybox.h"
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <ctype.h>
#ifndef S_IFMT
static const int S_IFMT = 0170000;
#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#endif
#if !defined(S_ISCHR) && defined(S_IFCHR)
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
#if !defined(S_ISDIR) && defined(S_IFDIR)
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISREG) && defined(S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISFIFO) && defined(S_IFIFO)
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined(S_ISLNK) && defined(S_IFLNK)
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#endif
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#endif
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
#endif
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
#define IN_CTYPE_DOMAIN(c) 1
#ifdef isblank
# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
#else
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
#endif
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
#define isodigit(c) ((c) >= '0' && (c) <= '7')
#define hextobin(c) ((c)>='a'&&(c)<='f' ? (c)-'a'+10 : (c)>='A'&&(c)<='F' ? (c)-'A'+10 : (c)-'0')
#define octtobin(c) ((c) - '0')
static double xstrtod __P((char *s));
static int print_esc __P((char *escstart));
static int print_formatted __P((char *format, int argc, char **argv));
static long xstrtol __P((char *s));
static unsigned long xstrtoul __P((char *s));
static void print_direc
__P(
(char *start, size_t length, int field_width, int precision,
char *argument));
static void print_esc_char __P((int c));
static void print_esc_string __P((char *str));
static void verify __P((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
int printf_main(int argc, char **argv)
{
char *format;
int args_used;
exit_status = 0;
if (argc <= 1 || **(argv + 1) == '-') {
usage(printf_usage);
}
format = argv[1];
argc -= 2;
argv += 2;
do {
args_used = print_formatted(format, argc, argv);
argc -= args_used;
argv += args_used;
}
while (args_used > 0 && argc > 0);
/*
if (argc > 0)
fprintf(stderr, "excess args ignored");
*/
return(exit_status);
}
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
arguments to any `%' directives.
Return the number of elements of ARGV used. */
static int print_formatted(char *format, int argc, char **argv)
{
int save_argc = argc; /* Preserve original value. */
char *f; /* Pointer into `format'. */
char *direc_start; /* Start of % directive. */
size_t direc_length; /* Length of % directive. */
int field_width; /* Arg to first '*', or -1 if none. */
int precision; /* Arg to second '*', or -1 if none. */
for (f = format; *f; ++f) {
switch (*f) {
case '%':
direc_start = f++;
direc_length = 1;
field_width = precision = -1;
if (*f == '%') {
putchar('%');
break;
}
if (*f == 'b') {
if (argc > 0) {
print_esc_string(*argv);
++argv;
--argc;
}
break;
}
if (strchr("-+ #", *f)) {
++f;
++direc_length;
}
if (*f == '*') {
++f;
++direc_length;
if (argc > 0) {
field_width = xstrtoul(*argv);
++argv;
--argc;
} else
field_width = 0;
} else
while (ISDIGIT(*f)) {
++f;
++direc_length;
}
if (*f == '.') {
++f;
++direc_length;
if (*f == '*') {
++f;
++direc_length;
if (argc > 0) {
precision = xstrtoul(*argv);
++argv;
--argc;
} else
precision = 0;
} else
while (ISDIGIT(*f)) {
++f;
++direc_length;
}
}
if (*f == 'l' || *f == 'L' || *f == 'h') {
++f;
++direc_length;
}
/*
if (!strchr ("diouxXfeEgGcs", *f))
fprintf(stderr, "%%%c: invalid directive", *f);
*/
++direc_length;
if (argc > 0) {
print_direc(direc_start, direc_length, field_width,
precision, *argv);
++argv;
--argc;
} else
print_direc(direc_start, direc_length, field_width,
precision, "");
break;
case '\\':
f += print_esc(f);
break;
default:
putchar(*f);
}
}
return save_argc - argc;
}
/* Print a \ escape sequence starting at ESCSTART.
Return the number of characters in the escape sequence
besides the backslash. */
static int print_esc(char *escstart)
{
register char *p = escstart + 1;
int esc_value = 0; /* Value of \nnn escape. */
int esc_length; /* Length of \nnn escape. */
/* \0ooo and \xhhh escapes have maximum length of 3 chars. */
if (*p == 'x') {
for (esc_length = 0, ++p;
esc_length < 3 && ISXDIGIT(*p); ++esc_length, ++p)
esc_value = esc_value * 16 + hextobin(*p);
/* if (esc_length == 0)
fprintf(stderr, "missing hex in esc");
*/
putchar(esc_value);
} else if (*p == '0') {
for (esc_length = 0, ++p;
esc_length < 3 && isodigit(*p); ++esc_length, ++p)
esc_value = esc_value * 8 + octtobin(*p);
putchar(esc_value);
} else if (strchr("\"\\abcfnrtv", *p))
print_esc_char(*p++);
/* else
fprintf(stderr, "\\%c: invalid esc", *p);
*/
return p - escstart - 1;
}
/* Output a single-character \ escape. */
static void print_esc_char(int c)
{
switch (c) {
case 'a': /* Alert. */
putchar(7);
break;
case 'b': /* Backspace. */
putchar(8);
break;
case 'c': /* Cancel the rest of the output. */
exit(0);
break;
case 'f': /* Form feed. */
putchar(12);
break;
case 'n': /* New line. */
putchar(10);
break;
case 'r': /* Carriage return. */
putchar(13);
break;
case 't': /* Horizontal tab. */
putchar(9);
break;
case 'v': /* Vertical tab. */
putchar(11);
break;
default:
putchar(c);
break;
}
}
/* Print string STR, evaluating \ escapes. */
static void print_esc_string(char *str)
{
for (; *str; str++)
if (*str == '\\')
str += print_esc(str);
else
putchar(*str);
}
static void
print_direc(char *start, size_t length, int field_width, int precision,
char *argument)
{
char *p; /* Null-terminated copy of % directive. */
p = xmalloc((unsigned) (length + 1));
strncpy(p, start, length);
p[length] = 0;
switch (p[length - 1]) {
case 'd':
case 'i':
if (field_width < 0) {
if (precision < 0)
printf(p, xstrtol(argument));
else
printf(p, precision, xstrtol(argument));
} else {
if (precision < 0)
printf(p, field_width, xstrtol(argument));
else
printf(p, field_width, precision, xstrtol(argument));
}
break;
case 'o':
case 'u':
case 'x':
case 'X':
if (field_width < 0) {
if (precision < 0)
printf(p, xstrtoul(argument));
else
printf(p, precision, xstrtoul(argument));
} else {
if (precision < 0)
printf(p, field_width, xstrtoul(argument));
else
printf(p, field_width, precision, xstrtoul(argument));
}
break;
case 'f':
case 'e':
case 'E':
case 'g':
case 'G':
if (field_width < 0) {
if (precision < 0)
printf(p, xstrtod(argument));
else
printf(p, precision, xstrtod(argument));
} else {
if (precision < 0)
printf(p, field_width, xstrtod(argument));
else
printf(p, field_width, precision, xstrtod(argument));
}
break;
case 'c':
printf(p, *argument);
break;
case 's':
if (field_width < 0) {
if (precision < 0)
printf(p, argument);
else
printf(p, precision, argument);
} else {
if (precision < 0)
printf(p, field_width, argument);
else
printf(p, field_width, precision, argument);
}
break;
}
free(p);
}
static unsigned long xstrtoul(char *s)
{
char *end;
unsigned long val;
errno = 0;
val = strtoul(s, &end, 0);
verify(s, end);
return val;
}
static long xstrtol(char *s)
{
char *end;
long val;
errno = 0;
val = strtol(s, &end, 0);
verify(s, end);
return val;
}
static double xstrtod(char *s)
{
char *end;
double val;
errno = 0;
val = strtod(s, &end);
verify(s, end);
return val;
}
static void verify(char *s, char *end)
{
if (errno) {
fprintf(stderr, "%s", s);
exit_status = 1;
} else if (*end) {
/*
if (s == end)
fprintf(stderr, "%s: expected numeric", s);
else
fprintf(stderr, "%s: not completely converted", s);
*/
exit_status = 1;
}
}
-113
View File
@@ -1,113 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini rm 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 "busybox.h"
#include <stdio.h>
#include <time.h>
#include <utime.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
static int recursiveFlag = FALSE;
static int forceFlag = FALSE;
static const char *srcName;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (unlink(fileName) < 0) {
perror_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);
}
if (rmdir(fileName) < 0) {
perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
}
extern int rm_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int stopIt=FALSE;
struct stat statbuf;
argc--;
argv++;
/* Parse any options */
while (argc > 0 && stopIt == FALSE) {
if (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 'R':
case 'r':
recursiveFlag = TRUE;
break;
case 'f':
forceFlag = TRUE;
break;
case '-':
stopIt = TRUE;
break;
default:
usage(rm_usage);
}
argc--;
argv++;
}
else
break;
}
if (argc < 1 && forceFlag == FALSE) {
usage(rm_usage);
}
while (argc-- > 0) {
srcName = *(argv++);
if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0
&& errno == ENOENT) {
/* do not reports errors for non-existent files if -f, just skip them */
} else {
if (recursive_action(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
status = EXIT_FAILURE;
}
}
}
return status;
}
-89
View File
@@ -1,89 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini sort 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 "busybox.h"
#include <getopt.h>
#include <stdlib.h>
int compare_ascii(const void *x, const void *y)
{
return strcmp(*(char **)x, *(char **)y);
}
int compare_numeric(const void *x, const void *y)
{
return atoi(*(char **)x) - atoi(*(char **)y);
}
int sort_main(int argc, char **argv)
{
FILE *fp;
char *line, **lines = NULL;
int i, opt, nlines = 0;
int (*compare)(const void *, const void *) = compare_ascii;
#ifdef BB_FEATURE_SORT_REVERSE
int reverse = FALSE;
#endif
while ((opt = getopt(argc, argv, "nr")) != -1) {
switch (opt) {
case 'n':
compare = compare_numeric;
break;
#ifdef BB_FEATURE_SORT_REVERSE
case 'r':
reverse = TRUE;
break;
#endif
default:
usage(sort_usage);
}
}
/* read the input */
for (i = optind; i == optind || i < argc; i++) {
if (argv[i] == NULL)
fp = stdin;
else
fp = xfopen(argv[i], "r");
while ((line = get_line_from_file(fp)) != NULL) {
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
lines[nlines++] = line;
}
}
/* sort it */
qsort(lines, nlines, sizeof(char *), compare);
/* print it */
#ifdef BB_FEATURE_SORT_REVERSE
if (reverse)
for (i = nlines - 1; 0 <= i; i--)
fputs(lines[i], stdout);
else
#endif
for (i = 0; i < nlines; i++)
fputs(lines[i], stdout);
return EXIT_SUCCESS;
}
-253
View File
@@ -1,253 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini tail implementation for busybox
*
*
* Copyright (C) 2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 <fcntl.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
static struct suffix_mult tail_suffixes[] = {
{ "b", 512 },
{ "k", 1024 },
{ "m", 1048576 },
{ NULL, 0 }
};
#ifndef BB_FEATURE_SIMPLE_TAIL
static struct suffix_mult null_suffixes[] = {
{ NULL, 0 }
};
#endif
static const int BYTES = 0;
static const int LINES = 1;
static char *tailbuf;
static int taillen;
static int newline;
void tailbuf_append(char *buf, int len)
{
tailbuf = xrealloc(tailbuf, taillen + len);
memcpy(tailbuf + taillen, buf, len);
taillen += len;
}
void tailbuf_trunc()
{
char *s;
s = memchr(tailbuf, '\n', taillen);
memmove(tailbuf, s + 1, taillen - ((s + 1) - tailbuf));
taillen -= (s + 1) - tailbuf;
newline = 0;
}
int tail_main(int argc, char **argv)
{
int from_top = 0, units = LINES, count = 10, sleep_period = 1;
int show_headers = 0, hide_headers = 0, follow = 0;
int *fds, nfiles = 0, status = EXIT_SUCCESS, nread, nwrite, seen = 0;
char *s, *start, *end, buf[BUFSIZ];
int i, opt;
while ((opt = getopt(argc, argv, "c:fhn:q:s:v")) > 0) {
switch (opt) {
case 'f':
follow = 1;
break;
#ifndef BB_FEATURE_SIMPLE_TAIL
case 'c':
units = BYTES;
/* FALLS THROUGH */
#endif
case 'n':
count = parse_number(optarg, tail_suffixes);
if (count < 0)
count = -count;
if (optarg[0] == '+')
from_top = 1;
break;
#ifndef BB_FEATURE_SIMPLE_TAIL
case 'q':
hide_headers = 1;
break;
case 's':
sleep_period = parse_number(optarg, null_suffixes);
break;
case 'v':
show_headers = 1;
break;
#endif
default:
usage(tail_usage);
}
}
/* open all the files */
fds = (int *)xmalloc(sizeof(int) * (argc - optind + 1));
if (argc == optind) {
fds[nfiles++] = STDIN_FILENO;
argv[optind] = "standard input";
} else {
for (i = optind; i < argc; i++) {
if (strcmp(argv[i], "-") == 0) {
fds[nfiles++] = STDIN_FILENO;
argv[i] = "standard input";
} else if ((fds[nfiles++] = open(argv[i], O_RDONLY)) < 0) {
perror_msg("%s", argv[i]);
status = EXIT_FAILURE;
}
}
}
#ifndef BB_FEATURE_SIMPLE_TAIL
/* tail the files */
if (!from_top && units == BYTES)
tailbuf = xmalloc(count);
#endif
for (i = 0; i < nfiles; i++) {
if (fds[i] == -1)
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
if (units == BYTES) {
if (count - 1 <= seen)
nwrite = nread;
else if (count - 1 <= seen + nread)
nwrite = nread + seen - (count - 1);
else
nwrite = 0;
seen += nread;
} else {
#else
{
#endif
if (count - 1 <= seen)
nwrite = nread;
else {
nwrite = 0;
for (s = memchr(buf, '\n', nread); s != NULL;
s = memchr(s+1, '\n', nread - (s + 1 - buf))) {
if (count - 1 <= ++seen) {
nwrite = nread - (s + 1 - buf);
break;
}
}
}
}
if (full_write(STDOUT_FILENO, buf + nread - nwrite,
nwrite) < 0) {
perror_msg("write");
status = EXIT_FAILURE;
break;
}
} else {
#ifndef BB_FEATURE_SIMPLE_TAIL
if (units == BYTES) {
if (nread < count) {
memmove(tailbuf, tailbuf + nread, count - nread);
memcpy(tailbuf + count - nread, buf, nread);
} else {
memcpy(tailbuf, buf + nread - count, count);
}
seen += nread;
} else {
#else
{
#endif
for (start = buf, end = memchr(buf, '\n', nread);
end != NULL; start = end+1,
end = memchr(start, '\n', nread - (start - buf))) {
if (newline && count <= seen)
tailbuf_trunc();
tailbuf_append(start, end - start + 1);
seen++;
newline = 1;
}
if (newline && count <= seen && nread - (start - buf) > 0)
tailbuf_trunc();
tailbuf_append(start, nread - (start - buf));
}
}
}
if (nread < 0) {
perror_msg("read");
status = EXIT_FAILURE;
}
#ifndef BB_FEATURE_SIMPLE_TAIL
if (!from_top && units == BYTES) {
if (count < seen)
seen = count;
if (full_write(STDOUT_FILENO, tailbuf + count - seen, seen) < 0) {
perror_msg("write");
status = EXIT_FAILURE;
}
}
#endif
if (!from_top && units == LINES) {
if (full_write(STDOUT_FILENO, tailbuf, taillen) < 0) {
perror_msg("write");
status = EXIT_FAILURE;
}
}
taillen = 0;
}
while (follow) {
sleep(sleep_period);
for (i = 0; i < nfiles; i++) {
if (fds[i] == -1)
continue;
if ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
if (show_headers || (!hide_headers && nfiles > 1))
printf("\n==> %s <==\n", argv[optind + i]);
do {
full_write(STDOUT_FILENO, buf, nread);
} while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0);
}
if (nread < 0) {
perror_msg("read");
status = EXIT_FAILURE;
}
}
}
return status;
}
-582
View File
@@ -1,582 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* test implementation for busybox
*
* Copyright (c) by a whole pile of folks:
*
* test(1); version 7-like -- author Erik Baalbergen
* modified by Eric Gisin to be used as built-in.
* modified by Arnold Robbins to add SVR3 compatibility
* (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket).
* modified by J.T. Conklin for NetBSD.
* modified by Herbert Xu to be used as built-in in ash.
* modified by Erik Andersen <andersee@debian.org> to be used
* in busybox.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice states:
* "This program is in the Public Domain."
*/
#include "busybox.h"
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#define BB_DECLARE_EXTERN
#define bb_need_help
#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
aexpr ::= nexpr | nexpr "-a" aexpr ;
nexpr ::= primary | "!" primary
primary ::= unary-operator operand
| operand binary-operator operand
| operand
| "(" oexpr ")"
;
unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"|
"-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";
binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
"-nt"|"-ot"|"-ef";
operand ::= <any legal UNIX file name>
*/
enum token {
EOI,
FILRD,
FILWR,
FILEX,
FILEXIST,
FILREG,
FILDIR,
FILCDEV,
FILBDEV,
FILFIFO,
FILSOCK,
FILSYM,
FILGZ,
FILTT,
FILSUID,
FILSGID,
FILSTCK,
FILNT,
FILOT,
FILEQ,
FILUID,
FILGID,
STREZ,
STRNZ,
STREQ,
STRNE,
STRLT,
STRGT,
INTEQ,
INTNE,
INTGE,
INTGT,
INTLE,
INTLT,
UNOT,
BAND,
BOR,
LPAREN,
RPAREN,
OPERAND
};
enum token_types {
UNOP,
BINOP,
BUNOP,
BBINOP,
PAREN
};
struct t_op {
const char *op_text;
short op_num, op_type;
} const ops [] = {
{"-r", FILRD, UNOP},
{"-w", FILWR, UNOP},
{"-x", FILEX, UNOP},
{"-e", FILEXIST,UNOP},
{"-f", FILREG, UNOP},
{"-d", FILDIR, UNOP},
{"-c", FILCDEV,UNOP},
{"-b", FILBDEV,UNOP},
{"-p", FILFIFO,UNOP},
{"-u", FILSUID,UNOP},
{"-g", FILSGID,UNOP},
{"-k", FILSTCK,UNOP},
{"-s", FILGZ, UNOP},
{"-t", FILTT, UNOP},
{"-z", STREZ, UNOP},
{"-n", STRNZ, UNOP},
{"-h", FILSYM, UNOP}, /* for backwards compat */
{"-O", FILUID, UNOP},
{"-G", FILGID, UNOP},
{"-L", FILSYM, UNOP},
{"-S", FILSOCK,UNOP},
{"=", STREQ, BINOP},
{"!=", STRNE, BINOP},
{"<", STRLT, BINOP},
{">", STRGT, BINOP},
{"-eq", INTEQ, BINOP},
{"-ne", INTNE, BINOP},
{"-ge", INTGE, BINOP},
{"-gt", INTGT, BINOP},
{"-le", INTLE, BINOP},
{"-lt", INTLT, BINOP},
{"-nt", FILNT, BINOP},
{"-ot", FILOT, BINOP},
{"-ef", FILEQ, BINOP},
{"!", UNOT, BUNOP},
{"-a", BAND, BBINOP},
{"-o", BOR, BBINOP},
{"(", LPAREN, PAREN},
{")", RPAREN, PAREN},
{0, 0, 0}
};
static char **t_wp;
static struct t_op const *t_wp_op;
static gid_t *group_array = NULL;
static int ngroups;
static enum token t_lex();
static int oexpr();
static int aexpr();
static int nexpr();
static int binop();
static int primary();
static int filstat();
static int getn();
static int newerf();
static int olderf();
static int equalf();
static void syntax();
static int test_eaccess();
static int is_a_group_member();
static void initialize_group_array();
extern int
test_main(int argc, char** argv)
{
int res;
if (strcmp(applet_name, "[") == 0) {
if (strcmp(argv[--argc], "]"))
error_msg_and_die("missing ]\n");
argv[argc] = NULL;
}
/* Implement special cases from POSIX.2, section 4.62.4 */
switch (argc) {
case 1:
exit( 1);
case 2:
exit (*argv[1] == '\0');
case 3:
if (argv[1][0] == '!' && argv[1][1] == '\0') {
exit (!(*argv[2] == '\0'));
}
break;
case 4:
if (argv[1][0] != '!' || argv[1][1] != '\0') {
if (t_lex(argv[2]),
t_wp_op && t_wp_op->op_type == BINOP) {
t_wp = &argv[1];
exit (binop() == 0);
}
}
break;
case 5:
if (argv[1][0] == '!' && argv[1][1] == '\0') {
if (t_lex(argv[3]),
t_wp_op && t_wp_op->op_type == BINOP) {
t_wp = &argv[2];
exit (!(binop() == 0));
}
}
break;
}
t_wp = &argv[1];
res = !oexpr(t_lex(*t_wp));
if (*t_wp != NULL && *++t_wp != NULL)
syntax(*t_wp, "unknown operand");
return( res);
}
static void
syntax(op, msg)
char *op;
char *msg;
{
if (op && *op)
error_msg_and_die("%s: %s\n", op, msg);
else
error_msg_and_die("%s\n", msg);
}
static int
oexpr(n)
enum token n;
{
int res;
res = aexpr(n);
if (t_lex(*++t_wp) == BOR)
return oexpr(t_lex(*++t_wp)) || res;
t_wp--;
return res;
}
static int
aexpr(n)
enum token n;
{
int res;
res = nexpr(n);
if (t_lex(*++t_wp) == BAND)
return aexpr(t_lex(*++t_wp)) && res;
t_wp--;
return res;
}
static int
nexpr(n)
enum token n; /* token */
{
if (n == UNOT)
return !nexpr(t_lex(*++t_wp));
return primary(n);
}
static int
primary(n)
enum token n;
{
int res;
if (n == EOI)
syntax(NULL, "argument expected");
if (n == LPAREN) {
res = oexpr(t_lex(*++t_wp));
if (t_lex(*++t_wp) != RPAREN)
syntax(NULL, "closing paren expected");
return res;
}
if (t_wp_op && t_wp_op->op_type == UNOP) {
/* unary expression */
if (*++t_wp == NULL)
syntax(t_wp_op->op_text, "argument expected");
switch (n) {
case STREZ:
return strlen(*t_wp) == 0;
case STRNZ:
return strlen(*t_wp) != 0;
case FILTT:
return isatty(getn(*t_wp));
default:
return filstat(*t_wp, n);
}
}
if (t_lex(t_wp[1]), t_wp_op && t_wp_op->op_type == BINOP) {
return binop();
}
return strlen(*t_wp) > 0;
}
static int
binop()
{
const char *opnd1, *opnd2;
struct t_op const *op;
opnd1 = *t_wp;
(void) t_lex(*++t_wp);
op = t_wp_op;
if ((opnd2 = *++t_wp) == (char *)0)
syntax(op->op_text, "argument expected");
switch (op->op_num) {
case STREQ:
return strcmp(opnd1, opnd2) == 0;
case STRNE:
return strcmp(opnd1, opnd2) != 0;
case STRLT:
return strcmp(opnd1, opnd2) < 0;
case STRGT:
return strcmp(opnd1, opnd2) > 0;
case INTEQ:
return getn(opnd1) == getn(opnd2);
case INTNE:
return getn(opnd1) != getn(opnd2);
case INTGE:
return getn(opnd1) >= getn(opnd2);
case INTGT:
return getn(opnd1) > getn(opnd2);
case INTLE:
return getn(opnd1) <= getn(opnd2);
case INTLT:
return getn(opnd1) < getn(opnd2);
case FILNT:
return newerf (opnd1, opnd2);
case FILOT:
return olderf (opnd1, opnd2);
case FILEQ:
return equalf (opnd1, opnd2);
}
/* NOTREACHED */
return 1;
}
static int
filstat(nm, mode)
char *nm;
enum token mode;
{
struct stat s;
unsigned int i;
if (mode == FILSYM) {
#ifdef S_IFLNK
if (lstat(nm, &s) == 0) {
i = S_IFLNK;
goto filetype;
}
#endif
return 0;
}
if (stat(nm, &s) != 0)
return 0;
switch (mode) {
case FILRD:
return test_eaccess(nm, R_OK) == 0;
case FILWR:
return test_eaccess(nm, W_OK) == 0;
case FILEX:
return test_eaccess(nm, X_OK) == 0;
case FILEXIST:
return 1;
case FILREG:
i = S_IFREG;
goto filetype;
case FILDIR:
i = S_IFDIR;
goto filetype;
case FILCDEV:
i = S_IFCHR;
goto filetype;
case FILBDEV:
i = S_IFBLK;
goto filetype;
case FILFIFO:
#ifdef S_IFIFO
i = S_IFIFO;
goto filetype;
#else
return 0;
#endif
case FILSOCK:
#ifdef S_IFSOCK
i = S_IFSOCK;
goto filetype;
#else
return 0;
#endif
case FILSUID:
i = S_ISUID;
goto filebit;
case FILSGID:
i = S_ISGID;
goto filebit;
case FILSTCK:
i = S_ISVTX;
goto filebit;
case FILGZ:
return s.st_size > 0L;
case FILUID:
return s.st_uid == geteuid();
case FILGID:
return s.st_gid == getegid();
default:
return 1;
}
filetype:
return ((s.st_mode & S_IFMT) == i);
filebit:
return ((s.st_mode & i) != 0);
}
static enum token
t_lex(s)
char *s;
{
struct t_op const *op = ops;
if (s == 0) {
t_wp_op = (struct t_op *)0;
return EOI;
}
while (op->op_text) {
if (strcmp(s, op->op_text) == 0) {
t_wp_op = op;
return op->op_num;
}
op++;
}
t_wp_op = (struct t_op *)0;
return OPERAND;
}
/* atoi with error detection */
static int
getn(s)
char *s;
{
char *p;
long r;
errno = 0;
r = strtol(s, &p, 10);
if (errno != 0)
error_msg_and_die("%s: out of range\n", s);
while (isspace(*p))
p++;
if (*p)
error_msg_and_die("%s: bad number\n", s);
return (int) r;
}
static int
newerf (f1, f2)
char *f1, *f2;
{
struct stat b1, b2;
return (stat (f1, &b1) == 0 &&
stat (f2, &b2) == 0 &&
b1.st_mtime > b2.st_mtime);
}
static int
olderf (f1, f2)
char *f1, *f2;
{
struct stat b1, b2;
return (stat (f1, &b1) == 0 &&
stat (f2, &b2) == 0 &&
b1.st_mtime < b2.st_mtime);
}
static int
equalf (f1, f2)
char *f1, *f2;
{
struct stat b1, b2;
return (stat (f1, &b1) == 0 &&
stat (f2, &b2) == 0 &&
b1.st_dev == b2.st_dev &&
b1.st_ino == b2.st_ino);
}
/* Do the same thing access(2) does, but use the effective uid and gid,
and don't make the mistake of telling root that any file is
executable. */
static int
test_eaccess (path, mode)
char *path;
int mode;
{
struct stat st;
unsigned int euid = geteuid();
if (stat (path, &st) < 0)
return (-1);
if (euid == 0) {
/* Root can read or write any file. */
if (mode != X_OK)
return (0);
/* Root can execute any file that has any one of the execute
bits set. */
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return (0);
}
if (st.st_uid == euid) /* owner */
mode <<= 6;
else if (is_a_group_member (st.st_gid))
mode <<= 3;
if (st.st_mode & mode)
return (0);
return (-1);
}
static void
initialize_group_array ()
{
ngroups = getgroups(0, NULL);
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
getgroups(ngroups, group_array);
}
/* Return non-zero if GID is one that we have in our groups list. */
static int
is_a_group_member (gid)
gid_t gid;
{
register int i;
/* Short-circuit if possible, maybe saving a call to getgroups(). */
if (gid == getgid() || gid == getegid())
return (1);
if (ngroups == 0)
initialize_group_array ();
/* Search through the list looking for GID. */
for (i = 0; i < ngroups; i++)
if (gid == group_array[i])
return (1);
return (0);
}
-75
View File
@@ -1,75 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini touch 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 "busybox.h"
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <utime.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
extern int touch_main(int argc, char **argv)
{
int fd;
int create = TRUE;
/* Parse options */
while (--argc > 0 && **(++argv) == '-') {
while (*(++(*argv))) {
switch (**argv) {
case 'c':
create = FALSE;
break;
default:
usage(touch_usage);
}
}
}
if (argc < 1) {
usage(touch_usage);
}
while (argc > 0) {
fd = open(*argv, (create == FALSE) ? O_RDWR : O_RDWR | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0) {
if (create == FALSE && errno == ENOENT)
return EXIT_SUCCESS;
else {
perror_msg_and_die("%s", *argv);
}
}
close(fd);
if (utime(*argv, NULL)) {
perror_msg_and_die("%s", *argv);
}
argc--;
argv++;
}
return EXIT_SUCCESS;
}
-237
View File
@@ -1,237 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini tr implementation for busybox
*
* Copyright (c) Michiel Huisjes
*
* This version of tr is adapted from Minix tr and was modified
* by Erik Andersen <andersee@debian.org> to be used in busybox.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice is retained at the end of this file.
*/
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#define BB_DECLARE_EXTERN
#define bb_need_write_error
#include "messages.c"
static const int ASCII = 0377;
/* some glabals 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 */
static unsigned char *poutput, *pinput;
static unsigned char *pvector;
static char *pinvec, *poutvec;
static void convert()
{
short read_chars = 0;
short c, coded;
short last = -1;
for (;;) {
if (in_index == read_chars) {
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
if (write(1, (char *) poutput, out_index) != out_index)
write(2, write_error, strlen(write_error));
exit(0);
}
in_index = 0;
}
c = pinput[in_index++];
coded = pvector[c];
if (del_fl && pinvec[c])
continue;
if (sq_fl && last == coded && (pinvec[c] || poutvec[coded]))
continue;
poutput[out_index++] = last = coded;
if (out_index == BUFSIZ) {
if (write(1, (char *) poutput, out_index) != out_index) {
write(2, write_error, strlen(write_error));
exit(1);
}
out_index = 0;
}
}
/* NOTREACHED */
}
static void map(register unsigned char *string1, unsigned int string1_len,
register unsigned char *string2, unsigned int string2_len)
{
unsigned char last = '0';
unsigned int i, j;
for (j = 0, i = 0; i < string1_len; i++) {
if (string2_len <= j)
pvector[string1[i]] = last;
else
pvector[string1[i]] = last = string2[j++];
}
}
static unsigned int expand(char *arg, register unsigned char *buffer)
{
unsigned char *buffer_start = buffer;
int i, ac;
while (*arg) {
if (*arg == '\\') {
arg++;
*buffer++ = process_escape_sequence(&arg);
} else if (*arg == '[') {
arg++;
i = *arg++;
if (*arg++ != '-') {
*buffer++ = '[';
arg -= 2;
continue;
}
ac = *arg++;
while (i <= ac)
*buffer++ = i++;
arg++; /* Skip ']' */
} else
*buffer++ = *arg++;
}
return (buffer - buffer_start);
}
static int complement(unsigned char *buffer, int buffer_len)
{
register short i, j, index;
char conv[ASCII + 2];
index = 0;
for (i = 0; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++)
if (buffer[j] == i)
break;
if (j == buffer_len)
conv[index++] = i & ASCII;
}
memcpy(buffer, conv, index);
return index;
}
extern int tr_main(int argc, char **argv)
{
register unsigned char *ptr;
int output_length=0, input_length;
int index = 1;
int i;
RESERVE_BB_BUFFER(output, BUFSIZ);
RESERVE_BB_BUFFER(input, BUFSIZ);
RESERVE_BB_UBUFFER(vector, ASCII+1);
RESERVE_BB_BUFFER(invec, ASCII+1);
RESERVE_BB_BUFFER(outvec, ASCII+1);
/* ... but make them available globally */
poutput = output;
pinput = input;
pvector = vector;
pinvec = invec;
poutvec = outvec;
if (argc > 1 && argv[index][0] == '-') {
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
switch (*ptr) {
case 'c':
com_fl = TRUE;
break;
case 'd':
del_fl = TRUE;
break;
case 's':
sq_fl = TRUE;
break;
default:
usage(tr_usage);
}
}
index++;
}
for (i = 0; i <= ASCII; i++) {
vector[i] = i;
invec[i] = outvec[i] = FALSE;
}
if (argv[index] != NULL) {
input_length = expand(argv[index++], input);
if (com_fl)
input_length = complement(input, input_length);
if (argv[index] != NULL) {
if (*argv[index] == '\0')
error_msg_and_die("STRING2 cannot be empty\n");
output_length = expand(argv[index], output);
map(input, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)
invec[(int)input[i]] = TRUE;
for (i = 0; i < output_length; i++)
outvec[(int)output[i]] = TRUE;
}
convert();
return (0);
}
/*
* Copyright (c) 1987,1997, Prentice Hall
* All rights reserved.
*
* Redistribution and use of the MINIX operating system in source and
* binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of Prentice Hall nor the names of the software
* authors or contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-155
View File
@@ -1,155 +0,0 @@
/* vi: set sw=4 ts=4: */
/* uname -- print system information
Copyright (C) 1989-1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Option Example
-s, --sysname SunOS
-n, --nodename rocky8
-r, --release 4.0
-v, --version
-m, --machine sun
-a, --all SunOS rocky8 4.0 sun
The default behavior is equivalent to `-s'.
David MacKenzie <djm@gnu.ai.mit.edu> */
/* Busyboxed by Erik Andersen */
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/utsname.h>
#if defined (HAVE_SYSINFO) && defined (HAVE_SYS_SYSTEMINFO_H)
# include <sys/systeminfo.h>
#endif
static void print_element(unsigned int mask, char *element);
/* Values that are bitwise or'd into `toprint'. */
/* Operating system name. */
static const int PRINT_SYSNAME = 1;
/* Node name on a communications network. */
static const int PRINT_NODENAME = 2;
/* Operating system release. */
static const int PRINT_RELEASE = 4;
/* Operating system version. */
static const int PRINT_VERSION = 8;
/* Machine hardware name. */
static const int PRINT_MACHINE = 16;
/* Host processor type. */
static const int PRINT_PROCESSOR = 32;
/* Mask indicating which elements of the name to print. */
static unsigned char toprint;
int uname_main(int argc, char **argv)
{
struct utsname name;
char processor[256];
#if defined(__sparc__) && defined(__linux__)
char *fake_sparc = getenv("FAKE_SPARC");
#endif
toprint = 0;
/* Parse any options */
//fprintf(stderr, "argc=%d, argv=%s\n", argc, *argv);
while (--argc > 0 && **(++argv) == '-') {
while (*(++(*argv))) {
switch (**argv) {
case 's':
toprint |= PRINT_SYSNAME;
break;
case 'n':
toprint |= PRINT_NODENAME;
break;
case 'r':
toprint |= PRINT_RELEASE;
break;
case 'v':
toprint |= PRINT_VERSION;
break;
case 'm':
toprint |= PRINT_MACHINE;
break;
case 'p':
toprint |= PRINT_PROCESSOR;
break;
case 'a':
toprint = (PRINT_SYSNAME | PRINT_NODENAME | PRINT_RELEASE |
PRINT_PROCESSOR | PRINT_VERSION |
PRINT_MACHINE);
break;
default:
usage(uname_usage);
}
}
}
if (toprint == 0)
toprint = PRINT_SYSNAME;
if (uname(&name) == -1)
perror_msg("cannot get system name");
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
perror_msg("cannot get processor type");
}
#else
strcpy(processor, "unknown");
#endif
#if defined(__sparc__) && defined(__linux__)
if (fake_sparc != NULL
&& (fake_sparc[0] == 'y'
|| fake_sparc[0] == 'Y')) strcpy(name.machine, "sparc");
#endif
print_element(PRINT_SYSNAME, name.sysname);
print_element(PRINT_NODENAME, name.nodename);
print_element(PRINT_RELEASE, name.release);
print_element(PRINT_VERSION, name.version);
print_element(PRINT_MACHINE, name.machine);
print_element(PRINT_PROCESSOR, processor);
return EXIT_SUCCESS;
}
/* If the name element set in MASK is selected for printing in `toprint',
print ELEMENT; then print a space unless it is the last element to
be printed, in which case print a newline. */
static void print_element(unsigned int mask, char *element)
{
if (toprint & mask) {
toprint &= ~mask;
printf("%s%c", element, toprint ? ' ' : '\n');
}
}
-89
View File
@@ -1,89 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini uniq implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Rewritten 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 "busybox.h"
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <stdlib.h>
static int print_count;
static int print_uniq = 1;
static int print_duplicates = 1;
static void print_line(char *line, int count, FILE *fp)
{
if ((print_duplicates && count > 1) || (print_uniq && count == 1)) {
if (print_count)
fprintf(fp, "%7d\t%s", count, line);
else
fputs(line, fp);
}
}
int uniq_main(int argc, char **argv)
{
FILE *in = stdin, *out = stdout;
char *lastline = NULL, *input;
int opt, count = 0;
/* parse argv[] */
while ((opt = getopt(argc, argv, "cdu")) > 0) {
switch (opt) {
case 'c':
print_count = 1;
break;
case 'd':
print_duplicates = 1;
print_uniq = 0;
break;
case 'u':
print_duplicates = 0;
print_uniq = 1;
break;
}
}
if (argv[optind] != NULL) {
in = xfopen(argv[optind], "r");
if (argv[optind+1] != NULL)
out = xfopen(argv[optind+1], "w");
}
while ((input = get_line_from_file(in)) != NULL) {
if (lastline == NULL || strcmp(input, lastline) != 0) {
print_line(lastline, count, out);
free(lastline);
lastline = input;
count = 0;
}
count++;
}
print_line(lastline, count, out);
free(lastline);
return EXIT_SUCCESS;
}
-350
View File
@@ -1,350 +0,0 @@
/* uudecode.c -- uudecode utility.
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
*
* This product is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This product is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this product; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93.
*
* Original copyright notice is retained at the end of this file.
*/
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
/*struct passwd *getpwnam();*/
/* Single character decode. */
#define DEC(Char) (((Char) - ' ') & 077)
static int read_stduu (const char *inname)
{
char buf[2 * BUFSIZ];
while (1) {
int n;
char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
error_msg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
/* N is used to avoid writing out all the characters at the end of
the file. */
n = DEC (*p);
if (n <= 0)
break;
for (++p; n > 0; p += 4, n -= 3) {
char ch;
if (n >= 3) {
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
putchar (ch);
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
putchar (ch);
ch = DEC (p[2]) << 6 | DEC (p[3]);
putchar (ch);
} else {
if (n >= 1) {
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
putchar (ch);
}
if (n >= 2) {
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
putchar (ch);
}
}
}
}
if (fgets (buf, sizeof(buf), stdin) == NULL
|| strcmp (buf, "end\n")) {
error_msg("%s: No `end' line\n", inname);
return FALSE;
}
return TRUE;
}
static int read_base64 (const char *inname)
{
static const char b64_tab[256] = {
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*000-007*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*010-017*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*020-027*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*030-037*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*040-047*/
'\177', '\177', '\177', '\76', '\177', '\177', '\177', '\77', /*050-057*/
'\64', '\65', '\66', '\67', '\70', '\71', '\72', '\73', /*060-067*/
'\74', '\75', '\177', '\177', '\177', '\100', '\177', '\177', /*070-077*/
'\177', '\0', '\1', '\2', '\3', '\4', '\5', '\6', /*100-107*/
'\7', '\10', '\11', '\12', '\13', '\14', '\15', '\16', /*110-117*/
'\17', '\20', '\21', '\22', '\23', '\24', '\25', '\26', /*120-127*/
'\27', '\30', '\31', '\177', '\177', '\177', '\177', '\177', /*130-137*/
'\177', '\32', '\33', '\34', '\35', '\36', '\37', '\40', /*140-147*/
'\41', '\42', '\43', '\44', '\45', '\46', '\47', '\50', /*150-157*/
'\51', '\52', '\53', '\54', '\55', '\56', '\57', '\60', /*160-167*/
'\61', '\62', '\63', '\177', '\177', '\177', '\177', '\177', /*170-177*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*200-207*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*210-217*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*220-227*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*230-237*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*240-247*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*250-257*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*260-267*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*270-277*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*300-307*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*310-317*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*320-327*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*330-337*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*340-347*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*350-357*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*360-367*/
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*370-377*/
};
unsigned char buf[2 * BUFSIZ];
while (1) {
int last_data = 0;
unsigned char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
error_msg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
if (memcmp (buf, "====", 4) == 0)
break;
if (last_data != 0) {
error_msg("%s: data following `=' padding character\n", inname);
return FALSE;
}
/* The following implementation of the base64 decoding might look
a bit clumsy but I only try to follow the POSIX standard:
``All line breaks or other characters not found in the table
[with base64 characters] shall be ignored by decoding
software.'' */
while (*p != '\n') {
char c1, c2, c3;
while ((b64_tab[*p] & '\100') != 0)
if (*p == '\n' || *p++ == '=')
break;
if (*p == '\n')
/* This leaves the loop. */
continue;
c1 = b64_tab[*p++];
while ((b64_tab[*p] & '\100') != 0)
if (*p == '\n' || *p++ == '=') {
error_msg("%s: illegal line\n", inname);
return FALSE;
}
c2 = b64_tab[*p++];
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
error_msg("%s: illegal line\n", inname);
return FALSE;
}
if (*p == '=') {
putchar (c1 << 2 | c2 >> 4);
last_data = 1;
break;
}
c3 = b64_tab[*p++];
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
error_msg("%s: illegal line\n", inname);
return FALSE;
}
putchar (c1 << 2 | c2 >> 4);
putchar (c2 << 4 | c3 >> 2);
if (*p == '=') {
last_data = 1;
break;
}
else
putchar (c3 << 6 | b64_tab[*p++]);
}
}
return TRUE;
}
static int decode (const char *inname,
const char *forced_outname)
{
struct passwd *pw;
register int n;
register char *p;
int mode, n1;
char buf[2 * BUFSIZ];
char *outname;
int do_base64 = 0;
/* Search for header line. */
while (1) {
if (fgets (buf, sizeof (buf), stdin) == NULL) {
error_msg("%s: No `begin' line\n", inname);
return FALSE;
}
if (strncmp (buf, "begin", 5) == 0) {
if (sscanf (buf, "begin-base64 %o %s", &mode, buf) == 2) {
do_base64 = 1;
break;
} else if (sscanf (buf, "begin %o %s", &mode, buf) == 2)
break;
}
}
/* If the output file name is given on the command line this rules. */
if (forced_outname != NULL)
outname = (char *) forced_outname;
else {
/* Handle ~user/file format. */
if (buf[0] != '~')
outname = buf;
else {
p = buf + 1;
while (*p != '/')
++p;
if (*p == '\0') {
error_msg("%s: Illegal ~user\n", inname);
return FALSE;
}
*p++ = '\0';
pw = getpwnam (buf + 1);
if (pw == NULL) {
error_msg("%s: No user `%s'\n", inname, buf + 1);
return FALSE;
}
n = strlen (pw->pw_dir);
n1 = strlen (p);
outname = (char *) alloca ((size_t) (n + n1 + 2));
memcpy (outname + n + 1, p, (size_t) (n1 + 1));
memcpy (outname, pw->pw_dir, (size_t) n);
outname[n] = '/';
}
}
/* Create output file and set mode. */
if (strcmp (outname, "/dev/stdout") != 0 && strcmp (outname, "-") != 0
&& (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
perror_msg("%s", outname); /* */
return FALSE;
}
/* We differenciate decoding standard UU encoding and base64. A
common function would only slow down the program. */
/* For each input line: */
if (do_base64)
return read_base64 (inname);
else
return read_stduu (inname);
}
int uudecode_main (int argc,
char **argv)
{
int opt;
int exit_status;
const char *outname;
outname = NULL;
while ((opt = getopt(argc, argv, "o:")) != EOF) {
switch (opt) {
case 0:
break;
case 'o':
outname = optarg;
break;
default:
usage(uudecode_usage);
}
}
if (optind == argc)
exit_status = decode ("stdin", outname) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
else {
exit_status = EXIT_SUCCESS;
do {
if (freopen (argv[optind], "r", stdin) != NULL) {
if (decode (argv[optind], outname) != 0)
exit_status = FALSE;
} else {
perror_msg("%s", argv[optind]);
exit_status = EXIT_FAILURE;
}
optind++;
}
while (optind < argc);
}
return(exit_status);
}
/* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-237
View File
@@ -1,237 +0,0 @@
/* uuencode.c -- uuencode utility.
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
*
* This product is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This product is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this product; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Original copyright notice is retained at the end of this file.
*/
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
/* Hacked to work with BusyBox by Alfred M. Szmidt */
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <stdlib.h>
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
static void encode __P ((void));
/* Pointer to the translation table we currently use. */
const char *trans_ptr;
/* The two currently defined translation tables. The first is the
standard uuencoding, the second is base64 encoding. */
const char uu_std[64] = {
'`', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
};
const char uu_base64[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
/* ENC is the basic 1 character encoding function to make a char printing. */
#define ENC(Char) (trans_ptr[(Char) & 077])
/* Copy from IN to OUT, encoding as you go along. */
static void encode()
{
register int ch, n;
char *p = NULL;
char buf[80];
while (1) {
n = 0;
do {
register int m = fread (buf, 1, 45 - n, stdin);
if (m == 0)
break;
n += m;
}
while (n < 45);
if (n == 0)
break;
if (trans_ptr == uu_std)
if (putchar (ENC (n)) == EOF)
break;
for (p = buf; n > 2; n -= 3, p += 3) {
ch = *p >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = p[2] & 077;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
}
if (n != 0)
break;
if (putchar ('\n') == EOF)
break;
}
while (n != 0) {
char c1 = *p;
char c2 = n == 1 ? 0 : p[1];
ch = c1 >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((c1 << 4) & 060) | ((c2 >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
if (n == 1)
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
else {
ch = (c2 << 2) & 074;
ch = ENC (ch);
}
if (putchar (ch) == EOF)
break;
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
if (putchar (ch) == EOF)
break;
putchar ('\n');
break;
}
if (ferror (stdin))
error_msg("Read error\n");
if (trans_ptr == uu_std) {
putchar (ENC ('\0'));
putchar ('\n');
}
}
int uuencode_main (int argc,
char **argv)
{
int opt;
struct stat sb;
int mode;
trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */
while ((opt = getopt (argc, argv, "m")) > 0) {
switch (opt) {
case 'm':
trans_ptr = uu_base64;
break;
default:
usage(uuencode_usage);
}
}
switch (argc - optind) {
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
perror_msg("%s", argv[optind]);
return EXIT_FAILURE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
optind++;
break;
case 1:
mode = RW & ~umask (RW);
break;
case 0:
default:
usage(uuencode_usage);
}
printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64",
mode, argv[optind]);
encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) {
error_msg("Write error\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-155
View File
@@ -1,155 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini wc implementation for busybox
*
* Copyright (C) 2000 Edward Betts <edward@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
void print_counts(int lines, int words, int chars, int length,
const char *name)
{
char const *space = "";
if (print_lines) {
printf("%7d", lines);
space = " ";
}
if (print_words) {
printf("%s%7d", space, words);
space = " ";
}
if (print_chars) {
printf("%s%7d", space, chars);
space = " ";
}
if (print_length)
printf("%s%7d", space, length);
if (*name)
printf(" %s", name);
putchar('\n');
}
static void wc_file(FILE * file, const char *name)
{
int lines, words, chars, length;
int in_word = 0, linepos = 0;
int c;
lines = words = chars = length = 0;
while ((c = getc(file)) != EOF) {
chars++;
switch (c) {
case '\n':
lines++;
case '\r':
case '\f':
if (linepos > length)
length = linepos;
linepos = 0;
goto word_separator;
case '\t':
linepos += 8 - (linepos % 8);
goto word_separator;
case ' ':
linepos++;
case '\v':
word_separator:
if (in_word) {
in_word = 0;
words++;
}
break;
default:
linepos++;
in_word = 1;
break;
}
}
if (linepos > length)
length = linepos;
if (in_word)
words++;
print_counts(lines, words, chars, length, name);
total_lines += lines;
total_words += words;
total_chars += chars;
if (length > max_length)
max_length = length;
fclose(file);
fflush(stdout);
}
int wc_main(int argc, char **argv)
{
FILE *file;
unsigned int num_files_counted = 0;
int opt, status = EXIT_SUCCESS;
total_lines = total_words = total_chars = max_length = 0;
print_lines = print_words = print_chars = print_length = 0;
while ((opt = getopt(argc, argv, "clLw")) > 0) {
switch (opt) {
case 'c':
print_chars = 1;
break;
case 'l':
print_lines = 1;
break;
case 'L':
print_length = 1;
break;
case 'w':
print_words = 1;
break;
default:
usage(wc_usage);
}
}
if (!print_lines && !print_words && !print_chars && !print_length)
print_lines = print_words = print_chars = 1;
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
wc_file(stdin, "");
return EXIT_SUCCESS;
} else {
while (optind < argc) {
if ((file = wfopen(argv[optind], "r")) != NULL)
wc_file(file, argv[optind]);
else
status = EXIT_FAILURE;
num_files_counted++;
optind++;
}
}
if (num_files_counted > 1)
print_counts(total_lines, total_words, total_chars,
max_length, "total");
return status;
}
+117
View File
@@ -0,0 +1,117 @@
/* 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, "adfipRr")) != -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 | 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;
}
-332
View File
@@ -1,332 +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 "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"
#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>
static const int is_cp = 0;
static const int is_mv = 1;
static int dz_i; /* index into cp_mv_usage */
static const char *cp_mv_usage[] = /* .rodata */
{
cp_usage,
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)
usage(cp_mv_usage[dz_i]);
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:
usage(cp_mv_usage[is_cp]);
}
}
if ((argc - optind) < 2) {
usage(cp_mv_usage[dz_i]);
}
} 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 = getcwd(NULL, BUFSIZ + 1)) == NULL) {
perror_msg("getcwd()");
continue;
}
if (chdir(baseDestName) < 0) {
perror_msg("chdir(%s)", baseSrcName);
continue;
}
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
perror_msg("getcwd()");
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'\n", 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:
*/
+95
View File
@@ -0,0 +1,95 @@
/* 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;
}
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names);
if (oldmask) {
umask(oldmask); /* Restore umask if we changed it */
}
return EXIT_SUCCESS;
}
+243 -133
View File
@@ -1,8 +1,8 @@
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Mark Whitley
* Copyright (C) 1999,2000,2001 by Mark Whitley <markw@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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\n");
/* 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--;
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
error_msg_and_die("invalid byte or field list\n");
/* 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\n");
}
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;
@@ -188,14 +299,14 @@ extern int cut_main(int argc, char **argv)
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
error_msg_and_die("only one type of list may be specified\n");
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) {
error_msg_and_die("the delimiter must be a single character\n");
error_msg_and_die("the delimiter must be a single character");
}
delim = optarg[0];
break;
@@ -209,17 +320,18 @@ extern int cut_main(int argc, char **argv)
}
if (part == 0) {
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
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\n");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields\n");
/* non-field (char or byte) cutting has some special handling */
if (part != 'f') {
if (supress_non_delimited_lines) {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
}
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
@@ -232,10 +344,8 @@ extern int cut_main(int argc, char **argv)
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
perror_msg("%s", argv[i]);
} else {
file = wfopen(argv[i], "r");
if(file) {
cut_file(file);
fclose(file);
}
+11 -15
View File
@@ -20,11 +20,6 @@
*
*/
#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_invalid_date
#define bb_need_memory_exhausted
#include "messages.c"
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
@@ -33,6 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
/* This 'date' command supports only 2 time setting formats,
@@ -46,7 +42,7 @@
/* Default input handling to save suprising some people */
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
{
int nr;
@@ -73,7 +69,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
/* The new stuff for LRP */
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
{
struct tm t;
@@ -151,7 +147,7 @@ int date_main(int argc, char **argv)
case 's':
set_time = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
usage(date_usage);
show_usage();
}
break;
case 'u':
@@ -162,10 +158,10 @@ int date_main(int argc, char **argv)
case 'd':
use_arg = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
usage(date_usage);
show_usage();
break;
default:
usage(date_usage);
show_usage();
}
}
@@ -178,7 +174,7 @@ int date_main(int argc, char **argv)
#if 0
else {
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
usage(date_usage);
show_usage();
}
#endif
@@ -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);
@@ -226,8 +222,8 @@ int date_main(int argc, char **argv)
if (date_fmt == NULL) {
date_fmt = (rfc822
? (utc
? "%a, %_d %b %Y %H:%M:%S GMT"
: "%a, %_d %b %Y %H:%M:%S %z")
? "%a, %e %b %Y %H:%M:%S GMT"
: "%a, %e %b %Y %H:%M:%S %z")
: "%a %b %e %H:%M:%S %Z %Y");
} else if (*date_fmt == '\0') {
@@ -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;
}
+6 -5
View File
@@ -1,10 +1,11 @@
/* vi: set sw=4 ts=4: */
#include "busybox.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include "busybox.h"
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
@@ -14,14 +15,14 @@ static unsigned int pointer;
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack)))
error_msg_and_die("stack overflow\n");
error_msg_and_die("stack overflow");
stack[pointer++] = a;
}
static double pop()
{
if (pointer == 0)
error_msg_and_die("stack underflow\n");
error_msg_and_die("stack underflow");
return stack[--pointer];
}
@@ -120,7 +121,7 @@ static void stack_machine(const char *argument)
}
o++;
}
error_msg_and_die("%s: syntax error.\n", argument);
error_msg_and_die("%s: syntax error.", argument);
}
/* return pointer to next token in buffer and set *buffer to one char
@@ -169,7 +170,7 @@ int dc_main(int argc, char **argv)
}
} else {
if (*argv[1]=='-')
usage(dc_usage);
show_usage();
while (argc >= 2) {
stack_machine(argv[1]);
argv++;
+31 -18
View File
@@ -21,16 +21,16 @@
*
*/
#include "busybox.h"
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include "busybox.h"
static struct suffix_mult dd_suffixes[] = {
static const struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
{ "w", 2 },
{ "b", 512 },
@@ -45,12 +45,11 @@ static struct suffix_mult dd_suffixes[] = {
int dd_main(int argc, char **argv)
{
int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE, noerror = FALSE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
off_t seek = 0, skip = 0;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
for (i = 1; i < argc; i++) {
@@ -73,10 +72,13 @@ int dd_main(int argc, char **argv)
trunc = FALSE;
buf += 7;
} else if (strncmp("sync", buf, 4) == 0) {
sync = TRUE;
sync_flag = TRUE;
buf += 4;
} else if (strncmp("noerror", buf, 7) == 0) {
noerror = TRUE;
buf += 7;
} else {
error_msg_and_die("invalid conversion `%s'\n", argv[i]+5);
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
}
if (buf[0] == '\0')
break;
@@ -84,7 +86,7 @@ int dd_main(int argc, char **argv)
buf++;
}
} else
usage(dd_usage);
show_usage();
}
buf = xmalloc(bs);
@@ -107,15 +109,16 @@ int dd_main(int argc, char **argv)
perror_msg_and_die("%s", outfile);
if (seek && trunc) {
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
if (ftruncate(ofd, seek * bs) < 0) {
struct stat st;
if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
S_ISDIR (st.st_mode))
perror_msg_and_die("%s", outfile);
}
}
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
if (skip) {
@@ -129,16 +132,26 @@ int dd_main(int argc, char **argv)
}
while (in_full + in_part != count) {
if (noerror) {
/* Pre-zero the buffer when doing the noerror thing */
memset(buf, '\0', bs);
}
n = safe_read(ifd, buf, bs);
if (n < 0)
perror_msg_and_die("%s", infile);
if (n < 0) {
if (noerror) {
n = bs;
perror_msg("%s", infile);
} else {
perror_msg_and_die("%s", infile);
}
}
if (n == 0)
break;
if (n == bs)
in_full++;
else
in_part++;
if (sync) {
if (sync_flag) {
memset(buf + n, '\0', bs - n);
n = bs;
}
@@ -151,8 +164,8 @@ int dd_main(int argc, char **argv)
out_part++;
}
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
return EXIT_SUCCESS;
}
+5 -5
View File
@@ -3,12 +3,12 @@
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
* Renamed deallocvt.
*/
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
@@ -19,9 +19,9 @@ int deallocvt_main(int argc, char *argv[])
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
if (argc > 2)
usage(deallocvt_usage);
show_usage();
fd = get_console_fd("/dev/console");
fd = get_console_fd();
if (argc == 1) {
/* deallocate all unused consoles */
@@ -31,9 +31,9 @@ int deallocvt_main(int argc, char *argv[])
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
error_msg("0: illegal VT number\n");
error_msg("0: illegal VT number");
else if (num == 1)
error_msg("VT 1 cannot be deallocated\n");
error_msg("VT 1 cannot be deallocated");
else if (ioctl(fd, VT_DISALLOCATE, num))
perror_msg_and_die("VT_DISALLOCATE");
}
+281 -159
View File
@@ -2,122 +2,146 @@
// 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_ASH
//#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_CHVT
#define BB_CLEAR
#define BB_CMP
#define BB_CP_MV
//#define BB_CMP
#define BB_CP
//#define BB_CPIO
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
#define BB_DEALLOCVT
//#define BB_DATE
//#define BB_DC
//#define BB_DD
//#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
#define BB_DOS2UNIX
#define BB_DPKG_DEB
#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
//#define BB_DOS2UNIX
//#define BB_DPKG
//#define BB_DPKG_DEB
//#define BB_DUTMP
//#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
//#define BB_ENV
#define BB_EXPR
#define BB_FBSET
#define BB_FDFLUSH
//#define BB_FBSET
//#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
#define BB_FREERAMDISK
#define BB_FSCK_MINIX
#define BB_GETOPT
//#define BB_FREERAMDISK
//#define BB_FSCK_MINIX
//#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
//#define BB_HOSTID
#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_LENGTH
#define BB_KLOGD
//#define BB_LASH
//#define BB_LENGTH
#define BB_LN
#define BB_LOADACM
#define BB_LOADFONT
//#define BB_LOADACM
//#define BB_LOADFONT
#define BB_LOADKMAP
#define BB_LOGGER
#define BB_LOGNAME
//#define BB_LOGNAME
#define BB_LOSETUP
#define BB_LS
#define BB_LSMOD
#define BB_MAKEDEVS
//#define BB_LSMOD
//#define BB_MAKEDEVS
#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
//#define BB_MKFIFO
//#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
#define BB_NC
//#define BB_MKTEMP
//#define BB_MODPROBE
#define BB_MORE
#define BB_MOUNT
#define BB_MT
#define BB_NSLOOKUP
//#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
//#define BB_PIDOF
#define BB_PING
//#define BB_PIVOT_ROOT
#define BB_POWEROFF
#define BB_PRINTF
//#define BB_PRINTF
#define BB_PS
#define BB_PWD
#define BB_RDATE
#define BB_READLINK
//#define BB_RDATE
//#define BB_READLINK
#define BB_REBOOT
#define BB_RENICE
//#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
#define BB_RMMOD
#define BB_RPMUNPACK
//#define BB_RMMOD
#define BB_ROUTE
//#define BB_RPM2CPIO
#define BB_SED
#define BB_SETKEYCODES
#define BB_SH
//#define BB_SETKEYCODES
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
#define BB_TAIL
#define BB_TAR
#define BB_TEE
//#define BB_TEE
#define BB_TEST
#define BB_TELNET
//#define BB_TELNET
//#define BB_TFTP
//#define BB_TIME
//#define BB_TOP
#define BB_TOUCH
#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
//#define BB_UPDATE
#define BB_UPTIME
#define BB_USLEEP
//#define BB_USLEEP
//#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
#define BB_UNIX2DOS
#define BB_UPDATE
#define BB_XARGS
#define BB_YES
//#define BB_XARGS
//#define BB_YES
// End of Applications List
//
//
@@ -128,36 +152,45 @@
// pretty/useful).
//
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
//#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. 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:
// lots and lots memory for more important things. NOTE: If you enable this
// feature, you _must_ have patched the kernel to include the devps patch that
// is included in the busybox/kernel-patches directory. You will also need to
// create some device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// 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
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
//#define BB_FEATURE_TRIVIAL_HELP
// 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)
// calculate terminal & column widths (for more, ls, and telnet)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
@@ -175,8 +208,11 @@
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
// Use color to identify different file types
#define BB_FEATURE_LS_COLOR
//
// 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
@@ -187,58 +223,68 @@
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
//#define BB_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//#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 syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//#define BB_FEATURE_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
//
// If you are using uClibc, be sure that you've already compiled
// uClibc with INCLUDE_RPC=true (contained in the Config file)
#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
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" and "-X" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//#define BB_FEATURE_TAR_EXCLUDE
//
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
// Enable reverse sort
//#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
// Enable uniqe sort
//#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if a shell is enabled. On by default.
//#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
//#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things.
#define BB_FEATURE_SH_STANDALONE_SHELL
//among other things. Off by default.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
//names. This causes applets (i.e., most busybox commands) to override
@@ -246,11 +292,21 @@
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
// 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 a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//
// Uncomment this option to disable job control. Job control lets you
// run jobs in the background (which completely useless for is all you
// are doing is running scripts). Disabing this is bad for interactive
// use, since when you hit ^C in an application, it will also kill the
// shell. This adds about 2.5k on an x86 system.
//#define BB_FEATURE_ASH_JOB_CONTROL
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -258,24 +314,39 @@
//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 insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// You must enable one or both of these features
// Support modules status from pre 2.1 kernels
//#define BB_FEATURE_LSMOD_OLD_KERNEL
// Support modules status from kernel versions after 2.1.18
#define BB_FEATURE_LSMOD_NEW_KERNEL
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 7k.
#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
#define BB_FEATURE_IFCONFIG_HW
//
// Allows "broadcast +" to set broadcast automatically based on hostaddr
// and netmask, at a cost of about 100 bytes of code (i386).
//#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
@@ -283,13 +354,61 @@
#define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_STATUSBAR
#define BB_FEATURE_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
//
// Support for the find -mtime option.
#define BB_FEATURE_FIND_MTIME
//
//// Support for the find -newer option.
#define BB_FEATURE_FIND_NEWER
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
//
// features for vi
//#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
//#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
//#define BB_FEATURE_VI_SEARCH // search and replace cmds
//#define BB_FEATURE_VI_USE_SIGNALS // catch signals
//#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
//#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
//#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
//#define BB_FEATURE_VI_SET // :set
//#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
// Support for devfs.
//#define BB_FEATURE_DEVFS
//
// End of Features List
//
//
@@ -301,71 +420,74 @@
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#include <features.h>
#if defined(__uClinux__)
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#if (defined BB_ASH || defined BB_HUSH || defined BB_MSH) && ! defined BB_TEST
#define BB_TEST
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#endif
#define BB_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#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
#undef BB_FEATURE_LINUXRC
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#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_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
+493
View File
@@ -0,0 +1,493 @@
/* vi: set sw=4 ts=4: */
// This file defines the feature set to be compiled into busybox.
// When you turn things off here, they won't be compiled in at all.
//
//// This file is parsed by sed. You MUST use single line comments.
// i.e., //#define BB_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
#define BB_AR
#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
#define BB_CMP
#define BB_CP
#define BB_CPIO
#define BB_CUT
#define BB_DATE
#define BB_DC
#define BB_DD
#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
#define BB_DOS2UNIX
#define BB_DPKG
#define BB_DPKG_DEB
#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
#define BB_EXPR
#define BB_FBSET
#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
#define BB_FREERAMDISK
#define BB_FSCK_MINIX
#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
#define BB_LENGTH
#define BB_LN
#define BB_LOADACM
#define BB_LOADFONT
#define BB_LOADKMAP
#define BB_LOGGER
#define BB_LOGNAME
#define BB_LOSETUP
#define BB_LS
#define BB_LSMOD
#define BB_MAKEDEVS
#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
#define BB_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
#define BB_MT
#define BB_MV
#define BB_NC
#define BB_NSLOOKUP
#define BB_PIDOF
#define BB_PING
#define BB_PIVOT_ROOT
#define BB_POWEROFF
#define BB_PRINTF
#define BB_PS
#define BB_PWD
#define BB_RDATE
#define BB_READLINK
#define BB_REBOOT
#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
#define BB_RMMOD
#define BB_ROUTE
#define BB_RPM2CPIO
#define BB_SED
#define BB_SETKEYCODES
#define BB_SLEEP
#define BB_SORT
#define BB_STTY
#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
#define BB_TAIL
#define BB_TAR
#define BB_TEE
#define BB_TEST
#define BB_TELNET
#define BB_TFTP
#define BB_TIME
#define BB_TOP
#define BB_TOUCH
#define BB_TR
#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UNIX2DOS
#define BB_UUENCODE
#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
#define BB_UPDATE
#define BB_UPTIME
#define BB_USLEEP
#define BB_VI
#define BB_WATCHDOG
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_XARGS
#define BB_YES
// End of Applications List
//
//
//
// ---------------------------------------------------------
// This is where feature definitions go. Generally speaking,
// turning this stuff off makes things a bit smaller (and less
// pretty/useful).
//
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
//#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. NOTE: If you enable this
// feature, you _must_ have patched the kernel to include the devps patch that
// is included in the busybox/kernel-patches directory. You will also need to
// create some device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// show verbose usage messages
#define BB_FEATURE_VERBOSE_USAGE
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more, ls, and telnet)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//
// sort the file names
#define BB_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Use color to identify different file types
#define BB_FEATURE_LS_COLOR
//
// Disable for a smaller (but less functional) ping
#define BB_FEATURE_FANCY_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
//
// If you are using uClibc, be sure that you've already compiled
// uClibc with INCLUDE_RPC=true (contained in the Config file)
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" and "-X" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable uniqe sort
#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things. Off by default.
// Only relevant if a shell is enabled.
#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
//names. This causes applets (i.e., most busybox commands) to override
//real commands on the filesystem. For example, if you run run /bin/cat, it
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if a shell is enabled. Off by default.
#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if a shell is enabled.
#define BB_FEATURE_SH_FANCY_PROMPT
//
// Uncomment this option to disable job control. Job control lets you
// run jobs in the background (which completely useless for is all you
// are doing is running scripts). Disabing this is bad for interactive
// use, since when you hit ^C in an application, it will also kill the
// shell. This adds about 2.5k on an x86 system.
#define BB_FEATURE_ASH_JOB_CONTROL
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
#define BB_FEATURE_FBSET_READMODE
//
// Support insmod/lsmod/rmmod for post 2.1 kernels
#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
#define BB_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 7k.
#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
#define BB_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
#define BB_FEATURE_IFCONFIG_HW
//
// Allows "broadcast +" to set broadcast automatically based on hostaddr
// and netmask, at a cost of about 100 bytes of code (i386).
#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
//#define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
//
// Support for the find -mtime option.
#define BB_FEATURE_FIND_MTIME
//
//// Support for the find -newer option.
#define BB_FEATURE_FIND_NEWER
//
// Support for the -A -B and -C context flags in grep
#define BB_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
#define BB_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
// Support for devfs.
//#define BB_FEATURE_DEVFS
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#include <features.h>
#if defined(__uClinux__)
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#if (defined BB_ASH || defined BB_HUSH || defined BB_MSH) && ! defined BB_TEST
#define BB_TEST
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
+268 -146
View File
@@ -2,36 +2,43 @@
// 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_ASH
#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_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_DATE
//#define BB_DC
#define BB_DD
//#define BB_DD
//#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
//#define BB_DOS2UNIX
#define BB_DPKG_DEB
//#define BB_DPKG
//#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
//#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
#define BB_EXPR
#define BB_FBSET
//#define BB_FBSET
//#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
@@ -40,40 +47,50 @@
//#define BB_GETOPT
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
//#define BB_GZIP
//#define BB_HALT
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
//#define BB_HOSTID
//#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
//#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM
//#define BB_LOADFONT
//#define BB_LOADKMAP
#define BB_LOGGER
//#define BB_LOGGER
//#define BB_LOGNAME
//#define BB_LOSETUP
#define BB_LS
//#define BB_LSMOD
#define BB_LSMOD
//#define BB_MAKEDEVS
//#define BB_MD5SUM
#define BB_MD5SUM
#define BB_MKDIR
//#define BB_MKFIFO
//#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
//#define BB_NC
#define BB_MORE
//#define BB_MKSWAP
//#define BB_MKTEMP
//#define BB_MODPROBE
//#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
//#define BB_PING
#define BB_POWEROFF
#define BB_PIDOF
#define BB_PING
#define BB_PIVOT_ROOT
//#define BB_POWEROFF
//#define BB_PRINTF
#define BB_PS
#define BB_PWD
@@ -81,43 +98,50 @@
//#define BB_READLINK
#define BB_REBOOT
//#define BB_RENICE
#define BB_RESET
//#define BB_RESET
#define BB_RM
#define BB_RMDIR
//#define BB_RMMOD
//#define BB_RPMUNPACK
#define BB_ROUTE
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
//#define BB_SH
#define BB_SLEEP
//#define BB_SORT
#define BB_SWAPONOFF
//#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
//#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
#define BB_TAIL
#define BB_TAR
//#define BB_TEE
//#define BB_TEST
//#define BB_TELNET
#define BB_TELNET
//#define BB_TFTP
//#define BB_TIME
//#define BB_TOP
#define BB_TOUCH
//#define BB_TR
#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
//#define BB_TTY
#define BB_UPTIME
//#define BB_USLEEP
//#define BB_WC
//#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
//#define BB_UNIQ
#define BB_UNAME
//#define BB_UNIX2DOS
//#define BB_UPDATE
#define BB_XARGS
#define BB_YES
//#define BB_UPTIME
//#define BB_USLEEP
//#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
#define BB_WGET
//#define BB_WHICH
//#define BB_WHOAMI
//#define BB_XARGS
//#define BB_YES
// End of Applications List
//
//
@@ -128,55 +152,67 @@
// pretty/useful).
//
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
// thereby eliminating the need for the /proc filesystem and thereby saving
// lots and lots memory for more important things. 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:
// lots and lots memory for more important things. NOTE: If you enable this
// feature, you _must_ have patched the kernel to include the devps patch that
// is included in the busybox/kernel-patches directory. You will also need to
// create some device special files in /dev on your embedded system:
// mknod /dev/mtab c 10 22
// mknod /dev/ps c 10 21
// I emailed Linus and this patch will not be going into the stock kernel.
//#define BB_FEATURE_USE_DEVPS_PATCH
//
// 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
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
#define BB_FEATURE_TRIVIAL_HELP
// 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)
// calculate terminal & column widths (for more, ls, and telnet)
#define BB_FEATURE_AUTOWIDTH
//
// show username/groupnames (bypasses libc6 NSS) for ls
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
//#define BB_FEATURE_LS_FILETYPES
//
// sort the file names
#define BB_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
//#define BB_FEATURE_LS_RECURSIVE
//
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
//
// Change ping implementation -- simplified, featureless, but really small.
//#define BB_FEATURE_SIMPLE_PING
// Use color to identify different file types
#define BB_FEATURE_LS_COLOR
//
// 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
@@ -187,37 +223,35 @@
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
//
// 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 syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
//#define BB_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//#define BB_FEATURE_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
//
// If you are using uClibc, be sure that you've already compiled
// uClibc with INCLUDE_RPC=true (contained in the Config file)
#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
//
// Enable support for creation of tar files.
@@ -229,15 +263,27 @@
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
// Enable reverse sort
//#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
#define BB_FEATURE_SH_COMMAND_EDITING
// Enable uniqe sort
//#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things.
//among other things. Off by default.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
@@ -246,11 +292,21 @@
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
// 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 a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//
// Uncomment this option to disable job control. Job control lets you
// run jobs in the background (which completely useless for is all you
// are doing is running scripts). Disabing this is bad for interactive
// use, since when you hit ^C in an application, it will also kill the
// shell. This adds about 2.5k on an x86 system.
#define BB_FEATURE_ASH_JOB_CONTROL
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -258,38 +314,101 @@
//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 insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// You must enable one or both of these features
// Support modules status from pre 2.1 kernels
//#define BB_FEATURE_LSMOD_OLD_KERNEL
// Support modules status from kernel versions after 2.1.18
#define BB_FEATURE_LSMOD_NEW_KERNEL
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 7k.
#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
#define BB_FEATURE_IFCONFIG_HW
//
// Allows "broadcast +" to set broadcast automatically based on hostaddr
// and netmask, at a cost of about 100 bytes of code (i386).
//#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS
//
// 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_STATUSBAR
#define BB_FEATURE_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
//#define BB_FEATURE_WGET_AUTHENTICATION
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
//
// Support for the find -mtime option.
#define BB_FEATURE_FIND_MTIME
//
//// Support for the find -newer option.
#define BB_FEATURE_FIND_NEWER
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
// Support for devfs.
//#define BB_FEATURE_DEVFS
//
// End of Features List
//
//
@@ -301,71 +420,74 @@
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#include <features.h>
#if defined(__uClinux__)
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
#if (defined BB_ASH || defined BB_HUSH || defined BB_MSH) && ! defined BB_TEST
#define BB_TEST
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#endif
#define BB_LINUXRC
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#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
#undef BB_FEATURE_LINUXRC
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#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_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
+1 -1
View File
@@ -5,6 +5,6 @@ BusyBox is being developed and maintained by Erik Andersen
<andersee@debian.org>.
If you have a problem with BusyBox, send email to the Debian bug tracking
system that lives at <submit@bugs.lineo.com>
system that lives at <submit@bugs.busybox.net>
Erik Andersen <andersee@debian.org>, Sun, 18 Jun 2000 21:52:00 -0600
+278 -4
View File
@@ -1,3 +1,281 @@
busybox (1:0.60.5-2) unstable; urgency=low
* It turns out that for the .udeb, we don't want to disable
BB_FEATURE_LINUXRC, we just want to kill the /linuxrc link.
Thanks to Matt Kraai for tracking this one down. (closes: #161611)
-- Erik Andersen <andersee@debian.org> Thu, 31 Oct 2002 02:25:01 -0700
busybox (1:0.60.5-1) unstable; urgency=low
* New version released. See Changelog for non-Debian specific details.
* zcat no longer tries to delete source files (closes: #164968)
* Eliminate /linuxrc from the .udeb (closes: #163890)
* Fix description of the --install option (closes: #164178)
-- Erik Andersen <andersee@debian.org> Sat, 26 Oct 2002 06:23:51 -0600
busybox (1:0.60.4-1.1) unstable; urgency=low
* NMU
* Fix cp -a so it handles symlinks properly (closes: #163501)
-- Tollef Fog Heen <tfheen@debian.org> Sun, 6 Oct 2002 16:08:45 +0200
busybox (1:0.60.4-1) unstable; urgency=low
* New version released. See Changelog for non-Debian specific details.
* enable uname for the debian-installer (closes: #158706)
* enable losetup for the boot floppies (closes: #138060)
* init behaves itself better consoles go missing (closes: #129626)
* In 'free', buffers change as buffered data increases (closes: #148396)
* Functions for debootstrap added to the .udeb (closes: #124388)
* This bug is not reproducable (closes: #127522)
-- Erik Andersen <andersee@debian.org> Wed, 18 Sep 2002 14:13:05 -0600
busybox (1:0.60.3-1) unstable; urgency=low
* New version released. See Changelog for non-Debian specific details.
* makedevs no longer segfaults (closes: #123921)
* wget no longer crashes (closes: #138943)
* wget now checks the safe_fwrite return code (closes: #143179)
-- Erik Andersen <andersee@debian.org> Sat, 27 Apr 2002 01:33:34 -0600
busybox (1:0.60.2-3) testing unstable; urgency=low
* Fix wc stdin handling (closes: #123387).
* Fix wget to do just one DNS lookup (closes: #124068)
-- Erik Andersen <andersee@debian.org> Sun, 16 Dec 2001 22:51:03 -0700
busybox (1:0.60.2-2) unstable; urgency=low
* Several small bugfixes (closes: #120353, #120369, #122638,
* Reworked wc.c to fix the severe efficiency problems and make it
smaller. This one is mainly for the boot-floppies (closes: #120441)
* Enable hostname (closes: #120511)
-- Erik Andersen <andersee@debian.org> Thu, 6 Dec 2001 00:06:33 -0700
busybox (1:0.60.2-1) unstable; urgency=low
* New version released. See Changelog for non-Debian specific details.
* dpkg.c now uses an int for getopt (closes: #118975)
* s390 console reboot msg is now appropriate (closes: #118859)
* the manpage is no longer empty (closes: #117013)
* no more .o files in the source tarball (closes: #112046)
* the .udeb contents are exactly as Joey wants them (closes: #105352)
* busybox ash is the default shell for the -static package,
so it can cope with /etc/profile just fine (closes: #95745)
-- Erik Andersen <andersee@debian.org> Tue, 20 Nov 2001 03:41:29 -0700
busybox (1:0.60.1-8) unstable; urgency=low
* Adjusted some apps for the debian installer's .udeb package.
Enabled ifconfig, route.
Disabled chgrp, clear, date, dd, du, gzip, halt, head, killall,
loadkmap, logger, mkswap, more, poweroff, reset, sleep, sort,
swapon, swapoff, touch, tty, uniq, uname, uptime, vi, wc, which,
whoami, xargs, and yes.
-- Erik Andersen <andersee@debian.org> Thu, 18 Oct 2001 22:59:06 -0600
busybox (1:0.60.1-7) unstable; urgency=low
* Re-enable wget's status bar for today's dbootstrap change. (closes: #115717)
* Enable initrd support (even if they are a bad idea). (closes: #114727)
-- Erik Andersen <andersee@debian.org> Mon, 15 Oct 2001 20:45:57 -0600
busybox (1:0.60.1-6) unstable; urgency=low
* Re-enable wc, gzip, tty, and expr. (closes: #114906)
-- Erik Andersen <andersee@debian.org> Wed, 10 Oct 2001 02:47:50 -0600
busybox (1:0.60.1-5) unstable; urgency=low
* Time to make this official. This enables several applets, such
as ifconfig and route, and disables several others.
* Revert ash to the version in the busybox stable branch. For the
-3 non-release, I tried the one from busybox unstable (which lived
up to its name). (closes: #112503)
* Enable id, disable ash (closes: #114260, #113698)
* Backport several bugfixes from unstable
-- Erik Andersen <andersee@debian.org> Fri, 5 Oct 2001 23:03:15 -0600
busybox (1:0.60.1-4) unstable; urgency=low
* Doh! With busybox ash, we need test and echo enabled...
-- Erik Andersen <andersee@debian.org> Wed, 26 Sep 2001 00:05:04 -0600
busybox (1:0.60.1-3) unstable; urgency=low
* This upload is to test whether disabling several applets, and
enabling several others will help. Enabled is ifconfig, route,
and ash. Disabled is basename, date, echo, env, expr, gzip,
lsmod, and wc.
-- Erik Andersen <andersee@debian.org> Tue, 25 Sep 2001 17:45:16 -0600
busybox (1:0.60.1-2) unstable; urgency=low
* Disabled several applets to make busybox be a bit thinner, since the
powerpc boot floppies are _very_ tight on space (closes: #112503)
* Teach 'mount' about usbdevfs (closes: #111055)
* Busybox supports full online help, but due to space constraints on
the boot floppies, it will not be enabled. People can read the
busybox documentation if they need full details. (closes: #111350)
-- Erik Andersen <andersee@debian.org> Sun, 23 Sep 2001 23:32:15 -0600
busybox (1:0.60.1-1) unstable; urgency=low
* New stable version released. See changelog for details.
* Enabled 'ar' for the udeb
-- Erik Andersen <andersee@debian.org> Thu, 23 Aug 2001 15:44:14 -0600
busybox (1:0.60.0-1) unstable; urgency=low
* New stable version released. See changelog for details.
-- Erik Andersen <andersee@debian.org> Thu, 2 Aug 2001 12:12:37 -0600
busybox (1:0.52-1.1) unstable; urgency=high
* Non-maintainer upload
* Fixed wget -P handling (closes: #106223).
-- Matt Kraai <kraai@debian.org> Wed, 25 Jul 2001 11:01:38 -0600
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
for complete details)
* Force USE_SYSTEM_PWD_GRP=false, so busybox bypasses
the glibc NSS libraries. (closes: #93362)
* Fixed a bug in sed's address range handling (closes: #91758)
* Removed irrelevant cruft from the bottem of debian/changelog
-- Erik Andersen <andersee@debian.org> Tue, 10 Apr 2001 14:07:29 -0600
busybox (0.50-2) unstable; urgency=low
* Enabled freeramdisk and pivot_root in the udeb (closes: #91336)
* Disabled lash (the busybox shell) in the udeb (closes: #91337)
* fixed a bug in syslog, a problem with rebooting when booted as
an initrd, and a few other minor problems.
-- Erik Andersen <andersee@debian.org> Sun, 25 Mar 2001 20:59:44 -0700
busybox (0.50-2) unstable; urgency=low
* Enabled freeramdisk and pivot_root in the udeb (closes: #91336)
* Disabled lash (the busybox shell) in the udeb (closes: #91337)
* fixed a bug in syslog, a problem with rebooting when booted as
an initrd, and a few other minor problems.
-- Erik Andersen <andersee@debian.org> Sun, 25 Mar 2001 20:59:44 -0700
busybox (0.50-1) unstable; urgency=low
* Tons on improvements all around -- See changelog for details.
* Fix malformed Build-Depends (closes: #86930)
* grep has worked for some time now (closes: #81084)
* init compiles with DEBUG_INIT enabled (closes: #85794)
* md5sum no longer displays filename when reading stdin (closes: #81283)
* lsmod, rmmod, and insmod are no longer enabled (closes: #85642)
* busybox and buxybox-static now conflict/replace each other (closes: #80421)
-- Erik Andersen <andersee@debian.org> Thu, 15 Mar 2001 14:45:00 -0700
busybox (0.49-1) unstable; urgency=low
* Lots more source updates and bug fixes. See changelog for details.
@@ -38,7 +316,3 @@ busybox (0.45-1) unstable; urgency=low
-- Erik Andersen <andersee@debian.org> Tue, 27 Jun 2000 12:26:41 -0600
Local variables:
mode: debian-changelog
add-log-mailing-address: "andersee@debian.org"
End:
+16 -12
View File
@@ -1,38 +1,41 @@
Source: busybox
Priority: optional
Maintainer: Erik Andersen <andersee@debian.org>
Build-Depends: debhelper (>= 2.1.18), dpkg-dev (1.7.0)
Build-Depends: debhelper (>= 2.1.18), dpkg-dev (>= 1.7.0)
Standards-Version: 3.2.1.0
Package: busybox
Architecture: any
Depends: ${shlibs:Depends}
Conflicts:
Replaces:
Conflicts: busybox-static
Replaces: busybox-static
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.
.
This package installs the BusyBox binary but does not install symlinks
for any of the supported utilities. You can use /bin/busybox --install
to install BusyBox to the current directory (you do not want to do this
in / on your Debian system!).
to install BusyBox to the root directory (you do not want to do this
to your your Debian system, except in dire emergencies!).
Package: busybox-static
Architecture: any
Depends: ${shlibs:Depends}
Conflicts: busybox
Replaces: busybox
Section: shells
Description: Provides a stand alone rescue shell with tons of builtin utilities.
Priority: extra
Description: Standalone 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.
@@ -48,11 +51,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.
+14 -13
View File
@@ -28,7 +28,8 @@ debian/build-stamp-busybox:
mkdir -p $(bbbd)
cp Makefile $(bbbd)
cp debian/Config.h-deb $(bbbd)/Config.h
(cd $(bbbd); $(MAKE) "BB_SRC_DIR=../../")
-(cd $(bbbd); $(MAKE) "BB_SRC_DIR=../../" applet_source_list)
(cd $(bbbd); $(MAKE) USE_SYSTEM_PWD_GRP=false "BB_SRC_DIR=../../")
touch debian/build-stamp-busybox
install: build
@@ -41,8 +42,8 @@ install: build
#(cd $(bbbd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bb)" install)
mkdir -p $(bb)/bin/
cp $(bbbd)/busybox $(bb)/bin/busybox
mkdir -p $(bb)/usr/share/doc/busybox/busybox.lineo.com
cp $(bbbd)/docs/busybox.lineo.com/BusyBox.html $(bb)/usr/share/doc/busybox/busybox.lineo.com/
mkdir -p $(bb)/usr/share/doc/busybox
cp $(bbbd)/docs/BusyBox.html $(bb)/usr/share/doc/busybox/
mkdir -p $(bb)/usr/share/man/man1
cp $(bbbd)/docs/BusyBox.1 $(bb)/usr/share/man/man1/busybox.1
@@ -52,8 +53,8 @@ debian/build-stamp-busybox-static:
dh_testdir
mkdir -p $(bbsbd)
cp Makefile $(bbsbd)
cp debian/Config.h-deb $(bbsbd)/Config.h
(cd $(bbsbd); $(MAKE) DOSTATIC=true "BB_SRC_DIR=../../")
cp debian/Config.h-static $(bbsbd)/Config.h
(cd $(bbsbd); $(MAKE) DOSTATIC=true USE_SYSTEM_PWD_GRP=false "BB_SRC_DIR=../../")
touch debian/build-stamp-busybox-static
install-static: build
@@ -66,8 +67,8 @@ install-static: build
#(cd $(bbsbd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bbs)" install)
mkdir -p $(bbs)/bin/
cp $(bbsbd)/busybox $(bbs)/bin/busybox
mkdir -p $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com
cp $(bbsbd)/docs/busybox.lineo.com/BusyBox.html $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/
mkdir -p $(bbs)/usr/share/doc/busybox-static
cp $(bbsbd)/docs/BusyBox.html $(bbs)/usr/share/doc/busybox-static/
mkdir -p $(bbs)/usr/share/man/man1/
cp $(bbsbd)/docs/BusyBox.1 $(bbs)/usr/share/man/man1/busybox.1
@@ -83,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:
@@ -94,7 +94,7 @@ debian/build-stamp-busybox-udeb:
mkdir -p $(bbubd)
cp Makefile $(bbubd)
cp debian/Config.h-udeb $(bbubd)/Config.h
(cd $(bbubd); $(MAKE) "BB_SRC_DIR=../../")
(cd $(bbubd); $(MAKE) USE_SYSTEM_PWD_GRP=false "BB_SRC_DIR=../../")
touch debian/build-stamp-busybox-udeb
install-udeb: build
@@ -103,6 +103,7 @@ install-udeb: build
dh_clean -k
dh_installdirs
(cd $(bbubd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bbu)" install)
rm -f $(bbu)/linuxrc
mkdir -p $(bbu)/usr/share/man/man1/
cp $(bbubd)/docs/BusyBox.1 $(bbu)/usr/share/man/man1/busybox.1
@@ -130,7 +131,7 @@ busybox: install
dh_installdirs
dh_installdocs -p$@ $(bbbd)/docs/BusyBox.txt \
$(bbbd)/docs/BusyBox.html docs/style-guide.txt \
docs/busybox.lineo.com AUTHORS README TODO
AUTHORS README TODO
rm -rf `find $(bb) -name CVS`
rm -f `find $(bb) -name .cvsignore`
dh_installchangelogs -p$@ Changelog
@@ -152,7 +153,7 @@ busybox-static: do_static
dh_installdirs
dh_installdocs -p$@ $(bbsbd)/docs/BusyBox.txt \
$(bbsbd)/docs/BusyBox.html docs/style-guide.txt \
docs/busybox.lineo.com AUTHORS README TODO
AUTHORS README TODO
rm -rf `find $(bbs) -name CVS`
rm -f `find $(bbs) -name .cvsignore`
dh_installchangelogs -p$@ Changelog
@@ -185,7 +186,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)
+55 -53
View File
@@ -2,8 +2,8 @@
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
@@ -22,58 +22,63 @@
*
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <getopt.h>
#include "busybox.h"
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long disp_hr = KILOBYTE;
static unsigned long df_disp_hr = KILOBYTE;
#endif
static int df(char *device, const char *mountPoint)
static int do_df(char *device, const char *mount_point)
{
struct statfs s;
long blocks_used;
long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) {
perror_msg("%s", mountPoint);
if (statfs(mount_point, &s) != 0) {
perror_msg("%s", mount_point);
return FALSE;
}
if (s.f_blocks > 0) {
blocks_used = s.f_blocks - s.f_bfree;
if(0 == blocks_used)
if(blocks_used == 0)
blocks_percent_used = 0;
else
else {
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
}
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
find_real_root_device_name( device);
device = find_real_root_device_name(device);
if(device==NULL)
return FALSE;
}
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%-20s %9s",
device,
format((s.f_blocks * s.f_bsize), disp_hr));
printf(" %9s", format((s.f_blocks - s.f_bfree) * s.f_bsize, disp_hr));
printf(" %9s %3ld%% %s\n",
format(s.f_bavail * s.f_bsize, disp_hr),
blocks_percent_used, mountPoint);
printf("%-20s %9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str( (s.f_blocks - s.f_bfree), s.f_bsize, df_disp_hr));
printf("%9s %3ld%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
blocks_percent_used, mountPoint);
device,
(long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
(long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
(long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
blocks_percent_used, mount_point);
#endif
}
return TRUE;
@@ -84,67 +89,64 @@ extern int df_main(int argc, char **argv)
int status = EXIT_SUCCESS;
int opt = 0;
int i = 0;
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
while ((opt = getopt(argc, argv, "?"
while ((opt = getopt(argc, argv, "k"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k"
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
case 'k': disp_hr = KILOBYTE; break;
#else
case 'k': break;
case 'h':
df_disp_hr = 0;
strcpy(disp_units_hdr, " Size");
break;
case 'm':
df_disp_hr = MEGABYTE;
strcpy(disp_units_hdr, "1M-blocks");
break;
#endif
case '?': goto print_df_usage; break;
case 'k':
/* default display is kilobytes */
break;
default:
show_usage();
}
}
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
#ifdef BB_FEATURE_HUMAN_READABLE
(KILOBYTE == disp_hr) ? "1k-blocks" : " Size",
#else
"1k-blocks",
#endif
printf("%-20s %-14s %s %s %s %s\n", "Filesystem", disp_units_hdr,
"Used", "Available", "Use%", "Mounted on");
if(optind < argc) {
struct mntent *mountEntry;
struct mntent *mount_entry;
for(i = optind; i < argc; i++)
{
if ((mountEntry = find_mount_point(argv[i], mtab_file)) == 0) {
error_msg("%s: can't find mount point.\n", argv[i]);
if ((mount_entry = find_mount_point(argv[i], mtab_file)) == 0) {
error_msg("%s: can't find mount point.", argv[i]);
status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
} else if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
status = EXIT_FAILURE;
}
} else {
FILE *mountTable;
struct mntent *mountEntry;
FILE *mount_table;
struct mntent *mount_entry;
mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) {
mount_table = setmntent(mtab_file, "r");
if (mount_table == 0) {
perror_msg("%s", mtab_file);
return EXIT_FAILURE;
}
while ((mountEntry = getmntent(mountTable))) {
if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
while ((mount_entry = getmntent(mount_table))) {
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
status = EXIT_FAILURE;
}
endmntent(mountTable);
endmntent(mount_table);
}
return status;
print_df_usage:
usage(df_usage);
return(FALSE);
}
/*
+9 -16
View File
@@ -2,8 +2,8 @@
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,28 +20,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "busybox.h"
/* getopt not needed */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
extern int dirname_main(int argc, char **argv)
{
char* s;
if ((argc < 2) || (**(argv + 1) == '-'))
usage(dirname_usage);
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;
}
+9 -17
View File
@@ -15,25 +15,20 @@
* Support, replaced getopt, added some gotos for redundant stuff.
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#if __GNU_LIBRARY__ < 5
#include <sys/syscall.h>
#include <linux/unistd.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
#else /* __alpha__ */
#define klogctl syslog
#endif
# ifdef __alpha__
# define klogctl syslog
# endif
#else
# include <sys/klog.h>
#endif
#include "busybox.h"
int dmesg_main(int argc, char **argv)
{
char *buf;
@@ -53,21 +48,21 @@ int dmesg_main(int argc, char **argv)
case 'n':
cmd = 8;
if (optarg == NULL)
usage(dmesg_usage);
show_usage();
level = atoi(optarg);
break;
case 's':
if (optarg == NULL)
usage(dmesg_usage);
show_usage();
bufsize = atoi(optarg);
break;
default:
usage(dmesg_usage);
show_usage();
}
}
if (optind < argc) {
goto end;
show_usage();
}
if (cmd == 8) {
@@ -97,7 +92,4 @@ int dmesg_main(int argc, char **argv)
if (lastc != '\n')
putchar('\n');
return EXIT_SUCCESS;
end:
usage(dmesg_usage);
return EXIT_FAILURE;
}
+1 -1
View File
@@ -5,4 +5,4 @@ busybox.txt
busybox.ps
busybox.pdf
busybox
busybox.pod
+287
View File
@@ -0,0 +1,287 @@
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
# collect lines continued with a '\' into an array
sub continuation {
my $fh = shift;
my @line;
while (<$fh>) {
my $s = $_;
$s =~ s/\\\s*$//;
#$s =~ s/#.*$//;
push @line, $s;
last unless (/\\\s*$/);
}
return @line;
}
# regex && eval away unwanted strings from documentation
sub beautify {
my $text = shift;
$text =~ s/USAGE_NOT\w+\(.*?"\s*\)//sxg;
$text =~ s/USAGE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
$text =~ s/"\s*"//sg;
my @line = split("\n", $text);
$text = join('',
map {
s/^\s*"//;
s/"\s*$//;
s/%/%%/g;
s/\$/\\\$/g;
eval qq[ sprintf(qq{$_}) ]
} @line
);
return $text;
}
# generate POD for an applet
sub pod_for_usage {
my $name = shift;
my $usage = shift;
# make options bold
my $trivial = $usage->{trivial};
$trivial =~ s/(?<!\w)(-\w+)/B<$1>/sxg;
my @f0 =
map { $_ !~ /^\s/ && s/(?<!\w)(-\w+)/B<$1>/g; $_ }
split("\n", $usage->{full});
# add "\n" prior to certain lines to make indented
# lines look right
my @f1;
my $len = @f0;
for (my $i = 0; $i < $len; $i++) {
push @f1, $f0[$i];
if (($i+1) != $len && $f0[$i] !~ /^\s/ && $f0[$i+1] =~ /^\s/) {
next if ($f0[$i] =~ /^$/);
push(@f1, "") unless ($f0[$i+1] =~ /^\s*$/s);
}
}
my $full = join("\n", @f1);
# prepare notes if they exist
my $notes = (defined $usage->{notes})
? "$usage->{notes}\n\n"
: "";
# prepare examples if they exist
my $example = (defined $usage->{example})
?
"Example:\n\n" .
join ("\n",
map { "\t$_" }
split("\n", $usage->{example})) . "\n\n"
: "";
return
"=item B<$name>".
"\n\n" .
"$name $trivial".
"\n\n" .
$full .
"\n\n" .
$notes .
$example.
"-------------------------------".
"\n\n"
;
}
# FIXME | generate SGML for an applet
sub sgml_for_usage {
my $name = shift;
my $usage = shift;
return
"<fixme>\n".
" $name\n".
"</fixme>\n"
;
}
# the keys are applet names, and
# the values will contain hashrefs of the form:
#
# {
# trivial => "...",
# full => "...",
# notes => "...",
# example => "...",
# }
my %docs;
# get command-line options
my %opt;
GetOptions(
\%opt,
"help|h",
"sgml|s",
"pod|p",
"verbose|v",
);
if (defined $opt{help}) {
print
"$0 [OPTION]... [FILE]...\n",
"\t--help\n",
"\t--sgml\n",
"\t--pod\n",
"\t--verbose\n",
;
exit 1;
}
# collect documenation into %docs
foreach (@ARGV) {
open(USAGE, $_) || die("$0: $_: $!");
my $fh = *USAGE;
my ($applet, $type, @line);
while (<$fh>) {
if (/^#define (\w+)_(\w+)_usage/) {
$applet = $1;
$type = $2;
@line = continuation($fh);
my $doc = $docs{$applet} ||= { };
my $text = join("\n", @line);
$doc->{$type} = beautify($text);
}
}
}
# generate structured documentation
my $generator = \&pod_for_usage;
if (defined $opt{sgml}) {
$generator = \&sgml_for_usage;
}
foreach my $applet (sort keys %docs) {
print $generator->($applet, $docs{$applet});
}
exit 0;
__END__
=head1 NAME
autodocifier.pl - generate docs for busybox based on usage.h
=head1 SYNOPSIS
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
The purpose of this script is to automagically generate documentation
for busybox using its usage.h as the original source for content.
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 <andersee@debian.org>
which was in turn based on a script by Mark Whitley <markw@codepoet.org>
=head1 OPTIONS
=over 4
=item B<--help>
This displays the help message.
=item B<--pod>
Generate POD (this is the default)
=item B<--sgml>
Generate SGML
=item B<--verbose>
Be verbose (not implemented)
=back
=head1 FORMAT
The following is an example of some data this script might parse.
#define length_trivial_usage \
"STRING"
#define length_full_usage \
"Prints out the length of the specified STRING."
#define length_example_usage \
"$ length Hello\n" \
"5\n"
Each entry is a cpp macro that defines a string. The macros are
named systematically in the form:
$name_$type_usage
$name is the name of the applet. $type can be "trivial", "full", "notes",
or "example". Every documentation macro must end with "_usage".
The definition of the types is as follows:
=over 4
=item B<trivial>
This should be a brief, one-line description of parameters that
the command expects. This will be displayed when B<-h> is issued to
a command. I<REQUIRED>
=item B<full>
This should contain descriptions of each option. This will also
be displayed along with the trivial help if BB_FEATURE_TRIVIAL_HELP
is disabled. I<REQUIRED>
=item B<notes>
This is documentation that is intended to go in the POD or SGML, but
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.
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
=head1 FILES
F<usage.h>
=head1 COPYRIGHT
Copyright (c) 2001 John BEPPU. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
=head1 AUTHOR
John BEPPU <beppu@codepoet.org>
=cut
# $Id: autodocifier.pl,v 1.22 2001/11/19 23:57:54 andersen Exp $
-1
View File
@@ -1 +0,0 @@
BusyBox.html
Loaded 100 of 401 files, more files were not shown because too many files have changed in this diff. Show more