Compare commits

..
Author SHA1 Message Date
Denis Vlasenko e9f8b2f830 apply post 1.10.3 patches, release 1.10.4 2008-06-25 11:01:42 +00:00
Denis Vlasenko 49b78fc1a8 Apply post-1.10.2 fixes, bump version to 1.10.3 2008-06-05 01:10:03 +00:00
Denis Vlasenko a3087ca749 Apply post-1.10.1 patches
Bump version to 1.10.2
2008-05-08 15:26:06 +00:00
Bernhard Reutner-Fischer 0abe9d96ee - correct usage helptext of ifupdown 2008-05-08 10:40:56 +00:00
Bernhard Reutner-Fischer 378481ed1e - fix strncmp'ing "runlevel"
r21931 from trunk
2008-05-05 14:48:13 +00:00
Denis Vlasenko fc9fc1f929 apply all post 1.10.0 fixes
bump version to 1.10.1
2008-04-19 04:05:28 +00:00
444 changed files with 8805 additions and 16648 deletions

No files matched your search

+31 -44
View File
@@ -13,6 +13,22 @@ menu "Busybox Settings"
menu "General Configuration"
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.
config DESKTOP
bool "Enable options for full-blown desktop systems"
default n
@@ -21,21 +37,10 @@ config DESKTOP
Select this only if you plan to use busybox on full-blown
desktop machine with common Linux distro, not on an embedded box.
config FEATURE_ASSUME_UNICODE
bool "Assume that 1:1 char/glyph correspondence is not true"
default n
help
This makes various applets aware that one byte is not
one character on screen.
Busybox aims to eventually work correctly with Unicode displays.
Any older encodings are not guaranteed to work.
Probably by the time when busybox will be fully Unicode-clean,
other encodings will be mainly of historic interest.
choice
prompt "Buffer allocation policy"
default FEATURE_BUFFERS_USE_MALLOC
depends on NITPICK
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
@@ -125,6 +130,7 @@ config FEATURE_DEVPTS
config FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
depends on NITPICK
help
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
@@ -274,14 +280,6 @@ config STATIC
Most people will leave this set to 'N'.
config PIE
bool "Build BusyBox as a position independent executable"
default n
depends on !STATIC
help
(TODO: what is it and why/when is it useful?)
Most people will leave this set to 'N'.
config NOMMU
bool "Force NOMMU build"
default n
@@ -293,12 +291,10 @@ config NOMMU
Most people will leave this set to 'N'.
# PIE can be made to work with BUILD_LIBBUSYBOX, but currently
# build system does not support that
config BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
depends on !FEATURE_PREFER_APPLETS && !PIE && !STATIC
depends on !FEATURE_PREFER_APPLETS
help
Build a shared library libbusybox.so.N.N.N which contains all
busybox code.
@@ -385,16 +381,6 @@ 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 CROSS_COMPILER_PREFIX
string "Cross Compiler prefix"
default ""
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,
"i386-uclibc-". Note that CROSS_COMPILE environment variable
or "make CROSS_COMPILE=xxx ..." will override this selection.
For native build leave it empty.
endmenu
menu 'Debugging Options'
@@ -410,17 +396,6 @@ config DEBUG
Most people should answer N.
config DEBUG_PESSIMIZE
bool "Disable compiler optimizations."
default n
depends on 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.
config WERROR
bool "Abort compilation on any warning"
default n
@@ -429,6 +404,18 @@ config WERROR
Most people should answer N.
# Seems to be unused
#config DEBUG_PESSIMIZE
# bool "Disable compiler optimizations."
# default n
# depends on 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 NO_DEBUG_LIB
+24 -36
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 11
SUBLEVEL = 3
PATCHLEVEL = 10
SUBLEVEL = 4
EXTRAVERSION =
NAME = Unnamed
@@ -142,6 +142,17 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH TOPDIR
# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
# line overrides the setting of ARCH below. If a native build is happening,
# then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
@@ -161,32 +172,8 @@ export srctree objtree VPATH TOPDIR
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
CROSS_COMPILE ?=
# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
# and it has not been included yet... thus using an awkward syntax.
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null)
CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE))
CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE))
endif
# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
# line overrides the setting of ARCH below. If a native build is happening,
# then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.
ifneq ($(CROSS_COMPILE),)
SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
else
SUBARCH := $(shell uname -m)
endif
SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
ARCH ?= $(SUBARCH)
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
# Architecture as present in compile.h
UTS_MACHINE := $(ARCH)
@@ -315,8 +302,6 @@ AFLAGS_KERNEL =
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
CFLAGS := $(CFLAGS)
# Added only to final link stage of busybox binary
CFLAGS_busybox := $(CFLAGS_busybox)
CPPFLAGS := $(CPPFLAGS)
AFLAGS := $(AFLAGS)
LDFLAGS := $(LDFLAGS)
@@ -376,8 +361,7 @@ endif
# of make so .config is not included in this case either (for *config).
no-dot-config-targets := clean mrproper distclean \
cscope TAGS tags help %docs
#bbox# check% is removed from above
cscope TAGS tags help %docs check%
config-targets := 0
mixed-targets := 0
@@ -513,6 +497,12 @@ all: busybox
#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# disable pointer signedness warnings in gcc 4.0
CFLAGS += $(call cc-option,-Wno-pointer-sign,)
# Default kernel image to build when no specific target is given.
# KBUILD_IMAGE may be overruled on the commandline or
# set in the environment
@@ -582,7 +572,7 @@ quiet_cmd_busybox__ ?= LINK $@
cmd_busybox__ ?= $(srctree)/scripts/trylink \
"$@" \
"$(CC)" \
"$(CFLAGS) $(CFLAGS_busybox)" \
"$(CFLAGS)" \
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
"$(core-y)" \
"$(libs-y)" \
@@ -698,8 +688,6 @@ ifeq ($(SKIP_STRIP),y)
else
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
busybox_unstripped -o $@
# strip is confused by PIE executable and does not set exec bits
$(Q)chmod a+x $@
endif
# The actual objects are generated when descending,
@@ -933,7 +921,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += busybox busybox_unstripped* System.map .kernelrelease \
CLEAN_FILES += busybox* System.map .kernelrelease \
.tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
# Directories & files removed with 'make mrproper'
+4 -9
View File
@@ -46,20 +46,15 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n)
done
endif
# Not very elegant: copies testsuite to objdir...
# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
.PHONY: check
.PHONY: test
check test: busybox busybox.links
test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
bindir=$(objtree) srcdir=$(srctree)/testsuite \
$(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
.PHONY: release
release: distclean
cd ..; \
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
-name .svn \
-print \
@@ -99,7 +94,7 @@ stksizes: busybox_unstripped
.PHONY: bigdata
bigdata: busybox_unstripped
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
# Documentation Targets
.PHONY: doc
+27 -40
View File
@@ -11,31 +11,38 @@ CPPFLAGS += $(call cc-option,-std=gnu99,)
CPPFLAGS += \
-Iinclude -Ilibbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include -I$(srctree)/libbb) \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
-include include/autoconf.h \
-D_GNU_SOURCE -DNDEBUG \
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
CFLAGS += $(call cc-option,-Wall,)
CFLAGS += $(call cc-option,-Wshadow,)
CFLAGS += $(call cc-option,-Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef,)
CFLAGS += $(call cc-option,-Wstrict-prototypes,)
# flag checks are grouped together to speed the checks up a bit..
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# If you want to add more -Wsomething above, make sure that it is
# still possible to build bbox without warnings.
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action().
# Looks more like gcc bug: gcc will warn on it with or without prototype.
# But still, warning-free compile is a must, or else we will drown
# in warnings pretty soon.
ifeq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Werror,)
else
# for development, warn a little bit about unused results..
CPPFLAGS += -D_FORTIFY_SOURCE=2
endif
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
ifneq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
endif
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
# -fno-guess-branch-probability: prohibit pseudo-random guessing
# of branch probabilities (hopefully makes bloatcheck more stable):
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
@@ -46,38 +53,21 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
# be fixed..
#CFLAGS+=$(call cc-option,-Wconversion,)
ifneq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-Os,)
else
CFLAGS += $(call cc-option,-g,)
ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
CFLAGS += $(call cc-option,-O0,)
else
CFLAGS += $(call cc-option,-Os,)
ifeq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-g)
endif
endif
# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
ARCH_FPIC ?= -fpic
ARCH_FPIE ?= -fpie
ARCH_PIE ?= -pie
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
# on i386: 14% smaller libbusybox.so
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
CFLAGS += $(ARCH_FPIC)
CFLAGS += -fpic
# and another 4% reduction of libbusybox.so:
# (external entry points must be marked EXTERNALLY_VISIBLE)
CFLAGS += $(call cc-option,-fvisibility=hidden)
endif
ifeq ($(CONFIG_STATIC),y)
CFLAGS_busybox += -static
endif
ifeq ($(CONFIG_PIE),y)
CFLAGS_busybox += $(ARCH_PIE)
CFLAGS += $(ARCH_FPIE)
LDFLAGS += -static
endif
LDLIBS += m crypt
@@ -98,13 +88,10 @@ ifeq ($(CONFIG_DMALLOC),y)
LDLIBS += dmalloc
endif
# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
# env var should be set for make invocation.
# Here we check whether CFLAGS_busybox indeed contains that flag.
# (For historical reasons, we also check LDFLAGS, which doesn't
# seem to be entirely correct variable to put "-Wl,-elf2flt" into).
W_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
#LDFLAGS += -nostdlib
LDFLAGS_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
SKIP_STRIP = y
endif
+11 -4
View File
@@ -6,7 +6,7 @@ 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 suggested these:
Rob Landley <rob@landley.net>:
Add a libbb/platform.c
Implement fdprintf() for platforms that haven't got one.
Implement bb_realpath() that can handle NULL on non-glibc.
@@ -24,6 +24,11 @@ Rob Landley suggested these:
but less buggy :)
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.
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
@@ -141,7 +146,7 @@ man
(How doclifter might work into this is anybody's guess.)
---
ar
Write support!
Write support?
---
stty / catv
stty's visible() function and catv's guts are identical. Merge them into
@@ -277,6 +282,10 @@ Minor stuff:
---
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()
---
@@ -285,8 +294,6 @@ Minor stuff:
See grep -r strtod
Alot of duplication that wants cleanup.
---
in_ether duplicated in network/{interface,ifconfig}.c
---
Code cleanup:
+6 -12
View File
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.11.0.svn
# Mon Apr 21 23:20:35 2008
# Busybox version: 1.10.0.svn
# Thu Mar 20 14:54:21 2008
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -12,6 +12,7 @@ CONFIG_HAVE_DOT_CONFIG=y
#
# General Configuration
#
CONFIG_NITPICK=y
CONFIG_DESKTOP=y
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
@@ -99,7 +100,6 @@ CONFIG_FEATURE_AR_LONG_FILENAMES=y
CONFIG_BUNZIP2=y
CONFIG_BZIP2=y
CONFIG_CPIO=y
CONFIG_FEATURE_CPIO_O=y
CONFIG_DPKG=y
CONFIG_DPKG_DEB=y
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
@@ -130,6 +130,7 @@ CONFIG_UNZIP=y
#
# Common options for cpio and tar
#
CONFIG_FEATURE_UNARCHIVE_TAPE=y
#
# Common options for dpkg and dpkg_deb
@@ -485,7 +486,6 @@ CONFIG_LOSETUP=y
CONFIG_MDEV=y
CONFIG_FEATURE_MDEV_CONF=y
CONFIG_FEATURE_MDEV_RENAME=y
CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
CONFIG_FEATURE_MDEV_EXEC=y
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
CONFIG_MKSWAP=y
@@ -522,7 +522,6 @@ CONFIG_PIVOT_ROOT=y
CONFIG_RDATE=y
CONFIG_READPROFILE=y
CONFIG_RTCWAKE=y
CONFIG_SCRIPT=y
CONFIG_SETARCH=y
CONFIG_SWAPONOFF=y
CONFIG_SWITCH_ROOT=y
@@ -561,7 +560,6 @@ CONFIG_DC=y
# CONFIG_FEATURE_DEVFS is not set
CONFIG_EJECT=y
CONFIG_FEATURE_EJECT_SCSI=y
CONFIG_FBSPLASH=y
CONFIG_LAST=y
CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
@@ -580,7 +578,6 @@ CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
CONFIG_MAKEDEVS=y
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
CONFIG_FEATURE_MAKEDEVS_TABLE=y
CONFIG_MAN=y
CONFIG_MICROCOM=y
CONFIG_MOUNTPOINT=y
CONFIG_MT=y
@@ -588,9 +585,9 @@ CONFIG_RAIDAUTORUN=y
CONFIG_READAHEAD=y
CONFIG_RUNLEVEL=y
CONFIG_RX=y
CONFIG_SETSID=y
CONFIG_SCRIPT=y
CONFIG_STRINGS=y
CONFIG_SYMLINKS=y
CONFIG_SETSID=y
CONFIG_TASKSET=y
CONFIG_FEATURE_TASKSET_FANCY=y
CONFIG_TIME=y
@@ -607,7 +604,6 @@ CONFIG_ARP=y
CONFIG_ARPING=y
CONFIG_BRCTL=y
CONFIG_FEATURE_BRCTL_FANCY=y
CONFIG_FEATURE_BRCTL_SHOW=y
CONFIG_DNSD=y
CONFIG_ETHER_WAKE=y
CONFIG_FAKEIDENTD=y
@@ -756,7 +752,6 @@ CONFIG_WATCH=y
# CONFIG_FEATURE_SH_IS_MSH is not set
CONFIG_FEATURE_SH_IS_NONE=y
# CONFIG_ASH is not set
# CONFIG_ASH_BASH_COMPAT is not set
# CONFIG_ASH_JOB_CONTROL is not set
# CONFIG_ASH_READ_NCHARS is not set
# CONFIG_ASH_READ_TIMEOUT is not set
@@ -786,7 +781,6 @@ CONFIG_MSH=y
#
CONFIG_FEATURE_SH_EXTRA_QUIET=y
CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_FEATURE_SH_NOFORK=y
CONFIG_CTTYHACK=y
#
+4 -15
View File
@@ -47,7 +47,6 @@ int main(int argc, char **argv)
{
int i;
int ofs;
unsigned MAX_APPLET_NAME_LEN = 1;
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
@@ -70,23 +69,15 @@ int main(int argc, char **argv)
/* Keep in sync with include/busybox.h! */
puts("/* This is a generated file, don't edit */\n");
puts("/* This is a generated file, don't edit */");
printf("#define NUM_APPLETS %u\n", NUM_APPLETS);
if (NUM_APPLETS == 1) {
printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].name);
}
puts("\nconst char applet_names[] ALIGN1 = \"\"");
puts("const char applet_names[] ALIGN1 = \"\"\n");
for (i = 0; i < NUM_APPLETS; i++) {
printf("\"%s\" \"\\0\"\n", applets[i].name);
if (MAX_APPLET_NAME_LEN < strlen(applets[i].name))
MAX_APPLET_NAME_LEN = strlen(applets[i].name);
}
puts(";");
puts("\nint (*const applet_main[])(int argc, char **argv) = {");
puts("int (*const applet_main[])(int argc, char **argv) = {");
for (i = 0; i < NUM_APPLETS; i++) {
printf("%s_main,\n", applets[i].main);
}
@@ -117,10 +108,8 @@ int main(int argc, char **argv)
printf("0x%02x,\n", v);
i++;
}
puts("};\n");
puts("};");
#endif
printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
return 0;
}
+4 -2
View File
@@ -14,11 +14,13 @@ const char *applet_name;
int main(int argc, char **argv)
{
applet_name = argv[0];
return APPLET_main(argc,argv);
}
void bb_show_usage(void)
{
fputs(APPLET_full_usage "\n", stdout);
exit(EXIT_FAILURE);
printf(APPLET_full_usage "\n");
exit(1);
}
+1 -1
View File
@@ -37,7 +37,7 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
for i in $DO_INSTALL_LIBS; do
rm -f $prefix/$libdir/$i || exit 1
if [ -f $i ]; then
cp -pPR $i $prefix/$libdir/ || exit 1
cp -a $i $prefix/$libdir/ || exit 1
chmod 0644 $prefix/$libdir/$i || exit 1
fi
done
+1 -12
View File
@@ -5,17 +5,6 @@
* object directory */
#include "../include/autoconf.h"
/* Since we can't use platform.h, have to do this again by hand: */
#if ENABLE_NOMMU
#define BB_MMU 0
#define USE_FOR_NOMMU(...) __VA_ARGS__
#define USE_FOR_MMU(...)
#else
#define BB_MMU 1
#define USE_FOR_NOMMU(...)
#define USE_FOR_MMU(...) __VA_ARGS__
#endif
static const char usage_messages[] = ""
#define MAKE_USAGE
#include "usage.h"
@@ -24,6 +13,6 @@ static const char usage_messages[] = ""
int main(void)
{
write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
write(1, usage_messages, sizeof(usage_messages));
return 0;
}
+4 -11
View File
@@ -14,21 +14,14 @@ exec >"$target"
echo 'static const char packed_usage[] ALIGN1 = {'
## Breaks on big-endian systems!
## # Extra effort to avoid using "od -t x1": -t is not available
## # in non-CONFIG_DESKTOPed busybox od
##
## "$loc/usage" | bzip2 -1 | od -v -x \
## | $SED -e 's/^[^ ]*//' \
## | $SED -e 's/ //g' \
## | grep -v '^$' \
## | $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
# Extra effort to avoid using "od -t x1": -t is not available
# in non-CONFIG_DESKTOPed busybox od
"$loc/usage" | bzip2 -1 | od -v -t x1 \
"$loc/usage" | bzip2 -1 | od -v -x \
| $SED -e 's/^[^ ]*//' \
| $SED -e 's/ //g' \
| grep -v '^$' \
| $SED -e 's/\(..\)/0x\1,/g'
| $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
echo '};'
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
+8 -9
View File
@@ -78,14 +78,6 @@ config CPIO
Unless you have a specific application which requires cpio, you should
probably say N here.
config FEATURE_CPIO_O
bool "Support for archive creation"
default n
depends on CPIO
help
This implementation of cpio can create cpio archives in the "newc"
format only.
config DPKG
bool "dpkg"
default n
@@ -287,7 +279,7 @@ config UNLZMA
should probably say N here.
config FEATURE_LZMA_FAST
bool "Optimize unlzma for speed"
bool "Optimze unlzma for speed"
default n
depends on UNLZMA
help
@@ -307,6 +299,13 @@ config UNZIP
comment "Common options for cpio and tar"
depends on CPIO || TAR
config FEATURE_UNARCHIVE_TAPE
bool "Enable tape drive support"
default n
depends on CPIO || TAR
help
I don't think this is needed anymore.
comment "Common options for dpkg and dpkg_deb"
depends on DPKG || DPKG_DEB
+1 -15
View File
@@ -256,24 +256,10 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
return status;
}
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
* -n --no-name
* gzip: do not save the original file name and time stamp.
* (The original name is always saved if the name had to be truncated.)
* gunzip: do not restore the original file name/time even if present
* (remove only the gzip suffix from the compressed file name).
* This option is the default when decompressing.
* -N --name
* gzip: always save the original file name and time stamp (this is the default)
* gunzip: restore the original file name and time stamp if present.
*/
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int gunzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
getopt32(argv, "cfvdtn");
getopt32(argv, "cfvdt");
argv += optind;
/* if called as zcat */
if (applet_name[1] == 'c')
+18 -285
View File
@@ -7,298 +7,35 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Limitations:
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
*
*/
#include "libbb.h"
#include "unarchive.h"
#if ENABLE_FEATURE_CPIO_O
static off_t cpio_pad4(off_t size)
{
int i;
i = (- size) & 3;
size += i;
while (--i >= 0)
bb_putchar('\0');
return size;
}
/* Return value will become exit code.
* It's ok to exit instead of return. */
static int cpio_o(void)
{
struct name_s {
struct name_s *next;
char name[1];
};
struct inodes_s {
struct inodes_s *next;
struct name_s *names;
struct stat st;
};
struct inodes_s *links = NULL;
off_t bytes = 0; /* output bytes count */
while (1) {
const char *name;
char *line;
struct stat st;
line = xmalloc_fgetline(stdin);
if (line) {
/* Strip leading "./[./]..." from the filename */
name = line;
while (name[0] == '.' && name[1] == '/') {
while (*++name == '/')
continue;
}
if (!*name) { /* line is empty */
free(line);
continue;
}
if (lstat(name, &st)) {
abort_cpio_o:
bb_simple_perror_msg_and_die(name);
}
if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)))
st.st_size = 0; /* paranoia */
/* Store hardlinks for later processing, dont output them */
if (!S_ISDIR(st.st_mode) && st.st_nlink > 1) {
struct name_s *n;
struct inodes_s *l;
/* Do we have this hardlink remembered? */
l = links;
while (1) {
if (l == NULL) {
/* Not found: add new item to "links" list */
l = xzalloc(sizeof(*l));
l->st = st;
l->next = links;
links = l;
break;
}
if (l->st.st_ino == st.st_ino) {
/* found */
break;
}
l = l->next;
}
/* Add new name to "l->names" list */
n = xmalloc(sizeof(*n) + strlen(name));
strcpy(n->name, name);
n->next = l->names;
l->names = n;
free(line);
continue;
}
} else { /* line == NULL: EOF */
next_link:
if (links) {
/* Output hardlink's data */
st = links->st;
name = links->names->name;
links->names = links->names->next;
/* GNU cpio is reported to emit file data
* only for the last instance. Mimic that. */
if (links->names == NULL)
links = links->next;
else
st.st_size = 0;
/* NB: we leak links->names and/or links,
* this is intended (we exit soon anyway) */
} else {
/* If no (more) hardlinks to output,
* output "trailer" entry */
name = "TRAILER!!!";
/* st.st_size == 0 is a must, but for uniformity
* in the output, we zero out everything */
memset(&st, 0, sizeof(st));
/* st.st_nlink = 1; - GNU cpio does this */
}
}
bytes += printf("070701"
"%08X%08X%08X%08X%08X%08X%08X"
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
/* strlen+1: */ "%08X"
/* chksum: */ "00000000" /* (only for "070702" files) */
/* name,NUL: */ "%s%c",
(unsigned)(uint32_t) st.st_ino,
(unsigned)(uint32_t) st.st_mode,
(unsigned)(uint32_t) st.st_uid,
(unsigned)(uint32_t) st.st_gid,
(unsigned)(uint32_t) st.st_nlink,
(unsigned)(uint32_t) st.st_mtime,
(unsigned)(uint32_t) st.st_size,
(unsigned)(uint32_t) major(st.st_dev),
(unsigned)(uint32_t) minor(st.st_dev),
(unsigned)(uint32_t) major(st.st_rdev),
(unsigned)(uint32_t) minor(st.st_rdev),
(unsigned)(strlen(name) + 1),
name, '\0');
bytes = cpio_pad4(bytes);
if (st.st_size) {
if (S_ISLNK(st.st_mode)) {
char *lpath = xmalloc_readlink_or_warn(name);
if (!lpath)
goto abort_cpio_o;
bytes += printf("%s", lpath);
free(lpath);
} else { /* S_ISREG */
int fd = xopen(name, O_RDONLY);
fflush(stdout);
/* We must abort if file got shorter too! */
bb_copyfd_exact_size(fd, STDOUT_FILENO, st.st_size);
bytes += st.st_size;
close(fd);
}
bytes = cpio_pad4(bytes);
}
if (!line) {
if (links)
goto next_link;
/* TODO: GNU cpio pads trailer to 512 bytes, do we want that? */
return EXIT_SUCCESS;
}
free(line);
} /* end of "while (1)" */
}
#endif
/* GNU cpio (GNU cpio) 2.9 help (abridged):
Main operation mode:
-i, --extract Extract files from an archive
-o, --create Create the archive
-p, --pass-through Copy-pass mode (was ist das?!)
-t, --list List the archive
Operation modifiers valid in any mode:
--block-size=SIZE I/O block size = SIZE * 512 bytes
-B I/O block size = 5120 bytes
-c Use the old portable (ASCII) archive format
-C, --io-size=NUMBER I/O block size to the given NUMBER bytes
-f, --nonmatching Only copy files that do not match given pattern
-F, --file=FILE Use FILE instead of standard input or output
-H, --format=FORMAT Use given archive FORMAT
-M, --message=STRING Print STRING when the end of a volume of the
backup media is reached
-n, --numeric-uid-gid If -v, show numeric UID and GID
--quiet Do not print the number of blocks copied
--rsh-command=COMMAND Use remote COMMAND instead of rsh
-v, --verbose Verbosely list the files processed
-V, --dot Print a "." for each file processed
-W, --warning=FLAG Control warning display: 'none','truncate','all';
multiple options accumulate
Operation modifiers valid only in --extract mode:
-b, --swap Swap both halfwords of words and bytes of
halfwords in the data (equivalent to -sS)
-r, --rename Interactively rename files
-s, --swap-bytes Swap the bytes of each halfword in the files
-S, --swap-halfwords Swap the halfwords of each word (4 bytes)
--to-stdout Extract files to standard output
-E, --pattern-file=FILE Read additional patterns specifying filenames to
extract or list from FILE
--only-verify-crc Verify CRC's, don't actually extract the files
Operation modifiers valid only in --create mode:
-A, --append Append to an existing archive
-O FILE File to use instead of standard output
Operation modifiers valid only in --pass-through mode:
-l, --link Link files instead of copying them, when possible
Operation modifiers valid in --extract and --create modes:
--absolute-filenames Do not strip file system prefix components from
the file names
--no-absolute-filenames Create all files relative to the current dir
Operation modifiers valid in --create and --pass-through modes:
-0, --null A list of filenames is terminated by a NUL
-a, --reset-access-time Reset the access times of files after reading them
-I FILE File to use instead of standard input
-L, --dereference Dereference symbolic links (copy the files
that they point to instead of copying the links)
-R, --owner=[USER][:.][GROUP] Set owner of created files
Operation modifiers valid in --extract and --pass-through modes:
-d, --make-directories Create leading directories where needed
-m, --preserve-modification-time
Retain previous file modification times when
creating files
--no-preserve-owner Do not change the ownership of the files
--sparse Write files with blocks of zeros as sparse files
-u, --unconditional Replace all files unconditionally
*/
#define CPIO_OPT_EXTRACT 0x01
#define CPIO_OPT_TEST 0x02
#define CPIO_OPT_UNCONDITIONAL 0x04
#define CPIO_OPT_VERBOSE 0x08
#define CPIO_OPT_FILE 0x10
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
#define CPIO_OPT_PRESERVE_MTIME 0x40
int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cpio_main(int argc ATTRIBUTE_UNUSED, char **argv)
int cpio_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename;
USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
char *cpio_filename = NULL;
unsigned opt;
enum {
CPIO_OPT_EXTRACT = (1 << 0),
CPIO_OPT_TEST = (1 << 1),
CPIO_OPT_UNCONDITIONAL = (1 << 2),
CPIO_OPT_VERBOSE = (1 << 3),
CPIO_OPT_FILE = (1 << 4),
CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
CPIO_OPT_PRESERVE_MTIME = (1 << 6),
CPIO_OPT_CREATE = (1 << 7),
CPIO_OPT_FORMAT = (1 << 8),
};
#if ENABLE_GETOPT_LONG && ENABLE_DESKTOP
applet_long_options =
"extract\0" No_argument "i"
"list\0" No_argument "t"
#if ENABLE_FEATURE_CPIO_O
"create\0" No_argument "o"
"format\0" Required_argument "H"
#endif
;
#endif
/* Initialize */
/* Initialise */
archive_handle = init_handle();
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
#if ENABLE_FEATURE_CPIO_O
opt = getopt32(argv, "ituvF:dmoH:", &cpio_filename, &cpio_fmt);
if (opt & CPIO_OPT_CREATE) {
if (*cpio_fmt != 'n')
bb_show_usage();
if (opt & CPIO_OPT_FILE) {
fclose(stdout);
stdout = fopen(cpio_filename, "w");
/* Paranoia: I don't trust libc that much */
xdup2(fileno(stdout), STDOUT_FILENO);
}
return cpio_o();
}
#else
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
#endif
argv += optind;
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
@@ -326,25 +63,21 @@ int cpio_main(int argc ATTRIBUTE_UNUSED, char **argv)
archive_handle->action_header = header_list;
}
}
if (opt & CPIO_OPT_FILE) { /* -F */
if (cpio_filename) { /* CPIO_OPT_FILE */
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
archive_handle->seek = seek_by_jump;
}
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
}
if (opt & CPIO_OPT_PRESERVE_MTIME) {
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
}
while (*argv) {
while (optind < argc) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), *argv);
argv++;
llist_add_to(&(archive_handle->accept), argv[optind]);
optind++;
}
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
continue;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
return EXIT_SUCCESS;
}
+81 -107
View File
@@ -75,21 +75,10 @@ typedef struct status_node_s {
unsigned status:16; /* was:14 */ /* has to fit STATUS_HASH_PRIME */
} status_node_t;
/* Globals */
struct globals {
char *name_hashtable[NAME_HASH_PRIME + 1];
common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
};
#define G (*ptr_to_globals)
#define name_hashtable (G.name_hashtable )
#define package_hashtable (G.package_hashtable)
#define status_hashtable (G.status_hashtable )
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0)
/* Were statically declared here, but such a big bss is nommu-unfriendly */
static char **name_hashtable; /* [NAME_HASH_PRIME + 1] */
static common_node_t **package_hashtable; /* [PACKAGE_HASH_PRIME + 1] */
static status_node_t **status_hashtable; /* [STATUS_HASH_PRIME + 1] */
/* Even numbers are for 'extras', like ored dependencies or null */
enum edge_type_e {
@@ -135,7 +124,7 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
* shift amount is mod 24 because long int is 32 bit and data
* to be shifted is 8, don't want to shift data to where it has
* no effect*/
hash_num += (key[i] + key[i-1]) << ((key[i] * i) % 24);
hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24));
}
*start = (unsigned) hash_num % hash_prime;
*decrement = (unsigned) 1 + (hash_num % (hash_prime - 1));
@@ -144,8 +133,8 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
/* this adds the key to the hash table */
static int search_name_hashtable(const char *key)
{
unsigned probe_address;
unsigned probe_decrement;
unsigned probe_address = 0;
unsigned probe_decrement = 0;
make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME);
while (name_hashtable[probe_address] != NULL) {
@@ -166,8 +155,8 @@ static int search_name_hashtable(const char *key)
*/
static unsigned search_status_hashtable(const char *key)
{
unsigned probe_address;
unsigned probe_decrement;
unsigned probe_address = 0;
unsigned probe_decrement = 0;
make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME);
while (status_hashtable[probe_address] != NULL) {
@@ -323,10 +312,11 @@ static int test_version(const unsigned version1, const unsigned version2, const
return FALSE;
}
static int search_package_hashtable(const unsigned name, const unsigned version, const unsigned operator)
{
unsigned probe_address;
unsigned probe_decrement;
unsigned probe_address = 0;
unsigned probe_decrement = 0;
make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME);
while (package_hashtable[probe_address] != NULL) {
@@ -420,10 +410,10 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS)
&& (strcmp(field, field2) != 0)
) {
or_edge = xzalloc(sizeof(edge_t));
or_edge = xmalloc(sizeof(edge_t));
or_edge->type = edge_type + 1;
or_edge->name = search_name_hashtable(field);
//or_edge->version = 0; // tracks the number of alternatives
or_edge->version = 0; // tracks the number of alternatives
add_edge_to_node(parent_node, or_edge);
}
@@ -449,13 +439,17 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
if (offset_ch > 0) {
if (strncmp(version, "=", offset_ch) == 0) {
edge->operator = VER_EQUAL;
} else if (strncmp(version, "<<", offset_ch) == 0) {
}
else if (strncmp(version, "<<", offset_ch) == 0) {
edge->operator = VER_LESS;
} else if (strncmp(version, "<=", offset_ch) == 0) {
}
else if (strncmp(version, "<=", offset_ch) == 0) {
edge->operator = VER_LESS_EQUAL;
} else if (strncmp(version, ">>", offset_ch) == 0) {
}
else if (strncmp(version, ">>", offset_ch) == 0) {
edge->operator = VER_MORE;
} else if (strncmp(version, ">=", offset_ch) == 0) {
}
else if (strncmp(version, ">=", offset_ch) == 0) {
edge->operator = VER_MORE_EQUAL;
} else {
bb_error_msg_and_die("illegal operator");
@@ -741,6 +735,7 @@ static const char *describe_status(int status_num)
return "is not installed or flagged to be installed";
}
static void index_status_file(const char *filename)
{
FILE *status_file;
@@ -1157,9 +1152,9 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
static char **create_list(const char *filename)
{
FILE *list_stream;
char **file_list;
char *line;
int count;
char **file_list = NULL;
char *line = NULL;
int count = 0;
/* don't use [xw]fopen here, handle error ourself */
list_stream = fopen(filename, "r");
@@ -1167,15 +1162,17 @@ static char **create_list(const char *filename)
return NULL;
}
file_list = NULL;
count = 0;
while ((line = xmalloc_fgetline(list_stream)) != NULL) {
while ((line = xmalloc_getline(list_stream)) != NULL) {
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
file_list[count++] = line;
file_list[count] = NULL;
file_list[count] = line;
count++;
}
fclose(list_stream);
if (count == 0) {
return NULL;
}
file_list[count] = NULL;
return file_list;
}
@@ -1212,54 +1209,24 @@ static int remove_file_array(char **remove_names, char **exclude_names)
return (remove_flag == 0);
}
static void run_package_script_or_die(const char *package_name, const char *script_type)
static int run_package_script(const char *package_name, const char *script_type)
{
struct stat path_stat;
char *script_path;
int result;
script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
/* If the file doesnt exist is isnt fatal */
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
/* If the file doesnt exist is isnt a fatal */
result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
free(script_path);
if (result)
bb_error_msg_and_die("%s failed, exit code %d", script_type, result);
return result;
}
/*
The policy manual defines what scripts get called when and with
what arguments. I realize that busybox does not support all of
these scenarios, but it does support some of them; it does not,
however, run them with any parameters in run_package_script_or_die().
Here are the scripts:
preinst install
preinst install <old_version>
preinst upgrade <old_version>
preinst abort_upgrade <new_version>
postinst configure <most_recent_version>
postinst abort-upgade <new_version>
postinst abort-remove
postinst abort-remove in-favour <package> <version>
postinst abort-deconfigure in-favor <failed_install_package> removing <conflicting_package> <version>
prerm remove
prerm upgrade <new_version>
prerm failed-upgrade <old_version>
prerm remove in-favor <package> <new_version>
prerm deconfigure in-favour <package> <version> removing <package> <version>
postrm remove
postrm purge
postrm upgrade <new_version>
postrm failed-upgrade <old_version>
postrm abort-install
postrm abort-install <old_version>
postrm abort-upgrade <old_version>
postrm disappear <overwriter> <version>
*/
static const char *const all_control_files[] = {
"preinst", "postinst", "prerm", "postrm",
"list", "md5sums", "shlibs", "conffiles",
"config", "templates"
"config", "templates", NULL
};
static char **all_control_list(const char *package_name)
@@ -1268,10 +1235,9 @@ 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) + sizeof(char*));
while (i < ARRAY_SIZE(all_control_files)) {
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s",
package_name, all_control_files[i]);
remove_files = xzalloc(sizeof(all_control_files));
while (all_control_files[i]) {
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
i++;
}
@@ -1344,26 +1310,27 @@ static void remove_package(const unsigned package_num, int noisy)
if (noisy)
printf("Removing %s (%s)...\n", package_name, package_version);
/* Run prerm script */
run_package_script_or_die(package_name, "prerm");
/* run prerm script */
if (run_package_script(package_name, "prerm") != 0) {
bb_error_msg_and_die("script failed, prerm failure");
}
/* Create a list of files to remove, and a separate list of those to keep */
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
remove_files = create_list(list_name);
sprintf(conffile_name, "/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
sprintf(conffile_name, "/var/lib/dpkg/info/%s.conffiles", package_name);
exclude_files = create_list(conffile_name);
/* Some directories can't be removed straight away, so do multiple passes */
while (remove_file_array(remove_files, exclude_files))
continue;
while (remove_file_array(remove_files, exclude_files)) /*repeat */;
free_array(exclude_files);
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[0] = xstrdup(conffile_name);
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.postrm", package_name);
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
@@ -1372,10 +1339,8 @@ static void remove_package(const unsigned package_num, int noisy)
free_array(remove_files);
free_array(exclude_files);
/* rename <package>.conffiles to <package>.list
* The conffiles control file isn't required in Debian packages, so don't
* error out if it's missing. */
rename(conffile_name, list_name);
/* rename <package>.conffile to <package>.list */
xrename(conffile_name, list_name);
/* Change package status */
set_status(status_num, "config-files", 3);
@@ -1392,11 +1357,13 @@ static void purge_package(const unsigned package_num)
printf("Purging %s (%s)...\n", package_name, package_version);
/* Run prerm script */
run_package_script_or_die(package_name, "prerm");
/* run prerm script */
if (run_package_script(package_name, "prerm") != 0) {
bb_error_msg_and_die("script failed, prerm failure");
}
/* Create a list of files to remove */
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
remove_files = create_list(list_name);
exclude_files = xzalloc(sizeof(char*));
@@ -1411,8 +1378,10 @@ static void purge_package(const unsigned package_num)
free_array(remove_files);
free(exclude_files);
/* Run postrm script */
run_package_script_or_die(package_name, "postrm");
/* run postrm script */
if (run_package_script(package_name, "postrm") != 0) {
bb_error_msg_and_die("postrm failure.. set status to what?");
}
/* Change package status */
set_status(status_num, "not-installed", 3);
@@ -1502,8 +1471,8 @@ static void unpack_package(deb_file_t *deb_file)
char *list_filename;
archive_handle_t *archive_handle;
FILE *out_stream;
llist_t *accept_list;
int i;
llist_t *accept_list = NULL;
int i = 0;
/* If existing version, remove it first */
if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
@@ -1517,13 +1486,11 @@ static void unpack_package(deb_file_t *deb_file)
}
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
info_prefix = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "");
info_prefix = xasprintf("/var/lib/dpkg/info/%s.", package_name);
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_control(archive_handle);
accept_list = NULL;
i = 0;
while (i < ARRAY_SIZE(all_control_files)) {
while (all_control_files[i]) {
char *c = xasprintf("./%s", all_control_files[i]);
llist_add_to(&accept_list, c);
i++;
@@ -1536,7 +1503,10 @@ static void unpack_package(deb_file_t *deb_file)
unpack_ar_archive(archive_handle);
/* Run the preinst prior to extracting */
run_package_script_or_die(package_name, "preinst");
if (run_package_script(package_name, "preinst") != 0) {
/* when preinst returns exit code != 0 then quit installation process */
bb_error_msg_and_die("subprocess pre-installation script returned error");
}
/* Extract data.tar.gz to the root directory */
archive_handle = init_archive_deb_ar(deb_file->filename);
@@ -1547,7 +1517,7 @@ static void unpack_package(deb_file_t *deb_file)
unpack_ar_archive(archive_handle);
/* Create the list file */
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
list_filename = xasprintf("/var/lib/dpkg/info/%s.list", package_name);
out_stream = xfopen(list_filename, "w");
while (archive_handle->sub_archive->passed) {
/* the leading . has been stripped by data_extract_all_prefix already */
@@ -1574,16 +1544,17 @@ static void configure_package(deb_file_t *deb_file)
printf("Setting up %s (%s)...\n", package_name, package_version);
/* Run the postinst script */
/* TODO: handle failure gracefully */
run_package_script_or_die(package_name, "postinst");
if (run_package_script(package_name, "postinst") != 0) {
/* TODO: handle failure gracefully */
bb_error_msg_and_die("postinst failure.. set status to what?");
}
/* Change status to reflect success */
set_status(status_num, "install", 1);
set_status(status_num, "installed", 3);
}
int dpkg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dpkg_main(int argc ATTRIBUTE_UNUSED, char **argv)
int dpkg_main(int argc, char **argv)
{
deb_file_t **deb_file = NULL;
status_node_t *status_node;
@@ -1604,8 +1575,6 @@ int dpkg_main(int argc ATTRIBUTE_UNUSED, char **argv)
OPT_unpack = 0x40,
};
INIT_G();
opt = getopt32(argv, "CF:ilPru", &str_f);
//if (opt & OPT_configure) ... // -C
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
@@ -1617,11 +1586,16 @@ int dpkg_main(int argc ATTRIBUTE_UNUSED, char **argv)
//if (opt & OPT_purge) ... // -P
//if (opt & OPT_remove) ... // -r
//if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
argc -= optind;
argv += optind;
/* check for non-option argument if expected */
if (!opt || (!argv[0] && !(opt && OPT_list_installed)))
if (!opt || (!argc && !(opt && OPT_list_installed)))
bb_show_usage();
name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1));
package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1));
status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1));
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
index_status_file("/var/lib/dpkg/status");
+1 -15
View File
@@ -2025,20 +2025,6 @@ USE_DESKTOP(long long) int pack_gzip(void)
return 0;
}
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
* -n --no-name
* gzip: do not save the original file name and time stamp.
* (The original name is always saved if the name had to be truncated.)
* gunzip: do not restore the original file name/time even if present
* (remove only the gzip suffix from the compressed file name).
* This option is the default when decompressing.
* -N --name
* gzip: always save the original file name and time stamp (this is the default)
* gunzip: restore the original file name and time stamp if present.
*/
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
#if ENABLE_GUNZIP
int gzip_main(int argc, char **argv)
@@ -2049,7 +2035,7 @@ int gzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
unsigned opt;
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789n" );
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
if (opt & 0x8) // -d
return gunzip_main(argc, argv);
@@ -12,7 +12,7 @@ ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
ssize_t size;
size = full_read(archive_handle->src_fd, buf, count);
if (size != 0 && size != (ssize_t)count) {
if (size != 0 && size != count) {
bb_error_msg_and_die("short read: %u of %u",
(unsigned)size, (unsigned)count);
}
+1 -1
View File
@@ -20,7 +20,7 @@ void data_extract_all(archive_handle_t *archive_handle)
/* Check if the file already exists */
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the entry if it exists */
/* Remove the existing entry if it exists */
if (((file_header->mode & S_IFMT) != S_IFDIR)
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
+80 -16
View File
@@ -66,6 +66,7 @@ struct group_data {
* | grep 'bd->' | sed 's/^.*bd->/bd->/' | sort | $PAGER
* and moved it (inbufBitCount) to offset 0.
*/
struct bunzip_data {
/* I/O tracking data (file handles, buffers, positions, etc.) */
unsigned inbufBitCount, inbufBits;
@@ -101,9 +102,11 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
/* If we need to get more data from the byte buffer, do so. (Loop getting
one byte at a time to enforce endianness and avoid unaligned access.) */
while ((int)(bd->inbufBitCount) < bits_wanted) {
while (bd->inbufBitCount < bits_wanted) {
/* If we need to read more data from file into byte buffer, do so */
if (bd->inbufPos == bd->inbufCount) {
/* if "no input fd" case: in_fd == -1, read fails, we jump */
bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE);
@@ -113,6 +116,7 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
}
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
if (bd->inbufBitCount >= 24) {
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
bits_wanted -= bd->inbufBitCount;
@@ -121,11 +125,13 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
}
/* Grab next 8 bits of input from buffer. */
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
bd->inbufBitCount += 8;
}
/* Calculate result */
bd->inbufBitCount -= bits_wanted;
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
@@ -133,6 +139,7 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
}
/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */
static int get_next_block(bunzip_data *bd)
{
struct group_data *hufGroup;
@@ -146,11 +153,13 @@ static int get_next_block(bunzip_data *bd)
selectors = bd->selectors;
/* Reset longjmp I/O error handling */
i = setjmp(bd->jmpbuf);
if (i) return i;
/* Read in header signature and CRC, then validate signature.
(last block signature means CRC is for whole file, return now) */
i = get_bits(bd, 24);
j = get_bits(bd, 24);
bd->headerCRC = get_bits(bd, 32);
@@ -160,15 +169,17 @@ static int get_next_block(bunzip_data *bd)
/* We can add support for blockRandomised if anybody complains. There was
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
it didn't actually work. */
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
origPtr = get_bits(bd, 24);
if ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR;
if (origPtr > dbufSize) return RETVAL_DATA_ERROR;
/* mapping table: if some byte values are never used (encoding things
like ascii text), the compression code removes the gaps to have fewer
symbols to deal with, and writes a sparse bitfield indicating which
values were present. We make a translation table to convert the symbols
back to the corresponding bytes. */
t = get_bits(bd, 16);
symTotal = 0;
for (i = 0; i < 16; i++) {
@@ -181,6 +192,7 @@ static int get_next_block(bunzip_data *bd)
}
/* How many different Huffman coding groups does this block use? */
groupCount = get_bits(bd, 3);
if (groupCount < 2 || groupCount > MAX_GROUPS)
return RETVAL_DATA_ERROR;
@@ -189,16 +201,19 @@ static int get_next_block(bunzip_data *bd)
group. Read in the group selector list, which is stored as MTF encoded
bit runs. (MTF=Move To Front, as each value is used it's moved to the
start of the list.) */
nSelectors = get_bits(bd, 15);
if (!nSelectors) return RETVAL_DATA_ERROR;
for (i = 0; i < groupCount; i++) mtfSymbol[i] = i;
for (i = 0; i < nSelectors; i++) {
/* Get next value */
for (j = 0; get_bits(bd, 1); j++)
if (j >= groupCount) return RETVAL_DATA_ERROR;
/* Decode MTF to get the next selector */
uc = mtfSymbol[j];
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
mtfSymbol[0] = selectors[i] = uc;
@@ -206,11 +221,10 @@ static int get_next_block(bunzip_data *bd)
/* Read the Huffman coding tables for each group, which code for symTotal
literal symbols, plus two run symbols (RUNA, RUNB) */
symCount = symTotal + 2;
for (j = 0; j < groupCount; j++) {
unsigned char length[MAX_SYMBOLS];
/* 8 bits is ALMOST enough for temp[], see below */
unsigned temp[MAX_HUFCODE_BITS+1];
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
int minLen, maxLen, pp;
/* Read Huffman code lengths for each symbol. They're stored in
@@ -219,6 +233,7 @@ static int get_next_block(bunzip_data *bd)
(Subtracting 1 before the loop and then adding it back at the end is
an optimization that makes the test inside the loop simpler: symbol
length 0 becomes negative, so an unsigned inequality catches it.) */
t = get_bits(bd, 5) - 1;
for (i = 0; i < symCount; i++) {
for (;;) {
@@ -228,6 +243,7 @@ static int get_next_block(bunzip_data *bd)
/* If first bit is 0, stop. Else second bit indicates whether
to increment or decrement the value. Optimization: grab 2
bits and unget the second if the first was 0. */
k = get_bits(bd, 2);
if (k < 2) {
bd->inbufBitCount++;
@@ -235,14 +251,17 @@ static int get_next_block(bunzip_data *bd)
}
/* Add one if second bit 1, else subtract 1. Avoids if/else */
t += (((k+1) & 2) - 1);
}
/* Correct for the initial -1, to get the final symbol length */
length[i] = t + 1;
}
/* Find largest and smallest lengths in this group */
minLen = maxLen = length[0];
for (i = 1; i < symCount; i++) {
if (length[i] > maxLen) maxLen = length[i];
@@ -259,6 +278,7 @@ static int get_next_block(bunzip_data *bd)
* number of bits can have. This is how the Huffman codes can vary in
* length: each code with a value>limit[length] needs another bit.
*/
hufGroup = bd->groups + j;
hufGroup->minLen = minLen;
hufGroup->maxLen = maxLen;
@@ -266,10 +286,12 @@ static int get_next_block(bunzip_data *bd)
/* Note that minLen can't be smaller than 1, so we adjust the base
and limit array pointers so we're not always wasting the first
entry. We do this again when using them (during symbol decoding).*/
base = hufGroup->base - 1;
limit = hufGroup->limit - 1;
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
pp = 0;
for (i = minLen; i <= maxLen; i++) {
temp[i] = limit[i] = 0;
@@ -279,14 +301,14 @@ static int get_next_block(bunzip_data *bd)
}
/* Count symbols coded for at each bit length */
/* NB: in pathological cases, temp[8] can end ip being 256.
* That's why uint8_t is too small for temp[]. */
for (i = 0; i < symCount; i++) temp[length[i]]++;
/* Calculate limit[] (the largest symbol-coding value at each bit
* length, which is (previous limit<<1)+symbols at this level), and
* base[] (number of symbols to ignore at each bit length, which is
* limit minus the cumulative count of symbols coded for already). */
pp = t = 0;
for (i = minLen; i < maxLen; i++) {
pp += temp[i];
@@ -297,6 +319,7 @@ static int get_next_block(bunzip_data *bd)
each level we're really only interested in the first few bits,
so here we set all the trailing to-be-ignored bits to 1 so they
don't affect the value>limit[length] comparison. */
limit[i] = (pp << (maxLen - i)) - 1;
pp <<= 1;
t += temp[i];
@@ -312,6 +335,7 @@ static int get_next_block(bunzip_data *bd)
and run length encoding, saving the result into dbuf[dbufCount++] = uc */
/* Initialize symbol occurrence counters and symbol Move To Front table */
memset(byteCount, 0, sizeof(byteCount)); /* smaller, maybe slower? */
for (i = 0; i < 256; i++) {
//byteCount[i] = 0;
@@ -323,7 +347,8 @@ static int get_next_block(bunzip_data *bd)
runPos = dbufCount = selector = 0;
for (;;) {
/* Fetch next Huffman coding group from list. */
/* fetch next Huffman coding group from list. */
symCount = GROUP_SIZE - 1;
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
hufGroup = bd->groups + selectors[selector++];
@@ -342,7 +367,8 @@ static int get_next_block(bunzip_data *bd)
dry). The following (up to got_huff_bits:) is equivalent to
j = get_bits(bd, hufGroup->maxLen);
*/
while ((int)(bd->inbufBitCount) < hufGroup->maxLen) {
while (bd->inbufBitCount < hufGroup->maxLen) {
if (bd->inbufPos == bd->inbufCount) {
j = get_bits(bd, hufGroup->maxLen);
goto got_huff_bits;
@@ -356,11 +382,13 @@ static int get_next_block(bunzip_data *bd)
got_huff_bits:
/* Figure how how many bits are in next symbol and unget extras */
i = hufGroup->minLen;
while (j > limit[i]) ++i;
bd->inbufBitCount += (hufGroup->maxLen - i);
/* Huffman decode value to get nextSym (with bounds checking) */
if (i > hufGroup->maxLen)
return RETVAL_DATA_ERROR;
j = (j >> (hufGroup->maxLen - i)) - base[i];
@@ -372,9 +400,11 @@ static int get_next_block(bunzip_data *bd)
byte, or a repeated run of the most recent literal byte. First,
check if nextSym indicates a repeated run, and if so loop collecting
how many times to repeat the last literal. */
if ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
/* If this is the start of a new run, zero out counter */
if (!runPos) {
runPos = 1;
t = 0;
@@ -387,6 +417,7 @@ static int get_next_block(bunzip_data *bd)
the basic or 0/1 method (except all bits 0, which would use no
symbols, but a run of length 0 doesn't mean anything in this
context). Thus space is saved. */
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
if (runPos < dbufSize) runPos <<= 1;
goto end_of_huffman_loop;
@@ -396,6 +427,7 @@ static int get_next_block(bunzip_data *bd)
how many times to repeat the last literal, so append that many
copies to our buffer of decoded symbols (dbuf) now. (The last
literal used is the one at the head of the mtfSymbol array.) */
if (runPos) {
runPos = 0;
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
@@ -406,6 +438,7 @@ static int get_next_block(bunzip_data *bd)
}
/* Is this the terminating symbol? */
if (nextSym > symTotal) break;
/* At this point, nextSym indicates a new literal character. Subtract
@@ -415,6 +448,7 @@ static int get_next_block(bunzip_data *bd)
first symbol in the mtf array, position 0, would have been handled
as part of a run above. Therefore 1 unused mtf position minus
2 non-literal nextSym values equals -1.) */
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
i = nextSym - 1;
uc = mtfSymbol[i];
@@ -423,6 +457,7 @@ static int get_next_block(bunzip_data *bd)
* small number of symbols, and are bound by 256 in any case, using
* memmove here would typically be bigger and slower due to function
* call overhead and other assorted setup costs. */
do {
mtfSymbol[i] = mtfSymbol[i-1];
} while (--i);
@@ -430,11 +465,13 @@ static int get_next_block(bunzip_data *bd)
uc = symToByte[uc];
/* We have our literal byte. Save it into dbuf. */
byteCount[uc]++;
dbuf[dbufCount++] = (unsigned)uc;
/* Skip group initialization if we're not done with this group. Done
* this way to avoid compiler warning. */
end_of_huffman_loop:
if (symCount--) goto continue_this_group;
}
@@ -447,6 +484,7 @@ static int get_next_block(bunzip_data *bd)
*/
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
j = 0;
for (i = 0; i < 256; i++) {
k = j + byteCount[i];
@@ -455,6 +493,7 @@ static int get_next_block(bunzip_data *bd)
}
/* Figure out what order dbuf would be in if we sorted it. */
for (i = 0; i < dbufCount; i++) {
uc = (unsigned char)(dbuf[i] & 0xff);
dbuf[byteCount[uc]] |= (i << 8);
@@ -464,10 +503,11 @@ static int get_next_block(bunzip_data *bd)
/* Decode first byte by hand to initialize "previous" byte. Note that it
doesn't get output, and if the first three characters are identical
it doesn't qualify as a run (hence writeRunCountdown=5). */
if (dbufCount) {
if ((int)origPtr >= dbufCount) return RETVAL_DATA_ERROR;
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
bd->writePos = dbuf[origPtr];
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
bd->writePos >>= 8;
bd->writeRunCountdown = 5;
}
@@ -482,6 +522,7 @@ static int get_next_block(bunzip_data *bd)
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
are ignored, data is written to out_fd and return is RETVAL_OK or error.
*/
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
{
const unsigned *dbuf;
@@ -498,15 +539,19 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* We will always have pending decoded data to write into the output
buffer unless this is the very first call (in which case we haven't
Huffman-decoded a block into the intermediate buffer yet). */
if (bd->writeCopies) {
/* Inside the loop, writeCopies means extra copies (beyond 1) */
--bd->writeCopies;
/* Loop outputting bytes */
for (;;) {
/* If the output buffer is full, snapshot state and return */
if (gotcount >= len) {
bd->writePos = pos;
bd->writeCurrent = current;
@@ -515,11 +560,13 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
}
/* Write next byte into output buffer, updating CRC */
outbuf[gotcount++] = current;
bd->writeCRC = (bd->writeCRC << 8)
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
/* Loop now if we're outputting multiple copies of this byte */
if (bd->writeCopies) {
--bd->writeCopies;
continue;
@@ -535,29 +582,35 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* After 3 consecutive copies of the same byte, the 4th
* is a repeat count. We count down from 4 instead
* of counting up because testing for non-zero is faster */
if (--bd->writeRunCountdown) {
if (current != previous)
bd->writeRunCountdown = 4;
} else {
/* We have a repeated run, this byte indicates the count */
bd->writeCopies = current;
current = previous;
bd->writeRunCountdown = 5;
/* Sometimes there are just 3 bytes (run length 0) */
if (!bd->writeCopies) goto decode_next_byte;
/* Subtract the 1 copy we'd output anyway to get extras */
--bd->writeCopies;
}
}
/* Decompression of this block completed successfully */
bd->writeCRC = ~bd->writeCRC;
bd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->writeCRC;
/* If this block had a CRC error, force file level CRC error. */
if (bd->writeCRC != bd->headerCRC) {
bd->totalCRC = bd->headerCRC + 1;
return RETVAL_LAST_BLOCK;
@@ -566,6 +619,7 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* Refill the intermediate buffer by Huffman-decoding next block of input */
/* (previous is just a convenient unused temp variable here) */
previous = get_next_block(bd);
if (previous) {
bd->writeCount = previous;
@@ -577,6 +631,7 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
goto decode_next_byte;
}
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
ignored, and data is read from file handle into temporary buffer. */
@@ -584,6 +639,7 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
should work for NOFORK applets too, we must be extremely careful to not leak
any allocations! */
int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
int len)
{
@@ -594,13 +650,16 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
};
/* Figure out how much data to allocate */
i = sizeof(bunzip_data);
if (in_fd != -1) i += IOBUF_SIZE;
/* Allocate bunzip_data. Most fields initialize to zero. */
bd = *bdp = xzalloc(i);
/* Setup input buffer */
bd->in_fd = in_fd;
if (-1 == in_fd) {
/* in this case, bd->inbuf is read-only */
@@ -610,18 +669,22 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
bd->inbuf = (unsigned char *)(bd + 1);
/* Init the CRC32 table (big endian) */
crc32_filltable(bd->crc32Table, 1);
/* Setup for I/O error handling via longjmp */
i = setjmp(bd->jmpbuf);
if (i) return i;
/* Ensure that file starts with "BZh['1'-'9']." */
i = get_bits(bd, 32);
if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
/* Fourth byte (ascii '1'-'9') indicates block size in units of 100k of
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
uncompressed data. Allocate intermediate buffer for block. */
bd->dbufSize = 100000 * (i - BZh0);
/* Cannot use xmalloc - may leak bd in NOFORK case! */
@@ -641,6 +704,7 @@ void dealloc_bunzip(bunzip_data *bd)
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
USE_DESKTOP(long long) int
unpack_bz2_stream(int src_fd, int dst_fd)
{
@@ -697,9 +761,9 @@ int main(int argc, char **argv)
char c;
if (i < 0)
fprintf(stderr, "%s\n", bunzip_errors[-i]);
else if (read(STDIN_FILENO, &c, 1))
fprintf(stderr, "Trailing garbage ignored\n");
fprintf(stderr,"%s\n", bunzip_errors[-i]);
else if (read(0, &c, 1))
fprintf(stderr,"Trailing garbage ignored\n");
return -i;
}
#endif
+3 -3
View File
@@ -329,7 +329,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
@@ -480,7 +480,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
@@ -489,7 +489,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
}
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
bad:
rc_free(rc);
return -1;
+3 -3
View File
@@ -922,7 +922,7 @@ static int inflate_block(STATE_PARAM smallint *e)
/* Two callsites, both in inflate_get_next_window */
static void calculate_gunzip_crc(STATE_PARAM_ONLY)
{
unsigned n;
int n;
for (n = 0; n < gunzip_outbuf_count; n++) {
gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
}
@@ -1003,7 +1003,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
while (1) {
int r = inflate_get_next_window(PASS_STATE_ONLY);
nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
if (nwrote != (ssize_t)gunzip_outbuf_count) {
if (nwrote != gunzip_outbuf_count) {
bb_perror_msg("write");
n = -1;
goto ret;
@@ -1064,7 +1064,7 @@ static int top_up(STATE_PARAM unsigned n)
{
int count = bytebuffer_size - bytebuffer_offset;
if (count < (int)n) {
if (count < n) {
memmove(bytebuffer, &bytebuffer[bytebuffer_offset], count);
bytebuffer_offset = 0;
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
+90 -98
View File
@@ -7,33 +7,71 @@
#include "libbb.h"
#include "unarchive.h"
typedef struct hardlinks_t {
struct hardlinks_t *next;
int inode; /* TODO: must match maj/min too! */
int mode ;
int mtime; /* These three are useful only in corner case */
int uid ; /* of hardlinks with zero size body */
int gid ;
char name[1];
typedef struct hardlinks_s {
char *name;
int inode;
struct hardlinks_s *next;
} hardlinks_t;
char get_header_cpio(archive_handle_t *archive_handle)
{
static hardlinks_t *saved_hardlinks = NULL;
static hardlinks_t *saved_hardlinks_created = NULL;
static unsigned pending_hardlinks = 0;
static int inode;
file_header_t *file_header = archive_handle->file_header;
char cpio_header[110];
char dummy[16];
int namesize;
int major, minor, nlink, mode, inode;
unsigned size, uid, gid, mtime;
char dummy[16];
int major, minor, nlink;
if (pending_hardlinks) { /* Deal with any pending hardlinks */
hardlinks_t *tmp, *oldtmp;
tmp = saved_hardlinks;
oldtmp = NULL;
file_header->link_target = file_header->name;
file_header->size = 0;
while (tmp) {
if (tmp->inode != inode) {
tmp = tmp->next;
continue;
}
file_header->name = tmp->name;
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
}
pending_hardlinks--;
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
if (oldtmp == saved_hardlinks)
saved_hardlinks = tmp;
}
file_header->name = file_header->link_target;
if (pending_hardlinks > 1) {
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
}
/* No more pending hardlinks, read next file entry */
pending_hardlinks = 0;
}
/* There can be padding before archive header */
data_align(archive_handle, 4);
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
goto create_hardlinks;
return EXIT_FAILURE;
}
archive_handle->offset += 110;
@@ -43,19 +81,17 @@ char get_header_cpio(archive_handle_t *archive_handle)
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
}
sscanf(cpio_header + 6,
"%8x" "%8x" "%8x" "%8x"
"%8x" "%8x" "%8x" /*maj,min:*/ "%16c"
/*rmaj,rmin:*/"%8x" "%8x" "%8x" /*chksum:*/ "%8c",
&inode, &mode, &uid, &gid,
&nlink, &mtime, &size, dummy,
&major, &minor, &namesize, dummy);
file_header->mode = mode;
file_header->uid = uid;
file_header->gid = gid;
file_header->mtime = mtime;
file_header->size = size;
{
unsigned long tmpsize;
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, (unsigned int*)&file_header->mode,
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
&nlink, &file_header->mtime, &tmpsize,
dummy, &major, &minor, &namesize, dummy);
file_header->size = tmpsize;
}
free(file_header->name);
file_header->name = xzalloc(namesize + 1);
/* Read in filename */
xread(archive_handle->src_fd, file_header->name, namesize);
@@ -65,9 +101,25 @@ char get_header_cpio(archive_handle_t *archive_handle)
data_align(archive_handle, 4);
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
/* Always round up. ">> 9" divides by 512 */
printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
goto create_hardlinks;
/* Always round up */
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
archive_handle->offset / 512 + 1 :
archive_handle->offset / 512
));
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
hardlinks_t *tmp = saved_hardlinks;
hardlinks_t *oldtmp = NULL;
while (tmp) {
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
}
saved_hardlinks = NULL;
pending_hardlinks = 0;
}
return EXIT_FAILURE;
}
if (S_ISLNK(file_header->mode)) {
@@ -78,33 +130,25 @@ char get_header_cpio(archive_handle_t *archive_handle)
} else {
file_header->link_target = NULL;
}
// TODO: data_extract_all can't deal with hardlinks to non-files...
// (should be !S_ISDIR instead of S_ISREG here)
if (nlink > 1 && S_ISREG(file_header->mode)) {
hardlinks_t *new = xmalloc(sizeof(*new) + namesize);
new->inode = inode;
new->mode = mode ;
new->mtime = mtime;
new->uid = uid ;
new->gid = gid ;
strcpy(new->name, file_header->name);
/* Put file on a linked list for later */
if (size == 0) {
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
if (file_header->size == 0) { /* Put file on a linked list for later */
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
new->next = saved_hardlinks;
new->inode = inode;
/* name current allocated, freed later */
new->name = file_header->name;
file_header->name = NULL;
saved_hardlinks = new;
return EXIT_SUCCESS; /* Skip this one */
/* TODO: this breaks cpio -t (it does not show hardlinks) */
}
new->next = saved_hardlinks_created;
saved_hardlinks_created = new;
/* Found the file with data in */
pending_hardlinks = nlink;
}
file_header->device = makedev(major, minor);
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(file_header);
archive_handle->action_header(archive_handle->file_header);
} else {
data_skip(archive_handle);
}
@@ -112,58 +156,6 @@ char get_header_cpio(archive_handle_t *archive_handle)
archive_handle->offset += file_header->size;
free(file_header->link_target);
free(file_header->name);
file_header->link_target = NULL;
file_header->name = NULL;
return EXIT_SUCCESS;
create_hardlinks:
free(file_header->link_target);
free(file_header->name);
while (saved_hardlinks) {
hardlinks_t *cur;
hardlinks_t *make_me = saved_hardlinks;
saved_hardlinks = make_me->next;
memset(file_header, 0, sizeof(*file_header));
file_header->name = make_me->name;
file_header->mode = make_me->mode;
/*file_header->size = 0;*/
/* Try to find a file we are hardlinked to */
cur = saved_hardlinks_created;
while (cur) {
/* TODO: must match maj/min too! */
if (cur->inode == make_me->inode) {
file_header->link_target = cur->name;
/* link_target != NULL, size = 0: "I am a hardlink" */
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
archive_handle->action_data(archive_handle);
free(make_me);
goto next_link;
}
cur = cur->next;
}
/* Oops... no file with such inode was created... do it now
* (happens when hardlinked files are empty (zero length)) */
file_header->mtime = make_me->mtime;
file_header->uid = make_me->uid ;
file_header->gid = make_me->gid ;
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
archive_handle->action_data(archive_handle);
/* Move to the list of created hardlinked files */
make_me->next = saved_hardlinks_created;
saved_hardlinks_created = make_me;
next_link: ;
}
while (saved_hardlinks_created) {
hardlinks_t *p = saved_hardlinks_created;
saved_hardlinks_created = p->next;
free(p);
}
return EXIT_FAILURE; /* "No more files to process" */
}
+4 -6
View File
@@ -22,13 +22,11 @@ int open_transformer(int src_fd,
#if BB_MMU
pid = fork();
if (pid == -1)
bb_perror_msg_and_die("can't fork");
#else
pid = vfork();
if (pid == -1)
bb_perror_msg_and_die("can't vfork");
#endif
if (pid == -1)
bb_perror_msg_and_die("fork failed");
if (pid == 0) {
/* child process */
@@ -40,7 +38,7 @@ int open_transformer(int src_fd,
close(fd_pipe.wr); /* Send EOF */
close(src_fd);
}
exit(EXIT_SUCCESS);
exit(0);
#else
{
char *argv[4];
@@ -51,7 +49,7 @@ int open_transformer(int src_fd,
argv[2] = (char*)"-";
argv[3] = NULL;
BB_EXECVP(transform_prog, argv);
bb_perror_msg_and_die("can't exec %s", transform_prog);
bb_perror_msg_and_die("exec failed");
}
#endif
/* notreached */
+4 -2
View File
@@ -9,9 +9,11 @@
void seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
if (errno == ESPIPE)
#if ENABLE_FEATURE_UNARCHIVE_TAPE
if (errno == ESPIPE) {
seek_by_read(archive_handle, amount);
else
} else
#endif
bb_perror_msg_and_die("seek failure");
}
}
+8 -8
View File
@@ -13,14 +13,14 @@
#define RPM_HEADER_MAGIC "\216\255\350"
struct rpm_lead {
unsigned char magic[4];
uint8_t major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
unsigned char magic[4];
uint8_t major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
};
struct rpm_header {
+119 -117
View File
@@ -24,6 +24,7 @@
*/
#include <fnmatch.h>
#include <getopt.h>
#include "libbb.h"
#include "unarchive.h"
@@ -84,26 +85,26 @@ struct TarHeader { /* byte offset */
*/
typedef struct HardLinkInfo HardLinkInfo;
struct HardLinkInfo {
HardLinkInfo *next; /* Next entry in list */
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
short linkCount; /* (Hard) Link Count */
char name[1]; /* Start of filename (must be last) */
HardLinkInfo *next; /* Next entry in list */
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
short linkCount; /* (Hard) Link Count */
char name[1]; /* Start of filename (must be last) */
};
/* Some info to be carried along when creating a new tarball */
typedef struct TarBallInfo TarBallInfo;
struct TarBallInfo {
int tarFd; /* Open-for-write file descriptor
* for the tarball */
struct stat statBuf; /* Stat info for the tarball, letting
* us know the inode and device that the
* tarball lives, so we can avoid trying
* to include the tarball into itself */
int verboseFlag; /* Whether to print extra stuff or not */
const llist_t *excludeList; /* List of files to not include */
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
int tarFd; /* Open-for-write file descriptor
for the tarball */
struct stat statBuf; /* Stat info for the tarball, letting
us know the inode and device that the
tarball lives, so we can avoid trying
to include the tarball into itself */
int verboseFlag; /* Whether to print extra stuff or not */
const llist_t *excludeList; /* List of files to not include */
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
};
/* A nice enum with all the possible tar file content types */
@@ -503,90 +504,11 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
return TRUE;
}
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
#if !(ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2)
#define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd)
#endif
/* Don't inline: vfork scares gcc and pessimizes code */
static void NOINLINE vfork_compressor(int tar_fd, int gzip)
{
pid_t gzipPid;
#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
#elif ENABLE_FEATURE_TAR_GZIP
const char *zip_exec = "gzip";
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
const char *zip_exec = "bzip2";
#endif
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
#define WAIT_FOR_CHILD 0
volatile int vfork_exec_errno = 0;
struct fd_pair gzipDataPipe;
#if WAIT_FOR_CHILD
struct fd_pair gzipStatusPipe;
xpiped_pair(gzipStatusPipe);
#endif
xpiped_pair(gzipDataPipe);
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
#if defined(__GNUC__) && __GNUC__
/* Avoid vfork clobbering */
(void) &zip_exec;
#endif
gzipPid = vfork();
if (gzipPid < 0)
bb_perror_msg_and_die("can't vfork");
if (gzipPid == 0) {
/* child */
/* NB: close _first_, then move fds! */
close(gzipDataPipe.wr);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.rd);
/* gzipStatusPipe.wr will close only on exec -
* parent waits for this close to happen */
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
#endif
xmove_fd(gzipDataPipe.rd, 0);
xmove_fd(tar_fd, 1);
/* exec gzip/bzip2 program/applet */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
_exit(EXIT_FAILURE);
}
/* parent */
xmove_fd(gzipDataPipe.wr, tar_fd);
close(gzipDataPipe.rd);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.wr);
while (1) {
char buf;
int n;
/* Wait until child execs (or fails to) */
n = full_read(gzipStatusPipe.rd, &buf, 1);
if (n < 0 /* && errno == EAGAIN */)
continue; /* try it again */
}
close(gzipStatusPipe.rd);
#endif
if (vfork_exec_errno) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("cannot exec %s", zip_exec);
}
}
#endif /* ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 */
/* gcc 4.2.1 inlines it, making code bigger */
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
const llist_t *exclude, int gzip)
static int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip)
{
pid_t gzipPid = 0;
int errorFlag = FALSE;
struct TarBallInfo tbInfo;
@@ -602,8 +524,80 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
bb_perror_msg_and_die("cannot stat tar file");
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
if (gzip)
vfork_compressor(tbInfo.tarFd, gzip);
if (gzip) {
#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
#elif ENABLE_FEATURE_TAR_GZIP
const char *zip_exec = "gzip";
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
const char *zip_exec = "bzip2";
#endif
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
#define WAIT_FOR_CHILD 0
volatile int vfork_exec_errno = 0;
#if WAIT_FOR_CHILD
struct fd_pair gzipStatusPipe;
#endif
struct fd_pair gzipDataPipe;
xpiped_pair(gzipDataPipe);
#if WAIT_FOR_CHILD
xpiped_pair(gzipStatusPipe);
#endif
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
#if defined(__GNUC__) && __GNUC__
/* Avoid vfork clobbering */
(void) &include;
(void) &errorFlag;
(void) &zip_exec;
#endif
gzipPid = vfork();
if (gzipPid < 0)
bb_perror_msg_and_die("vfork gzip");
if (gzipPid == 0) {
/* child */
/* NB: close _first_, then move fds! */
close(gzipDataPipe.wr);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.rd);
/* gzipStatusPipe.wr will close only on exec -
* parent waits for this close to happen */
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
#endif
xmove_fd(gzipDataPipe.rd, 0);
xmove_fd(tbInfo.tarFd, 1);
/* exec gzip/bzip2 program/applet */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
_exit(1);
}
/* parent */
xmove_fd(gzipDataPipe.wr, tbInfo.tarFd);
close(gzipDataPipe.rd);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.wr);
while (1) {
char buf;
int n;
/* Wait until child execs (or fails to) */
n = full_read(gzipStatusPipe.rd, &buf, 1);
if (n < 0 /* && errno == EAGAIN */)
continue; /* try it again */
}
close(gzipStatusPipe.rd);
#endif
if (vfork_exec_errno) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("cannot exec %s", zip_exec);
}
}
#endif
tbInfo.excludeList = exclude;
@@ -637,34 +631,37 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
if (errorFlag)
bb_error_msg("error exit delayed from previous errors");
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
if (gzip) {
if (gzipPid) {
int status;
if (safe_waitpid(-1, &status, 0) == -1)
if (safe_waitpid(gzipPid, &status, 0) == -1)
bb_perror_msg("waitpid");
else if (!WIFEXITED(status) || WEXITSTATUS(status))
/* gzip was killed or has exited with nonzero! */
errorFlag = TRUE;
}
#endif
return errorFlag;
}
#else
int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
const llist_t *exclude, int gzip);
int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip);
#endif /* FEATURE_TAR_CREATE */
#if ENABLE_FEATURE_TAR_FROM
static llist_t *append_file_list_to_list(llist_t *list)
{
FILE *src_stream;
llist_t *cur = list;
llist_t *tmp;
char *line;
llist_t *newlist = NULL;
while (list) {
src_stream = xfopen(llist_pop(&list), "r");
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
while (cur) {
src_stream = xfopen(cur->data, "r");
tmp = cur;
cur = cur->link;
free(tmp);
while ((line = xmalloc_getline(src_stream)) != NULL) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(line, '/');
if (cp > line)
@@ -800,7 +797,7 @@ static const char tar_longopts[] ALIGN1 =
#endif
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tar_main(int argc ATTRIBUTE_UNUSED, char **argv)
int tar_main(int argc, char **argv)
{
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
archive_handle_t *tar_handle;
@@ -850,7 +847,6 @@ int tar_main(int argc ATTRIBUTE_UNUSED, char **argv)
, &verboseFlag // combined count for -t and -v
, &verboseFlag // combined count for -t and -v
);
argv += optind;
if (verboseFlag) tar_handle->action_header = header_verbose_list;
if (verboseFlag == 1) tar_handle->action_header = header_list;
@@ -896,15 +892,21 @@ int tar_main(int argc ATTRIBUTE_UNUSED, char **argv)
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
#endif
/* Check if we are reading from stdin */
if (argv[optind] && *argv[optind] == '-') {
/* Default is to read from stdin, so just skip to next arg */
optind++;
}
/* Setup an array of filenames to work with */
/* TODO: This is the same as in ar, separate function ? */
while (*argv) {
while (optind < argc) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(*argv, '/');
if (cp > *argv)
char *cp = last_char_is(argv[optind], '/');
if (cp > argv[optind])
*cp = '\0';
llist_add_to_end(&tar_handle->accept, *argv);
argv++;
llist_add_to_end(&tar_handle->accept, argv[optind]);
optind++;
}
if (tar_handle->accept || tar_handle->reject)
+10 -2
View File
@@ -9,17 +9,25 @@
#include "libbb.h"
/* From <linux/vt.h> */
enum {
VT_ACTIVATE = 0x5606, /* make vt active */
VT_WAITACTIVE = 0x5607 /* wait for vt active */
};
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chvt_main(int argc, char **argv)
{
int num;
int fd, num;
if (argc != 2) {
bb_show_usage();
}
fd = get_console_fd();
num = xatou_range(argv[1], 1, 63);
/* double cast suppresses "cast to ptr from int of different size" */
console_make_active(get_console_fd(), num);
xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num);
xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num);
return EXIT_SUCCESS;
}
+8 -11
View File
@@ -7,7 +7,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
/* no options, no getopt */
#include "libbb.h"
@@ -24,17 +23,18 @@ struct kbentry {
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dumpkmap_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
int dumpkmap_main(int argc, char **argv)
{
struct kbentry ke;
int i, j, fd;
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
char flags[MAX_NR_KEYMAPS];
/* bb_warn_ignoring_args(argc>=2);*/
if (argc >= 2 && argv[1][0] == '-')
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
write(STDOUT_FILENO, "bkeymap", 7);
write(1, "bkeymap", 7);
/* Here we want to set everything to 0 except for indexes:
* [0-2] [4-6] [8-10] [12] */
@@ -43,7 +43,7 @@ int dumpkmap_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
flags[3] = flags[7] = flags[11] = 0;
/* dump flags */
write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS);
write(1, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
@@ -56,14 +56,11 @@ int dumpkmap_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
(char *)&ke.kb_table,
&ke.kb_value)
) {
write(STDOUT_FILENO, (void*)&ke.kb_value, 2);
write(1, (void*)&ke.kb_value, 2);
}
}
}
}
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd);
RELEASE_CONFIG_BUFFER(flags);
}
close(fd);
return EXIT_SUCCESS;
}
+49 -34
View File
@@ -1,8 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* Mini kbd_mode implementation for busybox
* Mini loadkmap implementation for busybox
*
* Copyright (C) 2007 Loic Grenie <loic.grenie@gmail.com>
* Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
* written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
* console-utils v0.2.3, licensed under GNU GPLv2
*
@@ -10,44 +10,59 @@
*
*/
#include <getopt.h>
#include "libbb.h"
#include <linux/kd.h>
int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int kbd_mode_main(int ATTRIBUTE_UNUSED argc, char **argv)
int kbd_mode_main(int argc, char **argv)
{
int fd;
unsigned opt;
enum {
SCANCODE = (1<<0),
ASCII = (1<<1),
MEDIUMRAW= (1<<2),
UNICODE = (1<<3)
};
static const char KD_xxx[] ALIGN1 = "saku";
opt = getopt32(argv, KD_xxx);
fd = get_console_fd();
/* if (fd < 0)
return EXIT_FAILURE;
*/
if (!opt) { /* print current setting */
const char *mode = "unknown";
int m;
static const char opts[] = "saku";
ioctl(fd, KDGKBMODE, &m);
if (m == K_RAW)
mode = "raw (scancode)";
else if (m == K_XLATE)
mode = "default (ASCII)";
else if (m == K_MEDIUMRAW)
mode = "mediumraw (keycode)";
else if (m == K_UNICODE)
mode = "Unicode (UTF-8)";
printf("The keyboard is in %s mode\n", mode);
} else {
opt = opt & UNICODE ? 3 : opt >> 1;
/* double cast prevents warnings about widening conversion */
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
const char *opt = argv[1];
const char *p;
int fd;
fd = get_console_fd();
if (fd < 0) /* get_console_fd() already complained */
return EXIT_FAILURE;
if (opt == NULL) {
/* No arg */
const char *msg = "unknown";
int mode;
ioctl(fd, KDGKBMODE, &mode);
switch(mode) {
case K_RAW:
msg = "raw (scancode)";
break;
case K_XLATE:
msg = "default (ASCII)";
break;
case K_MEDIUMRAW:
msg = "mediumraw (keycode)";
break;
case K_UNICODE:
msg = "Unicode (UTF-8)";
break;
}
printf("The keyboard is in %s mode\n", msg);
}
else if (argc > 2 /* more than 1 arg */
|| *opt != '-' /* not an option */
|| (p = strchr(opts, opt[1])) == NULL /* not an option we expect */
|| opt[2] != '\0' /* more than one option char */
) {
bb_show_usage();
/* return EXIT_FAILURE; - not reached */
}
else {
#if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
#error kbd_mode must be changed
#endif
/* The options are in the order of the various K_xxx */
ioctl(fd, KDSKBMODE, p - opts);
}
if (ENABLE_FEATURE_CLEAN_UP)
+12 -13
View File
@@ -26,26 +26,28 @@ struct kbentry {
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int loadkmap_main(int ATTRIBUTE_UNUSED argc, char **argv ATTRIBUTE_UNUSED)
int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
{
struct kbentry ke;
int i, j, fd;
uint16_t ibuff[NR_KEYS];
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
char flags[MAX_NR_KEYMAPS];
char buff[7];
/* bb_warn_ignoring_args(argc>=2);*/
if (argc != 1)
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
xread(STDIN_FILENO, flags, 7);
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("not a valid binary keymap");
xread(0, buff, 7);
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("this is not a valid binary keymap");
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
xread(0, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
@@ -55,9 +57,6 @@ int loadkmap_main(int ATTRIBUTE_UNUSED argc, char **argv ATTRIBUTE_UNUSED)
}
}
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd);
RELEASE_CONFIG_BUFFER(flags);
}
return EXIT_SUCCESS;
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
return 0;
}
+16 -161
View File
@@ -8,174 +8,29 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <linux/vt.h>
/* getopt not needed */
#include "libbb.h"
/* "Standard" openvt's man page (we do not support all of this):
openvt [-c NUM] [-fsulv] [--] [command [args]]
Find the first available VT, and run command on it. Stdio is directed
to that VT. If no command is specified then $SHELL is used.
-c NUM
Use the given VT number, not the first free one.
-f
Force opening a VT: don't try to check if VT is already in use.
-s
Switch to the new VT when starting the command.
The VT of the new command will be made the new current VT.
-u
Figure out the owner of the current VT, and run login as that user.
Suitable to be called by init. Shouldn't be used with -c or -l.
-l
Make the command a login shell: a "-" is prepended to the argv[0]
when command is executed.
-v
Verbose.
-w
Wait for command to complete. If -w and -s are used together,
switch back to the controlling terminal when the command completes.
bbox:
-u: not implemented
-f: always in effect
-l: not implemented, ignored
-v: ignored
-ws: does NOT switch back
*/
/* Helper: does this fd understand VT_xxx? */
static int not_vt_fd(int fd)
{
struct vt_stat vtstat;
return ioctl(fd, VT_GETSTATE, &vtstat); /* !0: error, it's not VT fd */
}
/* Helper: get a fd suitable for VT_xxx */
static int get_vt_fd(void)
{
int fd;
/* Do we, by chance, already have it? */
for (fd = 0; fd < 3; fd++)
if (!not_vt_fd(fd))
return fd;
/* _only_ O_NONBLOCK: ask for neither read nor write perms */
/*FIXME: use? device_open(DEV_CONSOLE,0); */
fd = open(DEV_CONSOLE, O_NONBLOCK);
if (fd >= 0 && !not_vt_fd(fd))
return fd;
bb_error_msg_and_die("can't find open VT");
}
static int find_free_vtno(void)
{
int vtno;
int fd = get_vt_fd();
errno = 0;
/*xfunc_error_retval = 3; - do we need compat? */
if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0)
bb_perror_msg_and_die("can't find open VT");
// Not really needed, grep for DAEMON_ONLY_SANITIZE
// if (fd > 2)
// close(fd);
return vtno;
}
/* vfork scares gcc, it generates bigger code.
* Keep it away from main program.
* TODO: move to libbb; or adapt existing libbb's spawn().
*/
static NOINLINE void vfork_child(char **argv)
{
if (vfork() == 0) {
/* CHILD */
/* Try to make this VT our controlling tty */
setsid(); /* lose old ctty */
ioctl(STDIN_FILENO, TIOCSCTTY, 0 /* 0: don't forcibly steal */);
//bb_error_msg("our sid %d", getsid(0));
//bb_error_msg("our pgrp %d", getpgrp());
//bb_error_msg("VT's sid %d", tcgetsid(0));
//bb_error_msg("VT's pgrp %d", tcgetpgrp(0));
BB_EXECVP(argv[0], argv);
bb_perror_msg_and_die("exec %s", argv[0]);
}
}
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
int openvt_main(int argc, char **argv)
{
char vtname[sizeof(VC_FORMAT) + sizeof(int)*3];
struct vt_stat vtstat;
char *str_c;
int vtno;
int flags;
enum {
OPT_c = (1 << 0),
OPT_w = (1 << 1),
OPT_s = (1 << 2),
OPT_l = (1 << 3),
OPT_f = (1 << 4),
OPT_v = (1 << 5),
};
char vtname[sizeof(VC_FORMAT) + 2];
/* "+" - stop on first non-option */
flags = getopt32(argv, "+c:wslfv", &str_c);
argv += optind;
if (argc < 3)
bb_show_usage();
if (flags & OPT_c) {
/* Check for illegal vt number: < 1 or > 63 */
vtno = xatou_range(str_c, 1, 63);
} else {
vtno = find_free_vtno();
}
/* check for illegal vt number: < 1 or > 63 */
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
/* Grab new VT */
sprintf(vtname, VC_FORMAT, vtno);
/* (Try to) clean up stray open fds above fd 2 */
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL);
close(STDIN_FILENO);
/*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
/* grab new one */
close(0);
xopen(vtname, O_RDWR);
xioctl(STDIN_FILENO, VT_GETSTATE, &vtstat);
xdup2(0, STDOUT_FILENO);
xdup2(0, STDERR_FILENO);
if (flags & OPT_s) {
console_make_active(STDIN_FILENO, vtno);
}
if (!argv[0]) {
argv--;
argv[0] = getenv("SHELL");
if (!argv[0])
argv[0] = (char *) DEFAULT_SHELL;
/*argv[1] = NULL; - already is */
}
xdup2(STDIN_FILENO, STDOUT_FILENO);
xdup2(STDIN_FILENO, STDERR_FILENO);
#ifdef BLOAT
{
/* Handle -l (login shell) option */
const char *prog = argv[0];
if (flags & OPT_l)
argv[0] = xasprintf("-%s", argv[0]);
}
#endif
vfork_child(argv);
if (flags & OPT_w) {
/* We have only one child, wait for it */
safe_waitpid(-1, NULL, 0); /* loops on EINTR */
if (flags & OPT_s) {
console_make_active(STDIN_FILENO, vtstat.v_active);
// Compat: even with -c N (try to) disallocate:
// # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5
// openvt: could not deallocate console 9
xioctl(STDIN_FILENO, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno);
}
}
return EXIT_SUCCESS;
argv += 2;
BB_EXECVP(argv[0], argv);
_exit(1);
}
+1 -1
View File
@@ -26,7 +26,7 @@ int reset_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
/* no options, no getopt */
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
if (isatty(0) && isatty(1)) {
/* See 'man 4 console_codes' for details:
* "ESC c" -- Reset
* "ESC ( K" -- Select user mapping
+1 -1
View File
@@ -17,7 +17,7 @@ static void
onintr(int sig ATTRIBUTE_UNUSED)
{
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
exit(EXIT_FAILURE);
exit(1);
}
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+20 -13
View File
@@ -3,34 +3,41 @@
* setconsole.c - redirect system console output
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
* Copyright (C) 2008 Bernhard Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <getopt.h>
#include "libbb.h"
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
#endif
#define OPT_SETCONS_RESET 1
int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setconsole_main(int ATTRIBUTE_UNUSED argc, char **argv)
int setconsole_main(int argc, char **argv)
{
unsigned long flags;
const char *device = CURRENT_TTY;
bool reset;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
applet_long_options = setconsole_longopts;
#endif
/* at most one non-option argument */
opt_complementary = "?1";
reset = getopt32(argv, "r");
flags = getopt32(argv, "r");
argv += 1 + reset;
if (*argv) {
device = *argv;
if (argc - optind > 1)
bb_show_usage();
if (argc - optind == 1) {
if (flags & OPT_SETCONS_RESET)
bb_show_usage();
device = argv[optind];
} else {
if (reset)
if (flags & OPT_SETCONS_RESET)
device = DEV_CONSOLE;
}
+5 -4
View File
@@ -17,14 +17,15 @@ int setlogcons_main(int argc ATTRIBUTE_UNUSED, char **argv)
struct {
char fn;
char subarg;
} arg = { 11, /* redirect kernel messages */
0 /* to specified console (current as default) */
};
} arg;
arg.fn = 11; /* redirect kernel messages */
arg.subarg = 0; /* to specified console (current as default) */
if (argv[1])
arg.subarg = xatou_range(argv[1], 0, 63);
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
return EXIT_SUCCESS;
return 0;
}
+2 -6
View File
@@ -30,7 +30,6 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_HUSH) += echo.o # used by hush
lib-$(CONFIG_ENV) += env.o
lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_EXPAND) += expand.o
@@ -54,7 +53,6 @@ lib-$(CONFIG_NOHUP) += nohup.o
lib-$(CONFIG_OD) += od.o
lib-$(CONFIG_PRINTENV) += printenv.o
lib-$(CONFIG_PRINTF) += printf.o
lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o
lib-$(CONFIG_PWD) += pwd.o
lib-$(CONFIG_READLINK) += readlink.o
lib-$(CONFIG_REALPATH) += realpath.o
@@ -72,10 +70,8 @@ lib-$(CONFIG_SYNC) += sync.o
lib-$(CONFIG_TAC) += tac.o
lib-$(CONFIG_TAIL) += tail.o
lib-$(CONFIG_TEE) += tee.o
lib-$(CONFIG_TEST) += test.o test_ptr_hack.o
lib-$(CONFIG_ASH) += test.o test_ptr_hack.o # used by ash
lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o # used by hush
lib-$(CONFIG_MSH) += test.o test_ptr_hack.o # used by msh
lib-$(CONFIG_TEST) += test.o
lib-$(CONFIG_ASH) += test.o # used by ash
lib-$(CONFIG_TOUCH) += touch.o
lib-$(CONFIG_TR) += tr.o
lib-$(CONFIG_TRUE) += true.o
+5 -6
View File
@@ -37,16 +37,15 @@ int basename_main(int argc, char **argv)
/* It should strip slash: /abc/def/ -> def */
s = bb_get_last_path_component_strip(*++argv);
m = strlen(s);
if (*++argv) {
n = strlen(*argv);
m = strlen(s);
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
m -= n;
/*s[m] = '\0'; - redundant */
s[m-n] = '\0';
}
}
/* puts(s) will do, but we can do without stdio this way: */
s[m++] = '\n';
return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
puts(s);
return fflush(stdout);
}
+1 -1
View File
@@ -179,7 +179,7 @@ int cal_main(int argc, char **argv)
}
}
fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(0);
}
/*
+1
View File
@@ -61,6 +61,7 @@ static int fileAction(const char *fileName, struct stat *statbuf,
return FALSE;
}
int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chown_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int retval = EXIT_SUCCESS;
+1 -1
View File
@@ -34,7 +34,7 @@ int cksum_main(int argc ATTRIBUTE_UNUSED, char **argv)
#define read_buf bb_common_bufsiz1
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
cp = (uint8_t *) read_buf;
cp = read_buf;
length += bytes_read;
do {
crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *cp++];
+11 -13
View File
@@ -37,27 +37,25 @@ int cp_main(int argc, char **argv)
OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)),
OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1),
OPT_H = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2),
OPT_L = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3),
};
// Need at least two arguments
// Soft- and hardlinking doesn't mix
// Soft- and hardlinking don't mix
// -P and -d are the same (-P is POSIX, -d is GNU)
// -r and -R are the same
// -R (and therefore -r) turns on -d (coreutils does this)
// -R (and therefore -r) switches on -d (coreutils does this)
// -a = -pdR
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR:HL";
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPH");
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR";
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL");
argc -= optind;
argv += optind;
flags ^= FILEUTILS_DEREFERENCE; /* the sense of this flag was reversed */
/* coreutils 6.9 compat:
* by default, "cp" derefs symlinks (creates regular dest files),
* but "cp -R" does not. We switch off deref if -r or -R (see above).
* However, "cp -RL" must still deref symlinks: */
if (flags & FILEUTILS_DEREF_SOFTLINK) /* -L */
flags |= FILEUTILS_DEREFERENCE;
/* The behavior of -H is *almost* like -L, but not quite, so let's
* just ignore it too for fun. TODO.
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
/* Default behavior of cp is to dereference, so we don't have to do
* anything special when we are given -L.
* The behavior of -H is *almost* like -L, but not quite, so let's
* just ignore it too for fun.
if (flags & OPT_L) ...
if (flags & OPT_H) ... // deref command-line params only
*/
+5 -5
View File
@@ -51,7 +51,7 @@ static void cut_file(FILE *file, char delim)
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
while ((line = xmalloc_fgetline(file)) != NULL) {
while ((line = xmalloc_getline(file)) != NULL) {
/* set up a list so we can keep track of what's been printed */
char * printed = xzalloc(strlen(line) * sizeof(char));
@@ -64,7 +64,7 @@ static void cut_file(FILE *file, char delim)
/* print the chars specified in each cut list */
for (; cl_pos < nlists; cl_pos++) {
spos = cut_lists[cl_pos].startpos;
while (spos < (int)strlen(line)) {
while (spos < strlen(line)) {
if (!printed[spos]) {
printed[spos] = 'X';
putchar(line[spos]);
@@ -80,12 +80,12 @@ static void cut_file(FILE *file, char delim)
/* get out if we have no more lists to process or if the lines
* are lower than what we're interested in */
if (((int)linenum < spos) || (cl_pos >= nlists))
if (linenum < spos || cl_pos >= nlists)
goto next_line;
/* if the line we're looking for is lower than the one we were
* passed, it means we displayed it already, so move on */
while (spos < (int)linenum) {
while (spos < linenum) {
spos++;
/* go to the next list if we're at the end of this one */
if (spos > cut_lists[cl_pos].endpos
@@ -97,7 +97,7 @@ static void cut_file(FILE *file, char delim)
spos = cut_lists[cl_pos].startpos;
/* get out if the current line is lower than the one
* we just became interested in */
if ((int)linenum < spos)
if (linenum < spos)
goto next_line;
}
}
+109 -111
View File
@@ -39,135 +39,131 @@ static void maybe_set_utc(int opt)
}
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int date_main(int argc ATTRIBUTE_UNUSED, char **argv)
int date_main(int argc, char **argv)
{
struct tm tm_time;
time_t tm;
struct tm tm_time;
unsigned opt;
int ifmt = -1;
char *date_str;
char *fmt_dt2str;
char *fmt_str2dt;
char *filename;
char *isofmt_arg = NULL;
char *date_str = NULL;
char *date_fmt = NULL;
char *filename = NULL;
char *isofmt_arg;
char *hintfmt_arg;
opt_complementary = "d--s:s--d"
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
opt = getopt32(argv, "Rs:ud:r:"
USE_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
argv += optind;
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
maybe_set_utc(opt);
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) {
ifmt = 0; /* default is date */
if (isofmt_arg) {
static const char isoformats[] ALIGN1 =
"date\0""hours\0""minutes\0""seconds\0";
ifmt = index_in_strings(isoformats, isofmt_arg);
if (ifmt < 0)
bb_show_usage();
if (!isofmt_arg) {
ifmt = 0; /* default is date */
} else {
static const char *const isoformats[] = {
"date", "hours", "minutes", "seconds"
};
for (ifmt = 0; ifmt < 4; ifmt++)
if (!strcmp(isofmt_arg, isoformats[ifmt]))
goto found;
/* parse error */
bb_show_usage();
found: ;
}
}
fmt_dt2str = NULL;
if (argv[0] && argv[0][0] == '+') {
fmt_dt2str = &argv[0][1]; /* Skip over the '+' */
argv++;
}
if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) {
/* XXX, date_fmt == NULL from this always */
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+')) {
date_fmt = &argv[optind][1]; /* Skip over the '+' */
} else if (date_str == NULL) {
opt |= DATE_OPT_SET;
date_str = argv[0]; /* can be NULL */
if (date_str)
argv++;
date_str = argv[optind];
}
if (*argv)
bb_show_usage();
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
if (opt & DATE_OPT_REFERENCE) {
if (filename) {
struct stat statbuf;
xstat(filename, &statbuf);
tm = statbuf.st_mtime;
} else
time(&tm);
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
/* If date string is given, update tm_time, and maybe set date */
/* Zero out fields - take her back to midnight! */
if (date_str != NULL) {
/* Zero out fields - take her back to midnight! */
tm_time.tm_sec = 0;
tm_time.tm_min = 0;
tm_time.tm_hour = 0;
/* Process any date input to UNIX time since 1 Jan 1970 */
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_HINT)) {
if (strptime(date_str, fmt_str2dt, &tm_time) == NULL)
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
} else {
char end = '\0';
const char *last_colon = strrchr(date_str, ':');
strptime(date_str, hintfmt_arg, &tm_time);
} else if (strchr(date_str, ':') != NULL) {
/* Parse input and assign appropriately to tm_time */
if (last_colon != NULL) {
/* Parse input and assign appropriately to tm_time */
if (sscanf(date_str, "%u:%u%c",
&tm_time.tm_hour,
&tm_time.tm_min,
&end) >= 2) {
/* no adjustments needed */
} else if (sscanf(date_str, "%u.%u-%u:%u%c",
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min,
&end) >= 4) {
/* Adjust dates from 1-12 to 0-11 */
tm_time.tm_mon -= 1;
} else if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &tm_time.tm_year,
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min,
&end) >= 5) {
tm_time.tm_year -= 1900; /* Adjust years */
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else if (sscanf(date_str, "%u-%u-%u %u:%u%c", &tm_time.tm_year,
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min,
&end) >= 5) {
tm_time.tm_year -= 1900; /* Adjust years */
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
//TODO: coreutils 6.9 also accepts "YYYY-MM-DD HH" (no minutes)
} else {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
if (end == ':') {
if (sscanf(last_colon + 1, "%u%c", &tm_time.tm_sec, &end) == 1)
end = '\0';
/* else end != NUL and we error out */
}
} else {
if (sscanf(date_str, "%2u%2u%2u%2u%u%c", &tm_time.tm_mon,
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
&tm_time.tm_year, &end) < 4)
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
/* correct for century - minor Y2K problem here? */
if (tm_time.tm_year >= 1900) {
tm_time.tm_year -= 1900;
}
/* adjust date */
if (sscanf(date_str, "%d:%d:%d", &tm_time.tm_hour, &tm_time.tm_min,
&tm_time.tm_sec) == 3) {
/* no adjustments needed */
} else if (sscanf(date_str, "%d:%d", &tm_time.tm_hour,
&tm_time.tm_min) == 2) {
/* no adjustments needed */
} else if (sscanf(date_str, "%d.%d-%d:%d:%d", &tm_time.tm_mon,
&tm_time.tm_mday, &tm_time.tm_hour,
&tm_time.tm_min, &tm_time.tm_sec) == 5) {
/* Adjust dates from 1-12 to 0-11 */
tm_time.tm_mon -= 1;
if (end == '.') {
if (sscanf(strchr(date_str, '.') + 1, "%u%c",
&tm_time.tm_sec, &end) == 1)
end = '\0';
/* else end != NUL and we error out */
}
}
if (end != '\0') {
} else if (sscanf(date_str, "%d.%d-%d:%d", &tm_time.tm_mon,
&tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min) == 4) {
/* Adjust dates from 1-12 to 0-11 */
tm_time.tm_mon -= 1;
} else if (sscanf(date_str, "%d.%d.%d-%d:%d:%d", &tm_time.tm_year,
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min,
&tm_time.tm_sec) == 6) {
tm_time.tm_year -= 1900; /* Adjust years */
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else if (sscanf(date_str, "%d.%d.%d-%d:%d", &tm_time.tm_year,
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min) == 5) {
tm_time.tm_year -= 1900; /* Adjust years */
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
} else {
int nr;
char *cp;
nr = sscanf(date_str, "%2d%2d%2d%2d%d", &tm_time.tm_mon,
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
&tm_time.tm_year);
if (nr < 4 || nr > 5) {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
cp = strchr(date_str, '.');
if (cp) {
nr = sscanf(cp + 1, "%2d", &tm_time.tm_sec);
if (nr != 1) {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
}
/* correct for century - minor Y2K problem here? */
if (tm_time.tm_year >= 1900) {
tm_time.tm_year -= 1900;
}
/* adjust date */
tm_time.tm_mon -= 1;
}
/* Correct any day of week and day of year etc. fields */
tm_time.tm_isdst = -1; /* Be sure to recheck dst. */
tm = mktime(&tm_time);
@@ -185,53 +181,55 @@ int date_main(int argc ATTRIBUTE_UNUSED, char **argv)
/* Display output */
/* Deal with format string */
if (fmt_dt2str == NULL) {
if (date_fmt == NULL) {
int i;
fmt_dt2str = xzalloc(32);
date_fmt = xzalloc(32);
if (ENABLE_FEATURE_DATE_ISOFMT && ifmt >= 0) {
strcpy(fmt_dt2str, "%Y-%m-%d");
strcpy(date_fmt, "%Y-%m-%d");
if (ifmt > 0) {
i = 8;
fmt_dt2str[i++] = 'T';
fmt_dt2str[i++] = '%';
fmt_dt2str[i++] = 'H';
date_fmt[i++] = 'T';
date_fmt[i++] = '%';
date_fmt[i++] = 'H';
if (ifmt > 1) {
fmt_dt2str[i++] = ':';
fmt_dt2str[i++] = '%';
fmt_dt2str[i++] = 'M';
if (ifmt > 2) {
fmt_dt2str[i++] = ':';
fmt_dt2str[i++] = '%';
fmt_dt2str[i++] = 'S';
}
date_fmt[i++] = ':';
date_fmt[i++] = '%';
date_fmt[i++] = 'M';
}
if (ifmt > 2) {
date_fmt[i++] = ':';
date_fmt[i++] = '%';
date_fmt[i++] = 'S';
}
format_utc:
fmt_dt2str[i++] = '%';
fmt_dt2str[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
date_fmt[i++] = '%';
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
}
} else if (opt & DATE_OPT_RFC2822) {
/* Undo busybox.c for date -R */
if (ENABLE_LOCALE_SUPPORT)
setlocale(LC_TIME, "C");
strcpy(fmt_dt2str, "%a, %d %b %Y %H:%M:%S ");
strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S ");
i = 22;
goto format_utc;
} else /* default case */
fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y";
date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
}
#define date_buf bb_common_bufsiz1
if (*fmt_dt2str == '\0') {
if (*date_fmt == '\0') {
/* With no format string, just print a blank line */
date_buf[0] = '\0';
} else {
/* Handle special conversions */
if (strncmp(fmt_dt2str, "%f", 2) == 0) {
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
if (strncmp(date_fmt, "%f", 2) == 0) {
date_fmt = (char*)"%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */
strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time);
strftime(date_buf, sizeof(date_buf), date_fmt, &tm_time);
}
puts(date_buf);
+63 -89
View File
@@ -65,7 +65,7 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
ssize_t n = full_write_or_warn(buf, len, filename);
if (n < 0)
return 1;
if ((size_t)n == obs)
if (n == obs)
G.out_full++;
else if (n) /* > 0 */
G.out_part++;
@@ -79,31 +79,23 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
#endif
int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
int dd_main(int argc, char **argv)
{
enum {
/* Must be in the same order as OP_conv_XXX! */
/* (see "flags |= (1 << what)" below) */
FLAG_NOTRUNC = 1 << 0,
FLAG_SYNC = 1 << 1,
FLAG_NOERROR = 1 << 2,
FLAG_FSYNC = 1 << 3,
/* end of conv flags */
FLAG_TWOBUFS = 1 << 4,
FLAG_COUNT = 1 << 5,
FLAG_SYNC = 1 << 0,
FLAG_NOERROR = 1 << 1,
FLAG_NOTRUNC = 1 << 2,
FLAG_TWOBUFS = 1 << 3,
FLAG_COUNT = 1 << 4,
};
static const char keywords[] ALIGN1 =
"bs\0""count\0""seek\0""skip\0""if\0""of\0"
"bs=\0""count=\0""seek=\0""skip=\0""if=\0""of=\0"
#if ENABLE_FEATURE_DD_IBS_OBS
"ibs\0""obs\0""conv\0"
"ibs=\0""obs=\0""conv=\0""notrunc\0""sync\0""noerror\0"
#endif
;
#if ENABLE_FEATURE_DD_IBS_OBS
static const char conv_words[] ALIGN1 =
"notrunc\0""sync\0""noerror\0""fsync\0";
#endif
enum {
OP_bs = 0,
OP_bs = 1,
OP_count,
OP_seek,
OP_skip,
@@ -113,23 +105,9 @@ int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
OP_ibs,
OP_obs,
OP_conv,
/* Must be in the same order as FLAG_XXX! */
OP_conv_notrunc = 0,
OP_conv_notrunc,
OP_conv_sync,
OP_conv_noerror,
OP_conv_fsync,
/* Unimplemented conv=XXX: */
//nocreat do not create the output file
//excl fail if the output file already exists
//fdatasync physically write output file data before finishing
//swab swap every pair of input bytes
//lcase change upper case to lower case
//ucase change lower case to upper case
//block pad newline-terminated records with spaces to cbs-size
//unblock replace trailing spaces in cbs-size records with newline
//ascii from EBCDIC to ASCII
//ebcdic from ASCII to EBCDIC
//ibm from ASCII to alternate EBCDIC
#endif
};
int exitcode = EXIT_FAILURE;
@@ -160,85 +138,85 @@ int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
signal_SA_RESTART_empty_mask(SIGUSR1, dd_output_status);
#endif
for (n = 1; argv[n]; n++) {
int what;
char *val;
for (n = 1; n < argc; n++) {
smalluint key_len;
smalluint what;
char *key;
char *arg = argv[n];
#if ENABLE_DESKTOP
/* "dd --". NB: coreutils 6.9 will complain if they see
* more than one of them. We wouldn't. */
if (arg[0] == '-' && arg[1] == '-' && arg[2] == '\0')
continue;
#endif
val = strchr(arg, '=');
if (val == NULL)
//XXX:FIXME: we reject plain "dd --" This would cost ~20 bytes, so..
//if (*arg == '-' && *++arg == '-' && !*++arg) continue;
key = strstr(arg, "=");
if (key == NULL)
bb_show_usage();
*val = '\0';
what = index_in_strings(keywords, arg);
if (what < 0)
key_len = key - arg + 1;
key = xstrndup(arg, key_len);
what = index_in_strings(keywords, key) + 1;
if (ENABLE_FEATURE_CLEAN_UP)
free(key);
if (what == 0)
bb_show_usage();
/* *val = '='; - to preserve ps listing? */
val++;
arg += key_len;
#if ENABLE_FEATURE_DD_IBS_OBS
if (what == OP_ibs) {
/* Must fit into positive ssize_t */
ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
/*continue;*/
ibs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
}
if (what == OP_obs) {
obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
/*continue;*/
obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
}
if (what == OP_conv) {
while (1) {
/* find ',', replace them with NUL so we can use val for
/* find ',', replace them with NUL so we can use arg for
* index_in_strings() without copying.
* We rely on val being non-null, else strchr would fault.
* We rely on arg being non-null, else strchr would fault.
*/
arg = strchr(val, ',');
if (arg)
*arg = '\0';
what = index_in_strings(conv_words, val);
if (what < 0)
bb_error_msg_and_die(bb_msg_invalid_arg, val, "conv");
flags |= (1 << what);
if (!arg) /* no ',' left, so this was the last specifier */
key = strchr(arg, ',');
if (key)
*key = '\0';
what = index_in_strings(keywords, arg) + 1;
if (what < OP_conv_notrunc)
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
if (what == OP_conv_notrunc)
flags |= FLAG_NOTRUNC;
if (what == OP_conv_sync)
flags |= FLAG_SYNC;
if (what == OP_conv_noerror)
flags |= FLAG_NOERROR;
if (!key) /* no ',' left, so this was the last specifier */
break;
/* *arg = ','; - to preserve ps listing? */
val = arg + 1; /* skip this keyword and ',' */
arg = key + 1; /* skip this keyword and ',' */
}
continue; /* we trashed 'what', can't fall through */
continue;
}
#endif
if (what == OP_bs) {
ibs = obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
/*continue;*/
ibs = obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
}
/* These can be large: */
if (what == OP_count) {
flags |= FLAG_COUNT;
count = XATOU_SFX(val, dd_suffixes);
/*continue;*/
count = XATOU_SFX(arg, dd_suffixes);
continue;
}
if (what == OP_seek) {
seek = XATOU_SFX(val, dd_suffixes);
/*continue;*/
seek = XATOU_SFX(arg, dd_suffixes);
continue;
}
if (what == OP_skip) {
skip = XATOU_SFX(val, dd_suffixes);
/*continue;*/
skip = XATOU_SFX(arg, dd_suffixes);
continue;
}
if (what == OP_if) {
infile = val;
/*continue;*/
infile = arg;
continue;
}
if (what == OP_of) {
outfile = val;
/*continue;*/
}
} /* end of "for (argv[n])" */
if (what == OP_of)
outfile = arg;
}
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
ibuf = obuf = xmalloc(ibs);
if (ibs != obs) {
@@ -312,7 +290,7 @@ int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
while (n) {
size_t d = obs - oc;
if (d > (size_t)n)
if (d > n)
d = n;
memcpy(obuf + oc, tmp, d);
n -= d;
@@ -326,17 +304,13 @@ int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
} else if (write_and_stats(ibuf, n, obs, outfile))
goto out_status;
if (flags & FLAG_FSYNC) {
if (fsync(ofd) < 0)
goto die_outfile;
}
}
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
w = full_write_or_warn(obuf, oc, outfile);
if (w < 0) goto out_status;
if (w > 0) G.out_part++;
if (w > 0)
G.out_part++;
}
if (close(ifd) < 0) {
die_infile:
+15 -18
View File
@@ -24,27 +24,24 @@ static void convert(char *fn, int conv_type)
{
FILE *in, *out;
int i;
char *temp_fn = temp_fn; /* for compiler */
char *resolved_fn = resolved_fn;
char *name_buf = name_buf; /* for compiler */
in = stdin;
out = stdout;
if (fn != NULL) {
struct stat st;
resolved_fn = xmalloc_follow_symlinks(fn);
if (resolved_fn == NULL)
bb_simple_perror_msg_and_die(fn);
in = xfopen(resolved_fn, "r");
fstat(fileno(in), &st);
temp_fn = xasprintf("%sXXXXXX", resolved_fn);
i = mkstemp(temp_fn);
in = xfopen(fn, "r");
/*
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.
*/
name_buf = xasprintf("%sXXXXXX", fn);
i = mkstemp(name_buf);
if (i == -1
|| fchmod(i, st.st_mode) == -1
|| fchmod(i, 0600) == -1
|| !(out = fdopen(i, "w+"))
) {
bb_simple_perror_msg_and_die(temp_fn);
bb_perror_nomsg_and_die();
}
}
@@ -59,12 +56,12 @@ static void convert(char *fn, int conv_type)
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
unlink(temp_fn);
unlink(name_buf);
bb_perror_nomsg_and_die();
}
xrename(temp_fn, resolved_fn);
free(temp_fn);
free(resolved_fn);
// TODO: destroys symlinks. See how passwd handles this
xrename(name_buf, fn);
free(name_buf);
}
}
+4 -2
View File
@@ -29,6 +29,7 @@
* - use xfunc_error_retval
*/
#include <getopt.h> /* struct option */
#include "libbb.h"
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
@@ -62,7 +63,8 @@ int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
environ = cleanenv;
} else {
while (unset_env) {
unsetenv(llist_pop(&unset_env));
unsetenv(unset_env->data);
unset_env = unset_env->link;
}
}
@@ -84,7 +86,7 @@ int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
puts(*ep);
}
fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(0);
}
/*
+2 -2
View File
@@ -41,7 +41,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
char *line;
char *ptr;
int convert;
unsigned pos;
int pos;
/* Increment tab_size by 1 locally.*/
tab_size++;
@@ -80,7 +80,7 @@ static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
int convert;
int pos;
int i = 0;
unsigned column = 0;
int column = 0;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
+87 -84
View File
@@ -28,6 +28,13 @@
#include "libbb.h"
#include "xregex.h"
/* The kinds of value we can have. */
enum valtype {
integer,
string
};
typedef enum valtype TYPE;
#if ENABLE_EXPR_MATH_SUPPORT_64
typedef int64_t arith_t;
@@ -44,16 +51,10 @@ typedef long arith_t;
/* TODO: use bb_strtol[l]? It's easier to check for errors... */
/* The kinds of value we can have. */
enum {
INTEGER,
STRING
};
/* A value is.... */
struct valinfo {
smallint type; /* Which kind. */
union { /* The value itself. */
TYPE type; /* Which kind. */
union { /* The value itself. */
arith_t i;
char *s;
} u;
@@ -76,9 +77,8 @@ static VALUE *int_value(arith_t i)
{
VALUE *v;
v = xzalloc(sizeof(VALUE));
if (INTEGER) /* otherwise xzaaloc did it already */
v->type = INTEGER;
v = xmalloc(sizeof(VALUE));
v->type = integer;
v->u.i = i;
return v;
}
@@ -89,47 +89,46 @@ static VALUE *str_value(const char *s)
{
VALUE *v;
v = xzalloc(sizeof(VALUE));
if (STRING) /* otherwise xzaaloc did it already */
v->type = STRING;
v = xmalloc(sizeof(VALUE));
v->type = string;
v->u.s = xstrdup(s);
return v;
}
/* Free VALUE V, including structure components. */
static void freev(VALUE *v)
static void freev(VALUE * v)
{
if (v->type == STRING)
if (v->type == string)
free(v->u.s);
free(v);
}
/* Return nonzero if V is a null-string or zero-number. */
static int null(VALUE *v)
static int null(VALUE * v)
{
if (v->type == INTEGER)
if (v->type == integer)
return v->u.i == 0;
/* STRING: */
/* string: */
return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0');
}
/* Coerce V to a STRING value (can't fail). */
/* Coerce V to a string value (can't fail). */
static void tostring(VALUE *v)
static void tostring(VALUE * v)
{
if (v->type == INTEGER) {
if (v->type == integer) {
v->u.s = xasprintf("%" PF_REZ "d", PF_REZ_TYPE v->u.i);
v->type = STRING;
v->type = string;
}
}
/* Coerce V to an INTEGER value. Return 1 on success, 0 on failure. */
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
static bool toarith(VALUE *v)
static bool toarith(VALUE * v)
{
if (v->type == STRING) {
if (v->type == string) {
arith_t i;
char *e;
@@ -140,54 +139,50 @@ static bool toarith(VALUE *v)
return 0;
free(v->u.s);
v->u.i = i;
v->type = INTEGER;
v->type = integer;
}
return 1;
}
/* Return str[0]+str[1] if the next token matches STR exactly.
/* Return nonzero if the next token matches STR exactly.
STR must not be NULL. */
static int nextarg(const char *str)
static bool nextarg(const char *str)
{
if (*G.args == NULL || strcmp(*G.args, str) != 0)
if (*G.args == NULL)
return 0;
return (unsigned char)str[0] + (unsigned char)str[1];
return strcmp(*G.args, str) == 0;
}
/* The comparison operator handling functions. */
static int cmp_common(VALUE *l, VALUE *r, int op)
static int cmp_common(VALUE * l, VALUE * r, int op)
{
arith_t ll, rr;
int cmpval;
ll = l->u.i;
rr = r->u.i;
if (l->type == STRING || r->type == STRING) {
if (l->type == string || r->type == string) {
tostring(l);
tostring(r);
ll = strcmp(l->u.s, r->u.s);
rr = 0;
}
/* calculating ll - rr and checking the result is prone to overflows.
* We'll do it differently: */
cmpval = strcmp(l->u.s, r->u.s);
} else
cmpval = l->u.i - r->u.i;
if (op == '<')
return ll < rr;
if (op == ('<' + '='))
return ll <= rr;
if (op == '=' || (op == '=' + '='))
return ll == rr;
if (op == '!' + '=')
return ll != rr;
return cmpval < 0;
if (op == ('L' + 'E'))
return cmpval <= 0;
if (op == '=')
return cmpval == 0;
if (op == '!')
return cmpval != 0;
if (op == '>')
return ll > rr;
return cmpval > 0;
/* >= */
return ll >= rr;
return cmpval >= 0;
}
/* The arithmetic operator handling functions. */
static arith_t arithmetic_common(VALUE *l, VALUE *r, int op)
static arith_t arithmetic_common(VALUE * l, VALUE * r, int op)
{
arith_t li, ri;
@@ -195,24 +190,25 @@ static arith_t arithmetic_common(VALUE *l, VALUE *r, int op)
bb_error_msg_and_die("non-numeric argument");
li = l->u.i;
ri = r->u.i;
if ((op == '/' || op == '%') && ri == 0)
bb_error_msg_and_die("division by zero");
if (op == '+')
return li + ri;
if (op == '-')
else if (op == '-')
return li - ri;
if (op == '*')
else if (op == '*')
return li * ri;
if (ri == 0)
bb_error_msg_and_die("division by zero");
if (op == '/')
else if (op == '/')
return li / ri;
return li % ri;
else
return li % ri;
}
/* Do the : operator.
SV is the VALUE for the lhs (the string),
PV is the VALUE for the rhs (the pattern). */
static VALUE *docolon(VALUE *sv, VALUE *pv)
static VALUE *docolon(VALUE * sv, VALUE * pv)
{
VALUE *v;
regex_t re_buffer;
@@ -234,16 +230,14 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
/* expr uses an anchored pattern match, so check that there was a
* match and that the match starts at offset 0. */
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH
&& re_regs[0].rm_so == 0
) {
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH &&
re_regs[0].rm_so == 0) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) {
sv->u.s[re_regs[1].rm_eo] = '\0';
v = str_value(sv->u.s + re_regs[1].rm_so);
} else {
} else
v = int_value(re_regs[0].rm_eo);
}
} else {
/* Match failed -- return the right kind of null. */
if (re_buffer.re_nsub > 0)
@@ -333,7 +327,7 @@ static VALUE *eval6(void)
v = str_value("");
else {
v = xmalloc(sizeof(VALUE));
v->type = STRING;
v->type = string;
v->u.s = xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
}
freev(l);
@@ -373,11 +367,14 @@ static VALUE *eval4(void)
l = eval5();
while (1) {
op = nextarg("*");
if (!op) { op = nextarg("/");
if (!op) { op = nextarg("%");
if (!op) return l;
}}
if (nextarg("*"))
op = '*';
else if (nextarg("/"))
op = '/';
else if (nextarg("%"))
op = '%';
else
return l;
G.args++;
r = eval5();
val = arithmetic_common(l, r, op);
@@ -397,11 +394,12 @@ static VALUE *eval3(void)
l = eval4();
while (1) {
op = nextarg("+");
if (!op) {
op = nextarg("-");
if (!op) return l;
}
if (nextarg("+"))
op = '+';
else if (nextarg("-"))
op = '-';
else
return l;
G.args++;
r = eval4();
val = arithmetic_common(l, r, op);
@@ -421,15 +419,20 @@ static VALUE *eval2(void)
l = eval3();
while (1) {
op = nextarg("<");
if (!op) { op = nextarg("<=");
if (!op) { op = nextarg("=");
if (!op) { op = nextarg("==");
if (!op) { op = nextarg("!=");
if (!op) { op = nextarg(">=");
if (!op) { op = nextarg(">");
if (!op) return l;
}}}}}}
if (nextarg("<"))
op = '<';
else if (nextarg("<="))
op = 'L' + 'E';
else if (nextarg("=") || nextarg("=="))
op = '=';
else if (nextarg("!="))
op = '!';
else if (nextarg(">="))
op = 'G' + 'E';
else if (nextarg(">"))
op = '>';
else
return l;
G.args++;
r = eval3();
toarith(l);
@@ -495,7 +498,7 @@ int expr_main(int argc, char **argv)
if (*G.args)
bb_error_msg_and_die("syntax error");
if (v->type == INTEGER)
if (v->type == integer)
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
+1 -1
View File
@@ -8,7 +8,7 @@
*/
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */
#include "libbb.h"
+3
View File
@@ -9,6 +9,9 @@
* owner/group, will probably modify bb_make_directory(...)
*/
#include <libgen.h>
#include <getopt.h> /* struct option */
#include "libbb.h"
#include "libcoreutils/coreutils.h"
-8
View File
@@ -6,10 +6,6 @@
#ifndef COREUTILS_H
#define COREUTILS_H 1
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility push(hidden)
#endif
typedef int (*stat_func)(const char *fn, struct stat *ps);
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf);
@@ -17,8 +13,4 @@ int cp_mv_stat(const char *fn, struct stat *fn_stat);
mode_t getopt_mk_fifo_nod(char **argv);
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility pop
#endif
#endif
+63 -87
View File
@@ -29,12 +29,9 @@
* 1. requires lstat (BSD) - how do you do it without?
*/
#include <getopt.h>
#include "libbb.h"
#if ENABLE_FEATURE_ASSUME_UNICODE
#include <wchar.h>
#endif
/* This is a NOEXEC applet. Be very careful! */
@@ -118,6 +115,18 @@ SPLIT_SUBDIR = 2,
#define ATTR(mode) ("\00\00\01\00\01\00\01\00"\
"\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)])
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
#if ENABLE_FEATURE_LS_COLOR
static smallint show_color;
/* long option entry used only for --color, which has no short option
* equivalent */
static const char ls_color_opt[] ALIGN1 =
"color\0" Optional_argument "\xff" /* no short equivalent */
;
#else
enum { show_color = 0 };
#endif
/*
* a directory entry and its stat info are stored here
*/
@@ -129,68 +138,25 @@ struct dnode { /* the basic node */
USE_SELINUX(security_context_t sid;)
struct dnode *next; /* point at the next node */
};
typedef struct dnode dnode_t;
static struct dnode **list_dir(const char *);
static struct dnode **dnalloc(int);
static int list_single(const struct dnode *);
static int list_single(struct dnode *);
static unsigned all_fmt;
struct globals {
#if ENABLE_FEATURE_LS_COLOR
smallint show_color;
#endif
smallint exit_code;
unsigned all_fmt;
#if ENABLE_FEATURE_AUTOWIDTH
unsigned tabstops; // = COLUMN_GAP;
unsigned terminal_width; // = TERMINAL_WIDTH;
#endif
#if ENABLE_FEATURE_LS_TIMESTAMPS
/* Do time() just once. Saves one syscall per file for "ls -l" */
time_t current_time_t;
#endif
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#if ENABLE_FEATURE_LS_COLOR
#define show_color (G.show_color )
#else
enum { show_color = 0 };
#endif
#define exit_code (G.exit_code )
#define all_fmt (G.all_fmt )
#if ENABLE_FEATURE_AUTOWIDTH
#define tabstops (G.tabstops )
#define terminal_width (G.terminal_width)
static unsigned tabstops = COLUMN_GAP;
static unsigned terminal_width = TERMINAL_WIDTH;
#else
enum {
tabstops = COLUMN_GAP,
terminal_width = TERMINAL_WIDTH,
};
#endif
#define current_time_t (G.current_time_t)
/* memset: we have to zero it out because of NOEXEC */
#define INIT_G() do { \
memset(&G, 0, sizeof(G)); \
USE_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \
USE_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \
USE_FEATURE_LS_TIMESTAMPS(time(&current_time_t);) \
} while (0)
#if ENABLE_FEATURE_ASSUME_UNICODE
/* libbb candidate */
static size_t mbstrlen(const char *string)
{
size_t width = mbsrtowcs(NULL /*dest*/, &string,
MAXINT(size_t) /*len*/, NULL /*state*/);
if (width == (size_t)-1)
return strlen(string);
return width;
}
#else
#define mbstrlen(string) strlen(string)
#endif
static int status = EXIT_SUCCESS;
static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
{
@@ -206,7 +172,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
#endif
if (stat(fullname, &dstat)) {
bb_simple_perror_msg(fullname);
exit_code = EXIT_FAILURE;
status = EXIT_FAILURE;
return 0;
}
} else {
@@ -217,7 +183,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
#endif
if (lstat(fullname, &dstat)) {
bb_simple_perror_msg(fullname);
exit_code = EXIT_FAILURE;
status = EXIT_FAILURE;
return 0;
}
}
@@ -430,7 +396,7 @@ static void showfiles(struct dnode **dn, int nfiles)
} else {
/* find the longest file name, use that as the column width */
for (i = 0; i < nfiles; i++) {
int len = mbstrlen(dn[i]->name);
int len = strlen(dn[i]->name);
if (column_width < len)
column_width = len;
}
@@ -529,7 +495,7 @@ static struct dnode **list_dir(const char *path)
nfiles = 0;
dir = warn_opendir(path);
if (dir == NULL) {
exit_code = EXIT_FAILURE;
status = EXIT_FAILURE;
return NULL; /* could not open the dir */
}
while ((entry = readdir(dir)) != NULL) {
@@ -573,7 +539,13 @@ static struct dnode **list_dir(const char *path)
}
static int list_single(const struct dnode *dn)
#if ENABLE_FEATURE_LS_TIMESTAMPS
/* Do time() just once. Saves one syscall per file for "ls -l" */
/* Initialized in main() */
static time_t current_time_t;
#endif
static int list_single(struct dnode *dn)
{
int i, column = 0;
@@ -687,12 +659,7 @@ static int list_single(const struct dnode *dn)
fgcolor(info.st_mode));
}
#endif
#if ENABLE_FEATURE_ASSUME_UNICODE
printf("%s", dn->name);
column += mbstrlen(dn->name);
#else
column += printf("%s", dn->name);
#endif
if (show_color) {
printf("\033[0m");
}
@@ -735,7 +702,6 @@ static int list_single(const struct dnode *dn)
return column;
}
/* "[-]Cadil1", POSIX mandated options, busybox always supports */
/* "[-]gnsx", POSIX non-mandated options, busybox always supports */
/* "[-]Ak" GNU options, busybox always supports */
@@ -814,18 +780,11 @@ static const unsigned opt_flags[] = {
};
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
#if ENABLE_FEATURE_LS_COLOR
/* long option entry used only for --color, which has no short option
* equivalent */
static const char ls_color_opt[] ALIGN1 =
"color\0" Optional_argument "\xff" /* no short equivalent */
;
#endif
/* THIS IS A "SAFE" APPLET, main() MAY BE CALLED INTERNALLY FROM SHELL */
/* BE CAREFUL! */
int ls_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
int ls_main(int argc, char **argv)
{
struct dnode **dnd;
struct dnode **dnf;
@@ -833,13 +792,18 @@ int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
struct dnode *dn;
struct dnode *cur;
unsigned opt;
int nfiles;
int nfiles = 0;
int dnfiles;
int dndirs;
int oi;
int ac;
int i;
char **av;
USE_FEATURE_LS_COLOR(char *color_opt;)
INIT_G();
#if ENABLE_FEATURE_LS_TIMESTAMPS
time(&current_time_t);
#endif
all_fmt = LIST_SHORT |
(ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD));
@@ -920,27 +884,39 @@ int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (!(all_fmt & STYLE_MASK))
all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
argv += optind;
if (!argv[0])
*--argv = (char*)".";
/*
* when there are no cmd line args we have to supply a default "." arg.
* we will create a second argv array, "av" that will hold either
* our created "." arg, or the real cmd line args. The av array
* just holds the pointers- we don't move the date the pointers
* point to.
*/
ac = argc - optind; /* how many cmd line args are left */
if (ac < 1) {
static const char *const dotdir[] = { "." };
if (argv[1])
all_fmt |= DISP_DIRNAME; /* 2 or more items? label directories */
av = (char **) dotdir;
ac = 1;
} else {
av = argv + optind;
}
/* now, everything is in the av array */
if (ac > 1)
all_fmt |= DISP_DIRNAME; /* 2 or more items? label directories */
/* stuff the command line file names into a dnode array */
dn = NULL;
nfiles = 0;
do {
for (oi = 0; oi < ac; oi++) {
/* ls w/o -l follows links on command line */
cur = my_stat(*argv, *argv, !(all_fmt & STYLE_LONG));
argv++;
cur = my_stat(av[oi], av[oi], !(all_fmt & STYLE_LONG));
if (!cur)
continue;
cur->allocated = 0;
cur->next = dn;
dn = cur;
nfiles++;
} while (*argv);
}
/* now that we know how many files there are
* allocate memory for an array to hold dnode pointers
@@ -975,5 +951,5 @@ int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
if (ENABLE_FEATURE_CLEAN_UP)
dfree(dnp, nfiles);
return exit_code;
return status;
}
+2 -2
View File
@@ -21,7 +21,7 @@ static unsigned char *hash_bin_to_hex(unsigned char *hash_value,
/* xzalloc zero-terminates */
char *hex_value = xzalloc((hash_length * 2) + 1);
bin2hex(hex_value, (char*)hash_value, hash_length);
return (unsigned char *)hex_value;
return hex_value;
}
static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
@@ -115,7 +115,7 @@ int md5_sha1_sum_main(int argc ATTRIBUTE_UNUSED, char **argv)
pre_computed_stream = xfopen_stdin(argv[0]);
while ((line = xmalloc_fgetline(pre_computed_stream)) != NULL) {
while ((line = xmalloc_getline(pre_computed_stream)) != NULL) {
char *filename_ptr;
count_total++;
+1
View File
@@ -19,6 +19,7 @@
/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
*/
#include <getopt.h> /* struct option */
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
+5 -5
View File
@@ -13,6 +13,10 @@
* Size reduction and improved error checking.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <getopt.h> /* struct option */
#include "libbb.h"
#include "libcoreutils/coreutils.h"
@@ -71,8 +75,7 @@ int mv_main(int argc, char **argv)
}
DO_MOVE:
if (dest_exists
&& !(flags & OPT_FILEUTILS_FORCE)
if (dest_exists && !(flags & OPT_FILEUTILS_FORCE)
&& ((access(dest, W_OK) < 0 && isatty(0))
|| (flags & OPT_FILEUTILS_INTERACTIVE))
) {
@@ -109,9 +112,6 @@ int mv_main(int argc, char **argv)
goto RET_1;
}
}
/* FILEUTILS_RECUR also prevents nasties like
* "read from device and write contents to dst"
* instead of "create same device node" */
copy_flag = FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS;
#if ENABLE_SELINUX
copy_flag |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
+1
View File
@@ -17,6 +17,7 @@
/* This one provides -t (busybox's own build script needs it) */
#include "od_bloaty.c"
#else
#include <getopt.h>
#include "dump.h"
+15 -11
View File
@@ -50,6 +50,7 @@ diff -u -a std bbox >bbox.diff || { echo Different!; sleep 1; }
*/
#include "libbb.h"
#include <getopt.h>
#define assert(a) ((void)0)
@@ -508,10 +509,10 @@ check_and_close(void)
}
/* If S points to a single valid modern od format string, put
a description of that format in *TSPEC, return pointer to
character following the just-decoded format.
For example, if S were "d4afL", we will return a rtp to "afL"
and *TSPEC would be
a description of that format in *TSPEC, make *NEXT point at the
character following the just-decoded format (if *NEXT is non-NULL),
and return zero. For example, if S were "d4afL"
*NEXT would be set to "afL" and *TSPEC would be
{
fmt = SIGNED_DECIMAL;
size = INT or LONG; (whichever integral_type_size[4] resolves to)
@@ -521,8 +522,9 @@ check_and_close(void)
S_ORIG is solely for reporting errors. It should be the full format
string argument. */
static const char *
decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
static void
decode_one_format(const char *s_orig, const char *s, const char **next,
struct tspec *tspec)
{
enum size_spec size_spec;
unsigned size;
@@ -535,6 +537,7 @@ decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
unsigned field_width = 0;
int pos;
assert(tspec != NULL);
switch (*s) {
case 'd':
@@ -560,14 +563,13 @@ decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
s = end;
}
} else {
static const uint8_t CSIL_sizeof[4] = {
static const uint8_t CSIL_sizeof[] = {
sizeof(char),
sizeof(short),
sizeof(int),
sizeof(long),
};
size = CSIL_sizeof[p - CSIL];
s++; /* skip C/S/I/L */
}
#define ISPEC_TO_FORMAT(Spec, Min_format, Long_format, Max_format) \
@@ -715,7 +717,8 @@ decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
if (tspec->hexl_mode_trailer)
s++;
return s;
if (next != NULL)
*next = s;
}
/* Decode the modern od format string S. Append the decoded
@@ -731,7 +734,7 @@ decode_format_string(const char *s)
struct tspec tspec;
const char *next;
next = decode_one_format(s_orig, s, &tspec);
decode_one_format(s_orig, s, &next, &tspec);
assert(s != next);
s = next;
@@ -1281,7 +1284,8 @@ int od_main(int argc, char **argv)
if (opt & OPT_o) decode_format_string("o2");
//if (opt & OPT_t)...
while (lst_t) {
decode_format_string(llist_pop(&lst_t));
decode_format_string(lst_t->data);
lst_t = lst_t->link;
}
if (opt & OPT_v) verbose = 1;
if (opt & OPT_x) decode_format_string("x2");
+1 -1
View File
@@ -29,5 +29,5 @@ int printenv_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
}
fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(0);
}
+57 -64
View File
@@ -107,28 +107,28 @@ static void print_esc_string(char *str)
}
}
static void print_direc(char *format, unsigned fmt_length,
int field_width, int precision,
static void print_direc(char *start, size_t length, int field_width, int precision,
const char *argument)
{
char saved;
char *p; /* Null-terminated copy of % directive. */
saved = format[fmt_length];
format[fmt_length] = '\0';
p = xmalloc((unsigned) (length + 1));
strncpy(p, start, length);
p[length] = 0;
switch (format[fmt_length - 1]) {
switch (p[length - 1]) {
case 'd':
case 'i':
if (field_width < 0) {
if (precision < 0)
printf(format, my_xstrtol(argument));
printf(p, my_xstrtol(argument));
else
printf(format, precision, my_xstrtol(argument));
printf(p, precision, my_xstrtol(argument));
} else {
if (precision < 0)
printf(format, field_width, my_xstrtol(argument));
printf(p, field_width, my_xstrtol(argument));
else
printf(format, field_width, precision, my_xstrtol(argument));
printf(p, field_width, precision, my_xstrtol(argument));
}
break;
case 'o':
@@ -137,14 +137,14 @@ static void print_direc(char *format, unsigned fmt_length,
case 'X':
if (field_width < 0) {
if (precision < 0)
printf(format, my_xstrtoul(argument));
printf(p, my_xstrtoul(argument));
else
printf(format, precision, my_xstrtoul(argument));
printf(p, precision, my_xstrtoul(argument));
} else {
if (precision < 0)
printf(format, field_width, my_xstrtoul(argument));
printf(p, field_width, my_xstrtoul(argument));
else
printf(format, field_width, precision, my_xstrtoul(argument));
printf(p, field_width, precision, my_xstrtoul(argument));
}
break;
case 'f':
@@ -154,48 +154,51 @@ static void print_direc(char *format, unsigned fmt_length,
case 'G':
if (field_width < 0) {
if (precision < 0)
printf(format, my_xstrtod(argument));
printf(p, my_xstrtod(argument));
else
printf(format, precision, my_xstrtod(argument));
printf(p, precision, my_xstrtod(argument));
} else {
if (precision < 0)
printf(format, field_width, my_xstrtod(argument));
printf(p, field_width, my_xstrtod(argument));
else
printf(format, field_width, precision, my_xstrtod(argument));
printf(p, field_width, precision, my_xstrtod(argument));
}
break;
case 'c':
printf(format, *argument);
printf(p, *argument);
break;
case 's':
if (field_width < 0) {
if (precision < 0)
printf(format, argument);
printf(p, argument);
else
printf(format, precision, argument);
printf(p, precision, argument);
} else {
if (precision < 0)
printf(format, field_width, argument);
printf(p, field_width, argument);
else
printf(format, field_width, precision, argument);
printf(p, field_width, precision, argument);
}
break;
}
format[fmt_length] = saved;
free(p);
}
/* Print the text in FORMAT, using ARGV for arguments to any '%' directives.
Return advanced ARGV. */
static char **print_formatted(char *f, char **argv)
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
arguments to any '%' directives.
Return the number of elements of ARGV used. */
static int print_formatted(char *format, int argc, char **argv)
{
int save_argc = argc; /* Preserve original value. */
char *f; /* Pointer into 'format'. */
char *direc_start; /* Start of % directive. */
unsigned direc_length; /* Length of % directive. */
size_t direc_length; /* Length of % directive. */
int field_width; /* Arg to first '*', or -1 if none. */
int precision; /* Arg to second '*', or -1 if none. */
char **saved_argv = argv;
for (; *f; ++f) {
for (f = format; *f; ++f) {
switch (*f) {
case '%':
direc_start = f++;
@@ -206,9 +209,10 @@ static char **print_formatted(char *f, char **argv)
break;
}
if (*f == 'b') {
if (*argv) {
if (argc > 0) {
print_esc_string(*argv);
++argv;
--argc;
}
break;
}
@@ -219,9 +223,10 @@ static char **print_formatted(char *f, char **argv)
if (*f == '*') {
++f;
++direc_length;
if (*argv) {
if (argc > 0) {
field_width = my_xstrtoul(*argv);
++argv;
--argc;
} else
field_width = 0;
} else {
@@ -236,9 +241,10 @@ static char **print_formatted(char *f, char **argv)
if (*f == '*') {
++f;
++direc_length;
if (*argv) {
if (argc > 0) {
precision = my_xstrtoul(*argv);
++argv;
--argc;
} else
precision = 0;
} else
@@ -256,18 +262,18 @@ static char **print_formatted(char *f, char **argv)
fprintf(stderr, "%%%c: invalid directive", *f);
*/
++direc_length;
if (*argv) {
if (argc > 0) {
print_direc(direc_start, direc_length, field_width,
precision, *argv);
++argv;
--argc;
} else
print_direc(direc_start, direc_length, field_width,
precision, "");
break;
case '\\':
if (*++f == 'c') {
return saved_argv; /* causes main() to exit */
}
if (*++f == 'c')
exit(0);
bb_putchar(bb_process_escape_sequence((const char **)&f));
f--;
break;
@@ -276,45 +282,32 @@ static char **print_formatted(char *f, char **argv)
}
}
return argv;
return save_argc - argc;
}
int printf_main(int argc ATTRIBUTE_UNUSED, char **argv)
int printf_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int printf_main(int argc, char **argv)
{
char *format;
char **argv2;
int args_used;
/* We must check that stdout is not closed.
* The reason for this is highly non-obvious. printf_main is used from shell.
* Shell must correctly handle 'printf "%s" foo'
* if stdout is closed. With stdio, output gets shoveled into
* stdout buffer, and even fflush cannot clear it out. It seems that
* even if libc receives EBADF on write attempts, it feels determined
* to output data no matter what. So it will try later,
* and possibly will clobber future output. Not good. */
if (dup2(1, 1) != 1)
return -1;
/* bash builtin errors out on "printf '-%s-\n' foo",
* coreutils-6.9 works. Both work with "printf -- '-%s-\n' foo".
* We will mimic coreutils. */
if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && argv[1][2] == '\0')
argv++;
if (!argv[1])
if (argc <= 1 || argv[1][0] == '-') {
bb_show_usage();
}
format = argv[1];
argv2 = argv + 2;
argc -= 2;
argv += 2;
do {
argv = argv2;
argv2 = print_formatted(format, argv);
} while (argv2 != argv && *argv2);
args_used = print_formatted(format, argc, argv);
argc -= args_used;
argv += args_used;
} while (args_used > 0 && argc > 0);
/* coreutils compat (bash doesn't do this):
if (*argv)
/* if (argc > 0)
fprintf(stderr, "excess args ignored");
*/
*/
return EXIT_SUCCESS;
}
+1
View File
@@ -7,6 +7,7 @@
* Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
*/
#include <getopt.h>
#include "libbb.h"
int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+6 -5
View File
@@ -59,8 +59,7 @@ static struct sort_key {
static char *get_key(char *str, struct sort_key *key, int flags)
{
int start = 0, end = 0, len, j;
unsigned i;
int start = 0, end = 0, len, i, j;
/* Special case whole string, so we don't have to make a copy */
if (key->range[0] == 1 && !key->range[1] && !key->range[2] && !key->range[3]
@@ -151,9 +150,9 @@ static struct sort_key *add_key(void)
#define GET_LINE(fp) \
((option_mask32 & FLAG_z) \
? bb_get_chunk_from_file(fp, NULL) \
: xmalloc_fgetline(fp))
: xmalloc_getline(fp))
#else
#define GET_LINE(fp) xmalloc_fgetline(fp)
#define GET_LINE(fp) xmalloc_getline(fp)
#endif
/* Iterate through keys list and perform comparisons */
@@ -314,7 +313,7 @@ int sort_main(int argc ATTRIBUTE_UNUSED, char **argv)
0
};
struct sort_key *key = add_key();
char *str_k = llist_pop(&lst_k);
char *str_k = lst_k->data;
const char *temp2;
i = 0; /* i==0 before comma, 1 after (-k3,6) */
@@ -344,6 +343,8 @@ int sort_main(int argc ATTRIBUTE_UNUSED, char **argv)
str_k++;
}
}
/* leaking lst_k... */
lst_k = lst_k->link;
}
#endif
/* global b strips leading and trailing spaces */
+2 -2
View File
@@ -98,7 +98,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
while (1) {
bytes_read = safe_read(STDIN_FILENO, read_buffer, READ_BUFFER_SIZE);
bytes_read = safe_read(0, read_buffer, READ_BUFFER_SIZE);
if (!bytes_read)
break;
if (bytes_read < 0)
@@ -130,7 +130,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
}
xwrite(STDOUT_FILENO, src, to_write);
xwrite(1, src, to_write);
bytes_read -= to_write;
src += to_write;
} while (bytes_read);
+6 -5
View File
@@ -627,10 +627,11 @@ struct globals {
char buf[10];
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { \
G.device_name = bb_msg_standard_input; \
G.max_col = 80; \
} while (0)
#define INIT_G() \
do { \
G.device_name = bb_msg_standard_input; \
G.max_col = 80; \
} while (0)
/* Return a string that is the printable representation of character CH */
@@ -709,7 +710,7 @@ static void wrapf(const char *message, ...)
{
char buf[128];
va_list args;
unsigned buflen;
int buflen;
va_start(args, message);
buflen = vsnprintf(buf, sizeof(buf), message, args);
+4 -5
View File
@@ -92,8 +92,7 @@ int tail_main(int argc, char **argv)
size_t tailbufsize;
int taillen = 0;
int newlines_seen = 0;
int nfiles, nread, nwrite, i, opt;
unsigned seen;
int nfiles, nread, nwrite, seen, i, opt;
int *fds;
char *s, *buf;
@@ -211,7 +210,7 @@ int tail_main(int argc, char **argv)
} else if (count) {
if (COUNT_BYTES) {
taillen += nread;
if (taillen > (int)count) {
if (taillen > count) {
memmove(tailbuf, tailbuf + taillen - count, count);
taillen = count;
}
@@ -226,7 +225,7 @@ int tail_main(int argc, char **argv)
}
} while (k);
if (newlines_seen + newlines_in_buf < (int)count) {
if (newlines_seen + newlines_in_buf < count) {
newlines_seen += newlines_in_buf;
taillen += nread;
} else {
@@ -244,7 +243,7 @@ int tail_main(int argc, char **argv)
memmove(tailbuf, s, taillen);
newlines_seen = count - extra;
}
if (tailbufsize < (size_t)taillen + BUFSIZ) {
if (tailbufsize < taillen + BUFSIZ) {
tailbufsize = taillen + BUFSIZ;
tailbuf = xrealloc(tailbuf, tailbufsize);
}
+8 -7
View File
@@ -159,7 +159,7 @@ typedef int arith_t;
/* We try to minimize both static and stack usage. */
struct test_statics {
struct statics {
char **t_wp;
const struct t_op *t_wp_op;
gid_t *group_array;
@@ -167,10 +167,11 @@ struct test_statics {
jmp_buf leaving;
};
/* See test_ptr_hack.c */
extern struct test_statics *const test_ptr_to_statics;
/* Make it reside in writable memory, yet make compiler understand
* that it is not going to change. */
static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
#define S (*test_ptr_to_statics)
#define S (*ptr_to_statics)
#define t_wp (S.t_wp )
#define t_wp_op (S.t_wp_op )
#define group_array (S.group_array )
@@ -178,11 +179,11 @@ extern struct test_statics *const test_ptr_to_statics;
#define leaving (S.leaving )
#define INIT_S() do { \
(*(struct test_statics**)&test_ptr_to_statics) = xzalloc(sizeof(S)); \
(*(struct statics**)&ptr_to_statics) = xzalloc(sizeof(S)); \
barrier(); \
} while (0)
#define DEINIT_S() do { \
free(test_ptr_to_statics); \
free(ptr_to_statics); \
} while (0)
static arith_t primary(enum token n);
@@ -412,7 +413,7 @@ static int test_eaccess(char *path, int mode)
static int filstat(char *nm, enum token mode)
{
struct stat s;
unsigned i = i; /* gcc 3.x thinks it can be used uninitialized */
int i = i; /* gcc 3.x thinks it can be used uninitialized */
if (mode == FILSYM) {
#ifdef S_IFLNK
-23
View File
@@ -1,23 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
struct test_statics;
#ifndef GCC_COMBINE
/* We cheat here. It is declared as const ptr in libbb.h,
* but here we make it live in R/W memory */
struct test_statics *test_ptr_to_statics;
#else
/* gcc -combine will see through and complain */
/* Using alternative method which is more likely to break
* on weird architectures, compilers, linkers and so on */
struct test_statics *const test_ptr_to_statics __attribute__ ((section (".data")));
#endif
+3 -3
View File
@@ -208,8 +208,8 @@ int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (*argv) {
if (argv[0][0] == '\0')
bb_error_msg_and_die("STRING2 cannot be empty");
output_length = expand(*argv, (char *)output);
map(vector, (unsigned char *)tr_buf, input_length, output, output_length);
output_length = expand(*argv, output);
map(vector, tr_buf, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)
invec[(unsigned char)tr_buf[i]] = TRUE;
@@ -219,7 +219,7 @@ int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
for (;;) {
/* If we're out of input, flush output and read more input. */
if ((ssize_t)in_index == read_chars) {
if (in_index == read_chars) {
if (out_index) {
xwrite(STDOUT_FILENO, (char *)output, out_index);
out_index = 0;
+22 -19
View File
@@ -17,7 +17,7 @@
-m, --machine sun
-a, --all SunOS rocky8 4.0 sun
The default behavior is equivalent to '-s'.
The default behavior is equivalent to `-s'.
David MacKenzie <djm@gnu.ai.mit.edu> */
@@ -39,43 +39,47 @@ typedef struct {
} uname_info_t;
static const char options[] ALIGN1 = "snrvmpa";
static const unsigned short utsname_offset[] = {
offsetof(uname_info_t, name.sysname),
offsetof(uname_info_t, name.nodename),
offsetof(uname_info_t, name.release),
offsetof(uname_info_t, name.version),
offsetof(uname_info_t, name.machine),
offsetof(uname_info_t, processor)
static const unsigned short utsname_offset[] ALIGN2 = {
offsetof(uname_info_t,name.sysname),
offsetof(uname_info_t,name.nodename),
offsetof(uname_info_t,name.release),
offsetof(uname_info_t,name.version),
offsetof(uname_info_t,name.machine),
offsetof(uname_info_t,processor)
};
int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uname_main(int argc ATTRIBUTE_UNUSED, char **argv)
int uname_main(int argc, char **argv)
{
uname_info_t uname_info;
#if defined(__sparc__) && defined(__linux__)
char *fake_sparc = getenv("FAKE_SPARC");
#endif
const unsigned short *delta;
const unsigned short int *delta;
char toprint;
toprint = getopt32(argv, options);
if (argv[optind]) { /* coreutils-6.9 compat */
if (argc != optind) {
bb_show_usage();
}
if (toprint & (1 << 6)) { /* -a => all opts on */
if (toprint & (1 << 6)) {
toprint = 0x3f;
}
if (toprint == 0) { /* no opts => -s (sysname) */
toprint = 1;
if (toprint == 0) {
toprint = 1; /* sysname */
}
uname(&uname_info.name); /* never fails */
if (uname(&uname_info.name) == -1) {
bb_error_msg_and_die("cannot get system name");
}
#if defined(__sparc__) && defined(__linux__)
if (fake_sparc && (fake_sparc[0] | 0x20) == 'y') {
if ((fake_sparc != NULL)
&& ((fake_sparc[0] == 'y')
|| (fake_sparc[0] == 'Y'))) {
strcpy(uname_info.name.machine, "sparc");
}
#endif
@@ -85,8 +89,7 @@ int uname_main(int argc ATTRIBUTE_UNUSED, char **argv)
delta = utsname_offset;
do {
if (toprint & 1) {
/* printf would not be safe here */
fputs((char *)(&uname_info) + *delta, stdout);
printf(((char *)(&uname_info)) + *delta);
if (toprint > 1) {
bb_putchar(' ');
}
@@ -95,5 +98,5 @@ int uname_main(int argc ATTRIBUTE_UNUSED, char **argv)
} while (toprint >>= 1);
bb_putchar('\n');
fflush_stdout_and_exit(EXIT_SUCCESS); /* coreutils-6.9 compat */
fflush_stdout_and_exit(EXIT_SUCCESS);
}
+13 -12
View File
@@ -12,6 +12,8 @@
#include "libbb.h"
static const char uniq_opts[] ALIGN1 = "cdu" "f:s:" "cdu\0\1\2\4";
static FILE *xgetoptfile_uniq_s(char **argv, int read0write2)
{
const char *n;
@@ -29,11 +31,9 @@ int uniq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
FILE *in, *out;
unsigned long dups, skip_fields, skip_chars, i;
const char *s0, *e0, *s1, *e1, *input_filename;
unsigned long dups;
unsigned skip_fields, skip_chars, max_chars;
unsigned opt;
unsigned i;
enum {
OPT_c = 0x1,
@@ -41,14 +41,15 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
OPT_u = 0x4,
OPT_f = 0x8,
OPT_s = 0x10,
OPT_w = 0x20,
};
skip_fields = skip_chars = 0;
max_chars = -1;
opt_complementary = "f+:s+:w+";
opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars);
opt = getopt32(argv, "cduf:s:", &s0, &s1);
if (opt & OPT_f)
skip_fields = xatoul(s0);
if (opt & OPT_s)
skip_chars = xatoul(s1);
argv += optind;
input_filename = *argv;
@@ -62,7 +63,7 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
bb_show_usage();
}
s1 = e1 = NULL; /* prime the pump */
s1 = e1 = NULL; /* prime the pump */
do {
s0 = s1;
@@ -70,7 +71,7 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
dups = 0;
/* gnu uniq ignores newlines */
while ((s1 = xmalloc_fgetline(in)) != NULL) {
while ((s1 = xmalloc_getline(in)) != NULL) {
e1 = s1;
for (i = skip_fields; i; i--) {
e1 = skip_whitespace(e1);
@@ -80,16 +81,16 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
++e1;
}
if (!s0 || strncmp(e0, e1, max_chars)) {
if (!s0 || strcmp(e0, e1)) {
break;
}
++dups; /* note: testing for overflow seems excessive. */
++dups; /* Note: Testing for overflow seems excessive. */
}
if (s0) {
if (!(opt & (OPT_d << !!dups))) { /* (if dups, opt & OPT_e) */
fprintf(out, "\0%ld " + (opt & 1), dups + 1); /* 1 == OPT_c */
fprintf(out, "\0%d " + (opt & 1), dups + 1);
fprintf(out, "%s\n", s0);
}
free((void *)s0);
+2 -2
View File
@@ -18,7 +18,7 @@ static void read_stduu(FILE *src_stream, FILE *dst_stream)
{
char *line;
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
while ((line = xmalloc_getline(src_stream)) != NULL) {
int encoded_len, str_len;
char *line_ptr, *dst;
@@ -151,7 +151,7 @@ int uudecode_main(int argc ATTRIBUTE_UNUSED, char **argv)
src_stream = xfopen_stdin(*argv);
/* Search for the start of the encoding */
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
while ((line = xmalloc_getline(src_stream)) != NULL) {
void (*decode_fn_ptr)(FILE * src, FILE * dst);
char *line_ptr;
FILE *dst_stream;
+1 -5
View File
@@ -56,20 +56,16 @@ int who_main(int argc ATTRIBUTE_UNUSED, char **argv)
printf("USER TTY IDLE TIME HOST\n");
while ((ut = getutent()) != NULL) {
if (ut->ut_user[0] && (opt || ut->ut_type == USER_PROCESS)) {
time_t tmp;
/* ut->ut_line is device name of tty - "/dev/" */
name = concat_path_file("/dev", ut->ut_line);
str6[0] = '?';
str6[1] = '\0';
if (stat(name, &st) == 0)
idle_string(str6, st.st_atime);
/* manpages say ut_tv.tv_sec *is* time_t,
* but some systems have it wrong */
tmp = ut->ut_tv.tv_sec;
/* 15 chars for time: Nov 10 19:33:20 */
printf("%-10s %-8s %-9s %-15.15s %s\n",
ut->ut_user, ut->ut_line, str6,
ctime(&tmp) + 4, ut->ut_host);
ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host);
if (ENABLE_FEATURE_CLEAN_UP)
free(name);
}
+11 -30
View File
@@ -9,53 +9,34 @@
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
/* Coreutils 6.12 man page says:
* mktemp [OPTION]... [TEMPLATE]
* Create a temporary file or directory, safely, and print its name. If
* TEMPLATE is not specified, use tmp.XXXXXXXXXX.
* -d, --directory
* create a directory, not a file
* -q, --quiet
* suppress diagnostics about file/dir-creation failure
* -u, --dry-run
* do not create anything; merely print a name (unsafe)
* --tmpdir[=DIR]
* interpret TEMPLATE relative to DIR. If DIR is not specified,
* use $TMPDIR if set, else /tmp. With this option, TEMPLATE must
* not be an absolute name. Unlike with -t, TEMPLATE may contain
* slashes, but even here, mktemp still creates only the final com-
* ponent.
* -p DIR use DIR as a prefix; implies -t [deprecated]
* -t interpret TEMPLATE as a single file name component, relative to
* a directory: $TMPDIR, if set; else the directory specified via
* -p; else /tmp [deprecated]
*/
#include "libbb.h"
int mktemp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mktemp_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
// -d Make a directory instead of a file
// -q Fail silently if an error occurs [bbox: ignored]
// -t Generate a path rooted in temporary directory
// -p DIR Use DIR as a temporary directory (implies -t)
const char *path;
char *chp;
unsigned opt;
unsigned flags;
opt_complementary = "?1"; /* 1 argument max */
opt = getopt32(argv, "dqtp:", &path);
chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
opt_complementary = "=1"; /* exactly one arg */
flags = getopt32(argv, "dqtp:", &path);
chp = argv[optind];
if (opt & (4|8)) { /* -t and/or -p */
if (flags & (4|8)) { /* -t and/or -p */
const char *dir = getenv("TMPDIR");
if (dir && *dir != '\0')
path = dir;
else if (!(opt & 8)) /* no -p */
else if (!(flags & 8)) /* No -p */
path = "/tmp/";
/* else path comes from -p DIR */
chp = concat_path_file(path, chp);
}
if (opt & 1) { /* -d */
if (flags & 1) { /* -d */
if (mkdtemp(chp) == NULL)
return EXIT_FAILURE;
} else {
+6 -2
View File
@@ -30,6 +30,8 @@
* -u MASK umask. Set the umask of the program executed to MASK.
*/
#include <getopt.h>
#include "libbb.h"
struct globals {
@@ -42,7 +44,7 @@ struct globals {
#define cur (G.cur )
#define cmd (G.cmd )
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(struct globals)) / sizeof(cmd[0]) };
enum {
OPT_r = (1 << 0),
@@ -130,7 +132,9 @@ int run_parts_main(int argc ATTRIBUTE_UNUSED, char **argv)
n = 1;
while (arg_list && n < NUM_CMD) {
cmd[n++] = llist_pop(&arg_list);
cmd[n] = arg_list->data;
arg_list = arg_list->link;
n++;
}
/* cmd[n] = NULL; - is already zeroed out */
+74 -157
View File
@@ -8,53 +8,8 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/*
This is how it is supposed to work:
start-stop-daemon [OPTIONS] [--start|--stop] [[--] arguments...]
One (only) of these must be given:
-S,--start Start
-K,--stop Stop
Search for matching processes.
If --stop is given, stop all matching processes (by sending a signal).
If --start is given, start a new process unless a matching process was found.
Options controlling process matching
(if multiple conditions are specified, all must match):
-u,--user USERNAME|UID Only consider this user's processes
-n,--name PROCESS_NAME Look for processes by matching PROCESS_NAME
with comm field in /proc/$PID/stat.
Only basename is compared:
"ntpd" == "./ntpd" == "/path/to/ntpd".
[TODO: can PROCESS_NAME be a full pathname? Should we require full match then
with /proc/$PID/exe or argv[0] (comm can't be matched, it never contains path)]
-x,--exec EXECUTABLE Look for processes that were started with this
command in /proc/$PID/cmdline.
Unlike -n, we match against the full path:
"ntpd" != "./ntpd" != "/path/to/ntpd"
-p,--pidfile PID_FILE Look for processes with PID from this file
Options which are valid for --start only:
-x,--exec EXECUTABLE Program to run (1st arg of execvp). Mandatory.
-a,--startas NAME argv[0] (defaults to EXECUTABLE)
-b,--background Put process into background
-N,--nicelevel N Add N to process' nice level
-c,--chuid USER[:[GRP]] Change to specified user [and group]
-m,--make-pidfile Write PID to the pidfile
(both -m and -p must be given!)
Options which are valid for --stop only:
-s,--signal SIG Signal to send (default:TERM)
-t,--test Exit with status 0 if process is found
(we don't actually start or stop daemons)
Misc options:
-o,--oknodo Exit with status 0 if nothing is done
-q,--quiet Quiet
-v,--verbose Verbose
*/
/* NB: we have a problem here with /proc/NN/exe usage, similar to
* one fixed in killall/pidof */
#include <sys/resource.h>
@@ -67,26 +22,6 @@ struct pid_list {
pid_t pid;
};
enum {
CTX_STOP = (1 << 0),
CTX_START = (1 << 1),
OPT_BACKGROUND = (1 << 2), // -b
OPT_QUIET = (1 << 3), // -q
OPT_TEST = (1 << 4), // -t
OPT_MAKEPID = (1 << 5), // -m
OPT_a = (1 << 6), // -a
OPT_n = (1 << 7), // -n
OPT_s = (1 << 8), // -s
OPT_u = (1 << 9), // -u
OPT_c = (1 << 10), // -c
OPT_x = (1 << 11), // -x
OPT_p = (1 << 12), // -p
OPT_OKNODO = (1 << 13) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
OPT_VERBOSE = (1 << 14) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
OPT_NICELEVEL = (1 << 15) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
};
#define QUIET (option_mask32 & OPT_QUIET)
#define TEST (option_mask32 & OPT_TEST)
struct globals {
struct pid_list *found;
@@ -95,7 +30,9 @@ struct globals {
char *execname;
char *pidfile;
int user_id;
smallint quiet;
smallint signal_nr;
struct stat execstat;
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#define found (G.found )
@@ -104,23 +41,22 @@ struct globals {
#define execname (G.execname )
#define pidfile (G.pidfile )
#define user_id (G.user_id )
#define quiet (G.quiet )
#define signal_nr (G.signal_nr )
#define INIT_G() do { \
user_id = -1; \
signal_nr = 15; \
} while (0)
#define execstat (G.execstat )
#define INIT_G() \
do { \
user_id = -1; \
signal_nr = 15; \
} while (0)
#ifdef OLDER_VERSION_OF_X
/* -x,--exec EXECUTABLE
* Look for processes with matching /proc/$PID/exe.
* Match is performed using device+inode.
*/
static int pid_is_exec(pid_t pid)
{
struct stat st;
char buf[sizeof("/proc//exe") + sizeof(int)*3];
sprintf(buf, "/proc/%u/exe", (unsigned)pid);
sprintf(buf, "/proc/%u/exe", pid);
if (stat(buf, &st) < 0)
return 0;
if (st.st_dev == execstat.st_dev
@@ -128,29 +64,24 @@ static int pid_is_exec(pid_t pid)
return 1;
return 0;
}
#endif
static int pid_is_exec(pid_t pid)
static int pid_is_user(int pid)
{
ssize_t bytes;
char buf[PATH_MAX];
struct stat sb;
char buf[sizeof("/proc/") + sizeof(int)*3];
sprintf(buf, "/proc/%u/cmdline", (unsigned)pid);
bytes = open_read_close(buf, buf, sizeof(buf) - 1);
if (bytes > 0) {
buf[bytes] = '\0';
return strcmp(buf, execname) == 0;
}
return 0;
sprintf(buf, "/proc/%u", pid);
if (stat(buf, &sb) != 0)
return 0;
return (sb.st_uid == user_id);
}
static int pid_is_name(pid_t pid)
static int pid_is_cmd(pid_t pid)
{
/* /proc/PID/stat is "PID (comm_15_bytes_max) ..." */
char buf[32]; /* should be enough */
char buf[256]; /* is it big enough? */
char *p, *pe;
sprintf(buf, "/proc/%u/stat", (unsigned)pid);
sprintf(buf, "/proc/%u/stat", pid);
if (open_read_close(buf, buf, sizeof(buf) - 1) < 0)
return 0;
buf[sizeof(buf) - 1] = '\0'; /* paranoia */
@@ -161,23 +92,7 @@ static int pid_is_name(pid_t pid)
if (!pe)
return 0;
*pe = '\0';
/* we require comm to match and to not be truncated */
/* in Linux, if comm is 15 chars, it may be a truncated
* name, so we don't allow that to match */
if (strlen(p) >= COMM_LEN - 1) /* COMM_LEN is 16 */
return 0;
return strcmp(p, cmdname) == 0;
}
static int pid_is_user(int pid)
{
struct stat sb;
char buf[sizeof("/proc/") + sizeof(int)*3];
sprintf(buf, "/proc/%u", (unsigned)pid);
if (stat(buf, &sb) != 0)
return 0;
return (sb.st_uid == (uid_t)user_id);
return !strcmp(p, cmdname);
}
static void check(int pid)
@@ -187,10 +102,10 @@ static void check(int pid)
if (execname && !pid_is_exec(pid)) {
return;
}
if (cmdname && !pid_is_name(pid)) {
if (userspec && !pid_is_user(pid)) {
return;
}
if (userspec && !pid_is_user(pid)) {
if (cmdname && !pid_is_cmd(pid)) {
return;
}
p = xmalloc(sizeof(*p));
@@ -227,11 +142,10 @@ static void do_procinit(void)
procdir = xopendir("/proc");
pid = 0;
while (1) {
while(1) {
errno = 0; /* clear any previous error */
entry = readdir(procdir);
// TODO: this check is too generic, it's better
// to check for exact errno(s) which mean that we got stale entry
// TODO: check for exact errno(s) which mean that we got stale entry
if (errno) /* Stale entry, process has died after opendir */
continue;
if (!entry) /* EOF, no more entries */
@@ -258,33 +172,32 @@ static int do_stop(void)
} else if (execname) {
if (ENABLE_FEATURE_CLEAN_UP) what = xstrdup(execname);
if (!ENABLE_FEATURE_CLEAN_UP) what = execname;
} else if (pidfile) {
} else if (pidfile)
what = xasprintf("process in pidfile '%s'", pidfile);
} else if (userspec) {
else if (userspec)
what = xasprintf("process(es) owned by '%s'", userspec);
} else {
else
bb_error_msg_and_die("internal error, please report");
}
if (!found) {
if (!QUIET)
if (!quiet)
printf("no %s found; none killed\n", what);
killed = -1;
goto ret;
}
for (p = found; p; p = p->next) {
if (TEST || kill(p->pid, signal_nr) == 0) {
if (kill(p->pid, signal_nr) == 0) {
p->pid = - p->pid;
killed++;
} else {
p->pid = 0;
bb_perror_msg("warning: killing process %u", (unsigned)p->pid);
bb_perror_msg("warning: killing process %u", p->pid);
}
}
if (!QUIET && killed) {
if (!quiet && killed) {
printf("stopped %s (pid", what);
for (p = found; p; p = p->next)
if (p->pid)
printf(" %u", (unsigned)p->pid);
if (p->pid < 0)
printf(" %u", - p->pid);
puts(")");
}
ret:
@@ -299,7 +212,6 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
"start\0" No_argument "S"
"background\0" No_argument "b"
"quiet\0" No_argument "q"
"test\0" No_argument "t"
"make-pidfile\0" No_argument "m"
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
"oknodo\0" No_argument "o"
@@ -319,6 +231,24 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
;
#endif
enum {
CTX_STOP = 0x1,
CTX_START = 0x2,
OPT_BACKGROUND = 0x4, // -b
OPT_QUIET = 0x8, // -q
OPT_MAKEPID = 0x10, // -m
OPT_a = 0x20, // -a
OPT_n = 0x40, // -n
OPT_s = 0x80, // -s
OPT_u = 0x100, // -u
OPT_c = 0x200, // -c
OPT_x = 0x400, // -x
OPT_p = 0x800, // -p
OPT_OKNODO = 0x1000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
OPT_VERBOSE = 0x2000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
OPT_NICELEVEL = 0x4000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
};
int start_stop_daemon_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
@@ -326,9 +256,6 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
char *signame;
char *startas;
char *chuid;
#ifdef OLDER_VERSION_OF_X
struct stat execstat;
#endif
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
// char *retry_arg = NULL;
// int retries = -1;
@@ -341,14 +268,9 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
applet_long_options = start_stop_daemon_longopts;
#endif
/* -K or -S is required; they are mutually exclusive */
/* -p is required if -m is given */
/* -xpun (at least one) is required if -K is given */
/* -xa (at least one) is required if -S is given */
/* -q turns off -v */
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa"
USE_FEATURE_START_STOP_DAEMON_FANCY("q-v");
opt = getopt32(argv, "KSbqtma:n:s:u:c:x:p:"
/* Check required one context option was given */
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa";
opt = getopt32(argv, "KSbqma:n:s:u:c:x:p:"
USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:"),
// USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"),
&startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
@@ -356,6 +278,8 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
// USE_FEATURE_START_STOP_DAEMON_FANCY(,&retry_arg)
);
quiet = (opt & OPT_QUIET) && !(opt & OPT_VERBOSE);
if (opt & OPT_s) {
signal_nr = get_signum(signame);
if (signal_nr < 0) bb_show_usage();
@@ -363,8 +287,6 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (!(opt & OPT_a))
startas = execname;
if (!execname) /* in case -a is given and -x is not */
execname = startas;
// USE_FEATURE_START_STOP_DAEMON_FANCY(
// if (retry_arg)
@@ -378,8 +300,10 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (errno)
user_id = xuname2uid(userspec);
}
/* Both start and stop need to know current processes */
do_procinit();
if (execname)
xstat(execname, &execstat);
do_procinit(); /* Both start and stop needs to know current processes */
if (opt & CTX_STOP) {
int i = do_stop();
@@ -387,22 +311,14 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
if (found) {
if (!QUIET)
printf("%s is already running\n%u\n", execname, (unsigned)found->pid);
if (!quiet)
printf("%s already running\n%d\n", execname, found->pid);
return !(opt & OPT_OKNODO);
}
#ifdef OLDER_VERSION_OF_X
if (execname)
xstat(execname, &execstat);
#endif
*--argv = startas;
if (opt & OPT_BACKGROUND) {
#if BB_MMU
bb_daemonize(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS);
/* DAEMON_DEVNULL_STDIO is superfluous -
* it's always done by bb_daemonize() */
bb_daemonize(0);
#else
pid_t pid = vfork();
if (pid < 0) /* error */
@@ -411,20 +327,21 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
/* parent */
/* why _exit? the child may have changed the stack,
* so "return 0" may do bad things */
_exit(EXIT_SUCCESS);
_exit(0);
}
/* Child */
/* child */
setsid(); /* detach from controlling tty */
/* Redirect stdio to /dev/null, close extra FDs.
* We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO
bb_daemonize_or_rexec(
DAEMON_DEVNULL_STDIO
+ DAEMON_CLOSE_EXTRA_FDS
+ DAEMON_ONLY_SANITIZE,
NULL /* argv, unused */ );
#endif
}
if (opt & OPT_MAKEPID) {
/* User wants _us_ to make the pidfile */
/* user wants _us_ to make the pidfile */
write_pidfile(pidfile);
}
if (opt & OPT_c) {
@@ -442,6 +359,6 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
}
#endif
execvp(startas, argv);
execv(startas, argv);
bb_perror_msg_and_die("cannot start %s", startas);
}
+12 -52
View File
@@ -13,69 +13,30 @@
#include "libbb.h"
int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int which_main(int argc ATTRIBUTE_UNUSED, char **argv)
int which_main(int argc, char **argv)
{
USE_DESKTOP(int opt;)
int status = EXIT_SUCCESS;
char *path;
char *p;
opt_complementary = "-1"; /* at least one argument */
USE_DESKTOP(opt =) getopt32(argv, "a");
argv += optind;
/* This matches what is seen on e.g. ubuntu.
* "which" there is a shell script. */
path = getenv("PATH");
if (!path) {
path = (char*)bb_PATH_root_path;
putenv(path);
path += 5; /* skip "PATH=" */
if (argc <= 1 || argv[1][0] == '-') {
bb_show_usage();
}
do {
#if ENABLE_DESKTOP
/* Much bloat just to support -a */
if (strchr(*argv, '/')) {
if (execable_file(*argv)) {
puts(*argv);
continue;
}
status = EXIT_FAILURE;
} else {
char *path2 = xstrdup(path);
char *tmp = path2;
/* This matches what is seen on e.g. ubuntu
* "which" there is a shell script */
if (!getenv("PATH")) {
putenv((char*)bb_PATH_root_path);
}
p = find_execable(*argv, &tmp);
if (!p)
status = EXIT_FAILURE;
else {
print:
puts(p);
free(p);
if (opt) {
/* -a: show matches in all PATH components */
if (tmp) {
p = find_execable(*argv, &tmp);
if (p)
goto print;
}
}
}
free(path2);
}
#else
/* Just ignoring -a */
while (--argc > 0) {
argv++;
if (strchr(*argv, '/')) {
if (execable_file(*argv)) {
puts(*argv);
continue;
}
} else {
char *path2 = xstrdup(path);
char *tmp = path2;
p = find_execable(*argv, &tmp);
free(path2);
p = find_execable(*argv);
if (p) {
puts(p);
free(p);
@@ -83,8 +44,7 @@ int which_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
}
status = EXIT_FAILURE;
#endif
} while (*(++argv) != NULL);
}
fflush_stdout_and_exit(status);
}
+1 -1
View File
@@ -17,7 +17,7 @@ your embedded systems. To create a working system, just add some device
nodes in /dev, a few configuration files in /etc, and a Linux kernel.</p>
<p>BusyBox is maintained by
<a href="mailto:vda.linux@googlemail.com">Denys Vlasenko</a>,
<a href="mailto:vda.linux@googlemail.com">Denis Vlasenko</a>,
and licensed under the <a href="/license.html">GNU GENERAL PUBLIC LICENSE</a>
version 2.</p>
-3
View File
@@ -14,9 +14,6 @@ Also there are patches on top of latest bug fix release.
<p>
Latest releases and patch directories for each branch:
<br>
<a href=http://busybox.net/downloads/busybox-1.10.1.tar.bz2>1.10.1</a>,
<a href=http://busybox.net/downloads/fixes-1.10.1/>patches</a>,
<br>
<a href=http://busybox.net/downloads/busybox-1.9.2.tar.bz2>1.9.2</a>,
<a href=http://busybox.net/downloads/fixes-1.9.2/>patches</a>,
<br>
+1 -1
View File
@@ -16,7 +16,7 @@
<br>
Mail all comments, insults, suggestions and bribes to
<br>
Denys Vlasenko <a href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a><br>
Denis Vlasenko <a href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a><br>
</font>
</td>
+7 -8
View File
@@ -65,7 +65,7 @@
<ul>
<li><a href="/cgi-bin/viewcvs.cgi/trunk/busybox/">Browse Source</a></li>
<li><a href="subversion.html">Source Control</a></li>
<!--li><a href="/downloads/patches/recent.html">Recent Changes</a></li-->
<li><a href="/downloads/patches/recent.html">Recent Changes</a></li>
<li><a href="lists.html">Mailing Lists</a></li>
<li><a href="http://bugs.busybox.net/">Bug Tracking</a></li>
</ul>
@@ -79,13 +79,12 @@
<ul>
<li><a href="http://busybox.net/~landley">Rob</a></li>
<li><a href="http://busybox.net/~aldot">Bernhard</a></li>
<li><a href="http://busybox.net/~vda">Denys</a>
<br>- <a href=http://busybox.net/~vda/resume/denys_vlasenko.htm>resume</a>
<br>- <a href=http://busybox.net/~vda/mboot/>mboot</a>
<br>- <a href=http://busybox.net/~vda/linld/>linld</a>
<br>- <a href=http://busybox.net/~vda/init_vs_runsv.html>init must die</a>
<br>- <a href=http://busybox.net/~vda/no_ifup.txt>no ifup</a>
<br>- <a href=http://busybox.net/~vda/unscd/>unscd</a>
<li><a href="http://busybox.net/~vda">Denis</a>
<br>-<a href=http://busybox.net/~vda/mboot/>mboot</a>
<br>-<a href=http://busybox.net/~vda/linld/>linld</a>
<br>-<a href=http://busybox.net/~vda/init_vs_runsv.html>init must die</a>
<br>-<a href=http://busybox.net/~vda/no_ifup.txt>no ifup</a>
<br>-<a href=http://busybox.net/~vda/unscd/>unscd</a>
</li>
</ul>
+801 -60
View File
@@ -1,63 +1,6 @@
<!--#include file="header.html" -->
<ul>
<li><b>12 June 2008 -- Sponsors!</b>
<p>We want to thank the following companies which are providing support
for BusyBox project:
<ul>
<li>AOE media, a <a href=http://www.aoemedia.com/typo3-development.html>
TYPO3 development agency</a> contributes financially.
<p>
<li><a href=http://www.analog.com/en/>Analog Devices, Inc.</a> provided
a <a href=http://docs.blackfin.uclinux.org/doku.php?id=bf537_quick_start>
Blackfin development board</a> free of charge.
<a href=http://www.analog.com/blackfin>Blackfin<a>
is a NOMMU processor, and its availability for testing is invaluable.
If you are an embedded device developer,
please note that Analog Devices has entire Linux distribution available
for download for this board. Visit
<a href=http://blackfin.uclinux.org/>http://blackfin.uclinux.org/</a>
for more information.
</ul>
</p>
<li><b>5 June 2008 -- BusyBox 1.10.3 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.3.tar.bz2>BusyBox 1.10.3</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.10.3/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>
Bugfix-only release for 1.10.x branch. It contains fixes for dnsd, fuser, hush,
ip, mdev and syslogd.
<p>
<a href=http://busybox.net/~vda/HOWTO/i486-linux-uclibc/HOWTO.txt>
How to build static busybox for i486-linux-uclibc</a>
<p>
The email address gpl@busybox.net is the recommended way to contact
the Software Freedom Law Center to report BusyBox license violations.
</p>
<li><b>8 May 2008 -- BusyBox 1.10.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.2.tar.bz2>BusyBox 1.10.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.10.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>
Bugfix-only release for 1.10.x branch. It contains fixes for echo, httpd, pidof,
start-stop-daemon, tar, taskset, tab completion in shells, build system.
<p>Please note that mdev was backported from current svn trunk. Please
report if you encounter any problems with it.
</p>
<li><b>19 April 2008 -- BusyBox 1.10.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.1.tar.bz2>BusyBox 1.10.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.10.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>
Bugfix-only release for 1.10.x branch. It contains fixes for
fuser, init, less, nameif, tail, taskset, tcpudp, top, udhcp.
<li><b>21 March 2008 -- BusyBox 1.10.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.0.tar.bz2>BusyBox 1.10.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
@@ -191,7 +134,7 @@ iproute_list_or_flush 3680 readhere 2308
<li>tail: fix "tail -c 20 /dev/huge_disk" (was taking ages)
<li>tar: compat: handle tarballs with only one zero block at the end
<li>tar: autodetection of gz/bz2 compressed tarballs. Closes bug 992
<li>tar: real support for -p. By Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>tar: real support for -p. By Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>tcpudp: narrow down time window where we have no wildcard socket
<li>telnetd: use login always, not "sometimes login, sometimes shell"
<li>test: fix mishandling of "test ! arg1 op arg2 more args"
@@ -209,11 +152,11 @@ iproute_list_or_flush 3680 readhere 2308
<li>unzip: handle short reads correctly
<li>vi: many fixes
<li>zcip: don't chdir to root
<li>zcip: open ARP socket before openlog (else we can trash syslog socket)
<li>zcip: open ARP socket before openlog (else we can thrash syslog socket)
</ul>
</p>
<li><b>21 March 2008 -- BusyBox old stable releases</b>
<li><b>21 March 2008 -- BusyBox stable releases</b>
<p>
Bugfix-only releases for four past branches. Links to locations
for future hot patches are in parentheses.
@@ -235,6 +178,804 @@ iproute_list_or_flush 3680 readhere 2308
the Software Freedom Law Center to report BusyBox license violations.
</p>
<li><b>12 February 2008 -- BusyBox 1.9.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.1.tar.bz2>BusyBox 1.9.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to fsck,
iproute, mdev, mkswap, msh, nameif, stty, test, zcip.</p>
<p>hush has `command` expansion re-enabled for NOMMU, although it is
inherently unsafe (by virtue of NOMMU's use of vfork instead of fork).
The plan is to make this less likely to bite people in future versions.</p>
</li>
<li><b>24 December 2007 -- BusyBox 1.9.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.0.tar.bz2>BusyBox 1.9.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Sizes of busybox-1.8.2 and busybox-1.9.0 (with almost full config, static uclibc build):<pre>
text data bss dec hex filename
792796 978 9724 803498 c42aa busybox-1.8.2
783803 683 7508 791994 c15ba busybox-1.9.0
</pre>
<p>Top 10 stack users:<pre>
busybox-1.8.2: busybox-1.9.0:
input_tab 10428 echo_dg 4116
umount_main 8252 bb_full_fd_action 4112
rtnl_talk 8240 discard_dg 4096
xrtnl_dump_filter 8240 echo_stream 4096
sendMTFValues 5316 discard_stream 4096
mainSort 4700 find_list_entry2 4096
mkfs_minix_main 4288 readlink_main 4096
grave 4260 ipaddr_list_or_flush 3900
unix_do_one 4156 iproute_list_or_flush 3680
parse_prompt 4132 insmod_main 3152
</pre>
<p>lash is deleted from this release. hush can be configured down to almost
the same size, but it is significantly less buggy. It even works
on NOMMU machines (interactive mode and backticks are not working on NOMMU,
though). "lash" applet is still available, but it runs hush.
<p>init has some changes in this release, please report if it causes
problems for you.
<p>Changes since previous release:
<ul>
<li>Build system improvements
<li>Testsuite additions
<li>Stack size reductions, code size reductions, data/bss reductions
<li>An option to prefer IPv4 address if host has both
<li>New applets: hd, sestatus
<li>Removed applets: lash
<li>hush: fixed a few bugs, wired up echo and test to be builtins
<li>init: simplify forking of children
<li>getty: special handling of '#' and '@' is removed
<li>[su]login: sanitize environment if called by non-root
<li>udhcpc: support "bad" servers which send oversized packets
(Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>udhcpc: -O option allows to specify which options to ask for
(Stefan Hellermann &lt;stefan at the2masters.de&gt;)
<li>udhcpc: optionally check whether given IP is really free (by ARP ping)
(Jonas Danielsson &lt;jonas.danielsson at axis.com&gt;)
<li>vi: now handles files with unlimited line length
<li>vi: speedup for huge line lengths
<li>vi: Del key works
<li>sed: support GNUism '\t'
<li>cp/mv/install: optionally use bigger buffer for bulk copying
<li>line editing: don't eat stack like crazy
<li>passwd: follows symlinked /etc/passwd
<li>renice: accepts priority with +N too
<li>netstat: wide output mode
<li>nameif: extended matching (Nico Erfurth &lt;masta at perlgolf.de&gt;)
<li>test: become NOFORK applet
<li>find: -iname (Alexander Griesser &lt;alexander.griesser at lkh-vil.or.at&gt;)
<li>df: -i option (show inode info) (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
<li>hexdump: -R option (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
</ul>
</p>
<li><b>23 November 2007 -- BusyBox 1.8.2 (stable), BusyBox 1.7.4 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.2.tar.bz2>BusyBox 1.8.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p><a href=http://busybox.net/downloads/busybox-1.7.4.tar.bz2>BusyBox 1.7.4</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.4/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>These are bugfix-only releases.
1.8.2 contains fixes for inetd, lash, tar, tr, and build system.
1.7.4 contains a fix for inetd.</p>
</li>
<li><b>9 November 2007 -- BusyBox 1.8.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.1.tar.bz2>BusyBox 1.8.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to login (PAM), modprobe, syslogd, telnetd, unzip.</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.8.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.0.tar.bz2>BusyBox 1.8.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Note: this is probably the very last release with lash. It will be dropped. Please migrate to hush.
<p>Applets which had many changes since 1.7.x:
<p>httpd:
<ul>
<li>does not clear environment, CGIs will see all environment variables which were set for httpd
<li>fix bug where we were trying to read more POSTDATA than content-length
<li>fix trivial bug (spotted by Alex Landau)
<li>optional support for partial downloads
<li>simplified CGI i/o loop (now it looks good to me)
<li>small auth and IPv6 fixes (Kim B. Heino &lt;Kim.Heino at bluegiga.com>)
<li>support for proxying connection to other http server (by Alex Landau &lt;landau_alex at yahoo.com>)
</ul>
<p>top:
<ul>
<li>TOPMEM feature - 's(how sizes)' command
<li>don't wait before final bailout (try top -b -n1)
<li>fix for command line wrapping
</ul>
<p>Build system improvements: libbusybox mode restored (it was lost in transition to new makefiles).
<p>Code and data size in comparison with 1.7.3:<pre>
Equivalent .config, i386 uclibc static builds:
text data bss dec hex filename
768123 1055 10768 779946 be6aa busybox-1.7.3/busybox
759693 974 9420 770087 bc027 busybox-1.8.0/busybox</pre>
<p>New applets:
<ul>
<li>microcom: new applet by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;
<li>kbd_mode: new applet by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>bzip2: port bzip2 1.0.4 to busybox, 9 kb of code
<li>pgrep, pkill: new applets by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>setsebool: new applet (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
</ul>
<p>Other changes since previous release (abridged):
<ul>
<li>cp: -r and -R imply -d (coreutils compat)
<li>cp: detect and prevent infinite recursion
<li>cp: make it a bit closer to POSIX, but still refuse to open and overwrite symbolic link
<li>hdparm: reduce possibility of numeric overflow in -T
<li>hdparm: simplify timing measurement
<li>wget: -O FILE is allowed to overwrite existing file (compat)
<li>wget: allow dots in header field names
<li>telnetd: add -K option to close sessions as soon as child exits
<li>telnetd: don't SIGKILL child when closing the session, kernel will send SIGHUP for us
<li>ed: large cleanup, add line editing
<li>hush: feeble attempt at making it more NOMMU-friendly
<li>hush: fix glob()
<li>hush: stop doing manual accounting of open fd's, kernel can do it for us
<li>adduser: implement -S and fix uid selection
<li>ash: fix prompt expansion (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>ash: revert "cat | jobs" fix, it causes more problems than good
<li>find: fix -xdev behavior in the presence of two or more nested mount points
<li>grep: fix grep -F -e str1 -e str2 (was matching str2 only)
<li>grep: optimization: stop on first -e match
<li>gunzip: support concatenated gz files
<li>inetd: fix bug 1562 "inetd does not set argv[0] properly" (fix by Ilya Panfilov)
<li>install: 'support' (by ignoring) -v and -b
<li>install: fix bug in "install -c file dir" (tried to copy dir into dir too)
<li>ip: tunnel parameter parsing fix by Jean Wolter &lt;jw5 at os.inf.tu-dresden.de&gt;
<li>isrv: use monotonic_sec
<li>less: make 'f' key page forward
<li>libiproute: add missing break statements
<li>load_policy: update (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>logger: fix a problem of losing all argv except first
<li>login: do reject wrong passwords with PAM auth
<li>losetup: support -f (Loic Grenie &lt;loic.grenie at gmail.com&gt;)
<li>fdisk: make fdisk compile on libc without llseek64
<li>libbb: by popular request allow PATH to be customized at build time
<li>mkswap: selinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>mount: allow (and ignore) -i
<li>mount: ignore NFS bg option on NOMMU machines
<li>mount: mount helpers support (by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;)
<li>passwd: handle Ctrl-C, restore termios on Ctrl-C
<li>passwd: SELinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>ping: make -I ethN work too (-I addr already worked)
<li>ps: fix RSS parsing (rss field in /proc/PID/stat is in pages, not bytes)
<li>read_line_input: fix it to not do any fancy editing if echoing is disabled
<li>run_parts: make it sort executables by name (required by API)
<li>runsv: do not use clock_gettime if !MONOTONIC_CLOCK
<li>runsvdir: fix "linear wait time" bug
<li>sulogin: remove alarm handling, it is redundant there
<li>svlogd: compat: svlogd -tt should timestamp stderr too
<li>syslogd: bail out if you see null read from Unix socket
<li>syslogd: do not need to poll(), we can just block in read()
<li>tail: work correctly on /proc files (Kazuo TAKADA &lt;kztakada at sm.sony.co.jp&gt;)
<li>tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>tar: strip leading '/' BEFORE memorizing hardlink's name
<li>tftp: fix infinite retry bug
<li>umount: support (by ignoring) -i; style fixes
<li>unzip: fix endianness bugs
<li>vi: don't wait 50 ms before reading ESC sequences
<li>watchdog: allow millisecond spec (-t 250ms)
<li>zcip: fix unaligned trap on ARM
</ul>
</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.7.3 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.3.tar.bz2>BusyBox 1.7.3</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.3/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail.</p>
</li>
<li><b>30 September 2007 -- BusyBox 1.7.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.2.tar.bz2>BusyBox 1.7.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to install, find, login, httpd, runsvdir, chcon, setfiles, fdisk and line editing.</p>
</li>
<li><b>16 September 2007 -- BusyBox 1.7.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.1.tar.bz2>BusyBox 1.7.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to cp, runsv, tar, busybox --install and build system.</p>
</li>
<li><b>24 August 2007 -- BusyBox 1.7.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.0.tar.bz2>BusyBox 1.7.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Applets which had many changes since 1.6.x:
<p>httpd:
<ul>
<li>works in standalone mode on NOMMU machines now (partly by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>indexer example is rewritten in C
<li>optional support for error pages (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>stop reading headers using 1-byte reads
<li>new option -v[v]: prints client addresses, HTTP codes returned, URLs
<li>extended -p PORT to -p [IP[v6]:]PORT
<li>sendfile support (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>add support for Status: CGI header
<li>fix CGI handling bug (we were closing wrong fd)
<li>CGI I/O loop still doesn't look 100% ok to me...
</ul>
<p>udhcp[cd]:
<ul>
<li>add -f "foreground" and -S "syslog" options
<li>fixed "ifupdown + udhcpc_without_pidfile_creation" bug
<li>new config option "Rewrite the lease file at every new acknowledge" (Mats Erik Andersson &lt;mats at blue2net.com&gt; (Blue2Net AB))
<li>consistently treat server_config.start/end IPs as host-order
<li>fix IP parsing for 64bit machines
<li>fix unsafe hton macro usage in read_opt()
<li>do not chdir to / when daemonizing
</ul>
<p>top, ps, killall, pidof:
<ul>
<li>simpler loadavg processing
<li>truncate usernames to 8 chars
<li>fix non-CONFIG_DESKTOP ps -ww (by rockeychu)
<li>improve /proc/PID/cmdinfo reading code
<li>use cmdline, not comm field (fixes problems with re-execed applets showing as processes with name "exe", and not being found by pidof/killall by applet name)
<li>reduce CPU usage in decimal conversion (optional) (corresponding speedup on kernel side is accepted in mainline Linux kernel, yay!)
<li>make percentile (0.1%) calculations configurable
<li>add config option and code for global CPU% display
<li>reorder columns, so that [P]PIDs are together and VSZ/%MEM are together - makes more sense
</ul>
<p>Build system improvements: doesn't link against libraries we don't need,
generates verbose link output and map file, allows for custom link
scripts (useful for removing extra padding, among other things).
<p>Code and data size in comparison with 1.6.1:<pre>
Equivalent .config, i386 glibc dynamic builds:
text data bss dec hex filename
672671 2768 16808 692247 a9017 busybox-1.6.1/busybox
662948 2660 13528 679136 a5ce0 busybox-1.7.0/busybox
662783 2631 13416 678830 a5bae busybox-1.7.0/busybox.customld
Same .config built against static uclibc:
765021 1059 11020 777100 bdb8c busybox-1.7.0/busybox_uc</pre>
<p>Code/data shrink done in applets: crond, hdparm, dd, cal, od, nc, expr, uuencode,
test, slattach, diff, ping, tr, syslogd, hwclock, zcip, find, pidof, ash, uudecode,
runit/*, in libbb.
<p>New applets:
<ul>
<li>pscan, expand, unexpand (from Tito &lt;farmatito at tiscali.it&gt;)
<li>setfiles, restorecon (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>chpasswd (by Alexander Shishkin &lt;virtuoso at slind.org&gt;)
<li>slattach, ttysize
</ul>
<p>Unfortunately, not much work is done on shells. This was mostly stalled
by lack of time (read: laziness) on my part to learn how to adapt existing
qemu-runnable image for a NOMMU architechture (available on qemu website)
for local testing of cross-compiled busybox on my machine.
<p>Other changes since previous release (abridged):
<ul>
<li>addgroup: disallow addgroup -g num user group; make -g 0 work (Tito &lt;farmatito at tiscali.it&gt;)
<li>adduser: close /etc/{passwd,shadow} before calling passwd etc. Spotted by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>arping: -i should be -I, fixed
<li>ash: make "jobs | cat" work like in bash (was giving empty output)
<li>ash: recognize -l as --login equivalent; do not recognize +-login
<li>ash: fix buglet in DEBUG code (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ash: fix SEGV if type has zero parameters
<li>awk: fix -F 'regex' bug (miscounted fields if last field is empty)
<li>catv: catv without arguments was trying to use environ as argv (Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>catv: don't die on open error (emit warning)
<li>chown/chgrp: completely match coreutils 6.8 wrt symlink handling
<li>correct_password: do not print "no shadow passwd..." message
<li>crond: don't start sendmail with absolute path, don't report obsolete version (report true bbox version)
<li>dd: fix bug where we assume count=INT_MAX when count is unspecified
<li>devfsd: sanitization by Tito &lt;farmatito at tiscali.it&gt;
<li>echo: fix non-fancy echo
<li>fdisk: make it work with big disks (read: typical today's disks) even if CONFIG_LFS is unset
<li>find: -context support for SELinux (KaiGai Kohei &lt;kaigai at kaigai.gr.jp&gt;)
<li>find: add conditional support for -maxdepth and -regex, make -size match GNU find
<li>find: fix build failure on certain configs (found by Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one
<li>grep: implement -m MAX_MATCHES, fix buglets with context printing
<li>grep: fix selection done by FEATURE_GREP_EGREP_ALIAS (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: add missing dependencies (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: fix read builtin to not read ahead past EOL and to not use insane amounts of stack
<li>ifconfig: make it work with ifaces with interface no. &gt; 255
<li>ifup/ifdown: make location of ifstate configurable
<li>ifupdown: make netmask parsing smaller and more strict (was accepting 255.0.255.0, 255.1234.0.0 etc...)
<li>install: fix -s (strip) option, fix install a b /a/link/to/dir
<li>libbb: consolidate ARRAY_SIZE macro (Walter Harms &lt;wharms at bfs.de&gt;)
<li>libbb: make /etc/network parsing configurable. -200 bytes when off
<li>libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
<li>libbb: xioctl and friends by Tito &lt;farmatito at tiscali.it&gt;
<li>login: optional support for PAM
<li>login: make /etc/nologin support configurable (-240 bytes)
<li>login: ask passwords even for wrong usernames
<li>md5_sha1_sum: fix mishandling when run as /bin/md5sum
<li>mdev: add support for firmware loading
<li>mdev: work even when CONFIG_SYSFS_DEPRECATED in kernel is off
<li>modprobe: add scanning of /lib/modules/`uname -r`/modules.symbols (by Yann E. MORIN &lt;yann.morin.1998 at anciens.enib.fr&gt;)
<li>more: fixes by Tristan Schmelcher &lt;tpkschme at engmail.uwaterloo.ca&gt;
<li>nc: make connecting to IPv4 from IPv6-enabled hosts easier (was requiring -s local_addr)
<li>passwd: fix bug "updating shadow even if user's record is in passwd"
<li>patch: fix -p -1 handling
<li>patch: fix bad line ending handling (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
<li>ping: fix incorrect handling of -I (Iouri Kharon &lt;bc-info at styx.cabel.net&gt;)
<li>ping: fix non-fancy ping6
<li>printenv: fix "printenv VAR1 VAR2" bug (spotted by Kalyanatejaswi Balabhadrapatruni &lt;kalyanatejaswi at yahoo.co.in&gt;)
<li>ps: fix -Z (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>rpm: add optional support for bz2 data. +50 bytes of code
<li>rpm: fix bogus "package is not installed" case
<li>sed: fix 'q' command handling (by Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>start_stop_daemon: NOMMU fixes by Alex Landau &lt;landau_alex at yahoo.com&gt;
<li>stat: fix option -Z SEGV
<li>strings: strings a b was processing a twice, fix that
<li>svlogd: fix timestamping, do not warn if config is missing
<li>syslogd, logread: get rid of head pointer, fix logread bug in the process
<li>syslogd: do not convert tabs to ^I, set syslog IPC buffer to mode 0644
<li>tar: improve OLDGNU compat, make old SUN compat configurable
<li>test: fix testing primary expressions like '"-u" = "-u"'
<li>uudecode: fix to base64 decode by Jorgen Cederlof &lt;jcz at google.com&gt;
<li>vi: multiple fixes by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>wget: fix bug in base64 encoding (bug 1404). +10 bytes
<li>wget: lift 256 chars limitation on terminal width
<li>wget, zcip: use monotonic_sec instead of gettimeofday
</ul>
</p>
</li>
<li><b>30 June 2007 -- BusyBox 1.6.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.1.tar.bz2>BusyBox 1.6.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to echo, hush, and wget.</p>
</li>
<li><b>1 June 2007 -- BusyBox 1.6.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.0.tar.bz2>BusyBox 1.6.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.6.1 stable by testing 1.6.0.</p>
<p>Note that hush shell had many changes and (hopefully) is much improved now,
but there is a possibility that it regressed in some obscure cases. Please
report any such cases.</p>
<p>lash users please note: lash is going to be deprecated in busybox 1.7.0
and removed in the more distant future. Please migrate to hush.</p>
<p><a href=http://busybox.net/~vda/mem_usage-1.6.0.txt>Memory usage has decreased, but we can do better still</a></p>
<p>Other changes since previous release:
<ul>
<li>NOFORK: audit small applets and mark some of them as NOFORK. Put big scary warnings in relevant places
<li>NOFORK: factor out NOFORK/NOEXEC code from find. Use NOFORK/NOEXEC in find and xargs
<li>NOFORK: remove potential xmalloc from NOFORK path in bb_full_fd_action
<li>NOMMU: random fixes; compressed --help now works for NOMMU
<li>SELinux: load_policy applet
<li>[u]mount: extend -t option (Roy Marples &lt;uberlord at gentoo.org&gt;)
<li>addgroup: clean up, fix adding users to existing groups and make it optional (Tito)
<li>adduser: don't bomb out if shadow password file doesn't exist (from Tito &lt;farmatito at tiscali.it&gt;)
<li>applet.c: do not even try to read config if run by real root; fix suid config handling
<li>ash: fix infinite loop on exit if tty is not there anymore
<li>ash: fix kill -l (by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>ash: implement type -p, costs less than 10 bytes (patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>awk: don't segfault on printf(%*s). Closes bug 1337
<li>awk: guard against empty environment
<li>awk: some 'lineno' vars were shorts, made them ints (code got smaller)
<li>cat: stop using stdio.h opens
<li>config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
<li>cryptpw: new applet (by Thomas Lundquist &lt;lists at zelow.no&gt;)
<li>cttyhack: new applet
<li>dd: NOEXEC fix; fix skip= parse error (spotted by Dirk Clemens &lt;develop at cle-mens.de&gt;)
<li>deluser: add optional support for removing users from groups (by Tito &lt;farmatito at tiscali.it&gt;)
<li>diff: fix SEGV (NULL deref) in diff -N
<li>diff: fix segfault on empty dirs (Peter Korsgaard &lt;peter.korsgaard at barco.com&gt;)
<li>dnsd: fix several buglets, make smaller; openlog(), so that applet's name is logged
<li>dpkg: run_package_script() returns 0 if all ok and non-zero if failure. The result code was checked incorrectly in two places. (from Kim B. Heino &lt;Kim.Heino at bluegiga.com&gt;)
<li>dpkg: use bitfields which are a bit closer to typical short/char. Code size -800 bytes
<li>dumpleases: getopt32()-ization (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>e2fsprogs: stop using statics in chattr. Minor code shrinkage (-130 bytes)
<li>ether-wake: close bug 1317. Reorder fuctions to avoid forward refs while at it
<li>ether-wake: save a few more bytes of code
<li>find: -group, -depth (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: add support for -delete, -path (by Natanael Copa)
<li>find: fix -prune. Add big comment about it
<li>find: improve usage text (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: missed 'static' on const data; size and prune were mixed up; use index_in_str_array
<li>find: un-DESKTOPize (Kai Schwenzfeier &lt;niteblade at gmx.net&gt;)
<li>find_root_device: teach to deal with /dev/ subdirs (by Kirill K. Smirnov &lt;lich at math.spbu.ru&gt;)
<li>find_root_device: use lstat - don't follow links
<li>getopt32: fix llist_t options ordering. llist_rev is now unused
<li>getopt: use getopt32 for option parsing - inspired by patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;
<li>hdparm: fix multisector mode setting (from Toni Mirabete &lt;amirabete at catix.cat&gt;)
<li>hdparm: make -T -t code smaller (-194 bytes), and output prettier
<li>ifupdown: make it possible to use DHCP clients different from udhcp
<li>ifupdown: reread state file before rewriting it. Fixes "ifup started another ifup" state corruption bug. Patch by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>ifupdown: small optimization (avoid doing useless work if we are not going to update state file)
<li>ip: fix compilation if FEATURE_TR_CLASSES is off
<li>ip: mv ip*_main into ip.c; use a dispatcher to save on needless duplication. Saves a minor 12b
<li>ip: rewrite the ip applet to be less bloaty. Convert to index_in_(sub)str_array()
<li>ip: set the scope properly. Thanks to Jean Wolter
<li>iplink: shrink iplink; sanitize libiproute a bit (-916 bytes)
<li>iproute: shrink a bit (-200 bytes)
<li>kill: know much more signals; make code smaller; use common code for kill applet and ash kill builtin
<li>klogd: remove dependency on syslogd
<li>lash: "forking" applets are actually can be treated the same way as "non-forked". Also save a bit of space on trailing NULL array elements.
<li>lash: fix kill buglet (didn't properly recognize ESRCH)
<li>lash: make -c work; crush buffer overrun and free of non-malloced ptr (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>lash: recognize and use NOFORK applets
<li>less: fix case when regex search finds nothing; fix very obscure memory corruption bug; fix less &lt;HUGEFILE + [End] busy loop
<li>libbb: add xsendto, xunlink, xpipe
<li>libbb: fix segfault in reset_ino_dev_hashtable() when *hashtable was NULL
<li>libbb: make pidfile writing configurable
<li>libbb: make xsocket die with address family printed (if VERBOSE_RESOLUTION_ERRORS=y)
<li>libbb: rework NOMMU helper API so that it makes more sense and easier to use
<li>libiproute: audit callgraph, shortcut error paths into die() functions
<li>lineedit: do not try to open NULL history file
<li>lineedit: nuke two unused variables and code which sets them
<li>login: remove setpgrp call (makes it work from shell prompt again); sanitize stdio descriptors (we are suid, need to be careful!)
<li>login: shrink login and set_environment by ~100 bytes
<li>mount: fix incorrect usage of strtok (inadvertently used NULL sometimes)
<li>mount: fix mounting of symlinks (mount from util-linux allows that)
<li>msh: data/bss reduction (more than 9k of it); fix "underscore bug" (a_b=1111 didn't work); fix obscure case with backticks and closed fd 1
<li>nc: port nc 1.10 to busybox
<li>netstat: fix for bogus state value for raw sockets
<li>netstat: introduce -W: wide, ipv6-friendly output; shrink by ~500 bytes
<li>nmeter: should die if stdout doesn't like him anymore
<li>patch: do not try to delete same file twice
<li>ping: fix wrong sign extension of packet id (bug 1373)
<li>ps: add -o tty and -o rss support; make a bit smaller; work around libc bug: printf("%.*s\n", MAX_INT, buffer)
<li>run_parts: rewrite
<li>run_parts: do not check path portion of a name for "bad chars". Needed for ifupdown. Patch by Gabriel L. Somlo &lt;somlo at cmu.edu&gt;
<li>sed: fix escaped newlines in -f
<li>split: new applet
<li>stat: remove superfluous bss user (flags) and manually unswitch some areas
<li>stty: fix option parsing bug (spotted by Sascha Hauer &lt;s.hauer at pengutronix.de&gt;)
<li>svlogd: fix 'SEGV on uninitialized data' and make it honor TERM
<li>tail: fix SEGV on "tail -N"
<li>ipsvd: tcpsvd,udpsvd are new applets, GPL-ed 'clones' of Dan Bernstein's tcpserver. Author: Gerrit Pape &lt;pape at smarden.org&gt;, http://smarden.sunsite.dk/ipsvd/
<li>test: close bug 1371; plug a memory leak; code size reduction
<li>tftp: code diet, and I think retransmits were broken
<li>tr: fix bug where we did not reject invalid classes like '[[:alpha'. debloat while at it
<li>udhcp: MAC_BCAST_ADDR and blank_chaddr are in fact constant, move to rodata; use pipe instead of socketpair
<li>udhcp[cd]: stop using atexit magic fir pidfile removal; stop deleting our own pidfile if we daemonize
<li>xargs: shrink code, ~80 bytes; simplify word list management
<li>zcip: make it work on NOMMU (+ improve NOMMU support machinery)
</ul>
</p>
</li>
<li><b>20 May 2007 -- BusyBox 1.5.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.1.tar.bz2>BusyBox 1.5.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to hdparm, hush, ifupdown, ps
and sed.</p>
</li>
<li><b>23 March 2007 -- BusyBox 1.5.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.0.tar.bz2>BusyBox 1.5.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.5.1 stable by testing 1.5.0.</p>
<p>Notable changes since previous release:
<ul>
<li>find: added support for -user, -not, fixed -mtime, -mmin, -perm
<li>[de]archivers: merge common logic into one module
<li>ping[6]: unified code for both
<li>less: regex search improved
<li>ash: more readable code, testsuite added
<li>sed: several very obscure bugs fixed
<li>chown: -H, -L, -P support (required by POSIX)
<li>tar: handle (broken) checksums a-la Sun; tar restores mode again
<li>grep: implement -w, "implement" -a and -I by ignoring them
<li>cp: more sane behavior when overwriting existing files
<li>init: stop doing silly things with the console (-400 bytes)
<li>httpd: make httpd usable for NOMMU CPUs; fix POSTDATA handling bugs
<li>httpd: run interpreter for configured file extensions in any dir,
not only in /cgi-bin/
<li>chrt: new applet
<li>SELinux: SELinux-related code and -Z option added to several applets,
new SELinux-specific applets: chcon, runcon.
<li>Build system: produces link map, uses -Wwrite-strings to catch
improper usage of string constants.
<li>Data and bss section usage audited and reduced - should help NOMMU
targets.
<li>Applets with bug fixes: gunzip, vi, syslogd, dpkg, ls, adjtimex, resize,
sv, printf, diff, awk, sort, dpkg, diff, tftp
<li>Applets with usability improvements: swapon, more, ifup/ifdown, hwclock,
udhcpd, start_stop_daemon, cmp
<li>Applets with code cleaned up: telnet, fdisk, fsck_minix, mkfs_minix,
syslogd, swapon, runsv, svlogd, klogd
</ul>
</p>
</li>
<li><b>18 March 2007 -- BusyBox 1.4.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.2.tar.bz2>BusyBox 1.4.2</a>.
</p>
<p>This release includes only trivial fixes accumulated since 1.4.1.
</p>
</li>
<li><b>25 January 2007 -- BusyBox 1.4.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.1.tar.bz2>BusyBox 1.4.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.1/>patches</a>)</p>
<p>This release includes only trivial fixes accumulated since 1.4.0.
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.4.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.0.tar.bz2>BusyBox 1.4.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.0/>patches</a>)</p>
<p>Since this is a x.x.0 release, it probably is a bit less "stable"
than usual.</p>
<p>Changes since previous release:
<ul>
<li>e2fsprogs are mostly removed from busybox. Some smaller parts remain,
the rest of it sits disabled in e2fsprogs/old_e2fsprogs/*, because
it's too bloated. Really. I'm afraid it's about the only way we can
ever get e2fsprogs cleaned up.
<li>less: many improvements. Now can display binary files
(although I expect it to have trouble with displays where 8bit chars
don't have 1-to-1 char/glyph relationship). Regexp search is not buggy
anymore. Less does not read entire input up-front. Reads input
as it appears (yay!). Works rather nice as man pager. I recommend it
for general use now.
<li>IPv6: generic support is in place, many networking applets are
upgraded to be IPv6 capable. Probably some work remains, but it is
already much better than what we had previously.
<li>arp: new applet (thanks to Eric Spakman).
<li>fakeidentd: non-forking standalone server part was taking ~90%
of the applet. Factored it out (in fact, rewrote it).
<li>syslogd: mostly rewritten.
<li>decompress_unzip, gzip: sanitized a bit.
<li>sed: better hadling of NULs
<li>httpd: stop adding our own "Content-type:" to CGI output
<li>chown: user.grp works again.
<li>minor bugfixes to: passwd, date, tftp, start_stop_daemon, tar,
ps, ifupdown, time, su, stty, awk, ping[6], sort,...
</ul>
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.3.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.2.tar.bz2>BusyBox 1.3.2</a>.</p>
<p>This release includes only one trivial fix accumulated since 1.3.1
</p>
</li>
<li><b>27 December 2006 -- BusyBox 1.3.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.1.tar.bz2>BusyBox 1.3.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.1/>patches</a>)</p>
<p>Closing 2006 with new release. It includes only trivial fixes accumulated since 1.3.0
</p>
</li>
<li><b>14 December 2006 -- BusyBox 1.3.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.0.tar.bz2>BusyBox 1.3.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.0/>patches</a>)</p>
<p>This release has CONFIG_DESKTOP option which enables features
needed for busybox usage on desktop machine. For example, find, chmod
and chown get several less frequently used options, od is significantly
bigger but matches GNU coreutils, etc. Intended to eventually make
busybox a viable alternative for "standard" utilities for slightly
adventurous desktop users.
<p>Changes since previous release:
<ul>
<li>find: taking many more of standard options
<li>ps: POSIX-compliant -o implemented
<li>cp: added -s, -l
<li>grep: added -r, fixed -h
<li>watch: make it exec child like standard one does (was totally
incompatible)
<li>tar: fix limitations which were preventing bbox tar usage
on big directories: long names and linknames, pax headers
(Linux kernel tarballs have that). Fixed a number of obscure bugs.
Raised max file limit (now 64Gb). Security fixes (/../ attacks).
<li>httpd: added -i (inetd), -f (foreground), support for
directory indexer CGI (example is included), bugfixes.
<li>telnetd: fixed/improved IPv6 support, inetd+standalone support,
other fixes. Useful IPv6 stuff factored out into libbb.
<li>runit/*: new applets adapted from http://smarden.sunsite.dk/runit/
(these are my personal favorite small-and-beautiful toys)
<li>minor bugfixes to: login, dd, mount, umount, chmod, chown, ln, udhcp,
fdisk, ifconfig, sort, tee, mkswap, wget, insmod.
</ul>
<p>Note that GnuPG key used to sign this release is different.
1.2.2.1 is also signed post-factum now. Sorry for the mess.
</p>
</li>
<li><b>29 October 2006 -- BusyBox 1.2.2.1 (fix)</b>
<p><a href=http://busybox.net/downloads/busybox-1.2.2.1.tar.bz2>BusyBox 1.2.2.1</a>.</p>
<p>Added compile-time warning that static linking against glibc
produces buggy executables.
</li>
<li><b>24 October 2006 -- BusyBox 1.2.2 (stable)</b>
<p>It's a bit overdue, but
<a href=http://busybox.net/downloads/busybox-1.2.2.tar.bz2>here is
BusyBox 1.2.2</a>.</p>
<p>This release has dozens of fixes backported from the ongoing development
branch. There are a couple of bugfixes to sed, two fixes to documentation
generation (BusyBox.html shouldn't have USE() macros in it anymore), fix
umount to report the right errno on failure and to umount block devices by
name with newer kernels, fix mount to handle symlinks properly, make mdev
delete device nodes when called for hotplug remove, fix a segfault
in traceroute, a minor portability fix to md5sum option parsing, a build
fix for httpd with old gccs, an options parsing tweak to hdparm, make test
fail gracefully when getgroups() returns -1, fix a race condition in
modprobe when two instances run at once (hotplug does this), make "tar xf
foo.tar dir/dir" extract all subdirectories, make our getty initialize the
terminal more like mingetty, an selinux build fix, an endianness fix in
ping6, fix for zcip defending addresses, clean up some global variables in
gzip to save memory, fix sulogin -tNNN, a help text tweak, several warning
fixes and build fixes, fixup dnsd a bit, and a partridge in a pear tree.</p>
<p>As <a href=http://lwn.net/Articles/202106/>Linux Weekly News noted</a>,
this is my (Rob's) last release of BusyBox. The new maintainer is Denis
Vlasenko, I'm off to do <a href=http://landley.net/code>other things</a>.
</p>
</li>
<li><b>29 September 2006 -- New license email address.</b>
<p>The email address gpl@busybox.net is now the recommended way to contact
the Software Freedom Law Center to report BusyBox license violations.</p>
<li><b>31 July 2006 -- BusyBox 1.2.1 (stable)</b>
<p>Since nobody seems to have objected too loudly over the weekend, I
might as well point you all at
<a href="http://busybox.net/downloads/busybox-1.2.1.tar.bz2">Busybox
1.2.1</a>, a bugfix-only release with no new features.</p>
<p>It has three shell fixes (two to lash: going "var=value" without
saying "export" should now work, plus a missing null pointer check, and
one to ash when redirecting output to a file that fills up.) Fix three
embarassing thinkos in the new dmesg command. Two build tweaks
(dependencies for the compressed usage messages and running make in the
libbb subdirectory). One fix to tar so it can extract git-generated
tarballs (rather than barfing on the pax extensions). And a partridge
in a pear... Ahem.</p>
<p>But wait, there's more! A passwd changing fix so an empty
gecos field doesn't trigger a false objection that the new passwd contains
the gecos field. Make all our setuid() and setgid() calls check the return
value in case somebody's using per-process resource limits that prevent
a user from having too many processes (and thus prevent a process from
switching away from root, in which case the process will now _die_ rather
than continue with root privileges). A fix to adduser to make sure that
/etc/group gets updated. And a fix to modprobe to look for modules.conf
in the right place on 2.6 kernels.</p>
<li><b>30 June 2006 -- BusyBox 1.2.0</b>
<p>The -devel branch has been stabilized and the result is
<a href="http://busybox.net/downloads/busybox-1.2.0.tar.bz2">Busybox
1.2.0</a>. Lots of stuff changed, I need to work up a decent changelog
over the weekend.</p>
<p>I'm still experimenting with how long is best for the development
cycle, and since we've got some largeish projects queued up I'm going to
try a longer one. Expect 1.3.0 in December. (Expect 1.2.1 any time
we fix enough bugs. :)</p>
<p>Update: Here are <a href="http://busybox.net/downloads/busybox-1.2.0.fixes.patch">the first few bug fixes</a> that will go into 1.2.1.</p>
<li><b>17 May 2006 -- BusyBox 1.1.3 (stable)</b>
<p><a href="http://busybox.net/downloads/busybox-1.1.3.tar.bz2">BusyBox
1.1.3</a> is another bugfix release. It makes passwd use salt, fixes a
memory freeing bug in ls, fixes "build all sources at once" mode, makes
mount -a not abort on the first failure, fixes msh so ctrl-c doesn't kill
background processes, makes patch work with patch hunks that don't have a
timestamp, make less's text search a lot more robust (the old one could
segfault), and fixes readlink -f when built against uClibc.</p>
<p>Expect 1.2.0 sometime next month, which won't be a bugfix release.</p>
<li><b>10 April 2006 -- BusyBox 1.1.2 (stable)</b>
<p>You can now download <a href="http://busybox.net/downloads/busybox-1.1.2.tar.bz2">BusyBox 1.1.2</a>, a bug fix release consisting of 11 patches
backported from the development branch: Some build fixes, several fixes
for mount and nfsmount, a fix for insmod on big endian systems, a fix for
find -xdev, and a fix for comm. Check the file "changelog" in the tarball
for more info.</p>
<p>The next new development release (1.2.0) is slated for June. A 1.1.3
will be released before then if more bug fixes crop up. (The new plan is
to have a 1.x.0 new development release every 3 months, with 1.x.y stable
bugfix only releases based on that as appropriate.)</p>
<li><b>27 March 2006 -- Software Freedom Law Center representing BusyBox and uClibc</b>
<p>One issue Erik Andersen wanted to resolve when handing off BusyBox
maintainership to Rob Landley was license enforcement. BusyBox and
uClibc's existing license enforcement efforts (pro-bono representation
by Erik's father's law firm, and the
<a href="http://www.busybox.net/shame.html">Hall of Shame</a>), haven't
scaled to match the popularity of the projects. So we put our heads
together and did the obvious thing: ask Pamela Jones of
<a href="http://www.groklaw.net">Groklaw</a> for suggestions. She
referred us to the fine folks at softwarefreedom.org.</p>
<p>As a result, we're pleased to announce that the
<a href="http://www.softwarefreedom.org">Software Freedom Law Center</a>
has agreed to represent BusyBox and uClibc. We join a number of other
free and open source software projects (such as
<a href="http://lwn.net/Articles/141806/">X.org</a>,
<a href="http://lwn.net/Articles/135413/">Wine</a>, and
<a href="http://plone.org/foundation/newsitems/software-freedom-law-center-support/">Plone</a>
in being represented by a fairly cool bunch of lawyers, which is not a
phrase you get to use every day.</p>
<li><b>22 March 2006 -- BusyBox 1.1.1</b>
<p>The new maintainer is Rob Landley, and the new release is <a href="http://busybox.net/downloads/busybox-1.1.1.tar.bz2">BusyBox 1.1.1</a>. Expect a "what's new" document in a few days. (Also, Erik and I have have another announcement pending...)</p>
<p>Update: Rather than put out an endless stream of 1.1.1.x releases,
the various small fixes have been collected together into a
<a href="http://busybox.net/downloads/busybox-1.1.1.fixes.patch">patch</a>,
and new fixes will be appended to that as needed. Expect 1.1.2 around
June.</p>
</li>
<li><b>11 January 2006 -- 1.1.0 is out</b>
<p>The new stable release is
<a href="http://www.busybox.net/downloads/busybox-1.1.0.tar.bz2">BusyBox
1.1.0</a>. It has a number of improvements, including several new applets.
(It also has <a href="http://www.busybox.net/lists/busybox/2006-January/017733.html">a few rough spots</a>,
but we're trying out a "release early, release often" strategy to see how
that works. Expect 1.1.1 sometime in March.)</p>
<li><b>Old News</b><p>
<a href="/oldnews.html">Click here to read older news</a>
-799
View File
@@ -2,805 +2,6 @@
<ul>
<li><b>12 February 2008 -- BusyBox 1.9.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.1.tar.bz2>BusyBox 1.9.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to fsck,
iproute, mdev, mkswap, msh, nameif, stty, test, zcip.</p>
<p>hush has `command` expansion re-enabled for NOMMU, although it is
inherently unsafe (by virtue of NOMMU's use of vfork instead of fork).
The plan is to make this less likely to bite people in future versions.</p>
</li>
<li><b>24 December 2007 -- BusyBox 1.9.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.0.tar.bz2>BusyBox 1.9.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Sizes of busybox-1.8.2 and busybox-1.9.0 (with almost full config, static uclibc build):<pre>
text data bss dec hex filename
792796 978 9724 803498 c42aa busybox-1.8.2
783803 683 7508 791994 c15ba busybox-1.9.0
</pre>
<p>Top 10 stack users:<pre>
busybox-1.8.2: busybox-1.9.0:
input_tab 10428 echo_dg 4116
umount_main 8252 bb_full_fd_action 4112
rtnl_talk 8240 discard_dg 4096
xrtnl_dump_filter 8240 echo_stream 4096
sendMTFValues 5316 discard_stream 4096
mainSort 4700 find_list_entry2 4096
mkfs_minix_main 4288 readlink_main 4096
grave 4260 ipaddr_list_or_flush 3900
unix_do_one 4156 iproute_list_or_flush 3680
parse_prompt 4132 insmod_main 3152
</pre>
<p>lash is deleted from this release. hush can be configured down to almost
the same size, but it is significantly less buggy. It even works
on NOMMU machines (interactive mode and backticks are not working on NOMMU,
though). "lash" applet is still available, but it runs hush.
<p>init has some changes in this release, please report if it causes
problems for you.
<p>Changes since previous release:
<ul>
<li>Build system improvements
<li>Testsuite additions
<li>Stack size reductions, code size reductions, data/bss reductions
<li>An option to prefer IPv4 address if host has both
<li>New applets: hd, sestatus
<li>Removed applets: lash
<li>hush: fixed a few bugs, wired up echo and test to be builtins
<li>init: simplify forking of children
<li>getty: special handling of '#' and '@' is removed
<li>[su]login: sanitize environment if called by non-root
<li>udhcpc: support "bad" servers which send oversized packets
(Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>udhcpc: -O option allows to specify which options to ask for
(Stefan Hellermann &lt;stefan at the2masters.de&gt;)
<li>udhcpc: optionally check whether given IP is really free (by ARP ping)
(Jonas Danielsson &lt;jonas.danielsson at axis.com&gt;)
<li>vi: now handles files with unlimited line length
<li>vi: speedup for huge line lengths
<li>vi: Del key works
<li>sed: support GNUism '\t'
<li>cp/mv/install: optionally use bigger buffer for bulk copying
<li>line editing: don't eat stack like crazy
<li>passwd: follows symlinked /etc/passwd
<li>renice: accepts priority with +N too
<li>netstat: wide output mode
<li>nameif: extended matching (Nico Erfurth &lt;masta at perlgolf.de&gt;)
<li>test: become NOFORK applet
<li>find: -iname (Alexander Griesser &lt;alexander.griesser at lkh-vil.or.at&gt;)
<li>df: -i option (show inode info) (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
<li>hexdump: -R option (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
</ul>
</p>
<li><b>23 November 2007 -- BusyBox 1.8.2 (stable), BusyBox 1.7.4 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.2.tar.bz2>BusyBox 1.8.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p><a href=http://busybox.net/downloads/busybox-1.7.4.tar.bz2>BusyBox 1.7.4</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.4/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>These are bugfix-only releases.
1.8.2 contains fixes for inetd, lash, tar, tr, and build system.
1.7.4 contains a fix for inetd.</p>
</li>
<li><b>9 November 2007 -- BusyBox 1.8.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.1.tar.bz2>BusyBox 1.8.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to login (PAM), modprobe, syslogd, telnetd, unzip.</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.8.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.0.tar.bz2>BusyBox 1.8.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Note: this is probably the very last release with lash. It will be dropped. Please migrate to hush.
<p>Applets which had many changes since 1.7.x:
<p>httpd:
<ul>
<li>does not clear environment, CGIs will see all environment variables which were set for httpd
<li>fix bug where we were trying to read more POSTDATA than content-length
<li>fix trivial bug (spotted by Alex Landau)
<li>optional support for partial downloads
<li>simplified CGI i/o loop (now it looks good to me)
<li>small auth and IPv6 fixes (Kim B. Heino &lt;Kim.Heino at bluegiga.com>)
<li>support for proxying connection to other http server (by Alex Landau &lt;landau_alex at yahoo.com>)
</ul>
<p>top:
<ul>
<li>TOPMEM feature - 's(how sizes)' command
<li>don't wait before final bailout (try top -b -n1)
<li>fix for command line wrapping
</ul>
<p>Build system improvements: libbusybox mode restored (it was lost in transition to new makefiles).
<p>Code and data size in comparison with 1.7.3:<pre>
Equivalent .config, i386 uclibc static builds:
text data bss dec hex filename
768123 1055 10768 779946 be6aa busybox-1.7.3/busybox
759693 974 9420 770087 bc027 busybox-1.8.0/busybox</pre>
<p>New applets:
<ul>
<li>microcom: new applet by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;
<li>kbd_mode: new applet by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>bzip2: port bzip2 1.0.4 to busybox, 9 kb of code
<li>pgrep, pkill: new applets by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>setsebool: new applet (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
</ul>
<p>Other changes since previous release (abridged):
<ul>
<li>cp: -r and -R imply -d (coreutils compat)
<li>cp: detect and prevent infinite recursion
<li>cp: make it a bit closer to POSIX, but still refuse to open and overwrite symbolic link
<li>hdparm: reduce possibility of numeric overflow in -T
<li>hdparm: simplify timing measurement
<li>wget: -O FILE is allowed to overwrite existing file (compat)
<li>wget: allow dots in header field names
<li>telnetd: add -K option to close sessions as soon as child exits
<li>telnetd: don't SIGKILL child when closing the session, kernel will send SIGHUP for us
<li>ed: large cleanup, add line editing
<li>hush: feeble attempt at making it more NOMMU-friendly
<li>hush: fix glob()
<li>hush: stop doing manual accounting of open fd's, kernel can do it for us
<li>adduser: implement -S and fix uid selection
<li>ash: fix prompt expansion (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>ash: revert "cat | jobs" fix, it causes more problems than good
<li>find: fix -xdev behavior in the presence of two or more nested mount points
<li>grep: fix grep -F -e str1 -e str2 (was matching str2 only)
<li>grep: optimization: stop on first -e match
<li>gunzip: support concatenated gz files
<li>inetd: fix bug 1562 "inetd does not set argv[0] properly" (fix by Ilya Panfilov)
<li>install: 'support' (by ignoring) -v and -b
<li>install: fix bug in "install -c file dir" (tried to copy dir into dir too)
<li>ip: tunnel parameter parsing fix by Jean Wolter &lt;jw5 at os.inf.tu-dresden.de&gt;
<li>isrv: use monotonic_sec
<li>less: make 'f' key page forward
<li>libiproute: add missing break statements
<li>load_policy: update (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>logger: fix a problem of losing all argv except first
<li>login: do reject wrong passwords with PAM auth
<li>losetup: support -f (Loic Grenie &lt;loic.grenie at gmail.com&gt;)
<li>fdisk: make fdisk compile on libc without llseek64
<li>libbb: by popular request allow PATH to be customized at build time
<li>mkswap: selinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>mount: allow (and ignore) -i
<li>mount: ignore NFS bg option on NOMMU machines
<li>mount: mount helpers support (by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;)
<li>passwd: handle Ctrl-C, restore termios on Ctrl-C
<li>passwd: SELinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>ping: make -I ethN work too (-I addr already worked)
<li>ps: fix RSS parsing (rss field in /proc/PID/stat is in pages, not bytes)
<li>read_line_input: fix it to not do any fancy editing if echoing is disabled
<li>run_parts: make it sort executables by name (required by API)
<li>runsv: do not use clock_gettime if !MONOTONIC_CLOCK
<li>runsvdir: fix "linear wait time" bug
<li>sulogin: remove alarm handling, it is redundant there
<li>svlogd: compat: svlogd -tt should timestamp stderr too
<li>syslogd: bail out if you see null read from Unix socket
<li>syslogd: do not need to poll(), we can just block in read()
<li>tail: work correctly on /proc files (Kazuo TAKADA &lt;kztakada at sm.sony.co.jp&gt;)
<li>tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>tar: strip leading '/' BEFORE memorizing hardlink's name
<li>tftp: fix infinite retry bug
<li>umount: support (by ignoring) -i; style fixes
<li>unzip: fix endianness bugs
<li>vi: don't wait 50 ms before reading ESC sequences
<li>watchdog: allow millisecond spec (-t 250ms)
<li>zcip: fix unaligned trap on ARM
</ul>
</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.7.3 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.3.tar.bz2>BusyBox 1.7.3</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.3/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail.</p>
</li>
<li><b>30 September 2007 -- BusyBox 1.7.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.2.tar.bz2>BusyBox 1.7.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to install, find, login, httpd, runsvdir, chcon, setfiles, fdisk and line editing.</p>
</li>
<li><b>16 September 2007 -- BusyBox 1.7.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.1.tar.bz2>BusyBox 1.7.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to cp, runsv, tar, busybox --install and build system.</p>
</li>
<li><b>24 August 2007 -- BusyBox 1.7.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.0.tar.bz2>BusyBox 1.7.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Applets which had many changes since 1.6.x:
<p>httpd:
<ul>
<li>works in standalone mode on NOMMU machines now (partly by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>indexer example is rewritten in C
<li>optional support for error pages (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>stop reading headers using 1-byte reads
<li>new option -v[v]: prints client addresses, HTTP codes returned, URLs
<li>extended -p PORT to -p [IP[v6]:]PORT
<li>sendfile support (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>add support for Status: CGI header
<li>fix CGI handling bug (we were closing wrong fd)
<li>CGI I/O loop still doesn't look 100% ok to me...
</ul>
<p>udhcp[cd]:
<ul>
<li>add -f "foreground" and -S "syslog" options
<li>fixed "ifupdown + udhcpc_without_pidfile_creation" bug
<li>new config option "Rewrite the lease file at every new acknowledge" (Mats Erik Andersson &lt;mats at blue2net.com&gt; (Blue2Net AB))
<li>consistently treat server_config.start/end IPs as host-order
<li>fix IP parsing for 64bit machines
<li>fix unsafe hton macro usage in read_opt()
<li>do not chdir to / when daemonizing
</ul>
<p>top, ps, killall, pidof:
<ul>
<li>simpler loadavg processing
<li>truncate usernames to 8 chars
<li>fix non-CONFIG_DESKTOP ps -ww (by rockeychu)
<li>improve /proc/PID/cmdinfo reading code
<li>use cmdline, not comm field (fixes problems with re-execed applets showing as processes with name "exe", and not being found by pidof/killall by applet name)
<li>reduce CPU usage in decimal conversion (optional) (corresponding speedup on kernel side is accepted in mainline Linux kernel, yay!)
<li>make percentile (0.1%) calculations configurable
<li>add config option and code for global CPU% display
<li>reorder columns, so that [P]PIDs are together and VSZ/%MEM are together - makes more sense
</ul>
<p>Build system improvements: doesn't link against libraries we don't need,
generates verbose link output and map file, allows for custom link
scripts (useful for removing extra padding, among other things).
<p>Code and data size in comparison with 1.6.1:<pre>
Equivalent .config, i386 glibc dynamic builds:
text data bss dec hex filename
672671 2768 16808 692247 a9017 busybox-1.6.1/busybox
662948 2660 13528 679136 a5ce0 busybox-1.7.0/busybox
662783 2631 13416 678830 a5bae busybox-1.7.0/busybox.customld
Same .config built against static uclibc:
765021 1059 11020 777100 bdb8c busybox-1.7.0/busybox_uc</pre>
<p>Code/data shrink done in applets: crond, hdparm, dd, cal, od, nc, expr, uuencode,
test, slattach, diff, ping, tr, syslogd, hwclock, zcip, find, pidof, ash, uudecode,
runit/*, in libbb.
<p>New applets:
<ul>
<li>pscan, expand, unexpand (from Tito &lt;farmatito at tiscali.it&gt;)
<li>setfiles, restorecon (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>chpasswd (by Alexander Shishkin &lt;virtuoso at slind.org&gt;)
<li>slattach, ttysize
</ul>
<p>Unfortunately, not much work is done on shells. This was mostly stalled
by lack of time (read: laziness) on my part to learn how to adapt existing
qemu-runnable image for a NOMMU architechture (available on qemu website)
for local testing of cross-compiled busybox on my machine.
<p>Other changes since previous release (abridged):
<ul>
<li>addgroup: disallow addgroup -g num user group; make -g 0 work (Tito &lt;farmatito at tiscali.it&gt;)
<li>adduser: close /etc/{passwd,shadow} before calling passwd etc. Spotted by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>arping: -i should be -I, fixed
<li>ash: make "jobs | cat" work like in bash (was giving empty output)
<li>ash: recognize -l as --login equivalent; do not recognize +-login
<li>ash: fix buglet in DEBUG code (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ash: fix SEGV if type has zero parameters
<li>awk: fix -F 'regex' bug (miscounted fields if last field is empty)
<li>catv: catv without arguments was trying to use environ as argv (Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>catv: don't die on open error (emit warning)
<li>chown/chgrp: completely match coreutils 6.8 wrt symlink handling
<li>correct_password: do not print "no shadow passwd..." message
<li>crond: don't start sendmail with absolute path, don't report obsolete version (report true bbox version)
<li>dd: fix bug where we assume count=INT_MAX when count is unspecified
<li>devfsd: sanitization by Tito &lt;farmatito at tiscali.it&gt;
<li>echo: fix non-fancy echo
<li>fdisk: make it work with big disks (read: typical today's disks) even if CONFIG_LFS is unset
<li>find: -context support for SELinux (KaiGai Kohei &lt;kaigai at kaigai.gr.jp&gt;)
<li>find: add conditional support for -maxdepth and -regex, make -size match GNU find
<li>find: fix build failure on certain configs (found by Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one
<li>grep: implement -m MAX_MATCHES, fix buglets with context printing
<li>grep: fix selection done by FEATURE_GREP_EGREP_ALIAS (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: add missing dependencies (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: fix read builtin to not read ahead past EOL and to not use insane amounts of stack
<li>ifconfig: make it work with ifaces with interface no. &gt; 255
<li>ifup/ifdown: make location of ifstate configurable
<li>ifupdown: make netmask parsing smaller and more strict (was accepting 255.0.255.0, 255.1234.0.0 etc...)
<li>install: fix -s (strip) option, fix install a b /a/link/to/dir
<li>libbb: consolidate ARRAY_SIZE macro (Walter Harms &lt;wharms at bfs.de&gt;)
<li>libbb: make /etc/network parsing configurable. -200 bytes when off
<li>libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
<li>libbb: xioctl and friends by Tito &lt;farmatito at tiscali.it&gt;
<li>login: optional support for PAM
<li>login: make /etc/nologin support configurable (-240 bytes)
<li>login: ask passwords even for wrong usernames
<li>md5_sha1_sum: fix mishandling when run as /bin/md5sum
<li>mdev: add support for firmware loading
<li>mdev: work even when CONFIG_SYSFS_DEPRECATED in kernel is off
<li>modprobe: add scanning of /lib/modules/`uname -r`/modules.symbols (by Yann E. MORIN &lt;yann.morin.1998 at anciens.enib.fr&gt;)
<li>more: fixes by Tristan Schmelcher &lt;tpkschme at engmail.uwaterloo.ca&gt;
<li>nc: make connecting to IPv4 from IPv6-enabled hosts easier (was requiring -s local_addr)
<li>passwd: fix bug "updating shadow even if user's record is in passwd"
<li>patch: fix -p -1 handling
<li>patch: fix bad line ending handling (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
<li>ping: fix incorrect handling of -I (Iouri Kharon &lt;bc-info at styx.cabel.net&gt;)
<li>ping: fix non-fancy ping6
<li>printenv: fix "printenv VAR1 VAR2" bug (spotted by Kalyanatejaswi Balabhadrapatruni &lt;kalyanatejaswi at yahoo.co.in&gt;)
<li>ps: fix -Z (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>rpm: add optional support for bz2 data. +50 bytes of code
<li>rpm: fix bogus "package is not installed" case
<li>sed: fix 'q' command handling (by Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>start_stop_daemon: NOMMU fixes by Alex Landau &lt;landau_alex at yahoo.com&gt;
<li>stat: fix option -Z SEGV
<li>strings: strings a b was processing a twice, fix that
<li>svlogd: fix timestamping, do not warn if config is missing
<li>syslogd, logread: get rid of head pointer, fix logread bug in the process
<li>syslogd: do not convert tabs to ^I, set syslog IPC buffer to mode 0644
<li>tar: improve OLDGNU compat, make old SUN compat configurable
<li>test: fix testing primary expressions like '"-u" = "-u"'
<li>uudecode: fix to base64 decode by Jorgen Cederlof &lt;jcz at google.com&gt;
<li>vi: multiple fixes by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>wget: fix bug in base64 encoding (bug 1404). +10 bytes
<li>wget: lift 256 chars limitation on terminal width
<li>wget, zcip: use monotonic_sec instead of gettimeofday
</ul>
</p>
</li>
<li><b>30 June 2007 -- BusyBox 1.6.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.1.tar.bz2>BusyBox 1.6.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to echo, hush, and wget.</p>
</li>
<li><b>1 June 2007 -- BusyBox 1.6.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.0.tar.bz2>BusyBox 1.6.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.6.1 stable by testing 1.6.0.</p>
<p>Note that hush shell had many changes and (hopefully) is much improved now,
but there is a possibility that it regressed in some obscure cases. Please
report any such cases.</p>
<p>lash users please note: lash is going to be deprecated in busybox 1.7.0
and removed in the more distant future. Please migrate to hush.</p>
<p><a href=http://busybox.net/~vda/mem_usage-1.6.0.txt>Memory usage has decreased, but we can do better still</a></p>
<p>Other changes since previous release:
<ul>
<li>NOFORK: audit small applets and mark some of them as NOFORK. Put big scary warnings in relevant places
<li>NOFORK: factor out NOFORK/NOEXEC code from find. Use NOFORK/NOEXEC in find and xargs
<li>NOFORK: remove potential xmalloc from NOFORK path in bb_full_fd_action
<li>NOMMU: random fixes; compressed --help now works for NOMMU
<li>SELinux: load_policy applet
<li>[u]mount: extend -t option (Roy Marples &lt;uberlord at gentoo.org&gt;)
<li>addgroup: clean up, fix adding users to existing groups and make it optional (Tito)
<li>adduser: don't bomb out if shadow password file doesn't exist (from Tito &lt;farmatito at tiscali.it&gt;)
<li>applet.c: do not even try to read config if run by real root; fix suid config handling
<li>ash: fix infinite loop on exit if tty is not there anymore
<li>ash: fix kill -l (by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>ash: implement type -p, costs less than 10 bytes (patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>awk: don't segfault on printf(%*s). Closes bug 1337
<li>awk: guard against empty environment
<li>awk: some 'lineno' vars were shorts, made them ints (code got smaller)
<li>cat: stop using stdio.h opens
<li>config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
<li>cryptpw: new applet (by Thomas Lundquist &lt;lists at zelow.no&gt;)
<li>cttyhack: new applet
<li>dd: NOEXEC fix; fix skip= parse error (spotted by Dirk Clemens &lt;develop at cle-mens.de&gt;)
<li>deluser: add optional support for removing users from groups (by Tito &lt;farmatito at tiscali.it&gt;)
<li>diff: fix SEGV (NULL deref) in diff -N
<li>diff: fix segfault on empty dirs (Peter Korsgaard &lt;peter.korsgaard at barco.com&gt;)
<li>dnsd: fix several buglets, make smaller; openlog(), so that applet's name is logged
<li>dpkg: run_package_script() returns 0 if all ok and non-zero if failure. The result code was checked incorrectly in two places. (from Kim B. Heino &lt;Kim.Heino at bluegiga.com&gt;)
<li>dpkg: use bitfields which are a bit closer to typical short/char. Code size -800 bytes
<li>dumpleases: getopt32()-ization (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>e2fsprogs: stop using statics in chattr. Minor code shrinkage (-130 bytes)
<li>ether-wake: close bug 1317. Reorder fuctions to avoid forward refs while at it
<li>ether-wake: save a few more bytes of code
<li>find: -group, -depth (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: add support for -delete, -path (by Natanael Copa)
<li>find: fix -prune. Add big comment about it
<li>find: improve usage text (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: missed 'static' on const data; size and prune were mixed up; use index_in_str_array
<li>find: un-DESKTOPize (Kai Schwenzfeier &lt;niteblade at gmx.net&gt;)
<li>find_root_device: teach to deal with /dev/ subdirs (by Kirill K. Smirnov &lt;lich at math.spbu.ru&gt;)
<li>find_root_device: use lstat - don't follow links
<li>getopt32: fix llist_t options ordering. llist_rev is now unused
<li>getopt: use getopt32 for option parsing - inspired by patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;
<li>hdparm: fix multisector mode setting (from Toni Mirabete &lt;amirabete at catix.cat&gt;)
<li>hdparm: make -T -t code smaller (-194 bytes), and output prettier
<li>ifupdown: make it possible to use DHCP clients different from udhcp
<li>ifupdown: reread state file before rewriting it. Fixes "ifup started another ifup" state corruption bug. Patch by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>ifupdown: small optimization (avoid doing useless work if we are not going to update state file)
<li>ip: fix compilation if FEATURE_TR_CLASSES is off
<li>ip: mv ip*_main into ip.c; use a dispatcher to save on needless duplication. Saves a minor 12b
<li>ip: rewrite the ip applet to be less bloaty. Convert to index_in_(sub)str_array()
<li>ip: set the scope properly. Thanks to Jean Wolter
<li>iplink: shrink iplink; sanitize libiproute a bit (-916 bytes)
<li>iproute: shrink a bit (-200 bytes)
<li>kill: know much more signals; make code smaller; use common code for kill applet and ash kill builtin
<li>klogd: remove dependency on syslogd
<li>lash: "forking" applets are actually can be treated the same way as "non-forked". Also save a bit of space on trailing NULL array elements.
<li>lash: fix kill buglet (didn't properly recognize ESRCH)
<li>lash: make -c work; crush buffer overrun and free of non-malloced ptr (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>lash: recognize and use NOFORK applets
<li>less: fix case when regex search finds nothing; fix very obscure memory corruption bug; fix less &lt;HUGEFILE + [End] busy loop
<li>libbb: add xsendto, xunlink, xpipe
<li>libbb: fix segfault in reset_ino_dev_hashtable() when *hashtable was NULL
<li>libbb: make pidfile writing configurable
<li>libbb: make xsocket die with address family printed (if VERBOSE_RESOLUTION_ERRORS=y)
<li>libbb: rework NOMMU helper API so that it makes more sense and easier to use
<li>libiproute: audit callgraph, shortcut error paths into die() functions
<li>lineedit: do not try to open NULL history file
<li>lineedit: nuke two unused variables and code which sets them
<li>login: remove setpgrp call (makes it work from shell prompt again); sanitize stdio descriptors (we are suid, need to be careful!)
<li>login: shrink login and set_environment by ~100 bytes
<li>mount: fix incorrect usage of strtok (inadvertently used NULL sometimes)
<li>mount: fix mounting of symlinks (mount from util-linux allows that)
<li>msh: data/bss reduction (more than 9k of it); fix "underscore bug" (a_b=1111 didn't work); fix obscure case with backticks and closed fd 1
<li>nc: port nc 1.10 to busybox
<li>netstat: fix for bogus state value for raw sockets
<li>netstat: introduce -W: wide, ipv6-friendly output; shrink by ~500 bytes
<li>nmeter: should die if stdout doesn't like him anymore
<li>patch: do not try to delete same file twice
<li>ping: fix wrong sign extension of packet id (bug 1373)
<li>ps: add -o tty and -o rss support; make a bit smaller; work around libc bug: printf("%.*s\n", MAX_INT, buffer)
<li>run_parts: rewrite
<li>run_parts: do not check path portion of a name for "bad chars". Needed for ifupdown. Patch by Gabriel L. Somlo &lt;somlo at cmu.edu&gt;
<li>sed: fix escaped newlines in -f
<li>split: new applet
<li>stat: remove superfluous bss user (flags) and manually unswitch some areas
<li>stty: fix option parsing bug (spotted by Sascha Hauer &lt;s.hauer at pengutronix.de&gt;)
<li>svlogd: fix 'SEGV on uninitialized data' and make it honor TERM
<li>tail: fix SEGV on "tail -N"
<li>ipsvd: tcpsvd,udpsvd are new applets, GPL-ed 'clones' of Dan Bernstein's tcpserver. Author: Gerrit Pape &lt;pape at smarden.org&gt;, http://smarden.sunsite.dk/ipsvd/
<li>test: close bug 1371; plug a memory leak; code size reduction
<li>tftp: code diet, and I think retransmits were broken
<li>tr: fix bug where we did not reject invalid classes like '[[:alpha'. debloat while at it
<li>udhcp: MAC_BCAST_ADDR and blank_chaddr are in fact constant, move to rodata; use pipe instead of socketpair
<li>udhcp[cd]: stop using atexit magic fir pidfile removal; stop deleting our own pidfile if we daemonize
<li>xargs: shrink code, ~80 bytes; simplify word list management
<li>zcip: make it work on NOMMU (+ improve NOMMU support machinery)
</ul>
</p>
</li>
<li><b>20 May 2007 -- BusyBox 1.5.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.1.tar.bz2>BusyBox 1.5.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to hdparm, hush, ifupdown, ps
and sed.</p>
</li>
<li><b>23 March 2007 -- BusyBox 1.5.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.0.tar.bz2>BusyBox 1.5.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.5.1 stable by testing 1.5.0.</p>
<p>Notable changes since previous release:
<ul>
<li>find: added support for -user, -not, fixed -mtime, -mmin, -perm
<li>[de]archivers: merge common logic into one module
<li>ping[6]: unified code for both
<li>less: regex search improved
<li>ash: more readable code, testsuite added
<li>sed: several very obscure bugs fixed
<li>chown: -H, -L, -P support (required by POSIX)
<li>tar: handle (broken) checksums a-la Sun; tar restores mode again
<li>grep: implement -w, "implement" -a and -I by ignoring them
<li>cp: more sane behavior when overwriting existing files
<li>init: stop doing silly things with the console (-400 bytes)
<li>httpd: make httpd usable for NOMMU CPUs; fix POSTDATA handling bugs
<li>httpd: run interpreter for configured file extensions in any dir,
not only in /cgi-bin/
<li>chrt: new applet
<li>SELinux: SELinux-related code and -Z option added to several applets,
new SELinux-specific applets: chcon, runcon.
<li>Build system: produces link map, uses -Wwrite-strings to catch
improper usage of string constants.
<li>Data and bss section usage audited and reduced - should help NOMMU
targets.
<li>Applets with bug fixes: gunzip, vi, syslogd, dpkg, ls, adjtimex, resize,
sv, printf, diff, awk, sort, dpkg, diff, tftp
<li>Applets with usability improvements: swapon, more, ifup/ifdown, hwclock,
udhcpd, start_stop_daemon, cmp
<li>Applets with code cleaned up: telnet, fdisk, fsck_minix, mkfs_minix,
syslogd, swapon, runsv, svlogd, klogd
</ul>
</p>
</li>
<li><b>18 March 2007 -- BusyBox 1.4.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.2.tar.bz2>BusyBox 1.4.2</a>.
</p>
<p>This release includes only trivial fixes accumulated since 1.4.1.
</p>
</li>
<li><b>25 January 2007 -- BusyBox 1.4.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.1.tar.bz2>BusyBox 1.4.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.1/>patches</a>)</p>
<p>This release includes only trivial fixes accumulated since 1.4.0.
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.4.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.0.tar.bz2>BusyBox 1.4.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.0/>patches</a>)</p>
<p>Since this is a x.x.0 release, it probably is a bit less "stable"
than usual.</p>
<p>Changes since previous release:
<ul>
<li>e2fsprogs are mostly removed from busybox. Some smaller parts remain,
the rest of it sits disabled in e2fsprogs/old_e2fsprogs/*, because
it's too bloated. Really. I'm afraid it's about the only way we can
ever get e2fsprogs cleaned up.
<li>less: many improvements. Now can display binary files
(although I expect it to have trouble with displays where 8bit chars
don't have 1-to-1 char/glyph relationship). Regexp search is not buggy
anymore. Less does not read entire input up-front. Reads input
as it appears (yay!). Works rather nice as man pager. I recommend it
for general use now.
<li>IPv6: generic support is in place, many networking applets are
upgraded to be IPv6 capable. Probably some work remains, but it is
already much better than what we had previously.
<li>arp: new applet (thanks to Eric Spakman).
<li>fakeidentd: non-forking standalone server part was taking ~90%
of the applet. Factored it out (in fact, rewrote it).
<li>syslogd: mostly rewritten.
<li>decompress_unzip, gzip: sanitized a bit.
<li>sed: better hadling of NULs
<li>httpd: stop adding our own "Content-type:" to CGI output
<li>chown: user.grp works again.
<li>minor bugfixes to: passwd, date, tftp, start_stop_daemon, tar,
ps, ifupdown, time, su, stty, awk, ping[6], sort,...
</ul>
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.3.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.2.tar.bz2>BusyBox 1.3.2</a>.</p>
<p>This release includes only one trivial fix accumulated since 1.3.1
</p>
</li>
<li><b>27 December 2006 -- BusyBox 1.3.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.1.tar.bz2>BusyBox 1.3.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.1/>patches</a>)</p>
<p>Closing 2006 with new release. It includes only trivial fixes accumulated since 1.3.0
</p>
</li>
<li><b>14 December 2006 -- BusyBox 1.3.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.0.tar.bz2>BusyBox 1.3.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.0/>patches</a>)</p>
<p>This release has CONFIG_DESKTOP option which enables features
needed for busybox usage on desktop machine. For example, find, chmod
and chown get several less frequently used options, od is significantly
bigger but matches GNU coreutils, etc. Intended to eventually make
busybox a viable alternative for "standard" utilities for slightly
adventurous desktop users.
<p>Changes since previous release:
<ul>
<li>find: taking many more of standard options
<li>ps: POSIX-compliant -o implemented
<li>cp: added -s, -l
<li>grep: added -r, fixed -h
<li>watch: make it exec child like standard one does (was totally
incompatible)
<li>tar: fix limitations which were preventing bbox tar usage
on big directories: long names and linknames, pax headers
(Linux kernel tarballs have that). Fixed a number of obscure bugs.
Raised max file limit (now 64Gb). Security fixes (/../ attacks).
<li>httpd: added -i (inetd), -f (foreground), support for
directory indexer CGI (example is included), bugfixes.
<li>telnetd: fixed/improved IPv6 support, inetd+standalone support,
other fixes. Useful IPv6 stuff factored out into libbb.
<li>runit/*: new applets adapted from http://smarden.sunsite.dk/runit/
(these are my personal favorite small-and-beautiful toys)
<li>minor bugfixes to: login, dd, mount, umount, chmod, chown, ln, udhcp,
fdisk, ifconfig, sort, tee, mkswap, wget, insmod.
</ul>
<p>Note that GnuPG key used to sign this release is different.
1.2.2.1 is also signed post-factum now. Sorry for the mess.
</p>
</li>
<li><b>29 October 2006 -- BusyBox 1.2.2.1 (fix)</b>
<p><a href=http://busybox.net/downloads/busybox-1.2.2.1.tar.bz2>BusyBox 1.2.2.1</a>.</p>
<p>Added compile-time warning that static linking against glibc
produces buggy executables.
</li>
<li><b>24 October 2006 -- BusyBox 1.2.2 (stable)</b>
<p>It's a bit overdue, but
<a href=http://busybox.net/downloads/busybox-1.2.2.tar.bz2>here is
BusyBox 1.2.2</a>.</p>
<p>This release has dozens of fixes backported from the ongoing development
branch. There are a couple of bugfixes to sed, two fixes to documentation
generation (BusyBox.html shouldn't have USE() macros in it anymore), fix
umount to report the right errno on failure and to umount block devices by
name with newer kernels, fix mount to handle symlinks properly, make mdev
delete device nodes when called for hotplug remove, fix a segfault
in traceroute, a minor portability fix to md5sum option parsing, a build
fix for httpd with old gccs, an options parsing tweak to hdparm, make test
fail gracefully when getgroups() returns -1, fix a race condition in
modprobe when two instances run at once (hotplug does this), make "tar xf
foo.tar dir/dir" extract all subdirectories, make our getty initialize the
terminal more like mingetty, an selinux build fix, an endianness fix in
ping6, fix for zcip defending addresses, clean up some global variables in
gzip to save memory, fix sulogin -tNNN, a help text tweak, several warning
fixes and build fixes, fixup dnsd a bit, and a partridge in a pear tree.</p>
<p>As <a href=http://lwn.net/Articles/202106/>Linux Weekly News noted</a>,
this is my (Rob's) last release of BusyBox. The new maintainer is Denis
Vlasenko, I'm off to do <a href=http://landley.net/code>other things</a>.
</p>
</li>
<li><b>29 September 2006 -- New license email address.</b>
<p>The email address gpl@busybox.net is now the recommended way to contact
the Software Freedom Law Center to report BusyBox license violations.</p>
<li><b>31 July 2006 -- BusyBox 1.2.1 (stable)</b>
<p>Since nobody seems to have objected too loudly over the weekend, I
might as well point you all at
<a href="http://busybox.net/downloads/busybox-1.2.1.tar.bz2">Busybox
1.2.1</a>, a bugfix-only release with no new features.</p>
<p>It has three shell fixes (two to lash: going "var=value" without
saying "export" should now work, plus a missing null pointer check, and
one to ash when redirecting output to a file that fills up.) Fix three
embarassing thinkos in the new dmesg command. Two build tweaks
(dependencies for the compressed usage messages and running make in the
libbb subdirectory). One fix to tar so it can extract git-generated
tarballs (rather than barfing on the pax extensions). And a partridge
in a pear... Ahem.</p>
<p>But wait, there's more! A passwd changing fix so an empty
gecos field doesn't trigger a false objection that the new passwd contains
the gecos field. Make all our setuid() and setgid() calls check the return
value in case somebody's using per-process resource limits that prevent
a user from having too many processes (and thus prevent a process from
switching away from root, in which case the process will now _die_ rather
than continue with root privileges). A fix to adduser to make sure that
/etc/group gets updated. And a fix to modprobe to look for modules.conf
in the right place on 2.6 kernels.</p>
<li><b>30 June 2006 -- BusyBox 1.2.0</b>
<p>The -devel branch has been stabilized and the result is
<a href="http://busybox.net/downloads/busybox-1.2.0.tar.bz2">Busybox
1.2.0</a>. Lots of stuff changed, I need to work up a decent changelog
over the weekend.</p>
<p>I'm still experimenting with how long is best for the development
cycle, and since we've got some largeish projects queued up I'm going to
try a longer one. Expect 1.3.0 in December. (Expect 1.2.1 any time
we fix enough bugs. :)</p>
<p>Update: Here are <a href="http://busybox.net/downloads/busybox-1.2.0.fixes.patch">the first few bug fixes</a> that will go into 1.2.1.</p>
<li><b>17 May 2006 -- BusyBox 1.1.3 (stable)</b>
<p><a href="http://busybox.net/downloads/busybox-1.1.3.tar.bz2">BusyBox
1.1.3</a> is another bugfix release. It makes passwd use salt, fixes a
memory freeing bug in ls, fixes "build all sources at once" mode, makes
mount -a not abort on the first failure, fixes msh so ctrl-c doesn't kill
background processes, makes patch work with patch hunks that don't have a
timestamp, make less's text search a lot more robust (the old one could
segfault), and fixes readlink -f when built against uClibc.</p>
<p>Expect 1.2.0 sometime next month, which won't be a bugfix release.</p>
<li><b>10 April 2006 -- BusyBox 1.1.2 (stable)</b>
<p>You can now download <a href="http://busybox.net/downloads/busybox-1.1.2.tar.bz2">BusyBox 1.1.2</a>, a bug fix release consisting of 11 patches
backported from the development branch: Some build fixes, several fixes
for mount and nfsmount, a fix for insmod on big endian systems, a fix for
find -xdev, and a fix for comm. Check the file "changelog" in the tarball
for more info.</p>
<p>The next new development release (1.2.0) is slated for June. A 1.1.3
will be released before then if more bug fixes crop up. (The new plan is
to have a 1.x.0 new development release every 3 months, with 1.x.y stable
bugfix only releases based on that as appropriate.)</p>
<li><b>27 March 2006 -- Software Freedom Law Center representing BusyBox and uClibc</b>
<p>One issue Erik Andersen wanted to resolve when handing off BusyBox
maintainership to Rob Landley was license enforcement. BusyBox and
uClibc's existing license enforcement efforts (pro-bono representation
by Erik's father's law firm, and the
<a href="http://www.busybox.net/shame.html">Hall of Shame</a>), haven't
scaled to match the popularity of the projects. So we put our heads
together and did the obvious thing: ask Pamela Jones of
<a href="http://www.groklaw.net">Groklaw</a> for suggestions. She
referred us to the fine folks at softwarefreedom.org.</p>
<p>As a result, we're pleased to announce that the
<a href="http://www.softwarefreedom.org">Software Freedom Law Center</a>
has agreed to represent BusyBox and uClibc. We join a number of other
free and open source software projects (such as
<a href="http://lwn.net/Articles/141806/">X.org</a>,
<a href="http://lwn.net/Articles/135413/">Wine</a>, and
<a href="http://plone.org/foundation/newsitems/software-freedom-law-center-support/">Plone</a>
in being represented by a fairly cool bunch of lawyers, which is not a
phrase you get to use every day.</p>
<li><b>22 March 2006 -- BusyBox 1.1.1</b>
<p>The new maintainer is Rob Landley, and the new release is <a href="http://busybox.net/downloads/busybox-1.1.1.tar.bz2">BusyBox 1.1.1</a>. Expect a "what's new" document in a few days. (Also, Erik and I have have another announcement pending...)</p>
<p>Update: Rather than put out an endless stream of 1.1.1.x releases,
the various small fixes have been collected together into a
<a href="http://busybox.net/downloads/busybox-1.1.1.fixes.patch">patch</a>,
and new fixes will be appended to that as needed. Expect 1.1.2 around
June.</p>
</li>
<li><b>11 January 2006 -- 1.1.0 is out</b>
<p>The new stable release is
<a href="http://www.busybox.net/downloads/busybox-1.1.0.tar.bz2">BusyBox
1.1.0</a>. It has a number of improvements, including several new applets.
(It also has <a href="http://www.busybox.net/lists/busybox/2006-January/017733.html">a few rough spots</a>,
but we're trying out a "release early, release often" strategy to see how
that works. Expect 1.1.1 sometime in March.)</p>
<li><b>31 October 2005 -- 1.1.0-pre1</b>
<p>The development branch of busybox is stable enough for wider testing, so
you can now
+41 -50
View File
@@ -12,61 +12,52 @@ Everybody loves to look at screenshots, so here is a live action screenshot of B
font-family: monospace; font-size: smaller;" width="100">
$ busybox
BusyBox v1.10.1 (2008-04-24 11:30:07 CEST) multi-call binary
Copyright (C) 1998-2007 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.
BusyBox v1.8.0 (2007-11-04 15:42:38 GMT) multi-call binary
Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
Licensed under GPLv2. See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: function [arguments]...
or: [function] [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!
Currently defined functions:
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
awk, basename, bbconfig, brctl, bunzip2, bzcat, bzip2,
cal, cat, catv, chat, chattr, chcon, chgrp, chmod, chown,
chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp,
comm, cp, cpio, crond, crontab, cryptpw, cttyhack, cut,
date, dc, dd, deallocvt, delgroup, deluser, devfsd, df,
dhcprelay, diff, dirname, dmesg, dnsd, dos2unix, dpkg,
dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep, eject,
env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd,
false, fbset, fdflush, fdformat, fdisk, fetchmail, fgrep,
find, findfs, fold, free, freeramdisk, fsck, fsck.minix,
ftpget, ftpput, fuser, getenforce, getopt, getsebool,
getty, grep, gunzip, gzip, halt, hd, hdparm, head, hexdump,
hostid, hostname, httpd, hush, hwclock, id, ifconfig,
ifdown, ifenslave, ifup, inetd, init, insmod, install,
ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule,
iptunnel, kbd_mode, kill, killall, killall5, klogd, lash,
last, length, less, linux32, linux64, linuxrc, ln, load_policy,
loadfont, loadkmap, logger, login, logname, logread, losetup,
lpd, lpq, lpr, ls, lsattr, lsmod, lzmacat, makedevs, matchpathcon,
md5sum, mdev, mesg, microcom, mkdir, mkfifo, mkfs.minix,
mknod, mkswap, mktemp, modprobe, more, mount, mountpoint,
msh, mt, mv, nameif, nc, netstat, nice, nmeter, nohup,
nslookup, od, openvt, passwd, patch, pgrep, pidof, ping,
ping6, pipe_progress, pivot_root, pkill, poweroff, printenv,
printf, ps, pscan, pwd, raidautorun, rdate, readahead,
readlink, readprofile, realpath, reboot, renice, reset,
resize, restorecon, rm, rmdir, rmmod, route, rpm, rpm2cpio,
rtcwake, run-parts, runcon, runlevel, runsv, runsvdir,
rx, script, sed, selinuxenabled, sendmail, seq, sestatus,
setarch, setconsole, setenforce, setfiles, setkeycodes,
setlogcons, setsebool, setsid, setuidgid, sha1sum, slattach,
sleep, softlimit, sort, split, start-stop-daemon, stat,
strings, stty, su, sulogin, sum, sv, svlogd, swapoff,
swapon, switch_root, sync, sysctl, syslogd, tac, tail,
tar, taskset, tcpsvd, tee, telnet, telnetd, test, tftp,
tftpd, time, top, touch, tr, traceroute, true, tty, ttysize,
udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand,
uniq, unix2dos, unlzma, unzip, uptime, usleep, uudecode,
uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget,
which, who, whoami, xargs, yes, zcat, zcip
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
awk, basename, bunzip2, bzcat, bzip2, cal, cat, catv, chattr,
chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt,
cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw,
cut, date, dc, dd, deallocvt, delgroup, deluser, df, dhcprelay,
diff, dirname, dmesg, dnsd, dos2unix, dpkg, du, dumpkmap,
dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid,
expand, expr, fakeidentd, false, fbset, fdflush, fdformat,
fdisk, fgrep, find, fold, free, freeramdisk, fsck, fsck.minix,
ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip,
hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock,
id, ifconfig, inetd, insmod, install, ip, ipaddr, ipcalc,
ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode,
kill, killall, killall5, klogd, lash, last, length, less,
linux32, linux64, ln, loadfont, loadkmap, logger, login, logname,
logread, losetup, ls, lsattr, lsmod, lzmacat, md5sum, mdev,
mesg, microcom, mkdir, mkfifo, mkfs.minix, mknod, mkswap,
mktemp, modprobe, more, mount, mountpoint, msh, mt, mv, nameif,
nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, passwd,
patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root,
pkill, printenv, printf, ps, pscan, pwd, raidautorun, rdate,
readlink, readprofile, realpath, renice, reset, resize, rm,
rmdir, rmmod, route, rpm, rpm2cpio, run-parts, runlevel, runsv,
runsvdir, rx, sed, seq, setarch, setconsole, setkeycodes,
setlogcons, setsid, setuidgid, sha1sum, slattach, sleep, softlimit,
sort, split, start-stop-daemon, stat, strings, stty, su, sulogin,
sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl,
syslogd, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp,
time, top, touch, tr, traceroute, true, tty, ttysize, udhcpc,
udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq,
unix2dos, unlzma, unzip, uptime, usleep, uudecode, uuencode,
vconfig, vi, vlock, watch, watchdog, wc, wget, which, who,
whoami, xargs, yes, zcat, zcip
$ <span style="text-decoration:blink;">_</span>
+9 -26
View File
@@ -12,41 +12,24 @@ project, consider these fine companies!</p>
OSU OSL kindly provides hosting for BusyBox and uClibc.
</li>
<li><a href="http://www.codepoet-consulting.com">Codepoet Consulting</a><br>
Custom Linux, embedded Linux, BusyBox, and uClibc development.
</li>
<li>AOE media, a <a href=http://www.aoemedia.com/typo3-development.html>
TYPO3 development agency</a> contributes financially.
</li>
<li><a href=http://www.analog.com/en/>Analog Devices, Inc.</a> provided
a <a href=http://docs.blackfin.uclinux.org/doku.php?id=bf537_quick_start>
Blackfin development board</a> free of charge.
<a href=http://www.analog.com/blackfin>Blackfin<a>
is a NOMMU processor, and its availability for testing is invaluable.
If you are an embedded device developer,
please note that Analog Devices has entire Linux distribution available
for download for this board. Visit
<a href=http://blackfin.uclinux.org/>http://blackfin.uclinux.org/</a>
for more information.
</li>
<li><a href="http://www.timesys.com">TimeSys</a><br>
Embedded Linux development, cross-compilers, real-time, KGDB, tsrpm and cygwin.
</li>
<li><a href="http://www.penguru.net">Penguru Consulting</a><br>
Custom development for embedded Linux systems and multimedia platforms.
Custom development for embedded Linux systems and multimedia platforms
</li>
<li><a href="http://opensource.se/">opensource.se</a><br>
Embedded open source consulting in Europe.
</li>
<li><a href="http://www.codepoet-consulting.com">Codepoet Consulting</a><br>
Custom Linux, embedded Linux, BusyBox, and uClibc development.
</li>
<li><a href="http://www.timesys.com">TimeSys</a><br>
Embedded Linux development, cross-compilers, real-time, KGDB, tsrpm and cygwin.
</li>
</ul>
<p>If you wish to be a sponsor, or if you have already contributed and would
like your name added here, email <a href="mailto:vda.linux@gmail.com">Denys</a>.</p>
like your name added here, email <a href="mailto:rob@landley.net">Rob</a>.</p>
<!--#include file="footer.html" -->
+3 -9
View File
@@ -15,20 +15,13 @@ require sysfs support in the kernel and have it mounted at /sys. For dynamic
updates, you also need to have hotplugging enabled in your kernel.
Here's a typical code snippet from the init script:
[0] mount -t proc proc /proc
[1] mount -t sysfs sysfs /sys
[2] echo /bin/mdev > /proc/sys/kernel/hotplug
[3] mdev -s
Alternatively, without procfs the above becomes:
[1] mount -t sysfs sysfs /sys
[2] sysctl -w kernel.hotplug=/bin/mdev
[3] mdev -s
Of course, a more "full" setup would entail executing this before the previous
code snippet:
[4] mount -t tmpfs -o size=64k,mode=0755 tmpfs /dev
[4] mount -t tmpfs mdev /dev
[5] mkdir /dev/pts
[6] mount -t devpts devpts /dev/pts
@@ -94,4 +87,5 @@ properly initialize a device. Place all such firmware files into the
/lib/firmware/ directory. At runtime, the kernel will invoke mdev with the
filename of the firmware which mdev will load out of /lib/firmware/ and into
the kernel via the sysfs interface. The exact filename is hardcoded in the
kernel, so look there if you need to know how to name the file in userspace.
kernel, so look there if you need to want to know what to name the file in
userspace.
+1 -1
View File
@@ -192,7 +192,7 @@ static const char e2attr_flags_lname[] =
"Top_of_Directory_Hierarchies" "\0"
/* Another trailing NUL is added by compiler */;
void print_e2flags(FILE *f, unsigned long flags, unsigned options)
void print_flags(FILE *f, unsigned long flags, unsigned options)
{
const uint32_t *fv;
const char *fn;
+1 -9
View File
@@ -9,10 +9,6 @@
/* Constants and structures */
#include "e2fs_defs.h"
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility push(hidden)
#endif
/* Iterate a function on each entry of a directory */
int iterate_on_dir(const char *dir_name,
int (*func)(const char *, struct dirent *, void *),
@@ -31,7 +27,7 @@ int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_f
/* Must be 1 for compatibility with `int long_format'. */
#define PFOPT_LONG 1
/* Print file attributes on an ext2 file system */
void print_e2flags(FILE *f, unsigned long flags, unsigned options);
void print_flags(FILE *f, unsigned long flags, unsigned options);
extern const uint32_t e2attr_flags_value[];
extern const char e2attr_flags_sname[];
@@ -45,7 +41,3 @@ extern const char e2attr_flags_sname[];
#define e2attr_flags_value_chattr (&e2attr_flags_value[1])
#define e2attr_flags_sname_chattr (&e2attr_flags_sname[1])
#endif
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility pop
#endif
+1 -1
View File
@@ -391,7 +391,7 @@ static void load_fs_info(const char *filename)
}
while (1) {
int r;
char *buf = xmalloc_fgetline(f);
char *buf = xmalloc_getline(f);
if (!buf) break;
r = parse_fstab_line(buf, &fs);
free(buf);
+2 -2
View File
@@ -45,10 +45,10 @@ static void list_attributes(const char *name)
if (option_mask32 & OPT_PF_LONG) {
printf("%-28s ", name);
print_e2flags(stdout, fsflags, PFOPT_LONG);
print_flags(stdout, fsflags, PFOPT_LONG);
bb_putchar('\n');
} else {
print_e2flags(stdout, fsflags, 0);
print_flags(stdout, fsflags, 0);
printf(" %s\n", name);
}
+1 -1
View File
@@ -13,7 +13,7 @@
#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
#endif
/* `options' for print_e2flags() */
/* `options' for print_flags() */
#define PFOPT_LONG 1 /* Must be 1 for compatibility with `int long_format'. */
+1 -1
View File
@@ -285,7 +285,7 @@ static char *string_copy(const char *s)
if (!s)
return 0;
ret = xstrdup(s);
ret = strdup(s);
return ret;
}
+2 -2
View File
@@ -56,10 +56,10 @@ static void list_attributes(const char *name)
if (flags & OPT_PF_LONG) {
printf("%-28s ", name);
print_e2flags(stdout, fsflags, PFOPT_LONG);
print_flags(stdout, fsflags, PFOPT_LONG);
bb_putchar('\n');
} else {
print_e2flags(stdout, fsflags, 0);
print_flags(stdout, fsflags, 0);
printf(" %s\n", name);
}
+30 -24
View File
@@ -676,11 +676,16 @@ static char nextchar(char **s)
return c;
}
static ALWAYS_INLINE int isalnum_(int c)
static int ALWAYS_INLINE isalnum_(int c)
{
return (isalnum(c) || c == '_');
}
static FILE *afopen(const char *path, const char *mode)
{
return (*path == '-' && *(path+1) == '\0') ? stdin : xfopen(path, mode);
}
/* -------- working with variables (set/get/copy/etc) -------- */
static xhash *iamarray(var *v)
@@ -1677,7 +1682,7 @@ static void hashwalk_init(var *v, xhash *array)
{
char **w;
hash_item *hi;
unsigned i;
int i;
if (v->type & VF_WALK)
free(v->x.walker);
@@ -1991,7 +1996,7 @@ static var *exec_builtin(node *op, var *res)
}
nargs = i;
if ((uint32_t)nargs < (info >> 30))
if (nargs < (info >> 30))
syntax_error(EMSG_TOO_FEW_ARGS);
switch (info & OPNMASK) {
@@ -2735,7 +2740,7 @@ static rstream *next_input_file(void)
ind = getvar_s(incvar(intvar[ARGIND]));
fname = getvar_s(findvar(iamarray(intvar[ARGV]), ind));
if (fname && *fname && !is_assignment(fname))
F = xfopen_stdin(fname);
F = afopen(fname, "r");
}
} while (!F);
@@ -2752,9 +2757,8 @@ int awk_main(int argc, char **argv)
{
unsigned opt;
char *opt_F, *opt_W;
llist_t *list_v = NULL;
llist_t *list_f = NULL;
int i, j;
llist_t *opt_v = NULL;
int i, j, flen;
var *v;
var tv;
char **envp;
@@ -2812,33 +2816,35 @@ int awk_main(int argc, char **argv)
*s1 = '=';
}
}
opt_complementary = "v::f::"; /* -v and -f can occur multiple times */
opt = getopt32(argv, "F:v:f:W:", &opt_F, &list_v, &list_f, &opt_W);
opt_complementary = "v::";
opt = getopt32(argv, "F:v:f:W:", &opt_F, &opt_v, &g_progname, &opt_W);
argv += optind;
argc -= optind;
if (opt & 0x1)
setvar_s(intvar[FS], opt_F); // -F
while (list_v) { /* -v */
if (!is_assignment(llist_pop(&list_v)))
while (opt_v) { /* -v */
if (!is_assignment(llist_pop(&opt_v)))
bb_show_usage();
}
if (list_f) { /* -f */
do {
char *s = NULL;
FILE *from_file;
g_progname = llist_pop(&list_f);
from_file = xfopen_stdin(g_progname);
/* one byte is reserved for some trick in next_token */
if (opt & 0x4) { // -f
char *s = s; /* die, gcc, die */
FILE *from_file = afopen(g_progname, "r");
/* one byte is reserved for some trick in next_token */
if (fseek(from_file, 0, SEEK_END) == 0) {
flen = ftell(from_file);
s = xmalloc(flen + 4);
fseek(from_file, 0, SEEK_SET);
i = 1 + fread(s + 1, 1, flen, from_file);
} else {
for (i = j = 1; j > 0; i += j) {
s = xrealloc(s, i + 4096);
j = fread(s + i, 1, 4094, from_file);
}
s[i] = '\0';
fclose(from_file);
parse_program(s + 1);
free(s);
} while (list_f);
}
s[i] = '\0';
fclose(from_file);
parse_program(s + 1);
free(s);
} else { // no -f: take program from 1st parameter
if (!argc)
bb_show_usage();
+235 -301
View File
File diff suppressed because it is too large. Load diff
+140 -135
View File
@@ -119,7 +119,7 @@ int ed_main(int argc ATTRIBUTE_UNUSED, char **argv)
static void doCommands(void)
{
const char *cp;
char *endbuf, buf[USERSIZE];
char *endbuf, *newname, buf[USERSIZE];
int len, num1, num2;
smallint have1, have2;
@@ -168,157 +168,162 @@ static void doCommands(void)
num2 = num1;
switch (*cp++) {
case 'a':
addLines(num1 + 1);
break;
case 'c':
deleteLines(num1, num2);
addLines(num1);
break;
case 'd':
deleteLines(num1, num2);
break;
case 'f':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad file command");
case 'a':
addLines(num1 + 1);
break;
}
cp = skip_blank(cp);
if (*cp == '\0') {
if (fileName)
printf("\"%s\"\n", fileName);
else
printf("No file name\n");
break;
}
free(fileName);
fileName = xstrdup(cp);
break;
case 'i':
addLines(num1);
break;
case 'k':
cp = skip_blank(cp);
if ((*cp < 'a') || (*cp > 'z') || cp[1]) {
bb_error_msg("bad mark name");
case 'c':
deleteLines(num1, num2);
addLines(num1);
break;
}
marks[*cp - 'a'] = num2;
break;
case 'l':
printLines(num1, num2, TRUE);
break;
case 'd':
deleteLines(num1, num2);
break;
case 'p':
printLines(num1, num2, FALSE);
break;
case 'f':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad file command");
break;
}
cp = skip_blank(cp);
if (*cp == '\0') {
if (fileName)
printf("\"%s\"\n", fileName);
else
printf("No file name\n");
break;
}
newname = strdup(cp);
if (newname == NULL) {
bb_error_msg("no memory for file name");
break;
}
free(fileName);
fileName = newname;
break;
case 'q':
cp = skip_blank(cp);
if (have1 || *cp) {
bb_error_msg("bad quit command");
case 'i':
addLines(num1);
break;
}
if (!dirty)
return;
len = read_line_input("Really quit? ", buf, 16, NULL);
/* read error/EOF - no way to continue */
if (len < 0)
return;
cp = skip_blank(buf);
if ((*cp | 0x20) == 'y') /* Y or y */
return;
break;
case 'r':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad read command");
case 'k':
cp = skip_blank(cp);
if ((*cp < 'a') || (*cp > 'z') || cp[1]) {
bb_error_msg("bad mark name");
break;
}
marks[*cp - 'a'] = num2;
break;
}
cp = skip_blank(cp);
if (*cp == '\0') {
bb_error_msg("no file name");
break;
}
if (!have1)
num1 = lastNum;
if (readLines(cp, num1 + 1))
break;
if (fileName == NULL)
fileName = xstrdup(cp);
break;
case 's':
subCommand(cp, num1, num2);
break;
case 'l':
printLines(num1, num2, TRUE);
break;
case 'w':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad write command");
case 'p':
printLines(num1, num2, FALSE);
break;
}
cp = skip_blank(cp);
if (!have1) {
num1 = 1;
num2 = lastNum;
}
if (*cp == '\0')
cp = fileName;
if (cp == NULL) {
bb_error_msg("no file name specified");
break;
}
writeLines(cp, num1, num2);
break;
case 'z':
switch (*cp) {
case '-':
printLines(curNum - 21, curNum, FALSE);
case 'q':
cp = skip_blank(cp);
if (have1 || *cp) {
bb_error_msg("bad quit command");
break;
}
if (!dirty)
return;
len = read_line_input("Really quit? ", buf, 16, NULL);
/* read error/EOF - no way to continue */
if (len < 0)
return;
cp = skip_blank(buf);
if ((*cp | 0x20) == 'y') /* Y or y */
return;
break;
case 'r':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad read command");
break;
}
cp = skip_blank(cp);
if (*cp == '\0') {
bb_error_msg("no file name");
break;
}
if (!have1)
num1 = lastNum;
if (readLines(cp, num1 + 1))
break;
if (fileName == NULL)
fileName = strdup(cp);
break;
case 's':
subCommand(cp, num1, num2);
break;
case 'w':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad write command");
break;
}
cp = skip_blank(cp);
if (!have1) {
num1 = 1;
num2 = lastNum;
}
if (*cp == '\0')
cp = fileName;
if (cp == NULL) {
bb_error_msg("no file name specified");
break;
}
writeLines(cp, num1, num2);
break;
case 'z':
switch (*cp) {
case '-':
printLines(curNum - 21, curNum, FALSE);
break;
case '.':
printLines(curNum - 11, curNum + 10, FALSE);
break;
default:
printLines(curNum, curNum + 21, FALSE);
break;
}
break;
case '.':
printLines(curNum - 11, curNum + 10, FALSE);
if (have1) {
bb_error_msg("no arguments allowed");
break;
}
printLines(curNum, curNum, FALSE);
break;
case '-':
if (setCurNum(curNum - 1))
printLines(curNum, curNum, FALSE);
break;
case '=':
printf("%d\n", num1);
break;
case '\0':
if (have1) {
printLines(num2, num2, FALSE);
break;
}
if (setCurNum(curNum + 1))
printLines(curNum, curNum, FALSE);
break;
default:
printLines(curNum, curNum + 21, FALSE);
bb_error_msg("unimplemented command");
break;
}
break;
case '.':
if (have1) {
bb_error_msg("no arguments allowed");
break;
}
printLines(curNum, curNum, FALSE);
break;
case '-':
if (setCurNum(curNum - 1))
printLines(curNum, curNum, FALSE);
break;
case '=':
printf("%d\n", num1);
break;
case '\0':
if (have1) {
printLines(num2, num2, FALSE);
break;
}
if (setCurNum(curNum + 1))
printLines(curNum, curNum, FALSE);
break;
default:
bb_error_msg("unimplemented command");
break;
}
}
}
@@ -825,7 +830,7 @@ static int printLines(int num1, int num2, int expandFlag)
while (num1 <= num2) {
if (!expandFlag) {
write(STDOUT_FILENO, lp->data, lp->len);
write(1, lp->data, lp->len);
setCurNum(num1++);
lp = lp->next;
continue;
+152 -135
View File
@@ -19,236 +19,253 @@
* - Reject file isnt saved
*/
#include <getopt.h>
#include "libbb.h"
static unsigned copy_lines(FILE *src_stream, FILE *dst_stream, unsigned lines_count)
static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsigned int lines_count)
{
while (src_stream && lines_count) {
unsigned int i = 0;
while (src_stream && (i < lines_count)) {
char *line;
line = xmalloc_fgets(src_stream);
if (line == NULL) {
break;
}
if (fputs(line, dst_stream) == EOF) {
if (fputs(line, dest_stream) == EOF) {
bb_perror_msg_and_die("error writing to new file");
}
free(line);
lines_count--;
i++;
}
return lines_count;
return i;
}
/* If patch_level is -1 it will remove all directory names
* char *line must be greater than 4 chars
* returns NULL if the file doesnt exist or error
* returns malloc'ed filename
* NB: frees 1st argument!
*/
static char *extract_filename(char *line, int patch_level, const char *pat)
static char *extract_filename(char *line, int patch_level)
{
char *temp = NULL, *filename_start_ptr = line + 4;
char *temp, *filename_start_ptr = line + 4;
int i;
if (strncmp(line, pat, 4) == 0) {
/* Terminate string at end of source filename */
line[strcspn(line,"\t\n\r")] = '\0';
/* Terminate string at end of source filename */
temp = strchrnul(filename_start_ptr, '\t');
*temp = '\0';
/* Skip over (patch_level) number of leading directories */
while (patch_level--) {
temp = strchr(filename_start_ptr, '/');
if (!temp)
break;
filename_start_ptr = temp + 1;
}
temp = xstrdup(filename_start_ptr);
/* Skip over (patch_level) number of leading directories */
if (patch_level == -1)
patch_level = INT_MAX;
for (i = 0; i < patch_level; i++) {
temp = strchr(filename_start_ptr, '/');
if (!temp)
break;
filename_start_ptr = temp + 1;
}
free(line);
return temp;
return xstrdup(filename_start_ptr);
}
int patch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int patch_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
struct stat saved_stat;
int patch_level = -1;
char *patch_line;
FILE *patch_file;
int patch_level;
int ret = 0;
char plus = '+';
xfunc_error_retval = 2;
int ret;
FILE *patch_file = NULL;
struct stat saved_stat;
{
const char *p = "-1";
const char *i = "-"; /* compat */
if (getopt32(argv, "p:i:R", &p, &i) & 4)
plus = '-';
patch_level = xatoi(p); /* can be negative! */
patch_file = xfopen_stdin(i);
char *p, *i;
ret = getopt32(argv, "p:i:", &p, &i);
if (ret & 1)
patch_level = xatol_range(p, -1, USHRT_MAX);
if (ret & 2) {
patch_file = xfopen(i, "r");
} else {
patch_file = stdin;
}
ret = 0;
}
patch_line = xmalloc_fgetline(patch_file);
patch_line = xmalloc_getline(patch_file);
while (patch_line) {
FILE *src_stream;
FILE *dst_stream;
//char *old_filename;
char *original_filename;
char *new_filename;
char *backup_filename;
unsigned src_cur_line = 1;
unsigned dst_cur_line = 0;
unsigned dst_beg_line;
unsigned bad_hunk_count = 0;
unsigned hunk_count = 0;
smallint copy_trailing_lines_flag = 0;
unsigned int src_cur_line = 1;
unsigned int dest_cur_line = 0;
unsigned int dest_beg_line;
unsigned int bad_hunk_count = 0;
unsigned int hunk_count = 0;
char copy_trailing_lines_flag = 0;
/* Skip everything upto the "---" marker
* No need to parse the lines "Only in <dir>", and "diff <args>"
*/
do {
/* Extract the filename used before the patch was generated */
new_filename = extract_filename(patch_line, patch_level, "--- ");
// was old_filename above
patch_line = xmalloc_fgetline(patch_file);
if (!patch_line) goto quit;
} while (!new_filename);
free(new_filename); // "source" filename is irrelevant
new_filename = extract_filename(patch_line, patch_level, "+++ ");
if (!new_filename) {
bb_error_msg_and_die("invalid patch");
while (patch_line && strncmp(patch_line, "--- ", 4) != 0) {
free(patch_line);
patch_line = xmalloc_getline(patch_file);
}
/* FIXME: patch_line NULL check?? */
/* Get access rights from the file to be patched */
if (stat(new_filename, &saved_stat) != 0) {
char *slash = strrchr(new_filename, '/');
if (slash) {
/* Create leading directories */
*slash = '\0';
/* Extract the filename used before the patch was generated */
original_filename = extract_filename(patch_line, patch_level);
free(patch_line);
patch_line = xmalloc_getline(patch_file);
/* FIXME: NULL check?? */
if (strncmp(patch_line, "+++ ", 4) != 0) {
ret = 2;
bb_error_msg("invalid patch");
continue;
}
new_filename = extract_filename(patch_line, patch_level);
free(patch_line);
/* Get access rights from the file to be patched, -1 file does not exist */
if (stat(new_filename, &saved_stat)) {
char *line_ptr;
/* Create leading directories */
line_ptr = strrchr(new_filename, '/');
if (line_ptr) {
*line_ptr = '\0';
bb_make_directory(new_filename, -1, FILEUTILS_RECUR);
*slash = '/';
*line_ptr = '/';
}
dst_stream = xfopen(new_filename, "w+");
backup_filename = NULL;
src_stream = NULL;
saved_stat.st_mode = 0644;
} else {
backup_filename = xasprintf("%s.orig", new_filename);
backup_filename = xmalloc(strlen(new_filename) + 6);
strcpy(backup_filename, new_filename);
strcat(backup_filename, ".orig");
xrename(new_filename, backup_filename);
src_stream = xfopen(backup_filename, "r");
dst_stream = xfopen(new_filename, "w");
fchmod(fileno(dst_stream), saved_stat.st_mode);
}
if ((backup_filename == NULL) || stat(original_filename, &saved_stat)) {
src_stream = NULL;
} else {
if (strcmp(original_filename, new_filename) == 0) {
src_stream = xfopen(backup_filename, "r");
} else {
src_stream = xfopen(original_filename, "r");
}
}
dst_stream = xfopen(new_filename, "w");
fchmod(fileno(dst_stream), saved_stat.st_mode);
printf("patching file %s\n", new_filename);
/* Handle all hunks for this file */
/* Handle each hunk */
patch_line = xmalloc_fgets(patch_file);
while (patch_line) {
unsigned count;
unsigned src_beg_line;
unsigned hunk_offset_start;
unsigned src_last_line = 1;
unsigned dst_last_line = 1;
unsigned int count;
unsigned int src_beg_line;
unsigned int unused;
unsigned int hunk_offset_start = 0;
int hunk_error = 0;
if ((sscanf(patch_line, "@@ -%d,%d +%d,%d", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3)
&& (sscanf(patch_line, "@@ -%d +%d,%d", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
) {
/* This bit should be improved */
if ((sscanf(patch_line, "@@ -%d,%d +%d,%d @@", &src_beg_line, &unused, &dest_beg_line, &unused) != 4) &&
(sscanf(patch_line, "@@ -%d,%d +%d @@", &src_beg_line, &unused, &dest_beg_line) != 3) &&
(sscanf(patch_line, "@@ -%d +%d,%d @@", &src_beg_line, &dest_beg_line, &unused) != 3)) {
/* No more hunks for this file */
break;
}
if (plus != '+') {
/* reverse patch */
unsigned tmp = src_last_line;
src_last_line = dst_last_line;
dst_last_line = tmp;
tmp = src_beg_line;
src_beg_line = dst_beg_line;
dst_beg_line = tmp;
}
free(patch_line);
hunk_count++;
if (src_beg_line && dst_beg_line) {
if (src_beg_line && dest_beg_line) {
/* Copy unmodified lines upto start of hunk */
/* src_beg_line will be 0 if it's a new file */
/* src_beg_line will be 0 if its a new file */
count = src_beg_line - src_cur_line;
if (copy_lines(src_stream, dst_stream, count)) {
if (copy_lines(src_stream, dst_stream, count) != count) {
bb_error_msg_and_die("bad src file");
}
src_cur_line += count;
dst_cur_line += count;
dest_cur_line += count;
copy_trailing_lines_flag = 1;
}
src_last_line += hunk_offset_start = src_cur_line;
dst_last_line += dst_cur_line;
hunk_offset_start = src_cur_line;
while (1) {
free(patch_line);
patch_line = xmalloc_fgets(patch_file);
if (patch_line == NULL)
break; /* EOF */
if ((*patch_line != '-') && (*patch_line != '+')
&& (*patch_line != ' ')
) {
break; /* End of hunk */
}
if (*patch_line != plus) { /* '-' or ' ' */
while ((patch_line = xmalloc_fgets(patch_file)) != NULL) {
if ((*patch_line == '-') || (*patch_line == ' ')) {
char *src_line = NULL;
if (src_cur_line == src_last_line)
break;
if (src_stream) {
src_line = xmalloc_fgets(src_stream);
if (src_line) {
int diff = strcmp(src_line, patch_line + 1);
if (!src_line) {
hunk_error++;
break;
} else {
src_cur_line++;
free(src_line);
if (diff)
src_line = NULL;
}
if (strcmp(src_line, patch_line + 1) != 0) {
bb_error_msg("hunk #%d FAILED at %d", hunk_count, hunk_offset_start);
hunk_error++;
free(patch_line);
/* Probably need to find next hunk, etc... */
/* but for now we just bail out */
patch_line = NULL;
break;
}
free(src_line);
}
if (!src_line) {
bb_error_msg("hunk #%u FAILED at %u", hunk_count, hunk_offset_start);
bad_hunk_count++;
break;
if (*patch_line == ' ') {
fputs(patch_line + 1, dst_stream);
dest_cur_line++;
}
if (*patch_line != ' ') { /* '-' */
continue;
}
}
if (dst_cur_line == dst_last_line)
} else if (*patch_line == '+') {
fputs(patch_line + 1, dst_stream);
dest_cur_line++;
} else {
break;
fputs(patch_line + 1, dst_stream);
dst_cur_line++;
} /* end of while loop handling one hunk */
} /* end of while loop handling one file */
}
free(patch_line);
}
if (hunk_error) {
bad_hunk_count++;
}
}
/* Cleanup last patched file */
if (copy_trailing_lines_flag) {
copy_lines(src_stream, dst_stream, (unsigned)(-1));
copy_lines(src_stream, dst_stream, -1);
}
if (src_stream) {
fclose(src_stream);
}
fclose(dst_stream);
if (dst_stream) {
fclose(dst_stream);
}
if (bad_hunk_count) {
ret = 1;
bb_error_msg("%u out of %u hunk FAILED", bad_hunk_count, hunk_count);
if (!ret) {
ret = 1;
}
bb_error_msg("%d out of %d hunk FAILED", bad_hunk_count, hunk_count);
} else {
/* It worked, we can remove the backup */
if (backup_filename) {
unlink(backup_filename);
}
if ((dst_cur_line == 0) || (dst_beg_line == 0)) {
if ((dest_cur_line == 0) || (dest_beg_line == 0)) {
/* The new patched file is empty, remove it */
xunlink(new_filename);
// /* old_filename and new_filename may be the same file */
// unlink(old_filename);
if (strcmp(new_filename, original_filename) != 0)
xunlink(original_filename);
}
}
free(backup_filename);
//free(old_filename);
free(new_filename);
} /* end of "while there are patch lines" */
quit:
}
/* 0 = SUCCESS
* 1 = Some hunks failed
* 2 = More serious problems (exited earlier)
* 2 = More serious problems
*/
return ret;
}
+10 -8
View File
@@ -628,7 +628,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line)
{
char *oldline = *line;
int altered = 0;
unsigned match_count = 0;
int match_count = 0;
regex_t *current_regex;
/* Handle empty regex. */
@@ -665,9 +665,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line)
/* If we aren't interested in this match, output old line to
end of match and continue */
if (sed_cmd->which_match
&& (sed_cmd->which_match != match_count)
) {
if (sed_cmd->which_match && sed_cmd->which_match != match_count) {
for (i = 0; i < G.regmatch[0].rm_eo; i++)
pipe_putc(*oldline++);
continue;
@@ -1030,7 +1028,7 @@ static void process_files(void)
if (rfile) {
char *line;
while ((line = xmalloc_fgetline(rfile))
while ((line = xmalloc_getline(rfile))
!= NULL)
append(line);
xprint_and_close_file(rfile);
@@ -1267,17 +1265,21 @@ int sed_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (opt & 0x2) G.regex_type |= REG_EXTENDED; // -r
//if (opt & 0x4) G.be_quiet++; // -n
while (opt_e) { // -e
add_cmd_block(llist_pop(&opt_e));
add_cmd_block(opt_e->data);
opt_e = opt_e->link;
/* we leak opt_e here... */
}
while (opt_f) { // -f
char *line;
FILE *cmdfile;
cmdfile = xfopen(llist_pop(&opt_f), "r");
while ((line = xmalloc_fgetline(cmdfile)) != NULL) {
cmdfile = xfopen(opt_f->data, "r");
while ((line = xmalloc_getline(cmdfile)) != NULL) {
add_cmd(line);
free(line);
}
fclose(cmdfile);
opt_f = opt_f->link;
/* we leak opt_f here... */
}
/* if we didn't get a pattern from -e or -f, use argv[0] */
if (!(opt & 0x18)) {
+181 -212
View File
@@ -112,19 +112,11 @@ enum {
S_END_ALNUM = 5, // used in skip_thing() for moving "dot"
};
/* vi.c expects chars to be unsigned. */
/* busybox build system provides that, but it's better */
/* to audit and fix the source */
struct globals {
/* many references - keep near the top of globals */
char *text, *end; // pointers to the user data in memory
char *dot; // where all the action takes place
int text_size; // size of the allocated buffer
/* the rest */
smallint vi_setops;
static smallint vi_setops;
#define VI_AUTOINDENT 1
#define VI_SHOWMATCH 2
#define VI_IGNORECASE 4
@@ -135,76 +127,83 @@ struct globals {
/* indicate error with beep or flash */
#define err_method (vi_setops & VI_ERR_METHOD)
static smallint editing; // >0 while we are editing a file
// [code audit says "can be 0 or 1 only"]
static smallint cmd_mode; // 0=command 1=insert 2=replace
static smallint file_modified; // buffer contents changed
static smallint last_file_modified = -1;
static int fn_start; // index of first cmd line file name
static int save_argc; // how many file names on cmd line
static int cmdcnt; // repetition count
static int rows, columns; // the terminal screen is this size
static int crow, ccol; // cursor is on Crow x Ccol
static int offset; // chars scrolled off the screen to the left
static char *status_buffer; // mesages to the user
#define STATUS_BUFFER_LEN 200
static int have_status_msg; // is default edit status needed?
// [don't make smallint!]
static int last_status_cksum; // hash of current status line
static char *current_filename; // current file name
//static char *text, *end; // pointers to the user data in memory
static char *screen; // pointer to the virtual screen buffer
static int screensize; // and its size
static char *screenbegin; // index into text[], of top line on the screen
//static char *dot; // where all the action takes place
static int tabstop;
static char erase_char; // the users erase character
static char last_input_char; // last char read from user
static char last_forward_char; // last char searched for with 'f'
#if ENABLE_FEATURE_VI_READONLY
smallint readonly_mode;
//static smallint vi_readonly, readonly;
static smallint readonly_mode = 0;
#define SET_READONLY_FILE(flags) ((flags) |= 0x01)
#define SET_READONLY_MODE(flags) ((flags) |= 0x02)
#define UNSET_READONLY_FILE(flags) ((flags) &= 0xfe)
#else
#define SET_READONLY_FILE(flags) ((void)0)
#define SET_READONLY_MODE(flags) ((void)0)
#define UNSET_READONLY_FILE(flags) ((void)0)
#define readonly_mode 0
#define SET_READONLY_FILE(flags)
#define SET_READONLY_MODE(flags)
#define UNSET_READONLY_FILE(flags)
#endif
smallint editing; // >0 while we are editing a file
// [code audit says "can be 0, 1 or 2 only"]
smallint cmd_mode; // 0=command 1=insert 2=replace
int file_modified; // buffer contents changed (counter, not flag!)
int last_file_modified; // = -1;
int fn_start; // index of first cmd line file name
int save_argc; // how many file names on cmd line
int cmdcnt; // repetition count
unsigned rows, columns; // the terminal screen is this size
int crow, ccol; // cursor is on Crow x Ccol
int offset; // chars scrolled off the screen to the left
int have_status_msg; // is default edit status needed?
// [don't make smallint!]
int last_status_cksum; // hash of current status line
char *current_filename;
char *screenbegin; // index into text[], of top line on the screen
char *screen; // pointer to the virtual screen buffer
int screensize; // and its size
int tabstop;
char erase_char; // the users erase character
char last_input_char; // last char read from user
char last_forward_char; // last char searched for with 'f'
#if ENABLE_FEATURE_VI_DOT_CMD
smallint adding2q; // are we currently adding user input to q
int lmc_len; // length of last_modifying_cmd
char *ioq, *ioq_start; // pointer to string for get_one_char to "read"
static smallint adding2q; // are we currently adding user input to q
static char *last_modifying_cmd; // [MAX_INPUT_LEN] last modifying cmd for "."
static smallint lmc_len; // length of last_modifying_cmd
static char *ioq, *ioq_start; // pointer to string for get_one_char to "read"
#endif
#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
int last_row; // where the cursor was last moved to
static int last_row; // where the cursor was last moved to
#endif
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
int my_pid;
static int my_pid;
#endif
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
char *modifying_cmds; // cmds that modify text[]
static char *modifying_cmds; // cmds that modify text[]
#endif
#if ENABLE_FEATURE_VI_SEARCH
char *last_search_pattern; // last pattern from a '/' or '?' search
static char *last_search_pattern; // last pattern from a '/' or '?' search
#endif
int chars_to_parse;
/* former statics */
#if ENABLE_FEATURE_VI_YANKMARK
char *edit_file__cur_line;
#endif
int refresh__old_offset;
int format_edit_status__tot;
/* a few references only */
/* Moving biggest data to malloced space... */
struct globals {
/* many references - keep near the top of globals */
char *text, *end; // pointers to the user data in memory
char *dot; // where all the action takes place
int text_size; // size of the allocated buffer
#if ENABLE_FEATURE_VI_YANKMARK
int YDreg, Ureg; // default delete register and orig line for "U"
char *reg[28]; // named register a-z, "D", and "U" 0-25,26,27
char *mark[28]; // user marks points somewhere in text[]- a-z and previous context ''
char *context_start, *context_end;
#endif
/* a few references only */
#if ENABLE_FEATURE_VI_USE_SIGNALS
sigjmp_buf restart; // catch_sig()
sigjmp_buf restart; // catch_sig()
#endif
struct termios term_orig, term_vi; // remember what the cooked mode was
struct termios term_orig, term_vi; // remember what the cooked mode was
#if ENABLE_FEATURE_VI_COLON
char *initial_cmds[3]; // currently 2 entries, NULL terminated
#endif
@@ -215,12 +214,6 @@ struct globals {
#else
char readbuffer[32];
#endif
#define STATUS_BUFFER_LEN 200
char status_buffer[STATUS_BUFFER_LEN]; // messages to the user
#if ENABLE_FEATURE_VI_DOT_CMD
char last_modifying_cmd[MAX_INPUT_LEN]; // last modifying cmd for "."
#endif
char get_input_line__buf[MAX_INPUT_LEN]; /* former static */
char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2];
};
@@ -230,50 +223,6 @@ struct globals {
#define end (G.end )
#define dot (G.dot )
#define reg (G.reg )
#define vi_setops (G.vi_setops )
#define editing (G.editing )
#define cmd_mode (G.cmd_mode )
#define file_modified (G.file_modified )
#define last_file_modified (G.last_file_modified )
#define fn_start (G.fn_start )
#define save_argc (G.save_argc )
#define cmdcnt (G.cmdcnt )
#define rows (G.rows )
#define columns (G.columns )
#define crow (G.crow )
#define ccol (G.ccol )
#define offset (G.offset )
#define status_buffer (G.status_buffer )
#define have_status_msg (G.have_status_msg )
#define last_status_cksum (G.last_status_cksum )
#define current_filename (G.current_filename )
#define screen (G.screen )
#define screensize (G.screensize )
#define screenbegin (G.screenbegin )
#define tabstop (G.tabstop )
#define erase_char (G.erase_char )
#define last_input_char (G.last_input_char )
#define last_forward_char (G.last_forward_char )
#if ENABLE_FEATURE_VI_READONLY
#define readonly_mode (G.readonly_mode )
#else
#define readonly_mode 0
#endif
#define adding2q (G.adding2q )
#define lmc_len (G.lmc_len )
#define ioq (G.ioq )
#define ioq_start (G.ioq_start )
#define last_row (G.last_row )
#define my_pid (G.my_pid )
#define modifying_cmds (G.modifying_cmds )
#define last_search_pattern (G.last_search_pattern)
#define chars_to_parse (G.chars_to_parse )
#define edit_file__cur_line (G.edit_file__cur_line)
#define refresh__old_offset (G.refresh__old_offset)
#define format_edit_status__tot (G.format_edit_status__tot)
#define YDreg (G.YDreg )
#define Ureg (G.Ureg )
#define mark (G.mark )
@@ -285,15 +234,10 @@ struct globals {
#define initial_cmds (G.initial_cmds )
#define readbuffer (G.readbuffer )
#define scr_out_buf (G.scr_out_buf )
#define last_modifying_cmd (G.last_modifying_cmd )
#define get_input_line__buf (G.get_input_line__buf)
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
last_file_modified = -1; \
} while (0)
static int init_text_buffer(char *); // init from file or create new
static void edit_file(char *); // edit one file
static void do_cmd(char); // execute a command
@@ -411,15 +355,22 @@ int vi_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int vi_main(int argc, char **argv)
{
int c;
INIT_G();
RESERVE_CONFIG_BUFFER(STATUS_BUFFER, STATUS_BUFFER_LEN);
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
my_pid = getpid();
#endif
INIT_G();
#if ENABLE_FEATURE_VI_CRASHME
srand((long) my_pid);
#endif
status_buffer = STATUS_BUFFER;
last_status_cksum = 0;
text = NULL;
#ifdef NO_SUCH_APPLET_YET
/* If we aren't "vi", we are "view" */
if (ENABLE_FEATURE_VI_READONLY && applet_name[2]) {
@@ -428,6 +379,9 @@ int vi_main(int argc, char **argv)
#endif
vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE;
#if ENABLE_FEATURE_VI_YANKMARK
memset(reg, 0, sizeof(reg)); // init the yank regs
#endif
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
modifying_cmds = (char *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[]
#endif
@@ -463,8 +417,9 @@ int vi_main(int argc, char **argv)
case 'H':
show_help();
/* fall through */
default:
bb_show_usage();
bb_show_usage();
return 1;
}
}
@@ -496,7 +451,9 @@ static int init_text_buffer(char *fn)
/* allocate/reallocate text buffer */
free(text);
text_size = size + 10240;
text_size = size * 2;
if (text_size < 10240)
text_size = 10240; // have a minimum size for new files
screenbegin = dot = end = text = xzalloc(text_size);
if (fn != current_filename) {
@@ -522,14 +479,15 @@ static int init_text_buffer(char *fn)
static void edit_file(char *fn)
{
#if ENABLE_FEATURE_VI_YANKMARK
#define cur_line edit_file__cur_line
#endif
char c;
int size;
#if ENABLE_FEATURE_VI_USE_SIGNALS
int sig;
#endif
#if ENABLE_FEATURE_VI_YANKMARK
static char *cur_line;
#endif
editing = 1; // 0 = exit, 1 = one file, 2 = multiple files
rawmode();
@@ -623,7 +581,7 @@ static void edit_file(char *fn)
// These are commands that change text[].
// Remember the input for the "." command
if (!adding2q && ioq_start == NULL
&& c != '\0' && strchr(modifying_cmds, c)
&& strchr(modifying_cmds, c)
) {
start_new_cmd_q(c);
}
@@ -645,10 +603,9 @@ static void edit_file(char *fn)
}
//-------------------------------------------------------------------
place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
clear_to_eol(); // erase to end of line
place_cursor(rows, 0, FALSE); // go to bottom of screen
clear_to_eol(); // Erase to end of line
cookmode();
#undef cur_line
}
//----- The Colon commands -------------------------------------
@@ -1124,7 +1081,7 @@ static void colon(char *buf)
}
#endif /* FEATURE_VI_SEARCH */
} else if (strncasecmp(cmd, "version", i) == 0) { // show software version
status_line(BB_VER " " BB_BT);
status_line("%s", BB_VER " " BB_BT);
} else if (strncasecmp(cmd, "write", i) == 0 // write text to file
|| strncasecmp(cmd, "wq", i) == 0
|| strncasecmp(cmd, "wn", i) == 0
@@ -1274,8 +1231,9 @@ static void sync_cursor(char *d, int *row, int *col)
// handle tabs like real vi
if (d == tp && cmd_mode) {
break;
} else {
co = next_tabstop(co);
}
co = next_tabstop(co);
} else if ((unsigned char)*tp < ' ' || *tp == 0x7f) {
co++; // display as ^X, use 2 columns
}
@@ -1325,7 +1283,7 @@ static char *begin_line(char *p) // return pointer to first char cur line
return p;
}
static char *end_line(char *p) // return pointer to NL of cur line
static char *end_line(char *p) // return pointer to NL of cur line line
{
if (p < end - 1) {
p = memchr(p, '\n', end - p - 1);
@@ -1347,7 +1305,7 @@ static char *dollar_line(char *p) // return pointer to just before NL line
static char *prev_line(char *p) // return pointer first char prev line
{
p = begin_line(p); // goto begining of cur line
if (p > text && p[-1] == '\n')
if (p[-1] == '\n' && p > text)
p--; // step to prev line
p = begin_line(p); // goto begining of prev line
return p;
@@ -1356,7 +1314,7 @@ static char *prev_line(char *p) // return pointer first char prev line
static char *next_line(char *p) // return pointer first char next line
{
p = end_line(p);
if (p < end - 1 && *p == '\n')
if (*p == '\n' && p < end - 1)
p++; // step to next line
return p;
}
@@ -1539,7 +1497,7 @@ static char *new_screen(int ro, int co)
}
#if ENABLE_FEATURE_VI_SEARCH
static int mycmp(const char *s1, const char *s2, int len)
static int mycmp(const char * s1, const char * s2, int len)
{
int i;
@@ -1551,7 +1509,7 @@ static int mycmp(const char *s1, const char *s2, int len)
}
// search for pattern starting at p
static char *char_search(char *p, const char *pat, int dir, int range)
static char *char_search(char * p, const char * pat, int dir, int range)
{
#ifndef REGEX_SEARCH
char *start, *stop;
@@ -1644,7 +1602,7 @@ static char *char_search(char *p, const char *pat, int dir, int range)
}
#endif /* FEATURE_VI_SEARCH */
static char *char_insert(char *p, char c) // insert the char c at 'p'
static char *char_insert(char * p, char c) // insert the char c at 'p'
{
if (c == 22) { // Is this an ctrl-V?
p = stupid_insert(p, '^'); // use ^ to indicate literal next
@@ -1653,7 +1611,7 @@ static char *char_insert(char *p, char c) // insert the char c at 'p'
c = get_one_char();
*p = c;
p++;
file_modified++;
file_modified++; // has the file been modified
} else if (c == 27) { // Is this an ESC?
cmd_mode = 0;
cmdcnt = 0;
@@ -1693,15 +1651,18 @@ static char *char_insert(char *p, char c) // insert the char c at 'p'
return p;
}
static char *stupid_insert(char *p, char c) // stupidly insert the char c at 'p'
static char *stupid_insert(char * p, char c) // stupidly insert the char c at 'p'
{
p = text_hole_make(p, 1);
*p = c;
//file_modified++; - done by text_hole_make()
return p + 1;
if (p != 0) {
*p = c;
file_modified++; // has the file been modified
p++;
}
return p;
}
static int find_range(char **start, char **stop, char c)
static int find_range(char ** start, char ** stop, char c)
{
char *save_dot, *p, *q, *t;
int cnt, multiline = 0;
@@ -1757,7 +1718,7 @@ static int find_range(char **start, char **stop, char c)
p = t;
}
// backward char movements don't include start position
// backward char movements don't include start position
if (q > p && strchr("^0bBh\b\177", c)) q--;
multiline = 0;
@@ -1774,7 +1735,7 @@ static int find_range(char **start, char **stop, char c)
return multiline;
}
static int st_test(char *p, int type, int dir, char *tested)
static int st_test(char * p, int type, int dir, char * tested)
{
char c, c0, ci;
int test, inc;
@@ -1808,7 +1769,7 @@ static int st_test(char *p, int type, int dir, char *tested)
return test;
}
static char *skip_thing(char *p, int linecnt, int dir, int type)
static char *skip_thing(char * p, int linecnt, int dir, int type)
{
char c;
@@ -1826,7 +1787,7 @@ static char *skip_thing(char *p, int linecnt, int dir, int type)
}
// find matching char of pair () [] {}
static char *find_pair(char *p, const char c)
static char *find_pair(char * p, const char c)
{
char match, *q;
int dir, level;
@@ -1879,29 +1840,31 @@ static void showmatching(char *p)
#endif /* FEATURE_VI_SETOPTS */
// open a hole in text[]
static char *text_hole_make(char *p, int size) // at "p", make a 'size' byte hole
static char *text_hole_make(char * p, int size) // at "p", make a 'size' byte hole
{
char *src, *dest;
int cnt;
if (size <= 0)
return p;
end += size; // adjust the new END
if (end >= (text + text_size)) {
char *new_text;
text_size += end - (text + text_size) + 10240;
new_text = xrealloc(text, text_size);
screenbegin = new_text + (screenbegin - text);
dot = new_text + (dot - text);
end = new_text + (end - text);
p = new_text + (p - text);
text = new_text;
goto thm0;
src = p;
dest = p + size;
cnt = end - src; // the rest of buffer
if ( ((end + size) >= (text + text_size)) // TODO: realloc here
|| memmove(dest, src, cnt) != dest) {
status_line_bold("can't create room for new characters");
p = NULL;
goto thm0;
}
memmove(p + size, p, end - size - p);
memset(p, ' ', size); // clear new hole
file_modified++;
end += size; // adjust the new END
file_modified++; // has the file been modified
thm0:
return p;
}
// close a hole in text[]
static char *text_hole_delete(char *p, char *q) // delete "p" through "q", inclusive
static char *text_hole_delete(char * p, char * q) // delete "p" through "q", inclusive
{
char *src, *dest;
int cnt, hole_size;
@@ -1922,14 +1885,16 @@ static char *text_hole_delete(char *p, char *q) // delete "p" through "q", inclu
goto thd0;
if (src >= end)
goto thd_atend; // just delete the end of the buffer
memmove(dest, src, cnt);
if (memmove(dest, src, cnt) != dest) {
status_line_bold("can't delete the character");
}
thd_atend:
end = end - hole_size; // adjust the new END
if (dest >= end)
dest = end - 1; // make sure dest in below end-1
if (end <= text)
dest = end = text; // keep pointers valid
file_modified++;
file_modified++; // has the file been modified
thd0:
return dest;
}
@@ -1937,7 +1902,7 @@ static char *text_hole_delete(char *p, char *q) // delete "p" through "q", inclu
// copy text into register, then delete text.
// if dist <= 0, do not include, or go past, a NewLine
//
static char *yank_delete(char *start, char *stop, int dist, int yf)
static char *yank_delete(char * start, char * stop, int dist, int yf)
{
char *p;
@@ -2008,10 +1973,12 @@ static void show_help(void)
static void start_new_cmd_q(char c)
{
// get buffer for new cmd
if (!last_modifying_cmd)
last_modifying_cmd = xzalloc(MAX_INPUT_LEN);
// if there is a current cmd count put it in the buffer first
if (cmdcnt > 0) {
if (cmdcnt > 0)
lmc_len = sprintf(last_modifying_cmd, "%d%c", cmdcnt, c);
} else { // just save char c onto queue
else { // just save char c onto queue
last_modifying_cmd[0] = c;
lmc_len = 1;
}
@@ -2030,26 +1997,27 @@ static void end_cmd_q(void)
#if ENABLE_FEATURE_VI_YANKMARK \
|| (ENABLE_FEATURE_VI_COLON && ENABLE_FEATURE_VI_SEARCH) \
|| ENABLE_FEATURE_VI_CRASHME
static char *string_insert(char *p, char *s) // insert the string at 'p'
static char *string_insert(char * p, char * s) // insert the string at 'p'
{
int cnt, i;
i = strlen(s);
text_hole_make(p, i);
strncpy(p, s, i);
for (cnt = 0; *s != '\0'; s++) {
if (*s == '\n')
cnt++;
}
if (text_hole_make(p, i)) {
strncpy(p, s, i);
for (cnt = 0; *s != '\0'; s++) {
if (*s == '\n')
cnt++;
}
#if ENABLE_FEATURE_VI_YANKMARK
status_line("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
status_line("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
#endif
}
return p;
}
#endif
#if ENABLE_FEATURE_VI_YANKMARK
static char *text_yank(char *p, char *q, int dest) // copy text into a register
static char *text_yank(char * p, char * q, int dest) // copy text into a register
{
char *t;
int cnt;
@@ -2196,6 +2164,8 @@ static int mysleep(int hund) // sleep for 'h' 1/100 seconds
return safe_poll(pfd, 1, hund*10) > 0;
}
static int chars_to_parse;
//----- IO Routines --------------------------------------------
static char readit(void) // read (maybe cursor) key from stdin
{
@@ -2247,20 +2217,18 @@ static char readit(void) // read (maybe cursor) key from stdin
fflush(stdout);
n = chars_to_parse;
// get input from User - are there already input chars in Q?
// get input from User- are there already input chars in Q?
if (n <= 0) {
// the Q is empty, wait for a typed char
again:
n = safe_read(STDIN_FILENO, readbuffer, sizeof(readbuffer));
if (n <= 0) {
place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
clear_to_eol(); // erase to end of line
cookmode(); // terminal to "cooked"
bb_error_msg_and_die("can't read user input");
n = safe_read(0, readbuffer, sizeof(readbuffer));
if (n < 0) {
if (errno == EBADF || errno == EFAULT || errno == EINVAL
|| errno == EIO)
editing = 0; // want to exit
errno = 0;
}
/* elsewhere we can get very confused by NULs */
if (readbuffer[0] == '\0')
goto again;
if (n <= 0)
return 0; // error
if (readbuffer[0] == 27) {
// This is an ESC char. Is this Esc sequence?
// Could be bare Esc key. See if there are any
@@ -2271,11 +2239,9 @@ static char readit(void) // read (maybe cursor) key from stdin
pfd[0].events = POLLIN;
// keep reading while there are input chars, and room in buffer
// for a complete ESC sequence (assuming 8 chars is enough)
while ((safe_poll(pfd, 1, 0) > 0)
&& ((size_t)n <= (sizeof(readbuffer) - 8))
) {
while (safe_poll(pfd, 1, 0) > 0 && n <= (sizeof(readbuffer) - 8)) {
// read the rest of the ESC string
int r = safe_read(STDIN_FILENO, readbuffer + n, sizeof(readbuffer) - n);
int r = safe_read(0, readbuffer + n, sizeof(readbuffer) - n);
if (r > 0)
n += r;
}
@@ -2332,11 +2298,13 @@ static char get_one_char(void)
} else {
// adding STDIN chars to q
c = readit(); // get the users input
if (lmc_len >= MAX_INPUT_LEN - 1) {
status_line_bold("last_modifying_cmd overrun");
} else {
// add new char to q
last_modifying_cmd[lmc_len++] = c;
if (last_modifying_cmd != NULL) {
if (lmc_len >= MAX_INPUT_LEN - 1) {
status_line_bold("last_modifying_cmd overrun");
} else {
// add new char to q
last_modifying_cmd[lmc_len++] = c;
}
}
}
#else
@@ -2348,12 +2316,13 @@ static char get_one_char(void)
// Get input line (uses "status line" area)
static char *get_input_line(const char *prompt)
{
// char [MAX_INPUT_LEN]
#define buf get_input_line__buf
static char *buf; // [MAX_INPUT_LEN]
char c;
int i;
if (!buf) buf = xmalloc(MAX_INPUT_LEN);
strcpy(buf, prompt);
last_status_cksum = 0; // force status update
place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen
@@ -2379,7 +2348,6 @@ static char *get_input_line(const char *prompt)
}
refresh(FALSE);
return buf;
#undef buf
}
static int file_size(const char *fn) // what is the byte size of "fn"
@@ -2393,7 +2361,7 @@ static int file_size(const char *fn) // what is the byte size of "fn"
return cnt;
}
static int file_insert(const char *fn, char *p
static int file_insert(const char * fn, char *p
USE_FEATURE_VI_READONLY(, int update_ro_status))
{
int cnt = -1;
@@ -2405,11 +2373,18 @@ static int file_insert(const char *fn, char *p
status_line_bold("\"%s\" %s", fn, strerror(errno));
goto fi0;
}
if (!S_ISREG(statbuf.st_mode)) {
if ((statbuf.st_mode & S_IFREG) == 0) {
// This is not a regular file
status_line_bold("\"%s\" Not a regular file", fn);
goto fi0;
}
/* // this check is done by open()
if ((statbuf.st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) == 0) {
// dont have any read permissions
status_line_bold("\"%s\" Not readable", fn);
goto fi0;
}
*/
if (p < text || p > end) {
status_line_bold("Trying to insert file outside of memory");
goto fi0;
@@ -2423,6 +2398,8 @@ static int file_insert(const char *fn, char *p
}
size = statbuf.st_size;
p = text_hole_make(p, size);
if (p == NULL)
goto fi0;
cnt = safe_read(fd, p, size);
if (cnt < 0) {
status_line_bold("\"%s\" %s", fn, strerror(errno));
@@ -2450,7 +2427,8 @@ static int file_insert(const char *fn, char *p
return cnt;
}
static int file_write(char *fn, char *first, char *last)
static int file_write(char * fn, char * first, char * last)
{
int fd, cnt, charcnt;
@@ -2459,19 +2437,14 @@ static int file_write(char *fn, char *first, char *last)
return -2;
}
charcnt = 0;
/* By popular request we do not open file with O_TRUNC,
* but instead ftruncate() it _after_ successful write.
* Might reduce amount of data lost on power fail etc.
*/
fd = open(fn, (O_WRONLY | O_CREAT), 0666);
fd = open(fn, (O_WRONLY | O_CREAT | O_TRUNC), 0666);
if (fd < 0)
return -1;
cnt = last - first + 1;
charcnt = full_write(fd, first, cnt);
ftruncate(fd, charcnt);
if (charcnt == cnt) {
// good write
//file_modified = FALSE;
//file_modified = FALSE; // the file has not been modified
} else {
charcnt = 0;
}
@@ -2721,10 +2694,8 @@ static void not_implemented(const char *s)
// show file status on status line
static int format_edit_status(void)
{
static int tot;
static const char cmd_mode_indicator[] ALIGN1 = "-IR-";
#define tot format_edit_status__tot
int cur, percent, ret, trunc_at;
// file_modified is now a counter rather than a flag. this
@@ -2775,14 +2746,13 @@ static int format_edit_status(void)
return ret; /* it all fit */
return trunc_at; /* had to truncate */
#undef tot
}
//----- Force refresh of all Lines -----------------------------
static void redraw(int full_screen)
{
place_cursor(0, 0, FALSE); // put cursor in correct place
clear_to_eos(); // tell terminal to erase display
clear_to_eos(); // tel terminal to erase display
screen_erase(); // erase the internal screen buffer
last_status_cksum = 0; // force status update
refresh(full_screen); // this will redraw the entire display
@@ -2854,13 +2824,13 @@ static char* format_line(char *src /*, int li*/)
//
static void refresh(int full_screen)
{
#define old_offset refresh__old_offset
static int old_offset;
int li, changed;
char *tp, *sp; // pointer into text[] and screen[]
if (ENABLE_FEATURE_VI_WIN_RESIZE) {
unsigned c = columns, r = rows;
int c = columns, r = rows;
get_terminal_width_height(0, &columns, &rows);
if (rows > MAX_SCR_ROWS) rows = MAX_SCR_ROWS;
if (columns > MAX_SCR_COLS) columns = MAX_SCR_COLS;
@@ -2942,7 +2912,6 @@ static void refresh(int full_screen)
place_cursor(crow, ccol, TRUE);
old_offset = offset;
#undef old_offset
}
//---------------------------------------------------------------------
@@ -3300,7 +3269,7 @@ static void do_cmd(char c)
case '.': // .- repeat the last modifying command
// Stuff the last_modifying_cmd back into stdin
// and let it be re-executed.
if (lmc_len > 0) {
if (last_modifying_cmd != NULL && lmc_len > 0) {
last_modifying_cmd[lmc_len] = 0;
ioq = ioq_start = xstrdup(last_modifying_cmd);
}
@@ -3774,7 +3743,7 @@ static void do_cmd(char c)
c1 = get_one_char(); // get the replacement char
if (*dot != '\n') {
*dot = c1;
file_modified++;
file_modified++; // has the file been modified
}
end_cmd_q(); // stop adding to q
break;
@@ -3819,10 +3788,10 @@ static void do_cmd(char c)
} // repeat cnt
if (islower(*dot)) {
*dot = toupper(*dot);
file_modified++;
file_modified++; // has the file been modified
} else if (isupper(*dot)) {
*dot = tolower(*dot);
file_modified++;
file_modified++; // has the file been modified
}
dot_right();
end_cmd_q(); // stop adding to q
@@ -4059,7 +4028,7 @@ static void crash_test()
printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
totalcmds, last_input_char, msg, SOs, SOn);
fflush(stdout);
while (safe_read(STDIN_FILENO, d, 1) > 0) {
while (safe_read(0, d, 1) > 0) {
if (d[0] == '\n' || d[0] == '\r')
break;
}
-57
View File
@@ -1,57 +0,0 @@
#!/bin/sh
#
# Simple depmod, use to generate modprobe.conf
#
# Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
#
# Licensed under GPLv2
#
local BASE="${1:-/usr/lib/modules}"
find "$BASE" -name '*.ko.gz' | while read I ; do
N=`basename "$I" '.ko.gz'`
echo -n "@$N"
zcat "$I" | strings | grep '^depends=' | sed -e 's/^depends=$//' -e 's/^depends=/,/' -e 's/,/ @/g'
done | awk '
{
# modules which has no dependencies are resolved
if ( NF == 1 ) { res[$1] = ""; next }
# others have to be resolved based on those which already resolved
i = $1; $1 = ""; deps[i] = $0; ++ndeps
}
END {
# resolve implicit dependencies
while ( ndeps ) for (mod in deps) {
if ( index(deps[mod], "@") > 0 ) {
$0 = deps[mod]
for ( i=1; i<=NF; ++i ) {
if ( substr($i,1,1) == "@" ) {
if ( $i in res ) {
$i = res[$i] " " substr($i,2)
}
}
}
deps[mod] = $0
} else {
res[mod] = deps[mod]
delete deps[mod]
--ndeps
}
}
# output dependencies in modules.dep format
for ( mod in res ) {
$0 = res[mod]
s = ""
delete a
for ( i=1; i<=NF; ++i ) {
if ( ! ($i in a) ) {
a[$i] = $i
s = " ," $i s
}
}
print "," substr(mod,2) ":" s
}
}
' | sort | sed -r -e "s!,([^,: ]*)!/usr/lib/modules/\\1.ko.gz!g"
+12 -12
View File
@@ -22,7 +22,7 @@ config FEATURE_FIND_PRINT0
interpreted by other programs.
config FEATURE_FIND_MTIME
bool "Enable modified time matching (-mtime option)"
bool "Enable modified time matching (-mtime) option"
default y
depends on FIND
help
@@ -30,7 +30,7 @@ config FEATURE_FIND_MTIME
files, in days.
config FEATURE_FIND_MMIN
bool "Enable modified time matching (-mmin option)"
bool "Enable modified time matching (-mmin) option"
default y
depends on FIND
help
@@ -38,14 +38,14 @@ config FEATURE_FIND_MMIN
files, in minutes.
config FEATURE_FIND_PERM
bool "Enable permissions matching (-perm option)"
bool "Enable permissions matching (-perm) option"
default y
depends on FIND
help
Enable searching based on file permissions.
config FEATURE_FIND_TYPE
bool "Enable filetype matching (-type option)"
bool "Enable filetype matching (-type) option"
default y
depends on FIND
help
@@ -53,7 +53,7 @@ config FEATURE_FIND_TYPE
directory, socket, device, etc.).
config FEATURE_FIND_XDEV
bool "Enable 'stay in filesystem' option (-xdev)"
bool "Enable stay in filesystem (-xdev) option"
default y
depends on FIND
help
@@ -75,14 +75,14 @@ config FEATURE_FIND_NEWER
a modified time that is more recent than the specified FILE.
config FEATURE_FIND_INUM
bool "Enable inode number matching (-inum option)"
bool "Enable inode number matching (-inum) option"
default y
depends on FIND
help
Support the 'find -inum' option for searching by inode number.
config FEATURE_FIND_EXEC
bool "Enable -exec option allowing execution of commands"
bool "Enable (-exec) option allowing execution of commands"
default y
depends on FIND
help
@@ -90,14 +90,14 @@ config FEATURE_FIND_EXEC
the files matched.
config FEATURE_FIND_USER
bool "Enable username/uid matching (-user option)"
bool "Enable username/uid matching (-user) option"
default y
depends on FIND
help
Support the 'find -user' option for searching by username or uid.
config FEATURE_FIND_GROUP
bool "Enable group/gid matching (-group option)"
bool "Enable group/gid matching (-group) option"
default y
depends on FIND
help
@@ -127,14 +127,14 @@ config FEATURE_FIND_PAREN
Enable usage of parens '(' to specify logical order of arguments.
config FEATURE_FIND_SIZE
bool "Enable -size option allowing matching for file size"
bool "Enable (-size) option allowing matching for file size"
default y
depends on FIND
help
Support the 'find -size' option for searching by file size.
config FEATURE_FIND_PRUNE
bool "Enable -prune option allowing to exclude subdirectories"
bool "Enable (-prune) option allowing to exclude subdirectories"
default y
depends on FIND
help
@@ -165,7 +165,7 @@ config FEATURE_FIND_REGEX
The -regex option matches whole pathname against regular expression.
config FEATURE_FIND_CONTEXT
bool "Enable -context option for matching security context"
bool "Enable (-context) option for matching security context"
default n
depends on FIND && SELINUX
help
+16 -15
View File
@@ -35,7 +35,7 @@
enum {
OPTBIT_l, /* list matched file names only */
OPTBIT_n, /* print line# */
OPTBIT_q, /* quiet - exit(EXIT_SUCCESS) of first match */
OPTBIT_q, /* quiet - exit(0) of first match */
OPTBIT_v, /* invert the match, to select non-matching lines */
OPTBIT_s, /* suppress errors about file open errors */
OPTBIT_c, /* count matches per file (suppresses normal output) */
@@ -103,11 +103,12 @@ struct globals {
const char *cur_file; /* the current file we are reading */
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { \
struct G_sizecheck { \
char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \
}; \
} while (0)
#define INIT_G() \
do { \
struct G_sizecheck { \
char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \
}; \
} while (0)
#define max_matches (G.max_matches )
#define reflags (G.reflags )
#define invert_search (G.invert_search )
@@ -125,7 +126,7 @@ struct globals {
typedef struct grep_list_data_t {
char *pattern;
regex_t preg;
#define ALLOCATED 1
#define PATTERN_MEM_A 1
#define COMPILED 2
int flg_mem_alocated_compiled;
} grep_list_data_t;
@@ -171,7 +172,7 @@ static int grep_file(FILE *file)
enum { print_n_lines_after = 0 };
#endif /* ENABLE_FEATURE_GREP_CONTEXT */
while ((line = xmalloc_fgetline(file)) != NULL) {
while ((line = xmalloc_getline(file)) != NULL) {
llist_t *pattern_ptr = pattern_head;
grep_list_data_t *gl = gl; /* for gcc */
@@ -223,7 +224,7 @@ static int grep_file(FILE *file)
* "exit immediately with zero status
* if any match is found,
* even if errors were detected" */
exit(EXIT_SUCCESS);
exit(0);
}
/* if we're just printing filenames, we stop after the first match */
if (PRINT_FILES_WITH_MATCHES) {
@@ -362,10 +363,10 @@ static void load_regexes_from_file(llist_t *fopt)
fopt = cur->link;
free(cur);
f = xfopen_stdin(ffile);
while ((line = xmalloc_fgetline(f)) != NULL) {
f = xfopen(ffile, "r");
while ((line = xmalloc_getline(f)) != NULL) {
llist_add_to(&pattern_head,
new_grep_list_data(line, ALLOCATED));
new_grep_list_data(line, PATTERN_MEM_A));
}
}
}
@@ -485,7 +486,7 @@ int grep_main(int argc, char **argv)
argc--;
}
/* argv[0..(argc-1)] should be names of file to grep through. If
/* argv[(optind)..(argc-1)] should be names of file to grep through. If
* there is more than one file to grep, we will print the filenames. */
if (argc > 1)
print_filename = 1;
@@ -534,9 +535,9 @@ int grep_main(int argc, char **argv)
grep_list_data_t *gl = (grep_list_data_t *)pattern_head_ptr->data;
pattern_head = pattern_head->link;
if (gl->flg_mem_alocated_compiled & ALLOCATED)
if ((gl->flg_mem_alocated_compiled & PATTERN_MEM_A))
free(gl->pattern);
if (gl->flg_mem_alocated_compiled & COMPILED)
if ((gl->flg_mem_alocated_compiled & COMPILED))
regfree(&(gl->preg));
free(gl);
free(pattern_head_ptr);
Loaded 100 of 444 files, more files were not shown because too many files have changed in this diff. Show more