Commit Graph

867 Commits

Author SHA1 Message Date
Stephen Heumann
ef1a853400 Minimal changes to enable hush-only builds on OS X 2014-10-26 21:14:47 -05:00
Denys Vlasenko
d6e7672545 less: move "retry-on-EAGAIN" logic closer to read ops
This makes "G" (goto end of input) command work as well as
/search_for_nonexistent_string: both will read to EOF now
even from somewhat slow input (such as kernel's "git log").

function                                             old     new   delta
ndelay_on                                             35      43      +8
ndelay_off                                            35      43      +8
read_lines                                           695     691      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4)              Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-22 21:14:02 +02:00
Morten Kvistgaard
feac9b607d ftpd: add optional support for authentication
function                                             old     new   delta
cmdio_get_cmd_and_arg                                  -     237    +237
get_passwd                                             -      97     +97
check_password                                         -      82     +82
ftpd_main                                           2297    2178    -119
ask_and_check_password_extended                      206      84    -122
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 0/2 up/down: 416/-241)          Total: 175 bytes

Signed-off-by: Morten Kvistgaard <MK@pch-engineering.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-05 21:57:18 +02:00
Bartosz Golaszewski
bf0f2c7aa6 Rename INIT_LAST to INIT_FUNC to avoid confusion
We don't have an INIT_FIRST, so let's rename INIT_LAST to INIT_FUNC
to imply that the function is called at program start-up.

Also: the priority argument for __attribute__((constructor)) isn't
used, so let's remove it.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-30 16:26:57 +02:00
Bartosz Golaszewski
3ed81cf052 unit-tests: implement the unit-testing framework
This set of patches adds a simple unit-testing framework to Busybox

unit-tests: add some helper macros for unit-test framework implementation
unit-tests: implement the unit-testing framework
unit-tests: add basic documentation on writing the unit test cases
unit-tests: modify the Makefile 'test' target to run unit-tests too
unit-tests: add two example test cases
unit-tests: modify the existing strrstr test code to use the unit-test framework

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 16:30:41 +02:00
Bartosz Golaszewski
5d2e409ef8 libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes
function                                             old     new   delta
bb_sc_clk_tck                                          -      10     +10
timescmd                                             118     113      -5
print_route                                         1763    1758      -5
mpstat_main                                         1288    1283      -5
iostat_main                                         1947    1942      -5
INET_setroute                                        879     871      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/5 up/down: 10/-28)            Total: -18 bytes
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 14:01:13 +02:00
Denys Vlasenko
f92f1d0181 find: use sysconf(_SC_ARG_MAX) to determine the command-line size limit
The find utility uses a hardcoded value of 32 * 1024 as the limit of
the command-line length when calling 'find -exec ... {} +'. This results
in over 4 times more execve() calls than in coreutils' find.

This patch uses the limit defined in system headers.

Based on the patch by  Bartosz Golaszewski <bartekgola@gmail.com>.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 13:54:40 +02:00
Denys Vlasenko
17f8418ea7 Add conditional support for -v / --verbose
With FEATURE_VERBOSE off, practically no size change.
With it on:

function                                             old     new   delta
remove_file                                          493     556     +63
install_main                                         719     765     +46
bb_make_directory                                    383     419     +36
rmdir_main                                           162     191     +29
copy_file                                           1516    1544     +28
mv_main                                              502     525     +23
cmp_main                                             677     693     +16
bbconfig_config_bz2                                 5264    5279     +15
mkdir_main                                           158     168     +10
install_longopts                                      66      76     +10
rm_main                                              167     175      +8
nexpr                                                840     846      +6
scan_tree                                            275     280      +5
fsck_main                                           1807    1811      +4
ed_main                                             2541    2545      +4
expand_one_var                                      1574    1575      +1
swap_on_off_main                                     420     418      -2
parse_command                                       1443    1440      -3
redirect                                            1279    1274      -5
do_load                                              946     918     -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 16/4 up/down: 304/-38)          Total: 266 bytes

Based on the patch by Igor Živković.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-19 16:23:50 +02:00
Denys Vlasenko
e765b5ac34 libbb: rename execable -> executable. No code changes
English speakers complained that it sounded awfully broken.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 17:15:58 +02:00
Denys Vlasenko
3dfe0ae5a8 libbb: make syslog level for bb_error_msg's configurable. use it in crond
function                                             old     new   delta
bb_verror_msg                                        380     386      +6
syslog_level                                           -       1      +1
crondlog                                             165     108     -57

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-30 14:48:28 +02:00
Denys Vlasenko
6f068904dc xargs: add support for -I and -i. Closes 493
function                                             old     new   delta
process_stdin_with_replace                             -     195    +195
xmalloc_substitute_string                              -     145    +145
xargs_main                                           808     884     +76
count_strstr                                           -      45     +45
packed_usage                                       29580   29571      -9
parse_params                                        1445    1416     -29
func_exec                                            285     138    -147
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 1/3 up/down: 461/-185)          Total: 276 bytes
   text	   data	    bss	    dec	    hex	filename
 922156	    932	  17692	 940780	  e5aec	busybox_old
 922440	    932	  17692	 941064	  e5c08	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-27 11:17:06 +01:00
Denys Vlasenko
640ce3de07 zcat: complain if input is not compressed
function                                             old     new   delta
buffer_fill_and_print                                178     191     +13
varvalue                                             735     743      +8
bbunpack                                             747     755      +8
open_zipped                                           85      89      +4
xmalloc_open_zipped_read_close                        61      63      +2
get_addr_1                                           240     242      +2
fbsplash_main                                       1228    1230      +2
pstree_main                                          322     321      -1
builtin_type                                         121     119      -2
do_load                                              954     926     -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/3 up/down: 39/-31)              Total: 8 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-02 02:06:38 +01:00
Denys Vlasenko
8b59b2c13e 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>
2013-11-19 13:36:45 +01:00
Denys Vlasenko
9c1c605b1a 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>
2013-11-19 13:09:06 +01:00
Thomas Petazzoni
af4f0e48ec 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>
2013-10-16 19:59:45 +02:00
Guilherme Maciel Ferreira
840ef17f63 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>
2013-10-16 14:43:30 +02:00
Ryan Mallon
5906a5c26c 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>
2013-10-08 14:52:49 +02:00
Denys Vlasenko
a407cf74cc Make smart_ulltoa return pointer to end (allows for code shink in callers)
function                                             old     new   delta
smart_ulltoa5                                        405     408      +3
smart_ulltoa4                                        273     276      +3
list_table                                          1113    1114      +1
scale                                                 36      34      -2
put_lu                                                55      53      -2
ulltoa6_and_space                                     19      14      -5
powertop_main                                       1470    1461      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-09-06 12:53:14 +02:00
Denys Vlasenko
982e87f2fb Whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-30 11:52:58 +02:00
Denys Vlasenko
bfa6ed1bf4 catv: code shrink
catv_main                                            250     227     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-30 11:41:58 +02:00
Bartosz Golaszewski
79c618c411 Refactor catv. Move visible() from stty to libbb.
Fixes the following TODO:

  stty's visible() function and catv's guts are identical. Merge them into
  an appropriate libbb function.

Also makes catv behave exactly like coreutils' cat -v e.g. it'll print 'M-^I'
instead of 'M-   '.

function                                             old     new   delta
visible                                                -      70     +70
do_display                                           431     379     -52
catv_main                                            306     250     -56
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 70/-108)           Total: -38 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-30 06:29:42 +02:00
Bartosz Golaszewski
c19be75d57 networking: code shrink
function                                             old     new   delta
in_ether                                               -     124    +124
hexchar2int                                           42       -     -42
ifconfig_main                                       1237    1106    -131
ether_input                                          141       -    -141
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/1 up/down: 124/-314)         Total: -190 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-25 04:39:04 +02:00
Denys Vlasenko
c72b43c2f0 Commonalize typical [b,]k,m suffix struct
function                                             old     new   delta
bkm_suffixes                                           -      32     +32
static.km_suffixes                                    24       -     -24
suffixes                                              32       -     -32
static.bkm                                            32       -     -32
head_tail_suffixes                                    32       -     -32
------------------------------------------------------------------------------
(add/remove: 2/6 grow/shrink: 0/0 up/down: 72/-160)           Total: -88 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-13 23:49:45 +02:00
Denys Vlasenko
59f46676a9 Move create_icmp[6]_socket to its only user, and simplify it
function                                             old     new   delta
run_applet_and_exit                                  711     714      +3
sendping_tail                                        239     236      -3
common_ping_main                                    1798    1770     -28
create_icmp_socket                                    65       -     -65
create_icmp6_socket                                   65       -     -65
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 1/2 up/down: 3/-161)           Total: -158 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-28 00:30:46 +02:00
Denys Vlasenko
4928e9f7d0 losetup: assorted fixes. Closes 6314
"losetup -d" was not complaining that LOOPDEV is missing.
"losetup -a" was listing only up to /dev/loop9.
"losetup -f" looped forever if llop0 was taken, and never tried
anything after /dev/loop9.
"-o" with other options (say, -r) had no effect.

function                                             old     new   delta
losetup_main                                         376     419     +43

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-27 03:45:16 +02:00
Flemming Madsen
d96ffda62e ash,hush: history builtin
function                                             old     new   delta
show_history                                           -      39     +39
builtin_history                                        -      16     +16
historycmd                                             -      13     +13
bltins1                                              312     324     +12
builtintab                                           336     344      +8
popstring                                            134     140      +6
hush_main                                           1048    1046      -2
ash_main                                            1398    1396      -2
size_from_HISTFILESIZE                                44      40      -4
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 3/3 up/down: 94/-8)              Total: 86 bytes

Signed-off-by: Flemming Madsen <busybox@themadsens.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07 18:47:24 +02:00
Denys Vlasenko
8f2cb7ab26 libbb: introduce and use strftime_[YYYYMMDD]HHMMSS()
function                                             old     new   delta
strftime_fmt                                           -      53     +53
strftime_YYYYMMDDHHMMSS                                -      12     +12
strftime_HHMMSS                                        -      12     +12
human_time                                            44      43      -1
fmtstr_t                                               9       -      -9
step_time                                            361     345     -16
watch_main                                           261     232     -29
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 0/3 up/down: 77/-55)             Total: 22 bytes
   text	   data	    bss	    dec	    hex	filename
 919203	    932	  17692	 937827	  e4f63	busybox_old
 919209	    932	  17692	 937833	  e4f69	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29 12:30:33 +01:00
Denys Vlasenko
1961aea305 move endofname() to libbb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-26 00:36:53 +01:00
Denys Vlasenko
2cfcc9e9d7 sha3: code shrink
function                                             old     new   delta
sha3_hash                                            155     101     -54

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 00:38:09 +01:00
Denys Vlasenko
6830ade6aa whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 13:58:01 +01:00
Lauri Kasanen
b8173b603f sha3sum: new applet
function                                             old     new   delta
KeccakF                                                -     496    +496
KeccakF_RoundConstants                                 -     192    +192
sha3_hash                                              -     171    +171
sha3_end                                               -      40     +40
hash_file                                            274     299     +25
KeccakF_RotationConstants                              -      25     +25
KeccakF_PiLane                                         -      25     +25
packed_usage                                       29213   29232     +19
sha3_begin                                             -      18     +18
KeccakF_Mod5                                           -      10     +10
applet_names                                        2445    2453      +8
applet_main                                         1420    1424      +4
applet_nameofs                                       710     712      +2
------------------------------------------------------------------------------
(add/remove: 8/0 grow/shrink: 9/7 up/down: 1049/-54)         Total: ~995 bytes

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 05:20:50 +01:00
Denys Vlasenko
fd77ea505e mark get_shell_name FAST_FUNC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-03 09:42:21 +02:00
Aurelien Jarno
d3a42391b1 *: declare strings with ALIGN1, as appropriate
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 16:28:34 +02:00
Pascal Bellard
70fc8c17e2 su: do not change to home dir unless -l
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-12 13:21:02 +02:00
Natanael Copa
02112d8ae3 unzip: ignore chmod errors
This makes unzip to FAT filesystems not exit with error.
This is similar to how the "normal" unzip works.

Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-28 01:29:15 +02:00
Ron Yorston
576b1d3c41 sendmail: use host rather than NIS domain name for HELO
According to RFC 5321 the argument to HELO "contains the fully-qualified
domain name of the SMTP client" or its IP address if no FQDN is available.
BusyBox sendmail uses the NIS domain name instead which, in many cases,
is likely to be the default "(none)". [vda: yes, I checked my machine
and its uts.domainname was indeed "(none)"]

Using the host name is more likely to satisfy the intent of the RFC while
allowing the otherwise unused safe_getdomainname function to be removed.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-28 17:04:19 +02:00
Denys Vlasenko
8a6a2f9c9c update seamless uncompression code
This change makes "tar tf hello_world.txz" work without
adding special-casing for ".txz" extension. It also removes
ever-growing magic checking code in rpm2cpio and get_header_tar -
we reuse one which lives in setup_unzip_on_fd.

function                                             old     new   delta
unpack_gz_stream                                       7     566    +559
check_signature16                                      -      70     +70
setup_unzip_on_fd                                     99     142     +43
handle_SIGCHLD                                         -      41     +41
unpack_bz2_stream                                    342     376     +34
unzip_main                                          2352    2385     +33
bbunpack                                             503     533     +30
open_transformer                                      74     102     +28
unpack_Z_stream                                     1278    1304     +26
unpack_gunzip                                        101     123     +22
init_transformer_aux_data                              -      18     +18
unpack_xz_stream                                    2388    2402     +14
open_zipped                                          131     141     +10
rpm_main                                            1358    1363      +5
get_header_tar_lzma                                   52      57      +5
get_header_tar_bz2                                    52      57      +5
unpack_lzma_stream                                  2698    2702      +4
hash_find                                            234     233      -1
get_header_tar                                      1759    1733     -26
get_header_tar_gz                                     92      57     -35
unpack_uncompress                                     51      12     -39
rpm2cpio_main                                        201     147     -54
unpack_unxz                                           67      12     -55
unpack_bz2_stream_prime                               55       -     -55
get_header_tar_Z                                      86       -     -86
unpack_gz_stream_with_info                           539       -    -539
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 14/6 up/down: 947/-890)          Total: 57 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-06 16:27:48 +01:00
Denys Vlasenko
59655077c5 preparatory cleanups for seamless uncompression improvements
unpack_gz_stream_with_info: fix buggy error check
man: fix possible accesses past the end of a string
move seamless uncompression helpers from read_printf.c to open_transformer.c

function                                             old     new   delta
show_manpage                                         153     212     +59
unpack_gz_stream_with_info                           520     539     +19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-06 16:23:50 +01:00
Jonh Wendell
9106107a50 Make unix (local) sockets work without IPv6 enabled
The xsocket_type() function had an optional "family" argument
that was enabled only if IPv6 is enabled. In the case of the
function was called with a valid AF_UNIX argument, and IPv6 is
disabled, this argument was silently ignored.

This patch makes the "family" argument mandatory, while keeping
the old behavior i.e., if AF_UNSPEC is passed, we try first IPv6
(if it's enabled) and fallback to IPv4.

Also I changed all callers of xsocket_type() to reflect its new
interface.

Signed-off-by: Jonh Wendell <jonh.wendell@vexcorp.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-09 15:14:33 +01:00
Denys Vlasenko
499597d6ef mdev: do not treat non-leading '#' chars as start of comment. Closes 4676
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-11 00:37:17 +01:00
Denys Vlasenko
3e0c428c45 Move include <shadow.h> close to pwd.h and grp.h includes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-08 16:13:55 +01:00
Denys Vlasenko
a76dd50ce1 Move Adroid endgrent() and endpwent() NOPS to libbb.h
They should be after includes of pwd.h and grp.h

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-08 16:11:38 +01:00
Denys Vlasenko
f282c6b657 libbb: remove is_directory's argument which is always NULL
function                                             old     new   delta
send_cgi_and_exit                                    892     890      -2
ln_main                                              447     445      -2
handle_incoming_and_exit                            2784    2780      -4
is_directory                                          66      59      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 2/-19)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-18 03:27:46 +01:00
Denys Vlasenko
d2277e262f nommu: fix cases where we mangle argv[0][0]
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-22 17:19:26 +01:00
Denys Vlasenko
1dc80bae0b libbb.h: add check for bad off_t size detection
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-17 21:51:32 +01:00
Denys Vlasenko
f59a50ee30 libbb.h: tighten up macro code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-16 21:30:19 +01:00
Peter Korsgaard
743edac6c8 bb_daemonize_or_rexec(): add flag to double-fork; use it in start-stop-daemon
Add a DAEMON_DOUBLE_FORK flag to make bb_daemonize double-fork so it isn't a
session leader, and hence doesn't get a controlling tty on Linux if a tty is
ever opened, similar to how libdaemon's daemon_fork or the big
start-stop-daemon does it - And use it in start-stop-daemon.

For details, see http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-09 19:44:37 +01:00
Denys Vlasenko
9ce09bc9cb lineedit: add support for M-b, M-f, M-d, M-Backspace
function                                             old     new   delta
ctrl_left                                              -      96     +96
ctrl_right                                             -      76     +76
static.esccmds                                        81      93     +12
read_line_input                                     3876    3885      +9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 193/0)             Total: 193 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-03 13:28:22 +01:00
Leonid Lisovskiy
328f27fe44 libbb: split decode_base64 off read_base64
function                                             old     new   delta
decode_base64                                          -     182    +182
read_base64                                          378     255    -123
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 182/-123)           Total: 59 bytes

Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-28 13:59:55 +02:00
Denys Vlasenko
ec447c7f01 libbb.h: remove unused defines
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-24 04:06:18 +02:00
Denys Vlasenko
1f56e51ca1 udhcpc: add support for DHCP option 212 (RFC 5969)
The patch is from OpenWRT people.

function                                             old     new   delta
xmalloc_optname_optval                               637     874    +237
dhcp_option_strings                                  237     243      +6
dhcp_optflags                                         68      70      +2
len_of_option_as_string                               12      13      +1
dhcp_option_lengths                                   12      13      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 247/0)             Total: 247 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-19 22:40:35 +02:00
Denys Vlasenko
16714245f9 add INIT_G()'s. No code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-21 01:59:15 +02:00
Denys Vlasenko
13e709c53f losetup: implement -r option. Closes 4033.
function                                             old     new   delta
packed_usage                                       28595   28633     +38
losetup_main                                         285     290      +5
singlemount                                          906     908      +2
set_loop                                             674     672      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-12 08:30:16 +02:00
Denys Vlasenko
dd1061b6a7 wget: URL-decode user:password before base64-encoding it into auth hdr. Closes 3625.
function                                             old     new   delta
percent_decode_in_place                                -     152    +152
parse_url                                            304     317     +13
handle_incoming_and_exit                            2795    2798      +3
httpd_main                                           763     760      -3
decodeString                                         152       -    -152
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/1 up/down: 168/-155)           Total: 13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-11 21:04:02 +02:00
Denys Vlasenko
d48fdde370 stop declariong our own dirname prototype
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-10 13:48:34 +02:00
Baruch Siach
e8f36330d9 networking: consolidate the IP checksum code. -129 bytes.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-07 17:55:40 +02:00
Denys Vlasenko
e45af7ad17 lineedit: remove SAVE_HISTORY bit, ->hist_file can be used as indicator
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 16:15:24 +02:00
Denys Vlasenko
bede215cf1 lineedit: add support for history saving on exit
Based on the patch by Dennis Groenen <tj.groenen@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 16:12:33 +02:00
Denys Vlasenko
67905e2d7c *: work around sysinfo.h versus linux/*.h problems
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-26 13:42:12 +02:00
Denys Vlasenko
be391e7596 libbb.h: do not use homegrown struct sysinfo.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-25 11:05:43 +02:00
Dan Fandrich
75214cfe00 Use the _unlocked stdio macros only when they're all available
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-30 02:59:17 +02:00
Denys Vlasenko
0c4cf42c1e libbb.h: tweak _unlocked hack
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-30 02:44:27 +02:00
Denys Vlasenko
06448912e6 libbb: use _unlocked variants of stdio I/O.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-20 10:06:28 +02:00
Timo Teras
adcabf3235 parse_config: use getline. BIG speedup with glibc (~40%).
function                                             old     new   delta
config_read                                          559     604     +45
getline                                                -      23     +23
config_close                                          29      49     +20
find_pair                                            169     187     +18
showmode                                             330     338      +8
hash_find                                            233     234      +1
builtin_umask                                        133     132      -1
lzo1x_optimize                                      1434    1429      -5
test_main                                            253     247      -6
buffer_fill_and_print                                196     179     -17
create_J                                            1849    1826     -23
config_free_data                                      37       -     -37
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 5/5 up/down: 138/-89)            Total: 26 bytes

Signed-off-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-20 09:49:56 +02:00
Denys Vlasenko
12ac6287ee procps: remove PSSCAN_STAT define, users were using it incorrectly
Also contains small cleanups ps.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-18 15:49:47 +02:00
Denys Vlasenko
a1a448347e libbb: split bb_get_chunk_from_file and bb_get_chunk_with_continuation
This also moves bb_get_chunk_with_continuation into its sole user,
parse_config.c.
This allows to optimize both functions separately,
they need to be optimized for speed.
(this need was highlighted by slow modprobe caused in part by slow
bb_get_chunk_with_continuation in config parser).

function                                             old     new   delta
bb_get_chunk_from_file                                 7     130    +123
config_read                                          457     558    +101
bb_get_chunk_with_continuation                       194       -    -194
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/0 up/down: 224/-194)           Total: 30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-17 03:37:43 +02:00
Denys Vlasenko
e6df7e261e libbb.h: small reordering
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-23 03:39:08 +02:00
Denys Vlasenko
9be4702a30 main: free suid_config list after use
function                                             old     new   delta
run_applet_no_and_exit                               438     450     +12
ifupdown_main                                       2147    2149      +2
writeFileToTarball                                  1325    1326      +1
pidof_main                                           244     245      +1
last_main                                            896     897      +1
grep_main                                            779     780      +1
find_list_entry2                                     121     122      +1
tar_main                                             835     833      -2
llist_unlink                                          28      26      -2
llist_rev                                             23      21      -2
main                                                 791     782      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/4 up/down: 19/-15)              Total: 4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16 12:21:31 +02:00
Denys Vlasenko
12a432715f adduser: safe username passing to passwd/addgroup
passwd: support creating SHA passwords
random code shrink

function                                             old     new   delta
crypt_make_pw_salt                                     -      87     +87
adduser_main                                         883     904     +21
...
crypt_make_salt                                       99      89     -10
chpasswd_main                                        329     312     -17
packed_usage                                       28731   28691     -40
passwd_main                                         1070    1000     -70
cryptpw_main                                         310     224     -86
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/12 up/down: 154/-288)        Total: -134 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 03:19:01 +02:00
Denys Vlasenko
89f5bfd6c3 libbb.h: use inlined sigfillset, sigemptyset, sigisemptyset on uclibc
text    data     bss     dec     hex filename
 875879     493    7584  883956   d7cf4 busybox_old
 875879     493    7584  883956   d7cf4 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 23:03:18 +02:00
Denys Vlasenko
80542bad2f hush: make read builtin interruptible.
function                                             old     new   delta
builtin_read                                         185     471    +286
check_and_run_traps                                  200     262     +62
nonblock_immune_read                                  73     119     +46
sigismember                                            -      44     +44
record_signal                                          -      21     +21
sigisemptyset                                          -      16     +16
...
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 7/5 up/down: 483/-46)           Total: 437 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:23:43 +02:00
Denys Vlasenko
80c5b6893d libbb: nonblock_safe_read->nonblock_immune_read, remove unused param of xmalloc_reads
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:21:10 +02:00
Denys Vlasenko
ca18311d0a libbb: make set_nport accept pointer to sockaddr, not to len_and_sockaddr.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-07 17:52:20 +02:00
Denys Vlasenko
2c4de5b045 ash,hush: optional support for $HISTFILESIZE.
Based on patch from Alexey Fomenko (ext-alexey.fomenko AT nokia.com)

function                                             old     new   delta
size_from_HISTFILESIZE                                 -      44     +44
hush_main                                            998    1025     +27
ash_main                                            1348    1374     +26
read_line_input                                     3361    3372     +11
new_line_input_t                                      17      24      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-31 13:16:52 +02:00
Denys Vlasenko
681efe20d3 use user's shell instead of hardwired "/bin/sh" (android needs this)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-08 21:00:36 +01:00
Denys Vlasenko
7d65abea09 libbb: make user/group name cache strings longer (~27 chars)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-01 16:27:13 +01:00
Denys Vlasenko
ab8d00d64f progress meter: fix bugs found in stall detection and unknown size logic
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-11 19:09:30 +01:00
Denys Vlasenko
d55e139649 progress meter: move file name to bb_progress_t. +20 bytes
We were doing expensive unicode conversion on every update

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-11 18:56:13 +01:00
Denys Vlasenko
805aa9fec9 progress bar: better overflow protection; more precise bar
function                                             old     new   delta
bb_progress_update                                   639     749    +110

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-10 14:25:51 +01:00
Denys Vlasenko
698e8095fa use unistd.h before _POSIX_VERSION
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-08 05:35:04 +01:00
Denys Vlasenko
66c5b12dbf ash: fix TMOUT not restoring tty attributes
function                                             old     new   delta
pgetc                                                420     500     +80
readtoken1                                          3202    3239     +37
read_line_input                                     3316    3337     +21
udhcpc_main                                         2610    2630     +20
file_get                                             266     272      +6
expandarg                                            958     963      +5
localcmd                                             257     259      +2
addLines                                              85      87      +2
read_line                                             94      95      +1
ed_main                                             2540    2541      +1
timed_out                                              1       -      -1
lineedit_read_key                                    256     255      -1
alrm_sighandler                                       44       -     -44
cmdloop                                              539     434    -105
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 10/2 up/down: 175/-151)          Total: 24 bytes
   text    data     bss     dec     hex filename
 887379     936   17200  905515   dd12b busybox_old
 887411     936   17192  905539   dd143 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-08 05:07:02 +01:00
Denys Vlasenko
dd807c16f9 incorporate header fixes proposed in bug 3097
Not sure these are *really* needed, but I suppose they don't hurt

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-07 14:58:57 +01:00
Denys Vlasenko
046341e8bd ash: optional support for $TMOUT variable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-04 17:53:59 +01:00
Denys Vlasenko
6307357eff move nofork_save_area from libbb.h to vfork_daemon_rexec.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-02 19:05:25 +01:00
Denys Vlasenko
b72baeb003 hush: use FEATURE_SH_NOFORK to enable NOFORK trick
Also expands docs

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-02 18:38:57 +01:00
Denys Vlasenko
c71b469f5d libbb: make BB_EXECVP/LP try to exec real binary if there's no /proc/self/exe
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-02 03:28:56 +01:00
Denys Vlasenko
8d0e0cdadf move utmp.h include to libbb.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-25 23:21:46 +01:00
Davide Cavalca
9b3b9790b3 add ENABLE_FEATURE_SYSTEMD and use it in syslogd
Signed-off-by: Davide Cavalca <davide@geexbox.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-25 02:26:03 +01:00
Denys Vlasenko
975c714183 nicer looking ifdef in libbb/makedev.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-24 23:53:12 +01:00
Chris Rees
330718ef55 FreeBSD compat
Signed-off-by: Chris Rees <utisoft@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-24 17:07:06 +01:00
Chris Rees
e3c127d846 FreeBSD compat
Signed-off-by: Chris Rees <utisoft@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-24 17:04:59 +01:00
Denys Vlasenko
e9a40e3b91 libbb: make ndelay_no/off a bit more clever. +14 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-24 00:29:55 +01:00
Denys Vlasenko
094cc51e50 insmod: check for module read errors
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-17 14:58:27 +01:00
Tito Ragusa
ad3d72f082 move passwd, shadow, group and gshadow path definitions to libbb.h
...and define them only if the used libc doesn't.

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-16 23:39:45 +01:00
Lauri Kasanen
6578f2cf5b pstree: new applet. +1664 bytes
text    data     bss     dec     hex filename
 883379     936   17192  901507   dc183 busybox_old
 885043     936   17192  903171   dc803 busybox_unstripped

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-05 05:22:29 +01:00
Denys Vlasenko
e4dcba1c10 *: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 18:57:19 +02:00
Denys Vlasenko
9ce642f974 libbb: introduce and use common crc32 routine
function                                             old     new   delta
crc32_block_endian1                                    -      37     +37
crc32_block_endian0                                    -      34     +34
global_crc32_table                                     -       8      +8
file_read                                             82      87      +5
gzip_main                                            211     214      +3
xz_crc32                                              40      35      -5
crc32_table                                            8       -      -8
calculate_gunzip_crc                                  54      34     -20
lzo_crc32                                             54      25     -29
cksum_main                                           298     211     -87
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/4 up/down: 87/-149)           Total: -62 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-10-27 15:26:45 +02:00
Kevin Cernekee
ccb070450e fdisk: initial stab at GPT partition support
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-25 02:00:24 +02:00
Denys Vlasenko
1c26e05f30 remove unused SC_x (serial port names) defines
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-24 02:35:17 +02:00
Denys Vlasenko
5360059131 libbb: introduce and use strcpy_and_process_escape_sequences
function                                             old     new   delta
strcpy_and_process_escape_sequences                    -      50     +50
bb_process_escape_sequence                           148     138     -10
printf_main                                          789     776     -13
getty_main                                          1897    1831     -66
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 50/-89)            Total: -39 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-23 21:06:06 +02:00