Commit Graph

2081 Commits

Author SHA1 Message Date
Stephen Heumann 2fd57a3bdc Add basic support for getting input escape sequences from termcap. 2014-11-12 23:25:01 -06:00
Stephen Heumann 5f6121c091 Add initial support for getting terminal information from termcap, instead of hard-coding vt100-style codes.
This currently only supports output, and still doesn't quite display correctly in some cases.
2014-11-11 20:58:06 -06:00
Stephen Heumann c37475dcbc Change vfork_and_run implementation to inspect the kernel's process tables to determine whether the child has really exec'd or exited.
This should avoid strange behavior due to races when the parent has resumed but the child is still running the exec* code in libc, which mainly manifests itself when running at low speed.

We also change to signaling the child's completion with SIGALRM, and setting an extra alarm in the parent in case the child doesn't actually do it.
2014-11-10 16:08:24 -06:00
Stephen Heumann 6d5e65b9df Fix corruption and hanging resulting from using _exit in forked processes by calling QuitGS directly instead.
GNO's _exit (contrary to its man page) does clean-up for stuff like the memory allocator, which is inappropriate in a forked child process and leads to hangs and crashes.
2014-11-09 18:49:58 -06:00
Stephen Heumann b3a419646b Changes to handle the use of \r as newline on the IIgs. 2014-11-08 19:58:11 -06:00
Stephen Heumann bff0844d44 Add code to get the path of the current executable, which we need to re-execute the shell.
On the GS, this uses GS/OS calls. Versions for OS X and Linux are also included.
2014-11-07 23:06:34 -06:00
Stephen Heumann 6bd3b140ea Misc. fixes related to file handling:
*Use .null instead of /dev/null
*Account for GNO's dup2(), which non-standardly returns 0 on success
*Always call open with appropriate number of arguments
*Use STDIN_FILENO instead of (implicitly) 0
2014-11-07 19:23:04 -06:00
Stephen Heumann cae994bc22 Add an emulation of waitpid that should be better than the one in libc.
In particular, it will buffer information about children other than the one being waited for, so it isn't lost. It can also emulate a non-blocking wait by arranging to interrupt the wait with a signal.
2014-11-07 12:12:18 -06:00
Stephen Heumann 9bc48e5ebf Add synchronization to prevent the parent from running concurrently with the child until the child execs or terminates.
Our approach is to have the parent wait for SIGUSR2, and send that from the child just before it calls exec* or _exit.
2014-11-06 23:29:42 -06:00
Stephen Heumann 71b8b67d7d Make the "smallint" type "int" instead of "signed char." This works around an apparent compiler bug where a conditional isn't evaluated correctly. 2014-11-06 13:36:41 -06:00
Stephen Heumann 3b1d003ea7 Handle globals more simply, declaring the "G" structure containing them directly in shell/hush.c.
This allows the "G" struct to show up in the debugger, so it can easily be inspected.
2014-11-06 13:08:38 -06:00
Stephen Heumann 9320c1e704 Set things up so hush can be build with debug code turned on.
This involved breaking things up into more segments in debug mode, since the code is larger. I also had to remove some unused extern definitions, which were causing link errors when debug code was enabled.

To enable debug code, pass "DEBUG=1" to make or build.gs.
2014-11-06 11:42:17 -06:00
Stephen Heumann c7f9c18893 Use GNO job control calls in place of unavailable POSIX ones. 2014-11-05 15:28:59 -06:00
Stephen Heumann a3c32aaa73 Revise terminal control code to use ioctls supported by GNO instead of termios calls that aren't supported. 2014-11-04 19:53:40 -06:00
Stephen Heumann 7e5a584f0c Use alternative code (also from BusyBox) for checking if the user is in a group, avoiding a call to getgroups(), which isn't supported.
This could actually be further simplified, since GNO doesn't really have group-based file permissions, but I'll leave that until later.
2014-11-04 16:24:41 -06:00
Stephen Heumann cbdfea4c97 Revise signal handling to work with GNO.
This involved using signal() rather than sigaction(), which GNO doesn't have. signal() doesn't have the signal-blocking feature of sigaction(), but I've tried to emulate it.
2014-11-04 10:45:28 -06:00
Michel Stam d3fabf89d7 zcip: Add environment variable for overriding log functionality
function                                             old     new   delta
bb_logenv_override                                     -      70     +70
packed_usage                                       29969   30033     +64
zcip_main                                           1426    1431      +5
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Michel Stam <m.stam@fugro.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-04 12:19:04 +01:00
Stephen Heumann 036b92595c Address some link errors with various small changes.
The most significant change is to at use malloc instead of alloca in the code to evaluate shell arithmetic expressions in shell/math.c.
2014-11-03 23:29:34 -06:00
Stephen Heumann bdafda3f97 Fixes to get libbb/getopt32.c to compile.
This disables long argument support, since that requires getopt_long(), which isn't included in GNO. There is a separate library available for it, but it's simpler to avoid depending on that.
2014-11-03 12:58:57 -06:00
Stephen Heumann 488a238ad7 Add an implementation of poll() written in terms of select(), to work around the lack of poll() on GNO.
This is a BSD-licensed poll() implementation by Brian M. Clapper. Its performance characteristics aren't as good as a "native" poll() would be, but this shouldn't be a problem in practice.
2014-11-03 12:26:43 -06:00
Stephen Heumann 051b79efc1 Move all the source files to 15-character ProDOS-compatible file names.
Dmake gets confused if you use over-15-character file names, so they needed to be shortened to get it to work. While I was at it, I also switched _ to . in the filenames so they're fully ProDOS compatible.

The shell/hush_test directory (not needed to build the code) still uses ProDOS-incompatible file names.
2014-11-02 22:11:07 -06:00
Stephen Heumann d4b2c3ce8b Various changes for GNO and ORCA/C compatibility. 2014-11-02 18:30:31 -06:00
Stephen Heumann a3d8a81bb0 Add makefile (which can be used on GNO or a modern system), and build scripts based on in. 2014-11-01 22:59:10 -05:00
Stephen Heumann 875b1bbd0e More GNO and ORCA/C compatibility fixes.
Everything in the shell directory now compiles.
2014-11-01 18:25:21 -05:00
Stephen Heumann 3577d48e74 Change the ARRAY_SIZE macro to work around an ORCA/C limitation. 2014-11-01 15:47:17 -05:00
Stephen Heumann f6c7fdc027 GNO/ORCA compatiblity: remove final comma in enums, and appropriately define stuff that GNO doesn't have in platform.h. 2014-11-01 14:22:47 -05:00
Stephen Heumann 8f6869ae25 Miscellaneous changes for ORCA/C and GNO compatibility, mainly removing C99isms.
At this point, ORCA/C can process the main header files, and some smaller source files compile without errors.
2014-11-01 09:46:02 -05:00
Stephen Heumann b7676499be More removal of stuff that used long longs 2014-10-27 19:45:38 -05:00
Stephen Heumann 6c2c9d8865 Get rid of long longs in the the hush code (but not yet in the libraries) 2014-10-27 14:09:00 -05:00
Stephen Heumann 16c89af688 Change vfork calls to use vfork_and_run operation with GNO-compatible semantics 2014-10-27 13:10:11 -05:00
Stephen Heumann 472db3bd56 Delete the stuff that's irrelevant to hush. Also, include (a simplified version of) the autoconf-generated headers and a simple build script, so it can easily be build in the hush-only configuration. 2014-10-26 22:39:01 -05:00
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
Denys Vlasenko 962c4e8220 taskset: support CPU masks for more than 64 CPUs
function                                             old     new   delta
taskset_main                                         522     631    +109

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-17 19:36:22 +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 01a1a967c9 crond: tweak help text, make course less cryptic
function                                             old     new   delta
packed_usage                                       29736   29740      +4
crond_main                                          1485    1486      +1
load_crontab                                         712     706      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-30 14:47:28 +02:00
Denys Vlasenko 5fd3ddfb24 modprobe-small: fix help messages for aliased module-related applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-19 15:04:39 +02:00
Bernhard Reutner-Fischer ad16741ccd libbb: provide usleep() fallback implementation
POSIX.1-2008 removed the usleep function, provide a fallback
implementaion using the recommended nanosleep().

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-13 16:37:57 +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 8e0ad2647a Another FreeBSD fix from Matthias Andree
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-08 15:10:54 +01:00
Denys Vlasenko 432fbd7a1a platform.h: undef HAVE_STRCHRNUL only on correct versions of FreeBSD
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-07 14:09:47 +01:00
Daniel Borca d9fc4d8f92 platform: strchrnul is missing if __APPLE__
Signed-off-by: Daniel Borca <dborca@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-27 00:27:46 +01:00
Denys Vlasenko 2635369a92 rfkill: use new-style config/kbuild/applet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-20 14:21:29 +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
Denys Vlasenko ac21687309 archival/*: move "applet:" snippets into .c files, part 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-14 11:38:18 +01:00
Denys Vlasenko 36184a487d archival/*: move "applet:" snippets into .c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-14 09:54:24 +01:00
Denys Vlasenko 73225b6d6e switch editors/* to embedded-in-source kbuild system
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-13 12:45:33 +01:00
Sven-Göran Bergh f200f732f4 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>
2013-11-12 14:18:25 +01:00
Denys Vlasenko cd0936be36 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>
2013-11-12 12:09:14 +01:00
Malek Degachi 1d39e33d46 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>
2013-11-09 22:14:33 +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 cd256e1c40 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>
2013-10-06 15:14:25 +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
Bernhard Reutner-Fischer 9078633fee buildsys: Add helper to list suid applets
Add a helper script that lists all applets that
- do or may require SUID provileges (busybox.cfg.suid)
- do not require SUID provileges (busybox.cfg.nosuid)

Some setups prefer to build two busybox binaries, one that is suid which
contains all applets that do or may require suid privileges, and a
second one for all the rest (which drops suid). To ease splitting these
two binaries, generate a list of CONFIG_ items for the suid binary.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-07-26 13:39:46 +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
Denys Vlasenko 1f5e81f8f8 md5/sha512: a better fix for strict aliasing warnings
The locations *are* well-aligned for direct stores
on any architecture.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-27 01:03:19 +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 80a38ca11c man: install to /usr/bin, not /sbin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-27 14:30:18 +01:00
Mike Frysinger 445e7543e8 platform: use KERNEL_VERSION to simplify uClibc version checking
This makes reading the logic (as well as adding new code) a lot simpler,
and fixes one or two cases that were broken due to incorrect sub-version
tests.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-03-12 11:13:22 -04:00
Denys Vlasenko e3e321682c Fix move_to_unaligned16
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-27 15:49:38 +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 2aec773688 rpm: use "create+rename" method of replacing existing files
Users were reporting getting errors like
"ls: error while loading shared libraries: libc.so.6: ELF load command past end of file"
while rpm was unpacking glibc tarball.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-20 15:58:42 +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
Denys Vlasenko 2ffd710656 platform.h: disable ALIGNn macros for s390[x]
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-06 17:17:15 +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
Michael Tokarev 32f774cd34 *: declare strings with ALIGN1, as appropriate
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 15:56:37 +02:00
Denys Vlasenko 440a509849 dpkg: fix creation of .list files (were empty since b768aeb). Closes 5324
While at it, fix filename order and free the list of names.

function                                             old     new   delta
llist_rev                                              -      21     +21
get_header_tar                                      1733    1741      +8
unpack_package                                       587     585      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 29/-2)              Total: 27 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-22 16:27:21 +02:00
Denys Vlasenko c9a13116a4 mount: fix the wrongly stored fs creation time
This bug made our ext2 images non-mountable by ext4 driver.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-21 16:50:46 +02:00
Denys Vlasenko 2bc495e4c4 adduser: install to /usr, not /, like all other similar tools
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-20 20:35:58 +02:00
Denys Vlasenko dac8e79a19 Move several applets to different install dir:
Moved to [/usr]/sbin:
addgroup, adduser, delgroup, deluser,
arping, chat, ether-wake, fdformat, ifplugd,
ip, ipaddr, iplink, iproute, iprule, iptunnel,
killall5, readahead, rtcwake, tftpd, add-shell, remove-shell, powertop.

Moved to /bin for /usr/bin: kbd_mode.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-20 20:24:57 +02:00
Denys Vlasenko ac164dd2a7 volume_id/ext: use common bb_e2fs_defs.h for ext2/3/4 constants and structs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-12 15:00:35 +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
Tias Guns 3645195377 platform.h: Android tweaks: ioprio defines, BB_ADDITIONAL_PATH
Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:26:32 +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 176bc34475 Drop include/bb_linux_ext2_fs.h, use existing e2fsprogs/e2fs_defs.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-17 15:06:55 +02:00
Denys Vlasenko 0b2b0f31a3 Create and use our own copy of linux/ext2_fs.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-13 16:39:18 +02:00
Denys Vlasenko faac1d3e6e tar,rpm2cpio: check that child decompressor did not error out
function                                             old     new   delta
check_errors_in_children                               -      57     +57
tar_main                                             833     848     +15
get_header_tar                                      1720    1733     +13
rpm2cpio_main                                        147     140      -7
handle_SIGCHLD                                        41       -     -41
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/1 up/down: 85/-48)             Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-06 16:33:42 +01: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