Commit Graph

1638 Commits

Author SHA1 Message Date
Ron Yorston
83e20cb81c getopt: code shrink
function                                             old     new   delta
.rodata                                            99277   99290     +13
normalize                                            177     142     -35
getopt_main                                          675     622     -53
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 13/-88)            Total: -75 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-16 01:09:32 +02:00
Denys Vlasenko
c421388dca blkdiscard: accept -f (force) as no-op
function                                             old     new   delta
.rodata                                           104250  104251      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-10 00:20:05 +02:00
Denys Vlasenko
1b661122a8 mount: code shrink
function                                             old     new   delta
append_mount_options                                 174     157     -17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-23 02:31:26 +02:00
Denys Vlasenko
dbdf9e0ab1 mount: with -w, do not fall back to read-only mounts
function                                             old     new   delta
mount_it_now                                         364     358      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-23 02:30:13 +02:00
Ron Yorston
4357569fdc rev: correct output for long input lines
The input buffer is initialised to a reasonable size and extended
if necessary.  When this happened the offset into the buffer wasn't
reset to zero so subsequent lines were appended to the long line.

Fix this and add some tests.

function                                             old     new   delta
rev_main                                             377     368      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-9)               Total: -9 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-22 00:08:18 +02:00
Denys Vlasenko
9ba502456f fdisk: indentation fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 11:13:30 +02:00
Denys Vlasenko
319e20b56b taskset: disallow "taskset -p 0"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:41:18 +02:00
Denys Vlasenko
53e5c59821 fdisk: commonalize strings
function                                             old     new   delta
.rodata                                           103674  103667      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-25 01:14:43 +02:00
Denys Vlasenko
294d0c85ad xxd: compat tweak for -i
function                                             old     new   delta
xxd_main                                             888     893      +5
.rodata                                           103669  103674      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 10/0)               Total: 10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-25 00:16:04 +02:00
Denys Vlasenko
3b267e9925 switch_root: code shrink - use iterate_on_dir()
function                                             old     new   delta
rmrf                                                   -      46     +46
delete_contents                                      181      99     -82
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 46/-82)            Total: -36 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-24 17:54:11 +02:00
Denys Vlasenko
6d61eb1363 taskset: use iterate_on_dir()
function                                             old     new   delta
iter                                                   -      27     +27
process_pid_str                                      854     856      +2
taskset_main                                         181     135     -46
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 29/-46)            Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-24 12:02:17 +02:00
Denys Vlasenko
9c291f2cc0 taskset: fix for PID longer than 12 chars
Should we validate that PID is a number for "taskset -ap PID"?
We don't actually need it, and pathological input like
"../../DIR_WITH_LOTS_OF_PIDS" can only cause "taskset"ing
of many pids. Which is something user can do anyway.

function                                             old     new   delta
taskset_main                                         190     181      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-20 09:04:45 +02:00
Denys Vlasenko
25128176c4 taskset: implement -a
function                                             old     new   delta
process_pid_str                                        -     854    +854
.rodata                                           103363  103378     +15
packed_usage                                       33654   33658      +4
taskset_main                                         936     190    -746
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 873/-746)          Total: 127 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-19 17:42:35 +02:00
Denys Vlasenko
2c436679fb xxd: implement -i "C style output"
function                                             old     new   delta
xxd_main                                             710     888    +178
.rodata                                           103252  103331     +79
print_C_style                                          -      78     +78
packed_usage                                       33639   33652     +13
next                                                 276     278      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 350/0)             Total: 350 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-18 00:59:17 +02:00
Denys Vlasenko
4d16161797 xxd: implement -o DISPLAYOFFSET
function                                             old     new   delta
xxd_main                                             680     710     +30
xstrtoll                                               -      30     +30
bb_dump_dump                                        1511    1531     +20
rewrite                                              941     951     +10
packed_usage                                       33629   33639     +10
.rodata                                           103250  103252      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/0 up/down: 102/0)             Total: 102 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-17 23:53:30 +02:00
Denys Vlasenko
f02b64de86 ionice: implement -t
function                                             old     new   delta
packed_usage                                       33618   33629     +11
ionice_main                                          272     282     +10
.rodata                                           103250  103251      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 22/0)               Total: 22 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-17 13:45:13 +02:00
Denys Vlasenko
46d315ae44 blockdev: support --get/setra
function                                             old     new   delta
blockdev_main                                        251     263     +12
bdcmd_names                                           82      94     +12
packed_usage                                       33534   33542      +8
bdcmd_ioctl                                           44      52      +8
bdcmd_flags                                           11      13      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 42/0)               Total: 42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-16 17:00:56 +02:00
Denys Vlasenko
1f60d88cf6 *: more --help tweaks
function                                             old     new   delta
packed_usage                                       33552   33541     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-15 10:00:18 +02:00
Denys Vlasenko
e2b9215868 *: --help tweaks
function                                             old     new   delta
packed_usage                                       33589   33552     -37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-14 20:47:20 +02:00
Denys Vlasenko
6f7b10cdab *: more --help tweaking
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-13 03:51:55 +02:00
Ron Yorston
cad3fc743a libbb: introduce and use fputs_stdout
function                                             old     new   delta
fputs_stdout                                           -      12     +12
zxc_vm_process                                      7237    7230      -7
yes_main                                              85      78      -7
write_block                                          380     373      -7
wrapf                                                305     298      -7
strings_main                                         437     430      -7
show_bridge                                          353     346      -7
rev_main                                             384     377      -7
put_prompt_custom                                     58      51      -7
put_cur_glyph_and_inc_cursor                         168     161      -7
print_numbered_lines                                 152     145      -7
print_named_ascii                                    130     123      -7
print_name                                           135     128      -7
print_login_issue                                    386     379      -7
print_ascii                                          208     201      -7
powertop_main                                       1249    1242      -7
od_main                                             1789    1782      -7
logread_main                                         518     511      -7
head_main                                            804     797      -7
display_process_list                                1319    1312      -7
cut_main                                            1002     995      -7
bb_dump_dump                                        1550    1543      -7
bb_ask_noecho                                        393     386      -7
baseNUM_main                                         702     695      -7
expand_main                                          755     745     -10
dumpleases_main                                      497     487     -10
write1                                                12       -     -12
putcsi                                                37      23     -14
print_login_prompt                                    55      41     -14
paste_main                                           525     511     -14
cat_main                                             440     426     -14
print_it                                             245     230     -15
print_addrinfo                                      1188    1171     -17
print_rule                                           770     750     -20
print_linkinfo                                       842     822     -20
httpd_main                                           791     771     -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341)         Total: -329 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03 20:52:40 +01:00
Denys Vlasenko
3c13da3dab libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells
function                                             old     new   delta
xgettimeofday                                          -      11     +11
get_local_var_value                                  280     281      +1
svlogd_main                                         1323    1322      -1
change_epoch                                          67      66      -1
timestamp_and_log                                    461     458      -3
hwclock_main                                         301     298      -3
fmt_time_bernstein_25                                135     132      -3
step_time                                            331     326      -5
script_main                                         1207    1202      -5
machtime                                              34      28      -6
curtime                                               61      54      -7
ts_main                                              423     415      -8
nmeter_main                                          761     751     -10
gettime1900d                                          67      46     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73)           Total: -61 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-30 23:48:01 +01:00
Denys Vlasenko
77a51a2709 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-29 16:53:11 +01:00
Lauri Kasanen
6cfec7dd02 mount: Surround syslog.h with the config check
This lets bb mount build for limited targets without syslog.h,
as long as the parts using it like NFS are disabled.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-25 18:15:37 +01:00
Denys Vlasenko
a2f18d950a help text tweaks
function                                             old     new   delta
packed_usage                                       33570   33502     -68

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-18 04:12:51 +01:00
Denys Vlasenko
251e08ffa6 move ADJTIME_PATH define to header files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-17 20:53:43 +01:00
Denys Vlasenko
eb0c2e218c libbb: introduce and use xsettimeofday()
function                                             old     new   delta
xsettimeofday                                          -      25     +25
rdate_main                                           274     260     -14
step_time                                            348     331     -17
set_kernel_timezone_and_clock                        119     102     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 25/-48)            Total: -23 bytes
   text	   data	    bss	    dec	    hex	filename
1020753	    559	   5052	1026364	  fa93c	busybox_old
1020708	    559	   5052	1026319	  fa90f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-16 21:36:36 +01:00
Denys Vlasenko
d3c36882dc hwclock: improve --help (-l is a compatible shortcut for --localtime)
function                                             old     new   delta
packed_usage                                       33605   33568     -37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-16 20:55:30 +01:00
Denys Vlasenko
9e262f13c2 hwclock: fix musl breakage of settimeofday(tz)
function                                             old     new   delta
set_kernel_timezone_and_clock                          -     119    +119
set_kernel_tz                                          -      28     +28
hwclock_main                                         480     301    -179
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 147/-179)          Total: -32 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-16 14:00:47 +01:00
Denys Vlasenko
caba1a16ec tweak help texts
function                                             old     new   delta
packed_usage                                       33650   33605     -45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-16 01:19:08 +01:00
Denys Vlasenko
c7b858ff8d libbb: add and use infrastructure for fixed page size optimization
function                                             old     new   delta
procps_scan                                         1121    1118      -3
getpagesize                                            6       -      -6
rpm_main                                            1037    1027     -10
rpm2cpio_main                                        120     110     -10
ptok                                                  38      21     -17
time_main                                           1282    1261     -21
mkswap_main                                          317     278     -39
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/6 up/down: 0/-106)           Total: -106 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-14 18:54:30 +01:00
Denys Vlasenko
fd3c512f88 libbb: create and use mmap() helpers
function                                             old     new   delta
mmap_anon                                              -      22     +22
mmap_read                                              -      21     +21
xmmap_anon                                             -      16     +16
rpm_gettags                                          465     447     -18
bb_full_fd_action                                    498     480     -18
uevent_main                                          337     310     -27
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 0/3 up/down: 59/-63)             Total: -4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-14 18:25:28 +01:00
Denys Vlasenko
84d5eddb25 help text: replace [OPTIONS] with actual options (if not too long)
function                                             old     new   delta
packed_usage                                       33620   33665     +45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 22:34:05 +01:00
Denys Vlasenko
5d553bc558 more --help text tweaks
function                                             old     new   delta
packed_usage                                       33545   33581     +36

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 19:18:28 +01:00
Denys Vlasenko
ef2366cdca nsenter: stop option parsing on 1st non-option
"nsenter ls -l" gives: invalid option -- 'l'

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 08:44:32 +01:00
Denys Vlasenko
56ee576507 mount: fix incorrect "success" exitcode if loop device setup fails
When mounting, in parallel, multiple loop devices (squashfs for the
submitter's case), the following behavior can be observed:

stat64(/path/to/image, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
openat(AT_FDCWD, /path/to/image, O_RDWR|O_LARGEFILE) = 3
openat(AT_FDCWD, /dev/loop-control, O_RDWR|O_LARGEFILE|O_CLOEXEC) = 4
ioctl(4, LOOP_CTL_GET_FREE)             = 12
close(4)                                = 0
openat(AT_FDCWD, /dev/loop12, O_RDWR|O_LARGEFILE) = 4
ioctl(4, LOOP_GET_STATUS64, {lo_offset=0, lo_number=12, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name=/path/to/image, ...}) = 0
close(4)                                = 0
close(3)                                = 0
write(2, "mount: can't setup loop device\n", 31mount: can't setup loop device
) = 31
exit_group(0)                           = ?
+++ exited with 0 +++

The ioctl LOOP_CTL_GET_FREE has resulted in the same result for
a competing mount process. The subsequent ioctl LOOP_GET_STATUS64
fails, having succeeded for the competing mount process.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-09 20:56:43 +01:00
Denys Vlasenko
34c5115a7f mount: implement -o nosymfollow, remove bogus -o union
The (1 << 8) MS_ flag is MS_NOSYMFOLLOW, not MS_UNION.
As far as I see in git history of kernel and util-linux,
MS_UNION did not ever exist.
Why did it appear in our tree in 2009?...

function                                             old     new   delta
mount_option_str                                     379     385      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-06 21:56:22 +01:00
Denys Vlasenko
696c38ddca mount: add -o nostrictatime and -o [no]lazytime
function                                             old     new   delta
mount_option_str                                     345     379     +34
mount_options                                        176     188     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 46/0)               Total: 46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-06 20:59:41 +01:00
Denys Vlasenko
b1eedfcfa1 mount: do not guess mount as NFS if "hostname:" contains slashes
function                                             old     new   delta
singlemount                                         1273    1295     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-05 14:14:11 +01:00
Denys Vlasenko
b4f93f562d mount: do not guess bind mounts as nfs
Fails as follows:

$ mount -o bind /dev/disk/by-path/pci-0000:13:00.0-scsi-0:0:3:0 /dir
mount: bad address '/dev/disk/by-path/pci-0000'

function                                             old     new   delta
singlemount                                         1256    1273     +17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-02 19:10:22 +01:00
Denys Vlasenko
6599e380ed mount: make filesystems[] array byte-aligned
text	   data	    bss	    dec	    hex	filename
1021120	    559	   5052	1026731	  faaab	busybox_old
1021092	    559	   5052	1026703	  faa8f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 15:10:43 +01:00
Denys Vlasenko
6cc4962b60 decrease padding: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly
text	   data	    bss	    dec	    hex	filename
1021236	    559	   5052	1026847	  fab1f	busybox_old
1021120	    559	   5052	1026731	  faaab	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 14:58:02 +01:00
Denys Vlasenko
965b795b87 decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly
text	   data	    bss	    dec	    hex	filename
1021988	    559	   5052	1027599	  fae0f	busybox_old
1021236	    559	   5052	1026847	  fab1f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 13:03:03 +01:00
Denys Vlasenko
ec16c030bd libbb: introduce and use sleep1()
function                                             old     new   delta
sleep1                                                 -       9      +9
run_shutdown_and_kill_processes                       97      95      -2
restore_state_and_exit                               116     114      -2
reread_partition_table                                67      65      -2
flush_buffer_cache                                    80      78      -2
chat_main                                           1302    1300      -2
timeout_main                                         310     307      -3
telnet_main                                         1235    1232      -3
stop_handler                                          86      83      -3
process_action                                      1078    1075      -3
nbdclient_main                                      1185    1182      -3
init_main                                            789     786      -3
getty_main                                          1541    1538      -3
do_time                                              410     407      -3
runsv_main                                          1682    1677      -5
pause_and_low_level_reboot                            59      54      -5
inetd_main                                          1917    1911      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 9/-50)            Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 11:37:34 +01:00
Denys Vlasenko
03eb6eba43 mdev: clear LOGMODE_STDIO only directly before daemonizing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 16:35:56 +01:00
Denys Vlasenko
cb143b9793 uevent: make it survive ENOBUFS
function                                             old     new   delta
uevent_main                                          285     337     +52

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 16:22:16 +01:00
Denys Vlasenko
1c9cd9b71b mdev: clean up
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:43:35 +01:00
Jan Klötzke
768153bf8c mdev: add -v to increase log verbosity
If logging to stderr and/or syslog the -v option can be given one or
more times to increase the log verbosity. If mdev is used as hotplug
helper the log level is fixed set to 2 if mdev.log is found an appended
because there is no possiblity to pass arguments to the hotplug helper.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:33:58 +01:00
Jan Klötzke
e9003caf6d mdev: add syslog logging mode
If mdev is run as daemon it should be possible to forward the debug
messages to syslog. This feature might be useful if mdev is run with -s
during boot too. OTOH it makes no sense for the daemon to log to
mdev.log. This can be handled by a syslog daemon way better. If the
daemon stays in the foreground due to -f, the messages are still written
to stderr as before.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:33:58 +01:00
Jan Klötzke
d560030548 mdev: re-initialize if uevent messages were lost
If the netlink read() failed with ENOBUFS we know that we have missed at
least one message due to a socket receive buffer overrun. The only way
how to recover is to drop the old socket, open a fresh one and make a
cold-plug scan of the current system state.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:33:58 +01:00