Compare commits

..
10 Commits
Author SHA1 Message Date
Bernhard Reutner-Fischer e203ea59c7 - don't look at the address but rather on the value.
(r14748 from trunk)
2006-04-10 20:37:29 +00:00
Bernhard Reutner-Fischer addf86e3d3 - stable version 1.1.2 2006-04-10 20:17:34 +00:00
Rob Landley 8dc83c654d Bring this up to date with busybox-1.1.1.fixes.patch by importing
svn 14653, 14684, 14746, and 14749.
2006-04-05 03:10:42 +00:00
Bernhard Reutner-Fischer 7fe9dd5dd7 - fix one-argument mount in cases where fstab or mtab contain overlapping
entries.  (Such as "mount -o remount,rw /" where you're not on rootfs.).
  (r14723 from trunk)
2006-04-04 08:23:59 +00:00
Bernhard Reutner-Fischer 5e89953273 - make sure that we see all lib*/.c in IMA-mode even when not building the .so
(r14740 from trunk).
2006-04-04 08:21:36 +00:00
Paul Fox efbadf9f3f prevent find from ever descending into an xdev'ed directory.
(brought over from trunk r14665)
2006-03-30 20:06:46 +00:00
Bernhard Reutner-Fischer 2ebc69a4c6 - pull r14681 from trunk:
don't free foreign mem.
2006-03-30 13:03:28 +00:00
Bernhard Reutner-Fischer 59970faa39 - pull r14643 from trunk:
make sure that we see freeramdisk only once
2006-03-30 12:56:26 +00:00
Bernhard Reutner-Fischer fe802ee02c - pull r14628 from trunk:
Bug spotted by Stephane Billiart: losetup depends on loop.c.
2006-03-30 12:55:12 +00:00
Bernhard Reutner-Fischer 7ff69e3ab8 - upcoming stable version 1.1.2 2006-03-30 12:52:37 +00:00
675 changed files with 24495 additions and 19086 deletions

No files matched your search

+53 -98
View File
@@ -13,26 +13,9 @@ menu "Busybox Settings"
menu "General Configuration"
config CONFIG_NITPICK
bool "See lots more (probably unnecessary) configuration options."
default n
help
Some BusyBox applets have more configuration options than anyone
will ever care about. To avoid drowining people in complexity, most
of the applet features that can be set to a sane default value are
hidden, unless you hit the above switch.
This is better than to telling people to edit the busybox source
code, but not by much.
See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet
You have been warned.
choice
prompt "Buffer allocation policy"
default CONFIG_FEATURE_BUFFERS_USE_MALLOC
depends on CONFIG_NITPICK
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
@@ -54,39 +37,15 @@ config CONFIG_FEATURE_BUFFERS_GO_IN_BSS
endchoice
config CONFIG_SHOW_USAGE
bool "Show terse applet usage messages"
default y
help
All BusyBox applets will show help messages when invoked with
wrong arguments. You can turn off printing these terse usage
messages if you say no here.
This will save you up to 7k.
config CONFIG_FEATURE_VERBOSE_USAGE
bool "Show verbose applet usage messages"
default n
select CONFIG_SHOW_USAGE
help
All BusyBox applets will show more verbose help messages when
busybox is invoked with --help. This will add a lot of text to the
busybox binary. In the default configuration, this will add about
13k, but it can add much more depending on your configuration.
config CONFIG_FEATURE_COMPRESS_USAGE
bool "Store applet usage messages in compressed form"
default y
depends on CONFIG_SHOW_USAGE && CONFIG_NITPICK
help
Store usage messages in compressed form, uncompress them on-the-fly
when <applet> --help is called.
If you have a really tiny busybox with few applets enabled (and
bunzip2 isn't one of them), the overhead of the decompressor might
be noticeable. Also, if you run executables directly from ROM
and have very little memory, this might not be a win. Otherwise,
you probably want this.
config CONFIG_FEATURE_INSTALLER
bool "Support --install [-s] to install applet links at runtime"
default n
@@ -103,29 +62,25 @@ config CONFIG_LOCALE_SUPPORT
Enable this if your system has locale support and you would like
busybox to support locale settings.
config CONFIG_GETOPT_LONG
bool
default y
# bool "Enable support for --long-options"
# default n
# help
# Enable this if you want busybox applets to use the gnu --long-option
# style, in addition to single character -a -b -c style options.
config CONFIG_FEATURE_DEVFS
bool "Support for devfs"
default n
help
Enable if you want BusyBox to work with devfs.
config CONFIG_FEATURE_DEVPTS
bool "Use the devpts filesystem for Unix98 PTYs"
default y
default y if CONFIG_FEATURE_DEVFS
help
Enable if you want BusyBox to use Unix98 PTY support. If enabled,
busybox will use /dev/ptmx for the master side of the pseudoterminal
and /dev/pts/<number> for the slave side. Otherwise, BSD style
/dev/ttyp<number> will be used. To use this option, you should have
devpts mounted.
devpts or devfs mounted.
config CONFIG_FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
depends on CONFIG_NITPICK
help
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
@@ -139,25 +94,15 @@ config CONFIG_FEATURE_SUID
bool "Support for SUID/SGID handling"
default n
help
With this option you can install the busybox binary belonging
to root with the suid bit set, and it'll and it'll automatically drop
priviledges for applets that don't need root access.
If you're really paranoid and don't want to do this, build two
busybox binaries with different applets in them (and the appropriate
symlinks pointing to each binary), and only set the suid bit on the
one that needs it. The applets currently marked to need the suid bit
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
and vlock.
Support SUID and SGID binaries.
config CONFIG_FEATURE_SUID_CONFIG
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
default n if CONFIG_FEATURE_SUID
depends on CONFIG_FEATURE_SUID
help
Allow the SUID / SGID state of an applet to be determined at runtime
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
The format of this file is as follows:
Allow the SUID / SGID state of an applet to be determined runtime by
checking /etc/busybox.conf. The format of this file is as follows:
<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)
@@ -184,7 +129,7 @@ config CONFIG_FEATURE_SUID_CONFIG
config CONFIG_FEATURE_SUID_CONFIG_QUIET
bool "Suppress warning message if /etc/busybox.conf is not readable"
default y
default n
depends on CONFIG_FEATURE_SUID_CONFIG
help
/etc/busybox.conf should be readable by the user needing the SUID, check
@@ -210,16 +155,6 @@ config CONFIG_SELINUX
Most people will leave this set to 'N'.
config CONFIG_BUSYBOX_EXEC_PATH
string "Path to BusyBox executable"
default "/proc/self/exe"
help
When Busybox applets need to run other busybox applets, BusyBox
sometimes needs to exec() itself. When the /proc filesystem is
mounted, /proc/self/exe always points to the currently running
executable. If you haven't got /proc, set this to wherever you
want to run BusyBox from.
endmenu
menu 'Build Options'
@@ -238,18 +173,21 @@ config CONFIG_STATIC
Most people will leave this set to 'N'.
# The busybox shared library feature is there so make standalone can produce
# smaller applets. Since make standalone isn't in yet, there's nothing using
# this yet, and so it's disabled.
config CONFIG_DISABLE_SHARED
bool
default n
config CONFIG_BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
depends on CONFIG_DISABLE_SHARED
help
Build a shared library libbusybox.so which contains all
libraries used inside busybox.
This is an experimental feature intended to support the upcoming
"make standalone" mode. Enabling it against the one big busybox
binary serves no purpose (and increases the size). You should
almost certainly say "no" to this right now.
config CONFIG_FEATURE_FULL_LIBBUSYBOX
bool "Feature-complete libbusybox"
default n if !CONFIG_FEATURE_SHARED_BUSYBOX
@@ -289,6 +227,33 @@ config CONFIG_LFS
cp, mount, tar, and many others. If you want to access files larger
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
config USING_CROSS_COMPILER
bool "Do you want to build BusyBox with a Cross Compiler?"
default n
help
Do you want to build BusyBox with a Cross Compiler? If so,
then enable this option. Otherwise leave it set to 'N'.
config CROSS_COMPILER_PREFIX
string "Cross Compiler prefix"
default "/usr/i386-linux-uclibc/bin/i386-uclibc-"
depends on USING_CROSS_COMPILER
help
If you want to build BusyBox with a cross compiler, then you
will need to set this to the cross-compiler prefix. For example,
if my cross-compiler is /usr/i386-linux-uclibc/bin/i386-uclibc-gcc
then I would enter '/usr/i386-linux-uclibc/bin/i386-uclibc-' here,
which will ensure the correct compiler is used.
config EXTRA_CFLAGS_OPTIONS
string "Any extra CFLAGS options for the compiler?"
default ""
help
Do you want to pass any extra CFLAGS options to the compiler as
you build BusyBox? If so, this is the option for you... For example,
if you want to add some simple compiler switches (like -march=i686),
or check for warnings using -Werror, just those options here.
config CONFIG_BUILD_AT_ONCE
bool "Compile all sources at once"
default n
@@ -313,27 +278,17 @@ endmenu
menu 'Debugging Options'
config CONFIG_DEBUG
bool "Build BusyBox with extra Debugging symbols"
bool "Build BusyBox with Debugging symbols"
default n
help
Say Y here if you wish to examine BusyBox internals while applets are
running. This increases the size of the binary considerably, and
should only be used when doing development. If you are doing
development and want to debug BusyBox, answer Y.
Say Y here if you wish to compile BusyBox with debugging symbols.
This will allow you to use a debugger to examine BusyBox internals
while applets are running. This increases the size of the binary
considerably and should only be used when doing development.
If you are doing development and want to debug BusyBox, answer Y.
Most people should answer N.
config CONFIG_DEBUG_PESSIMIZE
bool "Disable compiler optimizations."
default n
depends on CONFIG_DEBUG
help
The compiler's optimization of source code can eliminate and reorder
code, resulting in an executable that's hard to understand when
stepping through it with a debugger. This switches it off, resulting
in a much bigger executable that more closely matches the source
code.
choice
prompt "Additional debugging library"
default CONFIG_NO_DEBUG_LIB
@@ -380,7 +335,7 @@ config CONFIG_DEBUG_YANK_SUSv2
bool "Disable obsolete features removed before SUSv3?"
default y
help
This option will disable backwards compatibility with SuSv2,
This option will disable backwards compatability with SuSv2,
specifically, old-style numeric options ('command -1 <file>')
will not be supported in head, tail, and fold. (Note: should
yank from renice too.)
+1 -1
View File
@@ -53,7 +53,7 @@ is run without an existing configuration, make defconfig will run first to
create a known starting point.
Other starting configurations (mostly used for testing purposes) include
"make allbareconfig" (enables all applets but disables all optional features),
"make allbaseconfig" (enables all applets but disables all optional features),
"make allyesconfig" (enables absolutely everything including debug features),
and "make randconfig" (produce a random configuration).
+73 -140
View File
@@ -5,20 +5,14 @@
# Licensed under GPLv2, see the file LICENSE in this tarball for details.
#
# You shouldn't have to edit anything in this file for configuration
# purposes, try "make help" or read http://busybox.net/FAQ.html.
.PHONY: dummy subdirs release distclean clean config oldconfig menuconfig \
tags check test depend dep buildtree hosttools _all checkhelp \
sizes bloatcheck baseline objsizes
noconfig_targets := menuconfig config oldconfig randconfig hosttools \
#--------------------------------------------------------------
# You shouldn't need to mess with anything beyond this point...
#--------------------------------------------------------------
noconfig_targets := menuconfig config oldconfig randconfig \
defconfig allyesconfig allnoconfig allbareconfig \
clean distclean help \
release tags
nocheck_targets := clean distclean help release tags
# the toplevel sourcedir
ifndef top_srcdir
top_srcdir=$(CURDIR)
@@ -39,44 +33,27 @@ DIRS:=applets archival archival/libunarchive coreutils console-tools \
SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
# That's our default target when none is given on the command line
.PHONY: _all
_all:
CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
ifeq ($(BUILD_SRC),)
ifeq ($(KBUILD_SRC),)
ifdef O
ifeq ("$(origin O)", "command line")
BUILD_OUTPUT := $(O)
KBUILD_OUTPUT := $(O)
top_builddir := $(O)
endif
else
# If no alternate output-dir was specified, we build in cwd
# We are using BUILD_OUTPUT nevertheless to make sure that we create
# We are using KBUILD_OUTPUT nevertheless to make sure that we create
# Rules.mak and the toplevel Makefile, in case they don't exist.
BUILD_OUTPUT := $(top_builddir)
endif
# see if we are in verbose mode
BUILD_VERBOSE :=
ifdef V
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE := $(V)
endif
endif
ifdef VERBOSE
ifeq ("$(origin VERBOSE)", "command line")
BUILD_VERBOSE := $(VERBOSE)
endif
endif
ifneq ($(strip $(BUILD_VERBOSE)),)
export BUILD_VERBOSE
CHECK_VERBOSE := -v
# ARFLAGS+=v
KBUILD_OUTPUT := $(top_builddir)
endif
ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
# pull in settings early
# pull in OS specific commands like cp, mkdir, etc. early
-include $(top_srcdir)/Rules.mak
endif
@@ -87,40 +64,40 @@ all_tree: $(all_tree)
$(all_tree):
@mkdir -p "$@"
ifneq ($(BUILD_OUTPUT),)
ifneq ($(KBUILD_OUTPUT),)
# Invoke a second make in the output directory, passing relevant variables
# Check that the output directory actually exists
saved-output := $(BUILD_OUTPUT)
BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd)
$(if $(wildcard $(BUILD_OUTPUT)),, \
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: $(BUILD_OUTPUT)/Rules.mak $(BUILD_OUTPUT)/Makefile all_tree
$(Q)$(MAKE) -C $(BUILD_OUTPUT) \
$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) \
top_srcdir=$(top_srcdir) \
top_builddir=$(top_builddir) \
BUILD_SRC=$(top_srcdir) \
KBUILD_SRC=$(top_srcdir) \
-f $(CURDIR)/Makefile $@
$(BUILD_OUTPUT)/Rules.mak:
$(KBUILD_OUTPUT)/Rules.mak:
@echo > $@
@echo top_srcdir=$(top_srcdir) >> $@
@echo top_builddir=$(BUILD_OUTPUT) >> $@
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
@echo include $(top_srcdir)/Rules.mak >> $@
$(BUILD_OUTPUT)/Makefile:
$(KBUILD_OUTPUT)/Makefile:
@echo > $@
@echo top_srcdir=$(top_srcdir) >> $@
@echo top_builddir=$(BUILD_OUTPUT) >> $@
@echo BUILD_SRC='$$(top_srcdir)' >> $@
@echo include '$$(BUILD_SRC)'/Makefile >> $@
@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 ($(BUILD_OUTPUT),)
endif # ifeq ($(BUILD_SRC),)
endif # ifneq ($(KBUILD_OUTPUT),)
endif # ifeq ($(KBUILD_SRC),)
ifeq ($(skip-makefile),)
@@ -140,7 +117,6 @@ help:
@echo ' all - Executable and documentation'
@echo ' busybox - the swiss-army executable'
@echo ' doc - docs/BusyBox.{txt,html,1}'
@echo ' html - create html-based cross-reference'
@echo
@echo 'Configuration:'
@echo ' allnoconfig - disable all symbols in .config'
@@ -150,24 +126,16 @@ help:
@echo ' defconfig - set .config to largest generic configuration'
@echo ' menuconfig - interactive curses-based configurator'
@echo ' oldconfig - resolve any unresolved symbols in .config'
@echo ' hosttools - build sed for the host.'
@echo ' You can use these commands if the commands on the host'
@echo ' is unusable. Afterwards use it like:'
@echo ' make SED="$(top_builddir)/sed"'
@echo
@echo 'Installation:'
@echo ' install - install busybox into $(PREFIX)'
@echo ' uninstall'
@echo
@echo 'Development:'
@echo ' baseline - create busybox_old for bloatcheck.'
@echo ' bloatcheck - show size difference between old and new versions'
@echo ' check - run the test suite for all applets'
@echo ' checkhelp - check for missing help-entries in Config.in'
@echo ' randconfig - generate a random configuration'
@echo ' release - create a distribution tarball'
@echo ' sizes - show size of all enabled busybox symbols'
@echo ' objsizes - show size of each .o object built'
@echo
@@ -202,7 +170,7 @@ scripts/config/mconf: scripts/config/Makefile
fi
menuconfig: scripts/config/mconf
@[ -f .config ] || $(MAKE) $(MAKEFLAGS) defconfig
@[ -f .config ] || make $(MAKEFLAGS) defconfig
@./scripts/config/mconf $(CONFIG_CONFIG_IN)
config: scripts/config/conf
@@ -215,39 +183,29 @@ randconfig: scripts/config/conf
@./scripts/config/conf -r $(CONFIG_CONFIG_IN)
allyesconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
@$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
allnoconfig: scripts/config/conf
@./scripts/config/conf -n $(CONFIG_CONFIG_IN) > /dev/null
@./scripts/config/conf -n $(CONFIG_CONFIG_IN)
# defconfig is allyesconfig minus any features that are specialized enough
# or cause enough behavior change that the user really should switch them on
# manually if that's what they want. Sort of "maximum sane config".
defconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
@$(SED) -i -r -e "s/^(CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
@$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
allbareconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
@$(SED) -i -r -e "s/^(CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
@$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
@$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
@echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
@yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
hosttools:
$(Q)cp .config .config.bak || noold=yea
$(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" allnoconfig
$(Q)mv .config .config.in
$(Q)(grep -v CONFIG_SED .config.in ; \
echo "CONFIG_SED=y" ; ) > .config
$(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h
$(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox
$(Q)[ -f .config.bak ] && mv .config.bak .config || rm .config
mv busybox sed
@echo "Now do: $(MAKE) SED=$(top_builddir)/sed <target>"
@yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN)
else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
@@ -322,25 +280,31 @@ $(LIBBUSYBOX_SONAME):
ifndef MAJOR_VERSION
$(error MAJOR_VERSION needed for $@ is not defined)
endif
$(do_link.so) \
$(do_link) $(LIB_CFLAGS) $(CFLAGS_COMBINE) \
-Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
-Wl,-z,combreloc
-Wl,-z,combreloc $(LIB_LDFLAGS) \
-o $(@) \
-Wl,--start-group -Wl,--whole-archive \
$(LIBRARY_DEFINE) $(^) \
-Wl,--no-whole-archive -Wl,--end-group
@rm -f $(DO_INSTALL_LIBS)
@for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
$(do_strip)
endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y)
$(do_link)
busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(libraries-y)
$(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
-o $@ -Wl,--start-group \
$(APPLETS_DEFINE) $(APPLET_SRC) \
$(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
$(LDBUSYBOX) $(LIBRARIES) \
-Wl,--end-group
busybox: busybox_unstripped
$(Q)cp busybox_unstripped busybox
$(do_strip)
%.bflt: %_unstripped
$(do_elf2flt)
busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
$(Q)-$(SHELL) $^ >$@
@@ -367,26 +331,24 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n)
done
endif
# see if we are in verbose mode
KBUILD_VERBOSE :=
ifdef V
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE := $(V)
endif
endif
ifneq ($(strip $(KBUILD_VERBOSE)),)
CHECK_VERBOSE := -v
# ARFLAGS+=v
endif
check test: busybox
bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite SED="$(SED)" \
$(SHELL) $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
checkhelp:
$(Q)$(top_srcdir)/scripts/checkhelp.awk \
$(wildcard $(patsubst %,%/Config.in,$(SRC_DIRS) ./))
bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
$(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
sizes: busybox_unstripped
$(NM) --size-sort $(<)
bloatcheck: busybox_old busybox_unstripped
@$(top_srcdir)/scripts/bloat-o-meter busybox_old busybox_unstripped
baseline: busybox_unstripped
@mv busybox_unstripped busybox_old
objsizes: busybox_unstripped
$(SHELL) $(top_srcdir)/scripts/objsizes
# Documentation Targets
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
@@ -422,37 +384,20 @@ docs/busybox.net/BusyBox.html: docs/busybox.pod
# The nifty new dependency stuff
scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
$(do_link.h)
$(Q)$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
DEP_INCLUDES := include/bb_config.h
ifeq ($(strip $(CONFIG_BBCONFIG)),y)
DEP_INCLUDES += include/bbconfigopts.h
include/bbconfigopts.h: .config $(top_srcdir)/scripts/config/mkconfigs
include/bbconfigopts.h: .config
$(disp_gen)
$(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
endif
ifeq ($(strip $(CONFIG_FEATURE_COMPRESS_USAGE)),y)
USAGE_BIN:=scripts/usage
$(USAGE_BIN): $(top_srcdir)/scripts/usage.c .config \
$(top_srcdir)/include/usage.h
$(do_link.h)
DEP_INCLUDES += include/usage_compressed.h
include/usage_compressed.h: .config $(USAGE_BIN) \
$(top_srcdir)/scripts/usage_compressed
$(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed \
"$(top_builddir)/scripts" > $@
endif # CONFIG_FEATURE_COMPRESS_USAGE
# workaround alleged bug in make-3.80, make-3.81
.NOTPARALLEL: .depend
depend dep: .depend
.depend: scripts/bb_mkdep $(USAGE_BIN) $(DEP_INCLUDES)
.depend: scripts/bb_mkdep $(DEP_INCLUDES)
$(disp_gen)
$(Q)rm -f .depend
$(Q)mkdir -p include/config
@@ -473,18 +418,15 @@ clean:
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
docs/busybox.net/BusyBox.html busybox.links \
libbusybox.so* \
.config.old busybox busybox_unstripped \
include/usage_compressed.h scripts/usage
.config.old busybox busybox_unstripped
- rm -r -f _install testsuite/links
- find . -name .\*.flags -o -name \*.o -o -name \*.om -o -name \*.syn \
- find . -name .\*.flags -o -name \*.o -o -name \*.om \
-o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
distclean: clean
rm -f scripts/bb_mkdep scripts/usage
rm -r -f include/config include/config.h $(DEP_INCLUDES)
find . -name .depend'*' -print0 | xargs -0 rm -f
find . -name '*.rej' -print0 | xargs -0 rm -f
rm -f .hdepend
- rm -f scripts/bb_mkdep
- rm -r -f include/config $(DEP_INCLUDES)
- find . -name .depend'*' | xargs rm -f
rm -f .config .config.old .config.cmd
release: distclean #doc
@@ -507,17 +449,8 @@ release: distclean #doc
tags:
ctags -R .
# documentation, cross-reference
# Modern distributions already ship synopsis packages (e.g. debian)
# If you have an old distribution go to http://synopsis.fresco.org/
syn_tgt := $(wildcard $(patsubst %,%/*.c,$(SRC_DIRS)))
syn := $(patsubst %.c, %.syn, $(syn_tgt))
%.syn: %.c
synopsis -p C -l Comments.SSDFilter,Comments.Previous $(INCS) -Wp,verbose,debug,preprocess,cppflags="'$(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) $(APPLETS_DEFINE) $(BUSYBOX_DEFINE)'" -o $@ $<
html: $(syn)
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
endif # ifeq ($(skip-makefile),)
.PHONY: dummy subdirs release distclean clean config oldconfig \
menuconfig tags check test depend dep buildtree
+13 -8
View File
@@ -5,12 +5,12 @@ 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, dhcp, diffutils, e2fsprogs,
file, findutils, gawk, grep, inetutils, less, 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.
utilities you usually find in bzip2, coreutils, e2fsprogs, file, findutils,
gawk, grep, inetutils, less, 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.
@@ -65,6 +65,11 @@ Downloading the current source code:
http://busybox.net/downloads/
You can browse the up to the minute source code and change history online.
The "stable" series is at:
http://www.busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_00_stable/busybox/
And the development series is at:
http://www.busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/
@@ -194,5 +199,5 @@ Supported hardware:
Please feed suggestions, bug reports, insults, and bribes back to the busybox
maintainer:
Rob Landley
<rob@landley.net>
Erik Andersen
<andersen@codepoet.org>
+80 -203
View File
@@ -13,8 +13,8 @@ endif
#--------------------------------------------------------
PROG := busybox
MAJOR_VERSION :=1
MINOR_VERSION :=2
SUBLEVEL_VERSION:=0
MINOR_VERSION :=1
SUBLEVEL_VERSION:=2
EXTRAVERSION :=
VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
@@ -24,47 +24,69 @@ BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
# With a modern GNU make(1) (highly recommended, that's what all the
# developers use), all of the following configuration values can be
# overridden at the command line. For example:
# make CROSS_COMPILE=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
#--------------------------------------------------------
# If you are running a cross compiler, you will want to set CROSS_COMPILE
# If you are running a cross compiler, you will want to set 'CROSS'
# to something more interesting... Target architecture is determined
# by asking the CC compiler what arch it compiles things for, so unless
# your compiler is broken, you should not need to specify TARGET_ARCH
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
ELF2FLT = $(CROSS_COMPILE)elf2flt
CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
CC = $(CROSS)gcc
AR = $(CROSS)ar
AS = $(CROSS)as
LD = $(CROSS)ld
NM = $(CROSS)nm
STRIP = $(CROSS)strip
CPP = $(CC) -E
SED ?= sed
BZIP2 ?= bzip2
# What OS are you compiling busybox for? This allows you to include
# OS specific things, syscall overrides, etc.
TARGET_OS=linux
# Select the compiler needed to build binaries for your development system
HOSTCC = gcc
HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
LC_ALL:= C
# This must bind late because srcdir is reset for every source subdirectory.
INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
CFLAGS+=$(CHECKED_CFLAGS)
# 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)))
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
#LIBCDIR:=/usr/i386-glibc20-linux
#
# For other libraries, you are on your own. But these may (or may not) help...
#LDFLAGS+=-nostdlib
#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)
ARFLAGS=cru
# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
# get the CC MAJOR/MINOR version
CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
#--------------------------------------------------------
export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS_COMPILE CC AR AS LD NM STRIP CPP
export VERSION BUILDTIME 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' \
@@ -78,108 +100,22 @@ TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \
)
endif
# A nifty macro to make testing gcc features easier, but note that everything
# that uses this _must_ use := or it will be re-evaluated everytime it is
# referenced.
ifeq ($(strip $(BUILD_VERBOSE)),2)
VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2;
endif
check_cc=$(shell \
$(VERBOSE_CHECK_CC) \
if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
echo "int i;" > ./conftest.c; \
if $(1) $(2) -c -o conftest.o conftest.c > /dev/null 2>&1; \
then echo "$(2)"; else echo "$(3)"; fi ; \
rm -f conftest.c conftest.o; \
# A nifty macro to make testing gcc features easier
check_gcc=$(shell \
if [ "$(1)" != "" ]; then \
if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
then echo "$(1)"; else echo "$(2)"; fi \
fi)
ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
check_cc:=
endif
# A not very robust macro to check for available ld flags
ifeq ($(strip $(BUILD_VERBOSE)),2)
VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2;
endif
check_ld=$(shell \
$(VERBOSE_CHECK_LD) \
if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
$(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && \
echo "-Wl,$(2)" ; \
if [ "x$(1)" != "x" ]; then \
$(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \
fi)
ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
check_ld:=
endif
# A not very robust macro to check for available strip flags
ifeq ($(strip $(BUILD_VERBOSE)),2)
VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2;
endif
check_strip=$(shell \
$(VERBOSE_CHECK_STRIP) \
if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
echo "int i;" > ./conftest.c ; \
$(CC) -c -o conftest.o conftest.c > /dev/null 2>&1 ; \
$(1) $(2) conftest.o > /dev/null 2>&1 && \
echo "$(1) $(2)" || echo "$(3)"; \
rm -f conftest.c conftest.o > /dev/null 2>&1 ; \
fi)
ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
check_strip:=
endif
# Select the compiler needed to build binaries for your development system
HOSTCC = gcc
HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,)
HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,)
HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,)
HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,)
LD_WHOLE_ARCHIVE:=$(shell echo "int i;" > conftest.c ; \
$(CC) -c -o conftest.o conftest.c ; \
echo "int main(void){return 0;}" > conftest_main.c ; \
$(CC) -c -o conftest_main.o conftest_main.c ; \
$(AR) $(ARFLAGS) conftest.a conftest.o ; \
$(CC) -Wl,--whole-archive conftest.a -Wl,--no-whole-archive \
conftest_main.o -o conftest > /dev/null 2>&1 \
&& echo "-Wl,--whole-archive" ; \
rm conftest_main.o conftest_main.c conftest.o conftest.c \
conftest.a conftest > /dev/null 2>&1 ; )
ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),)
LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive
endif
LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \
$(CC) -c -o conftest.o conftest.c ; \
echo "int main(void){return bar();}" > conftest_main.c ; \
$(CC) -c -o conftest_main.o conftest_main.c ; \
$(AR) $(ARFLAGS) conftest.a conftest.o ; \
$(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \
-o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \
rm conftest_main.o conftest_main.c conftest.o conftest.c \
conftest.a conftest > /dev/null 2>&1 ; )
ifneq ($(findstring start-group,$(LD_START_GROUP)),)
LD_END_GROUP:= -Wl,--end-group
endif
CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,)
# Pin CHECKED_CFLAGS with := so it's only evaluated once.
CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,)
CHECKED_CFLAGS+=$(call check_cc,$(HOSTCC),-Werror,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-finline-limit=0)
# Preemptively pin this too.
PROG_CFLAGS:=
CFLAGS+=$(call check_gcc,-funsigned-char,)
CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,)
#--------------------------------------------------------
# Arch specific compiler optimization stuff should go here.
@@ -187,26 +123,22 @@ PROG_CFLAGS:=
# for OPTIMIZATION...
# use '-Os' optimization if available, else use -O2
OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2)
OPTIMIZATION:=$(call check_gcc,-Os,-O2)
ifeq ($(CONFIG_BUILD_AT_ONCE),y)
# gcc 2.95 exits with 0 for "unrecognized option"
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,)
CFLAGS_COMBINE:=$(call check_gcc,--combine,)
endif
OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,)
OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,)
ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y)
OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
# This prevents us from using -fwhole-program when we build the lib
PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,)
endif # CONFIG_BUILD_LIBBUSYBOX
#PROG_CFLAGS+=$(call check_gcc,-fwhole-program,)
endif # CONFIG_BUILD_AT_ONCE
LIB_LDFLAGS:=$(call check_ld,$(LD),--enable-new-dtags,)
#LIB_LDFLAGS+=$(call check_ld,$(LD),--reduce-memory-overheads,)
#LIB_LDFLAGS+=$(call check_ld,$(LD),--as-needed,)
#LIB_LDFLAGS+=$(call check_ld,$(LD),--warn-shared-textrel,)
LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,)
#LIB_LDFLAGS+=$(call check_ld,--reduce-memory-overheads,)
#LIB_LDFLAGS+=$(call check_ld,--as-needed,)
#LIB_LDFLAGS+=$(call check_ld,--warn-shared-textrel,)
# Some nice architecture specific optimizations
@@ -214,26 +146,25 @@ ifeq ($(strip $(TARGET_ARCH)),arm)
OPTIMIZATION+=-fstrict-aliasing
endif
ifeq ($(strip $(TARGET_ARCH)),i386)
OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,)
OPTIMIZATION+=$(call check_gcc,-march=i386,)
# gcc-4.0 and older seem to benefit from these
#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,)
OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
OPTIMIZATION+=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
-malign-functions=0 -malign-jumps=0 -malign-loops=0)
#endif # gcc-4.0 and older
# gcc-4.1 and beyond seem to benefit from these
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
# turn off flags which hurt -Os
OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-loop-optimize,)
OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-dominator-opts,)
OPTIMIZATION+=$(call check_cc,$(CC),-fno-strength-reduce,)
OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
OPTIMIZATION+=$(call check_cc,$(CC),-fno-branch-count-reg,)
OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,)
endif # gcc-4.1 and beyond
endif
OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,)
OPTIMIZATION+=$(call check_cc,$(CC),-ffunction-sections -fdata-sections,)
OPTIMIZATIONS:=$(OPTIMIZATION) $(call check_gcc,-fomit-frame-pointer,)
#
#--------------------------------------------------------
@@ -257,43 +188,27 @@ else
LIBRARIES:=-lefence
endif
endif
# Debugging info
ifeq ($(strip $(CONFIG_DEBUG)),y)
CFLAGS +=-g
CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS += $(call check_ld,--warn-common,)
else
CFLAGS +=-DNDEBUG
CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
CHECKED_LDFLAGS += $(call check_ld,--gc-sections,)
CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
LDFLAGS += $(call check_ld,--warn-common,)
LDFLAGS += $(call check_ld,--sort-common,)
endif
ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y)
CFLAGS += $(OPTIMIZATION)
endif
# warn a bit more verbosely for non-release versions
ifneq ($(EXTRAVERSION),)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-prototypes,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-declarations,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wunused,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winit-self,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wcast-align,)
endif
STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP))
STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
ifeq ($(strip $(CONFIG_STATIC)),y)
PROG_CFLAGS += $(call check_cc,$(CC),-static,)
PROG_CFLAGS += $(call check_gcc,-static,)
endif
CFLAGS_SHARED := $(call check_cc,$(CC),-shared,)
CFLAGS_SHARED += $(call check_gcc,-shared,)
LIB_CFLAGS+=$(CFLAGS_SHARED)
ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
CFLAGS_PIC:= $(call check_cc,$(CC),-fPIC,)
CFLAGS_PIC:= $(call check_gcc,-fPIC,)
LIB_CFLAGS+=$(CFLAGS_PIC)
endif
ifeq ($(strip $(CONFIG_SELINUX)),y)
LIBRARIES += -lselinux
endif
@@ -302,10 +217,6 @@ ifeq ($(strip $(PREFIX)),)
PREFIX:=`pwd`/_install
endif
ifneq ($(strip $(CONFIG_GETOPT_LONG)),y)
CFLAGS += -D__need_getopt
endif
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
# the copy in top_srcdir, both during the compilation phase and the
@@ -314,16 +225,14 @@ endif
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS)
LDFLAGS += $(CHECKED_LDFLAGS)
CFLAGS += $(CROSS_CFLAGS)
ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif
# Put user-supplied flags at the end, where they
# have a chance of winning.
-include $(top_builddir)/.config.mak
CFLAGS += $(CFLAGS_EXTRA)
#------------------------------------------------------------
# Installation options
@@ -347,7 +256,7 @@ SECHO := @-false
DISP := sil
Q := @
else
ifneq ($(BUILD_VERBOSE),)
ifneq ($(V)$(VERBOSE),)
SECHO := @-false
DISP := ver
Q :=
@@ -363,65 +272,33 @@ pur_disp_compile.c = echo " "CC $(show_objs)
pur_disp_compile.h = echo " "HOSTCC $(show_objs)
pur_disp_strip = echo " "STRIP $(show_objs)
pur_disp_link = echo " "LINK $(show_objs)
pur_disp_link.h = echo " "HOSTLINK $(show_objs)
pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs)
pur_disp_elf2flt = echo " "ELF2FLT $(ELF2FLTFLAGS) $(show_objs)
sil_disp_compile.c = true
sil_disp_compile.h = true
sil_disp_strip = true
sil_disp_link = true
sil_disp_link.h = true
sil_disp_ar = true
sil_disp_elf2flt = true
ver_disp_compile.c = echo $(cmd_compile.c)
ver_disp_compile.h = echo $(cmd_compile.h)
ver_disp_strip = echo $(cmd_strip)
ver_disp_link = echo $(cmd_link)
ver_disp_link.h = echo $(cmd_link.h)
ver_disp_ar = echo $(cmd_ar)
ver_disp_elf2flt = echo $(cmd_elf2flt)
disp_compile.c = $($(DISP)_disp_compile.c)
disp_compile.h = $($(DISP)_disp_compile.h)
disp_strip = $($(DISP)_disp_strip)
disp_link = $($(DISP)_disp_link)
disp_link.h = $($(DISP)_disp_link.h)
disp_ar = $($(DISP)_disp_ar)
disp_gen = $(SECHO) " "GEN $@ ; true
disp_doc = $(SECHO) " "DOC $(subst docs/,,$@) ; true
disp_elf2flt = $($(DISP)_disp_elf2flt)
cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $<
cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
cmd_strip = $(STRIPCMD) $@
cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
$(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
-o $@ $(LD_START_GROUP) \
$(APPLETS_DEFINE) $(APPLET_SRC) \
$(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
$(LDBUSYBOX) $(LIBRARIES) \
$(LD_END_GROUP)
cmd_link.so = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
$(LIB_CFLAGS) $(CFLAGS_COMBINE) $(LIB_LDFLAGS) \
-o $(@) $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \
$(LIBRARY_DEFINE) $(^) \
$(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP)
cmd_link.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@
cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS)
cmd_ar = $(AR) $(ARFLAGS) $@ $^
cmd_elf2flt = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@
compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
compile.h = @$(disp_compile.h) ; $(cmd_compile.h)
do_strip = @$(disp_strip) ; $(cmd_strip)
do_link = @$(disp_link) ; $(cmd_link)
do_link.so = @$(disp_link) ; $(cmd_link.so)
do_link.h = @$(disp_link.h) ; $(cmd_link.h)
do_ar = @$(disp_ar) ; $(cmd_ar)
do_elf2flt = @$(disp_elf2flt) ; $(cmd_elf2flt)
uppercase = $(shell echo $1 | $(SED) -e "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/")
%.a:
@if test -z "$($(call uppercase,$*)_DIR)" ; then \
echo "Invalid target $@" ; \
exit 1 ; \
fi
$(Q)$(MAKE) $($(call uppercase,$*)_DIR)$@
.PHONY: dummy
+102 -150
View File
@@ -1,138 +1,31 @@
Busybox TODO
Stuff that needs to be done. This is organized by who plans to get around to
doing it eventually, but that doesn't mean they "own" the item. If you want to
do one of these bounce an email off the person it's listed under to see if they
have any suggestions how they plan to go about it, and to minimize conflicts
between your work and theirs. But otherwise, all of these are fair game.
Rob Landley <rob@landley.net>:
Add BB_NOMMU to platform.h and migrate __uClinux__ tests to that.
#if defined __UCLIBC__ && !defined __ARCH_USE_MMU__
Add a libbb/platform.c
Implement fdprintf() for platforms that haven't got one.
Implement bb_realpath() that can handle NULL on non-glibc.
Cleanup bb_asprintf()
Migrate calloc() and bb_calloc() occurrences to bb_xzalloc().
Remove obsolete _() wrapper crud for internationalization we don't do.
Figure out where we need utf8 support, and add it.
sh
The command shell situation is a big mess. We have three or four different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. I'm writing a new shell (bbsh) to unify the various
shells and configurably add the minimal set of bash features people
actually use. The hardest part is it has to configure down as small as
lash while providing lash's features. The rest is easy in comparison.
bzip2
Compression-side support.
init
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
depmod
busybox lacks a way to update module deps when running from firmware without the
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
modutils. The orig depmod is rather pointless to have to add to a firmware image
in when we already have a insmod/rmmod and friends.
Unify base64 handling.
There's base64 encoding and decoding going on in:
networking/wget.c:base64enc()
coreutils/uudecode.c:read_base64()
coreutils/uuencode.c:tbl_base64[]
networking/httpd.c:decodeBase64()
And probably elsewhere. That needs to be unified into libbb functions.
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
figure out which of our apps are compliant, and what we're missing that
we might actually care about.
Even better would be some kind of automated compliance test harness that
exercises each command line option and the various corner cases.
Internationalization
How much internationalization should we do?
The low hanging fruit is UTF-8 character set support. We should do this.
(Vodz pointed out the shell's cmdedit as needing work here. What else?)
We also have lots of hardwired english text messages. Consolidating this
into some kind of message table not only makes translation easier, but
also allows us to consolidate redundant (or close) strings.
We probably don't want to be bloated with locale support. (Not unless we
can cleanly export it from our underlying C library without having to
concern ourselves with it directly. Perhaps a few specific things like a
config option for "date" are low hanging fruit here?)
What level should things happen at? How much do we care about
internationalizing the text console when X11 and xterms are so much better
at it? (There's some infrastructure here we don't implement: The
"unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a
--unicode option to loadkeys. That implies a real loadkeys/dumpkeys
implementation to replace loadkmap/dumpkmap. Plus messing with console font
loading. Is it worth it, or do we just say "use X"?)
Individual compilation of applets.
It would be nice if busybox had the option to compile to individual applets,
for people who want an alternate implementation less bloated than the gnu
utils (or simply with less political baggage), but without it being one big
executable.
Turning libbb into a real dll is another possibility, especially if libbb
could export some of the other library interfaces we've already more or less
got the code for (like zlib).
buildroot - Make a "dogfood" option
Busybox 1.1 will be capable of replacing most gnu packages for real world
use, such as developing software or in a live CD. It needs wider testing.
Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file,
findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting
system should be self-hosting (I.E. able to rebuild itself from source
code). This means it would need (at least) binutils, gcc, and make, or
equivalents.
It would be a good "eating our own dogfood" test if buildroot had the option
of using a "make allyesconfig" busybox instead of the all of the above
packages. Anything that's wrong with the resulting system, we can fix. (It
would be nice to be able to upgrade busybox to be able to replace bash and
diffutils as well, but we're not there yet.)
One example of an existing system that does this already is Firmware Linux:
http://www.landley.net/code/firmware
initramfs
Busybox should have a sample initramfs build script. This depends on
bbsh, mdev, and switch_root.
mkdep
Write a mkdep that doesn't segfault if there's a directory it doesn't
have permission to read, isn't based on manually editing the output of
lexx and yacc, doesn't make such a mess under include/config, etc.
Group globals into unions of structures.
Go through and turn all the global and static variables into structures,
and have all those structures be in a big union shared between processes,
so busybox uses less bss. (This is a big win on nommu machines.) See
sed.c and mdev.c for examples.
Go through bugs.busybox.net and close out all of that somehow.
This one's open to everybody, but I'll wind up doing it...
Bernhard Fischer <rep.nop@anon.at>:
Makefile stuff:
make -j is broken, -j1 is forced atm
New debug options:
-Wlarger-than-127
Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE
Use bb_common_bufsiz1?
As yet unclaimed:
Stuff that needs to be done. All of this is fair game for 1.2.
build system
make -j is broken, -j1 is forced atm
Make sure that the flags get pinned in e.g. Rules.mak so when expanding them
later on you get the cached result without the need to re-evaluate them.
----
find
doesn't understand (), lots of susv3 stuff.
----
sh
The command shell situation is a big mess. We have three or four different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. Unifying the various shells and figuring out a configurable
way of adding the minimal set of bash features a given script uses is a big
job, but it would be a big improvement.
Note: Rob Landley (rob@landley.net) is working on a new unified shell called
bbsh, but it's a low priority...
---
diff
Make sure we handle empty files properly:
We should have a diff -u command. We have patch, we should have diff
(we only need to support unified diffs though).
Also, make sure we handle empty files properly:
From the patch man page:
   you can remove a file by sending out a context diff that compares
@@ -155,11 +48,17 @@ man
(How doclifter might work into this is anybody's guess.)
---
bzip2
Compression-side support.
---
init
General cleanup.
---
ar
Write support?
---
crond
turn FEATURE_DEBUG_OPT into ENABLE_FEATURE_CROND_DEBUG_OPT
mdev
Micro-udev.
Architectural issues:
@@ -175,6 +74,46 @@ bb_close() with fsync()
You need to call fsync() if you care about errors that occur after write(),
but that can have a big performance impact. So make it a config option.
---
Unify base64 handling.
There's base64 encoding and decoding going on in:
networking/wget.c:base64enc()
coreutils/uudecode.c:read_base64()
coreutils/uuencode.c:tbl_base64[]
networking/httpd.c:decodeBase64()
And probably elsewhere. That needs to be unified into libbb functions.
---
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
figure out which of our apps are compliant, and what we're missing that
we might actually care about.
Even better would be some kind of automated compliance test harness that
exercises each command line option and the various corner cases.
---
Internationalization
How much internationalization should we do?
The low hanging fruit is UTF-8 character set support. We should do this.
(Vodz pointed out the shell's cmdedit as needing work here. What else?)
We also have lots of hardwired english text messages. Consolidating this
into some kind of message table not only makes translation easier, but
also allows us to consolidate redundant (or close) strings.
We probably don't want to be bloated with locale support. (Not unless we can
cleanly export it from our underlying C library without having to concern
ourselves with it directly. Perhaps a few specific things like a config
option for "date" are low hanging fruit here?)
What level should things happen at? How much do we care about
internationalizing the text console when X11 and xterms are so much better
at it? (There's some infrastructure here we don't implement: The
"unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a
--unicode option to loadkeys. That implies a real loadkeys/dumpkeys
implementation to replace loadkmap/dumpkmap. Plus messing with console font
loading. Is it worth it, or do we just say "use X"?)
---
Unify archivers
Lots of archivers have the same general infrastructure. The directory
traversal code should be factored out, and the guts of each archiver could
@@ -190,12 +129,45 @@ Text buffer support.
a whole file into memory and act on it. There might be an opportunity
for shared code in there that could be moved into libbb...
---
Individual compilation of applets.
It would be nice if busybox had the option to compile to individual applets,
for people who want an alternate implementation less bloated than the gnu
utils (or simply with less political baggage), but without it being one big
executable.
Turning libbb into a real dll is another possibility, especially if libbb
could export some of the other library interfaces we've already more or less
got the code for (like zlib).
---
buildroot - Make a "dogfood" option
Busybox 1.1 will be capable of replacing most gnu packages for real world use,
such as developing software or in a live CD. It needs wider testing.
Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file,
findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting
system should be self-hosting (I.E. able to rebuild itself from source code).
This means it would need (at least) binutils, gcc, and make, or equivalents.
It would be a good "eating our own dogfood" test if buildroot had the option
of using a "make allyesconfig" busybox instead of the all of the above
packages. Anything that's wrong with the resulting system, we can fix. (It
would be nice to be able to upgrade busybox to be able to replace bash and
diffutils as well, but we're not there yet.)
One example of an existing system that does this already is Firmware Linux:
http://www.landley.net/code/firmware
---
initramfs
Busybox should have a sample initramfs build script. This depends on
bbsh, mdev, and switch_root.
---
Memory Allocation
We have a CONFIG_BUFFER mechanism that lets us select whether to do memory
allocation on the stack or the heap. Unfortunately, we're not using it much.
We need to audit our memory allocations and turn a lot of malloc/free calls
into RESERVE_CONFIG_BUFFER/RELEASE_CONFIG_BUFFER.
For a start, see e.g. make EXTRA_CFLAGS=-Wlarger-than-64
For a start, see e.g. make CFLAGS_EXTRA=-Wlarger-than-64
And while we're at it, many of the CONFIG_FEATURE_CLEAN_UP #ifdefs will be
optimized out by the compiler in the stack allocation case (since there's no
@@ -275,24 +247,6 @@ Minor stuff:
if(!ioctl (fd, WDIOC_GETTIMEOUT, &tmo)) timer_duration = 1 + (tmo / 2);
Unfortunately, that needs linux/watchdog.h and that contains unfiltered
kernel types on some distros, which breaks the build.
---
use bb_error_msg where appropriate: See
egrep "(printf.*\([[:space:]]*(stderr|2)|[^_]write.*\([[:space:]]*(stderr|2))"
---
use bb_perror_msg where appropriate: See
egrep "[^_]perror"
---
Remove superfluous fmt occurances: e.g.
fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
---
possible code duplication ingroup() and is_a_group_member()
---
unify itoa: netstat.c, hush.c, lash.c, msh.c
Put one single, robust version into e.g. safe_strtol.c
---
Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c
---
Code cleanup:
@@ -303,6 +257,4 @@ bzero() -> memset()
---
sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
---
vdprintf() -> similar sized functionality
---
+1 -1
View File
@@ -12,7 +12,7 @@ top_builddir=..
endif
srcdir=$(top_srcdir)/applets
APPLETS_DIR:=./
include $(top_srcdir)/Rules.mak
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
+82 -91
View File
@@ -6,33 +6,48 @@
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
* Licensed under GPLv2 or later, see file License in this tarball for details.
*/
#include "busybox.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "busybox.h"
const char usage_messages[] =
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
static const char usage_messages[] =
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
;
#undef MAKE_USAGE
#else
#define usage_messages 0
#endif /* ENABLE_SHOW_USAGE */
#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. */
@@ -41,6 +56,7 @@ const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
#ifdef CONFIG_FEATURE_SUID_CONFIG
#include <sys/stat.h>
#include <ctype.h>
#include "pwd_.h"
#include "grp_.h"
@@ -96,7 +112,7 @@ static char *get_trimmed_slice(char *s, char *e)
/* Next, advance past all leading space and return a ptr to the
* first non-space char; possibly the terminating nul. */
return skip_whitespace(s);
return (char *) bb_skip_whitespace(s);
}
@@ -237,7 +253,7 @@ static void parse_config_file(void)
/* Get the specified mode. */
e = skip_whitespace(e+1);
e = (char *) bb_skip_whitespace(e+1);
for (i=0 ; i < 3 ; i++) {
const char *q;
@@ -250,7 +266,7 @@ static void parse_config_file(void)
/* Now get the the user/group info. */
s = skip_whitespace(e);
s = (char *) bb_skip_whitespace(e);
/* Note: We require whitespace between the mode and the
* user/group info. */
@@ -343,15 +359,22 @@ static void check_suid (struct BB_applet *applet)
bb_error_msg_and_die ("You have no permission to run this applet!");
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
xsetgid(sct->m_gid);
} else xsetgid(rgid); /* no sgid -> drop */
if (setegid (sct->m_gid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper GID for applet!");
} else
setgid (rgid); /* no sgid -> drop */
if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
else xsetuid(ruid); /* no suid -> drop */
if (sct->m_mode & S_ISUID) {
if (seteuid (sct->m_uid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper UID for applet!");
} else
setuid (ruid); /* no suid -> drop */
} else {
/* default: drop all privileges */
xsetgid(rgid);
xsetuid(ruid);
setgid (rgid);
setuid (ruid);
}
return;
} else {
@@ -367,10 +390,11 @@ static void check_suid (struct BB_applet *applet)
#endif
if (applet->need_suid == _BB_SUID_ALWAYS) {
if (geteuid()) bb_error_msg_and_die("Applet requires root privileges!");
if (geteuid () != 0)
bb_error_msg_and_die ("This applet requires root privileges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
xsetgid(rgid); /* drop all privileges */
xsetuid(ruid);
setgid (rgid); /* drop all privileges */
setuid (ruid);
}
}
#else
@@ -379,99 +403,66 @@ static void check_suid (struct BB_applet *applet)
#if ENABLE_FEATURE_COMPRESS_USAGE
#include "usage_compressed.h"
#include "unarchive.h"
static const char *unpack_usage_messages(void)
{
int input[2], output[2], pid;
char *buf;
if(pipe(input) < 0 || pipe(output) < 0)
exit(1);
pid = fork();
switch (pid) {
case -1: /* error */
exit(1);
case 0: /* child */
close(input[1]);
close(output[0]);
uncompressStream(input[0], output[1]);
exit(0);
}
/* parent */
close(input[0]);
close(output[1]);
pid = fork();
switch (pid) {
case -1: /* error */
exit(1);
case 0: /* child */
full_write(input[1], packed_usage, sizeof(packed_usage));
exit(0);
}
/* parent */
close(input[1]);
buf = xmalloc(SIZEOF_usage_messages);
full_read(output[0], buf, SIZEOF_usage_messages);
return buf;
}
#else
#define unpack_usage_messages() usage_messages
#endif /* ENABLE_FEATURE_COMPRESS_USAGE */
void bb_show_usage (void)
{
if (ENABLE_SHOW_USAGE) {
const char *format_string;
const char *usage_string = unpack_usage_messages();
int i;
const char *format_string;
const char *usage_string = usage_messages;
int i;
for (i = applet_using - applets; i > 0;)
if (!*usage_string++) --i;
format_string = "%s\n\nUsage: %s %s\n\n";
if (*usage_string == '\b')
format_string = "%s\n\nNo help available.\n\n";
fprintf (stderr, format_string, bb_msg_full_version,
applet_using->name, usage_string);
for (i = applet_using - applets; i > 0;) {
if (!*usage_string++) {
--i;
}
}
format_string = "%s\n\nUsage: %s %s\n\n";
if (*usage_string == '\b')
format_string = "%s\n\nNo help available.\n\n";
fprintf (stderr, format_string, bb_msg_full_version, applet_using->name,
usage_string);
exit (bb_default_error_retval);
}
static int applet_name_compare(const void *name, const void *vapplet)
static int applet_name_compare (const void *x, const void *y)
{
const struct BB_applet *applet = vapplet;
const char *name = x;
const struct BB_applet *applet = y;
return strcmp(name, applet->name);
return strcmp (name, applet->name);
}
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
struct BB_applet *find_applet_by_name (const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
return bsearch (name, applets, NUM_APPLETS, sizeof (struct BB_applet),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
void run_applet_by_name (const char *name, int argc, char **argv)
{
if (ENABLE_FEATURE_SUID_CONFIG) parse_config_file();
if(ENABLE_FEATURE_SUID_CONFIG) parse_config_file ();
if (!strncmp(name, "busybox", 7)) busybox_main(argc, argv);
if(!strncmp(name, "busybox", 7)) busybox_main(argc, argv);
/* Do a binary search to find the applet entry given the name. */
applet_using = find_applet_by_name(name);
if (applet_using) {
if(applet_using) {
bb_applet_name = applet_using->name;
if(argc==2 && !strcmp(argv[1], "--help")) bb_show_usage();
if(ENABLE_FEATURE_SUID) check_suid(applet_using);
exit((*(applet_using->main))(argc, argv));
if(argc==2 && !strcmp(argv[1], "--help")) bb_show_usage ();
if(ENABLE_FEATURE_SUID) check_suid (applet_using);
exit ((*(applet_using->main)) (argc, argv));
}
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+10 -7
View File
@@ -1,15 +1,10 @@
/* vi: set sw=4 ts=4: */
/*
* BusyBox' main applet dispatcher.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#if ENABLE_LOCALE_SUPPORT
#include <locale.h>
#else
@@ -148,7 +143,15 @@ int busybox_main(int argc, char **argv)
printf("\n\n");
exit(0);
}
} else run_applet_by_name(argv[1], argc-1, argv+1);
} else run_applet_by_name(bb_applet_name=argv[1], argc-1, argv+1);
bb_error_msg_and_die("applet not found");
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+16 -40
View File
@@ -5,22 +5,18 @@ export LC_CTYPE=POSIX
prefix=${1}
if [ -z "$prefix" ]; then
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
exit 1;
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
exit 1;
fi
h=`sort busybox.links | uniq`
cleanup="0"
noclobber="0"
case "$2" in
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
--cleanup) cleanup="1";;
--noclobber) noclobber="1";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
esac
if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
if [ "$DO_INSTALL_LIBS" != "n" ]; then
# get the target dir for the libs
# assume it starts with lib
libdir=$($CC -print-file-name=libc.so | \
@@ -38,22 +34,6 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
fi
done
fi
if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
sub_shell_it=`
cd "$prefix"
for d in usr/sbin usr/bin sbin bin ; do
pd=$PWD
if [ -d "$d" ]; then
cd $d
ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
fi
cd "$pd"
done
`
fi
rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
@@ -62,33 +42,29 @@ for i in $h ; do
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
bb_path="$prefix/bin/busybox"
else
case "$appdir" in
case "$appdir" in
/)
bb_path="bin/busybox"
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
fi
if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
else
echo " $prefix$i already exists"
esac
fi
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
done
exit 0
-7
View File
@@ -1,10 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Version stuff.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#ifndef BB_EXTRA_VERSION
+20 -20
View File
@@ -29,7 +29,7 @@ config CONFIG_AR
probably say N here.
config CONFIG_FEATURE_AR_LONG_FILENAMES
bool "Enable support for long filenames (not need for debs)"
bool " Enable support for long filenames (not need for debs)"
default n
depends on CONFIG_AR
help
@@ -89,7 +89,7 @@ config CONFIG_DPKG_DEB
probably say N here.
config CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
bool "extract only (-x)"
bool " extract only (-x)"
default n
depends on CONFIG_DPKG_DEB
help
@@ -106,7 +106,7 @@ config CONFIG_GUNZIP
an archive, without decompressing it.
config CONFIG_FEATURE_GUNZIP_UNCOMPRESS
bool "Uncompress support"
bool " Uncompress support"
default n
depends on CONFIG_GUNZIP
help
@@ -142,7 +142,7 @@ config CONFIG_TAR
UNIX archive program.
config CONFIG_FEATURE_TAR_CREATE
bool "Enable archive creation"
bool " Enable archive creation"
default y
depends on CONFIG_TAR
help
@@ -150,7 +150,7 @@ config CONFIG_FEATURE_TAR_CREATE
tar archives using the `-c' option.
config CONFIG_FEATURE_TAR_BZIP2
bool "Enable -j option to handle .tar.bz2 files"
bool " Enable -j option to handle .tar.bz2 files"
default n
depends on CONFIG_TAR
help
@@ -158,7 +158,7 @@ config CONFIG_FEATURE_TAR_BZIP2
archives compressed with bzip2.
config CONFIG_FEATURE_TAR_LZMA
bool "Enable -a option to handle .tar.lzma files"
bool " Enable -a option to handle .tar.lzma files"
default n
depends on CONFIG_TAR
help
@@ -166,7 +166,7 @@ config CONFIG_FEATURE_TAR_LZMA
archives compressed with lzma.
config CONFIG_FEATURE_TAR_FROM
bool "Enable -X (exclude from) and -T (include from) options)"
bool " Enable -X (exclude from) and -T (include from) options)"
default n
depends on CONFIG_TAR
help
@@ -174,7 +174,7 @@ config CONFIG_FEATURE_TAR_FROM
a list of files to include or exclude from an archive.
config CONFIG_FEATURE_TAR_GZIP
bool "Enable -z option"
bool " Enable -z option"
default y
depends on CONFIG_TAR
help
@@ -182,15 +182,15 @@ config CONFIG_FEATURE_TAR_GZIP
when creating or extracting tar gziped archives.
config CONFIG_FEATURE_TAR_COMPRESS
bool "Enable -Z option"
bool " Enable -Z option"
default n
depends on CONFIG_TAR
help
If you enable this option tar will be able to call uncompress,
when extracting .tar.Z archives.
config CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
bool "Enable support for old tar header format"
config CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
bool " Enable support for old tar header format"
default N
depends on CONFIG_TAR
help
@@ -199,7 +199,7 @@ config CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
repacking your ancient archives with the new format.
config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
bool "Enable support for some GNU tar extensions"
bool " Enable support for some GNU tar extensions"
default y
depends on CONFIG_TAR
help
@@ -207,9 +207,9 @@ config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
linknames.
config CONFIG_FEATURE_TAR_LONG_OPTIONS
bool "Enable long options"
bool " Enable long options"
default n
depends on CONFIG_TAR && CONFIG_GETOPT_LONG
depends on CONFIG_TAR
help
Enable use of long options, increases size by about 400 Bytes
@@ -236,11 +236,11 @@ config CONFIG_UNLZMA
should probably say N here.
config CONFIG_FEATURE_LZMA_FAST
bool "Optimze unlzma for speed"
bool " Optimze unlzma for speed"
default n
depends on CONFIG_UNLZMA
help
This option reduces decompression time by about 33% at the cost of
This option reduce decompression time by about 33% at the cost of
a 2K bigger binary.
config CONFIG_UNZIP
@@ -257,7 +257,7 @@ comment "Common options for cpio and tar"
depends on CONFIG_CPIO || CONFIG_TAR
config CONFIG_FEATURE_UNARCHIVE_TAPE
bool "Enable tape drive support"
bool " Enable tape drive support"
default n
depends on CONFIG_CPIO || CONFIG_TAR
help
@@ -267,7 +267,7 @@ comment "Common options for dpkg and dpkg_deb"
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
config CONFIG_FEATURE_DEB_TAR_GZ
bool "gzip debian packages (normal)"
bool " gzip debian packages (normal)"
default y if CONFIG_DPKG || CONFIG_DPKG_DEB
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
help
@@ -276,7 +276,7 @@ config CONFIG_FEATURE_DEB_TAR_GZ
If you want compatibility with standard .deb's you should say yes here.
config CONFIG_FEATURE_DEB_TAR_BZ2
bool "bzip2 debian packages"
bool " bzip2 debian packages"
default n
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
help
@@ -287,7 +287,7 @@ config CONFIG_FEATURE_DEB_TAR_BZ2
use an internal control.tar.bz2 or data.tar.bz2.
config CONFIG_FEATURE_DEB_TAR_LZMA
bool "lzma debian packages"
bool " lzma debian packages"
default n
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
help
+1 -1
View File
@@ -12,7 +12,7 @@ top_builddir=..
endif
ARCHIVAL_DIR:=./
srcdir=$(top_srcdir)/archival
include $(top_srcdir)/Rules.mak
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
+15 -3
View File
@@ -7,7 +7,19 @@
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
* There is no single standard to adhere to so ar may not portable
* between different systems
@@ -85,10 +97,10 @@ int ar_main(int argc, char **argv)
while (optind < argc) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), argv[optind++]);
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind++]);
}
xread(archive_handle->src_fd, magic, 7);
archive_xread_all(archive_handle, magic, 7);
if (strncmp(magic, "!<arch>", 7) != 0) {
bb_error_msg_and_die("Invalid ar magic");
}
+4 -6
View File
@@ -1,9 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
@@ -42,18 +41,16 @@ int bunzip2_main(int argc, char **argv)
/* Check that the input is sane. */
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
bb_error_msg_and_die("Compressed data not read from terminal. Use -f to force it.");
bb_error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
}
if (filename) {
struct stat stat_buf;
char *extension=filename+strlen(filename)-4;
if (strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("Invalid extension");
}
xstat(filename, &stat_buf);
*extension=0;
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
} else dst_fd = STDOUT_FILENO;
status = uncompressStream(src_fd, dst_fd);
if(filename) {
@@ -65,3 +62,4 @@ int bunzip2_main(int argc, char **argv)
return status;
}
/* vi:set ts=4: */
+14 -2
View File
@@ -4,7 +4,19 @@
*
* Copyright (C) 2001 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Limitations:
* Doesn't check CRC's
@@ -76,7 +88,7 @@ int cpio_main(int argc, char **argv)
while (optind < argc) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), argv[optind]);
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
optind++;
}
+137 -23
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dpkg implementation for busybox.
* This is not meant as a replacement for dpkg
@@ -8,7 +7,19 @@
*
* Started life as a busybox implementation of udpkg
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
@@ -545,7 +556,7 @@ static unsigned int fill_package_struct(char *control_buffer)
"Conflicts", "Suggests", "Recommends", "Enhances", 0
};
common_node_t *new_node = (common_node_t *) xzalloc(sizeof(common_node_t));
common_node_t *new_node = (common_node_t *) xcalloc(1, sizeof(common_node_t));
char *field_name;
char *field_value;
int field_start = 0;
@@ -666,7 +677,8 @@ static void set_status(const unsigned int status_node_num, const char *new_value
bb_error_msg_and_die("DEBUG ONLY: this shouldnt happen");
}
new_status = bb_xasprintf("%s %s %s", name_hashtable[want], name_hashtable[flag], name_hashtable[status]);
new_status = (char *) xmalloc(want_len + flag_len + status_len + 3);
sprintf(new_status, "%s %s %s", name_hashtable[want], name_hashtable[flag], name_hashtable[status]);
status_hashtable[status_node_num]->status = search_name_hashtable(new_status);
free(new_status);
return;
@@ -729,6 +741,79 @@ static void index_status_file(const char *filename)
return;
}
#if 0 /* this code is no longer used */
char *get_depends_field(common_node_t *package, const int depends_type)
{
char *depends = NULL;
char *old_sep = (char *)xcalloc(1, 3);
char *new_sep = (char *)xcalloc(1, 3);
int line_size = 0;
int depends_size;
int i;
for (i = 0; i < package->num_of_edges; i++) {
if ((package->edge[i]->type == EDGE_OR_PRE_DEPENDS) ||
(package->edge[i]->type == EDGE_OR_DEPENDS)) {
}
if ((package->edge[i]->type == depends_type) ||
(package->edge[i]->type == depends_type + 1)) {
/* Check if its the first time through */
depends_size = 8 + strlen(name_hashtable[package->edge[i]->name])
+ strlen(name_hashtable[package->edge[i]->version]);
line_size += depends_size;
depends = (char *) xrealloc(depends, line_size + 1);
/* Check to see if this dependency is the type we are looking for
* +1 to check for 'extra' types, e.g. ored dependecies */
strcpy(old_sep, new_sep);
if (package->edge[i]->type == depends_type) {
strcpy(new_sep, ", ");
}
else if (package->edge[i]->type == depends_type + 1) {
strcpy(new_sep, "| ");
}
if (depends_size == line_size) {
strcpy(depends, "");
} else {
if ((strcmp(old_sep, "| ") == 0) && (strcmp(new_sep, "| ") == 0)) {
strcat(depends, " | ");
} else {
strcat(depends, ", ");
}
}
strcat(depends, name_hashtable[package->edge[i]->name]);
if (strcmp(name_hashtable[package->edge[i]->version], "NULL") != 0) {
if (package->edge[i]->operator == VER_EQUAL) {
strcat(depends, " (= ");
}
else if (package->edge[i]->operator == VER_LESS) {
strcat(depends, " (<< ");
}
else if (package->edge[i]->operator == VER_LESS_EQUAL) {
strcat(depends, " (<= ");
}
else if (package->edge[i]->operator == VER_MORE) {
strcat(depends, " (>> ");
}
else if (package->edge[i]->operator == VER_MORE_EQUAL) {
strcat(depends, " (>= ");
} else {
strcat(depends, " (");
}
strcat(depends, name_hashtable[package->edge[i]->version]);
strcat(depends, ")");
}
}
}
return(depends);
}
#endif
static void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
{
char *name;
@@ -875,7 +960,9 @@ static void write_status_file(deb_file_t **deb_file)
/* Create a separate backfile to dpkg */
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
struct stat stat_buf;
xstat("/var/lib/dpkg/status", &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 because status
* file doesnt exist, maybe we are starting from scratch */
bb_error_msg("No status file found, creating new one");
@@ -940,9 +1027,11 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
package_hashtable[package_num]->edge[j]->operator);
if (package_hashtable[conflicts_package_num] == NULL) {
/* create a new package */
common_node_t *new_node = (common_node_t *) xzalloc(sizeof(common_node_t));
common_node_t *new_node = (common_node_t *) xmalloc(sizeof(common_node_t));
new_node->name = package_hashtable[package_num]->edge[j]->name;
new_node->version = package_hashtable[package_num]->edge[j]->version;
new_node->num_of_edges = 0;
new_node->edge = NULL;
package_hashtable[conflicts_package_num] = new_node;
}
conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1));
@@ -1022,6 +1111,15 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
continue;
}
#if 0
/* This might be needed so we don't complain about
* things which are broken but unrelated to the
* packages that are currently being installed
*/
if (state_status == search_name_hashtable("installed"))
continue;
#endif
/* 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 :-)
@@ -1181,10 +1279,15 @@ static int run_package_script(const char *package_name, const char *script_type)
char *script_path;
int result;
script_path = bb_xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
script_path = xmalloc(strlen(package_name) + strlen(script_type) + 21);
sprintf(script_path, "/var/lib/dpkg/info/%s.%s", package_name, script_type);
/* If the file doesnt exist is isnt a fatal */
result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
if (lstat(script_path, &path_stat) < 0) {
result = EXIT_SUCCESS;
} else {
result = system(script_path);
}
free(script_path);
return(result);
}
@@ -1198,11 +1301,13 @@ static char **all_control_list(const char *package_name)
char **remove_files;
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = xzalloc(sizeof(all_control_files));
remove_files = xmalloc(sizeof(all_control_files));
while (all_control_files[i]) {
remove_files[i] = bb_xasprintf("/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
remove_files[i] = xmalloc(strlen(package_name) + strlen(all_control_files[i]) + 21);
sprintf(remove_files[i], "/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
i++;
}
remove_files[sizeof(all_control_files)/sizeof(char*) - 1] = NULL;
return(remove_files);
}
@@ -1295,9 +1400,11 @@ static void remove_package(const unsigned int package_num, int noisy)
free_array(remove_files);
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
exclude_files = xzalloc(sizeof(char*) * 3);
exclude_files = xmalloc(sizeof(char*) * 3);
exclude_files[0] = bb_xstrdup(conffile_name);
exclude_files[1] = bb_xasprintf("/var/lib/dpkg/info/%s.postrm", package_name);
exclude_files[1] = xmalloc(package_name_length + 27);
sprintf(exclude_files[1], "/var/lib/dpkg/info/%s.postrm", package_name);
exclude_files[2] = NULL;
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
@@ -1333,7 +1440,8 @@ static void purge_package(const unsigned int package_num)
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
remove_files = create_list(list_name);
exclude_files = xzalloc(sizeof(char*));
exclude_files = xmalloc(sizeof(char*));
exclude_files[0] = NULL;
/* Some directories cant be removed straight away, so do multiple passes */
while (remove_file_array(remove_files, exclude_files));
@@ -1376,10 +1484,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), "control.tar.gz");
ar_handle->accept = llist_add_to(NULL, "control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), "control.tar.bz2");
ar_handle->accept = llist_add_to(ar_handle->accept, "control.tar.bz2");
#endif
/* Assign the tar handle as a subarchive of the ar handle */
@@ -1398,10 +1506,10 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), "data.tar.gz");
ar_handle->accept = llist_add_to(NULL, "data.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), "data.tar.bz2");
ar_handle->accept = llist_add_to(ar_handle->accept, "data.tar.bz2");
#endif
/* Assign the tar handle as a subarchive of the ar handle */
@@ -1428,7 +1536,9 @@ static void data_extract_all_prefix(archive_handle_t *archive_handle)
name_ptr += strspn(name_ptr, "./");
if (name_ptr[0] != '\0') {
archive_handle->file_header->name = bb_xasprintf("%s%s", archive_handle->buffer, name_ptr);
archive_handle->file_header->name = xmalloc(strlen(archive_handle->buffer) + 2 + strlen(name_ptr));
strcpy(archive_handle->file_header->name, archive_handle->buffer);
strcat(archive_handle->file_header->name, name_ptr);
data_extract_all(archive_handle);
}
return;
@@ -1457,13 +1567,15 @@ static void unpack_package(deb_file_t *deb_file)
}
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
info_prefix = bb_xasprintf("/var/lib/dpkg/info/%s.", package_name);
info_prefix = (char *) xmalloc(strlen(package_name) + 20 + 4 + 2);
sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name);
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_control(archive_handle);
while(all_control_files[i]) {
char *c = bb_xasprintf("./%s", all_control_files[i]);
llist_add_to(&accept_list, c);
char *c = (char *) xmalloc(3 + bb_strlen(all_control_files[i]));
sprintf(c, "./%s", all_control_files[i]);
accept_list= llist_add_to(accept_list, c);
i++;
}
archive_handle->sub_archive->accept = accept_list;
@@ -1587,13 +1699,13 @@ int dpkg_main(int argc, char **argv)
while (optind < argc) {
/* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
deb_file = xrealloc(deb_file, sizeof(deb_file_t *) * (deb_count + 2));
deb_file[deb_count] = (deb_file_t *) xzalloc(sizeof(deb_file_t));
deb_file[deb_count] = (deb_file_t *) xmalloc(sizeof(deb_file_t));
if (dpkg_opt & dpkg_opt_filename) {
archive_handle_t *archive_handle;
llist_t *control_list = NULL;
/* Extract the control file */
llist_add_to(&control_list, "./control");
control_list = llist_add_to(NULL, "./control");
archive_handle = init_archive_deb_ar(argv[optind]);
init_archive_deb_control(archive_handle);
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
@@ -1630,6 +1742,8 @@ int dpkg_main(int argc, char **argv)
}
}
else if (dpkg_opt & dpkg_opt_package_name) {
deb_file[deb_count]->filename = NULL;
deb_file[deb_count]->control_file = NULL;
deb_file[deb_count]->package = search_package_hashtable(
search_name_hashtable(argv[optind]),
search_name_hashtable("ANY"), VER_ANY);
+20 -10
View File
@@ -1,8 +1,18 @@
/* vi: set sw=4 ts=4: */
/*
* dpkg-deb packs, unpacks and provides information about Debian archives.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <stdlib.h>
@@ -36,13 +46,13 @@ int dpkg_deb_main(int argc, char **argv)
ar_archive->filter = filter_accept_list_reassign;
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_archive->accept), "data.tar.gz");
llist_add_to(&control_tar_llist, "control.tar.gz");
ar_archive->accept = llist_add_to(NULL, "data.tar.gz");
control_tar_llist = llist_add_to(NULL, "control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_archive->accept), "data.tar.bz2");
llist_add_to(&control_tar_llist, "control.tar.bz2");
ar_archive->accept = llist_add_to(ar_archive->accept, "data.tar.bz2");
control_tar_llist = llist_add_to(control_tar_llist, "control.tar.bz2");
#endif
bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
@@ -65,7 +75,7 @@ int dpkg_deb_main(int argc, char **argv)
* it should accept a second argument which specifies a
* specific field to print */
ar_archive->accept = control_tar_llist;
llist_add_to(&(tar_archive->accept), "./control");
tar_archive->accept = llist_add_to(NULL, "./control");
tar_archive->filter = filter_accept_list;
tar_archive->action_data = data_extract_to_stdout;
}
@@ -89,8 +99,8 @@ int dpkg_deb_main(int argc, char **argv)
extract_dir = argv[optind];
}
if (extract_dir) {
mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */
bb_xchdir(extract_dir);
mkdir(extract_dir, 0777);
chdir(extract_dir);
}
unpack_ar_archive(ar_archive);
+41 -5
View File
@@ -14,7 +14,20 @@
* General cleanup to better adhere to the style guide and make use of standard
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
@@ -27,6 +40,26 @@
* 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 <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -104,18 +137,21 @@ int gunzip_main(int argc, char **argv)
bb_error_msg_and_die("Invalid extension");
}
/* Open output file (with correct permissions) */
dst_fd = bb_xopen3(new_path, O_WRONLY | O_CREAT, stat_buf.st_mode);
/* Open output file */
dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
/* Set permissions on the file */
chmod(new_path, stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = old_path;
}
/* do the decompression, and cleanup */
if (xread_char(src_fd) == 0x1f) {
if (bb_xread_char(src_fd) == 0x1f) {
unsigned char magic2;
magic2 = xread_char(src_fd);
magic2 = bb_xread_char(src_fd);
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
if (magic2 == 0x9d) {
status = uncompress(src_fd, dst_fd);
+58 -24
View File
@@ -16,7 +16,11 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* These defines are very important for BusyBox. Without these,
* 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
#include <stdlib.h>
#include <stdio.h>
@@ -83,11 +87,17 @@ typedef unsigned long ulg;
# endif
#endif
#ifdef DYN_ALLOC
# define DECLARE(type, array, size) static type * array
# define ALLOC(type, array, size) { \
array = (type*)xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type)); \
array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
}
# define FREE(array) {free(array), array=NULL;}
#else
# define DECLARE(type, array, size) static type array[size]
# define ALLOC(type, array, size)
# define FREE(array)
#endif
#define tab_suffix window
#define tab_prefix prev /* hash link (see deflate.c) */
@@ -144,6 +154,15 @@ typedef int file_t; /* Do not use stdio */
#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\
flush_outbuf();}
/* Output a 32 bit value to the bit stream, lsb first */
#if 0
#define put_long(n) { \
put_short((n) & 0xffff); \
put_short(((ulg)(n)) >> 16); \
}
#endif
#define seekable() 0 /* force sequential output */
#define translate_eol 0 /* no option -a yet */
@@ -274,7 +293,6 @@ static int ofd; /* output file descriptor */
static unsigned insize; /* valid bytes in inbuf */
static unsigned outcnt; /* bytes in output buffer */
static uint32_t *crc_32_tab;
/* Output a 16 bit value, lsb first */
static void put_short(ush w)
@@ -315,7 +333,7 @@ static void write_buf(int fd, void *buf, unsigned cnt)
unsigned n;
while ((n = write(fd, buf, cnt)) != cnt) {
if (n == (unsigned) (-1)) bb_error_msg_and_die(bb_msg_write_error);
if (n == (unsigned) (-1)) bb_error_msg_and_die("can't write");
cnt -= n;
buf = (void *) ((char *) buf + n);
}
@@ -326,13 +344,32 @@ static void write_buf(int fd, void *buf, unsigned cnt)
* pointer, then initialize the crc shift register contents instead.
* Return the current crc in either case.
*/
static uint32_t updcrc(uch * s, unsigned n)
static ulg updcrc(uch * s, unsigned n)
{
static uint32_t crc = ~0; /* shift register contents */
uint32_t c; /* temporary variable */
static ulg crc = (ulg) 0xffffffffL; /* shift register contents */
register ulg c; /* temporary variable */
static unsigned long crc_32_tab[256];
if (crc_32_tab[1] == 0x00000000L) {
unsigned long csr; /* crc shift register */
const unsigned long e = 0xedb88320L; /* polynomial exclusive-or pattern */
int i; /* counter for all possible eight bit values */
int k; /* byte being shifted into crc apparatus */
/* Compute table of CRC's. */
for (i = 1; i < 256; i++) {
csr = 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--)
csr = csr & 1 ? (csr >> 1) ^ e : csr >> 1;
crc_32_tab[i] = csr;
}
}
if (s == NULL) {
c = ~0;
c = 0xffffffffL;
} else {
c = crc;
if (n)
@@ -341,7 +378,7 @@ static uint32_t updcrc(uch * s, unsigned n)
} while (--n);
}
crc = c;
return ~c;
return c ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */
}
/* bits.c -- output variable-length bit strings
@@ -475,7 +512,7 @@ static void send_bits(int value, int length)
*/
static unsigned bi_reverse(unsigned code, int len)
{
unsigned res = 0;
register unsigned res = 0;
do {
res |= code & 1;
@@ -773,7 +810,7 @@ static void check_match(IPos start, IPos match, int length);
*/
static void lm_init(ush * flags)
{
unsigned j;
register unsigned j;
/* Initialize the hash table. */
memset(head, 0, HASH_SIZE * sizeof(*head));
@@ -823,9 +860,9 @@ static void lm_init(ush * flags)
static int longest_match(IPos cur_match)
{
unsigned chain_length = max_chain_length; /* max hash chain length */
uch *scan = window + strstart; /* current string */
uch *match; /* matched string */
int len; /* length of current match */
register uch *scan = window + strstart; /* current string */
register uch *match; /* matched string */
register int len; /* length of current match */
int best_len = prev_length; /* best match length so far */
IPos limit =
strstart > (IPos) MAX_DIST ? strstart - (IPos) MAX_DIST : NIL;
@@ -839,9 +876,9 @@ static int longest_match(IPos cur_match)
#if HASH_BITS < 8 || MAX_MATCH != 258
# error Code too clever
#endif
uch *strend = window + strstart + MAX_MATCH;
uch scan_end1 = scan[best_len - 1];
uch scan_end = scan[best_len];
register uch *strend = window + strstart + MAX_MATCH;
register uch scan_end1 = scan[best_len - 1];
register uch scan_end = scan[best_len];
/* Do not waste too much time if we already have a good match: */
if (prev_length >= good_match) {
@@ -928,7 +965,7 @@ static void check_match(IPos start, IPos match, int length)
*/
static void fill_window(void)
{
unsigned n, m;
register unsigned n, m;
unsigned more =
(unsigned) (window_size - (ulg) lookahead - (ulg) strstart);
/* Amount of free space at the end of the window. */
@@ -996,7 +1033,7 @@ static ulg deflate(void)
IPos prev_match; /* previous match */
int flush; /* set if current block must be flushed */
int match_available = 0; /* set if previous match exists */
unsigned match_length = MIN_MATCH - 1; /* length of best match */
register unsigned match_length = MIN_MATCH - 1; /* length of best match */
/* Process the input block. */
while (lookahead != 0) {
@@ -1186,9 +1223,6 @@ int gzip_main(int argc, char **argv)
ALLOC(uch, window, 2L * WSIZE);
ALLOC(ush, tab_prefix, 1L << BITS);
/* Initialise the CRC32 table */
crc_32_tab = bb_crc32_filltable(0);
clear_bufs();
part_nb = 0;
@@ -1209,8 +1243,8 @@ int gzip_main(int argc, char **argv)
inFileNum = STDIN_FILENO;
outFileNum = STDOUT_FILENO;
} else {
inFileNum = bb_xopen3(argv[i], O_RDONLY, 0);
if (fstat(inFileNum, &statBuf) < 0)
inFileNum = open(argv[i], O_RDONLY);
if (inFileNum < 0 || fstat(inFileNum, &statBuf) < 0)
bb_perror_msg_and_die("%s", argv[i]);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
@@ -2382,7 +2416,7 @@ static void set_file_type(void)
*/
static uint32_t crc; /* crc on uncompressed file data */
static ulg crc; /* crc on uncompressed file data */
static long header_bytes; /* number of bytes in gzip header */
static void put_long(ulg n)
+1 -1
View File
@@ -25,7 +25,7 @@ top_builddir=../..
endif
srcdir=$(top_srcdir)/archival/libunarchive
LIBUNARCHIVE_DIR:=./
include $(top_srcdir)/Rules.mak
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
+1 -1
View File
@@ -29,6 +29,7 @@ LIBUNARCHIVE-y:= \
header_list.o \
header_verbose_list.o \
\
archive_xread_all.o \
archive_xread_all_eof.o \
\
seek_by_char.o \
@@ -66,7 +67,6 @@ LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
LIBUNARCHIVE-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
LIBUNARCHIVE-y:=$(sort $(LIBUNARCHIVE-y))
+32
View File
@@ -0,0 +1,32 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "unarchive.h"
#include "libbb.h"
void archive_xread_all(const archive_handle_t *archive_handle, void *buf, const size_t count)
{
ssize_t size;
size = bb_full_read(archive_handle->src_fd, buf, count);
if (size != count) {
bb_error_msg_and_die("Short read");
}
return;
}
+14 -3
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
@@ -13,7 +24,7 @@ ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *b
{
ssize_t size;
size = full_read(archive_handle->src_fd, buf, count);
size = bb_full_read(archive_handle->src_fd, buf, count);
if ((size != 0) && (size != count)) {
bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count);
}
+7 -11
View File
@@ -1,7 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <unistd.h>
#include "libbb.h"
@@ -20,7 +16,7 @@ void check_header_gzip(int src_fd)
} formated;
} header;
xread(src_fd, header.raw, 8);
bb_xread_all(src_fd, header.raw, 8);
/* Check the compression method */
if (header.formated.method != 8) {
@@ -32,10 +28,10 @@ void check_header_gzip(int src_fd)
/* bit 2 set: extra field present */
unsigned char extra_short;
extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
extra_short = bb_xread_char(src_fd) + (bb_xread_char(src_fd) << 8);
while (extra_short > 0) {
/* Ignore extra field */
xread_char(src_fd);
bb_xread_char(src_fd);
extra_short--;
}
}
@@ -43,19 +39,19 @@ void check_header_gzip(int src_fd)
/* Discard original name if any */
if (header.formated.flags & 0x08) {
/* bit 3 set: original file name present */
while(xread_char(src_fd) != 0);
while(bb_xread_char(src_fd) != 0);
}
/* Discard file comment if any */
if (header.formated.flags & 0x10) {
/* bit 4 set: file comment present */
while(xread_char(src_fd) != 0);
while(bb_xread_char(src_fd) != 0);
}
/* Read the header checksum */
if (header.formated.flags & 0x02) {
xread_char(src_fd);
xread_char(src_fd);
bb_xread_char(src_fd);
bb_xread_char(src_fd);
}
return;
+13 -2
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/types.h>
+13 -2
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/types.h>
+15 -5
View File
@@ -1,8 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright 2002 Glenn McGrath
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "libbb.h"
@@ -12,7 +21,8 @@ void data_extract_to_buffer(archive_handle_t *archive_handle)
{
const unsigned int size = archive_handle->file_header->size;
archive_handle->buffer = xzalloc(size + 1);
archive_handle->buffer = xmalloc(size + 1);
xread(archive_handle->src_fd, archive_handle->buffer, size);
archive_xread_all(archive_handle, archive_handle->buffer, size);
archive_handle->buffer[size] = '\0';
}
+13 -2
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "unarchive.h"
+13 -2
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/types.h>
+20 -15
View File
@@ -1,12 +1,13 @@
/* vi: set sw=4 ts=4: */
/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
which also acknowledges contributions by Mike Burrows, David Wheeler,
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
Robert Sedgewick, and Jon L. Bentley.
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
which also acknowledges contributions by Mike Burrows, David Wheeler,
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
Robert Sedgewick, and Jon L. Bentley.
Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
This code is licensed under the LGPLv2:
LGPL http://www.gnu.org/copyleft/lgpl.html
*/
/*
@@ -23,7 +24,7 @@
I would ask that anyone benefiting from this work, especially those
using it in commercial products, consider making a donation to my local
non-profit hospice organization (www.hospiceacadiana.com) in the name of
the woman I loved, Toni W. Hagan, who passed away Feb. 12, 2003.
the woman I loved, Toni W. Hagan, who passed away Feb. 12, 2003.
Manuel
*/
@@ -37,8 +38,6 @@
#include "libbb.h"
#include "unarchive.h"
/* Constants for Huffman coding */
#define MAX_GROUPS 6
#define GROUP_SIZE 50 /* 64 would have been more efficient */
@@ -83,8 +82,8 @@ typedef struct {
/* The CRC values stored in the block header and calculated from the data */
uint32_t headerCRC, totalCRC, writeCRC;
uint32_t *crc32Table;
unsigned int crc32Table[256],headerCRC, totalCRC, writeCRC;
/* Intermediate buffer and its size (in bytes) */
unsigned int *dbuf, dbufSize;
@@ -619,7 +618,7 @@ decode_next_byte:
bd->writeCount=previous;
return (previous!=RETVAL_LAST_BLOCK) ? previous : gotcount;
}
bd->writeCRC=~0;
bd->writeCRC=0xffffffffUL;
pos=bd->writePos;
current=bd->writeCurrent;
goto decode_next_byte;
@@ -633,7 +632,7 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
int len)
{
bunzip_data *bd;
unsigned int i;
unsigned int i,j,c;
const unsigned int BZh0=(((unsigned int)'B')<<24)+(((unsigned int)'Z')<<16)
+(((unsigned int)'h')<<8)+(unsigned int)'0';
@@ -644,7 +643,8 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
/* Allocate bunzip_data. Most fields initialize to zero. */
bd=*bdp=xzalloc(i);
bd=*bdp=xmalloc(i);
memset(bd,0,sizeof(bunzip_data));
/* Setup input buffer */
@@ -655,7 +655,12 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
/* Init the CRC32 table (big endian) */
bd->crc32Table = bb_crc32_filltable(1);
for(i=0;i<256;i++) {
c=i<<24;
for(j=8;j;j--)
c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1);
bd->crc32Table[i]=c;
}
/* Setup for I/O error handling via longjmp */
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
#include "libbb.h"
/* uncompress for busybox -- (c) 2002 Robert Griebl
@@ -77,7 +76,7 @@ static unsigned char inbuf[IBUFSIZ + 64];
static unsigned char outbuf[OBUFSIZ + 2048];
static unsigned char htab[HSIZE];
static long int htab[HSIZE];
static unsigned short codetab[HSIZE];
#define htabof(i) htab[i]
@@ -116,7 +115,7 @@ int uncompress(int fd_in, int fd_out)
insize = 0;
inbuf[0] = xread_char(fd_in);
inbuf[0] = bb_xread_char(fd_in);
maxbits = inbuf[0] & BIT_MASK;
block_mode = inbuf[0] & BLOCK_MODE;
+24 -147
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
@@ -6,154 +5,29 @@
* Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
* Copyright (C) 1999-2005 Igor Pavlov
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <byteswap.h>
#include "libbb.h"
#include "unarchive.h"
#ifdef CONFIG_FEATURE_LZMA_FAST
# define speed_inline ATTRIBUTE_ALWAYS_INLINE
#else
# define speed_inline
#endif
typedef struct {
int fd;
uint8_t *ptr;
uint8_t *buffer;
uint8_t *buffer_end;
int buffer_size;
uint32_t code;
uint32_t range;
uint32_t bound;
} rc_t;
#define RC_TOP_BITS 24
#define RC_MOVE_BITS 5
#define RC_MODEL_TOTAL_BITS 11
/* Called twice: once at startup and once in rc_normalize() */
static void rc_read(rc_t * rc)
{
rc->buffer_size = read(rc->fd, rc->buffer, rc->buffer_size);
if (rc->buffer_size <= 0)
bb_error_msg_and_die("unexpected EOF");
rc->ptr = rc->buffer;
rc->buffer_end = rc->buffer + rc->buffer_size;
}
/* Called once */
static void rc_init(rc_t * rc, int fd, int buffer_size)
{
int i;
rc->fd = fd;
rc->buffer = xmalloc(buffer_size);
rc->buffer_size = buffer_size;
rc->buffer_end = rc->buffer + rc->buffer_size;
rc->ptr = rc->buffer_end;
rc->code = 0;
rc->range = 0xFFFFFFFF;
for (i = 0; i < 5; i++) {
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->code = (rc->code << 8) | *rc->ptr++;
}
}
/* Called once. TODO: bb_maybe_free() */
static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc->buffer);
}
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
static void rc_do_normalize(rc_t * rc)
{
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* Called 9 times */
/* Why rc_is_bit_0_helper exists?
* Because we want to always expose (rc->code < rc->bound) to optimizer
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
{
rc_normalize(rc);
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
}
/* Called ~10 times, but very small, thus inlined */
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
{
rc->range = rc->bound;
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
}
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
{
rc->range -= rc->bound;
rc->code -= rc->bound;
*p -= *p >> RC_MOVE_BITS;
}
/* Called 4 times in unlzma loop */
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
{
if (rc_is_bit_0(rc, p)) {
rc_update_bit_0(rc, p);
*symbol *= 2;
return 0;
} else {
rc_update_bit_1(rc, p);
*symbol = *symbol * 2 + 1;
return 1;
}
}
/* Called once */
static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
if (rc->code >= rc->range) {
rc->code -= rc->range;
return 1;
}
return 0;
}
/* Called twice */
static speed_inline void
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
{
int i = num_levels;
*symbol = 1;
while (i--)
rc_get_bit(rc, p + *symbol, symbol);
*symbol -= 1 << num_levels;
}
#include "rangecoder.h"
typedef struct {
@@ -245,8 +119,10 @@ int unlzma(int src_fd, int dst_fd)
pos_state_mask = (1 << pb) - 1;
literal_pos_mask = (1 << lp) - 1;
header.dict_size = SWAP_LE32(header.dict_size);
header.dst_size = SWAP_LE64(header.dst_size);
#if BB_BIG_ENDIAN
header.dict_size = bswap_32(header.dict_size);
header.dst_size = bswap_64(header.dst_size);
#endif
if (header.dict_size == 0)
header.dict_size = 1;
@@ -468,3 +344,4 @@ int unlzma(int src_fd, int dst_fd)
return 0;
}
/* vi:set ts=4: */
+103 -36
View File
@@ -21,6 +21,21 @@
* to free leaked bytebuffer memory (used in unzip.c), and some minor style
* guide cleanups by Ed Clark
*
* 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.
@@ -28,14 +43,38 @@
* 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.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#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 "libbb.h"
#include "unarchive.h"
typedef struct huft_s {
@@ -56,8 +95,8 @@ static unsigned int gunzip_outbuf_count; /* bytes in output buffer */
enum { gunzip_wsize = 0x8000 };
static unsigned char *gunzip_window;
static uint32_t *gunzip_crc_table;
uint32_t gunzip_crc;
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) */
@@ -116,8 +155,9 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current
/* 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() */
if (1 > (bytebuffer_size = safe_read(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;
}
@@ -128,6 +168,35 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current
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 *) xmalloc(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
@@ -163,7 +232,6 @@ static int huft_free(huft_t * t)
* 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, unsigned int *m)
@@ -173,17 +241,17 @@ int huft_build(unsigned int *b, const unsigned int n,
unsigned eob_len; /* length of end-of-block code (value 256) */
unsigned f; /* i repeats in table every f entries */
int g; /* maximum code length */
int htl; /* table level */
unsigned i; /* counter, current code */
unsigned j; /* counter */
int k; /* number of bits in current code */
unsigned *p; /* pointer into c[], b[], or v[] */
huft_t *q; /* points to current table */
int h; /* table level */
register unsigned i; /* counter, current code */
register unsigned j; /* counter */
register int k; /* number of bits in current code */
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 */
int ws[BMAX+1]; /* bits decoded stack */
int w; /* bits decoded */
register int w; /* bits decoded */
unsigned x[BMAX + 1]; /* bit offsets, then code stack */
unsigned *xp; /* pointer into x */
int y; /* number of dummy codes added */
@@ -244,7 +312,7 @@ int huft_build(unsigned int *b, const unsigned int 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 */
htl = -1; /* no tables yet--level -1 */
h = -1; /* no tables yet--level -1 */
w = ws[0] = 0; /* bits decoded */
u[0] = (huft_t *) NULL; /* just to keep compilers happy */
q = (huft_t *) NULL; /* ditto */
@@ -256,8 +324,8 @@ int huft_build(unsigned int *b, const unsigned int n,
while (a--) {
/* here i is the Huffman code of length k bits for value *p */
/* make tables up to required level */
while (k > ws[htl + 1]) {
w = ws[++htl];
while (k > ws[h + 1]) {
w = ws[++h];
/* compute minimum size table less than or equal to *m bits */
z = (z = g - w) > *m ? *m : z; /* upper limit on table size */
@@ -274,22 +342,22 @@ int huft_build(unsigned int *b, const unsigned int n,
}
j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */
z = 1 << j; /* table entries for j-bit table */
ws[htl+1] = w + j; /* set bits decoded in stack */
ws[h+1] = w + j; /* set bits decoded in stack */
/* allocate and link in new table */
q = (huft_t *) xzalloc((z + 1) * sizeof(huft_t));
q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t));
*t = q + 1; /* link to list for huft_free() */
t = &(q->v.t);
u[htl] = ++q; /* table starts after link */
*(t = &(q->v.t)) = NULL;
u[h] = ++q; /* table starts after link */
/* connect to last table, if there is one */
if (htl) {
x[htl] = i; /* save pattern for backing up */
r.b = (unsigned char) (w - ws[htl - 1]); /* bits to dump before this table */
if (h) {
x[h] = i; /* save pattern for backing up */
r.b = (unsigned char) (w - ws[h - 1]); /* 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 & ((1 << w) - 1)) >> ws[htl - 1];
u[htl - 1][j] = r; /* connect to last table */
j = (i & ((1 << w) - 1)) >> ws[h - 1];
u[h - 1][j] = r; /* connect to last table */
}
}
@@ -318,8 +386,8 @@ int huft_build(unsigned int *b, const unsigned int n,
i ^= j;
/* backup over finished tables */
while ((i & ((1 << w) - 1)) != x[htl]) {
w = ws[--htl];
while ((i & ((1 << w) - 1)) != x[h]) {
w = ws[--h];
}
}
}
@@ -513,7 +581,7 @@ static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup)
static int inflate_block(int *e)
{
unsigned t; /* block type */
unsigned int b; /* bit buffer */
register unsigned int b; /* bit buffer */
unsigned int k; /* number of bits in bit buffer */
/* make local bit buffer */
@@ -853,15 +921,14 @@ int inflate_unzip(int in, int out)
gunzip_bb = 0;
/* Create the crc table */
gunzip_crc_table = bb_crc32_filltable(0);
gunzip_crc = ~0;
make_gunzip_crc_table();
/* Allocate space for buffer */
bytebuffer = xmalloc(bytebuffer_max);
while(1) {
int ret = inflate_get_next_window();
nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
nwrote = bb_full_write(out, gunzip_window, gunzip_outbuf_count);
if (nwrote == -1) {
bb_perror_msg("write");
return -1;
@@ -887,7 +954,7 @@ int inflate_unzip(int in, int out)
int inflate_gunzip(int in, int out)
{
uint32_t stored_crc = 0;
unsigned int stored_crc = 0;
unsigned int count;
inflate_unzip(in, out);
@@ -895,7 +962,7 @@ int inflate_gunzip(int in, int out)
/* top up the input buffer with the rest of the trailer */
count = bytebuffer_size - bytebuffer_offset;
if (count < 8) {
xread(in, &bytebuffer[bytebuffer_size], 8 - count);
bb_xread_all(in, &bytebuffer[bytebuffer_size], 8 - count);
bytebuffer_size += 8 - count;
}
for (count = 0; count != 4; count++) {
@@ -904,7 +971,7 @@ int inflate_gunzip(int in, int out)
}
/* Validate decompression - crc */
if (stored_crc != (~gunzip_crc)) {
if (stored_crc != (gunzip_crc ^ 0xffffffffL)) {
bb_error_msg("crc error");
return -1;
}
+16 -3
View File
@@ -1,11 +1,24 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "unarchive.h"
/* Accept any non-null name, its not really a filter at all */
+16 -3
View File
@@ -1,11 +1,24 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "unarchive.h"
/*
@@ -1,8 +1,19 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
@@ -1,11 +1,24 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
* Copyright (C) 2002 by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "unarchive.h"
/*
@@ -14,17 +27,16 @@
char filter_accept_reject_list(archive_handle_t *archive_handle)
{
const char *key = archive_handle->file_header->name;
const llist_t *accept_entry = find_list_entry(archive_handle->accept, key);
const llist_t *reject_entry = find_list_entry(archive_handle->reject, key);
const llist_t *accept_entry;
/* If the key is in a reject list fail */
if (reject_entry) {
return(EXIT_FAILURE);
}
accept_entry = find_list_entry(archive_handle->accept, key);
/* Fail if an accept list was specified and the key wasnt in there */
if ((accept_entry == NULL) && archive_handle->accept) {
if (archive_handle->accept && (accept_entry == NULL)) {
return(EXIT_FAILURE);
}
+13 -5
View File
@@ -1,20 +1,28 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "unarchive.h"
/* Find a string in a list */
const llist_t *find_list_entry(const llist_t *list, const char *filename)
{
while (list) {
if (fnmatch(list->data, filename, 0) == 0) {
return (list);
return(list);
}
list = list->link;
}
+15 -5
View File
@@ -1,7 +1,17 @@
/* vi: set sw=4 ts=4: */
/* Copyright 2001 Glenn McGrath.
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
@@ -43,7 +53,7 @@ char get_header_ar(archive_handle_t *archive_handle)
if (ar.raw[0] == '\n') {
/* fix up the header, we started reading 1 byte too early */
memmove(ar.raw, &ar.raw[1], 59);
ar.raw[59] = xread_char(archive_handle->src_fd);
ar.raw[59] = bb_xread_char(archive_handle->src_fd);
archive_handle->offset++;
}
archive_handle->offset += 60;
@@ -68,7 +78,7 @@ char get_header_ar(archive_handle_t *archive_handle)
* in static variable long_names for use in future entries */
ar_long_name_size = typed->size;
ar_long_names = xmalloc(ar_long_name_size);
xread(archive_handle->src_fd, ar_long_names, ar_long_name_size);
bb_xread_all(archive_handle->src_fd, ar_long_names, ar_long_name_size);
archive_handle->offset += ar_long_name_size;
/* This ar entries data section only contained filenames for other records
* they are stored in the static ar_long_names for future reference */
+19 -8
View File
@@ -1,7 +1,17 @@
/* vi: set sw=4 ts=4: */
/* Copyright 2002 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.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
@@ -75,9 +85,9 @@ char get_header_cpio(archive_handle_t *archive_handle)
file_header->size = tmpsize;
}
file_header->name = (char *) xzalloc(namesize + 1);
/* Read in filename */
xread(archive_handle->src_fd, file_header->name, namesize);
file_header->name = (char *) xmalloc(namesize + 1);
archive_xread_all(archive_handle, file_header->name, namesize); /* Read in filename */
file_header->name[namesize] = '\0';
archive_handle->offset += namesize;
/* Update offset amount and skip padding before file contents */
@@ -103,8 +113,9 @@ char get_header_cpio(archive_handle_t *archive_handle)
}
if (S_ISLNK(file_header->mode)) {
file_header->link_name = (char *) xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, file_header->link_name, file_header->size);
file_header->link_name = (char *) xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, file_header->link_name, file_header->size);
file_header->link_name[file_header->size] = '\0';
archive_handle->offset += file_header->size;
file_header->size = 0; /* Stop possible seeks in future */
} else {
+20 -14
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* FIXME:
@@ -56,7 +55,11 @@ char get_header_tar(archive_handle_t *archive_handle)
/* Align header */
data_align(archive_handle, 512);
xread(archive_handle->src_fd, tar.raw, 512);
if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) {
/* Assume end of file */
bb_error_msg_and_die("Short header");
//return(EXIT_FAILURE);
}
archive_handle->offset += 512;
/* If there is no filename its an empty header */
@@ -65,7 +68,7 @@ char get_header_tar(archive_handle_t *archive_handle)
/* This is the second consecutive empty header! End of archive!
* Read until the end to empty the pipe from gz or bz2
*/
while (full_read(archive_handle->src_fd, tar.raw, 512) == 512);
while (bb_full_read(archive_handle->src_fd, tar.raw, 512) == 512);
return(EXIT_FAILURE);
}
end = 1;
@@ -77,7 +80,7 @@ char get_header_tar(archive_handle_t *archive_handle)
* 0's are for the old tar format
*/
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
#endif
bb_error_msg_and_die("Invalid tar magic");
@@ -133,11 +136,15 @@ char get_header_tar(archive_handle_t *archive_handle)
case '1':
file_header->mode |= S_IFREG;
break;
case 'x':
case 'g':
bb_error_msg_and_die("pax is not tar");
break;
case '7':
/* Reserved for high performance files, treat as normal file */
case 0:
case '0':
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
if (last_char_is(file_header->name, '/')) {
file_header->mode |= S_IFDIR;
} else
@@ -161,15 +168,17 @@ char get_header_tar(archive_handle_t *archive_handle)
break;
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
case 'L': {
longname = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, longname, file_header->size);
longname = xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, longname, file_header->size);
longname[file_header->size] = '\0';
archive_handle->offset += file_header->size;
return(get_header_tar(archive_handle));
}
case 'K': {
linkname = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, linkname, file_header->size);
linkname = xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, linkname, file_header->size);
linkname[file_header->size] = '\0';
archive_handle->offset += file_header->size;
file_header->name = linkname;
@@ -180,11 +189,8 @@ char get_header_tar(archive_handle_t *archive_handle)
case 'N': /* Old GNU for names > 100 characters */
case 'S': /* Sparse file */
case 'V': /* Volume header */
bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
#endif
case 'g': /* pax global header */
case 'x': /* pax extended header */
bb_error_msg("Ignoring extension type %c", tar.formated.typeflag);
break;
default:
bb_error_msg("Unknown typeflag: 0x%x", tar.formated.typeflag);
}
@@ -200,7 +206,7 @@ char get_header_tar(archive_handle_t *archive_handle)
archive_handle->action_header(archive_handle->file_header);
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
archive_handle->action_data(archive_handle);
llist_add_to(&(archive_handle->passed), file_header->name);
archive_handle->passed = llist_add_to(archive_handle->passed, file_header->name);
} else {
data_skip(archive_handle);
}
+13 -2
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/types.h>
+14 -3
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
@@ -15,7 +26,7 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
/* Cant lseek over pipe's */
archive_handle->seek = seek_by_char;
xread(archive_handle->src_fd, &magic, 2);
archive_xread_all(archive_handle, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("Invalid gzip magic");
}
+1 -1
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
@@ -21,3 +20,4 @@ char get_header_tar_lzma(archive_handle_t * archive_handle)
return EXIT_FAILURE;
}
/* vi:set ts=4: */
-4
View File
@@ -1,7 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include "unarchive.h"
-4
View File
@@ -1,7 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include "unarchive.h"
@@ -1,8 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <string.h>
#include <time.h>
+15 -3
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <unistd.h>
@@ -13,7 +24,8 @@ archive_handle_t *init_handle(void)
archive_handle_t *archive_handle;
/* Initialise default values */
archive_handle = xzalloc(sizeof(archive_handle_t));
archive_handle = xmalloc(sizeof(archive_handle_t));
memset(archive_handle, 0, sizeof(archive_handle_t));
archive_handle->file_header = xmalloc(sizeof(file_header_t));
archive_handle->action_header = header_skip;
archive_handle->action_data = data_skip;
+13 -4
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
@@ -8,8 +19,6 @@
#include "libbb.h"
#include "unarchive.h"
/* transformer(), more than meets the eye */
int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd))
{
+178
View File
@@ -0,0 +1,178 @@
/*
* Small range coder implementation for lzma.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
* Copyright (c) 1999-2005 Igor Pavlov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include "libbb.h"
#ifndef always_inline
# if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >0)
# define always_inline __attribute__((always_inline)) inline
# else
# define always_inline inline
# endif
#endif
#ifdef CONFIG_FEATURE_LZMA_FAST
# define speed_inline always_inline
#else
# define speed_inline
#endif
typedef struct {
int fd;
uint8_t *ptr;
uint8_t *buffer;
uint8_t *buffer_end;
int buffer_size;
uint32_t code;
uint32_t range;
uint32_t bound;
} rc_t;
#define RC_TOP_BITS 24
#define RC_MOVE_BITS 5
#define RC_MODEL_TOTAL_BITS 11
/* Called twice: once at startup and once in rc_normalize() */
static void rc_read(rc_t * rc)
{
rc->buffer_size = read(rc->fd, rc->buffer, rc->buffer_size);
if (rc->buffer_size <= 0)
bb_error_msg_and_die("unexpected EOF");
rc->ptr = rc->buffer;
rc->buffer_end = rc->buffer + rc->buffer_size;
}
/* Called once */
static always_inline void rc_init(rc_t * rc, int fd, int buffer_size)
{
int i;
rc->fd = fd;
rc->buffer = malloc(buffer_size);
rc->buffer_size = buffer_size;
rc->buffer_end = rc->buffer + rc->buffer_size;
rc->ptr = rc->buffer_end;
rc->code = 0;
rc->range = 0xFFFFFFFF;
for (i = 0; i < 5; i++) {
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->code = (rc->code << 8) | *rc->ptr++;
}
}
/* Called once. TODO: bb_maybe_free() */
static always_inline void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc->buffer);
}
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
static void rc_do_normalize(rc_t * rc)
{
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static always_inline void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* Called 9 times */
/* Why rc_is_bit_0_helper exists?
* Because we want to always expose (rc->code < rc->bound) to optimizer
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
{
rc_normalize(rc);
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static always_inline int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
}
/* Called ~10 times, but very small, thus inlined */
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
{
rc->range = rc->bound;
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
}
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
{
rc->range -= rc->bound;
rc->code -= rc->bound;
*p -= *p >> RC_MOVE_BITS;
}
/* Called 4 times in unlzma loop */
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
{
if (rc_is_bit_0(rc, p)) {
rc_update_bit_0(rc, p);
*symbol *= 2;
return 0;
} else {
rc_update_bit_1(rc, p);
*symbol = *symbol * 2 + 1;
return 1;
}
}
/* Called once */
static always_inline int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
if (rc->code >= rc->range) {
rc->code -= rc->range;
return 1;
}
return 0;
}
/* Called twice */
static speed_inline void
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
{
int i = num_levels;
*symbol = 1;
while (i--)
rc_get_bit(rc, p + *symbol, symbol);
*symbol -= 1 << num_levels;
}
/* vi:set ts=4: */
+14 -5
View File
@@ -1,14 +1,23 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include "unarchive.h"
#include "libbb.h"
#include "busybox.h"
/* If we are reading through a pipe(), or from stdin then we cant lseek,
* we must read and discard the data to skip over it.
+13 -2
View File
@@ -1,6 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/types.h>
+15 -4
View File
@@ -1,18 +1,29 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include "unarchive.h"
#include "libbb.h"
#include "busybox.h"
void unpack_ar_archive(archive_handle_t *ar_archive)
{
char magic[7];
xread(ar_archive->src_fd, magic, 7);
archive_xread_all(ar_archive, magic, 7);
if (strncmp(magic, "!<arch>", 7) != 0) {
bb_error_msg_and_die("Invalid ar magic");
}
+9 -6
View File
@@ -193,12 +193,12 @@ void extract_cpio_gz(int fd) {
archive_handle->src_fd = fd;
archive_handle->offset = 0;
xread(archive_handle->src_fd, &magic, 2);
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);
bb_xchdir("/"); // Install RPM's to root
chdir("/"); // Install RPM's to root
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
archive_handle->offset = 0;
@@ -208,7 +208,7 @@ void extract_cpio_gz(int fd) {
rpm_index **rpm_gettags(int fd, int *num_tags)
{
rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *)); /* We should never need mode than 200, and realloc later */
rpm_index **tags = calloc(200, sizeof(struct rpmtag *)); /* We should never need mode than 200, and realloc later */
int pass, tagindex = 0;
lseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
@@ -327,10 +327,13 @@ void fileaction_list(char *filename, int ATTRIBUTE_UNUSED fileref)
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
{
int count = 0;
char *filename, *tmp_dirname, *tmp_basename;
while (rpm_getstring(filetag, count)) {
char * filename = bb_xasprintf("%s%s",
rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES,
count)), rpm_getstring(RPMTAG_BASENAMES, count));
tmp_dirname = rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, count)); /* 1st put on the directory */
tmp_basename = rpm_getstring(RPMTAG_BASENAMES, count);
filename = xmalloc(strlen(tmp_basename) + strlen(tmp_dirname) + 1);
strcpy(filename, tmp_dirname); /* First the directory name */
strcat(filename, tmp_basename); /* then the filename */
fileaction(filename, count++);
free(filename);
}
+16 -4
View File
@@ -4,7 +4,19 @@
*
* Copyright (C) 2001 by Laurence Anderson
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <sys/types.h>
#include <netinet/in.h> /* For ntohl & htonl function */
@@ -40,7 +52,7 @@ static void skip_header(int rpm_fd)
{
struct rpm_header header;
xread(rpm_fd, &header, sizeof(struct rpm_header));
bb_xread_all(rpm_fd, &header, sizeof(struct rpm_header));
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) {
bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
}
@@ -66,7 +78,7 @@ int rpm2cpio_main(int argc, char **argv)
rpm_fd = bb_xopen(argv[1], O_RDONLY);
}
xread(rpm_fd, &lead, sizeof(struct rpm_lead));
bb_xread_all(rpm_fd, &lead, sizeof(struct rpm_lead));
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) {
bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
}
@@ -78,7 +90,7 @@ int rpm2cpio_main(int argc, char **argv)
/* Skip the main header */
skip_header(rpm_fd);
xread(rpm_fd, &magic, 2);
bb_xread_all(rpm_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("Invalid gzip magic");
}
+21 -16
View File
@@ -19,8 +19,9 @@
*
* Based in part on the tar implementation from busybox-0.28
* Copyright (C) 1995 Bruce Perens
* This is free software under the GNU General Public License.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* Licensed under GPL v2 (or later), see file LICENSE in this tarball.
*/
#include <fcntl.h>
@@ -42,8 +43,12 @@
#ifdef CONFIG_FEATURE_TAR_CREATE
/* Tar file constants */
# define TAR_MAGIC "ustar" /* ustar and a null */
# define TAR_VERSION " " /* Be compatable with GNU tar format */
#define TAR_BLOCK_SIZE 512
#define TAR_MAGIC_LEN 6
#define TAR_VERSION_LEN 2
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
#define NAME_SIZE 100
@@ -204,14 +209,15 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
memset(&header, 0, size);
safe_strncpy(header.name, header_name, sizeof(header.name));
strncpy(header.name, header_name, sizeof(header.name));
putOctal(header.mode, sizeof(header.mode), statbuf->st_mode);
putOctal(header.uid, sizeof(header.uid), statbuf->st_uid);
putOctal(header.gid, sizeof(header.gid), statbuf->st_gid);
putOctal(header.size, sizeof(header.size), 0); /* Regular file size is handled later */
putOctal(header.mtime, sizeof(header.mtime), statbuf->st_mtime);
strcpy(header.magic, "ustar ");
strncpy(header.magic, TAR_MAGIC TAR_VERSION,
TAR_MAGIC_LEN + TAR_VERSION_LEN);
/* Enter the user and group names (default to root if it fails) */
if (bb_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL)
@@ -269,9 +275,9 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
putOctal(header.chksum, 7, chksum);
/* Now write the header out to disk */
if ((size = full_write(tbInfo->tarFd, (char *) &header,
sizeof(struct TarHeader))) < 0)
{
if ((size =
bb_full_write(tbInfo->tarFd, (char *) &header,
sizeof(struct TarHeader))) < 0) {
bb_error_msg(bb_msg_io_error, real_name);
return (FALSE);
}
@@ -475,7 +481,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
while (1) {
char buf;
int n = full_read(gzipStatusPipe[0], &buf, 1);
int n = bb_full_read(gzipStatusPipe[0], &buf, 1);
if (n == 0 && vfork_exec_errno != 0) {
errno = vfork_exec_errno;
@@ -546,7 +552,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
cur = cur->link;
free(tmp);
while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL)
llist_add_to(&newlist, line);
newlist = llist_add_to(newlist, line);
fclose(src_stream);
}
return newlist;
@@ -562,8 +568,8 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
archive_handle->seek = seek_by_char;
/* do the decompression, and cleanup */
if (xread_char(archive_handle->src_fd) != 0x1f ||
xread_char(archive_handle->src_fd) != 0x9d)
if (bb_xread_char(archive_handle->src_fd) != 0x1f ||
bb_xread_char(archive_handle->src_fd) != 0x9d)
{
bb_error_msg_and_die("Invalid magic");
}
@@ -591,7 +597,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
#define TAR_OPT_AFTER_START 8
#define CTX_CREATE (1 << (TAR_OPT_AFTER_START))
#define TAR_OPT_DEREFERENCE (1 << (TAR_OPT_AFTER_START + 1))
#define TAR_OPT_DEREFERNCE (1 << (TAR_OPT_AFTER_START + 1))
#ifdef CONFIG_FEATURE_TAR_CREATE
# define TAR_OPT_STR_CREATE "ch"
# define TAR_OPT_AFTER_CREATE TAR_OPT_AFTER_START + 2
@@ -795,7 +801,7 @@ int tar_main(int argc, char **argv)
if (filename_ptr > argv[optind])
*filename_ptr = '\0';
llist_add_to(&(tar_handle->accept), argv[optind]);
tar_handle->accept = llist_add_to(tar_handle->accept, argv[optind]);
optind++;
}
@@ -828,8 +834,8 @@ int tar_main(int argc, char **argv)
}
}
if (base_dir)
bb_xchdir(base_dir);
if ((base_dir) && (chdir(base_dir)))
bb_perror_msg_and_die("Couldnt chdir to %s", base_dir);
/* create an archive */
if (ENABLE_FEATURE_TAR_CREATE && (opt & CTX_CREATE)) {
@@ -846,8 +852,7 @@ int tar_main(int argc, char **argv)
{
verboseFlag = TRUE;
}
writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERENCE,
tar_handle->accept,
writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERNCE, tar_handle->accept,
tar_handle->reject, zipMode);
} else {
while (get_header_ptr(tar_handle) == EXIT_SUCCESS);
+20 -6
View File
@@ -2,7 +2,19 @@
/*
* Uncompress applet for busybox (c) 2002 Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
@@ -12,7 +24,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define GUNZIP_TO_STDOUT 1
@@ -61,16 +73,18 @@ int uncompress_main(int argc, char **argv)
*extension = '\0';
/* Open output file */
xstat(compressed_file, &stat_buf);
dst_fd = bb_xopen3(uncompressed_file, O_WRONLY | O_CREAT,
stat_buf.st_mode);
dst_fd = bb_xopen(uncompressed_file, O_WRONLY | O_CREAT);
/* Set permissions on the file */
stat(compressed_file, &stat_buf);
chmod(uncompressed_file, stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = compressed_file;
}
/* do the decompression, and cleanup */
if ((xread_char(src_fd) != 0x1f) || (xread_char(src_fd) != 0x9d)) {
if ((bb_xread_char(src_fd) != 0x1f) || (bb_xread_char(src_fd) != 0x9d)) {
bb_error_msg_and_die("Invalid magic");
}
+2 -4
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
@@ -42,15 +41,13 @@ int unlzma_main(int argc, char **argv)
filename = 0;
if (filename) {
struct stat stat_buf;
char *extension = filename + strlen(filename) - 5;
if (strcmp(extension, ".lzma") != 0) {
bb_error_msg_and_die("Invalid extension");
}
xstat(filename, &stat_buf);
*extension = 0;
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
} else
dst_fd = STDOUT_FILENO;
status = unlzma(src_fd, dst_fd);
@@ -65,3 +62,4 @@ int unlzma_main(int argc, char **argv)
return status;
}
/* vi:set ts=4: */
+64 -26
View File
@@ -32,10 +32,28 @@
#include "unarchive.h"
#include "busybox.h"
#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
#define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50)
#define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50)
#define ZIP_DD_MAGIC SWAP_LE32(0x08074b50)
#if BB_BIG_ENDIAN
static inline unsigned short
__swap16(unsigned short x) {
return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8);
}
static inline uint32_t
__swap32(uint32_t x) {
return (((x & 0xFF) << 24) |
((x & 0xFF00) << 8) |
((x & 0xFF0000) >> 8) |
((x & 0xFF000000) >> 24));
}
#else /* it's little-endian */
# define __swap16(x) (x)
# define __swap32(x) (x)
#endif /* BB_BIG_ENDIAN */
#define ZIP_FILEHEADER_MAGIC __swap32(0x04034b50)
#define ZIP_CDS_MAGIC __swap32(0x02014b50)
#define ZIP_CDS_END_MAGIC __swap32(0x06054b50)
#define ZIP_DD_MAGIC __swap32(0x08074b50)
extern unsigned int gunzip_crc;
extern unsigned int gunzip_bytes_out;
@@ -65,12 +83,19 @@ static void unzip_skip(int fd, off_t skip)
}
}
static void unzip_read(int fd, void *buf, size_t count)
{
if (bb_xread(fd, buf, count) != count) {
bb_error_msg_and_die("Read failure");
}
}
static void unzip_create_leading_dirs(char *fn)
{
/* Create all leading directories */
char *name = bb_xstrdup(fn);
if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
bb_error_msg_and_die("Exiting"); /* bb_make_directory is noisy */
bb_error_msg_and_die("Failed to create directory");
}
free(name);
}
@@ -155,7 +180,7 @@ int unzip_main(int argc, char **argv)
case 1: /* Include files */
if (opt == 1) {
llist_add_to(&zaccept, optarg);
zaccept = llist_add_to(zaccept, optarg);
} else if (opt == 'd') {
base_dir = optarg;
@@ -171,7 +196,7 @@ int unzip_main(int argc, char **argv)
case 2 : /* Exclude files */
if (opt == 1) {
llist_add_to(&zreject, optarg);
zreject = llist_add_to(zreject, optarg);
} else if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
@@ -211,8 +236,9 @@ int unzip_main(int argc, char **argv)
}
/* Change dir if necessary */
if (base_dir)
bb_xchdir(base_dir);
if (base_dir && chdir(base_dir)) {
bb_perror_msg_and_die("Cannot chdir");
}
if (verbosity != v_silent)
printf("Archive: %s\n", src_fn);
@@ -223,7 +249,7 @@ int unzip_main(int argc, char **argv)
unsigned int magic;
/* Check magic number */
xread(src_fd, &magic, 4);
unzip_read(src_fd, &magic, 4);
if (magic == ZIP_CDS_MAGIC) {
break;
} else if (magic != ZIP_FILEHEADER_MAGIC) {
@@ -231,32 +257,35 @@ int unzip_main(int argc, char **argv)
}
/* Read the file header */
xread(src_fd, zip_header.raw, 26);
zip_header.formated.version = SWAP_LE32(zip_header.formated.version);
zip_header.formated.flags = SWAP_LE32(zip_header.formated.flags);
zip_header.formated.method = SWAP_LE32(zip_header.formated.method);
zip_header.formated.modtime = SWAP_LE32(zip_header.formated.modtime);
zip_header.formated.moddate = SWAP_LE32(zip_header.formated.moddate);
zip_header.formated.crc32 = SWAP_LE32(zip_header.formated.crc32);
zip_header.formated.cmpsize = SWAP_LE32(zip_header.formated.cmpsize);
zip_header.formated.ucmpsize = SWAP_LE32(zip_header.formated.ucmpsize);
zip_header.formated.filename_len = SWAP_LE32(zip_header.formated.filename_len);
zip_header.formated.extra_len = SWAP_LE32(zip_header.formated.extra_len);
unzip_read(src_fd, zip_header.raw, 26);
#if BB_BIG_ENDIAN
zip_header.formated.version = __swap16(zip_header.formated.version);
zip_header.formated.flags = __swap16(zip_header.formated.flags);
zip_header.formated.method = __swap16(zip_header.formated.method);
zip_header.formated.modtime = __swap16(zip_header.formated.modtime);
zip_header.formated.moddate = __swap16(zip_header.formated.moddate);
zip_header.formated.crc32 = __swap32(zip_header.formated.crc32);
zip_header.formated.cmpsize = __swap32(zip_header.formated.cmpsize);
zip_header.formated.ucmpsize = __swap32(zip_header.formated.ucmpsize);
zip_header.formated.filename_len = __swap16(zip_header.formated.filename_len);
zip_header.formated.extra_len = __swap16(zip_header.formated.extra_len);
#endif /* BB_BIG_ENDIAN */
if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) {
bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method);
}
/* Read filename */
free(dst_fn);
dst_fn = xzalloc(zip_header.formated.filename_len + 1);
xread(src_fd, dst_fn, zip_header.formated.filename_len);
dst_fn = xmalloc(zip_header.formated.filename_len + 1);
unzip_read(src_fd, dst_fn, zip_header.formated.filename_len);
dst_fn[zip_header.formated.filename_len] = 0;
/* Skip extra header bytes */
unzip_skip(src_fd, zip_header.formated.extra_len);
if ((verbosity == v_list) && !list_header_done){
printf(" Length Date Time Name\n"
" -------- ---- ---- ----\n");
printf(" Length Date Time Name\n");
printf(" -------- ---- ---- ----\n");
list_header_done = 1;
}
@@ -294,7 +323,7 @@ int unzip_main(int argc, char **argv)
}
unzip_create_leading_dirs(dst_fn);
if (bb_make_directory(dst_fn, 0777, 0)) {
bb_error_msg_and_die("Exiting");
bb_error_msg_and_die("Failed to create directory");
}
} else {
if (!S_ISDIR(stat_buf.st_mode)) {
@@ -389,3 +418,12 @@ int unzip_main(int argc, char **argv)
return failed;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-7
View File
@@ -65,13 +65,6 @@ config CONFIG_SETCONSOLE
This program redirects the system console to another device,
like the current tty while logged in via telnet.
config CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS
bool "Enable long options"
default n
depends on CONFIG_SET_CONSOLE && CONFIG_GETOPT_LONG
help
Support long options for the setconsole applet.
config CONFIG_SETKEYCODES
bool "setkeycodes"
default n
+1 -1
View File
@@ -12,7 +12,7 @@ top_builddir=..
endif
srcdir=$(top_srcdir)/console/tools
CONSOLETOOLS_DIR:=./
include $(top_srcdir)/Rules.mak
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
+24 -1
View File
@@ -4,9 +4,23 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*/
/* no options, no getopt */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -36,3 +50,12 @@ int chvt_main(int argc, char **argv)
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+13 -1
View File
@@ -4,7 +4,19 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
+13 -1
View File
@@ -5,7 +5,19 @@
* Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*/
/* no options, no getopt */
+13 -1
View File
@@ -4,7 +4,19 @@
*
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
+6
View File
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <memory.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
@@ -127,6 +128,11 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
ud.entry_ct = ct;
ud.entries = up;
if (ioctl(fd, PIO_UNIMAP, &ud)) {
#if 0
if (errno == ENOMEM) {
/* change advice parameters */
}
#endif
bb_perror_msg_and_die("PIO_UNIMAP");
}
}
+21 -7
View File
@@ -4,7 +4,19 @@
*
* Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
@@ -45,15 +57,15 @@ int loadkmap_main(int argc, char **argv)
fd = bb_xopen(CURRENT_VC, O_RDWR);
xread(0, buff, 7);
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
if ((bb_full_read(0, buff, 7) != 7) || (strncmp(buff, BINARY_KEYMAP_MAGIC, 7) != 0))
bb_error_msg_and_die("This is not a valid binary keymap.");
xread(0, flags, MAX_NR_KEYMAPS);
if (bb_full_read(0, flags, MAX_NR_KEYMAPS) != MAX_NR_KEYMAPS)
bb_perror_msg_and_die("Error reading keymap flags");
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
xread(0, ibuff, NR_KEYS * sizeof(u_short));
bb_full_read(0, ibuff, NR_KEYS * sizeof(u_short));
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
@@ -63,6 +75,8 @@ int loadkmap_main(int argc, char **argv)
}
}
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
return 0;
/* Don't bother to close files. Exit does that
* automagically, so we can save a few bytes */
/* close(fd); */
return EXIT_SUCCESS;
}
+21 -1
View File
@@ -5,7 +5,19 @@
* busyboxed by Quy Tonthat <quy@signal3.com>
* hacked by Tito <farmatito@tiscali.it>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* getopt not needed */
@@ -51,3 +63,11 @@ int openvt_main(int argc, char **argv)
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+14 -1
View File
@@ -5,7 +5,20 @@
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* no options, no getopt */
+21 -5
View File
@@ -4,7 +4,19 @@
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/ioctl.h>
@@ -16,12 +28,10 @@
#include "busybox.h"
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const struct option setconsole_long_options[] = {
{ "reset", 0, NULL, 'r' },
{ 0, 0, 0, 0 }
};
#endif
#define OPT_SETCONS_RESET 1
@@ -30,9 +40,7 @@ int setconsole_main(int argc, char **argv)
unsigned long flags;
const char *device = CURRENT_TTY;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
bb_applet_long_options = setconsole_long_options;
#endif
flags = bb_getopt_ulflags(argc, argv, "r");
if (argc - optind > 1)
@@ -52,3 +60,11 @@ int setconsole_main(int argc, char **argv)
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+14 -1
View File
@@ -6,7 +6,20 @@
*
* Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
+1 -2
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* setlogcons: Send kernel messages to the current console or to console N
*
@@ -28,7 +27,7 @@ extern int setlogcons_main(int argc, char **argv)
if (argc == 2)
arg.subarg = atoi(argv[1]);
if (ioctl(bb_xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
if (ioctl(bb_xopen("/dev/tty1", O_RDONLY), TIOCLINUX, &arg))
bb_perror_msg_and_die("TIOCLINUX");;
return 0;
+29 -125
View File
@@ -26,13 +26,6 @@ config CONFIG_CAT
cat is used to concatenate files and print them to the standard
output. Enable this option if you wish to enable the 'cat' utility.
config CONFIG_CATV
bool "catv"
default n
help
Display nonprinting characters as escape sequences (like some
implementations' cat -v option).
config CONFIG_CHGRP
bool "chgrp"
default n
@@ -59,12 +52,6 @@ config CONFIG_CHROOT
chroot is used to change the root directory and run a command.
The default command is `/bin/sh'.
config CONFIG_CKSUM
bool "cksum"
default n
help
cksum is used to calculate the CRC32 checksum of a file.
config CONFIG_CMP
bool "cmp"
default n
@@ -100,7 +87,7 @@ config CONFIG_DATE
current time in the given format.
config CONFIG_FEATURE_DATE_ISOFMT
bool "Enable ISO date format output (-I)"
bool " Enable ISO date format output (-I)"
default y
depends on CONFIG_DATE
help
@@ -115,26 +102,6 @@ config CONFIG_DD
by default) using specific input and output blocksizes,
while optionally performing conversions on it.
config CONFIG_FEATURE_DD_SIGNAL_HANDLING
bool "Enable DD signal handling for status reporting"
default y
depends on CONFIG_DD
help
sending a SIGUSR1 signal to a running `dd' process makes it
print to standard error the number of records read and written
so far, then to resume copying.
$ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
10899206+0 records in 10899206+0 records out
config CONFIG_FEATURE_DD_IBS_OBS
bool "Enable ibs, obs and conv options"
default n
depends on CONFIG_DD
help
Enables support for writing a certain number of bytes in and out,
at a time, and performing conversions on the data stream.
config CONFIG_DF
bool "df"
default n
@@ -142,38 +109,6 @@ config CONFIG_DF
df reports the amount of disk space used and available
on filesystems.
config CONFIG_DIFF
bool "diff"
default n
help
diff compares two files or directories and outputs the
differences between them in a form that can be given to
the patch command.
config CONFIG_FEATURE_DIFF_BINARY
bool "Enable checks for binary files"
default y
depends on CONFIG_DIFF
help
This option enables support for checking for binary files
before a comparison is carried out.
config CONFIG_FEATURE_DIFF_DIR
bool "Enable directory support"
default y
depends on CONFIG_DIFF
help
This option enables support for directory and subdirectory
comparison.
config CONFIG_FEATURE_DIFF_MINIMAL
bool "Enable -d option to find smaller sets of changes"
default n
depends on CONFIG_DIFF
help
Enabling this option allows the use of -d to make diff
try hard to find the smallest possible set of changes.
config CONFIG_DIRNAME
bool "dirname"
default n
@@ -192,9 +127,6 @@ config CONFIG_UNIX2DOS
bool
default y
depends on CONFIG_DOS2UNIX
help
unix2dos is used to convert a text file from UNIX format to
DOS format, and vice versa.
config CONFIG_DU
bool "du (default blocksize of 512 bytes)"
@@ -203,8 +135,8 @@ config CONFIG_DU
du is used to report the amount of disk space used
for specified files.
config CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
bool "Use a default blocksize of 1024 bytes (1K)"
config CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
bool " Use a default blocksize of 1024 bytes (1K)"
default y
depends on CONFIG_DU
help
@@ -218,7 +150,7 @@ config CONFIG_ECHO
# this entry also appears in shell/Config.in, next to the echo builtin
config CONFIG_FEATURE_FANCY_ECHO
bool "Enable echo options (-n and -e)"
bool " Enable echo options (-n and -e)"
default y
depends on CONFIG_ECHO
help
@@ -232,13 +164,6 @@ config CONFIG_ENV
a command; without options it displays the current
environment.
config CONFIG_FEATURE_ENV_LONG_OPTIONS
bool "Enable long options"
default n
depends on CONFIG_ENV && CONFIG_GETOPT_LONG
help
Support long options for the env applet.
config CONFIG_EXPR
bool "expr"
default n
@@ -247,7 +172,7 @@ config CONFIG_EXPR
to standard output.
config CONFIG_EXPR_MATH_SUPPORT_64
bool "Extend Posix numbers support to 64 bit"
bool " Extend Posix numbers support to 64 bit"
default n
depends on CONFIG_EXPR
help
@@ -275,7 +200,7 @@ config CONFIG_HEAD
from files.
config CONFIG_FEATURE_FANCY_HEAD
bool "Enable head options (-c, -q, and -v)"
bool " Enable head options (-c, -q, and -v)"
default n
depends on CONFIG_HEAD
help
@@ -300,13 +225,6 @@ config CONFIG_INSTALL
help
Copy files and set attributes.
config CONFIG_FEATURE_INSTALL_LONG_OPTIONS
bool "Enable long options"
default n
depends on CONFIG_INSTALL && CONFIG_GETOPT_LONG
help
Support long options for the install applet.
config CONFIG_LENGTH
bool "length"
default n
@@ -332,56 +250,56 @@ config CONFIG_LS
ls is used to list the contents of directories.
config CONFIG_FEATURE_LS_FILETYPES
bool "Enable filetyping options (-p and -F)"
bool " Enable filetyping options (-p and -F)"
default y
depends on CONFIG_LS
help
Enable the ls options (-p and -F).
config CONFIG_FEATURE_LS_FOLLOWLINKS
bool "Enable symlinks dereferencing (-L)"
bool " Enable symlinks dereferencing (-L)"
default y
depends on CONFIG_LS
help
Enable the ls option (-L).
config CONFIG_FEATURE_LS_RECURSIVE
bool "Enable recursion (-R)"
bool " Enable recursion (-R)"
default y
depends on CONFIG_LS
help
Enable the ls option (-R).
config CONFIG_FEATURE_LS_SORTFILES
bool "Sort the file names"
bool " Sort the file names"
default y
depends on CONFIG_LS
help
Allow ls to sort file names alphabetically.
config CONFIG_FEATURE_LS_TIMESTAMPS
bool "Show file timestamps"
bool " Show file timestamps"
default y
depends on CONFIG_LS
help
Allow ls to display timestamps for files.
config CONFIG_FEATURE_LS_USERNAME
bool "Show username/groupnames"
bool " Show username/groupnames"
default y
depends on CONFIG_LS
help
Allow ls to display username/groupname for files.
config CONFIG_FEATURE_LS_COLOR
bool "Allow use of color to identify file types"
bool " Allow use of color to identify file types"
default y
depends on CONFIG_LS && CONFIG_GETOPT_LONG
depends on CONFIG_LS
help
This enables the --color option to ls.
config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
bool "Produce colored ls output by default"
bool " Produce colored ls output by default"
default n
depends on CONFIG_FEATURE_LS_COLOR
help
@@ -403,13 +321,6 @@ config CONFIG_MKDIR
help
mkdir is used to create directories with the specified names.
config CONFIG_FEATURE_MKDIR_LONG_OPTIONS
bool "Enable long options"
default n
depends on CONFIG_MKDIR && CONFIG_GETOPT_LONG
help
Support long options for the mkdir applet.
config CONFIG_MKFIFO
bool "mkfifo"
default n
@@ -430,13 +341,6 @@ config CONFIG_MV
help
mv is used to move or rename files or directories.
config CONFIG_FEATURE_MV_LONG_OPTIONS
bool "Enable long options"
default n
depends on CONFIG_MV && CONFIG_GETOPT_LONG
help
Support long options for the mv applet.
config CONFIG_NICE
bool "nice"
default n
@@ -512,7 +416,7 @@ config CONFIG_SLEEP
sleep is used to pause for a specified number of seconds,
config CONFIG_FEATURE_FANCY_SLEEP
bool "Enable multiple integer args and optional time suffixes"
bool " Enable multiple integer args and optional time suffixes"
default n
depends on CONFIG_SLEEP
help
@@ -525,7 +429,7 @@ config CONFIG_SORT
sort is used to sort lines of text in specified files.
config CONFIG_FEATURE_SORT_BIG
bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
bool " full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
default y
depends on CONFIG_SORT
help
@@ -543,7 +447,7 @@ config CONFIG_STAT
display file or filesystem status.
config CONFIG_FEATURE_STAT_FORMAT
bool "Enable custom formats (-c)"
bool " Enable custom formats (-c)"
default n
depends on CONFIG_STAT
help
@@ -577,7 +481,7 @@ config CONFIG_TAIL
from files.
config CONFIG_FEATURE_FANCY_TAIL
bool "Enable extra tail options (-q, -s, and -v)"
bool " Enable extra tail options (-q, -s, and -v)"
default y
depends on CONFIG_TAIL
help
@@ -592,7 +496,7 @@ config CONFIG_TEE
to standard output and files.
config CONFIG_FEATURE_TEE_USE_BLOCK_IO
bool "Enable block i/o (larger/faster) instead of byte i/o."
bool " Enable block i/o (larger/faster) instead of byte i/o."
default n
depends on CONFIG_TEE
help
@@ -603,11 +507,11 @@ config CONFIG_TEST
default n
help
test is used to check file types and compare values,
returning an appropriate exit code. The bash shell
has test built in, ash can build it in optionally.
returning an appropriate exit code. The shells (ash
and bash) have test builtin.
config CONFIG_FEATURE_TEST_64
bool "Extend test to 64 bit"
bool " Extend test to 64 bit"
default n
depends on CONFIG_TEST
help
@@ -628,7 +532,7 @@ config CONFIG_TR
input, writing to standard output.
config CONFIG_FEATURE_TR_CLASSES
bool "Enable character classes (such as [:upper:])"
bool " Enable character classes (such as [:upper:])"
default n
depends on CONFIG_TR
help
@@ -636,7 +540,7 @@ config CONFIG_FEATURE_TR_CLASSES
tr [:upper:] [:lower:] to convert input into lowercase.
config CONFIG_FEATURE_TR_EQUIV
bool "Enable equivalence classes"
bool " Enable equivalence classes"
default n
depends on CONFIG_TR
help
@@ -729,7 +633,7 @@ comment "Common options for cp and mv"
depends on CONFIG_CP || CONFIG_MV
config CONFIG_FEATURE_PRESERVE_HARDLINKS
bool "Preserve hard links"
bool " Preserve hard links"
default n
depends on CONFIG_CP || CONFIG_MV
help
@@ -739,7 +643,7 @@ comment "Common options for ls, more and telnet"
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
config CONFIG_FEATURE_AUTOWIDTH
bool "Calculate terminal & column widths"
bool " Calculate terminal & column widths"
default y
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
help
@@ -753,7 +657,7 @@ comment "Common options for df, du, ls"
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
config CONFIG_FEATURE_HUMAN_READABLE
bool "Support for human readable output (example 13k, 23M, 235G)"
bool " Support for human readable output (example 13k, 23M, 235G)"
default n
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
help
@@ -763,7 +667,7 @@ comment "Common options for md5sum, sha1sum"
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
config CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
bool "Enable -c, -s and -w options"
bool " Enable -c, -s and -w options"
default n
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
help
+1 -1
View File
@@ -12,7 +12,7 @@ top_builddir=..
endif
srcdir=$(top_srcdir)/coreutils
SHELLUTILS_DIR:=./
include $(top_srcdir)/Rules.mak
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
-3
View File
@@ -14,12 +14,10 @@ COREUTILS-y:=
COREUTILS-$(CONFIG_BASENAME) += basename.o
COREUTILS-$(CONFIG_CAL) += cal.o
COREUTILS-$(CONFIG_CAT) += cat.o
COREUTILS-$(CONFIG_CATV) += catv.o
COREUTILS-$(CONFIG_CHGRP) += chgrp.o
COREUTILS-$(CONFIG_CHMOD) += chmod.o
COREUTILS-$(CONFIG_CHOWN) += chown.o
COREUTILS-$(CONFIG_CHROOT) += chroot.o
COREUTILS-$(CONFIG_CKSUM) += cksum.o
COREUTILS-$(CONFIG_CMP) += cmp.o
COREUTILS-$(CONFIG_COMM) += comm.o
COREUTILS-$(CONFIG_CP) += cp.o
@@ -27,7 +25,6 @@ COREUTILS-$(CONFIG_CUT) += cut.o
COREUTILS-$(CONFIG_DATE) += date.o
COREUTILS-$(CONFIG_DD) += dd.o
COREUTILS-$(CONFIG_DF) += df.o
COREUTILS-$(CONFIG_DIFF) += diff.o
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
COREUTILS-$(CONFIG_DU) += du.o
+13 -1
View File
@@ -4,7 +4,19 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
+15 -3
View File
@@ -1,11 +1,23 @@
/* vi: set sw=4 ts=4: */
/*
* Calendar implementation for busybox
*
* See original copyright at the end of this file
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */
/* BB_AUDIT BUG: The output of 'cal -j 1752' is incorrect. The upstream
+29 -2
View File
@@ -4,14 +4,41 @@
*
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
*
* Licensed under GPLv2 or later, see file License in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
#include "busybox.h"
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* This is a new implementation of 'cat' which aims to be SUSv3 compliant.
*
* Changes from the previous implementation include:
* 1) Multiple '-' args are accepted as required by SUSv3. The previous
* implementation would close stdin and segfault on a subsequent '-'.
* 2) The '-u' options is required by SUSv3. Note that the specified
* behavior for '-u' is done by default, so all we need do is accept
* the option.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "busybox.h"
int cat_main(int argc, char **argv)
{
-65
View File
@@ -1,65 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* cat -v implementation for busybox
*
* Copyright (C) 2006 Rob Landley <rob@landley.net>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* See "Cat -v considered harmful" at
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
#include "busybox.h"
#include <unistd.h>
#include <fcntl.h>
int catv_main(int argc, char **argv)
{
int retval = EXIT_SUCCESS, fd, flags;
flags = bb_getopt_ulflags(argc, argv, "etv");
flags ^= 4;
// Loop through files.
argv += optind;
do {
// Read from stdin if there's nothing else to do.
fd = 0;
if (*argv && 0>(fd = bb_xopen(*argv, O_RDONLY))) retval = EXIT_FAILURE;
else for(;;) {
int i, res;
res = read(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1));
if (res < 0) retval = EXIT_FAILURE;
if (res <1) break;
for (i=0; i<res; i++) {
char c=bb_common_bufsiz1[i];
if (c > 126 && (flags & 4)) {
if (c == 127) {
printf("^?");
continue;
} else {
printf("M-");
c -= 128;
}
}
if (c < 32) {
if (c == 10) {
if (flags & 1) putchar('$');
} else if (flags & (c==9 ? 2 : 4)) {
printf("^%c", c+'@');
continue;
}
}
putchar(c);
}
}
if (ENABLE_FEATURE_CLEAN_UP && fd) close(fd);
} while (*++argv);
return retval;
}
+22 -1
View File
@@ -4,7 +4,20 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
@@ -58,3 +71,11 @@ int chgrp_main(int argc, char **argv)
return retval;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+8
View File
@@ -89,3 +89,11 @@ int chmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
return retval;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+8
View File
@@ -76,3 +76,11 @@ int chown_main(int argc, char **argv)
return retval;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+15 -3
View File
@@ -4,7 +4,20 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
@@ -22,10 +35,9 @@ int chroot_main(int argc, char **argv)
}
++argv;
if (chroot(*argv)) {
if (chroot(*argv) || (chdir("/"))) {
bb_perror_msg_and_die("cannot change root directory to %s", *argv);
}
bb_xchdir("/");
++argv;
if (argc == 2) {
-55
View File
@@ -1,55 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* cksum - calculate the CRC32 checksum of a file
*
* Copyright (C) 2006 by Rob Sullivan, with ideas from code by Walter Harms
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "busybox.h"
int cksum_main(int argc, char **argv) {
uint32_t *crc32_table = bb_crc32_filltable(1);
FILE *fp;
uint32_t crc;
long length, filesize;
int bytes_read;
char *cp;
RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
int inp_stdin = (argc == optind) ? 1 : 0;
do {
fp = bb_wfopen_input((inp_stdin) ? bb_msg_standard_input : *++argv);
crc = 0;
length = 0;
while ((bytes_read = fread(buf, 1, BUFSIZ, fp)) > 0) {
cp = buf;
length += bytes_read;
while (bytes_read--)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
}
filesize = length;
for (; length; length >>= 8)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xffL];
crc ^= 0xffffffffL;
if (inp_stdin) {
printf("%"PRIu32" %li\n", crc, filesize);
break;
}
printf("%"PRIu32" %li %s\n", crc, filesize, *argv);
fclose(fp);
} while (*(argv+1));
return EXIT_SUCCESS;
}
+14 -1
View File
@@ -4,7 +4,20 @@
*
* Copyright (C) 2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */
+1 -1
View File
@@ -46,7 +46,7 @@ int cp_main(int argc, char **argv)
}
if (flags & 64) {
/* Make -r a synonym for -R,
* -r was marked as obsolete in SUSv3, but is included for compatibility
* -r was marked as obsolete in SUSv3, but is included for compatability
*/
flags |= FILEUTILS_RECUR;
}
+15 -2
View File
@@ -1,11 +1,24 @@
/* vi: set sw=4 ts=4: */
/* vi: set sw=8 ts=8: */
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
+17 -17
View File
@@ -9,6 +9,15 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include "busybox.h"
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
setting time using UTC and displaying int, as well as
@@ -20,23 +29,6 @@
/* Default input handling to save surprising some people */
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include "busybox.h"
#define DATE_OPT_RFC2822 0x01
#define DATE_OPT_SET 0x02
#define DATE_OPT_UTC 0x04
#define DATE_OPT_DATE 0x08
#define DATE_OPT_REFERENCE 0x10
#define DATE_OPT_TIMESPEC 0x20
#define DATE_OPT_HINT 0x40
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
{
int nr;
@@ -112,6 +104,14 @@ static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
return (tm_time);
}
#define DATE_OPT_RFC2822 0x01
#define DATE_OPT_SET 0x02
#define DATE_OPT_UTC 0x04
#define DATE_OPT_DATE 0x08
#define DATE_OPT_REFERENCE 0x10
#define DATE_OPT_TIMESPEC 0x20
#define DATE_OPT_HINT 0x40
int date_main(int argc, char **argv)
{
char *date_str = NULL;
+83 -106
View File
@@ -5,7 +5,20 @@
*
* Copyright (C) 2000,2001 Matt Kraai
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <sys/types.h>
@@ -15,9 +28,9 @@
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h> // For FEATURE_DD_SIGNAL_HANDLING
#include "busybox.h"
static const struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
{ "w", 2 },
@@ -31,83 +44,66 @@ static const struct suffix_mult dd_suffixes[] = {
{ NULL, 0 }
};
static size_t out_full;
static size_t out_part;
static size_t in_full;
static size_t in_part;
static void dd_output_status(int cur_signal)
{
fprintf(stderr, "%ld+%ld records in\n%ld+%ld records out\n",
(long)in_full, (long)in_part,
(long)out_full, (long)out_part);
}
int dd_main(int argc, char **argv)
{
size_t count = -1, oc = 0, ibs = 512, obs = 512;
size_t out_full = 0;
size_t out_part = 0;
size_t in_full = 0;
size_t in_part = 0;
size_t count = -1;
size_t bs = 512;
ssize_t n;
off_t seek = 0, skip = 0;
int sync_flag = FALSE, noerror = FALSE, trunc_flag = TRUE, twobufs_flag = 0,
oflag, ifd, ofd, i;
const char *infile = NULL, *outfile = NULL;
char *ibuf, *obuf;
if (ENABLE_FEATURE_DD_SIGNAL_HANDLING)
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = dd_output_status;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR1, &sa, 0);
}
off_t seek = 0;
off_t skip = 0;
int sync_flag = FALSE;
int noerror = FALSE;
int trunc_flag = TRUE;
int oflag;
int ifd;
int ofd;
int i;
const char *infile = NULL;
const char *outfile = NULL;
char *buf;
for (i = 1; i < argc; i++) {
if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("ibs=", argv[i], 4)) {
ibs = bb_xparse_number(argv[i]+4, dd_suffixes);
twobufs_flag++;
} else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("obs=", argv[i], 4)) {
obs = bb_xparse_number(argv[i]+4, dd_suffixes);
twobufs_flag++;
} else if (!strncmp("bs=", argv[i], 3)) {
ibs = obs = bb_xparse_number(argv[i]+3, dd_suffixes);
} else if (!strncmp("count=", argv[i], 6))
if (strncmp("bs=", argv[i], 3) == 0)
bs = bb_xparse_number(argv[i]+3, dd_suffixes);
else if (strncmp("count=", argv[i], 6) == 0)
count = bb_xparse_number(argv[i]+6, dd_suffixes);
else if (!strncmp("seek=", argv[i], 5))
else if (strncmp("seek=", argv[i], 5) == 0)
seek = bb_xparse_number(argv[i]+5, dd_suffixes);
else if (!strncmp("skip=", argv[i], 5))
else if (strncmp("skip=", argv[i], 5) == 0)
skip = bb_xparse_number(argv[i]+5, dd_suffixes);
else if (!strncmp("if=", argv[i], 3))
else if (strncmp("if=", argv[i], 3) == 0)
infile = argv[i]+3;
else if (!strncmp("of=", argv[i], 3))
else if (strncmp("of=", argv[i], 3) == 0)
outfile = argv[i]+3;
else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("conv=", argv[i], 5)) {
ibuf = argv[i]+5;
else if (strncmp("conv=", argv[i], 5) == 0) {
buf = argv[i]+5;
while (1) {
if (!strncmp("notrunc", ibuf, 7)) {
if (strncmp("notrunc", buf, 7) == 0) {
trunc_flag = FALSE;
ibuf += 7;
} else if (!strncmp("sync", ibuf, 4)) {
buf += 7;
} else if (strncmp("sync", buf, 4) == 0) {
sync_flag = TRUE;
ibuf += 4;
} else if (!strncmp("noerror", ibuf, 7)) {
buf += 4;
} else if (strncmp("noerror", buf, 7) == 0) {
noerror = TRUE;
ibuf += 7;
buf += 7;
} else {
bb_error_msg_and_die(bb_msg_invalid_arg, argv[i]+5, "conv");
bb_error_msg_and_die("invalid conversion `%s'", argv[i]+5);
}
if (ibuf[0] == '\0') break;
if (ibuf[0] == ',') ibuf++;
if (buf[0] == '\0')
break;
if (buf[0] == ',')
buf++;
}
} else
bb_show_usage();
}
ibuf = xmalloc(ibs);
if (twobufs_flag) obuf = xmalloc(obs);
else obuf = ibuf;
buf = xmalloc(bs);
if (infile != NULL) {
ifd = bb_xopen(infile, O_RDONLY);
@@ -123,10 +119,12 @@ int dd_main(int argc, char **argv)
oflag |= O_TRUNC;
}
ofd = bb_xopen3(outfile, oflag, 0666);
if ((ofd = open(outfile, oflag, 0666)) < 0) {
bb_perror_msg_and_die("%s", outfile);
}
if (seek && trunc_flag) {
if (ftruncate(ofd, seek * obs) < 0) {
if (ftruncate(ofd, seek * bs) < 0) {
struct stat st;
if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
@@ -141,19 +139,13 @@ int dd_main(int argc, char **argv)
}
if (skip) {
if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
while (skip-- > 0) {
n = safe_read(ifd, ibuf, ibs);
if (n < 0)
bb_perror_msg_and_die("%s", infile);
if (n == 0)
break;
}
if (lseek(ifd, skip * bs, SEEK_CUR) < 0) {
bb_perror_msg_and_die("%s", infile);
}
}
if (seek) {
if (lseek(ofd, seek * obs, SEEK_CUR) < 0) {
if (lseek(ofd, seek * bs, SEEK_CUR) < 0) {
bb_perror_msg_and_die("%s", outfile);
}
}
@@ -161,57 +153,40 @@ int dd_main(int argc, char **argv)
while (in_full + in_part != count) {
if (noerror) {
/* Pre-zero the buffer when doing the noerror thing */
memset(ibuf, '\0', ibs);
}
n = safe_read(ifd, ibuf, ibs);
if (n == 0) {
break;
memset(buf, '\0', bs);
}
n = safe_read(ifd, buf, bs);
if (n < 0) {
if (noerror) {
n = ibs;
n = bs;
bb_perror_msg("%s", infile);
} else {
bb_perror_msg_and_die("%s", infile);
}
}
if ((size_t)n == ibs) {
if (n == 0) {
break;
}
if ((size_t)n == bs) {
in_full++;
} else {
in_part++;
if (sync_flag) {
memset(ibuf + n, '\0', ibs - n);
n = ibs;
}
}
if (twobufs_flag) {
char *tmp = ibuf;
while (n) {
size_t d = obs - oc;
if (d > n) d = n;
memcpy(obuf + oc, tmp, d);
n -= d;
tmp += d;
oc += d;
if (oc == obs) {
xwrite(ofd, obuf, obs);
out_full++;
oc = 0;
}
}
if (sync_flag) {
memset(buf + n, '\0', bs - n);
n = bs;
}
n = bb_full_write(ofd, buf, n);
if (n < 0) {
bb_perror_msg_and_die("%s", outfile);
}
if ((size_t)n == bs) {
out_full++;
} else {
xwrite(ofd, ibuf, n);
if (n == ibs) out_full++;
else out_part++;
out_part++;
}
}
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
xwrite(ofd, obuf, oc);
out_part++;
}
if (close (ifd) < 0) {
bb_perror_msg_and_die("%s", infile);
}
@@ -220,7 +195,9 @@ int dd_main(int argc, char **argv)
bb_perror_msg_and_die("%s", outfile);
}
dd_output_status(0);
fprintf(stderr, "%ld+%ld records in\n%ld+%ld records out\n",
(long)in_full, (long)in_part,
(long)out_full, (long)out_part);
return EXIT_SUCCESS;
}
+22 -1
View File
@@ -5,7 +5,20 @@
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 _NOT_ compliant -- options -P and -t missing. Also blocksize. */
@@ -147,3 +160,11 @@ int df_main(int argc, char **argv)
bb_fflush_stdout_and_exit(status);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
-1256
View File
File diff suppressed because it is too large. Load diff
+14 -1
View File
@@ -4,7 +4,20 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 compliant */
+41 -40
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/*
* dos2unix for BusyBox
*
@@ -9,78 +8,78 @@
*
* dos2unix filters reading input from stdin and writing output to stdout.
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/time.h>
#include "busybox.h"
enum ConvType {
CT_UNIX2DOS = 1,
CT_DOS2UNIX
} ConvType;
#define CT_UNIX2DOS 1
#define CT_DOS2UNIX 2
#define tempFn bb_common_bufsiz1
/* if fn is NULL then input is stdin and output is stdout */
static int convert(char *fn)
static int convert(char *fn, int ConvType)
{
int c, fd;
FILE *in, *out;
int i;
if (fn != NULL) {
in = bb_xfopen(fn, "rw");
/*
The file is then created with mode read/write and
permissions 0666 for glibc 2.0.6 and earlier or
0600 for glibc 2.0.7 and later.
*/
snprintf(bb_common_bufsiz1, sizeof(bb_common_bufsiz1), "%sXXXXXX", fn);
The file is then created with mode read/write and
permissions 0666 for glibc 2.0.6 and earlier or
0600 for glibc 2.0.7 and later.
*/
snprintf(tempFn, sizeof(tempFn), "%sXXXXXX", fn);
/*
sizeof bb_common_bufsiz1 is 4096, so it should be big enough to
hold the full path. However if the output is truncated the
subsequent call to mkstemp would fail.
*/
if ((i = mkstemp(&bb_common_bufsiz1[0])) == -1
|| chmod(bb_common_bufsiz1, 0600) == -1) {
sizeof tempFn is 4096, so it should be big enough to hold the full
path. however if the output is truncated the subsequent call to
mkstemp would fail.
*/
if ((fd = mkstemp(&tempFn[0])) == -1 || chmod(tempFn, 0600) == -1) {
bb_perror_nomsg_and_die();
}
out = fdopen(i, "w+");
out = fdopen(fd, "w+");
if (!out) {
close(i);
remove(bb_common_bufsiz1);
close(fd);
remove(tempFn);
}
} else {
in = stdin;
out = stdout;
}
while ((i = fgetc(in)) != EOF) {
if (i == '\r')
while ((c = fgetc(in)) != EOF) {
if (c == '\r')
continue;
if (i == '\n') {
if (c == '\n') {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(i, out);
fputc(c, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
bb_perror_nomsg();
remove(bb_common_bufsiz1);
remove(tempFn);
return -2;
}
}
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(bb_common_bufsiz1, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", bb_common_bufsiz1, fn);
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(tempFn, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", tempFn, fn);
return -1;
}
}
}
return 0;
@@ -88,13 +87,14 @@ static int convert(char *fn)
int dos2unix_main(int argc, char *argv[])
{
int ConvType;
int o;
/* See if we are supposed to be doing dos2unix or unix2dos */
if (bb_applet_name[0] == 'd') {
ConvType = CT_DOS2UNIX; /*2 */
if (argv[0][0]=='d') {
ConvType = CT_DOS2UNIX; /*2*/
} else {
ConvType = CT_UNIX2DOS; /*1 */
ConvType = CT_UNIX2DOS; /*1*/
}
/* -u and -d are mutally exclusive */
bb_opt_complementally = "?:u--d:d--u";
@@ -109,11 +109,12 @@ int dos2unix_main(int argc, char *argv[])
ConvType = o;
if (optind < argc) {
while (optind < argc)
if ((o = convert(argv[optind++])) < 0)
while(optind < argc)
if ((o = convert(argv[optind++], ConvType)) < 0)
break;
} else
o = convert(NULL);
}
else
o = convert(NULL, ConvType);
return o;
}
+20 -6
View File
@@ -6,7 +6,20 @@
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
* Copyright (C) 2002 Edward Betts <edward@debian.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 compliant (unless default blocksize set to 1k) */
@@ -31,12 +44,12 @@
#include "busybox.h"
#ifdef CONFIG_FEATURE_HUMAN_READABLE
# ifdef CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
# ifdef CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
static unsigned long disp_hr = KILOBYTE;
# else
static unsigned long disp_hr = 512;
# endif
#elif defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
#elif defined CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
static unsigned int disp_k = 1;
#else
static unsigned int disp_k; /* bss inits to 0 */
@@ -121,8 +134,9 @@ static long du(char *filename)
struct dirent *entry;
char *newfile;
dir = bb_opendir(filename);
dir = opendir(filename);
if (!dir) {
bb_perror_msg("%s", filename);
status = EXIT_FAILURE;
return sum;
}
@@ -160,7 +174,7 @@ int du_main(int argc, char **argv)
char *smax_print_depth;
unsigned long opt;
#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K
#ifdef CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */
#ifdef CONFIG_FEATURE_HUMAN_READABLE
disp_hr = 512;
@@ -194,7 +208,7 @@ int du_main(int argc, char **argv)
#else
bb_opt_complementally = "H-L:L-H:s-d:d-s";
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
#if !defined CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
if((opt & (1 << 2))) {
/* -k opt */
disp_k = 1;
+13 -142
View File
@@ -1,158 +1,29 @@
/* vi: set sw=4 ts=4: */
/*
* echo implementation for busybox
* echo applet implementation for busybox
*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice is retained at the end of this file.
*/
/* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* 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'.
* 2) SUSv3 specifies that octal escapes are of the form \0{#{#{#}}}.
* The previous version version did not allow 4-digit octals.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
int bb_echo(int ATTRIBUTE_UNUSED argc, char **argv)
{
#ifndef CONFIG_FEATURE_FANCY_ECHO
#define eflag '\\'
++argv;
#else
const char *p;
int nflag = 1;
int eflag = 0;
while (*++argv && (**argv == '-')) {
/* If it appears that we are handling options, then make sure
* that all of the options specified are actually valid.
* Otherwise, the string should just be echoed.
*/
if (!*(p = *argv + 1)) { /* A single '-', so echo it. */
goto just_echo;
}
do {
if (strrchr("neE", *p) == 0) {
goto just_echo;
}
} while (*++p);
/* All of the options in this arg are valid, so handle them. */
p = *argv + 1;
do {
if (*p == 'n') {
nflag = 0;
} else if (*p == 'e') {
eflag = '\\';
} else {
eflag = 0;
}
} while (*++p);
}
just_echo:
#endif
while (*argv) {
int c;
while ((c = *(*argv)++)) {
if (c == eflag) { /* Check for escape seq. */
if (**argv == 'c') {
/* '\c' means cancel newline and
* ignore all subsequent chars. */
return 0;
}
#ifndef CONFIG_FEATURE_FANCY_ECHO
/* SUSv3 specifies that octal escapes must begin with '0'. */
if (((unsigned int)(**argv - '1')) >= 7)
#endif
{
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
* of the form \0### are accepted. */
if ((**argv == '0') && (((unsigned int)(argv[0][1] - '0')) < 8)) {
(*argv)++;
}
/* bb_process_escape_sequence can handle nul correctly */
c = bb_process_escape_sequence((const char **) argv);
}
}
putchar(c);
}
if (*++argv) {
putchar(' ');
}
}
#ifdef CONFIG_FEATURE_FANCY_ECHO
if (nflag) {
putchar('\n');
}
#else
putchar('\n');
#endif
return 0;
}
int echo_main(int argc, char** argv)
{
(void)bb_echo(argc, argv);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)echo.c 8.1 (Berkeley) 5/31/93
*/
+14 -5
View File
@@ -5,7 +5,19 @@
* Copyright (c) 1988, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice is retained at the end of this file.
*
@@ -38,13 +50,12 @@
#include <getopt.h> /* struct option */
#include "busybox.h"
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
static const struct option env_long_options[] = {
{ "ignore-environment", 0, NULL, 'i' },
{ "unset", 1, NULL, 'u' },
{ 0, 0, 0, 0 }
};
#endif
int env_main(int argc, char** argv)
{
@@ -56,9 +67,7 @@ int env_main(int argc, char** argv)
extern char **environ;
bb_opt_complementally = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
bb_applet_long_options = env_long_options;
#endif
opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env);
+14 -1
View File
@@ -11,7 +11,20 @@
* - reduced 464 bytes.
* - 64 math support
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* This program evaluates expressions. Each token (operator, operand,
+1 -1
View File
@@ -1,4 +1,3 @@
/* vi: set sw=4 ts=4: */
/* fold -- wrap each input line to fit in specified width.
Written by David MacKenzie, djm@gnu.ai.mit.edu.
@@ -159,3 +158,4 @@ rescan:
bb_fflush_stdout_and_exit(errs);
}
/* vi: set sw=4 ts=4: */
+24 -1
View File
@@ -4,7 +4,20 @@
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -G is not currently supported. */
@@ -110,3 +123,13 @@ int id_main(int argc, char **argv)
putchar('\n');
bb_fflush_stdout_and_exit(status);
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
Loaded 100 of 675 files, more files were not shown because too many files have changed in this diff. Show more