Commit Graph

539 Commits

Author SHA1 Message Date
Denys Vlasenko
049b007865 pmap: fix bogus {no such process} comm field text
function                                             old     new   delta
read_cmdline                                         246     266     +20
procps_get_maps                                      196     193      -3
packed_usage                                       30413   30404      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 20/-12)              Total: 8 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 03:45:57 +02:00
Denys Vlasenko
641caaec3d libbb: factor out code which queries screen width
function                                             old     new   delta
get_terminal_width                                     -      17     +17
stty_main                                           1196    1197      +1
pstree_main                                          321     319      -2
ls_main                                              735     731      -4
watch_main                                           232     225      -7
bb_progress_update                                   714     706      -8
ps_main                                              555     543     -12
run_applet_and_exit                                  708     695     -13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/6 up/down: 18/-46)            Total: -28 byte

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-23 01:44:22 +02:00
Denys Vlasenko
4ad702c0a7 top: make sort field for 's' mode less confusing
function                                             old     new   delta
display_topmem_process_list                          542     565     +23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-14 22:30:47 +02:00
Denys Vlasenko
7b85ec30b5 *: more BUILD_BUG_ON conversions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-13 17:17:34 +02:00
Denys Vlasenko
7f3a2a2256 join some common strings, -400 bytes
function                                             old     new   delta
print_intel_cstates                                  499     511     +12
file_insert                                          355     364      +9
dpkg_main                                           2944    2940      -4
ifenslave_main                                       645     640      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 21/-9)              Total: 12 bytes
   text	   data	    bss	    dec	    hex	filename
 937564	    932	  17676	 956172	  e970c	busybox_old
 937164	    932	  17676	 955772	  e957c	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-08 11:24:44 +02:00
Denys Vlasenko
d60752f8c9 build system: -fno-builtin-printf
Benefits are: drops reference to out-of-line putchar(), fixes a few cases
of failed string merge.

function                                             old     new   delta
i2cdump_main                                        1488    1502     +14
sha256_process_block64                               423     433     +10
sendmail_main                                       1183    1185      +2
list_table                                          1114    1116      +2
i2cdetect_main                                      1235    1237      +2
fdisk_main                                          2852    2854      +2
builtin_type                                         119     121      +2
unicode_conv_to_printable2                           325     324      -1
scan_recursive                                       380     378      -2
mkfs_minix_main                                     2687    2684      -3
buffer_fill_and_print                                178     169      -9
putchar                                              152       -    -152
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 7/4 up/down: 34/-167)          Total: -133 bytes
   text    data     bss     dec     hex filename
 937788     932   17676  956396   e97ec busybox_old
 937564     932   17676  956172   e970c busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 22:42:45 +02:00
Denys Vlasenko
c9091d8947 ps: fix SEGV on narrow screens. closes 8176
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-01 19:07:24 +02:00
Bernhard Reutner-Fischer
86a7f18f21 *: Switch to POSIX utmpx API
UTMP is SVID legacy, UTMPX is mandated by POSIX.

Glibc and uClibc have identical layout of UTMP and UTMPX, both of these
libc treat _PATH_UTMPX as _PATH_UTMP so from a user-perspective nothing
changes except the names of the API entrypoints.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-02 23:03:46 +02:00
Ron Yorston
8ec1ff350c Use chomp to remove newlines
function                                             old     new   delta
unix_do_one                                          548     540      -8
process_timer_stats                                  508     500      -8
process_irq_counts                                   532     524      -8
lpd_main                                             839     831      -8
hwclock_main                                         502     494      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-50)             Total: -40 bytes

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 20:18:51 +01:00
Denys Vlasenko
8dff01d06a libbb: introduce and use is_prefixed_with()
function                                             old     new   delta
is_prefixed_with                                       -      18     +18
complete_username                                     78      77      -1
man_main                                             737     735      -2
fsck_device                                          429     427      -2
unpack_ar_archive                                     80      76      -4
strip_unsafe_prefix                                  105     101      -4
singlemount                                         1054    1050      -4
rtc_adjtime_is_utc                                    90      86      -4
resolve_mount_spec                                    88      84      -4
parse_one_line                                      1029    1025      -4
parse_conf                                          1460    1456      -4
may_wakeup                                            83      79      -4
loadkmap_main                                        219     215      -4
get_irqs_from_stat                                   103      99      -4
get_header_cpio                                      913     909      -4
findfs_main                                           79      75      -4
fbsplash_main                                       1230    1226      -4
load_crontab                                         776     771      -5
expand_vars_to_list                                 1151    1146      -5
date_main                                            881     876      -5
skip_dev_pfx                                          30      24      -6
make_device                                         2199    2193      -6
complete_cmd_dir_file                                773     767      -6
run_applet_and_exit                                  715     708      -7
uudecode_main                                        321     313      -8
pwdx_main                                            197     189      -8
execute                                              568     560      -8
i2cdetect_main                                      1186    1176     -10
procps_scan                                         1242    1230     -12
procps_read_smaps                                   1017    1005     -12
process_module                                       746     734     -12
patch_main                                          1903    1891     -12
nfsmount                                            3572    3560     -12
stack_machine                                        126     112     -14
process_timer_stats                                  449     435     -14
match_fstype                                         111      97     -14
do_ipaddr                                           1344    1330     -14
open_list_and_close                                  359     343     -16
get_header_tar                                      1795    1779     -16
prepend_new_eth_table                                340     323     -17
fsck_main                                           1811    1794     -17
find_iface_state                                      56      38     -18
dnsd_main                                           1321    1303     -18
base_device                                          179     158     -21
find_keyword                                         104      82     -22
handle_incoming_and_exit                            2785    2762     -23
parse_and_put_prompt                                 774     746     -28
modinfo                                              347     317     -30
find_action                                          204     171     -33
update_passwd                                       1470    1436     -34
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540)         Total: -522 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 17:48:34 +01:00
Denys Vlasenko
86031a5ffd trim extra newlines in help texts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-24 19:46:45 +01:00
Denys Vlasenko
1ec49732e2 mpstat: code shrink
function                                             old     new   delta
get_uptime                                           134     129      -5
get_irqs_from_stat                                   110     103      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-05 18:39:23 +01:00
Guillermo Rodriguez
75a1403f26 free: handle "cached" value too
function                                             old     new   delta
free_main                                            356     481    +125

Signed-off-by: Guillermo Rodriguez <guille.rodriguez@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-05 18:34:53 +01:00
Denys Vlasenko
6c6d37ee45 top: fix memset length (sizeof(ptr) vs sizeof(array) problem)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-29 17:00:30 +02:00
Timo Teräs
7df1f1dda1 top: fix and merge code to parse /proc/meminfo
display_header() code to parse meminfo as is was buggy:
- uninitialized variables were used if meminfo was not as expected
- meminfo parsing failed on new kernels (3.14+) as new field 'MemAvailable'
  was introduced between MemFree and Buffers
- shared memory was handled only for ancient kernels (2.4.x and earlier)

as result Buffers and shared memory fields were shown with bogus values
on current kernels.

The new code does not try to parse the old style summary header, as the
separated fields are always present (it saves code size). Additionally,
both Shmem (2.6+) and MemShared (2.4 and earlier) fields are now parsed
and summed for shared memory usage; as only one of them exists depending
on kernel version.

display_topmem_header() parses also meminfo so this makes it use the
same code for code shrink.

function                                             old     new   delta
display_header                                         -     681    +681
display_topmem_process_list                          465     684    +219
parse_meminfo                                          -     189    +189
static.fields                                          -     106    +106
static.match                                         132       -    -132
.rodata                                           120254  120117    -137
display_topmem_header                                513       -    -513
display_process_list                                1705     667   -1038
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 1/2 up/down: 1195/-1820)       Total: -625 bytes

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-27 21:49:27 +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
6554d03735 sysctl: do not error out showing write-only data. Closes 6386
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-24 17:28:43 +01:00
Bartosz Golaszewski
2de232da53 top.c: fix compilation warnings
pfd[1] is unused

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-20 03:26:34 +01:00
Denys Vlasenko
4b26f82c78 kill[all[5]]: code shrink
function                                             old     new   delta
kill_main                                            992     947     -45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-12-16 17:45:44 +01:00
Uros Vampl
3ac1e0d753 killall5: return 2 if no processes got killed
function                                             old     new   delta
kill_main                                            943     992     +49

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-12-16 17:44:58 +01:00
Denys Vlasenko
327f550669 Use unsigned printf/scanf conversion where more appropriate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-29 16:45:45 +01:00
Denys Vlasenko
dc57294485 top: fix breakage introduced by previous commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-09-06 12:59:48 +02:00
Denys Vlasenko
a407cf74cc Make smart_ulltoa return pointer to end (allows for code shink in callers)
function                                             old     new   delta
smart_ulltoa5                                        405     408      +3
smart_ulltoa4                                        273     276      +3
list_table                                          1113    1114      +1
scale                                                 36      34      -2
put_lu                                                55      53      -2
ulltoa6_and_space                                     19      14      -5
powertop_main                                       1470    1461      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-09-06 12:53:14 +02:00
Denys Vlasenko
173aa78bcf pstree: fix theoretically unsafe code
In practice, p->comm is never long enough to trigger the bug, but still.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-28 01:59:25 +02:00
Thomas De Schampheleire
879f008a8f lsof: correct check for symbolic link
Busybox lsof used the d_type field of a 'struct dirent' to verify whether the
entry is a symbolic link. This field, however, is not portable. On at least
one board [1] I have seen, that field is 0, and the check fails even though
the entry is a link.

The explicit check for a symbolic link is really only needed to skip the
default directory entries '.' and '..'. The directory /proc/<pid>/fd/
should not contain anything else but these two and symbolic links.
With these assumptions, this patch replaces the explicit link check with a
basic check for '.' and '..' (and any hidden file). In the unlikely case that
there are other file types, xmalloc_readlink() will return NULL, and we can
skip the entry.

[1] A MIPS-based board with glibc 2.9, Linux 2.6.32.27.

Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-27 03:44:46 +02:00
Mike Frysinger
fea2588021 pstree: stop truncating thread names
This also fixes a minor buffer overflow when displaying threads as
add_proc() only expects COMM_LEN bytes, but we give it one more than
that.

Reported-by: Dag Wieers <dag@wieers.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-06-19 11:29:57 -04:00
Denys Vlasenko
8f2cb7ab26 libbb: introduce and use strftime_[YYYYMMDD]HHMMSS()
function                                             old     new   delta
strftime_fmt                                           -      53     +53
strftime_YYYYMMDDHHMMSS                                -      12     +12
strftime_HHMMSS                                        -      12     +12
human_time                                            44      43      -1
fmtstr_t                                               9       -      -9
step_time                                            361     345     -16
watch_main                                           261     232     -29
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 0/3 up/down: 77/-55)             Total: 22 bytes
   text	   data	    bss	    dec	    hex	filename
 919203	    932	  17692	 937827	  e4f63	busybox_old
 919209	    932	  17692	 937833	  e4f69	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29 12:30:33 +01:00
Denys Vlasenko
7794c21daf pgrep: fix a "missing closing paren" build error
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-28 15:51:55 +01:00
Bernhard Walle
47f8558eee pgrep: fix -x option
Because when -x is used (exact match), then we cannot compile the
regular expression with REG_NOSUB. The manual page regcomp(3) states
in section "Byte offsets":

    Unless REG_NOSUB was set for the compilation of the pattern
    buffer, it is possible to obtain substring match addressing
    information.

The problem was detected on an ARM system with glibc 2.16.
Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-28 12:42:38 +01:00
Denys Vlasenko
17d4436424 ps: seconds_since_boot: uint64_t -> ulong
Even if long is 32-bit, 4 billion second uptime isn't likely :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-26 14:21:15 +01:00
Denys Vlasenko
778794d1dd *: reuse more strings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-22 10:13:52 +01:00
Denys Vlasenko
6aab061d2d ps: fix sscanf format specifier (%l); make uptime unsigned
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-22 10:07:23 +01:00
Denys Vlasenko
60cb48ca50 whitespace cleanup. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Denys Vlasenko
6967578728 whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 01:34:48 +01:00
Lauri Hintsala
fb499c5752 powertop: fix error message
Application tries to use timer_stats module instead of cpufreq_stats.
Error message is printed if opening of the file /proc/timer_stats fails.

Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-04 17:45:44 -05:00
Denys Vlasenko
c4f2d997a4 libbb: correctness/size tweaks in signal-related helpers
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 13:20:34 +02:00
Denys Vlasenko
73a1990897 top: do not touch stdin if -b
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-26 16:58:25 +02:00
Denys Vlasenko
ffe03f04cb top: fix build failure in !USE_TERMIOS case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-25 12:48:46 +02:00
Denys Vlasenko
42be921d48 ps: fix build failure in !DESKTOP case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-25 12:48:10 +02:00
Denys Vlasenko
2fb8d0dee9 top: implement scrolling up/down (_very_ useful)
function                                             old     new   delta
handle_input                                         494     564     +70
top_main                                             928     947     +19
display_topmem_process_list                          363     381     +18
display_process_list                                1442    1453     +11
clearmems                                             38      28     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 118/-10)           Total: 108 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-21 13:04:37 +02:00
Joshua Kahlenberg
c439851438 sysctl: implement -q
function                                             old     new   delta
packed_usage                                       29208   29223     +15
sysctl_act_recursive                                 605     598      -7
sysctl_main                                          233     222     -11

Signed-off-by: Joshua Kahlenberg <jbkberg@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-05 18:15:12 +02:00
Denys Vlasenko
dac8e79a19 Move several applets to different install dir:
Moved to [/usr]/sbin:
addgroup, adduser, delgroup, deluser,
arping, chat, ether-wake, fdformat, ifplugd,
ip, ipaddr, iplink, iproute, iprule, iptunnel,
killall5, readahead, rtcwake, tftpd, add-shell, remove-shell, powertop.

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-20 20:24:57 +02:00
Michael Tokarev
ac42e3de90 ps: use separate get_uptime() and make it work on non-linux too
Create get_uptime() function in procps/ps.c, and use it rather than
relying on linux-specific sysinfo() inline.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-13 02:52:28 +02:00
Denys Vlasenko
14850308e9 killall5: don't do STOP/CONT dance if the signal we send is SIGSTOP or SIGCONT
function                                             old     new   delta
kill_main                                            913     942     +29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-03 08:16:05 +02:00
Sven Oliver Moll
1c12b67705 lsof: new applet
text    data     bss     dec     hex filename
    221       0       0     221      dd lsof.o

Signed-off-by: Sven Oliver Moll <busybox@svol.li>
Signed-off-by: souf <souf_oued@yahoo.fr>
Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-01 16:23:23 +02:00
Denys Vlasenko
0687a5b496 libbb: make xchroot do a chdir("/") after chroot
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-08 00:28:24 +01:00
Alexey Fomenko
6a93212b54 kill: fix segfault in arguments parsing
Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-22 11:38:57 +01:00
Denys Vlasenko
3b1603410a nmeter: fix block i/o count on newer Linux kernels
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-01 23:34:46 +01:00
Cristian Ionescu-Idbohrn
85b1f292c9 ps: fix for !FEATURE_PS_LONG build
Signed-off-by: Cristian Ionescu-Idbohrn <cii@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-29 11:02:00 +02:00
Flemming Madsen
b64bd16459 ps: with -l, show STIME too
Signed-off-by: Flemming Madsen <busybox@themadsens.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-27 15:31:25 +02:00