Commit Graph

1614 Commits

Author SHA1 Message Date
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
Jan Klötzke
e3f4759019 mdev: move daemon setup to dedicated function
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
Denys Vlasenko
a569fd37fe uevent: increase netlink buffer sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 13:34:07 +01:00
Jan Klötzke
3cd55d49a2 mdev: increase netlink buffer sizes
The socket receive buffer turned out to be too small for real world
systems. Use the same size as udevd to be on the safe side. As this is
just a limit and the memory is not allocated by the kernel until really
needed there is actually no memory wasted.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 13:32:06 +01:00
Denys Vlasenko
2c92d1ec58 volume_id: improve struct layout (smaller offesets, smaller insns on x86)
function                                             old     new   delta
volume_id_probe_xfs                                  101      98      -3
volume_id_probe_vfat                                 827     824      -3
volume_id_probe_udf                                  541     538      -3
volume_id_probe_ubifs                                 67      64      -3
volume_id_probe_squashfs                              86      83      -3
volume_id_probe_romfs                                 97      94      -3
volume_id_probe_reiserfs                             246     243      -3
volume_id_probe_ocfs2                                110     107      -3
volume_id_probe_ntfs                                 288     285      -3
volume_id_probe_nilfs                                100      97      -3
volume_id_probe_minix                                 85      82      -3
volume_id_probe_luks                                  92      89      -3
volume_id_probe_linux_swap                           251     248      -3
volume_id_probe_linux_raid                           131     128      -3
volume_id_probe_lfs                                   62      59      -3
volume_id_probe_jfs                                  110     107      -3
volume_id_probe_iso9660                              318     315      -3
volume_id_probe_f2fs                                 107     104      -3
volume_id_probe_exfat                                285     282      -3
volume_id_probe_erofs                                 89      86      -3
volume_id_probe_cramfs                                67      64      -3
volume_id_probe_btrfs                                134     131      -3
volume_id_probe_bcache                               107     104      -3
volume_id_probe_sysv                                 194     188      -6
volume_id_probe_hfs_hfsplus                          518     512      -6
add_to_uuid_cache                                    271     265      -6
volume_id_probe_ext                                  131     122      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/27 up/down: 0/-96)            Total: -96 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-19 13:58:25 +01:00
Norbert Lange
c20e42e320 util-linux: support erofs filesystem
Add erofs to the known volume_ids.

function                                             old     new   delta
volume_id_probe_erofs                                  -      89     +89
fs1                                                   24      28      +4
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/0 up/down: 93/0)               Total: 93 bytes

Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-18 19:19:23 +01:00
Christian Eggers
89f063b900 chrt: support for musl C library
musl "implements" several sched_xxx() functions by returning ENOSYS. As
an alternative, either pthread_(g|s)etschedparam() or direct syscalls
can be used.

References: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/schedutils/chrt.c?id=fcc3078754291d2f5121797eb91b364f8e24b2f1
References: http://git.musl-libc.org/cgit/musl/commit/src/sched/sched_setscheduler.c?id=1e21e78bf7a5c24c217446d8760be7b7188711c2
Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-15 20:26:46 +01:00
Denys Vlasenko
32e1f69ae0 compat: move hexdump -R functionality to xxd -r
function                                             old     new   delta
xxd_main                                             466     680    +214
packed_usage                                       33474   33483      +9
hexdump_opts                                          17      16      -1
hexdump_main                                         565     401    -164
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 223/-165)           Total: 58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-25 16:06:45 +01:00
Denys Vlasenko
dac5b83142 xxd: fix printing of trailing spaces
function                                             old     new   delta
bb_dump_dump                                        1497    1523     +26
xxd_main                                             459     466      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 33/0)               Total: 33 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-20 18:57:02 +02:00
Denys Vlasenko
2496616b0a avoid using strok - eliminates use of hidden global variable
function                                             old     new   delta
udhcp_str2optset                                     616     650     +34
setpriv_main                                         950     975     +25
switch_root_main                                     688     706     +18
parse                                                958     970     +12
getopt_main                                          622     628      +6
parse_resolvconf                                     302     306      +4
mpstat_main                                         1139    1142      +3
static.p                                               4       -      -4
cdcmd                                                717     702     -15
strtok                                               148       -    -148
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 7/1 up/down: 102/-167)          Total: -65 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-06 02:36:47 +02:00
Denys Vlasenko
689d0650ab libbb: shrink recursive_action() by reducing memory pressure
function                                             old     new   delta
recursive_action1                                      -     316    +316
file_action_grep                                     161     164      +3
add_to_prg_cache_if_socket                           202     205      +3
depmod_main                                          509     511      +2
writeFileToTarball                                   488     489      +1
parse_module                                         281     282      +1
fileAction                                           207     208      +1
act                                                  189     190      +1
add_to_dirlist                                        65      64      -1
writeTarFile                                         196     194      -2
uuidcache_init                                        47      45      -2
uuidcache_check_device                               109     107      -2
true_action                                            8       6      -2
run_parts_main                                       310     308      -2
netstat_main                                         534     532      -2
lsusb_main                                            29      27      -2
lspci_main                                            45      43      -2
initial_scan                                         138     136      -2
grep_main                                            845     843      -2
find_main                                            482     480      -2
config_file_action                                   437     435      -2
chmod_main                                           142     140      -2
dirAction                                             14      10      -4
diff_main                                           1544    1540      -4
chown_main                                           154     148      -6
skip_dir                                             136     129      -7
dir_act                                              191     184      -7
recursive_action                                     453      69    -384
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/20 up/down: 328/-439)        Total: -111 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 21:52:16 +02:00
Steffen Trumtrar
6561e07460 mount: support the sizelimit and offset option for loop devices
Starting with linux kernel v5.4 squashfs has a more strict parameter
checking implemented. Unlike util-linux mount, busybox never supported
the sizelimit option but simply forwards it to the kernel.
Since v5.4 mounting will fail with

    squashfs: Unknown parameter 'sizelimit'

Support the sizelimit parameter by setting it in the LOOP_SET_STATUS64
structure before handing it to the kernel.

While at it also add support for the offset option, which currently will
always be set to 0.

function                                             old     new   delta
cut_out_ull_opt                                        -     167    +167
singlemount                                         1230    1266     +36
set_loop                                             834     862     +28
losetup_main                                         479     483      +4
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 235/0)             Total: 235 bytes

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 00:31:11 +02:00
Eddie James
1a5d6fcbb5 hwclock: Fix settimeofday for glibc v2.31+
The glibc implementation changed for settimeofday, resulting in "invalid
argument" error when attempting to set both timezone and time with a single
call. Fix this by calling settimeofday twice

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 22:29:00 +02:00
Ron Yorston
5c69ad0ecd build system: drop PLATFORM_LINUX
PLATFORM_LINUX is a hidden configuration option which is disabled by
default and enabled at over a hundred locations for features that are
deemed to be Linux specific.

The only effect of PLATFORM_LINUX is to control compilation of
libbb/match_fstype.c.  This file is only needed by mount and umount.

Remove all references to PLATFORM_LINUX and compile match_fstype.c
if mount or umount is enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 17:12:56 +02:00
Norbert Lange
79bd7c3f7b acpid: only display -p if supported in usage
Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:11:03 +02:00
Denys Vlasenko
67e1529b92 nologin: make it possible to build it as single applet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 15:05:22 +02:00
Denys Vlasenko
a6e48dead3 fdisk: add HFS / HFS+ partition type
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-14 13:57:41 +01: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
Denys Vlasenko
b230fdfa9d taskset: tighten the check for stride values
function                                             old     new   delta
taskset_main                                         986     987      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-09 17:32:43 +01:00
Denys Vlasenko
a82fb1b9d8 taskset: implement stride argument
function                                             old     new   delta
taskset_main                                         925     986     +61

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-09 17:07:44 +01:00
Denys Vlasenko
e5586605ca taskset: update comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-08 16:32:37 +01:00
Denys Vlasenko
162ac7f45e taskset: add support for taking/printing CPU list (-c option)
function                                             old     new   delta
taskset_main                                         511     855    +344

Based on patch by Fryderyk Wrobel <frd1996@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-01 15:44:49 +01:00
Denys Vlasenko
e5897d041d suppress a few "unused function" warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 13:05:15 +02:00
Denys Vlasenko
27f0e8a275 fdisk_aix: fix aliasing warning, comment out unused global variables
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-04 17:16:15 +02:00
Denys Vlasenko
d8e4ce0503 fdisk: avoid overflow in "mega/gigabytes" calculation, code shrink
function                                             old     new   delta
list_disk_geometry                                   175     145     -30

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-04 16:45:04 +02:00