Commit Graph

1919 Commits

Author SHA1 Message Date
Mark Edgar
b2ab920716 unexpand: correct behavior for --first-only --tabs=4
Prior to the patch, both -f and --first-only are in all cases either
no-op or ignored.
Without --tabs, --first-only is the default so specifying it is a no-op.
With --tabs, --all is implied, and --first-only is intended to reset this.

function                                             old     new   delta
expand_main                                          690     694      +4

Signed-off-by: Mark Edgar <medgar123@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 15:40:49 +02:00
Alistair Francis
d3539be8f2 Remove stime() function calls
stime() has been deprecated in glibc 2.31 and replaced with
clock_settime(). Let's replace the stime() function calls with
clock_settime() in preperation.

function                                             old     new   delta
rdate_main                                           197     224     +27
clock_settime                                          -      27     +27
date_main                                            926     941     +15
stime                                                 37       -     -37
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/0 up/down: 69/-37)             Total: 32 bytes

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-19 13:08:25 +01:00
Liu, Shuang (ADITG/ESM)
af6bc54fde chgrp: correct the usage for non-desktop chgrp calls
When IF_DESKTOP is not defined, chown and chgrp only takes option -R -h,
However the usage output of chgrp is wrong:

	$ ./busybox.nosuid chown
	Usage: chown [-Rh]... USER[:[GRP]] FILE...

	$ ./busybox.nosuid chgrp
	Usage: chgrp [-RhLHP]... GROUP FILE...

	$ ./busybox.nosuid chgrp -H group dummy
	chgrp: invalid option -- 'H'
	Usage: chgrp [-RhLHP]... GROUP FILE...

The chgrp is now a wrapper of chown, so the recognized options shall be the same.
This is introduced by 34425389e0

I would expect the correct behavior shall be the same as chown.
So suggest the below patch, the behavior shall be:

	$ ./busybox.nosuid chgrp
	Usage: chgrp [-Rh]... GROUP FILE...

Signed-off-by: Shuang Liu <sliu@de.adit-jv.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-17 17:06:31 +01:00
Denys Vlasenko
af7169b4a7 clang/llvm 9 fix - do not eliminate a store to a fake "const"
This is *much* better (9 kbytes better) than dropping "*const"
optimization trick.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 12:12:22 +02:00
Denys Vlasenko
be5a505d77 Remove syscall wrappers around clock_gettime, closes 12091
12091 "Direct use of __NR_clock_gettime is not time64-safe".

function                                             old     new   delta
runsv_main                                          1698    1712     +14
startservice                                         378     383      +5
get_mono                                              31      25      -6
date_main                                            932     926      -6
gettimeofday_ns                                       17       -     -17
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/2 up/down: 19/-29)            Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-24 16:26:55 +02:00
Alistair Francis
b7b7452f29 date: Use 64 prefix syscall if we have to
Some 32-bit architectures no longer have the 32-bit time_t syscalls.
Instead they have suffixed syscalls that returns a 64-bit time_t. If
the architecture doesn't have the non-suffixed syscall and is using a
64-bit time_t let's use the suffixed syscall instead.

This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
headers.

If an architecture only supports the suffixed syscalls, but is still
using a 32-bit time_t fall back to the libc call.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-08 16:31:54 +02:00
Kaarle Ritvanen
71b268c7d9 ln: --no-target-directory implies --no-dereference
as in GNU coreutils

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-08 14:07:50 +02:00
Denys Vlasenko
427c12cc51 tee: do not intercept SIGPIPE
GNU tee does this only with -p, which we don't have yet.

function                                             old     new   delta
tee_main                                             306     295     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-07 14:25:45 +02:00
Denys Vlasenko
b81f805658 stat: print nanosecond times, fix printing of empty lines
function                                             old     new   delta
human_time                                            36      73     +37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-08-03 18:08:27 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
48eebc8d5c expand: add commented-out code to handle NULs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-09 09:16:03 +02:00
Denys Vlasenko
92549250f3 expand,unexpand: drop broken test, add FIXME comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-08 13:04:44 +02:00
Denys Vlasenko
9501bc7da5 ls: fix SEGV when --color is used and ENABLE_LS_COLOR=n
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26 13:53:41 +02:00
Denys Vlasenko
875ce094cf dd: fix handling of short result of full_write(), closes 11711
$ dd bs=1G <sda1 of=/dev/sda1
dd: error writing '/dev/sda1': No space left on device
1+0 records in
0+0 records out
999292928 bytes (953.0MB) copied, 0.784617 seconds, 1.2GB/s

function                                             old     new   delta
write_and_stats                                       99     102      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-14 17:49:14 +02:00
John L. Hammond
94f607a904 ln: correct 'ln -T' usage message
Signed-off-by: John L. Hammond <jhammond@indeed.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-09 16:29:29 +02:00
Ron Yorston
e2026381be stat: reduce storage for human-readable filesystem names
function                                             old     new   delta
static.humanname                                       -     236    +236
static.fstype                                          -     140    +140
print_statfs                                         339     341      +2
static.humantypes                                    288       -    -288
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/0 up/down: 378/-288)           Total: 90 bytes
   text	   data	    bss	    dec	    hex	filename
 982183	    485	   7296	 989964	  f1b0c	busybox_old
 982152	    485	   7296	 989933	  f1aed	busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-12 12:00:38 +02:00
Denys Vlasenko
2f28b2bdbb fsync,sync: merge into one source module
With FEATURE_SYNC_FANCY not set:

function                                             old     new   delta
fsync_main                                           130     123      -7

With FEATURE_SYNC_FANCY set, should be much larger code size savings.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-02 14:55:29 +02:00
Denys Vlasenko
4f74bb6059 fsync,sync: make them similar
sync: add O_NOCTTY
fsync: drop O_NOATIME, add O_NONBLOCK, set exitcode to 1 if fsync() fails,
    update --help message to be similar to sync.
both: reformat code to minimize "diff -u sync.c fsync.c":
    in particular, they use same open() flags now

function                                             old     new   delta
fsync_main                                           126     130      +4
packed_usage                                       33316   33317      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 5/0)                 Total: 5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-02 14:39:56 +02:00
Denys Vlasenko
4a6748662a top: tweak --help
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-27 16:45:39 +01:00
Ron Yorston
e563f9e851 du: don't count duplicate arguments. Closes 5288
Since coreutils 8.6 (2010-10-15) du no longer counts duplicate arguments.

Revert the relevant part of commit 618a3027ed (du: fix "du /dir /dir"
case).

function                                             old     new   delta
du_main                                              302     297      -5
reset_ino_dev_hashtable                               78       -     -78
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-83)             Total: -83 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-19 17:08:39 +01:00
Rostislav Skudnov
d712edc6d8 dd: add 'oflag=append'
Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-14 13:01:46 +01:00
Denys Vlasenko
ecf02e8b83 date: improve help text for -D
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-09 12:58:52 +01:00
Denys Vlasenko
edca770d11 sleep: support "inf"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-07 15:20:56 +01:00
Martijn Dekker
f83292cfc4 ls: make -i compatible with coreutils: don't follow symlink by default
Signed-off-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-04 18:55:53 +01:00
Denys Vlasenko
b86b39bfda config: more tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 17:52:43 +01:00
Denys Vlasenko
b097a84d62 config: update size information
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 03:20:17 +01:00
Denys Vlasenko
c100535571 cat,nl: fix handling of open errors
$ cat -n does_not_exist; echo $?
cat: does_not_exist: No such file or directory
1

function                                             old     new   delta
print_numbered_lines                                 118     129     +11
nl_main                                              196     201      +5
cat_main                                             421     425      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 20/0)               Total: 20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-29 11:44:10 +01:00
Denys Vlasenko
93ef5dd640 printf: fix printf "%u\n" +18446744073709551614
function                                             old     new   delta
conv_strtoll                                          19      32     +13
conv_strtoull                                         49      61     +12
bb_strtoll                                            89      84      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 25/-5)              Total: 20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30 23:24:18 +01:00
Denys Vlasenko
9ab5a8d560 dd: do not have 'ocount' variable if ibs/obs support is not enabled
function                                             old     new   delta
packed_usage                                       32964   32961      -3
dd_main                                             1033    1021     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-15)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30 17:04:52 +01:00
Rostislav Skudnov
3f6a978a0d dd: add 'oflag=seek_bytes'
Allow specifying position in the output file in bytes instead of
obs-sized blocks, improve compatibility with GNU dd.

function                                             old     new   delta
dd_main                                             1632    1693     +61
packed_usage                                       33130   33150     +20
static.oflag_words                                     -      12     +12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 93/0)               Total: 93 bytes

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30 16:55:09 +01:00
Bernhard Reutner-Fischer
3db4e7f84c printf: fix printing +-prefixed numbers
Thanks to Cristian Ionescu-Idbohrn for noticing.

Also fix "%d" '  42' to skip leading whitespace.

function                                             old     new   delta
print_direc                                          435     454     +19
bb_strtoll                                            99     103      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 23/0)               Total: 23 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2018-10-19 15:27:42 +02:00
Denys Vlasenko
349d72c19c unzip: use printable_string() for printing filenames
function                                             old     new   delta
unzip_main                                          2726    2792     +66
printable_string2                                      -      57     +57
identify                                            4329    4336      +7
expmeta                                              659     663      +4
add_interface                                         99     103      +4
beep_main                                            286     289      +3
changepath                                           192     194      +2
builtin_type                                         115     117      +2
devmem_main                                          469     470      +1
input_tab                                           1076    1074      -2
create_J                                            1821    1819      -2
poplocalvars                                         314     311      -3
doCommands                                          2222    2214      -8
do_load                                              918     902     -16
printable_string                                      57       9     -48
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 8/6 up/down: 146/-79)            Total: 67 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-30 16:56:56 +02:00
Denys Vlasenko
c9720a761e timeout: fix arguments to match coreutils
Was: timeout [-t SECS] [-s SIG] PROG ARGS
Is:  timeout [-s SIG] SECS PROG ARGS

function                                             old     new   delta
timeout_main                                         312     319      +7
packed_usage                                       32882   32858     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-24)             Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-03 18:28:17 +02:00
Denys Vlasenko
4c20d9f2b0 extend fractional duration support to "top -d N.N" and "timeout"
function                                             old     new   delta
parse_duration_str                                     -     168    +168
sleep_for_duration                                     -     157    +157
top_main                                             885     928     +43
timeout_main                                         269     312     +43
handle_input                                         571     614     +43
duration_suffixes                                      -      40     +40
sfx                                                   40       -     -40
sleep_main                                           364      79    -285
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 3/1 up/down: 494/-325)          Total: 169 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-03 18:17:12 +02:00
Lauri Kasanen
a380aacca6 ls: When -h is passed, the total should also be in human units
Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-01 19:47:15 +02:00
Denys Vlasenko
d01c9aa7ca cp: placate gcc8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-01 18:29:41 +02:00
Denys Vlasenko
1fbb73fc4c cp: add missing quote in config snippet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-17 00:16:16 +02:00
Denys Vlasenko
79fb6ac7a5 cp: optional --reflink support
function                                             old     new   delta
cp_main                                              428     512     +84
copy_file                                           1676    1742     +66

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-13 20:30:02 +02:00
Denys Vlasenko
cbe8c65e59 sort: add -V "sort version"
function                                             old     new   delta
packed_usage                                       32855   32858      +3
get_key                                              500     503      +3
sort_opt_str                                          36      37      +1
sort_main                                           1037    1036      -1
compare_keys                                         795     783     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 7/-13)              Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-08 01:37:54 +02:00
haroon maqsood
4a85d56c4c nproc: implement --all --ignore=N
function                                             old     new   delta
nproc_main                                            98     242    +144
packed_usage                                       32799   32816     +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 161/0)             Total: 161 bytes

Signed-off-by: haroon maqsood <maqsood3525@live.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-06 16:19:04 +02:00
Denys Vlasenko
34254f9dde install: fix "-D -t DIR1/DIR2/DIR3" creating only DIR1/DIR2, closes 11106
function                                             old     new   delta
install_main                                         758     767      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-22 18:59:10 +02:00
Kartik Agaram
43b17b1cd0 restore documentation on the build config language
Kconfig-language.txt was deleted in commit 4fa499a17b back in 2006.
Move to docs/ as suggested by Xabier Oneca:
  http://lists.busybox.net/pipermail/busybox/2014-May/080914.html
Also update references to it everywhere.

Signed-off-by: Kartik Agaram <akkartik@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-06 15:16:48 +02:00
Denys Vlasenko
747162109f realpath,readlink -f: coreutils compat, closes 11021
function                                             old     new   delta
xmalloc_realpath_coreutils                             -     121    +121

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-24 17:31:00 +02:00
Denys Vlasenko
d80eecb868 cat: fix cat -e and cat -v erroneously numbering 1st line
function                                             old     new   delta
cat_main                                             418     421      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-29 14:05:43 +02:00
Denys Vlasenko
3632cb15f1 shell: add comments about [[, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-10 15:25:41 +02:00
Denys Vlasenko
38ccd6af8a bzip2: fix two crashes on corrupted archives
As it turns out, longjmp'ing into freed stack is not healthy...

function                                             old     new   delta
unpack_usage_messages                                  -      97     +97
unpack_bz2_stream                                    369     409     +40
get_next_block                                      1667    1677     +10
get_bits                                             156     155      -1
start_bunzip                                         212     183     -29
bb_show_usage                                        181     120     -61
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91)            Total: 56 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 20:05:04 +02:00
Denys Vlasenko
7bcde5f00d libbb.h: always include sys/resource.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 17:23:27 +02:00
Denys Vlasenko
77cb6b99a4 libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> bb_ask_y_confirmation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:08:12 +02:00
Denys Vlasenko
d1d6d9c5d8 sort: smaller and more agressive FEATURE_SORT_OPTIMIZE_MEMORY
function                                             old     new   delta
sort_main                                           1098    1037     -61

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 16:44:50 +02:00
Denys Vlasenko
759ca8a4cb sort: move misplaced comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-04 17:07:21 +02:00