Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3986eb7ec | ||
|
|
9e78a1772d | ||
|
|
f7c7dde158 | ||
|
|
830c040f6f | ||
|
|
045dedad91 | ||
|
|
b309ec71c8 | ||
|
|
866bad310f | ||
|
|
5e1f2d429d | ||
|
|
0be69b1693 | ||
|
|
c7cba1ae3b | ||
|
|
be3dae145f | ||
|
|
6022fc8723 | ||
|
|
fc455b2101 | ||
|
|
365a345e92 | ||
|
|
d5138f44fe | ||
|
|
9344d8aa10 | ||
|
|
44dbd4bc65 | ||
|
|
25b8652b4f | ||
|
|
091a3e510e | ||
|
|
ffaa3deeeb | ||
|
|
5f07779aca | ||
|
|
ab6399a4c6 | ||
|
|
ca17c937c2 | ||
|
|
d62df011a0 | ||
|
|
164a716f96 | ||
|
|
8c59a0bf0e |
No files matched your search
@@ -1,7 +0,0 @@
|
||||
busybox
|
||||
busybox.links
|
||||
_install
|
||||
.config
|
||||
.menuconfig.log
|
||||
.config.cmd
|
||||
.config.old
|
||||
@@ -1,671 +0,0 @@
|
||||
---------------------
|
||||
PatchSet 3926
|
||||
Date: 2004/02/09 10:01:01
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Buffalo appears to have resolved their GPL problems
|
||||
|
||||
Members:
|
||||
docs/busybox.net/products.html:1.5->1.6
|
||||
docs/busybox.net/shame.html:1.7->1.8
|
||||
|
||||
---------------------
|
||||
PatchSet 3927
|
||||
Date: 2004/02/09 10:57:04
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Update URL
|
||||
|
||||
Members:
|
||||
docs/busybox.net/products.html:1.6->1.7
|
||||
|
||||
---------------------
|
||||
PatchSet 3928
|
||||
Date: 2004/02/10 01:07:45
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Support disabling pipe and redirect support
|
||||
|
||||
Members:
|
||||
shell/lash.c:1.151->1.152
|
||||
|
||||
---------------------
|
||||
PatchSet 3929
|
||||
Date: 2004/02/10 01:28:36
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Initial effort at disabling job control as well
|
||||
|
||||
Members:
|
||||
shell/lash.c:1.152->1.153
|
||||
|
||||
---------------------
|
||||
PatchSet 3930
|
||||
Date: 2004/02/10 01:30:21
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
oops. Leave the default feature set enbled for now...
|
||||
|
||||
Members:
|
||||
shell/lash.c:1.153->1.154
|
||||
|
||||
---------------------
|
||||
PatchSet 3931
|
||||
Date: 2004/02/13 08:09:43
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Accomodate the fact that newer libc versions may in fact not
|
||||
contain query_module and friends and more
|
||||
|
||||
Members:
|
||||
libbb/module_syscalls.c:1.13->1.14
|
||||
|
||||
---------------------
|
||||
PatchSet 3932
|
||||
Date: 2004/02/14 21:33:39
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Avoid naming conflict with symbol in newer glibc headers
|
||||
|
||||
Members:
|
||||
miscutils/hdparm.c:1.9->1.10
|
||||
|
||||
---------------------
|
||||
PatchSet 3933
|
||||
Date: 2004/02/17 07:51:31
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
define option names to be clearer, simplify nested if statements, remove
|
||||
un-needed if statement, minor indenting change
|
||||
|
||||
Members:
|
||||
coreutils/date.c:1.41->1.42
|
||||
|
||||
---------------------
|
||||
PatchSet 3934
|
||||
Date: 2004/02/17 07:58:04
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Woops, im getting ahead of myself, we dont have the -r (refernece)
|
||||
option yet
|
||||
|
||||
Members:
|
||||
coreutils/date.c:1.42->1.43
|
||||
|
||||
---------------------
|
||||
PatchSet 3935
|
||||
Date: 2004/02/17 10:16:21
|
||||
Author: mjn3
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from Florian Schirmer <jolt@tuxbox.org>. When I rewrote the parser,
|
||||
I overlooked the case of someone wanting to use a valid but empty suid
|
||||
config file.
|
||||
|
||||
Members:
|
||||
applets/applets.c:1.21->1.22
|
||||
|
||||
---------------------
|
||||
PatchSet 3936
|
||||
Date: 2004/02/17 11:55:06
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Dont strip trailing '/' until _after_ i test to set if its there !
|
||||
|
||||
Members:
|
||||
archival/libunarchive/get_header_tar.c:1.30->1.31
|
||||
|
||||
---------------------
|
||||
PatchSet 3937
|
||||
Date: 2004/02/17 12:04:13
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Remove debugging
|
||||
|
||||
Members:
|
||||
archival/libunarchive/get_header_tar.c:1.31->1.32
|
||||
|
||||
---------------------
|
||||
PatchSet 3938
|
||||
Date: 2004/02/17 12:22:21
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Add the -r option, patch from Rob with some help from myself.
|
||||
|
||||
Members:
|
||||
coreutils/date.c:1.43->1.44
|
||||
|
||||
---------------------
|
||||
PatchSet 3939
|
||||
Date: 2004/02/17 20:04:34
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Mark Lord writes:
|
||||
|
||||
The config file processing for inetd in busybox-1.00-pre7 and newer
|
||||
is broken -- the saved command argv[] values overwrite each other.
|
||||
|
||||
Patch to fix it is attached.
|
||||
|
||||
Cheers
|
||||
--
|
||||
Mark Lord
|
||||
Real-Time Remedies Inc.
|
||||
|
||||
Members:
|
||||
networking/inetd.c:1.14->1.15
|
||||
|
||||
---------------------
|
||||
PatchSet 3940
|
||||
Date: 2004/02/17 20:08:11
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Remove the unused CONFIG_FEATURE_HTTPD_SET_CGI_VARS_TO_ENV option.
|
||||
|
||||
Members:
|
||||
networking/Config.in:1.25->1.26
|
||||
|
||||
---------------------
|
||||
PatchSet 3941
|
||||
Date: 2004/02/18 09:40:41
|
||||
Author: mjn3
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Fix vstype[] to match VS* defines. Patch from OpenWrt by mbm.
|
||||
|
||||
Members:
|
||||
shell/ash.c:1.89->1.90
|
||||
|
||||
---------------------
|
||||
PatchSet 3942
|
||||
Date: 2004/02/18 09:54:15
|
||||
Author: landley
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Add -i option to sed, to edit files in-place.
|
||||
|
||||
Members:
|
||||
editors/sed.c:1.159->1.160
|
||||
|
||||
---------------------
|
||||
PatchSet 3943
|
||||
Date: 2004/02/18 10:14:17
|
||||
Author: mjn3
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from OpenWrt.
|
||||
|
||||
Members:
|
||||
modutils/insmod.c:1.111->1.112
|
||||
|
||||
---------------------
|
||||
PatchSet 3944
|
||||
Date: 2004/02/18 12:58:00
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
remove debugging
|
||||
|
||||
Members:
|
||||
networking/inetd.c:1.15->1.16
|
||||
|
||||
---------------------
|
||||
PatchSet 3945
|
||||
Date: 2004/02/18 13:12:53
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Formatting
|
||||
|
||||
Members:
|
||||
networking/inetd.c:1.16->1.17
|
||||
|
||||
---------------------
|
||||
PatchSet 3946
|
||||
Date: 2004/02/18 13:19:58
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Dont use same variable and struct name
|
||||
|
||||
Members:
|
||||
networking/inetd.c:1.17->1.18
|
||||
|
||||
---------------------
|
||||
PatchSet 3947
|
||||
Date: 2004/02/19 00:44:08
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Chris Larson (kergoth) writes:
|
||||
|
||||
I was adding -s/--symbolic-link support to busybox cp when I noticed a
|
||||
bug with -r/-a. Test case:
|
||||
|
||||
mkdir -p test/out
|
||||
cd test
|
||||
busybox cp -a * out/
|
||||
|
||||
Will never return until we run out of open files or similar.
|
||||
Coreutils cp on the other hand will error with "cannot copy a directory,
|
||||
`out', into itself, `out'". Patch attached.
|
||||
|
||||
Members:
|
||||
libbb/copy_file.c:1.28->1.29
|
||||
|
||||
---------------------
|
||||
PatchSet 3948
|
||||
Date: 2004/02/19 01:52:29
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Chris Larson (kergoth) writes:
|
||||
|
||||
As Manuel points out, this is a flawed fix, and doesnt fix the
|
||||
following:
|
||||
|
||||
mkdir -p cpa cpb cpc
|
||||
cp -a cpa cpa/cpb/cpc
|
||||
|
||||
Attached what appears to be a more sane fix. Apply on top of previous.
|
||||
Please confirm sanity.
|
||||
|
||||
Members:
|
||||
libbb/copy_file.c:1.29->1.30
|
||||
|
||||
---------------------
|
||||
PatchSet 3949
|
||||
Date: 2004/02/19 08:48:30
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Add extra comments, freakout if a pax archive is encoutered.
|
||||
|
||||
Members:
|
||||
archival/libunarchive/get_header_tar.c:1.32->1.33
|
||||
|
||||
---------------------
|
||||
PatchSet 3950
|
||||
Date: 2004/02/20 02:25:18
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
A strict interpretation of the ustar format requires the type flag to be
|
||||
interpreted, we cannot depend on the file type being set in the mode
|
||||
field.
|
||||
|
||||
Members:
|
||||
archival/libunarchive/get_header_tar.c:1.33->1.34
|
||||
|
||||
---------------------
|
||||
PatchSet 3951
|
||||
Date: 2004/02/20 02:34:42
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Fix up hard links
|
||||
|
||||
Members:
|
||||
archival/libunarchive/get_header_tar.c:1.34->1.35
|
||||
|
||||
---------------------
|
||||
PatchSet 3952
|
||||
Date: 2004/02/20 09:55:37
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Document missing cp options
|
||||
|
||||
Members:
|
||||
include/usage.h:1.187->1.188
|
||||
|
||||
---------------------
|
||||
PatchSet 3953
|
||||
Date: 2004/02/21 07:49:54
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Use return instead of exit, use == instead of & ==, left justify labels,
|
||||
adjustment of whitespace.
|
||||
|
||||
Members:
|
||||
coreutils/mv.c:1.19->1.20
|
||||
|
||||
---------------------
|
||||
PatchSet 3954
|
||||
Date: 2004/02/21 09:20:56
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Sometimes i get carried away with the use of function pointers, im sure
|
||||
it seemed like a good idea at the time.
|
||||
|
||||
Members:
|
||||
archival/libunarchive/seek_by_char.c:1.3->1.4
|
||||
include/libbb.h:1.126->1.127
|
||||
libbb/copyfd.c:1.9->1.10
|
||||
|
||||
---------------------
|
||||
PatchSet 3955
|
||||
Date: 2004/02/22 00:27:34
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
No need to check proxy env variable twice, ignore proxy env variable if
|
||||
its set to 0
|
||||
|
||||
Members:
|
||||
networking/wget.c:1.68->1.69
|
||||
|
||||
---------------------
|
||||
PatchSet 3956
|
||||
Date: 2004/02/22 02:58:57
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Return 1 upon failure
|
||||
|
||||
Members:
|
||||
coreutils/md5_sha1_sum.c:1.4->1.5
|
||||
|
||||
---------------------
|
||||
PatchSet 3957
|
||||
Date: 2004/02/22 03:33:53
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Ptch by Hideki IWAMOTO, fix a bug preventing tftp from getting or
|
||||
putting more than 0xffff blocks.
|
||||
|
||||
Members:
|
||||
networking/tftp.c:1.21->1.22
|
||||
|
||||
---------------------
|
||||
PatchSet 3958
|
||||
Date: 2004/02/22 04:12:58
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Update usage for ftpget and ftpput
|
||||
|
||||
Members:
|
||||
include/usage.h:1.188->1.189
|
||||
|
||||
---------------------
|
||||
PatchSet 3959
|
||||
Date: 2004/02/22 04:17:26
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Thomas Geulig, remove duplicate header
|
||||
|
||||
Members:
|
||||
init/init_shared.c:1.3->1.4
|
||||
|
||||
---------------------
|
||||
PatchSet 3960
|
||||
Date: 2004/02/22 04:44:21
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Fixup braces (patch from Thomas Geulig), run through indent and manually
|
||||
adjust.
|
||||
|
||||
Members:
|
||||
miscutils/crond.c:1.12->1.13
|
||||
|
||||
---------------------
|
||||
PatchSet 3961
|
||||
Date: 2004/02/22 04:58:36
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
remove duplicate header declarations
|
||||
|
||||
Members:
|
||||
networking/inetd.c:1.18->1.19
|
||||
|
||||
---------------------
|
||||
PatchSet 3962
|
||||
Date: 2004/02/22 07:20:25
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from Hideki IWAMOTO, output debugging messages to stderr
|
||||
|
||||
Members:
|
||||
networking/tftp.c:1.22->1.23
|
||||
|
||||
---------------------
|
||||
PatchSet 3963
|
||||
Date: 2004/02/22 07:38:36
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from Florian Schirmer. compile fix for debug builds
|
||||
|
||||
Members:
|
||||
miscutils/devfsd.c:1.7->1.8
|
||||
|
||||
---------------------
|
||||
PatchSet 3964
|
||||
Date: 2004/02/22 08:33:37
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Use /var/lib/hwclock for adjtime, its really a state file rather than a
|
||||
config file, so it should be in /etc, FHS mentions it also.
|
||||
|
||||
Members:
|
||||
util-linux/hwclock.c:1.6->1.7
|
||||
|
||||
---------------------
|
||||
PatchSet 3965
|
||||
Date: 2004/02/22 09:11:33
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Use bb_getopt_ulflags, marginal saving, better argument checking.
|
||||
|
||||
Members:
|
||||
util-linux/hwclock.c:1.7->1.8
|
||||
|
||||
---------------------
|
||||
PatchSet 3966
|
||||
Date: 2004/02/22 09:45:57
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from James Zhu, telnetd window resizing support.
|
||||
|
||||
Members:
|
||||
networking/telnetd.c:1.9->1.10
|
||||
|
||||
---------------------
|
||||
PatchSet 3967
|
||||
Date: 2004/02/22 11:13:28
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Vodz. last_patch_128
|
||||
- declare applet_using as static from applets.c
|
||||
- small correction to cmdedit,
|
||||
previous version cleared history after Ctrl-C
|
||||
- small spelling correction (by Friedrich Lobenstock)
|
||||
|
||||
Members:
|
||||
applets/applets.c:1.22->1.23
|
||||
shell/cmdedit.c:1.88->1.89
|
||||
|
||||
---------------------
|
||||
PatchSet 3968
|
||||
Date: 2004/02/22 11:25:13
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from Vodz, cleanup memory usage, send strdup error messages to
|
||||
syslog.
|
||||
|
||||
Members:
|
||||
networking/inetd.c:1.19->1.20
|
||||
|
||||
---------------------
|
||||
PatchSet 3969
|
||||
Date: 2004/02/22 11:35:13
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from Chris Larson (kergoth), to allow multiple directores to be
|
||||
unmounted at once.
|
||||
|
||||
Members:
|
||||
docs/busybox.sgml:1.52->1.53
|
||||
util-linux/umount.c:1.62->1.63
|
||||
|
||||
---------------------
|
||||
PatchSet 3970
|
||||
Date: 2004/02/22 11:46:49
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
For the time being, revert the changes for detecting copying
|
||||
a directory into itself. It is harder to do this correctly
|
||||
than it appears. Not trying at all seems a better compromise
|
||||
for the time being, untill we can implement this correctly.
|
||||
|
||||
Members:
|
||||
libbb/copy_file.c:1.30->1.31
|
||||
|
||||
---------------------
|
||||
PatchSet 3971
|
||||
Date: 2004/02/22 11:55:09
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Patch from Dmitry Zakharov, this line was missedfrom the last patch
|
||||
|
||||
Members:
|
||||
editors/awk.c:1.5->1.6
|
||||
|
||||
---------------------
|
||||
PatchSet 3972
|
||||
Date: 2004/02/22 12:17:33
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Fix from Paul Kortekaas for syslog -C option, size should be in kB.
|
||||
|
||||
Members:
|
||||
sysklogd/syslogd.c:1.106->1.107
|
||||
|
||||
---------------------
|
||||
PatchSet 3973
|
||||
Date: 2004/02/22 12:25:47
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Fernando Silveira writes:
|
||||
|
||||
Hi,
|
||||
|
||||
Well, I made this patch a long time ago (08/2002) because it was a
|
||||
need of a project, but had no time to send it to you. It adds support
|
||||
to `autologin' option of the telnet protocol. It has been used since
|
||||
made with busybox 0.60.3 at production and I had no problems with it.
|
||||
I have ported it to the HEAD revision of the CVS server (20040211) and
|
||||
I hope you enjoy and apply it to the official sources. :)
|
||||
|
||||
Thanks a lot!
|
||||
|
||||
Members:
|
||||
include/usage.h:1.189->1.190
|
||||
networking/Config.in:1.26->1.27
|
||||
networking/telnet.c:1.41->1.42
|
||||
|
||||
---------------------
|
||||
PatchSet 3974
|
||||
Date: 2004/02/22 12:27:04
|
||||
Author: andersen
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
Bump up version in preparation for -pre8
|
||||
|
||||
Members:
|
||||
Rules.mak:1.27->1.28
|
||||
|
||||
---------------------
|
||||
PatchSet 3975
|
||||
Date: 2004/02/23 08:11:07
|
||||
Author: bug1
|
||||
Branch: HEAD
|
||||
Tag: (none)
|
||||
Log:
|
||||
bb_full_fd_action was incorrectly returning an error message causing
|
||||
major breaking.
|
||||
|
||||
Members:
|
||||
libbb/copyfd.c:1.10->1.11
|
||||
|
||||
@@ -1,259 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# You shouldn't need to mess with anything beyond this point...
|
||||
#--------------------------------------------------------------
|
||||
noconfig_targets := menuconfig config oldconfig randconfig \
|
||||
defconfig allyesconfig allnoconfig clean distclean \
|
||||
release tags
|
||||
TOPDIR=./
|
||||
include Rules.mak
|
||||
|
||||
DIRS:=applets archival archival/libunarchive coreutils console-tools \
|
||||
debianutils editors findutils init miscutils modutils networking \
|
||||
networking/libiproute networking/udhcp procps loginutils shell \
|
||||
sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb
|
||||
|
||||
ifeq ($(strip $(CONFIG_SELINUX)),y)
|
||||
CFLAGS += -I/usr/include/selinux
|
||||
LIBRARIES += -lsecure
|
||||
endif
|
||||
|
||||
CONFIG_CONFIG_IN = sysdeps/$(TARGET_OS)/Config.in
|
||||
CONFIG_DEFCONFIG = sysdeps/$(TARGET_OS)/defconfig
|
||||
|
||||
ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
all: busybox busybox.links doc
|
||||
|
||||
# In this section, we need .config
|
||||
-include .config.cmd
|
||||
include $(patsubst %,%/Makefile.in, $(DIRS))
|
||||
|
||||
busybox: .depend include/config.h $(libraries-y)
|
||||
$(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
|
||||
$(STRIPCMD) $@
|
||||
|
||||
busybox.links: applets/busybox.mkll include/config.h
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
install: applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
uninstall: busybox.links
|
||||
rm -f $(PREFIX)/bin/busybox
|
||||
for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
|
||||
|
||||
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 include/usage.h docs/busybox_footer.pod
|
||||
- ( cat docs/busybox_header.pod; \
|
||||
docs/autodocifier.pl include/usage.h; \
|
||||
cat docs/busybox_footer.pod ) > docs/busybox.pod
|
||||
|
||||
docs/BusyBox.txt: docs/busybox.pod
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
-mkdir -p docs
|
||||
-pod2text $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.net/BusyBox.html
|
||||
- mkdir -p docs
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.net/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.net
|
||||
- pod2html --noindex $< > \
|
||||
docs/busybox.net/BusyBox.html
|
||||
-@ rm -f pod2htm*
|
||||
|
||||
|
||||
# New docs based on DOCBOOK SGML
|
||||
newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
|
||||
|
||||
docs/busybox.txt: docs/busybox.sgml
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b txt busybox.sgml)
|
||||
|
||||
docs/busybox.dvi: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b dvi busybox.sgml)
|
||||
|
||||
docs/busybox.ps: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b ps busybox.sgml)
|
||||
|
||||
docs/busybox.pdf: docs/busybox.ps
|
||||
- mkdir -p docs
|
||||
(cd docs; ps2pdf busybox.ps)
|
||||
|
||||
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
# The nifty new buildsystem stuff
|
||||
scripts/mkdep: scripts/mkdep.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
|
||||
|
||||
scripts/split-include: scripts/split-include.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
|
||||
|
||||
.depend: scripts/mkdep
|
||||
rm -f .depend .hdepend;
|
||||
mkdir -p include/config;
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
|
||||
scripts/mkdep -I include -- \
|
||||
`find . -name \*.c -print` >> .depend;
|
||||
scripts/mkdep -I include -- \
|
||||
`find . -name \*.h -print` >> .hdepend;
|
||||
$(MAKE) $(patsubst %,_sfdep_%,$(DIRS)) _FASTDEP_ALL_SUB_DIRS="$(DIRS)" ;
|
||||
|
||||
depend dep: include/config.h .depend
|
||||
|
||||
include/config/MARKER: depend scripts/split-include
|
||||
scripts/split-include include/config.h include/config
|
||||
@ touch include/config/MARKER
|
||||
|
||||
include/config.h: .config
|
||||
@if [ ! -x ./scripts/config/conf ] ; then \
|
||||
$(MAKE) -C scripts/config conf; \
|
||||
fi;
|
||||
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
finished2:
|
||||
@echo
|
||||
@echo Finished installing...
|
||||
@echo
|
||||
|
||||
else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
all: menuconfig
|
||||
|
||||
# configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
scripts/config/conf:
|
||||
$(MAKE) -C scripts/config conf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp $(CONFIG_DEFCONFIG) .config; \
|
||||
fi
|
||||
scripts/config/mconf:
|
||||
$(MAKE) -C scripts/config ncurses conf mconf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp $(CONFIG_DEFCONFIG) .config; \
|
||||
fi
|
||||
|
||||
menuconfig: scripts/config/mconf
|
||||
@./scripts/config/mconf $(CONFIG_CONFIG_IN)
|
||||
|
||||
config: scripts/config/conf
|
||||
@./scripts/config/conf $(CONFIG_CONFIG_IN)
|
||||
|
||||
oldconfig: scripts/config/conf
|
||||
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
randconfig: scripts/config/conf
|
||||
@./scripts/config/conf -r $(CONFIG_CONFIG_IN)
|
||||
|
||||
allyesconfig: scripts/config/conf
|
||||
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
|
||||
|
||||
allnoconfig: scripts/config/conf
|
||||
@./scripts/config/conf -n $(CONFIG_CONFIG_IN)
|
||||
|
||||
defconfig: scripts/config/conf
|
||||
@./scripts/config/conf -d $(CONFIG_CONFIG_IN)
|
||||
|
||||
test tests: busybox
|
||||
# Note that 'tests' is depricated. Use 'make check' instead
|
||||
# To use the nice new testsuite....
|
||||
cd tests && ./tester.sh
|
||||
|
||||
check: busybox
|
||||
cd testsuite && ./runtest
|
||||
|
||||
clean:
|
||||
- $(MAKE) -C tests clean
|
||||
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pdf docs/busybox.pod docs/busybox.net/busybox.html \
|
||||
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
|
||||
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
|
||||
.config.old .hdepend busybox
|
||||
- rm -rf _install
|
||||
- find . -name .\*.flags -exec rm -f {} \;
|
||||
- find . -name \*.o -exec rm -f {} \;
|
||||
- find . -name \*.a -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f scripts/split-include scripts/mkdep
|
||||
- rm -rf include/config include/config.h
|
||||
- find . -name .depend -exec rm -f {} \;
|
||||
rm -f .config .config.old .config.cmd
|
||||
- $(MAKE) -C scripts/config clean
|
||||
|
||||
release: distclean #doc
|
||||
cd ..; \
|
||||
rm -rf $(PROG)-$(VERSION); \
|
||||
cp -a busybox $(PROG)-$(VERSION); \
|
||||
\
|
||||
find $(PROG)-$(VERSION)/ -type d \
|
||||
-name CVS \
|
||||
-print \
|
||||
-exec rm -rf {} \; ; \
|
||||
\
|
||||
find $(PROG)-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
|
||||
|
||||
tags:
|
||||
ctags -R .
|
||||
|
||||
|
||||
endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
.PHONY: dummy subdirs release distclean clean config oldconfig \
|
||||
menuconfig tags check test tests depend
|
||||
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
Please see the LICENSE file for details on copying and usage.
|
||||
|
||||
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
|
||||
embedded system. The utilities in BusyBox generally have fewer options than
|
||||
their full featured GNU cousins; however, the options that are included provide
|
||||
the expected functionality and behave very much like their GNU counterparts.
|
||||
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
|
||||
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, /etc, and a kernel.
|
||||
|
||||
As of version 0.20 there is now a version number. : ) Also as of version 0.20,
|
||||
BusyBox is now modularized to easily allow you to build only the components you
|
||||
need, thereby reducing binary size. Run 'make config' or 'make menuconfig'
|
||||
for select the functionality that you wish to enable.
|
||||
|
||||
After the build is complete, a busybox.links file is generated. This is
|
||||
used by 'make install' to create symlinks to the busybox binary for all
|
||||
compiled in functions. By default, 'make install' will place the symlink
|
||||
forest into `pwd`/_install unless you have defined the PREFIX environment
|
||||
variable (i.e., 'make PREFIX=/tmp/foo install')
|
||||
|
||||
If you wish to install hardlinks, rather than symlinks, you can use
|
||||
'make install-hardlinks' instead.
|
||||
|
||||
----------------
|
||||
|
||||
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, m68k,
|
||||
MIPS, cris, and v850e.
|
||||
|
||||
Supported libcs:
|
||||
|
||||
glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, glibc-2.3.x, uClibc. People
|
||||
are looking at newlib and diet-libc, but consider them unsupported,
|
||||
untested, or worse. Linux-libc5 is no longer supported -- you
|
||||
should probably use uClibc instead if you want a small C library.
|
||||
|
||||
Supported kernels:
|
||||
|
||||
Full functionality requires Linux 2.2.x or better. A large fraction of the
|
||||
code should run on just about anything. While the current code is fairly
|
||||
Linux specific, it should be fairly easy to port the majority of the code
|
||||
to, say, FreeBSD or Solaris, or MacOsX, or even Windows (if you are into that
|
||||
sortof thing).
|
||||
|
||||
----------------
|
||||
|
||||
Getting help:
|
||||
|
||||
When you find you need help, you can check out the BusyBox mailing list
|
||||
archives at http://busybox.net/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
|
||||
Bugs:
|
||||
|
||||
If you find bugs, please submit a detailed bug report to the busybox mailing
|
||||
list at busybox@mail.busybox.net. A well-written bug report should include a
|
||||
transcript of a shell session that demonstrates the bad behavior and enables
|
||||
anyone else to duplicate the bug on their own machine. The following is such
|
||||
an example:
|
||||
|
||||
To: busybox@mail.busybox.net
|
||||
From: diligent@testing.linux.org
|
||||
Subject: /bin/date doesn't work
|
||||
|
||||
Package: busybox
|
||||
Version: 1.00
|
||||
|
||||
When I execute Busybox 'date' it produces unexpected results.
|
||||
With GNU date I get the following output:
|
||||
|
||||
$ date
|
||||
Wed Mar 21 14:19:41 MST 2001
|
||||
|
||||
But when I use BusyBox date I get this instead:
|
||||
|
||||
$ date
|
||||
llegal instruction
|
||||
|
||||
I am using Debian unstable, kernel version 2.4.19-rmk1 on an Netwinder,
|
||||
and the latest uClibc from CVS. Thanks for the wonderful program!
|
||||
|
||||
-Diligent
|
||||
|
||||
Note the careful description and use of examples showing not only what BusyBox
|
||||
does, but also a counter example showing what an equivalent GNU app does. Bug
|
||||
reports lacking such detail may never be fixed... Thanks for understanding.
|
||||
|
||||
----------------
|
||||
|
||||
FTP:
|
||||
|
||||
Source for the latest released version, as well as daily snapshots, can always
|
||||
be downloaded from
|
||||
http://busybox.net/downloads/
|
||||
|
||||
----------------
|
||||
|
||||
CVS:
|
||||
|
||||
BusyBox now has its own publicly browsable CVS tree at:
|
||||
http://busybox.net/cgi-bin/cvsweb/busybox/
|
||||
|
||||
Anonymous CVS access is available. For instructions, check out:
|
||||
http://busybox.net/cvs_anon.html
|
||||
|
||||
For those that are actively contributing there is even CVS write access:
|
||||
http://busybox.net/cvs_write.html
|
||||
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@codepoet.org>
|
||||
<andersen@codepoet.org>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
TODO list for busybox in no particular order. Just because something
|
||||
is listed here doesn't mean that it is going to be added to busybox,
|
||||
or that doing so is even a good idea. It just means that we _might_ get
|
||||
around to it some time. If you have any good ideas, please send them
|
||||
on in...
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
Possible apps to include some time:
|
||||
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
|
||||
-----------
|
||||
|
||||
With sysvinit, reboot, poweroff and halt all used a named pipe,
|
||||
/dev/initctl, to communicate with the init process. Busybox
|
||||
currently uses signals to communicate with init. This makes
|
||||
busybox incompatible with sysvinit. We should probably use
|
||||
a named pipe as well so we can be compatible.
|
||||
|
||||
-----------------------
|
||||
|
||||
Run the following:
|
||||
|
||||
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
|
||||
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
|
||||
|
||||
reveals the list of all external (i.e., libc) things that BusyBox depends on.
|
||||
It would be a very nice thing to reduce this list to an absolute minimum, to
|
||||
reduce the footprint of busybox, especially when staticly linking with
|
||||
libraries such as uClibc.
|
||||
|
||||
-----------------------
|
||||
|
||||
Compile with debugging on, run 'nm --size-sort ./busybox'
|
||||
and then start with the biggest things and make them smaller...
|
||||
|
||||
-----------------------
|
||||
|
||||
xargs could use a -l option
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
libbb/unzip.c and archival/gzip.c have common constant static arrays and
|
||||
code for initializing the CRC array. Both use CRC-32 and could use
|
||||
common code for CRC calculation. Within archival/gzip.c, the CRC
|
||||
array should be malloc-ed as it is in libbb/unzip.c .
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "busybox.h"
|
||||
|
||||
const char usage_messages[] =
|
||||
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
|
||||
#include "applets.h"
|
||||
|
||||
;
|
||||
@@ -1,293 +0,0 @@
|
||||
#include "config.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
*
|
||||
* based on the original compress42.c source
|
||||
* (see disclaimer below)
|
||||
*/
|
||||
|
||||
|
||||
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
|
||||
*
|
||||
* Authors:
|
||||
* Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
|
||||
* Jim McKie (decvax!mcvax!jim)
|
||||
* Steve Davies (decvax!vax135!petsd!peora!srd)
|
||||
* Ken Turkowski (decvax!decwrl!turtlevax!ken)
|
||||
* James A. Woods (decvax!ihnp4!ames!jaw)
|
||||
* Joe Orost (decvax!vax135!petsd!joe)
|
||||
* Dave Mack (csu@alembic.acs.com)
|
||||
* Peter Jannesen, Network Communication Systems
|
||||
* (peter@ncs.nl)
|
||||
*
|
||||
* marc@suse.de : a small security fix for a buffer overflow
|
||||
*
|
||||
* [... History snipped ...]
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Defailt input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
|
||||
/* Default output buffer size */
|
||||
#define OBUFSIZ 2048
|
||||
|
||||
/* Defines for third byte of header */
|
||||
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
|
||||
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
|
||||
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
|
||||
/* Masks 0x20 and 0x40 are free. */
|
||||
/* I think 0x20 should mean that there is */
|
||||
/* a fourth header byte (for expansion). */
|
||||
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
|
||||
/* compression rate is dropping flush tables */
|
||||
/* the next two codes should not be changed lightly, as they must not */
|
||||
/* lie within the contiguous general code space. */
|
||||
#define FIRST 257 /* first free entry */
|
||||
#define CLEAR 256 /* table clear output code */
|
||||
|
||||
#define INIT_BITS 9 /* initial number of bits/code */
|
||||
|
||||
|
||||
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
|
||||
#define FAST
|
||||
|
||||
#define HBITS 17 /* 50% occupancy */
|
||||
#define HSIZE (1<<HBITS)
|
||||
#define HMASK (HSIZE-1)
|
||||
#define HPRIME 9941
|
||||
#define BITS 16
|
||||
#undef MAXSEG_64K
|
||||
#define MAXCODE(n) (1L << (n))
|
||||
|
||||
/* Block compress mode -C compatible with 2.0 */
|
||||
int block_mode = BLOCK_MODE;
|
||||
|
||||
/* user settable max # bits/code */
|
||||
int maxbits = BITS;
|
||||
|
||||
/* Exitcode of compress (-1 no file compressed) */
|
||||
int exit_code = -1;
|
||||
|
||||
/* Input buffer */
|
||||
unsigned char inbuf[IBUFSIZ + 64];
|
||||
|
||||
/* Output buffer */
|
||||
unsigned char outbuf[OBUFSIZ + 2048];
|
||||
|
||||
|
||||
long int htab[HSIZE];
|
||||
unsigned short codetab[HSIZE];
|
||||
|
||||
#define htabof(i) htab[i]
|
||||
#define codetabof(i) codetab[i]
|
||||
#define tab_prefixof(i) codetabof(i)
|
||||
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
|
||||
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
|
||||
#define clear_htab() memset(htab, -1, sizeof(htab))
|
||||
#define clear_tab_prefixof() memset(codetab, 0, 256);
|
||||
|
||||
|
||||
/*
|
||||
* Decompress stdin to stdout. This routine adapts to the codes in the
|
||||
* file building the "string" table on-the-fly; requiring no table to
|
||||
* be stored in the compressed file. The tables used herein are shared
|
||||
* with those of the compress() routine. See the definitions above.
|
||||
*/
|
||||
|
||||
extern int uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
unsigned char *stackp;
|
||||
long int code;
|
||||
int finchar;
|
||||
long int oldcode;
|
||||
long int incode;
|
||||
int inbits;
|
||||
int posbits;
|
||||
int outpos;
|
||||
int insize;
|
||||
int bitmask;
|
||||
long int free_ent;
|
||||
long int maxcode;
|
||||
long int maxmaxcode;
|
||||
int n_bits;
|
||||
int rsize = 0;
|
||||
|
||||
insize = 0;
|
||||
|
||||
inbuf[0] = bb_xread_char(fd_in);
|
||||
|
||||
maxbits = inbuf[0] & BIT_MASK;
|
||||
block_mode = inbuf[0] & BLOCK_MODE;
|
||||
maxmaxcode = MAXCODE(maxbits);
|
||||
|
||||
if (maxbits > BITS) {
|
||||
bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
|
||||
BITS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
oldcode = -1;
|
||||
finchar = 0;
|
||||
outpos = 0;
|
||||
posbits = 0 << 3;
|
||||
|
||||
free_ent = ((block_mode) ? FIRST : 256);
|
||||
|
||||
/* As above, initialize the first 256 entries in the table. */
|
||||
clear_tab_prefixof();
|
||||
|
||||
for (code = 255; code >= 0; --code) {
|
||||
tab_suffixof(code) = (unsigned char) code;
|
||||
}
|
||||
|
||||
do {
|
||||
resetbuf:;
|
||||
{
|
||||
int i;
|
||||
int e;
|
||||
int o;
|
||||
|
||||
e = insize - (o = (posbits >> 3));
|
||||
|
||||
for (i = 0; i < e; ++i)
|
||||
inbuf[i] = inbuf[i + o];
|
||||
|
||||
insize = e;
|
||||
posbits = 0;
|
||||
}
|
||||
|
||||
if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
|
||||
rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
|
||||
insize += rsize;
|
||||
}
|
||||
|
||||
inbits = ((rsize > 0) ? (insize - insize % n_bits) << 3 :
|
||||
(insize << 3) - (n_bits - 1));
|
||||
|
||||
while (inbits > posbits) {
|
||||
if (free_ent > maxcode) {
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
++n_bits;
|
||||
if (n_bits == maxbits) {
|
||||
maxcode = maxmaxcode;
|
||||
} else {
|
||||
maxcode = MAXCODE(n_bits) - 1;
|
||||
}
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
{
|
||||
unsigned char *p = &inbuf[posbits >> 3];
|
||||
|
||||
code =
|
||||
((((long) (p[0])) | ((long) (p[1]) << 8) |
|
||||
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
}
|
||||
posbits += n_bits;
|
||||
|
||||
|
||||
if (oldcode == -1) {
|
||||
outbuf[outpos++] = (unsigned char) (finchar =
|
||||
(int) (oldcode = code));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code == CLEAR && block_mode) {
|
||||
clear_tab_prefixof();
|
||||
free_ent = FIRST - 1;
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
|
||||
incode = code;
|
||||
stackp = de_stack;
|
||||
|
||||
/* Special case for KwKwK string. */
|
||||
if (code >= free_ent) {
|
||||
if (code > free_ent) {
|
||||
unsigned char *p;
|
||||
|
||||
posbits -= n_bits;
|
||||
p = &inbuf[posbits >> 3];
|
||||
|
||||
bb_error_msg
|
||||
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
|
||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||
(posbits & 07));
|
||||
bb_error_msg("uncompress: corrupt input");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) finchar;
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while ((long int) code >= (long int) 256) {
|
||||
*--stackp = tab_suffixof(code);
|
||||
code = tab_prefixof(code);
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) (finchar = tab_suffixof(code));
|
||||
|
||||
/* And put them out in forward order */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) {
|
||||
do {
|
||||
if (i > OBUFSIZ - outpos) {
|
||||
i = OBUFSIZ - outpos;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
|
||||
if (outpos >= OBUFSIZ) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
outpos = 0;
|
||||
}
|
||||
stackp += i;
|
||||
} while ((i = (de_stack - stackp)) > 0);
|
||||
} else {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate the new entry. */
|
||||
if ((code = free_ent) < maxmaxcode) {
|
||||
tab_prefixof(code) = (unsigned short) oldcode;
|
||||
tab_suffixof(code) = (unsigned char) finchar;
|
||||
free_ent = code + 1;
|
||||
}
|
||||
|
||||
/* Remember previous code. */
|
||||
oldcode = incode;
|
||||
}
|
||||
|
||||
} while (rsize > 0);
|
||||
|
||||
if (outpos > 0) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,982 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* gunzip implementation for busybox
|
||||
*
|
||||
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
*
|
||||
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
||||
* based on gzip sources
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support
|
||||
* files as well as stdin/stdout, and to generally behave itself wrt
|
||||
* command line handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@optushome.com.au>
|
||||
*
|
||||
* read_gz interface + associated hacking by Laurence Anderson
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
|
||||
* Copyright (C) 1992-1993 Jean-loup Gailly
|
||||
* The unzip code was written and put in the public domain by Mark Adler.
|
||||
* Portions of the lzw code are derived from the public domain 'compress'
|
||||
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
|
||||
* Ken Turkowski, Dave Mack and Peter Jannesen.
|
||||
*
|
||||
* See the license_msg below and the file COPYING for the software license.
|
||||
* See the file algorithm.doc for the compression algorithms and file formats.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static char *license_msg[] = {
|
||||
" Copyright (C) 1992-1993 Jean-loup Gailly",
|
||||
" 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., 675 Mass Ave, Cambridge, MA 02139, USA.",
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "config.h"
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
typedef struct huft_s {
|
||||
unsigned char e; /* number of extra bits or operation */
|
||||
unsigned char b; /* number of bits in this code or subcode */
|
||||
union {
|
||||
unsigned short n; /* literal, length base, or distance base */
|
||||
struct huft_s *t; /* pointer to next level of table */
|
||||
} v;
|
||||
} huft_t;
|
||||
|
||||
static int gunzip_src_fd;
|
||||
unsigned int gunzip_bytes_out; /* number of output bytes */
|
||||
static unsigned int gunzip_outbuf_count; /* bytes in output buffer */
|
||||
|
||||
/* gunzip_window size--must be a power of two, and
|
||||
* at least 32K for zip's deflate method */
|
||||
static const int gunzip_wsize = 0x8000;
|
||||
static unsigned char *gunzip_window;
|
||||
|
||||
static unsigned int *gunzip_crc_table;
|
||||
unsigned int gunzip_crc;
|
||||
|
||||
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
|
||||
#define BMAX 16 /* maximum bit length of any code (16 for explode) */
|
||||
#define N_MAX 288 /* maximum number of codes in any set */
|
||||
|
||||
/* bitbuffer */
|
||||
static unsigned int gunzip_bb; /* bit buffer */
|
||||
static unsigned char gunzip_bk; /* bits in bit buffer */
|
||||
|
||||
/* These control the size of the bytebuffer */
|
||||
static unsigned int bytebuffer_max = 0x8000;
|
||||
static unsigned char *bytebuffer = NULL;
|
||||
static unsigned int bytebuffer_offset = 0;
|
||||
static unsigned int bytebuffer_size = 0;
|
||||
|
||||
static const unsigned short mask_bits[] = {
|
||||
0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
};
|
||||
|
||||
/* Copy lengths for literal codes 257..285 */
|
||||
static const unsigned short cplens[] = {
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
|
||||
67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
|
||||
};
|
||||
|
||||
/* note: see note #13 above about the 258 in this list. */
|
||||
/* Extra bits for literal codes 257..285 */
|
||||
static const unsigned char cplext[] = {
|
||||
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, 99, 99
|
||||
}; /* 99==invalid */
|
||||
|
||||
/* Copy offsets for distance codes 0..29 */
|
||||
static const unsigned short cpdist[] = {
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
|
||||
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
|
||||
};
|
||||
|
||||
/* Extra bits for distance codes */
|
||||
static const unsigned char cpdext[] = {
|
||||
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
|
||||
};
|
||||
|
||||
/* Tables for deflate from PKZIP's appnote.txt. */
|
||||
/* Order of the bit length code lengths */
|
||||
static const unsigned char border[] = {
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
|
||||
};
|
||||
|
||||
static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current, const unsigned int required)
|
||||
{
|
||||
while (*current < required) {
|
||||
if (bytebuffer_offset >= bytebuffer_size) {
|
||||
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
|
||||
* to the front of the bytebuffer, leave 4 bytes free at end of tail
|
||||
* so we can easily top up buffer in check_trailer_gzip() */
|
||||
bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8);
|
||||
bytebuffer_offset = 4;
|
||||
}
|
||||
bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current;
|
||||
bytebuffer_offset++;
|
||||
*current += 8;
|
||||
}
|
||||
return(bitbuffer);
|
||||
}
|
||||
|
||||
static void make_gunzip_crc_table(void)
|
||||
{
|
||||
const unsigned int poly = 0xedb88320; /* polynomial exclusive-or pattern */
|
||||
unsigned short i; /* counter for all possible eight bit values */
|
||||
|
||||
/* initial shift register value */
|
||||
gunzip_crc = 0xffffffffL;
|
||||
gunzip_crc_table = (unsigned int *) malloc(256 * sizeof(unsigned int));
|
||||
|
||||
/* Compute and print table of CRC's, five per line */
|
||||
for (i = 0; i < 256; i++) {
|
||||
unsigned int table_entry; /* crc shift register */
|
||||
unsigned char k; /* byte being shifted into crc apparatus */
|
||||
|
||||
table_entry = i;
|
||||
/* The idea to initialize the register with the byte instead of
|
||||
* zero was stolen from Haruhiko Okumura's ar002
|
||||
*/
|
||||
for (k = 8; k; k--) {
|
||||
if (table_entry & 1) {
|
||||
table_entry = (table_entry >> 1) ^ poly;
|
||||
} else {
|
||||
table_entry >>= 1;
|
||||
}
|
||||
}
|
||||
gunzip_crc_table[i] = table_entry;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the malloc'ed tables built by huft_build(), which makes a linked
|
||||
* list of the tables it made, with the links in a dummy first entry of
|
||||
* each table.
|
||||
* t: table to free
|
||||
*/
|
||||
static int huft_free(huft_t * t)
|
||||
{
|
||||
huft_t *p;
|
||||
huft_t *q;
|
||||
|
||||
/* Go through linked list, freeing from the malloced (t[-1]) address. */
|
||||
p = t;
|
||||
while (p != (huft_t *) NULL) {
|
||||
q = (--p)->v.t;
|
||||
free((char *) p);
|
||||
p = q;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Given a list of code lengths and a maximum table size, make a set of
|
||||
* tables to decode that set of codes. Return zero on success, one if
|
||||
* the given code set is incomplete (the tables are still built in this
|
||||
* case), two if the input is invalid (all zero length codes or an
|
||||
* oversubscribed set of lengths), and three if not enough memory.
|
||||
*
|
||||
* b: code lengths in bits (all assumed <= BMAX)
|
||||
* n: number of codes (assumed <= N_MAX)
|
||||
* s: number of simple-valued codes (0..s-1)
|
||||
* d: list of base values for non-simple codes
|
||||
* e: list of extra bits for non-simple codes
|
||||
* t: result: starting table
|
||||
* m: maximum lookup bits, returns actual
|
||||
*/
|
||||
static int huft_build(unsigned int *b, const unsigned int n,
|
||||
const unsigned int s, const unsigned short *d,
|
||||
const unsigned char *e, huft_t ** t, int *m)
|
||||
{
|
||||
unsigned a; /* counter for codes of length k */
|
||||
unsigned c[BMAX + 1]; /* bit length count table */
|
||||
unsigned f; /* i repeats in table every f entries */
|
||||
int g; /* maximum code length */
|
||||
int h; /* table level */
|
||||
register unsigned i; /* counter, current code */
|
||||
register unsigned j; /* counter */
|
||||
register int k; /* number of bits in current code */
|
||||
int l; /* bits per table (returned in m) */
|
||||
register unsigned *p; /* pointer into c[], b[], or v[] */
|
||||
register huft_t *q; /* points to current table */
|
||||
huft_t r; /* table entry for structure assignment */
|
||||
huft_t *u[BMAX]; /* table stack */
|
||||
unsigned v[N_MAX]; /* values in order of bit length */
|
||||
register int w; /* bits before this table == (l * h) */
|
||||
unsigned x[BMAX + 1]; /* bit offsets, then code stack */
|
||||
unsigned *xp; /* pointer into x */
|
||||
int y; /* number of dummy codes added */
|
||||
unsigned z; /* number of entries in current table */
|
||||
|
||||
/* Generate counts for each bit length */
|
||||
memset((void *) (c), 0, sizeof(c));
|
||||
p = b;
|
||||
i = n;
|
||||
do {
|
||||
c[*p]++; /* assume all entries <= BMAX */
|
||||
p++; /* Can't combine with above line (Solaris bug) */
|
||||
} while (--i);
|
||||
if (c[0] == n) { /* null input--all zero length codes */
|
||||
*t = (huft_t *) NULL;
|
||||
*m = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find minimum and maximum length, bound *m by those */
|
||||
l = *m;
|
||||
for (j = 1; j <= BMAX; j++) {
|
||||
if (c[j]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
k = j; /* minimum code length */
|
||||
if ((unsigned) l < j) {
|
||||
l = j;
|
||||
}
|
||||
for (i = BMAX; i; i--) {
|
||||
if (c[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
g = i; /* maximum code length */
|
||||
if ((unsigned) l > i) {
|
||||
l = i;
|
||||
}
|
||||
*m = l;
|
||||
|
||||
/* Adjust last length count to fill out codes, if needed */
|
||||
for (y = 1 << j; j < i; j++, y <<= 1) {
|
||||
if ((y -= c[j]) < 0) {
|
||||
return 2; /* bad input: more codes than bits */
|
||||
}
|
||||
}
|
||||
if ((y -= c[i]) < 0) {
|
||||
return 2;
|
||||
}
|
||||
c[i] += y;
|
||||
|
||||
/* Generate starting offsets into the value table for each length */
|
||||
x[1] = j = 0;
|
||||
p = c + 1;
|
||||
xp = x + 2;
|
||||
while (--i) { /* note that i == g from above */
|
||||
*xp++ = (j += *p++);
|
||||
}
|
||||
|
||||
/* Make a table of values in order of bit lengths */
|
||||
p = b;
|
||||
i = 0;
|
||||
do {
|
||||
if ((j = *p++) != 0) {
|
||||
v[x[j]++] = i;
|
||||
}
|
||||
} while (++i < n);
|
||||
|
||||
/* Generate the Huffman codes and for each, make the table entries */
|
||||
x[0] = i = 0; /* first Huffman code is zero */
|
||||
p = v; /* grab values in bit order */
|
||||
h = -1; /* no tables yet--level -1 */
|
||||
w = -l; /* bits decoded == (l * h) */
|
||||
u[0] = (huft_t *) NULL; /* just to keep compilers happy */
|
||||
q = (huft_t *) NULL; /* ditto */
|
||||
z = 0; /* ditto */
|
||||
|
||||
/* go through the bit lengths (k already is bits in shortest code) */
|
||||
for (; k <= g; k++) {
|
||||
a = c[k];
|
||||
while (a--) {
|
||||
/* here i is the Huffman code of length k bits for value *p */
|
||||
/* make tables up to required level */
|
||||
while (k > w + l) {
|
||||
h++;
|
||||
w += l; /* previous table always l bits */
|
||||
|
||||
/* compute minimum size table less than or equal to l bits */
|
||||
z = (z = g - w) > (unsigned) l ? l : z; /* upper limit on table size */
|
||||
if ((f = 1 << (j = k - w)) > a + 1) { /* try a k-w bit table *//* too few codes for k-w bit table */
|
||||
f -= a + 1; /* deduct codes from patterns left */
|
||||
xp = c + k;
|
||||
while (++j < z) { /* try smaller tables up to z bits */
|
||||
if ((f <<= 1) <= *++xp) {
|
||||
break; /* enough codes to use up j bits */
|
||||
}
|
||||
f -= *xp; /* else deduct codes from patterns */
|
||||
}
|
||||
}
|
||||
z = 1 << j; /* table entries for j-bit table */
|
||||
|
||||
/* allocate and link in new table */
|
||||
q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t));
|
||||
|
||||
*t = q + 1; /* link to list for huft_free() */
|
||||
*(t = &(q->v.t)) = NULL;
|
||||
u[h] = ++q; /* table starts after link */
|
||||
|
||||
/* connect to last table, if there is one */
|
||||
if (h) {
|
||||
x[h] = i; /* save pattern for backing up */
|
||||
r.b = (unsigned char) l; /* bits to dump before this table */
|
||||
r.e = (unsigned char) (16 + j); /* bits in this table */
|
||||
r.v.t = q; /* pointer to this table */
|
||||
j = i >> (w - l); /* (get around Turbo C bug) */
|
||||
u[h - 1][j] = r; /* connect to last table */
|
||||
}
|
||||
}
|
||||
|
||||
/* set up table entry in r */
|
||||
r.b = (unsigned char) (k - w);
|
||||
if (p >= v + n) {
|
||||
r.e = 99; /* out of values--invalid code */
|
||||
} else if (*p < s) {
|
||||
r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is end-of-block code */
|
||||
r.v.n = (unsigned short) (*p); /* simple code is just the value */
|
||||
p++; /* one compiler does not like *p++ */
|
||||
} else {
|
||||
r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists */
|
||||
r.v.n = d[*p++ - s];
|
||||
}
|
||||
|
||||
/* fill code-like entries with r */
|
||||
f = 1 << (k - w);
|
||||
for (j = i >> w; j < z; j += f) {
|
||||
q[j] = r;
|
||||
}
|
||||
|
||||
/* backwards increment the k-bit code i */
|
||||
for (j = 1 << (k - 1); i & j; j >>= 1) {
|
||||
i ^= j;
|
||||
}
|
||||
i ^= j;
|
||||
|
||||
/* backup over finished tables */
|
||||
while ((i & ((1 << w) - 1)) != x[h]) {
|
||||
h--; /* don't need to update q */
|
||||
w -= l;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Return true (1) if we were given an incomplete table */
|
||||
return y != 0 && g != 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* inflate (decompress) the codes in a deflated (compressed) block.
|
||||
* Return an error code or zero if it all goes ok.
|
||||
*
|
||||
* tl, td: literal/length and distance decoder tables
|
||||
* bl, bd: number of bits decoded by tl[] and td[]
|
||||
*/
|
||||
static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_bl, const unsigned int my_bd, int setup)
|
||||
{
|
||||
static unsigned int e; /* table entry flag/number of extra bits */
|
||||
static unsigned int n, d; /* length and index for copy */
|
||||
static unsigned int w; /* current gunzip_window position */
|
||||
static huft_t *t; /* pointer to table entry */
|
||||
static unsigned int ml, md; /* masks for bl and bd bits */
|
||||
static unsigned int b; /* bit buffer */
|
||||
static unsigned int k; /* number of bits in bit buffer */
|
||||
static huft_t *tl, *td;
|
||||
static unsigned int bl, bd;
|
||||
static int resumeCopy = 0;
|
||||
|
||||
if (setup) { // 1st time we are called, copy in variables
|
||||
tl = my_tl;
|
||||
td = my_td;
|
||||
bl = my_bl;
|
||||
bd = my_bd;
|
||||
/* make local copies of globals */
|
||||
b = gunzip_bb; /* initialize bit buffer */
|
||||
k = gunzip_bk;
|
||||
w = gunzip_outbuf_count; /* initialize gunzip_window position */
|
||||
|
||||
/* inflate the coded data */
|
||||
ml = mask_bits[bl]; /* precompute masks for speed */
|
||||
md = mask_bits[bd];
|
||||
return 0; // Don't actually do anything the first time
|
||||
}
|
||||
|
||||
if (resumeCopy) goto do_copy;
|
||||
|
||||
while (1) { /* do until end of block */
|
||||
b = fill_bitbuffer(b, &k, bl);
|
||||
if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
|
||||
do {
|
||||
if (e == 99) {
|
||||
bb_error_msg_and_die("inflate_codes error 1");;
|
||||
}
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
e -= 16;
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
} while ((e =
|
||||
(t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
if (e == 16) { /* then it's a literal */
|
||||
gunzip_window[w++] = (unsigned char) t->v.n;
|
||||
if (w == gunzip_wsize) {
|
||||
gunzip_outbuf_count = (w);
|
||||
//flush_gunzip_window();
|
||||
w = 0;
|
||||
return 1; // We have a block to read
|
||||
}
|
||||
} else { /* it's an EOB or a length */
|
||||
|
||||
/* exit if end of block */
|
||||
if (e == 15) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* get length of block to copy */
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
n = t->v.n + ((unsigned) b & mask_bits[e]);
|
||||
b >>= e;
|
||||
k -= e;
|
||||
|
||||
/* decode distance of block to copy */
|
||||
b = fill_bitbuffer(b, &k, bd);
|
||||
if ((e = (t = td + ((unsigned) b & md))->e) > 16)
|
||||
do {
|
||||
if (e == 99)
|
||||
bb_error_msg_and_die("inflate_codes error 2");;
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
e -= 16;
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
} while ((e =
|
||||
(t =
|
||||
t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
d = w - t->v.n - ((unsigned) b & mask_bits[e]);
|
||||
b >>= e;
|
||||
k -= e;
|
||||
|
||||
/* do the copy */
|
||||
do_copy: do {
|
||||
n -= (e =
|
||||
(e =
|
||||
gunzip_wsize - ((d &= gunzip_wsize - 1) > w ? d : w)) > n ? n : e);
|
||||
/* copy to new buffer to prevent possible overwrite */
|
||||
if (w - d >= e) { /* (this test assumes unsigned comparison) */
|
||||
memcpy(gunzip_window + w, gunzip_window + d, e);
|
||||
w += e;
|
||||
d += e;
|
||||
} else {
|
||||
/* do it slow to avoid memcpy() overlap */
|
||||
/* !NOMEMCPY */
|
||||
do {
|
||||
gunzip_window[w++] = gunzip_window[d++];
|
||||
} while (--e);
|
||||
}
|
||||
if (w == gunzip_wsize) {
|
||||
gunzip_outbuf_count = (w);
|
||||
if (n) resumeCopy = 1;
|
||||
else resumeCopy = 0;
|
||||
//flush_gunzip_window();
|
||||
w = 0;
|
||||
return 1;
|
||||
}
|
||||
} while (n);
|
||||
resumeCopy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* restore the globals from the locals */
|
||||
gunzip_outbuf_count = w; /* restore global gunzip_window pointer */
|
||||
gunzip_bb = b; /* restore global bit buffer */
|
||||
gunzip_bk = k;
|
||||
|
||||
/* normally just after call to inflate_codes, but save code by putting it here */
|
||||
/* free the decoding tables, return */
|
||||
huft_free(tl);
|
||||
huft_free(td);
|
||||
|
||||
/* done */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup)
|
||||
{
|
||||
static int n, b_stored, k_stored, w;
|
||||
if (setup) {
|
||||
n = my_n;
|
||||
b_stored = my_b_stored;
|
||||
k_stored = my_k_stored;
|
||||
w = gunzip_outbuf_count; /* initialize gunzip_window position */
|
||||
return 0; // Don't do anything first time
|
||||
}
|
||||
|
||||
/* read and output the compressed data */
|
||||
while (n--) {
|
||||
b_stored = fill_bitbuffer(b_stored, &k_stored, 8);
|
||||
gunzip_window[w++] = (unsigned char) b_stored;
|
||||
if (w == (unsigned int) gunzip_wsize) {
|
||||
gunzip_outbuf_count = (w);
|
||||
//flush_gunzip_window();
|
||||
w = 0;
|
||||
b_stored >>= 8;
|
||||
k_stored -= 8;
|
||||
return 1; // We have a block
|
||||
}
|
||||
b_stored >>= 8;
|
||||
k_stored -= 8;
|
||||
}
|
||||
|
||||
/* restore the globals from the locals */
|
||||
gunzip_outbuf_count = w; /* restore global gunzip_window pointer */
|
||||
gunzip_bb = b_stored; /* restore global bit buffer */
|
||||
gunzip_bk = k_stored;
|
||||
return 0; // Finished
|
||||
}
|
||||
|
||||
/*
|
||||
* decompress an inflated block
|
||||
* e: last block flag
|
||||
*
|
||||
* GLOBAL VARIABLES: bb, kk,
|
||||
*/
|
||||
// Return values: -1 = inflate_stored, -2 = inflate_codes
|
||||
static int inflate_block(int *e)
|
||||
{
|
||||
unsigned t; /* block type */
|
||||
register unsigned int b; /* bit buffer */
|
||||
unsigned int k; /* number of bits in bit buffer */
|
||||
|
||||
/* make local bit buffer */
|
||||
|
||||
b = gunzip_bb;
|
||||
k = gunzip_bk;
|
||||
|
||||
/* read in last block bit */
|
||||
b = fill_bitbuffer(b, &k, 1);
|
||||
*e = (int) b & 1;
|
||||
b >>= 1;
|
||||
k -= 1;
|
||||
|
||||
/* read in block type */
|
||||
b = fill_bitbuffer(b, &k, 2);
|
||||
t = (unsigned) b & 3;
|
||||
b >>= 2;
|
||||
k -= 2;
|
||||
|
||||
/* restore the global bit buffer */
|
||||
gunzip_bb = b;
|
||||
gunzip_bk = k;
|
||||
|
||||
/* inflate that block type */
|
||||
switch (t) {
|
||||
case 0: /* Inflate stored */
|
||||
{
|
||||
unsigned int n; /* number of bytes in block */
|
||||
unsigned int b_stored; /* bit buffer */
|
||||
unsigned int k_stored; /* number of bits in bit buffer */
|
||||
|
||||
/* make local copies of globals */
|
||||
b_stored = gunzip_bb; /* initialize bit buffer */
|
||||
k_stored = gunzip_bk;
|
||||
|
||||
/* go to byte boundary */
|
||||
n = k_stored & 7;
|
||||
b_stored >>= n;
|
||||
k_stored -= n;
|
||||
|
||||
/* get the length and its complement */
|
||||
b_stored = fill_bitbuffer(b_stored, &k_stored, 16);
|
||||
n = ((unsigned) b_stored & 0xffff);
|
||||
b_stored >>= 16;
|
||||
k_stored -= 16;
|
||||
|
||||
b_stored = fill_bitbuffer(b_stored, &k_stored, 16);
|
||||
if (n != (unsigned) ((~b_stored) & 0xffff)) {
|
||||
return 1; /* error in compressed data */
|
||||
}
|
||||
b_stored >>= 16;
|
||||
k_stored -= 16;
|
||||
|
||||
inflate_stored(n, b_stored, k_stored, 1); // Setup inflate_stored
|
||||
return -1;
|
||||
}
|
||||
case 1: /* Inflate fixed
|
||||
* decompress an inflated type 1 (fixed Huffman codes) block. We should
|
||||
* either replace this with a custom decoder, or at least precompute the
|
||||
* Huffman tables.
|
||||
*/
|
||||
{
|
||||
int i; /* temporary variable */
|
||||
huft_t *tl; /* literal/length code table */
|
||||
huft_t *td; /* distance code table */
|
||||
unsigned int bl; /* lookup bits for tl */
|
||||
unsigned int bd; /* lookup bits for td */
|
||||
unsigned int l[288]; /* length list for huft_build */
|
||||
|
||||
/* set up literal table */
|
||||
for (i = 0; i < 144; i++) {
|
||||
l[i] = 8;
|
||||
}
|
||||
for (; i < 256; i++) {
|
||||
l[i] = 9;
|
||||
}
|
||||
for (; i < 280; i++) {
|
||||
l[i] = 7;
|
||||
}
|
||||
for (; i < 288; i++) { /* make a complete, but wrong code set */
|
||||
l[i] = 8;
|
||||
}
|
||||
bl = 7;
|
||||
if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
/* set up distance table */
|
||||
for (i = 0; i < 30; i++) { /* make an incomplete code set */
|
||||
l[i] = 5;
|
||||
}
|
||||
bd = 5;
|
||||
if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) {
|
||||
huft_free(tl);
|
||||
return i;
|
||||
}
|
||||
|
||||
/* decompress until an end-of-block code */
|
||||
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
|
||||
|
||||
/* huft_free code moved into inflate_codes */
|
||||
|
||||
return -2;
|
||||
}
|
||||
case 2: /* Inflate dynamic */
|
||||
{
|
||||
const int dbits = 6; /* bits in base distance lookup table */
|
||||
const int lbits = 9; /* bits in base literal/length lookup table */
|
||||
|
||||
huft_t *tl; /* literal/length code table */
|
||||
huft_t *td; /* distance code table */
|
||||
unsigned int i; /* temporary variables */
|
||||
unsigned int j;
|
||||
unsigned int l; /* last length */
|
||||
unsigned int m; /* mask for bit lengths table */
|
||||
unsigned int n; /* number of lengths to get */
|
||||
unsigned int bl; /* lookup bits for tl */
|
||||
unsigned int bd; /* lookup bits for td */
|
||||
unsigned int nb; /* number of bit length codes */
|
||||
unsigned int nl; /* number of literal/length codes */
|
||||
unsigned int nd; /* number of distance codes */
|
||||
|
||||
unsigned int ll[286 + 30]; /* literal/length and distance code lengths */
|
||||
unsigned int b_dynamic; /* bit buffer */
|
||||
unsigned int k_dynamic; /* number of bits in bit buffer */
|
||||
|
||||
/* make local bit buffer */
|
||||
b_dynamic = gunzip_bb;
|
||||
k_dynamic = gunzip_bk;
|
||||
|
||||
/* read in table lengths */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5);
|
||||
nl = 257 + ((unsigned int) b_dynamic & 0x1f); /* number of literal/length codes */
|
||||
|
||||
b_dynamic >>= 5;
|
||||
k_dynamic -= 5;
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5);
|
||||
nd = 1 + ((unsigned int) b_dynamic & 0x1f); /* number of distance codes */
|
||||
|
||||
b_dynamic >>= 5;
|
||||
k_dynamic -= 5;
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 4);
|
||||
nb = 4 + ((unsigned int) b_dynamic & 0xf); /* number of bit length codes */
|
||||
|
||||
b_dynamic >>= 4;
|
||||
k_dynamic -= 4;
|
||||
if (nl > 286 || nd > 30) {
|
||||
return 1; /* bad lengths */
|
||||
}
|
||||
|
||||
/* read in bit-length-code lengths */
|
||||
for (j = 0; j < nb; j++) {
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3);
|
||||
ll[border[j]] = (unsigned int) b_dynamic & 7;
|
||||
b_dynamic >>= 3;
|
||||
k_dynamic -= 3;
|
||||
}
|
||||
for (; j < 19; j++) {
|
||||
ll[border[j]] = 0;
|
||||
}
|
||||
|
||||
/* build decoding table for trees--single level, 7 bit lookup */
|
||||
bl = 7;
|
||||
i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl);
|
||||
if (i != 0) {
|
||||
if (i == 1) {
|
||||
huft_free(tl);
|
||||
}
|
||||
return i; /* incomplete code set */
|
||||
}
|
||||
|
||||
/* read in literal and distance code lengths */
|
||||
n = nl + nd;
|
||||
m = mask_bits[bl];
|
||||
i = l = 0;
|
||||
while ((unsigned int) i < n) {
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, (unsigned int)bl);
|
||||
j = (td = tl + ((unsigned int) b_dynamic & m))->b;
|
||||
b_dynamic >>= j;
|
||||
k_dynamic -= j;
|
||||
j = td->v.n;
|
||||
if (j < 16) { /* length of code in bits (0..15) */
|
||||
ll[i++] = l = j; /* save last length in l */
|
||||
} else if (j == 16) { /* repeat last length 3 to 6 times */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 2);
|
||||
j = 3 + ((unsigned int) b_dynamic & 3);
|
||||
b_dynamic >>= 2;
|
||||
k_dynamic -= 2;
|
||||
if ((unsigned int) i + j > n) {
|
||||
return 1;
|
||||
}
|
||||
while (j--) {
|
||||
ll[i++] = l;
|
||||
}
|
||||
} else if (j == 17) { /* 3 to 10 zero length codes */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3);
|
||||
j = 3 + ((unsigned int) b_dynamic & 7);
|
||||
b_dynamic >>= 3;
|
||||
k_dynamic -= 3;
|
||||
if ((unsigned int) i + j > n) {
|
||||
return 1;
|
||||
}
|
||||
while (j--) {
|
||||
ll[i++] = 0;
|
||||
}
|
||||
l = 0;
|
||||
} else { /* j == 18: 11 to 138 zero length codes */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 7);
|
||||
j = 11 + ((unsigned int) b_dynamic & 0x7f);
|
||||
b_dynamic >>= 7;
|
||||
k_dynamic -= 7;
|
||||
if ((unsigned int) i + j > n) {
|
||||
return 1;
|
||||
}
|
||||
while (j--) {
|
||||
ll[i++] = 0;
|
||||
}
|
||||
l = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* free decoding table for trees */
|
||||
huft_free(tl);
|
||||
|
||||
/* restore the global bit buffer */
|
||||
gunzip_bb = b_dynamic;
|
||||
gunzip_bk = k_dynamic;
|
||||
|
||||
/* build the decoding tables for literal/length and distance codes */
|
||||
bl = lbits;
|
||||
|
||||
if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) {
|
||||
if (i == 1) {
|
||||
bb_error_msg_and_die("Incomplete literal tree");
|
||||
huft_free(tl);
|
||||
}
|
||||
return i; /* incomplete code set */
|
||||
}
|
||||
|
||||
bd = dbits;
|
||||
if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) {
|
||||
if (i == 1) {
|
||||
bb_error_msg_and_die("incomplete distance tree");
|
||||
huft_free(td);
|
||||
}
|
||||
huft_free(tl);
|
||||
return i; /* incomplete code set */
|
||||
}
|
||||
|
||||
/* decompress until an end-of-block code */
|
||||
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
|
||||
|
||||
/* huft_free code moved into inflate_codes */
|
||||
|
||||
return -2;
|
||||
}
|
||||
default:
|
||||
/* bad block type */
|
||||
bb_error_msg_and_die("bad block type %d\n", t);
|
||||
}
|
||||
}
|
||||
|
||||
static void calculate_gunzip_crc(void)
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < gunzip_outbuf_count; n++) {
|
||||
gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
|
||||
}
|
||||
gunzip_bytes_out += gunzip_outbuf_count;
|
||||
}
|
||||
|
||||
static int inflate_get_next_window(void)
|
||||
{
|
||||
static int method = -1; // Method == -1 for stored, -2 for codes
|
||||
static int e = 0;
|
||||
static int needAnotherBlock = 1;
|
||||
|
||||
gunzip_outbuf_count = 0;
|
||||
|
||||
while(1) {
|
||||
int ret;
|
||||
|
||||
if (needAnotherBlock) {
|
||||
if(e) {
|
||||
calculate_gunzip_crc();
|
||||
e = 0;
|
||||
needAnotherBlock = 1;
|
||||
return 0;
|
||||
} // Last block
|
||||
method = inflate_block(&e);
|
||||
needAnotherBlock = 0;
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
case -1: ret = inflate_stored(0,0,0,0);
|
||||
break;
|
||||
case -2: ret = inflate_codes(0,0,0,0,0);
|
||||
break;
|
||||
default: bb_error_msg_and_die("inflate error %d", method);
|
||||
}
|
||||
|
||||
if (ret == 1) {
|
||||
calculate_gunzip_crc();
|
||||
return 1; // More data left
|
||||
} else needAnotherBlock = 1; // End of that block
|
||||
}
|
||||
/* Doesnt get here */
|
||||
}
|
||||
|
||||
/* Initialise bytebuffer, be carefull not to overfill the buffer */
|
||||
extern void inflate_init(unsigned int bufsize)
|
||||
{
|
||||
/* Set the bytebuffer size, default is same as gunzip_wsize */
|
||||
bytebuffer_max = bufsize + 8;
|
||||
bytebuffer_offset = 4;
|
||||
bytebuffer_size = 0;
|
||||
}
|
||||
|
||||
extern int inflate_unzip(int in, int out)
|
||||
{
|
||||
ssize_t nwrote;
|
||||
typedef void (*sig_type) (int);
|
||||
|
||||
/* Allocate all global buffers (for DYN_ALLOC option) */
|
||||
gunzip_window = xmalloc(gunzip_wsize);
|
||||
gunzip_outbuf_count = 0;
|
||||
gunzip_bytes_out = 0;
|
||||
gunzip_src_fd = in;
|
||||
|
||||
/* initialize gunzip_window, bit buffer */
|
||||
gunzip_bk = 0;
|
||||
gunzip_bb = 0;
|
||||
|
||||
/* Create the crc table */
|
||||
make_gunzip_crc_table();
|
||||
|
||||
/* Allocate space for buffer */
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
|
||||
while(1) {
|
||||
int ret = inflate_get_next_window();
|
||||
nwrote = bb_full_write(out, gunzip_window, gunzip_outbuf_count);
|
||||
if (nwrote == -1) {
|
||||
bb_perror_msg("write");
|
||||
return -1;
|
||||
}
|
||||
if (ret == 0) break;
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
free(gunzip_window);
|
||||
free(gunzip_crc_table);
|
||||
|
||||
/* Store unused bytes in a global buffer so calling applets can access it */
|
||||
if (gunzip_bk >= 8) {
|
||||
/* Undo too much lookahead. The next read will be byte aligned
|
||||
* so we can discard unused bits in the last meaningful byte. */
|
||||
bytebuffer_offset--;
|
||||
bytebuffer[bytebuffer_offset] = gunzip_bb & 0xff;
|
||||
gunzip_bb >>= 8;
|
||||
gunzip_bk -= 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int inflate_gunzip(int in, int out)
|
||||
{
|
||||
unsigned int stored_crc = 0;
|
||||
unsigned char count;
|
||||
|
||||
inflate_unzip(in, out);
|
||||
|
||||
/* top up the input buffer with the rest of the trailer */
|
||||
count = bytebuffer_size - bytebuffer_offset;
|
||||
if (count < 8) {
|
||||
bb_xread_all(in, &bytebuffer[bytebuffer_size], 8 - count);
|
||||
bytebuffer_size += 8 - count;
|
||||
}
|
||||
for (count = 0; count != 4; count++) {
|
||||
stored_crc |= (bytebuffer[bytebuffer_offset] << (count * 8));
|
||||
bytebuffer_offset++;
|
||||
}
|
||||
|
||||
/* Validate decompression - crc */
|
||||
if (stored_crc != (gunzip_crc ^ 0xffffffffL)) {
|
||||
bb_error_msg("crc error");
|
||||
}
|
||||
|
||||
/* Validate decompression - size */
|
||||
if (gunzip_bytes_out !=
|
||||
(bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) |
|
||||
(bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
|
||||
bb_error_msg("Incorrect length");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
File renamed without changes.
+30
-14
@@ -2,18 +2,20 @@ List of the authors of code contained in BusyBox.
|
||||
|
||||
If you have code in BusyBox, you should be listed here. If you should be
|
||||
listed, or the description of what you have done needs more detail, or is
|
||||
incorect, _please_ let me know.
|
||||
incorrect, _please_ let me know.
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
Emanuele Aina <emanuele.aina@tiscali.it>
|
||||
run-parts
|
||||
run-parts
|
||||
|
||||
Erik Andersen <andersen@codepoet.org>
|
||||
Tons of new stuff, major rewrite of most of the
|
||||
core apps, tons of new apps as noted in header files.
|
||||
Lots of tedious effort writing these boring docs that
|
||||
nobody is going to actually read.
|
||||
|
||||
Laurence Anderson <l.d.anderson@warwick.ac.uk>
|
||||
rpm2cpio, unzip, get_header_cpio, read_gz interface, rpm
|
||||
@@ -21,9 +23,12 @@ Laurence Anderson <l.d.anderson@warwick.ac.uk>
|
||||
Jeff Angielski <jeff@theptrgroup.com>
|
||||
ftpput, ftpget
|
||||
|
||||
Jim Bauer <jfbauer@nfr.com>
|
||||
modprobe shell dependency
|
||||
|
||||
Edward Betts <edward@debian.org>
|
||||
expr, hostid, logname, whoami
|
||||
|
||||
|
||||
John Beppu <beppu@codepoet.org>
|
||||
du, nslookup, sort
|
||||
|
||||
@@ -33,12 +38,12 @@ Brian Candler <B.Candler@pobox.com>
|
||||
Randolph Chung <tausq@debian.org>
|
||||
fbset, ping, hostname
|
||||
|
||||
Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
|
||||
Jordan Crouse <jordan@cosmicpenguin.net>
|
||||
ipcalc
|
||||
ipcalc
|
||||
|
||||
Magnus Damm <damm@opensource.se>
|
||||
tftp client
|
||||
@@ -54,6 +59,10 @@ Gennady Feldman <gfeldman@gena01.com>
|
||||
Sysklogd (single threaded syslogd, IPC Circular buffer support,
|
||||
logread), various fixes.
|
||||
|
||||
Robert Griebl <sandman@handhelds.org>
|
||||
modprobe, hwclock, suid/sgid handling, tinylogin integration
|
||||
many bugfixes and enhancements
|
||||
|
||||
Karl M. Hegbloom <karlheg@debian.org>
|
||||
cp_mv.c, the test suite, various fixes to utility.c, &c.
|
||||
|
||||
@@ -63,14 +72,21 @@ Daniel Jacobowitz <dan@debian.org>
|
||||
Matt Kraai <kraai@alumni.cmu.edu>
|
||||
documentation, bugfixes, test suite
|
||||
|
||||
Stephan Linz <linz@li-pro.net>
|
||||
ipcalc, Red Hat equivalence
|
||||
Rob Landley <rob@landley.net>
|
||||
sed (major rewrite in 2003, and I now maintain the thing).
|
||||
bunzip2 (complete from-scratch rewrite, then mjn3 optimized the result.)
|
||||
I've patched lots of other applets, but don't maintain 'em.
|
||||
|
||||
John Lombardo <john@deltanet.com>
|
||||
Stephan Linz <linz@li-pro.net>
|
||||
ipcalc, Red Hat equivalence
|
||||
|
||||
John Lombardo <john@deltanet.com>
|
||||
tr
|
||||
|
||||
Glenn McGrath <bug1@optushome.com.au>
|
||||
ar, dpkg, dpkg-deb
|
||||
Glenn McGrath <bug1@iinet.net.au>
|
||||
Common unarchiving code and unarchiving applets, ifupdown, ftpgetput,
|
||||
nameif, sed, patch, fold, install, uudecode.
|
||||
Various bugfixes, review and apply numerous patches.
|
||||
|
||||
Manuel Novoa III <mjn3@codepoet.org>
|
||||
cat, head, mkfifo, mknod, rmdir, sleep, tee, tty, uniq, usleep, wc, yes,
|
||||
@@ -80,7 +96,7 @@ Manuel Novoa III <mjn3@codepoet.org>
|
||||
also bug fixes, partial rewrites, and size optimizations in
|
||||
ash, basename, cal, cmp, cp, df, du, echo, env, ln, logname, md5sum, mkdir,
|
||||
mv, realpath, rm, sort, tail, touch, uname, watch, arith, human_readable,
|
||||
interface, dutmp, ifconfig
|
||||
interface, dutmp, ifconfig, route
|
||||
|
||||
Vladimir Oleynik <dzo@simtreas.ru>
|
||||
cmdedit; xargs(current), httpd(current);
|
||||
@@ -89,7 +105,7 @@ Vladimir Oleynik <dzo@simtreas.ru>
|
||||
and irreconcilable critic of everything not perfect.
|
||||
|
||||
Bruce Perens <bruce@pixar.com>
|
||||
Original author of BusyBox in 1995, 1996. Some of his code can
|
||||
Original author of BusyBox in 1995, 1996. Some of his code can
|
||||
still be found hiding here and there...
|
||||
|
||||
Tim Riker <Tim@Rikers.org>
|
||||
@@ -121,5 +137,5 @@ Enrique Zanardi <ezanardi@ull.es>
|
||||
tarcat (since removed), loadkmap, various fixes, Debian maintenance
|
||||
|
||||
Tito Ragusa <farmatito@tiscali.it>
|
||||
devfsd and size optimizations in strings, openvt and deallocvt.
|
||||
devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm and fdformat.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
1) Run 'make config' or 'make menuconfig' and select the
|
||||
1) Run 'make config' or 'make menuconfig' and select the
|
||||
functionality that you wish to enable.
|
||||
|
||||
2) Run 'make dep'
|
||||
|
||||
3) Check the Makefile for any Makefile setting you wish
|
||||
to adjust for your system (things like like setting
|
||||
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) Run 'make'
|
||||
File renamed without changes.
@@ -0,0 +1,314 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# You shouldn't need to mess with anything beyond this point...
|
||||
#--------------------------------------------------------------
|
||||
noconfig_targets := menuconfig config oldconfig randconfig \
|
||||
defconfig allyesconfig allnoconfig clean distclean \
|
||||
release tags
|
||||
|
||||
ifndef TOPDIR
|
||||
TOPDIR=$(CURDIR)/
|
||||
endif
|
||||
ifndef top_srcdir
|
||||
top_srcdir=$(CURDIR)
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=$(CURDIR)
|
||||
endif
|
||||
|
||||
export srctree=$(top_srcdir)
|
||||
vpath %/Config.in $(srctree)
|
||||
|
||||
include $(top_builddir)/Rules.mak
|
||||
|
||||
DIRS:=applets archival archival/libunarchive coreutils console-tools \
|
||||
debianutils editors findutils init miscutils modutils networking \
|
||||
networking/libiproute networking/udhcp procps loginutils shell \
|
||||
sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb
|
||||
|
||||
SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
|
||||
|
||||
ifeq ($(strip $(CONFIG_SELINUX)),y)
|
||||
CFLAGS += -I/usr/include/selinux
|
||||
LIBRARIES += -lsecure
|
||||
endif
|
||||
|
||||
CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in
|
||||
CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig
|
||||
|
||||
ALL_DIRS:= $(DIRS) scripts/config
|
||||
ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS))
|
||||
|
||||
ifeq ($(KBUILD_SRC),)
|
||||
|
||||
ifdef O
|
||||
ifeq ("$(origin O)", "command line")
|
||||
KBUILD_OUTPUT := $(O)
|
||||
endif
|
||||
endif
|
||||
|
||||
# That's our default target when none is given on the command line
|
||||
.PHONY: _all
|
||||
_all:
|
||||
|
||||
ifneq ($(KBUILD_OUTPUT),)
|
||||
# Invoke a second make in the output directory, passing relevant variables
|
||||
# check that the output directory actually exists
|
||||
saved-output := $(KBUILD_OUTPUT)
|
||||
KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
|
||||
$(if $(wildcard $(KBUILD_OUTPUT)),, \
|
||||
$(error output directory "$(saved-output)" does not exist))
|
||||
|
||||
.PHONY: $(MAKECMDGOALS)
|
||||
|
||||
$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile
|
||||
$(MAKE) -C $(KBUILD_OUTPUT) \
|
||||
top_srcdir=$(CURDIR) \
|
||||
top_builddir=$(KBUILD_OUTPUT) \
|
||||
TOPDIR=$(KBUILD_OUTPUT) \
|
||||
KBUILD_SRC=$(CURDIR) \
|
||||
-f $(CURDIR)/Makefile $@
|
||||
|
||||
$(KBUILD_OUTPUT)/Rules.mak:
|
||||
@echo > $@
|
||||
@echo top_srcdir=$(CURDIR) >> $@
|
||||
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
|
||||
@echo include $(top_srcdir)/Rules.mak >> $@
|
||||
|
||||
$(KBUILD_OUTPUT)/Makefile:
|
||||
@echo > $@
|
||||
@echo top_srcdir=$(CURDIR) >> $@
|
||||
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
|
||||
@echo KBUILD_SRC='$$(top_srcdir)' >> $@
|
||||
@echo include '$$(KBUILD_SRC)'/Makefile >> $@
|
||||
|
||||
# Leave processing to above invocation of make
|
||||
skip-makefile := 1
|
||||
endif # ifneq ($(KBUILD_OUTPUT),)
|
||||
endif # ifeq ($(KBUILD_SRC),)
|
||||
|
||||
ifeq ($(skip-makefile),)
|
||||
|
||||
_all: all
|
||||
|
||||
ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
all: busybox busybox.links doc
|
||||
|
||||
all_tree: $(ALL_MAKEFILES)
|
||||
|
||||
$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
|
||||
d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
|
||||
|
||||
# In this section, we need .config
|
||||
-include $(top_builddir)/.config.cmd
|
||||
include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
|
||||
$(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
|
||||
$(STRIPCMD) $@
|
||||
|
||||
busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
install: applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
|
||||
@echo
|
||||
@echo
|
||||
@echo --------------------------------------------------
|
||||
@echo You will probably need to make your busybox binary
|
||||
@echo setuid root to ensure all configured applets will
|
||||
@echo work properly.
|
||||
@echo --------------------------------------------------
|
||||
@echo
|
||||
endif
|
||||
|
||||
uninstall: busybox.links
|
||||
rm -f $(PREFIX)/bin/busybox
|
||||
for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
|
||||
|
||||
install-hardlinks: $(top_srcdir)/applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
check: busybox
|
||||
bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
|
||||
$(top_srcdir)/testsuite/runtest
|
||||
|
||||
# Documentation Targets
|
||||
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod
|
||||
-mkdir -p docs
|
||||
- ( cat $(top_srcdir)/docs/busybox_header.pod; \
|
||||
$(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h; \
|
||||
cat $(top_srcdir)/docs/busybox_footer.pod ) > docs/busybox.pod
|
||||
|
||||
docs/BusyBox.txt: docs/busybox.pod
|
||||
$(SECHO)
|
||||
$(SECHO) BusyBox Documentation
|
||||
$(SECHO)
|
||||
-mkdir -p docs
|
||||
-pod2text $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.net/BusyBox.html
|
||||
- mkdir -p docs
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ cp docs/busybox.net/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.net/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.net
|
||||
- pod2html --noindex $< > \
|
||||
docs/busybox.net/BusyBox.html
|
||||
-@ rm -f pod2htm*
|
||||
|
||||
# The nifty new buildsystem stuff
|
||||
scripts/mkdep: $(top_srcdir)/scripts/mkdep.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
|
||||
|
||||
scripts/split-include: $(top_srcdir)/scripts/split-include.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
|
||||
|
||||
.depend: scripts/mkdep include/config.h
|
||||
rm -f .depend .hdepend;
|
||||
mkdir -p include/config;
|
||||
scripts/mkdep -I include -- \
|
||||
`find $(top_srcdir) -name \*.c -print | sed -e "s,^./,,"` >> .depend;
|
||||
scripts/mkdep -I include -- \
|
||||
`find $(top_srcdir) -name \*.h -print | sed -e "s,^./,,"` >> .hdepend;
|
||||
|
||||
depend dep: .depend
|
||||
|
||||
include/config/MARKER: depend scripts/split-include
|
||||
scripts/split-include include/config.h include/config
|
||||
@ touch include/config/MARKER
|
||||
|
||||
include/config.h: .config
|
||||
@if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
|
||||
$(MAKE) -C scripts/config conf; \
|
||||
fi;
|
||||
@$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
finished2:
|
||||
$(SECHO)
|
||||
$(SECHO) Finished installing...
|
||||
$(SECHO)
|
||||
|
||||
else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
all: menuconfig
|
||||
|
||||
# configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
|
||||
d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
|
||||
|
||||
scripts/config/conf: scripts/config/Makefile Rules.mak
|
||||
$(MAKE) -C scripts/config conf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp $(CONFIG_DEFCONFIG) .config; \
|
||||
fi
|
||||
|
||||
scripts/config/mconf: scripts/config/Makefile Rules.mak
|
||||
$(MAKE) -C scripts/config ncurses conf mconf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp $(CONFIG_DEFCONFIG) .config; \
|
||||
fi
|
||||
|
||||
menuconfig: scripts/config/mconf
|
||||
@./scripts/config/mconf $(CONFIG_CONFIG_IN)
|
||||
|
||||
config: scripts/config/conf
|
||||
@./scripts/config/conf $(CONFIG_CONFIG_IN)
|
||||
|
||||
oldconfig: scripts/config/conf
|
||||
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
randconfig: scripts/config/conf
|
||||
@./scripts/config/conf -r $(CONFIG_CONFIG_IN)
|
||||
|
||||
allyesconfig: scripts/config/conf
|
||||
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
|
||||
sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
|
||||
sed -i -e "s/^USING_CROSS_COMPILER.*/# USING_CROSS_COMPILER is not set/" .config
|
||||
sed -i -e "s/^CONFIG_STATIC.*/# CONFIG_STATIC is not set/" .config
|
||||
sed -i -e "s/^CONFIG_SELINUX.*/# CONFIG_SELINUX is not set/" .config
|
||||
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
allnoconfig: scripts/config/conf
|
||||
@./scripts/config/conf -n $(CONFIG_CONFIG_IN)
|
||||
|
||||
defconfig: scripts/config/conf
|
||||
@./scripts/config/conf -d $(CONFIG_CONFIG_IN)
|
||||
|
||||
clean:
|
||||
- rm -f docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pod docs/busybox.net/busybox.html \
|
||||
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
|
||||
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
|
||||
.config.old .hdepend busybox
|
||||
- rm -rf _install
|
||||
- find . -name .\*.flags -exec rm -f {} \;
|
||||
- find . -name \*.o -exec rm -f {} \;
|
||||
- find . -name \*.a -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f scripts/split-include scripts/mkdep
|
||||
- rm -rf include/config include/config.h
|
||||
- find . -name .depend -exec rm -f {} \;
|
||||
rm -f .config .config.old .config.cmd
|
||||
- $(MAKE) -C scripts/config clean
|
||||
|
||||
release: distclean #doc
|
||||
cd ..; \
|
||||
rm -rf $(PROG)-$(VERSION); \
|
||||
cp -a busybox $(PROG)-$(VERSION); \
|
||||
\
|
||||
find $(PROG)-$(VERSION)/ -type d \
|
||||
-name .svn \
|
||||
-print \
|
||||
-exec rm -rf {} \; ; \
|
||||
\
|
||||
find $(PROG)-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
|
||||
|
||||
tags:
|
||||
ctags -R .
|
||||
|
||||
|
||||
endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
endif # ifeq ($(skip-makefile),)
|
||||
|
||||
.PHONY: dummy subdirs release distclean clean config oldconfig \
|
||||
menuconfig tags check test depend buildtree
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
Please see the LICENSE file for details on copying and usage.
|
||||
|
||||
What is busybox:
|
||||
|
||||
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 bzip2, coreutils, file, findutils, gawk, grep,
|
||||
inetutils, modutils, net-tools, procps, sed, shadow, sysklogd, sysvinit, tar,
|
||||
util-linux, and vim. The utilities in BusyBox often have fewer options than
|
||||
their full-featured cousins; however, the options that are included provide
|
||||
the expected functionality and behave very much like their larger
|
||||
counterparts.
|
||||
|
||||
BusyBox has been written with size-optimization and limited resources in
|
||||
mind, both to produce small binaries and to reduce run-time memory usage.
|
||||
Busybox is also extremely modular so you can easily include or exclude
|
||||
commands (or features) at compile time. This makes it easy to customize
|
||||
embedded systems; to create a working system, just add /dev, /etc, and a
|
||||
Linux kernel. Busybox (usually together with uClibc) has also been used as
|
||||
a component of "thin client" desktop systems, live-CD distributions, rescue
|
||||
disks, installers, and so on.
|
||||
|
||||
BusyBox provides a fairly complete POSIX environment for any small system,
|
||||
both embedded environments and more full featured systems concerned about
|
||||
space. Busybox is slowly working towards implementing the full Single Unix
|
||||
Specification V3 (http://www.opengroup.org/onlinepubs/009695399/), but isn't
|
||||
there yet (and for size reasons will probably support at most UTF-8 for
|
||||
internationalization). We are also interested in passing the Linux Test
|
||||
Project (http://ltp.sourceforge.net).
|
||||
|
||||
----------------
|
||||
|
||||
Using busybox:
|
||||
|
||||
BusyBox is extremely configurable. This allows you to include only the
|
||||
components and options you need, thereby reducing binary size. Run 'make
|
||||
config' or 'make menuconfig' to select the functionality that you wish to
|
||||
enable.
|
||||
|
||||
The behavior of busybox is determined by the name it's called under: as
|
||||
"cp" it behaves like cp, as "sed" it behaves like sed, and so on. Called
|
||||
as "busybox" it takes the second argument as the name of the applet to
|
||||
run (I.E. "./busybox ls -l /proc").
|
||||
|
||||
The "standalone shell" mode is an easy way to try out busybox; this is a
|
||||
command shell that calls the builtin applets without needing them to be
|
||||
installed in the path. (Note that this requires /proc to be mounted, if
|
||||
testing from a boot floppy or in a chroot environment.)
|
||||
|
||||
The build automatically generates a file "busybox.links", which is used by
|
||||
'make install' to create symlinks to the BusyBox binary for all compiled in
|
||||
commands. Use the PREFIX environment variable to specify where to install
|
||||
the busybox binary and symlink forest. (i.e., 'make PREFIX=/tmp/foo install',
|
||||
or 'make PREFIX=/tmp/foo install-hardlinks' if you prefer hard links.)
|
||||
|
||||
----------------
|
||||
|
||||
Downloading the current source code:
|
||||
|
||||
Source for the latest released version, as well as daily snapshots, can always
|
||||
be downloaded from
|
||||
|
||||
http://busybox.net/downloads/
|
||||
|
||||
You can browse the up to the minute source code and change history online
|
||||
at:
|
||||
|
||||
http://www.busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_00_stable/busybox/
|
||||
|
||||
Anonymous SVN access is available. For instructions, check out:
|
||||
|
||||
http://busybox.net/subversion.html
|
||||
|
||||
For those that are actively contributing and would like to check files in,
|
||||
see:
|
||||
|
||||
http://busybox.net/developer.html
|
||||
|
||||
The developers also have a bug and patch tracking system
|
||||
(http://bugs.busybox.net) although posting a bug/patch to the mailing list
|
||||
is generally a faster way of getting it fixed, and the complete archive of
|
||||
what happened is the subversion changelog.
|
||||
|
||||
----------------
|
||||
|
||||
getting help:
|
||||
|
||||
when you find you need help, you can check out the busybox mailing list
|
||||
archives at http://busybox.net/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
|
||||
bugs:
|
||||
|
||||
if you find bugs, please submit a detailed bug report to the busybox mailing
|
||||
list at busybox@busybox.net. a well-written bug report should include a
|
||||
transcript of a shell session that demonstrates the bad behavior and enables
|
||||
anyone else to duplicate the bug on their own machine. the following is such
|
||||
an example:
|
||||
|
||||
to: busybox@mail.busybox.net
|
||||
from: diligent@testing.linux.org
|
||||
subject: /bin/date doesn't work
|
||||
|
||||
package: busybox
|
||||
version: 1.00
|
||||
|
||||
when i execute busybox 'date' it produces unexpected results.
|
||||
with gnu date i get the following output:
|
||||
|
||||
$ date
|
||||
fri oct 8 14:19:41 mdt 2004
|
||||
|
||||
but when i use busybox date i get this instead:
|
||||
|
||||
$ date
|
||||
illegal instruction
|
||||
|
||||
i am using debian unstable, kernel version 2.4.25-vrs2 on a netwinder,
|
||||
and the latest uclibc from cvs. thanks for the wonderful program!
|
||||
|
||||
-diligent
|
||||
|
||||
note the careful description and use of examples showing not only what
|
||||
busybox does, but also a counter example showing what an equivalent app
|
||||
does (or pointing to the text of a relevant standard). Bug reports lacking
|
||||
such detail may never be fixed... Thanks for understanding.
|
||||
|
||||
----------------
|
||||
|
||||
Portability:
|
||||
|
||||
Busybox is developed and tested on Linux 2.4 and 2.6 kernels, linked
|
||||
against uClibc (0.9.27 or greater) and glibc (2.2 or greater). In such
|
||||
an environment, the full set of busybox features should work (and if
|
||||
anything doesn't we want to know about it so we can fix it). Note that
|
||||
the 2.6 kernel can be trimmed down considerably with the aid of Matt
|
||||
Mackall's -tiny work (http://www.selenic.com/tiny-about/).
|
||||
|
||||
Since busybox consists of a large number of more or less independent
|
||||
applets, portability is a question of which features work where. Some
|
||||
busybox applets (such as cat and rm) are highly portable and likely to work
|
||||
just about anywhere, while others (such as insmod and losetup) are only
|
||||
likely to work under fairly recent Linux kernels with recent C libraries.
|
||||
|
||||
Earlier versions of Linux and glibc may or may not work, for any given
|
||||
configuration. Linux 2.2 or earlier should mostly work, but this is no
|
||||
longer regularly tested and inherently won't support certain features (such
|
||||
as long files and --bind mounts). The same is true for glibc 2.0 and 2.1,
|
||||
expect a higher testing and debugging burden using such old infrastructure.
|
||||
(The busybox developers are not very interested in supporting these older
|
||||
versions, but can probably be talked into accepting small patches to fix
|
||||
simple problems.)
|
||||
|
||||
Some environments are not recommended. Early versions of uClibc were buggy
|
||||
and missing many features: upgrade. Linking against libc5 or dietlibc is
|
||||
not supported and not interesting to the busybox developers. (The first is
|
||||
obsolete and has no known size or feature advantages over uClibc, the second
|
||||
has known bugs that its developers have actively refused to fix.) Ancient
|
||||
Linux kernels (2.0.x and earlier) are similarly uninteresting.
|
||||
|
||||
In theory it's possible to use Busybox under other operating systems (such as
|
||||
MacOS X, Solaris, Cygwin, or the BSD Fork Du Jour). This generally involves
|
||||
a different kernel and a different C library at the same time. While it
|
||||
should be possible to port the majority of the code to work in one of
|
||||
these environments, don't be suprised if it doesn't work out of the box. If
|
||||
you're into that sort of thing, start small (selecting just a few applets)
|
||||
and work your way up.
|
||||
|
||||
Shaun Jackman has recently (2005) ported busybox to a combination of newlib
|
||||
and libgloss, and some of his patches have been integrated. This platform
|
||||
may join glibc/uclibc and Linux as a supported combination with the 1.1
|
||||
release, but is not supported in 1.0.
|
||||
|
||||
Supported hardware:
|
||||
|
||||
BusyBox in general will build on any architecture supported by gcc. We
|
||||
support both 32 and 64 bit platforms, and both big and little endian
|
||||
systems.
|
||||
|
||||
Under 2.4 Linux kernels, kernel module loading was implemented in a
|
||||
platform-specific manner. Busybox's insmod utility has been reported to
|
||||
work under ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC, S390,
|
||||
SH3/4/5, Sparc, v850e, and x86_64. Anything else probably won't work.
|
||||
|
||||
The module loading mechanism for the 2.6 kernel is much more generic, and
|
||||
we believe 2.6.x kernel module loading support should work on all
|
||||
architectures supported by the kernel.
|
||||
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to the busybox
|
||||
maintainer:
|
||||
Erik Andersen
|
||||
<andersen@codepoet.org>
|
||||
@@ -1,6 +1,6 @@
|
||||
# Rules.make for busybox
|
||||
#
|
||||
# Copyright (C) 2001-2003 Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#--------------------------------------------------------
|
||||
PROG := busybox
|
||||
VERSION := 1.00-pre8
|
||||
VERSION := 1.01
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ LD = $(CROSS)ld
|
||||
NM = $(CROSS)nm
|
||||
STRIP = $(CROSS)strip
|
||||
CPP = $(CC) -E
|
||||
MAKEFILES = $(TOPDIR).config
|
||||
# MAKEFILES = $(top_builddir)/.config
|
||||
|
||||
# What OS are you compiling busybox for? This allows you to include
|
||||
# OS specific things, syscall overrides, etc.
|
||||
@@ -52,14 +52,14 @@ TARGET_OS=linux
|
||||
HOSTCC = gcc
|
||||
HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
|
||||
|
||||
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
||||
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
||||
LC_ALL:= C
|
||||
|
||||
# If you want to add some simple compiler switches (like -march=i686),
|
||||
# especially from the command line, use this instead of CFLAGS directly.
|
||||
# For optimization overrides, it's better still to set OPTIMIZATION.
|
||||
CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
|
||||
|
||||
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@busybox.net> if you do or don't like it so far.
|
||||
@@ -80,13 +80,13 @@ BB_SRC_DIR=
|
||||
#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
|
||||
CFLAGS=-I$(TOPDIR)include
|
||||
ARFLAGS=-r
|
||||
CFLAGS=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)
|
||||
ARFLAGS=cru
|
||||
|
||||
#--------------------------------------------------------
|
||||
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
|
||||
ifeq ($(strip $(TARGET_ARCH)),)
|
||||
TARGET_ARCH=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
|
||||
TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
|
||||
-e 's/i.86/i386/' \
|
||||
-e 's/sparc.*/sparc/' \
|
||||
-e 's/arm.*/arm/g' \
|
||||
@@ -102,21 +102,29 @@ endif
|
||||
|
||||
# Pull in the user's busybox configuration
|
||||
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
||||
-include $(TOPDIR).config
|
||||
-include $(top_builddir)/.config
|
||||
endif
|
||||
|
||||
# A nifty macro to make testing gcc features easier
|
||||
check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
|
||||
then echo "$(1)"; else echo "$(2)"; fi)
|
||||
|
||||
# Setup some shortcuts so that silent mode is silent like it should be
|
||||
ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
|
||||
export MAKE_IS_SILENT=n
|
||||
SECHO=@echo
|
||||
else
|
||||
export MAKE_IS_SILENT=y
|
||||
SECHO=-@false
|
||||
endif
|
||||
|
||||
#--------------------------------------------------------
|
||||
# Arch specific compiler optimization stuff should go here.
|
||||
# Unless you want to override the defaults, do not set anything
|
||||
# for OPTIMIZATION...
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION=
|
||||
OPTIMIZATION=${call check_gcc,-Os,-O2}
|
||||
OPTIMIZATION:=${call check_gcc,-Os,-O2}
|
||||
|
||||
# Some nice architecture specific optimizations
|
||||
ifeq ($(strip $(TARGET_ARCH)),arm)
|
||||
@@ -137,7 +145,7 @@ OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer
|
||||
# by itself, instead of following it by the same half-dozen overrides
|
||||
# every time. The stuff below, on the other hand, is probably less
|
||||
# prone to casual user adjustment.
|
||||
#
|
||||
#
|
||||
|
||||
ifeq ($(strip $(CONFIG_LFS)),y)
|
||||
# For large file summit support
|
||||
@@ -158,8 +166,8 @@ ifeq ($(strip $(CONFIG_DEBUG)),y)
|
||||
STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
|
||||
else
|
||||
CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIPCMD:=$(STRIP) --remove-section=.note --remove-section=.comment
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_STATIC)),y)
|
||||
LDFLAGS += --static
|
||||
@@ -189,23 +197,4 @@ endif
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
ifdef _FASTDEP_ALL_SUB_DIRS
|
||||
fastdep: dummy
|
||||
$(TOPDIR)scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -- $(wildcard *.[chS]) > .depend
|
||||
ifdef ALL_SUB_DIRS
|
||||
$(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
|
||||
endif
|
||||
|
||||
$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
|
||||
$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
|
||||
endif
|
||||
|
||||
.PHONY: dummy
|
||||
|
||||
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
Busybox TODO
|
||||
|
||||
Stuff that needs to be done
|
||||
|
||||
----
|
||||
tr - missing SuS3 features in busybox 1.0pre10
|
||||
|
||||
tr doesnt support [:blank:], [:digit:] or other predefined classes, [=equiv=]
|
||||
support is also missing.
|
||||
----
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -17,13 +17,15 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR:= ../
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
srcdir=$(top_srcdir)/applets
|
||||
APPLETS_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
-include $(top_builddir).depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -19,18 +19,19 @@
|
||||
|
||||
APPLETS_AR:=applets.a
|
||||
ifndef $(APPLETS_DIR)
|
||||
APPLETS_DIR:=$(TOPDIR)applets/
|
||||
APPLETS_DIR:=$(top_builddir)/applets/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/applets
|
||||
|
||||
APPLET_SRC:=applets.c busybox.c usage.c
|
||||
APPLET_SRC:=applets.c busybox.c
|
||||
APPLET_OBJ:= $(patsubst %.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
|
||||
|
||||
|
||||
|
||||
libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
|
||||
|
||||
$(APPLET_OBJ): $(TOPDIR).config
|
||||
|
||||
$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
|
||||
$(AR) -ro $@ $(APPLET_OBJ)
|
||||
$(AR) $(ARFLAGS) $@ $(APPLET_OBJ)
|
||||
|
||||
$(APPLET_OBJ): $(top_builddir)/.config
|
||||
$(APPLET_OBJ): $(APPLETS_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -32,11 +32,22 @@
|
||||
#include <assert.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char usage_messages[] =
|
||||
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
|
||||
#include "applets.h"
|
||||
|
||||
;
|
||||
|
||||
#undef MAKE_USAGE
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
|
||||
static struct BB_applet *applet_using;
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
@@ -423,7 +434,7 @@ static void parse_config_file(void)
|
||||
}
|
||||
|
||||
/* Now get the the user/group info. */
|
||||
|
||||
|
||||
s = (char *) bb_skip_whitespace(e);
|
||||
|
||||
/* Note: We require whitespace between the mode and the
|
||||
@@ -464,7 +475,7 @@ static void parse_config_file(void)
|
||||
|
||||
/* Encountering configuration lines prior to seeing a
|
||||
* section header is treated as an error. This is how
|
||||
* the old code worked, but it may not be desireable.
|
||||
* the old code worked, but it may not be desirable.
|
||||
* We may want to simply ignore such lines in case they
|
||||
* are used in some future version of busybox. */
|
||||
if (!section) {
|
||||
@@ -13,7 +13,7 @@ int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *bb_applet_name;
|
||||
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
@@ -32,7 +32,7 @@ static const char* const install_dir[] = {
|
||||
/* 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
|
||||
@@ -52,7 +52,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
|
||||
bb_applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#ifdef CONFIG_INIT
|
||||
if(getpid()!=1) /* Do not set locale for `init' */
|
||||
#endif
|
||||
@@ -100,9 +100,9 @@ int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
#ifdef CONFIG_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.
|
||||
*/
|
||||
@@ -113,8 +113,8 @@ int busybox_main(int argc, char **argv)
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,25 +144,25 @@ int busybox_main(int argc, char **argv)
|
||||
output_width -= 20;
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "%s\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use, and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as.\n"
|
||||
"\nCurrently defined functions:\n", bb_msg_full_version);
|
||||
printf("%s\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as!\n"
|
||||
"\nCurrently defined functions:\n", bb_msg_full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
printf("%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
if (col > output_width && a->name != 0) {
|
||||
fprintf(stderr, ",\n");
|
||||
printf(",\n");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
printf("\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -46,11 +46,11 @@ config CONFIG_BUNZIP2
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
is generally considerably better than that achieved by more
|
||||
conventional LZ77/LZ78-based compressors, and approaches the
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
The BusyBox bunzip2 applet is limited to de-compression only.
|
||||
On an x86 system, this applet adds about 11K.
|
||||
|
||||
|
||||
Unless you have a specific application which requires bunzip2, you
|
||||
should probably say N here.
|
||||
|
||||
@@ -63,7 +63,7 @@ config CONFIG_CPIO
|
||||
cpio has 110 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of cpio can extract cpio archives created in the
|
||||
"newc" or "crc" format, it cannot create or modify them.
|
||||
"newc" or "crc" format, it cannot create or modify them.
|
||||
|
||||
Unless you have a specific application which requires cpio, you should
|
||||
probably say N here.
|
||||
@@ -73,7 +73,7 @@ config CONFIG_DPKG
|
||||
default n
|
||||
help
|
||||
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
|
||||
|
||||
|
||||
This implementation of dpkg has a number of limitations, you should use the
|
||||
official dpkg if possible.
|
||||
|
||||
@@ -82,9 +82,9 @@ config CONFIG_DPKG_DEB
|
||||
default n
|
||||
help
|
||||
dpkg-deb packs, unpacks and provides information about Debian archives.
|
||||
|
||||
|
||||
This implementation of dpkg-deb cannot pack archives.
|
||||
|
||||
|
||||
Unless you have a specific application which requires dpkg-deb, you should
|
||||
probably say N here.
|
||||
|
||||
@@ -94,7 +94,7 @@ config CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
depends on CONFIG_DPKG_DEB
|
||||
help
|
||||
This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
|
||||
However it saves space as none of the extra dpkg-deb, ar or tar options are
|
||||
However it saves space as none of the extra dpkg-deb, ar or tar options are
|
||||
needed, they are linked to internally.
|
||||
|
||||
config CONFIG_GUNZIP
|
||||
@@ -195,7 +195,7 @@ config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
With this option busybox supports GNU long filenames and
|
||||
With this option busybox supports GNU long filenames and
|
||||
linknames.
|
||||
|
||||
config CONFIG_FEATURE_TAR_LONG_OPTIONS
|
||||
@@ -241,7 +241,7 @@ config CONFIG_FEATURE_DEB_TAR_GZ
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
help
|
||||
This is the default compression method inside the debian ar file.
|
||||
|
||||
|
||||
If you want compatibility with standard .deb's you should say yes here.
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
@@ -251,7 +251,7 @@ config CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
help
|
||||
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
|
||||
with bzip2 instead of gzip.
|
||||
|
||||
|
||||
You only want this if you are creating your own custom debian packages that
|
||||
use an internal control.tar.bz2 or data.tar.bz2.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -17,13 +17,15 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR:= ../
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
ARCHIVAL_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
srcdir=$(top_srcdir)/archival
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
ARCHIVAL_AR:=archival.a
|
||||
ifndef $(ARCHIVAL_DIR)
|
||||
ARCHIVAL_DIR:=$(TOPDIR)archival/
|
||||
ARCHIVAL_DIR:=$(top_builddir)/archival/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/archival
|
||||
|
||||
ARCHIVAL-y:=
|
||||
ARCHIVAL-$(CONFIG_APT_GET) +=
|
||||
@@ -40,5 +41,8 @@ ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
|
||||
libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
|
||||
|
||||
$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
|
||||
$(ARCHIVAL_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ar implementation for busybox
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Written by Glenn McGrath <bug1@iinet.net.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
|
||||
@@ -50,24 +50,27 @@ static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, (int) file_header->size, &mtime[4], file_header->name);
|
||||
}
|
||||
|
||||
#define AR_CTX_PRINT 1
|
||||
#define AR_CTX_LIST 2
|
||||
#define AR_CTX_EXTRACT 4
|
||||
#define AR_OPT_PRESERVE_DATE 8
|
||||
#define AR_OPT_VERBOSE 16
|
||||
#define AR_CTX_PRINT 0x01
|
||||
#define AR_CTX_LIST 0x02
|
||||
#define AR_CTX_EXTRACT 0x04
|
||||
#define AR_OPT_PRESERVE_DATE 0x08
|
||||
#define AR_OPT_VERBOSE 0x10
|
||||
#define AR_OPT_CREATE 0x20
|
||||
#define AR_OPT_INSERT 0x40
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned long opt;
|
||||
char *msg_unsupported_err = "Archive %s not supported. Install binutils 'ar'.";
|
||||
char magic[8];
|
||||
|
||||
archive_handle = init_handle();
|
||||
|
||||
bb_opt_complementaly = "p~tx:t~px:x~pt";
|
||||
opt = bb_getopt_ulflags(argc, argv, "ptxov");
|
||||
opt = bb_getopt_ulflags(argc, argv, "ptxovcr");
|
||||
|
||||
if ((opt & 0x80000000UL) || (optind == argc)) {
|
||||
if ((opt & BB_GETOPT_ERROR) || (opt == 0) || (optind == argc)) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
@@ -86,6 +89,12 @@ extern int ar_main(int argc, char **argv)
|
||||
if (opt & AR_OPT_VERBOSE) {
|
||||
archive_handle->action_header = header_verbose_list_ar;
|
||||
}
|
||||
if (opt & AR_OPT_CREATE) {
|
||||
bb_error_msg_and_die(msg_unsupported_err, "creation");
|
||||
}
|
||||
if (opt & AR_OPT_INSERT) {
|
||||
bb_error_msg_and_die(msg_unsupported_err, "insertion");
|
||||
}
|
||||
|
||||
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Modified for busybox by Glenn McGrath <bug1@optushome.com.au>
|
||||
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
|
||||
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -33,6 +33,8 @@
|
||||
int bunzip2_main(int argc, char **argv)
|
||||
{
|
||||
char *compressed_name;
|
||||
/* Note: Ignore the warning about save_name being used uninitialized.
|
||||
* That is not the case, but gcc has trouble working that out... */
|
||||
char *save_name;
|
||||
unsigned long opt;
|
||||
int status;
|
||||
@@ -52,7 +54,7 @@ int bunzip2_main(int argc, char **argv)
|
||||
/* Open input file */
|
||||
src_fd = bb_xopen(compressed_name, O_RDONLY);
|
||||
} else {
|
||||
src_fd = fileno(stdin);
|
||||
src_fd = STDIN_FILENO;
|
||||
opt |= BUNZIP2_OPT_STDOUT;
|
||||
}
|
||||
|
||||
@@ -62,7 +64,7 @@ int bunzip2_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (opt & BUNZIP2_OPT_STDOUT) {
|
||||
dst_fd = fileno(stdout);
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
int len = strlen(compressed_name) - 4;
|
||||
if (strcmp(compressed_name + len, ".bz2") != 0) {
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini cpio implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2001 by Glenn McGrath
|
||||
* Copyright (C) 2001 by Glenn McGrath
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,55 +31,60 @@
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
|
||||
extern int cpio_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
int opt;
|
||||
char *cpio_filename = NULL;
|
||||
unsigned long opt;
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->src_fd = fileno(stdin);
|
||||
archive_handle->src_fd = STDIN_FILENO;
|
||||
archive_handle->seek = seek_by_char;
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
|
||||
|
||||
while ((opt = getopt(argc, argv, "idmuvtF:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': /* extract */
|
||||
archive_handle->action_data = data_extract_all;
|
||||
break;
|
||||
case 'd': /* create _leading_ directories */
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
break;
|
||||
#if 0
|
||||
case 'm': /* preserve modification time */
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
break;
|
||||
#endif
|
||||
case 'v': /* verbosly list files */
|
||||
if (archive_handle->action_header == header_list) {
|
||||
archive_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
break;
|
||||
case 'u': /* unconditional */
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
archive_handle->flags &= ~ARCHIVE_EXTRACT_NEWER;
|
||||
break;
|
||||
case 't': /* list files */
|
||||
if (archive_handle->action_header == header_list) {
|
||||
archive_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
archive_handle->src_fd = bb_xopen(optarg, O_RDONLY);
|
||||
archive_handle->seek = seek_by_jump;
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "ituvF:dm", &cpio_filename);
|
||||
|
||||
/* One of either extract or test options must be given */
|
||||
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (opt & CPIO_OPT_TEST) {
|
||||
/* if both extract and test option are given, ignore extract option */
|
||||
if (opt & CPIO_OPT_EXTRACT) {
|
||||
opt &= ~CPIO_OPT_EXTRACT;
|
||||
}
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
if (opt & CPIO_OPT_EXTRACT) {
|
||||
archive_handle->action_data = data_extract_all;
|
||||
}
|
||||
if (opt & CPIO_OPT_UNCONDITIONAL) {
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
archive_handle->flags &= ~ARCHIVE_EXTRACT_NEWER;
|
||||
}
|
||||
if (opt & CPIO_OPT_VERBOSE) {
|
||||
if (archive_handle->action_header == header_list) {
|
||||
archive_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
}
|
||||
if (cpio_filename) { /* CPIO_OPT_FILE */
|
||||
archive_handle->src_fd = bb_xopen(cpio_filename, O_RDONLY);
|
||||
archive_handle->seek = seek_by_jump;
|
||||
}
|
||||
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* Mini dpkg implementation for busybox.
|
||||
* This is not meant as a replacemnt for dpkg
|
||||
* This is not meant as a replacement for dpkg
|
||||
*
|
||||
* Written By Glenn McGrath with the help of others
|
||||
* Copyright (C) 2001 by Glenn McGrath
|
||||
*
|
||||
*
|
||||
* Started life as a busybox implementation of udpkg
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Known difference between busybox dpkg and the official dpkg that i dont
|
||||
* Known difference between busybox dpkg and the official dpkg that i don't
|
||||
* consider important, its worth keeping a note of differences anyway, just to
|
||||
* make it easier to maintain.
|
||||
* - The first value for the Confflile: field isnt placed on a new line.
|
||||
@@ -54,7 +54,7 @@
|
||||
* int's and chaos is assured, 16381 is the max prime for 14 bit field
|
||||
*/
|
||||
|
||||
/* NAME_HASH_PRIME, Stores package names and versions,
|
||||
/* NAME_HASH_PRIME, Stores package names and versions,
|
||||
* I estimate it should be at least 50% bigger than PACKAGE_HASH_PRIME,
|
||||
* as there a lot of duplicate version numbers */
|
||||
#define NAME_HASH_PRIME 16381
|
||||
@@ -86,7 +86,7 @@ common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
|
||||
|
||||
/* Currently it doesnt store packages that have state-status of not-installed
|
||||
* So it only really has to be the size of the maximum number of packages
|
||||
* likely to be installed at any one time, so there is a bit of leaway here */
|
||||
* likely to be installed at any one time, so there is a bit of leeway here */
|
||||
#define STATUS_HASH_PRIME 8191
|
||||
typedef struct status_node_s {
|
||||
unsigned int package:14; /* has to fit PACKAGE_HASH_PRIME */
|
||||
@@ -94,7 +94,7 @@ typedef struct status_node_s {
|
||||
} status_node_t;
|
||||
status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
|
||||
|
||||
/* Even numbers are for 'extras', like ored dependecies or null */
|
||||
/* Even numbers are for 'extras', like ored dependencies or null */
|
||||
enum edge_type_e {
|
||||
EDGE_NULL = 0,
|
||||
EDGE_PRE_DEPENDS = 1,
|
||||
@@ -148,9 +148,9 @@ void make_hash(const char *key, unsigned int *start, unsigned int *decrement, co
|
||||
for(i = 1; i < len; i++) {
|
||||
/* shifts the ascii based value and adds it to previous value
|
||||
* shift amount is mod 24 because long int is 32 bit and data
|
||||
* to be shifted is 8, dont want to shift data to where it has
|
||||
* to be shifted is 8, don't want to shift data to where it has
|
||||
* no effect*/
|
||||
hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24));
|
||||
hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24));
|
||||
}
|
||||
*start = (unsigned int) hash_num % hash_prime;
|
||||
*decrement = (unsigned int) 1 + (hash_num % (hash_prime - 1));
|
||||
@@ -392,7 +392,7 @@ int search_package_hashtable(const unsigned int name, const unsigned int version
|
||||
/*
|
||||
* This function searches through the entire package_hashtable looking
|
||||
* for a package which provides "needle". It returns the index into
|
||||
* the package_hashtable for the provining package.
|
||||
* the package_hashtable for the providing package.
|
||||
*
|
||||
* needle is the index into name_hashtable of the package we are
|
||||
* looking for.
|
||||
@@ -464,11 +464,11 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
|
||||
} else {
|
||||
or_edge = NULL;
|
||||
}
|
||||
|
||||
|
||||
if ( or_edge ) {
|
||||
or_edge->name = search_name_hashtable(field);
|
||||
or_edge->version = 0; // tracks the number of altenatives
|
||||
|
||||
|
||||
add_edge_to_node(parent_node, or_edge);
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
|
||||
/* Skip leading ' ' or '(' */
|
||||
version += strspn(field2, " ");
|
||||
version += strspn(version, "(");
|
||||
/* Calculate length of any operator charactors */
|
||||
/* Calculate length of any operator characters */
|
||||
offset_ch = strspn(version, "<=>");
|
||||
/* Determine operator */
|
||||
if (offset_ch > 0) {
|
||||
@@ -572,7 +572,7 @@ unsigned int fill_package_struct(char *control_buffer)
|
||||
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement ! */
|
||||
}
|
||||
|
||||
field_num = compare_string_array(field_names, field_name);
|
||||
field_num = compare_string_array(field_names, field_name);
|
||||
switch(field_num) {
|
||||
case 0: /* Package */
|
||||
new_node->name = search_name_hashtable(field_value);
|
||||
@@ -636,7 +636,7 @@ unsigned int get_status(const unsigned int status_node, const int num)
|
||||
for (i = 1; i < num; i++) {
|
||||
/* skip past a word */
|
||||
status_string += strcspn(status_string, " ");
|
||||
/* skip past the seperating spaces */
|
||||
/* skip past the separating spaces */
|
||||
status_string += strspn(status_string, " ");
|
||||
}
|
||||
len = strcspn(status_string, " \n\0");
|
||||
@@ -697,7 +697,7 @@ const char *describe_status(int status_num) {
|
||||
return "is marked to be removed";
|
||||
if ( status_want == search_name_hashtable("purge") )
|
||||
return "is marked to be purged";
|
||||
}
|
||||
}
|
||||
if ( status_want == search_name_hashtable("unknown") )
|
||||
return "is in an indeterminate state";
|
||||
if ( status_want == search_name_hashtable("install") )
|
||||
@@ -955,13 +955,13 @@ void write_status_file(deb_file_t **deb_file)
|
||||
fclose(new_status_file);
|
||||
|
||||
|
||||
/* Create a seperate backfile to dpkg */
|
||||
/* Create a separate backfile to dpkg */
|
||||
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
|
||||
struct stat stat_buf;
|
||||
struct stat stat_buf;
|
||||
if (stat("/var/lib/dpkg/status", &stat_buf) == 0) {
|
||||
bb_error_msg_and_die("Couldnt create backup status file");
|
||||
}
|
||||
/* Its ok if renaming the status file fails becasue status
|
||||
/* Its ok if renaming the status file fails because status
|
||||
* file doesnt exist, maybe we are starting from scratch */
|
||||
bb_error_msg("No status file found, creating new one");
|
||||
}
|
||||
@@ -971,10 +971,10 @@ void write_status_file(deb_file_t **deb_file)
|
||||
}
|
||||
}
|
||||
|
||||
/* This function returns TRUE if the given package can statisfy a
|
||||
/* This function returns TRUE if the given package can satisfy a
|
||||
* dependency of type depend_type.
|
||||
*
|
||||
* A pre-depends is statisfied only if a package is already installed,
|
||||
* A pre-depends is satisfied only if a package is already installed,
|
||||
* which a regular depends can be satisfied by a package which we want
|
||||
* to install.
|
||||
*/
|
||||
@@ -1056,10 +1056,10 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
const edge_t *package_edge = package_node->edge[j];
|
||||
|
||||
if (package_edge->type == EDGE_CONFLICTS) {
|
||||
const unsigned int package_num =
|
||||
const unsigned int package_num =
|
||||
search_package_hashtable(package_edge->name,
|
||||
package_edge->version,
|
||||
package_edge->operator);
|
||||
package_edge->version,
|
||||
package_edge->operator);
|
||||
int result = 0;
|
||||
if (package_hashtable[package_num] != NULL) {
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
|
||||
@@ -1078,14 +1078,14 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check dependendcies */
|
||||
for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
|
||||
int status_num = 0;
|
||||
int number_of_alternatives = 0;
|
||||
const edge_t * root_of_alternatives;
|
||||
const edge_t * root_of_alternatives = NULL;
|
||||
const common_node_t *package_node = package_hashtable[i];
|
||||
|
||||
/* If the package node does not exist then this
|
||||
@@ -1098,7 +1098,7 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
|
||||
/* If there is no status then this package is a
|
||||
* virtual one provided by something else. In which
|
||||
* case there are no dependencies to check.
|
||||
* case there are no dependencies to check.
|
||||
*/
|
||||
if ( status_hashtable[status_num] == NULL ) continue;
|
||||
|
||||
@@ -1118,14 +1118,14 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
/* This code is tested only for EDGE_DEPENDS, sine I
|
||||
/* This code is tested only for EDGE_DEPENDS, since I
|
||||
* have no suitable pre-depends available. There is no
|
||||
* reason that it shouldn't work though :-)
|
||||
*/
|
||||
for (j = 0; j < package_node->num_of_edges; j++) {
|
||||
const edge_t *package_edge = package_node->edge[j];
|
||||
unsigned int package_num;
|
||||
|
||||
|
||||
if ( package_edge->type == EDGE_OR_PRE_DEPENDS ||
|
||||
package_edge->type == EDGE_OR_DEPENDS ) { /* start an EDGE_OR_ list */
|
||||
number_of_alternatives = package_edge->version;
|
||||
@@ -1147,26 +1147,26 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
* this edge is the right type.
|
||||
*
|
||||
* EDGE_DEPENDS == OR_DEPENDS -1
|
||||
* EDGE_PRE_DEPENDS == OR_PRE_DEPENDS -1
|
||||
* EDGE_PRE_DEPENDS == OR_PRE_DEPENDS -1
|
||||
*/
|
||||
if ( root_of_alternatives && package_edge->type != root_of_alternatives->type - 1)
|
||||
bb_error_msg_and_die("Fatal error. Package dependencies corrupt: %d != %d - 1 \n",
|
||||
package_edge->type, root_of_alternatives->type);
|
||||
|
||||
|
||||
if (package_hashtable[package_num] != NULL)
|
||||
result = !package_satisfies_dependency(package_num, package_edge->type);
|
||||
|
||||
if (result) { /* check for other package which provide what we are looking for */
|
||||
int provider = -1;
|
||||
|
||||
|
||||
while ( (provider = search_for_provides(package_edge->name, provider) ) > -1 ) {
|
||||
if ( package_hashtable[provider] == NULL ) {
|
||||
printf("Have a provider but no package information for it\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result = !package_satisfies_dependency(provider, package_edge->type);
|
||||
|
||||
if ( result == 0 )
|
||||
|
||||
if ( result == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1176,14 +1176,14 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
if (result && number_of_alternatives == 0) {
|
||||
if ( root_of_alternatives )
|
||||
bb_error_msg_and_die(
|
||||
"Package %s %sdepends on %s, "
|
||||
"Package %s %sdepends on %s, "
|
||||
"which cannot be satisfied",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[root_of_alternatives->name]);
|
||||
else
|
||||
else
|
||||
bb_error_msg_and_die(
|
||||
"Package %s %sdepends on %s, which %s\n",
|
||||
"Package %s %sdepends on %s, which %s\n",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[package_edge->name],
|
||||
@@ -1192,7 +1192,7 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
/* we've found a package which
|
||||
* satisfies the dependency,
|
||||
* so skip over the rest of
|
||||
* the alternatives.
|
||||
* the alternatives.
|
||||
*/
|
||||
j += number_of_alternatives;
|
||||
number_of_alternatives = 0;
|
||||
@@ -1211,7 +1211,7 @@ char **create_list(const char *filename)
|
||||
char *line = NULL;
|
||||
int count = 0;
|
||||
|
||||
/* dont use [xw]fopen here, handle error ourself */
|
||||
/* don't use [xw]fopen here, handle error ourself */
|
||||
list_stream = fopen(filename, "r");
|
||||
if (list_stream == NULL) {
|
||||
return(NULL);
|
||||
@@ -1312,7 +1312,7 @@ char **all_control_list(const char *package_name)
|
||||
|
||||
void free_array(char **array)
|
||||
{
|
||||
|
||||
|
||||
if (array) {
|
||||
unsigned short i = 0;
|
||||
while (array[i]) {
|
||||
@@ -1325,15 +1325,15 @@ void free_array(char **array)
|
||||
|
||||
/* This function lists information on the installed packages. It loops through
|
||||
* the status_hashtable to retrieve the info. This results in smaller code than
|
||||
* scanning the status file. The resulting list, however, is unsorted.
|
||||
* scanning the status file. The resulting list, however, is unsorted.
|
||||
*/
|
||||
void list_packages(void)
|
||||
static void list_packages(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf(" Name Version\n");
|
||||
printf("+++-==============-==============\n");
|
||||
|
||||
|
||||
/* go through status hash, dereference package hash and finally strings */
|
||||
for (i=0; i<STATUS_HASH_PRIME+1; i++) {
|
||||
|
||||
@@ -1342,22 +1342,22 @@ void list_packages(void)
|
||||
const char *name_str; /* package name */
|
||||
const char *vers_str; /* version */
|
||||
char s1, s2; /* status abbreviations */
|
||||
int spccnt; /* space count */
|
||||
int spccnt; /* space count */
|
||||
int j;
|
||||
|
||||
|
||||
stat_str = name_hashtable[status_hashtable[i]->status];
|
||||
name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name];
|
||||
vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version];
|
||||
|
||||
|
||||
/* get abbreviation for status field 1 */
|
||||
s1 = stat_str[0] == 'i' ? 'i' : 'r';
|
||||
|
||||
|
||||
/* get abbreviation for status field 2 */
|
||||
for (j=0, spccnt=0; stat_str[j] && spccnt<2; j++) {
|
||||
if (stat_str[j] == ' ') spccnt++;
|
||||
}
|
||||
s2 = stat_str[j];
|
||||
|
||||
|
||||
/* print out the line formatted like Debian dpkg */
|
||||
printf("%c%c %-14s %s\n", s1, s2, name_str, vers_str);
|
||||
}
|
||||
@@ -1376,7 +1376,7 @@ void remove_package(const unsigned int package_num, int noisy)
|
||||
char conffile_name[package_name_length + 30];
|
||||
int return_value;
|
||||
|
||||
if ( noisy )
|
||||
if ( noisy )
|
||||
printf("Removing %s (%s) ...\n", package_name, package_version);
|
||||
|
||||
/* run prerm script */
|
||||
@@ -1385,7 +1385,7 @@ void remove_package(const unsigned int package_num, int noisy)
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
|
||||
/* Create a list of files to remove, and a seperate list of those to keep */
|
||||
/* Create a list of files to remove, and a separate list of those to keep */
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
|
||||
remove_files = create_list(list_name);
|
||||
|
||||
@@ -1464,12 +1464,12 @@ static archive_handle_t *init_archive_deb_ar(const char *filename)
|
||||
{
|
||||
archive_handle_t *ar_handle;
|
||||
|
||||
/* Setup an ar archive handle that refers to the gzip sub archive */
|
||||
/* Setup an ar archive handle that refers to the gzip sub archive */
|
||||
ar_handle = init_handle();
|
||||
ar_handle->filter = filter_accept_list_reassign;
|
||||
ar_handle->src_fd = bb_xopen(filename, O_RDONLY);
|
||||
|
||||
return(ar_handle);
|
||||
return(ar_handle);
|
||||
}
|
||||
|
||||
static void init_archive_deb_control(archive_handle_t *ar_handle)
|
||||
@@ -1480,7 +1480,7 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
|
||||
tar_handle = init_handle();
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We dont care about data.tar.* or debian-binary, just control.tar.* */
|
||||
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
ar_handle->accept = llist_add_to(NULL, "control.tar.gz");
|
||||
#endif
|
||||
@@ -1491,7 +1491,7 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->sub_archive = tar_handle;
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
static void init_archive_deb_data(archive_handle_t *ar_handle)
|
||||
@@ -1502,7 +1502,7 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
|
||||
tar_handle = init_handle();
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We dont care about control.tar.* or debian-binary, just data.tar.* */
|
||||
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
ar_handle->accept = llist_add_to(NULL, "data.tar.gz");
|
||||
#endif
|
||||
@@ -1513,13 +1513,14 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->sub_archive = tar_handle;
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *myaccept)
|
||||
{
|
||||
ar_handle->sub_archive->action_data = data_extract_to_buffer;
|
||||
ar_handle->sub_archive->accept = myaccept;
|
||||
ar_handle->sub_archive->filter = filter_accept_list;
|
||||
|
||||
unpack_ar_archive(ar_handle);
|
||||
close(ar_handle->src_fd);
|
||||
@@ -1586,7 +1587,7 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
if (run_package_script(package_name, "preinst") != 0) {
|
||||
/* when preinst returns exit code != 0 then quit installation process */
|
||||
bb_error_msg_and_die("subprocess pre-installation script returned error.");
|
||||
}
|
||||
}
|
||||
|
||||
/* Extract data.tar.gz to the root directory */
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
@@ -1598,7 +1599,7 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
|
||||
/* Create the list file */
|
||||
strcat(info_prefix, "list");
|
||||
out_stream = bb_xfopen(info_prefix, "w");
|
||||
out_stream = bb_xfopen(info_prefix, "w");
|
||||
while (archive_handle->sub_archive->passed) {
|
||||
/* the leading . has been stripped by data_extract_all_prefix already */
|
||||
fputs(archive_handle->sub_archive->passed->data, out_stream);
|
||||
@@ -1653,7 +1654,7 @@ int dpkg_main(int argc, char **argv)
|
||||
case 'F': // equivalent to --force in official dpkg
|
||||
if (strcmp(optarg, "depends") == 0) {
|
||||
dpkg_opt |= dpkg_opt_force_ignore_depends;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
dpkg_opt |= dpkg_opt_install;
|
||||
@@ -1691,7 +1692,7 @@ int dpkg_main(int argc, char **argv)
|
||||
list_packages();
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/* Read arguments and store relevant info in structs */
|
||||
while (optind < argc) {
|
||||
/* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
|
||||
@@ -1714,6 +1715,7 @@ int dpkg_main(int argc, char **argv)
|
||||
|
||||
if (package_num == -1) {
|
||||
bb_error_msg("Invalid control file in %s", argv[optind]);
|
||||
optind++;
|
||||
continue;
|
||||
}
|
||||
deb_file[deb_count]->package = (unsigned int) package_num;
|
||||
@@ -41,7 +41,7 @@ extern int dpkg_deb_main(int argc, char **argv)
|
||||
/* Setup the tar archive handle */
|
||||
tar_archive = init_handle();
|
||||
|
||||
/* Setup an ar archive handle that refers to the gzip sub archive */
|
||||
/* Setup an ar archive handle that refers to the gzip sub archive */
|
||||
ar_archive = init_handle();
|
||||
ar_archive->sub_archive = tar_archive;
|
||||
ar_archive->filter = filter_accept_list_reassign;
|
||||
@@ -73,7 +73,7 @@ extern int dpkg_deb_main(int argc, char **argv)
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_FIELD) {
|
||||
/* Print the entire control file
|
||||
* it should accept a second argument which specifies a
|
||||
* it should accept a second argument which specifies a
|
||||
* specific field to print */
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->accept = llist_add_to(NULL, "./control");;
|
||||
@@ -88,7 +88,7 @@ extern int dpkg_deb_main(int argc, char **argv)
|
||||
argcount = 2;
|
||||
}
|
||||
|
||||
if ((optind + argcount != argc) || (opt & 0x80000000UL)) {
|
||||
if ((optind + argcount != argc) || (opt & BB_GETOPT_ERROR)) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@optushome.com.au>
|
||||
*
|
||||
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* 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
|
||||
@@ -98,7 +98,7 @@ extern int gunzip_main(int argc, char **argv)
|
||||
optind++;
|
||||
|
||||
if (old_path == NULL || strcmp(old_path, "-") == 0) {
|
||||
src_fd = fileno(stdin);
|
||||
src_fd = STDIN_FILENO;
|
||||
opt |= GUNZIP_OPT_STDOUT;
|
||||
} else {
|
||||
src_fd = bb_xopen(old_path, O_RDONLY);
|
||||
@@ -119,7 +119,7 @@ extern int gunzip_main(int argc, char **argv)
|
||||
if (opt & GUNZIP_OPT_TEST) {
|
||||
dst_fd = bb_xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */
|
||||
} else if (opt & GUNZIP_OPT_STDOUT) {
|
||||
dst_fd = fileno(stdout);
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
char *extension;
|
||||
|
||||
@@ -153,12 +153,12 @@ extern int gunzip_main(int argc, char **argv)
|
||||
/* do the decompression, and cleanup */
|
||||
if (bb_xread_char(src_fd) == 0x1f) {
|
||||
unsigned char magic2;
|
||||
|
||||
|
||||
magic2 = bb_xread_char(src_fd);
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
if (magic2 == 0x9d) {
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
} else
|
||||
} else
|
||||
#endif
|
||||
if (magic2 == 0x8b) {
|
||||
check_header_gzip(src_fd);
|
||||
@@ -178,10 +178,10 @@ extern int gunzip_main(int argc, char **argv)
|
||||
delete_path = new_path;
|
||||
}
|
||||
|
||||
if (dst_fd != fileno(stdout)) {
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != fileno(stdin)) {
|
||||
if (src_fd != STDIN_FILENO) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
* only standard in to standard out with -9 compression. It also requires
|
||||
* the zcat module for some important functions."
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support
|
||||
* files as well as stdin/stdout, and to generally behave itself wrt
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support
|
||||
* files as well as stdin/stdout, and to generally behave itself wrt
|
||||
* command line handling.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
/* These defines are very important for BusyBox. Without these,
|
||||
* huge chunks of ram are pre-allocated making the BusyBox bss
|
||||
* huge chunks of ram are pre-allocated making the BusyBox bss
|
||||
* size Freaking Huge(tm), which is a bad thing.*/
|
||||
#define SMALL_MEM
|
||||
#define DYN_ALLOC
|
||||
@@ -51,12 +51,6 @@
|
||||
#include <time.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define memzero(s, n) memset ((void *)(s), 0, (n))
|
||||
|
||||
#ifndef RETSIGTYPE
|
||||
# define RETSIGTYPE void
|
||||
#endif
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef unsigned short ush;
|
||||
typedef unsigned long ulg;
|
||||
@@ -214,9 +208,6 @@ typedef int file_t; /* Do not use stdio */
|
||||
static int zip(int in, int out);
|
||||
static int file_read(char *buf, unsigned size);
|
||||
|
||||
/* from gzip.c */
|
||||
static RETSIGTYPE abort_gzip(void);
|
||||
|
||||
/* from deflate.c */
|
||||
static void lm_init(ush * flags);
|
||||
static ulg deflate(void);
|
||||
@@ -335,7 +326,7 @@ static void put_short(ush w)
|
||||
/* ========================================================================
|
||||
* Signal and error handler.
|
||||
*/
|
||||
static void abort_gzip()
|
||||
static void abort_gzip(int ignored)
|
||||
{
|
||||
exit(ERROR);
|
||||
}
|
||||
@@ -350,13 +341,6 @@ static void clear_bufs(void)
|
||||
bytes_in = 0L;
|
||||
}
|
||||
|
||||
static void write_bb_error_msg(void)
|
||||
{
|
||||
fputc('\n', stderr);
|
||||
bb_perror_nomsg();
|
||||
abort_gzip();
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Does the same as write(), but also handles partial pipe writes and checks
|
||||
* for error return.
|
||||
@@ -366,9 +350,7 @@ static void write_buf(int fd, void *buf, unsigned cnt)
|
||||
unsigned n;
|
||||
|
||||
while ((n = write(fd, buf, cnt)) != cnt) {
|
||||
if (n == (unsigned) (-1)) {
|
||||
write_bb_error_msg();
|
||||
}
|
||||
if (n == (unsigned) (-1)) bb_error_msg_and_die("can't write");
|
||||
cnt -= n;
|
||||
buf = (void *) ((char *) buf + n);
|
||||
}
|
||||
@@ -559,7 +541,7 @@ static unsigned bi_reverse(unsigned code, int len)
|
||||
/* ===========================================================================
|
||||
* Write out any remaining bits in an incomplete byte.
|
||||
*/
|
||||
static void bi_windup()
|
||||
static void bi_windup(void)
|
||||
{
|
||||
if (bi_valid > 8) {
|
||||
put_short(bi_buf);
|
||||
@@ -632,7 +614,7 @@ static void copy_block(char *buf, unsigned len, int header)
|
||||
* However the F&G algorithm may be faster for some highly redundant
|
||||
* files if the parameter max_chain_length (described below) is too large.
|
||||
*
|
||||
* ACKNOWLEDGEMENTS
|
||||
* ACKNOWLEDGMENTS
|
||||
*
|
||||
* The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
|
||||
* I found it in 'freeze' written by Leonid Broukhis.
|
||||
@@ -846,7 +828,7 @@ static void lm_init(ush * flags)
|
||||
register unsigned j;
|
||||
|
||||
/* Initialize the hash table. */
|
||||
memzero((char *) head, HASH_SIZE * sizeof(*head));
|
||||
memset(head, 0, HASH_SIZE * sizeof(*head));
|
||||
/* prev will be initialized on the fly */
|
||||
|
||||
*flags |= SLOW;
|
||||
@@ -996,7 +978,7 @@ static void check_match(IPos start, IPos match, int length)
|
||||
* file reads are performed for at least two bytes (required for the
|
||||
* translate_eol option).
|
||||
*/
|
||||
static void fill_window()
|
||||
static void fill_window(void)
|
||||
{
|
||||
register unsigned n, m;
|
||||
unsigned more =
|
||||
@@ -1060,7 +1042,7 @@ static void fill_window()
|
||||
* evaluation for matches: a match is finally adopted only if there is
|
||||
* no better match at the next window position.
|
||||
*/
|
||||
static ulg deflate()
|
||||
static ulg deflate(void)
|
||||
{
|
||||
IPos hash_head; /* head of hash chain */
|
||||
IPos prev_match; /* previous match */
|
||||
@@ -1188,8 +1170,6 @@ static ulg deflate()
|
||||
|
||||
typedef struct dirent dir_type;
|
||||
|
||||
typedef RETSIGTYPE(*sig_type) (int);
|
||||
|
||||
/* ======================================================================== */
|
||||
int gzip_main(int argc, char **argv)
|
||||
{
|
||||
@@ -1235,16 +1215,16 @@ int gzip_main(int argc, char **argv)
|
||||
|
||||
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
|
||||
if (foreground) {
|
||||
(void) signal(SIGINT, (sig_type) abort_gzip);
|
||||
(void) signal(SIGINT, abort_gzip);
|
||||
}
|
||||
#ifdef SIGTERM
|
||||
if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
|
||||
(void) signal(SIGTERM, (sig_type) abort_gzip);
|
||||
(void) signal(SIGTERM, abort_gzip);
|
||||
}
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
|
||||
(void) signal(SIGHUP, (sig_type) abort_gzip);
|
||||
(void) signal(SIGHUP, abort_gzip);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1271,6 +1251,7 @@ int gzip_main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
char *path = NULL;
|
||||
|
||||
clear_bufs();
|
||||
if (strcmp(argv[i], "-") == 0) {
|
||||
time_stamp = 0;
|
||||
ifile_size = -1L;
|
||||
@@ -1749,7 +1730,7 @@ static void ct_init(ush * attr, int *methodp)
|
||||
/* ===========================================================================
|
||||
* Initialize a new block.
|
||||
*/
|
||||
static void init_block()
|
||||
static void init_block(void)
|
||||
{
|
||||
int n; /* iterates over tree elements */
|
||||
|
||||
@@ -2162,7 +2143,7 @@ static void send_tree(ct_data * tree, int max_code)
|
||||
* Construct the Huffman tree for the bit lengths and return the index in
|
||||
* bl_order of the last bit length code to send.
|
||||
*/
|
||||
static const int build_bl_tree()
|
||||
static int build_bl_tree(void)
|
||||
{
|
||||
int max_blindex; /* index of last bit length code of non zero freq */
|
||||
|
||||
@@ -2425,7 +2406,7 @@ static void compress_block(ct_data * ltree, ct_data * dtree)
|
||||
* IN assertion: the fields freq of dyn_ltree are set and the total of all
|
||||
* frequencies does not exceed 64K (to fit in an int on 16 bit machines).
|
||||
*/
|
||||
static void set_file_type()
|
||||
static void set_file_type(void)
|
||||
{
|
||||
int n = 0;
|
||||
unsigned ascii_freq = 0;
|
||||
@@ -2538,7 +2519,7 @@ static int file_read(char *buf, unsigned size)
|
||||
* Write the output buffer outbuf[0..outcnt-1] and update bytes_out.
|
||||
* (used for the compressed data only)
|
||||
*/
|
||||
static void flush_outbuf()
|
||||
static void flush_outbuf(void)
|
||||
{
|
||||
if (outcnt == 0)
|
||||
return;
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -17,13 +17,15 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR:= ../../
|
||||
top_srcdir=../..
|
||||
top_builddir=../..
|
||||
srcdir=$(top_srcdir)/archival/libunarchive
|
||||
LIBUNARCHIVE_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
LIBUNARCHIVE_AR:=libunarchive.a
|
||||
ifndef $(LIBUNARCHIVE_DIR)
|
||||
LIBUNARCHIVE_DIR:=$(TOPDIR)archival/libunarchive/
|
||||
LIBUNARCHIVE_DIR:=$(top_builddir)/archival/libunarchive/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/archvial/libunarchive
|
||||
|
||||
LIBUNARCHIVE-y:= \
|
||||
\
|
||||
@@ -48,14 +49,14 @@ LIBUNARCHIVE-y:= \
|
||||
open_transformer.o \
|
||||
init_handle.o
|
||||
|
||||
GUNZIP_FILES:= check_header_gzip.o unzip.o
|
||||
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
|
||||
DPKG_FILES:= \
|
||||
get_header_ar.o \
|
||||
unpack_ar_archive.o \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.o
|
||||
|
||||
LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
LIBUNARCHIVE-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
|
||||
LIBUNARCHIVE-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_DPKG) += $(DPKG_FILES)
|
||||
@@ -63,18 +64,21 @@ LIBUNARCHIVE-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
|
||||
|
||||
libraries-y+=$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR)
|
||||
|
||||
$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
|
||||
|
||||
$(LIBUNARCHIVA_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
File renamed without changes.
+1
-1
@@ -26,7 +26,7 @@ extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned
|
||||
|
||||
size = bb_full_read(archive_handle->src_fd, buf, count);
|
||||
if ((size != 0) && (size != count)) {
|
||||
bb_perror_msg_and_die("Short read, read %d of %d", size, count);
|
||||
bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count);
|
||||
}
|
||||
return(size);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+3
-3
@@ -35,9 +35,9 @@ extern void data_extract_all(archive_handle_t *archive_handle)
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
char *name = bb_xstrdup(file_header->name);
|
||||
bb_make_directory (dirname(name), 0777, FILEUTILS_RECUR);
|
||||
bb_make_directory (dirname(name), -1, FILEUTILS_RECUR);
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the file already exists */
|
||||
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
|
||||
@@ -66,7 +66,7 @@ extern void data_extract_all(archive_handle_t *archive_handle)
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle hard links seperately
|
||||
/* Handle hard links separately
|
||||
* We identified hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
|
||||
/* hard link */
|
||||
File renamed without changes.
+2
-1
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
|
||||
#include "unarchive.h"
|
||||
#include <unistd.h>
|
||||
|
||||
extern void data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
{
|
||||
bb_copyfd_size(archive_handle->src_fd, fileno(stdout), archive_handle->file_header->size);
|
||||
bb_copyfd_size(archive_handle->src_fd, STDOUT_FILENO, archive_handle->file_header->size);
|
||||
}
|
||||
File renamed without changes.
+31
-28
@@ -13,7 +13,7 @@
|
||||
/*
|
||||
Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org).
|
||||
|
||||
More efficient reading of huffman codes, a streamlined read_bunzip()
|
||||
More efficient reading of Huffman codes, a streamlined read_bunzip()
|
||||
function, and various other tweaks. In (limited) tests, approximately
|
||||
20% faster than bzcat on x86 and about 10% faster on arm.
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* Constants for huffman coding */
|
||||
/* Constants for Huffman coding */
|
||||
#define MAX_GROUPS 6
|
||||
#define GROUP_SIZE 50 /* 64 would have been more efficient */
|
||||
#define MAX_HUFCODE_BITS 20 /* Longest huffman code allowed */
|
||||
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
|
||||
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
|
||||
#define SYMBOL_RUNA 0
|
||||
#define SYMBOL_RUNB 1
|
||||
@@ -70,7 +70,7 @@
|
||||
/* Other housekeeping constants */
|
||||
#define IOBUF_SIZE 4096
|
||||
|
||||
/* This is what we know about each huffman coding group */
|
||||
/* This is what we know about each Huffman coding group */
|
||||
struct group_data {
|
||||
/* We have an extra slot at the end of limit[] for a sentinal value. */
|
||||
int limit[MAX_HUFCODE_BITS+1],base[MAX_HUFCODE_BITS],permute[MAX_SYMBOLS];
|
||||
@@ -92,7 +92,7 @@ typedef struct {
|
||||
unsigned int *dbuf, dbufSize;
|
||||
/* These things are a bit too big to go on the stack */
|
||||
unsigned char selectors[32768]; /* nSelectors=15 bits */
|
||||
struct group_data groups[MAX_GROUPS]; /* huffman coding tables */
|
||||
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
|
||||
/* For I/O error handling */
|
||||
jmp_buf jmpbuf;
|
||||
} bunzip_data;
|
||||
@@ -172,10 +172,10 @@ static int get_next_block(bunzip_data *bd)
|
||||
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
|
||||
}
|
||||
}
|
||||
/* How many different huffman coding groups does this block use? */
|
||||
/* How many different Huffman coding groups does this block use? */
|
||||
groupCount=get_bits(bd,3);
|
||||
if (groupCount<2 || groupCount>MAX_GROUPS) return RETVAL_DATA_ERROR;
|
||||
/* nSelectors: Every GROUP_SIZE many symbols we select a new huffman coding
|
||||
/* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding
|
||||
group. Read in the group selector list, which is stored as MTF encoded
|
||||
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
||||
start of the list.) */
|
||||
@@ -189,13 +189,13 @@ static int get_next_block(bunzip_data *bd)
|
||||
for(;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
mtfSymbol[0]=selectors[i]=uc;
|
||||
}
|
||||
/* Read the huffman coding tables for each group, which code for symTotal
|
||||
/* Read the Huffman coding tables for each group, which code for symTotal
|
||||
literal symbols, plus two run symbols (RUNA, RUNB) */
|
||||
symCount=symTotal+2;
|
||||
for (j=0; j<groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS],temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
/* Read huffman code lengths for each symbol. They're stored in
|
||||
/* Read Huffman code lengths for each symbol. They're stored in
|
||||
a way similar to mtf; record a starting value for the first symbol,
|
||||
and an offset from the previous value for everys symbol after that.
|
||||
(Subtracting 1 before the loop and then adding it back at the end is
|
||||
@@ -228,12 +228,12 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
/* Calculate permute[], base[], and limit[] tables from length[].
|
||||
*
|
||||
* permute[] is the lookup table for converting huffman coded symbols
|
||||
* permute[] is the lookup table for converting Huffman coded symbols
|
||||
* into decoded symbols. base[] is the amount to subtract from the
|
||||
* value of a huffman symbol of a given length when using permute[].
|
||||
* value of a Huffman symbol of a given length when using permute[].
|
||||
*
|
||||
* limit[] indicates the largest numerical value a symbol with a given
|
||||
* number of bits can have. This is how the huffman codes can vary in
|
||||
* number of bits can have. This is how the Huffman codes can vary in
|
||||
* length: each code with a value>limit[length] needs another bit.
|
||||
*/
|
||||
hufGroup=bd->groups+j;
|
||||
@@ -248,7 +248,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
pp=0;
|
||||
for(i=minLen;i<=maxLen;i++) {
|
||||
temp[i]=limit[i]=0;
|
||||
for(t=0;t<symCount;t++)
|
||||
for(t=0;t<symCount;t++)
|
||||
if(length[t]==i) hufGroup->permute[pp++] = t;
|
||||
}
|
||||
/* Count symbols coded for at each bit length */
|
||||
@@ -275,7 +275,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
base[minLen]=0;
|
||||
}
|
||||
/* We've finished reading and digesting the block header. Now read this
|
||||
block's huffman coded symbols from the file and undo the huffman coding
|
||||
block's Huffman coded symbols from the file and undo the Huffman coding
|
||||
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
|
||||
|
||||
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
||||
@@ -284,17 +284,16 @@ static int get_next_block(bunzip_data *bd)
|
||||
mtfSymbol[i]=(unsigned char)i;
|
||||
}
|
||||
/* Loop through compressed symbols. */
|
||||
runPos=dbufCount=symCount=selector=0;
|
||||
runPos=dbufCount=selector=0;
|
||||
for(;;) {
|
||||
/* Determine which huffman coding group to use. */
|
||||
if(!(symCount--)) {
|
||||
symCount=GROUP_SIZE-1;
|
||||
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup=bd->groups+selectors[selector++];
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
}
|
||||
/* Read next huffman-coded symbol. */
|
||||
/* fetch next Huffman coding group from list. */
|
||||
symCount=GROUP_SIZE-1;
|
||||
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup=bd->groups+selectors[selector++];
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
continue_this_group:
|
||||
/* Read next Huffman-coded symbol. */
|
||||
/* Note: It is far cheaper to read maxLen bits and back up than it is
|
||||
to read minLen bits and then an additional bit at a time, testing
|
||||
as we go. Because there is a trailing last block (with file CRC),
|
||||
@@ -344,7 +343,7 @@ got_huff_bits:
|
||||
context). Thus space is saved. */
|
||||
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
|
||||
runPos <<= 1;
|
||||
continue;
|
||||
goto end_of_huffman_loop;
|
||||
}
|
||||
/* When we hit the first non-run symbol after a run, we now know
|
||||
how many times to repeat the last literal, so append that many
|
||||
@@ -382,8 +381,12 @@ got_huff_bits:
|
||||
/* We have our literal byte. Save it into dbuf. */
|
||||
byteCount[uc]++;
|
||||
dbuf[dbufCount++] = (unsigned int)uc;
|
||||
/* Skip group initialization if we're not done with this group. Done this
|
||||
* way to avoid compiler warning. */
|
||||
end_of_huffman_loop:
|
||||
if(symCount--) goto continue_this_group;
|
||||
}
|
||||
/* At this point, we've read all the huffman-coded symbols (and repeated
|
||||
/* At this point, we've read all the Huffman-coded symbols (and repeated
|
||||
runs) for this block from the input stream, and decoded them into the
|
||||
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
|
||||
Now undo the Burrows-Wheeler transform on dbuf.
|
||||
@@ -439,7 +442,7 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
|
||||
/* We will always have pending decoded data to write into the output
|
||||
buffer unless this is the very first call (in which case we haven't
|
||||
huffman-decoded a block into the intermediate buffer yet). */
|
||||
Huffman-decoded a block into the intermediate buffer yet). */
|
||||
|
||||
if (bd->writeCopies) {
|
||||
/* Inside the loop, writeCopies means extra copies (beyond 1) */
|
||||
@@ -495,7 +498,7 @@ decode_next_byte:
|
||||
}
|
||||
}
|
||||
|
||||
/* Refill the intermediate buffer by huffman-decoding next block of input */
|
||||
/* Refill the intermediate buffer by Huffman-decoding next block of input */
|
||||
/* (previous is just a convenient unused temp variable here) */
|
||||
previous=get_next_block(bd);
|
||||
if(previous) {
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
/* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
*
|
||||
* based on the original compress42.c source
|
||||
* based on the original compress42.c source
|
||||
* (see disclaimer below)
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Defailt input buffer size */
|
||||
/* Default input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
|
||||
/* Default output buffer size */
|
||||
+22
-19
@@ -12,8 +12,8 @@
|
||||
* command line handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@optushome.com.au>
|
||||
*
|
||||
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* read_gz interface + associated hacking by Laurence Anderson
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -148,10 +148,13 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current
|
||||
{
|
||||
while (*current < required) {
|
||||
if (bytebuffer_offset >= bytebuffer_size) {
|
||||
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
|
||||
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
|
||||
* to the front of the bytebuffer, leave 4 bytes free at end of tail
|
||||
* so we can easily top up buffer in check_trailer_gzip() */
|
||||
bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8);
|
||||
if (!(bytebuffer_size = bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8))) {
|
||||
bb_error_msg_and_die("unexpected end of file");
|
||||
}
|
||||
bytebuffer_size += 4;
|
||||
bytebuffer_offset = 4;
|
||||
}
|
||||
bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current;
|
||||
@@ -193,7 +196,7 @@ static void make_gunzip_crc_table(void)
|
||||
/*
|
||||
* Free the malloc'ed tables built by huft_build(), which makes a linked
|
||||
* list of the tables it made, with the links in a dummy first entry of
|
||||
* each table.
|
||||
* each table.
|
||||
* t: table to free
|
||||
*/
|
||||
static int huft_free(huft_t * t)
|
||||
@@ -435,9 +438,9 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b
|
||||
md = mask_bits[bd];
|
||||
return 0; // Don't actually do anything the first time
|
||||
}
|
||||
|
||||
|
||||
if (resumeCopy) goto do_copy;
|
||||
|
||||
|
||||
while (1) { /* do until end of block */
|
||||
b = fill_bitbuffer(b, &k, bl);
|
||||
if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
|
||||
@@ -533,7 +536,7 @@ do_copy: do {
|
||||
/* free the decoding tables, return */
|
||||
huft_free(tl);
|
||||
huft_free(td);
|
||||
|
||||
|
||||
/* done */
|
||||
return 0;
|
||||
}
|
||||
@@ -548,7 +551,7 @@ static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup)
|
||||
w = gunzip_outbuf_count; /* initialize gunzip_window position */
|
||||
return 0; // Don't do anything first time
|
||||
}
|
||||
|
||||
|
||||
/* read and output the compressed data */
|
||||
while (n--) {
|
||||
b_stored = fill_bitbuffer(b_stored, &k_stored, 8);
|
||||
@@ -639,7 +642,7 @@ static int inflate_block(int *e)
|
||||
inflate_stored(n, b_stored, k_stored, 1); // Setup inflate_stored
|
||||
return -1;
|
||||
}
|
||||
case 1: /* Inflate fixed
|
||||
case 1: /* Inflate fixed
|
||||
* decompress an inflated type 1 (fixed Huffman codes) block. We should
|
||||
* either replace this with a custom decoder, or at least precompute the
|
||||
* Huffman tables.
|
||||
@@ -682,9 +685,9 @@ static int inflate_block(int *e)
|
||||
|
||||
/* decompress until an end-of-block code */
|
||||
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
|
||||
|
||||
|
||||
/* huft_free code moved into inflate_codes */
|
||||
|
||||
|
||||
return -2;
|
||||
}
|
||||
case 2: /* Inflate dynamic */
|
||||
@@ -836,7 +839,7 @@ static int inflate_block(int *e)
|
||||
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
|
||||
|
||||
/* huft_free code moved into inflate_codes */
|
||||
|
||||
|
||||
return -2;
|
||||
}
|
||||
default:
|
||||
@@ -859,12 +862,12 @@ static int inflate_get_next_window(void)
|
||||
static int method = -1; // Method == -1 for stored, -2 for codes
|
||||
static int e = 0;
|
||||
static int needAnotherBlock = 1;
|
||||
|
||||
|
||||
gunzip_outbuf_count = 0;
|
||||
|
||||
while(1) {
|
||||
int ret;
|
||||
|
||||
|
||||
if (needAnotherBlock) {
|
||||
if(e) {
|
||||
calculate_gunzip_crc();
|
||||
@@ -875,7 +878,7 @@ static int inflate_get_next_window(void)
|
||||
method = inflate_block(&e);
|
||||
needAnotherBlock = 0;
|
||||
}
|
||||
|
||||
|
||||
switch (method) {
|
||||
case -1: ret = inflate_stored(0,0,0,0);
|
||||
break;
|
||||
@@ -892,7 +895,7 @@ static int inflate_get_next_window(void)
|
||||
/* Doesnt get here */
|
||||
}
|
||||
|
||||
/* Initialise bytebuffer, be carefull not to overfill the buffer */
|
||||
/* Initialise bytebuffer, be careful not to overfill the buffer */
|
||||
extern void inflate_init(unsigned int bufsize)
|
||||
{
|
||||
/* Set the bytebuffer size, default is same as gunzip_wsize */
|
||||
@@ -920,7 +923,7 @@ extern int inflate_unzip(int in, int out)
|
||||
make_gunzip_crc_table();
|
||||
|
||||
/* Allocate space for buffer */
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
|
||||
while(1) {
|
||||
int ret = inflate_get_next_window();
|
||||
@@ -977,6 +980,6 @@ extern int inflate_gunzip(int in, int out)
|
||||
(bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
|
||||
bb_error_msg("Incorrect length");
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -26,7 +26,7 @@
|
||||
/*
|
||||
* Reassign the subarchive metadata parser based on the filename extension
|
||||
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
|
||||
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
||||
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
||||
*/
|
||||
extern char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
{
|
||||
File renamed without changes.
File renamed without changes.
+4
-2
@@ -47,7 +47,9 @@ extern char get_header_ar(archive_handle_t *archive_handle)
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Some ar entries have a trailing '\n' after the previous data entry */
|
||||
/* ar header starts on an even byte (2 byte aligned)
|
||||
* '\n' is used for padding
|
||||
*/
|
||||
if (ar.raw[0] == '\n') {
|
||||
/* fix up the header, we started reading 1 byte too early */
|
||||
memmove(ar.raw, &ar.raw[1], 59);
|
||||
@@ -113,7 +115,7 @@ extern char get_header_ar(archive_handle_t *archive_handle)
|
||||
archive_handle->action_data(archive_handle);
|
||||
}
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
|
||||
archive_handle->offset += typed->size;
|
||||
+10
-4
@@ -18,6 +18,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sysmacros.h> /* major() and minor() */
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -36,7 +37,7 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
|
||||
int namesize;
|
||||
char dummy[16];
|
||||
int major, minor, nlink, inode;
|
||||
|
||||
|
||||
if (pending_hardlinks) { /* Deal with any pending hardlinks */
|
||||
hardlinks_t *tmp;
|
||||
hardlinks_t *oldtmp;
|
||||
@@ -77,7 +78,7 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
|
||||
{
|
||||
unsigned long tmpsize;
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&file_header->mode,
|
||||
dummy, &inode, (unsigned int*)&file_header->mode,
|
||||
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
|
||||
&nlink, &file_header->mtime, &tmpsize,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
@@ -117,6 +118,8 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
|
||||
file_header->link_name[file_header->size] = '\0';
|
||||
archive_handle->offset += file_header->size;
|
||||
file_header->size = 0; /* Stop possible seeks in future */
|
||||
} else {
|
||||
file_header->link_name = NULL;
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
|
||||
if (file_header->size == 0) { /* Put file on a linked list for later */
|
||||
@@ -141,15 +144,18 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
|
||||
}
|
||||
}
|
||||
}
|
||||
file_header->device = (major << 8) | minor;
|
||||
file_header->device = makedev(major, minor);
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_name);
|
||||
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
+15
-5
@@ -14,7 +14,7 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* FIXME:
|
||||
* In privelidged mode if uname and gname map to a uid amd gid then use the
|
||||
* In privileged mode if uname and gname map to a uid and gid then use the
|
||||
* mapped value instead of the uid/gid values in tar header
|
||||
*
|
||||
* References:
|
||||
@@ -62,6 +62,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
|
||||
} tar;
|
||||
long sum = 0;
|
||||
long i;
|
||||
static int end = 0;
|
||||
|
||||
/* Align header */
|
||||
data_align(archive_handle, 512);
|
||||
@@ -74,8 +75,17 @@ extern char get_header_tar(archive_handle_t *archive_handle)
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.formated.name[0] == 0) {
|
||||
if (end) {
|
||||
/* This is the second consecutive empty header! End of archive!
|
||||
* Read until the end to empty the pipe from gz or bz2
|
||||
*/
|
||||
while (bb_full_read(archive_handle->src_fd, tar.raw, 512) == 512);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
end = 1;
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
end = 0;
|
||||
|
||||
/* Check header has valid magic, "ustar" is for the proper tar
|
||||
* 0's are for the old tar format
|
||||
@@ -119,10 +129,10 @@ extern char get_header_tar(archive_handle_t *archive_handle)
|
||||
file_header->gid = strtol(tar.formated.gid, NULL, 8);
|
||||
file_header->size = strtol(tar.formated.size, NULL, 8);
|
||||
file_header->mtime = strtol(tar.formated.mtime, NULL, 8);
|
||||
file_header->link_name = (tar.formated.linkname[0] != '\0') ?
|
||||
file_header->link_name = (tar.formated.linkname[0] != '\0') ?
|
||||
bb_xstrdup(tar.formated.linkname) : NULL;
|
||||
file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) +
|
||||
strtol(tar.formated.devminor, NULL, 8));
|
||||
file_header->device = makedev(strtol(tar.formated.devmajor, NULL, 8),
|
||||
strtol(tar.formated.devminor, NULL, 8));
|
||||
|
||||
/* Set bits 0-11 of the files mode */
|
||||
file_header->mode = 07777 & strtol(tar.formated.mode, NULL, 8);
|
||||
@@ -205,7 +215,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->passed = llist_add_to(archive_handle->passed, file_header->name);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -204,12 +204,12 @@ void extract_cpio_gz(int fd) {
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
archive_handle->src_fd = fd;
|
||||
archive_handle->offset = 0;
|
||||
|
||||
|
||||
bb_xread_all(archive_handle->src_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
chdir("/"); // Install RPM's to root
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
|
||||
@@ -73,7 +73,7 @@ extern int rpm2cpio_main(int argc, char **argv)
|
||||
unsigned char magic[2];
|
||||
|
||||
if (argc == 1) {
|
||||
rpm_fd = fileno(stdin);
|
||||
rpm_fd = STDIN_FILENO;
|
||||
} else {
|
||||
rpm_fd = bb_xopen(argv[1], O_RDONLY);
|
||||
}
|
||||
@@ -89,14 +89,14 @@ extern int rpm2cpio_main(int argc, char **argv)
|
||||
|
||||
/* Skip the main header */
|
||||
skip_header(rpm_fd);
|
||||
|
||||
|
||||
bb_xread_all(rpm_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip(rpm_fd);
|
||||
if (inflate_gunzip(rpm_fd, fileno(stdout)) != 0) {
|
||||
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) {
|
||||
bb_error_msg("Error inflating");
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini tar implementation for busybox
|
||||
* Mini tar implementation for busybox
|
||||
*
|
||||
* Modifed to use common extraction code used by ar, cpio, dpkg-deb, dpkg
|
||||
* Glenn McGrath <bug1@optushome.com.au>
|
||||
* Modified to use common extraction code used by ar, cpio, dpkg-deb, dpkg
|
||||
* Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* Note, that as of BusyBox-0.43, tar has been completely rewritten from the
|
||||
* ground up. It still has remnents of the old code lying about, but it is
|
||||
* ground up. It still has remnants of the old code lying about, but it is
|
||||
* very different now (i.e., cleaner, less global variables, etc.)
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* Based in part in the tar implementation in sash
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysmacros.h> /* major() and minor() */
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
@@ -58,11 +59,6 @@
|
||||
# define TAR_MAGIC "ustar" /* ustar and a null */
|
||||
# define TAR_VERSION " " /* Be compatable with GNU tar format */
|
||||
|
||||
# ifndef MAJOR
|
||||
# define MAJOR(dev) (((dev)>>8)&0xff)
|
||||
# define MINOR(dev) ((dev)&0xff)
|
||||
# endif
|
||||
|
||||
static const int TAR_BLOCK_SIZE = 512;
|
||||
static const int TAR_MAGIC_LEN = 6;
|
||||
static const int TAR_VERSION_LEN = 2;
|
||||
@@ -111,7 +107,7 @@ struct TarBallInfo {
|
||||
for the tarball */
|
||||
struct stat statBuf; /* Stat info for the tarball, letting
|
||||
us know the inode and device that the
|
||||
tarball lives, so we can avoid trying
|
||||
tarball lives, so we can avoid trying
|
||||
to include the tarball into itself */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
const llist_t *excludeList; /* List of files to not include */
|
||||
@@ -238,9 +234,9 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
TAR_MAGIC_LEN + TAR_VERSION_LEN);
|
||||
|
||||
/* Enter the user and group names (default to root if it fails) */
|
||||
if (my_getpwuid(header.uname, statbuf->st_uid) == NULL)
|
||||
if (my_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL)
|
||||
strcpy(header.uname, "root");
|
||||
if (my_getgrgid(header.gname, statbuf->st_gid) == NULL)
|
||||
if (my_getgrgid(header.gname, statbuf->st_gid, sizeof(header.gname)) == NULL)
|
||||
strcpy(header.gname, "root");
|
||||
|
||||
if (tbInfo->hlInfo) {
|
||||
@@ -262,15 +258,15 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
} else if (S_ISCHR(statbuf->st_mode)) {
|
||||
header.typeflag = CHRTYPE;
|
||||
putOctal(header.devmajor, sizeof(header.devmajor),
|
||||
MAJOR(statbuf->st_rdev));
|
||||
major(statbuf->st_rdev));
|
||||
putOctal(header.devminor, sizeof(header.devminor),
|
||||
MINOR(statbuf->st_rdev));
|
||||
minor(statbuf->st_rdev));
|
||||
} else if (S_ISBLK(statbuf->st_mode)) {
|
||||
header.typeflag = BLKTYPE;
|
||||
putOctal(header.devmajor, sizeof(header.devmajor),
|
||||
MAJOR(statbuf->st_rdev));
|
||||
major(statbuf->st_rdev));
|
||||
putOctal(header.devminor, sizeof(header.devminor),
|
||||
MINOR(statbuf->st_rdev));
|
||||
minor(statbuf->st_rdev));
|
||||
} else if (S_ISFIFO(statbuf->st_mode)) {
|
||||
header.typeflag = FIFOTYPE;
|
||||
} else if (S_ISREG(statbuf->st_mode)) {
|
||||
@@ -308,7 +304,7 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
if (tbInfo->verboseFlag) {
|
||||
FILE *vbFd = stdout;
|
||||
|
||||
if (tbInfo->tarFd == fileno(stdout)) /* If the archive goes to stdout, verbose to stderr */
|
||||
if (tbInfo->tarFd == STDOUT_FILENO) /* If the archive goes to stdout, verbose to stderr */
|
||||
vbFd = stderr;
|
||||
|
||||
fprintf(vbFd, "%s\n", header.name);
|
||||
@@ -470,15 +466,15 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
(void) &include;
|
||||
(void) &errorFlag;
|
||||
# endif
|
||||
|
||||
|
||||
gzipPid = vfork();
|
||||
|
||||
if (gzipPid == 0) {
|
||||
dup2(gzipDataPipe[0], 0);
|
||||
close(gzipDataPipe[1]);
|
||||
|
||||
if (tbInfo.tarFd != 1);
|
||||
dup2(tbInfo.tarFd, 1);
|
||||
if (tbInfo.tarFd != 1)
|
||||
dup2(tbInfo.tarFd, 1);
|
||||
|
||||
close(gzipStatusPipe[0]);
|
||||
fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows sucess */
|
||||
@@ -616,7 +612,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_BZIP2
|
||||
# define TAR_OPT_BZIP2 (1 << (8 + TAR_OPT_FLAG_CREATE))
|
||||
# define TAR_OPT_BZIP2 (1 << (8 + TAR_OPT_FLAG_CREATE))
|
||||
# define TAR_OPT_STR_BZIP2 "j"
|
||||
# define TAR_OPT_FLAG_BZIP2 1
|
||||
#else
|
||||
@@ -625,7 +621,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_FROM
|
||||
# define TAR_OPT_FROM_FILE (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2))
|
||||
# define TAR_OPT_INCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2))
|
||||
# define TAR_OPT_EXCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + 1))
|
||||
# define TAR_OPT_STR_FROM "T:X:"
|
||||
# define TAR_OPT_FLAG_FROM 2
|
||||
@@ -646,7 +642,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
#ifdef CONFIG_FEATURE_TAR_COMPRESS
|
||||
# define TAR_OPT_UNCOMPRESS (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + TAR_OPT_FLAG_FROM + TAR_OPT_FLAG_GZIP))
|
||||
# define TAR_OPT_STR_COMPRESS "Z"
|
||||
#else
|
||||
#else
|
||||
# define TAR_OPT_STR_COMPRESS ""
|
||||
#endif
|
||||
|
||||
@@ -675,7 +671,7 @@ static const struct option tar_long_options[] = {
|
||||
{ "bzip2", 0, NULL, 'j' },
|
||||
# endif
|
||||
# ifdef CONFIG_FEATURE_TAR_FROM
|
||||
{ "from-file", 1, NULL, 'T' },
|
||||
{ "files-from", 1, NULL, 'T' },
|
||||
{ "exclude-from", 1, NULL, 'X' },
|
||||
# endif
|
||||
# ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
@@ -722,13 +718,13 @@ int tar_main(int argc, char **argv)
|
||||
&base_dir, /* Change to dir <optarg> */
|
||||
&tar_filename /* archive filename */
|
||||
#ifdef CONFIG_FEATURE_TAR_FROM
|
||||
, NULL,
|
||||
, &(tar_handle->accept),
|
||||
&(tar_handle->reject)
|
||||
#endif
|
||||
);
|
||||
|
||||
/* Check one and only one context option was given */
|
||||
if(opt & 0x80000000UL) {
|
||||
if(opt & BB_GETOPT_ERROR) {
|
||||
bb_show_usage();
|
||||
}
|
||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||
@@ -740,7 +736,7 @@ int tar_main(int argc, char **argv)
|
||||
bb_show_usage();
|
||||
}
|
||||
if(ctx_flag & CTX_TEST) {
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
(tar_handle->action_header == header_verbose_list)) {
|
||||
tar_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
@@ -756,8 +752,8 @@ int tar_main(int argc, char **argv)
|
||||
tar_handle->action_data = data_extract_to_stdout;
|
||||
}
|
||||
if(opt & TAR_OPT_VERBOSE) {
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
(tar_handle->action_header == header_verbose_list))
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
(tar_handle->action_header == header_verbose_list))
|
||||
{
|
||||
tar_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
@@ -787,6 +783,9 @@ int tar_main(int argc, char **argv)
|
||||
if(opt & TAR_OPT_EXCLUDE_FROM) {
|
||||
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
|
||||
}
|
||||
if(opt & TAR_OPT_INCLUDE_FROM) {
|
||||
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check if we are reading from stdin */
|
||||
@@ -796,7 +795,7 @@ int tar_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Setup an array of filenames to work with */
|
||||
/* TODO: This is the same as in ar, seperate function ? */
|
||||
/* TODO: This is the same as in ar, separate function ? */
|
||||
while (optind < argc) {
|
||||
char *filename_ptr = last_char_is(argv[optind], '/');
|
||||
if (filename_ptr) {
|
||||
@@ -860,13 +859,13 @@ int tar_main(int argc, char **argv)
|
||||
}
|
||||
# endif /* CONFIG_FEATURE_TAR_BZIP2 */
|
||||
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
(tar_handle->action_header == header_verbose_list)) {
|
||||
verboseFlag = TRUE;
|
||||
}
|
||||
writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERNCE, tar_handle->accept,
|
||||
tar_handle->reject, gzipFlag);
|
||||
} else
|
||||
} else
|
||||
#endif /* CONFIG_FEATURE_TAR_CREATE */
|
||||
{
|
||||
while (get_header_ptr(tar_handle) == EXIT_SUCCESS);
|
||||
@@ -883,7 +882,7 @@ int tar_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||
if (tar_handle->src_fd != fileno(stdin)) {
|
||||
if (tar_handle->src_fd != STDIN_FILENO) {
|
||||
close(tar_handle->src_fd);
|
||||
}
|
||||
#endif /* CONFIG_FEATURE_CLEAN_UP */
|
||||
@@ -46,7 +46,7 @@ extern int uncompress_main(int argc, char **argv)
|
||||
int dst_fd;
|
||||
|
||||
if (strcmp(compressed_file, "-") == 0) {
|
||||
src_fd = fileno(stdin);
|
||||
src_fd = STDIN_FILENO;
|
||||
flags |= GUNZIP_TO_STDOUT;
|
||||
} else {
|
||||
src_fd = bb_xopen(compressed_file, O_RDONLY);
|
||||
@@ -60,7 +60,7 @@ extern int uncompress_main(int argc, char **argv)
|
||||
|
||||
/* Set output filename and number */
|
||||
if (flags & GUNZIP_TO_STDOUT) {
|
||||
dst_fd = fileno(stdout);
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
struct stat stat_buf;
|
||||
char *extension;
|
||||
@@ -96,10 +96,10 @@ extern int uncompress_main(int argc, char **argv)
|
||||
delete_path = uncompressed_file;
|
||||
}
|
||||
|
||||
if (dst_fd != fileno(stdout)) {
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != fileno(stdin)) {
|
||||
if (src_fd != STDIN_FILENO) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* For reference to format see http://www.pkware.com/support/appnote.html */
|
||||
/* For reference see
|
||||
* http://www.pkware.com/products/enterprise/white_papers/appnote.txt
|
||||
* http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip
|
||||
*/
|
||||
|
||||
/* TODO Endian issues, exclude, should we accept input from stdin ? */
|
||||
|
||||
@@ -135,7 +138,7 @@ extern int unzip_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (*argv[optind] == '-') {
|
||||
archive_handle->src_fd = fileno(stdin);
|
||||
archive_handle->src_fd = STDIN_FILENO;
|
||||
archive_handle->seek = seek_by_char;
|
||||
} else {
|
||||
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -17,13 +17,15 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR:= ../
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
srcdir=$(top_srcdir)/console/tools
|
||||
CONSOLETOOLS_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
CONSOLETOOLS_AR:=console-tools.a
|
||||
ifndef $(CONSOLETOOLS_DIR)
|
||||
CONSOLETOOLS_DIR:=$(TOPDIR)console-tools/
|
||||
CONSOLETOOLS_DIR:=$(top_builddir)/console-tools/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/console-tools
|
||||
|
||||
CONSOLETOOLS_DIR-y:=
|
||||
CONSOLETOOLS_DIR-$(CONFIG_CHVT) += chvt.o
|
||||
@@ -36,5 +37,8 @@ CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
|
||||
|
||||
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
|
||||
|
||||
$(CONSOLETOOLS_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini chvt implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -3,13 +3,13 @@
|
||||
* Disallocate virtual terminal(s)
|
||||
*
|
||||
* Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@@ -35,11 +35,11 @@ struct kbentry {
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
|
||||
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
{
|
||||
@@ -47,28 +47,21 @@ int dumpkmap_main(int argc, char **argv)
|
||||
int i, j, fd;
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
if (argc >= 2 && *argv[1] == '-')
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd=bb_xopen(CURRENT_VC, O_RDWR);
|
||||
fd = bb_xopen(CURRENT_VC, O_RDWR);
|
||||
|
||||
write(1, magic, 7);
|
||||
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
|
||||
flags[0]=1;
|
||||
flags[1]=1;
|
||||
flags[2]=1;
|
||||
flags[4]=1;
|
||||
flags[5]=1;
|
||||
flags[6]=1;
|
||||
flags[8]=1;
|
||||
flags[9]=1;
|
||||
flags[10]=1;
|
||||
flags[12]=1;
|
||||
|
||||
/* Here we want to set everything to 0 except for indexes:
|
||||
* [0-2] [4-6] [8-10] [12] */
|
||||
memset(flags, 0x00, MAX_NR_KEYMAPS);
|
||||
memset(flags, 0x01, 13);
|
||||
flags[3] = flags[7] = flags[11] = 0;
|
||||
|
||||
/* dump flags */
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
|
||||
write(1, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
@@ -76,13 +69,13 @@ int dumpkmap_main(int argc, char **argv)
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
bb_error_msg("ioctl returned: %m, %s, %s, %xqq", (char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
}
|
||||
else {
|
||||
write(1,(void*)&ke.kb_value,2);
|
||||
}
|
||||
|
||||
bb_perror_msg("ioctl failed with %s, %s, %p",
|
||||
(char *)&ke.kb_index,
|
||||
(char *)&ke.kb_table,
|
||||
&ke.kb_value);
|
||||
} else {
|
||||
write(1, (void*)&ke.kb_value, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -75,7 +75,7 @@ int loadkmap_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't bother to close files. Exit does that
|
||||
/* Don't bother to close files. Exit does that
|
||||
* automagically, so we can save a few bytes */
|
||||
/* close(fd); */
|
||||
return EXIT_SUCCESS;
|
||||
@@ -56,7 +56,7 @@ int openvt_main(int argc, char **argv)
|
||||
if (setsid() < 0) {
|
||||
#endif
|
||||
|
||||
bb_perror_msg_and_die("Unable to set new session");
|
||||
bb_perror_msg_and_die("Unable to set new session");
|
||||
}
|
||||
close(0); /* so that new vt becomes stdin */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -35,7 +35,7 @@ struct kbkeycode {
|
||||
};
|
||||
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
|
||||
|
||||
extern int
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
{
|
||||
char *ep;
|
||||
@@ -45,7 +45,7 @@ setkeycodes_main(int argc, char** argv)
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
|
||||
fd = get_console_fd();
|
||||
|
||||
while (argc > 2) {
|
||||
@@ -10,7 +10,7 @@ config CONFIG_BASENAME
|
||||
default n
|
||||
help
|
||||
basename is used to strip the directory and suffix from filenames,
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
to enable the 'basename' utility.
|
||||
|
||||
config CONFIG_CAL
|
||||
@@ -101,7 +101,7 @@ config CONFIG_DD
|
||||
help
|
||||
dd copies a file (from standard input to standard output,
|
||||
by default) using specific input and output blocksizes,
|
||||
while optionally performing conversions on it.
|
||||
while optionally performing conversions on it.
|
||||
|
||||
config CONFIG_DF
|
||||
bool "df"
|
||||
@@ -144,7 +144,7 @@ config CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
Use a blocksize of (1K) instead of the default 512b.
|
||||
|
||||
config CONFIG_ECHO
|
||||
bool "echo (basic SUSv3 version taking no options"
|
||||
bool "echo (basic SUSv3 version taking no options)"
|
||||
default n
|
||||
help
|
||||
echo is used to print a specified string to stdout.
|
||||
@@ -154,7 +154,7 @@ config CONFIG_FEATURE_FANCY_ECHO
|
||||
default y
|
||||
depends on CONFIG_ECHO
|
||||
help
|
||||
This adds options (-n and -e) to echo.
|
||||
This adds options (-n and -e) to echo.
|
||||
|
||||
config CONFIG_ENV
|
||||
bool "env"
|
||||
@@ -455,6 +455,13 @@ if !CONFIG_ASH && !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
|
||||
and bash) have test builtin.
|
||||
endif
|
||||
|
||||
config CONFIG_FEATURE_TEST_64
|
||||
bool " Extend test to 64 bit"
|
||||
default n
|
||||
depends on CONFIG_TEST
|
||||
help
|
||||
Enable 64-bit support in test.
|
||||
|
||||
config CONFIG_TOUCH
|
||||
bool "touch"
|
||||
default n
|
||||
@@ -538,6 +545,7 @@ config CONFIG_WC
|
||||
config CONFIG_WHO
|
||||
bool "who"
|
||||
default n
|
||||
select CONFIG_FEATURE_UTMP
|
||||
help
|
||||
who is used to show who is logged on.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -17,13 +17,15 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR:= ../
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
srcdir=$(top_srcdir)/coreutils
|
||||
SHELLUTILS_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
COREUTILS_AR:=coreutils.a
|
||||
ifndef $(COREUTILS_DIR)
|
||||
COREUTILS_DIR:=$(TOPDIR)coreutils/
|
||||
COREUTILS_DIR:=$(top_builddir)/coreutils/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/coreutils
|
||||
|
||||
COREUTILS-y:=
|
||||
COREUTILS-$(CONFIG_BASENAME) += basename.o
|
||||
@@ -90,4 +91,8 @@ COREUTILS-$(CONFIG_YES) += yes.o
|
||||
libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
|
||||
|
||||
$(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
|
||||
$(COREUTILS_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -65,7 +65,7 @@ static const char sep1752[] = {
|
||||
|
||||
static int julian;
|
||||
|
||||
/* leap year -- account for gregorian reformation in 1752 */
|
||||
/* leap year -- account for Gregorian reformation in 1752 */
|
||||
#define leap_year(yr) \
|
||||
((yr) <= 1752 ? !((yr) % 4) : \
|
||||
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
|
||||
@@ -161,7 +161,7 @@ int cal_main(int argc, char **argv)
|
||||
int row, len, days[MAXDAYS];
|
||||
int *dp = days;
|
||||
char lineout[30];
|
||||
|
||||
|
||||
day_array(month, year, dp);
|
||||
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
|
||||
bb_printf("%*s%s\n%s\n",
|
||||
@@ -176,7 +176,7 @@ int cal_main(int argc, char **argv)
|
||||
int row, which_cal, week_len, days[12][MAXDAYS];
|
||||
int *dp;
|
||||
char lineout[80];
|
||||
|
||||
|
||||
sprintf(lineout, "%d", year);
|
||||
center(lineout,
|
||||
(WEEK_LEN * 3 + HEAD_SEP * 2)
|
||||
@@ -317,7 +317,7 @@ static void blank_string(char *buf, size_t buflen)
|
||||
static char *build_row(char *p, int *dp)
|
||||
{
|
||||
int col, val, day;
|
||||
|
||||
|
||||
memset(p, ' ', (julian + DAY_LEN) * 7);
|
||||
|
||||
col = 0;
|
||||
File renamed without changes.
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini chgrp implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -63,7 +63,7 @@ int chgrp_main(int argc, char **argv)
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
do {
|
||||
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
|
||||
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, &gid)) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini chmod implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* Reworked by (C) 2002 Vladimir Oleynik <dzo@simtreas.ru>
|
||||
* to correctly parse '-rwxgoa'
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini chown implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -84,10 +84,10 @@ int chown_main(int argc, char **argv)
|
||||
uid = get_ug_id(*argv, my_getpwnam);
|
||||
|
||||
++argv;
|
||||
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
do {
|
||||
if (! recursive_action (*argv, (flags & FLAG_R), FALSE, FALSE,
|
||||
if (! recursive_action (*argv, (flags & FLAG_R), FALSE, FALSE,
|
||||
fileAction, fileAction, NULL)) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -27,7 +27,7 @@
|
||||
*
|
||||
* Original version majorly reworked for SUSv3 compliance, bug fixes, and
|
||||
* size optimizations. Changes include:
|
||||
* 1) Now correctly distingusishes between errors and actual file differences.
|
||||
* 1) Now correctly distinguishes between errors and actual file differences.
|
||||
* 2) Proper handling of '-' args.
|
||||
* 3) Actual error checking of i/o.
|
||||
* 4) Accept SUSv3 -l option. Note that we use the slightly nicer gnu format
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
/* WARNING!! ORDER IS IMPORTANT!! */
|
||||
static const char cp_opts[] = "pdRfiar";
|
||||
static const char cp_opts[] = "pdRfiarP";
|
||||
|
||||
extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
@@ -73,6 +73,12 @@ extern int cp_main(int argc, char **argv)
|
||||
*/
|
||||
flags |= FILEUTILS_RECUR;
|
||||
}
|
||||
if (flags & 128) {
|
||||
/* Make -P a synonym for -d,
|
||||
* -d is the GNU option while -P is the POSIX 2003 option
|
||||
*/
|
||||
flags |= FILEUTILS_DEREFERENCE;
|
||||
}
|
||||
|
||||
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
* Written by Mark Whitley <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -69,8 +69,8 @@ static int cmpfunc(const void *a, const void *b)
|
||||
|
||||
/*
|
||||
* parse_lists() - parses a list and puts values into startpos and endpos.
|
||||
* valid list formats: N, N-, N-M, -M
|
||||
* more than one list can be seperated by commas
|
||||
* valid list formats: N, N-, N-M, -M
|
||||
* more than one list can be separated by commas
|
||||
*/
|
||||
static void parse_lists(char *lists)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ static void parse_lists(char *lists)
|
||||
char *junk;
|
||||
int s = 0, e = 0;
|
||||
|
||||
/* take apart the lists, one by one (they are seperated with commas */
|
||||
/* take apart the lists, one by one (they are separated with commas */
|
||||
while ((ltok = strsep(&lists, ",")) != NULL) {
|
||||
|
||||
/* it's actually legal to pass an empty list */
|
||||
@@ -96,7 +96,7 @@ static void parse_lists(char *lists)
|
||||
s = strtoul(ntok, &junk, 10);
|
||||
if(*junk != '\0' || s < 0)
|
||||
bb_error_msg_and_die("invalid byte or field list");
|
||||
|
||||
|
||||
/* account for the fact that arrays are zero based, while the user
|
||||
* expects the first char on the line to be char # 1 */
|
||||
if (s != 0)
|
||||
@@ -125,7 +125,7 @@ static void parse_lists(char *lists)
|
||||
/* if there's something left to tokenize, the user past an invalid list */
|
||||
if (ltok)
|
||||
bb_error_msg_and_die("invalid byte or field list");
|
||||
|
||||
|
||||
/* add the new list */
|
||||
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
|
||||
cut_lists[nlists-1].startpos = s;
|
||||
@@ -227,7 +227,7 @@ static void cut_file_by_lines(const char *line, unsigned int linenum)
|
||||
{
|
||||
static int c = 0;
|
||||
static int l = -1;
|
||||
|
||||
|
||||
/* I can't initialize this above cuz the "initializer isn't
|
||||
* constant" *sigh* */
|
||||
if (l == -1)
|
||||
@@ -300,7 +300,7 @@ extern int cut_main(int argc, char **argv)
|
||||
part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS);
|
||||
if(part == 0)
|
||||
bb_error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
if(opt & 0x80000000UL)
|
||||
if(opt & BB_GETOPT_ERROR)
|
||||
bb_error_msg_and_die("only one type of list may be specified");
|
||||
parse_lists(sopt);
|
||||
if((opt & (OPT_DELIM_FLGS))) {
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini date implementation for busybox
|
||||
*
|
||||
* by Matthew Grant <grantma@anathoth.gen.nz>
|
||||
*
|
||||
*
|
||||
* iso-format handling added by Robert Griebl <griebl@gmx.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
all the GNU strftime stuff (its in libc, lets use it),
|
||||
setting time using UTC and displaying int, as well as
|
||||
an RFC 822 complient date output for shell scripting
|
||||
@@ -42,11 +42,12 @@
|
||||
/* Input parsing code is always bulky - used heavy duty libc stuff as
|
||||
much as possible, missed out a lot of bounds checking */
|
||||
|
||||
/* Default input handling to save suprising some people */
|
||||
/* Default input handling to save surprising some people */
|
||||
|
||||
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
int nr;
|
||||
char *cp;
|
||||
|
||||
nr = sscanf(t_string, "%2d%2d%2d%2d%d", &(tm_time->tm_mon),
|
||||
&(tm_time->tm_mday), &(tm_time->tm_hour), &(tm_time->tm_min),
|
||||
@@ -56,6 +57,14 @@ static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, t_string);
|
||||
}
|
||||
|
||||
cp = strchr(t_string, '.');
|
||||
if (cp) {
|
||||
nr = sscanf(cp + 1, "%2d", &(tm_time->tm_sec));
|
||||
if (nr != 1) {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, t_string);
|
||||
}
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time->tm_year >= 1900) {
|
||||
tm_time->tm_year -= 1900;
|
||||
@@ -127,7 +136,6 @@ int date_main(int argc, char **argv)
|
||||
{
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int set_time;
|
||||
int utc;
|
||||
int use_arg = 0;
|
||||
@@ -157,7 +165,7 @@ int date_main(int argc, char **argv)
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
}
|
||||
use_arg = opt & DATE_OPT_DATE;
|
||||
if(opt & 0x80000000UL)
|
||||
if(opt & BB_GETOPT_ERROR)
|
||||
bb_show_usage();
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
if(opt & DATE_OPT_TIMESPEC) {
|
||||
@@ -253,10 +261,10 @@ int date_main(int argc, char **argv)
|
||||
case 0:
|
||||
default:
|
||||
#endif
|
||||
date_fmt =
|
||||
(opt & DATE_OPT_RFC2822
|
||||
? (utc ? "%a, %e %b %Y %H:%M:%S GMT" :
|
||||
"%a, %e %b %Y %H:%M:%S %z") : "%a %b %e %H:%M:%S %Z %Y");
|
||||
date_fmt = (opt & DATE_OPT_RFC2822 ?
|
||||
(utc ? "%a, %d %b %Y %H:%M:%S GMT" :
|
||||
"%a, %d %b %Y %H:%M:%S %z") :
|
||||
"%a %b %e %H:%M:%S %Z %Y");
|
||||
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
break;
|
||||
@@ -274,10 +282,13 @@ int date_main(int argc, char **argv)
|
||||
date_fmt = "%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
|
||||
/* Print OUTPUT (after ALL that!) */
|
||||
t_buff = xmalloc(201);
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
puts(t_buff);
|
||||
{
|
||||
/* Print OUTPUT (after ALL that!) */
|
||||
RESERVE_CONFIG_BUFFER(t_buff, 201);
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
puts(t_buff);
|
||||
RELEASE_CONFIG_BUFFER(t_buff);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
File renamed without changes.
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.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
|
||||
@@ -27,7 +27,7 @@
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Size reduction. Removed floating point dependency. Added error checking
|
||||
* on output. Output stats on 0-sized filesystems if specificly listed on
|
||||
* on output. Output stats on 0-sized filesystems if specifically listed on
|
||||
* the command line. Properly round *-blocks, Used, and Available quantities.
|
||||
*/
|
||||
|
||||
@@ -51,7 +51,7 @@ extern int df_main(int argc, char **argv)
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
unsigned long df_disp_hr = KILOBYTE;
|
||||
unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
int status = EXIT_SUCCESS;
|
||||
unsigned long opt;
|
||||
@@ -115,7 +115,7 @@ extern int df_main(int argc, char **argv)
|
||||
bb_perror_msg("%s", mount_point);
|
||||
goto SET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if ((s.f_blocks > 0) || !mount_table){
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = 0;
|
||||
@@ -124,25 +124,25 @@ extern int df_main(int argc, char **argv)
|
||||
+ (blocks_used + s.f_bavail)/2
|
||||
) / (blocks_used + s.f_bavail);
|
||||
}
|
||||
|
||||
|
||||
if (strcmp(device, "rootfs") == 0) {
|
||||
continue;
|
||||
} else if (strcmp(device, "/dev/root") == 0) {
|
||||
/* Adjusts device to be the real root device,
|
||||
* or leaves device alone if it can't find it */
|
||||
if ((device = find_real_root_device_name(device)) == NULL) {
|
||||
if ((device = find_real_root_device_name()) == NULL) {
|
||||
goto SET_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
bb_printf("%-21s%9s ", device,
|
||||
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
|
||||
|
||||
|
||||
bb_printf("%9s ",
|
||||
make_human_readable_str( (s.f_blocks - s.f_bfree),
|
||||
s.f_bsize, df_disp_hr));
|
||||
|
||||
|
||||
bb_printf("%9s %3ld%% %s\n",
|
||||
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
|
||||
blocks_percent_used, mount_point);
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini dirname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
@@ -50,7 +50,7 @@ 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)
|
||||
static int convert(char *fn, int ConvType)
|
||||
{
|
||||
int c, fd;
|
||||
struct timeval tv;
|
||||
@@ -64,7 +64,9 @@ static int convert(char *fn, int ConvType)
|
||||
c = strlen(tempFn);
|
||||
tempFn[c] = '.';
|
||||
while(1) {
|
||||
if (c >=BUFSIZ)
|
||||
/* tempFn is BUFSIZ so the last addressable spot it BUFSIZ-1.
|
||||
* The loop increments by 2. So this must check for BUFSIZ-3. */
|
||||
if (c >=BUFSIZ-3)
|
||||
bb_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)
|
||||
@@ -156,12 +158,12 @@ static int convert(char *fn, int ConvType)
|
||||
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
|
||||
//See if we are supposed to be doing dos2unix or unix2dos
|
||||
if (argv[0][0]=='d') {
|
||||
ConvType = CT_DOS2UNIX;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ static unsigned int disp_k; /* bss inits to 0 */
|
||||
#endif
|
||||
|
||||
static int max_print_depth = INT_MAX;
|
||||
static int count_hardlinks = INT_MAX;
|
||||
static int count_hardlinks = 1;
|
||||
|
||||
static int status
|
||||
#if EXIT_SUCCESS == 0
|
||||
@@ -77,7 +77,11 @@ static void print(long size, char *filename)
|
||||
bb_printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
|
||||
filename);
|
||||
#else
|
||||
bb_printf("%ld\t%s\n", size >> disp_k, filename);
|
||||
if (disp_k) {
|
||||
size++;
|
||||
size >>= 1;
|
||||
}
|
||||
bb_printf("%ld\t%s\n", size, filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -177,7 +181,7 @@ int du_main(int argc, char **argv)
|
||||
#else
|
||||
disp_k = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Note: SUSv3 specifies that -a and -s options can not be used together
|
||||
@@ -234,7 +238,7 @@ int du_main(int argc, char **argv)
|
||||
}
|
||||
if((opt & (1 << 7))) {
|
||||
/* -l opt */
|
||||
count_hardlinks = 1;
|
||||
count_hardlinks = INT_MAX;
|
||||
}
|
||||
print_final_total = opt & (1 << 8); /* -c opt */
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Because of behavioral differences, implemented configureable SUSv3
|
||||
* Because of behavioral differences, implemented configurable SUSv3
|
||||
* or 'fancy' gnu-ish behaviors. Also, reduced size and fixed bugs.
|
||||
* 1) In handling '\c' escape, the previous version only suppressed the
|
||||
* trailing newline. SUSv3 specifies _no_ output after '\c'.
|
||||
@@ -55,7 +55,7 @@ extern int echo_main(int argc, char** argv)
|
||||
* that all of the options specified are actually valid.
|
||||
* Otherwise, the string should just be echoed.
|
||||
*/
|
||||
|
||||
|
||||
if (!*(p = *argv + 1)) { /* A single '-', so echo it. */
|
||||
goto just_echo;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ just_echo:
|
||||
while ((c = *(*argv)++)) {
|
||||
if (c == eflag) { /* Check for escape seq. */
|
||||
if (**argv == 'c') {
|
||||
/* '\c' means cancel newline and
|
||||
/* '\c' means cancel newline and
|
||||
* ignore all subsequent chars. */
|
||||
goto DONE;
|
||||
}
|
||||
@@ -141,8 +141,8 @@ DONE:
|
||||
* 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>
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
Loaded 100 of 832 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user