Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28dd64a0e1 | ||
|
|
5698ff9323 | ||
|
|
d9e0c438e1 |
No files matched your search
-15
@@ -35,18 +35,3 @@ Config.in
|
||||
core
|
||||
.gdb_history
|
||||
.gdbinit
|
||||
|
||||
#
|
||||
# testing output
|
||||
#
|
||||
/busybox.links
|
||||
/runtest-tempdir-links
|
||||
/testsuite/echo-ne
|
||||
|
||||
#
|
||||
# cscope output
|
||||
#
|
||||
cscope.files
|
||||
cscope.in.out
|
||||
cscope.out
|
||||
cscope.po.out
|
||||
@@ -146,10 +146,6 @@ Rob Sullivan <cogito.ergo.cogito@gmail.com>
|
||||
Linus Torvalds
|
||||
mkswap, fsck.minix, mkfs.minix
|
||||
|
||||
Linus Walleij
|
||||
fbset and fbsplash config RGBA parsing
|
||||
rewrite of mdev helper to create devices from /sys/dev
|
||||
|
||||
Mark Whitley <markw@codepoet.org>
|
||||
grep, sed, cut, xargs(previous),
|
||||
style-guide, new-applet-HOWTO, bug fixes, etc.
|
||||
@@ -178,6 +174,3 @@ Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
Jie Zhang <jie.zhang@analog.com>
|
||||
fixed two bugs in msh and hush (exitcode of killed processes)
|
||||
|
||||
Maxime Coste <mawww@kakoune.org>
|
||||
paste implementation
|
||||
@@ -1,5 +1,5 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 28
|
||||
PATCHLEVEL = 22
|
||||
SUBLEVEL = 1
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
@@ -178,7 +178,7 @@ endif
|
||||
# SUBARCH is subsequently ignored.
|
||||
|
||||
ifneq ($(CROSS_COMPILE),)
|
||||
SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1 | sed 's:^.*/::g')
|
||||
SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
|
||||
else
|
||||
SUBARCH := $(shell uname -m)
|
||||
endif
|
||||
@@ -470,7 +470,6 @@ libs-y := \
|
||||
coreutils/ \
|
||||
coreutils/libcoreutils/ \
|
||||
debianutils/ \
|
||||
klibc-utils/ \
|
||||
e2fsprogs/ \
|
||||
editors/ \
|
||||
findutils/ \
|
||||
@@ -509,8 +508,6 @@ ifeq ($(dot-config),1)
|
||||
# To avoid any implicit rule to kick in, define an empty command
|
||||
.config .kconfig.d: ;
|
||||
|
||||
-include $(srctree)/arch/$(ARCH)/Makefile
|
||||
|
||||
# Now we can define CFLAGS etc according to .config
|
||||
include $(srctree)/Makefile.flags
|
||||
|
||||
@@ -534,6 +531,8 @@ endif
|
||||
# Defaults busybox but it is usually overridden in the arch makefile
|
||||
all: busybox doc
|
||||
|
||||
-include $(srctree)/arch/$(ARCH)/Makefile
|
||||
|
||||
# arch Makefile may override CC so keep this after arch Makefile is included
|
||||
#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
|
||||
CHECKFLAGS += $(NOSTDINC_FLAGS)
|
||||
@@ -553,7 +552,7 @@ export INSTALL_PATH ?= /boot
|
||||
#
|
||||
# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
|
||||
# relocations required by build roots. This is not defined in the
|
||||
# makefile but the argument can be passed to make if needed.
|
||||
# makefile but the arguement can be passed to make if needed.
|
||||
#
|
||||
|
||||
MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
|
||||
@@ -611,8 +610,7 @@ quiet_cmd_busybox__ ?= LINK $@
|
||||
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
|
||||
"$(core-y)" \
|
||||
"$(libs-y)" \
|
||||
"$(LDLIBS)" \
|
||||
&& $(srctree)/scripts/generate_BUFSIZ.sh --post include/common_bufsiz.h
|
||||
"$(LDLIBS)"
|
||||
|
||||
# Generate System.map
|
||||
quiet_cmd_sysmap = SYSMAP
|
||||
@@ -846,15 +844,12 @@ export CPPFLAGS_busybox.lds += -P -C -U$(ARCH)
|
||||
# Split autoconf.h into include/linux/config/*
|
||||
quiet_cmd_gen_bbconfigopts = GEN include/bbconfigopts.h
|
||||
cmd_gen_bbconfigopts = $(srctree)/scripts/mkconfigs include/bbconfigopts.h include/bbconfigopts_bz2.h
|
||||
quiet_cmd_gen_common_bufsiz = GEN include/common_bufsiz.h
|
||||
cmd_gen_common_bufsiz = $(srctree)/scripts/generate_BUFSIZ.sh include/common_bufsiz.h
|
||||
quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/*
|
||||
cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config
|
||||
#bbox# piggybacked generation of few .h files
|
||||
include/config/MARKER: scripts/basic/split-include include/autoconf.h
|
||||
$(call cmd,split_autoconf)
|
||||
$(call cmd,gen_bbconfigopts)
|
||||
$(call cmd,gen_common_bufsiz)
|
||||
@touch $@
|
||||
|
||||
# Generate some files
|
||||
@@ -970,7 +965,6 @@ CLEAN_FILES += busybox busybox_unstripped* busybox.links \
|
||||
MRPROPER_DIRS += include/config include2
|
||||
MRPROPER_FILES += .config .config.old include/asm .version .old_version \
|
||||
include/NUM_APPLETS.h \
|
||||
include/common_bufsiz.h \
|
||||
include/autoconf.h \
|
||||
include/bbconfigopts.h \
|
||||
include/bbconfigopts_bz2.h \
|
||||
@@ -1171,7 +1165,24 @@ endif
|
||||
ALLSOURCE_ARCHS := $(ARCH)
|
||||
|
||||
define all-sources
|
||||
( find -regex '.*\.[ch]$$' )
|
||||
( find $(__srctree) $(RCS_FIND_IGNORE) \
|
||||
\( -name include -o -name arch \) -prune -o \
|
||||
-name '*.[chS]' -print; \
|
||||
for ARCH in $(ALLSOURCE_ARCHS) ; do \
|
||||
find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
|
||||
-name '*.[chS]' -print; \
|
||||
done ; \
|
||||
find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
|
||||
-name '*.[chS]' -print; \
|
||||
find $(__srctree)include $(RCS_FIND_IGNORE) \
|
||||
\( -name config -o -name 'asm-*' \) -prune \
|
||||
-o -name '*.[chS]' -print; \
|
||||
for ARCH in $(ALLINCLUDE_ARCHS) ; do \
|
||||
find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \
|
||||
-name '*.[chS]' -print; \
|
||||
done ; \
|
||||
find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
|
||||
-name '*.[chS]' -print )
|
||||
endef
|
||||
|
||||
quiet_cmd_cscope-file = FILELST cscope.files
|
||||
|
||||
@@ -28,10 +28,6 @@ ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
|
||||
INSTALL_OPTS:= --scriptwrapper
|
||||
endif
|
||||
endif
|
||||
ifeq ($(CONFIG_FEATURE_INDIVIDUAL),y)
|
||||
INSTALL_OPTS:= --binaries
|
||||
LIBBUSYBOX_SONAME:= 0_lib/libbusybox.so.$(BB_VER)
|
||||
endif
|
||||
install: $(srctree)/applets/install.sh busybox busybox.links
|
||||
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
|
||||
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
|
||||
@@ -59,11 +55,7 @@ endif
|
||||
# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
|
||||
.PHONY: check
|
||||
.PHONY: test
|
||||
ifeq ($(CONFIG_UNIT_TEST),y)
|
||||
UNIT_CMD = ./busybox unit
|
||||
endif
|
||||
check test: busybox busybox.links
|
||||
$(UNIT_CMD)
|
||||
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)"
|
||||
|
||||
+10
-22
@@ -15,7 +15,7 @@ CPPFLAGS += \
|
||||
-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))"
|
||||
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
|
||||
|
||||
CFLAGS += $(call cc-option,-Wall,)
|
||||
CFLAGS += $(call cc-option,-Wshadow,)
|
||||
@@ -56,9 +56,6 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
|
||||
# Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller busybox binary):
|
||||
CFLAGS += $(call cc-option,-fno-unwind-tables,)
|
||||
CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
|
||||
# No automatic printf->puts,putchar conversions
|
||||
# (try disabling this and comparing assembly, it's instructive)
|
||||
CFLAGS += $(call cc-option,-fno-builtin-printf,)
|
||||
|
||||
# FIXME: These warnings are at least partially to be concerned about and should
|
||||
# be fixed..
|
||||
@@ -75,11 +72,6 @@ else
|
||||
CFLAGS += $(call cc-option,-Os,$(call cc-option,-O2,))
|
||||
endif
|
||||
endif
|
||||
ifeq ($(CONFIG_DEBUG_SANITIZE),y)
|
||||
CFLAGS += $(call cc-option,-fsanitize=address,)
|
||||
CFLAGS += $(call cc-option,-fsanitize=leak,)
|
||||
CFLAGS += $(call cc-option,-fsanitize=undefined,)
|
||||
endif
|
||||
|
||||
# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
|
||||
ARCH_FPIC ?= -fpic
|
||||
@@ -134,19 +126,15 @@ else
|
||||
LDLIBS += m
|
||||
endif
|
||||
|
||||
# libpam may use libpthread, libdl and/or libaudit.
|
||||
# On some platforms that requires an explicit -lpthread, -ldl, -laudit.
|
||||
# However, on *other platforms* it fails when some of those flags
|
||||
# given needlessly. On some systems, crypt needs pthread.
|
||||
#
|
||||
# I even had a system where a runtime test for pthread
|
||||
# (similar to CRYPT_AVAILABLE test above) was not reliable.
|
||||
#
|
||||
# Do not propagate this mess by adding libraries to CONFIG_PAM/CRYPT_AVAILABLE blocks.
|
||||
# Add libraries you need to CONFIG_EXTRA_LDLIBS instead.
|
||||
|
||||
ifeq ($(CONFIG_PAM),y)
|
||||
LDLIBS += pam pam_misc
|
||||
# libpam uses libpthread, so for static builds busybox must be linked to
|
||||
# libpthread. On some platforms that requires an explicit -lpthread, so
|
||||
# it should be in LDLIBS. For non-static builds, scripts/trylink will
|
||||
# take care of removing -lpthread if possible. (Not bothering to check
|
||||
# CONFIG_STATIC because even in a non-static build it could be that the
|
||||
# only libpam available is libpam.a, so -lpthread could still be
|
||||
# needed.)
|
||||
LDLIBS += pam pam_misc pthread
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SELINUX),y)
|
||||
@@ -175,7 +163,7 @@ SKIP_STRIP = y
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_EXTRA_LDFLAGS),)
|
||||
LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS)))
|
||||
EXTRA_LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS)))
|
||||
#"))
|
||||
endif
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ help:
|
||||
@echo ' defconfig - set .config to largest generic configuration'
|
||||
@echo ' menuconfig - interactive curses-based configurator'
|
||||
@echo ' oldconfig - resolve any unresolved symbols in .config'
|
||||
@echo ' hosttools - build sed for the host.'
|
||||
@echo ' You can use these commands if the commands on the host'
|
||||
@echo ' is unusable. Afterwards use it like:'
|
||||
@echo ' make SED="$(objtree)/sed"'
|
||||
@$(if $(boards), \
|
||||
$(foreach b, $(boards), \
|
||||
printf " %-21s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
|
||||
|
||||
@@ -1,437 +0,0 @@
|
||||
Why an applet can't be NOFORK or NOEXEC?
|
||||
|
||||
Why can't be NOFORK:
|
||||
interactive: may wait for user input, ^C has to work
|
||||
spawner: "tool PROG ARGS" which changes program state and execs - must fork
|
||||
changes state: e.g. environment, signal handlers
|
||||
leaks: does not free allocated memory or opened fds
|
||||
alloc+xfunc: xmalloc, then xfunc - leaks memory if xfunc dies
|
||||
open+xfunc: opens fd, then calls xfunc - fd is leaked if xfunc dies
|
||||
talks to network/serial/etc: it's not known how long the delay can be,
|
||||
it's reasonable to expect it might be many seconds
|
||||
(even if usually it is not), so ^C has to work
|
||||
runner: sometimes may run for long(ish) time, and/or works with network:
|
||||
^C has to work (cat BIGFILE, chmod -R, ftpget, nc)
|
||||
|
||||
"runners" can become eligible after shell is taught ^C to interrupt NOFORKs,
|
||||
need to be inspected that they do not fall into alloc+xfunc, open+xfunc,
|
||||
leak categories.
|
||||
|
||||
Why can't be NOEXEC:
|
||||
suid: runs under different uid - must fork+exec
|
||||
if it's important that /proc/PID/cmdline and comm are correct.
|
||||
("pkill sh" killing itself before it kills real "sh" is no fun)
|
||||
|
||||
Why shouldn't be NOFORK/NOEXEC:
|
||||
rare: not started often enough to bother optimizing (example: poweroff)
|
||||
daemon: runs indefinitely; these are also always fit "rare" category
|
||||
longterm: often runs for a long time (many seconds), execing makes
|
||||
memory footprint smaller
|
||||
complex: no immediately obvious reason why NOFORK wouldn't work,
|
||||
but does some non-obvoius operations (example: fuser, lsof, losetup);
|
||||
detailed audit often turns out that it's a leaker
|
||||
hardware: performs unusual hardware ops which may take long,
|
||||
or even hang due to hardware or firmware bugs
|
||||
|
||||
Interesting example of "interactive" applet which is nevertheless can be
|
||||
(and is) NOEXEC is "rm". Yes, "rm -i" is interactive - but it's not that typical
|
||||
for users to keep it waiting for many minutes, whereas running "rm" in shell
|
||||
is very typical, and speeding up this common use via NOEXEC is useful.
|
||||
IOW: rm is "interactive", but not "longterm".
|
||||
|
||||
Interesting example of an applet which can be NOFORK but if not,
|
||||
then should not be NOEXEC, is "usleep". As NOFORK, it amount to simply
|
||||
nanosleep()ing in the calling program (usually shell). No memory wasted.
|
||||
But if ran as NOEXEC, it would create a potentially long-term process,
|
||||
which would be taking more memory because it did not exec
|
||||
and did not free much of the copied memory of the parent
|
||||
(COW helps with this only as long as parent doesn't modify its memory).
|
||||
|
||||
|
||||
[ - NOFORK
|
||||
[[ - NOFORK
|
||||
acpid - daemon
|
||||
add-shell - noexec. leaks: open+xfunc
|
||||
addgroup - noexec. leaks
|
||||
adduser - noexec. leaks
|
||||
adjtimex - NOFORK
|
||||
ar - runner
|
||||
arch - NOFORK
|
||||
arp - talks to network: arp -n queries DNS
|
||||
arping - longterm
|
||||
ash - interactive, longterm
|
||||
awk - noexec. runner
|
||||
base64 - runner
|
||||
basename - NOFORK
|
||||
beep - longterm: beep -r 999999999
|
||||
blkdiscard - noexec. leaks: open+xioctl
|
||||
blkid - noexec
|
||||
blockdev - noexec. leaks fd
|
||||
bootchartd - daemon
|
||||
brctl - noexec
|
||||
bunzip2 - runner
|
||||
bzcat - runner
|
||||
bzip2 - runner
|
||||
cal - runner: cal -n9999
|
||||
cat - runner: cat HUGEFILE
|
||||
chat - longterm (when used as intended - talking to modem over stdin/out)
|
||||
chattr - noexec. runner
|
||||
chgrp - noexec. runner
|
||||
chmod - noexec. runner
|
||||
chown - noexec. runner
|
||||
chpasswd - longterm? (list of "user:password"s from stdin)
|
||||
chpst - noexec. spawner
|
||||
chroot - noexec. spawner
|
||||
chrt - noexec. spawner
|
||||
chvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
|
||||
cksum - noexec. runner
|
||||
clear - NOFORK
|
||||
cmp - runner
|
||||
comm - runner
|
||||
conspy - interactive, longterm
|
||||
cp - noexec. runner
|
||||
cpio - runner
|
||||
crond - daemon
|
||||
crontab - longterm (runs $EDITOR), leaks: open+xasprintf
|
||||
cryptpw - noexec. changes state: with --password-fd=N, moves N to stdin
|
||||
cttyhack - noexec. spawner
|
||||
cut - noexec. runner
|
||||
date - noexec. nofork candidate(needs to stop messing up env, free xasprintf result, not use xfuncs after xasprintf)
|
||||
dc - longterm (eats stdin if no params)
|
||||
dd - noexec. runner
|
||||
deallocvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
|
||||
delgroup - noexec. leaks
|
||||
deluser - noexec. leaks
|
||||
depmod - longterm(ish)
|
||||
devmem - hardware (access to device memory may hang)
|
||||
df - noexec. leaks: nested allocs
|
||||
dhcprelay - daemon
|
||||
diff - runner
|
||||
dirname - NOFORK
|
||||
dmesg - runner
|
||||
dnsd - daemon
|
||||
dnsdomainname - noexec. talks to network (may query DNS)
|
||||
dos2unix - noexec. runner
|
||||
dpkg - runner
|
||||
du - runner
|
||||
dumpkmap - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
|
||||
dumpleases - noexec. leaks: open+xread
|
||||
echo - NOFORK
|
||||
ed - interactive, longterm
|
||||
egrep - longterm runner ("CMD | egrep ..." may run indefinitely, better to exec to conserve memory)
|
||||
eject - hardware, leaks: open+ioctl_or_perror_and_die, changes state (moves fds)
|
||||
env - noexec. spawner, changes state (env)
|
||||
envdir - noexec. spawner
|
||||
envuidgid - noexec. spawner
|
||||
expand - runner
|
||||
expr - noexec. leaks: nested allocs
|
||||
factor - longterm (eats stdin if no params)
|
||||
fakeidentd - daemon
|
||||
false - NOFORK
|
||||
fatattr - noexec. leaks: open+xioctl, complex
|
||||
fbset - hardware, leaks: open+xfunc
|
||||
fbsplash - runner, longterm
|
||||
fdflush - hardware, leaks: open+ioctl_or_perror_and_die
|
||||
fdformat - hardware, longterm
|
||||
fdisk - interactive, longterm
|
||||
fgconsole - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
|
||||
fgrep - longterm runner ("CMD | fgrep ..." may run indefinitely, better to exec to conserve memory)
|
||||
find - noexec. runner
|
||||
findfs - suid
|
||||
flash_eraseall - hardware
|
||||
flash_lock - hardware
|
||||
flash_unlock - hardware
|
||||
flashcp - hardware
|
||||
flock - spawner, changes state (file locks), let's play safe and not be noexec
|
||||
fold - noexec. runner
|
||||
free - NOFORK
|
||||
freeramdisk - noexec. leaks: open+ioctl_or_perror_and_die
|
||||
fsck - interactive, longterm
|
||||
fsck.minix - needs ^C
|
||||
fsfreeze - noexec. leaks: open+xioctl
|
||||
fstrim - noexec. leaks: open+xioctl, find_block_device -> readdir+xstrdup
|
||||
fsync - NOFORK
|
||||
ftpd - daemon
|
||||
ftpget - runner
|
||||
ftpput - runner
|
||||
fuser - complex
|
||||
getopt - noexec. leaks: many allocs
|
||||
getty - interactive, longterm
|
||||
grep - longterm runner ("CMD | grep ..." may run indefinitely, better to exec to conserve memory)
|
||||
groups - noexec
|
||||
gunzip - runner
|
||||
gzip - runner
|
||||
halt - rare
|
||||
hd - noexec. runner
|
||||
hdparm - hardware
|
||||
head - noexec. runner
|
||||
hexdump - noexec. runner
|
||||
hexedit - interactive, longterm
|
||||
hostid - NOFORK
|
||||
hostname - noexec. talks to network (hostname -d may query DNS)
|
||||
httpd - daemon
|
||||
hush - interactive, longterm
|
||||
hwclock - hardware (xioctl(RTC_RD_TIME))
|
||||
i2cdetect - hardware
|
||||
i2cdump - hardware
|
||||
i2cget - hardware
|
||||
i2cset - hardware
|
||||
id - noexec
|
||||
ifconfig - hardware? (mem_start NN io_addr NN irq NN), leaks: xsocket+ioctl_or_perror_and_die
|
||||
ifenslave - noexec. leaks: xsocket+bb_perror_msg_and_die
|
||||
ifplugd - daemon
|
||||
inetd - daemon
|
||||
init - daemon
|
||||
inotifyd - daemon
|
||||
insmod - noexec
|
||||
install - runner
|
||||
ionice - noexec. spawner
|
||||
iostat - longterm: "iostat 1" runs indefinitely
|
||||
ip - noexec
|
||||
ipaddr - noexec
|
||||
ipcalc - noexec. ipcalc -h talks to network
|
||||
ipcrm - noexec
|
||||
ipcs - noexec
|
||||
iplink - noexec
|
||||
ipneigh - noexec
|
||||
iproute - noexec
|
||||
iprule - noexec
|
||||
iptunnel - noexec
|
||||
kbd_mode - noexec. leaks: xopen_nonblocking+xioctl
|
||||
kill - NOFORK
|
||||
killall - NOFORK
|
||||
killall5 - NOFORK
|
||||
klogd - daemon
|
||||
last - runner (I've got 1300 lines of output when tried it)
|
||||
less - interactive, longterm
|
||||
link - NOFORK
|
||||
linux32 - noexec. spawner
|
||||
linux64 - noexec. spawner
|
||||
linuxrc - daemon
|
||||
ln - noexec
|
||||
loadfont - noexec. leaks: config_open+bb_error_msg_and_die("map format")
|
||||
loadkmap - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
|
||||
logger - runner
|
||||
login - suid, interactive, longterm
|
||||
logname - NOFORK
|
||||
losetup - noexec. complex
|
||||
lpd - daemon
|
||||
lpq - runner
|
||||
lpr - runner
|
||||
ls - noexec. runner
|
||||
lsattr - noexec. runner
|
||||
lsmod - noexec
|
||||
lsof - complex
|
||||
lspci - noexec. too rare to bother for nofork
|
||||
lsscsi - noexec. too rare to bother for nofork
|
||||
lsusb - noexec. too rare to bother for nofork
|
||||
lzcat - runner
|
||||
lzma - runner
|
||||
lzop - runner
|
||||
lzopcat - runner
|
||||
makedevs - noexec
|
||||
makemime - runner
|
||||
man - spawner, interactive, longterm
|
||||
md5sum - noexec. runner
|
||||
mdev - daemon
|
||||
mesg - NOFORK
|
||||
microcom - interactive, longterm
|
||||
minips - noexec
|
||||
mkdir - NOFORK
|
||||
mkdosfs - needs ^C
|
||||
mke2fs - needs ^C
|
||||
mkfifo - noexec
|
||||
mkfs.ext2 - needs ^C
|
||||
mkfs.minix - needs ^C
|
||||
mkfs.vfat - needs ^C
|
||||
mknod - noexec
|
||||
mkpasswd - noexec. changes state: with --password-fd=N, moves N to stdin
|
||||
mkswap - needs ^C
|
||||
mktemp - noexec. leaks: xstrdup+concat_path_file
|
||||
modinfo - noexec
|
||||
modprobe - noexec
|
||||
more - interactive, longterm
|
||||
mount - suid
|
||||
mountpoint - noexec. leaks: option -n "print dev name": find_block_device -> readdir+xstrdup
|
||||
mpstat - longterm: "mpstat 1" runs indefinitely
|
||||
mt - hardware
|
||||
mv - noexec candidate, runner
|
||||
nameif - noexec. openlog(), leaks: config_open2+ioctl_or_perror_and_die
|
||||
nbd-client - noexec
|
||||
nc - runner
|
||||
netstat - longterm with -c (continuous listing)
|
||||
nice - noexec. spawner
|
||||
nl - runner
|
||||
nmeter - longterm
|
||||
nohup - noexec. spawner
|
||||
nproc - NOFORK
|
||||
ntpd - daemon
|
||||
nuke - noexec
|
||||
od - runner
|
||||
openvt - longterm: spawns a child and waits for it
|
||||
partprobe - noexec. leaks: open+ioctl_or_perror_and_die(BLKRRPART)
|
||||
passwd - suid
|
||||
paste - noexec. runner
|
||||
patch - needs ^C
|
||||
pgrep - must fork+exec to get correct /proc/PID/cmdline and comm field
|
||||
pidof - must fork+exec to get correct /proc/PID/cmdline and comm field
|
||||
ping - suid, longterm
|
||||
ping6 - suid, longterm
|
||||
pipe_progress - longterm
|
||||
pivot_root - NOFORK
|
||||
pkill - must fork+exec to get correct /proc/PID/cmdline and comm field
|
||||
pmap - noexec candidate, leaks: open+xstrdup
|
||||
popmaildir - runner
|
||||
poweroff - rare
|
||||
powertop - interactive, longterm
|
||||
printenv - NOFORK
|
||||
printf - NOFORK
|
||||
ps - noexec
|
||||
pscan - talks to network
|
||||
pstree - noexec
|
||||
pwd - NOFORK
|
||||
pwdx - NOFORK
|
||||
raidautorun - noexec. very simple. leaks: open+xioctl
|
||||
rdate - talks to network
|
||||
rdev - noexec. leaks: find_block_device -> readdir+xstrdup
|
||||
readlink - NOFORK
|
||||
readprofile - reads /boot/System.map and /proc/profile, better to free more memory by execing?
|
||||
realpath - NOFORK
|
||||
reboot - rare
|
||||
reformime - runner
|
||||
remove-shell - noexec. leaks: open+xfunc
|
||||
renice - noexec. nofork candidate(uses getpwnam, is that ok?)
|
||||
reset - noexec. spawner (execs "stty")
|
||||
resize - noexec. changes state (signal handlers)
|
||||
resume - noexec
|
||||
rev - runner
|
||||
rm - noexec. rm -i interactive
|
||||
rmdir - NOFORK
|
||||
rmmod - noexec
|
||||
route - talks to network (may query DNS to convert IPs to names)
|
||||
rpm - runner
|
||||
rpm2cpio - runner
|
||||
rtcwake - longterm: puts system to sleep, optimizing this for speed is pointless
|
||||
run-init - spawner, rare, changes state (oh yes), execing may be important to free binary's inode
|
||||
run-parts - longterm
|
||||
runlevel - noexec. can be nofork if "endutxent()" is called unconditionally, but too rare to bother?
|
||||
runsv - daemon
|
||||
runsvdir - daemon
|
||||
rx - runner
|
||||
script - longterm: pumps script output from slave pty
|
||||
scriptreplay - longterm: plays back "script" saved output, sleeping as necessary.
|
||||
sed - runner
|
||||
sendmail - runner
|
||||
seq - noexec. runner
|
||||
setarch - noexec. spawner
|
||||
setconsole - noexec
|
||||
setfattr - noexec
|
||||
setfont - noexec. leaks a lot of stuff
|
||||
setkeycodes - noexec
|
||||
setlogcons - noexec
|
||||
setpriv - spawner, changes state, let's play safe and not be noexec
|
||||
setserial - noexec
|
||||
setsid - spawner, uses fork_or_rexec() [not audited to work in noexec], let's play safe and not be noexec
|
||||
setuidgid - noexec. spawner
|
||||
sha1sum - noexec. runner
|
||||
sha256sum - noexec. runner
|
||||
sha3sum - noexec. runner
|
||||
sha512sum - noexec. runner
|
||||
showkey - interactive, longterm
|
||||
shred - runner
|
||||
shuf - noexec. runner
|
||||
slattach - longterm (may sleep forever), uses bb_common_bufsiz1
|
||||
sleep - longterm. Could be nofork, if not the problem of "killall sleep" not killing it.
|
||||
smemcap - runner
|
||||
softlimit - noexec. spawner
|
||||
sort - noexec. runner
|
||||
split - runner
|
||||
ssl_client - longterm
|
||||
start-stop-daemon - not noexec: uses bb_common_bufsiz1
|
||||
stat - noexec. nofork candidate(needs fewer allocs)
|
||||
strings - runner
|
||||
stty - noexec. nofork candidate: has no allocs or opens except xmove_fd(xopen("-F DEVICE"),STDIN). tcsetattr(STDIN) is not a problem: it would work the same across processes sharing this fd
|
||||
su - suid, spawner
|
||||
sulogin - noexec. spawner
|
||||
sum - runner
|
||||
sv - noexec. needs ^C (uses usleep(420000))
|
||||
svc - noexec. needs ^C (uses usleep(420000))
|
||||
svlogd - daemon
|
||||
swapoff - longterm: may cause memory pressure, execing is beneficial
|
||||
swapon - rare
|
||||
switch_root - spawner, rare, changes state (oh yes), execing may be important to free binary's inode
|
||||
sync - NOFORK
|
||||
sysctl - noexec. leaks: xstrdup+xmalloc_read
|
||||
syslogd - daemon
|
||||
tac - noexec. runner
|
||||
tail - runner
|
||||
tar - runner
|
||||
taskset - noexec. spawner
|
||||
tcpsvd - daemon
|
||||
tee - runner
|
||||
telnet - interactive, longterm
|
||||
telnetd - daemon
|
||||
test - NOFORK
|
||||
tftp - runner
|
||||
tftpd - daemon
|
||||
time - spawner, longterm, changes state (signals)
|
||||
timeout - spawner, longterm, changes state (signals)
|
||||
top - interactive, longterm
|
||||
touch - NOFORK
|
||||
tr - runner
|
||||
traceroute - suid, longterm
|
||||
traceroute6 - suid, longterm
|
||||
true - NOFORK
|
||||
truncate - NOFORK
|
||||
tty - NOFORK
|
||||
ttysize - NOFORK
|
||||
tunctl - noexec
|
||||
tune2fs - noexec. leaks: open+xfunc
|
||||
ubiattach - hardware
|
||||
ubidetach - hardware
|
||||
ubimkvol - hardware
|
||||
ubirename - hardware
|
||||
ubirmvol - hardware
|
||||
ubirsvol - hardware
|
||||
ubiupdatevol - hardware
|
||||
udhcpc - daemon
|
||||
udhcpd - daemon
|
||||
udpsvd - daemon
|
||||
uevent - daemon
|
||||
umount - noexec. leaks: nested xmalloc
|
||||
uname - NOFORK
|
||||
uncompress - runner
|
||||
unexpand - runner
|
||||
uniq - runner
|
||||
unix2dos - noexec. runner
|
||||
unlink - NOFORK
|
||||
unlzma - runner
|
||||
unlzop - runner
|
||||
unxz - runner
|
||||
unzip - runner
|
||||
uptime - noexec. nofork candidate(is getutxent ok?)
|
||||
users - noexec. nofork candidate(is getutxent ok?)
|
||||
usleep - NOFORK. But what about "killall usleep"?
|
||||
uudecode - runner
|
||||
uuencode - runner
|
||||
vconfig - noexec. leaks: xsocket+ioctl_or_perror_and_die
|
||||
vi - interactive, longterm
|
||||
vlock - suid
|
||||
volname - hardware (reads CDROM, this can take long-ish if need to spin up)
|
||||
w - noexec. nofork candidate(is getutxent ok?)
|
||||
wall - suid
|
||||
watch - longterm
|
||||
watchdog - daemon
|
||||
wc - runner
|
||||
wget - longterm
|
||||
which - NOFORK
|
||||
who - noexec. nofork candidate(is getutxent ok?)
|
||||
whoami - NOFORK
|
||||
whois - talks to network
|
||||
xargs - noexec. spawner
|
||||
xxd - noexec. runner
|
||||
xz - runner
|
||||
xzcat - runner
|
||||
yes - noexec. runner
|
||||
zcat - runner
|
||||
zcip - daemon
|
||||
@@ -185,7 +185,7 @@ Supported hardware:
|
||||
Under 2.4 Linux kernels, kernel module loading was implemented in a
|
||||
platform-specific manner. Busybox's insmod utility has been reported to
|
||||
work under ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC, S390,
|
||||
SH3/4/5, Sparc, and v850e. Anything else probably won't work.
|
||||
SH3/4/5, Sparc, v850e, and x86_64. Anything else probably won't work.
|
||||
|
||||
The module loading mechanism for the 2.6 kernel is much more generic, and
|
||||
we believe 2.6.x kernel module loading support should work on all
|
||||
|
||||
@@ -224,6 +224,8 @@ Minor stuff:
|
||||
---
|
||||
support start-stop-daemon -d <chdir-path>
|
||||
---
|
||||
vdprintf() -> similar sized functionality
|
||||
---
|
||||
|
||||
(TODO list after discussion 11.05.2009)
|
||||
|
||||
@@ -256,3 +258,5 @@ Minor stuff:
|
||||
|
||||
* more support for advanced linux 2.6.x features, see: iotop
|
||||
most likely there is more
|
||||
|
||||
* even more support for statistics: mpstat, iostat, powertop....
|
||||
+5
-15
@@ -29,7 +29,7 @@ applets/applets.o: include/usage_compressed.h include/applet_tables.h
|
||||
|
||||
applets/applet_tables: .config include/applets.h
|
||||
applets/usage: .config include/applets.h
|
||||
applets/usage_pod: .config include/applets.h include/applet_tables.h
|
||||
applets/usage_pod: .config include/applet_tables.h include/applets.h
|
||||
|
||||
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
|
||||
cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
|
||||
@@ -37,21 +37,11 @@ quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
|
||||
include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compressed
|
||||
$(call cmd,gen_usage_compressed)
|
||||
|
||||
quiet_cmd_gen_applet_tables = GEN include/applet_tables.h include/NUM_APPLETS.h
|
||||
quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
|
||||
cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
|
||||
|
||||
include/applet_tables.h: applets/applet_tables
|
||||
$(call cmd,gen_applet_tables)
|
||||
|
||||
include/NUM_APPLETS.h: applets/applet_tables
|
||||
$(call cmd,gen_applet_tables)
|
||||
|
||||
# In fact, include/applet_tables.h depends only on applets/applet_tables,
|
||||
# and is generated by it. But specifying only it can run
|
||||
# applets/applet_tables twice, possibly in parallel.
|
||||
# We say that it also needs NUM_APPLETS.h
|
||||
#
|
||||
# Unfortunately, we need to list the same command,
|
||||
# and it can be executed twice (sequentially).
|
||||
# The alternative is to not list any command,
|
||||
# and then if include/applet_tables.h is deleted, it won't be rebuilt.
|
||||
#
|
||||
include/applet_tables.h: include/NUM_APPLETS.h applets/applet_tables
|
||||
$(call cmd,gen_applet_tables)
|
||||
+36
-99
@@ -14,7 +14,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#undef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
|
||||
@@ -41,6 +40,8 @@ struct bb_applet {
|
||||
|
||||
enum { NUM_APPLETS = ARRAY_SIZE(applets) };
|
||||
|
||||
static int offset[NUM_APPLETS];
|
||||
|
||||
static int cmp_name(const void *a, const void *b)
|
||||
{
|
||||
const struct bb_applet *aa = a;
|
||||
@@ -48,42 +49,26 @@ static int cmp_name(const void *a, const void *b)
|
||||
return strcmp(aa->name, bb->name);
|
||||
}
|
||||
|
||||
static int str_isalnum_(const char *s)
|
||||
{
|
||||
while (*s) {
|
||||
if (!isalnum(*s) && *s != '_')
|
||||
return 0;
|
||||
s++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
// In find_applet_by_name(), before linear search, narrow it down
|
||||
// by looking at N "equidistant" names. With ~350 applets:
|
||||
// KNOWN_APPNAME_OFFSETS cycles
|
||||
// 0 9057
|
||||
// 2 4604 + ~100 bytes of code
|
||||
// 4 2407 + 4 bytes
|
||||
// 8 1342 + 8 bytes
|
||||
// 16 908 + 16 bytes
|
||||
// 32 884 + 32 bytes
|
||||
// With 8, int16_t applet_nameofs[] table has 7 elements.
|
||||
int KNOWN_APPNAME_OFFSETS = 8;
|
||||
// With 128 applets we do two linear searches, with 1..7 strcmp's in the first one
|
||||
// and 1..16 strcmp's in the second. With 256 apps, second search does 1..32 strcmp's.
|
||||
if (NUM_APPLETS < 128)
|
||||
KNOWN_APPNAME_OFFSETS = 4;
|
||||
if (NUM_APPLETS < 32)
|
||||
KNOWN_APPNAME_OFFSETS = 0;
|
||||
int i;
|
||||
int ofs;
|
||||
// unsigned MAX_APPLET_NAME_LEN = 1;
|
||||
|
||||
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
|
||||
|
||||
ofs = 0;
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
offset[i] = ofs;
|
||||
ofs += strlen(applets[i].name) + 1;
|
||||
}
|
||||
/* We reuse 4 high-order bits of offset array for other purposes,
|
||||
* so if they are indeed needed, refuse to proceed */
|
||||
if (ofs > 0xfff)
|
||||
return 1;
|
||||
if (!argv[1])
|
||||
return 1;
|
||||
|
||||
i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666);
|
||||
if (i < 0)
|
||||
return 1;
|
||||
@@ -98,27 +83,7 @@ int main(int argc, char **argv)
|
||||
printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
|
||||
printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].main);
|
||||
}
|
||||
|
||||
printf("#define KNOWN_APPNAME_OFFSETS %u\n\n", KNOWN_APPNAME_OFFSETS);
|
||||
if (KNOWN_APPNAME_OFFSETS > 0) {
|
||||
int ofs, offset[KNOWN_APPNAME_OFFSETS], index[KNOWN_APPNAME_OFFSETS];
|
||||
for (i = 0; i < KNOWN_APPNAME_OFFSETS; i++)
|
||||
index[i] = i * NUM_APPLETS / KNOWN_APPNAME_OFFSETS;
|
||||
ofs = 0;
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
for (j = 0; j < KNOWN_APPNAME_OFFSETS; j++)
|
||||
if (i == index[j])
|
||||
offset[j] = ofs;
|
||||
ofs += strlen(applets[i].name) + 1;
|
||||
}
|
||||
/* If the list of names is too long refuse to proceed */
|
||||
if (ofs > 0xffff)
|
||||
return 1;
|
||||
printf("const uint16_t applet_nameofs[] ALIGN2 = {\n");
|
||||
for (i = 1; i < KNOWN_APPNAME_OFFSETS; i++)
|
||||
printf("%d,\n", offset[i]);
|
||||
printf("};\n\n");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
//printf("#ifndef SKIP_definitions\n");
|
||||
printf("const char applet_names[] ALIGN1 = \"\"\n");
|
||||
@@ -129,12 +94,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
printf(";\n\n");
|
||||
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
if (str_isalnum_(applets[i].name))
|
||||
printf("#define APPLET_NO_%s %d\n", applets[i].name, i);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("#ifndef SKIP_applet_main\n");
|
||||
printf("int (*const applet_main[])(int argc, char **argv) = {\n");
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
@@ -143,41 +102,20 @@ int main(int argc, char **argv)
|
||||
printf("};\n");
|
||||
printf("#endif\n\n");
|
||||
|
||||
#if ENABLE_FEATURE_PREFER_APPLETS \
|
||||
|| ENABLE_FEATURE_SH_STANDALONE \
|
||||
|| ENABLE_FEATURE_SH_NOFORK
|
||||
printf("const uint8_t applet_flags[] ALIGN1 = {\n");
|
||||
i = 0;
|
||||
while (i < NUM_APPLETS) {
|
||||
int v = applets[i].nofork + (applets[i].noexec << 1);
|
||||
if (++i < NUM_APPLETS)
|
||||
v |= (applets[i].nofork + (applets[i].noexec << 1)) << 2;
|
||||
if (++i < NUM_APPLETS)
|
||||
v |= (applets[i].nofork + (applets[i].noexec << 1)) << 4;
|
||||
if (++i < NUM_APPLETS)
|
||||
v |= (applets[i].nofork + (applets[i].noexec << 1)) << 6;
|
||||
printf("0x%02x,\n", v);
|
||||
i++;
|
||||
}
|
||||
printf("};\n\n");
|
||||
printf("const uint16_t applet_nameofs[] ALIGN2 = {\n");
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
printf("0x%04x,\n",
|
||||
offset[i]
|
||||
#if ENABLE_FEATURE_PREFER_APPLETS
|
||||
+ (applets[i].nofork << 12)
|
||||
+ (applets[i].noexec << 13)
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_SUID
|
||||
printf("const uint8_t applet_suid[] ALIGN1 = {\n");
|
||||
i = 0;
|
||||
while (i < NUM_APPLETS) {
|
||||
int v = applets[i].need_suid; /* 2 bits */
|
||||
if (++i < NUM_APPLETS)
|
||||
v |= applets[i].need_suid << 2;
|
||||
if (++i < NUM_APPLETS)
|
||||
v |= applets[i].need_suid << 4;
|
||||
if (++i < NUM_APPLETS)
|
||||
v |= applets[i].need_suid << 6;
|
||||
printf("0x%02x,\n", v);
|
||||
i++;
|
||||
+ (applets[i].need_suid << 14) /* 2 bits */
|
||||
#endif
|
||||
);
|
||||
}
|
||||
printf("};\n\n");
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_INSTALLER
|
||||
printf("const uint8_t applet_install_loc[] ALIGN1 = {\n");
|
||||
@@ -192,28 +130,27 @@ int main(int argc, char **argv)
|
||||
printf("};\n");
|
||||
#endif
|
||||
//printf("#endif /* SKIP_definitions */\n");
|
||||
|
||||
// printf("\n");
|
||||
// printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
|
||||
|
||||
if (argv[2]) {
|
||||
FILE *fp;
|
||||
char line_old[80];
|
||||
char line_new[80];
|
||||
// char line_old[80];
|
||||
FILE *fp;
|
||||
|
||||
line_old[0] = 0;
|
||||
fp = fopen(argv[2], "r");
|
||||
if (fp) {
|
||||
fgets(line_old, sizeof(line_old), fp);
|
||||
fclose(fp);
|
||||
}
|
||||
sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
|
||||
// line_old[0] = 0;
|
||||
// fp = fopen(argv[2], "r");
|
||||
// if (fp) {
|
||||
// fgets(line_old, sizeof(line_old), fp);
|
||||
// fclose(fp);
|
||||
// }
|
||||
// if (strcmp(line_old, line_new) != 0) {
|
||||
if (strcmp(line_old, line_new) != 0) {
|
||||
fp = fopen(argv[2], "w");
|
||||
if (!fp)
|
||||
return 1;
|
||||
fputs(line_new, fp);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+2
-24
@@ -5,26 +5,19 @@ export LC_CTYPE=POSIX
|
||||
|
||||
prefix=$1
|
||||
if [ -z "$prefix" ]; then
|
||||
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--binaries/--scriptwrapper]"
|
||||
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Source the configuration
|
||||
. ./.config
|
||||
|
||||
h=`sort busybox.links | uniq`
|
||||
|
||||
sharedlib_dir="0_lib"
|
||||
|
||||
linkopts=""
|
||||
scriptwrapper="n"
|
||||
binaries="n"
|
||||
cleanup="0"
|
||||
noclobber="0"
|
||||
case "$2" in
|
||||
--hardlinks) linkopts="-f";;
|
||||
--symlinks) linkopts="-fs";;
|
||||
--binaries) binaries="y";;
|
||||
--scriptwrapper) scriptwrapper="y";swrapall="y";;
|
||||
--sw-sh-hard) scriptwrapper="y";linkopts="-f";;
|
||||
--sw-sh-sym) scriptwrapper="y";linkopts="-fs";;
|
||||
@@ -47,9 +40,8 @@ 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
|
||||
echo " Installing $i to the target at $prefix/$libdir/"
|
||||
cp -pPR "$i" "$prefix/$libdir/" || exit 1
|
||||
chmod 0644 "$prefix/$libdir/`basename $i`" || exit 1
|
||||
chmod 0644 "$prefix/$libdir/$i" || exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -76,7 +68,6 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1
|
||||
|
||||
for i in $h; do
|
||||
appdir=`dirname "$i"`
|
||||
app=`basename "$i"`
|
||||
mkdir -p "$prefix/$appdir" || exit 1
|
||||
if [ "$scriptwrapper" = "y" ]; then
|
||||
if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
|
||||
@@ -87,19 +78,6 @@ for i in $h; do
|
||||
chmod +x "$prefix/$i"
|
||||
fi
|
||||
echo " $prefix/$i"
|
||||
elif [ "$binaries" = "y" ]; then
|
||||
# Copy the binary over rather
|
||||
if [ -e $sharedlib_dir/$app ]; then
|
||||
if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
|
||||
echo " Copying $sharedlib_dir/$app to $prefix/$i"
|
||||
cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1
|
||||
else
|
||||
echo " $prefix/$i already exists"
|
||||
fi
|
||||
else
|
||||
echo "Error: Could not find $sharedlib_dir/$app"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
bb_path="$prefix/bin/busybox"
|
||||
|
||||
@@ -20,7 +20,6 @@ exec >"$target.$$"
|
||||
|
||||
echo '#define UNPACKED_USAGE "" \'
|
||||
"$loc/usage" | od -v -b \
|
||||
| grep -v '^ ' \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
-e 's/ //g' \
|
||||
-e '/^$/d' \
|
||||
@@ -28,16 +27,6 @@ echo '#define UNPACKED_USAGE "" \'
|
||||
-e 's/^/"/' \
|
||||
-e 's/$/" \\/'
|
||||
echo ''
|
||||
# "grep -v '^ '" is for toybox's od bug: od -b prints some extra lines:
|
||||
#0000000 010 000 010 000 133 055 144 146 135 040 133 055 143 040 103 117
|
||||
# 000010 000010 026533 063144 020135 026533 020143 047503
|
||||
#0000020 116 106 104 111 122 135 040 133 055 154 040 114 117 107 106 111
|
||||
# 043116 044504 056522 055440 066055 046040 043517 044506
|
||||
#0000040 114 105 135 040 133 055 141 040 101 103 124 111 117 116 106 111
|
||||
# 042514 020135 026533 020141 041501 044524 047117 044506
|
||||
|
||||
echo "#define UNPACKED_USAGE_LENGTH `$loc/usage | wc -c`"
|
||||
echo
|
||||
|
||||
echo '#define PACKED_USAGE \'
|
||||
## Breaks on big-endian systems!
|
||||
@@ -51,7 +40,6 @@ echo '#define PACKED_USAGE \'
|
||||
## -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
|
||||
## -e 's/$/ \\/'
|
||||
"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -b \
|
||||
| grep -v '^ ' \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
-e 's/ //g' \
|
||||
-e '/^$/d' \
|
||||
|
||||
@@ -90,8 +90,6 @@ int main(void)
|
||||
printf("%s\n\n", usage_array[i].aname);
|
||||
}
|
||||
}
|
||||
printf("=back\n\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# When building a library, even intra-library references,
|
||||
# such as from find_applet_by_name() to applet_names[],
|
||||
# don't work with -fpic on sparc, needs -fPIC.
|
||||
# Don't know why it fails in this case but works when
|
||||
# a binary is being built.
|
||||
#
|
||||
# (if is superfluous, ARCH_FPIC is only used by library build, but it
|
||||
# demonstrates the point: non-pic binary does not need it)
|
||||
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
||||
ARCH_FPIC = -fPIC
|
||||
endif
|
||||
@@ -1,11 +0,0 @@
|
||||
# When building a library, even intra-library references,
|
||||
# such as from find_applet_by_name() to applet_names[],
|
||||
# don't work with -fpic on sparc, needs -fPIC.
|
||||
# Don't know why it fails in this case but works when
|
||||
# a binary is being built.
|
||||
#
|
||||
# (if is superfluous, ARCH_FPIC is only used by library build, but it
|
||||
# demonstrates the point: non-pic binary does not need it)
|
||||
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
||||
ARCH_FPIC = -fPIC
|
||||
endif
|
||||
+12
-10
@@ -8,31 +8,33 @@ menu "Archival Utilities"
|
||||
config FEATURE_SEAMLESS_XZ
|
||||
bool "Make tar, rpm, modprobe etc understand .xz data"
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .xz data.
|
||||
|
||||
config FEATURE_SEAMLESS_LZMA
|
||||
bool "Make tar, rpm, modprobe etc understand .lzma data"
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .lzma data.
|
||||
|
||||
config FEATURE_SEAMLESS_BZ2
|
||||
bool "Make tar, rpm, modprobe etc understand .bz2 data"
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .bz2 data.
|
||||
|
||||
config FEATURE_SEAMLESS_GZ
|
||||
bool "Make tar, rpm, modprobe etc understand .gz data"
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .gz data.
|
||||
|
||||
config FEATURE_SEAMLESS_Z
|
||||
bool "Make tar, rpm, modprobe etc understand .Z data"
|
||||
default n # it is ancient
|
||||
bool "tar, rpm, modprobe etc understand .Z data"
|
||||
default n
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .Z data.
|
||||
|
||||
INSERT
|
||||
|
||||
config FEATURE_LZMA_FAST
|
||||
bool "Optimize lzma for speed"
|
||||
default n
|
||||
depends on UNLZMA || LZCAT || LZMA || FEATURE_SEAMLESS_LZMA
|
||||
help
|
||||
This option reduces decompression time by about 25% at the cost of
|
||||
a 1K bigger binary.
|
||||
|
||||
endmenu
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
|
||||
libs-y += libarchive/
|
||||
libs-y += libarchive/
|
||||
|
||||
lib-y:=
|
||||
|
||||
|
||||
+30
-23
@@ -16,36 +16,48 @@
|
||||
* between different systems
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
*/
|
||||
|
||||
//config:config AR
|
||||
//config: bool "ar (9.5 kb)"
|
||||
//config: bool "ar"
|
||||
//config: default n # needs to be improved to be able to replace binutils ar
|
||||
//config: help
|
||||
//config: ar is an archival utility program used to create, modify, and
|
||||
//config: extract contents from archives. In practice, it is used exclusively
|
||||
//config: for object module archives used by compilers.
|
||||
//config: ar is an archival utility program used to create, modify, and
|
||||
//config: extract contents from archives. An archive is a single file holding
|
||||
//config: a collection of other files in a structure that makes it possible to
|
||||
//config: retrieve the original individual files (called archive members).
|
||||
//config: The original files' contents, mode (permissions), timestamp, owner,
|
||||
//config: and group are preserved in the archive, and can be restored on
|
||||
//config: extraction.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires ar, you should
|
||||
//config: probably say N here: most compilers come with their own ar utility.
|
||||
//config: The stored filename is limited to 15 characters. (for more information
|
||||
//config: see long filename support).
|
||||
//config: ar has 60 bytes of overheads for every stored file.
|
||||
//config:
|
||||
//config: This implementation of ar can extract archives, it cannot create or
|
||||
//config: modify them.
|
||||
//config: On an x86 system, the ar applet adds about 1K.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires ar, you should
|
||||
//config: probably say N here.
|
||||
//config:
|
||||
//config:config FEATURE_AR_LONG_FILENAMES
|
||||
//config: bool "Support long filenames (not needed for debs)"
|
||||
//config: bool "Support for long filenames (not needed for debs)"
|
||||
//config: default y
|
||||
//config: depends on AR
|
||||
//config: help
|
||||
//config: By default the ar format can only store the first 15 characters
|
||||
//config: of the filename, this option removes that limitation.
|
||||
//config: It supports the GNU ar long filename method which moves multiple long
|
||||
//config: filenames into a the data section of a new ar entry.
|
||||
//config: By default the ar format can only store the first 15 characters
|
||||
//config: of the filename, this option removes that limitation.
|
||||
//config: It supports the GNU ar long filename method which moves multiple long
|
||||
//config: filenames into a the data section of a new ar entry.
|
||||
//config:
|
||||
//config:config FEATURE_AR_CREATE
|
||||
//config: bool "Support archive creation"
|
||||
//config: default y
|
||||
//config: depends on AR
|
||||
//config: help
|
||||
//config: This enables archive creation (-c and -r) with busybox ar.
|
||||
//config: This enables archive creation (-c and -r) with busybox ar.
|
||||
|
||||
//applet:IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_AR) += ar.o
|
||||
|
||||
//usage:#define ar_trivial_usage
|
||||
@@ -240,16 +252,11 @@ int ar_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
archive_handle = init_handle();
|
||||
|
||||
/* prepend '-' to the first argument if required */
|
||||
if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0')
|
||||
argv[1] = xasprintf("-%s", argv[1]);
|
||||
opt = getopt32(argv, "^"
|
||||
"voc""ptx"IF_FEATURE_AR_CREATE("r")
|
||||
"\0"
|
||||
/* -1: at least one arg is reqd */
|
||||
/* one of p,t,x[,r] is required */
|
||||
"-1:p:t:x"IF_FEATURE_AR_CREATE(":r")
|
||||
);
|
||||
/* --: prepend '-' to the first argument if required */
|
||||
/* -1: at least one param is reqd */
|
||||
/* one of p,t,x[,r] is required */
|
||||
opt_complementary = "--:-1:p:t:x"IF_FEATURE_AR_CREATE(":r");
|
||||
opt = getopt32(argv, "voc""ptx"IF_FEATURE_AR_CREATE("r"));
|
||||
argv += optind;
|
||||
|
||||
t = opt / FIRST_CMD;
|
||||
|
||||
+144
-194
@@ -4,34 +4,22 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
/* lzop_main() uses bbunpack(), need this: */
|
||||
//kbuild:lib-$(CONFIG_LZOP) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_LZOPCAT) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_UNLZOP) += bbunzip.o
|
||||
/* bzip2_main() too: */
|
||||
//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o
|
||||
/* gzip_main() too: */
|
||||
//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
/* Note: must be kept in sync with archival/lzop.c */
|
||||
enum {
|
||||
OPT_STDOUT = 1 << 0,
|
||||
OPT_FORCE = 1 << 1,
|
||||
/* only some decompressors: */
|
||||
OPT_KEEP = 1 << 2,
|
||||
OPT_VERBOSE = 1 << 3,
|
||||
OPT_QUIET = 1 << 4,
|
||||
OPT_DECOMPRESS = 1 << 5,
|
||||
OPT_TEST = 1 << 6,
|
||||
SEAMLESS_MAGIC = (1 << 31) * ENABLE_ZCAT * SEAMLESS_COMPRESSION,
|
||||
OPT_VERBOSE = 1 << 2,
|
||||
OPT_QUIET = 1 << 3,
|
||||
OPT_DECOMPRESS = 1 << 4,
|
||||
OPT_TEST = 1 << 5,
|
||||
SEAMLESS_MAGIC = (1 << 31) * SEAMLESS_COMPRESSION,
|
||||
};
|
||||
|
||||
static
|
||||
@@ -51,7 +39,7 @@ char* FAST_FUNC append_ext(char *filename, const char *expected_ext)
|
||||
}
|
||||
|
||||
int FAST_FUNC bbunpack(char **argv,
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_state_t *xstate),
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux),
|
||||
char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
|
||||
const char *expected_ext
|
||||
)
|
||||
@@ -60,7 +48,7 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
IF_DESKTOP(long long) int status = 0;
|
||||
char *filename, *new_name;
|
||||
smallint exitcode = 0;
|
||||
transformer_state_t xstate;
|
||||
transformer_aux_data_t aux;
|
||||
|
||||
do {
|
||||
/* NB: new_name is *maybe* malloc'ed! */
|
||||
@@ -84,8 +72,7 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
goto err;
|
||||
} else {
|
||||
/* "clever zcat" with FILE */
|
||||
/* fail_if_not_compressed because zcat refuses uncompressed input */
|
||||
int fd = open_zipped(filename, /*fail_if_not_compressed:*/ 1);
|
||||
int fd = open_zipped(filename);
|
||||
if (fd < 0)
|
||||
goto err_name;
|
||||
xmove_fd(fd, STDIN_FILENO);
|
||||
@@ -93,7 +80,7 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
} else
|
||||
if (option_mask32 & SEAMLESS_MAGIC) {
|
||||
/* "clever zcat" on stdin */
|
||||
if (setup_unzip_on_fd(STDIN_FILENO, /*fail_if_not_compressed*/ 1))
|
||||
if (setup_unzip_on_fd(STDIN_FILENO, /*fail_if_not_detected*/ 0))
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -132,11 +119,9 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
}
|
||||
|
||||
if (!(option_mask32 & SEAMLESS_MAGIC)) {
|
||||
init_transformer_state(&xstate);
|
||||
/*xstate.signature_skipped = 0; - already is */
|
||||
/*xstate.src_fd = STDIN_FILENO; - already is */
|
||||
xstate.dst_fd = STDOUT_FILENO;
|
||||
status = unpacker(&xstate);
|
||||
init_transformer_aux_data(&aux);
|
||||
aux.check_signature = 1;
|
||||
status = unpacker(&aux);
|
||||
if (status < 0)
|
||||
exitcode = 1;
|
||||
} else {
|
||||
@@ -155,10 +140,10 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
unsigned new_name_len;
|
||||
|
||||
/* TODO: restore other things? */
|
||||
if (xstate.mtime != 0) {
|
||||
if (aux.mtime != 0) {
|
||||
struct timeval times[2];
|
||||
|
||||
times[1].tv_sec = times[0].tv_sec = xstate.mtime;
|
||||
times[1].tv_sec = times[0].tv_sec = aux.mtime;
|
||||
times[1].tv_usec = times[0].tv_usec = 0;
|
||||
/* Note: we closed it first.
|
||||
* On some systems calling utimes
|
||||
@@ -188,11 +173,8 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
}
|
||||
/* Delete _source_ file */
|
||||
del = filename;
|
||||
if (option_mask32 & OPT_KEEP) /* ... unless -k */
|
||||
del = NULL;
|
||||
}
|
||||
if (del)
|
||||
xunlink(del);
|
||||
xunlink(del);
|
||||
free_name:
|
||||
if (new_name != filename)
|
||||
free(new_name);
|
||||
@@ -205,10 +187,7 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
#if ENABLE_UNCOMPRESS \
|
||||
|| ENABLE_FEATURE_BZIP2_DECOMPRESS \
|
||||
|| ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA \
|
||||
|| ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ
|
||||
#if ENABLE_UNCOMPRESS || ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNXZ
|
||||
static
|
||||
char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
|
||||
{
|
||||
@@ -237,31 +216,27 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
|
||||
//usage: "\n -f Overwrite"
|
||||
|
||||
//config:config UNCOMPRESS
|
||||
//config: bool "uncompress (7.1 kb)"
|
||||
//config: default n # ancient
|
||||
//config: bool "uncompress"
|
||||
//config: default n
|
||||
//config: help
|
||||
//config: uncompress is used to decompress archives created by compress.
|
||||
//config: Not much used anymore, replaced by gzip/gunzip.
|
||||
//config: uncompress is used to decompress archives created by compress.
|
||||
//config: Not much used anymore, replaced by gzip/gunzip.
|
||||
|
||||
//applet:IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
|
||||
#if ENABLE_UNCOMPRESS
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(transformer_aux_data_t *aux)
|
||||
{
|
||||
return unpack_Z_stream(aux, STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
// (N)compress 4.2.4.4:
|
||||
// -d If given, decompression is done instead
|
||||
// -c Write output on stdout, don't remove original
|
||||
// -b Parameter limits the max number of bits/code
|
||||
// -f Forces output file to be generated
|
||||
// -v Write compression statistics
|
||||
// -V Output vesion and compile options
|
||||
// -r Recursive. If a filename is a directory, descend into it and compress everything
|
||||
getopt32(argv, "cf");
|
||||
|
||||
argv += optind;
|
||||
|
||||
return bbunpack(argv, unpack_Z_stream, make_new_name_generic, "Z");
|
||||
return bbunpack(argv, unpack_uncompress, make_new_name_generic, "Z");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -291,12 +266,11 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
* Ken Turkowski, Dave Mack and Peter Jannesen.
|
||||
*/
|
||||
//usage:#define gunzip_trivial_usage
|
||||
//usage: "[-cfkt] [FILE]..."
|
||||
//usage: "[-cft] [FILE]..."
|
||||
//usage:#define gunzip_full_usage "\n\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
//usage: "\n -t Test file integrity"
|
||||
//usage:
|
||||
//usage:#define gunzip_example_usage
|
||||
@@ -312,30 +286,18 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config GUNZIP
|
||||
//config: bool "gunzip (12 kb)"
|
||||
//config: bool "gunzip"
|
||||
//config: default y
|
||||
//config: select FEATURE_GZIP_DECOMPRESS
|
||||
//config: help
|
||||
//config: gunzip is used to decompress archives created by gzip.
|
||||
//config: You can use the '-t' option to test the integrity of
|
||||
//config: an archive, without decompressing it.
|
||||
//config:
|
||||
//config:config ZCAT
|
||||
//config: bool "zcat (25 kb)"
|
||||
//config: default y
|
||||
//config: select FEATURE_GZIP_DECOMPRESS
|
||||
//config: help
|
||||
//config: Alias to "gunzip -c".
|
||||
//config:
|
||||
//config:config FEATURE_GUNZIP_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on (GUNZIP || ZCAT) && LONG_OPTS
|
||||
//config: gunzip is used to decompress archives created by gzip.
|
||||
//config: You can use the `-t' option to test the integrity of
|
||||
//config: an archive, without decompressing it.
|
||||
|
||||
//applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP))
|
||||
// APPLET_ODDNAME:name main location suid_type help
|
||||
//applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))
|
||||
#if ENABLE_FEATURE_GZIP_DECOMPRESS
|
||||
//applet:IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))
|
||||
//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o
|
||||
#if ENABLE_GUNZIP
|
||||
static
|
||||
char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
|
||||
{
|
||||
@@ -361,17 +323,11 @@ char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UN
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS
|
||||
static const char gunzip_longopts[] ALIGN1 =
|
||||
"stdout\0" No_argument "c"
|
||||
"to-stdout\0" No_argument "c"
|
||||
"force\0" No_argument "f"
|
||||
"test\0" No_argument "t"
|
||||
"no-name\0" No_argument "n"
|
||||
;
|
||||
#endif
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux)
|
||||
{
|
||||
return unpack_gz_stream(aux, STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
/*
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
||||
* Man page says:
|
||||
@@ -388,23 +344,19 @@ static const char gunzip_longopts[] ALIGN1 =
|
||||
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS
|
||||
getopt32long(argv, "cfkvqdtn", gunzip_longopts);
|
||||
#else
|
||||
getopt32(argv, "cfkvqdtn");
|
||||
#endif
|
||||
getopt32(argv, "cfvqdtn");
|
||||
argv += optind;
|
||||
|
||||
/* If called as zcat...
|
||||
* Normally, "zcat" is just "gunzip -c".
|
||||
* But if seamless magic is enabled, then we are much more clever.
|
||||
*/
|
||||
if (ENABLE_ZCAT && (!ENABLE_GUNZIP || applet_name[1] == 'c'))
|
||||
if (applet_name[1] == 'c')
|
||||
option_mask32 |= OPT_STDOUT | SEAMLESS_MAGIC;
|
||||
|
||||
return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip, /*unused:*/ NULL);
|
||||
return bbunpack(argv, unpack_gunzip, make_new_name_gunzip, /*unused:*/ NULL);
|
||||
}
|
||||
#endif /* FEATURE_GZIP_DECOMPRESS */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -414,51 +366,48 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//usage:#define bunzip2_trivial_usage
|
||||
//usage: "[-cfk] [FILE]..."
|
||||
//usage: "[-cf] [FILE]..."
|
||||
//usage:#define bunzip2_full_usage "\n\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
//usage:#define bzcat_trivial_usage
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define bzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config BUNZIP2
|
||||
//config: bool "bunzip2 (8.8 kb)"
|
||||
//config: bool "bunzip2"
|
||||
//config: default y
|
||||
//config: select FEATURE_BZIP2_DECOMPRESS
|
||||
//config: help
|
||||
//config: bunzip2 is a compression utility using the Burrows-Wheeler block
|
||||
//config: sorting text compression algorithm, and Huffman coding. Compression
|
||||
//config: is generally considerably better than that achieved by more
|
||||
//config: conventional LZ77/LZ78-based compressors, and approaches the
|
||||
//config: performance of the PPM family of statistical compressors.
|
||||
//config: bunzip2 is a compression utility using the Burrows-Wheeler block
|
||||
//config: sorting text compression algorithm, and Huffman coding. Compression
|
||||
//config: is generally considerably better than that achieved by more
|
||||
//config: conventional LZ77/LZ78-based compressors, and approaches the
|
||||
//config: performance of the PPM family of statistical compressors.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires bunzip2, you
|
||||
//config: should probably say N here.
|
||||
//config:
|
||||
//config:config BZCAT
|
||||
//config: bool "bzcat (8.8 kb)"
|
||||
//config: default y
|
||||
//config: select FEATURE_BZIP2_DECOMPRESS
|
||||
//config: help
|
||||
//config: Alias to "bunzip2 -c".
|
||||
//config: Unless you have a specific application which requires bunzip2, you
|
||||
//config: should probably say N here.
|
||||
|
||||
//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
// APPLET_ODDNAME:name main location suid_type help
|
||||
//applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat))
|
||||
#if ENABLE_FEATURE_BZIP2_DECOMPRESS || ENABLE_BUNZIP2 || ENABLE_BZCAT
|
||||
//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat))
|
||||
//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o
|
||||
#if ENABLE_BUNZIP2
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux)
|
||||
{
|
||||
return unpack_bz2_stream(aux, STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfkvqdt");
|
||||
getopt32(argv, "cfvqdt");
|
||||
argv += optind;
|
||||
if (ENABLE_BZCAT && (!ENABLE_BUNZIP2 || applet_name[2] == 'c')) /* bzcat */
|
||||
if (applet_name[2] == 'c') /* bzcat */
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
return bbunpack(argv, unpack_bz2_stream, make_new_name_generic, "bz2");
|
||||
return bbunpack(argv, unpack_bunzip2, make_new_name_generic, "bz2");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -472,139 +421,140 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//usage:#define unlzma_trivial_usage
|
||||
//usage: "[-cfk] [FILE]..."
|
||||
//usage: "[-cf] [FILE]..."
|
||||
//usage:#define unlzma_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
//usage:
|
||||
//usage:#define lzma_trivial_usage
|
||||
//usage: "-d [-cfk] [FILE]..."
|
||||
//usage: "-d [-cf] [FILE]..."
|
||||
//usage:#define lzma_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "\n -d Decompress"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
//usage:
|
||||
//usage:#define lzcat_trivial_usage
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define lzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config UNLZMA
|
||||
//config: bool "unlzma (8.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
||||
//config: compression algorithm, and range coding. Compression
|
||||
//config: is generally considerably better than that achieved by the bzip2
|
||||
//config: compressors.
|
||||
//config:
|
||||
//config:config LZCAT
|
||||
//config: bool "lzcat (8.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Alias to "unlzma -c".
|
||||
//config:
|
||||
//config:config LZMA
|
||||
//config: bool "lzma -d"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Enable this option if you want commands like "lzma -d" to work.
|
||||
//config: IOW: you'll get lzma applet, but it will always require -d option.
|
||||
|
||||
//applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
// APPLET_ODDNAME:name main location suid_type help
|
||||
//applet:IF_LZCAT(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat))
|
||||
//applet:IF_LZMA( APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma))
|
||||
//kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_LZCAT) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_LZMA) += bbunzip.o
|
||||
#if ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA
|
||||
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
IF_LZMA(int opts =) getopt32(argv, "cfkvqdt");
|
||||
# if ENABLE_LZMA
|
||||
/* lzma without -d or -t? */
|
||||
if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
|
||||
bb_show_usage();
|
||||
# endif
|
||||
/* lzcat? */
|
||||
if (ENABLE_LZCAT && applet_name[2] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
argv += optind;
|
||||
return bbunpack(argv, unpack_lzma_stream, make_new_name_generic, "lzma");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//usage:
|
||||
//usage:#define unxz_trivial_usage
|
||||
//usage: "[-cfk] [FILE]..."
|
||||
//usage: "[-cf] [FILE]..."
|
||||
//usage:#define unxz_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
//usage:
|
||||
//usage:#define xz_trivial_usage
|
||||
//usage: "-d [-cfk] [FILE]..."
|
||||
//usage: "-d [-cf] [FILE]..."
|
||||
//usage:#define xz_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "\n -d Decompress"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
//usage:
|
||||
//usage:#define xzcat_trivial_usage
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define xzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config UNXZ
|
||||
//config: bool "unxz (13 kb)"
|
||||
//config:config UNLZMA
|
||||
//config: bool "unlzma"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unxz is a unlzma successor.
|
||||
//config: unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
||||
//config: compression algorithm, and range coding. Compression
|
||||
//config: is generally considerably better than that achieved by the bzip2
|
||||
//config: compressors.
|
||||
//config:
|
||||
//config:config XZCAT
|
||||
//config: bool "xzcat (13 kb)"
|
||||
//config: The BusyBox unlzma applet is limited to decompression only.
|
||||
//config: On an x86 system, this applet adds about 4K.
|
||||
//config:
|
||||
//config:config FEATURE_LZMA_FAST
|
||||
//config: bool "Optimize unlzma for speed"
|
||||
//config: default n
|
||||
//config: depends on UNLZMA
|
||||
//config: help
|
||||
//config: This option reduces decompression time by about 25% at the cost of
|
||||
//config: a 1K bigger binary.
|
||||
//config:
|
||||
//config:config LZMA
|
||||
//config: bool "Provide lzma alias which supports only unpacking"
|
||||
//config: default y
|
||||
//config: depends on UNLZMA
|
||||
//config: help
|
||||
//config: Enable this option if you want commands like "lzma -d" to work.
|
||||
//config: IOW: you'll get lzma applet, but it will always require -d option.
|
||||
|
||||
//applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat))
|
||||
//applet:IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma))
|
||||
//kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o
|
||||
#if ENABLE_UNLZMA
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux)
|
||||
{
|
||||
return unpack_lzma_stream(aux, STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
IF_LZMA(int opts =) getopt32(argv, "cfvqdt");
|
||||
# if ENABLE_LZMA
|
||||
/* lzma without -d or -t? */
|
||||
if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
|
||||
bb_show_usage();
|
||||
# endif
|
||||
/* lzcat? */
|
||||
if (applet_name[2] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
argv += optind;
|
||||
return bbunpack(argv, unpack_unlzma, make_new_name_generic, "lzma");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//config:config UNXZ
|
||||
//config: bool "unxz"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Alias to "unxz -c".
|
||||
//config: unxz is a unlzma successor.
|
||||
//config:
|
||||
//config:config XZ
|
||||
//config: bool "xz -d"
|
||||
//config: bool "Provide xz alias which supports only unpacking"
|
||||
//config: default y
|
||||
//config: depends on UNXZ
|
||||
//config: help
|
||||
//config: Enable this option if you want commands like "xz -d" to work.
|
||||
//config: IOW: you'll get xz applet, but it will always require -d option.
|
||||
//config: Enable this option if you want commands like "xz -d" to work.
|
||||
//config: IOW: you'll get xz applet, but it will always require -d option.
|
||||
|
||||
//applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
// APPLET_ODDNAME:name main location suid_type help
|
||||
//applet:IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
|
||||
//applet:IF_XZ( APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz))
|
||||
//applet:IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
|
||||
//applet:IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz))
|
||||
//kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_XZCAT) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_XZ) += bbunzip.o
|
||||
#if ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ
|
||||
#if ENABLE_UNXZ
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux)
|
||||
{
|
||||
return unpack_xz_stream(aux, STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unxz_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
IF_XZ(int opts =) getopt32(argv, "cfkvqdt");
|
||||
IF_XZ(int opts =) getopt32(argv, "cfvqdt");
|
||||
# if ENABLE_XZ
|
||||
/* xz without -d or -t? */
|
||||
if (applet_name[2] == '\0' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
|
||||
bb_show_usage();
|
||||
# endif
|
||||
/* xzcat? */
|
||||
if (ENABLE_XZCAT && applet_name[2] == 'c')
|
||||
if (applet_name[2] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
argv += optind;
|
||||
return bbunpack(argv, unpack_xz_stream, make_new_name_generic, "xz");
|
||||
return bbunpack(argv, unpack_unxz, make_new_name_generic, "xz");
|
||||
}
|
||||
#endif
|
||||
+18
-33
@@ -6,30 +6,21 @@
|
||||
* See README and LICENSE files in bz/ directory for more information
|
||||
* about bzip2 library code.
|
||||
*/
|
||||
|
||||
//config:config BZIP2
|
||||
//config: bool "bzip2 (18 kb)"
|
||||
//config: bool "bzip2"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
//config: sorting text compression algorithm, and Huffman coding. Compression
|
||||
//config: is generally considerably better than that achieved by more
|
||||
//config: conventional LZ77/LZ78-based compressors, and approaches the
|
||||
//config: performance of the PPM family of statistical compressors.
|
||||
//config: bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
//config: sorting text compression algorithm, and Huffman coding. Compression
|
||||
//config: is generally considerably better than that achieved by more
|
||||
//config: conventional LZ77/LZ78-based compressors, and approaches the
|
||||
//config: performance of the PPM family of statistical compressors.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires bzip2, you
|
||||
//config: should probably say N here.
|
||||
//config:
|
||||
//config:config FEATURE_BZIP2_DECOMPRESS
|
||||
//config: bool "Enable decompression"
|
||||
//config: default y
|
||||
//config: depends on BZIP2 || BUNZIP2 || BZCAT
|
||||
//config: help
|
||||
//config: Enable -d (--decompress) and -t (--test) options for bzip2.
|
||||
//config: This will be automatically selected if bunzip2 or bzcat is
|
||||
//config: enabled.
|
||||
//config: Unless you have a specific application which requires bzip2, you
|
||||
//config: should probably say N here.
|
||||
|
||||
//applet:IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_BZIP2) += bzip2.o
|
||||
|
||||
//usage:#define bzip2_trivial_usage
|
||||
@@ -37,13 +28,9 @@
|
||||
//usage:#define bzip2_full_usage "\n\n"
|
||||
//usage: "Compress FILEs (or stdin) with bzip2 algorithm\n"
|
||||
//usage: "\n -1..9 Compression level"
|
||||
//usage: IF_FEATURE_BZIP2_DECOMPRESS(
|
||||
//usage: "\n -d Decompress"
|
||||
//usage: "\n -t Test file integrity"
|
||||
//usage: )
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
@@ -140,7 +127,7 @@ IF_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, vo
|
||||
}
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC compressStream(transformer_state_t *xstate UNUSED_PARAM)
|
||||
IF_DESKTOP(long long) int FAST_FUNC compressStream(transformer_aux_data_t *aux UNUSED_PARAM)
|
||||
{
|
||||
IF_DESKTOP(long long) int total;
|
||||
ssize_t count;
|
||||
@@ -195,17 +182,15 @@ int bzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
* --best alias for -9
|
||||
*/
|
||||
|
||||
opt = getopt32(argv, "^"
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
"cfkv" IF_FEATURE_BZIP2_DECOMPRESS("dt") "123456789qzs"
|
||||
"\0" "s2" /* -s means -2 (compatibility) */
|
||||
);
|
||||
#if ENABLE_FEATURE_BZIP2_DECOMPRESS /* bunzip2_main may not be visible... */
|
||||
if (opt & 0x30) // -d and/or -t
|
||||
opt_complementary = "s2"; /* -s means -2 (compatibility) */
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
opt = getopt32(argv, "cfv" IF_BUNZIP2("dt") "123456789qzs");
|
||||
#if ENABLE_BUNZIP2 /* bunzip2_main may not be visible... */
|
||||
if (opt & 0x18) // -d and/or -t
|
||||
return bunzip2_main(argc, argv);
|
||||
opt >>= 6;
|
||||
opt >>= 5;
|
||||
#else
|
||||
opt >>= 4;
|
||||
opt >>= 3;
|
||||
#endif
|
||||
opt = (uint8_t)opt; /* isolate bits for -1..-8 */
|
||||
opt |= 0x100; /* if nothing else, assume -9 */
|
||||
@@ -216,6 +201,6 @@ int bzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
argv += optind;
|
||||
option_mask32 &= 0xf; /* ignore all except -cfkv */
|
||||
option_mask32 &= 0x7; /* ignore all except -cfv */
|
||||
return bbunpack(argv, compressStream, append_ext, "bz2");
|
||||
}
|
||||
+32
-60
@@ -10,48 +10,50 @@
|
||||
* Doesn't check CRC's
|
||||
* Only supports new ASCII and CRC formats
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
//config:config CPIO
|
||||
//config: bool "cpio (14 kb)"
|
||||
//config: bool "cpio"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cpio is an archival utility program used to create, modify, and
|
||||
//config: extract contents from archives.
|
||||
//config: cpio has 110 bytes of overheads for every stored file.
|
||||
//config: cpio is an archival utility program used to create, modify, and
|
||||
//config: extract contents from archives.
|
||||
//config: cpio has 110 bytes of overheads for every stored file.
|
||||
//config:
|
||||
//config: This implementation of cpio can extract cpio archives created in the
|
||||
//config: "newc" or "crc" format.
|
||||
//config: This implementation of cpio can extract cpio archives created in the
|
||||
//config: "newc" or "crc" format, it cannot create or modify them.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires cpio, you
|
||||
//config: should probably say N here.
|
||||
//config: Unless you have a specific application which requires cpio, you
|
||||
//config: should probably say N here.
|
||||
//config:
|
||||
//config:config FEATURE_CPIO_O
|
||||
//config: bool "Support archive creation"
|
||||
//config: bool "Support for archive creation"
|
||||
//config: default y
|
||||
//config: depends on CPIO
|
||||
//config: help
|
||||
//config: This implementation of cpio can create cpio archives in the "newc"
|
||||
//config: format only.
|
||||
//config: This implementation of cpio can create cpio archives in the "newc"
|
||||
//config: format only.
|
||||
//config:
|
||||
//config:config FEATURE_CPIO_P
|
||||
//config: bool "Support passthrough mode"
|
||||
//config: bool "Support for passthrough mode"
|
||||
//config: default y
|
||||
//config: depends on FEATURE_CPIO_O
|
||||
//config: help
|
||||
//config: Passthrough mode. Rarely used.
|
||||
//config: Passthrough mode. Rarely used.
|
||||
|
||||
//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_CPIO) += cpio.o
|
||||
|
||||
//usage:#define cpio_trivial_usage
|
||||
//usage: "[-dmvu] [-F FILE] [-R USER[:GRP]]" IF_FEATURE_CPIO_O(" [-H newc]")
|
||||
//usage: "[-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]")
|
||||
//usage: " [-ti"IF_FEATURE_CPIO_O("o")"]" IF_FEATURE_CPIO_P(" [-p DIR]")
|
||||
//usage: " [EXTR_FILE]..."
|
||||
//usage:#define cpio_full_usage "\n\n"
|
||||
//usage: "Extract (-i) or list (-t) files from a cpio archive"
|
||||
//usage: "Extract or list files from a cpio archive"
|
||||
//usage: IF_FEATURE_CPIO_O(", or"
|
||||
//usage: "\ntake file list from stdin and create an archive (-o)"
|
||||
//usage: IF_FEATURE_CPIO_P(" or copy files (-p)")
|
||||
//usage: "\ncreate an archive" IF_FEATURE_CPIO_P(" (-o) or copy files (-p)")
|
||||
//usage: " using file list on stdin"
|
||||
//usage: )
|
||||
//usage: "\n"
|
||||
//usage: "\nMain operation mode:"
|
||||
@@ -63,13 +65,11 @@
|
||||
//usage: IF_FEATURE_CPIO_P(
|
||||
//usage: "\n -p DIR Copy files to DIR"
|
||||
//usage: )
|
||||
//usage: "\nOptions:"
|
||||
//usage: "\n -d Make leading directories"
|
||||
//usage: "\n -m Preserve mtime"
|
||||
//usage: "\n -v Verbose"
|
||||
//usage: "\n -u Overwrite"
|
||||
//usage: "\n -F FILE Input (-t,-i,-p) or output (-o) file"
|
||||
//usage: "\n -R USER[:GRP] Set owner of created files"
|
||||
//usage: IF_FEATURE_CPIO_O(
|
||||
//usage: "\n -H newc Archive format"
|
||||
//usage: )
|
||||
@@ -129,7 +129,7 @@
|
||||
-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][:.][GRP] Set owner of created files
|
||||
-R, --owner=[USER][:.][GROUP] Set owner of created files
|
||||
|
||||
Options valid in --extract and --pass-through modes:
|
||||
-d, --make-directories Create leading directories where needed
|
||||
@@ -139,10 +139,6 @@
|
||||
-u, --unconditional Replace all files unconditionally
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
enum {
|
||||
OPT_EXTRACT = (1 << 0),
|
||||
OPT_TEST = (1 << 1),
|
||||
@@ -153,8 +149,7 @@ enum {
|
||||
OPT_PRESERVE_MTIME = (1 << 6),
|
||||
OPT_DEREF = (1 << 7),
|
||||
OPT_FILE = (1 << 8),
|
||||
OPT_OWNER = (1 << 9),
|
||||
OPTBIT_OWNER = 9,
|
||||
OPTBIT_FILE = 8,
|
||||
IF_FEATURE_CPIO_O(OPTBIT_CREATE ,)
|
||||
IF_FEATURE_CPIO_O(OPTBIT_FORMAT ,)
|
||||
IF_FEATURE_CPIO_P(OPTBIT_PASSTHROUGH,)
|
||||
@@ -167,18 +162,7 @@ enum {
|
||||
OPT_2STDOUT = IF_LONG_OPTS( (1 << OPTBIT_2STDOUT )) + 0,
|
||||
};
|
||||
|
||||
#define OPTION_STR "it0uvdmLF:R:"
|
||||
|
||||
struct globals {
|
||||
struct bb_uidgid_t owner_ugid;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
void BUG_cpio_globals_too_big(void);
|
||||
#define INIT_G() do { \
|
||||
setup_common_bufsiz(); \
|
||||
G.owner_ugid.uid = -1L; \
|
||||
G.owner_ugid.gid = -1L; \
|
||||
} while (0)
|
||||
#define OPTION_STR "it0uvdmLF:"
|
||||
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
static off_t cpio_pad4(off_t size)
|
||||
@@ -196,6 +180,7 @@ static off_t cpio_pad4(off_t size)
|
||||
* It's ok to exit instead of return. */
|
||||
static NOINLINE int cpio_o(void)
|
||||
{
|
||||
static const char trailer[] ALIGN1 = "TRAILER!!!";
|
||||
struct name_s {
|
||||
struct name_s *next;
|
||||
char name[1];
|
||||
@@ -237,11 +222,6 @@ static NOINLINE int cpio_o(void)
|
||||
bb_simple_perror_msg_and_die(name);
|
||||
}
|
||||
|
||||
if (G.owner_ugid.uid != (uid_t)-1L)
|
||||
st.st_uid = G.owner_ugid.uid;
|
||||
if (G.owner_ugid.gid != (gid_t)-1L)
|
||||
st.st_gid = G.owner_ugid.gid;
|
||||
|
||||
if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)))
|
||||
st.st_size = 0; /* paranoia */
|
||||
|
||||
@@ -276,6 +256,7 @@ static NOINLINE int cpio_o(void)
|
||||
free(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
} else { /* line == NULL: EOF */
|
||||
next_link:
|
||||
if (links) {
|
||||
@@ -294,7 +275,7 @@ static NOINLINE int cpio_o(void)
|
||||
} else {
|
||||
/* If no (more) hardlinks to output,
|
||||
* output "trailer" entry */
|
||||
name = cpio_TRAILER;
|
||||
name = trailer;
|
||||
/* st.st_size == 0 is a must, but for uniformity
|
||||
* in the output, we zero out everything */
|
||||
memset(&st, 0, sizeof(st));
|
||||
@@ -342,7 +323,7 @@ static NOINLINE int cpio_o(void)
|
||||
}
|
||||
|
||||
if (!line) {
|
||||
if (name != cpio_TRAILER)
|
||||
if (name != trailer)
|
||||
goto next_link;
|
||||
/* TODO: GNU cpio pads trailer to 512 bytes, do we want that? */
|
||||
return EXIT_SUCCESS;
|
||||
@@ -358,11 +339,11 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
char *cpio_filename;
|
||||
char *cpio_owner;
|
||||
IF_FEATURE_CPIO_O(const char *cpio_fmt = "";)
|
||||
unsigned opt;
|
||||
|
||||
#if ENABLE_LONG_OPTS
|
||||
const char *long_opts =
|
||||
applet_long_options =
|
||||
"extract\0" No_argument "i"
|
||||
"list\0" No_argument "t"
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
@@ -372,14 +353,12 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
"pass-through\0" No_argument "p"
|
||||
#endif
|
||||
#endif
|
||||
"owner\0" Required_argument "R"
|
||||
"verbose\0" No_argument "v"
|
||||
"quiet\0" No_argument "\xff"
|
||||
"to-stdout\0" No_argument "\xfe"
|
||||
;
|
||||
#endif
|
||||
|
||||
INIT_G();
|
||||
archive_handle = init_handle();
|
||||
/* archive_handle->src_fd = STDIN_FILENO; - done by init_handle */
|
||||
archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
|
||||
@@ -390,21 +369,14 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* -L makes sense only with -o or -p */
|
||||
|
||||
#if !ENABLE_FEATURE_CPIO_O
|
||||
opt = getopt32long(argv, OPTION_STR, long_opts, &cpio_filename, &cpio_owner);
|
||||
#else
|
||||
opt = getopt32long(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), long_opts,
|
||||
&cpio_filename, &cpio_owner, &cpio_fmt);
|
||||
#endif
|
||||
opt = getopt32(argv, OPTION_STR, &cpio_filename);
|
||||
argv += optind;
|
||||
if (opt & OPT_OWNER) { /* -R */
|
||||
parse_chown_usergroup_or_die(&G.owner_ugid, cpio_owner);
|
||||
archive_handle->cpio__owner = G.owner_ugid;
|
||||
}
|
||||
#if !ENABLE_FEATURE_CPIO_O
|
||||
if (opt & OPT_FILE) { /* -F */
|
||||
xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
|
||||
}
|
||||
#else
|
||||
opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt);
|
||||
argv += optind;
|
||||
if ((opt & (OPT_FILE|OPT_CREATE)) == OPT_FILE) { /* -F without -o */
|
||||
xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
|
||||
}
|
||||
|
||||
+30
-36
@@ -18,26 +18,26 @@
|
||||
* known difference between busybox dpkg and the official dpkg that i don't
|
||||
* consider important, its worth keeping a note of differences anyway, just to
|
||||
* make it easier to maintain.
|
||||
* - the first value for the confflile: field isn't placed on a new line.
|
||||
* - the first value for the confflile: field isnt placed on a new line.
|
||||
* - when installing a package the status: field is placed at the end of the
|
||||
* section, rather than just after the package: field.
|
||||
*
|
||||
* bugs that need to be fixed
|
||||
* - (unknown, please let me know when you find any)
|
||||
*/
|
||||
|
||||
//config:config DPKG
|
||||
//config: bool "dpkg (44 kb)"
|
||||
//config: default y
|
||||
//config: bool "dpkg"
|
||||
//config: default n
|
||||
//config: select FEATURE_SEAMLESS_GZ
|
||||
//config: help
|
||||
//config: dpkg is a medium-level tool to install, build, remove and manage
|
||||
//config: Debian packages.
|
||||
//config: dpkg is a medium-level tool to install, build, remove and manage
|
||||
//config: Debian packages.
|
||||
//config:
|
||||
//config: This implementation of dpkg has a number of limitations,
|
||||
//config: you should use the official dpkg if possible.
|
||||
//config: This implementation of dpkg has a number of limitations,
|
||||
//config: you should use the official dpkg if possible.
|
||||
|
||||
//applet:IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_DPKG) += dpkg.o
|
||||
|
||||
//usage:#define dpkg_trivial_usage
|
||||
@@ -110,7 +110,7 @@ typedef struct common_node_s {
|
||||
edge_t **edge;
|
||||
} common_node_t;
|
||||
|
||||
/* Currently it doesn't store packages that have state-status of not-installed
|
||||
/* Currently it doesnt store packages that have state-status of not-installed
|
||||
* So it only really has to be the size of the maximum number of packages
|
||||
* likely to be installed at any one time, so there is a bit of leeway here */
|
||||
#define STATUS_HASH_PRIME 8191
|
||||
@@ -205,7 +205,7 @@ static int search_name_hashtable(const char *key)
|
||||
return probe_address;
|
||||
}
|
||||
|
||||
/* this DOESN'T add the key to the hashtable
|
||||
/* this DOESNT add the key to the hashtable
|
||||
* TODO make it consistent with search_name_hashtable
|
||||
*/
|
||||
static unsigned search_status_hashtable(const char *key)
|
||||
@@ -467,7 +467,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
version = strchr(field2, '(');
|
||||
if (version == NULL) {
|
||||
edge->operator = VER_ANY;
|
||||
/* Get the versions hash number, adding it if the number isn't already in there */
|
||||
/* Get the versions hash number, adding it if the number isnt already in there */
|
||||
edge->version = search_name_hashtable("ANY");
|
||||
} else {
|
||||
/* Skip leading ' ' or '(' */
|
||||
@@ -496,7 +496,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
|
||||
/* Truncate version at trailing ' ' or ')' */
|
||||
version[strcspn(version, " )")] = '\0';
|
||||
/* Get the versions hash number, adding it if the number isn't already in there */
|
||||
/* Get the versions hash number, adding it if the number isnt already in there */
|
||||
edge->version = search_name_hashtable(version);
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ static int read_package_field(const char *package_buffer, char **field_name, cha
|
||||
offset_name_end = offset;
|
||||
offset_value_start = next_offset;
|
||||
}
|
||||
/* TODO: Name might still have trailing spaces if ':' isn't
|
||||
/* TODO: Name might still have trailing spaces if ':' isnt
|
||||
* immediately after name */
|
||||
break;
|
||||
case '\n':
|
||||
@@ -776,7 +776,7 @@ static void index_status_file(const char *filename)
|
||||
const unsigned package_num = fill_package_struct(control_buffer);
|
||||
if (package_num != -1) {
|
||||
status_node = xmalloc(sizeof(status_node_t));
|
||||
/* fill_package_struct doesn't handle the status field */
|
||||
/* fill_package_struct doesnt handle the status field */
|
||||
status_line = strstr(control_buffer, "Status:");
|
||||
if (status_line != NULL) {
|
||||
status_line += 7;
|
||||
@@ -850,7 +850,7 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
if (status_hashtable[status_num] != NULL) {
|
||||
const char *status_from_hashtable = name_hashtable[status_hashtable[status_num]->status];
|
||||
if (strcmp(status_from_file, status_from_hashtable) != 0) {
|
||||
/* New status isn't exactly the same as old status */
|
||||
/* New status isnt exactly the same as old status */
|
||||
const int state_status = get_status(status_num, 3);
|
||||
if ((strcmp("installed", name_hashtable[state_status]) == 0)
|
||||
|| (strcmp("unpacked", name_hashtable[state_status]) == 0)
|
||||
@@ -919,7 +919,7 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* If the package from the status file wasn't handle above, do it now*/
|
||||
/* If the package from the status file wasnt handle above, do it now*/
|
||||
if (!write_flag) {
|
||||
fprintf(new_status_file, "%s\n\n", control_buffer);
|
||||
}
|
||||
@@ -946,7 +946,7 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
if (errno != ENOENT)
|
||||
bb_error_msg_and_die("can't create backup status file");
|
||||
/* Its ok if renaming the status file fails because status
|
||||
* file doesn't exist, maybe we are starting from scratch */
|
||||
* file doesnt exist, maybe we are starting from scratch */
|
||||
bb_error_msg("no status file found, creating new one");
|
||||
}
|
||||
|
||||
@@ -1061,7 +1061,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
|
||||
}
|
||||
|
||||
|
||||
/* Check dependentcies */
|
||||
/* Check dependendcies */
|
||||
for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
|
||||
int status_num = 0;
|
||||
int number_of_alternatives = 0;
|
||||
@@ -1151,13 +1151,13 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
|
||||
if (result && number_of_alternatives == 0) {
|
||||
if (root_of_alternatives)
|
||||
bb_error_msg_and_die(
|
||||
"package %s %sdepends on %s, which %s",
|
||||
"package %s %sdepends on %s, "
|
||||
"which cannot be satisfied",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[root_of_alternatives->name],
|
||||
"cannot be satisfied");
|
||||
name_hashtable[root_of_alternatives->name]);
|
||||
bb_error_msg_and_die(
|
||||
"package %s %sdepends on %s, which %s",
|
||||
"package %s %sdepends on %s, which %s\n",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[package_edge->name],
|
||||
@@ -1244,7 +1244,7 @@ static void run_package_script_or_die(const char *package_name, const char *scri
|
||||
|
||||
script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
|
||||
|
||||
/* If the file doesn't exist it isn't fatal */
|
||||
/* If the file doesnt exist is isnt fatal */
|
||||
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
|
||||
free(script_path);
|
||||
if (result)
|
||||
@@ -1472,16 +1472,12 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar");
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_XZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar.xz");
|
||||
#endif
|
||||
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->dpkg__sub_archive = tar_handle;
|
||||
@@ -1496,19 +1492,12 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar");
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_LZMA
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.lzma");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_XZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.xz");
|
||||
#endif
|
||||
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->dpkg__sub_archive = tar_handle;
|
||||
@@ -1766,7 +1755,8 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
INIT_G();
|
||||
|
||||
opt = getopt32long(argv, "CilPruF:", dpkg_longopts, &str_f);
|
||||
IF_LONG_OPTS(applet_long_options = dpkg_longopts);
|
||||
opt = getopt32(argv, "CilPruF:", &str_f);
|
||||
argv += optind;
|
||||
//if (opt & OPT_configure) ... // -C
|
||||
if (opt & OPT_force) { // -F (--force in official dpkg)
|
||||
@@ -1838,7 +1828,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
||||
) {
|
||||
status_node = xmalloc(sizeof(status_node_t));
|
||||
status_node->package = deb_file[deb_count]->package;
|
||||
/* reinstreq isn't changed to "ok" until the package control info
|
||||
/* reinstreq isnt changed to "ok" until the package control info
|
||||
* is written to the status file*/
|
||||
status_node->status = search_name_hashtable("install reinstreq not-installed");
|
||||
status_hashtable[status_num] = status_node;
|
||||
@@ -1937,6 +1927,10 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
||||
for (i = 0; i < STATUS_HASH_PRIME; i++) {
|
||||
free(status_hashtable[i]);
|
||||
}
|
||||
|
||||
free(status_hashtable);
|
||||
free(package_hashtable);
|
||||
free(name_hashtable);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+60
-48
@@ -4,31 +4,41 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//config:config DPKG_DEB
|
||||
//config: bool "dpkg_deb"
|
||||
//config: default y
|
||||
//config: default n
|
||||
//config: select FEATURE_SEAMLESS_GZ
|
||||
//config: help
|
||||
//config: dpkg-deb unpacks and provides information about Debian archives.
|
||||
//config: dpkg-deb unpacks and provides information about Debian archives.
|
||||
//config:
|
||||
//config: This implementation of dpkg-deb cannot pack archives.
|
||||
//config: This implementation of dpkg-deb cannot pack archives.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires dpkg-deb,
|
||||
//config: say N here.
|
||||
//config: Unless you have a specific application which requires dpkg-deb,
|
||||
//config: say N here.
|
||||
//config:
|
||||
//config:config FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
//config: bool "Extract only (-x)"
|
||||
//config: default n
|
||||
//config: depends on DPKG_DEB
|
||||
//config: help
|
||||
//config: This reduces dpkg-deb to the equivalent of
|
||||
//config: "ar -p <deb> data.tar.gz | tar -zx". However it saves space as none
|
||||
//config: of the extra dpkg-deb, ar or tar options are needed, they are linked
|
||||
//config: to internally.
|
||||
|
||||
//applet:IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, BB_DIR_USR_BIN, BB_SUID_DROP, dpkg_deb))
|
||||
|
||||
//kbuild:lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
|
||||
//usage:#define dpkg_deb_trivial_usage
|
||||
//usage: "[-cefxX] FILE [DIR]"
|
||||
//usage: "[-cefxX] FILE [argument]"
|
||||
//usage:#define dpkg_deb_full_usage "\n\n"
|
||||
//usage: "Perform actions on Debian packages (.deb)\n"
|
||||
//usage: "\n -c List files"
|
||||
//usage: "\n -f Print control fields"
|
||||
//usage: "\n -e Extract control files to DIR (default: ./DEBIAN)"
|
||||
//usage: "\n -x Extract files to DIR (no default)"
|
||||
//usage: "\n -X Verbose -x"
|
||||
//usage: "Perform actions on Debian packages (.debs)\n"
|
||||
//usage: "\n -c List contents of filesystem tree"
|
||||
//usage: "\n -e Extract control files to [argument] directory"
|
||||
//usage: "\n -f Display control field name starting with [argument]"
|
||||
//usage: "\n -x Extract packages filesystem tree to directory"
|
||||
//usage: "\n -X Verbose extract"
|
||||
//usage:
|
||||
//usage:#define dpkg_deb_example_usage
|
||||
//usage: "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
|
||||
@@ -39,17 +49,18 @@
|
||||
#define DPKG_DEB_OPT_CONTENTS 1
|
||||
#define DPKG_DEB_OPT_CONTROL 2
|
||||
#define DPKG_DEB_OPT_FIELD 4
|
||||
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 8
|
||||
#define DPKG_DEB_OPT_EXTRACT 16
|
||||
#define DPKG_DEB_OPT_EXTRACT 8
|
||||
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
|
||||
|
||||
int dpkg_deb_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dpkg_deb_main(int argc UNUSED_PARAM, char **argv)
|
||||
int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *ar_archive;
|
||||
archive_handle_t *tar_archive;
|
||||
llist_t *control_tar_llist = NULL;
|
||||
unsigned opt;
|
||||
const char *extract_dir;
|
||||
int need_args;
|
||||
|
||||
/* Setup the tar archive handle */
|
||||
tar_archive = init_handle();
|
||||
@@ -59,8 +70,6 @@ int dpkg_deb_main(int argc UNUSED_PARAM, char **argv)
|
||||
ar_archive->dpkg__sub_archive = tar_archive;
|
||||
ar_archive->filter = filter_accept_list_reassign;
|
||||
|
||||
llist_add_to(&ar_archive->accept, (char*)"data.tar");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar");
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
llist_add_to(&ar_archive->accept, (char*)"data.tar.gz");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
|
||||
@@ -73,51 +82,54 @@ int dpkg_deb_main(int argc UNUSED_PARAM, char **argv)
|
||||
llist_add_to(&ar_archive->accept, (char*)"data.tar.lzma");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.lzma");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_XZ
|
||||
llist_add_to(&ar_archive->accept, (char*)"data.tar.xz");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.xz");
|
||||
#endif
|
||||
|
||||
/* Must have 1 or 2 args */
|
||||
opt = getopt32(argv, "^" "cefXx"
|
||||
"\0" "-1:?2:c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"
|
||||
);
|
||||
opt_complementary = "c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
|
||||
opt = getopt32(argv, "cefXx");
|
||||
argv += optind;
|
||||
//argc -= optind;
|
||||
argc -= optind;
|
||||
|
||||
extract_dir = argv[1];
|
||||
if (opt & DPKG_DEB_OPT_CONTENTS) { // -c
|
||||
if (opt & DPKG_DEB_OPT_CONTENTS) {
|
||||
tar_archive->action_header = header_verbose_list;
|
||||
if (extract_dir)
|
||||
bb_show_usage();
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_FIELD) { // -f
|
||||
/* Print the entire control file */
|
||||
//TODO: standard tool accepts an optional list of fields to print
|
||||
extract_dir = NULL;
|
||||
need_args = 1;
|
||||
if (opt & DPKG_DEB_OPT_CONTROL) {
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->action_data = data_extract_all;
|
||||
if (1 == argc) {
|
||||
extract_dir = "./DEBIAN";
|
||||
} else {
|
||||
need_args++;
|
||||
}
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_FIELD) {
|
||||
/* Print the entire control file
|
||||
* it should accept a second argument which specifies a
|
||||
* specific field to print */
|
||||
ar_archive->accept = control_tar_llist;
|
||||
llist_add_to(&(tar_archive->accept), (char*)"./control");
|
||||
tar_archive->filter = filter_accept_list;
|
||||
tar_archive->action_data = data_extract_to_stdout;
|
||||
if (extract_dir)
|
||||
bb_show_usage();
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_CONTROL) { // -e
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->action_data = data_extract_all;
|
||||
if (!extract_dir)
|
||||
extract_dir = "./DEBIAN";
|
||||
if (opt & DPKG_DEB_OPT_EXTRACT) {
|
||||
tar_archive->action_header = header_list;
|
||||
}
|
||||
if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) { // -Xx
|
||||
if (opt & DPKG_DEB_OPT_EXTRACT_VERBOSE)
|
||||
tar_archive->action_header = header_list;
|
||||
if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) {
|
||||
tar_archive->action_data = data_extract_all;
|
||||
if (!extract_dir)
|
||||
bb_show_usage();
|
||||
need_args = 2;
|
||||
}
|
||||
|
||||
/* Standard tool supports "-" */
|
||||
tar_archive->src_fd = ar_archive->src_fd = xopen_stdin(argv[0]);
|
||||
if (need_args != argc) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[0], O_RDONLY);
|
||||
|
||||
/* Work out where to extract the files */
|
||||
/* 2nd argument is a dir name */
|
||||
if (argv[1]) {
|
||||
extract_dir = argv[1];
|
||||
}
|
||||
if (extract_dir) {
|
||||
mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */
|
||||
xchdir(extract_dir);
|
||||
|
||||
+44
-142
@@ -36,67 +36,43 @@ a: 85.1% -- replaced with a.gz
|
||||
gzip: bogus: No such file or directory
|
||||
aa: 85.1% -- replaced with aa.gz
|
||||
*/
|
||||
|
||||
//config:config GZIP
|
||||
//config: bool "gzip (19 kb)"
|
||||
//config: bool "gzip"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: gzip is used to compress files.
|
||||
//config: It's probably the most widely used UNIX compression program.
|
||||
//config: gzip is used to compress files.
|
||||
//config: It's probably the most widely used UNIX compression program.
|
||||
//config:
|
||||
//config:config FEATURE_GZIP_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on GZIP && LONG_OPTS
|
||||
//config: help
|
||||
//config: Enable use of long options, increases size by about 106 Bytes
|
||||
//config:
|
||||
//config:config GZIP_FAST
|
||||
//config: int "Trade memory for speed (0:small,slow - 2:fast,big)"
|
||||
//config: int "Trade memory for gzip speed (0:small,slow - 2:fast,big)"
|
||||
//config: default 0
|
||||
//config: range 0 2
|
||||
//config: depends on GZIP
|
||||
//config: help
|
||||
//config: Enable big memory options for gzip.
|
||||
//config: 0: small buffers, small hash-tables
|
||||
//config: 1: larger buffers, larger hash-tables
|
||||
//config: 2: larger buffers, largest hash-tables
|
||||
//config: Larger models may give slightly better compression
|
||||
//config:
|
||||
//config:config FEATURE_GZIP_LEVELS
|
||||
//config: bool "Enable compression levels"
|
||||
//config: default n
|
||||
//config: depends on GZIP
|
||||
//config: help
|
||||
//config: Enable support for compression levels 4-9. The default level
|
||||
//config: is 6. If levels 1-3 are specified, 4 is used.
|
||||
//config: If this option is not selected, -N options are ignored and -9
|
||||
//config: is used.
|
||||
//config:
|
||||
//config:config FEATURE_GZIP_DECOMPRESS
|
||||
//config: bool "Enable decompression"
|
||||
//config: default y
|
||||
//config: depends on GZIP || GUNZIP || ZCAT
|
||||
//config: help
|
||||
//config: Enable -d (--decompress) and -t (--test) options for gzip.
|
||||
//config: This will be automatically selected if gunzip or zcat is
|
||||
//config: enabled.
|
||||
//config: Enable big memory options for gzip.
|
||||
//config: 0: small buffers, small hash-tables
|
||||
//config: 1: larger buffers, larger hash-tables
|
||||
//config: 2: larger buffers, largest hash-tables
|
||||
//config: Larger models may give slightly better compression
|
||||
|
||||
//applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_GZIP) += gzip.o
|
||||
|
||||
//usage:#define gzip_trivial_usage
|
||||
//usage: "[-cfk" IF_FEATURE_GZIP_DECOMPRESS("dt") IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..."
|
||||
//usage: "[-cfd] [FILE]..."
|
||||
//usage:#define gzip_full_usage "\n\n"
|
||||
//usage: "Compress FILEs (or stdin)\n"
|
||||
//usage: IF_FEATURE_GZIP_LEVELS(
|
||||
//usage: "\n -1..9 Compression level"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_GZIP_DECOMPRESS(
|
||||
//usage: "\n -d Decompress"
|
||||
//usage: "\n -t Test file integrity"
|
||||
//usage: )
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
//usage:
|
||||
//usage:#define gzip_example_usage
|
||||
//usage: "$ ls -la /tmp/busybox*\n"
|
||||
@@ -276,8 +252,6 @@ enum {
|
||||
* input file length plus MIN_LOOKAHEAD.
|
||||
*/
|
||||
|
||||
#if !ENABLE_FEATURE_GZIP_LEVELS
|
||||
|
||||
max_chain_length = 4096,
|
||||
/* To speed up deflation, hash chains are never searched beyond this length.
|
||||
* A higher limit improves compression ratio but degrades the speed.
|
||||
@@ -309,23 +283,11 @@ enum {
|
||||
* For deflate_fast() (levels <= 3) good is ignored and lazy has a different
|
||||
* meaning.
|
||||
*/
|
||||
#endif /* ENABLE_FEATURE_GZIP_LEVELS */
|
||||
};
|
||||
|
||||
|
||||
struct globals {
|
||||
|
||||
#if ENABLE_FEATURE_GZIP_LEVELS
|
||||
unsigned max_chain_length;
|
||||
unsigned max_lazy_match;
|
||||
unsigned good_match;
|
||||
unsigned nice_match;
|
||||
#define max_chain_length (G1.max_chain_length)
|
||||
#define max_lazy_match (G1.max_lazy_match)
|
||||
#define good_match (G1.good_match)
|
||||
#define nice_match (G1.nice_match)
|
||||
#endif
|
||||
|
||||
lng block_start;
|
||||
|
||||
/* window position at the beginning of the current output block. Gets
|
||||
@@ -455,46 +417,19 @@ static void flush_outbuf(void)
|
||||
#define put_8bit(c) \
|
||||
do { \
|
||||
G1.outbuf[G1.outcnt++] = (c); \
|
||||
if (G1.outcnt == OUTBUFSIZ) \
|
||||
flush_outbuf(); \
|
||||
if (G1.outcnt == OUTBUFSIZ) flush_outbuf(); \
|
||||
} while (0)
|
||||
|
||||
/* Output a 16 bit value, lsb first */
|
||||
static void put_16bit(ush w)
|
||||
{
|
||||
/* GCC 4.2.1 won't optimize out redundant loads of G1.outcnt
|
||||
* (probably because of fear of aliasing with G1.outbuf[]
|
||||
* stores), do it explicitly:
|
||||
*/
|
||||
unsigned outcnt = G1.outcnt;
|
||||
uch *dst = &G1.outbuf[outcnt];
|
||||
|
||||
#if BB_UNALIGNED_MEMACCESS_OK && BB_LITTLE_ENDIAN
|
||||
if (outcnt < OUTBUFSIZ-2) {
|
||||
/* Common case */
|
||||
ush *dst16 = (void*) dst;
|
||||
*dst16 = w; /* unalinged LSB 16-bit store */
|
||||
G1.outcnt = outcnt + 2;
|
||||
return;
|
||||
if (G1.outcnt < OUTBUFSIZ - 2) {
|
||||
G1.outbuf[G1.outcnt++] = w;
|
||||
G1.outbuf[G1.outcnt++] = w >> 8;
|
||||
} else {
|
||||
put_8bit(w);
|
||||
put_8bit(w >> 8);
|
||||
}
|
||||
*dst = (uch)w;
|
||||
w >>= 8;
|
||||
#else
|
||||
*dst = (uch)w;
|
||||
w >>= 8;
|
||||
if (outcnt < OUTBUFSIZ-2) {
|
||||
/* Common case */
|
||||
dst[1] = w;
|
||||
G1.outcnt = outcnt + 2;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Slowpath: we will need to do flush_outbuf() */
|
||||
G1.outcnt = ++outcnt;
|
||||
if (outcnt == OUTBUFSIZ)
|
||||
flush_outbuf();
|
||||
put_8bit(w);
|
||||
}
|
||||
|
||||
static void put_32bit(ulg n)
|
||||
@@ -1383,6 +1318,7 @@ static void build_tree(tree_desc * desc)
|
||||
/* and insert the new node in the heap */
|
||||
G2.heap[SMALLEST] = node++;
|
||||
pqdownheap(tree, SMALLEST);
|
||||
|
||||
} while (G2.heap_len >= 2);
|
||||
|
||||
G2.heap[--G2.heap_max] = G2.heap[SMALLEST];
|
||||
@@ -1730,6 +1666,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
|
||||
|
||||
copy_block(buf, (unsigned) stored_len, 0); /* without header */
|
||||
G2.compressed_len = stored_len << 3;
|
||||
|
||||
} else if (stored_len + 4 <= opt_lenb && buf != NULL) {
|
||||
/* 4: two words for the lengths */
|
||||
/* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
|
||||
@@ -1743,6 +1680,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
|
||||
G2.compressed_len += (stored_len + 4) << 3;
|
||||
|
||||
copy_block(buf, (unsigned) stored_len, 1); /* with header */
|
||||
|
||||
} else if (static_lenb == opt_lenb) {
|
||||
send_bits((STATIC_TREES << 1) + eof, 3);
|
||||
compress_block((ct_data *) G2.static_ltree, (ct_data *) G2.static_dtree);
|
||||
@@ -2069,7 +2007,7 @@ static void ct_init(void)
|
||||
* IN assertions: the input and output buffers are cleared.
|
||||
*/
|
||||
|
||||
static void zip(void)
|
||||
static void zip(ulg time_stamp)
|
||||
{
|
||||
ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */
|
||||
|
||||
@@ -2080,7 +2018,7 @@ static void zip(void)
|
||||
/* compression method: 8 (DEFLATED) */
|
||||
/* general flags: 0 */
|
||||
put_32bit(0x00088b1f);
|
||||
put_32bit(0); /* Unix timestamp */
|
||||
put_32bit(time_stamp);
|
||||
|
||||
/* Write deflated file to zip file */
|
||||
G1.crc = ~0;
|
||||
@@ -2104,8 +2042,10 @@ static void zip(void)
|
||||
|
||||
/* ======================================================================== */
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC pack_gzip(transformer_state_t *xstate UNUSED_PARAM)
|
||||
IF_DESKTOP(long long) int FAST_FUNC pack_gzip(transformer_aux_data_t *aux UNUSED_PARAM)
|
||||
{
|
||||
struct stat s;
|
||||
|
||||
/* Clear input and output buffers */
|
||||
G1.outcnt = 0;
|
||||
#ifdef DEBUG
|
||||
@@ -2137,23 +2077,9 @@ IF_DESKTOP(long long) int FAST_FUNC pack_gzip(transformer_state_t *xstate UNUSED
|
||||
G2.bl_desc.max_length = MAX_BL_BITS;
|
||||
//G2.bl_desc.max_code = 0;
|
||||
|
||||
#if 0
|
||||
/* Saving of timestamp is disabled. Why?
|
||||
* - it is not Y2038-safe.
|
||||
* - some people want deterministic results
|
||||
* (normally they'd use -n, but our -n is a nop).
|
||||
* - it's bloat.
|
||||
* Per RFC 1952, gzfile.time=0 is "no timestamp".
|
||||
* If users will demand this to be reinstated,
|
||||
* implement -n "don't save timestamp".
|
||||
*/
|
||||
struct stat s;
|
||||
s.st_ctime = 0;
|
||||
fstat(STDIN_FILENO, &s);
|
||||
zip(s.st_ctime);
|
||||
#else
|
||||
zip();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2163,7 +2089,7 @@ static const char gzip_longopts[] ALIGN1 =
|
||||
"to-stdout\0" No_argument "c"
|
||||
"force\0" No_argument "f"
|
||||
"verbose\0" No_argument "v"
|
||||
#if ENABLE_FEATURE_GZIP_DECOMPRESS
|
||||
#if ENABLE_GUNZIP
|
||||
"decompress\0" No_argument "d"
|
||||
"uncompress\0" No_argument "d"
|
||||
"test\0" No_argument "t"
|
||||
@@ -2171,7 +2097,6 @@ static const char gzip_longopts[] ALIGN1 =
|
||||
"quiet\0" No_argument "q"
|
||||
"fast\0" No_argument "1"
|
||||
"best\0" No_argument "9"
|
||||
"no-name\0" No_argument "n"
|
||||
;
|
||||
#endif
|
||||
|
||||
@@ -2190,54 +2115,32 @@ static const char gzip_longopts[] ALIGN1 =
|
||||
*/
|
||||
|
||||
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
#if ENABLE_FEATURE_GZIP_DECOMPRESS
|
||||
#if ENABLE_GUNZIP
|
||||
int gzip_main(int argc, char **argv)
|
||||
#else
|
||||
int gzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
{
|
||||
unsigned opt;
|
||||
#if ENABLE_FEATURE_GZIP_LEVELS
|
||||
static const struct {
|
||||
uint8_t good;
|
||||
uint8_t chain_shift;
|
||||
uint8_t lazy2;
|
||||
uint8_t nice2;
|
||||
} gzip_level_config[6] = {
|
||||
{4, 4, 4/2, 16/2}, /* Level 4 */
|
||||
{8, 5, 16/2, 32/2}, /* Level 5 */
|
||||
{8, 7, 16/2, 128/2}, /* Level 6 */
|
||||
{8, 8, 32/2, 128/2}, /* Level 7 */
|
||||
{32, 10, 128/2, 258/2}, /* Level 8 */
|
||||
{32, 12, 258/2, 258/2}, /* Level 9 */
|
||||
};
|
||||
|
||||
#if ENABLE_FEATURE_GZIP_LONG_OPTIONS
|
||||
applet_long_options = gzip_longopts;
|
||||
#endif
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
opt = getopt32(argv, "cfv" IF_GUNZIP("dt") "q123456789n");
|
||||
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
|
||||
if (opt & 0x18) // -d and/or -t
|
||||
return gunzip_main(argc, argv);
|
||||
#endif
|
||||
option_mask32 &= 0x7; /* ignore -q, -0..9 */
|
||||
//if (opt & 0x1) // -c
|
||||
//if (opt & 0x2) // -f
|
||||
//if (opt & 0x4) // -v
|
||||
argv += optind;
|
||||
|
||||
SET_PTR_TO_GLOBALS((char *)xzalloc(sizeof(struct globals)+sizeof(struct globals2))
|
||||
+ sizeof(struct globals));
|
||||
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
#if ENABLE_FEATURE_GZIP_LONG_OPTIONS
|
||||
opt = getopt32long(argv, "cfkv" IF_FEATURE_GZIP_DECOMPRESS("dt") "qn123456789", gzip_longopts);
|
||||
#else
|
||||
opt = getopt32(argv, "cfkv" IF_FEATURE_GZIP_DECOMPRESS("dt") "qn123456789");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_GZIP_DECOMPRESS /* gunzip_main may not be visible... */
|
||||
if (opt & 0x30) // -d and/or -t
|
||||
return gunzip_main(argc, argv);
|
||||
#endif
|
||||
#if ENABLE_FEATURE_GZIP_LEVELS
|
||||
opt >>= ENABLE_FEATURE_GZIP_DECOMPRESS ? 8 : 6; /* drop cfkv[dt]qn bits */
|
||||
if (opt == 0)
|
||||
opt = 1 << 6; /* default: 6 */
|
||||
opt = ffs(opt >> 4); /* Maps -1..-4 to [0], -5 to [1] ... -9 to [5] */
|
||||
max_chain_length = 1 << gzip_level_config[opt].chain_shift;
|
||||
good_match = gzip_level_config[opt].good;
|
||||
max_lazy_match = gzip_level_config[opt].lazy2 * 2;
|
||||
nice_match = gzip_level_config[opt].nice2 * 2;
|
||||
#endif
|
||||
option_mask32 &= 0xf; /* retain only -cfkv */
|
||||
|
||||
/* Allocate all global buffers (for DYN_ALLOC option) */
|
||||
ALLOC(uch, G1.l_buf, INBUFSIZ);
|
||||
ALLOC(uch, G1.outbuf, OUTBUFSIZ);
|
||||
@@ -2248,6 +2151,5 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* Initialize the CRC32 table */
|
||||
global_crc32_table = crc32_filltable(NULL, 0);
|
||||
|
||||
argv += optind;
|
||||
return bbunpack(argv, pack_gzip, append_ext, "gz");
|
||||
}
|
||||
@@ -4,15 +4,13 @@
|
||||
#
|
||||
# Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
|
||||
lib-y:= common.o
|
||||
lib-y:=
|
||||
|
||||
COMMON_FILES:= \
|
||||
\
|
||||
data_skip.o \
|
||||
data_extract_all.o \
|
||||
data_extract_to_stdout.o \
|
||||
\
|
||||
unsafe_symlink_target.o \
|
||||
\
|
||||
filter_accept_all.o \
|
||||
filter_accept_list.o \
|
||||
@@ -32,13 +30,11 @@ COMMON_FILES:= \
|
||||
DPKG_FILES:= \
|
||||
unpack_ar_archive.o \
|
||||
filter_accept_list_reassign.o \
|
||||
unsafe_prefix.o \
|
||||
get_header_ar.o \
|
||||
get_header_tar.o \
|
||||
get_header_tar_gz.o \
|
||||
get_header_tar_bz2.o \
|
||||
get_header_tar_lzma.o \
|
||||
get_header_tar_xz.o \
|
||||
|
||||
INSERT
|
||||
|
||||
@@ -47,29 +43,19 @@ lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
|
||||
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
lib-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
lib-$(CONFIG_TAR) += get_header_tar.o unsafe_prefix.o
|
||||
lib-$(CONFIG_TAR) += get_header_tar.o
|
||||
lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o
|
||||
lib-$(CONFIG_LZOP) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o
|
||||
lib-$(CONFIG_UNLZOP) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o
|
||||
lib-$(CONFIG_LZOPCAT) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o
|
||||
lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.o
|
||||
# 'bzip2 -d', bunzip2 or bzcat selects FEATURE_BZIP2_DECOMPRESS
|
||||
lib-$(CONFIG_FEATURE_BZIP2_DECOMPRESS) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_UNZIP_BZIP2) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_BUNZIP2) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_UNLZMA) += open_transformer.o decompress_unlzma.o
|
||||
lib-$(CONFIG_LZCAT) += open_transformer.o decompress_unlzma.o
|
||||
lib-$(CONFIG_LZMA) += open_transformer.o decompress_unlzma.o
|
||||
lib-$(CONFIG_FEATURE_UNZIP_LZMA) += open_transformer.o decompress_unlzma.o
|
||||
lib-$(CONFIG_UNXZ) += open_transformer.o decompress_unxz.o
|
||||
lib-$(CONFIG_XZCAT) += open_transformer.o decompress_unxz.o
|
||||
lib-$(CONFIG_XZ) += open_transformer.o decompress_unxz.o
|
||||
lib-$(CONFIG_FEATURE_UNZIP_XZ) += open_transformer.o decompress_unxz.o
|
||||
# 'gzip -d', gunzip or zcat selects FEATURE_GZIP_DECOMPRESS
|
||||
lib-$(CONFIG_FEATURE_GZIP_DECOMPRESS) += open_transformer.o decompress_gunzip.o
|
||||
lib-$(CONFIG_GUNZIP) += open_transformer.o decompress_gunzip.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += open_transformer.o decompress_uncompress.o
|
||||
lib-$(CONFIG_UNZIP) += open_transformer.o decompress_gunzip.o unsafe_prefix.o
|
||||
lib-$(CONFIG_UNZIP) += open_transformer.o decompress_gunzip.o
|
||||
lib-$(CONFIG_RPM2CPIO) += open_transformer.o decompress_gunzip.o get_header_cpio.o
|
||||
lib-$(CONFIG_RPM) += open_transformer.o decompress_gunzip.o get_header_cpio.o
|
||||
|
||||
lib-$(CONFIG_GZIP) += open_transformer.o
|
||||
lib-$(CONFIG_BZIP2) += open_transformer.o
|
||||
lib-$(CONFIG_LZOP) += open_transformer.o
|
||||
|
||||
@@ -385,6 +385,7 @@ void sendMTFValues(EState* s)
|
||||
cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
|
||||
cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
|
||||
cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
|
||||
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
const char cpio_TRAILER[] ALIGN1 = "TRAILER!!!";
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -10,12 +11,6 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
int dst_fd;
|
||||
int res;
|
||||
char *hard_link;
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
char *dst_name;
|
||||
#else
|
||||
# define dst_name (file_header->name)
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_TAR_SELINUX
|
||||
char *sctx = archive_handle->tar__sctx[PAX_NEXT_FILE];
|
||||
@@ -28,49 +23,11 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Hard links are encoded as regular files of size 0
|
||||
* with a nonempty link field */
|
||||
hard_link = NULL;
|
||||
if (S_ISREG(file_header->mode) && file_header->size == 0)
|
||||
hard_link = file_header->link_target;
|
||||
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
dst_name = file_header->name;
|
||||
if (archive_handle->tar__strip_components) {
|
||||
unsigned n = archive_handle->tar__strip_components;
|
||||
do {
|
||||
dst_name = strchr(dst_name, '/');
|
||||
if (!dst_name || dst_name[1] == '\0') {
|
||||
data_skip(archive_handle);
|
||||
goto ret;
|
||||
}
|
||||
dst_name++;
|
||||
/*
|
||||
* Link target is shortened only for hardlinks:
|
||||
* softlinks restored unchanged.
|
||||
*/
|
||||
if (hard_link) {
|
||||
// GNU tar 1.26 does not check that we reached end of link name:
|
||||
// if "dir/hardlink" is hardlinked to "file",
|
||||
// tar xvf a.tar --strip-components=1 says:
|
||||
// tar: hardlink: Cannot hard link to '': No such file or directory
|
||||
// and continues processing. We silently skip such entries.
|
||||
hard_link = strchr(hard_link, '/');
|
||||
if (!hard_link || hard_link[1] == '\0') {
|
||||
data_skip(archive_handle);
|
||||
goto ret;
|
||||
}
|
||||
hard_link++;
|
||||
}
|
||||
} while (--n != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (archive_handle->ah_flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
char *slash = strrchr(dst_name, '/');
|
||||
char *slash = strrchr(file_header->name, '/');
|
||||
if (slash) {
|
||||
*slash = '\0';
|
||||
bb_make_directory(dst_name, -1, FILEUTILS_RECUR);
|
||||
bb_make_directory(file_header->name, -1, FILEUTILS_RECUR);
|
||||
*slash = '/';
|
||||
}
|
||||
}
|
||||
@@ -78,7 +35,12 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
if (archive_handle->ah_flags & ARCHIVE_UNLINK_OLD) {
|
||||
/* Remove the entry if it exists */
|
||||
if (!S_ISDIR(file_header->mode)) {
|
||||
if (hard_link) {
|
||||
/* Is it hardlink?
|
||||
* We encode hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode)
|
||||
&& file_header->link_target
|
||||
&& file_header->size == 0
|
||||
) {
|
||||
/* Ugly special case:
|
||||
* tar cf t.tar hardlink1 hardlink2 hardlink1
|
||||
* results in this tarball structure:
|
||||
@@ -86,48 +48,55 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
* hardlink2 -> hardlink1
|
||||
* hardlink1 -> hardlink1 <== !!!
|
||||
*/
|
||||
if (strcmp(hard_link, dst_name) == 0)
|
||||
if (strcmp(file_header->link_target, file_header->name) == 0)
|
||||
goto ret;
|
||||
}
|
||||
/* Proceed with deleting */
|
||||
if (unlink(dst_name) == -1
|
||||
if (unlink(file_header->name) == -1
|
||||
&& errno != ENOENT
|
||||
) {
|
||||
bb_perror_msg_and_die("can't remove old file %s",
|
||||
dst_name);
|
||||
file_header->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (archive_handle->ah_flags & ARCHIVE_EXTRACT_NEWER) {
|
||||
/* Remove the existing entry if its older than the extracted entry */
|
||||
struct stat existing_sb;
|
||||
if (lstat(dst_name, &existing_sb) == -1) {
|
||||
if (lstat(file_header->name, &existing_sb) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("can't stat old file");
|
||||
}
|
||||
}
|
||||
else if (existing_sb.st_mtime >= file_header->mtime) {
|
||||
if (!S_ISDIR(file_header->mode)) {
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
&& !S_ISDIR(file_header->mode)
|
||||
) {
|
||||
bb_error_msg("%s not created: newer or "
|
||||
"same age file exists", dst_name);
|
||||
"same age file exists", file_header->name);
|
||||
}
|
||||
data_skip(archive_handle);
|
||||
goto ret;
|
||||
}
|
||||
else if ((unlink(dst_name) == -1) && (errno != EISDIR)) {
|
||||
else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) {
|
||||
bb_perror_msg_and_die("can't remove old file %s",
|
||||
dst_name);
|
||||
file_header->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle hard links separately */
|
||||
if (hard_link) {
|
||||
res = link(hard_link, dst_name);
|
||||
if (res != 0) {
|
||||
/* shared message */
|
||||
bb_perror_msg("can't create %slink '%s' to '%s'",
|
||||
"hard", dst_name, hard_link
|
||||
);
|
||||
/* Handle hard links separately
|
||||
* We encode hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode)
|
||||
&& file_header->link_target
|
||||
&& file_header->size == 0
|
||||
) {
|
||||
/* hard link */
|
||||
res = link(file_header->link_target, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("can't create %slink "
|
||||
"from %s to %s", "hard",
|
||||
file_header->name,
|
||||
file_header->link_target);
|
||||
}
|
||||
/* Hardlinks have no separate mode/ownership, skip chown/chmod */
|
||||
goto ret;
|
||||
@@ -137,17 +106,17 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
switch (file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
/* Regular file */
|
||||
char *dst_nameN;
|
||||
char *dst_name;
|
||||
int flags = O_WRONLY | O_CREAT | O_EXCL;
|
||||
if (archive_handle->ah_flags & ARCHIVE_O_TRUNC)
|
||||
flags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||
dst_nameN = dst_name;
|
||||
dst_name = file_header->name;
|
||||
#ifdef ARCHIVE_REPLACE_VIA_RENAME
|
||||
if (archive_handle->ah_flags & ARCHIVE_REPLACE_VIA_RENAME)
|
||||
/* rpm-style temp file name */
|
||||
dst_nameN = xasprintf("%s;%x", dst_name, (int)getpid());
|
||||
dst_name = xasprintf("%s;%x", dst_name, (int)getpid());
|
||||
#endif
|
||||
dst_fd = xopen3(dst_nameN,
|
||||
dst_fd = xopen3(dst_name,
|
||||
flags,
|
||||
file_header->mode
|
||||
);
|
||||
@@ -155,57 +124,44 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
close(dst_fd);
|
||||
#ifdef ARCHIVE_REPLACE_VIA_RENAME
|
||||
if (archive_handle->ah_flags & ARCHIVE_REPLACE_VIA_RENAME) {
|
||||
xrename(dst_nameN, dst_name);
|
||||
free(dst_nameN);
|
||||
xrename(dst_name, file_header->name);
|
||||
free(dst_name);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case S_IFDIR:
|
||||
res = mkdir(dst_name, file_header->mode);
|
||||
if ((res != 0)
|
||||
res = mkdir(file_header->name, file_header->mode);
|
||||
if ((res == -1)
|
||||
&& (errno != EISDIR) /* btw, Linux doesn't return this */
|
||||
&& (errno != EEXIST)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't make dir %s", dst_name);
|
||||
bb_perror_msg("can't make dir %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
//TODO: what if file_header->link_target == NULL (say, corrupted tarball?)
|
||||
|
||||
/* To avoid a directory traversal attack via symlinks,
|
||||
* do not restore symlinks with ".." components
|
||||
* or symlinks starting with "/", unless a magic
|
||||
* envvar is set.
|
||||
*
|
||||
* For example, consider a .tar created via:
|
||||
* $ tar cvf bug.tar anything.txt
|
||||
* $ ln -s /tmp symlink
|
||||
* $ tar --append -f bug.tar symlink
|
||||
* $ rm symlink
|
||||
* $ mkdir symlink
|
||||
* $ tar --append -f bug.tar symlink/evil.py
|
||||
*
|
||||
* This will result in an archive that contains:
|
||||
* $ tar --list -f bug.tar
|
||||
* anything.txt
|
||||
* symlink [-> /tmp]
|
||||
* symlink/evil.py
|
||||
*
|
||||
* Untarring bug.tar would otherwise place evil.py in '/tmp'.
|
||||
*/
|
||||
create_or_remember_symlink(&archive_handle->symlink_placeholders,
|
||||
file_header->link_target,
|
||||
dst_name);
|
||||
res = symlink(file_header->link_target, file_header->name);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't create %slink "
|
||||
"from %s to %s", "sym",
|
||||
file_header->name,
|
||||
file_header->link_target);
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
res = mknod(dst_name, file_header->mode, file_header->device);
|
||||
if (res != 0) {
|
||||
bb_perror_msg("can't create node %s", dst_name);
|
||||
res = mknod(file_header->name, file_header->mode, file_header->device);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't create node %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -230,20 +186,20 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
}
|
||||
#endif
|
||||
/* GNU tar 1.15.1 uses chown, not lchown */
|
||||
chown(dst_name, uid, gid);
|
||||
chown(file_header->name, uid, gid);
|
||||
}
|
||||
/* uclibc has no lchmod, glibc is even stranger -
|
||||
* it has lchmod which seems to do nothing!
|
||||
* so we use chmod... */
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) {
|
||||
chmod(dst_name, file_header->mode);
|
||||
chmod(file_header->name, file_header->mode);
|
||||
}
|
||||
if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) {
|
||||
struct timeval t[2];
|
||||
|
||||
t[1].tv_sec = t[0].tv_sec = file_header->mtime;
|
||||
t[1].tv_usec = t[0].tv_usec = 0;
|
||||
utimes(dst_name, t);
|
||||
utimes(file_header->name, t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -111,12 +112,13 @@ void FAST_FUNC data_extract_to_command(archive_handle_t *archive_handle)
|
||||
bb_copyfd_exact_size(archive_handle->src_fd, p[1], -file_header->size);
|
||||
close(p[1]);
|
||||
|
||||
status = wait_for_exitstatus(pid);
|
||||
if (safe_waitpid(pid, &status, 0) == -1)
|
||||
bb_perror_msg_and_die("waitpid");
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status))
|
||||
bb_error_msg_and_die("'%s' returned status %d",
|
||||
archive_handle->tar__to_command, WEXITSTATUS(status));
|
||||
if (WIFSIGNALED(status))
|
||||
bb_error_msg_and_die("'%s' terminated by signal %d",
|
||||
bb_error_msg_and_die("'%s' terminated on signal %d",
|
||||
archive_handle->tar__to_command, WTERMSIG(status));
|
||||
|
||||
if (!BB_MMU) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
|
||||
*
|
||||
* Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
|
||||
* which also acknowledges contributions by Mike Burrows, David Wheeler,
|
||||
* Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
|
||||
* Robert Sedgewick, and Jon L. Bentley.
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
|
||||
|
||||
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
|
||||
which also acknowledges contributions by Mike Burrows, David Wheeler,
|
||||
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
|
||||
Robert Sedgewick, and Jon L. Bentley.
|
||||
|
||||
Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/*
|
||||
Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org).
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
Manuel
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -133,7 +134,7 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
|
||||
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
|
||||
if (bit_count >= 24) {
|
||||
bits = bd->inbufBits & ((1U << bit_count) - 1);
|
||||
bits = bd->inbufBits & ((1 << bit_count) - 1);
|
||||
bits_wanted -= bit_count;
|
||||
bits <<= bits_wanted;
|
||||
bit_count = 0;
|
||||
@@ -156,15 +157,15 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
static int get_next_block(bunzip_data *bd)
|
||||
{
|
||||
struct group_data *hufGroup;
|
||||
int groupCount, *base, *limit, selector,
|
||||
i, j, symCount, symTotal, nSelectors, byteCount[256];
|
||||
int dbufCount, dbufSize, groupCount, *base, *limit, selector,
|
||||
i, j, t, runPos, symCount, symTotal, nSelectors, byteCount[256];
|
||||
int runCnt = runCnt; /* for compiler */
|
||||
uint8_t uc, symToByte[256], mtfSymbol[256], *selectors;
|
||||
uint32_t *dbuf;
|
||||
unsigned origPtr, t;
|
||||
unsigned dbufCount, runPos;
|
||||
unsigned runCnt = runCnt; /* for compiler */
|
||||
unsigned origPtr;
|
||||
|
||||
dbuf = bd->dbuf;
|
||||
dbufSize = bd->dbufSize;
|
||||
selectors = bd->selectors;
|
||||
|
||||
/* In bbox, we are ok with aborting through setjmp which is set up in start_bunzip */
|
||||
@@ -187,7 +188,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
it didn't actually work. */
|
||||
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
|
||||
origPtr = get_bits(bd, 24);
|
||||
if (origPtr > bd->dbufSize) return RETVAL_DATA_ERROR;
|
||||
if ((int)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
|
||||
@@ -307,7 +308,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
base = hufGroup->base - 1;
|
||||
limit = hufGroup->limit - 1;
|
||||
|
||||
/* Calculate permute[]. Concurrently, initialize temp[] and limit[]. */
|
||||
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
||||
pp = 0;
|
||||
for (i = minLen; i <= maxLen; i++) {
|
||||
int k;
|
||||
@@ -435,14 +436,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
symbols, but a run of length 0 doesn't mean anything in this
|
||||
context). Thus space is saved. */
|
||||
runCnt += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
|
||||
//The 32-bit overflow of runCnt wasn't yet seen, but probably can happen.
|
||||
//This would be the fix (catches too large count way before it can overflow):
|
||||
// if (runCnt > bd->dbufSize) {
|
||||
// dbg("runCnt:%u > dbufSize:%u RETVAL_DATA_ERROR",
|
||||
// runCnt, bd->dbufSize);
|
||||
// return RETVAL_DATA_ERROR;
|
||||
// }
|
||||
if (runPos < bd->dbufSize) runPos <<= 1;
|
||||
if (runPos < dbufSize) runPos <<= 1;
|
||||
goto end_of_huffman_loop;
|
||||
}
|
||||
|
||||
@@ -452,15 +446,14 @@ static int get_next_block(bunzip_data *bd)
|
||||
literal used is the one at the head of the mtfSymbol array.) */
|
||||
if (runPos != 0) {
|
||||
uint8_t tmp_byte;
|
||||
if (dbufCount + runCnt > bd->dbufSize) {
|
||||
dbg("dbufCount:%u+runCnt:%u %u > dbufSize:%u RETVAL_DATA_ERROR",
|
||||
dbufCount, runCnt, dbufCount + runCnt, bd->dbufSize);
|
||||
if (dbufCount + runCnt > dbufSize) {
|
||||
dbg("dbufCount:%d+runCnt:%d %d > dbufSize:%d RETVAL_DATA_ERROR",
|
||||
dbufCount, runCnt, dbufCount + runCnt, dbufSize);
|
||||
return RETVAL_DATA_ERROR;
|
||||
}
|
||||
tmp_byte = symToByte[mtfSymbol[0]];
|
||||
byteCount[tmp_byte] += runCnt;
|
||||
while ((int)--runCnt >= 0)
|
||||
dbuf[dbufCount++] = (uint32_t)tmp_byte;
|
||||
while (--runCnt >= 0) dbuf[dbufCount++] = (uint32_t)tmp_byte;
|
||||
runPos = 0;
|
||||
}
|
||||
|
||||
@@ -474,7 +467,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 >= bd->dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
i = nextSym - 1;
|
||||
uc = mtfSymbol[i];
|
||||
|
||||
@@ -738,7 +731,7 @@ void FAST_FUNC dealloc_bunzip(bunzip_data *bd)
|
||||
|
||||
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_bz2_stream(transformer_state_t *xstate)
|
||||
unpack_bz2_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
{
|
||||
IF_DESKTOP(long long total_written = 0;)
|
||||
bunzip_data *bd;
|
||||
@@ -746,14 +739,14 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
||||
int i;
|
||||
unsigned len;
|
||||
|
||||
if (check_signature16(xstate, BZIP2_MAGIC))
|
||||
if (check_signature16(aux, src_fd, BZIP2_MAGIC))
|
||||
return -1;
|
||||
|
||||
outbuf = xmalloc(IOBUF_SIZE);
|
||||
len = 0;
|
||||
while (1) { /* "Process one BZ... stream" loop */
|
||||
|
||||
i = start_bunzip(&bd, xstate->src_fd, outbuf + 2, len);
|
||||
i = start_bunzip(&bd, src_fd, outbuf + 2, len);
|
||||
|
||||
if (i == 0) {
|
||||
while (1) { /* "Produce some output bytes" loop */
|
||||
@@ -763,7 +756,8 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
||||
i = IOBUF_SIZE - i; /* number of bytes produced */
|
||||
if (i == 0) /* EOF? */
|
||||
break;
|
||||
if (i != transformer_write(xstate, outbuf, i)) {
|
||||
if (i != full_write(dst_fd, outbuf, i)) {
|
||||
bb_error_msg("short write");
|
||||
i = RETVAL_SHORT_WRITE;
|
||||
goto release_mem;
|
||||
}
|
||||
@@ -796,7 +790,7 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
||||
len = bd->inbufCount - bd->inbufPos;
|
||||
memcpy(outbuf, &bd->inbuf[bd->inbufPos], len);
|
||||
if (len < 2) {
|
||||
if (safe_read(xstate->src_fd, outbuf + len, 2 - len) != 2 - len)
|
||||
if (safe_read(src_fd, outbuf + len, 2 - len) != 2 - len)
|
||||
break;
|
||||
len = 2;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
@@ -304,11 +305,11 @@ static int huft_build(const unsigned *b, const unsigned n,
|
||||
unsigned i; /* counter, current code */
|
||||
unsigned j; /* counter */
|
||||
int k; /* number of bits in current code */
|
||||
const unsigned *p; /* pointer into c[], b[], or v[] */
|
||||
unsigned *p; /* pointer into c[], b[], or v[] */
|
||||
huft_t *q; /* points to current table */
|
||||
huft_t r; /* table entry for structure assignment */
|
||||
huft_t *u[BMAX]; /* table stack */
|
||||
unsigned v[N_MAX + 1]; /* values in order of bit length. last v[] is never used */
|
||||
unsigned v[N_MAX]; /* values in order of bit length */
|
||||
int ws[BMAX + 1]; /* bits decoded stack */
|
||||
int w; /* bits decoded */
|
||||
unsigned x[BMAX + 1]; /* bit offsets, then code stack */
|
||||
@@ -323,7 +324,7 @@ static int huft_build(const unsigned *b, const unsigned n,
|
||||
|
||||
/* Generate counts for each bit length */
|
||||
memset(c, 0, sizeof(c));
|
||||
p = b;
|
||||
p = (unsigned *) b; /* cast allows us to reuse p for pointing to b */
|
||||
i = n;
|
||||
do {
|
||||
c[*p]++; /* assume all entries <= BMAX */
|
||||
@@ -363,12 +364,8 @@ static int huft_build(const unsigned *b, const unsigned n,
|
||||
*xp++ = j;
|
||||
}
|
||||
|
||||
/* Make a table of values in order of bit lengths.
|
||||
* To detect bad input, unused v[i]'s are set to invalid value UINT_MAX.
|
||||
* In particular, last v[i] is never filled and must not be accessed.
|
||||
*/
|
||||
memset(v, 0xff, sizeof(v));
|
||||
p = b;
|
||||
/* Make a table of values in order of bit lengths */
|
||||
p = (unsigned *) b;
|
||||
i = 0;
|
||||
do {
|
||||
j = *p++;
|
||||
@@ -435,9 +432,7 @@ static int huft_build(const unsigned *b, const unsigned n,
|
||||
|
||||
/* set up table entry in r */
|
||||
r.b = (unsigned char) (k - w);
|
||||
if (/*p >= v + n || -- redundant, caught by the second check: */
|
||||
*p == UINT_MAX /* do we access uninited v[i]? (see memset(v))*/
|
||||
) {
|
||||
if (p >= v + n) {
|
||||
r.e = 99; /* out of values--invalid code */
|
||||
} else if (*p < s) {
|
||||
r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB code */
|
||||
@@ -522,9 +517,8 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY)
|
||||
e = t->e;
|
||||
if (e > 16)
|
||||
do {
|
||||
if (e == 99) {
|
||||
abort_unzip(PASS_STATE_ONLY);
|
||||
}
|
||||
if (e == 99)
|
||||
abort_unzip(PASS_STATE_ONLY);;
|
||||
bb >>= t->b;
|
||||
k -= t->b;
|
||||
e -= 16;
|
||||
@@ -560,9 +554,8 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY)
|
||||
e = t->e;
|
||||
if (e > 16)
|
||||
do {
|
||||
if (e == 99) {
|
||||
if (e == 99)
|
||||
abort_unzip(PASS_STATE_ONLY);
|
||||
}
|
||||
bb >>= t->b;
|
||||
k -= t->b;
|
||||
e -= 16;
|
||||
@@ -828,9 +821,8 @@ static int inflate_block(STATE_PARAM smallint *e)
|
||||
|
||||
b_dynamic >>= 4;
|
||||
k_dynamic -= 4;
|
||||
if (nl > 286 || nd > 30) {
|
||||
if (nl > 286 || nd > 30)
|
||||
abort_unzip(PASS_STATE_ONLY); /* bad lengths */
|
||||
}
|
||||
|
||||
/* read in bit-length-code lengths */
|
||||
for (j = 0; j < nb; j++) {
|
||||
@@ -911,14 +903,12 @@ static int inflate_block(STATE_PARAM smallint *e)
|
||||
bl = lbits;
|
||||
|
||||
i = huft_build(ll, nl, 257, cplens, cplext, &inflate_codes_tl, &bl);
|
||||
if (i != 0) {
|
||||
if (i != 0)
|
||||
abort_unzip(PASS_STATE_ONLY);
|
||||
}
|
||||
bd = dbits;
|
||||
i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &inflate_codes_td, &bd);
|
||||
if (i != 0) {
|
||||
if (i != 0)
|
||||
abort_unzip(PASS_STATE_ONLY);
|
||||
}
|
||||
|
||||
/* set up data for inflate_codes() */
|
||||
inflate_codes_setup(PASS_STATE bl, bd);
|
||||
@@ -981,7 +971,7 @@ static int inflate_get_next_window(STATE_PARAM_ONLY)
|
||||
|
||||
/* Called from unpack_gz_stream() and inflate_unzip() */
|
||||
static IF_DESKTOP(long long) int
|
||||
inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
|
||||
inflate_unzip_internal(STATE_PARAM int in, int out)
|
||||
{
|
||||
IF_DESKTOP(long long) int n = 0;
|
||||
ssize_t nwrote;
|
||||
@@ -990,7 +980,7 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
|
||||
gunzip_window = xmalloc(GUNZIP_WSIZE);
|
||||
gunzip_outbuf_count = 0;
|
||||
gunzip_bytes_out = 0;
|
||||
gunzip_src_fd = xstate->src_fd;
|
||||
gunzip_src_fd = in;
|
||||
|
||||
/* (re) initialize state */
|
||||
method = -1;
|
||||
@@ -1006,15 +996,15 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
|
||||
error_msg = "corrupted data";
|
||||
if (setjmp(error_jmp)) {
|
||||
/* Error from deep inside zip machinery */
|
||||
bb_error_msg(error_msg);
|
||||
n = -1;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int r = inflate_get_next_window(PASS_STATE_ONLY);
|
||||
nwrote = transformer_write(xstate, gunzip_window, gunzip_outbuf_count);
|
||||
if (nwrote == (ssize_t)-1) {
|
||||
nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
|
||||
if (nwrote != (ssize_t)gunzip_outbuf_count) {
|
||||
bb_perror_msg("write");
|
||||
n = -1;
|
||||
goto ret;
|
||||
}
|
||||
@@ -1044,22 +1034,22 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
|
||||
/* For unzip */
|
||||
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
inflate_unzip(transformer_state_t *xstate)
|
||||
inflate_unzip(transformer_aux_data_t *aux, int in, int out)
|
||||
{
|
||||
IF_DESKTOP(long long) int n;
|
||||
DECLARE_STATE;
|
||||
|
||||
ALLOC_STATE;
|
||||
|
||||
to_read = xstate->bytes_in;
|
||||
to_read = aux->bytes_in;
|
||||
// bytebuffer_max = 0x8000;
|
||||
bytebuffer_offset = 4;
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
n = inflate_unzip_internal(PASS_STATE xstate);
|
||||
n = inflate_unzip_internal(PASS_STATE in, out);
|
||||
free(bytebuffer);
|
||||
|
||||
xstate->crc32 = gunzip_crc;
|
||||
xstate->bytes_out = gunzip_bytes_out;
|
||||
aux->crc32 = gunzip_crc;
|
||||
aux->bytes_out = gunzip_bytes_out;
|
||||
DEALLOC_STATE;
|
||||
return n;
|
||||
}
|
||||
@@ -1117,7 +1107,7 @@ static uint32_t buffer_read_le_u32(STATE_PARAM_ONLY)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int check_header_gzip(STATE_PARAM transformer_state_t *xstate)
|
||||
static int check_header_gzip(STATE_PARAM transformer_aux_data_t *aux)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[8];
|
||||
@@ -1129,8 +1119,9 @@ static int check_header_gzip(STATE_PARAM transformer_state_t *xstate)
|
||||
uint8_t os_flags_UNUSED;
|
||||
} PACKED formatted;
|
||||
} header;
|
||||
|
||||
BUILD_BUG_ON(sizeof(header) != 8);
|
||||
struct BUG_header {
|
||||
char BUG_header[sizeof(header) == 8 ? 1 : -1];
|
||||
};
|
||||
|
||||
/*
|
||||
* Rewind bytebuffer. We use the beginning because the header has 8
|
||||
@@ -1178,7 +1169,8 @@ static int check_header_gzip(STATE_PARAM transformer_state_t *xstate)
|
||||
}
|
||||
}
|
||||
|
||||
xstate->mtime = SWAP_LE32(header.formatted.mtime);
|
||||
if (aux)
|
||||
aux->mtime = SWAP_LE32(header.formatted.mtime);
|
||||
|
||||
/* Read the header checksum */
|
||||
if (header.formatted.flags & 0x02) {
|
||||
@@ -1190,27 +1182,27 @@ static int check_header_gzip(STATE_PARAM transformer_state_t *xstate)
|
||||
}
|
||||
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_gz_stream(transformer_state_t *xstate)
|
||||
unpack_gz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
{
|
||||
uint32_t v32;
|
||||
IF_DESKTOP(long long) int total, n;
|
||||
DECLARE_STATE;
|
||||
|
||||
#if !ENABLE_FEATURE_SEAMLESS_Z
|
||||
if (check_signature16(xstate, GZIP_MAGIC))
|
||||
if (check_signature16(aux, src_fd, GZIP_MAGIC))
|
||||
return -1;
|
||||
#else
|
||||
if (!xstate->signature_skipped) {
|
||||
if (aux && aux->check_signature) {
|
||||
uint16_t magic2;
|
||||
|
||||
if (full_read(xstate->src_fd, &magic2, 2) != 2) {
|
||||
if (full_read(src_fd, &magic2, 2) != 2) {
|
||||
bad_magic:
|
||||
bb_error_msg("invalid magic");
|
||||
return -1;
|
||||
}
|
||||
if (magic2 == COMPRESS_MAGIC) {
|
||||
xstate->signature_skipped = 2;
|
||||
return unpack_Z_stream(xstate);
|
||||
aux->check_signature = 0;
|
||||
return unpack_Z_stream(aux, src_fd, dst_fd);
|
||||
}
|
||||
if (magic2 != GZIP_MAGIC)
|
||||
goto bad_magic;
|
||||
@@ -1223,16 +1215,16 @@ unpack_gz_stream(transformer_state_t *xstate)
|
||||
to_read = -1;
|
||||
// bytebuffer_max = 0x8000;
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
gunzip_src_fd = xstate->src_fd;
|
||||
gunzip_src_fd = src_fd;
|
||||
|
||||
again:
|
||||
if (!check_header_gzip(PASS_STATE xstate)) {
|
||||
if (!check_header_gzip(PASS_STATE aux)) {
|
||||
bb_error_msg("corrupted data");
|
||||
total = -1;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
n = inflate_unzip_internal(PASS_STATE xstate);
|
||||
n = inflate_unzip_internal(PASS_STATE src_fd, dst_fd);
|
||||
if (n < 0) {
|
||||
total = -1;
|
||||
goto ret;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
/* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
*
|
||||
* based on the original compress42.c source
|
||||
* (see disclaimer below)
|
||||
*/
|
||||
|
||||
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
|
||||
*
|
||||
* Authors:
|
||||
@@ -21,7 +21,9 @@
|
||||
* marc@suse.de : a small security fix for a buffer overflow
|
||||
*
|
||||
* [... History snipped ...]
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -71,7 +73,7 @@
|
||||
*/
|
||||
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_Z_stream(transformer_state_t *xstate)
|
||||
unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
{
|
||||
IF_DESKTOP(long long total_written = 0;)
|
||||
IF_DESKTOP(long long) int retval = -1;
|
||||
@@ -100,7 +102,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
||||
/* block compress mode -C compatible with 2.0 */
|
||||
int block_mode; /* = BLOCK_MODE; */
|
||||
|
||||
if (check_signature16(xstate, COMPRESS_MAGIC))
|
||||
if (check_signature16(aux, src_fd, COMPRESS_MAGIC))
|
||||
return -1;
|
||||
|
||||
inbuf = xzalloc(IBUFSIZ + 64);
|
||||
@@ -112,7 +114,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
||||
|
||||
/* xread isn't good here, we have to return - caller may want
|
||||
* to do some cleanup (e.g. delete incomplete unpacked file etc) */
|
||||
if (full_read(xstate->src_fd, inbuf, 1) != 1) {
|
||||
if (full_read(src_fd, inbuf, 1) != 1) {
|
||||
bb_error_msg("short read");
|
||||
goto err;
|
||||
}
|
||||
@@ -164,7 +166,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
||||
}
|
||||
|
||||
if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
|
||||
rsize = safe_read(xstate->src_fd, inbuf + insize, IBUFSIZ);
|
||||
rsize = safe_read(src_fd, inbuf + insize, IBUFSIZ);
|
||||
if (rsize < 0)
|
||||
bb_error_msg_and_die(bb_msg_read_error);
|
||||
insize += rsize;
|
||||
@@ -272,7 +274,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
||||
}
|
||||
|
||||
if (outpos >= OBUFSIZ) {
|
||||
xtransformer_write(xstate, outbuf, outpos);
|
||||
xwrite(dst_fd, outbuf, outpos);
|
||||
IF_DESKTOP(total_written += outpos;)
|
||||
outpos = 0;
|
||||
}
|
||||
@@ -295,10 +297,11 @@ unpack_Z_stream(transformer_state_t *xstate)
|
||||
/* Remember previous code. */
|
||||
oldcode = incode;
|
||||
}
|
||||
|
||||
} while (rsize > 0);
|
||||
|
||||
if (outpos > 0) {
|
||||
xtransformer_write(xstate, outbuf, outpos);
|
||||
xwrite(dst_fd, outbuf, outpos);
|
||||
IF_DESKTOP(total_written += outpos;)
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ enum {
|
||||
|
||||
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_lzma_stream(transformer_state_t *xstate)
|
||||
unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst_fd)
|
||||
{
|
||||
IF_DESKTOP(long long total_written = 0;)
|
||||
lzma_header_t header;
|
||||
@@ -214,6 +214,8 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
uint32_t pos_state_mask;
|
||||
uint32_t literal_pos_mask;
|
||||
uint16_t *p;
|
||||
int num_bits;
|
||||
int num_probs;
|
||||
rc_t *rc;
|
||||
int i;
|
||||
uint8_t *buffer;
|
||||
@@ -223,7 +225,7 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
int state = 0;
|
||||
uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
|
||||
|
||||
if (full_read(xstate->src_fd, &header, sizeof(header)) != sizeof(header)
|
||||
if (full_read(src_fd, &header, sizeof(header)) != sizeof(header)
|
||||
|| header.pos >= (9 * 5 * 5)
|
||||
) {
|
||||
bb_error_msg("bad lzma header");
|
||||
@@ -237,9 +239,6 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
pos_state_mask = (1 << pb) - 1;
|
||||
literal_pos_mask = (1 << lp) - 1;
|
||||
|
||||
/* Example values from linux-3.3.4.tar.lzma:
|
||||
* dict_size: 64M, dst_size: 2^64-1
|
||||
*/
|
||||
header.dict_size = SWAP_LE32(header.dict_size);
|
||||
header.dst_size = SWAP_LE64(header.dst_size);
|
||||
|
||||
@@ -248,17 +247,13 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
|
||||
buffer = xmalloc(MIN(header.dst_size, header.dict_size));
|
||||
|
||||
{
|
||||
int num_probs;
|
||||
num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
|
||||
p = xmalloc(num_probs * sizeof(*p));
|
||||
num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;
|
||||
for (i = 0; i < num_probs; i++)
|
||||
p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
|
||||
|
||||
num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
|
||||
p = xmalloc(num_probs * sizeof(*p));
|
||||
num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;
|
||||
for (i = 0; i < num_probs; i++)
|
||||
p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
|
||||
}
|
||||
|
||||
rc = rc_init(xstate->src_fd); /*, RC_BUFFER_SIZE); */
|
||||
rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */
|
||||
|
||||
while (global_pos + buffer_pos < header.dst_size) {
|
||||
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
|
||||
@@ -278,10 +273,9 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
|
||||
if (state >= LZMA_NUM_LIT_STATES) {
|
||||
int match_byte;
|
||||
uint32_t pos;
|
||||
uint32_t pos = buffer_pos - rep0;
|
||||
|
||||
pos = buffer_pos - rep0;
|
||||
if ((int32_t)pos < 0)
|
||||
while (pos >= header.dict_size)
|
||||
pos += header.dict_size;
|
||||
match_byte = buffer[pos];
|
||||
do {
|
||||
@@ -307,7 +301,7 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
if (transformer_write(xstate, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
goto bad;
|
||||
IF_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
@@ -316,7 +310,6 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
goto one_byte2;
|
||||
#endif
|
||||
} else {
|
||||
int num_bits;
|
||||
int offset;
|
||||
uint16_t *prob2;
|
||||
#define prob_len prob2
|
||||
@@ -337,11 +330,9 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
);
|
||||
if (!rc_is_bit_1(rc, prob2)) {
|
||||
#if ENABLE_FEATURE_LZMA_FAST
|
||||
uint32_t pos;
|
||||
uint32_t pos = buffer_pos - rep0;
|
||||
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
|
||||
|
||||
pos = buffer_pos - rep0;
|
||||
if ((int32_t)pos < 0)
|
||||
while (pos >= header.dict_size)
|
||||
pos += header.dict_size;
|
||||
previous_byte = buffer[pos];
|
||||
goto one_byte1;
|
||||
@@ -432,55 +423,30 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
}
|
||||
|
||||
len += LZMA_MATCH_MIN_LEN;
|
||||
/*
|
||||
* LZMA SDK has this optimized:
|
||||
* it precalculates size and copies many bytes
|
||||
* in a loop with simpler checks, a-la:
|
||||
* do
|
||||
* *(dest) = *(dest + ofs);
|
||||
* while (++dest != lim);
|
||||
* and
|
||||
* do {
|
||||
* buffer[buffer_pos++] = buffer[pos];
|
||||
* if (++pos == header.dict_size)
|
||||
* pos = 0;
|
||||
* } while (--cur_len != 0);
|
||||
* Our code is slower (more checks per byte copy):
|
||||
*/
|
||||
IF_NOT_FEATURE_LZMA_FAST(string:)
|
||||
do {
|
||||
uint32_t pos = buffer_pos - rep0;
|
||||
if ((int32_t)pos < 0) {
|
||||
while (pos >= header.dict_size)
|
||||
pos += header.dict_size;
|
||||
/* bug 10436 has an example file where this triggers: */
|
||||
if ((int32_t)pos < 0)
|
||||
goto bad;
|
||||
}
|
||||
previous_byte = buffer[pos];
|
||||
IF_NOT_FEATURE_LZMA_FAST(one_byte2:)
|
||||
buffer[buffer_pos++] = previous_byte;
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
if (transformer_write(xstate, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
goto bad;
|
||||
IF_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
len--;
|
||||
} while (len != 0 && buffer_pos < header.dst_size);
|
||||
/* FIXME: ...........^^^^^
|
||||
* shouldn't it be "global_pos + buffer_pos < header.dst_size"?
|
||||
* It probably should, but it is a "do we accidentally
|
||||
* unpack more bytes than expected?" check - which
|
||||
* never happens for well-formed compression data...
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
IF_NOT_DESKTOP(int total_written = 0; /* success */)
|
||||
IF_DESKTOP(total_written += buffer_pos;)
|
||||
if (transformer_write(xstate, buffer, buffer_pos) != (ssize_t)buffer_pos) {
|
||||
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
|
||||
bad:
|
||||
total_written = -1; /* failure */
|
||||
}
|
||||
|
||||
@@ -27,23 +27,18 @@ static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
|
||||
return ~crc32_block_endian0(~crc, buf, size, global_crc32_table);
|
||||
}
|
||||
|
||||
/* We use arch-optimized unaligned fixed-endian accessors.
|
||||
* They have been moved to libbb (proved to be useful elsewhere as well),
|
||||
* just check that we have them defined:
|
||||
*/
|
||||
#if !defined(get_unaligned_le32) \
|
||||
|| !defined(get_unaligned_be32) \
|
||||
|| !defined(put_unaligned_le32) \
|
||||
|| !defined(put_unaligned_be32)
|
||||
# error get_unaligned_le32 accessors are not defined
|
||||
#endif
|
||||
/* We use arch-optimized unaligned accessors */
|
||||
#define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); })
|
||||
#define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); })
|
||||
#define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val))
|
||||
#define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val))
|
||||
|
||||
#include "unxz/xz_dec_bcj.c"
|
||||
#include "unxz/xz_dec_lzma2.c"
|
||||
#include "unxz/xz_dec_stream.c"
|
||||
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_xz_stream(transformer_state_t *xstate)
|
||||
unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
{
|
||||
enum xz_ret xz_result;
|
||||
struct xz_buf iobuf;
|
||||
@@ -60,7 +55,7 @@ unpack_xz_stream(transformer_state_t *xstate)
|
||||
iobuf.out = membuf + BUFSIZ;
|
||||
iobuf.out_size = BUFSIZ;
|
||||
|
||||
if (!xstate || xstate->signature_skipped) {
|
||||
if (!aux || aux->check_signature == 0) {
|
||||
/* Preload XZ file signature */
|
||||
strcpy((char*)membuf, HEADER_MAGIC);
|
||||
iobuf.in_size = HEADER_MAGIC_SIZE;
|
||||
@@ -72,7 +67,7 @@ unpack_xz_stream(transformer_state_t *xstate)
|
||||
xz_result = X_OK;
|
||||
while (1) {
|
||||
if (iobuf.in_pos == iobuf.in_size) {
|
||||
int rd = safe_read(xstate->src_fd, membuf, BUFSIZ);
|
||||
int rd = safe_read(src_fd, membuf, BUFSIZ);
|
||||
if (rd < 0) {
|
||||
bb_error_msg(bb_msg_read_error);
|
||||
total = -1;
|
||||
@@ -109,7 +104,7 @@ unpack_xz_stream(transformer_state_t *xstate)
|
||||
// bb_error_msg("<in pos:%d size:%d out pos:%d size:%d r:%d",
|
||||
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, xz_result);
|
||||
if (iobuf.out_pos) {
|
||||
xtransformer_write(xstate, iobuf.out, iobuf.out_pos);
|
||||
xwrite(dst_fd, iobuf.out, iobuf.out_pos);
|
||||
IF_DESKTOP(total += iobuf.out_pos;)
|
||||
iobuf.out_pos = 0;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2002 by Glenn McGrath
|
||||
* Copyright (C) 2002 by Glenn McGrath
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -27,10 +28,6 @@ char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
name_ptr++;
|
||||
|
||||
/* Modify the subarchive handler based on the extension */
|
||||
if (strcmp(name_ptr, "tar") == 0) {
|
||||
archive_handle->dpkg__action_data_subarchive = get_header_tar;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_GZ
|
||||
&& strcmp(name_ptr, "gz") == 0
|
||||
) {
|
||||
@@ -49,12 +46,6 @@ char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
archive_handle->dpkg__action_data_subarchive = get_header_tar_lzma;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_XZ
|
||||
&& strcmp(name_ptr, "xz") == 0
|
||||
) {
|
||||
archive_handle->dpkg__action_data_subarchive = get_header_tar_xz;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright 2001 Glenn McGrath.
|
||||
/* Copyright 2001 Glenn McGrath.
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
#include "ar.h"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright 2002 Laurence Anderson
|
||||
/* Copyright 2002 Laurence Anderson
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -37,7 +37,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
|
||||
}
|
||||
archive_handle->offset += 110;
|
||||
|
||||
if (!is_prefixed_with(&cpio_header[0], "07070")
|
||||
if (strncmp(&cpio_header[0], "07070", 5) != 0
|
||||
|| (cpio_header[5] != '1' && cpio_header[5] != '2')
|
||||
) {
|
||||
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
|
||||
@@ -52,11 +52,6 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
|
||||
&major, &minor, &namesize) != 10)
|
||||
bb_error_msg_and_die("damaged cpio file");
|
||||
file_header->mode = mode;
|
||||
/* "cpio -R USER:GRP" support: */
|
||||
if (archive_handle->cpio__owner.uid != (uid_t)-1L)
|
||||
uid = archive_handle->cpio__owner.uid;
|
||||
if (archive_handle->cpio__owner.gid != (gid_t)-1L)
|
||||
gid = archive_handle->cpio__owner.gid;
|
||||
file_header->uid = uid;
|
||||
file_header->gid = gid;
|
||||
file_header->mtime = mtime;
|
||||
@@ -80,7 +75,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
|
||||
/* Update offset amount and skip padding before file contents */
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (strcmp(file_header->name, cpio_TRAILER) == 0) {
|
||||
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
|
||||
/* Always round up. ">> 9" divides by 512 */
|
||||
archive_handle->cpio__blocks = (uoff_t)(archive_handle->offset + 511) >> 9;
|
||||
goto create_hardlinks;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
/* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*
|
||||
* FIXME:
|
||||
* In privileged mode if uname and gname map to a uid and gid then use the
|
||||
@@ -11,12 +10,43 @@
|
||||
* Opengroup's ustar interchange format,
|
||||
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
typedef uint32_t aliased_uint32_t FIX_ALIASING;
|
||||
typedef off_t aliased_off_t FIX_ALIASING;
|
||||
|
||||
|
||||
const char* FAST_FUNC strip_unsafe_prefix(const char *str)
|
||||
{
|
||||
const char *cp = str;
|
||||
while (1) {
|
||||
char *cp2;
|
||||
if (*cp == '/') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (strncmp(cp, "/../"+1, 3) == 0) {
|
||||
cp += 3;
|
||||
continue;
|
||||
}
|
||||
cp2 = strstr(cp, "/../");
|
||||
if (!cp2)
|
||||
break;
|
||||
cp = cp2 + 4;
|
||||
}
|
||||
if (cp != str) {
|
||||
static smallint warned = 0;
|
||||
if (!warned) {
|
||||
warned = 1;
|
||||
bb_error_msg("removing leading '%.*s' from member names",
|
||||
(int)(cp - str), str);
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
/* NB: _DESTROYS_ str[len] character! */
|
||||
static unsigned long long getOctal(char *str, int len)
|
||||
{
|
||||
@@ -60,21 +90,13 @@ static unsigned long long getOctal(char *str, int len)
|
||||
}
|
||||
#define GET_OCTAL(a) getOctal((a), sizeof(a))
|
||||
|
||||
#define TAR_EXTD (ENABLE_FEATURE_TAR_GNU_EXTENSIONS || ENABLE_FEATURE_TAR_SELINUX)
|
||||
#if !TAR_EXTD
|
||||
#define process_pax_hdr(archive_handle, sz, global) \
|
||||
process_pax_hdr(archive_handle, sz)
|
||||
#endif
|
||||
/* "global" is 0 or 1 */
|
||||
static void process_pax_hdr(archive_handle_t *archive_handle, unsigned sz, int global)
|
||||
{
|
||||
#if !TAR_EXTD
|
||||
unsigned blk_sz = (sz + 511) & (~511);
|
||||
seek_by_read(archive_handle->src_fd, blk_sz);
|
||||
#else
|
||||
unsigned blk_sz = (sz + 511) & (~511);
|
||||
char *buf, *p;
|
||||
unsigned blk_sz;
|
||||
|
||||
blk_sz = (sz + 511) & (~511);
|
||||
p = buf = xmalloc(blk_sz + 1);
|
||||
xread(archive_handle->src_fd, buf, blk_sz);
|
||||
archive_handle->offset += blk_sz;
|
||||
@@ -93,9 +115,7 @@ static void process_pax_hdr(archive_handle_t *archive_handle, unsigned sz, int g
|
||||
*/
|
||||
p += len;
|
||||
sz -= len;
|
||||
if (
|
||||
/** (int)sz < 0 - not good enough for huge malicious VALUE of 2^32-1 */
|
||||
(int)(sz|len) < 0 /* this works */
|
||||
if ((int)sz < 0
|
||||
|| len == 0
|
||||
|| errno != EINVAL
|
||||
|| *end != ' '
|
||||
@@ -112,39 +132,30 @@ static void process_pax_hdr(archive_handle_t *archive_handle, unsigned sz, int g
|
||||
p[-1] = '\0';
|
||||
value = end + 1;
|
||||
|
||||
# if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (!global) {
|
||||
if (is_prefixed_with(value, "path=")) {
|
||||
value += sizeof("path=") - 1;
|
||||
free(archive_handle->tar__longname);
|
||||
archive_handle->tar__longname = xstrdup(value);
|
||||
continue;
|
||||
}
|
||||
if (is_prefixed_with(value, "linkpath=")) {
|
||||
value += sizeof("linkpath=") - 1;
|
||||
free(archive_handle->tar__linkname);
|
||||
archive_handle->tar__linkname = xstrdup(value);
|
||||
continue;
|
||||
}
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (!global && strncmp(value, "path=", sizeof("path=") - 1) == 0) {
|
||||
value += sizeof("path=") - 1;
|
||||
free(archive_handle->tar__longname);
|
||||
archive_handle->tar__longname = xstrdup(value);
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# if ENABLE_FEATURE_TAR_SELINUX
|
||||
#if ENABLE_FEATURE_TAR_SELINUX
|
||||
/* Scan for SELinux contexts, via "RHT.security.selinux" keyword.
|
||||
* This is what Red Hat's patched version of tar uses.
|
||||
*/
|
||||
# define SELINUX_CONTEXT_KEYWORD "RHT.security.selinux"
|
||||
if (is_prefixed_with(value, SELINUX_CONTEXT_KEYWORD"=")) {
|
||||
# define SELINUX_CONTEXT_KEYWORD "RHT.security.selinux"
|
||||
if (strncmp(value, SELINUX_CONTEXT_KEYWORD"=", sizeof(SELINUX_CONTEXT_KEYWORD"=") - 1) == 0) {
|
||||
value += sizeof(SELINUX_CONTEXT_KEYWORD"=") - 1;
|
||||
free(archive_handle->tar__sctx[global]);
|
||||
archive_handle->tar__sctx[global] = xstrdup(value);
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
free(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
@@ -152,7 +163,6 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
struct tar_header_t tar;
|
||||
char *cp;
|
||||
int tar_typeflag; /* can be "char", "int" seems give smaller code */
|
||||
int i, sum_u, sum;
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
int sum_s;
|
||||
@@ -188,13 +198,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
* the message and we don't check whether we indeed
|
||||
* saw zero block directly before this. */
|
||||
if (i == 0) {
|
||||
/* GNU tar 1.29 will be silent if tar archive ends abruptly
|
||||
* (if there are no zero blocks at all, and last read returns zero,
|
||||
* not short read 0 < len < 512). Complain only if
|
||||
* the very first read fails. Grrr.
|
||||
*/
|
||||
if (archive_handle->offset == 0)
|
||||
bb_error_msg("short read");
|
||||
bb_error_msg("short read");
|
||||
/* this merely signals end of archive, not exit(1): */
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -210,11 +214,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += i;
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.name[0] == 0 && tar.prefix[0] == 0
|
||||
/* Have seen a tar archive with pax 'x' header supplying UTF8 filename,
|
||||
* with actual file having all name fields NUL-filled. Check this: */
|
||||
&& !p_longname
|
||||
) {
|
||||
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
|
||||
if (archive_handle->tar__end) {
|
||||
/* Second consecutive empty header - end of archive.
|
||||
* Read until the end to empty the pipe from gz or bz2
|
||||
@@ -230,7 +230,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
|
||||
/* Check header has valid magic, "ustar" is for the proper tar,
|
||||
* five NULs are for the old tar format */
|
||||
if (!is_prefixed_with(tar.magic, "ustar")
|
||||
if (strncmp(tar.magic, "ustar", 5) != 0
|
||||
&& (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
|| memcmp(tar.magic, "\0\0\0\0", 5) != 0)
|
||||
) {
|
||||
@@ -241,7 +241,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
* or not first block (false positive, it's not .gz/.bz2!) */
|
||||
if (lseek(archive_handle->src_fd, -i, SEEK_CUR) != 0)
|
||||
goto err;
|
||||
if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 0) != 0)
|
||||
if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_detected:*/ 0) != 0)
|
||||
err:
|
||||
bb_error_msg_and_die("invalid tar magic");
|
||||
archive_handle->offset = 0;
|
||||
@@ -254,10 +254,10 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
* POSIX says that checksum is done on unsigned bytes, but
|
||||
* Sun and HP-UX gets it wrong... more details in
|
||||
* GNU tar source. */
|
||||
sum_u = ' ' * sizeof(tar.chksum);
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
sum_s = sum_u;
|
||||
sum_s = ' ' * sizeof(tar.chksum);
|
||||
#endif
|
||||
sum_u = ' ' * sizeof(tar.chksum);
|
||||
for (i = 0; i < 148; i++) {
|
||||
sum_u += ((unsigned char*)&tar)[i];
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
@@ -270,22 +270,27 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
sum_s += ((signed char*)&tar)[i];
|
||||
#endif
|
||||
}
|
||||
/* Most tarfiles have tar.chksum NUL or space terminated, but
|
||||
* github.com decided to be "special" and have unterminated field:
|
||||
* 0090: 30343300 30303031 33323731 30000000 |043.000132710...|
|
||||
* ^^^^^^^^|
|
||||
* Need to use GET_OCTAL. This overwrites tar.typeflag ---+
|
||||
* (the '0' char immediately after chksum in example above) with NUL.
|
||||
*/
|
||||
tar_typeflag = (uint8_t)tar.typeflag; /* save it */
|
||||
sum = GET_OCTAL(tar.chksum);
|
||||
if (sum_u != sum
|
||||
IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)
|
||||
) {
|
||||
/* This field does not need special treatment (getOctal) */
|
||||
{
|
||||
char *endp; /* gcc likes temp var for &endp */
|
||||
sum = strtoul(tar.chksum, &endp, 8);
|
||||
if ((*endp != '\0' && *endp != ' ')
|
||||
|| (sum_u != sum IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
|
||||
) {
|
||||
bb_error_msg_and_die("invalid tar header checksum");
|
||||
}
|
||||
}
|
||||
/* don't use xstrtoul, tar.chksum may have leading spaces */
|
||||
sum = strtoul(tar.chksum, NULL, 8);
|
||||
if (sum_u != sum IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)) {
|
||||
bb_error_msg_and_die("invalid tar header checksum");
|
||||
}
|
||||
|
||||
/* GET_OCTAL trashes subsequent field, therefore we call it
|
||||
/* 0 is reserved for high perf file, treat as normal file */
|
||||
if (!tar.typeflag) tar.typeflag = '0';
|
||||
parse_names = (tar.typeflag >= '0' && tar.typeflag <= '7');
|
||||
|
||||
/* getOctal trashes subsequent field, therefore we call it
|
||||
* on fields in reverse order */
|
||||
if (tar.devmajor[0]) {
|
||||
char t = tar.prefix[0];
|
||||
@@ -295,11 +300,6 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
file_header->device = makedev(major, minor);
|
||||
tar.prefix[0] = t;
|
||||
}
|
||||
|
||||
/* 0 is reserved for high perf file, treat as normal file */
|
||||
if (tar_typeflag == '\0') tar_typeflag = '0';
|
||||
parse_names = (tar_typeflag >= '0' && tar_typeflag <= '7');
|
||||
|
||||
file_header->link_target = NULL;
|
||||
if (!p_linkname && parse_names && tar.linkname[0]) {
|
||||
file_header->link_target = xstrndup(tar.linkname, sizeof(tar.linkname));
|
||||
@@ -333,7 +333,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
|
||||
/* Set bits 12-15 of the files mode */
|
||||
/* (typeflag was not trashed because chksum does not use getOctal) */
|
||||
switch (tar_typeflag) {
|
||||
switch (tar.typeflag) {
|
||||
case '1': /* hardlink */
|
||||
/* we mark hardlinks as regular files with zero size and a link name */
|
||||
file_header->mode |= S_IFREG;
|
||||
@@ -378,14 +378,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
case '6':
|
||||
file_header->mode |= S_IFIFO;
|
||||
goto size0;
|
||||
case 'g': /* pax global header */
|
||||
case 'x': { /* pax extended header */
|
||||
if ((uoff_t)file_header->size > 0xfffff) /* paranoia */
|
||||
goto skip_ext_hdr;
|
||||
process_pax_hdr(archive_handle, file_header->size, (tar_typeflag == 'g'));
|
||||
goto again_after_align;
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
/* See http://www.gnu.org/software/tar/manual/html_node/Extensions.html */
|
||||
case 'L':
|
||||
/* free: paranoia: tar with several consecutive longnames */
|
||||
free(p_longname);
|
||||
@@ -405,22 +398,23 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += file_header->size;
|
||||
/* return get_header_tar(archive_handle); */
|
||||
goto again;
|
||||
/*
|
||||
* case 'S': // Sparse file
|
||||
* Was seen in the wild. Not supported (yet?).
|
||||
* See https://www.gnu.org/software/tar/manual/html_section/tar_92.html
|
||||
* for the format. (An "Old GNU Format" was seen, not PAX formats).
|
||||
*/
|
||||
// case 'D': /* GNU dump dir */
|
||||
// case 'M': /* Continuation of multi volume archive */
|
||||
// case 'N': /* Old GNU for names > 100 characters */
|
||||
// case 'V': /* Volume header */
|
||||
case 'D': /* GNU dump dir */
|
||||
case 'M': /* Continuation of multi volume archive */
|
||||
case 'N': /* Old GNU for names > 100 characters */
|
||||
case 'S': /* Sparse file */
|
||||
case 'V': /* Volume header */
|
||||
#endif
|
||||
case 'g': /* pax global header */
|
||||
case 'x': { /* pax extended header */
|
||||
if ((uoff_t)file_header->size > 0xfffff) /* paranoia */
|
||||
goto skip_ext_hdr;
|
||||
process_pax_hdr(archive_handle, file_header->size, (tar.typeflag == 'g'));
|
||||
goto again_after_align;
|
||||
}
|
||||
skip_ext_hdr:
|
||||
{
|
||||
off_t sz;
|
||||
bb_error_msg("warning: skipping header '%c'", tar_typeflag);
|
||||
bb_error_msg("warning: skipping header '%c'", tar.typeflag);
|
||||
sz = (file_header->size + 511) & ~(off_t)511;
|
||||
archive_handle->offset += sz;
|
||||
sz >>= 9; /* sz /= 512 but w/o contortions for signed div */
|
||||
@@ -430,7 +424,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
goto again_after_align;
|
||||
}
|
||||
default:
|
||||
bb_error_msg_and_die("unknown typeflag: 0x%x", tar_typeflag);
|
||||
bb_error_msg_and_die("unknown typeflag: 0x%x", tar.typeflag);
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
@@ -446,7 +440,6 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
|
||||
/* Everything up to and including last ".." component is stripped */
|
||||
overlapping_strcpy(file_header->name, strip_unsafe_prefix(file_header->name));
|
||||
//TODO: do the same for file_header->link_target?
|
||||
|
||||
/* Strip trailing '/' in directories */
|
||||
/* Must be done after mode is set as '/' is used to check if it's a directory */
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -10,7 +11,7 @@ char FAST_FUNC get_header_tar_bz2(archive_handle_t *archive_handle)
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
fork_transformer_with_sig(archive_handle->src_fd, unpack_bz2_stream, "bunzip2");
|
||||
open_transformer_with_sig(archive_handle->src_fd, unpack_bz2_stream, "bunzip2");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -10,7 +11,7 @@ char FAST_FUNC get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
fork_transformer_with_sig(archive_handle->src_fd, unpack_gz_stream, "gunzip");
|
||||
open_transformer_with_sig(archive_handle->src_fd, unpack_gz_stream, "gunzip");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -13,7 +14,7 @@ char FAST_FUNC get_header_tar_lzma(archive_handle_t *archive_handle)
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
fork_transformer_with_sig(archive_handle->src_fd, unpack_lzma_stream, "unlzma");
|
||||
open_transformer_with_sig(archive_handle->src_fd, unpack_lzma_stream, "unlzma");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
char FAST_FUNC get_header_tar_xz(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
fork_transformer_with_sig(archive_handle->src_fd, unpack_xz_stream, "unxz");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
@@ -16,10 +17,6 @@ archive_handle_t* FAST_FUNC init_handle(void)
|
||||
archive_handle->action_data = data_skip;
|
||||
archive_handle->filter = filter_accept_all;
|
||||
archive_handle->seek = seek_by_jump;
|
||||
#if ENABLE_CPIO || ENABLE_RPM2CPIO || ENABLE_RPM
|
||||
archive_handle->cpio__owner.uid = (uid_t)-1L;
|
||||
archive_handle->cpio__owner.gid = (gid_t)-1L;
|
||||
#endif
|
||||
|
||||
return archive_handle;
|
||||
}
|
||||
@@ -71,6 +71,7 @@ typedef struct {
|
||||
uint8_t *out;
|
||||
|
||||
unsigned r1_lit;
|
||||
|
||||
} lzo1x_999_t;
|
||||
|
||||
#define getbyte(c) ((c).ip < (c).in_end ? *((c).ip)++ : (-1))
|
||||
|
||||
@@ -2,68 +2,31 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
void FAST_FUNC init_transformer_state(transformer_state_t *xstate)
|
||||
void FAST_FUNC init_transformer_aux_data(transformer_aux_data_t *aux)
|
||||
{
|
||||
memset(xstate, 0, sizeof(*xstate));
|
||||
memset(aux, 0, sizeof(*aux));
|
||||
}
|
||||
|
||||
int FAST_FUNC check_signature16(transformer_state_t *xstate, unsigned magic16)
|
||||
int FAST_FUNC check_signature16(transformer_aux_data_t *aux, int src_fd, unsigned magic16)
|
||||
{
|
||||
if (!xstate->signature_skipped) {
|
||||
if (aux && aux->check_signature) {
|
||||
uint16_t magic2;
|
||||
if (full_read(xstate->src_fd, &magic2, 2) != 2 || magic2 != magic16) {
|
||||
if (full_read(src_fd, &magic2, 2) != 2 || magic2 != magic16) {
|
||||
bb_error_msg("invalid magic");
|
||||
#if 0 /* possible future extension */
|
||||
if (aux->check_signature > 1)
|
||||
xfunc_die();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
xstate->signature_skipped = 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t FAST_FUNC transformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize)
|
||||
{
|
||||
ssize_t nwrote;
|
||||
|
||||
if (xstate->mem_output_size_max != 0) {
|
||||
size_t pos = xstate->mem_output_size;
|
||||
size_t size;
|
||||
|
||||
size = (xstate->mem_output_size += bufsize);
|
||||
if (size > xstate->mem_output_size_max) {
|
||||
free(xstate->mem_output_buf);
|
||||
xstate->mem_output_buf = NULL;
|
||||
bb_perror_msg("buffer %u too small", (unsigned)xstate->mem_output_size_max);
|
||||
nwrote = -1;
|
||||
goto ret;
|
||||
}
|
||||
xstate->mem_output_buf = xrealloc(xstate->mem_output_buf, size + 1);
|
||||
memcpy(xstate->mem_output_buf + pos, buf, bufsize);
|
||||
xstate->mem_output_buf[size] = '\0';
|
||||
nwrote = bufsize;
|
||||
} else {
|
||||
nwrote = full_write(xstate->dst_fd, buf, bufsize);
|
||||
if (nwrote != (ssize_t)bufsize) {
|
||||
bb_perror_msg("write");
|
||||
nwrote = -1;
|
||||
goto ret;
|
||||
}
|
||||
}
|
||||
ret:
|
||||
return nwrote;
|
||||
}
|
||||
|
||||
ssize_t FAST_FUNC xtransformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize)
|
||||
{
|
||||
ssize_t nwrote = transformer_write(xstate, buf, bufsize);
|
||||
if (nwrote != (ssize_t)bufsize) {
|
||||
xfunc_die();
|
||||
}
|
||||
return nwrote;
|
||||
}
|
||||
|
||||
void check_errors_in_children(int signo)
|
||||
{
|
||||
int status;
|
||||
@@ -97,12 +60,12 @@ void check_errors_in_children(int signo)
|
||||
|
||||
/* transformer(), more than meets the eye */
|
||||
#if BB_MMU
|
||||
void FAST_FUNC fork_transformer(int fd,
|
||||
int signature_skipped,
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_state_t *xstate)
|
||||
void FAST_FUNC open_transformer(int fd,
|
||||
int check_signature,
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
)
|
||||
#else
|
||||
void FAST_FUNC fork_transformer(int fd, const char *transform_prog)
|
||||
void FAST_FUNC open_transformer(int fd, const char *transform_prog)
|
||||
#endif
|
||||
{
|
||||
struct fd_pair fd_pipe;
|
||||
@@ -117,12 +80,10 @@ void FAST_FUNC fork_transformer(int fd, const char *transform_prog)
|
||||
#if BB_MMU
|
||||
{
|
||||
IF_DESKTOP(long long) int r;
|
||||
transformer_state_t xstate;
|
||||
init_transformer_state(&xstate);
|
||||
xstate.signature_skipped = signature_skipped;
|
||||
xstate.src_fd = fd;
|
||||
xstate.dst_fd = fd_pipe.wr;
|
||||
r = transformer(&xstate);
|
||||
transformer_aux_data_t aux;
|
||||
init_transformer_aux_data(&aux);
|
||||
aux.check_signature = check_signature;
|
||||
r = transformer(&aux, fd, fd_pipe.wr);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd_pipe.wr); /* send EOF */
|
||||
close(fd);
|
||||
@@ -157,18 +118,16 @@ void FAST_FUNC fork_transformer(int fd, const char *transform_prog)
|
||||
/* Used by e.g. rpm which gives us a fd without filename,
|
||||
* thus we can't guess the format from filename's extension.
|
||||
*/
|
||||
static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_compressed)
|
||||
int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
|
||||
{
|
||||
union {
|
||||
uint8_t b[4];
|
||||
uint16_t b16[2];
|
||||
uint32_t b32[1];
|
||||
} magic;
|
||||
transformer_state_t *xstate;
|
||||
|
||||
xstate = xzalloc(sizeof(*xstate));
|
||||
xstate->src_fd = fd;
|
||||
xstate->signature_skipped = 2;
|
||||
int offset = -2;
|
||||
USE_FOR_MMU(IF_DESKTOP(long long) int FAST_FUNC (*xformer)(transformer_aux_data_t *aux, int src_fd, int dst_fd);)
|
||||
USE_FOR_NOMMU(const char *xformer_prog;)
|
||||
|
||||
/* .gz and .bz2 both have 2-byte signature, and their
|
||||
* unpack_XXX_stream wants this header skipped. */
|
||||
@@ -176,193 +135,85 @@ static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_comp
|
||||
if (ENABLE_FEATURE_SEAMLESS_GZ
|
||||
&& magic.b16[0] == GZIP_MAGIC
|
||||
) {
|
||||
xstate->xformer = unpack_gz_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "gunzip";)
|
||||
goto found_magic;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_Z
|
||||
&& magic.b16[0] == COMPRESS_MAGIC
|
||||
) {
|
||||
xstate->xformer = unpack_Z_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "uncompress";)
|
||||
USE_FOR_MMU(xformer = unpack_gz_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "gunzip";)
|
||||
goto found_magic;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
&& magic.b16[0] == BZIP2_MAGIC
|
||||
) {
|
||||
xstate->xformer = unpack_bz2_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "bunzip2";)
|
||||
USE_FOR_MMU(xformer = unpack_bz2_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "bunzip2";)
|
||||
goto found_magic;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_XZ
|
||||
&& magic.b16[0] == XZ_MAGIC1
|
||||
) {
|
||||
xstate->signature_skipped = 6;
|
||||
offset = -6;
|
||||
xread(fd, magic.b32, sizeof(magic.b32[0]));
|
||||
if (magic.b32[0] == XZ_MAGIC2) {
|
||||
xstate->xformer = unpack_xz_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "unxz";)
|
||||
USE_FOR_MMU(xformer = unpack_xz_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "unxz";)
|
||||
goto found_magic;
|
||||
}
|
||||
}
|
||||
|
||||
/* No known magic seen */
|
||||
if (fail_if_not_compressed)
|
||||
if (fail_if_not_detected)
|
||||
bb_error_msg_and_die("no gzip"
|
||||
IF_FEATURE_SEAMLESS_BZ2("/bzip2")
|
||||
IF_FEATURE_SEAMLESS_XZ("/xz")
|
||||
" magic");
|
||||
|
||||
/* Some callers expect this function to "consume" fd
|
||||
* even if data is not compressed. In this case,
|
||||
* we return a state with trivial transformer.
|
||||
*/
|
||||
// USE_FOR_MMU(xstate->xformer = copy_stream;)
|
||||
// USE_FOR_NOMMU(xstate->xformer_prog = "cat";)
|
||||
xlseek(fd, offset, SEEK_CUR);
|
||||
return 1;
|
||||
|
||||
found_magic:
|
||||
return xstate;
|
||||
}
|
||||
|
||||
static void fork_transformer_and_free(transformer_state_t *xstate)
|
||||
{
|
||||
# if BB_MMU
|
||||
fork_transformer_with_no_sig(xstate->src_fd, xstate->xformer);
|
||||
open_transformer_with_no_sig(fd, xformer);
|
||||
# else
|
||||
/* NOMMU version of fork_transformer execs
|
||||
/* NOMMU version of open_transformer execs
|
||||
* an external unzipper that wants
|
||||
* file position at the start of the file.
|
||||
*/
|
||||
xlseek(xstate->src_fd, - xstate->signature_skipped, SEEK_CUR);
|
||||
xstate->signature_skipped = 0;
|
||||
fork_transformer_with_sig(xstate->src_fd, xstate->xformer, xstate->xformer_prog);
|
||||
* file position at the start of the file */
|
||||
xlseek(fd, offset, SEEK_CUR);
|
||||
open_transformer_with_sig(fd, xformer, xformer_prog);
|
||||
# endif
|
||||
free(xstate);
|
||||
}
|
||||
|
||||
/* Used by e.g. rpm which gives us a fd without filename,
|
||||
* thus we can't guess the format from filename's extension.
|
||||
*/
|
||||
int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_compressed)
|
||||
{
|
||||
transformer_state_t *xstate = setup_transformer_on_fd(fd, fail_if_not_compressed);
|
||||
|
||||
if (!xstate->xformer) {
|
||||
free(xstate);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fork_transformer_and_free(xstate);
|
||||
return 0;
|
||||
}
|
||||
#if ENABLE_FEATURE_SEAMLESS_LZMA
|
||||
/* ...and custom version for LZMA */
|
||||
void FAST_FUNC setup_lzma_on_fd(int fd)
|
||||
{
|
||||
transformer_state_t *xstate = xzalloc(sizeof(*xstate));
|
||||
xstate->src_fd = fd;
|
||||
xstate->xformer = unpack_lzma_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "unlzma";)
|
||||
fork_transformer_and_free(xstate);
|
||||
}
|
||||
#endif
|
||||
|
||||
static transformer_state_t *open_transformer(const char *fname, int fail_if_not_compressed)
|
||||
int FAST_FUNC open_zipped(const char *fname)
|
||||
{
|
||||
transformer_state_t *xstate;
|
||||
int fd;
|
||||
|
||||
fd = open(fname, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
return fd;
|
||||
|
||||
if (ENABLE_FEATURE_SEAMLESS_LZMA) {
|
||||
/* .lzma has no header/signature, can only detect it by extension */
|
||||
char *sfx = strrchr(fname, '.');
|
||||
if (sfx && strcmp(sfx+1, "lzma") == 0) {
|
||||
xstate = xzalloc(sizeof(*xstate));
|
||||
xstate->src_fd = fd;
|
||||
xstate->xformer = unpack_lzma_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "unlzma";)
|
||||
return xstate;
|
||||
open_transformer_with_sig(fd, unpack_lzma_stream, "unlzma");
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
|
||||
xstate = setup_transformer_on_fd(fd, fail_if_not_compressed);
|
||||
|
||||
return xstate;
|
||||
}
|
||||
|
||||
int FAST_FUNC open_zipped(const char *fname, int fail_if_not_compressed)
|
||||
{
|
||||
int fd;
|
||||
transformer_state_t *xstate;
|
||||
|
||||
xstate = open_transformer(fname, fail_if_not_compressed);
|
||||
if (!xstate)
|
||||
return -1;
|
||||
|
||||
fd = xstate->src_fd;
|
||||
# if BB_MMU
|
||||
if (xstate->xformer) {
|
||||
fork_transformer_with_no_sig(fd, xstate->xformer);
|
||||
} else {
|
||||
/* the file is not compressed */
|
||||
xlseek(fd, - xstate->signature_skipped, SEEK_CUR);
|
||||
xstate->signature_skipped = 0;
|
||||
if ((ENABLE_FEATURE_SEAMLESS_GZ)
|
||||
|| (ENABLE_FEATURE_SEAMLESS_BZ2)
|
||||
|| (ENABLE_FEATURE_SEAMLESS_XZ)
|
||||
) {
|
||||
setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
|
||||
}
|
||||
# else
|
||||
/* NOMMU can't avoid the seek :( */
|
||||
xlseek(fd, - xstate->signature_skipped, SEEK_CUR);
|
||||
xstate->signature_skipped = 0;
|
||||
if (xstate->xformer) {
|
||||
fork_transformer_with_sig(fd, xstate->xformer, xstate->xformer_prog);
|
||||
} /* else: the file is not compressed */
|
||||
# endif
|
||||
|
||||
free(xstate);
|
||||
return fd;
|
||||
}
|
||||
|
||||
#endif /* SEAMLESS_COMPRESSION */
|
||||
|
||||
void* FAST_FUNC xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p)
|
||||
{
|
||||
# if 1
|
||||
transformer_state_t *xstate;
|
||||
char *image;
|
||||
|
||||
xstate = open_transformer(fname, /*fail_if_not_compressed:*/ 0);
|
||||
if (!xstate) /* file open error */
|
||||
return NULL;
|
||||
|
||||
image = NULL;
|
||||
if (xstate->xformer) {
|
||||
/* In-memory decompression */
|
||||
xstate->mem_output_size_max = maxsz_p ? *maxsz_p : (size_t)(INT_MAX - 4095);
|
||||
xstate->xformer(xstate);
|
||||
if (xstate->mem_output_buf) {
|
||||
image = xstate->mem_output_buf;
|
||||
if (maxsz_p)
|
||||
*maxsz_p = xstate->mem_output_size;
|
||||
}
|
||||
} else {
|
||||
/* File is not compressed */
|
||||
//FIXME: avoid seek
|
||||
xlseek(xstate->src_fd, - xstate->signature_skipped, SEEK_CUR);
|
||||
xstate->signature_skipped = 0;
|
||||
image = xmalloc_read(xstate->src_fd, maxsz_p);
|
||||
}
|
||||
|
||||
if (!image)
|
||||
bb_perror_msg("read error from '%s'", fname);
|
||||
close(xstate->src_fd);
|
||||
free(xstate);
|
||||
return image;
|
||||
# else
|
||||
/* This version forks a subprocess - much more expensive */
|
||||
int fd;
|
||||
char *image;
|
||||
|
||||
fd = open_zipped(fname, /*fail_if_not_compressed:*/ 0);
|
||||
fd = open_zipped(fname);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
@@ -370,8 +221,6 @@ void* FAST_FUNC xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_
|
||||
if (!image)
|
||||
bb_perror_msg("read error from '%s'", fname);
|
||||
close(fd);
|
||||
return image;
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif /* SEAMLESS_COMPRESSION */
|
||||
return image;
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
#include "ar.h"
|
||||
@@ -11,7 +12,7 @@ void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
char magic[7];
|
||||
|
||||
xread(ar_archive->src_fd, magic, AR_MAGIC_LEN);
|
||||
if (!is_prefixed_with(magic, AR_MAGIC)) {
|
||||
if (strncmp(magic, AR_MAGIC, AR_MAGIC_LEN) != 0) {
|
||||
bb_error_msg_and_die("invalid ar magic");
|
||||
}
|
||||
ar_archive->offset += AR_MAGIC_LEN;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
const char* FAST_FUNC strip_unsafe_prefix(const char *str)
|
||||
{
|
||||
const char *cp = str;
|
||||
while (1) {
|
||||
char *cp2;
|
||||
if (*cp == '/') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (is_prefixed_with(cp, "/../"+1)) {
|
||||
cp += 3;
|
||||
continue;
|
||||
}
|
||||
cp2 = strstr(cp, "/../");
|
||||
if (!cp2)
|
||||
break;
|
||||
cp = cp2 + 4;
|
||||
}
|
||||
if (cp != str) {
|
||||
static smallint warned = 0;
|
||||
if (!warned) {
|
||||
warned = 1;
|
||||
bb_error_msg("removing leading '%.*s' from member names",
|
||||
(int)(cp - str), str);
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
void FAST_FUNC create_or_remember_symlink(llist_t **symlink_placeholders,
|
||||
const char *target,
|
||||
const char *linkname)
|
||||
{
|
||||
if (target[0] == '/' || strstr(target, "..")) {
|
||||
llist_add_to(symlink_placeholders,
|
||||
xasprintf("%s%c%s", linkname, '\0', target)
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (symlink(target, linkname) != 0) {
|
||||
/* shared message */
|
||||
bb_perror_msg_and_die("can't create %slink '%s' to '%s'",
|
||||
"sym", linkname, target
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void FAST_FUNC create_symlinks_from_list(llist_t *list)
|
||||
{
|
||||
while (list) {
|
||||
char *target;
|
||||
|
||||
target = list->data + strlen(list->data) + 1;
|
||||
if (symlink(target, list->data)) {
|
||||
/* shared message */
|
||||
bb_error_msg_and_die("can't create %slink '%s' to '%s'",
|
||||
"sym",
|
||||
list->data, target
|
||||
);
|
||||
}
|
||||
list = list->link;
|
||||
}
|
||||
}
|
||||
@@ -486,11 +486,11 @@ static __always_inline void XZ_FUNC rc_normalize(struct rc_dec *rc)
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode one bit. In some versions, this function has been split in three
|
||||
* Decode one bit. In some versions, this function has been splitted in three
|
||||
* functions so that the compiler is supposed to be able to more easily avoid
|
||||
* an extra branch. In this particular version of the LZMA decoder, this
|
||||
* doesn't seem to be a good idea (tested with GCC 3.3.6, 3.4.6, and 4.3.3
|
||||
* on x86). Using a non-split version results in nicer looking code too.
|
||||
* on x86). Using a non-splitted version results in nicer looking code too.
|
||||
*
|
||||
* NOTE: This must return an int. Do not make it return a bool or the speed
|
||||
* of the code generated by GCC 3.x decreases 10-15 %. (GCC 4.3 doesn't care,
|
||||
@@ -995,8 +995,10 @@ XZ_EXTERN NOINLINE enum xz_ret XZ_FUNC xz_dec_lzma2_run(
|
||||
s->lzma2.need_props = false;
|
||||
s->lzma2.next_sequence
|
||||
= SEQ_PROPERTIES;
|
||||
|
||||
} else if (s->lzma2.need_props) {
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
} else {
|
||||
s->lzma2.next_sequence
|
||||
= SEQ_LZMA_PREPARE;
|
||||
@@ -1078,6 +1080,7 @@ XZ_EXTERN NOINLINE enum xz_ret XZ_FUNC xz_dec_lzma2_run(
|
||||
|
||||
rc_reset(&s->rc);
|
||||
s->lzma2.sequence = SEQ_CONTROL;
|
||||
|
||||
} else if (b->out_pos == b->out_size
|
||||
|| (b->in_pos == b->in_size
|
||||
&& s->temp.size
|
||||
|
||||
@@ -353,6 +353,7 @@ static enum xz_ret XZ_FUNC crc32_validate(struct xz_dec *s, struct xz_buf *b)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->pos += 8;
|
||||
|
||||
} while (s->pos < 32);
|
||||
|
||||
s->crc32 = 0;
|
||||
@@ -752,6 +753,7 @@ XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b)
|
||||
b->in_pos = in_start;
|
||||
b->out_pos = out_start;
|
||||
}
|
||||
|
||||
} else if (ret == XZ_OK && in_start == b->in_pos
|
||||
&& out_start == b->out_pos) {
|
||||
if (s->allow_buf_error)
|
||||
|
||||
+42
-73
@@ -24,73 +24,53 @@
|
||||
|
||||
"Minimalized" for busybox by Alain Knaff
|
||||
*/
|
||||
|
||||
//config:config LZOP
|
||||
//config: bool "lzop (13 kb)"
|
||||
//config: bool "lzop"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Lzop compression/decompresion.
|
||||
//config:
|
||||
//config:config UNLZOP
|
||||
//config: bool "unlzop (13 kb)"
|
||||
//config: default n # INCOMPAT: upstream lzop does not provide such tool
|
||||
//config: help
|
||||
//config: Lzop decompresion.
|
||||
//config:
|
||||
//config:config LZOPCAT
|
||||
//config: bool "lzopcat (13 kb)"
|
||||
//config: default n # INCOMPAT: upstream lzop does not provide such tool
|
||||
//config: help
|
||||
//config: Alias to "lzop -dc".
|
||||
//config: Lzop compression/decompresion.
|
||||
//config:
|
||||
//config:config LZOP_COMPR_HIGH
|
||||
//config: bool "lzop compression levels 7,8,9 (not very useful)"
|
||||
//config: default n
|
||||
//config: depends on LZOP || UNLZOP || LZOPCAT
|
||||
//config: depends on LZOP
|
||||
//config: help
|
||||
//config: High levels (7,8,9) of lzop compression. These levels
|
||||
//config: are actually slower than gzip at equivalent compression ratios
|
||||
//config: and take up 3.2K of code.
|
||||
//config: High levels (7,8,9) of lzop compression. These levels
|
||||
//config: are actually slower than gzip at equivalent compression ratios
|
||||
//config: and take up 3.2K of code.
|
||||
|
||||
//applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP))
|
||||
// APPLET_ODDNAME:name main location suid_type help
|
||||
//applet:IF_UNLZOP( APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop))
|
||||
//applet:IF_LZOPCAT(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat))
|
||||
|
||||
//applet:IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat))
|
||||
//applet:IF_LZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop))
|
||||
//kbuild:lib-$(CONFIG_LZOP) += lzop.o
|
||||
//kbuild:lib-$(CONFIG_UNLZOP) += lzop.o
|
||||
//kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o
|
||||
|
||||
//usage:#define lzop_trivial_usage
|
||||
//usage: "[-cfUvd123456789CF] [FILE]..."
|
||||
//usage: "[-cfvd123456789CF] [FILE]..."
|
||||
//usage:#define lzop_full_usage "\n\n"
|
||||
//usage: " -1..9 Compression level"
|
||||
//usage: "\n -d Decompress"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -U Delete input files"
|
||||
///////: "\n -k Keep input files" (default, so why bother documenting?)
|
||||
//usage: "\n -v Verbose"
|
||||
//usage: "\n -F Don't store or verify checksum"
|
||||
//usage: "\n -C Also write checksum of compressed block"
|
||||
//usage:
|
||||
//usage:#define lzopcat_trivial_usage
|
||||
//usage: "[-vF] [FILE]..."
|
||||
//usage: "[-vCF] [FILE]..."
|
||||
//usage:#define lzopcat_full_usage "\n\n"
|
||||
//usage: " -v Verbose"
|
||||
//usage: "\n -F Don't verify checksum"
|
||||
//usage: "\n -F Don't store or verify checksum"
|
||||
//usage:
|
||||
//usage:#define unlzop_trivial_usage
|
||||
//usage: "[-cfkvF] [FILE]..."
|
||||
//usage: "[-cfvCF] [FILE]..."
|
||||
//usage:#define unlzop_full_usage "\n\n"
|
||||
//usage: " -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -U Delete input files"
|
||||
///////: "\n -k Keep input files" (default, so why bother documenting?)
|
||||
//usage: "\n -v Verbose"
|
||||
//usage: "\n -F Don't verify checksum"
|
||||
//usage: "\n -F Don't store or verify checksum"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#include "bb_archive.h"
|
||||
#include "liblzo_interface.h"
|
||||
|
||||
@@ -463,8 +443,8 @@ struct globals {
|
||||
chksum_t chksum_in;
|
||||
chksum_t chksum_out;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { setup_common_bufsiz(); } while (0)
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define INIT_G() do { } while (0)
|
||||
//#define G (*ptr_to_globals)
|
||||
//#define INIT_G() do {
|
||||
// SET_PTR_TO_GLOBALS(xzalloc(sizeof(G)));
|
||||
@@ -476,33 +456,27 @@ struct globals {
|
||||
//#define LZOP_VERSION_STRING "1.01"
|
||||
//#define LZOP_VERSION_DATE "Apr 27th 2003"
|
||||
|
||||
// lzop wants to be weird:
|
||||
// unlike all other compressosrs, its -k "keep" option is the default,
|
||||
// and -U is used to delete the source. We will invert the bit after getopt().
|
||||
#define OPTION_STRING "cfUvqdt123456789CFk"
|
||||
#define OPTION_STRING "cfvqdt123456789CF"
|
||||
|
||||
/* Note: must be kept in sync with archival/bbunzip.c */
|
||||
enum {
|
||||
OPT_STDOUT = (1 << 0),
|
||||
OPT_FORCE = (1 << 1),
|
||||
OPT_KEEP = (1 << 2),
|
||||
OPT_VERBOSE = (1 << 3),
|
||||
OPT_QUIET = (1 << 4),
|
||||
OPT_DECOMPRESS = (1 << 5),
|
||||
OPT_TEST = (1 << 6),
|
||||
OPT_1 = (1 << 7),
|
||||
OPT_2 = (1 << 8),
|
||||
OPT_3 = (1 << 9),
|
||||
OPT_4 = (1 << 10),
|
||||
OPT_5 = (1 << 11),
|
||||
OPT_6 = (1 << 12),
|
||||
OPT_VERBOSE = (1 << 2),
|
||||
OPT_QUIET = (1 << 3),
|
||||
OPT_DECOMPRESS = (1 << 4),
|
||||
OPT_TEST = (1 << 5),
|
||||
OPT_1 = (1 << 6),
|
||||
OPT_2 = (1 << 7),
|
||||
OPT_3 = (1 << 8),
|
||||
OPT_4 = (1 << 9),
|
||||
OPT_5 = (1 << 10),
|
||||
OPT_6 = (1 << 11),
|
||||
OPT_789 = (7 << 12),
|
||||
OPT_7 = (1 << 13),
|
||||
OPT_8 = (1 << 14),
|
||||
OPT_9 = (1 << 15),
|
||||
OPT_C = (1 << 16),
|
||||
OPT_F = (1 << 17),
|
||||
OPT_k = (1 << 18),
|
||||
OPT_789 = OPT_7 | OPT_8 | OPT_9
|
||||
OPT_C = (1 << 15),
|
||||
OPT_F = (1 << 16),
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -666,7 +640,7 @@ static int lzo_get_method(header_t *h)
|
||||
/**********************************************************************/
|
||||
// compress a file
|
||||
/**********************************************************************/
|
||||
static NOINLINE int lzo_compress(const header_t *h)
|
||||
static NOINLINE smallint lzo_compress(const header_t *h)
|
||||
{
|
||||
unsigned block_size = LZO_BLOCK_SIZE;
|
||||
int r = 0; /* LZO_E_OK */
|
||||
@@ -676,6 +650,7 @@ static NOINLINE int lzo_compress(const header_t *h)
|
||||
uint32_t d_adler32 = ADLER32_INIT_VALUE;
|
||||
uint32_t d_crc32 = CRC32_INIT_VALUE;
|
||||
int l;
|
||||
smallint ok = 1;
|
||||
uint8_t *wrk_mem = NULL;
|
||||
|
||||
if (h->method == M_LZO1X_1)
|
||||
@@ -757,7 +732,7 @@ static NOINLINE int lzo_compress(const header_t *h)
|
||||
free(wrk_mem);
|
||||
free(b1);
|
||||
free(b2);
|
||||
return 1;
|
||||
return ok;
|
||||
}
|
||||
|
||||
static FAST_FUNC void lzo_check(
|
||||
@@ -778,7 +753,7 @@ static FAST_FUNC void lzo_check(
|
||||
/**********************************************************************/
|
||||
// decompress a file
|
||||
/**********************************************************************/
|
||||
static NOINLINE int lzo_decompress(const header_t *h)
|
||||
static NOINLINE smallint lzo_decompress(const header_t *h)
|
||||
{
|
||||
unsigned block_size = LZO_BLOCK_SIZE;
|
||||
int r;
|
||||
@@ -786,6 +761,7 @@ static NOINLINE int lzo_decompress(const header_t *h)
|
||||
uint32_t c_adler32 = ADLER32_INIT_VALUE;
|
||||
uint32_t d_adler32 = ADLER32_INIT_VALUE;
|
||||
uint32_t c_crc32 = CRC32_INIT_VALUE, d_crc32 = CRC32_INIT_VALUE;
|
||||
smallint ok = 1;
|
||||
uint8_t *b1;
|
||||
uint32_t mcs_block_size = MAX_COMPRESSED_SIZE(block_size);
|
||||
uint8_t *b2 = NULL;
|
||||
@@ -889,7 +865,7 @@ static NOINLINE int lzo_decompress(const header_t *h)
|
||||
}
|
||||
|
||||
free(b2);
|
||||
return 1;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -921,7 +897,7 @@ static NOINLINE int lzo_decompress(const header_t *h)
|
||||
* chksum_out
|
||||
* The rest is identical.
|
||||
*/
|
||||
static const unsigned char lzop_magic[9] ALIGN1 = {
|
||||
static const unsigned char lzop_magic[9] = {
|
||||
0x89, 0x4c, 0x5a, 0x4f, 0x00, 0x0d, 0x0a, 0x1a, 0x0a
|
||||
};
|
||||
|
||||
@@ -1074,7 +1050,7 @@ static void lzo_set_method(header_t *h)
|
||||
h->level = level;
|
||||
}
|
||||
|
||||
static int do_lzo_compress(void)
|
||||
static smallint do_lzo_compress(void)
|
||||
{
|
||||
header_t header;
|
||||
|
||||
@@ -1102,7 +1078,7 @@ static int do_lzo_compress(void)
|
||||
/**********************************************************************/
|
||||
// decompress
|
||||
/**********************************************************************/
|
||||
static int do_lzo_decompress(void)
|
||||
static smallint do_lzo_decompress(void)
|
||||
{
|
||||
header_t header;
|
||||
|
||||
@@ -1123,7 +1099,7 @@ static char* FAST_FUNC make_new_name_lzop(char *filename, const char *expected_e
|
||||
return xasprintf("%s.lzo", filename);
|
||||
}
|
||||
|
||||
static IF_DESKTOP(long long) int FAST_FUNC pack_lzop(transformer_state_t *xstate UNUSED_PARAM)
|
||||
static IF_DESKTOP(long long) int FAST_FUNC pack_lzop(transformer_aux_data_t *aux UNUSED_PARAM)
|
||||
{
|
||||
if (option_mask32 & OPT_DECOMPRESS)
|
||||
return do_lzo_decompress();
|
||||
@@ -1135,18 +1111,11 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, OPTION_STRING);
|
||||
argv += optind;
|
||||
/* -U is "anti -k", invert bit for bbunpack(): */
|
||||
option_mask32 ^= OPT_KEEP;
|
||||
/* -k disables -U (if any): */
|
||||
/* opt_complementary "k-U"? - nope, only handles -Uk, not -kU */
|
||||
if (option_mask32 & OPT_k)
|
||||
option_mask32 |= OPT_KEEP;
|
||||
|
||||
/* lzopcat? */
|
||||
if (ENABLE_LZOPCAT && applet_name[4] == 'c')
|
||||
if (applet_name[4] == 'c')
|
||||
option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS);
|
||||
/* unlzop? */
|
||||
if (ENABLE_UNLZOP && applet_name[4] == 'o')
|
||||
if (applet_name[4] == 'o')
|
||||
option_mask32 |= OPT_DECOMPRESS;
|
||||
|
||||
global_crc32_table = crc32_filltable(NULL, 0);
|
||||
|
||||
+131
-286
@@ -6,18 +6,29 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//config:config RPM
|
||||
//config: bool "rpm (33 kb)"
|
||||
//config: bool "rpm"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Mini RPM applet - queries and extracts RPM packages.
|
||||
//config: Mini RPM applet - queries and extracts RPM packages.
|
||||
|
||||
//applet:IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_RPM) += rpm.o
|
||||
|
||||
//usage:#define rpm_trivial_usage
|
||||
//usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm"
|
||||
//usage:#define rpm_full_usage "\n\n"
|
||||
//usage: "Manipulate RPM packages\n"
|
||||
//usage: "\nCommands:"
|
||||
//usage: "\n -i Install package"
|
||||
//usage: "\n -qp Query package"
|
||||
//usage: "\n -qpi Show information"
|
||||
//usage: "\n -qpl List contents"
|
||||
//usage: "\n -qpd List documents"
|
||||
//usage: "\n -qpc List config files"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#include "bb_archive.h"
|
||||
#include "rpm.h"
|
||||
|
||||
@@ -56,8 +67,6 @@
|
||||
#define TAG_DIRINDEXES 1116
|
||||
#define TAG_BASENAMES 1117
|
||||
#define TAG_DIRNAMES 1118
|
||||
#define TAG_PAYLOADCOMPRESSOR 1125
|
||||
|
||||
|
||||
#define RPMFILE_CONFIG (1 << 0)
|
||||
#define RPMFILE_DOC (1 << 1)
|
||||
@@ -81,145 +90,148 @@ typedef struct {
|
||||
|
||||
struct globals {
|
||||
void *map;
|
||||
rpm_index *mytags;
|
||||
rpm_index **mytags;
|
||||
int tagcount;
|
||||
unsigned mapsize, pagesize;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { setup_common_bufsiz(); } while (0)
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define INIT_G() do { } while (0)
|
||||
|
||||
static int rpm_gettags(const char *filename)
|
||||
static void extract_cpio(int fd, const char *source_rpm)
|
||||
{
|
||||
rpm_index *tags;
|
||||
int fd;
|
||||
unsigned pass, idx;
|
||||
unsigned storepos;
|
||||
archive_handle_t *archive_handle;
|
||||
|
||||
if (!filename) { /* rpm2cpio w/o filename? */
|
||||
filename = bb_msg_standard_output;
|
||||
fd = 0;
|
||||
} else {
|
||||
fd = xopen(filename, O_RDONLY);
|
||||
}
|
||||
if (source_rpm != NULL) {
|
||||
/* Binary rpm (it was built from some SRPM), install to root */
|
||||
xchdir("/");
|
||||
} /* else: SRPM, install to current dir */
|
||||
|
||||
/* Initialize */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->seek = seek_by_read;
|
||||
archive_handle->action_data = data_extract_all;
|
||||
#if 0 /* For testing (rpm -i only lists the files in internal cpio): */
|
||||
archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_skip;
|
||||
#endif
|
||||
archive_handle->ah_flags = ARCHIVE_RESTORE_DATE | ARCHIVE_CREATE_LEADING_DIRS
|
||||
/* compat: overwrite existing files.
|
||||
* try "rpm -i foo.src.rpm" few times in a row -
|
||||
* standard rpm will not complain.
|
||||
*/
|
||||
| ARCHIVE_REPLACE_VIA_RENAME;
|
||||
archive_handle->src_fd = fd;
|
||||
/*archive_handle->offset = 0; - init_handle() did it */
|
||||
|
||||
setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_detected:*/ 1);
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
}
|
||||
|
||||
static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
{
|
||||
/* We should never need more than 200 (shrink via realloc later) */
|
||||
rpm_index **tags = xzalloc(200 * sizeof(tags[0]));
|
||||
int pass, tagindex = 0;
|
||||
|
||||
xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
|
||||
|
||||
storepos = xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
|
||||
G.tagcount = 0;
|
||||
tags = NULL;
|
||||
idx = 0;
|
||||
/* 1st pass is the signature headers, 2nd is the main stuff */
|
||||
for (pass = 0; pass < 2; pass++) {
|
||||
struct rpm_header header;
|
||||
unsigned cnt;
|
||||
rpm_index *tmpindex;
|
||||
int storepos;
|
||||
|
||||
xread(fd, &header, sizeof(header));
|
||||
if (header.magic_and_ver != htonl(RPM_HEADER_MAGICnVER))
|
||||
bb_error_msg_and_die("invalid RPM header magic in '%s'", filename);
|
||||
return NULL; /* Invalid magic, or not version 1 */
|
||||
header.size = ntohl(header.size);
|
||||
cnt = ntohl(header.entries);
|
||||
storepos += sizeof(header) + cnt * 16;
|
||||
header.entries = ntohl(header.entries);
|
||||
storepos = xlseek(fd, 0, SEEK_CUR) + header.entries * 16;
|
||||
|
||||
G.tagcount += cnt;
|
||||
tags = xrealloc(tags, sizeof(tags[0]) * G.tagcount);
|
||||
xread(fd, &tags[idx], sizeof(tags[0]) * cnt);
|
||||
while (cnt--) {
|
||||
rpm_index *tag = &tags[idx];
|
||||
tag->tag = ntohl(tag->tag);
|
||||
tag->type = ntohl(tag->type);
|
||||
tag->count = ntohl(tag->count);
|
||||
tag->offset = storepos + ntohl(tag->offset);
|
||||
while (header.entries--) {
|
||||
tmpindex = tags[tagindex++] = xmalloc(sizeof(*tmpindex));
|
||||
xread(fd, tmpindex, sizeof(*tmpindex));
|
||||
tmpindex->tag = ntohl(tmpindex->tag);
|
||||
tmpindex->type = ntohl(tmpindex->type);
|
||||
tmpindex->count = ntohl(tmpindex->count);
|
||||
tmpindex->offset = storepos + ntohl(tmpindex->offset);
|
||||
if (pass == 0)
|
||||
tag->tag -= 743;
|
||||
idx++;
|
||||
tmpindex->tag -= 743;
|
||||
}
|
||||
storepos = xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
/* Skip padding to 8 byte boundary after reading signature headers */
|
||||
if (pass == 0)
|
||||
while (header.size & 7)
|
||||
header.size++;
|
||||
/* Seek past store */
|
||||
storepos = xlseek(fd, header.size, SEEK_CUR);
|
||||
xlseek(fd, (-storepos) & 0x7, SEEK_CUR);
|
||||
}
|
||||
G.mytags = tags;
|
||||
|
||||
/* Map the store */
|
||||
storepos = (storepos + G.pagesize) & -(int)G.pagesize;
|
||||
/* remember size for munmap */
|
||||
G.mapsize = storepos;
|
||||
/* some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */
|
||||
G.map = mmap(0, storepos, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (G.map == MAP_FAILED)
|
||||
bb_perror_msg_and_die("mmap '%s'", filename);
|
||||
|
||||
return fd;
|
||||
/* realloc tags to save space */
|
||||
tags = xrealloc(tags, tagindex * sizeof(tags[0]));
|
||||
*num_tags = tagindex;
|
||||
/* All done, leave the file at the start of the gzipped cpio archive */
|
||||
return tags;
|
||||
}
|
||||
|
||||
static int bsearch_rpmtag(const void *key, const void *item)
|
||||
{
|
||||
int *tag = (int *)key;
|
||||
rpm_index *tmp = (rpm_index *) item;
|
||||
return (*tag - tmp->tag);
|
||||
rpm_index **tmp = (rpm_index **) item;
|
||||
return (*tag - tmp[0]->tag);
|
||||
}
|
||||
|
||||
static int rpm_getcount(int tag)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found)
|
||||
return 0;
|
||||
return found[0]->count;
|
||||
}
|
||||
|
||||
static char *rpm_getstr(int tag, int itemindex)
|
||||
{
|
||||
rpm_index *found;
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(G.mytags[0]), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found->count)
|
||||
rpm_index **found;
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count)
|
||||
return NULL;
|
||||
if (found->type == RPM_STRING_TYPE
|
||||
|| found->type == RPM_I18NSTRING_TYPE
|
||||
|| found->type == RPM_STRING_ARRAY_TYPE
|
||||
if (found[0]->type == RPM_STRING_TYPE
|
||||
|| found[0]->type == RPM_I18NSTRING_TYPE
|
||||
|| found[0]->type == RPM_STRING_ARRAY_TYPE
|
||||
) {
|
||||
int n;
|
||||
char *tmpstr = (char *) G.map + found->offset;
|
||||
char *tmpstr = (char *) G.map + found[0]->offset;
|
||||
for (n = 0; n < itemindex; n++)
|
||||
tmpstr = tmpstr + strlen(tmpstr) + 1;
|
||||
return tmpstr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static char *rpm_getstr0(int tag)
|
||||
{
|
||||
return rpm_getstr(tag, 0);
|
||||
}
|
||||
|
||||
#if ENABLE_RPM
|
||||
|
||||
static int rpm_getint(int tag, int itemindex)
|
||||
{
|
||||
rpm_index *found;
|
||||
rpm_index **found;
|
||||
char *tmpint;
|
||||
|
||||
/* gcc throws warnings here when sizeof(void*)!=sizeof(int) ...
|
||||
* it's ok to ignore it because tag won't be used as a pointer */
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(G.mytags[0]), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found->count)
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count)
|
||||
return -1;
|
||||
|
||||
tmpint = (char *) G.map + found->offset;
|
||||
if (found->type == RPM_INT32_TYPE) {
|
||||
tmpint = (char *) G.map + found[0]->offset;
|
||||
if (found[0]->type == RPM_INT32_TYPE) {
|
||||
tmpint += itemindex*4;
|
||||
return ntohl(*(int32_t*)tmpint);
|
||||
}
|
||||
if (found->type == RPM_INT16_TYPE) {
|
||||
if (found[0]->type == RPM_INT16_TYPE) {
|
||||
tmpint += itemindex*2;
|
||||
return ntohs(*(int16_t*)tmpint);
|
||||
}
|
||||
if (found->type == RPM_INT8_TYPE) {
|
||||
if (found[0]->type == RPM_INT8_TYPE) {
|
||||
tmpint += itemindex;
|
||||
return *(int8_t*)tmpint;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int rpm_getcount(int tag)
|
||||
{
|
||||
rpm_index *found;
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(G.mytags[0]), bsearch_rpmtag);
|
||||
if (!found)
|
||||
return 0;
|
||||
return found->count;
|
||||
}
|
||||
|
||||
static void fileaction_dobackup(char *filename, int fileref)
|
||||
{
|
||||
struct stat oldfile;
|
||||
@@ -260,103 +272,11 @@ static void loop_through_files(int filetag, void (*fileaction)(char *filename, i
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 //DEBUG
|
||||
static void print_all_tags(void)
|
||||
{
|
||||
unsigned i = 0;
|
||||
while (i < G.tagcount) {
|
||||
rpm_index *tag = &G.mytags[i];
|
||||
if (tag->type == RPM_STRING_TYPE
|
||||
|| tag->type == RPM_I18NSTRING_TYPE
|
||||
|| tag->type == RPM_STRING_ARRAY_TYPE
|
||||
) {
|
||||
unsigned n;
|
||||
char *str = (char *) G.map + tag->offset;
|
||||
|
||||
printf("tag[%u] %08x type %08x offset %08x count %d '%s'\n",
|
||||
i, tag->tag, tag->type, tag->offset, tag->count, str
|
||||
);
|
||||
for (n = 1; n < tag->count; n++) {
|
||||
str += strlen(str) + 1;
|
||||
printf("\t'%s'\n", str);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define print_all_tags() ((void)0)
|
||||
#endif
|
||||
|
||||
static void extract_cpio(int fd, const char *source_rpm)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
|
||||
if (source_rpm != NULL) {
|
||||
/* Binary rpm (it was built from some SRPM), install to root */
|
||||
xchdir("/");
|
||||
} /* else: SRPM, install to current dir */
|
||||
|
||||
/* Initialize */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->seek = seek_by_read;
|
||||
archive_handle->action_data = data_extract_all;
|
||||
#if 0 /* For testing (rpm -i only lists the files in internal cpio): */
|
||||
archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_skip;
|
||||
#endif
|
||||
archive_handle->ah_flags = ARCHIVE_RESTORE_DATE | ARCHIVE_CREATE_LEADING_DIRS
|
||||
/* compat: overwrite existing files.
|
||||
* try "rpm -i foo.src.rpm" few times in a row -
|
||||
* standard rpm will not complain.
|
||||
*/
|
||||
| ARCHIVE_REPLACE_VIA_RENAME;
|
||||
archive_handle->src_fd = fd;
|
||||
/*archive_handle->offset = 0; - init_handle() did it */
|
||||
|
||||
setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 1);
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
}
|
||||
|
||||
//usage:#define rpm_trivial_usage
|
||||
//usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm"
|
||||
//usage:#define rpm_full_usage "\n\n"
|
||||
//usage: "Manipulate RPM packages\n"
|
||||
//usage: "\nCommands:"
|
||||
//usage: "\n -i Install package"
|
||||
//usage: "\n -qp Query package"
|
||||
//usage: "\n -qpi Show information"
|
||||
//usage: "\n -qpl List contents"
|
||||
//usage: "\n -qpd List documents"
|
||||
//usage: "\n -qpc List config files"
|
||||
|
||||
/* RPM version 4.13.0.1:
|
||||
* Unlike -q, -i seems to imply -p: -i, -ip and -pi work the same.
|
||||
* OTOH, with -q order is important: "-piq FILE.rpm" works as -qp, not -qpi
|
||||
* (IOW: shows only package name, not package info).
|
||||
* "-iq ARG" works as -q: treats ARG as package name, not a file.
|
||||
*
|
||||
* "man rpm" on -l option and options implying it:
|
||||
* -l, --list List files in package.
|
||||
* -c, --configfiles List only configuration files (implies -l).
|
||||
* -d, --docfiles List only documentation files (implies -l).
|
||||
* -L, --licensefiles List only license files (implies -l).
|
||||
* --dump Dump file information as follows (implies -l):
|
||||
* path size mtime digest mode owner group isconfig isdoc rdev symlink
|
||||
* -s, --state Display the states of files in the package (implies -l).
|
||||
* The state of each file is one of normal, not installed, or replaced.
|
||||
*
|
||||
* Looks like we can switch to getopt32 here: in practice, people
|
||||
* do place -q first if they intend to use it (misinterpreting "-piq" wouldn't matter).
|
||||
*/
|
||||
int rpm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rpm_main(int argc, char **argv)
|
||||
{
|
||||
int opt, func = 0;
|
||||
|
||||
INIT_G();
|
||||
G.pagesize = getpagesize();
|
||||
const unsigned pagesize = getpagesize();
|
||||
|
||||
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
|
||||
switch (opt) {
|
||||
@@ -368,17 +288,17 @@ int rpm_main(int argc, char **argv)
|
||||
if (func) bb_show_usage();
|
||||
func = rpm_query;
|
||||
break;
|
||||
case 'p': /* Query a package (IOW: .rpm file, we are not querying RPMDB) */
|
||||
case 'p': /* Query a package */
|
||||
func |= rpm_query_package;
|
||||
break;
|
||||
case 'l': /* List files in a package */
|
||||
func |= rpm_query_list;
|
||||
break;
|
||||
case 'd': /* List doc files in a package (implies -l) */
|
||||
case 'd': /* List doc files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_doc;
|
||||
break;
|
||||
case 'c': /* List config files in a package (implies -l) */
|
||||
case 'c': /* List config files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_config;
|
||||
break;
|
||||
@@ -392,18 +312,24 @@ int rpm_main(int argc, char **argv)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
while (*argv) {
|
||||
int rpm_fd;
|
||||
unsigned mapsize;
|
||||
const char *source_rpm;
|
||||
|
||||
rpm_fd = rpm_gettags(*argv);
|
||||
print_all_tags();
|
||||
rpm_fd = xopen(*argv++, O_RDONLY);
|
||||
G.mytags = rpm_gettags(rpm_fd, &G.tagcount);
|
||||
if (!G.mytags)
|
||||
bb_error_msg_and_die("error reading rpm header");
|
||||
mapsize = xlseek(rpm_fd, 0, SEEK_CUR);
|
||||
mapsize = (mapsize + pagesize) & -(int)pagesize;
|
||||
/* Some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */
|
||||
G.map = mmap(0, mapsize, PROT_READ, MAP_PRIVATE, rpm_fd, 0);
|
||||
//FIXME: error check?
|
||||
|
||||
source_rpm = rpm_getstr0(TAG_SOURCERPM);
|
||||
source_rpm = rpm_getstr(TAG_SOURCERPM, 0);
|
||||
|
||||
if (func & rpm_install) {
|
||||
/* -i (and not -qi) */
|
||||
|
||||
/* Backup any config files */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_dobackup);
|
||||
/* Extact the archive */
|
||||
@@ -411,13 +337,10 @@ int rpm_main(int argc, char **argv)
|
||||
/* Set the correct file uid/gid's */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_setowngrp);
|
||||
}
|
||||
else
|
||||
if ((func & (rpm_query|rpm_query_package)) == (rpm_query|rpm_query_package)) {
|
||||
/* -qp */
|
||||
|
||||
else if ((func & (rpm_query|rpm_query_package)) == (rpm_query|rpm_query_package)) {
|
||||
if (!(func & (rpm_query_info|rpm_query_list))) {
|
||||
/* If just a straight query, just give package name */
|
||||
printf("%s-%s-%s\n", rpm_getstr0(TAG_NAME), rpm_getstr0(TAG_VERSION), rpm_getstr0(TAG_RELEASE));
|
||||
printf("%s-%s-%s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_RELEASE, 0));
|
||||
}
|
||||
if (func & rpm_query_info) {
|
||||
/* Do the nice printout */
|
||||
@@ -426,33 +349,30 @@ int rpm_main(int argc, char **argv)
|
||||
char bdatestring[50];
|
||||
const char *p;
|
||||
|
||||
printf("%-12s: %s\n", "Name" , rpm_getstr0(TAG_NAME));
|
||||
printf("%-12s: %s\n", "Name" , rpm_getstr(TAG_NAME, 0));
|
||||
/* TODO compat: add "Epoch" here */
|
||||
printf("%-12s: %s\n", "Version" , rpm_getstr0(TAG_VERSION));
|
||||
printf("%-12s: %s\n", "Release" , rpm_getstr0(TAG_RELEASE));
|
||||
printf("%-12s: %s\n", "Version" , rpm_getstr(TAG_VERSION, 0));
|
||||
printf("%-12s: %s\n", "Release" , rpm_getstr(TAG_RELEASE, 0));
|
||||
/* add "Architecture" */
|
||||
/* printf("%-12s: %s\n", "Install Date", "(not installed)"); - we don't know */
|
||||
printf("%-12s: %s\n", "Group" , rpm_getstr0(TAG_GROUP));
|
||||
printf("%-12s: %s\n", "Install Date", "(not installed)");
|
||||
printf("%-12s: %s\n", "Group" , rpm_getstr(TAG_GROUP, 0));
|
||||
printf("%-12s: %d\n", "Size" , rpm_getint(TAG_SIZE, 0));
|
||||
printf("%-12s: %s\n", "License" , rpm_getstr0(TAG_LICENSE));
|
||||
printf("%-12s: %s\n", "License" , rpm_getstr(TAG_LICENSE, 0));
|
||||
/* add "Signature" */
|
||||
printf("%-12s: %s\n", "Source RPM" , source_rpm ? source_rpm : "(none)");
|
||||
bdate_time = rpm_getint(TAG_BUILDTIME, 0);
|
||||
bdate_ptm = localtime(&bdate_time);
|
||||
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate_ptm);
|
||||
printf("%-12s: %s\n", "Build Date" , bdatestring);
|
||||
printf("%-12s: %s\n", "Build Host" , rpm_getstr0(TAG_BUILDHOST));
|
||||
p = rpm_getstr0(TAG_PREFIXS);
|
||||
printf("%-12s: %s\n", "Build Host" , rpm_getstr(TAG_BUILDHOST, 0));
|
||||
p = rpm_getstr(TAG_PREFIXS, 0);
|
||||
printf("%-12s: %s\n", "Relocations" , p ? p : "(not relocatable)");
|
||||
/* add "Packager" */
|
||||
p = rpm_getstr0(TAG_VENDOR);
|
||||
if (p) /* rpm 4.13.0.1 does not show "(none)" for Vendor: */
|
||||
printf("%-12s: %s\n", "Vendor" , p);
|
||||
p = rpm_getstr0(TAG_URL);
|
||||
if (p) /* rpm 4.13.0.1 does not show "(none)"/"(null)" for URL: */
|
||||
printf("%-12s: %s\n", "URL" , p);
|
||||
printf("%-12s: %s\n", "Summary" , rpm_getstr0(TAG_SUMMARY));
|
||||
printf("Description :\n%s\n", rpm_getstr0(TAG_DESCRIPTION));
|
||||
p = rpm_getstr(TAG_VENDOR, 0);
|
||||
printf("%-12s: %s\n", "Vendor" , p ? p : "(none)");
|
||||
printf("%-12s: %s\n", "URL" , rpm_getstr(TAG_URL, 0));
|
||||
printf("%-12s: %s\n", "Summary" , rpm_getstr(TAG_SUMMARY, 0));
|
||||
printf("Description :\n%s\n", rpm_getstr(TAG_DESCRIPTION, 0));
|
||||
}
|
||||
if (func & rpm_query_list) {
|
||||
int count, it, flags;
|
||||
@@ -475,85 +395,10 @@ int rpm_main(int argc, char **argv)
|
||||
rpm_getstr(TAG_BASENAMES, it));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Unsupported (help text shows what we support) */
|
||||
bb_show_usage();
|
||||
}
|
||||
if (!*++argv)
|
||||
break;
|
||||
munmap(G.map, G.mapsize);
|
||||
munmap(G.map, mapsize);
|
||||
free(G.mytags);
|
||||
close(rpm_fd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* RPM */
|
||||
|
||||
/*
|
||||
* Mini rpm2cpio implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2001 by Laurence Anderson
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RPM2CPIO
|
||||
//config: bool "rpm2cpio (20 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Converts a RPM file into a CPIO archive.
|
||||
|
||||
//applet:IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_RPM2CPIO) += rpm.o
|
||||
|
||||
//usage:#define rpm2cpio_trivial_usage
|
||||
//usage: "PACKAGE.rpm"
|
||||
//usage:#define rpm2cpio_full_usage "\n\n"
|
||||
//usage: "Output a cpio archive of the rpm file"
|
||||
|
||||
#if ENABLE_RPM2CPIO
|
||||
|
||||
/* No getopt required */
|
||||
int rpm2cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
const char *str;
|
||||
int rpm_fd;
|
||||
|
||||
INIT_G();
|
||||
G.pagesize = getpagesize();
|
||||
|
||||
rpm_fd = rpm_gettags(argv[1]);
|
||||
|
||||
//if (SEAMLESS_COMPRESSION) - we do this at the end instead.
|
||||
// /* We need to know whether child (gzip/bzip/etc) exits abnormally */
|
||||
// signal(SIGCHLD, check_errors_in_children);
|
||||
|
||||
if (ENABLE_FEATURE_SEAMLESS_LZMA
|
||||
&& (str = rpm_getstr0(TAG_PAYLOADCOMPRESSOR)) != NULL
|
||||
&& strcmp(str, "lzma") == 0
|
||||
) {
|
||||
// lzma compression can't be detected
|
||||
// set up decompressor without detection
|
||||
setup_lzma_on_fd(rpm_fd);
|
||||
} else {
|
||||
setup_unzip_on_fd(rpm_fd, /*fail_if_not_compressed:*/ 1);
|
||||
}
|
||||
|
||||
if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0)
|
||||
bb_error_msg_and_die("error unpacking");
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(rpm_fd);
|
||||
}
|
||||
|
||||
if (SEAMLESS_COMPRESSION) {
|
||||
check_errors_in_children(0);
|
||||
return bb_got_signal;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif /* RPM2CPIO */
|
||||
@@ -0,0 +1,96 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rpm2cpio implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2001 by Laurence Anderson
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//config:config RPM2CPIO
|
||||
//config: bool "rpm2cpio"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Converts a RPM file into a CPIO archive.
|
||||
|
||||
//applet:IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
|
||||
//usage:#define rpm2cpio_trivial_usage
|
||||
//usage: "package.rpm"
|
||||
//usage:#define rpm2cpio_full_usage "\n\n"
|
||||
//usage: "Output a cpio archive of the rpm file"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
#include "rpm.h"
|
||||
|
||||
enum { rpm_fd = STDIN_FILENO };
|
||||
|
||||
static unsigned skip_header(void)
|
||||
{
|
||||
struct rpm_header header;
|
||||
unsigned len;
|
||||
|
||||
xread(rpm_fd, &header, sizeof(header));
|
||||
// if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC_STR, 3) != 0) {
|
||||
// bb_error_msg_and_die("invalid RPM header magic");
|
||||
// }
|
||||
// if (header.version != 1) {
|
||||
// bb_error_msg_and_die("unsupported RPM header version");
|
||||
// }
|
||||
if (header.magic_and_ver != htonl(RPM_HEADER_MAGICnVER)) {
|
||||
bb_error_msg_and_die("invalid RPM header magic or unsupported version");
|
||||
// ": %x != %x", header.magic_and_ver, htonl(RPM_HEADER_MAGICnVER));
|
||||
}
|
||||
|
||||
/* Seek past index entries, and past store */
|
||||
len = 16 * ntohl(header.entries) + ntohl(header.size);
|
||||
seek_by_jump(rpm_fd, len);
|
||||
|
||||
return sizeof(header) + len;
|
||||
}
|
||||
|
||||
/* No getopt required */
|
||||
int rpm2cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct rpm_lead lead;
|
||||
unsigned pos;
|
||||
|
||||
if (argv[1]) {
|
||||
xmove_fd(xopen(argv[1], O_RDONLY), rpm_fd);
|
||||
}
|
||||
xread(rpm_fd, &lead, sizeof(lead));
|
||||
|
||||
/* Just check the magic, the rest is irrelevant */
|
||||
if (lead.magic != htonl(RPM_LEAD_MAGIC)) {
|
||||
bb_error_msg_and_die("invalid RPM magic");
|
||||
}
|
||||
|
||||
/* Skip the signature header, align to 8 bytes */
|
||||
pos = skip_header();
|
||||
seek_by_jump(rpm_fd, (-(int)pos) & 7);
|
||||
|
||||
/* Skip the main header */
|
||||
skip_header();
|
||||
|
||||
//if (SEAMLESS_COMPRESSION)
|
||||
// /* We need to know whether child (gzip/bzip/etc) exits abnormally */
|
||||
// signal(SIGCHLD, check_errors_in_children);
|
||||
|
||||
/* This works, but doesn't report uncompress errors (they happen in child) */
|
||||
setup_unzip_on_fd(rpm_fd, /*fail_if_not_detected:*/ 1);
|
||||
if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0)
|
||||
bb_error_msg_and_die("error unpacking");
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(rpm_fd);
|
||||
}
|
||||
|
||||
if (SEAMLESS_COMPRESSION) {
|
||||
check_errors_in_children(0);
|
||||
return bb_got_signal;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+226
-267
@@ -22,118 +22,149 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
/* TODO: security with -C DESTDIR option can be enhanced.
|
||||
* Consider tar file created via:
|
||||
* $ tar cvf bug.tar anything.txt
|
||||
* $ ln -s /tmp symlink
|
||||
* $ tar --append -f bug.tar symlink
|
||||
* $ rm symlink
|
||||
* $ mkdir symlink
|
||||
* $ tar --append -f bug.tar symlink/evil.py
|
||||
*
|
||||
* This will result in an archive which contains:
|
||||
* $ tar --list -f bug.tar
|
||||
* anything.txt
|
||||
* symlink
|
||||
* symlink/evil.py
|
||||
*
|
||||
* Untarring it puts evil.py in '/tmp' even if the -C DESTDIR is given.
|
||||
* This doesn't feel right, and IIRC GNU tar doesn't do that.
|
||||
*/
|
||||
|
||||
//config:config TAR
|
||||
//config: bool "tar (40 kb)"
|
||||
//config: bool "tar"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tar is an archiving program. It's commonly used with gzip to
|
||||
//config: create compressed archives. It's probably the most widely used
|
||||
//config: UNIX archive program.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on TAR && LONG_OPTS
|
||||
//config: tar is an archiving program. It's commonly used with gzip to
|
||||
//config: create compressed archives. It's probably the most widely used
|
||||
//config: UNIX archive program.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_CREATE
|
||||
//config: bool "Enable -c (archive creation)"
|
||||
//config: bool "Enable archive creation"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: If you enable this option you'll be able to create
|
||||
//config: tar archives using the `-c' option.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_AUTODETECT
|
||||
//config: bool "Autodetect compressed tarballs"
|
||||
//config: default y
|
||||
//config: depends on TAR && (FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA || FEATURE_SEAMLESS_XZ)
|
||||
//config: help
|
||||
//config: With this option tar can automatically detect compressed
|
||||
//config: tarballs. Currently it works only on files (not pipes etc).
|
||||
//config: With this option tar can automatically detect compressed
|
||||
//config: tarballs. Currently it works only on files (not pipes etc).
|
||||
//config:
|
||||
//config:config FEATURE_TAR_FROM
|
||||
//config: bool "Enable -X (exclude from) and -T (include from) options"
|
||||
//config: bool "Enable -X (exclude from) and -T (include from) options)"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: If you enable this option you'll be able to specify
|
||||
//config: a list of files to include or exclude from an archive.
|
||||
//config: If you enable this option you'll be able to specify
|
||||
//config: a list of files to include or exclude from an archive.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
//config: bool "Support old tar header format"
|
||||
//config: bool "Support for old tar header format"
|
||||
//config: default y
|
||||
//config: depends on TAR || DPKG
|
||||
//config: help
|
||||
//config: This option is required to unpack archives created in
|
||||
//config: the old GNU format; help to kill this old format by
|
||||
//config: repacking your ancient archives with the new format.
|
||||
//config: This option is required to unpack archives created in
|
||||
//config: the old GNU format; help to kill this old format by
|
||||
//config: repacking your ancient archives with the new format.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
//config: bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
|
||||
//config: default y
|
||||
//config: depends on TAR || DPKG
|
||||
//config: help
|
||||
//config: This option is required to unpack archives created by some old
|
||||
//config: version of Sun's tar (it was calculating checksum using signed
|
||||
//config: arithmetic). It is said to be fixed in newer Sun tar, but "old"
|
||||
//config: tarballs still exist.
|
||||
//config: This option is required to unpack archives created by some old
|
||||
//config: version of Sun's tar (it was calculating checksum using signed
|
||||
//config: arithmetic). It is said to be fixed in newer Sun tar, but "old"
|
||||
//config: tarballs still exist.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_GNU_EXTENSIONS
|
||||
//config: bool "Support GNU tar extensions (long filenames)"
|
||||
//config: bool "Support for GNU tar extensions (long filenames)"
|
||||
//config: default y
|
||||
//config: depends on TAR || DPKG
|
||||
//config: help
|
||||
//config: With this option busybox supports GNU long filenames and
|
||||
//config: linknames.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on TAR && LONG_OPTS
|
||||
//config: help
|
||||
//config: Enable use of long options, increases size by about 400 Bytes
|
||||
//config:
|
||||
//config:config FEATURE_TAR_TO_COMMAND
|
||||
//config: bool "Support writing to an external program (--to-command)"
|
||||
//config: bool "Support for writing to an external program"
|
||||
//config: default y
|
||||
//config: depends on TAR && FEATURE_TAR_LONG_OPTIONS
|
||||
//config: help
|
||||
//config: If you enable this option you'll be able to instruct tar to send
|
||||
//config: the contents of each extracted file to the standard input of an
|
||||
//config: external program.
|
||||
//config: If you enable this option you'll be able to instruct tar to send
|
||||
//config: the contents of each extracted file to the standard input of an
|
||||
//config: external program.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_UNAME_GNAME
|
||||
//config: bool "Enable use of user and group names"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: Enable use of user and group names in tar. This affects contents
|
||||
//config: listings (-t) and preserving permissions when unpacking (-p).
|
||||
//config: +200 bytes.
|
||||
//config: Enables use of user and group names in tar. This affects contents
|
||||
//config: listings (-t) and preserving permissions when unpacking (-p).
|
||||
//config: +200 bytes.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_NOPRESERVE_TIME
|
||||
//config: bool "Enable -m (do not preserve time) GNU option"
|
||||
//config: bool "Enable -m (do not preserve time) option"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: With this option busybox supports GNU tar -m
|
||||
//config: (do not preserve time) option.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_SELINUX
|
||||
//config: bool "Support extracting SELinux labels"
|
||||
//config: bool "Support for extracting SELinux labels"
|
||||
//config: default n
|
||||
//config: depends on TAR && SELINUX
|
||||
//config: help
|
||||
//config: With this option busybox supports restoring SELinux labels
|
||||
//config: when extracting files from tar archives.
|
||||
//config: With this option busybox supports restoring SELinux labels
|
||||
//config: when extracting files from tar archives.
|
||||
|
||||
//applet:IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_TAR) += tar.o
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#include "bb_archive.h"
|
||||
/* FIXME: Stop using this non-standard feature */
|
||||
#ifndef FNM_LEADING_DIR
|
||||
# define FNM_LEADING_DIR 0
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
# define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__)
|
||||
#else
|
||||
# define DBG(...) ((void)0)
|
||||
#endif
|
||||
#define DBG_OPTION_PARSING 0
|
||||
|
||||
//#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__)
|
||||
#define DBG(...) ((void)0)
|
||||
|
||||
|
||||
#define block_buf bb_common_bufsiz1
|
||||
#define INIT_G() do { setup_common_bufsiz(); } while (0)
|
||||
|
||||
|
||||
#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
/* Do not pass gzip flag to writeTarFile() */
|
||||
#define writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude, gzip) \
|
||||
writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude)
|
||||
#endif
|
||||
|
||||
|
||||
#if ENABLE_FEATURE_TAR_CREATE
|
||||
@@ -156,9 +187,7 @@ typedef struct TarBallInfo {
|
||||
int tarFd; /* Open-for-write file descriptor
|
||||
* for the tarball */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
# if ENABLE_FEATURE_TAR_FROM
|
||||
const llist_t *excludeList; /* List of files to not include */
|
||||
# endif
|
||||
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
|
||||
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
|
||||
//TODO: save only st_dev + st_ino
|
||||
@@ -280,7 +309,7 @@ static void chksum_and_xwrite(int fd, struct tar_header_t* hp)
|
||||
xwrite(fd, hp, sizeof(*hp));
|
||||
}
|
||||
|
||||
# if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
static void writeLongname(int fd, int type, const char *name, int dir)
|
||||
{
|
||||
static const struct {
|
||||
@@ -320,7 +349,7 @@ static void writeLongname(int fd, int type, const char *name, int dir)
|
||||
memset(&header, 0, size);
|
||||
xwrite(fd, &header, size);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Write out a tar header for the specified file/directory/whatever */
|
||||
static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
@@ -349,30 +378,30 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
header.typeflag = LNKTYPE;
|
||||
strncpy(header.linkname, tbInfo->hlInfo->name,
|
||||
sizeof(header.linkname));
|
||||
# if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
/* Write out long linkname if needed */
|
||||
if (header.linkname[sizeof(header.linkname)-1])
|
||||
writeLongname(tbInfo->tarFd, GNULONGLINK,
|
||||
tbInfo->hlInfo->name, 0);
|
||||
# endif
|
||||
#endif
|
||||
} else if (S_ISLNK(statbuf->st_mode)) {
|
||||
char *lpath = xmalloc_readlink_or_warn(fileName);
|
||||
if (!lpath)
|
||||
return FALSE;
|
||||
header.typeflag = SYMTYPE;
|
||||
strncpy(header.linkname, lpath, sizeof(header.linkname));
|
||||
# if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
/* Write out long linkname if needed */
|
||||
if (header.linkname[sizeof(header.linkname)-1])
|
||||
writeLongname(tbInfo->tarFd, GNULONGLINK, lpath, 0);
|
||||
# else
|
||||
#else
|
||||
/* If it is larger than 100 bytes, bail out */
|
||||
if (header.linkname[sizeof(header.linkname)-1]) {
|
||||
free(lpath);
|
||||
bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
|
||||
return FALSE;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
free(lpath);
|
||||
} else if (S_ISDIR(statbuf->st_mode)) {
|
||||
header.typeflag = DIRTYPE;
|
||||
@@ -402,9 +431,9 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
* It always does unless off_t is wider than 64 bits.
|
||||
*/
|
||||
else if (ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
# if ULLONG_MAX > 0xffffffffffffffffLL /* 2^64-1 */
|
||||
#if ULLONG_MAX > 0xffffffffffffffffLL /* 2^64-1 */
|
||||
&& (filesize <= 0x3fffffffffffffffffffffffLL)
|
||||
# endif
|
||||
#endif
|
||||
) {
|
||||
/* GNU tar uses "base-256 encoding" for very large numbers.
|
||||
* Encoding is binary, with highest bit always set as a marker
|
||||
@@ -431,13 +460,13 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
# if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
/* Write out long name if needed */
|
||||
/* (we, like GNU tar, output long linkname *before* long name) */
|
||||
if (header.name[sizeof(header.name)-1])
|
||||
writeLongname(tbInfo->tarFd, GNULONGNAME,
|
||||
header_name, S_ISDIR(statbuf->st_mode));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Now write the header out to disk */
|
||||
chksum_and_xwrite(tbInfo->tarFd, &header);
|
||||
@@ -459,7 +488,7 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
# if ENABLE_FEATURE_TAR_FROM
|
||||
#if ENABLE_FEATURE_TAR_FROM
|
||||
static int exclude_file(const llist_t *excluded_files, const char *file)
|
||||
{
|
||||
while (excluded_files) {
|
||||
@@ -485,9 +514,9 @@ static int exclude_file(const llist_t *excluded_files, const char *file)
|
||||
|
||||
return 0;
|
||||
}
|
||||
# else
|
||||
# define exclude_file(excluded_files, file) 0
|
||||
# endif
|
||||
#else
|
||||
# define exclude_file(excluded_files, file) 0
|
||||
#endif
|
||||
|
||||
static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
void *userData, int depth UNUSED_PARAM)
|
||||
@@ -513,8 +542,8 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
|
||||
/*
|
||||
* Check to see if we are dealing with a hard link.
|
||||
* If so -
|
||||
* Treat the first occurrence of a given dev/inode as a file while
|
||||
* treating any additional occurrences as hard links. This is done
|
||||
* Treat the first occurance of a given dev/inode as a file while
|
||||
* treating any additional occurances as hard links. This is done
|
||||
* by adding the file information to the HardLinkInfo linked list.
|
||||
*/
|
||||
tbInfo->hlInfo = NULL;
|
||||
@@ -540,12 +569,12 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
|
||||
if (exclude_file(tbInfo->excludeList, header_name))
|
||||
return SKIP;
|
||||
|
||||
# if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
#if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (strlen(header_name) >= NAME_SIZE) {
|
||||
bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
|
||||
return TRUE;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Is this a regular file? */
|
||||
if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) {
|
||||
@@ -592,41 +621,55 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
# if SEAMLESS_COMPRESSION
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
# if !(ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2)
|
||||
# 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, const char *gzip)
|
||||
static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
{
|
||||
pid_t gzipPid;
|
||||
|
||||
# if ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
# elif ENABLE_FEATURE_SEAMLESS_GZ
|
||||
const char *zip_exec = "gzip";
|
||||
# else /* only ENABLE_FEATURE_SEAMLESS_BZ2 */
|
||||
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
|
||||
# define WAIT_FOR_CHILD 0
|
||||
volatile int vfork_exec_errno = 0;
|
||||
struct fd_pair gzipDataPipe;
|
||||
# if WAIT_FOR_CHILD
|
||||
# if WAIT_FOR_CHILD
|
||||
struct fd_pair gzipStatusPipe;
|
||||
xpiped_pair(gzipStatusPipe);
|
||||
# endif
|
||||
# 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 = xvfork();
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
/* NB: close _first_, then move fds! */
|
||||
close(gzipDataPipe.wr);
|
||||
# if WAIT_FOR_CHILD
|
||||
# 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
|
||||
# endif
|
||||
xmove_fd(gzipDataPipe.rd, 0);
|
||||
xmove_fd(tar_fd, 1);
|
||||
/* exec gzip/bzip2 program/applet */
|
||||
BB_EXECLP(gzip, gzip, "-f", (char *)0);
|
||||
BB_EXECLP(zip_exec, zip_exec, "-f", (char *)0);
|
||||
vfork_exec_errno = errno;
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -634,7 +677,7 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
|
||||
/* parent */
|
||||
xmove_fd(gzipDataPipe.wr, tar_fd);
|
||||
close(gzipDataPipe.rd);
|
||||
# if WAIT_FOR_CHILD
|
||||
# if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.wr);
|
||||
while (1) {
|
||||
char buf;
|
||||
@@ -646,52 +689,50 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
|
||||
continue; /* try it again */
|
||||
}
|
||||
close(gzipStatusPipe.rd);
|
||||
# endif
|
||||
# endif
|
||||
if (vfork_exec_errno) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("can't execute '%s'", gzip);
|
||||
bb_perror_msg_and_die("can't execute '%s'", zip_exec);
|
||||
}
|
||||
}
|
||||
# endif /* SEAMLESS_COMPRESSION */
|
||||
#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 */
|
||||
|
||||
|
||||
# if !SEAMLESS_COMPRESSION
|
||||
/* Do not pass gzip flag to writeTarFile() */
|
||||
#define writeTarFile(tbInfo, recurseFlags, filelist, gzip) \
|
||||
writeTarFile(tbInfo, recurseFlags, filelist)
|
||||
# endif
|
||||
/* gcc 4.2.1 inlines it, making code bigger */
|
||||
static NOINLINE int writeTarFile(
|
||||
struct TarBallInfo *tbInfo,
|
||||
int recurseFlags,
|
||||
const llist_t *filelist,
|
||||
const char *gzip)
|
||||
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int recurseFlags, const llist_t *include,
|
||||
const llist_t *exclude, int gzip)
|
||||
{
|
||||
int errorFlag = FALSE;
|
||||
struct TarBallInfo tbInfo;
|
||||
|
||||
/*tbInfo->hlInfoHead = NULL; - already is */
|
||||
tbInfo.hlInfoHead = NULL;
|
||||
tbInfo.tarFd = tar_fd;
|
||||
tbInfo.verboseFlag = verboseFlag;
|
||||
|
||||
/* Store the stat info for the tarball's file, so
|
||||
* can avoid including the tarball into itself.... */
|
||||
xfstat(tbInfo->tarFd, &tbInfo->tarFileStatBuf, "can't stat tar file");
|
||||
xfstat(tbInfo.tarFd, &tbInfo.tarFileStatBuf, "can't stat tar file");
|
||||
|
||||
# if SEAMLESS_COMPRESSION
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (gzip)
|
||||
vfork_compressor(tbInfo->tarFd, gzip);
|
||||
# endif
|
||||
vfork_compressor(tbInfo.tarFd, gzip);
|
||||
#endif
|
||||
|
||||
tbInfo.excludeList = exclude;
|
||||
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (filelist) {
|
||||
if (!recursive_action(filelist->data, recurseFlags,
|
||||
writeFileToTarball, writeFileToTarball, tbInfo, 0)
|
||||
while (include) {
|
||||
if (!recursive_action(include->data, recurseFlags,
|
||||
writeFileToTarball, writeFileToTarball, &tbInfo, 0)
|
||||
) {
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
filelist = filelist->link;
|
||||
include = include->link;
|
||||
}
|
||||
/* Write two empty blocks to the end of the archive */
|
||||
memset(block_buf, 0, 2*TAR_BLOCK_SIZE);
|
||||
xwrite(tbInfo->tarFd, block_buf, 2*TAR_BLOCK_SIZE);
|
||||
xwrite(tbInfo.tarFd, block_buf, 2*TAR_BLOCK_SIZE);
|
||||
|
||||
/* To be pedantically correct, we would check if the tarball
|
||||
* is smaller than 20 tar blocks, and pad it if it was smaller,
|
||||
@@ -699,16 +740,16 @@ static NOINLINE int writeTarFile(
|
||||
* so is considered a waste of space */
|
||||
|
||||
/* Close so the child process (if any) will exit */
|
||||
close(tbInfo->tarFd);
|
||||
close(tbInfo.tarFd);
|
||||
|
||||
/* Hang up the tools, close up shop, head home */
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
freeHardLinkInfo(&tbInfo->hlInfoHead);
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
|
||||
if (errorFlag)
|
||||
bb_error_msg("error exit delayed from previous errors");
|
||||
|
||||
# if SEAMLESS_COMPRESSION
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (gzip) {
|
||||
int status;
|
||||
if (safe_waitpid(-1, &status, 0) == -1)
|
||||
@@ -717,25 +758,23 @@ static NOINLINE int writeTarFile(
|
||||
/* gzip was killed or has exited with nonzero! */
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
return errorFlag;
|
||||
}
|
||||
|
||||
#else /* !FEATURE_TAR_CREATE */
|
||||
|
||||
# define writeTarFile(...) 0
|
||||
|
||||
#endif
|
||||
#else
|
||||
int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int recurseFlags, const llist_t *include,
|
||||
const llist_t *exclude, 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;
|
||||
char *line;
|
||||
llist_t *newlist = NULL;
|
||||
|
||||
while (list) {
|
||||
FILE *src_stream;
|
||||
char *line;
|
||||
|
||||
src_stream = xfopen_stdin(llist_pop(&list));
|
||||
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
|
||||
/* kill trailing '/' unless the string is just "/" */
|
||||
@@ -751,7 +790,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
#endif
|
||||
|
||||
//usage:#define tar_trivial_usage
|
||||
//usage: IF_FEATURE_TAR_CREATE("c|") "x|t [-"
|
||||
//usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt"
|
||||
//usage: IF_FEATURE_SEAMLESS_Z("Z")
|
||||
//usage: IF_FEATURE_SEAMLESS_GZ("z")
|
||||
//usage: IF_FEATURE_SEAMLESS_XZ("J")
|
||||
@@ -760,9 +799,8 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
//usage: IF_FEATURE_TAR_CREATE("h")
|
||||
//usage: IF_FEATURE_TAR_NOPRESERVE_TIME("m")
|
||||
//usage: "vO] "
|
||||
//usage: "[-f TARFILE] [-C DIR] "
|
||||
//usage: IF_FEATURE_TAR_FROM("[-T FILE] [-X FILE] "IF_FEATURE_TAR_LONG_OPTIONS("[--exclude PATTERN]... "))
|
||||
//usage: "[FILE]..."
|
||||
//usage: IF_FEATURE_TAR_FROM("[-X FILE] [-T FILE] ")
|
||||
//usage: "[-f TARFILE] [-C DIR] [FILE]..."
|
||||
//usage:#define tar_full_usage "\n\n"
|
||||
//usage: IF_FEATURE_TAR_CREATE("Create, extract, ")
|
||||
//usage: IF_NOT_FEATURE_TAR_CREATE("Extract ")
|
||||
@@ -773,37 +811,37 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
//usage: )
|
||||
//usage: "\n x Extract"
|
||||
//usage: "\n t List"
|
||||
//usage: "\n -f FILE Name of TARFILE ('-' for stdin/out)"
|
||||
//usage: "\n -C DIR Change to DIR before operation"
|
||||
//usage: "\n -v Verbose"
|
||||
//usage: "\n f Name of TARFILE ('-' for stdin/out)"
|
||||
//usage: "\n C Change to DIR before operation"
|
||||
//usage: "\n v Verbose"
|
||||
//usage: IF_FEATURE_SEAMLESS_Z(
|
||||
//usage: "\n -Z (De)compress using compress"
|
||||
//usage: "\n Z (De)compress using compress"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_GZ(
|
||||
//usage: "\n -z (De)compress using gzip"
|
||||
//usage: "\n z (De)compress using gzip"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_XZ(
|
||||
//usage: "\n -J (De)compress using xz"
|
||||
//usage: "\n J (De)compress using xz"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_BZ2(
|
||||
//usage: "\n -j (De)compress using bzip2"
|
||||
//usage: "\n j (De)compress using bzip2"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_LZMA(
|
||||
//usage: "\n -a (De)compress using lzma"
|
||||
//usage: "\n a (De)compress using lzma"
|
||||
//usage: )
|
||||
//usage: "\n -O Extract to stdout"
|
||||
//usage: "\n O Extract to stdout"
|
||||
//usage: IF_FEATURE_TAR_CREATE(
|
||||
//usage: "\n -h Follow symlinks"
|
||||
//usage: "\n h Follow symlinks"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_TAR_NOPRESERVE_TIME(
|
||||
//usage: "\n -m Don't restore mtime"
|
||||
//usage: "\n m Don't restore mtime"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_TAR_FROM(
|
||||
//usage: "\n -T FILE File with names to include"
|
||||
//usage: "\n -X FILE File with glob patterns to exclude"
|
||||
//usage: IF_FEATURE_TAR_LONG_OPTIONS(
|
||||
//usage: "\n --exclude PATTERN Glob pattern to exclude"
|
||||
//usage: "\n exclude File to exclude"
|
||||
//usage: )
|
||||
//usage: "\n X File with names to exclude"
|
||||
//usage: "\n T File with names to include"
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define tar_example_usage
|
||||
@@ -835,7 +873,6 @@ enum {
|
||||
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
|
||||
IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
OPTBIT_STRIP_COMPONENTS,
|
||||
OPTBIT_NORECURSION,
|
||||
IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,)
|
||||
OPTBIT_NUMERIC_OWNER,
|
||||
@@ -860,13 +897,12 @@ enum {
|
||||
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
|
||||
OPT_XZ = IF_FEATURE_SEAMLESS_XZ( (1 << OPTBIT_XZ )) + 0, // J
|
||||
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
|
||||
OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
|
||||
OPT_STRIP_COMPONENTS = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_STRIP_COMPONENTS)) + 0, // strip-components
|
||||
OPT_NORECURSION = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION )) + 0, // no-recursion
|
||||
OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command
|
||||
OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
|
||||
OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
|
||||
OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite
|
||||
OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
|
||||
OPT_NORECURSION = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION )) + 0, // no-recursion
|
||||
OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command
|
||||
OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
|
||||
OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
|
||||
OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite
|
||||
|
||||
OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_XZ | OPT_COMPRESS),
|
||||
};
|
||||
@@ -910,7 +946,6 @@ static const char tar_longopts[] ALIGN1 =
|
||||
# if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
|
||||
"touch\0" No_argument "m"
|
||||
# endif
|
||||
"strip-components\0" Required_argument "\xf9"
|
||||
"no-recursion\0" No_argument "\xfa"
|
||||
# if ENABLE_FEATURE_TAR_TO_COMMAND
|
||||
"to-command\0" Required_argument "\xfb"
|
||||
@@ -927,11 +962,6 @@ static const char tar_longopts[] ALIGN1 =
|
||||
"exclude\0" Required_argument "\xff"
|
||||
# endif
|
||||
;
|
||||
# define GETOPT32 getopt32long
|
||||
# define LONGOPTS ,tar_longopts
|
||||
#else
|
||||
# define GETOPT32 getopt32
|
||||
# define LONGOPTS
|
||||
#endif
|
||||
|
||||
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@@ -945,7 +975,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||
llist_t *excludes = NULL;
|
||||
#endif
|
||||
INIT_G();
|
||||
|
||||
/* Initialise default values */
|
||||
tar_handle = init_handle();
|
||||
@@ -957,22 +986,25 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (getuid() != 0)
|
||||
tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM;
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
/* Lie to buildroot when it starts asking stupid questions. */
|
||||
if (argv[1] && strcmp(argv[1], "--version") == 0) {
|
||||
// Output of 'tar --version' examples:
|
||||
// tar (GNU tar) 1.15.1
|
||||
// tar (GNU tar) 1.25
|
||||
// bsdtar 2.8.3 - libarchive 2.8.3
|
||||
puts("tar (busybox) " BB_VER);
|
||||
return 0;
|
||||
}
|
||||
/* Prepend '-' to the first argument if required */
|
||||
opt_complementary = "--:" // first arg is options
|
||||
"tt:vv:" // count -t,-v
|
||||
IF_FEATURE_TAR_FROM("X::T::") // cumulative lists
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||
"\xff::" // cumulative lists for --exclude
|
||||
#endif
|
||||
if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0') {
|
||||
IF_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
|
||||
IF_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
|
||||
IF_NOT_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
applet_long_options = tar_longopts;
|
||||
#endif
|
||||
#if ENABLE_DESKTOP
|
||||
if (argv[1] && argv[1][0] != '-') {
|
||||
/* Compat:
|
||||
* 1st argument without dash handles options with parameters
|
||||
* differently from dashed one: it takes *next argv[i]*
|
||||
* as parameter even if there are more chars in 1st argument:
|
||||
* as paramenter even if there are more chars in 1st argument:
|
||||
* "tar fx TARFILE" - "x" is not taken as f's param
|
||||
* but is interpreted as -x option
|
||||
* "tar -xf TARFILE" - dashed equivalent of the above
|
||||
@@ -992,39 +1024,22 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
*f = 'f';
|
||||
}
|
||||
/* Prepend '-' to the first argument */
|
||||
argv[1] = xasprintf("-%s", argv[1]);
|
||||
}
|
||||
opt = GETOPT32(argv, "^"
|
||||
#endif
|
||||
opt = getopt32(argv,
|
||||
"txC:f:Oopvk"
|
||||
IF_FEATURE_TAR_CREATE( "ch" )
|
||||
IF_FEATURE_SEAMLESS_BZ2( "j" )
|
||||
IF_FEATURE_SEAMLESS_LZMA("a" )
|
||||
IF_FEATURE_TAR_FROM( "T:*X:*")
|
||||
IF_FEATURE_SEAMLESS_GZ( "z" )
|
||||
IF_FEATURE_SEAMLESS_XZ( "J" )
|
||||
IF_FEATURE_SEAMLESS_Z( "Z" )
|
||||
IF_FEATURE_TAR_CREATE( "ch" )
|
||||
IF_FEATURE_SEAMLESS_BZ2( "j" )
|
||||
IF_FEATURE_SEAMLESS_LZMA("a" )
|
||||
IF_FEATURE_TAR_FROM( "T:X:")
|
||||
IF_FEATURE_SEAMLESS_GZ( "z" )
|
||||
IF_FEATURE_SEAMLESS_XZ( "J" )
|
||||
IF_FEATURE_SEAMLESS_Z( "Z" )
|
||||
IF_FEATURE_TAR_NOPRESERVE_TIME("m")
|
||||
IF_FEATURE_TAR_LONG_OPTIONS("\xf9:") // --strip-components
|
||||
"\0"
|
||||
"tt:vv:" // count -t,-v
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||
"\xff::" // --exclude=PATTERN is a list
|
||||
#endif
|
||||
IF_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
|
||||
IF_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
|
||||
IF_NOT_FEATURE_TAR_CREATE("t--x:x--t") // mutually exclusive
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
":\xf9+" // --strip-components=NUM
|
||||
#endif
|
||||
LONGOPTS
|
||||
, &base_dir // -C dir
|
||||
, &tar_filename // -f filename
|
||||
IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
|
||||
IF_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
, &tar_handle->tar__strip_components // --strip-components
|
||||
#endif
|
||||
IF_FEATURE_TAR_TO_COMMAND(, &(tar_handle->tar__to_command)) // --to-command
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||
, &excludes // --exclude
|
||||
@@ -1032,49 +1047,11 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
, &verboseFlag // combined count for -t and -v
|
||||
, &verboseFlag // combined count for -t and -v
|
||||
);
|
||||
#if DBG_OPTION_PARSING
|
||||
bb_error_msg("opt: 0x%08x", opt);
|
||||
# define showopt(o) bb_error_msg("opt & %s(%x): %x", #o, o, opt & o);
|
||||
showopt(OPT_TEST );
|
||||
showopt(OPT_EXTRACT );
|
||||
showopt(OPT_BASEDIR );
|
||||
showopt(OPT_TARNAME );
|
||||
showopt(OPT_2STDOUT );
|
||||
showopt(OPT_NOPRESERVE_OWNER);
|
||||
showopt(OPT_P );
|
||||
showopt(OPT_VERBOSE );
|
||||
showopt(OPT_KEEP_OLD );
|
||||
showopt(OPT_CREATE );
|
||||
showopt(OPT_DEREFERENCE );
|
||||
showopt(OPT_BZIP2 );
|
||||
showopt(OPT_LZMA );
|
||||
showopt(OPT_INCLUDE_FROM );
|
||||
showopt(OPT_EXCLUDE_FROM );
|
||||
showopt(OPT_GZIP );
|
||||
showopt(OPT_XZ );
|
||||
showopt(OPT_COMPRESS );
|
||||
showopt(OPT_NOPRESERVE_TIME );
|
||||
showopt(OPT_STRIP_COMPONENTS);
|
||||
showopt(OPT_NORECURSION );
|
||||
showopt(OPT_2COMMAND );
|
||||
showopt(OPT_NUMERIC_OWNER );
|
||||
showopt(OPT_NOPRESERVE_PERM );
|
||||
showopt(OPT_OVERWRITE );
|
||||
showopt(OPT_ANY_COMPRESS );
|
||||
bb_error_msg("base_dir:'%s'", base_dir);
|
||||
bb_error_msg("tar_filename:'%s'", tar_filename);
|
||||
bb_error_msg("verboseFlag:%d", verboseFlag);
|
||||
bb_error_msg("tar_handle->tar__to_command:'%s'", tar_handle->tar__to_command);
|
||||
bb_error_msg("tar_handle->tar__strip_components:%u", tar_handle->tar__strip_components);
|
||||
return 0;
|
||||
# undef showopt
|
||||
#endif
|
||||
//bb_error_msg("opt:%08x", opt);
|
||||
argv += optind;
|
||||
|
||||
if (verboseFlag)
|
||||
tar_handle->action_header = header_verbose_list;
|
||||
if (verboseFlag == 1)
|
||||
tar_handle->action_header = header_list;
|
||||
if (verboseFlag) tar_handle->action_header = header_verbose_list;
|
||||
if (verboseFlag == 1) tar_handle->action_header = header_list;
|
||||
|
||||
if (opt & OPT_EXTRACT)
|
||||
tar_handle->action_data = data_extract_all;
|
||||
@@ -1160,7 +1137,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
&& flags == O_RDONLY
|
||||
&& !(opt & OPT_ANY_COMPRESS)
|
||||
) {
|
||||
tar_handle->src_fd = open_zipped(tar_filename, /*fail_if_not_compressed:*/ 0);
|
||||
tar_handle->src_fd = open_zipped(tar_filename);
|
||||
if (tar_handle->src_fd < 0)
|
||||
bb_perror_msg_and_die("can't open '%s'", tar_filename);
|
||||
} else {
|
||||
@@ -1172,64 +1149,48 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (base_dir)
|
||||
xchdir(base_dir);
|
||||
|
||||
#if ENABLE_FEATURE_TAR_CREATE
|
||||
//if (SEAMLESS_COMPRESSION || OPT_COMPRESS)
|
||||
// /* We need to know whether child (gzip/bzip/etc) exits abnormally */
|
||||
// signal(SIGCHLD, check_errors_in_children);
|
||||
|
||||
/* Create an archive */
|
||||
if (opt & OPT_CREATE) {
|
||||
struct TarBallInfo *tbInfo;
|
||||
# if SEAMLESS_COMPRESSION
|
||||
const char *zipMode = NULL;
|
||||
if (opt & OPT_COMPRESS)
|
||||
zipMode = "compress";
|
||||
if (opt & OPT_GZIP)
|
||||
zipMode = "gzip";
|
||||
if (opt & OPT_BZIP2)
|
||||
zipMode = "bzip2";
|
||||
if (opt & OPT_LZMA)
|
||||
zipMode = "lzma";
|
||||
if (opt & OPT_XZ)
|
||||
zipMode = "xz";
|
||||
# endif
|
||||
tbInfo = xzalloc(sizeof(*tbInfo));
|
||||
tbInfo->tarFd = tar_handle->src_fd;
|
||||
tbInfo->verboseFlag = verboseFlag;
|
||||
# if ENABLE_FEATURE_TAR_FROM
|
||||
tbInfo->excludeList = tar_handle->reject;
|
||||
# endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
int zipMode = 0;
|
||||
if (ENABLE_FEATURE_SEAMLESS_GZ && (opt & OPT_GZIP))
|
||||
zipMode = 1;
|
||||
if (ENABLE_FEATURE_SEAMLESS_BZ2 && (opt & OPT_BZIP2))
|
||||
zipMode = 2;
|
||||
#endif
|
||||
/* NB: writeTarFile() closes tar_handle->src_fd */
|
||||
return writeTarFile(tbInfo,
|
||||
return writeTarFile(tar_handle->src_fd, verboseFlag,
|
||||
(opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0)
|
||||
| (opt & OPT_NORECURSION ? 0 : ACTION_RECURSE),
|
||||
tar_handle->accept,
|
||||
zipMode);
|
||||
tar_handle->reject, zipMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (opt & OPT_ANY_COMPRESS) {
|
||||
USE_FOR_MMU(IF_DESKTOP(long long) int FAST_FUNC (*xformer)(transformer_state_t *xstate);)
|
||||
USE_FOR_MMU(IF_DESKTOP(long long) int FAST_FUNC (*xformer)(transformer_aux_data_t *aux, int src_fd, int dst_fd);)
|
||||
USE_FOR_NOMMU(const char *xformer_prog;)
|
||||
|
||||
if (opt & OPT_COMPRESS) {
|
||||
USE_FOR_MMU(IF_FEATURE_SEAMLESS_Z(xformer = unpack_Z_stream;))
|
||||
if (opt & OPT_COMPRESS)
|
||||
USE_FOR_MMU(xformer = unpack_Z_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "uncompress";)
|
||||
}
|
||||
if (opt & OPT_GZIP) {
|
||||
USE_FOR_MMU(IF_FEATURE_SEAMLESS_GZ(xformer = unpack_gz_stream;))
|
||||
if (opt & OPT_GZIP)
|
||||
USE_FOR_MMU(xformer = unpack_gz_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "gunzip";)
|
||||
}
|
||||
if (opt & OPT_BZIP2) {
|
||||
USE_FOR_MMU(IF_FEATURE_SEAMLESS_BZ2(xformer = unpack_bz2_stream;))
|
||||
if (opt & OPT_BZIP2)
|
||||
USE_FOR_MMU(xformer = unpack_bz2_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "bunzip2";)
|
||||
}
|
||||
if (opt & OPT_LZMA) {
|
||||
USE_FOR_MMU(IF_FEATURE_SEAMLESS_LZMA(xformer = unpack_lzma_stream;))
|
||||
if (opt & OPT_LZMA)
|
||||
USE_FOR_MMU(xformer = unpack_lzma_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "unlzma";)
|
||||
}
|
||||
if (opt & OPT_XZ) {
|
||||
USE_FOR_MMU(IF_FEATURE_SEAMLESS_XZ(xformer = unpack_xz_stream;))
|
||||
if (opt & OPT_XZ)
|
||||
USE_FOR_MMU(xformer = unpack_xz_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "unxz";)
|
||||
}
|
||||
|
||||
fork_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog);
|
||||
open_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog);
|
||||
/* Can't lseek over pipes */
|
||||
tar_handle->seek = seek_by_read;
|
||||
/*tar_handle->offset = 0; - already is */
|
||||
@@ -1244,8 +1205,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
while (get_header_tar(tar_handle) == EXIT_SUCCESS)
|
||||
bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */
|
||||
|
||||
create_symlinks_from_list(tar_handle->symlink_placeholders);
|
||||
|
||||
/* Check that every file that should have been extracted was */
|
||||
while (tar_handle->accept) {
|
||||
if (!find_list_entry(tar_handle->reject, tar_handle->accept->data)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Makes "symlink attack" tarball (needs GNU tar for --append)
|
||||
|
||||
true >anything.txt
|
||||
tar cvf tar_symlink_attack.tar anything.txt
|
||||
rm anything.txt
|
||||
|
||||
ln -s /tmp symlink
|
||||
tar --append -f tar_symlink_attack.tar symlink
|
||||
rm symlink
|
||||
|
||||
mkdir symlink
|
||||
echo BUG >symlink/bb_test_evilfile
|
||||
tar --append -f tar_symlink_attack.tar symlink/bb_test_evilfile
|
||||
rm symlink/bb_test_evilfile
|
||||
rmdir symlink
|
||||
+303
-570
File diff suppressed because it is too large.
Load diff
@@ -37,6 +37,7 @@ CONFIG_SELINUX=y
|
||||
CONFIG_FEATURE_PREFER_APPLETS=y
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
CONFIG_FEATURE_HAVE_RPC=y
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -117,6 +118,7 @@ CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_FEATURE_CPIO_P=y
|
||||
CONFIG_DPKG=y
|
||||
CONFIG_DPKG_DEB=y
|
||||
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
|
||||
@@ -264,6 +266,11 @@ CONFIG_YES=y
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
@@ -381,9 +388,9 @@ CONFIG_FEATURE_KILL_REMOVED=y
|
||||
CONFIG_FEATURE_KILL_DELAY=1
|
||||
CONFIG_FEATURE_INIT_SCTTY=y
|
||||
CONFIG_FEATURE_INIT_SYSLOG=y
|
||||
CONFIG_FEATURE_INIT_QUIET=y
|
||||
CONFIG_FEATURE_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_INIT_COREDUMPS=y
|
||||
CONFIG_LINUXRC=y
|
||||
CONFIG_FEATURE_INITRD=y
|
||||
CONFIG_HALT=y
|
||||
# CONFIG_FEATURE_CALL_TELINIT is not set
|
||||
CONFIG_TELINIT_PATH=""
|
||||
@@ -451,12 +458,15 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
CONFIG_FEATURE_INSMOD_TRY_MMAP=y
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
|
||||
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
|
||||
@@ -515,6 +525,7 @@ CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
|
||||
CONFIG_MKSWAP=y
|
||||
CONFIG_FEATURE_MKSWAP_UUID=y
|
||||
CONFIG_MORE=y
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_VOLUMEID=y
|
||||
CONFIG_FEATURE_VOLUMEID_EXT=y
|
||||
CONFIG_FEATURE_VOLUMEID_BTRFS=y
|
||||
@@ -749,6 +760,7 @@ CONFIG_TFTP_DEBUG=y
|
||||
CONFIG_TRACEROUTE=y
|
||||
CONFIG_TRACEROUTE6=y
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_USE_ICMP=y
|
||||
CONFIG_UDHCPD=y
|
||||
CONFIG_DHCPRELAY=y
|
||||
@@ -869,9 +881,9 @@ CONFIG_FEATURE_SH_IS_HUSH=y
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_ECHO is not set
|
||||
# CONFIG_ASH_PRINTF is not set
|
||||
# CONFIG_ASH_TEST is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
@@ -890,6 +902,7 @@ CONFIG_HUSH_FUNCTIONS=y
|
||||
CONFIG_HUSH_LOCAL=y
|
||||
CONFIG_HUSH_EXPORT_N=y
|
||||
CONFIG_HUSH_RANDOM_SUPPORT=y
|
||||
CONFIG_MSH=y
|
||||
CONFIG_SH_MATH_SUPPORT=y
|
||||
CONFIG_SH_MATH_SUPPORT_64=y
|
||||
CONFIG_FEATURE_SH_EXTRA_QUIET=y
|
||||
|
||||
@@ -47,6 +47,7 @@ CONFIG_FEATURE_PIDFILE=y
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
# CONFIG_FEATURE_SYSLOG is not set
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -129,6 +130,7 @@ CONFIG_FEATURE_SEAMLESS_Z=y
|
||||
# CONFIG_FEATURE_CPIO_P is not set
|
||||
# CONFIG_DPKG is not set
|
||||
# CONFIG_DPKG_DEB is not set
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
# CONFIG_GUNZIP is not set
|
||||
# CONFIG_GZIP is not set
|
||||
# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
|
||||
@@ -276,6 +278,7 @@ CONFIG_TRUE=y
|
||||
# CONFIG_WHOAMI is not set
|
||||
# CONFIG_YES is not set
|
||||
# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set
|
||||
# CONFIG_FEATURE_AUTOWIDTH is not set
|
||||
# CONFIG_FEATURE_HUMAN_READABLE is not set
|
||||
# CONFIG_FEATURE_MD5_SHA1_SUM_CHECK is not set
|
||||
|
||||
@@ -390,9 +393,9 @@ CONFIG_FEATURE_VI_MAX_LEN=0
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
# CONFIG_FEATURE_INIT_SCTTY is not set
|
||||
# CONFIG_FEATURE_INIT_SYSLOG is not set
|
||||
# CONFIG_FEATURE_INIT_QUIET is not set
|
||||
# CONFIG_FEATURE_EXTRA_QUIET is not set
|
||||
# CONFIG_FEATURE_INIT_COREDUMPS is not set
|
||||
# CONFIG_LINUXRC is not set
|
||||
# CONFIG_FEATURE_INITRD is not set
|
||||
# CONFIG_HALT is not set
|
||||
# CONFIG_FEATURE_CALL_TELINIT is not set
|
||||
CONFIG_TELINIT_PATH=""
|
||||
@@ -525,6 +528,7 @@ CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
|
||||
# CONFIG_MKSWAP is not set
|
||||
# CONFIG_FEATURE_MKSWAP_UUID is not set
|
||||
# CONFIG_MORE is not set
|
||||
# CONFIG_FEATURE_USE_TERMIOS is not set
|
||||
CONFIG_VOLUMEID=y
|
||||
# CONFIG_FEATURE_VOLUMEID_EXT is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_BTRFS is not set
|
||||
@@ -758,6 +762,7 @@ CONFIG_IFUPDOWN_IFSTATE_PATH=""
|
||||
# CONFIG_TRACEROUTE is not set
|
||||
# CONFIG_TRACEROUTE6 is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
# CONFIG_TUNCTL is not set
|
||||
# CONFIG_FEATURE_TUNCTL_UG is not set
|
||||
@@ -870,9 +875,9 @@ CONFIG_SV_DEFAULT_SERVICE_DIR=""
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_ECHO is not set
|
||||
# CONFIG_ASH_PRINTF is not set
|
||||
# CONFIG_ASH_TEST is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
@@ -897,6 +902,7 @@ CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_FEATURE_BASH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_BASH_IS_HUSH is not set
|
||||
CONFIG_FEATURE_BASH_IS_NONE=y
|
||||
# CONFIG_MSH is not set
|
||||
# CONFIG_SH_MATH_SUPPORT is not set
|
||||
# CONFIG_SH_MATH_SUPPORT_64 is not set
|
||||
# CONFIG_FEATURE_SH_EXTRA_QUIET is not set
|
||||
|
||||
@@ -46,6 +46,7 @@ CONFIG_FEATURE_SUID_CONFIG_QUIET=y
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
CONFIG_FEATURE_HAVE_RPC=y
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -127,6 +128,7 @@ CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_FEATURE_CPIO_P=y
|
||||
# CONFIG_DPKG is not set
|
||||
# CONFIG_DPKG_DEB is not set
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
|
||||
@@ -275,6 +277,11 @@ CONFIG_YES=y
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
@@ -398,9 +405,9 @@ CONFIG_FEATURE_USE_INITTAB=y
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
CONFIG_FEATURE_INIT_SCTTY=y
|
||||
CONFIG_FEATURE_INIT_SYSLOG=y
|
||||
CONFIG_FEATURE_INIT_QUIET=y
|
||||
CONFIG_FEATURE_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_INIT_COREDUMPS=y
|
||||
CONFIG_LINUXRC=y
|
||||
CONFIG_FEATURE_INITRD=y
|
||||
CONFIG_HALT=y
|
||||
# CONFIG_FEATURE_CALL_TELINIT is not set
|
||||
CONFIG_TELINIT_PATH=""
|
||||
@@ -466,12 +473,15 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
|
||||
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
|
||||
@@ -531,6 +541,7 @@ CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
|
||||
CONFIG_MKSWAP=y
|
||||
CONFIG_FEATURE_MKSWAP_UUID=y
|
||||
CONFIG_MORE=y
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_VOLUMEID=y
|
||||
CONFIG_FEATURE_VOLUMEID_EXT=y
|
||||
CONFIG_FEATURE_VOLUMEID_BTRFS=y
|
||||
@@ -767,6 +778,7 @@ CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
|
||||
CONFIG_TRACEROUTE=y
|
||||
CONFIG_TRACEROUTE6=y
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
CONFIG_TUNCTL=y
|
||||
CONFIG_FEATURE_TUNCTL_UG=y
|
||||
@@ -883,9 +895,9 @@ CONFIG_ASH_BASH_COMPAT=y
|
||||
CONFIG_ASH_JOB_CONTROL=y
|
||||
CONFIG_ASH_ALIAS=y
|
||||
CONFIG_ASH_GETOPTS=y
|
||||
CONFIG_ASH_ECHO=y
|
||||
CONFIG_ASH_PRINTF=y
|
||||
CONFIG_ASH_TEST=y
|
||||
CONFIG_ASH_BUILTIN_ECHO=y
|
||||
CONFIG_ASH_BUILTIN_PRINTF=y
|
||||
CONFIG_ASH_BUILTIN_TEST=y
|
||||
CONFIG_ASH_CMDCMD=y
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
|
||||
@@ -904,6 +916,7 @@ CONFIG_HUSH_FUNCTIONS=y
|
||||
CONFIG_HUSH_LOCAL=y
|
||||
CONFIG_HUSH_EXPORT_N=y
|
||||
CONFIG_HUSH_RANDOM_SUPPORT=y
|
||||
CONFIG_MSH=y
|
||||
CONFIG_SH_MATH_SUPPORT=y
|
||||
CONFIG_SH_MATH_SUPPORT_64=y
|
||||
CONFIG_FEATURE_SH_EXTRA_QUIET=y
|
||||
|
||||
@@ -49,6 +49,7 @@ CONFIG_LAST_SUPPORTED_WCHAR=0
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -88,11 +89,13 @@ CONFIG_PREFIX="./_install"
|
||||
#
|
||||
# Busybox Library Tuning
|
||||
#
|
||||
# CONFIG_FEATURE_SYSTEMD is not set
|
||||
# CONFIG_FEATURE_RTMINMAX is not set
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SMALL=1
|
||||
# CONFIG_FEATURE_FAST_TOP is not set
|
||||
# CONFIG_FEATURE_ETC_NETWORKS is not set
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
# CONFIG_FEATURE_EDITING is not set
|
||||
CONFIG_FEATURE_EDITING_MAX_LEN=0
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
@@ -132,6 +135,7 @@ CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_FEATURE_CPIO_P=y
|
||||
CONFIG_DPKG=y
|
||||
CONFIG_DPKG_DEB=y
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
|
||||
@@ -287,6 +291,11 @@ CONFIG_YES=y
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
@@ -415,9 +424,9 @@ CONFIG_FEATURE_USE_INITTAB=y
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
CONFIG_FEATURE_INIT_SCTTY=y
|
||||
CONFIG_FEATURE_INIT_SYSLOG=y
|
||||
CONFIG_FEATURE_INIT_QUIET=y
|
||||
CONFIG_FEATURE_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_INIT_COREDUMPS=y
|
||||
CONFIG_LINUXRC=y
|
||||
CONFIG_FEATURE_INITRD=y
|
||||
CONFIG_INIT_TERMINAL_TYPE="linux"
|
||||
CONFIG_MESG=y
|
||||
CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
|
||||
@@ -486,12 +495,15 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
|
||||
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
|
||||
@@ -803,6 +815,7 @@ CONFIG_TCPSVD=y
|
||||
# CONFIG_TRACEROUTE is not set
|
||||
# CONFIG_TRACEROUTE6 is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
CONFIG_TUNCTL=y
|
||||
CONFIG_FEATURE_TUNCTL_UG=y
|
||||
@@ -926,9 +939,9 @@ CONFIG_SOFTLIMIT=y
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_ECHO is not set
|
||||
# CONFIG_ASH_PRINTF is not set
|
||||
# CONFIG_ASH_TEST is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
@@ -951,6 +964,7 @@ CONFIG_CTTYHACK=y
|
||||
# CONFIG_HUSH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_HUSH_EXPORT_N is not set
|
||||
# CONFIG_HUSH_MODE_X is not set
|
||||
# CONFIG_MSH is not set
|
||||
# CONFIG_FEATURE_SH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -49,6 +49,7 @@ CONFIG_LAST_SUPPORTED_WCHAR=0
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -106,11 +107,13 @@ CONFIG_PREFIX="./_install"
|
||||
#
|
||||
# Busybox Library Tuning
|
||||
#
|
||||
# CONFIG_FEATURE_SYSTEMD is not set
|
||||
# CONFIG_FEATURE_RTMINMAX is not set
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SMALL=1
|
||||
# CONFIG_FEATURE_FAST_TOP is not set
|
||||
# CONFIG_FEATURE_ETC_NETWORKS is not set
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
# CONFIG_FEATURE_EDITING is not set
|
||||
CONFIG_FEATURE_EDITING_MAX_LEN=0
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
@@ -152,6 +155,7 @@ CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_FEATURE_CPIO_P=y
|
||||
CONFIG_DPKG=y
|
||||
CONFIG_DPKG_DEB=y
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
|
||||
@@ -310,6 +314,11 @@ CONFIG_YES=y
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
@@ -438,9 +447,9 @@ CONFIG_FEATURE_USE_INITTAB=y
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
CONFIG_FEATURE_INIT_SCTTY=y
|
||||
CONFIG_FEATURE_INIT_SYSLOG=y
|
||||
CONFIG_FEATURE_INIT_QUIET=y
|
||||
CONFIG_FEATURE_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_INIT_COREDUMPS=y
|
||||
CONFIG_LINUXRC=y
|
||||
CONFIG_FEATURE_INITRD=y
|
||||
CONFIG_INIT_TERMINAL_TYPE="linux"
|
||||
CONFIG_MESG=y
|
||||
CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
|
||||
@@ -510,12 +519,15 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
|
||||
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
|
||||
@@ -832,6 +844,7 @@ CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
|
||||
CONFIG_TRACEROUTE=y
|
||||
# CONFIG_TRACEROUTE6 is not set
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
CONFIG_TUNCTL=y
|
||||
CONFIG_FEATURE_TUNCTL_UG=y
|
||||
@@ -958,9 +971,9 @@ CONFIG_SOFTLIMIT=y
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_ECHO is not set
|
||||
# CONFIG_ASH_PRINTF is not set
|
||||
# CONFIG_ASH_TEST is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
@@ -983,6 +996,7 @@ CONFIG_CTTYHACK=y
|
||||
# CONFIG_HUSH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_HUSH_EXPORT_N is not set
|
||||
# CONFIG_HUSH_MODE_X is not set
|
||||
# CONFIG_MSH is not set
|
||||
# CONFIG_FEATURE_SH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
|
||||
+90
-119
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.24.0.git
|
||||
# Fri Sep 18 20:39:29 2015
|
||||
# Busybox version: 1.21.0.git
|
||||
# Mon May 28 21:51:18 2012
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -36,15 +36,12 @@ CONFIG_LAST_SUPPORTED_WCHAR=0
|
||||
# CONFIG_UNICODE_BIDI_SUPPORT is not set
|
||||
# CONFIG_UNICODE_NEUTRAL_TABLE is not set
|
||||
# CONFIG_UNICODE_PRESERVE_BROKEN is not set
|
||||
# CONFIG_PAM is not set
|
||||
CONFIG_FEATURE_USE_SENDFILE=y
|
||||
CONFIG_LONG_OPTS=y
|
||||
# CONFIG_FEATURE_DEVPTS is not set
|
||||
# CONFIG_FEATURE_CLEAN_UP is not set
|
||||
# CONFIG_FEATURE_UTMP is not set
|
||||
# CONFIG_FEATURE_WTMP is not set
|
||||
# CONFIG_FEATURE_PIDFILE is not set
|
||||
CONFIG_PID_FILE_PATH=""
|
||||
# CONFIG_FEATURE_SUID is not set
|
||||
# CONFIG_FEATURE_SUID_CONFIG is not set
|
||||
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
|
||||
@@ -52,6 +49,7 @@ CONFIG_PID_FILE_PATH=""
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -65,7 +63,7 @@ CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_LFS is not set
|
||||
CONFIG_CROSS_COMPILER_PREFIX="arm-linux-androideabi-"
|
||||
CONFIG_SYSROOT="/opt/android-ndk/platforms/android-9/arch-arm"
|
||||
CONFIG_EXTRA_CFLAGS="-DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -march=armv7-a -msoft-float -mfloat-abi=softfp -mfpu=neon -mthumb -mthumb-interwork -fpic -fno-short-enums -fgcse-after-reload -frename-registers -fuse-ld=bfd"
|
||||
CONFIG_EXTRA_CFLAGS="-DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -march=armv7-a -msoft-float -mfloat-abi=softfp -mfpu=neon -mthumb -mthumb-interwork -fpic -fno-short-enums -fgcse-after-reload -frename-registers"
|
||||
CONFIG_EXTRA_LDFLAGS="-Xlinker -z -Xlinker muldefs -nostdlib -Bdynamic -Xlinker -dynamic-linker -Xlinker /system/bin/linker -Xlinker -z -Xlinker nocopyreloc -Xlinker --no-undefined ${SYSROOT}/usr/lib/crtbegin_dynamic.o ${SYSROOT}/usr/lib/crtend_android.o"
|
||||
CONFIG_EXTRA_LDLIBS="dl m c gcc"
|
||||
|
||||
@@ -74,7 +72,6 @@ CONFIG_EXTRA_LDLIBS="dl m c gcc"
|
||||
#
|
||||
# CONFIG_DEBUG is not set
|
||||
# CONFIG_DEBUG_PESSIMIZE is not set
|
||||
# CONFIG_UNIT_TEST is not set
|
||||
# CONFIG_WERROR is not set
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
@@ -95,12 +92,13 @@ CONFIG_PREFIX="./_install"
|
||||
#
|
||||
# Busybox Library Tuning
|
||||
#
|
||||
# CONFIG_FEATURE_SYSTEMD is not set
|
||||
# CONFIG_FEATURE_RTMINMAX is not set
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SMALL=1
|
||||
CONFIG_SHA3_SMALL=1
|
||||
# CONFIG_FEATURE_FAST_TOP is not set
|
||||
# CONFIG_FEATURE_ETC_NETWORKS is not set
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
# CONFIG_FEATURE_EDITING is not set
|
||||
CONFIG_FEATURE_EDITING_MAX_LEN=0
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
@@ -135,28 +133,22 @@ CONFIG_FEATURE_SEAMLESS_Z=y
|
||||
CONFIG_AR=y
|
||||
CONFIG_FEATURE_AR_LONG_FILENAMES=y
|
||||
CONFIG_FEATURE_AR_CREATE=y
|
||||
CONFIG_UNCOMPRESS=y
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_BUNZIP2=y
|
||||
CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
CONFIG_LZMA=y
|
||||
CONFIG_UNXZ=y
|
||||
CONFIG_XZ=y
|
||||
CONFIG_BZIP2=y
|
||||
CONFIG_CPIO=y
|
||||
CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_FEATURE_CPIO_P=y
|
||||
CONFIG_DPKG=y
|
||||
CONFIG_DPKG_DEB=y
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
|
||||
CONFIG_GZIP_FAST=0
|
||||
# CONFIG_FEATURE_GZIP_LEVELS is not set
|
||||
CONFIG_LZOP=y
|
||||
CONFIG_LZOP_COMPR_HIGH=y
|
||||
CONFIG_RPM=y
|
||||
CONFIG_RPM2CPIO=y
|
||||
CONFIG_RPM=y
|
||||
CONFIG_TAR=y
|
||||
CONFIG_FEATURE_TAR_CREATE=y
|
||||
CONFIG_FEATURE_TAR_AUTODETECT=y
|
||||
@@ -169,6 +161,12 @@ CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
|
||||
CONFIG_FEATURE_TAR_UNAME_GNAME=y
|
||||
CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
|
||||
# CONFIG_FEATURE_TAR_SELINUX is not set
|
||||
CONFIG_UNCOMPRESS=y
|
||||
CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
CONFIG_LZMA=y
|
||||
CONFIG_UNXZ=y
|
||||
CONFIG_XZ=y
|
||||
CONFIG_UNZIP=y
|
||||
|
||||
#
|
||||
@@ -180,27 +178,16 @@ CONFIG_CAT=y
|
||||
# CONFIG_FEATURE_DATE_ISOFMT is not set
|
||||
# CONFIG_FEATURE_DATE_NANO is not set
|
||||
# CONFIG_FEATURE_DATE_COMPAT is not set
|
||||
CONFIG_DD=y
|
||||
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
|
||||
CONFIG_FEATURE_DD_THIRD_STATUS_LINE=y
|
||||
CONFIG_FEATURE_DD_IBS_OBS=y
|
||||
CONFIG_FEATURE_DD_STATUS=y
|
||||
# CONFIG_HOSTID is not set
|
||||
# CONFIG_ID is not set
|
||||
# CONFIG_GROUPS is not set
|
||||
CONFIG_SHUF=y
|
||||
CONFIG_SYNC=y
|
||||
# CONFIG_FEATURE_SYNC_FANCY is not set
|
||||
CONFIG_TEST=y
|
||||
CONFIG_FEATURE_TEST_64=y
|
||||
CONFIG_TOUCH=y
|
||||
# CONFIG_FEATURE_TOUCH_NODEREF is not set
|
||||
CONFIG_FEATURE_TOUCH_SUSV3=y
|
||||
CONFIG_TR=y
|
||||
CONFIG_FEATURE_TR_CLASSES=y
|
||||
CONFIG_FEATURE_TR_EQUIV=y
|
||||
CONFIG_TRUNCATE=y
|
||||
CONFIG_UNLINK=y
|
||||
CONFIG_BASE64=y
|
||||
# CONFIG_WHO is not set
|
||||
# CONFIG_USERS is not set
|
||||
@@ -216,6 +203,10 @@ CONFIG_COMM=y
|
||||
CONFIG_CP=y
|
||||
# CONFIG_FEATURE_CP_LONG_OPTIONS is not set
|
||||
CONFIG_CUT=y
|
||||
CONFIG_DD=y
|
||||
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
|
||||
CONFIG_FEATURE_DD_THIRD_STATUS_LINE=y
|
||||
CONFIG_FEATURE_DD_IBS_OBS=y
|
||||
# CONFIG_DF is not set
|
||||
# CONFIG_FEATURE_DF_FANCY is not set
|
||||
CONFIG_DIRNAME=y
|
||||
@@ -272,7 +263,6 @@ CONFIG_SEQ=y
|
||||
CONFIG_SHA1SUM=y
|
||||
CONFIG_SHA256SUM=y
|
||||
CONFIG_SHA512SUM=y
|
||||
CONFIG_SHA3SUM=y
|
||||
CONFIG_SLEEP=y
|
||||
CONFIG_FEATURE_FANCY_SLEEP=y
|
||||
CONFIG_FEATURE_FLOAT_SLEEP=y
|
||||
@@ -284,6 +274,7 @@ CONFIG_FEATURE_SPLIT_FANCY=y
|
||||
# CONFIG_FEATURE_STAT_FORMAT is not set
|
||||
CONFIG_STTY=y
|
||||
CONFIG_SUM=y
|
||||
CONFIG_SYNC=y
|
||||
CONFIG_TAC=y
|
||||
CONFIG_TAIL=y
|
||||
CONFIG_FEATURE_FANCY_TAIL=y
|
||||
@@ -292,7 +283,6 @@ CONFIG_FEATURE_TEE_USE_BLOCK_IO=y
|
||||
CONFIG_TRUE=y
|
||||
# CONFIG_TTY is not set
|
||||
CONFIG_UNAME=y
|
||||
CONFIG_UNAME_OSNAME="GNU/Linux"
|
||||
CONFIG_UNEXPAND=y
|
||||
# CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS is not set
|
||||
CONFIG_UNIQ=y
|
||||
@@ -304,23 +294,23 @@ CONFIG_FEATURE_WC_LARGE=y
|
||||
CONFIG_WHOAMI=y
|
||||
CONFIG_YES=y
|
||||
|
||||
#
|
||||
# Common options
|
||||
#
|
||||
CONFIG_FEATURE_VERBOSE=y
|
||||
|
||||
#
|
||||
# Common options for cp and mv
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
CONFIG_FEATURE_HUMAN_READABLE=y
|
||||
|
||||
#
|
||||
# Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum
|
||||
# Common options for md5sum, sha1sum, sha256sum, sha512sum
|
||||
#
|
||||
CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
|
||||
|
||||
@@ -366,16 +356,7 @@ CONFIG_WHICH=y
|
||||
#
|
||||
# Editors
|
||||
#
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_FEATURE_AWK_GNU_EXTENSIONS=y
|
||||
CONFIG_CMP=y
|
||||
CONFIG_DIFF=y
|
||||
# CONFIG_FEATURE_DIFF_LONG_OPTIONS is not set
|
||||
CONFIG_FEATURE_DIFF_DIR=y
|
||||
CONFIG_ED=y
|
||||
CONFIG_PATCH=y
|
||||
CONFIG_SED=y
|
||||
CONFIG_VI=y
|
||||
CONFIG_FEATURE_VI_MAX_LEN=4096
|
||||
CONFIG_FEATURE_VI_8BIT=y
|
||||
@@ -390,9 +371,14 @@ CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_ASK_TERMINAL=y
|
||||
CONFIG_FEATURE_VI_UNDO=y
|
||||
CONFIG_FEATURE_VI_UNDO_QUEUE=y
|
||||
CONFIG_FEATURE_VI_UNDO_QUEUE_MAX=256
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_CMP=y
|
||||
CONFIG_DIFF=y
|
||||
# CONFIG_FEATURE_DIFF_LONG_OPTIONS is not set
|
||||
CONFIG_FEATURE_DIFF_DIR=y
|
||||
CONFIG_ED=y
|
||||
CONFIG_SED=y
|
||||
CONFIG_FEATURE_ALLOW_EXEC=y
|
||||
|
||||
#
|
||||
@@ -409,7 +395,6 @@ CONFIG_FEATURE_FIND_MAXDEPTH=y
|
||||
CONFIG_FEATURE_FIND_NEWER=y
|
||||
CONFIG_FEATURE_FIND_INUM=y
|
||||
CONFIG_FEATURE_FIND_EXEC=y
|
||||
CONFIG_FEATURE_FIND_EXEC_PLUS=y
|
||||
CONFIG_FEATURE_FIND_USER=y
|
||||
CONFIG_FEATURE_FIND_GROUP=y
|
||||
CONFIG_FEATURE_FIND_NOT=y
|
||||
@@ -431,7 +416,6 @@ CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR=y
|
||||
|
||||
#
|
||||
# Init Utilities
|
||||
@@ -448,9 +432,9 @@ CONFIG_FEATURE_USE_INITTAB=y
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
CONFIG_FEATURE_INIT_SCTTY=y
|
||||
CONFIG_FEATURE_INIT_SYSLOG=y
|
||||
CONFIG_FEATURE_INIT_QUIET=y
|
||||
CONFIG_FEATURE_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_INIT_COREDUMPS=y
|
||||
CONFIG_LINUXRC=y
|
||||
CONFIG_FEATURE_INITRD=y
|
||||
CONFIG_INIT_TERMINAL_TYPE="linux"
|
||||
CONFIG_MESG=y
|
||||
CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
|
||||
@@ -463,12 +447,11 @@ CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
|
||||
# CONFIG_FEATURE_SHADOWPASSWDS is not set
|
||||
# CONFIG_USE_BB_PWD_GRP is not set
|
||||
# CONFIG_USE_BB_SHADOW is not set
|
||||
CONFIG_USE_BB_CRYPT=y
|
||||
CONFIG_USE_BB_CRYPT_SHA=y
|
||||
# CONFIG_USE_BB_CRYPT is not set
|
||||
# CONFIG_USE_BB_CRYPT_SHA is not set
|
||||
# CONFIG_ADDUSER is not set
|
||||
# CONFIG_FEATURE_ADDUSER_LONG_OPTIONS is not set
|
||||
# CONFIG_FEATURE_CHECK_NAMES is not set
|
||||
CONFIG_LAST_ID=0
|
||||
CONFIG_FIRST_SYSTEM_ID=0
|
||||
CONFIG_LAST_SYSTEM_ID=0
|
||||
# CONFIG_ADDGROUP is not set
|
||||
@@ -480,6 +463,7 @@ CONFIG_LAST_SYSTEM_ID=0
|
||||
# CONFIG_GETTY is not set
|
||||
# CONFIG_LOGIN is not set
|
||||
# CONFIG_LOGIN_SESSION_AS_CHILD is not set
|
||||
# CONFIG_PAM is not set
|
||||
# CONFIG_LOGIN_SCRIPTS is not set
|
||||
# CONFIG_FEATURE_NOLOGIN is not set
|
||||
# CONFIG_FEATURE_SECURETTY is not set
|
||||
@@ -521,12 +505,15 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
|
||||
CONFIG_DEFAULT_MODULES_DIR="/system/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
|
||||
@@ -534,26 +521,13 @@ CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
# Linux System Utilities
|
||||
#
|
||||
CONFIG_BLOCKDEV=y
|
||||
CONFIG_FATATTR=y
|
||||
CONFIG_FSTRIM=y
|
||||
# CONFIG_MDEV is not set
|
||||
# CONFIG_FEATURE_MDEV_CONF is not set
|
||||
# CONFIG_FEATURE_MDEV_RENAME is not set
|
||||
# CONFIG_FEATURE_MDEV_RENAME_REGEXP is not set
|
||||
# CONFIG_FEATURE_MDEV_EXEC is not set
|
||||
# CONFIG_FEATURE_MDEV_LOAD_FIRMWARE is not set
|
||||
# CONFIG_MOUNT is not set
|
||||
# CONFIG_FEATURE_MOUNT_FAKE is not set
|
||||
# CONFIG_FEATURE_MOUNT_VERBOSE is not set
|
||||
# CONFIG_FEATURE_MOUNT_HELPERS is not set
|
||||
# CONFIG_FEATURE_MOUNT_LABEL is not set
|
||||
# CONFIG_FEATURE_MOUNT_NFS is not set
|
||||
# CONFIG_FEATURE_MOUNT_CIFS is not set
|
||||
# CONFIG_FEATURE_MOUNT_FLAGS is not set
|
||||
# CONFIG_FEATURE_MOUNT_FSTAB is not set
|
||||
# CONFIG_FEATURE_MOUNT_OTHERTAB is not set
|
||||
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_REV=y
|
||||
CONFIG_UEVENT=y
|
||||
# CONFIG_ACPID is not set
|
||||
# CONFIG_FEATURE_ACPID_COMPAT is not set
|
||||
CONFIG_BLKID=y
|
||||
@@ -599,6 +573,15 @@ CONFIG_LSUSB=y
|
||||
CONFIG_MKSWAP=y
|
||||
CONFIG_FEATURE_MKSWAP_UUID=y
|
||||
CONFIG_MORE=y
|
||||
# CONFIG_MOUNT is not set
|
||||
# CONFIG_FEATURE_MOUNT_FAKE is not set
|
||||
# CONFIG_FEATURE_MOUNT_VERBOSE is not set
|
||||
# CONFIG_FEATURE_MOUNT_HELPERS is not set
|
||||
# CONFIG_FEATURE_MOUNT_LABEL is not set
|
||||
# CONFIG_FEATURE_MOUNT_NFS is not set
|
||||
# CONFIG_FEATURE_MOUNT_CIFS is not set
|
||||
# CONFIG_FEATURE_MOUNT_FLAGS is not set
|
||||
# CONFIG_FEATURE_MOUNT_FSTAB is not set
|
||||
# CONFIG_PIVOT_ROOT is not set
|
||||
# CONFIG_RDATE is not set
|
||||
CONFIG_RDEV=y
|
||||
@@ -608,7 +591,6 @@ CONFIG_SCRIPT=y
|
||||
CONFIG_SCRIPTREPLAY=y
|
||||
# CONFIG_SETARCH is not set
|
||||
# CONFIG_SWAPONOFF is not set
|
||||
# CONFIG_FEATURE_SWAPON_DISCARD is not set
|
||||
# CONFIG_FEATURE_SWAPON_PRI is not set
|
||||
CONFIG_SWITCH_ROOT=y
|
||||
# CONFIG_UMOUNT is not set
|
||||
@@ -621,45 +603,32 @@ CONFIG_VOLUMEID=y
|
||||
#
|
||||
# Filesystem/Volume identification
|
||||
#
|
||||
CONFIG_FEATURE_VOLUMEID_BTRFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_CRAMFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_EXFAT=y
|
||||
CONFIG_FEATURE_VOLUMEID_EXT=y
|
||||
CONFIG_FEATURE_VOLUMEID_F2FS=y
|
||||
CONFIG_FEATURE_VOLUMEID_BTRFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_REISERFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_FAT=y
|
||||
CONFIG_FEATURE_VOLUMEID_HFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_ISO9660=y
|
||||
CONFIG_FEATURE_VOLUMEID_JFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_LINUXRAID=y
|
||||
CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
|
||||
CONFIG_FEATURE_VOLUMEID_LUKS=y
|
||||
CONFIG_FEATURE_VOLUMEID_NILFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_NTFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_OCFS2=y
|
||||
CONFIG_FEATURE_VOLUMEID_REISERFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_ROMFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_SQUASHFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_SYSV=y
|
||||
CONFIG_FEATURE_VOLUMEID_UDF=y
|
||||
CONFIG_FEATURE_VOLUMEID_XFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_NTFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_ISO9660=y
|
||||
CONFIG_FEATURE_VOLUMEID_UDF=y
|
||||
CONFIG_FEATURE_VOLUMEID_LUKS=y
|
||||
CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
|
||||
CONFIG_FEATURE_VOLUMEID_CRAMFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_ROMFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_SYSV=y
|
||||
CONFIG_FEATURE_VOLUMEID_OCFS2=y
|
||||
CONFIG_FEATURE_VOLUMEID_LINUXRAID=y
|
||||
|
||||
#
|
||||
# Miscellaneous Utilities
|
||||
#
|
||||
# CONFIG_CONSPY is not set
|
||||
CONFIG_CROND=y
|
||||
CONFIG_FEATURE_CROND_D=y
|
||||
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
|
||||
CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
|
||||
CONFIG_I2CGET=y
|
||||
CONFIG_I2CSET=y
|
||||
CONFIG_I2CDUMP=y
|
||||
CONFIG_I2CDETECT=y
|
||||
CONFIG_LESS=y
|
||||
CONFIG_FEATURE_LESS_MAXLINES=9999999
|
||||
CONFIG_FEATURE_LESS_BRACKETS=y
|
||||
CONFIG_FEATURE_LESS_FLAGS=y
|
||||
CONFIG_FEATURE_LESS_TRUNCATE=y
|
||||
CONFIG_FEATURE_LESS_MARKS=y
|
||||
CONFIG_FEATURE_LESS_REGEXP=y
|
||||
CONFIG_FEATURE_LESS_WINCH=y
|
||||
@@ -668,17 +637,13 @@ CONFIG_FEATURE_LESS_DASHCMD=y
|
||||
CONFIG_FEATURE_LESS_LINENUMS=y
|
||||
# CONFIG_NANDWRITE is not set
|
||||
CONFIG_NANDDUMP=y
|
||||
# CONFIG_RFKILL is not set
|
||||
CONFIG_SETSERIAL=y
|
||||
# CONFIG_TASKSET is not set
|
||||
# CONFIG_FEATURE_TASKSET_FANCY is not set
|
||||
# CONFIG_UBIATTACH is not set
|
||||
# CONFIG_UBIDETACH is not set
|
||||
# CONFIG_UBIMKVOL is not set
|
||||
# CONFIG_UBIRMVOL is not set
|
||||
# CONFIG_UBIRSVOL is not set
|
||||
# CONFIG_UBIUPDATEVOL is not set
|
||||
# CONFIG_WALL is not set
|
||||
# CONFIG_ADJTIMEX is not set
|
||||
CONFIG_BBCONFIG=y
|
||||
CONFIG_FEATURE_COMPRESS_BBCONFIG=y
|
||||
@@ -694,6 +659,10 @@ CONFIG_FEATURE_CHAT_SEND_ESCAPES=y
|
||||
CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
|
||||
CONFIG_FEATURE_CHAT_CLR_ABORT=y
|
||||
CONFIG_CHRT=y
|
||||
CONFIG_CROND=y
|
||||
CONFIG_FEATURE_CROND_D=y
|
||||
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
|
||||
CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
|
||||
CONFIG_CRONTAB=y
|
||||
CONFIG_DC=y
|
||||
CONFIG_FEATURE_DC_LIBM=y
|
||||
@@ -731,14 +700,18 @@ CONFIG_MAN=y
|
||||
# CONFIG_MT is not set
|
||||
CONFIG_RAIDAUTORUN=y
|
||||
# CONFIG_READAHEAD is not set
|
||||
# CONFIG_RFKILL is not set
|
||||
# CONFIG_RUNLEVEL is not set
|
||||
CONFIG_RX=y
|
||||
CONFIG_SETSID=y
|
||||
CONFIG_STRINGS=y
|
||||
# CONFIG_TASKSET is not set
|
||||
# CONFIG_FEATURE_TASKSET_FANCY is not set
|
||||
CONFIG_TIME=y
|
||||
CONFIG_TIMEOUT=y
|
||||
CONFIG_TTYSIZE=y
|
||||
CONFIG_VOLNAME=y
|
||||
# CONFIG_WALL is not set
|
||||
# CONFIG_WATCHDOG is not set
|
||||
|
||||
#
|
||||
@@ -770,13 +743,13 @@ CONFIG_FAKEIDENTD=y
|
||||
CONFIG_FTPD=y
|
||||
CONFIG_FEATURE_FTP_WRITE=y
|
||||
CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST=y
|
||||
CONFIG_FEATURE_FTP_AUTHENTICATION=y
|
||||
CONFIG_FTPGET=y
|
||||
CONFIG_FTPPUT=y
|
||||
# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set
|
||||
# CONFIG_HOSTNAME is not set
|
||||
CONFIG_HTTPD=y
|
||||
CONFIG_FEATURE_HTTPD_RANGES=y
|
||||
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
|
||||
CONFIG_FEATURE_HTTPD_SETUID=y
|
||||
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
|
||||
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
|
||||
@@ -833,7 +806,6 @@ CONFIG_FEATURE_NETSTAT_PRG=y
|
||||
# CONFIG_NSLOOKUP is not set
|
||||
# CONFIG_NTPD is not set
|
||||
# CONFIG_FEATURE_NTPD_SERVER is not set
|
||||
# CONFIG_FEATURE_NTPD_CONF is not set
|
||||
CONFIG_PSCAN=y
|
||||
CONFIG_ROUTE=y
|
||||
# CONFIG_SLATTACH is not set
|
||||
@@ -858,6 +830,7 @@ CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
|
||||
CONFIG_TRACEROUTE=y
|
||||
# CONFIG_TRACEROUTE6 is not set
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
CONFIG_TUNCTL=y
|
||||
CONFIG_FEATURE_TUNCTL_UG=y
|
||||
@@ -870,7 +843,6 @@ CONFIG_FEATURE_TUNCTL_UG=y
|
||||
CONFIG_DHCPD_LEASES_FILE=""
|
||||
CONFIG_UDHCPC=y
|
||||
CONFIG_FEATURE_UDHCPC_ARPING=y
|
||||
CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y
|
||||
CONFIG_FEATURE_UDHCP_PORT=y
|
||||
CONFIG_UDHCP_DEBUG=9
|
||||
CONFIG_FEATURE_UDHCP_RFC3397=y
|
||||
@@ -917,13 +889,6 @@ CONFIG_POWERTOP=y
|
||||
CONFIG_PSTREE=y
|
||||
CONFIG_PWDX=y
|
||||
CONFIG_SMEMCAP=y
|
||||
CONFIG_TOP=y
|
||||
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
|
||||
CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
|
||||
CONFIG_FEATURE_TOP_SMP_CPU=y
|
||||
CONFIG_FEATURE_TOP_DECIMALS=y
|
||||
CONFIG_FEATURE_TOP_SMP_PROCESS=y
|
||||
CONFIG_FEATURE_TOPMEM=y
|
||||
CONFIG_UPTIME=y
|
||||
# CONFIG_FEATURE_UPTIME_UTMP_SUPPORT is not set
|
||||
CONFIG_FREE=y
|
||||
@@ -944,6 +909,13 @@ CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=y
|
||||
# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
|
||||
CONFIG_RENICE=y
|
||||
CONFIG_BB_SYSCTL=y
|
||||
CONFIG_TOP=y
|
||||
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
|
||||
CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
|
||||
CONFIG_FEATURE_TOP_SMP_CPU=y
|
||||
CONFIG_FEATURE_TOP_DECIMALS=y
|
||||
CONFIG_FEATURE_TOP_SMP_PROCESS=y
|
||||
CONFIG_FEATURE_TOPMEM=y
|
||||
CONFIG_FEATURE_SHOW_THREADS=y
|
||||
CONFIG_WATCH=y
|
||||
|
||||
@@ -986,10 +958,9 @@ CONFIG_SOFTLIMIT=y
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_ECHO is not set
|
||||
# CONFIG_ASH_PRINTF is not set
|
||||
# CONFIG_ASH_TEST is not set
|
||||
# CONFIG_ASH_HELP is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
@@ -1012,6 +983,7 @@ CONFIG_CTTYHACK=y
|
||||
# CONFIG_HUSH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_HUSH_EXPORT_N is not set
|
||||
# CONFIG_HUSH_MODE_X is not set
|
||||
# CONFIG_MSH is not set
|
||||
# CONFIG_FEATURE_SH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
@@ -1038,7 +1010,6 @@ CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0
|
||||
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
|
||||
# CONFIG_LOGREAD is not set
|
||||
# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set
|
||||
# CONFIG_FEATURE_KMSG_SYSLOG is not set
|
||||
CONFIG_KLOGD=y
|
||||
CONFIG_FEATURE_KLOGD_KLOGCTL=y
|
||||
# CONFIG_LOGGER is not set
|
||||
@@ -49,6 +49,7 @@ CONFIG_FEATURE_SUID=y
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -88,11 +89,13 @@ CONFIG_PREFIX="./_install"
|
||||
#
|
||||
# Busybox Library Tuning
|
||||
#
|
||||
# CONFIG_FEATURE_SYSTEMD is not set
|
||||
CONFIG_FEATURE_RTMINMAX=y
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SMALL=1
|
||||
CONFIG_FEATURE_FAST_TOP=y
|
||||
# CONFIG_FEATURE_ETC_NETWORKS is not set
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_FEATURE_EDITING=y
|
||||
CONFIG_FEATURE_EDITING_MAX_LEN=1024
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
@@ -132,6 +135,7 @@ CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_FEATURE_CPIO_P=y
|
||||
# CONFIG_DPKG is not set
|
||||
# CONFIG_DPKG_DEB is not set
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
|
||||
@@ -287,6 +291,11 @@ CONFIG_YES=y
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
@@ -415,9 +424,9 @@ CONFIG_TELINIT_PATH=""
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
# CONFIG_FEATURE_INIT_SCTTY is not set
|
||||
# CONFIG_FEATURE_INIT_SYSLOG is not set
|
||||
# CONFIG_FEATURE_INIT_QUIET is not set
|
||||
# CONFIG_FEATURE_EXTRA_QUIET is not set
|
||||
# CONFIG_FEATURE_INIT_COREDUMPS is not set
|
||||
# CONFIG_LINUXRC is not set
|
||||
# CONFIG_FEATURE_INITRD is not set
|
||||
CONFIG_INIT_TERMINAL_TYPE=""
|
||||
CONFIG_MESG=y
|
||||
CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
|
||||
@@ -806,6 +815,7 @@ CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
|
||||
# CONFIG_TRACEROUTE is not set
|
||||
# CONFIG_TRACEROUTE6 is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
# CONFIG_TUNCTL is not set
|
||||
# CONFIG_FEATURE_TUNCTL_UG is not set
|
||||
@@ -929,9 +939,9 @@ CONFIG_ASH_BASH_COMPAT=y
|
||||
CONFIG_ASH_JOB_CONTROL=y
|
||||
CONFIG_ASH_ALIAS=y
|
||||
CONFIG_ASH_GETOPTS=y
|
||||
CONFIG_ASH_ECHO=y
|
||||
CONFIG_ASH_PRINTF=y
|
||||
CONFIG_ASH_TEST=y
|
||||
CONFIG_ASH_BUILTIN_ECHO=y
|
||||
CONFIG_ASH_BUILTIN_PRINTF=y
|
||||
CONFIG_ASH_BUILTIN_TEST=y
|
||||
CONFIG_ASH_CMDCMD=y
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
|
||||
@@ -954,6 +964,7 @@ CONFIG_HUSH_LOCAL=y
|
||||
CONFIG_HUSH_RANDOM_SUPPORT=y
|
||||
CONFIG_HUSH_EXPORT_N=y
|
||||
CONFIG_HUSH_MODE_X=y
|
||||
# CONFIG_MSH is not set
|
||||
CONFIG_FEATURE_SH_IS_ASH=y
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
# CONFIG_FEATURE_SH_IS_NONE is not set
|
||||
|
||||
@@ -49,6 +49,7 @@ CONFIG_FEATURE_SUID_CONFIG_QUIET=y
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
@@ -92,6 +93,7 @@ CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SMALL=1
|
||||
CONFIG_FEATURE_FAST_TOP=y
|
||||
# CONFIG_FEATURE_ETC_NETWORKS is not set
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_FEATURE_EDITING=y
|
||||
CONFIG_FEATURE_EDITING_MAX_LEN=1024
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
@@ -130,6 +132,7 @@ CONFIG_CPIO=y
|
||||
# CONFIG_FEATURE_CPIO_P is not set
|
||||
# CONFIG_DPKG is not set
|
||||
# CONFIG_DPKG_DEB is not set
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
|
||||
@@ -285,6 +288,11 @@ CONFIG_YES=y
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
@@ -412,9 +420,9 @@ CONFIG_TELINIT_PATH=""
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
# CONFIG_FEATURE_INIT_SCTTY is not set
|
||||
# CONFIG_FEATURE_INIT_SYSLOG is not set
|
||||
# CONFIG_FEATURE_INIT_QUIET is not set
|
||||
# CONFIG_FEATURE_EXTRA_QUIET is not set
|
||||
# CONFIG_FEATURE_INIT_COREDUMPS is not set
|
||||
# CONFIG_LINUXRC is not set
|
||||
# CONFIG_FEATURE_INITRD is not set
|
||||
CONFIG_INIT_TERMINAL_TYPE=""
|
||||
# CONFIG_MESG is not set
|
||||
|
||||
@@ -787,6 +795,7 @@ CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
|
||||
# CONFIG_TRACEROUTE is not set
|
||||
# CONFIG_TRACEROUTE6 is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
# CONFIG_TUNCTL is not set
|
||||
# CONFIG_FEATURE_TUNCTL_UG is not set
|
||||
@@ -905,9 +914,9 @@ CONFIG_ASH=y
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_ECHO is not set
|
||||
# CONFIG_ASH_PRINTF is not set
|
||||
# CONFIG_ASH_TEST is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
@@ -930,6 +939,7 @@ CONFIG_ASH=y
|
||||
# CONFIG_HUSH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_HUSH_EXPORT_N is not set
|
||||
# CONFIG_HUSH_MODE_X is not set
|
||||
# CONFIG_MSH is not set
|
||||
CONFIG_FEATURE_SH_IS_ASH=y
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
# CONFIG_FEATURE_SH_IS_NONE is not set
|
||||
|
||||
@@ -7,4 +7,170 @@ menu "Console Utilities"
|
||||
|
||||
INSERT
|
||||
|
||||
config CHVT
|
||||
bool "chvt"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program is used to change to another terminal.
|
||||
Example: chvt 4 (change to terminal /dev/tty4)
|
||||
|
||||
config FGCONSOLE
|
||||
bool "fgconsole"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program prints active (foreground) console number.
|
||||
|
||||
config CLEAR
|
||||
bool "clear"
|
||||
default y
|
||||
help
|
||||
This program clears the terminal screen.
|
||||
|
||||
config DEALLOCVT
|
||||
bool "deallocvt"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program deallocates unused virtual consoles.
|
||||
|
||||
config DUMPKMAP
|
||||
bool "dumpkmap"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program dumps the kernel's keyboard translation table to
|
||||
stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
config KBD_MODE
|
||||
bool "kbd_mode"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program reports and sets keyboard mode.
|
||||
|
||||
config LOADFONT
|
||||
bool "loadfont"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program loads a console font from standard input.
|
||||
|
||||
config LOADKMAP
|
||||
bool "loadkmap"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program loads a keyboard translation table from
|
||||
standard input.
|
||||
|
||||
config OPENVT
|
||||
bool "openvt"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program is used to start a command on an unused
|
||||
virtual terminal.
|
||||
|
||||
config RESET
|
||||
bool "reset"
|
||||
default y
|
||||
help
|
||||
This program is used to reset the terminal screen, if it
|
||||
gets messed up.
|
||||
|
||||
config RESIZE
|
||||
bool "resize"
|
||||
default y
|
||||
help
|
||||
This program is used to (re)set the width and height of your current
|
||||
terminal.
|
||||
|
||||
config FEATURE_RESIZE_PRINT
|
||||
bool "Print environment variables"
|
||||
default y
|
||||
depends on RESIZE
|
||||
help
|
||||
Prints the newly set size (number of columns and rows) of
|
||||
the terminal.
|
||||
E.g.:
|
||||
COLUMNS=80;LINES=44;export COLUMNS LINES;
|
||||
|
||||
config SETCONSOLE
|
||||
bool "setconsole"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program redirects the system console to another device,
|
||||
like the current tty while logged in via telnet.
|
||||
|
||||
config FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on SETCONSOLE && LONG_OPTS
|
||||
help
|
||||
Support long options for the setconsole applet.
|
||||
|
||||
config SETFONT
|
||||
bool "setfont"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
Allows to load console screen map. Useful for i18n.
|
||||
|
||||
config FEATURE_SETFONT_TEXTUAL_MAP
|
||||
bool "Support reading textual screen maps"
|
||||
default y
|
||||
depends on SETFONT
|
||||
help
|
||||
Support reading textual screen maps.
|
||||
|
||||
config DEFAULT_SETFONT_DIR
|
||||
string "Default directory for console-tools files"
|
||||
default ""
|
||||
depends on SETFONT
|
||||
help
|
||||
Directory to use if setfont's params are simple filenames
|
||||
(not /path/to/file or ./file). Default is "" (no default directory).
|
||||
|
||||
config SETKEYCODES
|
||||
bool "setkeycodes"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program loads entries into the kernel's scancode-to-keycode
|
||||
map, allowing unusual keyboards to generate usable keycodes.
|
||||
|
||||
config SETLOGCONS
|
||||
bool "setlogcons"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
This program redirects the output console of kernel messages.
|
||||
|
||||
config SHOWKEY
|
||||
bool "showkey"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
Shows keys pressed.
|
||||
|
||||
comment "Common options for loadfont and setfont"
|
||||
depends on LOADFONT || SETFONT
|
||||
|
||||
config FEATURE_LOADFONT_PSF2
|
||||
bool "Support for PSF2 console fonts"
|
||||
default y
|
||||
depends on LOADFONT || SETFONT
|
||||
help
|
||||
Support PSF2 console fonts.
|
||||
|
||||
config FEATURE_LOADFONT_RAW
|
||||
bool "Support for old (raw) console fonts"
|
||||
default y
|
||||
depends on LOADFONT || SETFONT
|
||||
help
|
||||
Support old (raw) console fonts.
|
||||
|
||||
endmenu
|
||||
@@ -7,3 +7,19 @@
|
||||
lib-y:=
|
||||
|
||||
INSERT
|
||||
lib-$(CONFIG_CHVT) += chvt.o
|
||||
lib-$(CONFIG_FGCONSOLE) += fgconsole.o
|
||||
lib-$(CONFIG_CLEAR) += clear.o
|
||||
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
lib-$(CONFIG_SETCONSOLE) += setconsole.o
|
||||
lib-$(CONFIG_KBD_MODE) += kbd_mode.o
|
||||
lib-$(CONFIG_LOADFONT) += loadfont.o
|
||||
lib-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
lib-$(CONFIG_OPENVT) += openvt.o
|
||||
lib-$(CONFIG_RESET) += reset.o
|
||||
lib-$(CONFIG_RESIZE) += resize.o
|
||||
lib-$(CONFIG_SETFONT) += loadfont.o
|
||||
lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
lib-$(CONFIG_SETLOGCONS) += setlogcons.o
|
||||
lib-$(CONFIG_SHOWKEY) += showkey.o
|
||||
@@ -6,17 +6,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CHVT
|
||||
//config: bool "chvt (2 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program is used to change to another terminal.
|
||||
//config: Example: chvt 4 (change to terminal /dev/tty4)
|
||||
|
||||
//applet:IF_CHVT(APPLET_NOEXEC(chvt, chvt, BB_DIR_USR_BIN, BB_SUID_DROP, chvt))
|
||||
|
||||
//kbuild:lib-$(CONFIG_CHVT) += chvt.o
|
||||
|
||||
//usage:#define chvt_trivial_usage
|
||||
//usage: "N"
|
||||
|
||||
+1
-12
@@ -6,15 +6,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CLEAR
|
||||
//config: bool "clear (tiny)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: This program clears the terminal screen.
|
||||
|
||||
//applet:IF_CLEAR(APPLET_NOFORK(clear, clear, BB_DIR_USR_BIN, BB_SUID_DROP, clear))
|
||||
|
||||
//kbuild:lib-$(CONFIG_CLEAR) += clear.o
|
||||
|
||||
//usage:#define clear_trivial_usage
|
||||
//usage: ""
|
||||
@@ -23,11 +14,9 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#define ESC "\033"
|
||||
|
||||
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
/* home; clear to the end of screen */
|
||||
return full_write1_str(ESC"[H" ESC"[J") != 6;
|
||||
return full_write1_str("\033[H""\033[J") != 6;
|
||||
}
|
||||
@@ -7,16 +7,8 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config DEALLOCVT
|
||||
//config: bool "deallocvt (1.9 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program deallocates unused virtual consoles.
|
||||
|
||||
//applet:IF_DEALLOCVT(APPLET_NOEXEC(deallocvt, deallocvt, BB_DIR_USR_BIN, BB_SUID_DROP, deallocvt))
|
||||
|
||||
//kbuild:lib-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
/* no options, no getopt */
|
||||
|
||||
//usage:#define deallocvt_trivial_usage
|
||||
//usage: "[N]"
|
||||
|
||||
+17
-15
@@ -5,19 +5,9 @@
|
||||
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*
|
||||
*/
|
||||
//config:config DUMPKMAP
|
||||
//config: bool "dumpkmap (1.3 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program dumps the kernel's keyboard translation table to
|
||||
//config: stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
//applet:IF_DUMPKMAP(APPLET_NOEXEC(dumpkmap, dumpkmap, BB_DIR_BIN, BB_SUID_DROP, dumpkmap))
|
||||
/* bb_common_bufsiz1 usage here is safe wrt NOEXEC: not expecting it to be zeroed. */
|
||||
|
||||
//kbuild:lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
/* no options, no getopt */
|
||||
|
||||
//usage:#define dumpkmap_trivial_usage
|
||||
//usage: "> keymap"
|
||||
@@ -28,7 +18,6 @@
|
||||
//usage: "$ dumpkmap > keymap\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
@@ -47,6 +36,7 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
#define flags bb_common_bufsiz1
|
||||
|
||||
/* When user accidentally runs "dumpkmap FILE"
|
||||
* instead of "dumpkmap >FILE", we'd dump binary stuff to tty.
|
||||
@@ -58,8 +48,19 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
#define flags bb_common_bufsiz1
|
||||
setup_common_bufsiz();
|
||||
#if 0
|
||||
write(STDOUT_FILENO, "bkeymap", 7);
|
||||
/* Here we want to set everything to 0 except for indexes:
|
||||
* [0-2] [4-6] [8-10] [12]
|
||||
*/
|
||||
/*memset(flags, 0x00, MAX_NR_KEYMAPS); - already is */
|
||||
memset(flags, 0x01, 13);
|
||||
flags[3] = flags[7] = flags[11] = 0;
|
||||
/* dump flags */
|
||||
write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
#define flags7 flags
|
||||
#else
|
||||
/* Same effect */
|
||||
/* 0 1 2 3 4 5 6 7 8 9 a b c=12 */
|
||||
memcpy(flags, "bkeymap\1\1\1\0\1\1\1\0\1\1\1\0\1",
|
||||
/* Can use sizeof, or sizeof-1. sizeof is even, using that */
|
||||
@@ -67,6 +68,7 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
);
|
||||
write(STDOUT_FILENO, flags, 7 + MAX_NR_KEYMAPS);
|
||||
#define flags7 (flags + 7)
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 13; i++) {
|
||||
if (flags7[i]) {
|
||||
|
||||
@@ -6,16 +6,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config FGCONSOLE
|
||||
//config: bool "fgconsole (1.6 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program prints active (foreground) console number.
|
||||
|
||||
//applet:IF_FGCONSOLE(APPLET_NOEXEC(fgconsole, fgconsole, BB_DIR_USR_BIN, BB_SUID_DROP, fgconsole))
|
||||
|
||||
//kbuild:lib-$(CONFIG_FGCONSOLE) += fgconsole.o
|
||||
|
||||
//usage:#define fgconsole_trivial_usage
|
||||
//usage: ""
|
||||
|
||||
@@ -8,26 +8,16 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config KBD_MODE
|
||||
//config: bool "kbd_mode (4 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program reports and sets keyboard mode.
|
||||
|
||||
//applet:IF_KBD_MODE(APPLET_NOEXEC(kbd_mode, kbd_mode, BB_DIR_BIN, BB_SUID_DROP, kbd_mode))
|
||||
|
||||
//kbuild:lib-$(CONFIG_KBD_MODE) += kbd_mode.o
|
||||
|
||||
//usage:#define kbd_mode_trivial_usage
|
||||
//usage: "[-a|k|s|u] [-C TTY]"
|
||||
//usage:#define kbd_mode_full_usage "\n\n"
|
||||
//usage: "Report or set VT console keyboard mode\n"
|
||||
//usage: "Report or set the keyboard mode\n"
|
||||
//usage: "\n -a Default (ASCII)"
|
||||
//usage: "\n -k Medium-raw (keycode)"
|
||||
//usage: "\n -k Medium-raw (keyboard)"
|
||||
//usage: "\n -s Raw (scancode)"
|
||||
//usage: "\n -u Unicode (utf-8)"
|
||||
//usage: "\n -C TTY Affect TTY"
|
||||
//usage: "\n -C TTY Affect TTY instead of /dev/tty"
|
||||
|
||||
#include "libbb.h"
|
||||
#include <linux/kd.h>
|
||||
@@ -43,20 +33,11 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
|
||||
};
|
||||
int fd;
|
||||
unsigned opt;
|
||||
const char *tty_name;
|
||||
const char *tty_name = CURRENT_TTY;
|
||||
|
||||
opt = getopt32(argv, "sakuC:", &tty_name);
|
||||
if (opt & 0x10) {
|
||||
opt &= 0xf; /* clear -C bit, see (*) */
|
||||
fd = xopen_nonblocking(tty_name);
|
||||
} else {
|
||||
/* kbd-2.0.3 tries in sequence:
|
||||
* fd#0, /dev/tty, /dev/tty0.
|
||||
* get_console_fd_or_die: /dev/console, /dev/tty0, /dev/tty.
|
||||
* kbd-2.0.3 checks KDGKBTYPE, get_console_fd_or_die checks too.
|
||||
*/
|
||||
fd = get_console_fd_or_die();
|
||||
}
|
||||
fd = xopen_nonblocking(tty_name);
|
||||
opt &= 0xf; /* clear -C bit, see (*) */
|
||||
|
||||
if (!opt) { /* print current setting */
|
||||
const char *mode = "unknown";
|
||||
@@ -71,19 +52,9 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
|
||||
mode = "mediumraw (keycode)";
|
||||
else if (m == K_UNICODE)
|
||||
mode = "Unicode (UTF-8)";
|
||||
else if (m == 4 /*K_OFF*/) /* kbd-2.0.3 does not show this mode, says "unknown" */
|
||||
mode = "off";
|
||||
printf("The keyboard is in %s mode\n", mode);
|
||||
} else {
|
||||
/* here we depend on specific bits assigned to options (*)
|
||||
* KDSKBMODE constants have these values:
|
||||
* #define K_RAW 0x00
|
||||
* #define K_XLATE 0x01
|
||||
* #define K_MEDIUMRAW 0x02
|
||||
* #define K_UNICODE 0x03
|
||||
* #define K_OFF 0x04
|
||||
* (looks like "-ak" together would cause the same effect as -u)
|
||||
*/
|
||||
/* here we depend on specific bits assigned to options (*) */
|
||||
opt = opt & UNICODE ? 3 : opt >> 1;
|
||||
/* double cast prevents warnings about widening conversion */
|
||||
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
|
||||
|
||||
+32
-75
@@ -9,53 +9,25 @@
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config LOADFONT
|
||||
//config: bool "loadfont (5.4 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program loads a console font from standard input.
|
||||
//config:
|
||||
//config:config SETFONT
|
||||
//config: bool "setfont (26 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Allows to load console screen map. Useful for i18n.
|
||||
//config:
|
||||
//config:config FEATURE_SETFONT_TEXTUAL_MAP
|
||||
//config: bool "Support reading textual screen maps"
|
||||
//config: default y
|
||||
//config: depends on SETFONT
|
||||
//config: help
|
||||
//config: Support reading textual screen maps.
|
||||
//config:
|
||||
//config:config DEFAULT_SETFONT_DIR
|
||||
//config: string "Default directory for console-tools files"
|
||||
//config: default ""
|
||||
//config: depends on SETFONT
|
||||
//config: help
|
||||
//config: Directory to use if setfont's params are simple filenames
|
||||
//config: (not /path/to/file or ./file). Default is "" (no default directory).
|
||||
//config:
|
||||
//config:comment "Common options for loadfont and setfont"
|
||||
//config: depends on LOADFONT || SETFONT
|
||||
//config:
|
||||
//config:config FEATURE_LOADFONT_PSF2
|
||||
//config: bool "Support PSF2 console fonts"
|
||||
//config: default y
|
||||
//config: depends on LOADFONT || SETFONT
|
||||
//config:
|
||||
//config:config FEATURE_LOADFONT_RAW
|
||||
//config: bool "Support old (raw) console fonts"
|
||||
//config: default y
|
||||
//config: depends on LOADFONT || SETFONT
|
||||
|
||||
//applet:IF_LOADFONT(APPLET_NOEXEC(loadfont, loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP, loadfont))
|
||||
//applet:IF_SETFONT(APPLET_NOEXEC(setfont, setfont, BB_DIR_USR_SBIN, BB_SUID_DROP, setfont))
|
||||
|
||||
//kbuild:lib-$(CONFIG_LOADFONT) += loadfont.o
|
||||
//kbuild:lib-$(CONFIG_SETFONT) += loadfont.o
|
||||
//usage:#define loadfont_trivial_usage
|
||||
//usage: "< font"
|
||||
//usage:#define loadfont_full_usage "\n\n"
|
||||
//usage: "Load a console font from stdin"
|
||||
/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
|
||||
//usage:
|
||||
//usage:#define loadfont_example_usage
|
||||
//usage: "$ loadfont < /etc/i18n/fontname\n"
|
||||
//usage:
|
||||
//usage:#define setfont_trivial_usage
|
||||
//usage: "FONT [-m MAPFILE] [-C TTY]"
|
||||
//usage:#define setfont_full_usage "\n\n"
|
||||
//usage: "Load a console font\n"
|
||||
//usage: "\n -m MAPFILE Load console screen map"
|
||||
//usage: "\n -C TTY Affect TTY instead of /dev/tty"
|
||||
//usage:
|
||||
//usage:#define setfont_example_usage
|
||||
//usage: "$ setfont -m koi8-r /etc/i18n/fontname\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include <sys/kd.h>
|
||||
@@ -333,14 +305,6 @@ static void do_load(int fd, unsigned char *buffer, size_t len)
|
||||
|
||||
|
||||
#if ENABLE_LOADFONT
|
||||
//usage:#define loadfont_trivial_usage
|
||||
//usage: "< font"
|
||||
//usage:#define loadfont_full_usage "\n\n"
|
||||
//usage: "Load a console font from stdin"
|
||||
/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
|
||||
//usage:
|
||||
//usage:#define loadfont_example_usage
|
||||
//usage: "$ loadfont < /etc/i18n/fontname\n"
|
||||
int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
@@ -348,16 +312,15 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
unsigned char *buffer;
|
||||
|
||||
// no arguments allowed!
|
||||
getopt32(argv, "^" "" "\0" "=0");
|
||||
opt_complementary = "=0";
|
||||
getopt32(argv, "");
|
||||
|
||||
/*
|
||||
* We used to look at the length of the input file
|
||||
* with stat(); now that we accept compressed files,
|
||||
* just read the entire file.
|
||||
* Len was 32k, but latarcyrheb-sun32.psfu is 34377 bytes
|
||||
* (it has largish Unicode map).
|
||||
*/
|
||||
len = 128*1024;
|
||||
len = 32*1024; // can't be larger
|
||||
buffer = xmalloc_read(STDIN_FILENO, &len);
|
||||
// xmalloc_open_zipped_read_close(filename, &len);
|
||||
if (!buffer)
|
||||
@@ -368,9 +331,11 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if ENABLE_SETFONT
|
||||
/* kbd-1.12:
|
||||
|
||||
/*
|
||||
kbd-1.12:
|
||||
|
||||
setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
|
||||
[-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console]
|
||||
[-hNN] [-v] [-V]
|
||||
@@ -400,17 +365,8 @@ setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
|
||||
-v Verbose
|
||||
-V Version
|
||||
*/
|
||||
//usage:#define setfont_trivial_usage
|
||||
//usage: "FONT [-m MAPFILE] [-C TTY]"
|
||||
//usage:#define setfont_full_usage "\n\n"
|
||||
//usage: "Load a console font\n"
|
||||
//usage: "\n -m MAPFILE Load console screen map"
|
||||
//usage: "\n -C TTY Affect TTY instead of /dev/tty"
|
||||
//usage:
|
||||
//usage:#define setfont_example_usage
|
||||
//usage: "$ setfont -m koi8-r /etc/i18n/fontname\n"
|
||||
|
||||
# if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
static int ctoi(char *s)
|
||||
{
|
||||
if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0')
|
||||
@@ -424,7 +380,7 @@ static int ctoi(char *s)
|
||||
return -1;
|
||||
return xstrtoul(s, 0);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
@@ -436,7 +392,8 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
char *mapfilename;
|
||||
const char *tty_name = CURRENT_TTY;
|
||||
|
||||
opts = getopt32(argv, "^" "m:C:" "\0" "=1", &mapfilename, &tty_name);
|
||||
opt_complementary = "=1";
|
||||
opts = getopt32(argv, "m:C:", &mapfilename, &tty_name);
|
||||
argv += optind;
|
||||
|
||||
fd = xopen_nonblocking(tty_name);
|
||||
@@ -448,7 +405,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
}
|
||||
// load font
|
||||
len = 128*1024;
|
||||
len = 32*1024; // can't be larger
|
||||
buffer = xmalloc_open_zipped_read_close(*argv, &len);
|
||||
if (!buffer)
|
||||
bb_simple_perror_msg_and_die(*argv);
|
||||
@@ -474,7 +431,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (len == 2*E_TABSZ)
|
||||
mode = PIO_UNISCRNMAP;
|
||||
}
|
||||
# if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
// assume textual Unicode console maps:
|
||||
// 0x00 U+0000 # NULL (NUL)
|
||||
// 0x01 U+0001 # START OF HEADING (SOH)
|
||||
@@ -521,7 +478,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#undef unicodes
|
||||
}
|
||||
# endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
#endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
|
||||
// do set screen map
|
||||
xioctl(fd, mode, map);
|
||||
|
||||
@@ -6,24 +6,12 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config LOADKMAP
|
||||
//config: bool "loadkmap (1.5 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program loads a keyboard translation table from
|
||||
//config: standard input.
|
||||
|
||||
//applet:IF_LOADKMAP(APPLET_NOEXEC(loadkmap, loadkmap, BB_DIR_SBIN, BB_SUID_DROP, loadkmap))
|
||||
|
||||
//kbuild:lib-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
|
||||
//usage:#define loadkmap_trivial_usage
|
||||
//usage: "< keymap"
|
||||
//usage:#define loadkmap_full_usage "\n\n"
|
||||
//usage: "Load a binary keyboard translation table from stdin"
|
||||
////usage: "\n"
|
||||
////usage: "\n -C TTY Affect TTY instead of /dev/tty"
|
||||
//usage: "Load a binary keyboard translation table from stdin\n"
|
||||
/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
|
||||
//usage:
|
||||
//usage:#define loadkmap_example_usage
|
||||
//usage: "$ loadkmap < /etc/i18n/lang-keymap\n"
|
||||
@@ -68,7 +56,7 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
*/
|
||||
|
||||
xread(STDIN_FILENO, flags, 7);
|
||||
if (!is_prefixed_with(flags, BINARY_KEYMAP_MAGIC))
|
||||
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
|
||||
bb_error_msg_and_die("not a valid binary keymap");
|
||||
|
||||
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
+2
-13
@@ -7,17 +7,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config OPENVT
|
||||
//config: bool "openvt (7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program is used to start a command on an unused
|
||||
//config: virtual terminal.
|
||||
|
||||
//applet:IF_OPENVT(APPLET(openvt, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_OPENVT) += openvt.o
|
||||
|
||||
//usage:#define openvt_trivial_usage
|
||||
//usage: "[-c N] [-sw] [PROG ARGS]"
|
||||
@@ -99,7 +88,7 @@ static int find_free_vtno(void)
|
||||
/*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_CLOSE_EXTRA_FDS
|
||||
// Not really needed, grep for DAEMON_ONLY_SANITIZE
|
||||
// if (fd > 2)
|
||||
// close(fd);
|
||||
return vtno;
|
||||
@@ -155,7 +144,7 @@ int openvt_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* Grab new VT */
|
||||
sprintf(vtname, VC_FORMAT, vtno);
|
||||
/* (Try to) clean up stray open fds above fd 2 */
|
||||
bb_daemon_helper(DAEMON_CLOSE_EXTRA_FDS);
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL);
|
||||
close(STDIN_FILENO);
|
||||
/*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */
|
||||
xopen(vtname, O_RDWR);
|
||||
|
||||
+4
-15
@@ -7,24 +7,15 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RESET
|
||||
//config: bool "reset (275 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: This program is used to reset the terminal screen, if it
|
||||
//config: gets messed up.
|
||||
|
||||
//applet:IF_RESET(APPLET_NOEXEC(reset, reset, BB_DIR_USR_BIN, BB_SUID_DROP, reset))
|
||||
|
||||
//kbuild:lib-$(CONFIG_RESET) += reset.o
|
||||
/* BTW, which "standard" package has this utility? It doesn't seem
|
||||
* to be ncurses, coreutils, console-tools... then what? */
|
||||
|
||||
//usage:#define reset_trivial_usage
|
||||
//usage: ""
|
||||
//usage:#define reset_full_usage "\n\n"
|
||||
//usage: "Reset the screen"
|
||||
|
||||
/* "Standard" version of this tool is in ncurses package */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#define ESC "\033"
|
||||
@@ -46,18 +37,16 @@ int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
/* See 'man 4 console_codes' for details:
|
||||
* "ESC c" -- Reset
|
||||
* "ESC ( B" -- Select G0 Character Set (B = US)
|
||||
* "ESC [ m" -- Reset all display attributes
|
||||
* "ESC [ 0 m" -- Reset all display attributes
|
||||
* "ESC [ J" -- Erase to the end of screen
|
||||
* "ESC [ ? 25 h" -- Make cursor visible
|
||||
*/
|
||||
printf(ESC"c" ESC"(B" ESC"[m" ESC"[J" ESC"[?25h");
|
||||
printf(ESC"c" ESC"(B" ESC"[0m" ESC"[J" ESC"[?25h");
|
||||
/* http://bugs.busybox.net/view.php?id=1414:
|
||||
* people want it to reset echo etc: */
|
||||
#if ENABLE_STTY
|
||||
return stty_main(2, (char**)args);
|
||||
#else
|
||||
/* Make sure stdout gets drained before we execvp */
|
||||
fflush_all();
|
||||
execvp("stty", (char**)args);
|
||||
#endif
|
||||
}
|
||||
|
||||
+2
-27
@@ -6,27 +6,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RESIZE
|
||||
//config: bool "resize (756 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: This program is used to (re)set the width and height of your current
|
||||
//config: terminal.
|
||||
//config:
|
||||
//config:config FEATURE_RESIZE_PRINT
|
||||
//config: bool "Print environment variables"
|
||||
//config: default y
|
||||
//config: depends on RESIZE
|
||||
//config: help
|
||||
//config: Prints the newly set size (number of columns and rows) of
|
||||
//config: the terminal.
|
||||
//config: E.g.:
|
||||
//config: COLUMNS=80;LINES=44;export COLUMNS LINES;
|
||||
|
||||
//applet:IF_RESIZE(APPLET_NOEXEC(resize, resize, BB_DIR_USR_BIN, BB_SUID_DROP, resize))
|
||||
/* bb_common_bufsiz1 usage here is safe wrt NOEXEC: not expecting it to be zeroed. */
|
||||
|
||||
//kbuild:lib-$(CONFIG_RESIZE) += resize.o
|
||||
/* no options, no getopt */
|
||||
|
||||
//usage:#define resize_trivial_usage
|
||||
//usage: ""
|
||||
@@ -34,12 +14,10 @@
|
||||
//usage: "Resize the screen"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
#define ESC "\033"
|
||||
|
||||
#define old_termios_p ((struct termios*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { setup_common_bufsiz(); } while (0)
|
||||
#define old_termios_p ((struct termios*)&bb_common_bufsiz1)
|
||||
|
||||
static void
|
||||
onintr(int sig UNUSED_PARAM)
|
||||
@@ -55,8 +33,6 @@ int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
struct winsize w = { 0, 0, 0, 0 };
|
||||
int ret;
|
||||
|
||||
INIT_G();
|
||||
|
||||
/* We use _stderr_ in order to make resize usable
|
||||
* in shell backticks (those redirect stdout away from tty).
|
||||
* NB: other versions of resize open "/dev/tty"
|
||||
@@ -64,7 +40,6 @@ int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
*/
|
||||
|
||||
tcgetattr(STDERR_FILENO, old_termios_p); /* fiddle echo */
|
||||
//TODO: die if the above fails?
|
||||
memcpy(&new, old_termios_p, sizeof(new));
|
||||
new.c_cflag |= (CLOCAL | CREAD);
|
||||
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
|
||||
+15
-35
@@ -1,42 +1,18 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* setconsole.c - redirect system console output
|
||||
* setconsole.c - redirect system console output
|
||||
*
|
||||
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
|
||||
* Copyright (C) 2008 Bernhard Reutner-Fischer
|
||||
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
|
||||
* Copyright (C) 2008 Bernhard Reutner-Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SETCONSOLE
|
||||
//config: bool "setconsole (3.7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Redirect writes to /dev/console to another device,
|
||||
//config: like the current tty while logged in via telnet.
|
||||
//config: This does not redirect kernel log, only writes
|
||||
//config: from user space.
|
||||
//config:
|
||||
//config:config FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on SETCONSOLE && LONG_OPTS
|
||||
|
||||
//applet:IF_SETCONSOLE(APPLET_NOEXEC(setconsole, setconsole, BB_DIR_SBIN, BB_SUID_DROP, setconsole))
|
||||
|
||||
//kbuild:lib-$(CONFIG_SETCONSOLE) += setconsole.o
|
||||
|
||||
//usage:#define setconsole_trivial_usage
|
||||
//usage: "[-r] [DEVICE]"
|
||||
//usage: "[-r" IF_FEATURE_SETCONSOLE_LONG_OPTIONS("|--reset") "] [DEVICE]"
|
||||
//usage:#define setconsole_full_usage "\n\n"
|
||||
//usage: "Make writes to /dev/console appear on DEVICE (default: /dev/tty)."
|
||||
//usage: "\n""Does not redirect kernel log output or reads from /dev/console."
|
||||
//usage: "\n"
|
||||
//usage: "\n"" -r Reset: writes to /dev/console go to kernel log tty(s)"
|
||||
|
||||
/* It was a bbox-specific invention, but SUSE does have a similar utility.
|
||||
* SUSE has no -r option, though.
|
||||
*/
|
||||
//usage: "Redirect system console output to DEVICE (default: /dev/tty)\n"
|
||||
//usage: "\n -r Reset output to /dev/console"
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -44,10 +20,17 @@ int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setconsole_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
const char *device = CURRENT_TTY;
|
||||
int reset;
|
||||
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 */
|
||||
reset = getopt32(argv, "^" "r" "\0" "?1");
|
||||
opt_complementary = "?1";
|
||||
reset = getopt32(argv, "r");
|
||||
|
||||
argv += 1 + reset;
|
||||
if (*argv) {
|
||||
@@ -57,9 +40,6 @@ int setconsole_main(int argc UNUSED_PARAM, char **argv)
|
||||
device = DEV_CONSOLE;
|
||||
}
|
||||
|
||||
//TODO: fails if TIOCCONS redir is already active to some tty.
|
||||
//I think SUSE version first does TIOCCONS on /dev/console fd (iow: resets)
|
||||
//then TIOCCONS to new tty?
|
||||
xioctl(xopen(device, O_WRONLY), TIOCCONS, NULL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -8,24 +8,14 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SETKEYCODES
|
||||
//config: bool "setkeycodes (1.7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program loads entries into the kernel's scancode-to-keycode
|
||||
//config: map, allowing unusual keyboards to generate usable keycodes.
|
||||
|
||||
//applet:IF_SETKEYCODES(APPLET_NOEXEC(setkeycodes, setkeycodes, BB_DIR_USR_BIN, BB_SUID_DROP, setkeycodes))
|
||||
|
||||
//kbuild:lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
|
||||
//usage:#define setkeycodes_trivial_usage
|
||||
//usage: "{ SCANCODE KEYCODE }..."
|
||||
//usage: "SCANCODE KEYCODE..."
|
||||
//usage:#define setkeycodes_full_usage "\n\n"
|
||||
//usage: "Modify kernel's scancode-to-keycode map,\n"
|
||||
//usage: "Set entries into the kernel's scancode-to-keycode map,\n"
|
||||
//usage: "allowing unusual keyboards to generate usable keycodes.\n\n"
|
||||
//usage: "SCANCODE is either xx or e0xx (hexadecimal), KEYCODE is decimal."
|
||||
//usage: "SCANCODE may be either xx or e0xx (hexadecimal),\n"
|
||||
//usage: "and KEYCODE is given in decimal."
|
||||
//usage:
|
||||
//usage:#define setkeycodes_example_usage
|
||||
//usage: "$ setkeycodes e030 127\n"
|
||||
@@ -44,6 +34,7 @@ int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setkeycodes_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
struct kbkeycode a;
|
||||
|
||||
if (!(argc & 1) /* if even */ || argc < 2) {
|
||||
bb_show_usage();
|
||||
@@ -52,10 +43,7 @@ int setkeycodes_main(int argc, char **argv)
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
while (argv[1]) {
|
||||
struct kbkeycode a;
|
||||
int sc;
|
||||
|
||||
sc = xstrtoul_range(argv[1], 16, 0, 0xe07f);
|
||||
int sc = xstrtoul_range(argv[1], 16, 0, 0xe07f);
|
||||
if (sc >= 0xe000) {
|
||||
sc -= 0xe000;
|
||||
sc += 0x0080;
|
||||
|
||||
@@ -8,33 +8,11 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SETLOGCONS
|
||||
//config: bool "setlogcons (1.8 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program redirects the output console of kernel messages.
|
||||
|
||||
//applet:IF_SETLOGCONS(APPLET_NOEXEC(setlogcons, setlogcons, BB_DIR_USR_SBIN, BB_SUID_DROP, setlogcons))
|
||||
|
||||
//kbuild:lib-$(CONFIG_SETLOGCONS) += setlogcons.o
|
||||
|
||||
//usage:#define setlogcons_trivial_usage
|
||||
//usage: "[N]"
|
||||
//usage: "N"
|
||||
//usage:#define setlogcons_full_usage "\n\n"
|
||||
//usage: "Pin kernel output to VT console N. Default:0 (do not pin)"
|
||||
|
||||
// Comment from kernel source:
|
||||
/* ...
|
||||
* By default, the kernel messages are always printed on the current virtual
|
||||
* console. However, the user may modify that default with the
|
||||
* TIOCL_SETKMSGREDIRECT ioctl call.
|
||||
*
|
||||
* This function sets the kernel message console to be @new. It returns the old
|
||||
* virtual console number. The virtual terminal number 0 (both as parameter and
|
||||
* return value) means no redirection (i.e. always printed on the currently
|
||||
* active console).
|
||||
*/
|
||||
//usage: "Redirect the kernel output to console N (0 for current)"
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -45,8 +23,8 @@ int setlogcons_main(int argc UNUSED_PARAM, char **argv)
|
||||
char fn;
|
||||
char subarg;
|
||||
} arg = {
|
||||
11, /* redirect kernel messages (TIOCL_SETKMSGREDIRECT) */
|
||||
0
|
||||
11, /* redirect kernel messages */
|
||||
0 /* to specified console (current as default) */
|
||||
};
|
||||
|
||||
if (argv[1])
|
||||
|
||||
+1
-10
@@ -6,16 +6,6 @@
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SHOWKEY
|
||||
//config: bool "showkey (4.7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Shows keys pressed.
|
||||
|
||||
//applet:IF_SHOWKEY(APPLET(showkey, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_SHOWKEY) += showkey.o
|
||||
|
||||
//usage:#define showkey_trivial_usage
|
||||
//usage: "[-a | -k | -s]"
|
||||
@@ -93,6 +83,7 @@ int showkey_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (04 /*CTRL-D*/ == c)
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
// we assume a PC keyboard
|
||||
xioctl(STDIN_FILENO, KDGKBMODE, &kbmode);
|
||||
|
||||
+758
-10
@@ -7,15 +7,736 @@ menu "Coreutils"
|
||||
|
||||
INSERT
|
||||
|
||||
comment "Common options"
|
||||
|
||||
config FEATURE_VERBOSE
|
||||
bool "Support verbose options (usually -v) for various applets"
|
||||
config CAL
|
||||
bool "cal"
|
||||
default y
|
||||
help
|
||||
Enable cp -v, rm -v and similar messages.
|
||||
Also enables long option (--verbose) if it exists.
|
||||
Without this option, -v is accepted but ignored.
|
||||
cal is used to display a monthly calender.
|
||||
|
||||
config CATV
|
||||
bool "catv"
|
||||
default y
|
||||
help
|
||||
Display nonprinting characters as escape sequences (like some
|
||||
implementations' cat -v option).
|
||||
|
||||
config CHGRP
|
||||
bool "chgrp"
|
||||
default y
|
||||
help
|
||||
chgrp is used to change the group ownership of files.
|
||||
|
||||
config CHMOD
|
||||
bool "chmod"
|
||||
default y
|
||||
help
|
||||
chmod is used to change the access permission of files.
|
||||
|
||||
config CHOWN
|
||||
bool "chown"
|
||||
default y
|
||||
help
|
||||
chown is used to change the user and/or group ownership
|
||||
of files.
|
||||
|
||||
config FEATURE_CHOWN_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on CHOWN && LONG_OPTS
|
||||
help
|
||||
Enable use of long options
|
||||
|
||||
config CHROOT
|
||||
bool "chroot"
|
||||
default y
|
||||
help
|
||||
chroot is used to change the root directory and run a command.
|
||||
The default command is `/bin/sh'.
|
||||
|
||||
config CKSUM
|
||||
bool "cksum"
|
||||
default y
|
||||
help
|
||||
cksum is used to calculate the CRC32 checksum of a file.
|
||||
|
||||
config COMM
|
||||
bool "comm"
|
||||
default y
|
||||
help
|
||||
comm is used to compare two files line by line and return
|
||||
a three-column output.
|
||||
|
||||
config CP
|
||||
bool "cp"
|
||||
default y
|
||||
help
|
||||
cp is used to copy files and directories.
|
||||
|
||||
config FEATURE_CP_LONG_OPTIONS
|
||||
bool "Enable long options for cp"
|
||||
default y
|
||||
depends on CP && LONG_OPTS
|
||||
help
|
||||
Enable long options for cp.
|
||||
Also add support for --parents option.
|
||||
|
||||
config CUT
|
||||
bool "cut"
|
||||
default y
|
||||
help
|
||||
cut is used to print selected parts of lines from
|
||||
each file to stdout.
|
||||
|
||||
config DD
|
||||
bool "dd"
|
||||
default y
|
||||
help
|
||||
dd copies a file (from standard input to standard output,
|
||||
by default) using specific input and output blocksizes,
|
||||
while optionally performing conversions on it.
|
||||
|
||||
config FEATURE_DD_SIGNAL_HANDLING
|
||||
bool "Enable DD signal handling for status reporting"
|
||||
default y
|
||||
depends on DD
|
||||
help
|
||||
Sending a SIGUSR1 signal to a running `dd' process makes it
|
||||
print to standard error the number of records read and written
|
||||
so far, then to resume copying.
|
||||
|
||||
$ dd if=/dev/zero of=/dev/null&
|
||||
$ pid=$! kill -USR1 $pid; sleep 1; kill $pid
|
||||
10899206+0 records in
|
||||
10899206+0 records out
|
||||
|
||||
config FEATURE_DD_THIRD_STATUS_LINE
|
||||
bool "Enable the third status line upon signal"
|
||||
default y
|
||||
depends on DD && FEATURE_DD_SIGNAL_HANDLING
|
||||
help
|
||||
Displays a coreutils-like third status line with transferred bytes,
|
||||
elapsed time and speed.
|
||||
|
||||
config FEATURE_DD_IBS_OBS
|
||||
bool "Enable ibs, obs and conv options"
|
||||
default y
|
||||
depends on DD
|
||||
help
|
||||
Enables support for writing a certain number of bytes in and out,
|
||||
at a time, and performing conversions on the data stream.
|
||||
|
||||
config DF
|
||||
bool "df"
|
||||
default y
|
||||
help
|
||||
df reports the amount of disk space used and available
|
||||
on filesystems.
|
||||
|
||||
config FEATURE_DF_FANCY
|
||||
bool "Enable -a, -i, -B"
|
||||
default y
|
||||
depends on DF
|
||||
help
|
||||
This option enables -a, -i and -B.
|
||||
|
||||
-a Show all filesystems
|
||||
-i Inodes
|
||||
-B <SIZE> Blocksize
|
||||
|
||||
config DIRNAME
|
||||
bool "dirname"
|
||||
default y
|
||||
help
|
||||
dirname is used to strip a non-directory suffix from
|
||||
a file name.
|
||||
|
||||
config DOS2UNIX
|
||||
bool "dos2unix/unix2dos"
|
||||
default y
|
||||
help
|
||||
dos2unix is used to convert a text file from DOS format to
|
||||
UNIX format, and vice versa.
|
||||
|
||||
config UNIX2DOS
|
||||
bool
|
||||
default y
|
||||
depends on DOS2UNIX
|
||||
help
|
||||
unix2dos is used to convert a text file from UNIX format to
|
||||
DOS format, and vice versa.
|
||||
|
||||
config DU
|
||||
bool "du (default blocksize of 512 bytes)"
|
||||
default y
|
||||
help
|
||||
du is used to report the amount of disk space used
|
||||
for specified files.
|
||||
|
||||
config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
bool "Use a default blocksize of 1024 bytes (1K)"
|
||||
default y
|
||||
depends on DU
|
||||
help
|
||||
Use a blocksize of (1K) instead of the default 512b.
|
||||
|
||||
config ECHO
|
||||
bool "echo (basic SuSv3 version taking no options)"
|
||||
default y
|
||||
help
|
||||
echo is used to print a specified string to stdout.
|
||||
|
||||
# this entry also appears in shell/Config.in, next to the echo builtin
|
||||
config FEATURE_FANCY_ECHO
|
||||
bool "Enable echo options (-n and -e)"
|
||||
default y
|
||||
depends on ECHO || ASH_BUILTIN_ECHO || HUSH
|
||||
help
|
||||
This adds options (-n and -e) to echo.
|
||||
|
||||
config ENV
|
||||
bool "env"
|
||||
default y
|
||||
help
|
||||
env is used to set an environment variable and run
|
||||
a command; without options it displays the current
|
||||
environment.
|
||||
|
||||
config FEATURE_ENV_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on ENV && LONG_OPTS
|
||||
help
|
||||
Support long options for the env applet.
|
||||
|
||||
config EXPAND
|
||||
bool "expand"
|
||||
default y
|
||||
help
|
||||
By default, convert all tabs to spaces.
|
||||
|
||||
config FEATURE_EXPAND_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on EXPAND && LONG_OPTS
|
||||
help
|
||||
Support long options for the expand applet.
|
||||
|
||||
config EXPR
|
||||
bool "expr"
|
||||
default y
|
||||
help
|
||||
expr is used to calculate numbers and print the result
|
||||
to standard output.
|
||||
|
||||
config EXPR_MATH_SUPPORT_64
|
||||
bool "Extend Posix numbers support to 64 bit"
|
||||
default y
|
||||
depends on EXPR
|
||||
help
|
||||
Enable 64-bit math support in the expr applet. This will make
|
||||
the applet slightly larger, but will allow computation with very
|
||||
large numbers.
|
||||
|
||||
config FALSE
|
||||
bool "false"
|
||||
default y
|
||||
help
|
||||
false returns an exit code of FALSE (1).
|
||||
|
||||
config FOLD
|
||||
bool "fold"
|
||||
default y
|
||||
help
|
||||
Wrap text to fit a specific width.
|
||||
|
||||
config FSYNC
|
||||
bool "fsync"
|
||||
default y
|
||||
help
|
||||
fsync is used to flush file-related cached blocks to disk.
|
||||
|
||||
config HEAD
|
||||
bool "head"
|
||||
default y
|
||||
help
|
||||
head is used to print the first specified number of lines
|
||||
from files.
|
||||
|
||||
config FEATURE_FANCY_HEAD
|
||||
bool "Enable head options (-c, -q, and -v)"
|
||||
default y
|
||||
depends on HEAD
|
||||
help
|
||||
This enables the head options (-c, -q, and -v).
|
||||
|
||||
config INSTALL
|
||||
bool "install"
|
||||
default y
|
||||
help
|
||||
Copy files and set attributes.
|
||||
|
||||
config FEATURE_INSTALL_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on INSTALL && LONG_OPTS
|
||||
help
|
||||
Support long options for the install applet.
|
||||
|
||||
####config LENGTH
|
||||
#### bool "length"
|
||||
#### default y
|
||||
#### help
|
||||
#### length is used to print out the length of a specified string.
|
||||
|
||||
config LN
|
||||
bool "ln"
|
||||
default y
|
||||
help
|
||||
ln is used to create hard or soft links between files.
|
||||
|
||||
config LOGNAME
|
||||
bool "logname"
|
||||
default y
|
||||
help
|
||||
logname is used to print the current user's login name.
|
||||
|
||||
config LS
|
||||
bool "ls"
|
||||
default y
|
||||
help
|
||||
ls is used to list the contents of directories.
|
||||
|
||||
config FEATURE_LS_FILETYPES
|
||||
bool "Enable filetyping options (-p and -F)"
|
||||
default y
|
||||
depends on LS
|
||||
help
|
||||
Enable the ls options (-p and -F).
|
||||
|
||||
config FEATURE_LS_FOLLOWLINKS
|
||||
bool "Enable symlinks dereferencing (-L)"
|
||||
default y
|
||||
depends on LS
|
||||
help
|
||||
Enable the ls option (-L).
|
||||
|
||||
config FEATURE_LS_RECURSIVE
|
||||
bool "Enable recursion (-R)"
|
||||
default y
|
||||
depends on LS
|
||||
help
|
||||
Enable the ls option (-R).
|
||||
|
||||
config FEATURE_LS_SORTFILES
|
||||
bool "Sort the file names"
|
||||
default y
|
||||
depends on LS
|
||||
help
|
||||
Allow ls to sort file names alphabetically.
|
||||
|
||||
config FEATURE_LS_TIMESTAMPS
|
||||
bool "Show file timestamps"
|
||||
default y
|
||||
depends on LS
|
||||
help
|
||||
Allow ls to display timestamps for files.
|
||||
|
||||
config FEATURE_LS_USERNAME
|
||||
bool "Show username/groupnames"
|
||||
default y
|
||||
depends on LS
|
||||
help
|
||||
Allow ls to display username/groupname for files.
|
||||
|
||||
config FEATURE_LS_COLOR
|
||||
bool "Allow use of color to identify file types"
|
||||
default y
|
||||
depends on LS && LONG_OPTS
|
||||
help
|
||||
This enables the --color option to ls.
|
||||
|
||||
config FEATURE_LS_COLOR_IS_DEFAULT
|
||||
bool "Produce colored ls output by default"
|
||||
default y
|
||||
depends on FEATURE_LS_COLOR
|
||||
help
|
||||
Saying yes here will turn coloring on by default,
|
||||
even if no "--color" option is given to the ls command.
|
||||
This is not recommended, since the colors are not
|
||||
configurable, and the output may not be legible on
|
||||
many output screens.
|
||||
|
||||
config MD5SUM
|
||||
bool "md5sum"
|
||||
default y
|
||||
help
|
||||
md5sum is used to print or check MD5 checksums.
|
||||
|
||||
config MKDIR
|
||||
bool "mkdir"
|
||||
default y
|
||||
help
|
||||
mkdir is used to create directories with the specified names.
|
||||
|
||||
config FEATURE_MKDIR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on MKDIR && LONG_OPTS
|
||||
help
|
||||
Support long options for the mkdir applet.
|
||||
|
||||
config MKFIFO
|
||||
bool "mkfifo"
|
||||
default y
|
||||
help
|
||||
mkfifo is used to create FIFOs (named pipes).
|
||||
The `mknod' program can also create FIFOs.
|
||||
|
||||
config MKNOD
|
||||
bool "mknod"
|
||||
default y
|
||||
help
|
||||
mknod is used to create FIFOs or block/character special
|
||||
files with the specified names.
|
||||
|
||||
config MV
|
||||
bool "mv"
|
||||
default y
|
||||
help
|
||||
mv is used to move or rename files or directories.
|
||||
|
||||
config FEATURE_MV_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on MV && LONG_OPTS
|
||||
help
|
||||
Support long options for the mv applet.
|
||||
|
||||
config NICE
|
||||
bool "nice"
|
||||
default y
|
||||
help
|
||||
nice runs a program with modified scheduling priority.
|
||||
|
||||
config NOHUP
|
||||
bool "nohup"
|
||||
default y
|
||||
help
|
||||
run a command immune to hangups, with output to a non-tty.
|
||||
|
||||
config OD
|
||||
bool "od"
|
||||
default y
|
||||
help
|
||||
od is used to dump binary files in octal and other formats.
|
||||
|
||||
config PRINTENV
|
||||
bool "printenv"
|
||||
default y
|
||||
help
|
||||
printenv is used to print all or part of environment.
|
||||
|
||||
config PRINTF
|
||||
bool "printf"
|
||||
default y
|
||||
help
|
||||
printf is used to format and print specified strings.
|
||||
It's similar to `echo' except it has more options.
|
||||
|
||||
config PWD
|
||||
bool "pwd"
|
||||
default y
|
||||
help
|
||||
pwd is used to print the current directory.
|
||||
|
||||
config READLINK
|
||||
bool "readlink"
|
||||
default y
|
||||
help
|
||||
This program reads a symbolic link and returns the name
|
||||
of the file it points to
|
||||
|
||||
config FEATURE_READLINK_FOLLOW
|
||||
bool "Enable canonicalization by following all symlinks (-f)"
|
||||
default y
|
||||
depends on READLINK
|
||||
help
|
||||
Enable the readlink option (-f).
|
||||
|
||||
config REALPATH
|
||||
bool "realpath"
|
||||
default y
|
||||
help
|
||||
Return the canonicalized absolute pathname.
|
||||
This isn't provided by GNU shellutils, but where else does it belong.
|
||||
|
||||
config RM
|
||||
bool "rm"
|
||||
default y
|
||||
help
|
||||
rm is used to remove files or directories.
|
||||
|
||||
config RMDIR
|
||||
bool "rmdir"
|
||||
default y
|
||||
help
|
||||
rmdir is used to remove empty directories.
|
||||
|
||||
config FEATURE_RMDIR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on RMDIR && LONG_OPTS
|
||||
help
|
||||
Support long options for the rmdir applet, including
|
||||
--ignore-fail-on-non-empty for compatibility with GNU rmdir.
|
||||
|
||||
config SEQ
|
||||
bool "seq"
|
||||
default y
|
||||
help
|
||||
print a sequence of numbers
|
||||
|
||||
config SHA1SUM
|
||||
bool "sha1sum"
|
||||
default y
|
||||
help
|
||||
Compute and check SHA1 message digest
|
||||
|
||||
config SHA256SUM
|
||||
bool "sha256sum"
|
||||
default y
|
||||
help
|
||||
Compute and check SHA256 message digest
|
||||
|
||||
config SHA512SUM
|
||||
bool "sha512sum"
|
||||
default y
|
||||
help
|
||||
Compute and check SHA512 message digest
|
||||
|
||||
config SHA3SUM
|
||||
bool "sha3sum"
|
||||
default y
|
||||
help
|
||||
Compute and check SHA3 (512-bit) message digest
|
||||
|
||||
config SLEEP
|
||||
bool "sleep"
|
||||
default y
|
||||
help
|
||||
sleep is used to pause for a specified number of seconds.
|
||||
It comes in 3 versions:
|
||||
- small: takes one integer parameter
|
||||
- fancy: takes multiple integer arguments with suffixes:
|
||||
sleep 1d 2h 3m 15s
|
||||
- fancy with fractional numbers:
|
||||
sleep 2.3s 4.5h sleeps for 16202.3 seconds
|
||||
Last one is "the most compatible" with coreutils sleep,
|
||||
but it adds around 1k of code.
|
||||
|
||||
config FEATURE_FANCY_SLEEP
|
||||
bool "Enable multiple arguments and s/m/h/d suffixes"
|
||||
default y
|
||||
depends on SLEEP
|
||||
help
|
||||
Allow sleep to pause for specified minutes, hours, and days.
|
||||
|
||||
config FEATURE_FLOAT_SLEEP
|
||||
bool "Enable fractional arguments"
|
||||
default y
|
||||
depends on FEATURE_FANCY_SLEEP
|
||||
help
|
||||
Allow for fractional numeric parameters.
|
||||
|
||||
config SORT
|
||||
bool "sort"
|
||||
default y
|
||||
help
|
||||
sort is used to sort lines of text in specified files.
|
||||
|
||||
config FEATURE_SORT_BIG
|
||||
bool "Full SuSv3 compliant sort (support -ktcsbdfiozgM)"
|
||||
default y
|
||||
depends on SORT
|
||||
help
|
||||
Without this, sort only supports -r, -u, and an integer version
|
||||
of -n. Selecting this adds sort keys, floating point support, and
|
||||
more. This adds a little over 3k to a nonstatic build on x86.
|
||||
|
||||
The SuSv3 sort standard is available at:
|
||||
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
|
||||
|
||||
config SPLIT
|
||||
bool "split"
|
||||
default y
|
||||
help
|
||||
split a file into pieces.
|
||||
|
||||
config FEATURE_SPLIT_FANCY
|
||||
bool "Fancy extensions"
|
||||
default y
|
||||
depends on SPLIT
|
||||
help
|
||||
Add support for features not required by SUSv3.
|
||||
Supports additional suffixes 'b' for 512 bytes,
|
||||
'g' for 1GiB for the -b option.
|
||||
|
||||
config STAT
|
||||
bool "stat"
|
||||
default y
|
||||
select PLATFORM_LINUX # statfs()
|
||||
help
|
||||
display file or filesystem status.
|
||||
|
||||
config FEATURE_STAT_FORMAT
|
||||
bool "Enable custom formats (-c)"
|
||||
default y
|
||||
depends on STAT
|
||||
help
|
||||
Without this, stat will not support the '-c format' option where
|
||||
users can pass a custom format string for output. This adds about
|
||||
7k to a nonstatic build on amd64.
|
||||
|
||||
config STTY
|
||||
bool "stty"
|
||||
default y
|
||||
help
|
||||
stty is used to change and print terminal line settings.
|
||||
|
||||
config SUM
|
||||
bool "sum"
|
||||
default y
|
||||
help
|
||||
checksum and count the blocks in a file
|
||||
|
||||
config SYNC
|
||||
bool "sync"
|
||||
default y
|
||||
help
|
||||
sync is used to flush filesystem buffers.
|
||||
|
||||
config TAC
|
||||
bool "tac"
|
||||
default y
|
||||
help
|
||||
tac is used to concatenate and print files in reverse.
|
||||
|
||||
config TAIL
|
||||
bool "tail"
|
||||
default y
|
||||
help
|
||||
tail is used to print the last specified number of lines
|
||||
from files.
|
||||
|
||||
config FEATURE_FANCY_TAIL
|
||||
bool "Enable extra tail options (-q, -s, -v, and -F)"
|
||||
default y
|
||||
depends on TAIL
|
||||
help
|
||||
The options (-q, -s, and -v) are provided by GNU tail, but
|
||||
are not specific in the SUSv3 standard.
|
||||
|
||||
-q Never output headers giving file names
|
||||
-s SEC Wait SEC seconds between reads with -f
|
||||
-v Always output headers giving file names
|
||||
|
||||
config TEE
|
||||
bool "tee"
|
||||
default y
|
||||
help
|
||||
tee is used to read from standard input and write
|
||||
to standard output and files.
|
||||
|
||||
config FEATURE_TEE_USE_BLOCK_IO
|
||||
bool "Enable block I/O (larger/faster) instead of byte I/O"
|
||||
default y
|
||||
depends on TEE
|
||||
help
|
||||
Enable this option for a faster tee, at expense of size.
|
||||
|
||||
config TRUE
|
||||
bool "true"
|
||||
default y
|
||||
help
|
||||
true returns an exit code of TRUE (0).
|
||||
|
||||
config TTY
|
||||
bool "tty"
|
||||
default y
|
||||
help
|
||||
tty is used to print the name of the current terminal to
|
||||
standard output.
|
||||
|
||||
config UNAME
|
||||
bool "uname"
|
||||
default y
|
||||
help
|
||||
uname is used to print system information.
|
||||
|
||||
config UNEXPAND
|
||||
bool "unexpand"
|
||||
default y
|
||||
help
|
||||
By default, convert only leading sequences of blanks to tabs.
|
||||
|
||||
config FEATURE_UNEXPAND_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on UNEXPAND && LONG_OPTS
|
||||
help
|
||||
Support long options for the unexpand applet.
|
||||
|
||||
config UNIQ
|
||||
bool "uniq"
|
||||
default y
|
||||
help
|
||||
uniq is used to remove duplicate lines from a sorted file.
|
||||
|
||||
config USLEEP
|
||||
bool "usleep"
|
||||
default y
|
||||
help
|
||||
usleep is used to pause for a specified number of microseconds.
|
||||
|
||||
config UUDECODE
|
||||
bool "uudecode"
|
||||
default y
|
||||
help
|
||||
uudecode is used to decode a uuencoded file.
|
||||
|
||||
config UUENCODE
|
||||
bool "uuencode"
|
||||
default y
|
||||
help
|
||||
uuencode is used to uuencode a file.
|
||||
|
||||
config WC
|
||||
bool "wc"
|
||||
default y
|
||||
help
|
||||
wc is used to print the number of bytes, words, and lines,
|
||||
in specified files.
|
||||
|
||||
config FEATURE_WC_LARGE
|
||||
bool "Support very large files in wc"
|
||||
default y
|
||||
depends on WC
|
||||
help
|
||||
Use "unsigned long long" in wc for counter variables.
|
||||
|
||||
config WHOAMI
|
||||
bool "whoami"
|
||||
default y
|
||||
help
|
||||
whoami is used to print the username of the current
|
||||
user id (same as id -un).
|
||||
|
||||
config YES
|
||||
bool "yes"
|
||||
default y
|
||||
help
|
||||
yes is used to repeatedly output a specific string, or
|
||||
the default string `y'.
|
||||
|
||||
comment "Common options for cp and mv"
|
||||
depends on CP || MV
|
||||
@@ -25,16 +746,43 @@ config FEATURE_PRESERVE_HARDLINKS
|
||||
default y
|
||||
depends on CP || MV
|
||||
help
|
||||
Allow cp and mv to preserve hard links.
|
||||
Allow cp and mv to preserve hard links.
|
||||
|
||||
comment "Common options for ls, more and telnet"
|
||||
depends on LS || MORE || TELNET
|
||||
|
||||
config FEATURE_AUTOWIDTH
|
||||
bool "Calculate terminal & column widths"
|
||||
default y
|
||||
depends on LS || MORE || TELNET
|
||||
help
|
||||
This option allows utilities such as 'ls', 'more' and 'telnet'
|
||||
to determine the width of the screen, which can allow them to
|
||||
display additional text or avoid wrapping text onto the next line.
|
||||
If you leave this disabled, your utilities will be especially
|
||||
primitive and will be unable to determine the current screen width.
|
||||
|
||||
comment "Common options for df, du, ls"
|
||||
depends on DF || DU || LS
|
||||
|
||||
config FEATURE_HUMAN_READABLE
|
||||
bool "Support human readable output (example 13k, 23M, 235G)"
|
||||
bool "Support for human readable output (example 13k, 23M, 235G)"
|
||||
default y
|
||||
depends on DF || DU || LS
|
||||
help
|
||||
Allow df, du, and ls to have human readable output.
|
||||
Allow df, du, and ls to have human readable output.
|
||||
|
||||
comment "Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum"
|
||||
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
|
||||
|
||||
config FEATURE_MD5_SHA1_SUM_CHECK
|
||||
bool "Enable -c, -s and -w options"
|
||||
default y
|
||||
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
|
||||
help
|
||||
Enabling the -c options allows files to be checked
|
||||
against pre-calculated hash values.
|
||||
|
||||
-s and -w are useful options when verifying checksums.
|
||||
|
||||
endmenu
|
||||
+73
-7
@@ -9,10 +9,76 @@ libs-y += libcoreutils/
|
||||
lib-y:=
|
||||
|
||||
INSERT
|
||||
|
||||
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
|
||||
lib-$(CONFIG_LESS) += cat.o # less too
|
||||
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
|
||||
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
|
||||
lib-$(CONFIG_ADDGROUP) += chown.o # used by addgroup
|
||||
lib-$(CONFIG_FTPD) += ls.o # used by ftpd
|
||||
lib-$(CONFIG_CAL) += cal.o
|
||||
lib-$(CONFIG_CATV) += catv.o
|
||||
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
|
||||
lib-$(CONFIG_CHMOD) += chmod.o
|
||||
lib-$(CONFIG_CHOWN) += chown.o
|
||||
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
|
||||
lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser
|
||||
lib-$(CONFIG_CHROOT) += chroot.o
|
||||
lib-$(CONFIG_CKSUM) += cksum.o
|
||||
lib-$(CONFIG_COMM) += comm.o
|
||||
lib-$(CONFIG_CP) += cp.o
|
||||
lib-$(CONFIG_CUT) += cut.o
|
||||
lib-$(CONFIG_DD) += dd.o
|
||||
lib-$(CONFIG_DF) += df.o
|
||||
lib-$(CONFIG_DIRNAME) += dirname.o
|
||||
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
|
||||
lib-$(CONFIG_FALSE) += false.o
|
||||
lib-$(CONFIG_FOLD) += fold.o
|
||||
lib-$(CONFIG_FSYNC) += fsync.o
|
||||
lib-$(CONFIG_INSTALL) += install.o
|
||||
#lib-$(CONFIG_LENGTH) += length.o
|
||||
lib-$(CONFIG_LN) += ln.o
|
||||
lib-$(CONFIG_LOGNAME) += logname.o
|
||||
lib-$(CONFIG_LS) += ls.o
|
||||
lib-$(CONFIG_FTPD) += ls.o
|
||||
lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_MKDIR) += mkdir.o
|
||||
lib-$(CONFIG_MKFIFO) += mkfifo.o
|
||||
lib-$(CONFIG_MKNOD) += mknod.o
|
||||
lib-$(CONFIG_MV) += mv.o
|
||||
lib-$(CONFIG_NICE) += nice.o
|
||||
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
|
||||
lib-$(CONFIG_RM) += rm.o
|
||||
lib-$(CONFIG_RMDIR) += rmdir.o
|
||||
lib-$(CONFIG_SEQ) += seq.o
|
||||
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SHA3SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SLEEP) += sleep.o
|
||||
lib-$(CONFIG_SPLIT) += split.o
|
||||
lib-$(CONFIG_SORT) += sort.o
|
||||
lib-$(CONFIG_STAT) += stat.o
|
||||
lib-$(CONFIG_STTY) += stty.o
|
||||
lib-$(CONFIG_SUM) += sum.o
|
||||
lib-$(CONFIG_SYNC) += sync.o
|
||||
lib-$(CONFIG_TAC) += tac.o
|
||||
lib-$(CONFIG_TEE) += tee.o
|
||||
lib-$(CONFIG_TRUE) += true.o
|
||||
lib-$(CONFIG_TTY) += tty.o
|
||||
lib-$(CONFIG_UNAME) += uname.o
|
||||
lib-$(CONFIG_UNEXPAND) += expand.o
|
||||
lib-$(CONFIG_UNIQ) += uniq.o
|
||||
lib-$(CONFIG_USLEEP) += usleep.o
|
||||
lib-$(CONFIG_UUDECODE) += uudecode.o
|
||||
lib-$(CONFIG_UUENCODE) += uuencode.o
|
||||
lib-$(CONFIG_WC) += wc.o
|
||||
lib-$(CONFIG_WHOAMI) += whoami.o
|
||||
lib-$(CONFIG_YES) += yes.o
|
||||
+17
-16
@@ -6,6 +6,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Changes:
|
||||
@@ -13,25 +14,24 @@
|
||||
* 2) Don't check for options, as per SUSv3.
|
||||
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
|
||||
*/
|
||||
//config:config BASENAME
|
||||
//config: bool "basename (371 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: basename is used to strip the directory and suffix from filenames,
|
||||
//config: leaving just the filename itself. Enable this option if you wish
|
||||
//config: to enable the 'basename' utility.
|
||||
|
||||
//applet:IF_BASENAME(APPLET_NOFORK(basename, basename, BB_DIR_USR_BIN, BB_SUID_DROP, basename))
|
||||
|
||||
//kbuild:lib-$(CONFIG_BASENAME) += basename.o
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
|
||||
|
||||
//kbuild:lib-$(CONFIG_BASENAME) += basename.o
|
||||
|
||||
//config:config BASENAME
|
||||
//config: bool "basename"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: basename is used to strip the directory and suffix from filenames,
|
||||
//config: leaving just the filename itself. Enable this option if you wish
|
||||
//config: to enable the 'basename' utility.
|
||||
|
||||
//usage:#define basename_trivial_usage
|
||||
//usage: "FILE [SUFFIX]"
|
||||
//usage:#define basename_full_usage "\n\n"
|
||||
//usage: "Strip directory path and .SUFFIX from FILE"
|
||||
//usage: "Strip directory path and .SUFFIX from FILE\n"
|
||||
//usage:
|
||||
//usage:#define basename_example_usage
|
||||
//usage: "$ basename /usr/local/bin/foo\n"
|
||||
@@ -46,24 +46,25 @@
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int basename_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int basename_main(int argc UNUSED_PARAM, char **argv)
|
||||
int basename_main(int argc, char **argv)
|
||||
{
|
||||
size_t m, n;
|
||||
char *s;
|
||||
|
||||
if (argv[1] && strcmp(argv[1], "--") == 0) {
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
if (!argv[1])
|
||||
|
||||
if ((unsigned)(argc-2) >= 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* It should strip slash: /abc/def/ -> def */
|
||||
s = bb_get_last_path_component_strip(*++argv);
|
||||
|
||||
m = strlen(s);
|
||||
if (*++argv) {
|
||||
if (argv[1])
|
||||
bb_show_usage();
|
||||
n = strlen(*argv);
|
||||
if ((m > n) && (strcmp(s+m-n, *argv) == 0)) {
|
||||
m -= n;
|
||||
|
||||
@@ -6,25 +6,17 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Major size reduction... over 50% (>1.5k) on i386.
|
||||
*/
|
||||
//config:config CAL
|
||||
//config: bool "cal (6.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cal is used to display a monthly calendar.
|
||||
|
||||
//applet:IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_CAL) += cal.o
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */
|
||||
/* BB_AUDIT BUG: The output of 'cal -j 1752' is incorrect. The upstream
|
||||
* BB_AUDIT BUG: version in util-linux seems to be broken as well. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cal.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Major size reduction... over 50% (>1.5k) on i386.
|
||||
*/
|
||||
|
||||
//usage:#define cal_trivial_usage
|
||||
//usage: "[-jy] [[MONTH] YEAR]"
|
||||
//usage:#define cal_full_usage "\n\n"
|
||||
@@ -35,7 +27,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unicode.h"
|
||||
|
||||
/* We often use "unsigned" instead of "int", it's easier to div on most CPUs */
|
||||
/* We often use "unsigned" intead of "int", it's easier to div on most CPUs */
|
||||
|
||||
#define THURSDAY 4 /* for reformation */
|
||||
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
|
||||
@@ -376,7 +368,7 @@ static char *build_row(char *p, unsigned *dp)
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
+30
-176
@@ -6,210 +6,64 @@
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CAT
|
||||
//config: bool "cat (5.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cat is used to concatenate files and print them to the standard
|
||||
//config: output. Enable this option if you wish to enable the 'cat' utility.
|
||||
//config:
|
||||
//config:config FEATURE_CATN
|
||||
//config: bool "Enable -n and -b options"
|
||||
//config: default y
|
||||
//config: depends on CAT
|
||||
//config: help
|
||||
//config: -n numbers all output lines while -b numbers nonempty output lines.
|
||||
//config:
|
||||
//config:config FEATURE_CATV
|
||||
//config: bool "cat -v[etA]"
|
||||
//config: default y
|
||||
//config: depends on CAT
|
||||
//config: help
|
||||
//config: Display nonprinting characters as escape sequences
|
||||
|
||||
//applet:IF_CAT(APPLET(cat, BB_DIR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_CAT) += cat.o
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
|
||||
|
||||
//usage:#if ENABLE_FEATURE_CATN || ENABLE_FEATURE_CATV
|
||||
//usage:#define cat_trivial_usage
|
||||
//usage: "[-" IF_FEATURE_CATN("nb") IF_FEATURE_CATV("vteA") "] [FILE]..."
|
||||
//usage:#else
|
||||
//kbuild:lib-$(CONFIG_CAT) += cat.o
|
||||
//kbuild:lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
|
||||
//kbuild:lib-$(CONFIG_LESS) += cat.o # less too
|
||||
//kbuild:lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
|
||||
|
||||
//config:config CAT
|
||||
//config: bool "cat"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cat is used to concatenate files and print them to the standard
|
||||
//config: output. Enable this option if you wish to enable the 'cat' utility.
|
||||
|
||||
//usage:#define cat_trivial_usage
|
||||
//usage: "[FILE]..."
|
||||
//usage:#endif
|
||||
//usage:#define cat_full_usage "\n\n"
|
||||
//usage: "Print FILEs to stdout\n"
|
||||
//usage: IF_FEATURE_CATN(
|
||||
//usage: "\n -n Number output lines"
|
||||
//usage: "\n -b Number nonempty lines"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_CATV(
|
||||
//usage: "\n -v Show nonprinting characters as ^x or M-x"
|
||||
//usage: "\n -t ...and tabs as ^I"
|
||||
//usage: "\n -e ...and end lines with $"
|
||||
//usage: "\n -A Same as -vte"
|
||||
//usage: )
|
||||
/*
|
||||
Longopts not implemented yet:
|
||||
--number-nonblank number nonempty output lines, overrides -n
|
||||
--number number all output lines
|
||||
--show-nonprinting use ^ and M- notation, except for LFD and TAB
|
||||
--show-all equivalent to -vet
|
||||
Not implemented yet:
|
||||
-E, --show-ends display $ at end of each line (-e sans -v)
|
||||
-T, --show-tabs display TAB characters as ^I (-t sans -v)
|
||||
-s, --squeeze-blank suppress repeated empty output lines
|
||||
*/
|
||||
//usage: "Concatenate FILEs and print them to stdout"
|
||||
//usage:
|
||||
//usage:#define cat_example_usage
|
||||
//usage: "$ cat /proc/uptime\n"
|
||||
//usage: "110716.72 17.67"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
#if ENABLE_FEATURE_CATV
|
||||
/*
|
||||
* cat -v implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2006 Rob Landley <rob@landley.net>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
/* Rob had "cat -v" implemented as a separate applet, catv.
|
||||
* See "cat -v considered harmful" at
|
||||
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz
|
||||
* From USENIX Summer Conference Proceedings, 1983
|
||||
* """
|
||||
* The talk reviews reasons for UNIX's popularity and shows, using UCB cat
|
||||
* as a primary example, how UNIX has grown fat. cat isn't for printing
|
||||
* files with line numbers, it isn't for compressing multiple blank lines,
|
||||
* it's not for looking at non-printing ASCII characters, it's for
|
||||
* concatenating files.
|
||||
* We are reminded that ls isn't the place for code to break a single column
|
||||
* into multiple ones, and that mailnews shouldn't have its own more
|
||||
* processing or joke encryption code.
|
||||
* """
|
||||
*
|
||||
* I agree with the argument. Unfortunately, this ship has sailed (1983...).
|
||||
* There are dozens of Linux distros and each of them has "cat" which supports -v.
|
||||
* It's unrealistic for us to "reeducate" them to use our, incompatible way
|
||||
* to achieve "cat -v" effect. The actual effect would be "users pissed off
|
||||
* by gratuitous incompatibility".
|
||||
*/
|
||||
#define CAT_OPT_e (1<<0)
|
||||
#define CAT_OPT_t (1<<1)
|
||||
#define CAT_OPT_v (1<<2)
|
||||
/* -A occupies bit (1<<3) */
|
||||
#define CAT_OPT_n ((1<<4) * ENABLE_FEATURE_CATN)
|
||||
#define CAT_OPT_b ((1<<5) * ENABLE_FEATURE_CATN)
|
||||
static int catv(unsigned opts, char **argv)
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
|
||||
int bb_cat(char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int fd;
|
||||
#if ENABLE_FEATURE_CATN
|
||||
unsigned lineno = 0;
|
||||
unsigned eol_char = (opts & (CAT_OPT_n|CAT_OPT_b)) ? '\n' : 0x100;
|
||||
unsigned skip_num_on = (opts & CAT_OPT_b) ? '\n' : 0x100;
|
||||
bool eol_seen = 1;
|
||||
#endif
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
BUILD_BUG_ON(CAT_OPT_e != VISIBLE_ENDLINE);
|
||||
BUILD_BUG_ON(CAT_OPT_t != VISIBLE_SHOW_TABS);
|
||||
#if 0 /* These consts match, we can just pass "opts" to visible() */
|
||||
if (opts & CAT_OPT_e)
|
||||
flags |= VISIBLE_ENDLINE;
|
||||
if (opts & CAT_OPT_t)
|
||||
flags |= VISIBLE_SHOW_TABS;
|
||||
#endif
|
||||
if (!*argv)
|
||||
argv = (char**) &bb_argv_dash;
|
||||
|
||||
#define read_buf bb_common_bufsiz1
|
||||
setup_common_bufsiz();
|
||||
do {
|
||||
fd = open_or_warn_stdin(*argv);
|
||||
if (fd < 0) {
|
||||
retval = EXIT_FAILURE;
|
||||
continue;
|
||||
if (fd >= 0) {
|
||||
/* This is not a xfunc - never exits */
|
||||
off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
|
||||
if (fd != STDIN_FILENO)
|
||||
close(fd);
|
||||
if (r >= 0)
|
||||
continue;
|
||||
}
|
||||
for (;;) {
|
||||
int i, res;
|
||||
|
||||
res = read(fd, read_buf, COMMON_BUFSIZE);
|
||||
if (res < 0)
|
||||
retval = EXIT_FAILURE;
|
||||
if (res <= 0)
|
||||
break;
|
||||
for (i = 0; i < res; i++) {
|
||||
unsigned char c = read_buf[i];
|
||||
char buf[sizeof("M-^c")];
|
||||
#if ENABLE_FEATURE_CATN
|
||||
if (eol_seen && c != skip_num_on)
|
||||
printf("%6u ", ++lineno);
|
||||
eol_seen = (c == eol_char);
|
||||
#endif
|
||||
visible(c, buf, opts);
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP && fd)
|
||||
close(fd);
|
||||
retval = EXIT_FAILURE;
|
||||
} while (*++argv);
|
||||
|
||||
fflush_stdout_and_exit(retval);
|
||||
return retval;
|
||||
}
|
||||
#undef CAT_OPT_n
|
||||
#undef CAT_OPT_b
|
||||
#endif
|
||||
|
||||
int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cat_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
#if ENABLE_FEATURE_CATV || ENABLE_FEATURE_CATN
|
||||
unsigned opts;
|
||||
|
||||
opts =
|
||||
#endif
|
||||
getopt32(argv, IF_FEATURE_CATV("^")
|
||||
/* -u is ignored ("unbuffered") */
|
||||
IF_FEATURE_CATV("etvA")IF_FEATURE_CATN("nb")"u"
|
||||
IF_FEATURE_CATV("\0" "Aetv" /* -A == -vet */)
|
||||
);
|
||||
getopt32(argv, "u");
|
||||
argv += optind;
|
||||
|
||||
/* Read from stdin if there's nothing else to do. */
|
||||
if (!argv[0])
|
||||
*--argv = (char*)"-";
|
||||
|
||||
#if ENABLE_FEATURE_CATV
|
||||
if (opts & 7)
|
||||
return catv(opts, argv);
|
||||
opts >>= 4;
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_CATN
|
||||
# define CAT_OPT_n (1<<0)
|
||||
# define CAT_OPT_b (1<<1)
|
||||
if (opts & (CAT_OPT_n|CAT_OPT_b)) { /* -n or -b */
|
||||
struct number_state ns;
|
||||
|
||||
ns.width = 6;
|
||||
ns.start = 1;
|
||||
ns.inc = 1;
|
||||
ns.sep = "\t";
|
||||
ns.empty_str = "\n";
|
||||
ns.all = !(opts & CAT_OPT_b); /* -n without -b */
|
||||
ns.nonempty = (opts & CAT_OPT_b); /* -b (with or without -n) */
|
||||
do {
|
||||
print_numbered_lines(&ns, *argv);
|
||||
} while (*++argv);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
/*opts >>= 2;*/
|
||||
#endif
|
||||
|
||||
return bb_cat(argv);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* cat -v implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2006 Rob Landley <rob@landley.net>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/* See "Cat -v considered harmful" at
|
||||
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
|
||||
|
||||
//usage:#define catv_trivial_usage
|
||||
//usage: "[-etv] [FILE]..."
|
||||
//usage:#define catv_full_usage "\n\n"
|
||||
//usage: "Display nonprinting characters as ^x or M-x\n"
|
||||
//usage: "\n -e End each line with $"
|
||||
//usage: "\n -t Show tabs as ^I"
|
||||
//usage: "\n -v Don't use ^x or M-x escapes"
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int catv_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int fd;
|
||||
unsigned opts;
|
||||
#define CATV_OPT_e (1<<0)
|
||||
#define CATV_OPT_t (1<<1)
|
||||
#define CATV_OPT_v (1<<2)
|
||||
typedef char BUG_const_mismatch[
|
||||
CATV_OPT_e == VISIBLE_ENDLINE && CATV_OPT_t == VISIBLE_SHOW_TABS
|
||||
? 1 : -1
|
||||
];
|
||||
|
||||
opts = getopt32(argv, "etv");
|
||||
argv += optind;
|
||||
#if 0 /* These consts match, we can just pass "opts" to visible() */
|
||||
if (opts & CATV_OPT_e)
|
||||
flags |= VISIBLE_ENDLINE;
|
||||
if (opts & CATV_OPT_t)
|
||||
flags |= VISIBLE_SHOW_TABS;
|
||||
#endif
|
||||
|
||||
/* Read from stdin if there's nothing else to do. */
|
||||
if (!argv[0])
|
||||
*--argv = (char*)"-";
|
||||
do {
|
||||
fd = open_or_warn_stdin(*argv);
|
||||
if (fd < 0) {
|
||||
retval = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
for (;;) {
|
||||
int i, res;
|
||||
|
||||
#define read_buf bb_common_bufsiz1
|
||||
res = read(fd, read_buf, COMMON_BUFSIZE);
|
||||
if (res < 0)
|
||||
retval = EXIT_FAILURE;
|
||||
if (res <= 0)
|
||||
break;
|
||||
for (i = 0; i < res; i++) {
|
||||
unsigned char c = read_buf[i];
|
||||
if (opts & CATV_OPT_v) {
|
||||
putchar(c);
|
||||
} else {
|
||||
char buf[sizeof("M-^c")];
|
||||
visible(c, buf, opts);
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP && fd)
|
||||
close(fd);
|
||||
} while (*++argv);
|
||||
|
||||
fflush_stdout_and_exit(retval);
|
||||
}
|
||||
Loaded 100 of 1694 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user