Commit Graph

2044 Commits

Author SHA1 Message Date
Ron Yorston 20cd31a2d7 lineedit: don't block when looking for escape sequence in vi-mode
In vi-mode lineedit tries to detect some escape sequences.
After the ESC it reads the next character to check for certain
values.  This read should have a timeout or a user-entered ESC to
switch to command mode doesn't properly handle the next character.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-15 13:30:58 +01:00
Stephen Heumann d0dd867542 Fix problem where trying to run a program on a nonexistent volume gave an unescapable 'insert disk' dialog.
This also gives more sensible error messages when trying to execute nonexistent files.
2014-12-14 22:37:12 -06:00
Stephen Heumann 26efb6c33e Add support for moving forward/backward one word with OA-left/right on GNO and Ctrl/Alt/Command-left/right on VT100-style terminals.
The support for OA-left/right on GNO uses the OA2META ioctl option to map OA-x to ESC x.

VT100-type terminal emulators have significant variations in what modifier combinations they'll pass through and what escape sequences they produce. Hopefully at least one of them works on just about everything.
2014-12-14 18:49:10 -06:00
Stephen Heumann 8bc7d9fb31 Fix lineedit to process down arrow key properly.
This was broken by the change to using CRMOD mode, which actually does mapping on input as well as output. The fix is to set the terminal to "vt100 arrow" mode, which is an undocumented option that translates arrows to vt100-style escape sequences (also used by gsh).

(Note that the earlier patch actually makes us use CRMOD mode most of the time, not non-CRMOD mode as the summary erroneously says.)
2014-12-14 17:25:04 -06:00
Stephen Heumann 3887b30719 Fix bb_put_cr on non-GNO (it wasn't flushing stdout before printing the CR, leading to the prior character not appearing). 2014-12-14 14:21:25 -06:00
Stephen Heumann 55302cd56c Change lineedit so the terminal isn't kept in CRMOD mode most of the time.
This is important because CRMOD mode prevents text from backgrounded programs from being printed properly. It also leaves the terminal in an inappropriate state if hush crashes or is killed.

For the time being, we still switch briefly to CRMOD mode when we want to print just a CR.
2014-12-14 12:40:46 -06:00
Stephen Heumann 4f7d95d896 Fix problems with editing of commands that extend to multiple lines. 2014-12-13 22:21:38 -06:00
Denys Vlasenko d598a8d4e6 lineedit: don't fall back to simple line input if tty is in raw mode
Testcase: shell command input after python ^Z should still work

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-10 17:22:13 +01:00
Stephen Heumann ac0aab62bf Eliminate memory leaks in the exec* routines for GNO.
This is done by adding new memory allocation routines that use the current process's userID, so the memory will be deallocated when it quits or execs, even if it's a forked child process.
2014-12-09 18:11:20 -06:00
Stephen Heumann b4a362ef71 Make test report EXEC files (shell scripts) as executable. 2014-12-04 13:41:21 -06:00
Stephen Heumann dc2193b997 Translate colons to slashes in the current path name, for compatibility with Unix-style usage.
As an exception, the translation isn't done if there is a directory name containing a /.
2014-12-03 23:02:15 -06:00
Stephen Heumann fb9b298ca4 Implement "close-on-exec" functionality for GNO.
We do this by maintaining a mask (for each pid) giving the fds to be closed on exec. We wrap functions that close fds so that their close-on-exec bits can be cleared at that point.

This implementation may close the fds even if the execve operation ultimately fails.
2014-12-03 21:04:46 -06:00
Stephen Heumann 8cdae3cd7a Add our own version of qsort, because the one from ORCA/C is recursive and can use thousands of KB of stack space.
The new version is a heap sort implementation adapted from musl libc.
2014-12-03 10:49:24 -06:00
Stephen Heumann 52c59f6da1 Properly reset getopt in each invocation of getopt32() on BSD-type systems, including GNO and OS X.
Also, fix issue where callers of getopt32() weren't properly detecting errors on GNO due to a size mismatch.

This avoids strange behavior when commands using getopt32 (like export) are invoked multiple times, sometimes with invalid arguments.
2014-12-02 15:31:50 -06:00
Stephen Heumann 3805dfc06e Replace stack-allocated array with dynamically-allocated data in getopt32(). 2014-12-02 11:31:20 -06:00
Stephen Heumann 468751ba5f Switch the vfork implementation to use procrecvtim() for waiting, and not signal the parent from the child.
This avoids a problem where one of the SIGALRM signals could be delivered after the original SIGALRM handler was restored, which would normally cause the process to terminate.

For now, we just rely on polling in a loop to determine when the child is done. This isn't optimal, but should be OK. If procsend() worked, we could use that in the child to signal the parent. However, procsend() is broken in GNO 2.0.6 -- it seems that it actually tries to invoke the send() call for sockets, but with the wrong arguments, leading to a crash.
2014-12-01 21:05:13 -06:00
Bartosz Golaszewski 8d75d794ea libbb: use sendfile() to copy data between file descriptors
Busybox already uses sendfile in httpd. This patch proposes to use it
globally to copy data between file descriptors.

It speeds up the copying on slow systems a lot - below are the times needed
to copy a 450Mb file with and without this option enabled on a BeagleBone
Black:

sendfile:
user    0m0.000s
sys     0m8.170s

read/write 4k:
user    0m0.470s
sys     0m16.300s

function                                             old     new   delta
bb_full_fd_action                                    394     474     +80

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-27 23:31:58 +01:00
Denys Vlasenko 04c1417602 libbb: use ARG_MAX for bb_arg_max() only if it's 60k+
Sometimes ARG_MAX is small (like 32k) yet sysconf(_SC_ARG_MAX)
is big, and people prefer using the bigger value.

OTOH, with sufficiently large ARG_MAX, further wins from
sysconf(_SC_ARG_MAX) being bigger are exponentially smaller:
you can see 4 times fewer fork+execs when you run find, but
when each execed process already takes a thousand parameters
it's likely execution time is dominated by what that process
does with each parameter.

Thus, with this change ARG_MAX is used if it's sufficiently big,
otherwise sysconf(_SC_ARG_MAX) is used.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-26 15:17:59 +01:00
Denys Vlasenko 2835a224cd bbunit: fix WANT_TIMING compilation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-26 14:04:51 +01:00
Stephen Heumann 334678c6e9 Change various uses of signal masks to use 32-bit values (previously half the signals were essentially cut off). 2014-11-25 17:43:14 -06:00
Stephen Heumann 7ceb59ae57 Minor cleanup in execve. 2014-11-22 22:57:59 -06:00
Stephen Heumann 036cea4dbe Add support to our execve for running scripts, which may have a #! line giving the interpreter to use.
We have to do this ourselves, since the GNO kernel's _execve doesn't do it for us.
2014-11-22 21:27:11 -06:00
Stephen Heumann 3e7c0d0ace Add our own version of execve for GNO, which can quote arguments and can remove variables from the environment if needed.
Our versions of the execv* functions have been moved to their own file. They are now used for all the exec* calls in hush.
2014-11-22 16:53:59 -06:00
Stephen Heumann 5c972aa397 Fix our handling of process groups for job control, working around a couple GNO bugs.
*Most significantly, we avoid using setpgid(), because it doesn't work and in fact corrupts the kernel's process group table.
*Also, work around tctpgrp() returning garbage instead of 0 on success.

This adds an implementation of tcsetpgrp that works by reading the process tables to find a process in the appropriate group. This isn't used for the main job control operations, though, since it might be relatively slow.

At this point, basic job control seems to work.
2014-11-21 23:05:38 -06:00
Stephen Heumann 95bcfc3b6e Remove libbb/copyfd.c and an unused function that was its only caller. 2014-11-20 20:00:21 -06:00
Stephen Heumann 2e0e5358c3 Change some stack-allocated arrays in libbb/lineedit.c to be dynamically allocated. 2014-11-20 18:34:52 -06:00
Stephen Heumann 4d60cd1043 Fixes for environment variable handling on GNO:
* Push/pop environment to make sure it is isolated from our parents and children.
* Make all environment vars (and shell vars) case-insensitive, consistent with GNO's internal handling of environment vars.
* Wrap putenv and unsetenv to make sure they are called with lower-case variable names, which is necessary to maintain consistency between the environ array and the kernel's internal representation of variables.
2014-11-20 13:21:23 -06:00
Stephen Heumann 97eb1defae Fix input handling so $ and # can be typed. This also fixes handling of ^C and ^D during line editing.
The issue with $ and # resulted from incompatible definitions of the CTRL macro between our code and the system headers.
2014-11-19 20:44:25 -06:00
Stephen Heumann 078f526df7 Fixes for terminal behavior on the GNO console 2014-11-19 12:52:05 -06:00
Denys Vlasenko 628f134fe7 exit with 127 if appled name wasn't found - it's more POSIXy
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-17 17:03:47 +01:00
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 b3a419646b Changes to handle the use of \r as newline on the IIgs. 2014-11-08 19:58:11 -06:00
Stephen Heumann 8f7e30fc8b Use prefix 9 instead of 1 to get the executable path, to avoid a length limitation. 2014-11-08 12:26:36 -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 f52d5394bf Change code using 0/1/2 for stdin/stdout/stderr file descriptors to use macros instead, to properly deal with their different numbers on GNO. 2014-11-06 18:14:15 -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 d583686459 Disable functionality for printing the time in the shell's prompt. This required strftime(), which is missing in GNO 2.0.6.
It would have been possible to add a version of strftime(), but it didn't seem worth it for this little bit of functionality. It should also be possible to get similar functionality by invoking an external program like "date" in PS1.
2014-11-05 18:00:35 -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 af402a28a4 Restructure macros in libbb/xatonum.c and its template file to work with the ORCA/C preprocessor.
Also, get rid of a use of long long.
2014-11-03 20:17:51 -06:00
Stephen Heumann 32e9dccc33 Fix the implementation of vasprintf to work with ORCA/C's varargs implementation. Also, shrink the stack-allocated buffer in it.
This code could theoretically break if the ORCA/C varargs implementation changed, but it should be OK in practice.

Also removed some unused code in libbb/xfuncs.printf.c that includes potentially problematic varargs use (defining varargs functions but not necessarily calling va_start/va_end in them).
2014-11-03 16:08:43 -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 4e47bee9d2 Change libbb/signal.names.c to use C89-style constructs for ORCA/C compatibility. 2014-11-02 23:15:17 -06:00
Stephen Heumann 9b98d32e66 Fix ORCA/C compatibility problems in libbb/lineedit.c. 2014-11-02 22:40:28 -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 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 16c89af688 Change vfork calls to use vfork_and_run operation with GNO-compatible semantics 2014-10-27 13:10:11 -05:00
Stephen Heumann a00ca4770f Eliminate or disable all the warnings given by clang -Wall 2014-10-26 23:30:51 -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 cd7a38a87d false: make "false --help" exit with 1
function                                             old     new   delta
run_applet_no_and_exit                               447     445      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-18 00:47:05 +02:00
Denys Vlasenko 45b4ecc868 init: if libc-based Unicode support is on, run setlocale(LC_ALL, "") at startup
It is not clear why we were excluding init from this.
The "getpid() != 1" clause was there from the beginning (2001)
but not explained.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-11 20:33:18 +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
Denys Vlasenko 09a0e2223f sha3: tweak comments and indentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-30 16:26:09 +02:00
Denys Vlasenko 4ff933c0e7 sha3: code shrink (and speedup for SHA3_SMALL=0)
function                                             old     new   delta
sha3_process_block72                                1454    1359     -95

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-30 14:18:57 +02:00
Denys Vlasenko 2a563ea49a sha3: add 32-bit optimized bit-sliced implementation
It is an interesting trick, but so far I only managed to make it work
correctly, not to make it faster and/or smaller.
The code is ifdefed out for now.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-25 17:24:13 +02:00
Denys Vlasenko d32fc647d7 libbb: fix bb_ask() to flush input before prompt, not after. Closes 7190
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-01 13:20:22 +02:00
Denys Vlasenko 5aeae36e2b libbb: fix compile failure if both ARG_MAX and _SC_ARG_MAX are defined
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-25 15:39:27 +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 15a357e596 libbb: fix empty PATH components handling
function                                             old     new   delta
find_execable                                         81      86      +5
exists_execable                                       71      66      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 17:08:29 +02:00
Denys Vlasenko d8290c2ef0 libbb: fix thinko in rtc_xopen()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 09:07:16 +02:00
Denys Vlasenko 528808fa7b libbb: make rtc_xopen try harder on EBUSY
function                                             old     new   delta
rtc_xopen                                             77     139     +62

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 09:05:03 +02:00
Denys Vlasenko fe33683c8b Fix compile failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 07:18:55 +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 eb9f485b07 libbb/obscure.c: code shrink. Suggested by Tito.
function                                             old     new   delta
string_checker                                        97      92      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-16 19:51:34 +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 c50493854a libbb: fix a bad check for uclibc >= 0.9.31
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-16 20:53:40 +01:00
Denys Vlasenko 438b4ac286 script: make it work even if fd 0 is closed
Testcase:
script -q -c "echo hey" /dev/null 0>&-

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-16 12:34:53 +01: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 83bc4332e7 du, copy_file: fix file matching on cramfs. Closes 5456
function                                             old     new   delta
is_in_ino_dev_hashtable                               88     108     +20
add_to_ino_dev_hashtable                             150     142      -8
reset_ino_dev_hashtable                               84      75      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 20/-17)              Total: 3 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-25 15:27:58 +01:00
Denys Vlasenko 12916b9220 libbb: trivial code shrink
function                                             old     new   delta
reset_ino_dev_hashtable                               84      74     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-25 15:09:01 +01:00
Denys Vlasenko 8ed9672660 libbb: don't die if crypt() returns NULL
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-09 14:38:03 +01:00
Mike Frysinger f1999b5a9d appletlib: fix set-but-unused warning
When you build with FEATURE_INSTALLER disabled, you get a build
warning like so:

libbb/appletlib.c: In function 'busybox_main':
libbb/appletlib.c:691:7: warning: variable 'use_symbolic_links' set but
                                  not used [-Wunused-but-set-variable]
   int use_symbolic_links;
       ^

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-01-31 00:29:47 -05:00
Denys Vlasenko fa6ab56353 libbb: if opening /dev/loopN returns ENXIO, don't try N++.
function                                             old     new   delta
set_loop                                             639     635      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-21 13:44:21 +01:00
Denys Vlasenko 3b394781b5 libbb: fix parsing of "10101010" date/time form
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-21 07:58:18 +01:00
Denys Vlasenko 79df481dc4 lineedit: fix trivial build failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-10 14:38:26 +01:00
Denys Vlasenko 96f92a1afa libbb: FreeBSD fix for B<num> baud rate constants not fitting into a short.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-08 15:25:20 +01:00
Denys Vlasenko 198b02f7dd fix failures found by randomconfig builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-12-31 23:22:36 +01:00
Michael Tokarev 9f4f60183b 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>
2013-12-16 03:41:30 +01:00
Denys Vlasenko 9b2a9f0210 fix assorted unused code and wrong format specs found by cppchekc (bug 6716)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-29 16:43:33 +01:00
Denys Vlasenko 1a7256ac38 chpst: fix a bug where -U USER was using wrong USER (one from -u USER)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-29 16:39:28 +01:00
Denys Vlasenko 259b3c047a 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>
2013-11-28 03:14:16 +01:00
Denys Vlasenko cffe28ef87 libbb: add sketch of tentative 'better' passwd/group API
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-26 13:46:18 +01:00