Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b8a1e89a5 | ||
|
|
f435a918fa | ||
|
|
81ee96fe62 | ||
|
|
c36642195c | ||
|
|
edc6e0248c | ||
|
|
372f12678e | ||
|
|
efd7f03657 | ||
|
|
4e05da89f3 | ||
|
|
36c613a443 | ||
|
|
9dfe508a3f | ||
|
|
c2d6ca0922 | ||
|
|
03bb3088b0 | ||
|
|
6f8b7ea452 | ||
|
|
55805bcba4 | ||
|
|
d81891a2e6 | ||
|
|
43626d7671 | ||
|
|
cc05ce64e9 | ||
|
|
fff11f1ab7 | ||
|
|
fedce06b7f | ||
|
|
9c6b5fcb0a | ||
|
|
bff7a60f63 | ||
|
|
80f5ac7016 | ||
|
|
26f8e95d2d | ||
|
|
5c2bbb55d7 | ||
|
|
6c5fdfaf56 | ||
|
|
a21c24bf03 | ||
|
|
c8227639db | ||
|
|
357cfc739e | ||
|
|
9fb38f600c | ||
|
|
a5f09c668e | ||
|
|
c5f9a9dd0c | ||
|
|
31ac3b7764 | ||
|
|
45784febaf | ||
|
|
dba4e6f046 | ||
|
|
c223ced0ea | ||
|
|
282671bf76 | ||
|
|
30fcef430c | ||
|
|
cd8c436d81 | ||
|
|
94f19a8385 | ||
|
|
744a194f53 | ||
|
|
c52a6b0f10 | ||
|
|
e5d58c3dcc | ||
|
|
882cbcdfa1 | ||
|
|
7131213460 | ||
|
|
df23302cb5 | ||
|
|
5abdaa9a16 | ||
|
|
3c513e3858 | ||
|
|
0a25b35c66 | ||
|
|
55b2deda08 | ||
|
|
60281118d0 | ||
|
|
b89637a037 | ||
|
|
5447f17ef9 | ||
|
|
f419855300 | ||
|
|
bb0088e980 | ||
|
|
8fc0589777 | ||
|
|
f46999f8bc | ||
|
|
1552ff7efb | ||
|
|
ec07469a3e | ||
|
|
31a0ece3a7 | ||
|
|
7d6829096d | ||
|
|
eaecbf33f7 | ||
|
|
69a20f0aca | ||
|
|
6cf47a79ac | ||
|
|
2bc4dec7a1 | ||
|
|
a58f040a37 | ||
|
|
85dd4b3b27 | ||
|
|
ccd96f1972 | ||
|
|
3d61b10595 | ||
|
|
950d8b496f | ||
|
|
2c669dd108 | ||
|
|
ce22feea01 | ||
|
|
3889078dbe | ||
|
|
999623e973 | ||
|
|
b5f2516e3f | ||
|
|
813d88cf78 | ||
|
|
4acf8f8481 | ||
|
|
72f9a4277f | ||
|
|
9af363fe20 | ||
|
|
7134d6581b | ||
|
|
8e392922b0 | ||
|
|
c265b17550 | ||
|
|
087bc82bb0 | ||
|
|
ee28362597 | ||
|
|
107c796e79 | ||
|
|
9f2f8540c5 | ||
|
|
e9fc781570 | ||
|
|
633f153808 | ||
|
|
ef0eab514d | ||
|
|
0d2fb76c11 | ||
|
|
95ebf618b7 | ||
|
|
8eaa7b3698 | ||
|
|
2293b96f42 | ||
|
|
9ae7ebd0fd | ||
|
|
258bd3d971 | ||
|
|
3c2f27d9f1 | ||
|
|
99702ab221 | ||
|
|
b78d9b56eb | ||
|
|
1a10eec178 | ||
|
|
bfebd35bea | ||
|
|
a49b025b19 | ||
|
|
a3483db55f | ||
|
|
3cd2760ba1 | ||
|
|
b36e684fd7 | ||
|
|
28593a085b | ||
|
|
ca38a29c81 | ||
|
|
9b5a953a98 | ||
|
|
4bcdd72142 | ||
|
|
bdfd0d78bc | ||
|
|
9260fc5552 | ||
|
|
1c9cebc8df | ||
|
|
8470b9a85c | ||
|
|
6ccdd8c122 | ||
|
|
c2e5b977ab | ||
|
|
68ca35c90f | ||
|
|
9c93721ea5 | ||
|
|
d63dee4019 | ||
|
|
f4c208937c | ||
|
|
c2af1ee036 | ||
|
|
bcca3317b5 | ||
|
|
a7512d74fa | ||
|
|
3dd4f5ed69 | ||
|
|
a0f0ae5a7a | ||
|
|
74400ccfd0 | ||
|
|
8acbf1d307 | ||
|
|
11fdb8a4c7 | ||
|
|
1bf25f0307 | ||
|
|
4bef7b4186 | ||
|
|
051eee6ed3 | ||
|
|
d642a67928 | ||
|
|
527880e5cf | ||
|
|
b5937d3eea | ||
|
|
0e766183ee | ||
|
|
f86bbfaddd | ||
|
|
9b2589dafd | ||
|
|
dfa7b0eff6 | ||
|
|
30f68908ef | ||
|
|
f28d819554 | ||
|
|
3550753445 | ||
|
|
1d098cefe2 | ||
|
|
bf265daa47 | ||
|
|
ad117d8a21 | ||
|
|
24e2833cdf | ||
|
|
2e772edacf | ||
|
|
4c557bf576 | ||
|
|
54a992d81e | ||
|
|
b0a0fc8944 | ||
|
|
a8412dbf39 | ||
|
|
fd35de564e | ||
|
|
371ca19f53 | ||
|
|
f0a4ac8216 | ||
|
|
35636540ea | ||
|
|
5c72104a85 | ||
|
|
c9fc633f9e | ||
|
|
524fcb9e01 | ||
|
|
95bfe631a4 | ||
|
|
63ae66198d | ||
|
|
b67adb0d83 | ||
|
|
c5bd149261 | ||
|
|
dece3c5684 | ||
|
|
b8f5adb64f | ||
|
|
3be34309e3 | ||
|
|
f8f6e624bb | ||
|
|
48cc89b738 | ||
|
|
e73866181f | ||
|
|
4c67c596d1 | ||
|
|
8d0afde412 | ||
|
|
6a9d1f652b | ||
|
|
f6ecaccf92 | ||
|
|
886b84211e | ||
|
|
5bb1677f1d | ||
|
|
88cec25e99 | ||
|
|
1644db9a2b | ||
|
|
b9408504f5 | ||
|
|
3b1525e444 | ||
|
|
1350666498 | ||
|
|
5171bf6d40 | ||
|
|
dcbca62e89 | ||
|
|
5078919981 | ||
|
|
28d0ac13d1 | ||
|
|
91631011cc | ||
|
|
863a3e15d6 | ||
|
|
ab3d839ef4 | ||
|
|
861e624e15 | ||
|
|
449377aa6a | ||
|
|
80f6d55836 | ||
|
|
ac20ce1924 | ||
|
|
2a953aed38 | ||
|
|
a0065d5955 | ||
|
|
31b35a16e0 | ||
|
|
a3c8481a33 | ||
|
|
b76cb68979 | ||
|
|
1071ccfd25 | ||
|
|
c0f9d0dce7 | ||
|
|
5d60a46269 | ||
|
|
ac5dbd193b | ||
|
|
59443965ad | ||
|
|
d36cdd25a5 | ||
|
|
39eb040757 | ||
|
|
a07c902648 | ||
|
|
75220b55ff | ||
|
|
994c6ffd3b | ||
|
|
c61804ed59 | ||
|
|
f349e978c4 | ||
|
|
a3e4f455ac | ||
|
|
54eceffcae | ||
|
|
76fa8ea790 | ||
|
|
bac490fe53 | ||
|
|
b6ec78161d | ||
|
|
0a68590314 | ||
|
|
c639a35f50 | ||
|
|
dd9173c07f | ||
|
|
16815d4b45 | ||
|
|
80dd0863e2 | ||
|
|
e20b7d844a | ||
|
|
a7cecbc917 | ||
|
|
4fb0b51703 | ||
|
|
6c4250c0dc | ||
|
|
d0b5be6da8 | ||
|
|
2338d3176b | ||
|
|
063c1f54ea | ||
|
|
69edfecfb9 | ||
|
|
b373a8d0ca | ||
|
|
0b7d70c822 | ||
|
|
8aa0b62a88 | ||
|
|
9e6089ee0f | ||
|
|
c9dd5f945b | ||
|
|
be0c36009a | ||
|
|
23b1e5c7df | ||
|
|
879d6c85af | ||
|
|
8a915880e7 | ||
|
|
95b520110d | ||
|
|
deba6dea03 | ||
|
|
46bf7de5f6 | ||
|
|
ff9b4a8981 | ||
|
|
fdbac35b33 | ||
|
|
842757dc96 | ||
|
|
3450636169 | ||
|
|
2d91deba45 | ||
|
|
0034443140 | ||
|
|
af6b40a1ea | ||
|
|
f672c9e62f | ||
|
|
bb9579ffc3 | ||
|
|
fa1c5aac51 | ||
|
|
73f6a1b058 | ||
|
|
221b2ea6c4 | ||
|
|
9a53feaa76 | ||
|
|
57c82fe7c4 | ||
|
|
51038a3f42 | ||
|
|
74bcd16425 | ||
|
|
dc6647201d | ||
|
|
c126f8ffb6 | ||
|
|
3555fd006e | ||
|
|
13cb842773 | ||
|
|
547e102082 | ||
|
|
7499918f30 | ||
|
|
14d7ea460f | ||
|
|
b6071b6341 | ||
|
|
eba260587a | ||
|
|
4e664ac51d | ||
|
|
089decab65 | ||
|
|
220238305f | ||
|
|
26eeb0c9da | ||
|
|
f9d6aa0a86 | ||
|
|
4db35647dd | ||
|
|
2835efe3da | ||
|
|
1b06419e60 | ||
|
|
655584b07a | ||
|
|
6c7ac21f3a | ||
|
|
096b151f76 | ||
|
|
439e3df653 | ||
|
|
0139ca92ff | ||
|
|
8d79ce8320 | ||
|
|
20aab260e2 | ||
|
|
0382eb8865 | ||
|
|
e92895c038 | ||
|
|
c8eae6684b | ||
|
|
c1cda4a609 | ||
|
|
81108e7653 | ||
|
|
c3fbec73fb | ||
|
|
8d3b0497a4 | ||
|
|
778041f8d1 | ||
|
|
b9e4ce99d8 | ||
|
|
ed4492a697 | ||
|
|
7b0241579c | ||
|
|
6fc92a506a | ||
|
|
4cdc607f72 | ||
|
|
bc4c030023 | ||
|
|
044228d5ec | ||
|
|
51ded05b3b | ||
|
|
a868ec89e8 | ||
|
|
58a5bd187d | ||
|
|
06ef16563b | ||
|
|
ccd65c9be6 | ||
|
|
3d46224b78 | ||
|
|
cfeb08a193 | ||
|
|
5e66a26eaa | ||
|
|
26a0d9a945 | ||
|
|
b028e08d35 | ||
|
|
7467c8d3b6 | ||
|
|
f69bfc76fa | ||
|
|
ab6526c8b3 | ||
|
|
3e94f729a5 | ||
|
|
c127008840 | ||
|
|
481d19b38e | ||
|
|
daf0b78e1a | ||
|
|
93febe672a | ||
|
|
c59fa37d40 | ||
|
|
248c57ca43 | ||
|
|
59e50f634a | ||
|
|
8c145dc31b | ||
|
|
55522080c6 | ||
|
|
5c58d283bb | ||
|
|
91b84603d3 | ||
|
|
2a46634617 | ||
|
|
5710f9f690 | ||
|
|
654944fc36 | ||
|
|
c3d2f1287e | ||
|
|
6199fa90e5 | ||
|
|
6248355c6f | ||
|
|
5a4a46a251 | ||
|
|
f52947ba71 | ||
|
|
aa64ba459f | ||
|
|
ceece81414 | ||
|
|
d0e5f86a10 | ||
|
|
d0b4d3dabf | ||
|
|
7b2dfc623b |
No files matched your search
+2
-1
@@ -1,4 +1,5 @@
|
||||
busybox
|
||||
busybox.links
|
||||
_install
|
||||
applet_source_list
|
||||
.config
|
||||
.menuconfig.log
|
||||
@@ -8,7 +8,7 @@ incorect, _please_ let me know.
|
||||
|
||||
-----------
|
||||
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
Erik Andersen <andersen@codepoet.org>, <andersee@debian.org>
|
||||
Tons of new stuff, major rewrite of most of the
|
||||
core apps, tons of new apps as noted in header files.
|
||||
|
||||
@@ -28,9 +28,17 @@ Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
|
||||
Magnus Damm <damm@opensource.se>
|
||||
tftp client
|
||||
insmod powerpc support
|
||||
|
||||
Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
pristine source directory compilation, lots of patches and fixes.
|
||||
|
||||
Gennady Feldman <gfeldman@cachier.com>
|
||||
Sysklogd (single threaded syslogd, IPC Circular buffer support,
|
||||
logread), various fixes.
|
||||
|
||||
Karl M. Hegbloom <karlheg@debian.org>
|
||||
cp_mv.c, the test suite, various fixes to utility.c, &c.
|
||||
|
||||
@@ -38,17 +46,24 @@ Daniel Jacobowitz <dan@debian.org>
|
||||
mktemp.c
|
||||
|
||||
Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
documentation, bugfixes
|
||||
documentation, bugfixes, test suite
|
||||
|
||||
John Lombardo <john@deltanet.com>
|
||||
dirname, tr
|
||||
|
||||
Glenn McGrath <bug1@netconnect.com.au>
|
||||
ar.c
|
||||
Glenn McGrath <bug1@optushome.com.au>
|
||||
ar, dpkg, dpkg-deb
|
||||
|
||||
Vladimir Oleynik <dzo@simtreas.ru>
|
||||
cmdedit; ports: ash, stty, traceroute; locale, various fixes
|
||||
and irreconcilable critic of everything not perfect.
|
||||
|
||||
Bruce Perens <bruce@pixar.com>
|
||||
Original author of BusyBox. His code is still in many apps.
|
||||
|
||||
Tim Riker <Tim@Rikers.org>
|
||||
bug fixes, member of fan club
|
||||
|
||||
Kent Robotti <robotti@metconnect.com>
|
||||
reset, tons and tons of bug reports and patchs.
|
||||
|
||||
@@ -73,9 +88,6 @@ Charles P. Wright <cpwright@villagenet.com>
|
||||
Enrique Zanardi <ezanardi@ull.es>
|
||||
tarcat (since removed), loadkmap, various fixes, Debian maintenance
|
||||
|
||||
Vladimir Oleynik <dzo@simtreas.ru>
|
||||
cmdedit, stty-port, locale, various fixes
|
||||
and irreconcilable critic of everything not perfect.
|
||||
Emanuele Aina <emanuele.aina@tiscali.it>
|
||||
run-parts
|
||||
|
||||
Tim Riker <Tim@Rikers.org>
|
||||
bug fixes, member of fan club
|
||||
@@ -1,3 +1,184 @@
|
||||
0.61.pre
|
||||
|
||||
Development Version
|
||||
|
||||
|
||||
|
||||
New Applets:
|
||||
* Erik Andersen -- Merged several applets from tinylogin,
|
||||
namely adduser, addgroup, deluser, delgroup, getty.
|
||||
|
||||
|
||||
Other Changes:
|
||||
|
||||
* Vladimir Oleynik, Manuel Novoa III, Aaron Lehmann
|
||||
-- a whole bunch of ash size optimizations
|
||||
-- Fix for ash leading redirections (i.e. '2>/dev/null ls rubbish')
|
||||
* Rodney Brown <RDBrown@mira.net>
|
||||
-- Optimized gzip.c, shrinking it be ~1.5k
|
||||
* Matt Kraai
|
||||
-- Fix sed s/[/]// handling (closes: #1208).
|
||||
-- Fix `-/bin/sh' invocation (closes: #1209).
|
||||
-- Fix ash exec (noted by Arne Bernin).
|
||||
-- Fix tar segfault when include list is empty and exclude list is
|
||||
not.
|
||||
-- Fix sed s/$/@/ handling (noted by Joshua Hudson).
|
||||
-- Fix opt type in dpkg (closes: #118975).
|
||||
* Magick
|
||||
-- made init run inittab command's in the order they show up
|
||||
in the inittab file (FIFO instead of LIFO).
|
||||
* Vladimir Oleynik
|
||||
-- reverse resolve network name and cache in route and ifconfig
|
||||
applets, fix print nslookup server name if compile without
|
||||
uClibc, fix route crashe 'route add', fix warnings compile
|
||||
networking and pwd_grp applets
|
||||
|
||||
-Erik Andersen, --not yet released--
|
||||
|
||||
|
||||
|
||||
0.60.1
|
||||
|
||||
Stable Release
|
||||
|
||||
|
||||
New Applets & New Features:
|
||||
none. :)
|
||||
|
||||
Known Problems (to be fixed in 0.60.2)
|
||||
* msh can segfault on constructs such as
|
||||
for i in `ls *.c` ; do echo $i ; done
|
||||
due to a memory allocation problem. This only seems to cause
|
||||
problems when the backtick expands to be several k in size.
|
||||
|
||||
|
||||
Bugfixes:
|
||||
* Matt Kraai
|
||||
-- Fixed msh to support underscores in variable names.
|
||||
-- Fixed a sed problem with unsatisfied backrefs (the problem was
|
||||
noted by Martin Bene).
|
||||
-- Removed CONFIG_SH define entirely. Now one simply picks the shell
|
||||
or shells they want as CONFIG_<foo> in Config.h
|
||||
-- Fixed head to use ferror(3) to check for errors, not errno.
|
||||
* Shu-Hao Chang <shuhao_chang@trend.com.tw>
|
||||
-- Fixed sed handling of multiple -e commands
|
||||
* Magick <magick@linux-fan.com>
|
||||
-- Fixed an init bug with AskFirst and /dev/null
|
||||
* Jaspreet Singh <jsingh@somanetworks.com>
|
||||
-- Fixed both a segfault and cosmetic bug in route
|
||||
* Erik Andersen
|
||||
-- Made the insmod options CONFIG_FEATURE_NEW_MODULE_INTERFACE and
|
||||
CONFIG_FEATURE_OLD_MODULE_INTERFACE mutually exclusive
|
||||
-- xgetcwd.c now includes sys/param.h to ensure PATH_MAX is defined
|
||||
-- Fixed a potential segfault with lash + CONFIG_FEATURE_CLEAN_UP
|
||||
-- Removed uint64_t from dos2unix, avoiding C lib compat. problems.
|
||||
* Glenn McGrath
|
||||
-- Rewrite of tftp (commands match atftp, accepts -b, can use
|
||||
non-standard ports, and is smaller).
|
||||
-- Fixed unarchive exclude list handling
|
||||
* Manuel Novoa III
|
||||
-- rewrite of simplify_path so it behaves itself (fixing some
|
||||
problems with mount and other applets).
|
||||
-- Fixed ifconfig 'broadcast +' handling and disabled it by default
|
||||
* Matthias ? <matthias@corelatus.com>
|
||||
-- Fixed syslogd to log all messages from a single connection, not
|
||||
just the first.
|
||||
|
||||
|
||||
-Erik Andersen, 23 August 2001
|
||||
|
||||
|
||||
0.60.0
|
||||
|
||||
Note:
|
||||
|
||||
For this release I have bumped the version number to 0.60.0. This
|
||||
reflects the fact that this release is intended to form a new stable
|
||||
BusyBox release series. If you need to rely on a stable version of
|
||||
BusyBox, you should plan on using the stable 0.60.x series. If bugs
|
||||
show up then I will release 0.60.1, then 0.60.2, etc... This is also
|
||||
intended to deal with the fact that the BusyBox build system will be
|
||||
getting a major overhaul for the next release and I don't want that to
|
||||
break products that people are shipping. To avoid that, the new build
|
||||
system will be released as part of a new BusyBox development series
|
||||
that will have some not-yet-decided-on odd version number. Once things
|
||||
stabablize and the new build system is working for everyone, then I
|
||||
will release that as a new stable release series.
|
||||
|
||||
Critical Bugfixes:
|
||||
* Matt Kraai
|
||||
-- Fixed wget output file opening (wget failed in 0.52).
|
||||
-- Fixed a memory leak in syslogd (found by Adam Slattery).
|
||||
* Vladimir Oleynik, Matt Kraai, Erik Andersen
|
||||
-- several nasty bugs in ash and msh. msh could not assign
|
||||
any variables and had debug code still enabled. ash
|
||||
had several compile errors (depending on selected options)
|
||||
and variable assignment problems as well.
|
||||
|
||||
New Applets:
|
||||
* David McCullough <davidm@lineo.com> -- modprobe
|
||||
* Vladimir Oleynik -- traceroute
|
||||
* Erik Andersen -- pidof
|
||||
|
||||
New Scripts:
|
||||
* David Schleef, Erik Andersen, Stuart Hughes -- depmod.pl
|
||||
This is a replacement for the depmod program from the modutils
|
||||
package, but is fully cross platform and is designed to run on
|
||||
your host system (not on the target).
|
||||
|
||||
Other Changes:
|
||||
* Erik Andersen
|
||||
-- fixed busybox.spec so it should now work on redhat systems
|
||||
-- fixed dos2unix and unix2dos so they should work once again
|
||||
-- Adjustments to make busybox more uClinux friendly. Busybox
|
||||
should now work on uClinux systems without needing and source
|
||||
code changes (applets that won't work on uClinux systems are
|
||||
now automagicaly disabled).
|
||||
-- various things (cleanups, libc compatibility work, etc, etc)
|
||||
* Jim Gleason <jimg@lineo.com>
|
||||
-- Fixed for sed, where it failed to preserve whether or not the
|
||||
line was previously altered when running a subst command.
|
||||
* Matt Kraai
|
||||
-- Made tar read 20 512byte blocks at a time (like GNU tar)
|
||||
-- Allow msh.c assignments with the export and readonly commands.
|
||||
-- Added CONFIG_FEATURE_DEVFS to enable devfs device names.
|
||||
-- Better devfs support
|
||||
-- Don't save/restore vi readonly flag if vi is compiled read-only.
|
||||
-- Reworked rdate option handling (is now smaller).
|
||||
-- Size reduction in ping
|
||||
-- Always write dd counts to stderr
|
||||
-- Allow multiple shells to be enabled
|
||||
* Aaron Lehmann
|
||||
-- slimmed down md5sum
|
||||
-- contributed a nice new (hand written, not lex/yacc) Posix math
|
||||
support for ash, which is once again a full posix shell.
|
||||
* Felix von Leitner <leitner@convergence.de> -- patches to make busybox
|
||||
work with dietlibc.
|
||||
* David McCullough
|
||||
-- Adjustments to make busybox more uClinux friendly
|
||||
* Glenn McGrath
|
||||
-- Fixed gzip so when a filename is '-' it will use stdin/stdout
|
||||
-- dpkg rewrite. Should now be compatable with the real dpkg,
|
||||
but needs more testing.
|
||||
-- Updates to archiving tools (gunzip/gzip/cpio/ar/etc)
|
||||
-- Rewrote uuencode, will allow base64 encoding to be used by wget
|
||||
* Vladimir Oleynik
|
||||
-- Fixed tr to support 'tr a-z A-Z' syntax,
|
||||
-- Many ash corrections, optimizations, and cleanups.
|
||||
-- optimizations for traceroute, md5sum, chown, ping
|
||||
-- cmdedit updates and API change
|
||||
-- Namespace cleanup (i.e. adding 'static' private function calls)
|
||||
-- added "stopped jobs" warning to ash on exit
|
||||
* Adam Slattery
|
||||
-- Fixed ping compile problem
|
||||
* Robert J. Osborne <rj@resourceinternational.com>
|
||||
-- fixed a vi bug with delete and escape sequences on empty files.
|
||||
|
||||
|
||||
-Erik Andersen, 31 July 2001
|
||||
|
||||
|
||||
|
||||
0.52
|
||||
|
||||
Critical Bugfixes:
|
||||
@@ -141,7 +322,7 @@
|
||||
* Magnus Damm -- added a tftp applet
|
||||
* Magnus Damm -- powerpc support for busybox insmod.
|
||||
* David Douthitt -- fixed a build error in df.c when
|
||||
BB_FEATURE_HUMAN_READABLE was disabled
|
||||
CONFIG_FEATURE_HUMAN_READABLE was disabled
|
||||
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
|
||||
generate the documentation from the source code, making life
|
||||
much simpler for all.
|
||||
@@ -248,7 +429,7 @@
|
||||
* Mark Whitley -- Updates to style guide
|
||||
* Mark Whitley -- Big cleanup in utility.c: style guide compliance,
|
||||
de-macro-ifying some variables and functions
|
||||
* Erik Andersen -- ls now honors BB_FEATURE_AUTOWIDTH so it can find
|
||||
* Erik Andersen -- ls now honors CONFIG_FEATURE_AUTOWIDTH so it can find
|
||||
the width and height of the console.
|
||||
* Erik Andersen -- insmod now ignores -L and accepts the -o option.
|
||||
* Erik Andersen -- updates so you can now select from the Makefile
|
||||
@@ -264,7 +445,7 @@
|
||||
0.48
|
||||
|
||||
* Glenn McGrath -- tar now supports uncompressing tar files,
|
||||
define BB_FEATURE_TAR_GZIP to use the -z option.
|
||||
define CONFIG_FEATURE_TAR_GZIP to use the -z option.
|
||||
* Matt Kraai -- fix all usage of TRUE and FALSE so all apps now
|
||||
return EXIT_SUCCESS or EXIT_FAILURE to the system.
|
||||
Now TRUE and FALSE are set to the C standard where TRUE=1.
|
||||
@@ -296,7 +477,7 @@
|
||||
GNU-date compatible
|
||||
* me -- Progress meter (optional) in wget
|
||||
* Doolittle/me -- programs invoked by full path name take
|
||||
precedence over applets unless BB_FEATURE_SH_BUILTINS_ALWAYS_WIN
|
||||
precedence over applets unless CONFIG_FEATURE_SH_BUILTINS_ALWAYS_WIN
|
||||
* Gaute B Strokkenes <gs234@cam.ac.uk> -- applets found using a
|
||||
binary search instead of linear search. Much faster!
|
||||
* new applets: cmp readlink
|
||||
@@ -429,7 +610,7 @@
|
||||
0.45
|
||||
* Now compiles vs libc5 (which can save lots of space for
|
||||
embedded systems).
|
||||
* Added BB_FEATURE_TRIVIAL_HELP which compiles out most all of the
|
||||
* Added CONFIG_FEATURE_TRIVIAL_HELP which compiles out most all of the
|
||||
help messages (i.e --help). Saves 17k over a full compile.
|
||||
* Added cut and tr from minix, since due to the license change,
|
||||
we can now use minix code. Minix tr saves 4k.
|
||||
@@ -450,7 +631,7 @@
|
||||
* Replaced the telnet implementation with one written by
|
||||
Tomi Ollila <too@iki.fi> It works great and costs 3k.
|
||||
* BusyBox sh (lash) now supports being used as a standalone shell. When
|
||||
BB_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
|
||||
CONFIG_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
|
||||
be invoked as shell internals. Best used when compiling staticly
|
||||
(i.e. DOSTATIC=true)
|
||||
* BusyBox sh (lash) internals now behave as expected wrt pipes
|
||||
@@ -502,7 +683,7 @@
|
||||
* Fixed exit status for killall - Pavel Roskin
|
||||
* Fixed 'swapon -a' and 'swapoff -a', which were broken.
|
||||
* Fixed 'mount -a' so it works as expected.
|
||||
* Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE)
|
||||
* Implemented 'ls -R' (enabled by enabling CONFIG_FEATURE_LS_RECURSIVE)
|
||||
* Implemented "ping -s", fixed error messages and argument parsing -
|
||||
Pavel Roskin
|
||||
* Syslogd will not go to background if "-n" is given. Better help
|
||||
@@ -540,7 +721,7 @@
|
||||
saving a bunch of memory (kernel /proc support is not thin). This
|
||||
is done by making use of some nice kernel patches I wrote up to
|
||||
support the features that busybox requires and that /proc usually
|
||||
provides. To enable this, turn on BB_FEATURE_USE_DEVPS_PATCH and
|
||||
provides. To enable this, turn on CONFIG_FEATURE_USE_DEVPS_PATCH and
|
||||
patch your kernel with the devps patch in the kernel-patches/
|
||||
directory.
|
||||
* Wrote basename, dirname, killall, and uptime.
|
||||
@@ -585,7 +766,7 @@
|
||||
* An initial telnet implementation was added by
|
||||
Randolph Chung <tausq@debian.org>.
|
||||
* Fixed a bug where "sed 's/foo/bar/g'" (i.e. a script w/o a "-e")
|
||||
* ps now supports BB_FEATURE_AUTOWIDTH, and can adjust its width
|
||||
* ps now supports CONFIG_FEATURE_AUTOWIDTH, and can adjust its width
|
||||
to match the terminal (defaults to width=79 when this is off).
|
||||
* ps now accepts (and ignores) all options except for "--help" (which
|
||||
as would be expected displays help).
|
||||
@@ -608,7 +789,7 @@
|
||||
|
||||
* Fairly massive restructuring of umount.c to deal with remounting
|
||||
busy devices read-only. Adds a -r option to control that; it is
|
||||
optionally compiled in with BB_FEATURE_REMOUNT
|
||||
optionally compiled in with CONFIG_FEATURE_REMOUNT
|
||||
* Added a bunch of functions to mtab.c to interact with the
|
||||
{get,set,end}mntent interface; as it turns out, those functions do
|
||||
not appear to be re-entrant, and that causes a lot of problems with
|
||||
@@ -679,7 +860,7 @@
|
||||
* Created a tiny tail implementation, removing -c, -q, -v, and making
|
||||
tail -f work only with a single file. This reduced tail from 6k to
|
||||
2.4k. The bigger/more featured tail can still be had by disabling
|
||||
BB_FEATURE_SIMPLE_TAIL in busybox.defs.h
|
||||
CONFIG_FEATURE_SIMPLE_TAIL in busybox.defs.h
|
||||
* Ping now falls back to doing the right thing if /etc/protocols
|
||||
turns up missing.
|
||||
* Fixed mount and umount. Previously they could leak loop device
|
||||
@@ -731,14 +912,14 @@
|
||||
devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins
|
||||
<bcollins@debian.org>
|
||||
* Several fixes from Marco Pantaleoni <panta@prosa.it> compile in
|
||||
* fullWrite() not only if BB_TAR is defined, but also
|
||||
if BB_CP or BB_MV are (fullWrite() is referenced by copyFile())
|
||||
* fullWrite() not only if CONFIG_TAR is defined, but also
|
||||
if CONFIG_CP or CONFIG_MV are (fullWrite() is referenced by copyFile())
|
||||
* add some compiler optimizations to further reduce executable size
|
||||
(as a side note, on my machines the largest code is generated
|
||||
by gcc 2.95.2 with -Os ! The smallest by plain gcc 2.7.2.3 with
|
||||
-O2 -m386 ...)
|
||||
* Compile now won't fail if busybox.def.h defines
|
||||
BB_FEATURE_LINUXRC but not BB_INIT. (init_main used to be
|
||||
CONFIG_FEATURE_INITRD but not CONFIG_INIT. (init_main used to be
|
||||
referenced, but not compiled)
|
||||
* Fixed a bug in setting TERM for serial console support. TERM now
|
||||
defaults to "ansi" for serial consoles.
|
||||
@@ -798,7 +979,7 @@
|
||||
to suit my evil purposes. Costs 6k. I'll make it smaller
|
||||
sometime.
|
||||
* on reboot, init called 'umount -a -n', which caused errors
|
||||
when BB_MTAB was not enabled. Changed to 'umount -a', which does
|
||||
when CONFIG_MTAB was not enabled. Changed to 'umount -a', which does
|
||||
the right thing.
|
||||
* init will now try to run /sbin/getty if it is present (for easy
|
||||
integration with the about-to-be-released tinylogin.)
|
||||
@@ -833,7 +1014,7 @@
|
||||
* I've taken a first step to making busybox not need the /proc
|
||||
filesystem. Most apps don't need it. Those that _require_ it,
|
||||
will complain if you enable them when you disable
|
||||
BB_FEATURE_USE_PROCFS.
|
||||
CONFIG_FEATURE_USE_PROCFS.
|
||||
|
||||
-Erik Andersen, Dec 5, 1999
|
||||
|
||||
@@ -871,7 +1052,7 @@
|
||||
* from
|
||||
Eric Delaunay).
|
||||
* Made createPath be quiet (again thanks to Eric Delaunay). If
|
||||
* BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
|
||||
* CONFIG_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
|
||||
command you define it as will be run if the init script exits.
|
||||
* Updated install.sh to make it more robust (thanks to Adam Di Carlo)
|
||||
* NFS support added to mount by Eric Delaunay. It costs 10k when
|
||||
@@ -927,7 +1108,7 @@
|
||||
to Eric Delaunay.
|
||||
* more started to read from stdin after the last file was finished, and
|
||||
options were not parsed correctly (fix thanks to Eric Delaunay).
|
||||
* more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on.
|
||||
* more will now use the terminal size if CONFIG_FEATURE_AUTOWIDTH is on.
|
||||
* rm wouldn't remove a symlink unless the symlink was valid. This was
|
||||
a side effect of the busybox 0.32 recursiveAction() fix. Things
|
||||
should now work correctly.
|
||||
@@ -945,7 +1126,7 @@
|
||||
* Removed some debugging noise from init.c
|
||||
* Fixed ln so it works now (it was very broken).
|
||||
* Fixed df so it won't segfault when there is no /etc/fstab,
|
||||
* If BB_MTAB is not defined, df and mount will whine if /etc/fstab
|
||||
* If CONFIG_MTAB is not defined, df and mount will whine if /etc/fstab
|
||||
is not installed (since they cannot fixup "/dev/root" to
|
||||
state the real root device name)
|
||||
* merged some redundant code from mtab.c/df.c into utility.c
|
||||
@@ -953,9 +1134,8 @@
|
||||
-Erik Andersen, Nov 5, 1999
|
||||
|
||||
0.32
|
||||
* More changes -- many thanks to Lineo for paying me to work on
|
||||
busybox. If you have any problems please let me know ASAP at
|
||||
andersen@lineo.com or andersee@debian.org
|
||||
* More changes -- If you have any problems please let me know ASAP at
|
||||
andersee@debian.org
|
||||
* usage() now prints the BusyBox version. This will help folks
|
||||
realize that they are not in Kansas anymore.
|
||||
* Fixed mkdir -m option so that it works. kill segfaulted w/o any
|
||||
@@ -966,11 +1146,11 @@
|
||||
* with full regular expressions!). Fixed a stupid seg-fault in sync
|
||||
* Fixed mount -- mount -a failed to parse and apply mount options Fixed
|
||||
* umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>)
|
||||
* umount -a no longer umounts /proc Added BB_MTAB, allowing (at the
|
||||
* umount -a no longer umounts /proc Added CONFIG_MTAB, allowing (at the
|
||||
* cost of ~1.5k and the need for a rw /etc)
|
||||
folks to use a real /etc/mtab file instead of a symlink to
|
||||
/proc/mounts. mount, and umount will add/remove entries and df
|
||||
will now use /etc/mtab if BB_MTAB is defined.
|
||||
will now use /etc/mtab if CONFIG_MTAB is defined.
|
||||
* Fixed a nice bug in recursiveAction() which caused it to infinitely
|
||||
hunt through /proc/../fd/* creating new file descriptors if it
|
||||
followed the /dev/fd link over to /proc. recursiveAction() now
|
||||
@@ -997,10 +1177,9 @@
|
||||
-Erik Andersen, Oct 21, 1999
|
||||
|
||||
0.30
|
||||
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
|
||||
paying me to make these updates. If you have any problems with busybox,
|
||||
or notice any bugs -- please let me know so I can fix it. These
|
||||
changes include:
|
||||
Major changes -- lots of stuff rewritten. If you have any problems
|
||||
with busybox, or notice any bugs -- please let me know so I can fix
|
||||
it. These changes include:
|
||||
|
||||
Core Changes:
|
||||
* busybox can now invoke apps in two ways: via symlinks to the
|
||||
|
||||
@@ -1,484 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e., //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
//#define BB_ADJTIMEX
|
||||
//#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHGRP
|
||||
#define BB_CHMOD
|
||||
#define BB_CHOWN
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
//#define BB_CMP
|
||||
#define BB_CP
|
||||
//#define BB_CPIO
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
//#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
//#define BB_DOS2UNIX
|
||||
//#define BB_DPKG
|
||||
//#define BB_DPKG_DEB
|
||||
//#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
#define BB_ENV
|
||||
//#define BB_EXPR
|
||||
//#define BB_FBSET
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
//#define BB_FREERAMDISK
|
||||
//#define BB_FSCK_MINIX
|
||||
//#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
//#define BB_HOSTID
|
||||
//#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_IFCONFIG
|
||||
#define BB_INIT
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_KLOGD
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM
|
||||
//#define BB_LOADFONT
|
||||
//#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
//#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
//#define BB_MKFIFO
|
||||
//#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
//#define BB_MKTEMP
|
||||
//#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
//#define BB_MT
|
||||
#define BB_MV
|
||||
//#define BB_NSLOOKUP
|
||||
//#define BB_PING
|
||||
//#define BB_PIVOT_ROOT
|
||||
#define BB_POWEROFF
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
//#define BB_RDATE
|
||||
//#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
//#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD
|
||||
//#define BB_ROUTE
|
||||
//#define BB_RPM2CPIO
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_STTY
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
//#define BB_TEE
|
||||
//#define BB_TEST
|
||||
//#define BB_TELNET
|
||||
//#define BB_TFTP
|
||||
#define BB_TOUCH
|
||||
//#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UNIX2DOS
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
//#define BB_UPDATE
|
||||
#define BB_UPTIME
|
||||
//#define BB_USLEEP
|
||||
//#define BB_VI
|
||||
//#define BB_WATCHDOG
|
||||
#define BB_WC
|
||||
//#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
// If you enabled BB_SH above, you may select one of the following shells.
|
||||
// You can only select ONE of the following shells. Sorry.
|
||||
//
|
||||
// lash is the very smallest shell (adds just 10k) and it is quite usable as
|
||||
// a command prompt, but it is not suitable for any but the most trivial
|
||||
// scripting (such as an initrd that calls insmod a few times) since it does
|
||||
// not understand Bourne shell grammer. It does handle pipes, redirects, and
|
||||
// job control though. Adding in command editing makes it very nice
|
||||
// lightweight command prompt.
|
||||
//#define BB_FEATURE_LASH
|
||||
//
|
||||
// hush is also quite small (just 18k) and it has very complete Bourne shell
|
||||
// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
|
||||
// like for/do/done or case/esac and such. It also currently has a problem
|
||||
// with job control.
|
||||
//#define BB_FEATURE_HUSH
|
||||
//
|
||||
// msh: The minix shell (adds just 30k) is quite complete and handles things
|
||||
// like for/do/done, case/esac and all the things you expect a Bourne shell to
|
||||
// do. It is not always pedantically correct about Bourne shell grammer (try
|
||||
// running the shell testscript "tests/sh.testcases" on it and compare vs bash)
|
||||
// but for most things it works quite well. It also uses only vfork, so it can
|
||||
// be used on uClinux systems. This was only recently added, so there is still
|
||||
// room to shrink it further...
|
||||
#define BB_FEATURE_MSH
|
||||
//
|
||||
// ash: This adds about 60k in the default configuration and is the most
|
||||
// complete and most pedantically correct shell included with busybox. This
|
||||
// shell was also recently added, and several people (mainly Vladimir and Erik)
|
||||
// have been working on it. There are a number of configurable things at the
|
||||
// top of ash.c as well, so check those out if you want to tweak things. The
|
||||
// Posix math support is currently disabled (that bit of code was horrible) but
|
||||
// will be restored for the next BusyBox release.
|
||||
//#define BB_FEATURE_ASH
|
||||
//
|
||||
// BusyBox will, by default, malloc space for its buffers. This costs code
|
||||
// size for the call to xmalloc. You can use the following feature to have
|
||||
// them put on the stack. For some very small machines with limited stack
|
||||
// space, this can be deadly. For most folks, this works just fine...
|
||||
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
// The third alternative for buffer allocation is to use BSS. This works
|
||||
// beautifully for computers with a real MMU (and OS support), but wastes
|
||||
// runtime RAM for uCLinux. This behavior was the only one available for
|
||||
// BusyBox versions 0.48 and earlier.
|
||||
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. NOTE: If you enable this
|
||||
// feature, you _must_ have patched the kernel to include the devps patch that
|
||||
// is included in the busybox/kernel-patches directory. You will also need to
|
||||
// create some device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// show verbose usage messages
|
||||
//#define BB_FEATURE_VERBOSE_USAGE
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
//#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// enable ls -L
|
||||
#define BB_FEATURE_LS_FOLLOWLINKS
|
||||
//
|
||||
// Disable for a smaller (but less functional) ping
|
||||
#define BB_FEATURE_FANCY_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
// enable syslogd -C
|
||||
//#define BB_FEATURE_IPC_SYSLOG
|
||||
//
|
||||
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
|
||||
#define BB_FEATURE_FANCY_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may need to mount with "-o nolock" if you are
|
||||
// not running a local portmapper daemon...
|
||||
//#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e., in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" and "-X" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable uniqe sort
|
||||
#define BB_FEATURE_SORT_UNIQUE
|
||||
//
|
||||
// Enable command line editing in the shell.
|
||||
// Only relevant if BB_SH is enabled. On by default.
|
||||
#define BB_FEATURE_COMMAND_EDITING
|
||||
//
|
||||
// Enable tab completion in the shell. This is now working quite nicely.
|
||||
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
//
|
||||
// Attempts to match usernames in a ~-prefixed path
|
||||
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things. Off by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
//#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
//names. This causes applets (i.e., most busybox commands) to override
|
||||
//real commands on the filesystem. For example, if you run run /bin/cat, it
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
// Only relevant if BB_SH is enabled. Off by default.
|
||||
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Uncomment this option for a fancy shell prompt that includes the
|
||||
// current username and hostname. On systems that don't have usernames
|
||||
// or hostnames, this can look hideous.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
//#define BB_FEATURE_SH_FANCY_PROMPT
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// Support insmod/lsmod/rmmod for post 2.1 kernels
|
||||
//#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
//
|
||||
// Support insmod/lsmod/rmmod for pre 2.1 kernels
|
||||
//#define BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for uClinux memory usage optimization, which will load the image
|
||||
// directly into the kernel memory. This divides memory requrements by three.
|
||||
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
|
||||
// disabled...
|
||||
//#define BB_FEATURE_INSMOD_LOADINKMEM
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
// Enable ifconfig status reporting output -- this feature adds 12k.
|
||||
//#define BB_FEATURE_IFCONFIG_STATUS
|
||||
//
|
||||
// Enable ifconfig slip-specific options "keepalive" and "outfill"
|
||||
//#define BB_FEATURE_IFCONFIG_SLIP
|
||||
//
|
||||
// Enable ifconfig options "mem_start", "io_addr", and "irq".
|
||||
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
|
||||
//
|
||||
// Enable ifconfig option "hw". Currently works for only with "ether".
|
||||
//#define BB_FEATURE_IFCONFIG_HW
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
//#define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
#define BB_FEATURE_WGET_STATUSBAR
|
||||
//
|
||||
// Enable HTTP authentication in wget
|
||||
#define BB_FEATURE_WGET_AUTHENTICATION
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
|
||||
#define BB_FEATURE_HUMAN_READABLE
|
||||
//
|
||||
// Support for the find -type option.
|
||||
#define BB_FEATURE_FIND_TYPE
|
||||
//
|
||||
// Support for the find -perm option.
|
||||
#define BB_FEATURE_FIND_PERM
|
||||
//
|
||||
// Support for the find -mtine option.
|
||||
#define BB_FEATURE_FIND_MTIME
|
||||
//
|
||||
// Support for the -A -B and -C context flags in grep
|
||||
//#define BB_FEATURE_GREP_CONTEXT
|
||||
//
|
||||
// Support for the EGREP applet (alias to the grep applet)
|
||||
//#define BB_FEATURE_GREP_EGREP_ALIAS
|
||||
//
|
||||
// Tell tftp what commands that should be supported.
|
||||
#define BB_FEATURE_TFTP_PUT
|
||||
#define BB_FEATURE_TFTP_GET
|
||||
//
|
||||
// features for vi
|
||||
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
|
||||
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
|
||||
#define BB_FEATURE_VI_SEARCH // search and replace cmds
|
||||
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
|
||||
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
|
||||
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
|
||||
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
|
||||
#define BB_FEATURE_VI_SET // :set
|
||||
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
|
||||
//
|
||||
// Enable a if you system have setuped locale
|
||||
//#define BB_LOCALE_SUPPORT
|
||||
//
|
||||
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
|
||||
#define BB_FEATURE_TELNET_TTYPE
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#undef BB_FEATURE_SH_FANCY_PROMPT
|
||||
#endif
|
||||
#if ! defined BB_FEATURE_LASH && ! defined BB_FEATURE_HUSH && ! defined BB_FEATURE_MSH && ! defined BB_FEATURE_ASH
|
||||
#define BB_FEATURE_MSH
|
||||
#endif
|
||||
#if defined BB_FEATURE_ASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_LASH
|
||||
#undef BB_FEATURE_HUSH
|
||||
#undef BB_FEATURE_MSH
|
||||
#elif defined BB_FEATURE_MSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_LASH
|
||||
#undef BB_FEATURE_HUSH
|
||||
#undef BB_FEATURE_ASH
|
||||
#elif defined BB_FEATURE_HUSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_LASH
|
||||
#undef BB_FEATURE_MSH
|
||||
#undef BB_FEATURE_ASH
|
||||
#elif defined BB_FEATURE_LASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_HUSH
|
||||
#undef BB_FEATURE_MSH
|
||||
#undef BB_FEATURE_ASH
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_FANCY_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,8 +1,13 @@
|
||||
1) Check Config.h and adjust if you need a different functionality than
|
||||
defined by default.
|
||||
1) Run 'make config' or 'make menuconfig' and select the
|
||||
functionality that you wish to enable.
|
||||
|
||||
2) Check the Makefile
|
||||
2) make dep
|
||||
|
||||
3) make
|
||||
3) Check the Makefile for any Makefile setting you wish
|
||||
to adjust for your system (things like like setting
|
||||
your cross compiler, adjusting optimizations, etc)
|
||||
|
||||
4) make install
|
||||
4) make
|
||||
|
||||
5) Run 'make install' or 'make PREFIX=/target install' to
|
||||
install busybox and all the needed links.
|
||||
@@ -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>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -18,14 +18,21 @@
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.52
|
||||
VERSION := 0.61.pre
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
export VERSION
|
||||
TOPDIR := ${shell /bin/pwd}
|
||||
HOSTCC := gcc
|
||||
HOSTCFLAGS:= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
|
||||
|
||||
|
||||
# What OS are you compiling busybox for? This allows you to include
|
||||
# OS specific things, syscall overrides, etc.
|
||||
TARGET_OS := linux
|
||||
|
||||
# With a modern GNU make(1) (highly recommended, that's what all the
|
||||
# developers use), all of the following configuration values can be
|
||||
# overridden at the command line. For example:
|
||||
# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
|
||||
# make CROSS=powerpc-linux- CONFIG_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
|
||||
|
||||
# If you want to add some simple compiler switches (like -march=i686),
|
||||
# especially from the command line, use this instead of CFLAGS directly.
|
||||
@@ -39,18 +46,6 @@ DOSTATIC = false
|
||||
# Leave this set to `false' for production use.
|
||||
DODEBUG = false
|
||||
|
||||
# Setting this to `true' will cause busybox to directly use the system's
|
||||
# password and group functions. Assuming you use GNU libc, when this is
|
||||
# `true', you will need to install the /etc/nsswitch.conf configuration file
|
||||
# and the required libnss_* libraries. This generally makes your embedded
|
||||
# system quite a bit larger... If you leave this off, busybox will directly use
|
||||
# the /etc/password, /etc/group files (and your system will be smaller, and I
|
||||
# will get fewer emails asking about how glibc NSS works). Enabling this adds
|
||||
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs).
|
||||
# Note that if you want hostname resolution to work with glibc, you still need
|
||||
# the libnss_* libraries. Most people will want to leave this set to false.
|
||||
USE_SYSTEM_PWD_GRP = true
|
||||
|
||||
# This enables compiling with dmalloc ( http://dmalloc.com/ )
|
||||
# which is an excellent public domain mem leak and malloc problem
|
||||
# detector. To enable dmalloc, before running busybox you will
|
||||
@@ -72,22 +67,28 @@ DOEFENCE = false
|
||||
# larger than 2GB!
|
||||
DOLFS = false
|
||||
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# If you have a "pristine" source directory, point CONFIG_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@opensource.lineo.com> if you do or don't like it so far.
|
||||
BB_SRC_DIR =
|
||||
CONFIG_SRC_DIR =
|
||||
|
||||
# If you are running a cross compiler, you may want to set this
|
||||
# to something more interesting, like "powerpc-linux-".
|
||||
# If you are running a cross compiler, you may want to set CROSS
|
||||
# to something more interesting, like "arm-linux-".
|
||||
CROSS =
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
STRIPTOOL = $(CROSS)strip
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
AS = $(CROSS)as
|
||||
LD = $(CROSS)ld
|
||||
NM = $(CROSS)nm
|
||||
STRIP = $(CROSS)strip
|
||||
CPP = $(CC) -E
|
||||
MAKEFILES = $(TOPDIR)/.config
|
||||
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
|
||||
|
||||
|
||||
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
|
||||
# This make things very easy? Everything should compile and work as
|
||||
# expected these days...
|
||||
#CC = ../uClibc/extra/gcc-uClibc/i386-uclibc-gcc
|
||||
# Everything should compile and work as expected these days...
|
||||
#CC = /usr/i386-linux-uclibc/usr/bin/i386-uclibc-gcc
|
||||
|
||||
# To compile vs some other alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs...
|
||||
@@ -108,11 +109,13 @@ STRIPTOOL = $(CROSS)strip
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
||||
then echo "-Os"; else echo "-O2" ; fi)
|
||||
|
||||
WARNINGS = -Wall -Wshadow
|
||||
|
||||
OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null \
|
||||
>/dev/null 2>&1; then echo "-Os"; else echo "-O2" ; fi}
|
||||
GCC_STACK_BOUNDRY := ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc /dev/null \
|
||||
>/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; else echo "" ; fi}
|
||||
OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer $(GCC_STACK_BOUNDRY)
|
||||
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
|
||||
CFLAGS = -I$(TOPDIR)/include
|
||||
ARFLAGS = -r
|
||||
|
||||
#
|
||||
@@ -126,7 +129,7 @@ ARFLAGS = -r
|
||||
|
||||
ifeq ($(strip $(DOLFS)),true)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_FILE_OFFSET_BITS=64
|
||||
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64
|
||||
endif
|
||||
ifeq ($(strip $(DODMALLOC)),true)
|
||||
# For testing mem leaks with dmalloc
|
||||
@@ -144,25 +147,14 @@ endif
|
||||
ifeq ($(strip $(DODEBUG)),true)
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIP =
|
||||
STRIPCMD =
|
||||
else
|
||||
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
|
||||
CFLAGS += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
STRIPCMD = $(STRIP) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
endif
|
||||
ifeq ($(strip $(DOSTATIC)),true)
|
||||
LDFLAGS += --static
|
||||
#
|
||||
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
|
||||
# work) to try and strip out any unused junk. Doesn't do much for me,
|
||||
# but you may want to give it a shot...
|
||||
#
|
||||
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
|
||||
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \
|
||||
# --gc-sections -v >/dev/null && echo 1),1)
|
||||
# CFLAGS += -ffunction-sections -fdata-sections
|
||||
# LDFLAGS += --gc-sections
|
||||
#endif
|
||||
endif
|
||||
|
||||
ifndef $(PREFIX)
|
||||
@@ -171,120 +163,78 @@ endif
|
||||
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Include files in the build directory should take precedence over
|
||||
# the copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# the copy in CONFIG_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
#
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
VPATH = $(BB_SRC_DIR)
|
||||
ifneq ($(strip $(CONFIG_SRC_DIR)),)
|
||||
VPATH = $(CONFIG_SRC_DIR)
|
||||
endif
|
||||
#ifneq ($(strip $(VPATH)),)
|
||||
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
|
||||
#endif
|
||||
|
||||
# We need to set APPLET_SOURCES to something like
|
||||
# $(shell busybox.sh Config.h)
|
||||
# but in a manner that works with VPATH and BB_SRC_DIR.
|
||||
# Possible ways to approach this:
|
||||
#
|
||||
# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
|
||||
# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
|
||||
#
|
||||
# 2. Explicity search through .:$(VPATH) for slist.mk,
|
||||
# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
|
||||
#
|
||||
# 3. Create slist.mk in this directory, with commands embedded in
|
||||
# a $(shell ...) command, and $(MAKE) it immediately.
|
||||
#
|
||||
# 4. Use a real rule within this makefile to create a file that sets
|
||||
# APPLET_SOURCE_LIST, then include that file. Has complications
|
||||
# with the first trip through the makefile (before processing the
|
||||
# include) trying to do too much, and a spurious warning the first
|
||||
# time make is run.
|
||||
#
|
||||
# This is option 3:
|
||||
#
|
||||
#APPLET_SOURCES = $(shell \
|
||||
# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
|
||||
# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
|
||||
#)
|
||||
# And option 4:
|
||||
-include applet_source_list
|
||||
|
||||
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
||||
CFLAGS += $(CROSS_CFLAGS)
|
||||
CFLAGS += -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
ifdef CONFIG_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(CONFIG_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
|
||||
PWD_GRP = pwd_grp
|
||||
PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
|
||||
PWD_LIB = libpwd.a
|
||||
PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
|
||||
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
|
||||
initgroups.c setgroups.c
|
||||
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
|
||||
PWD_CFLAGS = -I$(PWD_GRP_DIR)
|
||||
else
|
||||
CFLAGS += -DUSE_SYSTEM_PWD_GRP
|
||||
endif
|
||||
|
||||
LIBBB = libbb
|
||||
LIBBB_LIB = libbb.a
|
||||
LIBBB_CSRC= ask_confirmation.c chomp.c concat_path_file.c copy_file.c \
|
||||
copy_file_chunk.c daemon.c device_open.c error_msg.c \
|
||||
error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \
|
||||
find_root_device.c full_read.c full_write.c get_console.c \
|
||||
get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \
|
||||
isdirectory.c kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c \
|
||||
mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \
|
||||
my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
|
||||
print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \
|
||||
safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
|
||||
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
|
||||
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
|
||||
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
|
||||
dirname.c make_directory.c
|
||||
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
|
||||
LIBBB_CFLAGS = -I$(LIBBB)
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
LIBBB_CFLAGS += -I$(BB_SRC_DIR)/$(LIBBB)
|
||||
endif
|
||||
|
||||
LIBBB_MSRC=libbb/messages.c
|
||||
LIBBB_MESSAGES= full_version name_too_long omitting_directory not_a_directory \
|
||||
memory_exhausted invalid_date invalid_option io_error dash_dash_help \
|
||||
write_error too_few_args name_longer_than_foo unknown
|
||||
LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES))
|
||||
|
||||
LIBBB_ARCSRC=libbb/unarchive.c
|
||||
LIBBB_ARCOBJ= archive_offset seek_sub_file extract_archive unarchive \
|
||||
get_header_ar get_header_cpio get_header_tar deb_extract
|
||||
LIBBB_AROBJS=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_ARCOBJ))
|
||||
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
all: applet_source_list busybox busybox.links doc
|
||||
all: do-it-all
|
||||
|
||||
applet_source_list: busybox.sh Config.h
|
||||
(echo -n "APPLET_SOURCES := "; BB_SRC_DIR=$(BB_SRC_DIR) $(SHELL) $^) > $@
|
||||
#
|
||||
# Make "config" the default target if there is no configuration file or
|
||||
# "depend" the target if there is no top-level dependency information.
|
||||
ifeq (.config,$(wildcard .config))
|
||||
include .config
|
||||
ifeq (.depend,$(wildcard .depend))
|
||||
include .depend
|
||||
do-it-all: busybox busybox.links doc
|
||||
else
|
||||
CONFIGURATION = depend
|
||||
do-it-all: depend
|
||||
endif
|
||||
else
|
||||
CONFIGURATION = menuconfig
|
||||
do-it-all: menuconfig
|
||||
endif
|
||||
|
||||
|
||||
SUBDIRS =applets archival archival/libunarchive console-tools editors \
|
||||
fileutils findutils init miscutils modutils networking procps \
|
||||
pwd_grp shell shellutils sysklogd textutils util-linux libbb
|
||||
|
||||
bbsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
|
||||
|
||||
$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/config/MARKER
|
||||
$(MAKE) CFLAGS="$(CFLAGS)" -C $(patsubst _dir_%, %, $@)
|
||||
|
||||
busybox: config.h dep-files bbsubdirs
|
||||
$(CC) $(LDFLAGS) -o $@ applets/busybox.o $(shell find $(SUBDIRS) -name \*.a) $(LIBCONFIG_LIB) $(LIBRARIES)
|
||||
$(STRIPCMD)
|
||||
|
||||
busybox.links: applets/busybox.mkll
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
install: applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
install-hardlinks: applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
|
||||
# Documentation Targets
|
||||
doc: olddoc
|
||||
|
||||
# Old Docs...
|
||||
olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
docs/busybox.pod : docs/busybox_header.pod usage.h docs/busybox_footer.pod
|
||||
docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
|
||||
- ( cat docs/busybox_header.pod; \
|
||||
docs/autodocifier.pl usage.h; \
|
||||
docs/autodocifier.pl include/usage.h; \
|
||||
cat docs/busybox_footer.pod ) > docs/busybox.pod
|
||||
|
||||
docs/BusyBox.txt: docs/busybox.pod
|
||||
@@ -337,84 +287,103 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
# The nifty new buildsystem stuff
|
||||
scripts/mkdep: scripts/mkdep.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
|
||||
|
||||
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBBB_LIB) $(PWD_LIB) $(LIBRARIES)
|
||||
$(STRIP)
|
||||
scripts/split-include: scripts/split-include.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
|
||||
|
||||
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
|
||||
# but with VPATH, some or all of those file names are resolved to the
|
||||
# directories in which they live.
|
||||
busybox.links: busybox.mkll Config.h applets.h
|
||||
- $(SHELL) $^ >$@
|
||||
dep-files: scripts/mkdep
|
||||
@if [ ! -f .depend ] ; then \
|
||||
rm -f .depend .hdepend; \
|
||||
mkdir -p $(TOPDIR)/include/config; \
|
||||
scripts/mkdep -I $(TOPDIR)/include -- \
|
||||
`find $(TOPDIR) -name \*.c -print` >> .depend; \
|
||||
scripts/mkdep -I $(TOPDIR)/include -- \
|
||||
`find $(TOPDIR) -name \*.h -print` >> .hdepend; \
|
||||
$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ; \
|
||||
fi;
|
||||
|
||||
nfsmount.o cmdedit.o: %.o: %.h
|
||||
sh.o: cmdedit.h
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
$(CC) -I- $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
|
||||
|
||||
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
- mkdir -p $(PWD_GRP)
|
||||
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
|
||||
depend dep: config.h dep-files
|
||||
@ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
|
||||
|
||||
$(LIBBB_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile libbb/libbb.h
|
||||
- mkdir -p $(LIBBB)
|
||||
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -c $< -o $*.o
|
||||
CONFIG_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
||||
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
||||
else echo sh; fi ; fi}
|
||||
|
||||
$(LIBBB_MOBJ): $(LIBBB_MSRC)
|
||||
- mkdir -p $(LIBBB)
|
||||
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
|
||||
include/config/MARKER: scripts/split-include include/config.h
|
||||
scripts/split-include include/config.h include/config
|
||||
@ touch include/config/MARKER
|
||||
|
||||
$(LIBBB_AROBJS): $(LIBBB_ARCSRC)
|
||||
- mkdir -p $(LIBBB)
|
||||
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
|
||||
config.h:
|
||||
@if [ ! -f include/config.h ] ; then \
|
||||
make oldconfig; \
|
||||
fi;
|
||||
|
||||
libpwd.a: $(PWD_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
menuconfig:
|
||||
mkdir -p $(TOPDIR)/include/config
|
||||
$(MAKE) -C scripts/lxdialog all
|
||||
$(CONFIG_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
|
||||
|
||||
libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
config:
|
||||
mkdir -p $(TOPDIR)/include/config
|
||||
$(CONFIG_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
|
||||
|
||||
usage.o: usage.h
|
||||
oldconfig:
|
||||
mkdir -p $(TOPDIR)/include/config
|
||||
$(CONFIG_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
|
||||
|
||||
sh.o: sh.c lash.c hush.c msh.c ash.c
|
||||
|
||||
libbb/loop.o: libbb/loop.h
|
||||
ifdef CONFIGURATION
|
||||
..$(CONFIGURATION):
|
||||
@echo
|
||||
@echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
|
||||
@echo
|
||||
$(MAKE) $(CONFIGURATION)
|
||||
@echo
|
||||
@echo "Successful. Try re-making (ignore the error that follows)"
|
||||
@echo
|
||||
exit 1
|
||||
|
||||
libbb/loop.h: mk_loop_h.sh
|
||||
@ $(SHELL) $< > $@
|
||||
dummy:
|
||||
|
||||
else
|
||||
|
||||
dummy:
|
||||
|
||||
endif
|
||||
|
||||
include Rules.mak
|
||||
|
||||
# Testing...
|
||||
test tests:
|
||||
# old way of doing it
|
||||
#cd tests && $(MAKE) all
|
||||
# new way of doing it
|
||||
cd tests && ./tester.sh
|
||||
|
||||
# Cleanup
|
||||
clean:
|
||||
- cd tests && $(MAKE) clean
|
||||
- $(MAKE) -C tests clean
|
||||
- $(MAKE) -C scripts/lxdialog clean
|
||||
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
|
||||
- rm -f multibuild.log Config.h.orig
|
||||
- rm -rf docs/busybox _install libpwd.a libbb.a pod2htm*
|
||||
- rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list
|
||||
docs/busybox.pdf docs/busybox.lineo.com/busybox.html \
|
||||
docs/busybox _install pod2htm* *.gdb *.elf *~ core
|
||||
- rm -f busybox.links libbb/loop.h .config.old .hdepend
|
||||
- rm -f scripts/split-include scripts/mkdep .*config.log
|
||||
- rm -rf include/config include/config.h
|
||||
- find -name .\*.flags -o -name .depend -exec rm -f {} \;
|
||||
- find -name \*.o -exec rm -f {} \;
|
||||
- find -name \*.a -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f busybox applet_source_list
|
||||
- rm -f busybox
|
||||
- cd tests && $(MAKE) distclean
|
||||
|
||||
install: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
install-hardlinks: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
debug_pristine:
|
||||
@ echo VPATH=\"$(VPATH)\"
|
||||
@ echo OBJECTS=\"$(OBJECTS)\"
|
||||
|
||||
dist release: distclean doc
|
||||
cd ..; \
|
||||
rm -rf busybox-$(VERSION); \
|
||||
@@ -432,6 +401,11 @@ dist release: distclean doc
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
.PHONY: tags
|
||||
|
||||
|
||||
.PHONY: tags check
|
||||
tags:
|
||||
ctags -R .
|
||||
|
||||
check: busybox
|
||||
cd testsuite && ./runtest
|
||||
@@ -11,9 +11,7 @@ the expected functionality and behave very much like their GNU counterparts.
|
||||
BusyBox has been written with size-optimization and limited resources in mind.
|
||||
It is also extremely modular so you can easily include or exclude commands (or
|
||||
features) at compile time. This makes it easy to customize your embedded
|
||||
systems. To create a working system, just add /dev, a shell, and a kernel. For
|
||||
a really minimal system, you can even use the busybox shell (not Bourne
|
||||
compatible, but very small and quite usable) and the busybox vi editor.
|
||||
systems. To create a working system, just add /dev, /etc, and a kernel.
|
||||
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
@@ -36,12 +34,14 @@ Supported architectures:
|
||||
|
||||
Busybox in general will build on any architecture supported by gcc. It has
|
||||
a few specialized features added for __sparc__ and __alpha__. insmod
|
||||
functionality is currently limited to x86, ARM, SH3/4, powerpc, and MIPS.
|
||||
functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k,
|
||||
and MIPS.
|
||||
|
||||
Supported libcs:
|
||||
|
||||
glibc-2.0.x, glibc-2.1.x, Linux-libc5, uClibc. People are looking at
|
||||
newlib and diet-libc, but consider them unsupported, untested, or worse.
|
||||
glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, Linux-libc5, uClibc. People
|
||||
are looking at newlib and diet-libc, but consider them unsupported,
|
||||
untested, or worse.
|
||||
|
||||
Supported kernels:
|
||||
|
||||
@@ -50,10 +50,40 @@ Supported kernels:
|
||||
|
||||
----------------
|
||||
|
||||
Shells:
|
||||
|
||||
lash is the very smallest shell (adds just 10k) and it is quite usable as
|
||||
a command prompt, but it is not suitable for any but the most trivial
|
||||
scripting (such as an initrd that calls insmod a few times) since it does
|
||||
not understand Bourne shell grammer. It does handle pipes, redirects, and
|
||||
job control though. Adding in command editing makes it a very nice
|
||||
lightweight command prompt.
|
||||
|
||||
hush is also quite small (just 18k) and it has very complete Bourne shell
|
||||
grammer. It handles if/then/else/fi just fine, but doesn't handle loops
|
||||
like for/do/done or case/esac and such. It also currently has a problem
|
||||
with job control. Using hush is not yet recommended.
|
||||
|
||||
msh: The minix shell (adds just 30k) is quite complete and handles things
|
||||
like for/do/done, case/esac and all the things you expect a Bourne shell to
|
||||
do. It is not always pedantically correct about Bourne shell grammer (try
|
||||
running the shell testscript "tests/sh.testcases" on it and compare vs bash)
|
||||
but for most things it works quite well. It also uses only vfork, so it can
|
||||
be used on uClinux systems. This was only recently added, so there is still
|
||||
room to shrink it further...
|
||||
|
||||
ash: This adds about 60k in the default configuration and is the most
|
||||
complete and most pedantically correct shell included with busybox. This
|
||||
shell was also recently added, and several people (mainly Vladimir and Erik)
|
||||
have been working on it. There are a number of configurable things at the
|
||||
top of ash.c as well, so check those out if you want to tweak things.
|
||||
|
||||
----------------
|
||||
|
||||
Getting help:
|
||||
|
||||
When you find you need help, you can check out the BusyBox mailing list
|
||||
archives at http://opensource.lineo.com/lists/busybox/ or even join
|
||||
archives at http://oss.lineo.com/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
@@ -101,23 +131,18 @@ Source for the latest released version can always be downloaded from
|
||||
CVS:
|
||||
|
||||
BusyBox now has its own publicly browsable CVS tree at:
|
||||
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
|
||||
http://oss.lineo.com/cgi-bin/cvsweb/busybox/
|
||||
|
||||
Anonymous CVS access is available. For instructions, check out:
|
||||
http://opensource.lineo.com/cvs_anon.html
|
||||
http://oss.lineo.com/cvs_anon.html
|
||||
|
||||
For those that are actively contributing there is even CVS write access:
|
||||
http://opensource.lineo.com/cvs_write.html
|
||||
http://oss.lineo.com/cvs_write.html
|
||||
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@lineo.com>
|
||||
<andersen@codepoet.org>
|
||||
<andersee@debian.org>
|
||||
<andersee@codepoet.org>
|
||||
|
||||
<blatant plug>
|
||||
Many thanks to go to Lineo for paying me to work on busybox.
|
||||
</blatant plug>
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
#
|
||||
# This file contains rules which are shared between multiple Makefiles.
|
||||
#
|
||||
|
||||
#
|
||||
# False targets.
|
||||
#
|
||||
.PHONY: dummy
|
||||
|
||||
#
|
||||
# Special variables which should not be exported
|
||||
#
|
||||
unexport EXTRA_AFLAGS
|
||||
unexport EXTRA_CFLAGS
|
||||
unexport EXTRA_LDFLAGS
|
||||
unexport EXTRA_ARFLAGS
|
||||
unexport SUBDIRS
|
||||
unexport SUB_DIRS
|
||||
unexport ALL_SUB_DIRS
|
||||
unexport O_TARGET
|
||||
|
||||
unexport obj-y
|
||||
unexport obj-n
|
||||
unexport obj-
|
||||
unexport export-objs
|
||||
unexport subdir-y
|
||||
unexport subdir-n
|
||||
unexport subdir-
|
||||
|
||||
#
|
||||
# Get things started.
|
||||
#
|
||||
first_rule: sub_dirs
|
||||
$(MAKE) all_targets
|
||||
|
||||
SUB_DIRS := $(subdir-y)
|
||||
ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-n) $(subdir-))
|
||||
|
||||
|
||||
#
|
||||
# Common rules
|
||||
#
|
||||
|
||||
%.s: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@
|
||||
|
||||
%.i: %.c
|
||||
$(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
|
||||
@ ( \
|
||||
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
|
||||
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
|
||||
echo 'endif' \
|
||||
) > $(dir $@)/.$(notdir $@).flags
|
||||
|
||||
%.o: %.s
|
||||
$(AS) $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
|
||||
|
||||
# Old makefiles define their own rules for compiling .S files,
|
||||
# but these standard rules are available for any Makefile that
|
||||
# wants to use them. Our plan is to incrementally convert all
|
||||
# the Makefiles to these standard rules. -- rmk, mec
|
||||
ifdef USE_STANDARD_AS_RULE
|
||||
|
||||
%.s: %.S
|
||||
$(CPP) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) $< > $@
|
||||
|
||||
%.o: %.S
|
||||
$(CC) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) -c -o $@ $<
|
||||
|
||||
endif
|
||||
|
||||
%.lst: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
|
||||
$(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
|
||||
#
|
||||
#
|
||||
#
|
||||
all_targets: $(O_TARGET) $(L_TARGET)
|
||||
|
||||
#
|
||||
# Rule to compile a set of .o files into one .o file
|
||||
#
|
||||
ifdef O_TARGET
|
||||
$(O_TARGET): $(obj-y)
|
||||
rm -f $@
|
||||
ifneq "$(strip $(obj-y))" ""
|
||||
$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
|
||||
else
|
||||
$(AR) rcs $@
|
||||
endif
|
||||
@ ( \
|
||||
echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
|
||||
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
|
||||
echo 'endif' \
|
||||
) > $(dir $@)/.$(notdir $@).flags
|
||||
endif # O_TARGET
|
||||
|
||||
#
|
||||
# Rule to compile a set of .o files into one .a file
|
||||
#
|
||||
ifdef L_TARGET
|
||||
$(L_TARGET): $(obj-y)
|
||||
rm -f $@
|
||||
$(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)
|
||||
@ ( \
|
||||
echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \
|
||||
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
|
||||
echo 'endif' \
|
||||
) > $(dir $@)/.$(notdir $@).flags
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# This make dependencies quickly
|
||||
#
|
||||
fastdep: dummy
|
||||
$(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS) -- $(wildcard *.[chS]) > .depend
|
||||
ifdef ALL_SUB_DIRS
|
||||
$(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
|
||||
endif
|
||||
|
||||
ifdef _FASTDEP_ALL_SUB_DIRS
|
||||
$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
|
||||
$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# A rule to make subdirectories
|
||||
#
|
||||
subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
|
||||
sub_dirs: dummy $(subdir-list)
|
||||
|
||||
ifdef SUB_DIRS
|
||||
$(subdir-list) : dummy
|
||||
$(MAKE) -C $(patsubst _subdir_%,%,$@)
|
||||
endif
|
||||
|
||||
#
|
||||
# A rule to do nothing
|
||||
#
|
||||
dummy:
|
||||
|
||||
#
|
||||
# This is useful for testing
|
||||
#
|
||||
script:
|
||||
$(SCRIPT)
|
||||
|
||||
#
|
||||
# include dependency files if they exist
|
||||
#
|
||||
ifneq ($(wildcard .depend),)
|
||||
include .depend
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(TOPDIR)/.hdepend),)
|
||||
include $(TOPDIR)/.hdepend
|
||||
endif
|
||||
|
||||
#
|
||||
# Find files whose flags have changed and force recompilation.
|
||||
# For safety, this works in the converse direction:
|
||||
# every file is forced, except those whose flags are positively up-to-date.
|
||||
#
|
||||
FILES_FLAGS_UP_TO_DATE :=
|
||||
|
||||
# For use in expunging commas from flags, which mung our checking.
|
||||
comma = ,
|
||||
|
||||
FILES_FLAGS_EXIST := $(wildcard .*.flags)
|
||||
ifneq ($(FILES_FLAGS_EXIST),)
|
||||
include $(FILES_FLAGS_EXIST)
|
||||
endif
|
||||
|
||||
FILES_FLAGS_CHANGED := $(strip \
|
||||
$(filter-out $(FILES_FLAGS_UP_TO_DATE), \
|
||||
$(O_TARGET) $(L_TARGET) $(active-objs) \
|
||||
))
|
||||
|
||||
# A kludge: .S files don't get flag dependencies (yet),
|
||||
# because that will involve changing a lot of Makefiles. Also
|
||||
# suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
|
||||
# This allows handling of assembly files that get translated into
|
||||
# multiple object files (see arch/ia64/lib/idiv.S, for example).
|
||||
FILES_FLAGS_CHANGED := $(strip \
|
||||
$(filter-out $(patsubst %.S, %.o, $(wildcard *.S) $(IGNORE_FLAGS_OBJS)), \
|
||||
$(FILES_FLAGS_CHANGED)))
|
||||
|
||||
ifneq ($(FILES_FLAGS_CHANGED),)
|
||||
$(FILES_FLAGS_CHANGED): dummy
|
||||
endif
|
||||
@@ -18,8 +18,9 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* start-stop-daemon
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
* login/sulogin/passwd/etc are part of tinylogin. These are
|
||||
being merged into busybox as time allows.
|
||||
|
||||
-----------
|
||||
|
||||
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* adjtimex.c - read, and possibly modify, the Linux kernel `timex' variables.
|
||||
*
|
||||
* Originally written: October 1997
|
||||
* Last hack: March 2001
|
||||
* Copyright 1997, 2000, 2001 Larry Doolittle <LRDoolittle@lbl.gov>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License (Version 2,
|
||||
* June 1991) as published by the Free Software Foundation. At the
|
||||
* time of writing, that license was published by the FSF with the URL
|
||||
* http://www.gnu.org/copyleft/gpl.html, and is incorporated herein by
|
||||
* reference.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This adjtimex(1) is very similar in intent to adjtimex(8) by Steven
|
||||
* Dick <ssd@nevets.oau.org> and Jim Van Zandt <jrv@vanzandt.mv.com>
|
||||
* (see http://metalab.unc.edu/pub/Linux/system/admin/time/adjtimex*).
|
||||
* That version predates this one, and is _much_ bigger and more
|
||||
* featureful. My independently written version was very similar to
|
||||
* Steven's from the start, because they both follow the kernel timex
|
||||
* structure. I further tweaked this version to be equivalent to Steven's
|
||||
* where possible, but I don't like getopt_long, so the actual usage
|
||||
* syntax is incompatible.
|
||||
*
|
||||
* Amazingly enough, my Red Hat 5.2 sys/timex (and sub-includes)
|
||||
* don't actually give a prototype for adjtimex(2), so building
|
||||
* this code (with -Wall) gives a warning. Later versions of
|
||||
* glibc fix this issue.
|
||||
*
|
||||
* This program is too simple for a Makefile, just build with:
|
||||
* gcc -Wall -O adjtimex.c -o adjtimex
|
||||
*
|
||||
* busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
* It will autosense if it is built in a busybox environment, based
|
||||
* on the BB_VER preprocessor macro.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if __GNU_LIBRARY__ < 5
|
||||
#include <sys/timex.h>
|
||||
extern int adjtimex(struct timex *buf);
|
||||
#else
|
||||
#include <sys/timex.h>
|
||||
#endif
|
||||
|
||||
#ifdef BB_VER
|
||||
#include "busybox.h"
|
||||
#endif
|
||||
|
||||
static struct {int bit; char *name;} statlist[] = {
|
||||
{ STA_PLL, "PLL" },
|
||||
{ STA_PPSFREQ, "PPSFREQ" },
|
||||
{ STA_PPSTIME, "PPSTIME" },
|
||||
{ STA_FLL, "FFL" },
|
||||
{ STA_INS, "INS" },
|
||||
{ STA_DEL, "DEL" },
|
||||
{ STA_UNSYNC, "UNSYNC" },
|
||||
{ STA_FREQHOLD, "FREQHOLD" },
|
||||
{ STA_PPSSIGNAL, "PPSSIGNAL" },
|
||||
{ STA_PPSJITTER, "PPSJITTER" },
|
||||
{ STA_PPSWANDER, "PPSWANDER" },
|
||||
{ STA_PPSERROR, "PPSERROR" },
|
||||
{ STA_CLOCKERR, "CLOCKERR" },
|
||||
{ 0, NULL } };
|
||||
|
||||
static char *ret_code_descript[] = {
|
||||
"clock synchronized",
|
||||
"insert leap second",
|
||||
"delete leap second",
|
||||
"leap second in progress",
|
||||
"leap second has occurred",
|
||||
"clock not synchronized" };
|
||||
|
||||
#ifdef BB_VER
|
||||
#define main adjtimex_main
|
||||
#else
|
||||
void usage(char *prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: %s [ -q ] [ -o offset ] [ -f frequency ] [ -p timeconstant ] [ -t tick ]\n",
|
||||
prog);
|
||||
}
|
||||
#define show_usage() usage(argv[0])
|
||||
#endif
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct timex txc;
|
||||
int quiet=0;
|
||||
int c, i, ret, sep;
|
||||
char *descript;
|
||||
txc.modes=0;
|
||||
for (;;) {
|
||||
c = getopt( argc, argv, "qo:f:p:t:");
|
||||
if (c == EOF) break;
|
||||
switch (c) {
|
||||
case 'q':
|
||||
quiet=1;
|
||||
break;
|
||||
case 'o':
|
||||
txc.offset = atoi(optarg);
|
||||
txc.modes |= ADJ_OFFSET_SINGLESHOT;
|
||||
break;
|
||||
case 'f':
|
||||
txc.freq = atoi(optarg);
|
||||
txc.modes |= ADJ_FREQUENCY;
|
||||
break;
|
||||
case 'p':
|
||||
txc.constant = atoi(optarg);
|
||||
txc.modes |= ADJ_TIMECONST;
|
||||
break;
|
||||
case 't':
|
||||
txc.tick = atoi(optarg);
|
||||
txc.modes |= ADJ_TICK;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (argc != optind) { /* no valid non-option parameters */
|
||||
show_usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = adjtimex(&txc);
|
||||
|
||||
if (ret < 0) perror("adjtimex");
|
||||
|
||||
if (!quiet && ret>=0) {
|
||||
printf(
|
||||
" mode: %d\n"
|
||||
"-o offset: %ld\n"
|
||||
"-f frequency: %ld\n"
|
||||
" maxerror: %ld\n"
|
||||
" esterror: %ld\n"
|
||||
" status: %d ( ",
|
||||
txc.modes, txc.offset, txc.freq, txc.maxerror,
|
||||
txc.esterror, txc.status);
|
||||
|
||||
/* representative output of next code fragment:
|
||||
"PLL | PPSTIME" */
|
||||
sep=0;
|
||||
for (i=0; statlist[i].name; i++) {
|
||||
if (txc.status & statlist[i].bit) {
|
||||
if (sep) fputs(" | ",stdout);
|
||||
fputs(statlist[i].name,stdout);
|
||||
sep=1;
|
||||
}
|
||||
}
|
||||
|
||||
descript = "error";
|
||||
if (ret >= 0 && ret <= 5) descript = ret_code_descript[ret];
|
||||
printf(" )\n"
|
||||
"-p timeconstant: %ld\n"
|
||||
" precision: %ld\n"
|
||||
" tolerance: %ld\n"
|
||||
"-t tick: %ld\n"
|
||||
" time.tv_sec: %ld\n"
|
||||
" time.tv_usec: %ld\n"
|
||||
" return value: %d (%s)\n",
|
||||
txc.constant,
|
||||
txc.precision, txc.tolerance, txc.tick,
|
||||
(long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
|
||||
}
|
||||
return (ret<0);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
struct BB_applet *applet_using;
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
extern void show_usage(void)
|
||||
{
|
||||
const char *format_string;
|
||||
const char *usage_string = usage_messages;
|
||||
int i;
|
||||
/* From busybox.c */
|
||||
extern int been_there_done_that;
|
||||
|
||||
if (strcmp(applet_using->name, "busybox")==0) {
|
||||
been_there_done_that=1;
|
||||
busybox_main(0, NULL);
|
||||
}
|
||||
|
||||
for (i = applet_using - applets; i > 0; ) {
|
||||
if (!*usage_string++) {
|
||||
--i;
|
||||
}
|
||||
}
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if(*usage_string == 0)
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf(stderr, format_string,
|
||||
full_version, applet_using->name, usage_string);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int applet_name_compare(const void *x, const void *y)
|
||||
{
|
||||
const char *name = x;
|
||||
const struct BB_applet *applet = y;
|
||||
|
||||
return strcmp(name, applet->name);
|
||||
}
|
||||
|
||||
extern const size_t NUM_APPLETS;
|
||||
|
||||
struct BB_applet *find_applet_by_name(const char *name)
|
||||
{
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
|
||||
applet_name_compare);
|
||||
}
|
||||
|
||||
void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
{
|
||||
static int recurse_level = 0;
|
||||
|
||||
recurse_level++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
if ((applet_using = find_applet_by_name(name)) != NULL) {
|
||||
applet_name = applet_using->name;
|
||||
if (argv[1] && strcmp(argv[1], "--help") == 0) {
|
||||
show_usage();
|
||||
}
|
||||
exit((*(applet_using->main)) (argc, argv));
|
||||
}
|
||||
/* Just in case they have renamed busybox - Check argv[1] */
|
||||
if (recurse_level == 1) {
|
||||
run_applet_by_name("busybox", argc, argv);
|
||||
}
|
||||
recurse_level = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,454 +0,0 @@
|
||||
/*
|
||||
* applets.h - a listing of all busybox applets.
|
||||
*
|
||||
* If you write a new applet, you need to add an entry to this list to make
|
||||
* busybox aware of it.
|
||||
*
|
||||
* It is CRUCIAL that this listing be kept in ascii order, otherwise the binary
|
||||
* search lookup contributed by Gaute B Strokkenes stops working. If you value
|
||||
* your kneecaps, you'll be sure to *make sure* that any changes made to this
|
||||
* file result in the listing remaining in ascii order. You have been warned.
|
||||
*/
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_ODDNAME
|
||||
#undef APPLET_NOUSAGE
|
||||
|
||||
|
||||
#if defined(PROTOTYPES)
|
||||
#define APPLET(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_NOUSAGE(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_ODDNAME(a,b,c,d) extern int b(int argc, char **argv);
|
||||
extern const char usage_messages[];
|
||||
#elif defined(MAKE_USAGE)
|
||||
#ifdef BB_FEATURE_VERBOSE_USAGE
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\n\n" a##_full_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\n\n" d##_full_usage "\0"
|
||||
#else
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\0"
|
||||
#endif
|
||||
#elif defined(MAKE_LINKS)
|
||||
# define APPLET(a,b,c) LINK c a
|
||||
# define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
# define APPLET_ODDNAME(a,b,c,d) LINK c a
|
||||
#else
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c) {#a,b,c},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c},
|
||||
#define APPLET_ODDNAME(a,b,c,d) {a,b,c},
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef BB_TEST
|
||||
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ADJTIMEX
|
||||
APPLET(adjtimex, adjtimex_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_AR
|
||||
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
|
||||
#ifdef BB_CAT
|
||||
APPLET(cat, cat_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHGRP
|
||||
APPLET(chgrp, chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD
|
||||
APPLET(chmod, chmod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHOWN
|
||||
APPLET(chown, chown_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CMP
|
||||
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CP
|
||||
APPLET(cp, cp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CPIO
|
||||
APPLET(cpio, cpio_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
APPLET(cut, cut_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
APPLET(date, date_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
APPLET(dd, dd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
APPLET(df, df_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
APPLET(dos2unix, dos2unix_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG
|
||||
APPLET(dpkg, dpkg_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG_DEB
|
||||
APPLET_ODDNAME("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb)
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
APPLET(du, du_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
APPLET(echo, echo_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#if defined(BB_FEATURE_GREP_EGREP_ALIAS) && defined(BB_GREP)
|
||||
APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ENV
|
||||
APPLET(env, env_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
APPLET(expr, expr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET(false, false_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
APPLET(find, find_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
APPLET(free, free_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
APPLET(getopt, getopt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
APPLET(grep, grep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
APPLET(gzip, gzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
APPLET(halt, halt_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
APPLET(head, head_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
APPLET(hostname, hostname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
APPLET(id, id_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_IFCONFIG
|
||||
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
APPLET(init, init_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
APPLET(kill, kill_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
APPLET(killall, kill_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KLOGD
|
||||
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
APPLET(length, length_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
APPLET(ln, ln_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
APPLET(logname, logname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGREAD
|
||||
APPLET(logread, logread_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
APPLET(ls, ls_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
APPLET(mknod, mknod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
APPLET(more, more_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
APPLET(mount, mount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
APPLET(mt, mt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MV
|
||||
APPLET(mv, mv_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
APPLET(ping, ping_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PIVOT_ROOT
|
||||
APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
APPLET(poweroff, poweroff_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
APPLET(ps, ps_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
APPLET(pwd, pwd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_READLINK
|
||||
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
APPLET(rm, rm_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
APPLET(rmmod, rmmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ROUTE
|
||||
APPLET(route, route_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RPM2CPIO
|
||||
APPLET(rpm2cpio, rpm2cpio_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RPMUNPACK
|
||||
APPLET(rpmunpack, rpmunpack_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
APPLET(sed, sed_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
APPLET(sh, shell_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
APPLET(sleep, sleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
APPLET(sort, sort_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_STTY
|
||||
APPLET(stty, stty_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET(swapoff, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
APPLET(sync, sync_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
APPLET(tar, tar_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
APPLET(test, test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TFTP
|
||||
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
APPLET(touch, touch_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET(true, true_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
APPLET(umount, umount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
APPLET(uname, uname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
APPLET(unix2dos, unix2dos_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
APPLET(update, update_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
APPLET(usleep, usleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
APPLET(uuencode, uuencode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_VI
|
||||
APPLET(vi, vi_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WATCHDOG
|
||||
APPLET(watchdog, watchdog_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
APPLET(wc, wc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
APPLET(which, which_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
|
||||
{ 0,NULL,0 }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=..
|
||||
L_TARGET := applets.a
|
||||
|
||||
obj-y :=
|
||||
obj-n :=
|
||||
obj- :=
|
||||
|
||||
obj-y += applets.o busybox.o usage.o
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
|
||||
+12
-9
@@ -45,13 +45,6 @@ extern void show_usage(void)
|
||||
const char *format_string;
|
||||
const char *usage_string = usage_messages;
|
||||
int i;
|
||||
/* From busybox.c */
|
||||
extern int been_there_done_that;
|
||||
|
||||
if (strcmp(applet_using->name, "busybox")==0) {
|
||||
been_there_done_that=1;
|
||||
busybox_main(0, NULL);
|
||||
}
|
||||
|
||||
for (i = applet_using - applets; i > 0; ) {
|
||||
if (!*usage_string++) {
|
||||
@@ -85,13 +78,23 @@ struct BB_applet *find_applet_by_name(const char *name)
|
||||
void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
{
|
||||
static int recurse_level = 0;
|
||||
extern int been_there_done_that; /* From busybox.c */
|
||||
|
||||
recurse_level++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
if ((applet_using = find_applet_by_name(name)) != NULL) {
|
||||
applet_name = applet_using->name;
|
||||
if (argv[1] && strcmp(argv[1], "--help") == 0) {
|
||||
show_usage();
|
||||
if (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));
|
||||
}
|
||||
@@ -99,7 +102,7 @@ void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
if (recurse_level == 1) {
|
||||
run_applet_by_name("busybox", argc, argv);
|
||||
}
|
||||
recurse_level = 0;
|
||||
recurse_level--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+13
-13
@@ -5,14 +5,14 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *applet_name;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
@@ -63,24 +63,24 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
#endif /* CONFIG_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
applet_name = argv[0];
|
||||
|
||||
if (applet_name[0] == '-')
|
||||
applet_name++;
|
||||
|
||||
for (s = applet_name; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
/* Add in a special case hack for a leading hyphen */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
applet_name = (*argv+1);
|
||||
}
|
||||
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#ifdef BB_INIT
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#ifdef CONFIG_INIT
|
||||
if(getpid()!=1) /* Do not set locale for `init' */
|
||||
#endif
|
||||
{
|
||||
@@ -97,7 +97,7 @@ int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
@@ -125,7 +125,7 @@ int busybox_main(int argc, char **argv)
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
#endif /* CONFIG_FEATURE_INSTALLER */
|
||||
|
||||
argc--;
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
CONFIG_H=${1:-include/config.h}
|
||||
APPLETS_H=${2:-include/applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
dir=substr($2,8)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
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' ' '
|
||||
|
||||
-1787
File diff suppressed because it is too large.
Load diff
@@ -1,89 +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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
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':
|
||||
extract_function |= extract_preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
extract_function |= extract_verbose_list;
|
||||
break;
|
||||
case 't':
|
||||
extract_function |= extract_list;
|
||||
break;
|
||||
case 'p':
|
||||
extract_function |= extract_to_stdout;
|
||||
break;
|
||||
case 'x':
|
||||
extract_function |= extract_all_to_fs;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
src_stream = xfopen(argv[optind++], "r");
|
||||
|
||||
/* check ar magic */
|
||||
fread(ar_magic, 1, 8, src_stream);
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
archive_offset = 8;
|
||||
|
||||
extract_names = malloc(sizeof(char *));
|
||||
extract_names[0] = NULL;
|
||||
while (optind < argc) {
|
||||
num_of_entries++;
|
||||
*extract_names = realloc(*extract_names, num_of_entries);
|
||||
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=..
|
||||
L_TARGET := archival.a
|
||||
|
||||
obj-y :=
|
||||
obj-n :=
|
||||
obj- :=
|
||||
subdir-y := libunarchive
|
||||
|
||||
obj-$(CONFIG_AR) += ar.o
|
||||
obj-$(CONFIG_BUNZIP2) += bunzip2.o
|
||||
obj-$(CONFIG_CPIO) += cpio.o
|
||||
obj-$(CONFIG_DPKG) += dpkg.o
|
||||
obj-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
obj-$(CONFIG_GUNZIP) += gunzip.o
|
||||
obj-$(CONFIG_GZIP) += gzip.o
|
||||
obj-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
obj-$(CONFIG_TAR) += tar.o
|
||||
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
|
||||
+8
-7
@@ -23,10 +23,11 @@
|
||||
*
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
@@ -70,20 +71,20 @@ extern int ar_main(int argc, char **argv)
|
||||
|
||||
/* 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");
|
||||
}
|
||||
archive_offset = 8;
|
||||
|
||||
extract_names = malloc(sizeof(char *));
|
||||
extract_names[0] = NULL;
|
||||
/* 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 = realloc(*extract_names, num_of_entries);
|
||||
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
|
||||
extract_names[num_of_entries] = NULL;
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
|
||||
unarchive(src_stream, stdout, &get_header_ar, extract_function, "./", extract_names, NULL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+2370
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
mainmenu_option next_comment
|
||||
comment 'Archival Utilities'
|
||||
|
||||
bool 'ar' CONFIG_AR
|
||||
bool 'bunzip2' CONFIG_BUNZIP2
|
||||
bool 'cpio' CONFIG_CPIO
|
||||
bool 'dpkg' CONFIG_DPKG
|
||||
bool 'dpkg_deb' CONFIG_DPKG_DEB
|
||||
bool 'gunzip' CONFIG_GUNZIP
|
||||
bool 'gzip' CONFIG_GZIP
|
||||
bool 'rpm2cpio' CONFIG_RPM2CPIO
|
||||
bool 'tar' CONFIG_TAR
|
||||
if [ "$CONFIG_TAR" = "y" ] ; then
|
||||
bool ' Enable archive creation' CONFIG_FEATURE_TAR_CREATE
|
||||
bool ' Enable -X and --exclude options (exclude files)' CONFIG_FEATURE_TAR_EXCLUDE
|
||||
bool ' Enable -z option (currently only for extracting)' CONFIG_FEATURE_TAR_GZIP
|
||||
fi
|
||||
endmenu
|
||||
+11
-7
@@ -28,6 +28,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cpio_main(int argc, char **argv)
|
||||
@@ -68,25 +69,28 @@ extern int cpio_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (extract_function & extract_all_to_fs && extract_function & extract_list) {
|
||||
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 */
|
||||
if ((extract_function & extract_all_to_fs) && (extract_function & extract_verbose_list)) {
|
||||
/* The meaning of v changes on extract */
|
||||
extract_function ^= extract_verbose_list;
|
||||
extract_function |= extract_list;
|
||||
}
|
||||
|
||||
extract_names = malloc(4);
|
||||
while (optind < argc) {
|
||||
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
|
||||
extract_names[num_of_entries] = xstrdup(argv[optind]);
|
||||
num_of_entries++;
|
||||
*extract_names = realloc(*extract_names, num_of_entries);
|
||||
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
|
||||
extract_names[num_of_entries] = NULL;
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, &get_header_cpio, extract_function, "./", extract_names);
|
||||
if (oldmask) umask(oldmask); /* Restore umask if we changed it */
|
||||
unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names, NULL);
|
||||
if (oldmask) {
|
||||
umask(oldmask); /* Restore umask if we changed it */
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+1412
-755
File diff suppressed because it is too large.
Load diff
+10
-4
@@ -17,6 +17,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
@@ -110,12 +111,17 @@ extern int dpkg_deb_main(int argc, char **argv)
|
||||
}
|
||||
else if (arg_type == arg_type_field) {
|
||||
char *field = NULL;
|
||||
char *name;
|
||||
char *value;
|
||||
int field_start = 0;
|
||||
|
||||
while ((field = read_package_field(&output_buffer[field_start])) != NULL) {
|
||||
field_start += (strlen(field) + 1);
|
||||
if (strstr(field, argv[optind + 1]) == field) {
|
||||
puts(field + strlen(argv[optind + 1]) + 2);
|
||||
while (1) {
|
||||
field_start += read_package_field(&output_buffer[field_start], &name, &value);
|
||||
if (name == NULL) {
|
||||
break;
|
||||
}
|
||||
if (strcmp(name, argv[optind + 1]) == 0) {
|
||||
puts(value);
|
||||
}
|
||||
free(field);
|
||||
}
|
||||
|
||||
+4
-1
@@ -114,10 +114,13 @@ extern int gunzip_main(int argc, char **argv)
|
||||
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
||||
flags |= gunzip_to_stdout;
|
||||
} else {
|
||||
if_name = strdup(argv[optind]);
|
||||
if_name = xstrdup(argv[optind]);
|
||||
/* Open input file */
|
||||
in_file = xfopen(if_name, "r");
|
||||
|
||||
/* set the buffer size */
|
||||
setvbuf(in_file, NULL, _IOFBF, 0x8000);
|
||||
|
||||
/* Get the time stamp on the input file. */
|
||||
if (stat(if_name, &stat_buf) < 0) {
|
||||
error_msg_and_die("Couldn't stat file %s", if_name);
|
||||
|
||||
+48
-30
@@ -110,8 +110,7 @@ static int method; /* compression method */
|
||||
#ifdef DYN_ALLOC
|
||||
# define DECLARE(type, array, size) static type * array
|
||||
# define ALLOC(type, array, size) { \
|
||||
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
|
||||
if (array == NULL) error_msg(memory_exhausted); \
|
||||
array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
|
||||
}
|
||||
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
|
||||
#else
|
||||
@@ -181,16 +180,17 @@ typedef int file_t; /* Do not use stdio */
|
||||
outbuf[outcnt++] = (uch) ((w) & 0xff); \
|
||||
outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \
|
||||
} else { \
|
||||
put_byte((uch)((w) & 0xff)); \
|
||||
put_byte((uch)((ush)(w) >> 8)); \
|
||||
put_short_when_full(w); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Output a 32 bit value to the bit stream, lsb first */
|
||||
#if 0
|
||||
#define put_long(n) { \
|
||||
put_short((n) & 0xffff); \
|
||||
put_short(((ulg)(n)) >> 16); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define seekable() 0 /* force sequential output */
|
||||
#define translate_eol 0 /* no option -a yet */
|
||||
@@ -220,7 +220,6 @@ typedef int file_t; /* Do not use stdio */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* from zip.c: */
|
||||
static int zip (int in, int out);
|
||||
static int file_read (char *buf, unsigned size);
|
||||
@@ -248,6 +247,9 @@ static int (*read_buf) (char *buf, unsigned size);
|
||||
/* from util.c: */
|
||||
static void flush_outbuf (void);
|
||||
|
||||
static void put_short_when_full (ush);
|
||||
|
||||
|
||||
/* lzw.h -- define the lzw functions.
|
||||
* Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
* This is free software; you can redistribute it and/or modify it under the
|
||||
@@ -352,7 +354,7 @@ static void clear_bufs(void)
|
||||
bytes_in = 0L;
|
||||
}
|
||||
|
||||
static void write_error_msg()
|
||||
static void write_error_msg(void)
|
||||
{
|
||||
fprintf(stderr, "\n");
|
||||
perror("");
|
||||
@@ -388,18 +390,11 @@ static ulg updcrc(uch *s, unsigned n)
|
||||
static unsigned long crc_32_tab[256];
|
||||
if (crc_table_empty) {
|
||||
unsigned long csr; /* crc shift register */
|
||||
unsigned long e=0; /* polynomial exclusive-or pattern */
|
||||
const unsigned long e = 0xedb88320L; /* polynomial exclusive-or pattern */
|
||||
int i; /* counter for all possible eight bit values */
|
||||
int k; /* byte being shifted into crc apparatus */
|
||||
|
||||
/* terms of polynomial defining this crc (except x^32): */
|
||||
static const int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
||||
|
||||
/* Make exclusive-or pattern from polynomial (0xedb88320) */
|
||||
for (i = 0; i < sizeof(p)/sizeof(int); i++)
|
||||
e |= 1L << (31 - p[i]);
|
||||
|
||||
/* Compute and print table of CRC's, five per line */
|
||||
/* Compute table of CRC's. */
|
||||
crc_32_tab[0] = 0x00000000L;
|
||||
for (i = 1; i < 256; i++) {
|
||||
csr = i;
|
||||
@@ -1206,7 +1201,6 @@ typedef struct dirent dir_type;
|
||||
|
||||
typedef RETSIGTYPE(*sig_type) (int);
|
||||
|
||||
|
||||
/* ======================================================================== */
|
||||
// int main (argc, argv)
|
||||
// int argc;
|
||||
@@ -1237,7 +1231,7 @@ int gzip_main(int argc, char **argv)
|
||||
break;
|
||||
case 'q':
|
||||
break;
|
||||
#ifdef BB_GUNZIP
|
||||
#ifdef CONFIG_GUNZIP
|
||||
case 'd':
|
||||
optind = 1;
|
||||
return gunzip_main(argc, argv);
|
||||
@@ -1246,7 +1240,7 @@ int gzip_main(int argc, char **argv)
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
if (optind == argc) {
|
||||
if ((optind == argc) || (strcmp(argv[optind], "-") == 0)) {
|
||||
fromstdin = 1;
|
||||
tostdout = 1;
|
||||
}
|
||||
@@ -1291,11 +1285,9 @@ int gzip_main(int argc, char **argv)
|
||||
|
||||
/* Open input file */
|
||||
inFileNum = open(ifname, O_RDONLY);
|
||||
if (inFileNum < 0)
|
||||
if (inFileNum < 0 || stat(ifname, &statBuf) < 0)
|
||||
perror_msg_and_die("%s", ifname);
|
||||
/* Get the time stamp on the input file. */
|
||||
if (stat(ifname, &statBuf) < 0)
|
||||
perror_msg_and_die("%s", ifname);
|
||||
time_stamp = statBuf.st_ctime;
|
||||
ifile_size = statBuf.st_size;
|
||||
}
|
||||
@@ -1433,16 +1425,20 @@ int gzip_main(int argc, char **argv)
|
||||
#define BL_CODES 19
|
||||
/* number of codes used to transfer the bit lengths */
|
||||
|
||||
typedef uch extra_bits_t;
|
||||
|
||||
static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
|
||||
/* extra bits for each length code */
|
||||
static const extra_bits_t extra_lbits[LENGTH_CODES]
|
||||
= { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
|
||||
4, 4, 5, 5, 5, 5, 0 };
|
||||
|
||||
static const int extra_dbits[D_CODES] /* extra bits for each distance code */
|
||||
/* extra bits for each distance code */
|
||||
static const extra_bits_t extra_dbits[D_CODES]
|
||||
= { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
|
||||
10, 10, 11, 11, 12, 12, 13, 13 };
|
||||
|
||||
static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */
|
||||
/* extra bits for each bit length code */
|
||||
static const extra_bits_t extra_blbits[BL_CODES]
|
||||
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 };
|
||||
|
||||
#define STORED_BLOCK 0
|
||||
@@ -1537,7 +1533,7 @@ static ct_data bl_tree[2 * BL_CODES + 1];
|
||||
typedef struct tree_desc {
|
||||
ct_data *dyn_tree; /* the dynamic tree */
|
||||
ct_data *static_tree; /* corresponding static tree or NULL */
|
||||
const int *extra_bits; /* extra bits for each code or NULL */
|
||||
const extra_bits_t *extra_bits; /* extra bits for each code or NULL */
|
||||
int extra_base; /* base index for extra_bits */
|
||||
int elems; /* max number of elements in the tree */
|
||||
int max_length; /* max bit length for the codes */
|
||||
@@ -1834,7 +1830,7 @@ static void pqdownheap(ct_data *tree, int k)
|
||||
static void gen_bitlen(tree_desc *desc)
|
||||
{
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
const int *extra = desc->extra_bits;
|
||||
const extra_bits_t *extra = desc->extra_bits;
|
||||
int base = desc->extra_base;
|
||||
int max_code = desc->max_code;
|
||||
int max_length = desc->max_length;
|
||||
@@ -2466,6 +2462,28 @@ static void set_file_type()
|
||||
static ulg crc; /* crc on uncompressed file data */
|
||||
static long header_bytes; /* number of bytes in gzip header */
|
||||
|
||||
static void put_short_when_full(ush w)
|
||||
{
|
||||
put_byte((uch)((w) & 0xff));
|
||||
put_byte((uch)((ush)(w) >> 8));
|
||||
}
|
||||
|
||||
static void put_short_function(ush n)
|
||||
{
|
||||
put_short(n);
|
||||
}
|
||||
|
||||
static void put_long(ulg n)
|
||||
{
|
||||
put_short_function((n) & 0xffff);
|
||||
put_short_function(((ulg)(n)) >> 16);
|
||||
}
|
||||
|
||||
/* put_header_byte is used for the compressed output
|
||||
* - for the initial 4 bytes that can't overflow the buffer.
|
||||
*/
|
||||
#define put_header_byte(c) {outbuf[outcnt++]=(uch)(c);}
|
||||
|
||||
/* ===========================================================================
|
||||
* Deflate in to out.
|
||||
* IN assertions: the input and output buffers are cleared.
|
||||
@@ -2485,11 +2503,11 @@ static int zip(int in, int out)
|
||||
|
||||
|
||||
method = DEFLATED;
|
||||
put_byte(GZIP_MAGIC[0]); /* magic header */
|
||||
put_byte(GZIP_MAGIC[1]);
|
||||
put_byte(DEFLATED); /* compression method */
|
||||
put_header_byte(GZIP_MAGIC[0]); /* magic header */
|
||||
put_header_byte(GZIP_MAGIC[1]);
|
||||
put_header_byte(DEFLATED); /* compression method */
|
||||
|
||||
put_byte(my_flags); /* general flags */
|
||||
put_header_byte(my_flags); /* general flags */
|
||||
put_long(time_stamp);
|
||||
|
||||
/* Write deflated file to zip file */
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=../..
|
||||
L_TARGET := libunarchive.a
|
||||
|
||||
obj-y := unarchive.o seek_sub_file.o
|
||||
obj-n :=
|
||||
obj- :=
|
||||
|
||||
ifeq ($(CONFIG_DPKG),y)
|
||||
obj-y += deb_extract.o get_header_ar.o get_header_tar.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DPKG_DEB),y)
|
||||
obj-y += deb_extract.o get_header_ar.o get_header_tar.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_AR),y)
|
||||
obj-y += get_header_ar.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CPIO),y)
|
||||
obj-y += get_header_cpio.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RPM2CPIO),y)
|
||||
obj-y += get_header_cpio.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TAR),y)
|
||||
obj-y += get_header_tar.o
|
||||
endif
|
||||
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
char *deb_extract(const char *package_filename, FILE *out_stream,
|
||||
const int extract_function, const char *prefix, const char *filename)
|
||||
{
|
||||
FILE *deb_stream;
|
||||
FILE *uncompressed_stream = NULL;
|
||||
file_header_t *ar_header = NULL;
|
||||
char **file_list = NULL;
|
||||
char *output_buffer = NULL;
|
||||
char *ared_file = NULL;
|
||||
char ar_magic[8];
|
||||
int gunzip_pid;
|
||||
|
||||
if (filename != NULL) {
|
||||
file_list = xmalloc(sizeof(char *) * 2);
|
||||
file_list[0] = xstrdup(filename);
|
||||
file_list[1] = NULL;
|
||||
}
|
||||
|
||||
if (extract_function & extract_control_tar_gz) {
|
||||
ared_file = xstrdup("control.tar.gz");
|
||||
}
|
||||
else if (extract_function & extract_data_tar_gz) {
|
||||
ared_file = xstrdup("data.tar.gz");
|
||||
}
|
||||
|
||||
/* open the debian package to be worked on */
|
||||
deb_stream = wfopen(package_filename, "r");
|
||||
if (deb_stream == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
/* set the buffer size */
|
||||
setvbuf(deb_stream, NULL, _IOFBF, 0x8000);
|
||||
|
||||
/* check ar magic */
|
||||
fread(ar_magic, 1, 8, deb_stream);
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
archive_offset = 8;
|
||||
|
||||
while ((ar_header = get_header_ar(deb_stream)) != NULL) {
|
||||
if (strcmp(ared_file, ar_header->name) == 0) {
|
||||
/* open a stream of decompressed data */
|
||||
uncompressed_stream = gz_open(deb_stream, &gunzip_pid);
|
||||
archive_offset = 0;
|
||||
output_buffer = unarchive(uncompressed_stream, out_stream, get_header_tar, extract_function, prefix, file_list, NULL);
|
||||
}
|
||||
seek_sub_file(deb_stream, ar_header->size);
|
||||
free(ar_header->name);
|
||||
free(ar_header);
|
||||
}
|
||||
gz_close(gunzip_pid);
|
||||
fclose(deb_stream);
|
||||
fclose(uncompressed_stream);
|
||||
free(ared_file);
|
||||
if (filename != NULL) {
|
||||
free(file_list[0]);
|
||||
free(file_list);
|
||||
}
|
||||
return(output_buffer);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ static char *license_msg[] = {
|
||||
#include <string.h>
|
||||
#include "libbb.h"
|
||||
|
||||
FILE *in_file, *out_file;
|
||||
static FILE *in_file, *out_file;
|
||||
|
||||
/* these are freed by gz_close */
|
||||
static unsigned char *window;
|
||||
@@ -91,9 +91,9 @@ static const int N_MAX = 288; /* maximum number of codes in any set */
|
||||
static long bytes_out; /* number of output bytes */
|
||||
static unsigned long outcnt; /* bytes in output buffer */
|
||||
|
||||
unsigned hufts; /* track memory usage */
|
||||
unsigned long bb; /* bit buffer */
|
||||
unsigned bk; /* bits in bit buffer */
|
||||
static unsigned hufts; /* track memory usage */
|
||||
static unsigned long bb; /* bit buffer */
|
||||
static unsigned bk; /* bits in bit buffer */
|
||||
|
||||
typedef struct huft_s {
|
||||
unsigned char e; /* number of extra bits or operation */
|
||||
@@ -104,7 +104,7 @@ typedef struct huft_s {
|
||||
} v;
|
||||
} huft_t;
|
||||
|
||||
unsigned short mask_bits[] = {
|
||||
static const unsigned short mask_bits[] = {
|
||||
0x0000,
|
||||
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
@@ -115,13 +115,13 @@ unsigned short mask_bits[] = {
|
||||
* Signal and error handler.
|
||||
*/
|
||||
|
||||
static void abort_gzip()
|
||||
static void abort_gzip(void)
|
||||
{
|
||||
error_msg("gzip aborted\n");
|
||||
exit(ERROR);
|
||||
}
|
||||
|
||||
static void make_crc_table()
|
||||
static void make_crc_table(void)
|
||||
{
|
||||
unsigned long table_entry; /* crc shift register */
|
||||
unsigned long poly = 0; /* polynomial exclusive-or pattern */
|
||||
@@ -154,7 +154,7 @@ static void make_crc_table()
|
||||
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
|
||||
* (Used for the decompressed data only.)
|
||||
*/
|
||||
void flush_window()
|
||||
static void flush_window(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -853,7 +853,7 @@ static int inflate_block(int *e)
|
||||
*
|
||||
* GLOBAL VARIABLES: outcnt, bk, bb, hufts, inptr
|
||||
*/
|
||||
static int inflate()
|
||||
static int inflate(void)
|
||||
{
|
||||
int e; /* last block flag */
|
||||
int r; /* result code */
|
||||
@@ -925,9 +925,6 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
outcnt = 0;
|
||||
bytes_out = 0L;
|
||||
|
||||
/* set the buffer size */
|
||||
setvbuf(in_file, NULL, _IOFBF, 0x8000);
|
||||
|
||||
magic[0] = fgetc(in_file);
|
||||
magic[1] = fgetc(in_file);
|
||||
|
||||
@@ -1024,6 +1021,6 @@ extern void gz_close(int gunzip_pid)
|
||||
if (waitpid(gunzip_pid, NULL, 0) == -1) {
|
||||
printf("Couldnt wait ?");
|
||||
}
|
||||
free(window);
|
||||
free(crc_table);
|
||||
free(window);
|
||||
free(crc_table);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
file_header_t *get_header_ar(FILE *src_stream)
|
||||
{
|
||||
file_header_t *typed;
|
||||
union {
|
||||
char raw[60];
|
||||
struct {
|
||||
char name[16];
|
||||
char date[12];
|
||||
char uid[6];
|
||||
char gid[6];
|
||||
char mode[8];
|
||||
char size[10];
|
||||
char magic[2];
|
||||
} formated;
|
||||
} ar;
|
||||
static char *ar_long_names;
|
||||
|
||||
if (fread(ar.raw, 1, 60, src_stream) != 60) {
|
||||
return(NULL);
|
||||
}
|
||||
archive_offset += 60;
|
||||
/* align the headers based on the header magic */
|
||||
if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) {
|
||||
/* some version of ar, have an extra '\n' after each data entry,
|
||||
* this puts the next header out by 1 */
|
||||
if (ar.formated.magic[1] != '`') {
|
||||
error_msg("Invalid magic");
|
||||
return(NULL);
|
||||
}
|
||||
/* read the next char out of what would be the data section,
|
||||
* if its a '\n' then it is a valid header offset by 1*/
|
||||
archive_offset++;
|
||||
if (fgetc(src_stream) != '\n') {
|
||||
error_msg("Invalid magic");
|
||||
return(NULL);
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early */
|
||||
/* raw_header[60] wont be '\n' as it should, but it doesnt matter */
|
||||
memmove(ar.raw, &ar.raw[1], 59);
|
||||
}
|
||||
|
||||
typed = (file_header_t *) xcalloc(1, sizeof(file_header_t));
|
||||
|
||||
typed->size = (size_t) atoi(ar.formated.size);
|
||||
/* long filenames have '/' as the first character */
|
||||
if (ar.formated.name[0] == '/') {
|
||||
if (ar.formated.name[1] == '/') {
|
||||
/* If the second char is a '/' then this entries data section
|
||||
* stores long filename for multiple entries, they are stored
|
||||
* in static variable long_names for use in future entries */
|
||||
ar_long_names = (char *) xrealloc(ar_long_names, typed->size);
|
||||
fread(ar_long_names, 1, typed->size, src_stream);
|
||||
archive_offset += typed->size;
|
||||
/* This ar entries data section only contained filenames for other records
|
||||
* they are stored in the static ar_long_names for future reference */
|
||||
return (get_header_ar(src_stream)); /* Return next header */
|
||||
} else if (ar.formated.name[1] == ' ') {
|
||||
/* This is the index of symbols in the file for compilers */
|
||||
seek_sub_file(src_stream, typed->size);
|
||||
return (get_header_ar(src_stream)); /* Return next header */
|
||||
} else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
if (!ar_long_names) {
|
||||
error_msg("Cannot resolve long file name");
|
||||
return (NULL);
|
||||
}
|
||||
typed->name = xstrdup(ar_long_names + atoi(&ar.formated.name[1]));
|
||||
}
|
||||
} else {
|
||||
/* short filenames */
|
||||
typed->name = xcalloc(1, 16);
|
||||
strncpy(typed->name, ar.formated.name, 16);
|
||||
}
|
||||
typed->name[strcspn(typed->name, " /")]='\0';
|
||||
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(ar.formated.mode, &typed->mode);
|
||||
typed->mtime = atoi(ar.formated.date);
|
||||
typed->uid = atoi(ar.formated.uid);
|
||||
typed->gid = atoi(ar.formated.gid);
|
||||
|
||||
return(typed);
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
struct hardlinks {
|
||||
file_header_t *entry;
|
||||
int inode;
|
||||
struct hardlinks *next;
|
||||
};
|
||||
|
||||
file_header_t *get_header_cpio(FILE *src_stream)
|
||||
{
|
||||
file_header_t *cpio_entry = NULL;
|
||||
char cpio_header[110];
|
||||
int namesize;
|
||||
char dummy[16];
|
||||
int major, minor, nlink, inode;
|
||||
static struct hardlinks *saved_hardlinks = NULL;
|
||||
static int pending_hardlinks = 0;
|
||||
|
||||
if (pending_hardlinks) { /* Deal with any pending hardlinks */
|
||||
struct hardlinks *tmp = saved_hardlinks, *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */
|
||||
cpio_entry = tmp->entry;
|
||||
if (oldtmp) oldtmp->next = tmp->next; /* Remove item from linked list */
|
||||
else saved_hardlinks = tmp->next;
|
||||
free(tmp);
|
||||
return (cpio_entry);
|
||||
}
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */
|
||||
}
|
||||
|
||||
/* There can be padding before archive header */
|
||||
seek_sub_file(src_stream, (4 - (archive_offset % 4)) % 4);
|
||||
if (fread(cpio_header, 1, 110, src_stream) == 110) {
|
||||
archive_offset += 110;
|
||||
if (strncmp(cpio_header, "07070", 5) != 0) {
|
||||
error_msg("Unsupported format or invalid magic");
|
||||
return(NULL);
|
||||
}
|
||||
switch (cpio_header[5]) {
|
||||
case '2': /* "crc" header format */
|
||||
/* Doesnt do the crc check yet */
|
||||
case '1': /* "newc" header format */
|
||||
cpio_entry = (file_header_t *) xcalloc(1, sizeof(file_header_t));
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&cpio_entry->mode,
|
||||
(unsigned int*)&cpio_entry->uid, (unsigned int*)&cpio_entry->gid,
|
||||
&nlink, &cpio_entry->mtime, &cpio_entry->size,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
|
||||
cpio_entry->name = (char *) xcalloc(1, namesize);
|
||||
fread(cpio_entry->name, 1, namesize, src_stream); /* Read in filename */
|
||||
archive_offset += namesize;
|
||||
/* Skip padding before file contents */
|
||||
seek_sub_file(src_stream, (4 - (archive_offset % 4)) % 4);
|
||||
if (strcmp(cpio_entry->name, "TRAILER!!!") == 0) {
|
||||
printf("%d blocks\n", (int) (archive_offset % 512 ? (archive_offset / 512) + 1 : archive_offset / 512)); /* Always round up */
|
||||
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
|
||||
struct hardlinks *tmp = saved_hardlinks, *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free (oldtmp->entry->name);
|
||||
free (oldtmp->entry);
|
||||
free (oldtmp);
|
||||
}
|
||||
saved_hardlinks = NULL;
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (S_ISLNK(cpio_entry->mode)) {
|
||||
cpio_entry->link_name = (char *) xcalloc(1, cpio_entry->size + 1);
|
||||
fread(cpio_entry->link_name, 1, cpio_entry->size, src_stream);
|
||||
archive_offset += cpio_entry->size;
|
||||
cpio_entry->size = 0; /* Stop possiable seeks in future */
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(cpio_entry->mode)) {
|
||||
if (cpio_entry->size == 0) { /* Put file on a linked list for later */
|
||||
struct hardlinks *new = xmalloc(sizeof(struct hardlinks));
|
||||
new->next = saved_hardlinks;
|
||||
new->inode = inode;
|
||||
new->entry = cpio_entry;
|
||||
saved_hardlinks = new;
|
||||
return(get_header_cpio(src_stream)); /* Recurse to next file */
|
||||
} else { /* Found the file with data in */
|
||||
struct hardlinks *tmp = saved_hardlinks;
|
||||
pending_hardlinks = 1;
|
||||
while (tmp) {
|
||||
if (tmp->inode == inode) {
|
||||
tmp->entry->link_name = xstrdup(cpio_entry->name);
|
||||
nlink--;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (nlink > 1) error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
|
||||
}
|
||||
}
|
||||
cpio_entry->device = (major << 8) | minor;
|
||||
break;
|
||||
default:
|
||||
error_msg("Unsupported format");
|
||||
return(NULL);
|
||||
}
|
||||
if (ferror(src_stream) || feof(src_stream)) {
|
||||
perror_msg("Stream error");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
return(cpio_entry);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
file_header_t *get_header_tar(FILE *tar_stream)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[512];
|
||||
struct {
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} formated;
|
||||
} tar;
|
||||
file_header_t *tar_entry = NULL;
|
||||
long sum = 0;
|
||||
long i;
|
||||
|
||||
if (archive_offset % 512 != 0) {
|
||||
seek_sub_file(tar_stream, 512 - (archive_offset % 512));
|
||||
}
|
||||
|
||||
if (fread(tar.raw, 1, 512, tar_stream) != 512) {
|
||||
/* Unfortunatly its common for tar files to have all sorts of
|
||||
* trailing garbage, fail silently */
|
||||
// error_msg("Couldnt read header");
|
||||
return(NULL);
|
||||
}
|
||||
archive_offset += 512;
|
||||
|
||||
/* Check header has valid magic, unfortunately some tar files
|
||||
* have empty (0'ed) tar entries at the end, which will
|
||||
* cause this to fail, so fail silently for now
|
||||
*/
|
||||
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Do checksum on headers */
|
||||
for (i = 0; i < 148 ; i++) {
|
||||
sum += tar.raw[i];
|
||||
}
|
||||
sum += ' ' * 8;
|
||||
for (i = 156; i < 512 ; i++) {
|
||||
sum += tar.raw[i];
|
||||
}
|
||||
if (sum != strtol(tar.formated.chksum, NULL, 8)) {
|
||||
error_msg("Invalid tar header checksum");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* convert to type'ed variables */
|
||||
tar_entry = xcalloc(1, sizeof(file_header_t));
|
||||
tar_entry->name = xstrdup(tar.formated.name);
|
||||
|
||||
parse_mode(tar.formated.mode, &tar_entry->mode);
|
||||
tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
|
||||
tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
|
||||
tar_entry->size = strtol(tar.formated.size, NULL, 8);
|
||||
tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
|
||||
tar_entry->link_name = strlen(tar.formated.linkname) ?
|
||||
xstrdup(tar.formated.linkname) : NULL;
|
||||
tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) +
|
||||
strtol(tar.formated.devminor, NULL, 8);
|
||||
|
||||
return(tar_entry);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
off_t archive_offset;
|
||||
|
||||
void seek_sub_file(FILE *src_stream, const int count)
|
||||
{
|
||||
/* Try to fseek as faster */
|
||||
archive_offset += count;
|
||||
if (fseek(src_stream, count, SEEK_CUR) != 0 && errno == ESPIPE) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
fgetc(src_stream);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* Extract the data postioned at src_stream to either filesystem, stdout or
|
||||
* buffer depending on the value of 'function' which is defined in libbb.h
|
||||
*
|
||||
* prefix doesnt have to be just a directory, it may prefix the filename as well.
|
||||
*
|
||||
* e.g. '/var/lib/dpkg/info/dpkg.' will extract all files to the base bath
|
||||
* '/var/lib/dpkg/info/' and all files/dirs created in that dir will have
|
||||
* 'dpkg.' as their prefix
|
||||
*
|
||||
* For this reason if prefix does point to a dir then it must end with a
|
||||
* trailing '/' or else the last dir will be assumed to be the file prefix
|
||||
*/
|
||||
char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry,
|
||||
const int function, const char *prefix)
|
||||
{
|
||||
FILE *dst_stream = NULL;
|
||||
char *full_name = NULL;
|
||||
char *buffer = NULL;
|
||||
struct utimbuf t;
|
||||
|
||||
/* prefix doesnt have to be a proper path it may prepend
|
||||
* the filename as well */
|
||||
if (prefix != NULL) {
|
||||
/* strip leading '/' in filename to extract as prefix may not be dir */
|
||||
/* Cant use concat_path_file here as prefix might not be a directory */
|
||||
char *path = file_entry->name;
|
||||
if (strncmp("./", path, 2) == 0) {
|
||||
path += 2;
|
||||
if (strlen(path) == 0) {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
full_name = xmalloc(strlen(prefix) + strlen(path) + 1);
|
||||
strcpy(full_name, prefix);
|
||||
strcat(full_name, path);
|
||||
} else {
|
||||
full_name = file_entry->name;
|
||||
}
|
||||
if (function & extract_to_stdout) {
|
||||
if (S_ISREG(file_entry->mode)) {
|
||||
copy_file_chunk(src_stream, out_stream, file_entry->size);
|
||||
archive_offset += file_entry->size;
|
||||
}
|
||||
}
|
||||
else if (function & extract_one_to_buffer) {
|
||||
if (S_ISREG(file_entry->mode)) {
|
||||
buffer = (char *) xmalloc(file_entry->size + 1);
|
||||
fread(buffer, 1, file_entry->size, src_stream);
|
||||
buffer[file_entry->size] = '\0';
|
||||
archive_offset += file_entry->size;
|
||||
return(buffer);
|
||||
}
|
||||
}
|
||||
else if (function & extract_all_to_fs) {
|
||||
struct stat oldfile;
|
||||
int stat_res;
|
||||
stat_res = lstat (full_name, &oldfile);
|
||||
if (stat_res == 0) { /* The file already exists */
|
||||
if ((function & extract_unconditional) || (oldfile.st_mtime < file_entry->mtime)) {
|
||||
if (!S_ISDIR(oldfile.st_mode)) {
|
||||
unlink(full_name); /* Directories might not be empty etc */
|
||||
}
|
||||
} else {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
error_msg("%s not created: newer or same age file exists", file_entry->name);
|
||||
}
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */
|
||||
char *buf, *parent;
|
||||
buf = xstrdup(full_name);
|
||||
parent = dirname(buf);
|
||||
if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
error_msg("couldn't create leading directories");
|
||||
}
|
||||
}
|
||||
free (buf);
|
||||
}
|
||||
switch(file_entry->mode & S_IFMT) {
|
||||
case S_IFREG:
|
||||
if (file_entry->link_name) { /* Found a cpio hard link */
|
||||
if (link(file_entry->link_name, full_name) != 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("Cannot link from %s to '%s'",
|
||||
file_entry->name, file_entry->link_name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((dst_stream = wfopen(full_name, "w")) == NULL) {
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
return NULL;
|
||||
}
|
||||
archive_offset += file_entry->size;
|
||||
copy_file_chunk(src_stream, dst_stream, file_entry->size);
|
||||
fclose(dst_stream);
|
||||
}
|
||||
break;
|
||||
case S_IFDIR:
|
||||
if (stat_res != 0) {
|
||||
if (mkdir(full_name, file_entry->mode) < 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("extract_archive: %s", full_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
if (symlink(file_entry->link_name, full_name) < 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
if (mknod(full_name, file_entry->mode, file_entry->device) == -1) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("Cannot create node %s", file_entry->name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Changing a symlink's properties normally changes the properties of the
|
||||
* file pointed to, so dont try and change the date or mode, lchown does
|
||||
* does the right thing, but isnt available in older versions of libc */
|
||||
if (S_ISLNK(file_entry->mode)) {
|
||||
#if (__GLIBC__ > 2) && (__GLIBC_MINOR__ > 1)
|
||||
lchown(full_name, file_entry->uid, file_entry->gid);
|
||||
#endif
|
||||
} else {
|
||||
if (function & extract_preserve_date) {
|
||||
t.actime = file_entry->mtime;
|
||||
t.modtime = file_entry->mtime;
|
||||
utime(full_name, &t);
|
||||
}
|
||||
chmod(full_name, file_entry->mode);
|
||||
chown(full_name, file_entry->uid, file_entry->gid);
|
||||
}
|
||||
} else {
|
||||
/* If we arent extracting data we have to skip it,
|
||||
* if data size is 0 then then just do it anyway
|
||||
* (saves testing for it) */
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
}
|
||||
|
||||
/* extract_list and extract_verbose_list can be used in conjunction
|
||||
* with one of the above four extraction functions, so do this seperately */
|
||||
if (function & extract_verbose_list) {
|
||||
fprintf(out_stream, "%s %d/%d %8d %s ", mode_string(file_entry->mode),
|
||||
file_entry->uid, file_entry->gid,
|
||||
(int) file_entry->size, time_string(file_entry->mtime));
|
||||
}
|
||||
if ((function & extract_list) || (function & extract_verbose_list)){
|
||||
/* fputs doesnt add a trailing \n, so use fprintf */
|
||||
fprintf(out_stream, "%s\n", full_name);
|
||||
}
|
||||
|
||||
free(full_name);
|
||||
|
||||
return(NULL); /* Maybe we should say if failed */
|
||||
}
|
||||
|
||||
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *),
|
||||
const int extract_function, const char *prefix, char **include_name, char **exclude_name)
|
||||
{
|
||||
file_header_t *file_entry;
|
||||
int extract_flag = TRUE;
|
||||
int i;
|
||||
char *buffer = NULL;
|
||||
|
||||
archive_offset = 0;
|
||||
while ((file_entry = get_headers(src_stream)) != NULL) {
|
||||
|
||||
if (include_name != NULL) {
|
||||
extract_flag = FALSE;
|
||||
for(i = 0; include_name[i] != 0; i++) {
|
||||
if (fnmatch(include_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
|
||||
extract_flag = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
|
||||
/* If the file entry is in the exclude list dont extract it */
|
||||
if (exclude_name != NULL) {
|
||||
for(i = 0; exclude_name[i] != 0; i++) {
|
||||
if (fnmatch(exclude_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
|
||||
extract_flag = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (extract_flag == TRUE) {
|
||||
buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
|
||||
} else {
|
||||
/* seek past the data entry */
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
}
|
||||
free(file_entry->name);
|
||||
free(file_entry->link_name);
|
||||
free(file_entry);
|
||||
}
|
||||
return(buffer);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ static char *license_msg[] = {
|
||||
#include <string.h>
|
||||
#include "libbb.h"
|
||||
|
||||
FILE *in_file, *out_file;
|
||||
static FILE *in_file, *out_file;
|
||||
|
||||
/* these are freed by gz_close */
|
||||
static unsigned char *window;
|
||||
@@ -91,9 +91,9 @@ static const int N_MAX = 288; /* maximum number of codes in any set */
|
||||
static long bytes_out; /* number of output bytes */
|
||||
static unsigned long outcnt; /* bytes in output buffer */
|
||||
|
||||
unsigned hufts; /* track memory usage */
|
||||
unsigned long bb; /* bit buffer */
|
||||
unsigned bk; /* bits in bit buffer */
|
||||
static unsigned hufts; /* track memory usage */
|
||||
static unsigned long bb; /* bit buffer */
|
||||
static unsigned bk; /* bits in bit buffer */
|
||||
|
||||
typedef struct huft_s {
|
||||
unsigned char e; /* number of extra bits or operation */
|
||||
@@ -104,7 +104,7 @@ typedef struct huft_s {
|
||||
} v;
|
||||
} huft_t;
|
||||
|
||||
unsigned short mask_bits[] = {
|
||||
static const unsigned short mask_bits[] = {
|
||||
0x0000,
|
||||
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
@@ -115,13 +115,13 @@ unsigned short mask_bits[] = {
|
||||
* Signal and error handler.
|
||||
*/
|
||||
|
||||
static void abort_gzip()
|
||||
static void abort_gzip(void)
|
||||
{
|
||||
error_msg("gzip aborted\n");
|
||||
exit(ERROR);
|
||||
}
|
||||
|
||||
static void make_crc_table()
|
||||
static void make_crc_table(void)
|
||||
{
|
||||
unsigned long table_entry; /* crc shift register */
|
||||
unsigned long poly = 0; /* polynomial exclusive-or pattern */
|
||||
@@ -154,7 +154,7 @@ static void make_crc_table()
|
||||
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
|
||||
* (Used for the decompressed data only.)
|
||||
*/
|
||||
void flush_window()
|
||||
static void flush_window(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -853,7 +853,7 @@ static int inflate_block(int *e)
|
||||
*
|
||||
* GLOBAL VARIABLES: outcnt, bk, bb, hufts, inptr
|
||||
*/
|
||||
static int inflate()
|
||||
static int inflate(void)
|
||||
{
|
||||
int e; /* last block flag */
|
||||
int r; /* result code */
|
||||
@@ -925,9 +925,6 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
outcnt = 0;
|
||||
bytes_out = 0L;
|
||||
|
||||
/* set the buffer size */
|
||||
setvbuf(in_file, NULL, _IOFBF, 0x8000);
|
||||
|
||||
magic[0] = fgetc(in_file);
|
||||
magic[1] = fgetc(in_file);
|
||||
|
||||
@@ -1024,6 +1021,6 @@ extern void gz_close(int gunzip_pid)
|
||||
if (waitpid(gunzip_pid, NULL, 0) == -1) {
|
||||
printf("Couldnt wait ?");
|
||||
}
|
||||
free(window);
|
||||
free(crc_table);
|
||||
free(window);
|
||||
free(crc_table);
|
||||
}
|
||||
+13
-15
@@ -26,27 +26,23 @@
|
||||
#define RPM_MAGIC "\355\253\356\333"
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
|
||||
struct rpm_lead {
|
||||
unsigned char magic[4];
|
||||
u8 major, minor;
|
||||
u16 type;
|
||||
u16 archnum;
|
||||
u_int8_t major, minor;
|
||||
u_int16_t type;
|
||||
u_int16_t archnum;
|
||||
char name[66];
|
||||
u16 osnum;
|
||||
u16 signature_type;
|
||||
u_int16_t osnum;
|
||||
u_int16_t signature_type;
|
||||
char reserved[16];
|
||||
};
|
||||
|
||||
struct rpm_header {
|
||||
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
|
||||
u8 version; /* 1 byte version number */
|
||||
u32 reserved; /* 4 bytes reserved */
|
||||
u32 entries; /* Number of entries in header (4 bytes) */
|
||||
u32 size; /* Size of store (4 bytes) */
|
||||
u_int8_t version; /* 1 byte version number */
|
||||
u_int32_t reserved; /* 4 bytes reserved */
|
||||
u_int32_t entries; /* Number of entries in header (4 bytes) */
|
||||
u_int32_t size; /* Size of store (4 bytes) */
|
||||
};
|
||||
|
||||
void skip_header(FILE *rpmfile)
|
||||
@@ -72,8 +68,9 @@ extern int rpm2cpio_main(int argc, char **argv)
|
||||
if (argc == 1) {
|
||||
rpmfile = stdin;
|
||||
} else {
|
||||
rpmfile = fopen(argv[1], "r");
|
||||
if (!rpmfile) perror_msg_and_die("Can't open rpm file");
|
||||
rpmfile = xfopen(argv[1], "r");
|
||||
/* set the buffer size */
|
||||
setvbuf(rpmfile, NULL, _IOFBF, 0x8000);
|
||||
}
|
||||
|
||||
fread (&lead, sizeof(struct rpm_lead), 1, rpmfile);
|
||||
@@ -85,6 +82,7 @@ extern int rpm2cpio_main(int argc, char **argv)
|
||||
skip_header(rpmfile);
|
||||
|
||||
cpiofile = gz_open(rpmfile, &gunzip_pid);
|
||||
|
||||
copyfd(fileno(cpiofile), fileno(stdout));
|
||||
gz_close(gunzip_pid);
|
||||
fclose(rpmfile);
|
||||
|
||||
+316
-708
File diff suppressed because it is too large.
Load diff
-52
@@ -1,52 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini basename 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if (m>=n && strncmp(s+m-n, *argv, n)==0)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
puts(s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *applet_name;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static char* install_dir[] = {
|
||||
"/",
|
||||
"/bin",
|
||||
"/sbin",
|
||||
"/usr/bin",
|
||||
"/usr/sbin",
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*__link_f)(const char *, const char *);
|
||||
|
||||
/*
|
||||
* Where in the filesystem is this busybox?
|
||||
* [return]
|
||||
* malloc'd string w/ full pathname of busybox's location
|
||||
* NULL on failure
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
{
|
||||
return xreadlink("/proc/self/exe");
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, fpc);
|
||||
if (rc!=0 && errno!=EEXIST) {
|
||||
perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
/* Add in a special case hack for a leading hyphen */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
applet_name = (*argv+1);
|
||||
}
|
||||
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#ifdef BB_INIT
|
||||
if(getpid()!=1) /* Do not set locale for `init' */
|
||||
#endif
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
* If someone has a cleaner approach, by all means implement it.
|
||||
*/
|
||||
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
||||
int use_symbolic_links = 0;
|
||||
int rc = 0;
|
||||
char *busybox;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct BB_applet *a = applets;
|
||||
|
||||
fprintf(stderr, "%s\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use, and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as.\n"
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
if (col > 60 && a->name != 0) {
|
||||
fprintf(stderr, ",\n");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* Move the command line down a notch */
|
||||
len = argv[argc] + strlen(argv[argc]) - argv[1];
|
||||
memmove(argv[0], argv[1], len);
|
||||
memset(argv[0] + len, 0, argv[1] - argv[0]);
|
||||
|
||||
/* Fix up the argv pointers */
|
||||
len = argv[1] - argv[0];
|
||||
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] -= len;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,103 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Busybox main internal header file
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
#ifndef _BB_INTERNAL_H_
|
||||
#define _BB_INTERNAL_H_ 1
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
|
||||
#include <features.h>
|
||||
|
||||
|
||||
enum Location {
|
||||
_BB_DIR_ROOT = 0,
|
||||
_BB_DIR_BIN,
|
||||
_BB_DIR_SBIN,
|
||||
_BB_DIR_USR_BIN,
|
||||
_BB_DIR_USR_SBIN
|
||||
};
|
||||
|
||||
struct BB_applet {
|
||||
const char* name;
|
||||
int (*main)(int argc, char** argv);
|
||||
enum Location location;
|
||||
};
|
||||
/* From busybox.c */
|
||||
extern const struct BB_applet applets[];
|
||||
|
||||
/* Automagically pull in all the applet function prototypes and
|
||||
* applet usage strings. These are all of the form:
|
||||
* extern int foo_main(int argc, char **argv);
|
||||
* extern const char foo_usage[];
|
||||
* These are all autogenerated from the set of currently defined applets.
|
||||
*/
|
||||
#define PROTOTYPES
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
|
||||
#else
|
||||
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
|
||||
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) static unsigned char buffer[len]
|
||||
#else
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Bit map related macros -- libc5 doens't provide these... sigh. */
|
||||
#ifndef setbit
|
||||
#define NBBY CHAR_BIT
|
||||
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
|
||||
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
|
||||
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
|
||||
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
||||
#endif
|
||||
|
||||
#ifndef RB_POWER_OFF
|
||||
/* Stop system and switch power off if possible. */
|
||||
#define RB_POWER_OFF 0x4321fedc
|
||||
#endif
|
||||
|
||||
|
||||
/* Pull in the utility routines from libbb */
|
||||
#include "libbb/libbb.h"
|
||||
|
||||
|
||||
|
||||
#endif /* _BB_INTERNAL_H_ */
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
gsub("\"","",file)
|
||||
if (file=="busybox") next
|
||||
print tolower(dir) "/" file
|
||||
}'
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
if [ -d "$BB_SRC_DIR" ]; then cd $BB_SRC_DIR; fi
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
Name: busybox
|
||||
Version: 0.52
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
Copyright: GPL
|
||||
Packager : Erik Andersen <andersen@lineo.com>
|
||||
Conflicts: fileutils grep shellutils
|
||||
Buildroot: /tmp/%{Name}-%{Version}
|
||||
Source: %{Name}-%{Version}.tar.gz
|
||||
|
||||
%Description
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
|
||||
tar, etc. BusyBox provides a fairly complete POSIX environment for any small
|
||||
or emdedded system. The utilities in BusyBox generally have fewer options then
|
||||
their full featured GNU cousins; however, the options that are provided behave
|
||||
very much like their GNU counterparts.
|
||||
|
||||
%Prep
|
||||
%setup -q -n %{Name}-%{Version}
|
||||
|
||||
%Build
|
||||
make
|
||||
|
||||
%Install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make PREFIX=$RPM_BUILD_ROOT install
|
||||
|
||||
%Clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%Files
|
||||
%defattr(-,root,root)
|
||||
/
|
||||
@@ -1,53 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
return status;
|
||||
}
|
||||
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,91 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* 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:
|
||||
*/
|
||||
@@ -1,85 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (!parse_mode((char *)junk, &(statbuf->st_mode)))
|
||||
error_msg_and_die("internal error");
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* Parse the specified mode */
|
||||
mode_t mode;
|
||||
if (parse_mode(argv[optind], &mode) == FALSE) {
|
||||
error_msg_and_die( "unknown mode: %s", argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
for (i = optind + 1; i < argc; i++) {
|
||||
if (recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction,
|
||||
fileAction, argv[optind]) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,113 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
static long uid;
|
||||
static long gid;
|
||||
|
||||
static int (*chown_func)() = chown;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chown_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int recursiveFlag = FALSE,
|
||||
noderefFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "Rh")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
noderefFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (noderefFlag) chown_func = lchown;
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* First, check if there is a group name here */
|
||||
groupName = strchr(argv[optind], '.');
|
||||
if (groupName == NULL)
|
||||
groupName = strchr(argv[optind], ':');
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = strtoul(groupName, &p, 10);
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
} else {
|
||||
gid = -1;
|
||||
}
|
||||
/* Now check for the username */
|
||||
uid = strtoul(argv[optind], &p, 10); /* Is is numeric? */
|
||||
if (argv[optind] == p) {
|
||||
uid = my_getpwnam(argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
while (++optind < argc) {
|
||||
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,75 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
char shell[] = "/bin/sh";
|
||||
char *shell_argv[2] = { shell, NULL };
|
||||
applet_name = shell;
|
||||
shell_main(1, shell_argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,43 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* chvt.c - aeb - 940227 - Change virtual terminal
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,34 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef CMDEDIT_H
|
||||
#define CMDEDIT_H
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_terminate(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
|
||||
|
||||
#endif /* CMDEDIT_H */
|
||||
@@ -1,80 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1, *filename2 = "-";
|
||||
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
|
||||
|
||||
while ((c = getopt(argc, argv, "s")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
silent = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
filename1 = argv[optind];
|
||||
switch (argc - optind) {
|
||||
case 2:
|
||||
fp2 = xfopen(filename2 = argv[optind + 1], "r");
|
||||
case 1:
|
||||
fp1 = xfopen(filename1, "r");
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (silent)
|
||||
return EXIT_FAILURE;
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=..
|
||||
L_TARGET := console-tools.a
|
||||
|
||||
obj-y :=
|
||||
obj-n :=
|
||||
obj- :=
|
||||
|
||||
obj-$(CONFIG_CHVT) += chvt.o
|
||||
obj-$(CONFIG_CLEAR) += clear.o
|
||||
obj-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
obj-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
obj-$(CONFIG_LOADACM) += loadacm.o
|
||||
obj-$(CONFIG_LOADFONT) += loadfont.o
|
||||
obj-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
obj-$(CONFIG_RESET) += reset.o
|
||||
obj-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
mainmenu_option next_comment
|
||||
comment 'Console Utilities'
|
||||
bool 'chvt' CONFIG_CHVT
|
||||
bool 'clear' CONFIG_CLEAR
|
||||
bool 'deallocvt' CONFIG_DEALLOCVT
|
||||
bool 'dumpkmap' CONFIG_DUMPKMAP
|
||||
bool 'loadacm' CONFIG_LOADACM
|
||||
bool 'loadfont' CONFIG_LOADFONT
|
||||
bool 'loadkmap' CONFIG_LOADKMAP
|
||||
bool 'reset' CONFIG_RESET
|
||||
bool 'setkeycodes' CONFIG_SETKEYCODES
|
||||
|
||||
endmenu
|
||||
@@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg("Error opening /dev/tty0");
|
||||
perror_msg("Error opening " CURRENT_VC);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg_and_die("Error opening /dev/tty1");
|
||||
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
|
||||
@@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
loadnewfont(fd);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
/*
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* and Kent Robotti <robotti@metconnect.com>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -44,7 +44,7 @@ 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';
|
||||
}
|
||||
puts(s);
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+3
-4
@@ -1,10 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
* Mini chgrp 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
|
||||
|
||||
+3
-4
@@ -1,10 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
* Mini chmod 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
|
||||
|
||||
+4
-5
@@ -1,10 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
* Mini chown 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
|
||||
@@ -36,7 +35,7 @@
|
||||
static long uid;
|
||||
static long gid;
|
||||
|
||||
static int (*chown_func)() = chown;
|
||||
static int (*chown_func)(const char *, __uid_t, __gid_t) = chown;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
|
||||
+8
-9
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -48,17 +47,17 @@ int chroot_main(int argc, char **argv)
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
#if defined shell_main && defined CONFIG_FEATURE_SH_STANDALONE_SHELL
|
||||
char shell[] = "/bin/sh";
|
||||
char *shell_argv[2] = { shell, NULL };
|
||||
applet_name = shell;
|
||||
shell_main(1, shell_argv);
|
||||
return EXIT_SUCCESS;
|
||||
#else
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#endif
|
||||
}
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
+1
-3
@@ -2,9 +2,7 @@
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
* Copyright (C) 2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+4
-4
@@ -36,7 +36,7 @@ extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
int opt;
|
||||
int flags = 0;
|
||||
int flags = FILEUTILS_DEREFERENCE;
|
||||
int i;
|
||||
|
||||
while ((opt = getopt(argc, argv, "adfipR")) != -1)
|
||||
@@ -45,7 +45,7 @@ extern int cp_main(int argc, char **argv)
|
||||
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
|
||||
/* fallthrough */
|
||||
case 'd':
|
||||
flags |= FILEUTILS_PRESERVE_SYMLINKS;
|
||||
flags &= ~FILEUTILS_DEREFERENCE;
|
||||
break;
|
||||
case 'f':
|
||||
flags |= FILEUTILS_FORCE;
|
||||
@@ -73,9 +73,9 @@ extern int cp_main(int argc, char **argv)
|
||||
int source_exists = 1;
|
||||
int dest_exists = 1;
|
||||
|
||||
if (((flags & FILEUTILS_PRESERVE_SYMLINKS) &&
|
||||
if ((!(flags & FILEUTILS_DEREFERENCE) &&
|
||||
lstat(argv[optind], &source_stat) < 0) ||
|
||||
(!(flags & FILEUTILS_PRESERVE_SYMLINKS) &&
|
||||
((flags & FILEUTILS_DEREFERENCE) &&
|
||||
stat(argv[optind], &source_stat))) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind]);
|
||||
|
||||
+2
-4
@@ -344,10 +344,8 @@ extern int cut_main(int argc, char **argv)
|
||||
int i;
|
||||
FILE *file;
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
file = wfopen(argv[i], "r");
|
||||
if(file) {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
+2
-6
@@ -50,7 +50,6 @@ int dd_main(int argc, char **argv)
|
||||
size_t bs = 512, count = -1;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
FILE *statusfp;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
@@ -110,12 +109,9 @@ int dd_main(int argc, char **argv)
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
if (skip) {
|
||||
@@ -151,8 +147,8 @@ int dd_main(int argc, char **argv)
|
||||
out_part++;
|
||||
}
|
||||
|
||||
fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
|
||||
fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
|
||||
fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
|
||||
fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+6
-6
@@ -2,8 +2,8 @@
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "busybox.h"
|
||||
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
static unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@ static int do_df(char *device, const char *mount_point)
|
||||
if(device==NULL)
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
printf("%-20s %9s ", device,
|
||||
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
|
||||
|
||||
@@ -92,13 +92,13 @@ extern int df_main(int argc, char **argv)
|
||||
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
|
||||
|
||||
while ((opt = getopt(argc, argv, "k"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
)) > 0)
|
||||
{
|
||||
switch (opt) {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
case 'h':
|
||||
df_disp_hr = 0;
|
||||
strcpy(disp_units_hdr, " Size");
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+68
-19
@@ -29,21 +29,60 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* We are making a lame pseudo-random string generator here. in
|
||||
* convert(), each pass through the while loop will add more and more
|
||||
* stuff into value, which is _supposed_ to wrap. We don't care about
|
||||
* it being accurate. We care about it being messy, since we then mod
|
||||
* it by the sizeof(letters) and then use that as an index into letters
|
||||
* to pick a random letter to add to out temporary file. */
|
||||
typedef unsigned long int bb_uint64_t;
|
||||
|
||||
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
// if fn is NULL then input is stdin and output is stdout
|
||||
static int convert(char *fn, int ConvType) {
|
||||
int c;
|
||||
char *tempFn = NULL;
|
||||
static int convert(char *fn, int ConvType)
|
||||
{
|
||||
int c, fd;
|
||||
struct timeval tv;
|
||||
char tempFn[BUFSIZ];
|
||||
static bb_uint64_t value=0;
|
||||
FILE *in = stdin, *out = stdout;
|
||||
|
||||
if (fn != NULL) {
|
||||
if ((in = wfopen(fn, "r")) == NULL) {
|
||||
if ((in = wfopen(fn, "rw")) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if ((out = tmpfile()) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
strcpy(tempFn, fn);
|
||||
c = strlen(tempFn);
|
||||
tempFn[c] = '.';
|
||||
while(1) {
|
||||
if (c >=BUFSIZ)
|
||||
error_msg_and_die("unique name not found");
|
||||
/* Get some semi random stuff to try and make a
|
||||
* random filename based (and in the same dir as)
|
||||
* the input file... */
|
||||
gettimeofday (&tv, NULL);
|
||||
value += ((bb_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
|
||||
tempFn[++c] = letters[value % 62];
|
||||
tempFn[c+1] = '\0';
|
||||
value /= 62;
|
||||
|
||||
if ((fd = open(tempFn, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0 ) {
|
||||
continue;
|
||||
}
|
||||
out = fdopen(fd, "w+");
|
||||
if (!out) {
|
||||
close(fd);
|
||||
remove(tempFn);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +90,7 @@ static int convert(char *fn, int ConvType) {
|
||||
if (c == '\r') {
|
||||
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
|
||||
// file is alredy in DOS format so it is not necessery to touch it
|
||||
remove(tempFn);
|
||||
if (fclose(in) < 0 || fclose(out) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
@@ -64,6 +104,7 @@ static int convert(char *fn, int ConvType) {
|
||||
if (c == '\n') {
|
||||
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
|
||||
// file is alredy in UNIX format so it is not necessery to touch it
|
||||
remove(tempFn);
|
||||
if ((fclose(in) < 0) || (fclose(out) < 0)) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
@@ -95,29 +136,37 @@ static int convert(char *fn, int ConvType) {
|
||||
}
|
||||
|
||||
if (fn != NULL) {
|
||||
if (fclose(in) < 0 || fclose(out) < 0 ||
|
||||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
if (fclose(in) < 0 || fclose(out) < 0) {
|
||||
perror_msg(NULL);
|
||||
remove(tempFn);
|
||||
return -2;
|
||||
}
|
||||
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
fputc(c, out);
|
||||
}
|
||||
|
||||
if ((fclose(in) < 0) || (fclose(out) < 0)) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
/* Assume they are both on the same filesystem (which
|
||||
* should be true since we put them into the same directory
|
||||
* so we _should_ be ok, but you never know... */
|
||||
if (rename(tempFn, fn) < 0) {
|
||||
perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dos2unix_main(int argc, char *argv[]) {
|
||||
int dos2unix_main(int argc, char *argv[])
|
||||
{
|
||||
int ConvType = CT_AUTO;
|
||||
int o;
|
||||
|
||||
//See if we are supposed to be doing dos2unix or unix2dos
|
||||
if (argv[0][0]=='d') {
|
||||
ConvType = CT_DOS2UNIX;
|
||||
}
|
||||
if (argv[0][0]=='u') {
|
||||
ConvType = CT_UNIX2DOS;
|
||||
}
|
||||
|
||||
// process parameters
|
||||
while ((o = getopt(argc, argv, "du")) != EOF) {
|
||||
switch (o) {
|
||||
|
||||
+7
-8
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini du implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc. and John Beppu
|
||||
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -33,7 +32,7 @@
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
static unsigned long disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
@@ -46,7 +45,7 @@ static Display *print;
|
||||
|
||||
static void print_normal(long size, char *filename)
|
||||
{
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
printf("%s\t%s\n", make_human_readable_str(size<<10, 1, disp_hr), filename);
|
||||
#else
|
||||
printf("%ld\t%s\n", size, filename);
|
||||
@@ -207,7 +206,7 @@ int du_main(int argc, char **argv)
|
||||
|
||||
/* parse argv[] */
|
||||
while ((c = getopt(argc, argv, "sl"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k")) != EOF) {
|
||||
@@ -218,7 +217,7 @@ int du_main(int argc, char **argv)
|
||||
case 'l':
|
||||
count_hardlinks = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
case 'h': disp_hr = 0; break;
|
||||
case 'm': disp_hr = MEGABYTE; break;
|
||||
#endif
|
||||
@@ -247,7 +246,7 @@ int du_main(int argc, char **argv)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: du.c,v 1.50 2001/06/30 17:54:20 andersen Exp $ */
|
||||
/* $Id: du.c,v 1.51 2001/10/24 04:59:27 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
|
||||
+6
-6
@@ -194,7 +194,7 @@ nextarg (char *str)
|
||||
/* The comparison operator handling functions. */
|
||||
|
||||
#define cmpf(name, rel) \
|
||||
static int name (l, r) VALUE *l; VALUE *r; \
|
||||
static int name (VALUE *l, VALUE *r) \
|
||||
{ \
|
||||
if (l->type == string || r->type == string) { \
|
||||
tostring (l); \
|
||||
@@ -217,7 +217,7 @@ static int name (l, r) VALUE *l; VALUE *r; \
|
||||
|
||||
#define arithf(name, op) \
|
||||
static \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
int name (VALUE *l, VALUE *r) \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ("non-numeric argument"); \
|
||||
@@ -225,7 +225,7 @@ int name (l, r) VALUE *l; VALUE *r; \
|
||||
}
|
||||
|
||||
#define arithdivf(name, op) \
|
||||
static int name (l, r) VALUE *l; VALUE *r; \
|
||||
static int name (VALUE *l, VALUE *r) \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ( "non-numeric argument"); \
|
||||
@@ -414,7 +414,7 @@ static VALUE *eval5 (void)
|
||||
static VALUE *eval4 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
int (*fxn) (VALUE *, VALUE *), val;
|
||||
|
||||
l = eval5 ();
|
||||
while (1) {
|
||||
@@ -440,7 +440,7 @@ static VALUE *eval4 (void)
|
||||
static VALUE *eval3 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
int (*fxn) (VALUE *, VALUE *), val;
|
||||
|
||||
l = eval4 ();
|
||||
while (1) {
|
||||
@@ -464,7 +464,7 @@ static VALUE *eval3 (void)
|
||||
static VALUE *eval2 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
int (*fxn) (VALUE *, VALUE *), val;
|
||||
|
||||
l = eval3 ();
|
||||
while (1) {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini true/false implementation for busybox
|
||||
* Mini false implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,12 +26,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int true_main(int argc, char **argv)
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
extern int false_main(int argc, char **argv)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
+3
-6
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini head implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Copyright (C) 1999 by Lineo, inc. and John Beppu
|
||||
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,7 +21,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
@@ -82,10 +80,9 @@ int head_main(int argc, char **argv)
|
||||
printf("==> %s <==\n", argv[optind]);
|
||||
}
|
||||
head(len, fp);
|
||||
if (errno) {
|
||||
if (ferror(fp)) {
|
||||
perror_msg("%s", argv[optind]);
|
||||
status = EXIT_FAILURE;
|
||||
errno = 0;
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
putchar('\n');
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
/*
|
||||
* Mini ln implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+61
-58
@@ -61,10 +61,11 @@ enum {
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
@@ -107,7 +108,7 @@ STYLE_COLUMNS = 3 /* fill columns */
|
||||
#define DISP_RECURSIVE (1<<4) /* show directory and everything below it */
|
||||
#define DISP_ROWS (1<<5) /* print across rows */
|
||||
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
/* how will the files be sorted */
|
||||
static const int SORT_FORWARD = 0; /* sort in reverse order */
|
||||
static const int SORT_REVERSE = 1; /* sort in reverse order */
|
||||
@@ -121,7 +122,7 @@ static const int SORT_EXT = 8; /* sort by file name extension */
|
||||
static const int SORT_DIR = 9; /* sort by file or directory */
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
/* which of the three times will be used */
|
||||
static const int TIME_MOD = 0;
|
||||
static const int TIME_CHANGE = 1;
|
||||
@@ -141,7 +142,7 @@ static const int SPLIT_SUBDIR = 2;
|
||||
|
||||
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
|
||||
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
|
||||
#endif
|
||||
|
||||
@@ -163,19 +164,19 @@ static int list_single(struct dnode *);
|
||||
static unsigned int disp_opts;
|
||||
static unsigned int style_fmt;
|
||||
static unsigned int list_fmt;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
static unsigned int sort_opts;
|
||||
static unsigned int sort_order;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
static unsigned int time_fmt;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
|
||||
static unsigned int follow_links=FALSE;
|
||||
#endif
|
||||
|
||||
static unsigned short column = 0;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
static unsigned short terminal_width = TERMINAL_WIDTH;
|
||||
static unsigned short column_width = COLUMN_WIDTH;
|
||||
static unsigned short tabstops = COLUMN_GAP;
|
||||
@@ -185,13 +186,13 @@ static unsigned short column_width = COLUMN_WIDTH;
|
||||
|
||||
static int status = EXIT_SUCCESS;
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
static unsigned long ls_disp_hr = 0;
|
||||
#endif
|
||||
|
||||
static int my_stat(struct dnode *cur)
|
||||
{
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
|
||||
if (follow_links == TRUE) {
|
||||
if (stat(cur->fullname, &cur->dstat)) {
|
||||
perror_msg("%s", cur->fullname);
|
||||
@@ -221,7 +222,7 @@ static void newline(void)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
static char append_char(mode_t mode)
|
||||
{
|
||||
if ( !(list_fmt & LIST_FILETYPE))
|
||||
@@ -303,6 +304,7 @@ static struct dnode **dnalloc(int num)
|
||||
return(p);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_LS_RECURSIVE
|
||||
static void dfree(struct dnode **dnp)
|
||||
{
|
||||
struct dnode *cur, *next;
|
||||
@@ -318,6 +320,7 @@ static void dfree(struct dnode **dnp)
|
||||
}
|
||||
free(dnp); /* free the array holding the dnode pointers */
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
{
|
||||
@@ -358,7 +361,7 @@ static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
static int sortcmp(struct dnode *d1, struct dnode *d2)
|
||||
{
|
||||
int cmp, dif;
|
||||
@@ -423,13 +426,13 @@ static void shellsort(struct dnode **dn, int size)
|
||||
static void showfiles(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, ncols, nrows, row, nc;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
int len;
|
||||
#endif
|
||||
|
||||
if(dn==NULL || nfiles < 1) return;
|
||||
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
/* find the longest file name- use that as the column width */
|
||||
column_width= 0;
|
||||
for (i=0; i<nfiles; i++) {
|
||||
@@ -485,7 +488,7 @@ static void showdirs(struct dnode **dn, int ndirs)
|
||||
{
|
||||
int i, nfiles;
|
||||
struct dnode **subdnp;
|
||||
#ifdef BB_FEATURE_LS_RECURSIVE
|
||||
#ifdef CONFIG_FEATURE_LS_RECURSIVE
|
||||
int dndirs;
|
||||
struct dnode **dnd;
|
||||
#endif
|
||||
@@ -500,17 +503,17 @@ static void showdirs(struct dnode **dn, int ndirs)
|
||||
nfiles= countfiles(subdnp);
|
||||
if (nfiles > 0) {
|
||||
/* list all files at this level */
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
shellsort(subdnp, nfiles);
|
||||
#endif
|
||||
showfiles(subdnp, nfiles);
|
||||
#ifdef BB_FEATURE_LS_RECURSIVE
|
||||
#ifdef CONFIG_FEATURE_LS_RECURSIVE
|
||||
if (disp_opts & DISP_RECURSIVE) {
|
||||
/* recursive- list the sub-dirs */
|
||||
dnd= splitdnarray(subdnp, nfiles, SPLIT_SUBDIR);
|
||||
dndirs= countsubdirs(subdnp, nfiles);
|
||||
if (dndirs > 0) {
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
shellsort(dnd, dndirs);
|
||||
#endif
|
||||
showdirs(dnd, dndirs);
|
||||
@@ -579,26 +582,26 @@ static int list_single(struct dnode *dn)
|
||||
{
|
||||
int i;
|
||||
char scratch[BUFSIZ + 1];
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
char *filetime;
|
||||
time_t ttime, age;
|
||||
#endif
|
||||
#if defined (BB_FEATURE_LS_FILETYPES)
|
||||
#if defined (CONFIG_FEATURE_LS_FILETYPES)
|
||||
struct stat info;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
char append;
|
||||
#endif
|
||||
|
||||
if (dn==NULL || dn->fullname==NULL) return(0);
|
||||
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
ttime= dn->dstat.st_mtime; /* the default time */
|
||||
if (time_fmt & TIME_ACCESS) ttime= dn->dstat.st_atime;
|
||||
if (time_fmt & TIME_CHANGE) ttime= dn->dstat.st_ctime;
|
||||
filetime= ctime(&ttime);
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
append = append_char(dn->dstat.st_mode);
|
||||
#endif
|
||||
|
||||
@@ -609,7 +612,7 @@ static int list_single(struct dnode *dn)
|
||||
column += 8;
|
||||
break;
|
||||
case LIST_BLOCKS:
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
fprintf(stdout, "%6s ", make_human_readable_str(dn->dstat.st_blocks>>1,
|
||||
KILOBYTE, (ls_disp_hr==TRUE)? 0: KILOBYTE));
|
||||
#else
|
||||
@@ -630,11 +633,11 @@ static int list_single(struct dnode *dn)
|
||||
column += 10;
|
||||
break;
|
||||
case LIST_ID_NAME:
|
||||
#ifdef BB_FEATURE_LS_USERNAME
|
||||
#ifdef CONFIG_FEATURE_LS_USERNAME
|
||||
my_getpwuid(scratch, dn->dstat.st_uid);
|
||||
printf("%-8.8s ", scratch);
|
||||
my_getgrgid(scratch, dn->dstat.st_gid);
|
||||
printf("%-8.8s ", scratch);
|
||||
printf("%-8.8s", scratch);
|
||||
column += 17;
|
||||
break;
|
||||
#endif
|
||||
@@ -647,7 +650,7 @@ static int list_single(struct dnode *dn)
|
||||
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
|
||||
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
|
||||
} else {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
if (ls_disp_hr==TRUE) {
|
||||
fprintf(stdout, "%8s ", make_human_readable_str(dn->dstat.st_size, 1, 0));
|
||||
} else
|
||||
@@ -662,7 +665,7 @@ static int list_single(struct dnode *dn)
|
||||
}
|
||||
column += 10;
|
||||
break;
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
case LIST_FULLTIME:
|
||||
case LIST_DATE_TIME:
|
||||
if (list_fmt & LIST_FULLTIME) {
|
||||
@@ -690,7 +693,7 @@ static int list_single(struct dnode *dn)
|
||||
char *lpath = xreadlink(dn->fullname);
|
||||
if (lpath) {
|
||||
printf(" -> %s", lpath);
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
if (!stat(dn->fullname, &info)) {
|
||||
append = append_char(info.st_mode);
|
||||
}
|
||||
@@ -700,7 +703,7 @@ static int list_single(struct dnode *dn)
|
||||
}
|
||||
}
|
||||
break;
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
case LIST_FILETYPE:
|
||||
if (append != '\0') {
|
||||
printf("%1c", append);
|
||||
@@ -724,21 +727,21 @@ extern int ls_main(int argc, char **argv)
|
||||
int opt;
|
||||
int oi, ac;
|
||||
char **av;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
struct winsize win = { 0, 0, 0, 0 };
|
||||
#endif
|
||||
|
||||
disp_opts= DISP_NORMAL;
|
||||
style_fmt= STYLE_AUTO;
|
||||
list_fmt= LIST_SHORT;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_NAME;
|
||||
sort_order= SORT_FORWARD;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
time_fmt= TIME_MOD;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
ioctl(fileno(stdout), TIOCGWINSZ, &win);
|
||||
if (win.ws_row > 4)
|
||||
column_width = win.ws_row - 2;
|
||||
@@ -749,25 +752,25 @@ extern int ls_main(int argc, char **argv)
|
||||
|
||||
/* process options */
|
||||
while ((opt = getopt(argc, argv, "1AaCdgilnsx"
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
"T:w:"
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
"Fp"
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_RECURSIVE
|
||||
#ifdef CONFIG_FEATURE_LS_RECURSIVE
|
||||
"R"
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
"rSvX"
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
"cetu"
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
|
||||
"L"
|
||||
#endif
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
"h"
|
||||
#endif
|
||||
"k")) > 0) {
|
||||
@@ -782,54 +785,54 @@ extern int ls_main(int argc, char **argv)
|
||||
case 'l':
|
||||
style_fmt = STYLE_LONG;
|
||||
list_fmt |= LIST_LONG;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
ls_disp_hr = FALSE;
|
||||
#endif
|
||||
break;
|
||||
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
|
||||
case 's': list_fmt |= LIST_BLOCKS; break;
|
||||
case 'x': disp_opts = DISP_ROWS; break;
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#ifdef CONFIG_FEATURE_LS_FILETYPES
|
||||
case 'F': list_fmt |= LIST_FILETYPE | LIST_EXEC; break;
|
||||
case 'p': list_fmt |= LIST_FILETYPE; break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_RECURSIVE
|
||||
#ifdef CONFIG_FEATURE_LS_RECURSIVE
|
||||
case 'R': disp_opts |= DISP_RECURSIVE; break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
case 'r': sort_order |= SORT_REVERSE; break;
|
||||
case 'S': sort_opts= SORT_SIZE; break;
|
||||
case 'v': sort_opts= SORT_VERSION; break;
|
||||
case 'X': sort_opts= SORT_EXT; break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
case 'e': list_fmt |= LIST_FULLTIME; break;
|
||||
case 'c':
|
||||
time_fmt = TIME_CHANGE;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_CTIME;
|
||||
#endif
|
||||
break;
|
||||
case 'u':
|
||||
time_fmt = TIME_ACCESS;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_ATIME;
|
||||
#endif
|
||||
break;
|
||||
case 't':
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_MTIME;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
|
||||
case 'L': follow_links= TRUE; break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
case 'T': tabstops= atoi(optarg); break;
|
||||
case 'w': terminal_width= atoi(optarg); break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
case 'h': ls_disp_hr = TRUE; break;
|
||||
#endif
|
||||
case 'k': break;
|
||||
@@ -839,17 +842,17 @@ extern int ls_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* sort out which command line options take precedence */
|
||||
#ifdef BB_FEATURE_LS_RECURSIVE
|
||||
#ifdef CONFIG_FEATURE_LS_RECURSIVE
|
||||
if (disp_opts & DISP_NOLIST)
|
||||
disp_opts &= ~DISP_RECURSIVE; /* no recurse if listing only dir */
|
||||
#endif
|
||||
#if defined (BB_FEATURE_LS_TIMESTAMPS) && defined (BB_FEATURE_LS_SORTFILES)
|
||||
#if defined (CONFIG_FEATURE_LS_TIMESTAMPS) && defined (CONFIG_FEATURE_LS_SORTFILES)
|
||||
if (time_fmt & TIME_CHANGE) sort_opts= SORT_CTIME;
|
||||
if (time_fmt & TIME_ACCESS) sort_opts= SORT_ATIME;
|
||||
#endif
|
||||
if (style_fmt != STYLE_LONG)
|
||||
list_fmt &= ~LIST_ID_NUMERIC; /* numeric uid only for long list */
|
||||
#ifdef BB_FEATURE_LS_USERNAME
|
||||
#ifdef CONFIG_FEATURE_LS_USERNAME
|
||||
if (style_fmt == STYLE_LONG && (list_fmt & LIST_ID_NUMERIC))
|
||||
list_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */
|
||||
#endif
|
||||
@@ -905,7 +908,7 @@ extern int ls_main(int argc, char **argv)
|
||||
|
||||
|
||||
if (disp_opts & DISP_NOLIST) {
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
shellsort(dnp, nfiles);
|
||||
#endif
|
||||
if (nfiles > 0) showfiles(dnp, nfiles);
|
||||
@@ -915,13 +918,13 @@ extern int ls_main(int argc, char **argv)
|
||||
dndirs= countdirs(dnp, nfiles);
|
||||
dnfiles= nfiles - dndirs;
|
||||
if (dnfiles > 0) {
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
shellsort(dnf, dnfiles);
|
||||
#endif
|
||||
showfiles(dnf, dnfiles);
|
||||
}
|
||||
if (dndirs > 0) {
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef CONFIG_FEATURE_LS_SORTFILES
|
||||
shellsort(dnd, dndirs);
|
||||
#endif
|
||||
showdirs(dnd, dndirs);
|
||||
|
||||
+42
-112
@@ -63,24 +63,6 @@
|
||||
|
||||
/* 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. */
|
||||
@@ -90,34 +72,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
/* 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;
|
||||
|
||||
/* 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. */
|
||||
computing library functions. */
|
||||
|
||||
typedef u_int32_t md5_uint32;
|
||||
|
||||
@@ -141,20 +96,20 @@ struct md5_ctx
|
||||
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
extern void md5_init_ctx __P ((struct md5_ctx *ctx));
|
||||
static void md5_init_ctx __P ((struct md5_ctx *ctx));
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is necessary that LEN is a multiple of 64!!! */
|
||||
extern void md5_process_block __P ((const void *buffer, size_t len,
|
||||
static void md5_process_block __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is NOT required that LEN is a multiple of 64. */
|
||||
extern void md5_process_bytes __P ((const void *buffer, size_t len,
|
||||
static void md5_process_bytes __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
@@ -164,30 +119,21 @@ extern void md5_process_bytes __P ((const void *buffer, size_t len,
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
|
||||
static void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
|
||||
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result is
|
||||
always in little endian byte order, so that a byte-wise output yields
|
||||
to the wanted ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
|
||||
|
||||
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
extern int md5_stream __P ((FILE *stream, void *resblock));
|
||||
static int md5_stream __P ((FILE *stream, void *resblock));
|
||||
|
||||
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
|
||||
|
||||
#endif
|
||||
static void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//--------end of md5.h
|
||||
@@ -221,27 +167,12 @@ void md5_init_ctx(struct md5_ctx *ctx)
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result
|
||||
must be in little endian byte order.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
|
||||
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
|
||||
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
|
||||
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
/* Process the remaining bytes in the internal buffer and the usual
|
||||
prolog according to the standard and write the result to RESBUF.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
static void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
/* Take yet unprocessed bytes into account. */
|
||||
md5_uint32 bytes = ctx->buflen;
|
||||
@@ -268,13 +199,24 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
/* Process last bytes. */
|
||||
md5_process_block(ctx->buffer, bytes + pad + 8, ctx);
|
||||
|
||||
return md5_read_ctx(ctx, resbuf);
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result is
|
||||
always in little endian byte order, so that a byte-wise output yields
|
||||
to the wanted ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
|
||||
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
|
||||
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
|
||||
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
int md5_stream(FILE *stream, void *resblock)
|
||||
static int md5_stream(FILE *stream, void *resblock)
|
||||
{
|
||||
/* Important: BLOCKSIZE must be a multiple of 64. */
|
||||
static const int BLOCKSIZE = 4096;
|
||||
@@ -326,7 +268,7 @@ static const int BLOCKSIZE = 4096;
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
void *md5_buffer(const char *buffer, size_t len, void *resblock)
|
||||
static void *md5_buffer(const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
|
||||
@@ -340,7 +282,7 @@ void *md5_buffer(const char *buffer, size_t len, void *resblock)
|
||||
return md5_finish_ctx(&ctx, resblock);
|
||||
}
|
||||
|
||||
void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
static void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
{
|
||||
/* When we already have some bits in our internal buffer concatenate
|
||||
both inputs first. */
|
||||
@@ -388,7 +330,7 @@ void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
|
||||
/* Process LEN bytes of BUFFER, accumulating context into CTX.
|
||||
It is assumed that LEN % 64 == 0. */
|
||||
void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
{
|
||||
md5_uint32 correct_words[16];
|
||||
const md5_uint32 *words = buffer;
|
||||
@@ -490,7 +432,6 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
break;
|
||||
case 3:
|
||||
temp += FI(B,C,D);
|
||||
break;
|
||||
}
|
||||
temp += cwp[(int)(*pp++)] + *pc++;
|
||||
temp = CYCLIC (temp, ps[i&3]);
|
||||
@@ -550,6 +491,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
|
||||
/* It is unfortunate that C does not provide an operator for
|
||||
cyclic rotation. Hope the C compiler is smart enough. */
|
||||
/* gcc 2.95.4 seems to be --aaronl */
|
||||
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
|
||||
|
||||
/* Before we start, one word to the strange constants.
|
||||
@@ -707,11 +649,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
|
||||
#define IN_CTYPE_DOMAIN(c) 1
|
||||
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
|
||||
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
|
||||
#define TOLOWER(Ch) tolower (Ch)
|
||||
#define OPENOPTS(BINARY) "r"
|
||||
#define ISXDIGIT(c) (isxdigit (c))
|
||||
|
||||
/* The minimum length of a valid digest line in a file produced
|
||||
by `md5sum FILE' and read by `md5sum -c'. This length does
|
||||
@@ -731,7 +669,6 @@ static int warn = 0; /* With -w, print a message to standard error warning
|
||||
static int split_3(char *s,
|
||||
size_t s_len,
|
||||
unsigned char **u,
|
||||
int *binary,
|
||||
char **w)
|
||||
{
|
||||
size_t i = 0;
|
||||
@@ -764,11 +701,10 @@ static int split_3(char *s,
|
||||
|
||||
if (s[i] != ' ' && s[i] != '*')
|
||||
return FALSE;
|
||||
*binary = (s[i++] == '*');
|
||||
|
||||
/* All characters between the type indicator and end of line are
|
||||
significant -- that includes leading and trailing white space. */
|
||||
*w = &s[i];
|
||||
*w = &s[++i];
|
||||
|
||||
if (escaped_filename) {
|
||||
/* Translate each `\n' string in the file name to a NEWLINE,
|
||||
@@ -812,7 +748,7 @@ static int split_3(char *s,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int hex_digits(unsigned char const *s)
|
||||
static inline int hex_digits(unsigned char const *s)
|
||||
{
|
||||
while (*s) {
|
||||
if (!ISXDIGIT(*s))
|
||||
@@ -826,21 +762,18 @@ static int hex_digits(unsigned char const *s)
|
||||
put the result in *MD5_RESULT. Return non-zero upon failure, zero
|
||||
to indicate success. */
|
||||
static int md5_file(const char *filename,
|
||||
int binary,
|
||||
unsigned char *md5_result)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if (STREQ(filename, "-")) {
|
||||
if (filename[0] == '-' && filename[1] == '\0') {
|
||||
have_read_stdin = 1;
|
||||
fp = stdin;
|
||||
} else {
|
||||
fp = fopen(filename, OPENOPTS(binary));
|
||||
if (fp == NULL) {
|
||||
perror_msg("%s", filename);
|
||||
fp = wfopen(filename, "r");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (md5_stream(fp, md5_result)) {
|
||||
perror_msg("%s", filename);
|
||||
@@ -868,22 +801,19 @@ static int md5_check(const char *checkfile_name)
|
||||
size_t line_number;
|
||||
char line[BUFSIZ];
|
||||
|
||||
if (STREQ(checkfile_name, "-")) {
|
||||
if (checkfile_name[0] == '-' && checkfile_name[1] == '\0') {
|
||||
have_read_stdin = 1;
|
||||
checkfile_stream = stdin;
|
||||
} else {
|
||||
checkfile_stream = fopen(checkfile_name, "r");
|
||||
if (checkfile_stream == NULL) {
|
||||
perror_msg("%s", checkfile_name);
|
||||
checkfile_stream = wfopen(checkfile_name, "r");
|
||||
if (checkfile_stream == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
line_number = 0;
|
||||
|
||||
do {
|
||||
char *filename;
|
||||
int binary;
|
||||
unsigned char *md5num;
|
||||
int line_length;
|
||||
|
||||
@@ -903,7 +833,7 @@ static int md5_check(const char *checkfile_name)
|
||||
if (line[line_length - 1] == '\n')
|
||||
line[--line_length] = '\0';
|
||||
|
||||
if (split_3(line, line_length, &md5num, &binary, &filename)
|
||||
if (split_3(line, line_length, &md5num, &filename)
|
||||
|| !hex_digits(md5num)) {
|
||||
if (warn) {
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line",
|
||||
@@ -919,7 +849,7 @@ static int md5_check(const char *checkfile_name)
|
||||
|
||||
++n_properly_formated_lines;
|
||||
|
||||
if (md5_file(filename, binary, md5buffer)) {
|
||||
if (md5_file(filename, md5buffer)) {
|
||||
++n_open_or_read_failures;
|
||||
if (!status_only) {
|
||||
printf("%s: FAILED open or read\n", filename);
|
||||
@@ -930,9 +860,9 @@ static int md5_check(const char *checkfile_name)
|
||||
/* Compare generated binary number with text representation
|
||||
in check file. Ignore case of hex digits. */
|
||||
for (cnt = 0; cnt < 16; ++cnt) {
|
||||
if (TOLOWER(md5num[2 * cnt])
|
||||
if (tolower(md5num[2 * cnt])
|
||||
!= bin2hex[md5buffer[cnt] >> 4]
|
||||
|| (TOLOWER(md5num[2 * cnt + 1])
|
||||
|| (tolower(md5num[2 * cnt + 1])
|
||||
!= (bin2hex[md5buffer[cnt] & 0xf])))
|
||||
break;
|
||||
}
|
||||
@@ -997,8 +927,8 @@ int md5sum_main(int argc,
|
||||
char **string = NULL;
|
||||
size_t n_strings = 0;
|
||||
size_t err = 0;
|
||||
int file_type_specified = 0;
|
||||
int binary = 0;
|
||||
char file_type_specified = 0;
|
||||
char binary = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "g:bcstw")) != -1) {
|
||||
switch (opt) {
|
||||
@@ -1084,9 +1014,9 @@ int md5sum_main(int argc,
|
||||
int fail;
|
||||
char *file = argv[optind];
|
||||
|
||||
fail = md5_file (file, binary, md5buffer);
|
||||
fail = md5_file (file, md5buffer);
|
||||
err |= fail;
|
||||
if (!fail && STREQ(file, "-")) {
|
||||
if (!fail && file[0]=='-' && file[1] == '\0') {
|
||||
size_t i;
|
||||
for (i = 0; i < 16; ++i)
|
||||
printf ("%02x", md5buffer[i]);
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ static int manual_rename(const char *source, const char *dest)
|
||||
}
|
||||
}
|
||||
|
||||
if (copy_file(source, dest, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS |
|
||||
FILEUTILS_PRESERVE_SYMLINKS) < 0)
|
||||
if (copy_file(source, dest,
|
||||
FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) < 0)
|
||||
return -1;
|
||||
|
||||
if (remove_file(source, FILEUTILS_RECUR | FILEUTILS_FORCE) < 0)
|
||||
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
* od implementation for busybox
|
||||
* Based on code from util-linux v 2.11l
|
||||
*
|
||||
* Copyright (c) 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include "dump.h"
|
||||
#include "busybox.h"
|
||||
|
||||
extern FS *fshead; /* head of format strings */
|
||||
extern int blocksize; /* data block size */
|
||||
extern int length; /* max bytes to read */
|
||||
|
||||
#define ishexdigit(c) \
|
||||
((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
|
||||
|
||||
static void
|
||||
odoffset(int argc, char ***argvp)
|
||||
{
|
||||
extern off_t skip;
|
||||
register char *num, *p;
|
||||
int base;
|
||||
char *end;
|
||||
|
||||
/*
|
||||
* The offset syntax of od(1) was genuinely bizarre. First, if
|
||||
* it started with a plus it had to be an offset. Otherwise, if
|
||||
* there were at least two arguments, a number or lower-case 'x'
|
||||
* followed by a number makes it an offset. By default it was
|
||||
* octal; if it started with 'x' or '0x' it was hex. If it ended
|
||||
* in a '.', it was decimal. If a 'b' or 'B' was appended, it
|
||||
* multiplied the number by 512 or 1024 byte units. There was
|
||||
* no way to assign a block count to a hex offset.
|
||||
*
|
||||
* We assumes it's a file if the offset is bad.
|
||||
*/
|
||||
p = **argvp;
|
||||
if (*p != '+' && (argc < 2 ||
|
||||
(!isdigit(p[0]) && (p[0] != 'x' || !ishexdigit(p[1])))))
|
||||
return;
|
||||
|
||||
base = 0;
|
||||
/*
|
||||
* skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
|
||||
* set base.
|
||||
*/
|
||||
if (p[0] == '+')
|
||||
++p;
|
||||
if (p[0] == 'x' && ishexdigit(p[1])) {
|
||||
++p;
|
||||
base = 16;
|
||||
} else if (p[0] == '0' && p[1] == 'x') {
|
||||
p += 2;
|
||||
base = 16;
|
||||
}
|
||||
|
||||
/* skip over the number */
|
||||
if (base == 16)
|
||||
for (num = p; ishexdigit(*p); ++p);
|
||||
else
|
||||
for (num = p; isdigit(*p); ++p);
|
||||
|
||||
/* check for no number */
|
||||
if (num == p)
|
||||
return;
|
||||
|
||||
/* if terminates with a '.', base is decimal */
|
||||
if (*p == '.') {
|
||||
if (base)
|
||||
return;
|
||||
base = 10;
|
||||
}
|
||||
|
||||
skip = strtol(num, &end, base ? base : 8);
|
||||
|
||||
/* if end isn't the same as p, we got a non-octal digit */
|
||||
if (end != p)
|
||||
skip = 0;
|
||||
else {
|
||||
if (*p) {
|
||||
if (*p == 'b')
|
||||
skip *= 512;
|
||||
else if (*p == 'B')
|
||||
skip *= 1024;
|
||||
++p;
|
||||
}
|
||||
if (*p)
|
||||
skip = 0;
|
||||
else {
|
||||
++*argvp;
|
||||
/*
|
||||
* If the offset uses a non-octal base, the base of
|
||||
* the offset is changed as well. This isn't pretty,
|
||||
* but it's easy.
|
||||
*/
|
||||
#define TYPE_OFFSET 7
|
||||
if (base == 16) {
|
||||
fshead->nextfu->fmt[TYPE_OFFSET] = 'x';
|
||||
fshead->nextfs->nextfu->fmt[TYPE_OFFSET] = 'x';
|
||||
} else if (base == 10) {
|
||||
fshead->nextfu->fmt[TYPE_OFFSET] = 'd';
|
||||
fshead->nextfs->nextfu->fmt[TYPE_OFFSET] = 'd';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void odprecede(void)
|
||||
{
|
||||
static int first = 1;
|
||||
|
||||
if (first) {
|
||||
first = 0;
|
||||
add("\"%07.7_Ao\n\"");
|
||||
add("\"%07.7_ao \"");
|
||||
} else
|
||||
add("\" \"");
|
||||
}
|
||||
|
||||
int od_main(int argc, char **argv)
|
||||
{
|
||||
int ch;
|
||||
extern enum _vflag vflag;
|
||||
vflag = FIRST;
|
||||
length = -1;
|
||||
|
||||
while ((ch = getopt(argc, argv, "aBbcDdeFfHhIiLlOoPpswvXx")) != EOF)
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
odprecede();
|
||||
add("16/1 \"%3_u \" \"\\n\"");
|
||||
break;
|
||||
case 'B':
|
||||
case 'o':
|
||||
odprecede();
|
||||
add("8/2 \" %06o \" \"\\n\"");
|
||||
break;
|
||||
case 'b':
|
||||
odprecede();
|
||||
add("16/1 \"%03o \" \"\\n\"");
|
||||
break;
|
||||
case 'c':
|
||||
odprecede();
|
||||
add("16/1 \"%3_c \" \"\\n\"");
|
||||
break;
|
||||
case 'd':
|
||||
odprecede();
|
||||
add("8/2 \" %05u \" \"\\n\"");
|
||||
break;
|
||||
case 'D':
|
||||
odprecede();
|
||||
add("4/4 \" %010u \" \"\\n\"");
|
||||
break;
|
||||
case 'e': /* undocumented in od */
|
||||
case 'F':
|
||||
odprecede();
|
||||
add("2/8 \" %21.14e \" \"\\n\"");
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
odprecede();
|
||||
add("4/4 \" %14.7e \" \"\\n\"");
|
||||
break;
|
||||
case 'H':
|
||||
case 'X':
|
||||
odprecede();
|
||||
add("4/4 \" %08x \" \"\\n\"");
|
||||
break;
|
||||
case 'h':
|
||||
case 'x':
|
||||
odprecede();
|
||||
add("8/2 \" %04x \" \"\\n\"");
|
||||
break;
|
||||
case 'I':
|
||||
case 'L':
|
||||
case 'l':
|
||||
odprecede();
|
||||
add("4/4 \" %11d \" \"\\n\"");
|
||||
break;
|
||||
case 'i':
|
||||
odprecede();
|
||||
add("8/2 \" %6d \" \"\\n\"");
|
||||
break;
|
||||
case 'O':
|
||||
odprecede();
|
||||
add("4/4 \" %011o \" \"\\n\"");
|
||||
break;
|
||||
case 'v':
|
||||
vflag = ALL;
|
||||
break;
|
||||
case 'P':
|
||||
case 'p':
|
||||
case 's':
|
||||
case 'w':
|
||||
case '?':
|
||||
default:
|
||||
error_msg("od: od(1) has been deprecated for hexdump(1).\n");
|
||||
if (ch != '?') {
|
||||
error_msg("od: hexdump(1) compatibility doesn't support the -%c option%s\n",
|
||||
ch, ch == 's' ? "; see strings(1)." : ".");
|
||||
}
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (!fshead) {
|
||||
add("\"%07.7_Ao\n\"");
|
||||
add("\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
odoffset(argc, &argv);
|
||||
|
||||
return(dump(argv));
|
||||
}
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
+63
-12
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini rmdir implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,24 +21,76 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
|
||||
/* Return true if a path is composed of multiple components. */
|
||||
|
||||
static int
|
||||
multiple_components_p (const char *path)
|
||||
{
|
||||
const char *s = path;
|
||||
|
||||
while (s[0] != '\0' && s[0] != '/')
|
||||
s++;
|
||||
|
||||
while (s[0] == '/')
|
||||
s++;
|
||||
|
||||
return (s[0] != '\0');
|
||||
}
|
||||
|
||||
|
||||
/* Remove a directory. Returns 0 if successful, -1 on error. */
|
||||
|
||||
static int
|
||||
remove_directory (char *path, int flags)
|
||||
{
|
||||
if (!(flags & FILEUTILS_RECUR)) {
|
||||
if (rmdir (path) < 0) {
|
||||
perror_msg ("unable to remove `%s'", path);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (remove_directory (path, 0) < 0)
|
||||
return -1;
|
||||
|
||||
if (multiple_components_p (path))
|
||||
if (remove_directory (dirname (path), flags) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
extern int
|
||||
rmdir_main (int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int flags = 0;
|
||||
int i, opt;
|
||||
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
while ((opt = getopt (argc, argv, "p")) != -1)
|
||||
switch (opt) {
|
||||
case 'p':
|
||||
flags |= FILEUTILS_RECUR;
|
||||
break;
|
||||
|
||||
default:
|
||||
show_usage ();
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
show_usage();
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
perror_msg("%s", *argv);
|
||||
for (i = optind; i < argc; i++)
|
||||
if (remove_directory (argv[i], flags) < 0)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
+7
-7
@@ -43,10 +43,10 @@ int sort_main(int argc, char **argv)
|
||||
char *line, **lines = NULL;
|
||||
int i, opt, nlines = 0;
|
||||
int (*compare)(const void *, const void *) = compare_ascii;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
#ifdef CONFIG_FEATURE_SORT_REVERSE
|
||||
int reverse = FALSE;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
#ifdef CONFIG_FEATURE_SORT_UNIQUE
|
||||
int unique = FALSE;
|
||||
#endif
|
||||
|
||||
@@ -55,12 +55,12 @@ int sort_main(int argc, char **argv)
|
||||
case 'n':
|
||||
compare = compare_numeric;
|
||||
break;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
#ifdef CONFIG_FEATURE_SORT_REVERSE
|
||||
case 'r':
|
||||
reverse = TRUE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
#ifdef CONFIG_FEATURE_SORT_UNIQUE
|
||||
case 'u':
|
||||
unique = TRUE;
|
||||
break;
|
||||
@@ -88,17 +88,17 @@ int sort_main(int argc, char **argv)
|
||||
qsort(lines, nlines, sizeof(char *), compare);
|
||||
|
||||
/* print it */
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
#ifdef CONFIG_FEATURE_SORT_REVERSE
|
||||
if (reverse) {
|
||||
for (i = --nlines; 0 <= i; i--)
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
#ifdef CONFIG_FEATURE_SORT_UNIQUE
|
||||
if((!unique) || (i == nlines) || (strcmp(lines[i + 1], lines[i])))
|
||||
#endif
|
||||
puts(lines[i]);
|
||||
} else
|
||||
#endif
|
||||
for (i = 0; i < nlines; i++)
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
#ifdef CONFIG_FEATURE_SORT_UNIQUE
|
||||
if((!unique) || (!i) || (strcmp(lines[i - 1], lines[i])))
|
||||
#endif
|
||||
puts(lines[i]);
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
|
||||
Special for busybox ported by Vladimir Oleynik <vodz@usa.net> 2001
|
||||
Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001
|
||||
|
||||
*/
|
||||
|
||||
|
||||
+7
-7
@@ -51,7 +51,7 @@ static void tailbuf_append(char *buf, int len)
|
||||
taillen += len;
|
||||
}
|
||||
|
||||
static void tailbuf_trunc()
|
||||
static void tailbuf_trunc(void)
|
||||
{
|
||||
char *s;
|
||||
s = memchr(tailbuf, '\n', taillen);
|
||||
@@ -73,7 +73,7 @@ int tail_main(int argc, char **argv)
|
||||
case 'f':
|
||||
follow = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
||||
case 'c':
|
||||
units = BYTES;
|
||||
/* FALLS THROUGH */
|
||||
@@ -85,7 +85,7 @@ int tail_main(int argc, char **argv)
|
||||
if (optarg[0] == '+')
|
||||
from_top = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
||||
case 'q':
|
||||
hide_headers = 1;
|
||||
break;
|
||||
@@ -118,7 +118,7 @@ int tail_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
||||
/* tail the files */
|
||||
if (!from_top && units == BYTES)
|
||||
tailbuf = xmalloc(count);
|
||||
@@ -136,7 +136,7 @@ int tail_main(int argc, char **argv)
|
||||
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
|
||||
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
|
||||
if (from_top) {
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
||||
if (units == BYTES) {
|
||||
if (count - 1 <= seen)
|
||||
nwrite = nread;
|
||||
@@ -169,7 +169,7 @@ int tail_main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
||||
if (units == BYTES) {
|
||||
if (nread < count) {
|
||||
memmove(tailbuf, tailbuf + nread, count - nread);
|
||||
@@ -203,7 +203,7 @@ int tail_main(int argc, char **argv)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
||||
if (!from_top && units == BYTES) {
|
||||
if (count < seen)
|
||||
seen = count;
|
||||
|
||||
+2
-4
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini tee implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
* Copyright (C) 2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -45,9 +44,8 @@ tee_main(int argc, char **argv)
|
||||
files = (FILE **)xmalloc(sizeof(FILE *) * (argc - optind + 1));
|
||||
files[nfiles++] = stdout;
|
||||
while (optind < argc) {
|
||||
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
|
||||
if ((files[nfiles++] = wfopen(argv[optind++], mode)) == NULL) {
|
||||
nfiles--;
|
||||
perror_msg("%s", argv[optind-1]);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-21
@@ -158,21 +158,21 @@ static struct t_op const *t_wp_op;
|
||||
static gid_t *group_array = NULL;
|
||||
static int ngroups;
|
||||
|
||||
static enum token t_lex();
|
||||
static int oexpr();
|
||||
static int aexpr();
|
||||
static int nexpr();
|
||||
static int binop();
|
||||
static int primary();
|
||||
static int filstat();
|
||||
static int getn();
|
||||
static int newerf();
|
||||
static int olderf();
|
||||
static int equalf();
|
||||
static void syntax();
|
||||
static int test_eaccess();
|
||||
static int is_a_group_member();
|
||||
static void initialize_group_array();
|
||||
static enum token t_lex(char* s);
|
||||
static int oexpr(enum token n);
|
||||
static int aexpr(enum token n);
|
||||
static int nexpr(enum token n);
|
||||
static int binop(void);
|
||||
static int primary(enum token n);
|
||||
static int filstat(char *nm, enum token mode);
|
||||
static int getn(const char *s);
|
||||
static int newerf(const char *f1, const char *f2);
|
||||
static int olderf(const char *f1, const char *f2);
|
||||
static int equalf(const char *f1, const char *f2);
|
||||
static void syntax(const char *op, const char *msg);
|
||||
static int test_eaccess(char *path, int mode);
|
||||
static int is_a_group_member(gid_t gid);
|
||||
static void initialize_group_array(void);
|
||||
|
||||
extern int
|
||||
test_main(int argc, char** argv)
|
||||
@@ -226,8 +226,8 @@ test_main(int argc, char** argv)
|
||||
|
||||
static void
|
||||
syntax(op, msg)
|
||||
char *op;
|
||||
char *msg;
|
||||
const char *op;
|
||||
const char *msg;
|
||||
{
|
||||
if (op && *op)
|
||||
error_msg_and_die("%s: %s", op, msg);
|
||||
@@ -458,7 +458,7 @@ t_lex(s)
|
||||
/* atoi with error detection */
|
||||
static int
|
||||
getn(s)
|
||||
char *s;
|
||||
const char *s;
|
||||
{
|
||||
char *p;
|
||||
long r;
|
||||
@@ -480,7 +480,7 @@ getn(s)
|
||||
|
||||
static int
|
||||
newerf (f1, f2)
|
||||
char *f1, *f2;
|
||||
const char *f1, *f2;
|
||||
{
|
||||
struct stat b1, b2;
|
||||
|
||||
@@ -491,7 +491,7 @@ char *f1, *f2;
|
||||
|
||||
static int
|
||||
olderf (f1, f2)
|
||||
char *f1, *f2;
|
||||
const char *f1, *f2;
|
||||
{
|
||||
struct stat b1, b2;
|
||||
|
||||
@@ -502,7 +502,7 @@ char *f1, *f2;
|
||||
|
||||
static int
|
||||
equalf (f1, f2)
|
||||
char *f1, *f2;
|
||||
const char *f1, *f2;
|
||||
{
|
||||
struct stat b1, b2;
|
||||
|
||||
|
||||
+2
-3
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini touch implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+19
-11
@@ -44,7 +44,7 @@ static unsigned char *pvector;
|
||||
static char *pinvec, *poutvec;
|
||||
|
||||
|
||||
static void convert()
|
||||
static void convert(void)
|
||||
{
|
||||
short read_chars = 0;
|
||||
short c, coded;
|
||||
@@ -54,7 +54,7 @@ static void convert()
|
||||
if (in_index == read_chars) {
|
||||
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index)
|
||||
write(2, write_error, strlen(write_error));
|
||||
error_msg("%s", write_error);
|
||||
exit(0);
|
||||
}
|
||||
in_index = 0;
|
||||
@@ -67,10 +67,8 @@ static void convert()
|
||||
continue;
|
||||
poutput[out_index++] = last = coded;
|
||||
if (out_index == BUFSIZ) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index) {
|
||||
write(2, write_error, strlen(write_error));
|
||||
exit(1);
|
||||
}
|
||||
if (write(1, (char *) poutput, out_index) != out_index)
|
||||
error_msg_and_die("%s", write_error);
|
||||
out_index = 0;
|
||||
}
|
||||
}
|
||||
@@ -105,6 +103,16 @@ static unsigned int expand(const char *arg, register unsigned char *buffer)
|
||||
if (*arg == '\\') {
|
||||
arg++;
|
||||
*buffer++ = process_escape_sequence(&arg);
|
||||
} else if (*(arg+1) == '-') {
|
||||
ac = *(arg+2);
|
||||
if(ac == 0) {
|
||||
*buffer++ = *arg++;
|
||||
continue;
|
||||
}
|
||||
i = *arg;
|
||||
while (i <= ac)
|
||||
*buffer++ = i++;
|
||||
arg += 3; /* Skip the assumed a-z */
|
||||
} else if (*arg == '[') {
|
||||
arg++;
|
||||
i = *arg++;
|
||||
@@ -147,11 +155,11 @@ extern int tr_main(int argc, char **argv)
|
||||
int output_length=0, input_length;
|
||||
int idx = 1;
|
||||
int i;
|
||||
RESERVE_BB_BUFFER(output, BUFSIZ);
|
||||
RESERVE_BB_BUFFER(input, BUFSIZ);
|
||||
RESERVE_BB_UBUFFER(vector, ASCII+1);
|
||||
RESERVE_BB_BUFFER(invec, ASCII+1);
|
||||
RESERVE_BB_BUFFER(outvec, ASCII+1);
|
||||
RESERVE_CONFIG_BUFFER(output, BUFSIZ);
|
||||
RESERVE_CONFIG_BUFFER(input, BUFSIZ);
|
||||
RESERVE_CONFIG_UBUFFER(vector, ASCII+1);
|
||||
RESERVE_CONFIG_BUFFER(invec, ASCII+1);
|
||||
RESERVE_CONFIG_BUFFER(outvec, ASCII+1);
|
||||
|
||||
/* ... but make them available globally */
|
||||
poutput = output;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini hostid implementation for busybox
|
||||
* Mini true implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,13 +21,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int hostid_main(int argc, char **argv)
|
||||
extern int true_main(int argc, char **argv)
|
||||
{
|
||||
printf("%lx\n", gethostid());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+2
-3
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini uniq implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Copyright (C) 1999 by Lineo, inc. and John Beppu
|
||||
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
|
||||
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
||||
+15
-12
@@ -29,8 +29,8 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include "pwd_grp/pwd.h"
|
||||
#include "pwd_grp/grp.h"
|
||||
#include "pwd.h"
|
||||
#include "grp.h"
|
||||
|
||||
/*struct passwd *getpwnam();*/
|
||||
|
||||
@@ -201,12 +201,13 @@ static int decode (const char *inname,
|
||||
const char *forced_outname)
|
||||
{
|
||||
struct passwd *pw;
|
||||
register int n;
|
||||
register char *p;
|
||||
int mode, n1;
|
||||
int mode;
|
||||
char buf[2 * BUFSIZ];
|
||||
char *outname;
|
||||
int do_base64 = 0;
|
||||
int res;
|
||||
int dofre;
|
||||
|
||||
/* Search for header line. */
|
||||
|
||||
@@ -226,6 +227,7 @@ static int decode (const char *inname,
|
||||
}
|
||||
|
||||
/* If the output file name is given on the command line this rules. */
|
||||
dofre = FALSE;
|
||||
if (forced_outname != NULL)
|
||||
outname = (char *) forced_outname;
|
||||
else {
|
||||
@@ -246,12 +248,8 @@ static int decode (const char *inname,
|
||||
error_msg("%s: No user `%s'", inname, buf + 1);
|
||||
return FALSE;
|
||||
}
|
||||
n = strlen (pw->pw_dir);
|
||||
n1 = strlen (p);
|
||||
outname = (char *) alloca ((size_t) (n + n1 + 2));
|
||||
memcpy (outname + n + 1, p, (size_t) (n1 + 1));
|
||||
memcpy (outname, pw->pw_dir, (size_t) n);
|
||||
outname[n] = '/';
|
||||
outname = concat_path_file(pw->pw_dir, p);
|
||||
dofre = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,6 +259,8 @@ static int decode (const char *inname,
|
||||
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
|
||||
)) {
|
||||
perror_msg("%s", outname); /* */
|
||||
if (dofre)
|
||||
free(outname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -269,9 +269,12 @@ static int decode (const char *inname,
|
||||
|
||||
/* For each input line: */
|
||||
if (do_base64)
|
||||
return read_base64 (inname);
|
||||
res = read_base64 (inname);
|
||||
else
|
||||
return read_stduu (inname);
|
||||
res = read_stduu (inname);
|
||||
if (dofre)
|
||||
free(outname);
|
||||
return res;
|
||||
}
|
||||
|
||||
int uudecode_main (int argc,
|
||||
|
||||
+164
-221
@@ -1,237 +1,180 @@
|
||||
/* uuencode.c -- uuencode utility.
|
||||
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
*
|
||||
* This product is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
* based on the function base64_encode from http.c in wget v1.6
|
||||
* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
*
|
||||
* This product is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this product; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt */
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
|
||||
|
||||
static void encode __P ((void));
|
||||
|
||||
/* Pointer to the translation table we currently use. */
|
||||
static const char *trans_ptr;
|
||||
|
||||
/* The two currently defined translation tables. The first is the
|
||||
standard uuencoding, the second is base64 encoding. */
|
||||
static const char uu_std[64] = {
|
||||
'`', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
|
||||
/* Conversion table. for base 64 */
|
||||
static char tbl_base64[64] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '/'
|
||||
};
|
||||
|
||||
static const char uu_base64[64] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '/'
|
||||
static char tbl_std[64] = {
|
||||
'`', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
|
||||
};
|
||||
|
||||
/* ENC is the basic 1 character encoding function to make a char printing. */
|
||||
#define ENC(Char) (trans_ptr[(Char) & 077])
|
||||
|
||||
/* Copy from IN to OUT, encoding as you go along. */
|
||||
static void encode()
|
||||
{
|
||||
register int ch, n;
|
||||
char *p = NULL;
|
||||
char buf[80];
|
||||
|
||||
while (1) {
|
||||
n = 0;
|
||||
do {
|
||||
register int m = fread (buf, 1, 45 - n, stdin);
|
||||
if (m == 0)
|
||||
break;
|
||||
n += m;
|
||||
}
|
||||
while (n < 45);
|
||||
|
||||
if (n == 0)
|
||||
break;
|
||||
|
||||
if (trans_ptr == uu_std)
|
||||
if (putchar (ENC (n)) == EOF)
|
||||
break;
|
||||
for (p = buf; n > 2; n -= 3, p += 3) {
|
||||
ch = *p >> 2;
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = p[2] & 077;
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
}
|
||||
|
||||
if (n != 0)
|
||||
break;
|
||||
|
||||
if (putchar ('\n') == EOF)
|
||||
break;
|
||||
}
|
||||
|
||||
while (n != 0) {
|
||||
char c1 = *p;
|
||||
char c2 = n == 1 ? 0 : p[1];
|
||||
|
||||
ch = c1 >> 2;
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
|
||||
ch = ((c1 << 4) & 060) | ((c2 >> 4) & 017);
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
|
||||
if (n == 1)
|
||||
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
|
||||
else {
|
||||
ch = (c2 << 2) & 074;
|
||||
ch = ENC (ch);
|
||||
}
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
putchar ('\n');
|
||||
break;
|
||||
}
|
||||
|
||||
if (ferror (stdin))
|
||||
error_msg("Read error");
|
||||
|
||||
if (trans_ptr == uu_std) {
|
||||
putchar (ENC ('\0'));
|
||||
putchar ('\n');
|
||||
}
|
||||
}
|
||||
|
||||
int uuencode_main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
int opt;
|
||||
struct stat sb;
|
||||
int mode;
|
||||
|
||||
trans_ptr = uu_std; /* Standard encoding is old uu format */
|
||||
|
||||
/* Parse any options */
|
||||
while ((opt = getopt (argc, argv, "m")) > 0) {
|
||||
switch (opt) {
|
||||
case 'm':
|
||||
trans_ptr = uu_base64;
|
||||
break;
|
||||
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
switch (argc - optind) {
|
||||
case 2:
|
||||
/* Optional first argument is input file. */
|
||||
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
|
||||
perror_msg("%s", argv[optind]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
optind++;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
mode = RW & ~umask (RW);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64",
|
||||
mode, argv[optind]);
|
||||
encode();
|
||||
printf(trans_ptr == uu_std ? "end\n" : "====\n");
|
||||
if (ferror (stdout)) {
|
||||
error_msg("Write error");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
/*
|
||||
* Encode the string S of length LENGTH to base64 format and place it
|
||||
* to STORE. STORE will be 0-terminated, and must point to a writable
|
||||
* buffer of at least 1+BASE64_LENGTH(length) bytes.
|
||||
* where BASE64_LENGTH(len) = (4 * ((LENGTH + 2) / 3))
|
||||
*/
|
||||
static void uuencode (const char *s, const char *store, const int length, const char *tbl)
|
||||
{
|
||||
int i;
|
||||
unsigned char *p = (unsigned char *)store;
|
||||
|
||||
/* Transform the 3x8 bits to 4x6 bits, as required by base64. */
|
||||
for (i = 0; i < length; i += 3) {
|
||||
*p++ = tbl[s[0] >> 2];
|
||||
*p++ = tbl[((s[0] & 3) << 4) + (s[1] >> 4)];
|
||||
*p++ = tbl[((s[1] & 0xf) << 2) + (s[2] >> 6)];
|
||||
*p++ = tbl[s[2] & 0x3f];
|
||||
s += 3;
|
||||
}
|
||||
/* Pad the result if necessary... */
|
||||
if (i == length + 1) {
|
||||
*(p - 1) = '=';
|
||||
}
|
||||
else if (i == length + 2) {
|
||||
*(p - 1) = *(p - 2) = '=';
|
||||
}
|
||||
/* ...and zero-terminate it. */
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
int uuencode_main(int argc, char **argv)
|
||||
{
|
||||
const int src_buf_size = 60; // This *MUST* be a multiple of 3
|
||||
const int dst_buf_size = 4 * ((src_buf_size + 2) / 3);
|
||||
RESERVE_CONFIG_BUFFER(src_buf, src_buf_size + 1);
|
||||
RESERVE_CONFIG_BUFFER(dst_buf, dst_buf_size + 1);
|
||||
struct stat stat_buf;
|
||||
FILE *src_stream = stdin;
|
||||
char *tbl = tbl_std;
|
||||
size_t size;
|
||||
mode_t mode;
|
||||
int opt;
|
||||
int column = 0;
|
||||
int write_size = 0;
|
||||
int remaining;
|
||||
int buffer_offset = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "m")) != -1) {
|
||||
switch (opt) {
|
||||
case 'm':
|
||||
tbl = tbl_base64;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
switch (argc - optind) {
|
||||
case 2:
|
||||
src_stream = xfopen(argv[optind], "r");
|
||||
stat(argv[optind], &stat_buf);
|
||||
mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
if (src_stream == stdout) {
|
||||
printf("NULL\n");
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
mode = 0666 & ~umask(0666);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
printf("begin%s %o %s", tbl == tbl_std ? "" : "-base64", mode, argv[argc - 1]);
|
||||
|
||||
while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) {
|
||||
/* Encode the buffer we just read in */
|
||||
uuencode(src_buf, dst_buf, size, tbl);
|
||||
|
||||
/* Write the buffer to stdout, wrapping at 60 chars.
|
||||
* This looks overly complex, but it gets tricky as
|
||||
* the line has to continue to wrap correctly if we
|
||||
* have to refill the buffer
|
||||
*
|
||||
* Improvments most welcome
|
||||
*/
|
||||
|
||||
/* Initialise values for the new buffer */
|
||||
remaining = 4 * ((size + 2) / 3);
|
||||
buffer_offset = 0;
|
||||
|
||||
/* Write the buffer to stdout, wrapping at 60 chars
|
||||
* starting from the column the last buffer ran out
|
||||
*/
|
||||
do {
|
||||
if (remaining > (60 - column)) {
|
||||
write_size = 60 - column;
|
||||
}
|
||||
else if (remaining < 60) {
|
||||
write_size = remaining;
|
||||
} else {
|
||||
write_size = 60;
|
||||
}
|
||||
|
||||
/* Setup a new row if required */
|
||||
if (column == 0) {
|
||||
putchar('\n');
|
||||
if (tbl == tbl_std) {
|
||||
putchar('M');
|
||||
}
|
||||
}
|
||||
/* Write to the 60th column */
|
||||
if (fwrite(&dst_buf[buffer_offset], 1, write_size, stdout) != write_size) {
|
||||
perror("Couldnt finish writing");
|
||||
}
|
||||
/* Update variables based on last write */
|
||||
buffer_offset += write_size;
|
||||
remaining -= write_size;
|
||||
column += write_size;
|
||||
if (column % 60 == 0) {
|
||||
column = 0;
|
||||
}
|
||||
} while (remaining > 0);
|
||||
}
|
||||
printf(tbl == tbl_std ? "\n`\nend\n" : "\n====\n");
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
int opt;
|
||||
int flags = 0;
|
||||
int i;
|
||||
|
||||
while ((opt = getopt(argc, argv, "adfipR")) != -1)
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
|
||||
/* fallthrough */
|
||||
case 'd':
|
||||
flags |= FILEUTILS_PRESERVE_SYMLINKS;
|
||||
break;
|
||||
case 'f':
|
||||
flags |= FILEUTILS_FORCE;
|
||||
break;
|
||||
case 'i':
|
||||
flags |= FILEUTILS_INTERACTIVE;
|
||||
break;
|
||||
case 'p':
|
||||
flags |= FILEUTILS_PRESERVE_STATUS;
|
||||
break;
|
||||
case 'R':
|
||||
flags |= FILEUTILS_RECUR;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (optind + 2 > argc)
|
||||
show_usage();
|
||||
|
||||
/* If there are only two arguments and... */
|
||||
if (optind + 2 == argc) {
|
||||
struct stat source_stat;
|
||||
struct stat dest_stat;
|
||||
int source_exists = 1;
|
||||
int dest_exists = 1;
|
||||
|
||||
if (((flags & FILEUTILS_PRESERVE_SYMLINKS) &&
|
||||
lstat(argv[optind], &source_stat) < 0) ||
|
||||
(!(flags & FILEUTILS_PRESERVE_SYMLINKS) &&
|
||||
stat(argv[optind], &source_stat))) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind]);
|
||||
source_exists = 0;
|
||||
}
|
||||
|
||||
if (stat(argv[optind + 1], &dest_stat) < 0) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind + 1]);
|
||||
dest_exists = 0;
|
||||
}
|
||||
|
||||
/* ...if neither is a directory or... */
|
||||
if (((!source_exists || !S_ISDIR(source_stat.st_mode)) &&
|
||||
(!dest_exists || !S_ISDIR(dest_stat.st_mode))) ||
|
||||
/* ...recursing, the first is a directory, and the
|
||||
* second doesn't exist, then... */
|
||||
((flags & FILEUTILS_RECUR) && S_ISDIR(source_stat.st_mode) &&
|
||||
!dest_exists)) {
|
||||
/* ...do a simple copy. */
|
||||
if (copy_file(argv[optind], argv[optind + 1], flags) < 0)
|
||||
status = 1;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = optind; i < argc - 1; i++) {
|
||||
char *dest = concat_path_file(argv[argc - 1],
|
||||
get_last_path_component(argv[i]));
|
||||
if (copy_file(argv[i], dest, flags) < 0)
|
||||
status = 1;
|
||||
free(dest);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
Loaded 100 of 510 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user