Compare commits

..
6 Commits
Author SHA1 Message Date
Denys Vlasenko e50f74da70 Bump version to 1.24.2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-17 21:38:03 +01:00
Denys Vlasenko 9de318d63e scripts/trylink: fix static build with glibc again. Closes 8471
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-17 21:37:12 +01:00
Ari Sundholm be729c1d3b truncate: always set mode when opening file to avoid fortify errors
Busybox crashes due to no mode being given when opening:
$ ./busybox truncate -s 1M foo
*** invalid open64 call: O_CREAT without mode ***: ./busybox terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7338f)[0x7f66d921338f]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f66d92aac9c]
/lib/x86_64-linux-gnu/libc.so.6(+0xeb6aa)[0x7f66d928b6aa]
./busybox[0x4899f9]
======= Memory map: ========
00400000-004d0000 r-xp 00000000 00:1a 137559                             /home/ari/busybox/busybox
006cf000-006d0000 r--p 000cf000 00:1a 137559                             /home/ari/busybox/busybox
006d0000-006d1000 rw-p 000d0000 00:1a 137559                             /home/ari/busybox/busybox
006d1000-006d4000 rw-p 00000000 00:00 0
014e7000-01508000 rw-p 00000000 00:00 0                                  [heap]
7f66d8f8a000-7f66d8fa0000 r-xp 00000000 08:07 1579008                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66d8fa0000-7f66d919f000 ---p 00016000 08:07 1579008                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66d919f000-7f66d91a0000 rw-p 00015000 08:07 1579008                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66d91a0000-7f66d935b000 r-xp 00000000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d935b000-7f66d955a000 ---p 001bb000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d955a000-7f66d955e000 r--p 001ba000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d955e000-7f66d9560000 rw-p 001be000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d9560000-7f66d9565000 rw-p 00000000 00:00 0
7f66d9565000-7f66d966a000 r-xp 00000000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d966a000-7f66d9869000 ---p 00105000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d9869000-7f66d986a000 r--p 00104000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d986a000-7f66d986b000 rw-p 00105000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d986b000-7f66d988e000 r-xp 00000000 08:07 1578981                    /lib/x86_64-linux-gnu/ld-2.19.so
7f66d9a64000-7f66d9a67000 rw-p 00000000 00:00 0
7f66d9a8a000-7f66d9a8d000 rw-p 00000000 00:00 0
7f66d9a8d000-7f66d9a8e000 r--p 00022000 08:07 1578981                    /lib/x86_64-linux-gnu/ld-2.19.so
7f66d9a8e000-7f66d9a8f000 rw-p 00023000 08:07 1578981                    /lib/x86_64-linux-gnu/ld-2.19.so
7f66d9a8f000-7f66d9a90000 rw-p 00000000 00:00 0
7ffc47761000-7ffc47782000 rw-p 00000000 00:00 0                          [stack]
7ffc477ab000-7ffc477ad000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)
$

Fix this by simply always setting the mode, as it doesn't hurt even
when O_CREAT is not specified.

This bug is a regression introduced in fc3e40e, as xopen(), which
was originally used, would automatically set the mode.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
(cherry picked from commit e111a16404)
2016-01-13 13:33:38 -05:00
Denys Vlasenko 092fabcf1d [g]unzip: fix recent breakage.
Also, do emit error message we so painstakingly pass from gzip internals

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 6bd3fff51a)
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2015-12-02 00:03:42 -05:00
Denys Vlasenko 6767af17f1 unzip: test for bad archive SEGVing
function                                             old     new   delta
huft_build                                          1296    1300      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 1de25a6e87)
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2015-12-01 11:05:07 -05:00
Denys Vlasenko 5c23f2566c Apply post-1.24.0 patches, bump version to 1.24.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 02:29:00 +02:00
983 changed files with 11563 additions and 21401 deletions

No files matched your search

-4
View File
@@ -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.
+258 -113
View File
@@ -11,18 +11,15 @@ config HAVE_DOT_CONFIG
menu "Busybox Settings"
menu "General Configuration"
config DESKTOP
bool "Enable options for full-blown desktop systems"
default y
help
Enable options and features which are not essential.
Select this if you plan to use busybox on full-blown desktop machine
with common Linux distro, which needs higher level of command-line
compatibility.
If you are preparing your build to be used on an embedded box
where you have tighter control over the entire set of userspace
tools, you can unselect this option for smaller code size.
Select this only if you plan to use busybox on full-blown
desktop machine with common Linux distro, not on an embedded box.
config EXTRA_COMPAT
bool "Provide compatible behavior for rare corner cases (bigger code)"
@@ -61,6 +58,30 @@ config PLATFORM_LINUX
Answering 'N' here will disable such applets and hide the
corresponding configuration options.
choice
prompt "Buffer allocation policy"
default FEATURE_BUFFERS_USE_MALLOC
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
- Put them on stack. For some very small machines with limited stack
space, this can be deadly. For most folks, this works just fine.
- Put them in BSS. This works beautifully for computers with a real
MMU (and OS support), but wastes runtime RAM for uCLinux. This
behavior was the only one available for BusyBox versions 0.48 and
earlier.
config FEATURE_BUFFERS_USE_MALLOC
bool "Allocate with Malloc"
config FEATURE_BUFFERS_GO_ON_STACK
bool "Allocate on the Stack"
config FEATURE_BUFFERS_GO_IN_BSS
bool "Allocate in the .bss section"
endchoice
config SHOW_USAGE
bool "Show applet usage messages"
default y
@@ -95,21 +116,9 @@ config FEATURE_COMPRESS_USAGE
and have very little memory, this might not be a win. Otherwise,
you probably want this.
config BUSYBOX
bool "Include busybox applet"
default y
help
The busybox applet provides general help regarding busybox and
allows the included applets to be listed. It's also required
if applet links are to be installed at runtime.
If you can live without these features disabling this will save
some space.
config FEATURE_INSTALLER
bool "Support --install [-s] to install applet links at runtime"
default y
depends on BUSYBOX
help
Enable 'busybox --install [-s]' support. This will allow you to use
busybox at runtime to create hard links or symlinks for all the
@@ -123,6 +132,131 @@ config INSTALL_NO_USR
will install applets only to /bin and /sbin,
never to /usr/bin or /usr/sbin.
config LOCALE_SUPPORT
bool "Enable locale support (system needs locale for this to work)"
default n
help
Enable this if your system has locale support and you would like
busybox to support locale settings.
config UNICODE_SUPPORT
bool "Support Unicode"
default y
help
This makes various applets aware that one byte is not
one character on screen.
Busybox aims to eventually work correctly with Unicode displays.
Any older encodings are not guaranteed to work.
Probably by the time when busybox will be fully Unicode-clean,
other encodings will be mainly of historic interest.
config UNICODE_USING_LOCALE
bool "Use libc routines for Unicode (else uses internal ones)"
default n
depends on UNICODE_SUPPORT && LOCALE_SUPPORT
help
With this option on, Unicode support is implemented using libc
routines. Otherwise, internal implementation is used.
Internal implementation is smaller.
config FEATURE_CHECK_UNICODE_IN_ENV
bool "Check $LC_ALL, $LC_CTYPE and $LANG environment variables"
default n
depends on UNICODE_SUPPORT && !UNICODE_USING_LOCALE
help
With this option on, Unicode support is activated
only if locale-related variables have the value of the form
"xxxx.utf8"
Otherwise, Unicode support will be always enabled and active.
config SUBST_WCHAR
int "Character code to substitute unprintable characters with"
depends on UNICODE_SUPPORT
default 63
help
Typical values are 63 for '?' (works with any output device),
30 for ASCII substitute control code,
65533 (0xfffd) for Unicode replacement character.
config LAST_SUPPORTED_WCHAR
int "Range of supported Unicode characters"
depends on UNICODE_SUPPORT
default 767
help
Any character with Unicode value bigger than this is assumed
to be non-printable on output device. Many applets replace
such chars with substitution character.
The idea is that many valid printable Unicode chars are
nevertheless are not displayed correctly. Think about
combining charachers, double-wide hieroglyphs, obscure
characters in dozens of ancient scripts...
Many terminals, terminal emulators, xterms etc will fail
to handle them correctly. Choose the smallest value
which suits your needs.
Typical values are:
126 - ASCII only
767 (0x2ff) - there are no combining chars in [0..767] range
(the range includes Latin 1, Latin Ext. A and B),
code is ~700 bytes smaller for this case.
4351 (0x10ff) - there are no double-wide chars in [0..4351] range,
code is ~300 bytes smaller for this case.
12799 (0x31ff) - nearly all non-ideographic characters are
available in [0..12799] range, including
East Asian scripts like katakana, hiragana, hangul,
bopomofo...
0 - off, any valid printable Unicode character will be printed.
config UNICODE_COMBINING_WCHARS
bool "Allow zero-width Unicode characters on output"
default n
depends on UNICODE_SUPPORT
help
With this option off, any Unicode char with width of 0
is substituted on output.
config UNICODE_WIDE_WCHARS
bool "Allow wide Unicode characters on output"
default n
depends on UNICODE_SUPPORT
help
With this option off, any Unicode char with width > 1
is substituted on output.
config UNICODE_BIDI_SUPPORT
bool "Bidirectional character-aware line input"
default n
depends on UNICODE_SUPPORT && !UNICODE_USING_LOCALE
help
With this option on, right-to-left Unicode characters
are treated differently on input (e.g. cursor movement).
config UNICODE_NEUTRAL_TABLE
bool "In bidi input, support non-ASCII neutral chars too"
default n
depends on UNICODE_BIDI_SUPPORT
help
In most cases it's enough to treat only ASCII non-letters
(i.e. punctuation, numbers and space) as characters
with neutral directionality.
With this option on, more extensive (and bigger) table
of neutral chars will be used.
config UNICODE_PRESERVE_BROKEN
bool "Make it possible to enter sequences of chars which are not Unicode"
default n
depends on UNICODE_SUPPORT
help
With this option on, on line-editing input (such as used by shells)
invalid UTF-8 bytes are not substituted with the selected
substitution character.
For example, this means that entering 'l', 's', ' ', 0xff, [Enter]
at shell prompt will list file named 0xff (single char name
with char value 255), not file named '?'.
config PAM
bool "Support for PAM (Pluggable Authentication Modules)"
default n
@@ -130,6 +264,19 @@ config PAM
Use PAM in some busybox applets (currently login and httpd) instead
of direct access to password database.
config FEATURE_USE_SENDFILE
bool "Use sendfile system call"
default y
select PLATFORM_LINUX
help
When enabled, busybox will use the kernel sendfile() function
instead of read/write loops to copy data between file descriptors
(for example, cp command does this a lot).
If sendfile() doesn't work, copying code falls back to read/write
loop. sendfile() was originally implemented for faster I/O
from files to sockets, but since Linux 2.6.33 it was extended
to work for many more file types.
config LONG_OPTS
bool "Support for --long-options"
default y
@@ -338,7 +485,9 @@ config FEATURE_HAVE_RPC
# This is automatically selected if any of enabled applets need it.
# You do not need to select it manually.
comment 'Build Options'
endmenu
menu 'Build Options'
config STATIC
bool "Build BusyBox as a static binary (no shared libs)"
@@ -513,7 +662,93 @@ config EXTRA_LDLIBS
help
Additional LDLIBS to pass to the linker with -l.
comment 'Installation Options ("make install" behavior)'
endmenu
menu 'Debugging Options'
config DEBUG
bool "Build BusyBox with extra Debugging symbols"
default n
help
Say Y here if you wish to examine BusyBox internals while applets are
running. This increases the size of the binary considerably, and
should only be used when doing development. If you are doing
development and want to debug BusyBox, answer Y.
Most people should answer N.
config DEBUG_PESSIMIZE
bool "Disable compiler optimizations"
default n
depends on DEBUG
help
The compiler's optimization of source code can eliminate and reorder
code, resulting in an executable that's hard to understand when
stepping through it with a debugger. This switches it off, resulting
in a much bigger executable that more closely matches the source
code.
config UNIT_TEST
bool "Build unit tests"
default n
help
Say Y here if you want to build unit tests (both the framework and
test cases) as a Busybox applet. This results in bigger code, so you
probably don't want this option in production builds.
config WERROR
bool "Abort compilation on any warning"
default n
help
Selecting this will add -Werror to gcc command line.
Most people should answer N.
choice
prompt "Additional debugging library"
default NO_DEBUG_LIB
help
Using an additional debugging library will make BusyBox become
considerable larger and will cause it to run more slowly. You
should always leave this option disabled for production use.
dmalloc support:
----------------
This enables compiling with dmalloc ( http://dmalloc.com/ )
which is an excellent public domain mem leak and malloc problem
detector. To enable dmalloc, before running busybox you will
want to properly set your environment, for example:
export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
The 'debug=' value is generated using the following command
dmalloc -p log-stats -p log-non-free -p log-bad-space \
-p log-elapsed-time -p check-fence -p check-heap \
-p check-lists -p check-blank -p check-funcs -p realloc-copy \
-p allow-free-null
Electric-fence support:
-----------------------
This enables compiling with Electric-fence support. Electric
fence is another very useful malloc debugging library which uses
your computer's virtual memory hardware to detect illegal memory
accesses. This support will make BusyBox be considerable larger
and run slower, so you should leave this option disabled unless
you are hunting a hard to find memory problem.
config NO_DEBUG_LIB
bool "None"
config DMALLOC
bool "Dmalloc"
config EFENCE
bool "Electric-fence"
endchoice
endmenu
menu 'Installation Options ("make install" behavior)'
choice
prompt "What kind of applet links to install"
@@ -579,102 +814,12 @@ config PREFIX
help
Define your directory to install BusyBox files/subdirs in.
comment 'Debugging Options'
config DEBUG
bool "Build BusyBox with extra Debugging symbols"
default n
help
Say Y here if you wish to examine BusyBox internals while applets are
running. This increases the size of the binary considerably, and
should only be used when doing development. If you are doing
development and want to debug BusyBox, answer Y.
Most people should answer N.
config DEBUG_PESSIMIZE
bool "Disable compiler optimizations"
default n
depends on DEBUG
help
The compiler's optimization of source code can eliminate and reorder
code, resulting in an executable that's hard to understand when
stepping through it with a debugger. This switches it off, resulting
in a much bigger executable that more closely matches the source
code.
config DEBUG_SANITIZE
bool "Enable runtime sanitizers (ASAN/LSAN/USAN/etc...)"
default n
help
Say Y here if you want to enable runtime sanitizers. These help
catch bad memory accesses (e.g. buffer overflows), but will make
the executable larger and slow down runtime a bit.
If you aren't developing/testing busybox, say N here.
config UNIT_TEST
bool "Build unit tests"
default n
help
Say Y here if you want to build unit tests (both the framework and
test cases) as a Busybox applet. This results in bigger code, so you
probably don't want this option in production builds.
config WERROR
bool "Abort compilation on any warning"
default n
help
Selecting this will add -Werror to gcc command line.
Most people should answer N.
choice
prompt "Additional debugging library"
default NO_DEBUG_LIB
help
Using an additional debugging library will make BusyBox become
considerable larger and will cause it to run more slowly. You
should always leave this option disabled for production use.
dmalloc support:
----------------
This enables compiling with dmalloc ( http://dmalloc.com/ )
which is an excellent public domain mem leak and malloc problem
detector. To enable dmalloc, before running busybox you will
want to properly set your environment, for example:
export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
The 'debug=' value is generated using the following command
dmalloc -p log-stats -p log-non-free -p log-bad-space \
-p log-elapsed-time -p check-fence -p check-heap \
-p check-lists -p check-blank -p check-funcs -p realloc-copy \
-p allow-free-null
Electric-fence support:
-----------------------
This enables compiling with Electric-fence support. Electric
fence is another very useful malloc debugging library which uses
your computer's virtual memory hardware to detect illegal memory
accesses. This support will make BusyBox be considerable larger
and run slower, so you should leave this option disabled unless
you are hunting a hard to find memory problem.
config NO_DEBUG_LIB
bool "None"
config DMALLOC
bool "Dmalloc"
config EFENCE
bool "Electric-fence"
endchoice
endmenu
source libbb/Config.in
endmenu
comment "Applets"
source archival/Config.in
+2 -7
View File
@@ -1,5 +1,5 @@
VERSION = 1
PATCHLEVEL = 26
PATCHLEVEL = 24
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
@@ -610,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
@@ -845,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
@@ -969,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 \
-5
View File
@@ -75,11 +75,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
+2
View File
@@ -258,3 +258,5 @@ vdprintf() -> similar sized functionality
* 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
View File
@@ -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 -82
View File
@@ -41,6 +41,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;
@@ -60,30 +62,24 @@ static int str_isalnum_(const char *s)
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 +94,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");
@@ -143,41 +119,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 +147,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
View File
@@ -90,8 +90,6 @@ int main(void)
printf("%s\n\n", usage_array[i].aname);
}
}
printf("=back\n\n");
return 0;
}
+2 -2
View File
@@ -30,8 +30,8 @@ config FEATURE_SEAMLESS_GZ
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.
+1 -1
View File
@@ -4,7 +4,7 @@
#
# Licensed under GPLv2, see file LICENSE in this source tree.
libs-y += libarchive/
libs-y += libarchive/
lib-y:=
+13 -3
View File
@@ -22,13 +22,23 @@
//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: 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: 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: most compilers come with their own ar utility.
//config: probably say N here.
//config:
//config:config FEATURE_AR_LONG_FILENAMES
//config: bool "Support for long filenames (not needed for debs)"
+28 -90
View File
@@ -9,12 +9,6 @@
/* 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
/* Note: must be kept in sync with archival/lzop.c */
enum {
@@ -127,7 +121,7 @@ int FAST_FUNC bbunpack(char **argv,
if (!(option_mask32 & SEAMLESS_MAGIC)) {
init_transformer_state(&xstate);
xstate.signature_skipped = 0;
xstate.check_signature = 1;
/*xstate.src_fd = STDIN_FILENO; - already is */
xstate.dst_fd = STDOUT_FILENO;
status = unpacker(&xstate);
@@ -196,10 +190,7 @@ int FAST_FUNC bbunpack(char **argv,
return exitcode;
}
#if ENABLE_UNCOMPRESS \
|| ENABLE_BUNZIP2 || ENABLE_BZCAT \
|| 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)
{
@@ -229,7 +220,7 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
//config:config UNCOMPRESS
//config: bool "uncompress"
//config: default n # ancient
//config: default n
//config: help
//config: uncompress is used to decompress archives created by compress.
//config: Not much used anymore, replaced by gzip/gunzip.
@@ -299,25 +290,12 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
//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"
//config: default y
//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: help
//config: Enable use of long options.
//applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))
//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
//kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o
#if ENABLE_GUNZIP || ENABLE_ZCAT
#if ENABLE_GUNZIP
static
char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
{
@@ -343,17 +321,6 @@ 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
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
@@ -370,9 +337,6 @@ 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
applet_long_options = gunzip_longopts;
#endif
getopt32(argv, "cfvqdtn");
argv += optind;
@@ -380,7 +344,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
* Normally, "zcat" is just "gunzip -c".
* But if seamless magic is enabled, then we are much more clever.
*/
if (ENABLE_ZCAT && 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);
@@ -417,24 +381,18 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
//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"
//config: default y
//config: help
//config: Alias to "bunzip2 -c".
//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
//applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, 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
//kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o
#if ENABLE_BUNZIP2 || ENABLE_BZCAT
#if ENABLE_BUNZIP2
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
{
getopt32(argv, "cfvqdt");
argv += optind;
if (ENABLE_BZCAT && 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");
@@ -502,40 +460,27 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
//config: The BusyBox unlzma applet is limited to decompression only.
//config: On an x86 system, this applet adds about 4K.
//config:
//config:config LZCAT
//config: bool "lzcat"
//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: The BusyBox unlzma applet is limited to decompression only.
//config: On an x86 system, this applet adds about 4K.
//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.
//config:
//config:config FEATURE_LZMA_FAST
//config: bool "Optimize unlzma for speed"
//config: default n
//config: depends on UNLZMA || LZCAT || LZMA
//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_LZCAT(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat))
//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
//kbuild:lib-$(CONFIG_LZCAT) += bbunzip.o
//kbuild:lib-$(CONFIG_LZMA) += bbunzip.o
#if ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA
#if ENABLE_UNLZMA
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unlzma_main(int argc UNUSED_PARAM, char **argv)
{
@@ -546,7 +491,7 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage();
# endif
/* lzcat? */
if (ENABLE_LZCAT && applet_name[2] == 'c')
if (applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT;
argv += optind;
@@ -561,26 +506,19 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
//config: help
//config: unxz is a unlzma successor.
//config:
//config:config XZCAT
//config: bool "xzcat"
//config: default y
//config: help
//config: Alias to "unxz -c".
//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.
//applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP))
//applet:IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
//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
int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unxz_main(int argc UNUSED_PARAM, char **argv)
{
@@ -591,7 +529,7 @@ int unxz_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage();
# endif
/* xzcat? */
if (ENABLE_XZCAT && applet_name[2] == 'c')
if (applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT;
argv += optind;
+14 -42
View File
@@ -11,7 +11,6 @@
* Only supports new ASCII and CRC formats
*/
#include "libbb.h"
#include "common_bufsiz.h"
#include "bb_archive.h"
//config:config CPIO
@@ -23,7 +22,7 @@
//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: "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.
@@ -47,14 +46,14 @@
//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:"
@@ -72,7 +71,6 @@
//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: )
@@ -132,7 +130,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
@@ -152,8 +150,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,)
@@ -166,18 +163,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)
@@ -195,6 +181,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];
@@ -236,11 +223,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 */
@@ -293,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));
@@ -341,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;
@@ -357,7 +339,6 @@ 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;
@@ -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 = getopt32(argv, OPTION_STR, &cpio_filename, &cpio_owner);
#else
opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"),
&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);
}
+1 -1
View File
@@ -28,7 +28,7 @@
//config:config DPKG
//config: bool "dpkg"
//config: default y
//config: default n
//config: select FEATURE_SEAMLESS_GZ
//config: help
//config: dpkg is a medium-level tool to install, build, remove and manage
+54 -36
View File
@@ -7,7 +7,7 @@
//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.
@@ -16,20 +16,29 @@
//config:
//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"
@@ -40,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();
@@ -79,45 +89,53 @@ int dpkg_deb_main(int argc UNUSED_PARAM, char **argv)
llist_add_to(&control_tar_llist, (char*)"control.tar.xz");
#endif
/* Must have 1 or 2 args */
opt_complementary = "-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);
+5 -5
View File
@@ -77,15 +77,13 @@ aa: 85.1% -- replaced with aa.gz
//kbuild:lib-$(CONFIG_GZIP) += gzip.o
//usage:#define gzip_trivial_usage
//usage: "[-cf" IF_GUNZIP("d") IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..."
//usage: "[-cfd" IF_FEATURE_GZIP_LEVELS("123456789") "] [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_GUNZIP(
//usage: "\n -d Decompress"
//usage: )
//usage: "\n -c Write to stdout"
//usage: "\n -f Force"
//usage:
@@ -2162,7 +2160,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
@@ -2220,7 +2217,10 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
opt >>= ENABLE_GUNZIP ? 7 : 5; /* drop cfv[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] */
/* Map 1..3 to 4 */
if (opt & 0x7)
opt |= 1 << 4;
opt = ffs(opt >> 3);
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;
+2 -9
View File
@@ -4,7 +4,7 @@
#
# Licensed under GPLv2 or later, see file LICENSE in this source tree.
lib-y:= common.o
lib-y:=
COMMON_FILES:= \
\
@@ -48,23 +48,16 @@ lib-$(CONFIG_CPIO) += get_header_cpio.o
lib-$(CONFIG_TAR) += get_header_tar.o unsafe_prefix.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
lib-$(CONFIG_BUNZIP2) += open_transformer.o decompress_bunzip2.o
lib-$(CONFIG_BZCAT) += 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_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_GUNZIP) += open_transformer.o decompress_gunzip.o
lib-$(CONFIG_ZCAT) += 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_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
-9
View File
@@ -1,9 +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!!!";
+42 -76
View File
@@ -11,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];
@@ -29,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 = '/';
}
}
@@ -79,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:
@@ -87,22 +48,22 @@ 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");
}
@@ -112,25 +73,30 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
&& !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 && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) {
/* 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",
dst_name,
hard_link);
file_header->name,
file_header->link_target);
}
/* Hardlinks have no separate mode/ownership, skip chown/chmod */
goto ret;
@@ -140,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
);
@@ -158,32 +124,32 @@ 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);
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?)
res = symlink(file_header->link_target, dst_name);
if (res != 0
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",
dst_name,
file_header->name,
file_header->link_target);
}
break;
@@ -191,11 +157,11 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
case S_IFBLK:
case S_IFCHR:
case S_IFIFO:
res = mknod(dst_name, file_header->mode, file_header->device);
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", dst_name);
bb_perror_msg("can't create node %s", file_header->name);
}
break;
default:
@@ -220,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);
}
}
@@ -112,7 +112,8 @@ 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));
+5 -4
View File
@@ -1130,8 +1130,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
@@ -1201,7 +1202,7 @@ unpack_gz_stream(transformer_state_t *xstate)
if (check_signature16(xstate, GZIP_MAGIC))
return -1;
#else
if (!xstate->signature_skipped) {
if (xstate->check_signature) {
uint16_t magic2;
if (full_read(xstate->src_fd, &magic2, 2) != 2) {
@@ -1210,7 +1211,7 @@ unpack_gz_stream(transformer_state_t *xstate)
return -1;
}
if (magic2 == COMPRESS_MAGIC) {
xstate->signature_skipped = 2;
xstate->check_signature = 0;
return unpack_Z_stream(xstate);
}
if (magic2 != GZIP_MAGIC)
+1 -1
View File
@@ -55,7 +55,7 @@ unpack_xz_stream(transformer_state_t *xstate)
iobuf.out = membuf + BUFSIZ;
iobuf.out_size = BUFSIZ;
if (!xstate || xstate->signature_skipped) {
if (!xstate || xstate->check_signature == 0) {
/* Preload XZ file signature */
strcpy((char*)membuf, HEADER_MAGIC);
iobuf.in_size = HEADER_MAGIC_SIZE;
+1 -6
View File
@@ -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;
+14 -42
View File
@@ -60,21 +60,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;
@@ -112,39 +104,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 && is_prefixed_with(value, "path=")) {
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"
# define SELINUX_CONTEXT_KEYWORD "RHT.security.selinux"
if (is_prefixed_with(value, SELINUX_CONTEXT_KEYWORD"=")) {
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)
@@ -187,13 +170,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;
}
@@ -209,11 +186,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
@@ -445,7 +418,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 */
-4
View File
@@ -17,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;
}
+26 -29
View File
@@ -13,13 +13,16 @@ void FAST_FUNC init_transformer_state(transformer_state_t *xstate)
int FAST_FUNC check_signature16(transformer_state_t *xstate, unsigned magic16)
{
if (!xstate->signature_skipped) {
if (xstate->check_signature) {
uint16_t magic2;
if (full_read(xstate->src_fd, &magic2, 2) != 2 || magic2 != magic16) {
bb_error_msg("invalid magic");
#if 0 /* possible future extension */
if (xstate->check_signature > 1)
xfunc_die();
#endif
return -1;
}
xstate->signature_skipped = 2;
}
return 0;
}
@@ -99,7 +102,7 @@ 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,
int check_signature,
IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_state_t *xstate)
)
#else
@@ -120,7 +123,7 @@ void FAST_FUNC fork_transformer(int fd, const char *transform_prog)
IF_DESKTOP(long long) int r;
transformer_state_t xstate;
init_transformer_state(&xstate);
xstate.signature_skipped = signature_skipped;
xstate.check_signature = check_signature;
xstate.src_fd = fd;
xstate.dst_fd = fd_pipe.wr;
r = transformer(&xstate);
@@ -165,11 +168,12 @@ static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_comp
uint16_t b16[2];
uint32_t b32[1];
} magic;
int offset;
transformer_state_t *xstate;
offset = -2;
xstate = xzalloc(sizeof(*xstate));
xstate->src_fd = fd;
xstate->signature_skipped = 2;
/* .gz and .bz2 both have 2-byte signature, and their
* unpack_XXX_stream wants this header skipped. */
@@ -198,7 +202,7 @@ static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_comp
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;
@@ -220,8 +224,18 @@ static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_comp
*/
// USE_FOR_MMU(xstate->xformer = copy_stream;)
// USE_FOR_NOMMU(xstate->xformer_prog = "cat";)
/* fall through to seeking bck over bytes we read earlier */
USE_FOR_NOMMU(found_magic:)
/* NOMMU version of fork_transformer execs
* an external unzipper that wants
* file position at the start of the file.
*/
xlseek(fd, offset, SEEK_CUR);
USE_FOR_MMU(found_magic:)
/* In MMU case, if magic was found, seeking back is not necessary */
found_magic:
return xstate;
}
@@ -240,12 +254,6 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_compressed)
# if BB_MMU
fork_transformer_with_no_sig(xstate->src_fd, xstate->xformer);
# else
/* NOMMU version of fork_transformer execs
* an external unzipper that wants
* file position at the start of the file.
*/
xlseek(fd, - xstate->signature_skipped, SEEK_CUR);
xstate->signature_skipped = 0;
fork_transformer_with_sig(xstate->src_fd, xstate->xformer, xstate->xformer_prog);
# endif
free(xstate);
@@ -288,22 +296,14 @@ int FAST_FUNC open_zipped(const char *fname, int fail_if_not_compressed)
return -1;
fd = xstate->src_fd;
if (xstate->xformer) {
# 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;
}
fork_transformer_with_no_sig(xstate->src_fd, xstate->xformer);
# 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 */
fork_transformer_with_sig(xstate->src_fd, xstate->xformer, xstate->xformer_prog);
# endif
}
/* else: the file is not compressed */
free(xstate);
return fd;
@@ -331,9 +331,6 @@ void* FAST_FUNC xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_
}
} 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);
}
+20 -33
View File
@@ -31,33 +31,19 @@
//config: help
//config: Lzop compression/decompresion.
//config:
//config:config UNLZOP
//config: bool "unlzop"
//config: default y
//config: help
//config: Lzop decompresion.
//config:
//config:config LZOPCAT
//config: bool "lzopcat"
//config: default y
//config: help
//config: Alias to "unlzop -c".
//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.
//applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP))
//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: "[-cfvd123456789CF] [FILE]..."
@@ -71,21 +57,20 @@
//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: "[-cfvF] [FILE]..."
//usage: "[-cfvCF] [FILE]..."
//usage:#define unlzop_full_usage "\n\n"
//usage: " -c Write to stdout"
//usage: "\n -f Force"
//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"
@@ -458,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)));
@@ -655,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 */
@@ -665,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)
@@ -746,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(
@@ -767,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;
@@ -775,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;
@@ -878,7 +865,7 @@ static NOINLINE int lzo_decompress(const header_t *h)
}
free(b2);
return 1;
return ok;
}
/**********************************************************************/
@@ -910,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
};
@@ -1063,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;
@@ -1091,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;
@@ -1125,10 +1112,10 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
getopt32(argv, OPTION_STRING);
argv += optind;
/* 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);
+2 -3
View File
@@ -29,7 +29,6 @@
//usage: "\n -qpc List config files"
#include "libbb.h"
#include "common_bufsiz.h"
#include "bb_archive.h"
#include "rpm.h"
@@ -94,8 +93,8 @@ struct globals {
rpm_index **mytags;
int tagcount;
} 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 void extract_cpio(int fd, const char *source_rpm)
{
+24 -89
View File
@@ -146,23 +146,18 @@
#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_TAR_CREATE
@@ -860,7 +855,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,
@@ -885,13 +879,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),
};
@@ -935,7 +928,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"
@@ -965,7 +957,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();
@@ -980,29 +971,17 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
/* 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::" // --exclude=PATTERN is a list
"\xff::" // cumulative lists for --exclude
#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
;
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
/* 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;
}
if (argv[1] && argv[1][0] != '-') {
/* Compat:
* 1st argument without dash handles options with parameters
@@ -1031,22 +1010,18 @@ int tar_main(int argc UNUSED_PARAM, char **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
, &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
@@ -1054,49 +1029,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;
@@ -1198,10 +1135,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
// /* We need to know whether child (gzip/bzip/etc) exits abnormally */
// signal(SIGCHLD, check_errors_in_children);
#if ENABLE_FEATURE_TAR_CREATE
/* Create an archive */
if (opt & OPT_CREATE) {
# if SEAMLESS_COMPRESSION
#if SEAMLESS_COMPRESSION
const char *zipMode = NULL;
if (opt & OPT_COMPRESS)
zipMode = "compress";
@@ -1213,7 +1149,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
zipMode = "lzma";
if (opt & OPT_XZ)
zipMode = "xz";
# endif
#endif
/* NB: writeTarFile() closes tar_handle->src_fd */
return writeTarFile(tar_handle->src_fd, verboseFlag,
(opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0)
@@ -1221,7 +1157,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
tar_handle->accept,
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);)
+42 -96
View File
@@ -45,12 +45,6 @@
#include "libbb.h"
#include "bb_archive.h"
#if 0
# define dbg(...) bb_error_msg(__VA_ARGS__)
#else
# define dbg(...) ((void)0)
#endif
enum {
#if BB_BIG_ENDIAN
ZIP_FILEHEADER_MAGIC = 0x504b0304,
@@ -199,17 +193,15 @@ static uint32_t find_cdf_offset(void)
unsigned char *p;
off_t end;
unsigned char *buf = xzalloc(PEEK_FROM_END);
uint32_t found;
end = xlseek(zip_fd, 0, SEEK_END);
end -= PEEK_FROM_END;
if (end < 0)
end = 0;
dbg("Looking for cdf_offset starting from 0x%"OFF_FMT"x", end);
xlseek(zip_fd, end, SEEK_SET);
xlseek(zip_fd, end, SEEK_SET);
full_read(zip_fd, buf, PEEK_FROM_END);
found = BAD_CDF_OFFSET;
cde_header.formatted.cdf_offset = BAD_CDF_OFFSET;
p = buf;
while (p <= buf + PEEK_FROM_END - CDE_HEADER_LEN - 4) {
if (*p != 'P') {
@@ -228,25 +220,14 @@ static uint32_t find_cdf_offset(void)
/*
* I've seen .ZIP files with seemingly valid CDEs
* where cdf_offset points past EOF - ??
* This check ignores such CDEs:
* Ignore such CDEs:
*/
if (cde_header.formatted.cdf_offset < end + (p - buf)) {
found = cde_header.formatted.cdf_offset;
dbg("Possible cdf_offset:0x%x at 0x%"OFF_FMT"x",
(unsigned)found, end + (p-3 - buf));
dbg(" cdf_offset+cdf_size:0x%x",
(unsigned)(found + SWAP_LE32(cde_header.formatted.cdf_size)));
/*
* We do not "break" here because only the last CDE is valid.
* I've seen a .zip archive which contained a .zip file,
* uncompressed, and taking the first CDE was using
* the CDE inside that file!
*/
}
if (cde_header.formatted.cdf_offset < end + (p - buf))
break;
cde_header.formatted.cdf_offset = BAD_CDF_OFFSET;
}
free(buf);
dbg("Found cdf_offset:0x%x", (unsigned)found);
return found;
return cde_header.formatted.cdf_offset;
};
static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr)
@@ -259,22 +240,15 @@ static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr)
cdf_offset = find_cdf_offset();
if (cdf_offset != BAD_CDF_OFFSET) {
dbg("Reading CDF at 0x%x", (unsigned)cdf_offset);
xlseek(zip_fd, cdf_offset + 4, SEEK_SET);
xread(zip_fd, cdf_ptr->raw, CDF_HEADER_LEN);
FIX_ENDIANNESS_CDF(*cdf_ptr);
dbg(" file_name_length:%u extra_field_length:%u file_comment_length:%u",
(unsigned)cdf_ptr->formatted.file_name_length,
(unsigned)cdf_ptr->formatted.extra_field_length,
(unsigned)cdf_ptr->formatted.file_comment_length
);
cdf_offset += 4 + CDF_HEADER_LEN
+ cdf_ptr->formatted.file_name_length
+ cdf_ptr->formatted.extra_field_length
+ cdf_ptr->formatted.file_comment_length;
}
dbg("Returning file position to 0x%"OFF_FMT"x", org);
xlseek(zip_fd, org, SEEK_SET);
return cdf_offset;
};
@@ -487,7 +461,7 @@ int unzip_main(int argc, char **argv)
if (overwrite == O_PROMPT)
overwrite = O_NEVER;
} else {
static const char extn[][5] ALIGN1 = { ".zip", ".ZIP" };
static const char extn[][5] = { ".zip", ".ZIP" };
char *ext = src_fn + strlen(src_fn);
int src_fd;
@@ -514,11 +488,11 @@ int unzip_main(int argc, char **argv)
printf("Archive: %s\n", src_fn);
if (listing) {
puts(verbose ?
" Length Method Size Cmpr Date Time CRC-32 Name\n"
"-------- ------ ------- ---- ---------- ----- -------- ----"
" Length Method Size Ratio Date Time CRC-32 Name\n"
"-------- ------ ------- ----- ---- ---- ------ ----"
:
" Length Date Time Name\n"
"--------- ---------- ----- ----"
" Length Date Time Name\n"
" -------- ---- ---- ----"
);
}
}
@@ -558,14 +532,11 @@ int unzip_main(int argc, char **argv)
/* Check magic number */
xread(zip_fd, &magic, 4);
/* Central directory? It's at the end, so exit */
if (magic == ZIP_CDF_MAGIC) {
dbg("got ZIP_CDF_MAGIC");
if (magic == ZIP_CDF_MAGIC)
break;
}
#if ENABLE_DESKTOP
/* Data descriptor? It was a streaming file, go on */
if (magic == ZIP_DD_MAGIC) {
dbg("got ZIP_DD_MAGIC");
/* skip over duplicate crc32, cmpsize and ucmpsize */
unzip_skip(3 * 4);
continue;
@@ -573,7 +544,6 @@ int unzip_main(int argc, char **argv)
#endif
if (magic != ZIP_FILEHEADER_MAGIC)
bb_error_msg_and_die("invalid zip magic %08X", (int)magic);
dbg("got ZIP_FILEHEADER_MAGIC");
/* Read the file header */
xread(zip_fd, zip_header.raw, ZIP_HEADER_LEN);
@@ -617,11 +587,6 @@ int unzip_main(int argc, char **argv)
bb_error_msg_and_die("can't find file table");
}
#endif
dbg("File cmpsize:0x%x extra_len:0x%x ucmpsize:0x%x",
(unsigned)zip_header.formatted.cmpsize,
(unsigned)zip_header.formatted.extra_len,
(unsigned)zip_header.formatted.ucmpsize
);
/* Read filename */
free(dst_fn);
@@ -642,55 +607,40 @@ int unzip_main(int argc, char **argv)
} else {
if (listing) {
/* List entry */
char dtbuf[sizeof("mm-dd-yyyy hh:mm")];
sprintf(dtbuf, "%02u-%02u-%04u %02u:%02u",
(zip_header.formatted.moddate >> 5) & 0xf, // mm: 0x01e0
(zip_header.formatted.moddate) & 0x1f, // dd: 0x001f
(zip_header.formatted.moddate >> 9) + 1980, // yy: 0xfe00
(zip_header.formatted.modtime >> 11), // hh: 0xf800
(zip_header.formatted.modtime >> 5) & 0x3f // mm: 0x07e0
// seconds/2 are not shown, encoded in ----------- 0x001f
);
unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
if (!verbose) {
// " Length Date Time Name\n"
// "--------- ---------- ----- ----"
printf( "%9u " "%s " "%s\n",
// " Length Date Time Name\n"
// " -------- ---- ---- ----"
printf( "%9u %02u-%02u-%02u %02u:%02u %s\n",
(unsigned)zip_header.formatted.ucmpsize,
dtbuf,
(dostime & 0x01e00000) >> 21,
(dostime & 0x001f0000) >> 16,
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
(dostime & 0x0000f800) >> 11,
(dostime & 0x000007e0) >> 5,
dst_fn);
total_usize += zip_header.formatted.ucmpsize;
} else {
unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize;
if ((int32_t)percents < 0)
percents = 0; /* happens if ucmpsize < cmpsize */
percents = percents * 100;
if (zip_header.formatted.ucmpsize)
percents /= zip_header.formatted.ucmpsize;
// " Length Method Size Cmpr Date Time CRC-32 Name\n"
// "-------- ------ ------- ---- ---------- ----- -------- ----"
printf( "%8u %s" "%9u%4u%% " "%s " "%08x " "%s\n",
// " Length Method Size Ratio Date Time CRC-32 Name\n"
// "-------- ------ ------- ----- ---- ---- ------ ----"
printf( "%8u Defl:N" "%9u%4u%% %02u-%02u-%02u %02u:%02u %08x %s\n",
(unsigned)zip_header.formatted.ucmpsize,
zip_header.formatted.method == 0 ? "Stored" : "Defl:N", /* Defl is method 8 */
/* TODO: show other methods?
* 1 - Shrunk
* 2 - Reduced with compression factor 1
* 3 - Reduced with compression factor 2
* 4 - Reduced with compression factor 3
* 5 - Reduced with compression factor 4
* 6 - Imploded
* 7 - Reserved for Tokenizing compression algorithm
* 9 - Deflate64
* 10 - PKWARE Data Compression Library Imploding
* 11 - Reserved by PKWARE
* 12 - BZIP2
*/
(unsigned)zip_header.formatted.cmpsize,
(unsigned)percents,
dtbuf,
(dostime & 0x01e00000) >> 21,
(dostime & 0x001f0000) >> 16,
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
(dostime & 0x0000f800) >> 11,
(dostime & 0x000007e0) >> 5,
zip_header.formatted.crc32,
dst_fn);
total_usize += zip_header.formatted.ucmpsize;
total_size += zip_header.formatted.cmpsize;
}
total_usize += zip_header.formatted.ucmpsize;
i = 'n';
} else if (dst_fd == STDOUT_FILENO) {
/* Extracting to STDOUT */
@@ -793,25 +743,21 @@ int unzip_main(int argc, char **argv)
if (listing && quiet <= 1) {
if (!verbose) {
// " Length Date Time Name\n"
// "--------- ---------- ----- ----"
printf( " --------%21s" "-------\n"
"%9lu%21s" "%u files\n",
"",
total_usize, "", total_entries);
// " Length Date Time Name\n"
// " -------- ---- ---- ----"
printf( " -------- -------\n"
"%9lu" " %u files\n",
total_usize, total_entries);
} else {
unsigned long percents = total_usize - total_size;
if ((long)percents < 0)
percents = 0; /* happens if usize < size */
percents = percents * 100;
if (total_usize)
percents /= total_usize;
// " Length Method Size Cmpr Date Time CRC-32 Name\n"
// "-------- ------ ------- ---- ---------- ----- -------- ----"
printf( "-------- ------- ----%28s" "----\n"
"%8lu" "%17lu%4u%%%28s" "%u files\n",
"",
total_usize, total_size, (unsigned)percents, "",
// " Length Method Size Ratio Date Time CRC-32 Name\n"
// "-------- ------ ------- ----- ---- ---- ------ ----"
printf( "-------- ------- --- -------\n"
"%8lu" "%17lu%4u%% %u files\n",
total_usize, total_size, (unsigned)percents,
total_entries);
}
}
+3 -1
View File
@@ -118,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
@@ -389,7 +390,7 @@ CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=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=""
@@ -759,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
+3 -1
View File
@@ -130,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
@@ -394,7 +395,7 @@ CONFIG_FEATURE_KILL_DELAY=0
# CONFIG_FEATURE_INIT_SYSLOG 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=""
@@ -761,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
+3 -1
View File
@@ -128,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
@@ -406,7 +407,7 @@ CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=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=""
@@ -777,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
+4 -1
View File
@@ -89,6 +89,7 @@ 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
@@ -134,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
@@ -424,7 +426,7 @@ CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=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
@@ -813,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
File diff suppressed because it is too large. Load diff
+4 -1
View File
@@ -107,6 +107,7 @@ 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
@@ -154,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
@@ -447,7 +449,7 @@ CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=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
@@ -842,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
+4 -1
View File
@@ -96,6 +96,7 @@ 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
@@ -151,6 +152,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_GZIP=y
# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
CONFIG_GZIP_FAST=0
@@ -457,7 +459,7 @@ CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=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
@@ -868,6 +870,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
+4 -1
View File
@@ -89,6 +89,7 @@ CONFIG_PREFIX="./_install"
#
# Busybox Library Tuning
#
# CONFIG_FEATURE_SYSTEMD is not set
CONFIG_FEATURE_RTMINMAX=y
CONFIG_PASSWORD_MINLEN=6
CONFIG_MD5_SMALL=1
@@ -134,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
@@ -424,7 +426,7 @@ CONFIG_FEATURE_KILL_DELAY=0
# CONFIG_FEATURE_INIT_SYSLOG 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
@@ -813,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
+3 -1
View File
@@ -132,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
@@ -421,7 +422,7 @@ CONFIG_FEATURE_KILL_DELAY=0
# CONFIG_FEATURE_INIT_SYSLOG 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
@@ -794,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
+166
View File
@@ -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
+16
View File
@@ -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
-11
View File
@@ -6,17 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CHVT
//config: bool "chvt"
//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(chvt, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_CHVT) += chvt.o
//usage:#define chvt_trivial_usage
//usage: "N"
-9
View File
@@ -6,15 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CLEAR
//config: bool "clear"
//config: default y
//config: help
//config: This program clears the terminal screen.
//applet:IF_CLEAR(APPLET(clear, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_CLEAR) += clear.o
//usage:#define clear_trivial_usage
//usage: ""
+1 -9
View File
@@ -7,16 +7,8 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config DEALLOCVT
//config: bool "deallocvt"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: This program deallocates unused virtual consoles.
//applet:IF_DEALLOCVT(APPLET(deallocvt, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_DEALLOCVT) += deallocvt.o
/* no options, no getopt */
//usage:#define deallocvt_trivial_usage
//usage: "[N]"
+1 -13
View File
@@ -7,17 +7,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*
*/
//config:config DUMPKMAP
//config: bool "dumpkmap"
//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(dumpkmap, BB_DIR_BIN, BB_SUID_DROP))
//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 {
@@ -48,7 +37,6 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
struct kbentry ke;
int i, j, fd;
#define flags bb_common_bufsiz1
setup_common_bufsiz();
/* When user accidentally runs "dumpkmap FILE"
* instead of "dumpkmap >FILE", we'd dump binary stuff to tty.
-10
View File
@@ -6,16 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config FGCONSOLE
//config: bool "fgconsole"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: This program prints active (foreground) console number.
//applet:IF_FGCONSOLE(APPLET(fgconsole, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_FGCONSOLE) += fgconsole.o
//usage:#define fgconsole_trivial_usage
//usage: ""
-10
View File
@@ -8,16 +8,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config KBD_MODE
//config: bool "kbd_mode"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: This program reports and sets keyboard mode.
//applet:IF_KBD_MODE(APPLET(kbd_mode, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_KBD_MODE) += kbd_mode.o
//usage:#define kbd_mode_trivial_usage
//usage: "[-a|k|s|u] [-C TTY]"
+2 -55
View File
@@ -9,57 +9,6 @@
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
//config:config LOADFONT
//config: bool "loadfont"
//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"
//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 for PSF2 console fonts"
//config: default y
//config: depends on LOADFONT || SETFONT
//config: help
//config: Support PSF2 console fonts.
//config:
//config:config FEATURE_LOADFONT_RAW
//config: bool "Support for old (raw) console fonts"
//config: default y
//config: depends on LOADFONT || SETFONT
//config: help
//config: Support old (raw) console fonts.
//applet:IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP))
//applet:IF_SETFONT(APPLET(setfont, BB_DIR_USR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_LOADFONT) += loadfont.o
//kbuild:lib-$(CONFIG_SETFONT) += loadfont.o
//usage:#define loadfont_trivial_usage
//usage: "< font"
@@ -370,10 +319,8 @@ int loadfont_main(int argc UNUSED_PARAM, char **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)
@@ -458,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);
-11
View File
@@ -6,17 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config LOADKMAP
//config: bool "loadkmap"
//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(loadkmap, BB_DIR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_LOADKMAP) += loadkmap.o
//usage:#define loadkmap_trivial_usage
//usage: "< keymap"
-11
View File
@@ -7,17 +7,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config OPENVT
//config: bool "openvt"
//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]"
+2 -11
View File
@@ -7,18 +7,9 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* "Standard" version of this tool is in ncurses package */
//config:config RESET
//config: bool "reset"
//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(reset, BB_DIR_USR_BIN, BB_SUID_DROP))
//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: ""
+2 -25
View File
@@ -6,26 +6,7 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config RESIZE
//config: bool "resize"
//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(resize, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_RESIZE) += resize.o
/* no options, no getopt */
//usage:#define resize_trivial_usage
//usage: ""
@@ -33,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)
@@ -54,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"
-18
View File
@@ -7,24 +7,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config SETCONSOLE
//config: bool "setconsole"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: This program redirects the system console to another device,
//config: like the current tty while logged in via telnet.
//config:
//config:config FEATURE_SETCONSOLE_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on SETCONSOLE && LONG_OPTS
//config: help
//config: Support long options for the setconsole applet.
//applet:IF_SETCONSOLE(APPLET(setconsole, BB_DIR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_SETCONSOLE) += setconsole.o
//usage:#define setconsole_trivial_usage
//usage: "[-r" IF_FEATURE_SETCONSOLE_LONG_OPTIONS("|--reset") "] [DEVICE]"
-11
View File
@@ -8,17 +8,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config SETKEYCODES
//config: bool "setkeycodes"
//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(setkeycodes, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
//usage:#define setkeycodes_trivial_usage
//usage: "SCANCODE KEYCODE..."
-10
View File
@@ -8,16 +8,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config SETLOGCONS
//config: bool "setlogcons"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: This program redirects the output console of kernel messages.
//applet:IF_SETLOGCONS(APPLET(setlogcons, BB_DIR_USR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_SETLOGCONS) += setlogcons.o
//usage:#define setlogcons_trivial_usage
//usage: "[N]"
-10
View File
@@ -6,16 +6,6 @@
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
//config:config SHOWKEY
//config: bool "showkey"
//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]"
+709
View File
@@ -7,6 +7,702 @@ menu "Coreutils"
INSERT
config CAL
bool "cal"
default y
help
cal is used to display a monthly calendar.
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 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 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, -v and -F) 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
-F Same as -f, but keep retrying
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 UNAME_OSNAME
string "Operating system name"
default "GNU/Linux"
depends on UNAME
help
Sets the operating system name reported by uname -o. The
default is "GNU/Linux".
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"
config FEATURE_VERBOSE
@@ -51,4 +747,17 @@ config FEATURE_HUMAN_READABLE
help
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
+71 -13
View File
@@ -9,17 +9,75 @@ 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 adduser
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_SH_IS_ASH) += echo.o # used by ash
lib-$(CONFIG_BASH_IS_ASH) += echo.o # used by ash
lib-$(CONFIG_HUSH) += echo.o # used by hush
lib-$(CONFIG_SH_IS_HUSH) += echo.o # used by hush
lib-$(CONFIG_BASH_IS_HUSH) += echo.o # used by hush
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_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
+6 -7
View File
@@ -14,6 +14,12 @@
* 2) Don't check for options, as per SUSv3.
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
*/
/* 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
@@ -22,13 +28,6 @@
//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 */
//usage:#define basename_trivial_usage
//usage: "FILE [SUFFIX]"
//usage:#define basename_full_usage "\n\n"
+5 -13
View File
@@ -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"
//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"
+9 -7
View File
@@ -6,6 +6,15 @@
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
//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
@@ -13,13 +22,6 @@
//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.
//applet:IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat))
//kbuild:lib-$(CONFIG_CAT) += cat.o
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
//usage:#define cat_trivial_usage
//usage: "[FILE]..."
//usage:#define cat_full_usage "\n\n"
+1 -15
View File
@@ -10,17 +10,6 @@
/* See "Cat -v considered harmful" at
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
//config:config CATV
//config: bool "catv"
//config: default y
//config: help
//config: Display nonprinting characters as escape sequences (like some
//config: implementations' cat -v option).
//applet:IF_CATV(APPLET(catv, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_CATV) += catv.o
//usage:#define catv_trivial_usage
//usage: "[-etv] [FILE]..."
//usage:#define catv_full_usage "\n\n"
@@ -30,7 +19,6 @@
//usage: "\n -v Don't use ^x or M-x escapes"
#include "libbb.h"
#include "common_bufsiz.h"
#define CATV_OPT_e (1<<0)
#define CATV_OPT_t (1<<1)
@@ -60,9 +48,6 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
/* Read from stdin if there's nothing else to do. */
if (!argv[0])
*--argv = (char*)"-";
#define read_buf bb_common_bufsiz1
setup_common_bufsiz();
do {
fd = open_or_warn_stdin(*argv);
if (fd < 0) {
@@ -72,6 +57,7 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
for (;;) {
int i, res;
#define read_buf bb_common_bufsiz1
res = read(fd, read_buf, COMMON_BUFSIZE);
if (res < 0)
retval = EXIT_FAILURE;
-9
View File
@@ -6,15 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CHGRP
//config: bool "chgrp"
//config: default y
//config: help
//config: chgrp is used to change the group ownership of files.
//applet:IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, BB_DIR_BIN, BB_SUID_DROP, chgrp))
//kbuild:lib-$(CONFIG_CHGRP) += chgrp.o chown.o
/* BB_AUDIT SUSv3 defects - none? */
/* BB_AUDIT GNU defects - unsupported long options. */
-9
View File
@@ -9,15 +9,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CHMOD
//config: bool "chmod"
//config: default y
//config: help
//config: chmod is used to change the access permission of files.
//applet:IF_CHMOD(APPLET_NOEXEC(chmod, chmod, BB_DIR_BIN, BB_SUID_DROP, chmod))
//kbuild:lib-$(CONFIG_CHMOD) += chmod.o
/* BB_AUDIT SUSv3 compliant */
/* BB_AUDIT GNU defects - unsupported long options. */
+6 -19
View File
@@ -6,31 +6,14 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CHOWN
//config: bool "chown"
//config: default y
//config: help
//config: chown is used to change the user and/or group ownership
//config: of files.
//config:
//config:config FEATURE_CHOWN_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on CHOWN && LONG_OPTS
//config: help
//config: Enable use of long options
//applet:IF_CHOWN(APPLET_NOEXEC(chown, chown, BB_DIR_BIN, BB_SUID_DROP, chown))
//kbuild:lib-$(CONFIG_CHOWN) += chown.o
/* BB_AUDIT SUSv3 defects - none? */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
//usage:#define chown_trivial_usage
//usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... USER[:[GRP]] FILE..."
//usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... OWNER[<.|:>[GROUP]] FILE..."
//usage:#define chown_full_usage "\n\n"
//usage: "Change the owner and/or group of each FILE to USER and/or GRP\n"
//usage: "Change the owner and/or group of each FILE to OWNER and/or GROUP\n"
//usage: "\n -R Recurse"
//usage: "\n -h Affect symlinks instead of symlink targets"
//usage: IF_DESKTOP(
@@ -129,6 +112,10 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
int opt, flags;
struct param_t param;
/* Just -1 might not work: uid_t may be unsigned long */
param.ugid.uid = -1L;
param.ugid.gid = -1L;
#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
applet_long_options = chown_longopts;
#endif
-10
View File
@@ -6,16 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CHROOT
//config: bool "chroot"
//config: default y
//config: help
//config: chroot is used to change the root directory and run a command.
//config: The default command is `/bin/sh'.
//applet:IF_CHROOT(APPLET(chroot, BB_DIR_USR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_CHROOT) += chroot.o
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
+1 -12
View File
@@ -6,15 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CKSUM
//config: bool "cksum"
//config: default y
//config: help
//config: cksum is used to calculate the CRC32 checksum of a file.
//applet:IF_CKSUM(APPLET_NOEXEC(cksum, cksum, BB_DIR_USR_BIN, BB_SUID_DROP, cksum))
//kbuild:lib-$(CONFIG_CKSUM) += cksum.o
//usage:#define cksum_trivial_usage
//usage: "FILES..."
@@ -22,7 +13,6 @@
//usage: "Calculate the CRC32 checksums of FILES"
#include "libbb.h"
#include "common_bufsiz.h"
/* This is a NOEXEC applet. Be very careful! */
@@ -42,7 +32,6 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
argv++;
#endif
setup_common_bufsiz();
do {
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
@@ -54,7 +43,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
length = 0;
#define read_buf bb_common_bufsiz1
while ((bytes_read = safe_read(fd, read_buf, COMMON_BUFSIZE)) > 0) {
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
length += bytes_read;
crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
}
-10
View File
@@ -6,16 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config COMM
//config: bool "comm"
//config: default y
//config: help
//config: comm is used to compare two files line by line and return
//config: a three-column output.
//applet:IF_COMM(APPLET(comm, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_COMM) += comm.o
//usage:#define comm_trivial_usage
//usage: "[-123] FILE1 FILE2"
+15 -37
View File
@@ -7,29 +7,13 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cp.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Size reduction.
*/
//config:config CP
//config: bool "cp"
//config: default y
//config: help
//config: cp is used to copy files and directories.
//config:
//config:config FEATURE_CP_LONG_OPTIONS
//config: bool "Enable long options for cp"
//config: default y
//config: depends on CP && LONG_OPTS
//config: help
//config: Enable long options for cp.
//config: Also add support for --parents option.
//applet:IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp))
//kbuild:lib-$(CONFIG_CP) += cp.o
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cp.html */
//usage:#define cp_trivial_usage
//usage: "[OPTIONS] SOURCE... DEST"
@@ -47,7 +31,6 @@
//usage: "\n -f Overwrite"
//usage: "\n -i Prompt before overwrite"
//usage: "\n -l,-s Create (sym)links"
//usage: "\n -u Copy only newer files"
#include "libbb.h"
#include "libcoreutils/coreutils.h"
@@ -66,10 +49,12 @@ int cp_main(int argc, char **argv)
int flags;
int status;
enum {
FILEUTILS_CP_OPTNUM = sizeof(FILEUTILS_CP_OPTSTR)-1,
OPT_a = 1 << (sizeof(FILEUTILS_CP_OPTSTR)-1),
OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)),
OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1),
OPT_v = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2),
#if ENABLE_FEATURE_CP_LONG_OPTIONS
/*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */
OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1),
OPT_parents = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3),
#endif
};
@@ -91,12 +76,10 @@ int cp_main(int argc, char **argv)
"recursive\0" No_argument "R"
"symbolic-link\0" No_argument "s"
"verbose\0" No_argument "v"
"update\0" No_argument "u"
"remove-destination\0" No_argument "\xff"
"parents\0" No_argument "\xfe"
"parents\0" No_argument "\xff"
;
#endif
flags = getopt32(argv, FILEUTILS_CP_OPTSTR);
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPv");
/* Options of cp from GNU coreutils 6.10:
* -a, --archive
* -f, --force
@@ -111,11 +94,6 @@ int cp_main(int argc, char **argv)
* -d same as --no-dereference --preserve=links
* -p same as --preserve=mode,ownership,timestamps
* -c same as --preserve=context
* -u, --update
* copy only when the SOURCE file is newer than the destination
* file or when the destination file is missing
* --remove-destination
* remove each existing destination file before attempting to open
* --parents
* use full source file name under DIRECTORY
* NOT SUPPORTED IN BBOX:
@@ -128,6 +106,8 @@ int cp_main(int argc, char **argv)
* preserve attributes (default: mode,ownership,timestamps),
* if possible additional attributes: security context,links,all
* --no-preserve=ATTR_LIST
* --remove-destination
* remove each existing destination file before attempting to open
* --sparse=WHEN
* control creation of sparse files
* --strip-trailing-slashes
@@ -138,6 +118,9 @@ int cp_main(int argc, char **argv)
* copy all SOURCE arguments into DIRECTORY
* -T, --no-target-directory
* treat DEST as a normal file
* -u, --update
* copy only when the SOURCE file is newer than the destination
* file or when the destination file is missing
* -x, --one-file-system
* stay on this file system
* -Z, --context=CONTEXT
@@ -173,16 +156,11 @@ int cp_main(int argc, char **argv)
return EXIT_FAILURE;
#if ENABLE_FEATURE_CP_LONG_OPTIONS
//bb_error_msg("flags:%x FILEUTILS_RMDEST:%x OPT_parents:%x",
// flags, FILEUTILS_RMDEST, OPT_parents);
if (flags & OPT_parents) {
if (!(d_flags & 2)) {
bb_error_msg_and_die("with --parents, the destination must be a directory");
}
}
if (flags & FILEUTILS_RMDEST) {
flags |= FILEUTILS_FORCE;
}
#endif
/* ...if neither is a directory... */
-10
View File
@@ -8,16 +8,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config CUT
//config: bool "cut"
//config: default y
//config: help
//config: cut is used to print selected parts of lines from
//config: each file to stdout.
//applet:IF_CUT(APPLET_NOEXEC(cut, cut, BB_DIR_USR_BIN, BB_SUID_DROP, cut))
//kbuild:lib-$(CONFIG_CUT) += cut.o
//usage:#define cut_trivial_usage
//usage: "[OPTIONS] [FILE]..."
+7 -8
View File
@@ -8,7 +8,8 @@
* bugfixes and cleanup by Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
*/
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
setting time using UTC and displaying it, as well as
@@ -18,6 +19,10 @@
/* Input parsing code is always bulky - used heavy duty libc stuff as
much as possible, missed out a lot of bounds checking */
//applet:IF_DATE(APPLET(date, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_DATE) += date.o
//config:config DATE
//config: bool "date"
//config: default y
@@ -58,10 +63,6 @@
//config: the same format. With it on, 'date DATE' additionally supports
//config: MMDDhhmm[[YY]YY][.ss] format.
//applet:IF_DATE(APPLET(date, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_DATE) += date.o
/* GNU coreutils 6.9 man page:
* date [OPTION]... [+FORMAT]
* date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
@@ -137,7 +138,6 @@
//usage: "Wed Apr 12 18:52:41 MDT 2000\n"
#include "libbb.h"
#include "common_bufsiz.h"
#if ENABLE_FEATURE_DATE_NANO
# include <sys/syscall.h>
#endif
@@ -368,7 +368,6 @@ int date_main(int argc UNUSED_PARAM, char **argv)
#endif
#define date_buf bb_common_bufsiz1
setup_common_bufsiz();
if (*fmt_dt2str == '\0') {
/* With no format string, just print a blank line */
date_buf[0] = '\0';
@@ -378,7 +377,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */
strftime(date_buf, COMMON_BUFSIZE, fmt_dt2str, &tm_time);
strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time);
}
puts(date_buf);
+31 -59
View File
@@ -2,10 +2,12 @@
/*
* Mini dd implementation for busybox
*
*
* Copyright (C) 2000,2001 Matt Kraai
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config DD
//config: bool "dd"
//config: default y
@@ -51,13 +53,9 @@
//config: help
//config: Enables support for status=noxfer/none option.
//applet:IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd))
//kbuild:lib-$(CONFIG_DD) += dd.o
//usage:#define dd_trivial_usage
//usage: "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n"
//usage: " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync] [iflag=skip_bytes]")
//usage: " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync]")
//usage:#define dd_full_usage "\n\n"
//usage: "Copy a file with converting and formatting\n"
//usage: "\n if=FILE Read from FILE instead of stdin"
@@ -78,7 +76,6 @@
//usage: "\n conv=sync Pad blocks with zeros"
//usage: "\n conv=fsync Physically write data out before finishing"
//usage: "\n conv=swab Swap every pair of bytes"
//usage: "\n iflag=skip_bytes skip=N is in bytes"
//usage: )
//usage: IF_FEATURE_DD_STATUS(
//usage: "\n status=noxfer Suppress rate output"
@@ -93,7 +90,6 @@
//usage: "4+0 records out\n"
#include "libbb.h"
#include "common_bufsiz.h"
/* This is a NOEXEC applet. Be very careful! */
@@ -111,9 +107,8 @@ struct globals {
#endif
int flags;
} FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1)
#define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { \
setup_common_bufsiz(); \
/* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \
} while (0)
@@ -127,15 +122,11 @@ enum {
FLAG_FSYNC = (1 << 3) * ENABLE_FEATURE_DD_IBS_OBS,
FLAG_SWAB = (1 << 4) * ENABLE_FEATURE_DD_IBS_OBS,
/* end of conv flags */
/* start of input flags */
FLAG_IFLAG_SHIFT = 5,
FLAG_SKIP_BYTES = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS,
/* end of input flags */
FLAG_TWOBUFS = (1 << 6) * ENABLE_FEATURE_DD_IBS_OBS,
FLAG_COUNT = 1 << 7,
FLAG_STATUS = 1 << 8,
FLAG_STATUS_NONE = 1 << 9,
FLAG_STATUS_NOXFER = 1 << 10,
FLAG_TWOBUFS = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS,
FLAG_COUNT = 1 << 6,
FLAG_STATUS = 1 << 7,
FLAG_STATUS_NONE = 1 << 7,
FLAG_STATUS_NOXFER = 1 << 8,
};
static void dd_output_status(int UNUSED_PARAM cur_signal)
@@ -212,47 +203,18 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
# define XATOU_SFX xatoul_sfx
#endif
#if ENABLE_FEATURE_DD_IBS_OBS
static int parse_comma_flags(char *val, const char *words, const char *error_in)
{
int flags = 0;
while (1) {
int n;
char *arg;
/* find ',', replace them with NUL so we can use val for
* index_in_strings() without copying.
* We rely on val being non-null, else strchr would fault.
*/
arg = strchr(val, ',');
if (arg)
*arg = '\0';
n = index_in_strings(words, val);
if (n < 0)
bb_error_msg_and_die(bb_msg_invalid_arg_to, val, error_in);
flags |= (1 << n);
if (!arg) /* no ',' left, so this was the last specifier */
break;
*arg = ','; /* to preserve ps listing */
val = arg + 1; /* skip this keyword and ',' */
}
return flags;
}
#endif
int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dd_main(int argc UNUSED_PARAM, char **argv)
{
static const char keywords[] ALIGN1 =
"bs\0""count\0""seek\0""skip\0""if\0""of\0"IF_FEATURE_DD_STATUS("status\0")
#if ENABLE_FEATURE_DD_IBS_OBS
"ibs\0""obs\0""conv\0""iflag\0"
"ibs\0""obs\0""conv\0"
#endif
;
#if ENABLE_FEATURE_DD_IBS_OBS
static const char conv_words[] ALIGN1 =
"notrunc\0""sync\0""noerror\0""fsync\0""swab\0";
static const char iflag_words[] ALIGN1 =
"skip_bytes\0";
#endif
#if ENABLE_FEATURE_DD_STATUS
static const char status_words[] ALIGN1 =
@@ -270,7 +232,6 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
OP_ibs,
OP_obs,
OP_conv,
OP_iflag,
/* Must be in the same order as FLAG_XXX! */
OP_conv_notrunc = 0,
OP_conv_sync,
@@ -290,7 +251,6 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
//ibm from ASCII to alternate EBCDIC
/* Partially implemented: */
//swab swap every pair of input bytes: will abort on non-even reads
OP_iflag_skip_bytes,
#endif
};
smallint exitcode = EXIT_FAILURE;
@@ -355,11 +315,24 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
/*continue;*/
}
if (what == OP_conv) {
G.flags |= parse_comma_flags(val, conv_words, "conv");
/*continue;*/
}
if (what == OP_iflag) {
G.flags |= parse_comma_flags(val, iflag_words, "iflag") << FLAG_IFLAG_SHIFT;
while (1) {
int n;
/* find ',', replace them with NUL so we can use val for
* index_in_strings() without copying.
* We rely on val being non-null, else strchr would fault.
*/
arg = strchr(val, ',');
if (arg)
*arg = '\0';
n = index_in_strings(conv_words, val);
if (n < 0)
bb_error_msg_and_die(bb_msg_invalid_arg, val, "conv");
G.flags |= (1 << n);
if (!arg) /* no ',' left, so this was the last specifier */
break;
/* *arg = ','; - to preserve ps listing? */
val = arg + 1; /* skip this keyword and ',' */
}
/*continue;*/
}
#endif
@@ -395,7 +368,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
int n;
n = index_in_strings(status_words, val);
if (n < 0)
bb_error_msg_and_die(bb_msg_invalid_arg_to, val, "status");
bb_error_msg_and_die(bb_msg_invalid_arg, val, "status");
G.flags |= FLAG_STATUS << n;
/*continue;*/
}
@@ -448,10 +421,9 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
outfile = bb_msg_standard_output;
}
if (skip) {
size_t blocksz = (G.flags & FLAG_SKIP_BYTES) ? 1 : ibs;
if (lseek(ifd, skip * blocksz, SEEK_CUR) < 0) {
if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
do {
ssize_t n = safe_read(ifd, ibuf, blocksz);
ssize_t n = safe_read(ifd, ibuf, ibs);
if (n < 0)
goto die_infile;
if (n == 0)
+16 -52
View File
@@ -7,6 +7,10 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -t missing. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/df.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Size reduction. Removed floating point dependency. Added error checking
@@ -17,30 +21,6 @@
*
* Implement -P and -B; better coreutils compat; cleanup
*/
//config:config DF
//config: bool "df"
//config: default y
//config: help
//config: df reports the amount of disk space used and available
//config: on filesystems.
//config:
//config:config FEATURE_DF_FANCY
//config: bool "Enable -a, -i, -B"
//config: default y
//config: depends on DF
//config: help
//config: This option enables -a, -i and -B.
//config:
//config: -a Show all filesystems
//config: -i Inodes
//config: -B <SIZE> Blocksize
//applet:IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_DF) += df.o
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -t missing. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/df.html */
//usage:#define df_trivial_usage
//usage: "[-Pk"
@@ -129,19 +109,8 @@ int df_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_MEGA)
df_disp_hr = 1024*1024;
if (opt & OPT_BSIZE) {
/* GNU coreutils 8.25 accepts "-BMiB" form too */
int i;
for (i = 0; kmg_i_suffixes[i].suffix[0]; i++) {
if (strcmp(kmg_i_suffixes[i].suffix, chp) == 0) {
df_disp_hr = kmg_i_suffixes[i].mult;
goto got_it;
}
}
/* Range used to disallow 0 */
df_disp_hr = xatoul_range_sfx(chp, 1, ULONG_MAX, kmg_i_suffixes);
got_it: ;
}
if (opt & OPT_BSIZE)
df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
/* From the manpage of df from coreutils-6.10:
* Disk space is shown in 1K blocks by default, unless the environment
@@ -214,17 +183,12 @@ int df_main(int argc UNUSED_PARAM, char **argv)
bb_simple_perror_msg(mount_point);
goto set_error;
}
/* Some uclibc versions were seen to lose f_frsize
* (kernel does return it, but then uclibc does not copy it)
*/
if (s.f_frsize == 0)
s.f_frsize = s.f_bsize;
if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) {
if (opt & OPT_INODE) {
s.f_blocks = s.f_files;
s.f_bavail = s.f_bfree = s.f_ffree;
s.f_frsize = 1;
s.f_bsize = 1;
if (df_disp_hr)
df_disp_hr = 1;
@@ -282,26 +246,26 @@ int df_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_HUMAN_READABLE
printf(" %9s ",
/* f_blocks x f_frsize / df_disp_hr, show one fractional,
/* f_blocks x f_bsize / df_disp_hr, show one fractional,
* use suffixes if df_disp_hr == 0 */
make_human_readable_str(s.f_blocks, s.f_frsize, df_disp_hr));
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf(" %9s " + 1,
/* EXPR x f_frsize / df_disp_hr, show one fractional,
/* EXPR x f_bsize / df_disp_hr, show one fractional,
* use suffixes if df_disp_hr == 0 */
make_human_readable_str((s.f_blocks - s.f_bfree),
s.f_frsize, df_disp_hr));
s.f_bsize, df_disp_hr));
printf("%9s %3u%% %s\n",
/* f_bavail x f_frsize / df_disp_hr, show one fractional,
/* f_bavail x f_bsize / df_disp_hr, show one fractional,
* use suffixes if df_disp_hr == 0 */
make_human_readable_str(s.f_bavail, s.f_frsize, df_disp_hr),
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf(" %9lu %9lu %9lu %3u%% %s\n",
kscale(s.f_blocks, s.f_frsize),
kscale(s.f_blocks - s.f_bfree, s.f_frsize),
kscale(s.f_bavail, s.f_frsize),
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks - s.f_bfree, s.f_bsize),
kscale(s.f_bavail, s.f_bsize),
blocks_percent_used, mount_point);
#endif
}
-10
View File
@@ -6,16 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config DIRNAME
//config: bool "dirname"
//config: default y
//config: help
//config: dirname is used to strip a non-directory suffix from
//config: a file name.
//applet:IF_DIRNAME(APPLET_NOFORK(dirname, dirname, BB_DIR_USR_BIN, BB_SUID_DROP, dirname))
//kbuild:lib-$(CONFIG_DIRNAME) += dirname.o
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
+12 -36
View File
@@ -10,26 +10,7 @@
* dos2unix filters reading input from stdin and writing output to stdout.
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config DOS2UNIX
//config: bool "dos2unix"
//config: default y
//config: help
//config: dos2unix is used to convert a text file from DOS format to
//config: UNIX format, and vice versa.
//config:
//config:config UNIX2DOS
//config: bool "unix2dos"
//config: default y
//config: help
//config: unix2dos is used to convert a text file from UNIX format to
//config: DOS format, and vice versa.
//applet:IF_DOS2UNIX(APPLET_NOEXEC(dos2unix, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, dos2unix))
//applet:IF_UNIX2DOS(APPLET_NOEXEC(unix2dos, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, unix2dos))
//kbuild:lib-$(CONFIG_DOS2UNIX) += dos2unix.o
//kbuild:lib-$(CONFIG_UNIX2DOS) += dos2unix.o
*/
//usage:#define dos2unix_trivial_usage
//usage: "[-ud] [FILE]"
@@ -60,7 +41,7 @@ enum {
static void convert(char *fn, int conv_type)
{
FILE *in, *out;
int ch;
int i;
char *temp_fn = temp_fn; /* for compiler */
char *resolved_fn = resolved_fn;
@@ -68,30 +49,28 @@ static void convert(char *fn, int conv_type)
out = stdout;
if (fn != NULL) {
struct stat st;
int fd;
resolved_fn = xmalloc_follow_symlinks(fn);
if (resolved_fn == NULL)
bb_simple_perror_msg_and_die(fn);
in = xfopen_for_read(resolved_fn);
xfstat(fileno(in), &st, resolved_fn);
fstat(fileno(in), &st);
temp_fn = xasprintf("%sXXXXXX", resolved_fn);
fd = xmkstemp(temp_fn);
if (fchmod(fd, st.st_mode) == -1)
i = xmkstemp(temp_fn);
if (fchmod(i, st.st_mode) == -1)
bb_simple_perror_msg_and_die(temp_fn);
fchown(fd, st.st_uid, st.st_gid);
out = xfdopen_for_write(fd);
out = xfdopen_for_write(i);
}
while ((ch = fgetc(in)) != EOF) {
if (ch == '\r')
while ((i = fgetc(in)) != EOF) {
if (i == '\r')
continue;
if (ch == '\n')
if (i == '\n')
if (conv_type == CT_UNIX2DOS)
fputc('\r', out);
fputc(ch, out);
fputc(i, out);
}
if (fn != NULL) {
@@ -111,12 +90,9 @@ int dos2unix_main(int argc UNUSED_PARAM, char **argv)
int o, conv_type;
/* See if we are supposed to be doing dos2unix or unix2dos */
if (ENABLE_DOS2UNIX
&& (!ENABLE_UNIX2DOS || applet_name[0] == 'd')
) {
conv_type = CT_UNIX2DOS;
if (applet_name[0] == 'd') {
conv_type = CT_DOS2UNIX;
} else {
conv_type = CT_UNIX2DOS;
}
/* -u convert to unix, -d convert to dos */
+24 -50
View File
@@ -8,6 +8,10 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 compliant (unless default blocksize set to 1k) */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/du.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Mostly rewritten for SUSv3 compliance and to fix bugs/defects.
@@ -18,26 +22,6 @@
* 3) Added error checking of output.
* 4) Fixed busybox bug #1284 involving long overflow with human_readable.
*/
//config:config DU
//config: bool "du (default blocksize of 512 bytes)"
//config: default y
//config: help
//config: du is used to report the amount of disk space used
//config: for specified files.
//config:
//config:config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
//config: bool "Use a default blocksize of 1024 bytes (1K)"
//config: default y
//config: depends on DU
//config: help
//config: Use a blocksize of (1K) instead of the default 512b.
//applet:IF_DU(APPLET(du, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_DU) += du.o
/* BB_AUDIT SUSv3 compliant (unless default blocksize set to 1k) */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/du.html */
//usage:#define du_trivial_usage
//usage: "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..."
@@ -74,7 +58,6 @@
//usage: "2417 .\n"
#include "libbb.h"
#include "common_bufsiz.h"
enum {
OPT_a_files_too = (1 << 0),
@@ -92,7 +75,7 @@ enum {
struct globals {
#if ENABLE_FEATURE_HUMAN_READABLE
unsigned long disp_unit;
unsigned long disp_hr;
#else
unsigned disp_k;
#endif
@@ -102,31 +85,22 @@ struct globals {
int du_depth;
dev_t dir_dev;
} 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)
/* FIXME? coreutils' du rounds sizes up:
* for example, 1025k file is shown as "2" by du -m.
* We round to nearest.
*/
static void print(unsigned long long size, const char *filename)
{
/* TODO - May not want to defer error checking here. */
#if ENABLE_FEATURE_HUMAN_READABLE
# if ENABLE_DESKTOP
/* ~30 bytes of code for extra comtat:
* coreutils' du rounds sizes up:
* for example, 1025k file is shown as "2" by du -m.
* We round to nearest if human-readable [too hard to fix],
* else (fixed scale such as -m), we round up. To that end,
* add yet another half of the unit before displaying:
*/
if (G.disp_unit)
size += (G.disp_unit-1) / (unsigned)(512 * 2);
# endif
printf("%s\t%s\n",
/* size x 512 / G.disp_unit.
* If G.disp_unit == 0, show one fractional
* and use suffixes
*/
make_human_readable_str(size, 512, G.disp_unit),
/* size x 512 / G.disp_hr, show one fractional,
* use suffixes if G.disp_hr == 0 */
make_human_readable_str(size, 512, G.disp_hr),
filename);
#else
if (G.disp_k) {
@@ -225,10 +199,10 @@ int du_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
#if ENABLE_FEATURE_HUMAN_READABLE
IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 1024;)
IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 512;)
IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
G.disp_unit = 512;
G.disp_hr = 512;
#else
IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 1;)
/* IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 0;) - G is pre-zeroed */
@@ -242,21 +216,21 @@ int du_main(int argc UNUSED_PARAM, char **argv)
* ignore -a. This is consistent with -s being equivalent to -d 0.
*/
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
opt = getopt32(argv, "aHkLsx" "d:+" "lc" "hm", &G.max_print_depth);
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+";
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth);
argv += optind;
if (opt & OPT_h_for_humans) {
G.disp_unit = 0;
G.disp_hr = 0;
}
if (opt & OPT_m_mbytes) {
G.disp_unit = 1024*1024;
G.disp_hr = 1024*1024;
}
if (opt & OPT_k_kbytes) {
G.disp_unit = 1024;
G.disp_hr = 1024;
}
#else
opt_complementary = "H-L:L-H:s-d:d-s";
opt = getopt32(argv, "aHkLsx" "d:+" "lc", &G.max_print_depth);
opt_complementary = "H-L:L-H:s-d:d-s:d+";
opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth);
argv += optind;
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if (opt & OPT_k_kbytes) {
+4 -20
View File
@@ -9,6 +9,10 @@
*
* Original copyright notice is retained at the end of this file.
*/
/* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Because of behavioral differences, implemented configurable SUSv3
@@ -18,26 +22,6 @@
* 2) SUSv3 specifies that octal escapes are of the form \0{#{#{#}}}.
* The previous version did not allow 4-digit octals.
*/
//config:config ECHO
//config: bool "echo (basic SuSv3 version taking no options)"
//config: default y
//config: help
//config: echo is used to print a specified string to stdout.
//config:
//config:# this entry also appears in shell/Config.in, next to the echo builtin
//config:config FEATURE_FANCY_ECHO
//config: bool "Enable echo options (-n and -e)"
//config: default y
//config: depends on ECHO || ASH_BUILTIN_ECHO || HUSH
//config: help
//config: This adds options (-n and -e) to echo.
//applet:IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo))
//kbuild:lib-$(CONFIG_ECHO) += echo.o
/* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */
//usage:#define echo_trivial_usage
//usage: IF_FEATURE_FANCY_ECHO("[-neE] ") "[ARG]..."
+8 -21
View File
@@ -11,11 +11,16 @@
*
* Modified for BusyBox by Erik Andersen <andersen@codepoet.org>
*/
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/env.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Fixed bug involving exit return codes if execvp fails. Also added
* output error checking.
*/
/*
* Modified by Vladimir Oleynik <dzo@simtreas.ru> (C) 2003
* - correct "-" option usage
@@ -23,27 +28,8 @@
* - GNU long option support
* - use xfunc_error_retval
*/
//config:config ENV
//config: bool "env"
//config: default y
//config: help
//config: env is used to set an environment variable and run
//config: a command; without options it displays the current
//config: environment.
//config:
//config:config FEATURE_ENV_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on ENV && LONG_OPTS
//config: help
//config: Support long options for the env applet.
//applet:IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env))
//kbuild:lib-$(CONFIG_ENV) += env.o
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/env.html */
/* This is a NOEXEC applet. Be very careful! */
//usage:#define env_trivial_usage
//usage: "[-iu] [-] [name=value]... [PROG ARGS]"
@@ -68,10 +54,11 @@ int env_main(int argc UNUSED_PARAM, char **argv)
unsigned opts;
llist_t *unset_env = NULL;
opt_complementary = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
applet_long_options = env_longopts;
#endif
opts = getopt32(argv, "+iu:+", &unset_env);
opts = getopt32(argv, "+iu:", &unset_env);
argv += optind;
if (argv[0] && LONE_DASH(argv[0])) {
opts |= 1;
-31
View File
@@ -20,37 +20,6 @@
*
* Caveat: this versions of expand and unexpand don't accept tab lists.
*/
//config:config EXPAND
//config: bool "expand"
//config: default y
//config: help
//config: By default, convert all tabs to spaces.
//config:
//config:config FEATURE_EXPAND_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on EXPAND && LONG_OPTS
//config: help
//config: Support long options for the expand applet.
//config:
//config:config UNEXPAND
//config: bool "unexpand"
//config: default y
//config: help
//config: By default, convert only leading sequences of blanks to tabs.
//config:
//config:config FEATURE_UNEXPAND_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on UNEXPAND && LONG_OPTS
//config: help
//config: Support long options for the unexpand applet.
//applet:IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP))
//applet:IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, BB_DIR_USR_BIN, BB_SUID_DROP, unexpand))
//kbuild:lib-$(CONFIG_EXPAND) += expand.o
//kbuild:lib-$(CONFIG_UNEXPAND) += expand.o
//usage:#define expand_trivial_usage
//usage: "[-i] [-t N] [FILE]..."
+7 -25
View File
@@ -13,6 +13,7 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* This program evaluates expressions. Each token (operator, operand,
* parenthesis) of the expression must be a separate argument. The
* parser used is a reasonably general one, though any incarnation of
@@ -20,27 +21,9 @@
*
* No parse tree is needed; a new node is evaluated immediately.
* One function can handle multiple operators all of equal precedence,
* provided they all associate ((x op x) op x).
*/
//config:config EXPR
//config: bool "expr"
//config: default y
//config: help
//config: expr is used to calculate numbers and print the result
//config: to standard output.
//config:
//config:config EXPR_MATH_SUPPORT_64
//config: bool "Extend Posix numbers support to 64 bit"
//config: default y
//config: depends on EXPR
//config: help
//config: Enable 64-bit math support in the expr applet. This will make
//config: the applet slightly larger, but will allow computation with very
//config: large numbers.
* provided they all associate ((x op x) op x). */
//applet:IF_EXPR(APPLET(expr, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_EXPR) += expr.o
/* no getopt needed */
//usage:#define expr_trivial_usage
//usage: "EXPRESSION"
@@ -78,7 +61,6 @@
//usage: "of characters matched or 0."
#include "libbb.h"
#include "common_bufsiz.h"
#include "xregex.h"
#if ENABLE_EXPR_MATH_SUPPORT_64
@@ -117,8 +99,8 @@ typedef struct valinfo VALUE;
struct globals {
char **args;
} 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)
/* forward declarations */
static VALUE *eval(void);
@@ -131,7 +113,7 @@ static VALUE *int_value(arith_t i)
VALUE *v;
v = xzalloc(sizeof(VALUE));
if (INTEGER) /* otherwise xzalloc did it already */
if (INTEGER) /* otherwise xzaaloc did it already */
v->type = INTEGER;
v->u.i = i;
return v;
@@ -144,7 +126,7 @@ static VALUE *str_value(const char *s)
VALUE *v;
v = xzalloc(sizeof(VALUE));
if (STRING) /* otherwise xzalloc did it already */
if (STRING) /* otherwise xzaaloc did it already */
v->type = STRING;
v->u.s = xstrdup(s);
return v;
-9
View File
@@ -6,15 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config FALSE
//config: bool "false"
//config: default y
//config: help
//config: false returns an exit code of FALSE (1).
//applet:IF_FALSE(APPLET_NOFORK(false, false, BB_DIR_BIN, BB_SUID_DROP, false))
//kbuild:lib-$(CONFIG_FALSE) += false.o
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */
-9
View File
@@ -9,15 +9,6 @@
Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config FOLD
//config: bool "fold"
//config: default y
//config: help
//config: Wrap text to fit a specific width.
//applet:IF_FOLD(APPLET_NOEXEC(fold, fold, BB_DIR_USR_BIN, BB_SUID_DROP, fold))
//kbuild:lib-$(CONFIG_FOLD) += fold.o
//usage:#define fold_trivial_usage
//usage: "[-bs] [-w WIDTH] [FILE]..."
-9
View File
@@ -6,15 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config FSYNC
//config: bool "fsync"
//config: default y
//config: help
//config: fsync is used to flush file-related cached blocks to disk.
//applet:IF_FSYNC(APPLET_NOFORK(fsync, fsync, BB_DIR_BIN, BB_SUID_DROP, fsync))
//kbuild:lib-$(CONFIG_FSYNC) += fsync.o
//usage:#define fsync_trivial_usage
//usage: "[-d] FILE..."
+2 -17
View File
@@ -6,28 +6,13 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config HEAD
//config: bool "head"
//config: default y
//config: help
//config: head is used to print the first specified number of lines
//config: from files.
//config:
//config:config FEATURE_FANCY_HEAD
//config: bool "Enable head options (-c, -q, and -v)"
//config: default y
//config: depends on HEAD
//config: help
//config: This enables the head options (-c, -q, and -v).
//applet:IF_HEAD(APPLET_NOEXEC(head, head, BB_DIR_USR_BIN, BB_SUID_DROP, head))
//kbuild:lib-$(CONFIG_HEAD) += head.o
/* BB_AUDIT SUSv3 compliant */
/* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */
//kbuild:lib-$(CONFIG_HEAD) += head.o
//usage:#define head_trivial_usage
//usage: "[OPTIONS] [FILE]..."
//usage:#define head_full_usage "\n\n"
+3 -2
View File
@@ -6,6 +6,9 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
//config:config HOSTID
//config: bool "hostid"
//config: default y
@@ -17,8 +20,6 @@
//kbuild:lib-$(CONFIG_HOSTID) += hostid.o
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
//usage:#define hostid_trivial_usage
//usage: ""
//usage:#define hostid_full_usage "\n\n"
+6 -5
View File
@@ -7,30 +7,31 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 compliant. */
/* Hacked by Tito Ragusa (C) 2004 to handle usernames of whatever
* length and to be more similar to GNU id.
* -Z option support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
* Added -G option Tito Ragusa (C) 2008 for SUSv3.
*/
//config:config ID
//config: bool "id"
//config: default y
//config: help
//config: id displays the current user and group ID names.
//config:
//config:config GROUPS
//config: bool "groups"
//config: default y
//config: help
//config: Print the group names associated with current user id.
//applet:IF_GROUPS(APPLET_NOEXEC(groups, id, BB_DIR_USR_BIN, BB_SUID_DROP, groups))
//applet:IF_ID( APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id ))
//kbuild:lib-$(CONFIG_GROUPS) += id.o
//kbuild:lib-$(CONFIG_ID) += id.o
/* BB_AUDIT SUSv3 compliant. */
//applet:IF_GROUPS(APPLET_NOEXEC(groups, id, BB_DIR_USR_BIN, BB_SUID_DROP, groups))
//applet:IF_ID( APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id ))
//usage:#define id_trivial_usage
//usage: "[OPTIONS] [USER]"
+1 -18
View File
@@ -5,22 +5,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config INSTALL
//config: bool "install"
//config: default y
//config: help
//config: Copy files and set attributes.
//config:
//config:config FEATURE_INSTALL_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on INSTALL && LONG_OPTS
//config: help
//config: Support long options for the install applet.
//applet:IF_INSTALL(APPLET(install, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_INSTALL) += install.o
/* -v, -b, -c are ignored */
//usage:#define install_trivial_usage
@@ -211,8 +195,7 @@ int install_main(int argc, char **argv)
char *ddir = xstrdup(dest);
bb_make_directory(dirname(ddir), 0755, mkdir_flags);
/* errors are not checked. copy_file
* will fail if dir is not created.
*/
* will fail if dir is not created. */
free(ddir);
}
if (isdir)
+31
View File
@@ -0,0 +1,31 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */
//usage:#define length_trivial_usage
//usage: "STRING"
//usage:#define length_full_usage "\n\n"
//usage: "Print STRING's length"
//usage:
//usage:#define length_example_usage
//usage: "$ length Hello\n"
//usage: "5\n"
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int length_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int length_main(int argc, char **argv)
{
if ((argc != 2) || (**(++argv) == '-')) {
bb_show_usage();
}
printf("%u\n", (unsigned)strlen(*argv));
return fflush_all();
}
-9
View File
@@ -6,15 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config LN
//config: bool "ln"
//config: default y
//config: help
//config: ln is used to create hard or soft links between files.
//applet:IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN, BB_SUID_DROP, ln))
//kbuild:lib-$(CONFIG_LN) += ln.o
/* BB_AUDIT SUSv3 compliant */
/* BB_AUDIT GNU options missing: -d, -F, -i, and -v. */
+4 -12
View File
@@ -6,6 +6,10 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/logname.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* SUSv3 specifies the string used is that returned from getlogin().
@@ -15,18 +19,6 @@
* correct course of action wrt SUSv3 for a failing getlogin() is
* a diagnostic message and an error return.
*/
//config:config LOGNAME
//config: bool "logname"
//config: default y
//config: help
//config: logname is used to print the current user's login name.
//applet:IF_LOGNAME(APPLET_NOFORK(logname, logname, BB_DIR_USR_BIN, BB_SUID_DROP, logname))
//kbuild:lib-$(CONFIG_LOGNAME) += logname.o
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/logname.html */
//usage:#define logname_trivial_usage
//usage: ""
+6 -76
View File
@@ -4,6 +4,7 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* [date unknown. Perhaps before year 2000]
* To achieve a small memory footprint, this version of 'ls' doesn't do any
* file sorting, and only has the most essential command line switches
@@ -27,75 +28,6 @@
* [2009-03]
* ls sorts listing now, and supports almost all options.
*/
//config:config LS
//config: bool "ls"
//config: default y
//config: help
//config: ls is used to list the contents of directories.
//config:
//config:config FEATURE_LS_FILETYPES
//config: bool "Enable filetyping options (-p and -F)"
//config: default y
//config: depends on LS
//config: help
//config: Enable the ls options (-p and -F).
//config:
//config:config FEATURE_LS_FOLLOWLINKS
//config: bool "Enable symlinks dereferencing (-L)"
//config: default y
//config: depends on LS
//config: help
//config: Enable the ls option (-L).
//config:
//config:config FEATURE_LS_RECURSIVE
//config: bool "Enable recursion (-R)"
//config: default y
//config: depends on LS
//config: help
//config: Enable the ls option (-R).
//config:
//config:config FEATURE_LS_SORTFILES
//config: bool "Sort the file names"
//config: default y
//config: depends on LS
//config: help
//config: Allow ls to sort file names alphabetically.
//config:
//config:config FEATURE_LS_TIMESTAMPS
//config: bool "Show file timestamps"
//config: default y
//config: depends on LS
//config: help
//config: Allow ls to display timestamps for files.
//config:
//config:config FEATURE_LS_USERNAME
//config: bool "Show username/groupnames"
//config: default y
//config: depends on LS
//config: help
//config: Allow ls to display username/groupname for files.
//config:
//config:config FEATURE_LS_COLOR
//config: bool "Allow use of color to identify file types"
//config: default y
//config: depends on LS && LONG_OPTS
//config: help
//config: This enables the --color option to ls.
//config:
//config:config FEATURE_LS_COLOR_IS_DEFAULT
//config: bool "Produce colored ls output by default"
//config: default y
//config: depends on FEATURE_LS_COLOR
//config: help
//config: Saying yes here will turn coloring on by default,
//config: even if no "--color" option is given to the ls command.
//config: This is not recommended, since the colors are not
//config: configurable, and the output may not be legible on
//config: many output screens.
//applet:IF_LS(APPLET_NOEXEC(ls, ls, BB_DIR_BIN, BB_SUID_DROP, ls))
//kbuild:lib-$(CONFIG_LS) += ls.o
//usage:#define ls_trivial_usage
//usage: "[-1AaCxd"
@@ -161,7 +93,6 @@
//usage: )
#include "libbb.h"
#include "common_bufsiz.h"
#include "unicode.h"
@@ -434,9 +365,8 @@ struct globals {
time_t current_time_t;
#endif
} FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1)
#define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { \
setup_common_bufsiz(); \
/* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \
IF_FEATURE_AUTOWIDTH(G_terminal_width = TERMINAL_WIDTH;) \
@@ -738,7 +668,7 @@ static void display_files(struct dnode **dn, unsigned nfiles)
if (column_width < len)
column_width = len;
}
column_width += 2 +
column_width += 1 +
IF_SELINUX( ((G.all_fmt & LIST_CONTEXT) ? 33 : 0) + )
((G.all_fmt & LIST_INO) ? 8 : 0) +
((G.all_fmt & LIST_BLOCKS) ? 5 : 0);
@@ -766,8 +696,8 @@ static void display_files(struct dnode **dn, unsigned nfiles)
if (i < nfiles) {
if (column > 0) {
nexttab -= column;
printf("%*s", nexttab, "");
column += nexttab;
printf("%*s ", nexttab, "");
column += nexttab + 1;
}
nexttab = column + column_width;
column += display_single(dn[i]);
@@ -1175,7 +1105,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_AUTOWIDTH
/* obtain the terminal width */
G_terminal_width = get_terminal_width(STDIN_FILENO);
get_terminal_width_height(STDIN_FILENO, &G_terminal_width, NULL);
/* go one less... */
G_terminal_width--;
#endif
+25 -120
View File
@@ -5,60 +5,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config MD5SUM
//config: bool "md5sum"
//config: default y
//config: help
//config: md5sum is used to print or check MD5 checksums.
//config:
//config:config SHA1SUM
//config: bool "sha1sum"
//config: default y
//config: help
//config: Compute and check SHA1 message digest
//config:
//config:config SHA256SUM
//config: bool "sha256sum"
//config: default y
//config: help
//config: Compute and check SHA256 message digest
//config:
//config:config SHA512SUM
//config: bool "sha512sum"
//config: default y
//config: help
//config: Compute and check SHA512 message digest
//config:
//config:config SHA3SUM
//config: bool "sha3sum"
//config: default y
//config: help
//config: Compute and check SHA3 message digest
//config:
//config:comment "Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum"
//config: depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
//config:
//config:config FEATURE_MD5_SHA1_SUM_CHECK
//config: bool "Enable -c, -s and -w options"
//config: default y
//config: depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
//config: help
//config: Enabling the -c options allows files to be checked
//config: against pre-calculated hash values.
//config:
//config: -s and -w are useful options when verifying checksums.
//applet:IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum))
//applet:IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha1sum))
//applet:IF_SHA3SUM(APPLET_NOEXEC(sha3sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha3sum))
//applet:IF_SHA256SUM(APPLET_NOEXEC(sha256sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha256sum))
//applet:IF_SHA512SUM(APPLET_NOEXEC(sha512sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha512sum))
//kbuild:lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
//kbuild:lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
//kbuild:lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o
//kbuild:lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o
//kbuild:lib-$(CONFIG_SHA3SUM) += md5_sha1_sum.o
//usage:#define md5sum_trivial_usage
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("[-c[sw]] ")"[FILE]..."
@@ -111,20 +57,15 @@
//usage: )
//usage:
//usage:#define sha3sum_trivial_usage
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("[-c[sw]] ")"[-a BITS] [FILE]..."
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("[-c[sw]] ")"[FILE]..."
//usage:#define sha3sum_full_usage "\n\n"
//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA3 checksums"
//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA3-512 checksums"
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
//usage: "\n -c Check sums against list in FILEs"
//usage: "\n -s Don't output anything, status code shows success"
//usage: "\n -w Warn about improperly formatted checksum lines"
//usage: "\n -a BITS 224 (default), 256, 384, 512"
//usage: )
//FIXME: GNU coreutils 8.25 has no -s option, it has only these two long opts:
// --quiet don't print OK for each successfully verified file
// --status don't output anything, status code shows success
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
@@ -152,10 +93,7 @@ static unsigned char *hash_bin_to_hex(unsigned char *hash_value,
return (unsigned char *)hex_value;
}
#if !ENABLE_SHA3SUM
# define hash_file(f,w) hash_file(f)
#endif
static uint8_t *hash_file(const char *filename, unsigned sha3_width)
static uint8_t *hash_file(const char *filename)
{
int src_fd, hash_len, count;
union _ctx_ {
@@ -183,47 +121,27 @@ static uint8_t *hash_file(const char *filename, unsigned sha3_width)
update = (void*)md5_hash;
final = (void*)md5_end;
hash_len = 16;
}
else if (ENABLE_SHA1SUM && hash_algo == HASH_SHA1) {
} else if (ENABLE_SHA1SUM && hash_algo == HASH_SHA1) {
sha1_begin(&context.sha1);
update = (void*)sha1_hash;
final = (void*)sha1_end;
hash_len = 20;
}
else if (ENABLE_SHA256SUM && hash_algo == HASH_SHA256) {
} else if (ENABLE_SHA256SUM && hash_algo == HASH_SHA256) {
sha256_begin(&context.sha256);
update = (void*)sha256_hash;
final = (void*)sha256_end;
hash_len = 32;
}
else if (ENABLE_SHA512SUM && hash_algo == HASH_SHA512) {
} else if (ENABLE_SHA512SUM && hash_algo == HASH_SHA512) {
sha512_begin(&context.sha512);
update = (void*)sha512_hash;
final = (void*)sha512_end;
hash_len = 64;
}
#if ENABLE_SHA3SUM
else if (ENABLE_SHA3SUM && hash_algo == HASH_SHA3) {
} else if (ENABLE_SHA3SUM && hash_algo == HASH_SHA3) {
sha3_begin(&context.sha3);
update = (void*)sha3_hash;
final = (void*)sha3_end;
/*
* Should support 224, 256, 384, 512.
* We allow any value which does not blow the algorithm up.
*/
if (sha3_width >= 1600/2 /* input block can't be <= 0 */
|| sha3_width == 0 /* hash len can't be 0 */
|| (sha3_width & 0x1f) /* should be multiple of 32 */
/* (because input uses up to 8 byte wide word XORs. 32/4=8) */
) {
bb_error_msg_and_die("bad -a%u", sha3_width);
}
sha3_width /= 4;
context.sha3.input_block_bytes = 1600/8 - sha3_width;
hash_len = sha3_width/2;
}
#endif
else {
hash_len = 64;
} else {
xfunc_die(); /* can't reach this */
}
@@ -254,33 +172,28 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
{
int return_value = EXIT_SUCCESS;
unsigned flags;
#if ENABLE_SHA3SUM
unsigned sha3_width = 224;
#endif
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) {
/* -s and -w require -c */
opt_complementary = "s?c:w?c";
/* -b "binary", -t "text" are ignored (shaNNNsum compat) */
#if ENABLE_SHA3SUM
if (applet_name[3] == HASH_SHA3)
flags = getopt32(argv, "scwbta:+", &sha3_width);
else
#endif
flags = getopt32(argv, "scwbt");
flags = getopt32(argv, "scwbt");
argv += optind;
//argc -= optind;
} else {
#if ENABLE_SHA3SUM
if (applet_name[3] == HASH_SHA3)
getopt32(argv, "a:+", &sha3_width);
else
#endif
getopt32(argv, "");
argv += 1;
//argc -= 1;
}
argv += optind;
//argc -= optind;
if (!*argv)
*--argv = (char*)"-";
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
if (flags & FLAG_SILENT) {
bb_error_msg_and_die("-%c is meaningful only with -c", 's');
}
if (flags & FLAG_WARN) {
bb_error_msg_and_die("-%c is meaningful only with -c", 'w');
}
}
do {
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && (flags & FLAG_CHECK)) {
FILE *pre_computed_stream;
@@ -312,7 +225,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
*filename_ptr = '\0';
filename_ptr += 2;
hash_value = hash_file(filename_ptr, sha3_width);
hash_value = hash_file(filename_ptr);
if (hash_value && (strcmp((char*)hash_value, line) == 0)) {
if (!(flags & FLAG_SILENT))
@@ -331,17 +244,9 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
bb_error_msg("WARNING: %d of %d computed checksums did NOT match",
count_failed, count_total);
}
if (count_total == 0) {
return_value = EXIT_FAILURE;
/*
* md5sum from GNU coreutils 8.25 says:
* md5sum: <FILE>: no properly formatted MD5 checksum lines found
*/
bb_error_msg("%s: no checksum lines found", *argv);
}
fclose_if_not_stdin(pre_computed_stream);
} else {
uint8_t *hash_value = hash_file(*argv, sha3_width);
uint8_t *hash_value = hash_file(*argv);
if (hash_value == NULL) {
return_value = EXIT_FAILURE;
} else {
+5 -19
View File
@@ -6,32 +6,18 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkdir.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Fixed broken permission setting when -p was used; especially in
* conjunction with -m.
*/
/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
*/
//config:config MKDIR
//config: bool "mkdir"
//config: default y
//config: help
//config: mkdir is used to create directories with the specified names.
//config:
//config:config FEATURE_MKDIR_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on MKDIR && LONG_OPTS
//config: help
//config: Support long options for the mkdir applet.
//applet:IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir))
//kbuild:lib-$(CONFIG_MKDIR) += mkdir.o
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkdir.html */
//usage:#define mkdir_trivial_usage
//usage: "[OPTIONS] DIRECTORY..."
-10
View File
@@ -6,16 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config MKFIFO
//config: bool "mkfifo"
//config: default y
//config: help
//config: mkfifo is used to create FIFOs (named pipes).
//config: The 'mknod' program can also create FIFOs.
//applet:IF_MKFIFO(APPLET_NOEXEC(mkfifo, mkfifo, BB_DIR_USR_BIN, BB_SUID_DROP, mkfifo))
//kbuild:lib-$(CONFIG_MKFIFO) += mkfifo.o
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
-10
View File
@@ -6,16 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config MKNOD
//config: bool "mknod"
//config: default y
//config: help
//config: mknod is used to create FIFOs or block/character special
//config: files with the specified names.
//applet:IF_MKNOD(APPLET_NOEXEC(mknod, mknod, BB_DIR_BIN, BB_SUID_DROP, mknod))
//kbuild:lib-$(CONFIG_MKNOD) += mknod.o
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
+3 -18
View File
@@ -7,26 +7,14 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Size reduction and improved error checking.
*/
//config:config MV
//config: bool "mv"
//config: default y
//config: help
//config: mv is used to move or rename files or directories.
//config:
//config:config FEATURE_MV_LONG_OPTIONS
//config: bool "Enable long options"
//config: default y
//config: depends on MV && LONG_OPTS
//config: help
//config: Support long options for the mv applet.
//applet:IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_MV) += mv.o
#include "libbb.h"
#include "libcoreutils/coreutils.h"
//usage:#define mv_trivial_usage
//usage: "[-fin] SOURCE DEST\n"
@@ -40,9 +28,6 @@
//usage:#define mv_example_usage
//usage: "$ mv /tmp/foo /bin/bar\n"
#include "libbb.h"
#include "libcoreutils/coreutils.h"
#if ENABLE_FEATURE_MV_LONG_OPTIONS
static const char mv_longopts[] ALIGN1 =
"interactive\0" No_argument "i"
-9
View File
@@ -6,15 +6,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config NICE
//config: bool "nice"
//config: default y
//config: help
//config: nice runs a program with modified scheduling priority.
//applet:IF_NICE(APPLET(nice, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_NICE) += nice.o
//usage:#define nice_trivial_usage
//usage: "[-n ADJUST] [PROG ARGS]"
-9
View File
@@ -9,15 +9,6 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config NOHUP
//config: bool "nohup"
//config: default y
//config: help
//config: run a command immune to hangups, with output to a non-tty.
//applet:IF_NOHUP(APPLET(nohup, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_NOHUP) += nohup.o
//usage:#define nohup_trivial_usage
//usage: "PROG ARGS"
-9
View File
@@ -10,15 +10,6 @@
*
* Original copyright notice is retained at the end of this file.
*/
//config:config OD
//config: bool "od"
//config: default y
//config: help
//config: od is used to dump binary files in octal and other formats.
//applet:IF_OD(APPLET(od, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_OD) += od.o
//usage:#if !ENABLE_DESKTOP
//usage:#define od_trivial_usage
+108 -123
View File
@@ -20,7 +20,6 @@
/* #include "libbb.h" - done in od.c */
#include "common_bufsiz.h"
#define assert(a) ((void)0)
@@ -62,12 +61,12 @@ enum {
};
#define OD_GETOPT32() getopt32(argv, \
"A:N:abcdfhij:lot:*vxsS:w:+:", \
"A:N:abcdfhij:lot:vxsS:w::", \
/* -w with optional param */ \
/* -S was -s and also had optional parameter */ \
/* but in coreutils 6.3 it was renamed and now has */ \
/* _mandatory_ parameter */ \
&str_A, &str_N, &str_j, &lst_t, &str_S, &G.bytes_per_block)
&str_A, &str_N, &str_j, &lst_t, &str_S, &bytes_per_block)
/* Check for 0x7f is a coreutils 6.3 addition */
@@ -175,53 +174,38 @@ struct ERR_width_bytes_has_bad_size {
char ERR_width_bytes_has_bad_size[ARRAY_SIZE(width_bytes) == N_SIZE_SPECS ? 1 : -1];
};
struct globals {
smallint exit_code;
static smallint exit_code;
unsigned string_min;
static unsigned string_min;
/* An array of specs describing how to format each input block. */
unsigned n_specs;
struct tspec *spec;
/* An array of specs describing how to format each input block. */
static size_t n_specs;
static struct tspec *spec;
/* Function that accepts an address and an optional following char,
and prints the address and char to stdout. */
void (*format_address)(off_t, char);
/* The difference between the old-style pseudo starting address and
the number of bytes to skip. */
/* Function that accepts an address and an optional following char,
and prints the address and char to stdout. */
static void (*format_address)(off_t, char);
/* The difference between the old-style pseudo starting address and
the number of bytes to skip. */
#if ENABLE_LONG_OPTS
off_t pseudo_offset;
# define G_pseudo_offset G.pseudo_offset
static off_t pseudo_offset;
#else
enum { pseudo_offset = 0 };
#endif
/* When zero, MAX_BYTES_TO_FORMAT and END_OFFSET are ignored, and all
input is formatted. */
/* When zero, MAX_BYTES_TO_FORMAT and END_OFFSET are ignored, and all
input is formatted. */
/* The number of input bytes formatted per output line. It must be
a multiple of the least common multiple of the sizes associated with
the specified output types. It should be as large as possible, but
no larger than 16 -- unless specified with the -w option. */
unsigned bytes_per_block; /* have to use unsigned, not size_t */
/* The number of input bytes formatted per output line. It must be
a multiple of the least common multiple of the sizes associated with
the specified output types. It should be as large as possible, but
no larger than 16 -- unless specified with the -w option. */
static unsigned bytes_per_block = 32; /* have to use unsigned, not size_t */
/* A NULL-terminated list of the file-arguments from the command line. */
const char *const *file_list;
/* The input stream associated with the current file. */
FILE *in_stream;
bool not_first;
bool prev_pair_equal;
} FIX_ALIASING;
#if !ENABLE_LONG_OPTS
enum { G_pseudo_offset = 0 };
#endif
#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
G.bytes_per_block = 32; \
} while (0)
/* A NULL-terminated list of the file-arguments from the command line. */
static const char *const *file_list;
/* The input stream associated with the current file. */
static FILE *in_stream;
#define MAX_INTEGRAL_TYPE_SIZE sizeof(ulonglong_t)
static const unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] ALIGN1 = {
@@ -492,17 +476,17 @@ static void
open_next_file(void)
{
while (1) {
if (!*G.file_list)
if (!*file_list)
return;
G.in_stream = fopen_or_warn_stdin(*G.file_list++);
if (G.in_stream) {
in_stream = fopen_or_warn_stdin(*file_list++);
if (in_stream) {
break;
}
G.exit_code = 1;
exit_code = 1;
}
if ((option_mask32 & (OPT_N|OPT_S)) == OPT_N)
setbuf(G.in_stream, NULL);
setbuf(in_stream, NULL);
}
/* Test whether there have been errors on in_stream, and close it if
@@ -515,16 +499,16 @@ open_next_file(void)
static void
check_and_close(void)
{
if (G.in_stream) {
if (ferror(G.in_stream)) {
bb_error_msg("%s: read error", (G.in_stream == stdin)
if (in_stream) {
if (ferror(in_stream)) {
bb_error_msg("%s: read error", (in_stream == stdin)
? bb_msg_standard_input
: G.file_list[-1]
: file_list[-1]
);
G.exit_code = 1;
exit_code = 1;
}
fclose_if_not_stdin(G.in_stream);
G.in_stream = NULL;
fclose_if_not_stdin(in_stream);
in_stream = NULL;
}
if (ferror(stdout)) {
@@ -760,9 +744,9 @@ decode_format_string(const char *s)
assert(s != next);
s = next;
G.spec = xrealloc_vector(G.spec, 4, G.n_specs);
memcpy(&G.spec[G.n_specs], &tspec, sizeof(G.spec[0]));
G.n_specs++;
spec = xrealloc_vector(spec, 4, n_specs);
memcpy(&spec[n_specs], &tspec, sizeof(spec[0]));
n_specs++;
}
}
@@ -779,7 +763,7 @@ skip(off_t n_skip)
if (n_skip == 0)
return;
while (G.in_stream) { /* !EOF */
while (in_stream) { /* !EOF */
struct stat file_stats;
/* First try seeking. For large offsets, this extra work is
@@ -797,15 +781,15 @@ skip(off_t n_skip)
If the number of bytes left to skip is at least
as large as the size of the current file, we can
decrement n_skip and go on to the next file. */
if (fstat(fileno(G.in_stream), &file_stats) == 0
if (fstat(fileno(in_stream), &file_stats) == 0
&& S_ISREG(file_stats.st_mode) && file_stats.st_size > 0
) {
if (file_stats.st_size < n_skip) {
n_skip -= file_stats.st_size;
/* take "check & close / open_next" route */
} else {
if (fseeko(G.in_stream, n_skip, SEEK_CUR) != 0)
G.exit_code = 1;
if (fseeko(in_stream, n_skip, SEEK_CUR) != 0)
exit_code = 1;
return;
}
} else {
@@ -818,7 +802,7 @@ skip(off_t n_skip)
while (n_skip > 0) {
if (n_skip < n_bytes_to_read)
n_bytes_to_read = n_skip;
n_bytes_read = fread(buf, 1, n_bytes_to_read, G.in_stream);
n_bytes_read = fread(buf, 1, n_bytes_to_read, in_stream);
n_skip -= n_bytes_read;
if (n_bytes_read != n_bytes_to_read)
break; /* EOF on this file or error */
@@ -871,7 +855,7 @@ static void
format_address_label(off_t address, char c)
{
format_address_std(address, ' ');
format_address_paren(address + G_pseudo_offset, c);
format_address_paren(address + pseudo_offset, c);
}
#endif
@@ -902,34 +886,36 @@ static void
write_block(off_t current_offset, size_t n_bytes,
const char *prev_block, const char *curr_block)
{
unsigned i;
static char first = 1;
static char prev_pair_equal = 0;
size_t i;
if (!(option_mask32 & OPT_v)
&& G.not_first
&& n_bytes == G.bytes_per_block
&& memcmp(prev_block, curr_block, G.bytes_per_block) == 0
&& !first
&& n_bytes == bytes_per_block
&& memcmp(prev_block, curr_block, bytes_per_block) == 0
) {
if (G.prev_pair_equal) {
if (prev_pair_equal) {
/* The two preceding blocks were equal, and the current
block is the same as the last one, so print nothing. */
} else {
puts("*");
G.prev_pair_equal = 1;
prev_pair_equal = 1;
}
} else {
G.not_first = 1;
G.prev_pair_equal = 0;
for (i = 0; i < G.n_specs; i++) {
first = 0;
prev_pair_equal = 0;
for (i = 0; i < n_specs; i++) {
if (i == 0)
G.format_address(current_offset, '\0');
format_address(current_offset, '\0');
else
printf("%*s", address_pad_len_char - '0', "");
(*G.spec[i].print_function) (n_bytes, curr_block, G.spec[i].fmt_string);
if (G.spec[i].hexl_mode_trailer) {
(*spec[i].print_function) (n_bytes, curr_block, spec[i].fmt_string);
if (spec[i].hexl_mode_trailer) {
/* space-pad out to full line width, then dump the trailer */
unsigned datum_width = width_bytes[G.spec[i].size];
unsigned blank_fields = (G.bytes_per_block - n_bytes) / datum_width;
unsigned field_width = G.spec[i].field_width + 1;
unsigned datum_width = width_bytes[spec[i].size];
unsigned blank_fields = (bytes_per_block - n_bytes) / datum_width;
unsigned field_width = spec[i].field_width + 1;
printf("%*s", blank_fields * field_width, "");
dump_hexl_mode_trailer(n_bytes, curr_block);
}
@@ -941,19 +927,19 @@ write_block(off_t current_offset, size_t n_bytes,
static void
read_block(size_t n, char *block, size_t *n_bytes_in_buffer)
{
assert(0 < n && n <= G.bytes_per_block);
assert(0 < n && n <= bytes_per_block);
*n_bytes_in_buffer = 0;
if (n == 0)
return;
while (G.in_stream != NULL) { /* EOF. */
while (in_stream != NULL) { /* EOF. */
size_t n_needed;
size_t n_read;
n_needed = n - *n_bytes_in_buffer;
n_read = fread(block + *n_bytes_in_buffer, 1, n_needed, G.in_stream);
n_read = fread(block + *n_bytes_in_buffer, 1, n_needed, in_stream);
*n_bytes_in_buffer += n_read;
if (n_read == n_needed)
break;
@@ -972,8 +958,8 @@ get_lcm(void)
size_t i;
int l_c_m = 1;
for (i = 0; i < G.n_specs; i++)
l_c_m = lcm(l_c_m, width_bytes[(int) G.spec[i].size]);
for (i = 0; i < n_specs; i++)
l_c_m = lcm(l_c_m, width_bytes[(int) spec[i].size]);
return l_c_m;
}
@@ -994,8 +980,8 @@ dump(off_t current_offset, off_t end_offset)
int idx;
size_t n_bytes_read;
block[0] = xmalloc(2 * G.bytes_per_block);
block[1] = block[0] + G.bytes_per_block;
block[0] = xmalloc(2 * bytes_per_block);
block[1] = block[0] + bytes_per_block;
idx = 0;
if (option_mask32 & OPT_N) {
@@ -1005,21 +991,21 @@ dump(off_t current_offset, off_t end_offset)
n_bytes_read = 0;
break;
}
n_needed = MIN(end_offset - current_offset, (off_t) G.bytes_per_block);
n_needed = MIN(end_offset - current_offset, (off_t) bytes_per_block);
read_block(n_needed, block[idx], &n_bytes_read);
if (n_bytes_read < G.bytes_per_block)
if (n_bytes_read < bytes_per_block)
break;
assert(n_bytes_read == G.bytes_per_block);
assert(n_bytes_read == bytes_per_block);
write_block(current_offset, n_bytes_read, block[idx ^ 1], block[idx]);
current_offset += n_bytes_read;
idx ^= 1;
}
} else {
while (1) {
read_block(G.bytes_per_block, block[idx], &n_bytes_read);
if (n_bytes_read < G.bytes_per_block)
read_block(bytes_per_block, block[idx], &n_bytes_read);
if (n_bytes_read < bytes_per_block)
break;
assert(n_bytes_read == G.bytes_per_block);
assert(n_bytes_read == bytes_per_block);
write_block(current_offset, n_bytes_read, block[idx ^ 1], block[idx]);
current_offset += n_bytes_read;
idx ^= 1;
@@ -1042,7 +1028,7 @@ dump(off_t current_offset, off_t end_offset)
current_offset += n_bytes_read;
}
G.format_address(current_offset, '\n');
format_address(current_offset, '\n');
if ((option_mask32 & OPT_N) && current_offset >= end_offset)
check_and_close();
@@ -1073,16 +1059,16 @@ dump(off_t current_offset, off_t end_offset)
static void
dump_strings(off_t address, off_t end_offset)
{
unsigned bufsize = MAX(100, G.string_min);
unsigned bufsize = MAX(100, string_min);
unsigned char *buf = xmalloc(bufsize);
while (1) {
size_t i;
int c;
/* See if the next 'G.string_min' chars are all printing chars. */
/* See if the next 'string_min' chars are all printing chars. */
tryline:
if ((option_mask32 & OPT_N) && (end_offset - G.string_min <= address))
if ((option_mask32 & OPT_N) && (end_offset - string_min <= address))
break;
i = 0;
while (!(option_mask32 & OPT_N) || address < end_offset) {
@@ -1091,8 +1077,8 @@ dump_strings(off_t address, off_t end_offset)
buf = xrealloc(buf, bufsize);
}
while (G.in_stream) { /* !EOF */
c = fgetc(G.in_stream);
while (in_stream) { /* !EOF */
c = fgetc(in_stream);
if (c != EOF)
goto got_char;
check_and_close();
@@ -1109,12 +1095,12 @@ dump_strings(off_t address, off_t end_offset)
buf[i++] = c; /* String continues; store it all. */
}
if (i < G.string_min) /* Too short! */
if (i < string_min) /* Too short! */
goto tryline;
/* If we get here, the string is all printable and NUL-terminated */
buf[i] = 0;
G.format_address(address - i - 1, ' ');
format_address(address - i - 1, ' ');
for (i = 0; (c = buf[i]); i++) {
switch (c) {
@@ -1132,7 +1118,7 @@ dump_strings(off_t address, off_t end_offset)
}
/* We reach this point only if we search through
(max_bytes_to_format - G.string_min) bytes before reaching EOF. */
(max_bytes_to_format - string_min) bytes before reaching EOF. */
check_and_close();
ret:
free(buf);
@@ -1204,14 +1190,13 @@ int od_main(int argc UNUSED_PARAM, char **argv)
/* The maximum number of bytes that will be formatted. */
off_t max_bytes_to_format = 0;
INIT_G();
/*G.spec = NULL; - already is */
G.format_address = format_address_std;
spec = NULL;
format_address = format_address_std;
address_base_char = 'o';
address_pad_len_char = '7';
/* Parse command line */
opt_complementary = "w+:t::"; /* -w N, -t is a list */
#if ENABLE_LONG_OPTS
applet_long_options = od_longopts;
#endif
@@ -1232,7 +1217,7 @@ int od_main(int argc UNUSED_PARAM, char **argv)
bb_error_msg_and_die("bad output address radix "
"'%c' (must be [doxn])", str_A[0]);
pos = p - doxn;
if (pos == 3) G.format_address = format_address_none;
if (pos == 3) format_address = format_address_none;
address_base_char = doxn_address_base_char[pos];
address_pad_len_char = doxn_address_pad_len_char[pos];
}
@@ -1255,11 +1240,11 @@ int od_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_x) decode_format_string("x2");
if (opt & OPT_s) decode_format_string("d2");
if (opt & OPT_S) {
G.string_min = xstrtou_sfx(str_S, 0, bkm_suffixes);
string_min = xstrtou_sfx(str_S, 0, bkm_suffixes);
}
// Bloat:
//if ((option_mask32 & OPT_S) && G.n_specs > 0)
//if ((option_mask32 & OPT_S) && n_specs > 0)
// bb_error_msg_and_die("no type may be specified when dumping strings");
/* If the --traditional option is used, there may be from
@@ -1315,14 +1300,14 @@ int od_main(int argc UNUSED_PARAM, char **argv)
}
if (pseudo_start >= 0) {
if (G.format_address == format_address_none) {
if (format_address == format_address_none) {
address_base_char = 'o';
address_pad_len_char = '7';
G.format_address = format_address_paren;
format_address = format_address_paren;
} else {
G.format_address = format_address_label;
format_address = format_address_label;
}
G_pseudo_offset = pseudo_start - n_bytes_to_skip;
pseudo_offset = pseudo_start - n_bytes_to_skip;
}
}
/* else: od --traditional (without args) */
@@ -1335,45 +1320,45 @@ int od_main(int argc UNUSED_PARAM, char **argv)
bb_error_msg_and_die("SKIP + SIZE is too large");
}
if (G.n_specs == 0) {
if (n_specs == 0) {
decode_format_string("o2");
/*G.n_specs = 1; - done by decode_format_string */
/*n_specs = 1; - done by decode_format_string */
}
/* If no files were listed on the command line,
set the global pointer FILE_LIST so that it
references the null-terminated list of one name: "-". */
G.file_list = bb_argv_dash;
file_list = bb_argv_dash;
if (argv[0]) {
/* Set the global pointer FILE_LIST so that it
references the first file-argument on the command-line. */
G.file_list = (char const *const *) argv;
file_list = (char const *const *) argv;
}
/* Open the first input file */
open_next_file();
/* Skip over any unwanted header bytes */
skip(n_bytes_to_skip);
if (!G.in_stream)
if (!in_stream)
return EXIT_FAILURE;
/* Compute output block length */
l_c_m = get_lcm();
if (opt & OPT_w) { /* -w: width */
if (!G.bytes_per_block || G.bytes_per_block % l_c_m != 0) {
if (!bytes_per_block || bytes_per_block % l_c_m != 0) {
bb_error_msg("warning: invalid width %u; using %d instead",
(unsigned)G.bytes_per_block, l_c_m);
G.bytes_per_block = l_c_m;
(unsigned)bytes_per_block, l_c_m);
bytes_per_block = l_c_m;
}
} else {
G.bytes_per_block = l_c_m;
bytes_per_block = l_c_m;
if (l_c_m < DEFAULT_BYTES_PER_BLOCK)
G.bytes_per_block *= DEFAULT_BYTES_PER_BLOCK / l_c_m;
bytes_per_block *= DEFAULT_BYTES_PER_BLOCK / l_c_m;
}
#ifdef DEBUG
for (i = 0; i < G.n_specs; i++) {
for (i = 0; i < n_specs; i++) {
printf("%d: fmt=\"%s\" width=%d\n",
i, spec[i].fmt_string, width_bytes[spec[i].size]);
}
@@ -1387,5 +1372,5 @@ int od_main(int argc UNUSED_PARAM, char **argv)
if (fclose(stdin))
bb_perror_msg_and_die(bb_msg_standard_input);
return G.exit_code;
return exit_code;
}
Loaded 100 of 983 files, more files were not shown because too many files have changed in this diff. Show more