oweals/busybox.git
10 years agontpd: adjust last packet's recv time after a step
Denys Vlasenko [Wed, 8 Jan 2014 16:17:52 +0000 (17:17 +0100)]
ntpd: adjust last packet's recv time after a step

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: FreeBSD fix for B<num> baud rate constants not fitting into a short.
Denys Vlasenko [Wed, 8 Jan 2014 14:25:20 +0000 (15:25 +0100)]
libbb: FreeBSD fix for B<num> baud rate constants not fitting into a short.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoAnother FreeBSD fix from Matthias Andree
Denys Vlasenko [Wed, 8 Jan 2014 14:10:54 +0000 (15:10 +0100)]
Another FreeBSD fix from Matthias Andree

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoash: in bash compat mode, always export $SHLVL
Denys Vlasenko [Tue, 7 Jan 2014 15:12:48 +0000 (16:12 +0100)]
ash: in bash compat mode, always export $SHLVL

function                                             old     new   delta
ash_main                                            1437    1442      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agogrep: fix two bugs with -w
Denys Vlasenko [Tue, 7 Jan 2014 13:57:42 +0000 (14:57 +0100)]
grep: fix two bugs with -w

Unfortunately, with !EXTRA_COMPAT, "grep -w ^str" still erroneously matches "strstr".

function                                             old     new   delta
grep_file                                           1499    1510     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoplatform.h: undef HAVE_STRCHRNUL only on correct versions of FreeBSD
Denys Vlasenko [Tue, 7 Jan 2014 13:09:47 +0000 (14:09 +0100)]
platform.h: undef HAVE_STRCHRNUL only on correct versions of FreeBSD

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoStart 1.23.0 development cycle
Denys Vlasenko [Tue, 31 Dec 2013 23:44:30 +0000 (00:44 +0100)]
Start 1.23.0 development cycle

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoBump version to 1.22.0 1_22_0
Denys Vlasenko [Tue, 31 Dec 2013 23:42:11 +0000 (00:42 +0100)]
Bump version to 1.22.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotestsuite: remove forgotten debug hack
Denys Vlasenko [Tue, 31 Dec 2013 22:25:46 +0000 (23:25 +0100)]
testsuite: remove forgotten debug hack

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofix failures found by randomconfig builds
Denys Vlasenko [Tue, 31 Dec 2013 22:22:36 +0000 (23:22 +0100)]
fix failures found by randomconfig builds

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotestsuite: disable tests for no longer supported bbox-specific date formats
Denys Vlasenko [Tue, 31 Dec 2013 17:57:39 +0000 (18:57 +0100)]
testsuite: disable tests for no longer supported bbox-specific date formats

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoadduser: check whether run with no USERNAME. Closes 6728
Denys Vlasenko [Fri, 20 Dec 2013 19:45:02 +0000 (20:45 +0100)]
adduser: check whether run with no USERNAME. Closes 6728

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotestsuite: fix false positives for du
Denys Vlasenko [Fri, 20 Dec 2013 01:55:16 +0000 (02:55 +0100)]
testsuite: fix false positives for du

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: fix make gconfig
Daniel Borca [Thu, 19 Dec 2013 03:43:24 +0000 (04:43 +0100)]
build system: fix make gconfig

Was getting "undefined reference to symbol 'dlsym@@GLIBC_2.2.5'".

Signed-off-by: Daniel Borca <dborca@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosed: accept s///i as a synonym for s///I ("ignore case")
David A. Wheeler [Fri, 6 Dec 2013 01:42:17 +0000 (20:42 -0500)]
sed: accept s///i as a synonym for s///I ("ignore case")

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agohostname: do not use gethostbyname() for "hostname -s"
Michael Tokarev [Tue, 17 Dec 2013 18:13:45 +0000 (19:13 +0100)]
hostname: do not use gethostbyname() for "hostname -s"

There's no reason to call gethostbyname() on the value returned
by uname() when asked just for a short name of a host.  This may
also be wrong, when uname is set to one value, but in /etc/hosts
(or elsewhere) the "canonical" name is different.  This is often
the case for localhost entry in /etc/hosts:

  127.0.0.1     localhost       myname

With this content of /etc/hosts, and uname being set to myname,
busybox hostname -s will return localhost, while regular
hostname utility returns myname.

Fix this by not calling gethostbyname() for the simple
'hostname -s' use.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agowget: user-friendly fallback to http
Lauri Kasanen [Tue, 17 Dec 2013 18:03:41 +0000 (19:03 +0100)]
wget: user-friendly fallback to http

GNU wget: wget google.com // ok
bb before: wget google.com // wget: not an http or ftp url

function                                             old     new   delta
parse_url                                            317     339     +22

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agokill[all[5]]: code shrink
Denys Vlasenko [Mon, 16 Dec 2013 16:45:44 +0000 (17:45 +0100)]
kill[all[5]]: code shrink

function                                             old     new   delta
kill_main                                            992     947     -45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agokillall5: return 2 if no processes got killed
Uros Vampl [Mon, 16 Dec 2013 16:44:58 +0000 (17:44 +0100)]
killall5: return 2 if no processes got killed

function                                             old     new   delta
kill_main                                            943     992     +49

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agodo not fail build if MAXSYMLINKS isn't defined
Michael Tokarev [Mon, 9 Dec 2013 10:45:01 +0000 (14:45 +0400)]
do not fail build if MAXSYMLINKS isn't defined

This is needed for, eg, hurd, which is known to have no constraints.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoexpand: use printable_string instead of hard-coding implementation
Michael Tokarev [Mon, 9 Dec 2013 12:09:35 +0000 (16:09 +0400)]
expand: use printable_string instead of hard-coding implementation

function                                             old     new   delta
expand_main                                          709     690     -19

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: speed up resyncing if our clock is seriously off
Denys Vlasenko [Sun, 8 Dec 2013 15:11:04 +0000 (16:11 +0100)]
ntpd: speed up resyncing if our clock is seriously off

function                                             old     new   delta
recv_and_process_peer_pkt                            892     922     +30

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: do not invalidate datapoints after step
Denys Vlasenko [Sat, 7 Dec 2013 16:29:03 +0000 (17:29 +0100)]
ntpd: do not invalidate datapoints after step

Used to set p->filter_datapoint[i].d_dispersion = MAXDISP
and clear reachable bits, but this proved to be too agressive:
after step (tested with suspinding laptop for ~30 secs),
this caused all previous data to be considered invalid,
making us needing to collect full ~8 datapoins per peer
after step in order to start trusting them.
In turn, this was making poll interval decrease even after
step was done. (Poll interval decreases already before step
in this scenario, because we see large offsets and end up with
no good peer to select).

function                                             old     new   delta
reset_peer_stats                                     157     139     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: comment out "spike detection" code
Denys Vlasenko [Wed, 4 Dec 2013 16:12:11 +0000 (17:12 +0100)]
ntpd: comment out "spike detection" code

function                                             old     new   delta
update_local_clock                                   982     835    -147

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: promote log level 3 to production
Denys Vlasenko [Wed, 4 Dec 2013 15:32:09 +0000 (16:32 +0100)]
ntpd: promote log level 3 to production

Without it, peer selection logic is hard to debug

function                                             old     new   delta
update_local_clock                                   861     982    +121
select_and_cluster                                   962    1065    +103
common_ping_main                                    1788    1821     +33
huft_build                                          1287    1296      +9
chpst_main                                           708     704      -4
INET6_resolve                                        127     119      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/2 up/down: 266/-12)           Total: 254 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agontpd: let user know if spike was detected
Denys Vlasenko [Wed, 4 Dec 2013 12:19:04 +0000 (13:19 +0100)]
ntpd: let user know if spike was detected

function                                             old     new   delta
update_local_clock                                   861     943     +82

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoUse unsigned printf/scanf conversion where more appropriate
Denys Vlasenko [Fri, 29 Nov 2013 15:45:45 +0000 (16:45 +0100)]
Use unsigned printf/scanf conversion where more appropriate

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofix assorted unused code and wrong format specs found by cppchekc (bug 6716)
Denys Vlasenko [Fri, 29 Nov 2013 15:43:33 +0000 (16:43 +0100)]
fix assorted unused code and wrong format specs found by cppchekc (bug 6716)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agochpst: fix a bug where -U USER was using wrong USER (one from -u USER)
Denys Vlasenko [Fri, 29 Nov 2013 15:39:28 +0000 (16:39 +0100)]
chpst: fix a bug where -U USER was using wrong USER (one from -u USER)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoping: try SOCK_DGRAM if no root privileges
Daniel Borca [Thu, 28 Nov 2013 11:50:25 +0000 (12:50 +0100)]
ping: try SOCK_DGRAM if no root privileges

Signed-off-by: Daniel Borca <dborca@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agodpkg-deb: cosmetic correction to usage text
Daniel Borca [Thu, 28 Nov 2013 11:38:25 +0000 (12:38 +0100)]
dpkg-deb: cosmetic correction to usage text

Signed-off-by: Daniel Borca <dborca@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosed: code shrink
Denys Vlasenko [Thu, 28 Nov 2013 11:08:51 +0000 (12:08 +0100)]
sed: code shrink

function                                             old     new   delta
get_next_line                                        246     250      +4
sed_main                                             671     662      -9
add_input_file                                        47       -     -47
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 4/-56)             Total: -52 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosed: open input files sequentially to avoid EMFILE
Denys Vlasenko [Thu, 28 Nov 2013 02:14:16 +0000 (03:14 +0100)]
sed: open input files sequentially to avoid EMFILE

Currently, sed pre-opens all files, which may cause EMFILE errors
on systems with low ulimit -n.  Change sed to open one file at a time.

function                                             old     new   delta
get_next_line                                        177     235     +58
sed_main                                             682     652     -30
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 58/-30)             Total: 28 bytes

Based on the patch by Daniel Borca <dborca@yahoo.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agohush: typo fixes in comments
Denys Vlasenko [Thu, 28 Nov 2013 00:50:01 +0000 (01:50 +0100)]
hush: typo fixes in comments

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoplatform: strchrnul is missing if __APPLE__
Daniel Borca [Tue, 26 Nov 2013 23:27:46 +0000 (00:27 +0100)]
platform: strchrnul is missing if __APPLE__

Signed-off-by: Daniel Borca <dborca@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: use od -b instead of od -t x1
Denys Vlasenko [Tue, 26 Nov 2013 13:56:29 +0000 (14:56 +0100)]
build system: use od -b instead of od -t x1

od -t is not available in non-CONFIG_DESKTOPed busybox od

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoinit: halt on SIGPWR too
Bogdan Purcareata [Tue, 26 Nov 2013 12:54:48 +0000 (13:54 +0100)]
init: halt on SIGPWR too

Most init processes implement a handler for SIGPWR that gracefully
stops all child processes when shutting down a machine. Some other
technologies rely on this signal - e.g. Busybox powered LXC
containers.

This patch makes busybox init halt when receiving SIGPWR.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: add sketch of tentative 'better' passwd/group API
Denys Vlasenko [Tue, 26 Nov 2013 12:46:18 +0000 (13:46 +0100)]
libbb: add sketch of tentative 'better' passwd/group API

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agodevfsd: remove static variable
Denys Vlasenko [Tue, 26 Nov 2013 11:12:27 +0000 (12:12 +0100)]
devfsd: remove static variable

function                                             old     new   delta
static.msg                                             4       -      -4
get_uid_gid                                          114     107      -7
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-11)             Total: -11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agobuild system: do not generate MAX_APPLET_NAME_LEN (unused)
Denys Vlasenko [Tue, 26 Nov 2013 11:03:24 +0000 (12:03 +0100)]
build system: do not generate MAX_APPLET_NAME_LEN (unused)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agologread: don't call shmdt() before exit, kernel does it for us.
Denys Vlasenko [Tue, 26 Nov 2013 11:02:18 +0000 (12:02 +0100)]
logread: don't call shmdt() before exit, kernel does it for us.

function                                             old     new   delta
logread_main                                         472     466      -6
interrupted                                           20       9     -11
error_exit                                            20       -     -20
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/2 up/down: 0/-37)             Total: -37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agologread: flush output. closes 6710
Denys Vlasenko [Tue, 26 Nov 2013 10:44:27 +0000 (11:44 +0100)]
logread: flush output. closes 6710

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoawk: fix a bug in argc counting in recent change
Denys Vlasenko [Thu, 21 Nov 2013 14:09:55 +0000 (15:09 +0100)]
awk: fix a bug in argc counting in recent change

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agorfkill: use new-style config/kbuild/applet
Denys Vlasenko [Wed, 20 Nov 2013 13:20:07 +0000 (14:20 +0100)]
rfkill: use new-style config/kbuild/applet

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotar: prevent empty file to be treated as valid tarball
Denys Vlasenko [Tue, 19 Nov 2013 16:17:48 +0000 (17:17 +0100)]
tar: prevent empty file to be treated as valid tarball

function                                             old     new   delta
tar_main                                             879     895     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofix a copy/paste error in last tar testcase name
Denys Vlasenko [Tue, 19 Nov 2013 15:56:26 +0000 (16:56 +0100)]
fix a copy/paste error in last tar testcase name

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotar: add a testcase for previous commit
Denys Vlasenko [Tue, 19 Nov 2013 13:52:02 +0000 (14:52 +0100)]
tar: add a testcase for previous commit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agotar: fix exitcode check for MMU-spawned unpacking helpers
Denys Vlasenko [Tue, 19 Nov 2013 13:44:04 +0000 (14:44 +0100)]
tar: fix exitcode check for MMU-spawned unpacking helpers

Testcase: tar xvzf EMPTY_FILE

function                                             old     new   delta
open_transformer                                     102     106      +4
get_header_tar                                      1781    1785      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agolibbb: move nuke_str() from passwd into libbb
Denys Vlasenko [Tue, 19 Nov 2013 12:36:45 +0000 (13:36 +0100)]
libbb: move nuke_str() from passwd into libbb

function                                             old     new   delta
nuke_str                                               -      15     +15
ask_and_check_password_extended                      215     206      -9
init_main                                            781     771     -10
nuke_str                                              27       -     -27
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 15/-46)            Total: -31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agocomment tweak
Denys Vlasenko [Tue, 19 Nov 2013 12:16:44 +0000 (13:16 +0100)]
comment tweak

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agosulogin: use common password-checking routine.
Denys Vlasenko [Tue, 19 Nov 2013 12:09:06 +0000 (13:09 +0100)]
sulogin: use common password-checking routine.

This needed some extensions correct_passwd() function,
which got renamed ask_and_check_password() to better describe what it does.

function                                             old     new   delta
ask_and_check_password_extended                        -     215    +215
ask_and_check_password                                 -      12     +12
vlock_main                                           394     397      +3
sulogin_main                                         494     326    -168
correct_password                                     207       -    -207
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/1 up/down: 230/-375)         Total: -145 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoarchival/*: move "config:" snippets into .c files
Denys Vlasenko [Thu, 14 Nov 2013 10:39:00 +0000 (11:39 +0100)]
archival/*: move "config:" snippets into .c files

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoarchival/*: move "applet:" snippets into .c files, part 2
Denys Vlasenko [Thu, 14 Nov 2013 10:38:18 +0000 (11:38 +0100)]
archival/*: move "applet:" snippets into .c files, part 2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoarchival/*: move "applet:" snippets into .c files
Denys Vlasenko [Thu, 14 Nov 2013 08:54:24 +0000 (09:54 +0100)]
archival/*: move "applet:" snippets into .c files

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoarchival/*: move "kbuild:" snippets into .c files
Denys Vlasenko [Thu, 14 Nov 2013 08:53:52 +0000 (09:53 +0100)]
archival/*: move "kbuild:" snippets into .c files

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoswitch editors/* to embedded-in-source kbuild system
Denys Vlasenko [Wed, 13 Nov 2013 11:45:33 +0000 (12:45 +0100)]
switch editors/* to embedded-in-source kbuild system

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoawk: optionally support -e AWK_PROG
Sven-Göran Bergh [Tue, 12 Nov 2013 13:18:25 +0000 (14:18 +0100)]
awk: optionally support -e AWK_PROG

function                                             old     new   delta
awk_main                                             959     978     +19

Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofstrim: use new-style config/kbuild/applet snippets; trim help text
Denys Vlasenko [Tue, 12 Nov 2013 11:09:14 +0000 (12:09 +0100)]
fstrim: use new-style config/kbuild/applet snippets; trim help text

function                                             old     new   delta
packed_usage                                       29546   29520     -26

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agoudhcp: add PXELINUX config file option (code 209) definition
Jeremy Kerr [Tue, 12 Nov 2013 10:18:26 +0000 (11:18 +0100)]
udhcp: add PXELINUX config file option (code 209) definition

This change adds a definition for DHCP option 209. RFC 5071 defines code
209 as a configuration file for a PXE bootloader; this change uses
the string "pxeconffile" as its text identifier.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofix "warning: ISO C90 forbids mixed declarations and code"
Denys Vlasenko [Tue, 12 Nov 2013 10:16:30 +0000 (11:16 +0100)]
fix "warning: ISO C90 forbids mixed declarations and code"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 years agofix bashisms in testsuite/
Michael Tokarev [Sun, 10 Nov 2013 21:01:38 +0000 (22:01 +0100)]
fix bashisms in testsuite/

These places use ${var/search/replace}, $((n++) and
`type -p' constructs which are not-so-standard.
Replace with equivalent constructs.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
10 years agofstrim: Needs to fire at the mp, not bd
Bernhard Reutner-Fischer [Sun, 10 Nov 2013 20:47:02 +0000 (21:47 +0100)]
fstrim: Needs to fire at the mp, not bd

It's a filesystem thing from this perspective.
+1b

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
10 years agofstrim: Indicate failure on error
Bernhard Reutner-Fischer [Sat, 9 Nov 2013 23:02:43 +0000 (00:02 +0100)]
fstrim: Indicate failure on error

+14b

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
10 years agofstrim: -17b
Bernhard Reutner-Fischer [Sat, 9 Nov 2013 22:13:17 +0000 (23:13 +0100)]
fstrim: -17b

Also, use the name of the block device we found, not necessarily the one
we got from the user:
fstrim -v /
/dev/sdj: 4711 bytes were trimmed

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
10 years agofstrim: New applet
Malek Degachi [Sat, 9 Nov 2013 20:27:27 +0000 (21:27 +0100)]
fstrim: New applet

fstrim applet is a port from util-linux.

"Trimming" your NAND/eMMC storage will restore the write performance
back to normal after having slow down issues on sequential write and
random write due to usage over time.

Good reading on subject:
http://forum.xda-developers.com/showthread.php?t=1971852

(with long options and CLEAN_UP turned on)
function                                             old     new   delta
.rodata                                           148494  148791    +297
fstrim_main                                            -     283    +283
fstrim_sfx                                             -     128    +128
packed_usage                                       28826   28903     +77
applet_main                                         2760    2768      +8
applet_names                                        2343    2350      +7
applet_nameofs                                       690     692      +2
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 5/0 up/down: 802/0)             Total: 802 bytes

Signed-off-by: Malek Degachi <malek-degachi@laposte.net>
Cc: Eugene San (eugenesan) <eugenesan@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
10 years agoash: Set SHLVL in ASH_BASH_COMPAT
Bernhard Reutner-Fischer [Fri, 8 Nov 2013 13:25:24 +0000 (14:25 +0100)]
ash: Set SHLVL in ASH_BASH_COMPAT

function                                             old     new   delta
ash_main                                            1456    1505     +49
.rodata                                           148488  148494      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 55/0)               Total: 55 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
10 years agoash: Use setvar2 some more
Bernhard Reutner-Fischer [Fri, 8 Nov 2013 13:12:13 +0000 (14:12 +0100)]
ash: Use setvar2 some more

(add/remove: 0/0 grow/shrink: 10/15 up/down: 13/-27)          Total: -14 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
10 years agoswaponoff: shrink
Bernhard Reutner-Fischer [Fri, 27 Sep 2013 11:39:41 +0000 (13:39 +0200)]
swaponoff: shrink

function                                             old     new   delta
.rodata                                           148469  148468      -1
swap_on_off_main                                     381     379      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-3)               Total: -3 bytes
   text    data     bss     dec     hex filename
 803030    4090    9504  816624   c75f0 busybox_old
 803027    4090    9504  816621   c75ed busybox_unstripped

11 years agoudhcpc: allow zero server-id. Closes 6614.
Denys Vlasenko [Sun, 3 Nov 2013 18:20:54 +0000 (19:20 +0100)]
udhcpc: allow zero server-id. Closes 6614.

function                                             old     new   delta
bcast_or_ucast                                         -      47     +47
udhcp_send_kernel_packet                             271     295     +24
udhcpc_main                                         2696    2705      +9
udhcp_send_raw_packet                                456     459      +3
send_release                                          90      76     -14
send_renew                                           105      77     -28
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 83/-42)             Total: 41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoinit: fix illegal memory access when max message length is reached
Yuan-Hsiang Lee [Sat, 2 Nov 2013 23:13:16 +0000 (00:13 +0100)]
init: fix illegal memory access when max message length is reached

Signed-off-by: Yuan-Hsiang Lee <yhlee@ubnt.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agobootchartd: warn if .config looks wrong
Denys Vlasenko [Sat, 2 Nov 2013 23:07:31 +0000 (00:07 +0100)]
bootchartd: warn if .config looks wrong

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMakefile.custom: make "make release" delete .gitignore files too
Denys Vlasenko [Sat, 2 Nov 2013 21:06:36 +0000 (22:06 +0100)]
Makefile.custom: make "make release" delete .gitignore files too

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: fix "sed clusternewline" testcase
Denys Vlasenko [Wed, 30 Oct 2013 13:25:22 +0000 (14:25 +0100)]
sed: fix "sed clusternewline" testcase

function                                             old     new   delta
process_files                                       2197    2226     +29
flush_append                                          47      54      +7
get_next_line                                        184     189      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0)               Total: 41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: document -E in help text
Denys Vlasenko [Wed, 30 Oct 2013 12:00:00 +0000 (13:00 +0100)]
sed: document -E in help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: fix memory leak in 'r FILE' command
Denys Vlasenko [Wed, 30 Oct 2013 09:22:47 +0000 (10:22 +0100)]
sed: fix memory leak in 'r FILE' command

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agosed: accept -E as a synonym for -r
David A. Wheeler [Mon, 28 Oct 2013 23:52:48 +0000 (00:52 +0100)]
sed: accept -E as a synonym for -r

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoudhcpc: make DHCP packets to have at least 300 DHCP bytes
Johannes Stezenbach [Mon, 28 Oct 2013 22:27:37 +0000 (23:27 +0100)]
udhcpc: make DHCP packets to have at least 300 DHCP bytes

Commit b8b72f02 removed all padding from DHCP packets
to fix operation with buggy servers which can't handle
maximum sized packets.  But it introduced a regression
with buggy routers which drop DHCP packets smaller
than 300 bytes (i.e. 342 byte ethernet packets).
Add back some padding to work around.

function                                             old     new   delta
udhcp_send_kernel_packet                             268     292     +24
udhcp_send_raw_packet                                462     473     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 35/0)               Total: 35 bytes

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolibbb: use <poll.h> instead of <sys/poll.h>
Thomas Petazzoni [Wed, 16 Oct 2013 17:59:45 +0000 (19:59 +0200)]
libbb: use <poll.h> instead of <sys/poll.h>

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agobloat-o-meter: add usage info
Bartosz Golaszewski [Wed, 16 Oct 2013 17:18:05 +0000 (19:18 +0200)]
bloat-o-meter: add usage info

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotail compat: fix header printing for tail -f
Bartosz Golaszewski [Mon, 14 Oct 2013 18:11:55 +0000 (20:11 +0200)]
tail compat: fix header printing for tail -f

Makes tail -f for multiple files display the header only if another (ie. not
currently displayed) file changed.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowget: if FEATURE_CLEAN_UP, free(ptr_to_globals)
Guilherme Maciel Ferreira [Wed, 16 Oct 2013 12:43:30 +0000 (14:43 +0200)]
wget: if FEATURE_CLEAN_UP, free(ptr_to_globals)

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix some compiler warnings emitted by gcc-4.8.0
Denys Vlasenko [Wed, 16 Oct 2013 12:21:20 +0000 (14:21 +0200)]
Fix some compiler warnings emitted by gcc-4.8.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoether-wake: shorten help text, reduce packet buffer size
Denys Vlasenko [Mon, 14 Oct 2013 17:04:20 +0000 (19:04 +0200)]
ether-wake: shorten help text, reduce packet buffer size

function                                             old     new   delta
ether_wake_main                                      726     727      +1
packed_usage                                       29468   29434     -34

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowget: add support for connect timeout
Lauri Kasanen [Sat, 12 Oct 2013 19:47:07 +0000 (21:47 +0200)]
wget: add support for connect timeout

function                                             old     new   delta
open_socket                                           33      64     +31
wget_main                                           2182    2194     +12

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoinit: better --help text
Denys Vlasenko [Sat, 12 Oct 2013 02:52:22 +0000 (04:52 +0200)]
init: better --help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoawk: fix length(array)
Denys Vlasenko [Sat, 12 Oct 2013 02:51:54 +0000 (04:51 +0200)]
awk: fix length(array)

function                                             old     new   delta
evaluate                                            3526    3548     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowall,crontab: use xopen_as_uid_gid()
Ryan Mallon [Tue, 8 Oct 2013 12:53:29 +0000 (14:53 +0200)]
wall,crontab: use xopen_as_uid_gid()

This fixes a narrow security race in crontab.

function                                             old     new   delta
xopen_as_uid_gid                                       -      80     +80
seteuid                                                -      64     +64
setegid                                                -      64     +64
setreuid                                               -      37     +37
xseteuid                                               -      22     +22
xsetegid                                               -      22     +22
crontab_main                                         590     577     -13
setfsuid                                              33       -     -33
setfsgid                                              33       -     -33
wall_main                                            138     102     -36
open_as_user                                         109       -    -109

   text    data     bss     dec     hex filename
 893539     497    7568  901604   dc1e4 busybox_old
 893618     497    7568  901683   dc233 busybox_unstripped

Signed-off-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agolibbb: Add xsetegid(), xseteuid(), xopen_as_uid_gid() functions
Ryan Mallon [Tue, 8 Oct 2013 12:52:49 +0000 (14:52 +0200)]
libbb: Add xsetegid(), xseteuid(), xopen_as_uid_gid() functions

Signed-off-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agobunzip2: fix off-by-one check
Denys Vlasenko [Sun, 6 Oct 2013 20:53:14 +0000 (22:53 +0200)]
bunzip2: fix off-by-one check

stage3-armv7a_hardfp-20130209.tar.bz2, 149189948 bytes long,
md5sum b29ce23312e14eb15a143377d4a38473, was failing to unpack.

It so happened that this file has a run which exactly fills
the 90k buffer. The check was "size >= bufsize", apparently
it has to be ">".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agowall: access FILE under real user's credentials
Denys Vlasenko [Sun, 6 Oct 2013 13:14:25 +0000 (15:14 +0200)]
wall: access FILE under real user's credentials

While at it, move applet/config/kbuild bits into wall.c.
(This way, it's more visible that applet is suid'ed).

function                                             old     new   delta
wall_main                                             87     138     +51

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotrylink: only prefix libs with -l
Mike Frysinger [Thu, 12 Sep 2013 04:29:40 +0000 (00:29 -0400)]
trylink: only prefix libs with -l

If our pkg-config queries pass back a flag like -pthread, the trylink
script will expand that to -l-pthread.  So change trylink to only add
the -l prefix to a value that doesn't have a - prefix already.

Reported-by: thaehaid@incognitomail.org
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoloadkmap: explain what happens with K_ALLOCATED key value
Denys Vlasenko [Thu, 19 Sep 2013 15:56:59 +0000 (17:56 +0200)]
loadkmap: explain what happens with K_ALLOCATED key value

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agohttpd: make sire pfd[TO_CGI].revents is cleared before poll()
Denys Vlasenko [Wed, 18 Sep 2013 10:08:41 +0000 (12:08 +0200)]
httpd: make sire pfd[TO_CGI].revents is cleared before poll()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoDocumentation update
Denys Vlasenko [Tue, 17 Sep 2013 14:24:01 +0000 (16:24 +0200)]
Documentation update

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agodumpkmap: code shrink
Denys Vlasenko [Tue, 17 Sep 2013 12:16:25 +0000 (14:16 +0200)]
dumpkmap: code shrink

function                                             old     new   delta
dumpkmap_main                                        223     160     -63

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agohttpd: treat errors from stdin correctly.
Denys Vlasenko [Wed, 11 Sep 2013 12:59:21 +0000 (14:59 +0200)]
httpd: treat errors from stdin correctly.

Fron bug report:

If a CGI or proxied connection is rudely aborted (SIG_{KILL,BUS,SEGV})
then httpd will spin madly the poll loop in:

networking/httpd.c:1080
cgi_io_loop_and_exit()

Upon investigation I found that pfd[0].revents == 0x0018 (POLLHUP|POLLERR),
which leads to empty read, but the pfd[0].fd (STDIN_FILENO) is left open,
and in the FD list given to poll() which immediately returns to once
again inform the loop of (POLLHUP|POLLERR) condition of pfd[0].fd.
This continues until pfd[FROM_CGI].revents != 0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotouch: add conditional support for -h
Denys Vlasenko [Wed, 11 Sep 2013 09:58:33 +0000 (11:58 +0200)]
touch: add conditional support for -h

Based on a patch by Andy <andy.padavan@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoar: better comment
Denys Vlasenko [Tue, 10 Sep 2013 14:27:08 +0000 (16:27 +0200)]
ar: better comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoar: read_num(): fix reading fields using the entire width
Peter Korsgaard [Tue, 10 Sep 2013 09:52:35 +0000 (11:52 +0200)]
ar: read_num(): fix reading fields using the entire width

ar fields are fixed length text strings (padded with spaces). Ensure
bb_strtou doesn't read past the field in case the full width is used.

The fields are only read once, so the simplest/smallest solution to me
seems to be to just pass the length to read_num() and then zero terminate
the string before passing it to bb_strtou. This does mean that the fields
MUST be read in reverse order, so some minor reshuffling was needed.

Bloat-o-meter:
function                                             old     new   delta
get_header_ar                                        394     414     +20
read_num                                              29      36      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0)               Total: 27 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agotop: fix breakage introduced by previous commit
Denys Vlasenko [Fri, 6 Sep 2013 10:59:48 +0000 (12:59 +0200)]
top: fix breakage introduced by previous commit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>