Compare commits

..
1444 Commits
Author SHA1 Message Date
Denis Vlasenko 84641942e5 apply post-1.12.1 patches, bump version to 1.12.2 2008-11-09 17:21:26 +00:00
Denis Vlasenko bacaff6e54 apply post-1.12.0 fixes, bump version to 1.12.1 2008-09-28 16:40:25 +00:00
Denis Vlasenko 261cf4784f This is 1.12.0 2008-08-20 23:29:10 +00:00
Denis Vlasenko e417be6697 getopt32: do not return pointer to alloca() areas 2008-08-20 23:03:38 +00:00
Denis Vlasenko b9c262b029 envdir: fix "envdir with no params" case 2008-08-20 22:19:27 +00:00
Denis Vlasenko 99b4083647 findfs: make it use setuid-ness of busybox binary 2008-08-20 08:50:02 +00:00
Denis Vlasenko b9f5d59893 fsck: use getmntent_r instead of open-coded parsing. By Vladimir
function                                             old     new   delta
create_fs_device                                     125     158     +33
parse_word                                            41       -     -41
parse_escape                                          55       -     -55
fsck_main                                           2246    1893    -353
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/1 up/down: 33/-449)          Total: -416 bytes
2008-08-20 02:38:48 +00:00
Denis Vlasenko f31c3b677d linedit: fix use-after-free 2008-08-20 00:46:32 +00:00
Denis Vlasenko 4301616b27 libbb: getopt32() should not ever touch argv[0] (even read) 2008-08-20 00:15:42 +00:00
Denis Vlasenko 1c45a505eb libbb: fix mishandling of "all argv are opts" in getopt32()
function                                             old     new   delta
top_main                                            1100    1095      -5
getopt32                                            1398    1361     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-42)             Total: -42 bytes
2008-08-20 00:12:22 +00:00
Denis Vlasenko 6c4eb44113 ifupdown: fixes for shutdown of DHCP-managed interfaces
from Wade Berrier <wberrier AT gmail.com>
2008-08-19 23:02:23 +00:00
Denis Vlasenko 625ed8e027 Updating defconfig, fixing a typo in Config.in 2008-08-19 22:26:05 +00:00
Bernhard Reutner-Fischer c77e843c09 - add new applet rdev (Grant Erickson)
- fixes and shrink (me)
2008-08-19 11:28:52 +00:00
Denis Vlasenko d7cc2e601d showkey: new applet by Vladimir 2008-08-17 14:17:48 +00:00
Denis Vlasenko c8d02aa959 setfont: new applet by Vladimir 2008-08-17 14:12:26 +00:00
Denis Vlasenko eb084779d7 libbb: use ptsname_r, it's smaller
function                                             old     new   delta
xgetpty                                               91      81     -10
ptsname                                               33       -     -33

   text    data     bss     dec     hex filename
 793828     592    6692  801112   c3958 busybox_old
 793796     592    6660  801048   c3918 busybox_unstripped
2008-08-17 12:47:19 +00:00
Denis Vlasenko 34c73c499b ash: fix "(cat < file)" hang introduced by rev 22944. 2008-08-16 11:48:02 +00:00
Denis Vlasenko 8334db13c3 cut: fix buffer overflow (bug 4544). 2008-08-15 21:20:23 +00:00
Denis Vlasenko 69ed30928e chpst: fix "envdir dir" case (bug 4574). 2008-08-15 21:03:17 +00:00
Denis Vlasenko ec7e7aec8a arp: without -H <type>, assume "ether". closes 4564 2008-08-15 20:14:23 +00:00
Denis Vlasenko c80191c1d9 install: fix long option not taking params (bug 4584) 2008-08-15 19:56:24 +00:00
Denis Vlasenko 11152e30e3 mkdir: fix "uname 0222; mkdir foo/bar" case
(by Doug Graham <dgraham AT nortel.com>)

function                                             old     new   delta
bb_make_directory                                    291     280     -11
2008-08-15 19:18:35 +00:00
Denis Vlasenko cd785fb716 nmeter: fix read past the end if a buffer. Closes 4594 2008-08-14 21:57:43 +00:00
Denis Vlasenko ee777c4e5f ifupdown: fixes for custom MAC address, by Wade Berrier <wberrier AT gmail.com> 2008-08-12 01:35:34 +00:00
Denis Vlasenko 8d07560eef sendmail: work around (bogus) gcc warning 2008-08-10 20:46:39 +00:00
Denis Vlasenko 63e49fa56f fix byte-swapping of compressed help on big-endian machines 2008-08-09 20:31:57 +00:00
Denis Vlasenko 69f4f9a6f4 optimize config_read() (by Timo Teras <timo.teras AT iki.fi>)
function                                             old     new   delta
bb_get_chunk_with_continuation                         -     176    +176
find_pair                                            169     187     +18
...
process_stdin                                        443     433     -10
config_read                                          549     456     -93
bb_get_chunk_from_file                               139       7    -132
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/7 up/down: 215/-254)          Total: -39 bytes
2008-08-09 17:16:40 +00:00
Denis Vlasenko 3fd15e197e grep: option to use GNU regex matching instead of POSIX one.
This fixes problems with NULs in files being scanned, but
 costs +800 bytes. The same can be done to sed (TODO).
2008-08-09 16:15:14 +00:00
Bernhard Reutner-Fischer fb5902ca5c - support relatime / norelatime 2008-08-06 18:14:38 +00:00
Bernhard Reutner-Fischer 1dbc643dd3 - fix typo 2008-08-06 17:39:30 +00:00
Denis Vlasenko 8e80411151 modprobe-small: fix infinite looping, by Timo Teras 2008-08-06 09:41:09 +00:00
Denis Vlasenko 728161b556 fix bug 4464 for real. I am dumb. 2008-08-06 08:44:09 +00:00
Denis Vlasenko 9ddc0045ec modprobe: semi-trivial code shrink
function                                             old     new   delta
build_dep                                            870     859     -11
already_loaded                                       134     112     -22
modprobe_main                                        449     368     -81
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-114)           Total: -114 bytes
2008-08-06 00:51:43 +00:00
Denis Vlasenko 2afd5ab62c *: use get_console_fd() as appropriate, and make it fail on open error -
get_console_fd_or_die().

function                                             old     new   delta
get_console_fd_or_die                                  -     163    +163
loadkmap_main                                        211     201     -10
loadfont_main                                        440     430     -10
dumpkmap_main                                        218     208     -10
kbd_mode_main                                        158     146     -12
setkeycodes_main                                     156     143     -13
get_console_fd                                       163       -    -163
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/5 up/down: 163/-218)          Total: -55 bytes
2008-08-05 23:32:27 +00:00
Denis Vlasenko e0143a1aad kbd_mode: remove erroneous & from &var. By Vladimir. 2008-08-05 23:01:01 +00:00
Denis Vlasenko db29f5e73e libbb: fix thinko in latest xrealloc_vector change 2008-08-05 21:12:00 +00:00
Bernhard Reutner-Fischer e6ce824edd - reinstate commented out _FORTIFY_SOURCE that was somehow dropped by Denys? 2008-08-05 19:06:35 +00:00
Denis Vlasenko ec73d30322 randomconfig fixes 2008-08-05 17:43:29 +00:00
Denis Vlasenko 0e7f28d674 man: teach it to use .lzma if requested by .config
man: fix a case when a full pathname to manpage is given
2008-08-05 15:28:05 +00:00
Denis Vlasenko e2a09de415 man: yet another fixlet to "manpage link" code 2008-08-05 14:15:19 +00:00
Denis Vlasenko 22b0bd85fd man: fixlet for man links 2008-08-05 13:45:22 +00:00
Denis Vlasenko 540baf646a man: add handling of "man links", by Ivana Varekova <varekova AT redhat.com>
function                                             old     new   delta
run_pipe                                             102     354    +252
show_manpage                                           -     126    +126
man_main                                             705     615     -90
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 378/-90)           Total: 288 bytes
2008-08-05 13:16:18 +00:00
Denis Vlasenko e9ad84dfd4 *: refactor handling of archived files. "tar f file.tar.lzma" now works too.
function                                             old     new   delta
unpack_Z_stream                                        -    1229   +1229
open_zipped                                            -     176    +176
unpack_bz2_stream_prime                                -      60     +60
tar_main                                             642     677     +35
find_main                                            406     418     +12
sv_main                                             1222    1233     +11
decode_format_string                                 829     837      +8
cmp_main                                             641     649      +8
popstring                                            134     140      +6
filter_accept_list_reassign                          120     125      +5
parse_and_put_prompt                                 800     804      +4
passwd_main                                         1053    1049      -4
make_new_name_gunzip                                 119     114      -5
rpm_main                                            1688    1670     -18
prepare                                              302     283     -19
xmalloc_open_zipped_read_close                       135      61     -74
uncompress                                          1229       -   -1229
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 8/5 up/down: 1554/-1349)        Total: 205 bytes
2008-08-05 13:10:34 +00:00
Bernhard Reutner-Fischer 9b44613202 - don't free user-supplied string (via -e)
- fix helptext

function                                             old     new   delta
chpasswd_main                                        300     319     +19
packed_usage                                       24352   24344      -8
.rodata                                           122227  122195     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 19/-40)            Total: -21 bytes
2008-08-05 09:56:56 +00:00
Denis Vlasenko 35d8c47987 whitespace fixes, no code changed 2008-08-05 07:59:25 +00:00
Denis Vlasenko 82ad032e26 xargs: fix -e default to match newer GNU xargs, add SUS mandated -E.
closes bug 4414
2008-08-04 21:30:55 +00:00
Denis Vlasenko 855ff6f503 modprobe: use buffering line reads (fgets) instead of reads().
libbb: remove reads()

function                                             old     new   delta
include_conf_file_act                                961     980     +19
localcmd                                             282     284      +2
already_loaded                                       155     151      -4
in_cksum                                              58      53      -5
modprobe_main                                       1630    1624      -6
reads                                                129       -    -129
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/3 up/down: 21/-144)          Total: -123 bytes
2008-08-04 21:16:46 +00:00
Denis Vlasenko 5db861a9eb fix some testsuite false positives 2008-08-04 14:40:58 +00:00
Denis Vlasenko 27842288b3 libbb: make xrealloc_vector zero out the realloc'ed tail
function                                             old     new   delta
xrealloc_vector_helper                                51      76     +25
man_main                                             712     705      -7
act                                                  250     234     -16
create_list                                           91      70     -21
getopt_main                                          695     664     -31
load_dep_bb                                          281     248     -33
fileAction                                           744     709     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 25/-143)          Total: -118 bytes
2008-08-04 13:20:36 +00:00
Denis Vlasenko 2b576b8e76 hush: fix mishandling of a'b'c=fff as assignments. They are not.
function                                             old     new   delta
parse_stream                                        1920    2004     +84
done_word                                            715     752     +37
parse_and_run_stream                                 328     333      +5
builtin_exec                                          25      29      +4
pseudo_exec_argv                                     138     139      +1
run_list                                            2006    1999      -7
is_assignment                                        215     134     -81
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/2 up/down: 131/-88)            Total: 43 bytes
2008-08-04 00:46:07 +00:00
Denis Vlasenko c8bec9a085 hush: remove a comment about already fixed bug 2008-08-03 22:27:50 +00:00
Denis Vlasenko b2dc913527 makedevs: shrink by Vladimir
function                                             old     new   delta
makedevs_main                                       1071    1049     -22
packed_usage                                       24744   24708     -36
2008-08-03 22:14:02 +00:00
Denis Vlasenko 7ce47e698e ssd: fix -K/-S mixup in help text 2008-08-03 19:23:30 +00:00
Denis Vlasenko c45b53940a xargs: update help text 2008-08-03 19:20:25 +00:00
Denis Vlasenko cc08ad26fe xargs: fix xargs -e; added test for that 2008-08-03 19:12:25 +00:00
Denis Vlasenko 1e28f6171f halt: signal init regardless of ENABLE_INIT 2008-08-03 18:43:45 +00:00
Denis Vlasenko cfe2936a73 nameif: shrink (by Vladimir)
function                                             old     new   delta
nameif_main                                          668     636     -32
2008-08-01 02:32:23 +00:00
Denis Vlasenko 9ef1a5ddc1 makedevs: fix help text discrepancies 2008-08-01 02:15:51 +00:00
Denis Vlasenko e1fa817995 makedevs: shrink (by Vladimir); testsuite
function                                             old     new   delta
makedevs_main                                       1153    1071     -82
2008-08-01 02:15:05 +00:00
Denis Vlasenko d498131168 hush: support $_NUMBERS variable names 2008-07-31 10:34:48 +00:00
Denis Vlasenko f173607520 hush: fix "case ... in <newline> word)..." 2008-07-31 10:09:26 +00:00
Denis Vlasenko fbeeb328b8 hush: support "pattern1|pattern2...)" in case statements
parse_stream                                        1847    1861     +14
run_list                                            1995    2006     +11
2008-07-31 00:17:01 +00:00
Denis Vlasenko 20be63fe71 tr: fix yet another access past the end of a string (bug 4374) 2008-07-30 22:58:18 +00:00
Denis Vlasenko b357149867 chpst: large code shrink by Vladimir
function                                             old     new   delta
chpst_main                                          1058    1357    +299
euidgid                                               56       -     -56
suidgid                                               59       -     -59
slimit                                               208       -    -208
packed_usage                                       24638   24420    -218
edir                                                 375       -    -375
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 1/1 up/down: 299/-916)         Total: -617 bytes
2008-07-30 21:23:26 +00:00
Denis Vlasenko c90e1be01b ash: bash compat: "shift $BIGNUM" is equivalent to "shift 1" 2008-07-30 15:35:05 +00:00
Denis Vlasenko 4f504a9e57 hush: trivial code shrink
function                                             old     new   delta
builtin_continue                                      48      22     -26
2008-07-29 19:48:30 +00:00
Denis Vlasenko 87a8655f46 hush: use G.xxx instead of #define xxx G.xxx. We have too many globals
there and #defines get messy. Remove one write-only G.variable.
2008-07-29 19:43:10 +00:00
Denis Vlasenko ff29b4fc42 randomconfig fix 2008-07-29 13:57:59 +00:00
Denis Vlasenko 4554b721ad hush: small fix for repeated continue and fix for wrong loop depth count
after Ctrl-C; with testcase for first one
2008-07-29 13:36:09 +00:00
Denis Vlasenko 45cb9f9581 hush: fix inverted check (was making all break's to act as "break 99999") 2008-07-29 11:47:46 +00:00
Denis Vlasenko fcf37c3183 hush: fix break'ing out of {} and () groups; with testcase
function                                             old     new   delta
builtin_break                                         93     129     +36
builtin_continue                                      21      47     +26
run_list                                            1973    1976      +3
2008-07-29 11:37:15 +00:00
Denis Vlasenko d91afa33fd randomconfig fixes 2008-07-29 11:10:01 +00:00
Denis Vlasenko dadfb4975b hush: add #defines to switch off break/continue if loops are not supported
*: remove a few inline keywords
no code changes
2008-07-29 10:16:05 +00:00
Denis Vlasenko e1ee48e0fd modprobe: support for /etc/modprobe.d, by Timo Teras.
function                                             old     new   delta
include_conf_file_act                                  -     929    +929
include_conf_recursive                                 -      30     +30
include_conf_file2                                     -      30     +30
include_conf_file                                      -      14     +14
include_conf_dir_act                                   -      14     +14
build_dep                                           1011     875    -136
include_conf                                         922       -    -922
------------------------------------------------------------------------------
(add/remove: 5/1 grow/shrink: 0/1 up/down: 1017/-1058)        Total: -41 bytes
2008-07-29 00:19:44 +00:00
Denis Vlasenko 2f86d13dff libbb: dump: do not use uninitialized memory. close bug 4364. 2008-07-29 00:00:14 +00:00
Denis Vlasenko 043d15da31 tr: fix "tr [=" case. Closes bug 4374.
function                                             old     new   delta
expand                                              1701    1738     +37
tr_main                                              472     474      +2
2008-07-28 23:49:42 +00:00
Denis Vlasenko 918a34b9e0 hush: fix "while false; ..." exitcode; add testsuites 2008-07-28 23:17:31 +00:00
Denis Vlasenko 6a2d40f239 hush: support "break N" and "continue N"
fix non-detection of builtins and applets in "v=break; ...; $v; ..." case
 add testsuite entries for the above

function                                             old     new   delta
builtin_break                                         12      93     +81
run_list                                            1948    1971     +23
builtin_continue                                      12      21      +9
pseudo_exec_argv                                     132     138      +6
builtin_exec                                          23      25      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 121/0)             Total: 121 bytes
2008-07-28 23:07:06 +00:00
Denis Vlasenko bcb25537d0 hush: implement break and continue
function                                             old     new   delta
bltins                                               252     276     +24
builtin_continue                                       -      12     +12
builtin_break                                          -      12     +12
static.version_str                                    18      17      -1
run_list                                            1984    1948     -36
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/2 up/down: 48/-27)             Total: 11 bytes
2008-07-28 23:04:34 +00:00
Denis Vlasenko cf22c89f9a hush: in run_list(), some loop_top ops seems to be superfluous.
comment them out. Also, use separate temp variable
 for verification loop, helps gcc to optimize better.

function                                             old     new   delta
run_list                                            2039    1984     -55
2008-07-28 15:17:44 +00:00
Denis Vlasenko 12acec5ad4 hush: in run_list(), last_cond_code seems to be superfluous. comment it out
function                                             old     new   delta
run_list                                            2055    2039     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16)             Total: -16 bytes
2008-07-28 15:15:59 +00:00
Denis Vlasenko 5e052cab17 hush: explain run_list() in detail; small optimizations
function                                             old     new   delta
hush_main                                            785     786      +1
expand_variables                                    1447    1448      +1
builtin_exit                                          48      49      +1
builtin_eval                                          54      55      +1
run_list                                            2075    2055     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 4/-20)             Total: -16 bytes
2008-07-28 15:15:09 +00:00
Denis Vlasenko 38c89210d6 documentation fix 2008-07-28 00:06:02 +00:00
Denis Vlasenko be709c24d4 hush: finish and enable optional case...esac support. Code size cost:
function                                             old     new   delta
run_list                                            1891    2075    +184
parse_stream                                        1764    1847     +83
expand_strvec_to_string                                -      83     +83
done_word                                            647     715     +68
static.reserved_list                                 144     168     +24
static.reserved_match                                  -      12     +12
done_pipe                                             95     105     +10
builtin_exit                                          48      46      -2
builtin_eval                                         127      54     -73
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/2 up/down: 464/-75)           Total: 389 bytes
2008-07-28 00:01:16 +00:00
Denis Vlasenko 8d523cbcd7 fbset: shrink code a bit more 2008-07-27 21:16:30 +00:00
Denis Vlasenko 09f5ecfa47 fbset: code shrink
function                                             old     new   delta
ss                                                     -      33     +33
fbset_main                                          1968    1844    -124
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 33/-124)           Total: -91 bytes
2008-07-27 20:25:29 +00:00
Denis Vlasenko 2c7a1fd6d4 netstat: code shrink
function                                             old     new   delta
print_inet_line                                        -     193    +193
scan_inet_proc_line                                    -     130    +130
unix_do_one                                          519     503     -16
do_info                                              145      97     -48
netstat_main                                         601     548     -53
tcp_do_one                                           462      61    -401
raw_do_one                                           513     107    -406
udp_do_one                                           533     119    -414
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/6 up/down: 323/-1338)       Total: -1015 bytes
2008-07-27 17:24:19 +00:00
Denis Vlasenko cf8b1ef845 style fix, no code changes 2008-07-27 14:15:42 +00:00
Denis Vlasenko 6e69e4237d netstat: optional -p support by L. Gabriel Somlo <somlo AT cmu.edu>
Without FEATURE_NETSTAT_PRG:
function                                             old     new   delta
recursive_action                                     416     425      +9
tcp_do_one                                           420     428      +8
udp_do_one                                           492     499      +7
raw_do_one                                           472     479      +7
expand                                              1697    1701      +4
netstat_main                                         489     492      +3
unix_do_one                                          486     488      +2
flags                                                  1       -      -1
qgravechar                                           109     106      -3
net_conn_line                                          4       -      -4
bbunpack                                             391     383      -8
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 7/2 up/down: 40/-16)             Total: 24 bytes

With FEATURE_NETSTAT_PRG:
file_act                                               -     213    +213
dir_act                                                -     192    +192
netstat_main                                         489     601    +112
prg_cache_get                                          -      50     +50
tcp_do_one                                           420     462     +42
udp_do_one                                           492     533     +41
raw_do_one                                           472     513     +41
unix_do_one                                          486     519     +33
recursive_action                                     416     425      +9
expand                                              1697    1701      +4
flags                                                  1       -      -1
qgravechar                                           109     106      -3
net_conn_line                                          4       -      -4
bbunpack                                             391     383      -8
packed_usage                                       24586   24572     -14
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 7/3 up/down: 737/-30)           Total: 707 bytes
2008-07-27 12:10:07 +00:00
Denis Vlasenko 94d03f0da0 whitespace fix 2008-07-26 23:16:33 +00:00
Denis Vlasenko c24033eebe man: a forgotten chunk of lask commit (config file parser fixes) 2008-07-26 23:14:23 +00:00
Denis Vlasenko 084266ed52 fix several problems with config parser:
a bug where it underflows the string
 a bug where it never frees parser_t struct
make read_config() return 0 if parser is NULL,
 make config_close() accept and ignore NULL parser -
 eliminates many if() blocks
reverse the sense of parser bit flags - negative flags
 are harder to grok.
hexdump: revert the change to use config parser, it is BIGGER
 and also requires additional quirks in parser
*: explicitly use PARSER_NORMAL instead of 0

function                                             old     new   delta
login_main                                          1575    1596     +21
config_close                                          18      29     +11
bbunpack                                             383     391      +8
qgravechar                                           106     109      +3
rtnl_tab_initialize                                  121     117      -4
expand                                              1697    1693      -4
man_main                                             717     712      -5
nameif_main                                          674     668      -6
hexdump_main                                         597     591      -6
read_config                                          217     209      -8
dnsd_main                                           1478    1470      -8
sysctl_main                                          203     189     -14
config_open2                                          44      25     -19
make_device                                         1177    1141     -36
config_read                                          597     549     -48
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/11 up/down: 43/-158)         Total: -115 bytes
2008-07-26 23:08:31 +00:00
Denis Vlasenko 8895c2073e man: ignore (not complain) lines with less than 2 tokens
in config file
2008-07-26 19:44:53 +00:00
Denis Vlasenko 5e40070d38 tr: fix "access past the end of a string" bug 4354 2008-07-26 19:34:00 +00:00
Denis Vlasenko df96df9c7c mdev: do not complain if mdev.conf does not exist;
use #if to prevent gcc from generating dead code
 (sadly, it's more ugly this way)
2008-07-26 18:35:10 +00:00
Denis Vlasenko 48a9971bd4 unzip: move check for unsupported zip features to better place 2008-07-26 17:32:41 +00:00
Denis Vlasenko c2dcb7cf63 unzip: give better error message when presented with unsupported
zip file. Add zip documentation and an example of file we cant
 (yet) unpack.
2008-07-26 16:50:24 +00:00
Denis Vlasenko 8dbea7dbb1 ash: add slightly different testcase 2008-07-26 14:20:04 +00:00
Denis Vlasenko 160e6fa53a fix example of vcsa creation 2008-07-26 14:02:24 +00:00
Denis Vlasenko 5c13270359 ash: fix testcase to not sleep for whole 10 seconds,
gets annoying pretty fast. Also fix wrong message there.
2008-07-26 13:53:42 +00:00
Denis Vlasenko 87d5fd984e ash: fix typo 2008-07-26 13:48:35 +00:00
Denis Vlasenko 4e19a9c81a ash: hopefully close bug 4324. With testcase.
function                                             old     new   delta
evaltree                                             621     869    +248
popstring                                            134     140      +6
2008-07-26 13:45:57 +00:00
Denis Vlasenko 2b2e267b43 ash: testsuite entries for last change 2008-07-25 13:40:06 +00:00
Denis Vlasenko 6a0ad25061 ash: dont allow e.g. exec <&10 to attach to stript's fd!
function                                             old     new   delta
is_hidden_fd                                           -      61     +61
redirect                                            1135    1164     +29
popstring                                            134     140      +6
printf_main                                          635     637      +2
evalvar                                             1374    1376      +2
echo_main                                            294     296      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/0 up/down: 102/0)             Total: 102 bytes
2008-07-25 13:34:05 +00:00
Denis Vlasenko 0f99d49ae6 *: conversion to config parser
function                                             old     new   delta
config_read                                          540     597     +57
config_open2                                          41      44      +3
rtnl_rtprot_initialize                                70      66      -4
rtnl_rttable_initialize                               78      73      -5
rtnl_rtscope_initialize                               88      83      -5
rtnl_rtrealm_initialize                               48      43      -5
rtnl_rtdsfield_initialize                             48      43      -5
process_module                                       566     560      -6
bbunpack                                             391     383      -8
rtnl_tab_initialize                                  279     121    -158
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/8 up/down: 60/-196)          Total: -136 bytes
2008-07-24 23:38:04 +00:00
Denis Vlasenko 22f7414843 ash: prevent exec NN>&- from closing fd used for script reading 2008-07-24 22:34:43 +00:00
Denis Vlasenko 5a867317bb ash: fix a bug where redirection fds were not closed afterwards.
optimize close+fcntl(DUPFD) into dup2. add testsuites.

function                                             old     new   delta
copyfd                                                47      68     +21
argstr                                              1311    1298     -13
popredir                                             148     131     -17
redirect                                            1139    1107     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 21/-62)            Total: -41 bytes
2008-07-24 19:46:38 +00:00
Denis Vlasenko 6fbb43bc3c ash: teach ash about 123>file. It could take only 0..9 before
function                                             old     new   delta
redirect                                            1052    1139     +87
need_to_remember                                       -      36     +36
popredir                                             132     148     +16
fixredir                                              86     101     +15
readtoken1                                          3130    3143     +13
evalvar                                             1374    1376      +2
popstring                                            140     134      -6
cmdtxt                                               592     561     -31
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/2 up/down: 169/-37)           Total: 132 bytes
2008-07-24 19:44:41 +00:00
Denis Vlasenko 6514c5e35c ash: ducument where "no fds > 9 in redirects" limitation is.
no code changes.
2008-07-24 13:41:37 +00:00
Denis Vlasenko 8d924ecf38 ash: ditch dupredirect(), it was only making code harder to read.
incorporate it in its single callsite.

function                                             old     new   delta
redirect                                            1054    1052      -2
changepath                                           196     194      -2
2008-07-24 11:34:27 +00:00
Denis Vlasenko 0b76964ae1 ash: explain redirect code a bit
function                                             old     new   delta
redirect                                            1059    1054      -5
2008-07-24 07:54:57 +00:00
Denis Vlasenko 2dc240c0d6 ash: code shrink
function                                             old     new   delta
copynode                                             171     180      +9
evaltreenr                                           615     621      +6
evaltree                                             615     621      +6
calcsize                                             121     127      +6
evalpipe                                             349     350      +1
redirect                                            1059    1057      -2
parseheredoc                                         129     126      -3
makename                                              35      32      -3
expredir                                             130     127      -3
parsefname                                           224     219      -5
popstring                                            140     134      -6
pipeline                                             276     268      -8
list                                                 360     351      -9
readtoken1                                          3157    3130     -27
parse_command                                       1504    1460     -44
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/10 up/down: 28/-110)          Total: -82 bytes
2008-07-24 06:07:50 +00:00
Denis Vlasenko 49a5eba9ae s/othervise/otherwise/g 2008-07-23 08:41:08 +00:00
Denis Vlasenko 040e32f84c lpd: extend help text
function                                             old     new   delta
packed_usage                                       24466   24612    +146
2008-07-23 08:39:19 +00:00
Denis Vlasenko f54e62a3f2 inetd: do not trash errno in signal handlers;
in CHLD handler, stop looping through services when pid is found

function                                             old     new   delta
reread_config_file                                  1072    1092     +20
retry_network_setup                                   55      69     +14
reap_child                                           132     130      -2
2008-07-22 20:57:28 +00:00
Denis Vlasenko 41660c5b2d another overlapping_strcpy 2008-07-22 20:25:24 +00:00
Denis Vlasenko 0f293b96dc fix all cases of strcpy on overlapping strings. 2008-07-22 20:16:55 +00:00
Denis Vlasenko 68a192c007 fix trivial build warning 2008-07-22 19:38:57 +00:00
Denis Vlasenko c445758708 lpd,lpr: send/receive ACKs after filenames, not only after file bodies.
lpqr_main                                           1114    1149     +35
lpd_main                                             748     768     +20
2008-07-22 19:15:30 +00:00
Bernhard Reutner-Fischer e99a92dc2f - strip implied proto and superfluous "www." domain part.
If my lynx groks it, your browser will too ;)
2008-07-22 18:32:06 +00:00
Bernhard Reutner-Fischer 3e8669f359 - wrap overlong lines (Cristian Ionescu-Idbohrn)
- s/\.  /. /g;# (me)
2008-07-22 18:27:53 +00:00
Denis Vlasenko 08d120e6e1 chown: do not use static data
function                                             old     new   delta
chown_main                                           160     182     +22
fileAction                                           750     744      -6
ugid                                                   8       -      -8
2008-07-22 11:37:23 +00:00
Denis Vlasenko 9e3a540b1b cut: stop using static data. This alone removed ~70 bytes of code.
+ some optimizations

function                                             old     new   delta
nlists                                                 4       -      -4
cut_lists                                              4       -      -4
cut_main                                            1041     960     -81
2008-07-22 10:34:46 +00:00
Denis Vlasenko a5254032f5 cal: remove lone static data variable. -4 bytes. coreutils
is down to four applets with nonzero data+bss.
2008-07-22 10:10:13 +00:00
Bernhard Reutner-Fischer b62bd7b261 - unused variables if !ENABLE_FEATURE_MDEV_RENAME_REGEXP 2008-07-22 07:33:53 +00:00
Denis Vlasenko 5415c856ea libbb: [x]fopen_for_{read,write} introduced and used.
(by Valdimir)

function                                             old     new   delta
config_open2                                           -      41     +41
config_read                                          507     542     +35
find_pair                                            169     187     +18
fopen_for_write                                        -      14     +14
fopen_for_read                                         -      14     +14
find_main                                            406     418     +12
xfopen_for_write                                       -      10     +10
xfopen_for_read                                        -      10     +10
popstring                                            134     140      +6
parse_inittab                                        396     401      +5
next_token                                           923     928      +5
pack_gzip                                           1659    1661      +2
bb__parsespent                                       117     119      +2
fallbackSort                                        1719    1717      -2
evalvar                                             1376    1374      -2
qrealloc                                              36      33      -3
...
...
...
...
singlemount                                         4579    4569     -10
process_stdin                                        443     433     -10
patch_main                                          1111    1101     -10
ifupdown_main                                       2175    2165     -10
file_action_grep                                      90      80     -10
uuidcache_init                                       649     637     -12
hush_main                                            797     785     -12
read_config                                          230     217     -13
dpkg_main                                           3835    3820     -15
read_line_input                                     3134    3110     -24
sysctl_main                                          232     203     -29
config_open                                           40      10     -30
WARN_BAD_LINE                                         44       -     -44
login_main                                          1714    1575    -139
------------------------------------------------------------------------------
(add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737)        Total: -563 bytes
2008-07-21 23:05:26 +00:00
Denis Vlasenko b74a2dba57 whitespace fixes, no code changed 2008-07-21 21:34:51 +00:00
Bernhard Reutner-Fischer 1d4cd606a1 - commentary typo fix 2008-07-21 15:29:36 +00:00
Bernhard Reutner-Fischer d73cbd31a2 - first pass to unify/cleanup uid handling (-236b)
This needs further love, alot of love.. Tito?
2008-07-21 14:41:33 +00:00
Bernhard Reutner-Fischer a53de7f7c2 - fix spelling 2008-07-21 13:46:54 +00:00
Bernhard Reutner-Fischer e1e5174942 - s/super.block/superblock/g; # for consistency; -1b 2008-07-21 13:33:22 +00:00
Bernhard Reutner-Fischer 5259361957 - remove superfluous forward declaration 2008-07-21 11:53:04 +00:00
Bernhard Reutner-Fischer ef9876a40e - document -f 2008-07-21 11:30:51 +00:00
Bernhard Reutner-Fischer 0328b40aee - commentary typo fix 2008-07-21 11:18:02 +00:00
Bernhard Reutner-Fischer ad2fa65fc0 - no obj-code changes. Fix indentation, use existing defines. 2008-07-21 11:16:39 +00:00
Denis Vlasenko 1101d1c980 telnet: shrink
telnetd: shrink, and fix issue file printing
test: better and shorter usage text

function                                             old     new   delta
putiac2                                               51      50      -1
putiac                                                24      20      -4
handlenetoutput                                       95      91      -4
telnet_main                                         1480    1475      -5
iacflush                                              37      32      -5
make_new_session                                     436     421     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-34)             Total: -34 bytes
2008-07-21 09:22:28 +00:00
Denis Vlasenko 84c8daa11f help text: test --help doesnt print it (by design),
so do not account for it
2008-07-21 08:37:13 +00:00
Denis Vlasenko 395410b748 httpd: add Hopedir directive specially for
(and by) walter harms <wharms AT bfs.de>;
 fix silly double-parse bug added in 21412.

function                                             old     new   delta
parse_conf                                          1532    1576     +44
2008-07-20 23:25:32 +00:00
Denis Vlasenko 7ae1cc16b4 msh: fix "while...continue" bug 3884. 2008-07-20 23:03:23 +00:00
Denis Vlasenko 2b68c8f744 build system: clean more files on make clean/make mrproper 2008-07-20 18:37:54 +00:00
Denis Vlasenko eb7512984a udhcp: use libbb for config file parsing (by Vladimir)
function                                             old     new   delta
read_config                                          313     230     -83
2008-07-20 17:58:12 +00:00
Denis Vlasenko 9b366f4136 libbb/parse_config.c: fix small buglet (by Vladimir) 2008-07-20 17:50:58 +00:00
Denis Vlasenko a34f1ed737 dnsd,sestatus: use libbb to parse config file (by Vladimir)
function                                             old     new   delta
dnsd_main                                           1544    1487     -57
2008-07-20 17:48:59 +00:00
Denis Vlasenko 1e8034e614 man: fix breakage: must not die on lines with < 2 tokens 2008-07-20 17:43:21 +00:00
Denis Vlasenko 09aaf78ad5 mn: use libbb for config parsing (by Vladimir)
function                                             old     new   delta
man_main                                             757     713     -44
2008-07-20 17:41:30 +00:00
Denis Vlasenko adc772a5f2 tar: fix handling of tarballs with symlinks with size field != 0 2008-07-20 17:10:43 +00:00
Denis Vlasenko b9bbc40f64 libbb: fix print_flags() [fix somehow is only in 1.11.1?) 2008-07-20 13:47:51 +00:00
Denis Vlasenko 4a717e0c19 libbb: fixes to config_read() by maintainer
sysctl: use config_read()

function                                             old     new   delta
sysctl_main                                          121     232    +111
config_read                                          478     502     +24
parse_main                                           239     241      +2
sysctl_preload_file_and_exit                         234       -    -234
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/0 up/down: 137/-234)          Total: -97 bytes
2008-07-20 13:01:56 +00:00
Denis Vlasenko dcb3fcb042 libbb: config_read() update 2008-07-19 22:57:00 +00:00
Denis Vlasenko c29684afd6 mount: support nfs mount option nordiplus.
By Octavian Purdila <opurdila AT ixiacom.com>

function                                             old     new   delta
static.options                                       272     281      +9
daemonize                                            130     107     -23
singlemount                                         4674    4579     -95
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 9/-118)           Total: -109 bytes
2008-07-19 22:40:30 +00:00
Denis Vlasenko 2e157ddf9e libbb: updated config_parse() from Vladimir
function                                             old     new   delta
config_read                                          385     460     +75
runsvdir_main                                       1701    1716     +15
readit                                               331     338      +7
passwd_main                                         1049    1053      +4
parse_command                                       1504    1507      +3
decode_format_string                                 822     824      +2
bb__parsespent                                       117     119      +2
udhcp_get_option                                     221     222      +1
changepath                                           196     194      -2
parse_inittab                                        400     396      -4
nameif_main                                          683     679      -4
make_device                                         1176    1172      -4
config_open                                           48      40      -8
expand_main                                          698     689      -9
readcmd                                             1012    1002     -10
config_free_data                                      37      21     -16
SynchronizeFile                                      683     643     -40
sleep_main                                           474     362    -112
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/10 up/down: 109/-209)        Total: -100 bytes
2008-07-19 09:27:19 +00:00
Denis Vlasenko bd28f6bf7f test: fix parser to prefer binop over unop, as coreutils does.
remove bogus workaround in main(). rename atrocious variables/functions.
 much expand testsuite.
libbb: fix --help to not affect "test --help"

function                                             old     new   delta
run_applet_no_and_exit                               421     440     +19
nexpr                                                817     825      +8
static.no_op                                           -       6      +6
test_main                                            397     257    -140
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/1 up/down: 104/-211)         Total: -107 bytes
2008-07-19 08:15:13 +00:00
Denis Vlasenko 5f116629d8 printf: do not print garbage on "%Ld". closes bug 4214.
function                                             old     new   delta
printf_main                                          633     637      +4
multiconvert                                          99      79     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-20)             Total: -16 bytes
2008-07-18 18:41:55 +00:00
Denis Vlasenko f19817ddc2 libbb: fix bb_strtol[l]'s check for "-". Hopefully closes bug 4174
function                                             old     new   delta
bb_strtol                                             82      85      +3
handle_errors                                         75      66      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-9)               Total: -6 bytes
2008-07-18 18:17:10 +00:00
Denis Vlasenko a48656b441 printf: fix %b, fix several bugs in %*.*, fix compat issues with
aborting too early, support %zd; expand testsuite

function                                             old     new   delta
get_width_prec                                         -      46     +46
multiconvert                                          82      99     +17
conv_strtod                                           44      54     +10
print_direc                                          382     391      +9
printf_main                                          629     633      +4
conv_strtoul                                          20      16      -4
conv_strtol                                           20      16      -4
my_xstrtoul                                           20       -     -20
my_xstrtol                                            20       -     -20
my_xstrtod                                            21       -     -21
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 4/2 up/down: 86/-69)             Total: 17 bytes
2008-07-18 11:10:51 +00:00
Bernhard Reutner-Fischer 1a715e487d - fix compilation for mips (Brian Daniels) 2008-07-18 07:42:00 +00:00
Denis Vlasenko 7b54dc788c vi: using array data after it fell out of scope is stupid. 2008-07-17 21:32:32 +00:00
Denis Vlasenko 7354244c4a sendmail: update from the maintainer 2008-07-17 19:37:09 +00:00
Denis Vlasenko 3b3ca113ed pidof/killall: allow find_pid_by_name to find running
processes started as scripts_with_name_longer_than_15_bytes.sh
 closes bug 4054 (and is generally neat)
2008-07-17 18:39:36 +00:00
Denis Vlasenko 18875bf772 update README 2008-07-17 18:33:35 +00:00
Denis Vlasenko bc06fb27d2 build system: fix indentation in config menu 2008-07-17 18:26:45 +00:00
Denis Vlasenko a474b68991 init: fix compile-time error; fix exiting on broken config file
parse_config: cosmetics
2008-07-17 17:58:44 +00:00
Bernhard Reutner-Fischer 02a1c6a7c3 - very minor shrinkage (-9b) 2008-07-17 15:13:31 +00:00
Bernhard Reutner-Fischer 54d50a0b47 - fix "noreduce" flag of config_read (didn't work at all, at least for me).
- convert init's inittab parsing to the new config parser:
function                                             old     new   delta
config_read                                          393     386      -7
static.actions                                        72      64      -8
.rodata                                           121772  121764      -8
parse_inittab                                        554     393    -161
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-184)           Total: -184 bytes
2008-07-17 14:00:42 +00:00
Bernhard Reutner-Fischer 679212836a - fix segfault in nameif with mactab file
(by fixing and shrink config parser)

function                                             old     new   delta
config_free_data                                       -      37     +37
config_open                                           43      48      +5
pack_gzip                                           1658    1660      +2
nameif_main                                          527     525      -2
SynchronizeFile                                      629     623      -6
make_device                                         1184    1176      -8
config_close                                          31      18     -13
config_read                                          431     393     -38
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/5 up/down: 44/-67)            Total: -23 bytes
2008-07-17 11:59:13 +00:00
Denis Vlasenko 0f683f818c printf: protect against bogus format specifiers. Hopefully closes bug 4184 2008-07-17 09:17:51 +00:00
Denis Vlasenko 416914fc61 bb_strtoXXX: close bug 4174 (potential use of buf[-1]) 2008-07-17 08:48:13 +00:00
Bernhard Reutner-Fischer 627052e75d - warn about overlong lines in help-texts
I initially bailed out with an error, but then that's a bit rough. Just warn to trick somebody into fixing them..
2008-07-17 08:02:28 +00:00
Denis Vlasenko c185e290ee config help fixes 2008-07-16 23:45:11 +00:00
Denis Vlasenko fb1642f2ca fix up callsites of config_read to check for >= 0 2008-07-16 23:04:49 +00:00
Denis Vlasenko c01340fe26 update of config file parser from Vladimir 2008-07-16 22:12:18 +00:00
Denis Vlasenko 38e54f1c13 sendmail: do not discard all headers 2008-07-16 21:55:03 +00:00
Denis Vlasenko 4d0cd28947 cpio: make long opts depend only on ENABLE_GETOPT_LONG 2008-07-16 21:51:43 +00:00
Denis Vlasenko d6817f5d8b install: do not chown intermediate directories with install -d; shrink
(by Natanael Copa)

function                                             old     new   delta
.rodata                                           171528  171511     -17
install_main                                         841     697    -144
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-161)           Total: -161 bytes
2008-07-16 21:49:02 +00:00
Denis Vlasenko 83cea0ef04 s/SELINIX/SELINUX/ 2008-07-16 21:11:09 +00:00
Denis Vlasenko 55f7912dda libbb: get rid of statics in dump.c; code shrinks a lot too
function                                             old     new   delta
alloc_dumper                                           -      26     +26
hexdump_main                                         600     601      +1
static.done                                            1       -      -1
static.ateof                                           1       -      -1
bb_dump_vflag                                          1       -      -1
static.savp                                            4       -      -4
static.nextfs                                          4       -      -4
static.curp                                            4       -      -4
exitval                                                4       -      -4
endfu                                                  4       -      -4
bb_dump_length                                         4       -      -4
bb_dump_fshead                                         4       -      -4
bb_dump_blocksize                                      4       -      -4
_argv                                                  4       -      -4
bb_dump_add                                          365     358      -7
savaddress                                             8       -      -8
eaddress                                               8       -      -8
bb_dump_skip                                           8       -      -8
address                                                8       -      -8
bb_dump_dump                                        2748    2672     -76
next                                                 538     445     -93
------------------------------------------------------------------------------
(add/remove: 1/16 grow/shrink: 1/3 up/down: 27/-247)         Total: -220 bytes
   text	   data	    bss	    dec	    hex	filename
 789458	    607	   6764	 796829	  c289d	busybox_old
 789309	    601	   6696	 796606	  c27be	busybox_unstripped
2008-07-16 11:00:16 +00:00
Denis Vlasenko 8ddb6410ed tee: fix infinite looping on open error (echo asd | tee "") 2008-07-16 07:34:00 +00:00
Denis Vlasenko bd9874db74 od,hexdump: fix bug where xrealloc may move pointer,
leaving other pointers dangling (bug 4104).
 + many style fixes in libbb/dump.c.
2008-07-16 07:22:14 +00:00
Denis Vlasenko 018bee6afb mdev: support for serializing hotplug
function                                             old     new   delta
mdev_main                                            503     647    +144
2008-07-15 22:33:13 +00:00
Denis Vlasenko 97faf531c8 sleep: make fractional seconds separately selectable in .config 2008-07-15 22:01:49 +00:00
Denis Vlasenko 5e476bab9c libbb: document plans to speed up line-based input 2008-07-15 21:29:44 +00:00
Denis Vlasenko e559e0a757 libbb: unified config parser (By Vladimir Dronnikov)
mdev: use it

function                                             old     new   delta
config_read                                            -     400    +400
config_open                                            -      43     +43
config_close                                           -       9      +9
qrealloc                                              33      36      +3
compare_keys                                         735     737      +2
xstrtoull_range_sfx                                  296     295      -1
qgravechar                                           109     106      -3
get_address                                          181     178      -3
next_token                                           928     923      -5
sv_main                                             1228    1222      -6
find_main                                            418     406     -12
next_field                                            32       -     -32
make_device                                         1269    1184     -85
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/7 up/down: 457/-147)          Total: 310 bytes
2008-07-15 21:09:30 +00:00
Denis Vlasenko 0ed090e184 sendmail: do not ignore CC; accept to: and cc: case-insensitively.
+20 bytes.
2008-07-15 20:56:23 +00:00
Denis Vlasenko 2132e02213 libbb: experimental faster string reading routines. 2008-07-15 10:33:12 +00:00
Denis Vlasenko bb13079c8e comm: almost total rewrite; add testsuite
function                                             old     new   delta
writeline                                            128     125      -3
comm_main                                            540     239    -301
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-304)           Total: -304 bytes
2008-07-15 06:45:14 +00:00
Denis Vlasenko 51f1b6c0e0 ls: fix a bug where we may use uninintialized variable 2008-07-15 05:21:47 +00:00
Denis Vlasenko 4b8171cd7a tee: "-" is a name for stdout, handle it that way 2008-07-15 05:10:15 +00:00
Denis Vlasenko 09ce45fd10 insmod: users report that "|| defined(__powerpc__)" is missing 2008-07-14 21:29:35 +00:00
Denis Vlasenko 757361f9f5 hush: fix "... pattern) cmd;; esac" case 2008-07-14 08:26:47 +00:00
Denis Vlasenko 395ae45216 hush: delete unused field in struct child.
reinstate needed check for invalid syntax.
 document command parsing in hush_doc.txt.
2008-07-14 06:29:38 +00:00
Denis Vlasenko 17f02e79f4 hush: add case statement support. It is incomplete and disabled for now.
costs ~300 bytes when enabled.
2008-07-14 04:32:29 +00:00
Denis Vlasenko 3177ba0852 ash: small code shrink 2008-07-13 20:39:23 +00:00
Denis Vlasenko ad6d6ffcdc libbb: shrink print_login_issue (by Vladimir Dronnikov)
function                                             old     new   delta
print_login_issue                                    469     435     -34
2008-07-12 23:47:24 +00:00
Denis Vlasenko 52ec4b98d5 whitespace fixes 2008-07-12 23:02:43 +00:00
Denis Vlasenko a8374a1916 whitespace fixing script 2008-07-12 22:48:58 +00:00
Denis Vlasenko adbb73bda7 sleep: if FANCY && DESKTOP, support fractional seconds, minutes,
hours and so on. It's coreutils compat. bloatcheck is atrocious :(

function                                             old     new   delta
sleep_main                                            71     362    +291
bb_strtod                                              -     127    +127
make_device                                         1269    1294     +25
getoptscmd                                           708     713      +5
switch_root_main                                     402     401      -1
display_speed                                         90      85      -5
show_entry                                           295     289      -6
parse_expr                                           841     833      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/4 up/down: 448/-20)           Total: 428 bytes
2008-07-12 17:05:14 +00:00
Denis Vlasenko 34e8f6a7ac *: add FAST_FUNC markers
function                                             old     new   delta
getopt_mk_fifo_nod                                    73      70      -3
mv_main                                              505     501      -4
cp_mv_stat2                                           79      73      -6
cp_main                                              266     257      -9
cp_mv_stat                                            22      10     -12
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/5 up/down: 46/-80)            Total: -34 bytes
2008-07-12 11:23:36 +00:00
Denis Vlasenko 13afb2acda mv: fix a case when we move dangling symlink 2008-07-12 11:22:19 +00:00
Denis Vlasenko a87045ce37 mdev: check for "/block/" substring for block dev detection
function                                             old     new   delta
make_device                                         1294    1269     -25
2008-07-12 10:28:41 +00:00
Denis Vlasenko d9860487e0 mdev: if device was moved at creation, at removal coreectly remove
it from moved location and also remove symlinks to it

function                                             old     new   delta
build_alias                                            -      78     +78
mdev_main                                            505     503      -2
make_device                                         1300    1294      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 78/-8)              Total: 70 bytes
2008-07-12 10:23:16 +00:00
Denis Vlasenko 6b7971805c fuser: a bit of safety in scanf 2008-07-12 09:32:38 +00:00
Denis Vlasenko a46dd89e94 cpio: internalize archive_xread_all_eof. add a few paranoia checks
for corrupted cpio files.
modprobe-small: remove stray include
route: small code shrink

function                                             old     new   delta
get_header_cpio                                      958     980     +22
archive_xread_all_eof                                 33       -     -33
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 22/-33)            Total: -11 bytes
2008-07-12 09:20:44 +00:00
Denis Vlasenko 39acf45335 switch_root: shrink
function                                             old     new   delta
switch_root_main                                     402     401      -1
rootdev                                                8       -      -8
delete_contents                                      226     179     -47
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/2 up/down: 0/-56)             Total: -56 bytes
2008-07-11 23:44:50 +00:00
Denis Vlasenko e7067e38ea ash: fix segfault in "command -v" 2008-07-11 23:09:34 +00:00
Denis Vlasenko ee1b3b1042 cpio: on unpack, limit filename length to 8k; shorten comment a bit 2008-07-11 22:20:59 +00:00
Denis Vlasenko e18d21dda4 Announce 1.11.1 2008-07-11 22:11:50 +00:00
Denis Vlasenko 29ec0b94a4 cpio: testsuite for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466771
which was fixed in proevious commit
2008-07-11 21:43:11 +00:00
Denis Vlasenko 2b407b12be cpio: support some long options; document GNU options 2008-07-11 21:42:12 +00:00
Denis Vlasenko abe49fa54f testsuite: uniformly use $ECHO with -n -e 2008-07-11 21:41:14 +00:00
Denis Vlasenko 94884eb486 time: don't segfault with no arguments 2008-07-11 15:05:51 +00:00
Denis Vlasenko 0e52541917 taskset: fix some careless code in both fancy and non-fancy cases.
-5 bytes for fancy, +5 for non-fancy
2008-07-11 13:57:08 +00:00
Denis Vlasenko 88643a86d0 build system: re-add mistakenly deleted script 2008-07-11 10:21:29 +00:00
Denis Vlasenko ff814f821a website: announce updated HOWTO 2008-07-11 09:55:58 +00:00
Denis Vlasenko 86090e2599 fix compile failures resulting from last few commits 2008-07-11 08:23:52 +00:00
Denis Vlasenko 3e8fd18037 fix typo in config help text 2008-07-10 23:42:36 +00:00
Denis Vlasenko 0381d422d9 dpkg_deb: slight code shrink
ar: reuse existing ar unpacking code
get_header_tar: handle autodetection for tiny .tar.gz files too
unarchive.h: do not include CONFIGed out things

function                                             old     new   delta
get_header_tar                                      1521    1534     +13
dpkg_deb_main                                        400     380     -20
ar_main                                              260     196     -64
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 13/-84)            Total: -71 bytes
2008-07-10 23:06:00 +00:00
Denis Vlasenko b6052724ff open_transformer: do not return fd, it does not change
libbb: adopt zipped read from modprobe-small

function                                             old     new   delta
getoptscmd                                           708     713      +5
qgravechar                                           106     109      +3
huft_build                                          1165    1168      +3
tr_main                                              474     472      -2
open_transformer                                      91      89      -2
evalvar                                             1376    1374      -2
rpm_main                                            1691    1688      -3
qrealloc                                              36      33      -3
get_header_tar_lzma                                   55      52      -3
get_header_tar_gz                                    100      97      -3
get_header_tar_bz2                                    55      52      -3
get_header_tar_Z                                      89      86      -3
find_main                                            418     406     -12
prepare                                              302     283     -19
xmalloc_open_zipped_read_close                       161     135     -26
xmalloc_read                                         248     199     -49
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/13 up/down: 11/-130)         Total: -119 bytes
2008-07-10 17:43:01 +00:00
Denis Vlasenko 0e2c93fc0b modprobe-small: make depmod compatible with kernel build.
three last commits' sizes combined:

function                                             old     new   delta
find_alias                                           218     612    +394
load_dep_bb                                            -     310    +310
modprobe_main                                        289     380     +91
copy_stringbuf                                         -      40     +40
process_module                                       637     655     +18
reset_stringbuf                                        -      15     +15
parse_module                                         333     334      +1
append                                                84      85      +1
fileAction                                           832     819     -13
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 5/1 up/down: 870/-13)           Total: 857 bytes
2008-07-10 14:16:11 +00:00
Denis Vlasenko 7f950a93ff modprobe-small: add depfile creation 2008-07-10 14:14:45 +00:00
Denis Vlasenko 784369987f modprobe-small: add depfile loading 2008-07-10 14:14:20 +00:00
Denis Vlasenko 7621ac20f2 website: add 'Laptop Computers' to sponsors page 2008-07-10 08:55:40 +00:00
Denis Vlasenko 4131d855a1 whitespace fix 2008-07-09 22:04:37 +00:00
Denis Vlasenko fc5e80651f build system: libbusybox cannot be static 2008-07-09 21:24:18 +00:00
Denis Vlasenko 9764d6908a fdisk: fix compile failure 2008-07-09 21:20:50 +00:00
Denis Vlasenko 6bdff08e6c hush: compile fixes for !LOOPS case 2008-07-09 20:14:53 +00:00
Denis Vlasenko 7c053262af buld system: suppress a warning 2008-07-09 20:07:59 +00:00
Denis Vlasenko d38d38eed3 last: fix ctime(ptr) ptr type mismatch 2008-07-09 19:48:43 +00:00
Denis Vlasenko 96c45b0e0b libbb/mtab: fix xrealloc_vector fallout 2008-07-09 19:44:08 +00:00
Bernhard Reutner-Fischer 5606b1c4f3 - fix typo (Cristian Ionescu-Idbohrn) 2008-07-09 17:56:53 +00:00
Denis Vlasenko 24a131ea4d modprobe-small: preparatory patch for modprobe.dep.bb creation patches,
Code size impact ~0.
2008-07-09 15:30:57 +00:00
Denis Vlasenko f62ab2d774 libbb: use improved xmalloc_read() from modprobe-small
who: fix compile breakage on some systems
modprobe-small: improve Config help text wording
2008-07-09 09:50:33 +00:00
Denis Vlasenko dbef1173b0 add xrealloc_vector.c 2008-07-08 20:41:57 +00:00
Denis Vlasenko 8b393e5999 website: return HOWTO link and GPL violations address to the top
of the page
2008-07-08 09:07:01 +00:00
Denis Vlasenko deeed59de0 libbb: introduce and use xrealloc_vector
function                                             old     new   delta
xrealloc_vector_helper                                 -      51     +51
create_list                                           84      99     +15
getopt_main                                          690     695      +5
passwd_main                                         1049    1053      +4
get_cached                                            85      89      +4
msh_main                                            1377    1380      +3
add_match                                             42      41      -1
read_lines                                           720     718      -2
grave                                               1068    1066      -2
fill_match_lines                                     143     141      -2
add_to_dirlist                                        67      65      -2
add_input_file                                        49      47      -2
act                                                  252     250      -2
fsck_main                                           2252    2246      -6
man_main                                             765     757      -8
bb_internal_initgroups                               228     220      -8
cut_main                                            1052    1041     -11
add_edge_to_node                                      55      43     -12
dpkg_main                                           3851    3835     -16
ifupdown_main                                       2202    2178     -24
sort_main                                            838     812     -26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/15 up/down: 82/-124)          Total: -42 bytes
2008-07-08 05:14:36 +00:00
Denis Vlasenko 493829207c ifupdown: /etc/network/interfaces can have comments with leading blanks 2008-07-08 03:25:25 +00:00
Denis Vlasenko 5d62462a8c mount: testsuite for "-o mand" 2008-07-08 02:57:40 +00:00
Denis Vlasenko 580ce2d138 mount: support for "-o mand" 2008-07-08 02:56:53 +00:00
Denis Vlasenko 67075bb95f mdev: reinstate "follow symlinks" flag, this time with explanation 2008-07-06 17:00:49 +00:00
Denis Vlasenko 58f59a25ee modprobe-small: match aliases with fnmatch(), making
shell pattern-specified alias names in module bodies work.
2008-07-06 11:52:23 +00:00
Denis Vlasenko cee0dfcc6a modprobe-small: fix debug leftover 2008-07-06 11:11:35 +00:00
Denis Vlasenko 733e3fbc2f hush: support "for if in do done then; do echo $if; done" case
function                                             old     new   delta
done_pipe                                             83      95     +12
parse_stream                                        1758    1764      +6
done_word                                            674     647     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 18/-27)             Total: -9 bytes
2008-07-06 10:01:13 +00:00
Denis Vlasenko d48e81f0cd mdev: do not follow symlinks in /sys (as was intended prior to rev 18811).
If this breaks things, please document why!
mdev,init: use shared code for fd sanitization

function                                             old     new   delta
bb_daemonize_or_rexec                                155     172     +17
mdev_main                                            500     505      +5
init_main                                            907     856     -51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 22/-51)            Total: -29 bytes
2008-07-06 07:00:11 +00:00
Denis Vlasenko ff182a3d68 hush: support "for v; do ... done" syntax (implied 'in "$@"') 2008-07-05 20:29:59 +00:00
Denis Vlasenko afdcd12ed7 hush: fix a case where "$@" must expand to no word at all 2008-07-05 17:40:04 +00:00
Denis Vlasenko a60f84ebf0 *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
Denis Vlasenko f6efccc065 man: fix inverted cat/man bool variable 2008-07-05 08:50:08 +00:00
Denis Vlasenko fec8b42317 man: code shrink
function                                             old     new   delta
man_main                                             725     765     +40
show_manpage                                         112       -    -112
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 40/-112)           Total: -72 bytes
2008-07-05 08:38:41 +00:00
Denis Vlasenko 4cbffc0f34 man: support cat pages too (by Jason Curl <jcurlnews AT arcor.de>)
function                                             old     new   delta
show_manpage                                           -     112    +112
run_pipe                                              89     102     +13
man_main                                             721     725      +4
2008-07-04 21:58:00 +00:00
Denis Vlasenko 9835d47acc man: fix missed NULL termination of an array
function                                             old     new   delta
man_main                                             741     721     -20
2008-07-04 21:57:11 +00:00
Denis Vlasenko a8a3b497fc libbb/recursive_action.c: fix slight error in prev commit 2008-07-04 10:29:30 +00:00
Denis Vlasenko 671691cf21 modutils: optional modutils-small by Vladimir Dronnikov.
15kb smaller than standard one.
libbb/recursive_action.c: commented-out code for aborting the scan.
2008-07-04 10:25:44 +00:00
Denis Vlasenko 8ae5b28b4b awk: another smallish code shrink 2008-07-02 22:47:49 +00:00
Denis Vlasenko f8e8783a92 webpage: fix typos 2008-07-02 11:34:49 +00:00
Denis Vlasenko e0a7fc54eb uname,individual: fix improper printf usage
uname,awk: small code shrink

function                                             old     new   delta
uname_main                                           175     166      -9
nvalloc                                              167     157     -10
evaluate                                            6381    6370     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-30)             Total: -30 bytes
2008-07-02 11:14:59 +00:00
Ned Ludd d4f72438e4 - fix trivial exploit vector when setXid 2008-07-02 00:12:06 +00:00
Denis Vlasenko fa0b56db76 sendmail: fix wrong vfork usage here too
*: shorten error texts

function                                             old     new   delta
launch_helper                                          -     151    +151
vfork_or_die                                          20       -     -20
sendgetmail_main                                    1946    1848     -98
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 151/-118)           Total: 33 bytes
2008-07-01 16:09:07 +00:00
Denis Vlasenko 82604e9730 revert last two commits. vfork cannot be used in subroutine,
it trashes stack on return
2008-07-01 15:59:42 +00:00
Bernhard Reutner-Fischer b111917972 - wrap overlong lines 2008-07-01 12:20:20 +00:00
Denis Vlasenko 58d60c3333 *: introduce and use xfork()
function                                             old     new   delta
xfork                                                  -      20     +20
msh_main                                            1377    1380      +3
mod_process                                          455     446      -9
forkexit_or_rexec                                     30      17     -13
expand_variables                                    1434    1421     -13
open_transformer                                      91      76     -15
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/4 up/down: 23/-50)            Total: -27 bytes
2008-07-01 11:11:24 +00:00
Denis Vlasenko 49b5c516b5 add missing file 2008-07-01 10:55:45 +00:00
Denis Vlasenko 3da5572bfa *: introduce and use xvfork()
function                                             old     new   delta
time_main                                           1052    1285    +233
crontab_main                                         623     856    +233
ifupdown_main                                       2202    2403    +201
xvfork                                                 -      20     +20
passwd_main                                         1049    1053      +4
grave                                               1068    1066      -2
script_main                                          935     921     -14
vfork_or_die                                          20       -     -20
vfork_compressor                                     206     175     -31
open_as_user                                         109       -    -109
popen2                                               218       -    -218
edit_file                                            910     690    -220
run_command                                          268       -    -268
------------------------------------------------------------------------------
(add/remove: 1/4 grow/shrink: 4/4 up/down: 691/-882)         Total: -191 bytes
2008-07-01 10:40:41 +00:00
Denis Vlasenko 148f67af9d ssd: fix missed + in prev commit 2008-07-01 10:05:12 +00:00
Denis Vlasenko 7987a1844b ssd: do not stat -x EXECUTABLE, it is not needed anymore
ssd: use PATH
ssd: fix -a without -x case
ssd: fix help text
ssd: CLOSE_EXTRA_FDS in MMU case too
ssd: add testsuite
2008-07-01 10:00:46 +00:00
Denis Vlasenko 3bb2bbd684 awk: fix a case with multiple -f options. simplify -f file reading.
function                                             old     new   delta
parse_expr                                           833     841      +8
qrealloc                                              33      36      +3
next_input_file                                      203     198      -5
afopen                                                22       -     -22
ftello                                                41       -     -41
ftell                                                 41       -     -41
__GI_ftell                                            41       -     -41
awk_main                                            1002     944     -58
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 2/2 up/down: 11/-208)          Total: -197 bytes
   text    data     bss     dec     hex filename
 804232     610    6804  811646   c627e busybox_old
 804120     610    6804  811534   c620e busybox_unstripped
2008-07-01 01:57:36 +00:00
Denis Vlasenko 0a65692048 crond: use execlp instead of execl 2008-06-30 15:48:34 +00:00
Denis Vlasenko c94d3564c2 sendmail: from Vladimir:
Here comes the third part of compatibility patch for sendmail.
* Introduced new safe_getdomainname() -- will it be useful?
* Fixed SEGV if sender address is missed. Should snoop for sender address in mail headers?
* More compat: use HOSTNAME instead of HOST when no server is explicitly specified.
* crond: fixed mail recipient address.

function                                             old     new   delta
safe_getdomainname                                     -      56     +56
sendgetmail_main                                    1937    1946      +9
grep_file                                            846     850      +4
crond_main                                          1423    1425      +2
xstrtoull_range_sfx                                  295     296      +1
utoa_to_buf                                          110     108      -2
passwd_main                                         1053    1049      -4
sv_main                                             1234    1228      -6
parse_expr                                           841     833      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/4 up/down: 72/-20)             Total: 52 bytes
2008-06-30 13:30:21 +00:00
Denis Vlasenko bc2fd37227 nmeter: tiny shrink 2008-06-30 07:33:52 +00:00
Denis Vlasenko 0db2c2eb71 libiproute: print_route() always uses stdout, do not pass FILE pointer to it.
libiproute: Use FAST_FUNC

function                                             old     new   delta
iprule_modify                                        884     905     +21
ipaddr_modify                                       1289    1310     +21
rtnl_send                                             53      69     +16
xrtnl_wilddump_request                               109     124     +15
xrtnl_dump_filter                                    394     403      +9
rtnl_talk                                            534     539      +5
print_addrinfo                                      1369    1374      +5
iproute_modify                                      1017    1020      +3
iprule_list                                           81      83      +2
xrtnl_open                                           163     161      -2
parse_rtattr                                          89      87      -2
ipaddr_list_or_flush                                2176    2174      -2
addattr_l                                             91      88      -3
flush_update                                         116     108      -8
iproute_list_or_flush                               1285    1263     -22
iproute_get                                          878     852     -26
print_route                                         1913    1752    -161
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 9/8 up/down: 97/-226)          Total: -129 bytes
2008-06-29 06:22:40 +00:00
Denis Vlasenko 270d5d75f1 fdisk: cosmetics, and removal of dead data 2008-06-29 05:16:45 +00:00
Denis Vlasenko 6eaf0a9883 fdisk: move more data to struct globals; shrink code
function                                             old     new   delta
nowarn                                                 1       -      -1
listing                                                1       -      -1
dos_compatible_flag                                    1       -      -1
warn_cylinders                                        44      42      -2
open_list_and_close                                  364     362      -2
fdisk_fatal                                           41      38      -3
verify                                              1053    1049      -4
user_sectors                                           4       -      -4
user_heads                                             4       -      -4
user_cylinders                                         4       -      -4
pt_sectors                                             4       -      -4
pt_heads                                               4       -      -4
kern_sectors                                           4       -      -4
kern_heads                                             4       -      -4
ext_index                                              4       -      -4
total_number_of_sectors                                8       -      -8
extended_offset                                        8       -      -8
create_doslabel                                      129     120      -9
write_table                                          225     211     -14
delete_partition                                     445     431     -14
set_partition                                        476     459     -17
list_disk_geometry                                   247     229     -18
unable_to_write                                       19       -     -19
add_partition                                       2515    2486     -29
get_boot                                            1709    1636     -73
fdisk_main                                          2812    2679    -133
------------------------------------------------------------------------------
(add/remove: 0/14 grow/shrink: 0/12 up/down: 0/-388)         Total: -388 bytes
   text    data     bss     dec     hex filename
 804634     611    6852  812097   c6441 busybox_old
 804298     610    6804  811712   c62c0 busybox_unstripped
2008-06-29 05:10:47 +00:00
Denis Vlasenko ce13b76002 libbb: shrink monotonic_XXX functions, introduce monotonic_ns
(unused for now)

function                                             old     new   delta
get_mono                                               -      31     +31
sv_main                                             1228    1234      +6
expand                                              1693    1697      +4
get_address                                          178     181      +3
utoa_to_buf                                          108     110      +2
builtin_exit                                          46      48      +2
qrealloc                                              36      33      -3
qgravechar                                           109     106      -3
ash_main                                            1383    1380      -3
grep_file                                            850     846      -4
popstring                                            140     134      -6
monotonic_us                                          85      60     -25
monotonic_sec                                         41      16     -25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/7 up/down: 48/-69)            Total: -21 bytes
2008-06-29 02:25:53 +00:00
Denis Vlasenko 540ab7097c wget: "support" -t and -T by ignoring them 2008-06-29 00:32:35 +00:00
Denis Vlasenko 259c9a6e90 nmeter: tiny shrink 2008-06-28 23:42:03 +00:00
Denis Vlasenko befd5eaec8 nmeter: cosmetics 2008-06-28 23:33:02 +00:00
Denis Vlasenko 333aa0c04a nmeter: code shrink
function                                             old     new   delta
init_delay                                            61      64      +3
init_cpu                                              86      82      -4
init_int                                              63      57      -6
nmeter_main                                          679     667     -12
init_if                                               88      63     -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 3/-47)             Total: -44 bytes
2008-06-28 23:30:37 +00:00
Denis Vlasenko 6ea75e2f5d sendmail: another update from the maintainer
function                                             old     new   delta
sendgetmail_main                                    1894    1937     +43
crond_main                                          1416    1423      +7
packed_usage                                       24540   24470     -70
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 50/-70)            Total: -20 bytes
2008-06-28 21:46:41 +00:00
Denis Vlasenko 78ff8197cc lineedit: document prompt handling 2008-06-28 21:03:43 +00:00
Denis Vlasenko 86d88c0990 bunzip2: make proper fix for the problem "fixed" in rev. 22521
Thanks for Rob Landley <rob@landley.net>
2008-06-28 18:10:09 +00:00
Denis Vlasenko a60936da06 libunarchive: stop using static data in archivers - archive_handle_t
can trivially provide space for that.
rpm: code shrink
tar: simplify autodetection of bz2/.gz


function                                             old     new   delta
static.not_first                                       1       -      -1
static.end                                             1       -      -1
bb_makedev                                            51      49      -2
static.saved_hardlinks_created                         4       -      -4
static.saved_hardlinks                                 4       -      -4
longname                                               4       -      -4
linkname                                               4       -      -4
hash_file                                            251     247      -4
get_header_tar                                      1528    1521      -7
rpm_main                                            1711    1697     -14
get_header_cpio                                      965     944     -21
------------------------------------------------------------------------------
(add/remove: 0/6 grow/shrink: 0/5 up/down: 0/-66)             Total: -66 bytes
   text    data     bss     dec     hex filename
 804926     611    6868  812405   c6575 busybox_old
 804878     611    6852  812341   c6535 busybox_unstripped
2008-06-28 05:04:09 +00:00
Denis Vlasenko 9579d87be4 fix FAST_FUNC fallout 2008-06-28 04:58:55 +00:00
Denis Vlasenko dbcf3275ec build system fixlet to ease blackfin build 2008-06-28 04:00:01 +00:00
Denis Vlasenko ed90bdabb4 touch: support -r REF_FILE if ENABLE_DESKTOP (needed for blackfin compile)
function                                             old     new   delta
touch_main                                           136     221     +85
2008-06-28 01:18:09 +00:00
Denis Vlasenko b75fe798bb stat: pointers are not 0L, they are NULL
man: better error handling
2008-06-27 22:31:07 +00:00
Denis Vlasenko ce02b157be man: mimic "no manual entry for 'bogus'" message and exitcode 2008-06-27 22:05:21 +00:00
Denis Vlasenko 55da0be405 support gzip -t and bzip2 -t 2008-06-27 21:52:41 +00:00
Denis Vlasenko 3dee8e2bac sendmail: update from maintainer 2008-06-27 21:24:08 +00:00
Denis Vlasenko bbd55c9ec7 cpio: fix -m to actually work as expected (Pascal Bellard)
function                                             old     new   delta
cpio_main                                           1140    1153     +13
2008-06-27 15:52:07 +00:00
Denis Vlasenko 2bbdda09df unlzma: fix memory leak (Pascal Bellard) 2008-06-27 15:48:45 +00:00
Denis Vlasenko ac2b50ebea add stdcall to FAST_FUNC
text    data     bss     dec     hex filename
 804476     611    6868  811955   c63b3 busybox_old
 804373     611    6868  811852   c634c busybox_unstripped
2008-06-27 04:30:48 +00:00
Denis Vlasenko d699544205 vi: fix vda's thinko 2008-06-27 04:06:13 +00:00
Denis Vlasenko 42b8daf88a expand comment about FAST_FUNC 2008-06-27 03:55:18 +00:00
Denis Vlasenko defc1ea340 *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
text    data     bss     dec     hex filename
 808035     611    6868  815514   c719a busybox_old
 804472     611    6868  811951   c63af busybox_unstripped
2008-06-27 02:52:20 +00:00
Denis Vlasenko 26bc57d8b2 ash: improve comments 2008-06-27 00:29:34 +00:00
Denis Vlasenko 448d30ee17 ash: fix very weak $RANDOM generator; and move even more things
out of data/bss

   text    data     bss     dec     hex filename
 807935     611    6884  815430   c7146 busybox_old
 808035     611    6868  815514   c719a busybox_unstripped
2008-06-27 00:24:11 +00:00
Denis Vlasenko 843cbd54d1 ash: move stuff out of data/bss
text    data     bss     dec     hex filename
 807939     611    6900  815450   c715a busybox_old
 807935     611    6884  815430   c7146 busybox_unstripped
2008-06-27 00:23:18 +00:00
Denis Vlasenko 9092f754bd print_flags: fix trivial thinko
vi: fix reversed checks for underflow
2008-06-26 22:40:02 +00:00
Denis Vlasenko 5fb79535ee bunzip2: fix an uncompression error. Add the example to testsuite. 2008-06-26 20:27:42 +00:00
Denis Vlasenko f5d8c90d73 style fixes, no code changes 2008-06-26 14:32:57 +00:00
Denis Vlasenko 2649f215ae open_transformer: fix bug of calling exit instead of _exit
open_transformer: don't leak compressed descriptor anymore
recursive_action: tiny shrink
2008-06-26 03:26:57 +00:00
Denis Vlasenko a04cc47f1c b[un]zip2, g[un]zip: unlink destination if -f is given. Closes 3854 2008-06-25 20:54:45 +00:00
Denis Vlasenko 6e18f9a6ea Announce 1.10.4 and 1.11.0 2008-06-25 15:58:00 +00:00
Denis Vlasenko 21278dff70 busybox: do not print help to fd 2, print it to fd 1
otherwise this can break scripts
2008-06-25 12:15:46 +00:00
Denis Vlasenko f4cfa1bd5a update defconfig 2008-06-25 10:59:44 +00:00
Denis Vlasenko f54256ec6f Start 1.12.x 2008-06-25 10:18:16 +00:00
Denis Vlasenko dabe36e4a0 This is 1.11.0 2008-06-25 10:16:17 +00:00
Denis Vlasenko e06f61d273 mkfs_minix, fsck_minix: code shrink
function                                             old     new   delta
fsck_minix_main                                     3092    3094      +2
next                                                 539     538      -1
get_free_block                                       165     164      -1
check_zone_nr2                                       121     120      -1
alarm_intr                                            94      93      -1
recursive_check2                                     587     583      -4
recursive_check                                      587     583      -4
mkfs_minix_main                                     2974    2968      -6
map_block                                            237     231      -6
map_block2                                           341     333      -8
bad_zone                                              64      56      -8
write_block                                          619     610      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/11 up/down: 2/-49)            Total: -47 bytes
2008-06-25 10:00:58 +00:00
Denis Vlasenko 7049ff8696 whitespace fixes. no code changes 2008-06-25 09:53:17 +00:00
Denis Vlasenko f26e3d2e41 mount: fix mishandling of proto=tcp/udp
function                                             old     new   delta
singlemount                                         4729    4695     -34
2008-06-24 21:39:32 +00:00
Denis Vlasenko d0cc3f4ade mount: code shrink without logic changes. Added a comment
on possible mismatch with util-linux in -o remount handling.

function                                             old     new   delta
mount_main                                           995     953     -42
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-42)             Total: -42 bytes
2008-06-24 18:59:59 +00:00
Denis Vlasenko fe733a9744 changes in comments only 2008-06-24 16:08:22 +00:00
Denis Vlasenko 70685bd022 vi: fix yet another vda's thinko 2008-06-24 14:10:41 +00:00
Denis Vlasenko 5ec6132c98 hush: ifdef out parts which are not needed
if neither loops nor ifs are supported. Code savings:

function                                             old     new   delta
parse_stream                                        1758    1757      -1
checkjobs                                            335     318     -17
done_pipe                                             74      52     -22
expand_variables                                    1437    1407     -30
run_list                                            1232    1189     -43
parse_and_run_stream                                 328     267     -61
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-174)           Total: -174 bytes
2008-06-24 00:50:07 +00:00
Denis Vlasenko 003f9fb213 hush: kill some old unused fields; small code shrink
function                                             old     new   delta
builtin_exit                                          48      47      -1
checkjobs                                            351     335     -16
checkjobs_and_fg_shell                                60      35     -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-42)             Total: -42 bytes
2008-06-24 00:47:58 +00:00
Denis Vlasenko cc3f20b9bd fix breakage found by randomconfig 2008-06-23 22:31:52 +00:00
Denis Vlasenko 211b59be43 hush: trivial fix in debug code 2008-06-23 16:28:53 +00:00
Denis Vlasenko 2f5d0cd511 ash: trivial code readability fixes 2008-06-23 13:24:19 +00:00
Denis Vlasenko 2b75a94118 ash: improve readability of the code. No real code changes. 2008-06-23 13:06:34 +00:00
Denis Vlasenko ef527f50e6 ash: optional support for $'...\t...\n...' bashism
function                                             old     new   delta
readtoken1                                          2824    3172    +348
static.C_escapes                                       -      18     +18
parse_command                                       1504    1500      -4
SIT                                                   89      83      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 366/-10)           Total: 356 bytes
2008-06-23 01:52:30 +00:00
Denis Vlasenko a80d0e4bf7 trim usage text 2008-06-22 20:14:00 +00:00
Denis Vlasenko 8124a96c34 mdoprobe: fix SEGV bug (by Vlad Dronnikov) 2008-06-22 16:59:46 +00:00
Denis Vlasenko e3eae0d445 vi: fix obvious thinko's 2008-06-22 16:38:53 +00:00
Denis Vlasenko 50b5cac59f wget: accept code 204. 2008-06-22 16:28:02 +00:00
Denis Vlasenko 2a210e5df2 vi: fix vda's breakage (by Cristian Ionescu-Idbohrn) 2008-06-22 13:20:42 +00:00
Denis Vlasenko b07a496229 ash: minor shrink (mostly smallints) and variable renaming
function                                             old     new   delta
optschanged                                           85      91      +6
tryexec                                              115     118      +3
xxreadtoken                                          290     292      +2
raise_error_unexpected_syntax                         75      77      +2
bltincmd                                               6       8      +2
parseheredoc                                         128     129      +1
static.is_interactive                                  4       1      -3
readtoken                                            156     153      -3
lasttoken                                              4       1      -3
evalcommand                                         1147    1144      -3
checkkwd                                               4       1      -3
back_exitstatus                                        4       1      -3
pipeline                                             282     276      -6
list                                                 369     360      -9
ash_main                                            1402    1393      -9
options                                              616     606     -10
readtoken1                                          2823    2811     -12
parse_command                                       1529    1507     -22
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 6/12 up/down: 21/-91)           Total: -70 bytes
   text    data     bss     dec     hex filename
 807603     611    6908  815122   c7012 busybox_old
 807545     611    6900  815056   c6fd0 busybox_unstripped
2008-06-22 13:16:23 +00:00
Denis Vlasenko c87339d584 dpkg: trivial code shrinkage, and redo G trick correctly.
function                                             old     new   delta
run_package_script_or_die                              -      72     +72
fill_package_struct                                  303     309      +6
search_package_hashtable                             122     125      +3
get_status                                           112     111      -1
status_hashtable                                       4       -      -4
set_status                                           162     158      -4
package_hashtable                                      4       -      -4
name_hashtable                                         4       -      -4
package_satisfies_dependency                         112     106      -6
search_name_hashtable                                118     110      -8
configure_package                                    121     106     -15
remove_package                                       333     317     -16
search_status_hashtable                              133     111     -22
purge_package                                        247     217     -30
unpack_package                                       552     521     -31
run_package_script                                    62       -     -62
dpkg_main                                           3991    3867    -124
------------------------------------------------------------------------------
(add/remove: 1/4 grow/shrink: 2/10 up/down: 81/-331)         Total: -250 bytes
   text    data     bss     dec     hex filename
 807972     611    6924  815507   c7193 busybox_old
 807603     611    6908  815122   c7012 busybox_unstripped
2008-06-21 23:15:43 +00:00
Denis Vlasenko d235f58ac2 dpkg: code shrink
dpkg: add documentation from bug 3644

function                                             old     new   delta
remove_package                                       318     333     +15
unpack_package                                       541     552     +11
purge_package                                        242     247      +5
all_control_list                                      55      53      -2
all_control_files                                     44      40      -4
add_split_dependencies                               709     703      -6
search_status_hashtable                              148     133     -15
search_package_hashtable                             137     122     -15
search_name_hashtable                                134     118     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/6 up/down: 31/-58)            Total: -27 bytes
   text    data     bss     dec     hex filename
 808093     611    6924  815628   c720c busybox_old
 807972     611    6924  815507   c7193 busybox_unstripped
2008-06-21 22:46:58 +00:00
Denis Vlasenko 20273138fc dpkg: code shrink (by Peter Korsgaard <jacmet@uclibc.org>)
function                                             old     new   delta
create_list                                          104      86     -18
2008-06-21 22:10:52 +00:00
Denis Vlasenko 3387538bbe vi: small code shrink
function                                             old     new   delta
file_insert                                          328     329      +1
colon                                               3067    3064      -3
string_insert                                         93      89      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-7)               Total: -6 bytes
2008-06-21 20:31:50 +00:00
Denis Vlasenko b175946ba4 vi: fix the bug where vi never grows the edit buffer.
vi: do G trick on it

function                                             old     new   delta
place_cursor                                         264     276     +12
next_tabstop                                          22      34     +12
mycmp                                                 44      52      +8
status_line                                           34      40      +6
yank_delete                                           89      92      +3
what_reg                                              34      37      +3
suspend_sig                                           63      66      +3
find_range                                           493     496      +3
redraw                                               104     106      +2
cont_sig                                              63      65      +2
Indicate_Error                                        59      61      +2
status_line_bold                                      71      72      +1
file_insert                                          327     328      +1
vi_setops                                              1       -      -1
...
cmdcnt                                                 4       -      -4
chars_to_parse                                         4       -      -4
ccol                                                   4       -      -4
dot_scroll                                            88      79      -9
stupid_insert                                         28      18     -10
winch_sig                                            102      91     -11
char_insert                                          353     336     -17
readit                                               354     336     -18
get_one_char                                         128     110     -18
init_text_buffer                                     171     152     -19
text_hole_delete                                     132     112     -20
edit_file                                            940     918     -22
get_input_line                                       198     168     -30
show_status_line                                     449     408     -41
colon                                               3112    3067     -45
vi_main                                              312     250     -62
refresh                                             1077     974    -103
do_cmd                                              4818    4483    -335
------------------------------------------------------------------------------
(add/remove: 0/38 grow/shrink: 13/20 up/down: 58/-889)       Total: -831 bytes
   text    data     bss     dec     hex filename
 809566     612    7044  817222   c7846 busybox_old
 808794     611    6924  816329   c74c9 busybox_unstripped

   text    data     bss     dec     hex filename
  18888       1     122   19011    4a43 busybox.t8/editors/vi.o
  18116       0       0   18116    46c4 busybox.t9/editors/vi.o
2008-06-20 20:20:54 +00:00
Denis Vlasenko b67004b2ae ssd: fix comment 2008-06-20 18:24:14 +00:00
Denis Vlasenko dd9c072846 udhcpc: change BPF filter to not use 0xffffffff as a max packet size,
there are kernels which don't like big (negative when viewed as signed)
sizes.
2008-06-20 12:17:59 +00:00
Denis Vlasenko 1363f0df15 strrchr: actually, last one was finding "" in "any" at pos 0,
should find at pos LAST...
2008-06-18 20:01:12 +00:00
Denis Vlasenko d5736c5607 strrchr: bikeshed painting time!
replace cubic running time implementation with quadratic
 make embedded test actually readable

function                                             old     new   delta
strrstr                                               42      44      +2
2008-06-18 19:49:46 +00:00
Denis Vlasenko 9cd4c76b50 ash: fix "shift BIGNUM" and "read with no variable name" bugs.
omg. hush testsuite helps to find bugs in ash! what next?

function                                             old     new   delta
static.arg_REPLY                                       -       8      +8
readcmd                                             1023    1021      -2
shiftcmd                                             129     125      -4
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 8/-6)                Total: 2 bytes
2008-06-18 19:22:19 +00:00
Denis Vlasenko 1ba323e5b6 cosmetics in hush testsuites 2008-06-18 17:53:57 +00:00
Denis Vlasenko 324a3fdf87 fix globbing in unquoted $* and $@ 2008-06-18 17:49:58 +00:00
Denis Vlasenko 4a689e9b49 fix trivial error with inverted exit code in ls 2008-06-18 16:38:22 +00:00
Denis Vlasenko 55789c6646 hush: fix a bug with backslashes improperly handled in unquoted variables.
with previous patch:

function                                             old     new   delta
parse_stream                                        1638    1758    +120
expand_on_ifs                                         97     174     +77
free_pipe                                            206     237     +31
setup_redirect                                       217     220      +3
setup_redirects                                      143     144      +1
done_word                                            698     688     -10
free_strings                                          38       -     -38
expand_variables                                    1451    1403     -48
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 5/2 up/down: 232/-96)           Total: 136 bytes
2008-06-18 16:30:42 +00:00
Denis Vlasenko ab876cd107 hush: add testsuite for "no globbing in redirection" rule.
simplify redirection habdling
2008-06-18 16:29:32 +00:00
Denis Vlasenko 985de15bf3 hush: expand quote3.tests and move from hush-bugs to hush-parsing 2008-06-18 09:22:31 +00:00
Denis Vlasenko c1c63b622d hush: fix last hush-bugs testcase (disappearing "", $empty"" etc) 2008-06-18 09:20:35 +00:00
Bernhard Reutner-Fischer 4954d47ab0 - fixes from Tito 2008-06-18 08:32:25 +00:00
Bernhard Reutner-Fischer 619b87dfa5 - fix includes 2008-06-17 12:45:39 +00:00
Denis Vlasenko 16c2fea280 hush: fix $$ handling 2008-06-17 12:28:44 +00:00
Bernhard Reutner-Fischer 13436ea0dd - improved strrstr impl from vda with testcases from Tito and vda 2008-06-17 12:11:34 +00:00
Denis Vlasenko 6eaf8deddd hush: fix "for a in; do echo 'I should never run'; done" bug 2008-06-17 12:09:21 +00:00
Bernhard Reutner-Fischer b6926109b7 - remove depmod from TODO, it was recently added.
Small touch up while at it
2008-06-17 07:52:43 +00:00
Denis Vlasenko 988339259f move glob_and_assign.tests from hush-bugs to hush-glob 2008-06-17 07:26:52 +00:00
Denis Vlasenko 30c9cc5b17 hush: continue fixing quoting and subst: fix glob_and_assign.tests. 2008-06-17 07:24:29 +00:00
Denis Vlasenko c7985b76c5 hush: cleanup pass, the biggest is - moved builtins to the end of the file,
they really annoy in the middle of parser code. no real code changes.
2008-06-17 05:43:38 +00:00
Denis Vlasenko b61e13d247 hush: fix memory leak. it was actually rather invloved problem.
Now finally glob/variable expansion is done IN THE RIGHT ORDER!
It opens up a possibility to cleanly fix remaining known bugs.

function                                             old     new   delta
o_save_ptr                                           115     286    +171
o_save_ptr_helper                                      -     115    +115
done_word                                            591     690     +99
o_get_last_ptr                                         -      31     +31
expand_on_ifs                                        125      97     -28
add_string_to_strings                                 28       -     -28
run_list                                            1895    1862     -33
debug_print_strings                                   42       -     -42
add_strings_to_strings                               126       -    -126
expand_variables                                    1550    1394    -156
o_debug_list                                         168       -    -168
expand_strvec_to_strvec                              388      10    -378
------------------------------------------------------------------------------
(add/remove: 2/4 grow/shrink: 2/4 up/down: 416/-959)         Total: -543 bytes
2008-06-17 05:11:43 +00:00
Denis Vlasenko ccce59d562 hush: fixing fallout from last big glob fix:
fix segfault; identify where we leak memory

function                                             old     new   delta
expand_strvec_to_strvec                              353     336     -17
2008-06-16 14:35:57 +00:00
Denis Vlasenko 32d8423e63 hush: delete hush-bugs/glob_and_vars.tests for real 2008-06-16 12:53:33 +00:00
Denis Vlasenko 82dfec3e4e hush: fix hush-bugs/glob_and_vars.tests testcase:
globbing is now done _after_ variable/`cmd` substitution

function                                             old     new   delta
expand_strvec_to_strvec                                7     353    +346
expand_variables                                    1348    1383     +35
add_string_to_strings                                  -      28     +28
globhack                                             114       -    -114
done_word                                            778     579    -199
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/1 up/down: 409/-313)           Total: 96 bytes
2008-06-16 12:47:11 +00:00
Denis Vlasenko 31e1286365 tftp: help compiler a bit 2008-06-16 07:32:40 +00:00
Denis Vlasenko 8474cd38f3 tftpd: PXE server said to need to support "tsize" option
(by Pascal Bellard <pascal.bellard AT ads-lu.com>).
 Conditional on blocksize option && tftpd support.

function                                             old     new   delta
tftp_protocol                                       1488    1670    +182
tftp_get_option                                        -     102    +102
tftpd_main                                           494     538     +44
tftp_main                                            252     254      +2
tftp_get_blksize                                      97       -     -97
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/0 up/down: 330/-97)           Total: 233 bytes
2008-06-16 07:12:19 +00:00
Denis Vlasenko f45c4f41b7 whitespace and comment fixes, no code changes 2008-06-16 04:09:25 +00:00
Denis Vlasenko 57c899e4c2 even more of help text fixes 2008-06-15 20:15:27 +00:00
Denis Vlasenko 1dba30f2de fix config help text 2008-06-15 20:14:26 +00:00
Bernhard Reutner-Fischer f54a088429 - fix copy'n paste error.
thanks, vda! :)
2008-06-15 19:02:31 +00:00
Denis Vlasenko b4c5bf615e Specially for Bernhard Fischer introduce USE_BB_CRYPT
which selects between libc/custom crypt routines.
2008-06-15 18:35:34 +00:00
Denis Vlasenko 5703c22a51 hush: eliminate PARSEFLAG_SEMICOLON and ctx->parse_type field.
function                                             old     new   delta
parse_and_run_file                                    30      27      -3
hush_main                                            795     792      -3
initialize_context                                    45      39      -6
done_word                                            791     778     -13
parse_and_run_stream                                 375     338     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-62)             Total: -62 bytes
2008-06-15 11:49:42 +00:00
Denis Vlasenko ff7cd6f925 use USE_FEATURE_UDHCP_PORT instead of ifdef 2008-06-15 09:58:53 +00:00
Denis Vlasenko f716a6da9a udhcpc: removing stray whitespace 2008-06-15 09:49:21 +00:00
Denis Vlasenko 5cdc247ba4 further encrypt_des optimizations
function                                             old     new   delta
pw_encrypt                                           943     964     +21
des_crypt                                           1512    1509      -3
u_sbox                                               512     256    -256
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 21/-259)          Total: -238 bytes
2008-06-15 09:48:18 +00:00
Denis Vlasenko 04087c6bbd cryptpw: fix "cryptpw -a des -- TEXT" case
libbb/pw_encrypt_des.c: optimize

function                                             old     new   delta
cryptpw_main                                         177     157     -20
des_crypt                                           1682    1512    -170
pw_encrypt                                          1036     842    -194
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-384)           Total: -384 bytes

Run tested.
2008-06-15 08:12:00 +00:00
Denis Vlasenko d50dda8c35 *: use llist_pop for traverse-and-free list operation
function                                             old     new   delta
append_file_list_to_list                             109     111      +2
udhcpc_main                                         2414    2413      -1
run_parts_main                                       325     324      -1
od_main                                             2324    2323      -1
getopt_main                                          709     707      -2
env_main                                             253     251      -2
sed_main                                             659     656      -3
ps_main                                              522     519      -3
traceroute_main                                     3960    3954      -6
sort_main                                            844     838      -6
diff_main                                            866     858      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/10 up/down: 2/-33)            Total: -31 bytes
2008-06-15 05:40:56 +00:00
Denis Vlasenko 873b895d50 udhcpc: reduce ifdef forest, no code changes 2008-06-15 05:40:08 +00:00
Denis Vlasenko e235285c3a crypt: code shrink
function                                             old     new   delta
des_crypt                                              -    1682   +1682
md5_crypt                                              -     627    +627
pw_encrypt                                          3608    1036   -2572
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 2309/-2572)       Total: -263 bytes
2008-06-14 22:11:29 +00:00
Denis Vlasenko 7a762f9dbf tar: fix "unused parameter 'gzip'" warning 2008-06-14 19:38:35 +00:00
Denis Vlasenko f8d01d3f66 hush: fix a bug where we were requiring semicolon here: (cmd;)
also fix a bug where after error prompt is not shown.

function                                             old     new   delta
parse_stream                                        1612    1638     +26
parse_and_run_stream                                 361     375     +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0)               Total: 40 bytes
2008-06-14 17:13:20 +00:00
Denis Vlasenko dd316dd283 hush: add support for ':'; create testsuite entries
text    data     bss     dec     hex filename
 809569     612    7044  817225   c7849 busybox_old
 809528     612    7044  817184   c7820 busybox_unstripped
2008-06-14 15:50:55 +00:00
Denis Vlasenko a84420062a hush: support "! cmd | cmd" negation
function                                             old     new   delta
done_word                                            749     791     +42
run_list                                            1821    1859     +38
checkjobs                                            334     351     +17
done_pipe                                             61      74     +13
static.reserved_list                                 132     144     +12
initialize_context                                    53      45      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/1 up/down: 122/-8)            Total: 114 bytes
2008-06-14 11:00:17 +00:00
Denis Vlasenko 6108dc4df6 Update sponsors page as well 2008-06-14 06:23:25 +00:00
Denis Vlasenko 29038c06d6 ash: small cosmetic change 2008-06-14 06:14:02 +00:00
Denis Vlasenko 2659c63213 ash: fix ${var/s/r} handling, add testcase. 2008-06-14 06:04:59 +00:00
Denis Vlasenko a1767a1f5d dos2unix: do not destroy symlinks and mode of the file being converted. 2008-06-14 04:28:41 +00:00
Denis Vlasenko 21765fa063 udhcpc: kill undocumented -W, it was a no-op.
fix option parsing in the case some CONFIG_x are off.
 disable -b on NOMMU, make backgrounding work correctly
 (if a bit differently from MMU case). Previously,
 it wasn't working at all.
 stop using global data for flags in main(), opt
 bitfield works as well.

function                                             old     new   delta
cryptpw_main                                         177     153     -24
packed_usage                                       24478   24452     -26
client_background                                     26       -     -26
udhcpc_main                                         2462    2372     -90
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-166)           Total: -166 bytes
2008-06-13 20:44:05 +00:00
Denis Vlasenko 76f812803b trivial crypt shrinkage
function                                             old     new   delta
__md5_to64                                            27      29      +2
pw_encrypt                                          3631    3608     -23
2008-06-13 15:13:41 +00:00
Denis Vlasenko aa9cd89c67 fix typo in "Analog Devices" 2008-06-13 13:49:59 +00:00
Denis Vlasenko 7504f2f5d2 httpd: fix authentication 2008-06-13 13:20:38 +00:00
Denis Vlasenko e773be0428 shorten sponsor's link per its request 2008-06-13 13:10:01 +00:00
Denis Vlasenko eee4f55a65 website: announce sponsors. 2008-06-13 12:06:22 +00:00
Denis Vlasenko c7497ea31b build system: introduce FEATURE_ASSUME_UNICODE
ls: use it. also do G trick. with UNICODE off:

function                                             old     new   delta
ls_main                                              843     871     +28
show_color                                             1       -      -1
showdirs                                             500     497      -3
my_stat                                              100      97      -3
terminal_width                                         4       -      -4
tabstops                                               4       -      -4
status                                               122     118      -4
static.dotdir                                          4       -      -4
current_time_t                                         4       -      -4
all_fmt                                                4       -      -4
------------------------------------------------------------------------------
(add/remove: 0/6 grow/shrink: 1/3 up/down: 28/-31)             Total: -3 bytes

Also was tested with UNICODE on with glibc.
2008-06-13 11:16:09 +00:00
Denis Vlasenko 25b463079d httpd: fix bugs in authentication (by Peter Korsgaard <jacmet ATuclibc.org>)
we were accepting empty username; also we were always checking
 dummy user:passwd pair ":" if user gave us wrong one.

function                                             old     new   delta
check_user_passwd                                    338     319     -19
2008-06-13 09:55:13 +00:00
Denis Vlasenko 0eb406caa8 htppd: lots of variable/function renaming in config file parsing.
fixed a bug where we trashed config file's name;
otherwise, should not have any real behavioral changes.

function                                             old     new   delta
check_user_passwd                                      -     338    +338
handle_incoming_and_exit                            2661    2649     -12
parse_conf                                          1650    1536    -114
checkPerm                                            338       -    -338
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 338/-464)         Total: -126 bytes
2008-06-13 09:53:06 +00:00
Denis Vlasenko bd8390a872 Reinstate DEBUG_PESSIMIZE (by Christian Ionescu-Idbohrn) 2008-06-12 20:23:03 +00:00
Denis Vlasenko fdddab0c61 make pw_encrypt() return malloc'ed string.
text    data     bss     dec     hex filename
 759802     604    6684  767090   bb472 busybox_old
 759804     604    6676  767084   bb46c busybox_unstripped
2008-06-12 16:56:52 +00:00
Denis Vlasenko 4ea83bf562 uclibc insists on having 70k static buffer for crypt.
For bbox it's not acceptable. Roll our own des and md5 crypt
implementation. Against older uclibc:

   text    data     bss     dec     hex filename
 759945     604    6684  767233   bb501 busybox_old
 759766     604    6684  767054   bb44e busybox_unstripped

so, we still save on code size.
2008-06-12 16:55:59 +00:00
Bernhard Reutner-Fischer 9de4622055 - make the first arg of the filter function passed to rtnl_dump_filter constant
to match normal iproute. No obj-code changes.
2008-06-12 15:54:49 +00:00
Denis Vlasenko 7e3d33b6ce hush: speed up o_addX{chr,str}
function                                             old     new   delta
o_addQstr                                              -     162    +162
o_addQchr                                              -      89     +89
o_addstr                                               -      58     +58
o_addqchr                                             50      81     +31
expand_on_ifs                                        103      97      -6
add_till_backquote                                    92      82     -10
expand_variables                                    1281    1217     -64
parse_stream                                        1675    1609     -66
o_addqstr                                            155       -    -155
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 1/4 up/down: 340/-301)           Total: 39 bytes
   text    data     bss     dec     hex filename
 759870     604    6684  767158   bb4b6 busybox_old
 759909     604    6684  767197   bb4dd busybox_unstripped
2008-06-12 13:31:04 +00:00
Denis Vlasenko 76db5adbf7 hush: fix for nested $()s with escapes + testsuite 2008-06-12 12:58:20 +00:00
Denis Vlasenko bd1aeeb850 logger: "clean up" a dirty hack a bit 2008-06-11 15:43:19 +00:00
Denis Vlasenko 87f40bac14 hush: more backtick and quoting fixes... 2008-06-10 22:39:37 +00:00
Denis Vlasenko 43360e5178 hush: fix escaping of \[*?; add testsuites for these and for globbing 2008-06-10 20:13:40 +00:00
Denis Vlasenko 2e76c3f901 hush: fix yet another fallout
hush: move fixed testsuites out of hush-bugs/*
2008-06-10 18:27:50 +00:00
Denis Vlasenko 895bea2303 hush: fix some fallout from prev commits, add testsuite 2008-06-10 18:06:24 +00:00
Denis Vlasenko 46ccdcb96e hush: search/and/replace style cleanups, no code changes 2008-06-10 18:05:12 +00:00
Denis Vlasenko 7b4f3f13d3 hush: fix two nasty bugs:
hush-bugs/tick2.tests: ok
hush-bugs/tick.tests: ok

function                                             old     new   delta
parse_stream                                        1332    1557    +225
b_addptr                                               -      97     +97
add_till_backquote                                     -      82     +82
b_addstr                                               -      58     +58
b_grow_by                                              -      50     +50
setup_string_in_str                                    -      29     +29
expand_variables                                    1196    1199      +3
expand_on_ifs                                        100      97      -3
b_addqchr                                             57      50      -7
parse_and_run_string                                  48      31     -17
lookup_param                                          27       -     -27
b_addchr                                              75      45     -30
count_ifs                                             44       -     -44
process_command_subs                                 222       -    -222
------------------------------------------------------------------------------
(add/remove: 5/3 grow/shrink: 2/4 up/down: 544/-350)          Total: 194 bytes
   text    data     bss     dec     hex filename
 759354     604    6684  766642   bb2b2 busybox_old
 759534     604    6684  766822   bb366 busybox_unstripped
2008-06-10 18:04:32 +00:00
Denis Vlasenko 76d50418b3 hush: fix a memory leak in NOMMU case 2008-06-10 16:19:39 +00:00
Denis Vlasenko 3fe4f986a0 less: fix a case when regexp matches ""
hush: remove wrong comment, expand another one
2008-06-09 16:02:39 +00:00
Mike Frysinger 98a6f56d49 reword the error msg so people realize that they broke it, they buy it 2008-06-09 09:38:45 +00:00
Denis Vlasenko 598bb732e8 cosmetics 2008-06-09 07:58:53 +00:00
Denis Vlasenko 2d0529c9bc msh_function.patch: picked it up in the wild.
Fixed allocation bugs (it was allocating
one too small vectors) but it still is very buggy,
thus not applied.
2008-06-09 07:50:25 +00:00
Denis Vlasenko ed9d621cf4 msh: style cleanups. No code changes. 2008-06-09 07:44:19 +00:00
Denis Vlasenko f2cccbce37 mktemp: make default tempfile template shorter;
make help text more understandable
2008-06-08 20:40:33 +00:00
Denis Vlasenko b8c9354114 hush: add yet another bug to testsuite :( 2008-06-08 16:47:09 +00:00
Denis Vlasenko 048897c971 ifenslave: small shrink
text    data     bss     dec     hex filename
 809731     624    7060  817415   c7907 busybox_old
 809629     624    7060  817313   c78a1 busybox_unstripped
2008-06-08 08:01:12 +00:00
Denis Vlasenko 52a8d975da ip: make numeric table work: "ip route list table 255". closes bug 3664.
function                                             old     new   delta
iproute_list_or_flush                               1270    1300     +30
2008-06-08 00:25:55 +00:00
Denis Vlasenko b597564e4c ifenslave: tiny shrink
text    data     bss     dec     hex filename
   2221       0       0    2221     8ad busybox.t5/networking/ifenslave.o
   2215       0       0    2215     8a7 busybox.t6/networking/ifenslave.o
2008-06-08 00:24:43 +00:00
Denis Vlasenko 09c0a749a1 define CLOCK_MONOTONIC to 1 if it is not defined 2008-06-07 23:43:43 +00:00
Denis Vlasenko c8fa04f9b1 ifenslave: further shrink by suppressing excessive inlining
ifenslave: reorder functions to avoid forward declarations

function                                             old     new   delta
enslave                                                -     531    +531
get_drv_info                                           -     176    +176
ifenslave_main                                      1411     671    -740
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 707/-740)          Total: -33 bytes
   text    data     bss     dec     hex filename
 809737     624    7060  817421   c790d busybox_old
 809704     624    7060  817388   c78ec busybox_unstripped
2008-06-07 22:14:25 +00:00
Denis Vlasenko 0876822ded ifenslave: fix improper longopts definition
ifenslave: shrink

function                                             old     new   delta
set_hwaddr                                             -      45     +45
set_ifrname_and_do_ioctl                               -      26     +26
set_mtu                                                -      25     +25
ioctl_on_skfd                                          -      13     +13
static.ifenslave_longopts                             31      34      +3
set_if_up                                             39      36      -3
set_if_down                                           39      36      -3
set_if_flags                                          38      26     -12
static.ifra                                           32      16     -16
get_slave_flags                                       40      24     -16
get_if_settings                                       98      67     -31
set_slave_mtu                                         37       -     -37
set_slave_hwaddr                                      52       -     -52
set_master_hwaddr                                     52       -     -52
ifenslave_main                                      1566    1411    -155
------------------------------------------------------------------------------
(add/remove: 4/3 grow/shrink: 1/7 up/down: 112/-377)         Total: -265 bytes
   text    data     bss     dec     hex filename
 810002     624    7060  817686   c7a16 busybox_old
 809737     624    7060  817421   c790d busybox_unstripped
2008-06-07 22:13:04 +00:00
Denis Vlasenko dd6f570fa3 add libbb/print_flags.c... 2008-06-07 15:11:08 +00:00
Denis Vlasenko 53354ac47d libbb: introduce and use print_flags().
Mostly by Natanael Copa <natanael.copa AT gmail.com>

function                                             old     new   delta
print_e2flags                                          -     189    +189
print_flags_separated                                  -      86     +86
static.flag_labels                                     -      60     +60
static.dma_wmode_masks                                 -      32     +32
static.flag_masks                                      -      28     +28
static.arp_labels                                      -      16     +16
static.arp_masks                                       -      12     +12
ls_main                                              836     843      +7
...
popstring                                            140     134      -6
arp_show                                             740     708     -32
print_flags                                          189      25    -164
ipaddr_list_or_flush                                2396    2170    -226
process_dev                                         5306    4706    -600
------------------------------------------------------------------------------
(add/remove: 10/0 grow/shrink: 5/10 up/down: 458/-1043)      Total: -585 bytes
   text    data     bss     dec     hex filename
 810564     624    7060  818248   c7c48 busybox_old
 810002     624    7060  817686   c7a16 busybox_unstripped
2008-06-07 15:10:29 +00:00
Denis Vlasenko f0d6c25586 Update a link to cross-compiling HOWTO. 2008-06-07 13:59:27 +00:00
Denis Vlasenko c0cd9f29d2 Fix trivial problems: "make clean" cleaning too much
and add #include to pull in __be32 typedef.
2008-06-07 12:23:44 +00:00
Denis Vlasenko a05c0716c2 grep: make "-f -" work (+ testsuite)
diff: small code shrink

function                                             old     new   delta
grep_main                                            722     714      -8
diffreg                                             1825    1793     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-40)             Total: -40 bytes
2008-06-07 05:19:31 +00:00
Denis Vlasenko 401de648a7 Build system: track -Wl,-elf2flt in CFLAGS_busybox too.
Document in comments that it generally should be thers,
not in LDFLAGS
2008-06-06 16:11:12 +00:00
Denis Vlasenko 7bdf0c82da klogd: make help text more understandable
klogd: by using a register instead of global variable, shrink code a bit

function                                             old     new   delta
klogd_main                                           372     362     -10
packed_usage                                       24504   24486     -18
   text    data     bss     dec     hex filename
 808464     642    7180  816286   c749e busybox_old
 808422     642    7180  816244   c7474 busybox_unstripped
2008-06-06 16:08:04 +00:00
Bernhard Reutner-Fischer 797c96d8ce - fix compilation on standard-conforming compilers 2008-06-06 10:31:39 +00:00
Bernhard Reutner-Fischer 593f8baeb0 - fix copy'n paste error for the release date 2008-06-06 08:40:28 +00:00
Denis Vlasenko 9b6f4aa8e8 ip: support for the LOWER_UP flag by Natanael Copa <natanael.copa@gmail.com>.
~50 bytes code growth.
2008-06-05 14:01:04 +00:00
Denis Vlasenko f592aa36f3 which: -a support (needed for bfin uclibc build script)
real support (with CONFIG_DESKTOP=y): 120+ bytes:
   text	   data	    bss	    dec	    hex	filename
 807958	    624	   7036	 815618	  c7202	busybox_old
 808085	    624	   7036	 815745	  c7281	busybox_unstripped

"fake" support (with CONFIG_DESKTOP unset): ~45 bytes:
   text	   data	    bss	    dec	    hex	filename
 797790	    611	   6996	 805397	  c4a15	busybox_old
 797834	    611	   6996	 805441	  c4a41	busybox_unstripped
2008-06-05 13:33:59 +00:00
Bernhard Reutner-Fischer f0d6068086 - The conffiles control file isn't required in Debian packages, so don't
error out if it's missing. (Peter Korsgaard)
2008-06-05 12:18:42 +00:00
Denis Vlasenko c05b1684a0 mktemp: make argument optional (coreutil 6.12 compat)
function                                             old     new   delta
mktemp_main                                          157     174     +17
packed_usage                                       24508   24504      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 17/-4)              Total: 13 bytes
2008-06-05 12:06:00 +00:00
Denis Vlasenko 66d56c565e ash testsuite: modify it so that it can run hush and msh tests 2008-06-05 09:07:02 +00:00
Denis Vlasenko 50120dab4e added testsuite for printf by Cristian Ionescu-Idbohrn 2008-06-05 08:27:26 +00:00
Denis Vlasenko 7d60fc1c0a replace single-char printf's with bb_putchar 2008-06-05 06:51:06 +00:00
Denis Vlasenko bedfabd500 libiproute: use stdout directly instead of passing it as a parameter
function                                             old     new   delta
iprule_list                                           86      82      -4
print_rule                                           860     791     -69
ipaddr_list_or_flush                                2484    2384    -100
print_addrinfo                                      1498    1292    -206
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-379)           Total: -379 bytes
2008-06-05 05:00:24 +00:00
Denis Vlasenko b6fe10091d announce 1.10.3 2008-06-05 01:17:49 +00:00
Denis Vlasenko e7860e358e config help text: fix capitalization 2008-06-04 22:41:14 +00:00
Denis Vlasenko 1a9bbfb96f remove -fno-jump-tables - after stripping it proved to be worse 2008-06-04 11:53:24 +00:00
Denis Vlasenko 1da86d2f40 build system: add PIE build option 2008-06-04 11:28:24 +00:00
Mike Frysinger 1e93f3c585 change default rtcwake mode to match changed behavior in upstream util-linux 2008-06-04 10:33:33 +00:00
Denis Vlasenko 3b162ecdf6 networking/interface.c: fix indentation 2008-06-04 07:59:51 +00:00
Denis Vlasenko 630a7f75e8 Remove stray debug instrumentation 2008-06-02 22:24:34 +00:00
Mike Frysinger 85571d8d01 make the help for rtcwake reflect the actual default behavior 2008-06-02 20:37:45 +00:00
Bernhard Reutner-Fischer 6075b2aee0 - add FIXME. Perhaps somebody is interrested in looking into this one.
We would try to be clever and compare the *data instead of the *elt.

Somethink like this might be of more general use:
/* Unlink arbitrary element from the list that contains data */
void llist_unlink_data(llist_t **head, void *data)
{
    llist_t *elt;

    for (elt = *head; elt; elt = elt->link) {
        if (elt->data == data) {
            llist_unlink(elt);
            return;
        }
    }
}
2008-06-02 19:23:47 +00:00
Bernhard Reutner-Fischer c2741e1f72 - add alias support 2008-06-02 18:59:16 +00:00
Bernhard Reutner-Fischer ef729dd90c - revert revision 22183 since it breaks -b /abs /abs/path/to/mod.ko 2008-06-02 13:40:13 +00:00
Bernhard Reutner-Fischer d42816763f - just chdir to the basedir (-30b). 2008-06-02 13:34:36 +00:00
Bernhard Reutner-Fischer beac1bd58e - optional fancy pruning-mode for depmod 2008-06-02 13:28:47 +00:00
Bernhard Reutner-Fischer 9af7aba579 - pm_states[PM_SUSPEND_MAX] suggests to support "standby" and not "suspend"
Thanks to Paulius Zaleckas for mentioning this.
2008-06-02 11:01:40 +00:00
Denis Vlasenko b8e653bfbf Reinstate CONFIG_CROSS_COMPILE_PREFIX 2008-06-02 04:51:29 +00:00
Denis Vlasenko cd2663f15e ash: optional printf builtin. +25 bytes if off, +35 if on.
by Cristian Ionescu-Idbohrn.
2008-06-01 22:36:39 +00:00
Denis Vlasenko d78920675f msh: fix ENOENT testcase 2008-06-01 14:16:54 +00:00
Bernhard Reutner-Fischer 62d8503589 - use ut_user rather than ut_name (Cristian Ionescu-Idbohrn)
- use ut_tv.tv_sec rather than ut_time (me)
- shrink halt a little bit (me):
halt_main                                            464     433     -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-31)             Total: -31 bytes
2008-06-01 10:10:22 +00:00
Bernhard Reutner-Fischer e0fd13e901 - shrink modprobe a little bit (~-40 bytes). ACKed by Yann. 2008-05-31 18:50:17 +00:00
Denis Vlasenko a76669c595 printf: fix a trivial bug 2008-05-31 18:32:56 +00:00
Denis Vlasenko f4e6bd0bf3 mdev: add commented-out debug code to open stdio. 2008-05-31 18:27:58 +00:00
Denis Vlasenko 1d1bba4e99 printf: code shrink by eliminating string alloc/copy
function                                             old     new   delta
print_direc                                          428     382     -46
2008-05-31 11:41:50 +00:00
Denis Vlasenko d12fcc20da libiproute: fix option parsing, so that "ip -o link" works again.
closes bug 3524
2008-05-31 07:34:14 +00:00
Denis Vlasenko 3e57adb731 libiproute: style fixes, and using smallint as appropriate
function                                             old     new   delta
print_route                                         1730    1731      +1
print_addrinfo                                      1497    1498      +1
iproute_list_or_flush                               1232    1229      -3
ipaddr_list_or_flush                                2490    2484      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 2/-9)               Total: -7 bytes
2008-05-31 07:33:18 +00:00
Denis Vlasenko 8f74094548 runsvdir: make it more robust against libc buglets (errno accidentally set to !0)
closes bug 3514

function                                             old     new   delta
runsvdir_main                                       1672    1664      -8
2008-05-31 07:00:33 +00:00
Denis Vlasenko 447bd66837 msh: fix the case where the file has exec bit but can't be run directly
(run "$SHELL $file" instead)
msh: fix exit codes when command is not found or can't be execed
     (with testcases)
2008-05-30 22:28:32 +00:00
Bernhard Reutner-Fischer f9a0784144 - add FIXME to use hasmntopt() 2008-05-30 10:44:37 +00:00
Bernhard Reutner-Fischer db508e3b82 - fix overflow; improve documentation while at it 2008-05-28 15:57:31 +00:00
Denis Vlasenko cd9d4c85a4 fuser: a now, the corrected fix (vda botched previous one) 2008-05-28 14:57:58 +00:00
Bernhard Reutner-Fischer 634b022108 - misc. improvements and shrinkage 2008-05-28 14:20:20 +00:00
Bernhard Reutner-Fischer 17282292c2 - add strrchr 2008-05-28 14:19:27 +00:00
Denis Vlasenko 5de8a13b08 fiser: opendir "/proc", not "." (by Cristian Ionescu-Idbohrn) 2008-05-28 12:44:22 +00:00
Denis Vlasenko ea9f7a6a7f find: beautify config prompts a bit 2008-05-28 12:00:59 +00:00
Denis Vlasenko 417e240abb Remove 'busybox' word from configuration programs
(based on experience of adapting it to uclibc).
2008-05-28 11:59:32 +00:00
Bernhard Reutner-Fischer 10be1a787f - move depmod shell script to examples/ 2008-05-28 11:21:20 +00:00
Bernhard Reutner-Fischer c21d9c7290 - the moddir_base is supposed to be omitted frmo the .dep file
- other tweaks while at it
2008-05-28 10:35:51 +00:00
Bernhard Reutner-Fischer 1510216a55 - Spaghetti alert. Fix clash with ancient fwd-decl. This is an unfortunate
combination of linux not providing a useable linux/module.h to userspace and
  mixing legacy-cruft with the current stuff in one insmod.c.
2008-05-27 13:27:18 +00:00
Bernhard Reutner-Fischer 55fb9da5b8 - remove duplicate helptext of dhcprelay and improve it 2008-05-27 12:42:39 +00:00
Bernhard Reutner-Fischer b85fb693c1 - Add config option for DEFAULT_DEPMOD_FILE and DEFAULT_DEPMOD_FILE.
No obj-code changes.
2008-05-27 10:55:34 +00:00
Bernhard Reutner-Fischer 4fec346966 - use (uC)libc functions. Saves a dozen bytes. 2008-05-27 10:13:54 +00:00
Bernhard Reutner-Fischer 9cf0f62b15 vda, xmalloc'ing can use *alot* of RAM. Don't forget that there are
modules out there that are half a megabyte! mmap()ing is way nicer
   for small mem boxes.
2008-05-27 09:06:05 +00:00
Bernhard Reutner-Fischer 9474830006 - improve help-text 2008-05-27 08:41:32 +00:00
Bernhard Reutner-Fischer 1ea2568469 - improve option-handling a bit 2008-05-26 21:33:05 +00:00
Denis Vlasenko 7a5f494cab scripts: add a script which prints memory map of running busybox 2008-05-26 18:41:35 +00:00
Denis Vlasenko c47e8978fe scripts: add primitive memory usage meter script 2008-05-26 18:36:37 +00:00
Denis Vlasenko fc9e108032 udhcpc: shrink
udhcpc: guard against zero lease time

function                                             old     new   delta
timeout                                                4       -      -4
server_addr                                            4       -      -4
requested_ip                                           4       -      -4
perform_release                                      134     112     -22
udhcpc_main                                         2511    2485     -26
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 0/2 up/down: 0/-60)             Total: -60 bytes
2008-05-26 17:32:35 +00:00
Bernhard Reutner-Fischer 6bb55cfb99 - add basic option-handling (+220b). Untested 2008-05-26 17:04:01 +00:00
Bernhard Reutner-Fischer cf18010ca9 - use mmap instead of allocating hundreds of megabytes of RAM. +39b 2008-05-26 15:12:01 +00:00
Bernhard Reutner-Fischer dc5d7fec35 - remove some bloat -28b: now approx. 501b 2008-05-26 13:30:41 +00:00
Bernhard Reutner-Fischer 423465cd5e - switch to FILE base writer and remove now unneeded stuff. -50b 2008-05-26 12:19:35 +00:00
Bernhard Reutner-Fischer 55e547eb6f - add simple first-draft unoptimized depmod just to proove Vladimir Dronnikov wrong
text	   data	    bss	    dec	    hex	filename
    569	      0	      0	    569	    239	modutils/depmod.o
2008-05-26 12:01:49 +00:00
Denis Vlasenko a0e17f7df6 [u]mount: add/update dietlibc build fix 2008-05-26 01:19:53 +00:00
Denis Vlasenko b267ed95bc lineedit: correctly handle prompt longer than screen width. closes bug 3414 2008-05-25 21:52:03 +00:00
Denis Vlasenko 4830fc565a hush: make it ignore SIGINT etc in a config wich has no job control 2008-05-25 21:50:55 +00:00
Denis Vlasenko af6cca50af move setgroups definition to libbb.h so that it no longer inadvertently
get hidden attribute
2008-05-25 04:31:54 +00:00
Denis Vlasenko 30f892a0ee last: code shrink
function                                             old     new   delta
show_entry                                           319     311      -8
last_main                                            917     907     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18)             Total: -18 bytes
2008-05-25 01:14:14 +00:00
Denis Vlasenko 69dc325397 syslogd: do not error out on missing files to rotate. closes bug 3404. 2008-05-24 21:03:53 +00:00
Denis Vlasenko bd23fbbd0a docs/depmod: and example of depmod in shell/sed/awk... 2008-05-24 20:54:14 +00:00
Denis Vlasenko 8e2c9e1518 inotify: new applet by Vladimir Dronnikov <dronnikov AT gmail.com>
function                                             old     new   delta
inotifyd_main                                          -     453    +453
packed_usage                                       24246   24450    +204
inotify_add_watch                                      -      47     +47
inotify_init                                           -      29     +29
mask_names                                             -      13     +13
signal_handler                                       130     140     +10
applet_names                                        1859    1868      +9
applet_main                                         1132    1136      +4
applet_nameofs                                       566     568      +2
signalled                                              1       2      +1
2008-05-24 20:47:18 +00:00
Denis Vlasenko e94a87134d mdev: fix counting of '%' in pattern 2008-05-24 16:46:13 +00:00
Denis Vlasenko ff9234948e mdev: fix whitespace damage 2008-05-23 20:36:33 +00:00
Bernhard Reutner-Fischer cf575ca856 - optionally pass additional flags down to nm 2008-05-23 12:53:18 +00:00
Bernhard Reutner-Fischer 61082ec1cc - not sure but i may have had the shutdown-time wrong and no records to verify 2008-05-22 22:05:55 +00:00
Bernhard Reutner-Fischer 69d5ba2f95 - untangle the implementation of the small and huge last applets 2008-05-22 21:56:26 +00:00
Denis Vlasenko a959a2abdd mdev: suppress "may be used uninitialized" warning 2008-05-22 21:35:16 +00:00
Denis Vlasenko 4801441e9a mdev: add support for "only rename" option in mdev.conf 2008-05-22 17:49:58 +00:00
Denis Vlasenko e9b76e1f1e dnsd: fixes various segfaults.
One was a lib api change that was not updated and another
is a stack buffer overflow.
It also adds support for '*' in dnsd.conf. It resolves all hostnames to
a specific ip address. This is useful if you for example want redirect
all http traffic to your first-boot-web-wizard on you router/firewall.

By Timo Teras
2008-05-22 17:41:01 +00:00
Denis Vlasenko ae84b11467 modprobe: fix for blacklisting
The patch makes the order of the alias/blacklist in modprobe.conf 
irrelevant (like module-utils' modprobe). In first patch the alias had 
to be defined before the blacklist which caused problems because the 
modprobe.conf file is read before /lib/modules/*/modules.alias.

The attatched patch will mark the blacklisted module itself rather than 
trying to find the alias that points to the blacklisted module and test 
this flag later in the alias resolving stage.
2008-05-22 17:37:38 +00:00
Denis Vlasenko dfd8282464 last: make its output more like "standard" last (aka "fancy last").
The main difference is that LOGIN lines are still shown by non-fancy one.

function                                             old     new   delta
static._ut_usr                                         -      26     +26
last_main                                            448     471     +23
static._ut_lin                                         -       7      +7
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/0 up/down: 56/0)               Total: 56 bytes
2008-05-22 17:35:22 +00:00
Denis Vlasenko 7b3863986d last: trim format string a bit 2008-05-22 17:14:09 +00:00
Denis Vlasenko b22a8059cb last: trim help text 2008-05-22 02:10:50 +00:00
Denis Vlasenko 869d3d318f last: optional alternative sysv-like implementation
(by Patricia Muscalu <patricia.muscalu AT axis.com>)

function                                             old     new   delta
last_main                                            448     917    +469
show_entry                                             -     319    +319
packed_usage                                       24216   24268     +52
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 840/0)             Total: 840 bytes
2008-05-22 02:07:58 +00:00
Bernhard Reutner-Fischer 7bd8d8fd26 - make Christian happy 2008-05-21 21:15:37 +00:00
Bernhard Reutner-Fischer 49bdf28c32 - skip empty lines and archive members 2008-05-21 10:32:39 +00:00
Denis Vlasenko 6de8994440 udhcpc: regularize the names of receiving functions,
pause on "serious failure to receive".
Some misc fixes are also folded in here.
2008-05-21 07:05:06 +00:00
Denis Vlasenko 19903f0d44 udhcpc: simplify renewal of the lease 2008-05-21 07:03:03 +00:00
Denis Vlasenko b23429198e udhcpc: properly reduce timeout if bogus packets were received 2008-05-21 07:02:16 +00:00
Denis Vlasenko 54b90b5988 fix another -Wall warning 2008-05-20 20:44:08 +00:00
Denis Vlasenko 38100a4ebe ifenslave: add forgotten INIT_G() 2008-05-20 18:57:35 +00:00
Bernhard Reutner-Fischer 0953336951 - Rob sais that he rewrote it, so reinstate the GPLv2-only boilerplate. 2008-05-20 08:27:26 +00:00
Denis Vlasenko eaad910655 fix "make bigdata" to not show weak aliases 2008-05-20 06:31:56 +00:00
Bernhard Reutner-Fischer f02efd11c9 - improve readability 2008-05-19 10:28:32 +00:00
Bernhard Reutner-Fischer 5e25ddb7d3 - use STD*_FILENO some more. No object-code changes 2008-05-19 09:48:17 +00:00
Bernhard Reutner-Fischer 636a1f85e8 - use EXIT_{SUCCESS,FAILURE}. No object-code changes 2008-05-19 09:29:47 +00:00
Bernhard Reutner-Fischer cb83abd7b6 - mention FIXME use find_mount_point() 2008-05-19 08:40:26 +00:00
Bernhard Reutner-Fischer 3576bed2f9 - improve wording 2008-05-19 08:25:23 +00:00
Bernhard Reutner-Fischer ae4342ca3e - Rename getpty() to xgetpty() and adjust callers.
- Rewrite kbd_mode and setconsole
- Introduce and use console_make_active() and xopen_xwrite_close()
- honour buffer-reservation method as set by the user (dumpkmap, loadkmap)
- shrink rtcwake and some console-tools

  Saves about 270 Bytes
2008-05-19 08:18:50 +00:00
Denis Vlasenko ee56e013cf swapon: optional -p PRIO support (by Francois Barel <frabar666 AT gmail.com>)
function                                             old     new   delta
swap_on_off_main                                     153     216     +63
packed_usage                                       24190   24214     +24
swap_enable_disable                                  127     131      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 91/0)               Total: 91 bytes
2008-05-18 23:05:34 +00:00
Denis Vlasenko 5599502a55 more -Wall warning fixes. -Wall is enabled now. 2008-05-18 22:28:26 +00:00
Denis Vlasenko e125a683a7 start_stop_daemon: add -test, fix -x to not match by inode,
vastly improve hext text. (mostly by Roy Marples <roy AT marples.name>)

function                                             old     new   delta
packed_usage                                       24124   24190     +66
start_stop_daemon_main                               959     991     +32
start_stop_daemon_longopts                           149     156      +7
check                                               1632    1589     -43
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 105/-43)            Total: 62 bytes
2008-05-18 21:17:52 +00:00
Denis Vlasenko faf334aeb8 httpd: fix obscure case when user runs httpd -i from command line for testing.
(fixes bug 3334)

function                                             old     new   delta
httpd_main                                           743     757     +14
handle_incoming_and_exit                            2657    2669     +12
log_and_exit                                          75      43     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 26/-32)             Total: -6 bytes
2008-05-18 15:14:36 +00:00
Denis Vlasenko 9ddc8d54d1 modprobe: optional "blacklist" command support (by Natanael Copa)
is_conf_command                                        -      56     +56
include_conf                                         898     917     +19
check_dep                                            348     356      +8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 83/0)               Total: 83 bytes
2008-05-18 14:39:43 +00:00
Denis Vlasenko b6c4855f1d printf: fix printf -%s- foo, printf -- -%s- foo (bug 3354)
function                                             old     new   delta
printf_main                                          577     548     -29
2008-05-18 14:28:40 +00:00
Denis Vlasenko 29eb3599e4 ash: more of -Wall fixes 2008-05-18 14:06:08 +00:00
Denis Vlasenko d04e1fc309 last: style fixes 2008-05-17 23:50:14 +00:00
Denis Vlasenko 2794c9bb93 insmod: build fix for microblaze (by Greg Steuck <greg AT nest.cx>) 2008-05-17 02:47:55 +00:00
Denis Vlasenko 85e015c7c8 two fixlets for -Wall 2008-05-17 02:36:28 +00:00
Denis Vlasenko 29952d79fc fix bug 2704: remove verbatim RFC text from source
(this creates problems for Debian).
2008-05-17 01:26:15 +00:00
Bernhard Reutner-Fischer 51a06c07da - accept ip l s ib0 addr 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 2008-05-16 17:19:03 +00:00
Bernhard Reutner-Fischer b8635e28b5 - very minor shrinkage
odd that this saved 1byte. And there could be something wrong with
  ifcombine or the like since omitting the braces produces bigger code?
2008-05-16 16:55:17 +00:00
Bernhard Reutner-Fischer dff6190112 - add appropriate string for arp header #32 for use by ip(8) 2008-05-16 16:21:00 +00:00
Bernhard Reutner-Fischer f3b778a4dc - fix bug where we incorrectly rejected ifconfig eth0 hw ether $whatever
- add support for printing ipoib to ifconfig
2008-05-16 16:10:31 +00:00
Bernhard Reutner-Fischer 825968f92c - fix compilation on x86_64 2008-05-16 16:00:38 +00:00
Bernhard Reutner-Fischer 1b23773e26 - mention duplication of in_ether() 2008-05-16 14:35:34 +00:00
Bernhard Reutner-Fischer 9c3052aab6 - provide proc-less sample
- improve wording
2008-05-16 11:36:32 +00:00
Denis Vlasenko 81e97a1380 testsuite instrumentation fixes by Christian 2008-05-15 22:43:48 +00:00
Denis Vlasenko e251337a4d Add more -W options to gcc. 2008-05-15 21:44:46 +00:00
Denis Vlasenko 6b06cb80be more of -Wall fixes from Cristian Ionescu-Idbohrn.
Some are fixing real bugs.

function                                             old     new   delta
syslogd_main                                         938     958     +20
get_signum                                           136     143      +7
obj_load                                             777     782      +5
recv_from_to                                         210     214      +4
get_next_block                                      1795    1799      +4
display_topmem_process_list                         1117    1121      +4
logread_main                                         484     487      +3
buffer_fill_and_print                                 73      76      +3
kill_main                                            687     689      +2
ll_remember_index                                    240     241      +1
do_stats                                             452     453      +1
if_readconf                                          166     165      -1
display_process_list                                1192    1191      -1
run_applet_and_exit                                  507     505      -2
print_signames                                        33      31      -2
parse_one_line                                      1092    1090      -2
find_out_spec                                         57      55      -2
add_ksymoops_symbols                                 421     419      -2
ash_main                                            1407    1402      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 11/8 up/down: 54/-17)            Total: 37 bytes
2008-05-15 21:30:45 +00:00
Denis Vlasenko 43d5d429fd remove stray semicolons (by Cristian Ionescu-Idbohrn) 2008-05-15 19:44:46 +00:00
Mike Frysinger b81f97bbd2 fix by Jie Zhang for exit status and POSIX compliance:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
The exit status of a command that terminated because it received a signal shall be reported as greater than 128.
2008-05-14 11:51:04 +00:00
Denis Vlasenko 9305cdddbf Kill CONFIG_NITPICK, it turned out to not be useful. no code changes. 2008-05-13 02:43:27 +00:00
Denis Vlasenko 77ad97f199 more -Wall warning fixes from Cristian Ionescu-Idbohrn.
This time it resulted in small code changes:

function                                             old     new   delta
nexpr                                                820     828      +8
tail_main                                           1200    1202      +2
wrapf                                                166     167      +1
parse_mount_options                                  227     209     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 11/-18)             Total: -7 bytes
2008-05-13 02:27:31 +00:00
Denis Vlasenko c4f12f59cc -Wall fixes by Cristian Ionescu-Idbohrn. No object code changes. 2008-05-12 14:35:56 +00:00
Denis Vlasenko 023dc6798e fix warnings about pointer signedness 2008-05-09 18:07:15 +00:00
Denis Vlasenko 98636eb08c Use intra-DSO calls when we build libbusybox. No-op for normal build.
This was Bernhard Fischer' idea.

   text    data     bss     dec     hex filename
 773549    7781    9740  791070   c121e busybox.t7/0_lib/libbusybox.so.1.11.0.svn_unstripped
 769683    7397    9740  786820   c0184 busybox.t9t/0_lib/libbusybox.so.1.11.0.svn_unstripped
2008-05-09 17:59:34 +00:00
Bernhard Reutner-Fischer 50dbed95fb - pass flags to ld in one argument 2008-05-09 12:43:04 +00:00
Denis Vlasenko b89e2027d9 udhcp: protect agianst timer overflowing 32-bit counter
function                                             old     new   delta
arpping                                              398     387     -11
2008-05-09 11:55:58 +00:00
Denis Vlasenko f3aa4a8ec5 insmod: fix build warnings. By Cristian Ionescu-Idbohrn 2008-05-09 11:36:17 +00:00
Denis Vlasenko 4579e9c1c8 mdev: /sys/class/block/ are also block devices
function                                             old     new   delta
make_device                                         1200    1221     +21
2008-05-08 21:49:28 +00:00
Denis Vlasenko 4b04f543a1 build system: do not rebuild entire tree if it is moved 2008-05-08 16:26:49 +00:00
Denis Vlasenko 35d1683ce9 website: announce 1.10.2 2008-05-08 15:36:54 +00:00
Bernhard Reutner-Fischer 2af860464e - forgot to pull in arch-specific tweaks 2008-05-08 13:25:20 +00:00
Bernhard Reutner-Fischer 6253880450 - fix selinux stuff 2008-05-08 12:21:44 +00:00
Bernhard Reutner-Fischer 6e38d52120 - correct usage helptext of ifupdown 2008-05-08 10:40:34 +00:00
Denis Vlasenko 647c20cfc2 start_stop_daemon: try to clarify intended meaning of the options 2008-05-07 14:52:01 +00:00
Denis Vlasenko 6bf05cf1ff httpd: fix several bugs triggering by realtive path in -h DIR.
function                                             old     new   delta
handle_incoming_and_exit                            2657    2659      +2
send_cgi_and_exit                                    869     862      -7
parse_conf                                          1647    1626     -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 2/-28)             Total: -26 bytes
2008-05-07 12:18:48 +00:00
Denis Vlasenko b153ace939 httpd: restore HUP, CHLD and PIPE to SIG_DFL prior to execing CGI.
function                                             old     new   delta
send_cgi_and_exit                                    856     869     +13
2008-05-07 09:22:44 +00:00
Denis Vlasenko 06ebc16461 script: exit if reading from pseudo-tty errors out (do not loop)
function                                             old     new   delta
script_main                                          991     966     -25
2008-05-06 19:11:41 +00:00
Denis Vlasenko dddfaff363 ash: make set -o and set +o work as in dash/bash.
by Cristian Ionescu-Idbohrn.

function                                             old     new   delta
options                                              565     625     +60
getoptscmd                                           709     698     -11
2008-05-06 15:30:27 +00:00
Denis Vlasenko 380bcfc9f7 cpio.tests: remove useless command 2008-05-06 12:08:19 +00:00
Bernhard Reutner-Fischer c8f7a97f89 - fix strncmp'ing "runlevel". (Cristian Ionescu-Idbohrn) 2008-05-05 14:45:32 +00:00
Denis Vlasenko 8abae88410 vi: do not truncate file to zero length. closes bug 2944.
function                                             old     new   delta
file_write                                            98     104      +6
2008-05-03 11:35:59 +00:00
Denis Vlasenko 96b99b860c uniq: support -w. closes bug 3094.
function                                             old     new   delta
packed_usage                                       24136   24132      -4
uniq_main                                            399     384     -15
2008-05-03 07:21:27 +00:00
Denis Vlasenko 687a26fe0d more fixes to testsuite by Cristian and vda 2008-05-02 21:46:30 +00:00
Denis Vlasenko 4e79049e10 clarify grep version 2008-05-02 13:26:18 +00:00
Denis Vlasenko 32dcc53b71 mdev: fix a bug where we were eating argv[0] of helper 2008-05-02 13:21:24 +00:00
Denis Vlasenko 6da9b00f4f fix grep test false positive 2008-05-02 12:34:59 +00:00
Denis Vlasenko 2dea01ca11 testing.sh: bashisms are eradicated.
By Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn AT axis.com>
2008-05-02 09:39:09 +00:00
Denis Vlasenko 57be4abcf8 runtest: the saga continues :( 2008-05-02 09:19:29 +00:00
Denis Vlasenko e061226668 start_stop_daemon: use existing global variable
start_stop_daemon_main                               976     959     -17
2008-04-30 13:58:31 +00:00
Denis Vlasenko 812870a2e7 remove stray semicolon 2008-04-30 13:56:32 +00:00
Denis Vlasenko dcbd350ccf echo: fix echo -e -n "msg\n\0"
(by "Pinedo, David" <david.pinedo AT hp.com>)
2008-04-30 00:39:22 +00:00
Denis Vlasenko a2dcb50175 trylink: fix glibc check; make --sort-section option look less ugly 2008-04-30 00:15:56 +00:00
Denis Vlasenko 3c07e4b877 runtest: more cleanups 2008-04-29 14:11:57 +00:00
Denis Vlasenko b34266b42b ping: dont leak uninitialized data in ping packets
function                                             old     new   delta
sendping4                                            176     186     +10
sendping6                                             93     100      +7
2008-04-29 12:31:53 +00:00
Denis Vlasenko a0c103a30a tar: add testsuite entries 2008-04-29 04:40:15 +00:00
Denis Vlasenko 05efca90d2 tar: fix obscure case when name is "" and prefix is not "" 2008-04-29 04:12:58 +00:00
Denis Vlasenko d93400bffb tar: fix the case where long base names can be ignored 2008-04-29 03:54:16 +00:00
Denis Vlasenko c450379ff0 tar: remove bogus check for "-" (we handle it corrently later)
tar: simplify argv handling

function                                             old     new   delta
tar_main                                             772     722     -50
2008-04-29 02:43:23 +00:00
Denis Vlasenko 10f6fb1d46 fix build failure for libbusybox 2008-04-29 00:10:27 +00:00
Denis Vlasenko e4ed64067e date: better version of previous commit; + fix testsuite
to have it checked
2008-04-28 00:25:22 +00:00
Denis Vlasenko e6520f0532 date: complain if there are extraneout arguments 2008-04-28 00:10:34 +00:00
Denis Vlasenko c0431ed455 cp: fix "cp -RL" to create regular files even if src is a symlink 2008-04-27 22:06:24 +00:00
Denis Vlasenko 4809a9f78e date: fix date-works test, add date-works-1 one (currently fails) 2008-04-27 20:58:43 +00:00
Denis Vlasenko 7dff4333d6 runtest: fix fallout from mucking with runtest :( [vda's fault] 2008-04-27 20:48:49 +00:00
Denis Vlasenko 5d0f4aaa99 runtest: even more fixes from Cristian 2008-04-27 13:34:43 +00:00
Denis Vlasenko 92a6f878e9 runtest: further fixes from Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn AT axis.com> 2008-04-27 03:33:29 +00:00
Denis Vlasenko 64d5bfda1a runtest: use numeric compare instead of string where appropriate 2008-04-26 10:14:25 +00:00
Denis Vlasenko 16afa38a7b libbb: fix wrong sscanf count check (affects pidof etc) 2008-04-25 23:20:25 +00:00
Denis Vlasenko b140eddc41 fix KCONFIG_NOTIMESTAMP=1 mode (just learned that we have such thing) 2008-04-25 19:00:39 +00:00
Denis Vlasenko 2c84495184 lineedit: hack for making it sort-of-work even if term width is wrong
function                                             old     new   delta
read_line_input                                     3158    3153      -5
input_end                                             29      24      -5
input_delete                                         115     110      -5
input_forward                                         27      20      -7
cmdedit_set_out_char                                  88      80      -8
2008-04-25 18:44:35 +00:00
Denis Vlasenko 44f0821259 taskset: (1ull < 65) like ops are not good, avoid that 2008-04-25 17:01:06 +00:00
Denis Vlasenko 95842fbc16 testsuite/runtest: remove (last) bashism
mkswap: fix selinux build
2008-04-25 08:43:01 +00:00
Denis Vlasenko a6b3a1f0bf arping: save a few bytes by using mempcpy
function                                             old     new   delta
catcher                                              357     339     -18
2008-04-25 08:13:36 +00:00
Denis Vlasenko 4d89a8bd1d date: make it accept ISO date format. Fix help text.
make testsuite actually test something useful.

function                                             old     new   delta
date_main                                           1094    1149     +55
2008-04-25 02:14:07 +00:00
Denis Vlasenko ad6cab1834 partially fix date testsuite 2008-04-24 19:37:11 +00:00
Bernhard Reutner-Fischer c6191e9a0a - fsetfilecon_war is hidden so use fsetfilecon instead.
Fixes dynamic linking-error:
  util-linux/lib.a(mkswap.o): In function `mkswap_selinux_setcontext':
  util-linux/mkswap.c:38: undefined reference to `fsetfilecon_raw'
2008-04-24 10:44:31 +00:00
Bernhard Reutner-Fischer 15ce7f5b58 - bump copyright year 2008-04-24 10:35:50 +00:00
Bernhard Reutner-Fischer 019d299f01 - update screenshot 2008-04-24 10:27:20 +00:00
Denis Vlasenko b520271f65 lineedit: filename completion on symlinks-to-dirs should add / too 2008-04-24 04:42:52 +00:00
Paul Fox a50a9b0fdf delay reconfig of input tty until target device has been both opened
and configured correctly.
2008-04-23 15:31:29 +00:00
Denis Vlasenko 765c1c3c31 getopt32: fix "tar x" case; fix memory leak 2008-04-23 07:22:31 +00:00
Denis Vlasenko 71e3ab327a testsuite: fix du testsuite to not use changing directories 2008-04-23 07:02:02 +00:00
Denis Vlasenko 58dc274a7a testsuite: runtest enhancements by Cristian Ionescu-Idbohrn 2008-04-23 06:45:11 +00:00
Denis Vlasenko fa5b05ab07 testsuite: fix 2008-04-23 06:42:49 +00:00
Denis Vlasenko ffdcb41fd2 build system: typo fix in help text 2008-04-23 05:46:55 +00:00
Denis Vlasenko 9d4a17e0b6 dd: fix recent breakage (was comparing "if" with "if=" etc). 2008-04-23 05:44:59 +00:00
Denis Vlasenko be002adb2f add forgotten files. I am forgetting it all the time :( 2008-04-22 18:07:41 +00:00
Denis Vlasenko 1f228985b2 whitespace fixes. no code changes 2008-04-22 00:16:29 +00:00
Denis Vlasenko 5d89fbaa2e *: remove remaining instances of ".data" hack 2008-04-22 00:08:27 +00:00
Denis Vlasenko 9137341851 getopt32: fix recently broken opt_complementary "--" 2008-04-21 22:04:21 +00:00
Denis Vlasenko 5a07a1d255 tar: move vfork into separate function (smaller code)
open_transformer: more informative error messages

function                                             old     new   delta
vfork_compressor                                       -     210    +210
writeTarFile                                         547     299    -248
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 210/-248)          Total: -38 bytes
2008-04-21 21:56:07 +00:00
Denis Vlasenko a4a93fdf18 udhcp: fix config help text 2008-04-21 20:27:29 +00:00
Denis Vlasenko 2d94992235 build system: use spaces in Kbuild files 2008-04-21 05:07:15 +00:00
Denis Vlasenko 376003bbbe build system: move misplaced config entry for script applet 2008-04-21 05:05:17 +00:00
Denis Vlasenko 5bb2fc2dc1 tentative fix for ppc64 problems with ioctl.
Zero code size impact.
2008-04-21 03:23:59 +00:00
Denis Vlasenko 01eaee9309 *: s/IF_NAMESIZE/IFNAMSIZ/, regularize its use a bit.
function                                             old     new   delta
strncpy_IFNAMSIZ                                       -      13     +13
set_slave_mtu                                         39      37      -2
set_slave_hwaddr                                      52      50      -2
set_master_hwaddr                                     52      50      -2
set_if_flags                                          40      38      -2
get_if_settings                                      101      98      -3
ifenslave_main                                      1680    1661     -19
vconfig_main                                         306     280     -26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/7 up/down: 13/-56)            Total: -43 bytes
2008-04-21 02:21:45 +00:00
Denis Vlasenko 0a1446275d xmalloc_open_read_close: use fstat to get file size (instead of lseek).
by Joakim Tjernlund <Joakim.Tjernlund AT transmode.se>

function                                             old     new   delta
xmalloc_open_read_close                              190     181      -9
2008-04-20 14:45:43 +00:00
Denis Vlasenko fe493479e2 start_stop_daemon: stat executable only once
function                                             old     new   delta
start_stop_daemon_main                               954     976     +22
check                                               1661    1632     -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-29)             Total: -7 bytes
2008-04-20 14:25:26 +00:00
Denis Vlasenko 25cfe4996e libbb: prevent xmalloc_open_read_close from dying on seek failure
start_stop_daemon: use open_read_close instead of xmalloc_open_read_close
start_stop_daemon: use local structure instead of global one

function                                             old     new   delta
check                                               1620    1661     +41
xmalloc_open_read_close                              171     190     +19
start_stop_daemon_main                               976     954     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 60/-22)             Total: 38 bytes
2008-04-20 01:27:59 +00:00
Denis Vlasenko 5b3adae7e8 remove whitespace damage. No code changes 2008-04-19 21:57:57 +00:00
Denis Vlasenko 85d788e491 start_stop_daemon: optimization - do not pass paramenter, use
existing globals instead

function                                             old     new   delta
start_stop_daemon_main                               792     976    +184
check                                               1618    1620      +2
do_procinit                                          196       -    -196
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/0 up/down: 186/-196)          Total: -10 bytes
2008-04-19 21:30:52 +00:00
Denis Vlasenko daeddee442 start_stop_daemon: do not stop /proc scan prematurely
function                                             old     new   delta
do_procinit                                          185     196     +11
2008-04-19 20:19:45 +00:00
Denis Vlasenko f3745ea489 libbb: introduce xmalloc_xopen_read_close and use where appropriate
instead of xmalloc_open_read_close.

function                                             old     new   delta
xmalloc_xopen_read_close                               -      34     +34
xmalloc_open_read_close                              163     171      +8
passwd_main                                         1070    1074      +4
rexecve                                              254     257      +3
handle_incoming_and_exit                            2657    2659      +2
parse_command                                       1509    1510      +1
buffer_fill_and_print                                 76      73      -3
evaltreenr                                           599     589     -10
evaltree                                             599     589     -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/3 up/down: 52/-23)             Total: 29 bytes
2008-04-19 19:32:08 +00:00
Denis Vlasenko d9c51e9fa7 start-stop-daemon: make --exec follow symlinks
by Joakim Tjernlund <joakim.tjernlund AT transmode.se>

function                                             old     new   delta
check                                               1591    1618     +27
start_stop_daemon_main                               770     792     +22
2008-04-19 19:06:23 +00:00
Denis Vlasenko 6c10657c4a style fixes. no code changes 2008-04-19 19:05:12 +00:00
Denis Vlasenko 5a96c3eab6 start_stop_daemon: mark argc as unused 2008-04-19 17:40:29 +00:00
Bernhard Reutner-Fischer a4e55ab840 - rotate some older new to oldnews 2008-04-19 09:33:22 +00:00
Bernhard Reutner-Fischer 33b92f2fdb - ignore "recent"; We have an RCS to serve these 2008-04-19 09:27:14 +00:00
Denis Vlasenko 9a7af9fc17 website: add 1.10.1 to news page. 2008-04-19 04:28:21 +00:00
Denis Vlasenko d2095fd903 website: add a link to 1.10.1 2008-04-19 04:15:13 +00:00
Denis Vlasenko 1b2d0b2821 openvt: handle -ws correctly. By James Simmons <jsimmons AT infradead.org>
function                                             old     new   delta
openvt_main                                          343     429     +86
2008-04-19 03:44:45 +00:00
Denis Vlasenko 50d068cb76 man: handle many MANPAGER directives so that they do not override
but accumulate. By Ivana Varekova <varekova AT redhat.com>

function                                             old     new   delta
man_main                                             567     684    +117
2008-04-19 03:42:47 +00:00
Denis Vlasenko e96dcb4dcf top: fix build failure 2008-04-17 18:04:38 +00:00
Denis Vlasenko 250aa5bb01 httpd: add an example of POST upload CGI 2008-04-17 12:35:09 +00:00
Denis Vlasenko c033d5196d fdisk: fix a case where we can inadvertently close /proc/partitions fd early 2008-04-17 01:52:28 +00:00
Denis Vlasenko 4437d19fb4 fdisk: do not open device twice. Complain on fdisk -l /dev/bogus.
Made enums UPPERCASE. Removed one global variable.
  Added some FIXMEs.

   text    data     bss     dec     hex filename
 804708     645    7112  812465   c65b1 busybox_old
 804685     641    7112  812438   c6596 busybox_unstripped
2008-04-17 00:12:10 +00:00
Denis Vlasenko aca10f852a arping: remove superfluous assignment 2008-04-16 15:01:48 +00:00
Denis Vlasenko bc1918a7a2 trivial fixes to make bbox compile with gcc 4.3.0 2008-04-15 01:17:50 +00:00
Denis Vlasenko 3cfebe44c7 od: fix testsuite 2008-04-14 19:56:46 +00:00
Denis Vlasenko 7089c31d57 od: fix "od -b" 2008-04-14 19:50:06 +00:00
Denis Vlasenko c7131c3e58 ash: fix breakage introduced in rev 21481.
Fixes ash-vars/var_posix1.tests testsuite entry.
2008-04-14 01:59:53 +00:00
Denis Vlasenko b15ebe46fc fix typo in Config.in hext text 2008-04-13 22:41:27 +00:00
Denis Vlasenko 4f98e19382 make test, [ and [[ all NOFORK, for consistency.
Revamp handling of NOUSAGE applets.

function                                             old     new   delta
packed_usage                                       24122   24104     -18
2008-04-13 22:12:19 +00:00
Denis Vlasenko 6d1ebecf65 ash: add another testsuite entry ("leaking variables" bug) 2008-04-13 17:45:56 +00:00
Denis Vlasenko 24f824edb3 less: fix somewhat elusive case when less gets stuck in search mode
function                                             old     new   delta
read_lines                                           719     730     +11
goto_match                                           141     116     -25
2008-04-13 08:32:51 +00:00
Denis Vlasenko ffa4499c9f man: new applet. ~600 bytes. 2008-04-13 08:20:00 +00:00
Denis Vlasenko 867bd37c7f fix english in comment 2008-04-13 02:27:39 +00:00
Denis Vlasenko 7465dbcf2a ash: speed up NOFORK code in ash by eliminating second find_applet().
some code reduction along the way.

function                                             old     new   delta
run_list                                            1971    1981     +10
run_nofork_applet_prime                              181     182      +1
unsetcmd                                              97      96      -1
delete_cmd_entry                                      54      53      -1
describe_command                                     399     397      -2
cmdlookup                                            152     150      -2
evaltreenr                                           602     599      -3
evaltree                                             602     599      -3
clearcmdentry                                        101      98      -3
cdcmd                                                675     672      -3
hashcmd                                              305     301      -4
find_command                                         933     910     -23
evalcommand                                         1371    1229    -142
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/11 up/down: 11/-187)         Total: -176 bytes
2008-04-13 02:25:53 +00:00
Denis Vlasenko f78a656f7c ash: a bit more complete POSIX subst testsuite entry 2008-04-12 23:02:43 +00:00
Denis Vlasenko 033424a213 ash: add testsuite entry for POSIX-mandated ${var#word} ${var##word}
${var%word} ${var%%word}
2008-04-12 22:55:33 +00:00
Denis Vlasenko 9bc80d7062 ash: add FEATURE_SH_NOFORK support 2008-04-12 20:07:53 +00:00
Denis Vlasenko 4a9ca13fe7 ash: do not do find_applet() twice in shellexec/tryexec 2008-04-12 20:07:08 +00:00
Denis Vlasenko 55e06c1edf Makefile.IMA: generate autoconf.h if needed
Makefile.IMA: use ld -gc-collect on gc -combine result
 (by using trylink script). Saves ~3k.
2008-04-12 13:46:39 +00:00
Bernhard Reutner-Fischer eecd588c53 - fix detection of whole-program
It helps if we first pull in the function we use for testing flags ;)
2008-04-11 12:42:23 +00:00
Bernhard Reutner-Fischer 1d690db720 - also use the incoming LDFLAGS and EXTRA_LDFLAGS
This isn't perfect since it will barf on linker flags with two args like -Wl,z,now et al.
2008-04-11 12:31:57 +00:00
Bernhard Reutner-Fischer 3bc7d7df3d - erm sorry. no ipsvd here 2008-04-11 11:59:09 +00:00
Bernhard Reutner-Fischer 0f5dfd6b9a - add ipsvd 2008-04-11 11:50:55 +00:00
Denis Vlasenko 93b8263652 fix build with gcc -combine 2008-04-11 11:27:29 +00:00
Denis Vlasenko 80f647c21c build system: use POSIX options only for cp
cp: improve comment
2008-04-11 10:54:37 +00:00
Bernhard Reutner-Fischer 119f87be2a - add printutils and util-linux/volume_id
- pull in Kbuild.includes
2008-04-11 08:46:56 +00:00
Denis Vlasenko da616dbfa8 webpage: remove date from URL 2008-04-11 02:49:56 +00:00
Denis Vlasenko 37bb6ada96 webpage: s/Denis/Denys/ (I don't like "denys", but it's in passport); add a link to resume 2008-04-11 00:28:19 +00:00
Denis Vlasenko b75a1c3c2a fix "make check" 2008-04-10 19:59:20 +00:00
Denis Vlasenko fcc6347976 udhcp,ipcalc: simple code shrink (Nico Erfurth <masta AT perlgolf.de>)
function                                             old     new   delta
ipcalc_main                                          609     610      +1
read_staticlease                                     102      85     -17
ether_aton                                            17       -     -17
2008-04-10 02:09:40 +00:00
Denis Vlasenko b3f39f0cfa nameif: fix vda's breakage (Nico Erfurth <masta AT perlgolf.de>)
function                                             old     new   delta
nameif_main                                          684     691      +7
prepend_new_eth_table                                304     301      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-3)                Total: 4 bytes
2008-04-10 02:03:21 +00:00
Denis Vlasenko 858ebf130a actually adding xfuncs_printf.c :( 2008-04-09 00:33:53 +00:00
Denis Vlasenko b12b1c87b5 Splitting xfuncs.c into two parts. No code chabges. 2008-04-09 00:33:23 +00:00
Denis Vlasenko 79cedcb2c0 Avoid linking in printf/bsearch if possible. -20k for static bbox with
"basename", "true" and "false" only.

function                                             old     new   delta
full_write2_str                                        -      25     +25
bb_show_usage                                        183     202     +19
main                                                 883     898     +15
run_applet_and_exit                                  501     507      +6
2008-04-08 21:13:28 +00:00
Denis Vlasenko 643dcf00e3 dd: update usage text 2008-04-07 21:11:23 +00:00
Denis Vlasenko ed23adce72 mount: remove superfluous comment 2008-04-07 21:05:59 +00:00
Denis Vlasenko 6fa1ba3972 crond: add handling of "MAILTO=user" lines
sendmail: handle a case when the whole mail comes from stdin
(and no separate sender/subj is provided)
both by dronnikov AT gmail.com

function                                             old     new   delta
sendgetmail_main                                    1509    1674    +165
SynchronizeFile                                      671     767     +96
packed_usage                                       24054   24088     +34
crond_main                                          1404    1420     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 311/0)             Total: 311 bytes
2008-04-07 21:02:35 +00:00
Denis Vlasenko 90c31b3d4b ping: add -w, -W support (James Simmons <jsimmons AT infradead.org>)
function                                             old     new   delta
print_stats_and_exit                                   -     282    +282
sendping_tail                                        151     231     +80
packed_usage                                       23976   24054     +78
ping_main                                            401     412     +11
arm_ioctl                                             13      20      +7
pingstats                                            259       -    -259
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 4/0 up/down: 458/-259)          Total: 199 bytes
2008-04-07 00:46:29 +00:00
Denis Vlasenko 278a1c2264 brctl: optional support for "show" cmd (by L. Gabriel Somlo <somlo AT cmu.edu>)
function                                             old     new   delta
brctl_main                                           739    1186    +447
if_indextoname                                         -     104    +104
static.keywords                                      827     841     +14
static.ops                                             -       7      +7
packed_usage                                       23978   23976      -2
2008-04-06 07:17:02 +00:00
Denis Vlasenko ad4da989e3 init: fix askfirst not working as intended 2008-04-05 04:24:23 +00:00
Denis Vlasenko 0a38bcf570 cpio: actually add testsuite entry... 2008-04-05 02:46:47 +00:00
Denis Vlasenko 1af00eda92 cpio: fix a bug where we do not extract zero-sized hardlinks
(spotted at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466771).
Add testsuite entry for that, and another one for another bug:
we do not list hardlinks in cpio -t (not fixed).

function                                             old     new   delta
get_header_cpio                                      884     909     +25
static.saved_hardlinks_created                         -       4      +4
static.pending_hardlinks                               4       -      -4
static.inode                                           4       -      -4
cpio_main                                           1122    1060     -62
2008-04-05 02:44:30 +00:00
Denis Vlasenko 1a95e3960c cpio: typo fix in error message 2008-04-05 00:13:19 +00:00
Denis Vlasenko 261f237024 cpio: optional support for writing cpio files in newc format.
by pascal.bellard AT ads-lu.com.

function                                             old     new   delta
cpio_main                                            247    1122    +875
cpio_pad4                                              -      58     +58
gnu_dev_major                                         66      99     +33
gnu_dev_minor                                         38      57     +19
packed_usage                                       23964   23978     +14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 999/0)             Total: 999 bytes
2008-04-05 00:07:46 +00:00
Denis Vlasenko 7f8f0fafdb fbsplash: more compact support for named pipes + EOF scenario
function                                             old     new   delta
fbsplash_main                                       1121    1043     -78
2008-04-04 20:38:49 +00:00
Denis Vlasenko 7b6d9d687d dd: support conv=fsync
dd: support "dd --" if CONFIG_DESKTOP=y

function                                             old     new   delta
static.conv_words                                      -      28     +28
dd_main                                             1369    1373      +4
static.keywords                                      848     827     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 32/-21)             Total: 11 bytes
2008-04-02 21:20:35 +00:00
Denis Vlasenko a7f4e4bbd8 expr: fix comparisons 'a < b' where we were overflowing a-b
(not to mention that we used int, not arith_t). closes bug 2744.
Also, shrink a bit and add testsuite entry

function                                             old     new   delta
nextarg                                               75      84      +9
tostring                                              38      35      -3
toarith                                               89      86      -3
str_value                                             35      32      -3
eval6                                                555     552      -3
int_value                                             29      23      -6
eval4                                                128     120      -8
eval3                                                112     104      -8
eval2                                                512     417     -95
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/8 up/down: 9/-129)           Total: -120 bytes
2008-04-02 20:24:09 +00:00
Denis Vlasenko 2e4c3c4cc3 udhcpc: add -o "do not request options by default" switch
(by L. Gabriel Somlo <somlo AT cmu.edu>)

function                                             old     new   delta
udhcpc_main                                         2513    2554     +41
static.udhcpc_longopts                               226     247     +21
add_param_req_option                                 119     132     +13
packed_usage                                       23952   23964     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 87/0)               Total: 87 bytes
2008-04-02 13:04:19 +00:00
Denis Vlasenko 0edbdd8ac8 xfunc_die: resurrect (actually, it's "svn add" being forgotten again) 2008-04-01 17:43:03 +00:00
Denis Vlasenko c59d802a5a basename: tiny shrink 2008-04-01 16:29:21 +00:00
Denis Vlasenko 9895dfdb9a chpst: fix "env directory" parsing to not strip everything
after 1st whitespace. -6 bytes.
2008-04-01 16:13:14 +00:00
Denis Vlasenko 9dedf72e71 script: do not ignore poll() errors. ~+20 bytes. 2008-04-01 16:12:17 +00:00
Denis Vlasenko 468aea2d88 shells: do not frocibly enable test, echo and kill _applets_,
just build relevant source and use xxx_main functions.
build system: add a special case when we have exactly one applet enabled
(makes "true", "false", "basename" REALLY tiny).
getopt32: do not use stdio.

function                                             old     new   delta
getopt32                                            1385    1412     +27
make_device                                         1187    1200     +13
basename_main                                        120     127      +7
tcpudpsvd_main                                      1922    1926      +4
testcmd                                                5       -      -5
echocmd                                                5       -      -5
fuser_main                                          1243    1231     -12
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 4/1 up/down: 51/-22)             Total: 29 bytes
2008-04-01 14:47:57 +00:00
Denis Vlasenko 165f5b394f tcpudp: trivial build fix 2008-03-31 20:30:38 +00:00
Denis Vlasenko d943af058b libbb: preventive fix for SIGxxx >= 32 2008-03-30 15:56:38 +00:00
Denis Vlasenko 5297809c03 g[un]zip: accept and ignore -n (needed for kernel compile) 2008-03-30 13:11:47 +00:00
Denis Vlasenko 1b2058fe98 fuser: fix vda's breakage: DOH! chdir'ing to /proc breaks relative paths 2008-03-29 17:59:27 +00:00
Denis Vlasenko f2f3868e0d mdev: optional support for regex pattern group substitution.
+142 bytes.
2008-03-29 17:26:10 +00:00
Denis Vlasenko aa8a601084 mdev: fix block/char device detection. Closes bug 2144. 2008-03-29 16:07:46 +00:00
Denis Vlasenko 02f12f53e8 inetd: small shrink for NOMMU case
function                                             old     new   delta
cat_args                                               -       8      +8
echo_stream                                           64      63      -1
discard_stream                                        64      63      -1
static.args                                           32      12     -20
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 8/-22)             Total: -14 bytes
2008-03-29 16:00:52 +00:00
Denis Vlasenko cae11b51aa mdev: fix "foo 0:0 444 >bar/baz" rule handling. make_device() +23 bytes 2008-03-29 15:11:07 +00:00
Denis Vlasenko 4461564c77 mdev: fix a bug where it was not stopping on first matching rule
(testsuite entry added). Revamped line parsing while at it.

function                                             old     new   delta
next_field                                             -      36     +36
make_device                                         1104    1022     -82
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 36/-82)            Total: -46 bytes
2008-03-29 13:10:57 +00:00
Denis Vlasenko 7cb808e1c5 ftpgetput: move control_stream to "struct globals";
unify common data pumpung stage for upload and download;
other small shrinkage. EPSV still not implemented...

function                                             old     new   delta
pump_data_and_QUIT                                     -      82     +82
xconnect_ftpdata                                     127     156     +29
ftpcmd                                               301     304      +3
ftp_die                                               59      55      -4
ftpgetput_main                                       352     344      -8
ftp_send                                             185      91     -94
ftp_receive                                          394     293    -101
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/4 up/down: 114/-207)          Total: -93 bytes
2008-03-29 07:40:35 +00:00
Denis Vlasenko 0e7940ae90 ftpgetput: deal with long-standing TODOs:
- do not use ALLO on upload
- move globals to "struct globals"
- move buf[] there too
- remove commented out "filesize" code
- other shrinkage

function                                             old     new   delta
xconnect_ftpdata                                     117     127     +10
ftp_die                                               49      59     +10
ftpcmd                                               292     301      +9
verbose_flag                                           1       -      -1
do_continue                                            1       -      -1
ftpgetput_main                                       405     352     -53
ftp_receive                                          451     394     -57
ftp_send                                             325     185    -140
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 3/3 up/down: 29/-252)          Total: -223 bytes
2008-03-29 07:37:42 +00:00
Denis Vlasenko 6c615a6c07 ftpgetput: add comment about EPSV (extended PASV).
Fix bug where we were using lstat instead of stat.
Added many TODOs.
2008-03-28 22:11:49 +00:00
Denis Vlasenko b9ad75fa60 copy_file: handle "cp /dev/foo file" (almost) compatibly to coreutils.
(almost because we do not copy mode, which is probably wasn't intended).
+61 bytes.
2008-03-28 17:49:31 +00:00
Denis Vlasenko a38ba59cc3 fbsplash: move to /sbin; small shrink
function                                             old     new   delta
fb_drawprogressbar                                   413     423     +10
fbsplash_main                                       1146    1121     -25
2008-03-28 11:17:35 +00:00
Denis Vlasenko c4523c2b3d fix a few stray unguarded strdup's 2008-03-28 02:24:59 +00:00
Denis Vlasenko 2570b2e575 whitespace fixes 2008-03-28 01:00:09 +00:00
Denis Vlasenko cf26ab70c1 mdev: plug a few memory and fd leaks; simplify code a bit 2008-03-27 22:45:44 +00:00
Denis Vlasenko e1caabbb75 mdev: add testsuite entry 2008-03-27 20:49:26 +00:00
Denis Vlasenko 95891fc016 openvt: fix gross mismatch between us and "standard" openvt.
standard one even has different syntax!
  std: "openvt -c 12", we: "openvt 12"
  std: "openvt top", we: complain that "top" is not a number.
openvt: implement -c -w -s (-l -f -v are also accepted but ingnored)

openvt_main                                          188     343    +155
vfork_child                                            -      67     +67
not_vt_fd                                              -      23     +23
packed_usage                                       23932   23952     +20
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 265/0)             Total: 265 bytes
   text    data     bss     dec     hex filename
 801344     641    7380  809365   c5995 busybox_old
 801617     641    7380  809638   c5aa6 busybox_unstripped
2008-03-27 16:26:35 +00:00
Denis Vlasenko 72b3442aeb fbsplash: support this usage:
mkfifo cmd_pipe
fbsplash -f cmd_pipe .... &
...
echo 33 >cmd_pipe
...
echo 66 >cmd_pipe

Code size: fbsplash_main +116 bytes :(
2008-03-27 13:14:29 +00:00
Denis Vlasenko 11b9f26610 fbsplash: fix broken handling of buffered case:
"{echo 45; echo 33; } | { sleep 1; fbsplash -f - ...; }"

function                                             old     new   delta
fb_drawprogressbar                                     -     413    +413
xmalloc_fgetline                                       -      46     +46
xmalloc_reads                                        184     183      -1
xmalloc_getline                                       46       -     -46
fbsplash_main                                       1472    1030    -442
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/2 up/down: 459/-489)          Total: -30 bytes
   text    data     bss     dec     hex filename
 801181     641    7380  809202   c58f2 busybox_old
 801151     641    7380  809172   c58d4 busybox_unstripped
2008-03-26 20:06:24 +00:00
Denis Vlasenko 8ee649a02e *: more uniform naming: s/xmalloc_getline/xmalloc_fgetline/ 2008-03-26 20:04:27 +00:00
Bernhard Reutner-Fischer ce7eb4443c - add fbsplash and CONFIG_ASH_BASH_COMPAT to defconfig 2008-03-26 16:15:13 +00:00
Denis Vlasenko 25a9c17f55 fbsplash: cosmetic comment and Config text fixes; rename .ini -> .cfg 2008-03-26 15:12:11 +00:00
Denis Vlasenko c6dbb85c9e fbsplash: shrink, better help text; inifile cannot specify image now;
image can come from stdin

function                                             old     new   delta
packed_usage                                       23872   23932     +60
static.param_names                                     -      57     +57
fbsplash_main                                       1525    1472     -53
static.param_value                                   100       -    -100
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 117/-153)          Total: -36 bytes
   text    data     bss     dec     hex filename
 801202     641    7380  809223   c5907 busybox_old
 801181     641    7380  809202   c58f2 busybox_unstripped
2008-03-26 14:57:49 +00:00
Denis Vlasenko 08ec67bc62 patch: add support for -R. ~ +110 byte. By Pascal Bellard <pascal.bellard AT ads-lu.com>
fbsplash: new applet by Michele Sanges <michele.sanges AT otomelara.it

function                                             old     new   delta
fbsplash_main                                          -    1525   +1525
fb_drawfullrectangle                                   -     118    +118
static.param_value                                     -     100    +100
packed_usage                                       23776   23872     +96
applet_names                                        1843    1852      +9
applet_main                                         1120    1124      +4
read_line_input                                     3156    3158      +2
applet_nameofs                                       560     562      +2
applet_install_loc                                   140     141      +1
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 6/0 up/down: 1857/0)           Total: 1857 bytes
   text    data     bss     dec     hex filename
 799233     641    7380  807254   c5156 busybox_old
 801202     641    7380  809223   c5907 busybox_unstripped
2008-03-26 13:32:30 +00:00
Denis Vlasenko cc2965fd23 patch: fix vda's thinko: we need to open new_filename.orig, always!
plug memory leak; add testsuite

patch_main                                          1009     988     -21
2008-03-25 14:15:39 +00:00
Denis Vlasenko 80591b0a00 ash: support for && and || in [[ expr ]]; add testsuite checks 2008-03-25 07:49:43 +00:00
Denis Vlasenko b02cea1212 ifupdown: support for %retries% (L. Gabriel Somlo <somlo AT cmu.edu>) 2008-03-25 06:10:14 +00:00
Denis Vlasenko a1acfc8f37 udhcp: build fix for ppc kernel 2.4.36 2008-03-25 06:04:58 +00:00
Denis Vlasenko 0c3b0d501e lpd: small shrink
lpd_main     761     747     -14
2008-03-25 06:03:19 +00:00
Denis Vlasenko f7d5665969 ash: comment about [[; code style fixes. No code changes. 2008-03-25 05:51:41 +00:00
Denis Vlasenko 68e5e2b1c7 help text shrinkage 2008-03-25 03:17:04 +00:00
Denis Vlasenko fa076d491f date: even more of help text shrink 2008-03-25 02:49:11 +00:00
Denis Vlasenko 9ce4ae8142 date: make help text more understandable; small shrink
text    data     bss     dec     hex filename
 799025     641    7380  807046   c5086 busybox_old
 799009     641    7380  807030   c5076 busybox_unstripped
2008-03-25 02:43:34 +00:00
Denis Vlasenko 92e13c2a11 ash: optional bash-like pattern subst and substring opts
(by James Simmons <jsimmons AT infradead.org>)
TODO: write testsuite!

BASH_COMPAT off:
scanleft                                             101     262    +161
subevalvar                                           346     335     -11
BASH_COMPAT on:
subevalvar                                           346    1397   +1051
scanleft                                             101     262    +161
readtoken1                                          2739    2807     +68
cmdputs                                              397     399      +2
static.vstype                                         64      48     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 1282/-16)         Total: 1266 bytes
2008-03-25 01:17:40 +00:00
Denis Vlasenko 59f351ccda ash: add read -u; fix read -t and read -n; add testsuite entries. 2008-03-25 00:07:12 +00:00
Denis Vlasenko f39653e306 lpd: debugging by Vladimir: he found vda's breakage (trashed s[0])! 2008-03-24 21:19:51 +00:00
Denis Vlasenko cee01cfb2e diff: add testsuite entry for it 2008-03-24 20:33:47 +00:00
Denis Vlasenko dccfe05e17 diff: improve comments (no code chages) 2008-03-24 18:40:32 +00:00
Denis Vlasenko 64a76d7b44 patch: support for patches without dates and generated with -U1; shrink
function                                             old     new   delta
extract_filename                                       -      92     +92
extract_filename_and_free_line                        70       -     -70
patch_main                                          1096    1009     -87
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 92/-157)           Total: -65 bytes
2008-03-24 18:18:03 +00:00
Denis Vlasenko c4c2cd44d2 diff: exclude D_EMPTY code if there is no support for -r
function                                             old     new   delta
diffreg                                             1808    1825     +17
files_differ                                         189     166     -23
2008-03-24 16:55:13 +00:00
Denis Vlasenko e9d67a81c8 diff: fix small bug; don't make a copy for "/dev/null" case 2008-03-24 16:28:47 +00:00
Denis Vlasenko 7fe0ebac5f diff: reordering and renaming of variables
function                                             old     new   delta
diff_main                                            843     848      +5
get_recursive_dirlist                                177     180      +3
add_to_dirlist                                        64      66      +2
change                                               329     326      -3
files_differ                                         182     176      -6
diffreg                                             1823    1808     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/3 up/down: 10/-24)            Total: -14 bytes
2008-03-24 16:19:21 +00:00
Denis Vlasenko 73132b9c12 diff: make a few variables local
function                                             old     new   delta
diffreg                                             1844    1823     -21
2008-03-24 15:04:24 +00:00
Denis Vlasenko 04211fd204 diff: make it work on pipes etc (needed for kernel compile)
function                                             old     new   delta
get_recursive_dirlist                                  -     177    +177
make_temp                                              -     144    +144
diffreg                                             1818    1844     +26
files_differ                                         175     182      +7
diff_main                                            842     843      +1
get_dir                                              177       -    -177
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 355/-177)          Total: 178 bytes
2008-03-24 14:44:59 +00:00
Denis Vlasenko dc1cbf839d diff: shrink
function                                             old     new   delta
check                                                678    1607    +929
files_differ                                           -     175    +175
do_diff                                              436     433      -3
asciifile                                             94      90      -4
print_only                                            23      16      -7
diff_main                                            868     842     -26
prepare                                              339     301     -38
print_status                                         316     178    -138
diffreg                                             2993    1818   -1175
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/7 up/down: 1104/-1391)       Total: -287 bytes
2008-03-24 14:44:20 +00:00
Denis Vlasenko c693840fe8 *: whitespace fixes, no code changes 2008-03-24 02:18:03 +00:00
Denis Vlasenko 42cc304e90 lpr: add more accurate comments
*: trailing whitespace removal
2008-03-24 02:05:58 +00:00
Denis Vlasenko 39c77c3738 lpd: much safer against malicious input. Does not fork anymore,
as this is not needed.
2008-03-24 01:52:52 +00:00
Denis Vlasenko 0b6c6a9c9f lpd: fix OOM vulnerability (was eating arbitrarily large commands) 2008-03-24 00:04:42 +00:00
Denis Vlasenko a79428998d lpd: maintainer's update: now with spool helpers
function                                             old     new   delta
exec_helper                                            -     227    +227
sane                                                  66     117     +51
packed_usage                                       23806   23828     +22
lpd_main                                             486     504     +18
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 318/0)             Total: 318 bytes
2008-03-23 23:40:18 +00:00
Denis Vlasenko c93b162248 patch: shrink by Pascal Bellard <pascal.bellard AT ads-lu.com> (-80 bytes)
*: removal of #include <getopt.h>
2008-03-23 22:55:25 +00:00
Denis Vlasenko 324d26f9aa pscan: fix a typo in help text 2008-03-23 18:44:59 +00:00
Denis Vlasenko 715c16ab0a pscan: add -c, -b: report closed, blocked ports 2008-03-23 14:46:14 +00:00
Denis Vlasenko 69ca5a70fd tail: fix fallout from tail -c optimization 2008-03-23 03:28:40 +00:00
Denis Vlasenko c8bac033f3 bump version to 1.11.0.svn 2008-03-22 17:46:43 +00:00
Denis Vlasenko 45ecfc2f5c taskset: fix false failure in testsuite 2008-03-22 17:46:16 +00:00
Denis Vlasenko b9d0f0c762 webpage: typo fix 2008-03-21 21:22:24 +00:00
Denis Vlasenko 74f8208f18 Bump version to 1.10.0 and announce it on website. 2008-03-21 20:50:37 +00:00
Denis Vlasenko ffa5d76602 update defconfig 2008-03-21 20:37:16 +00:00
Denis Vlasenko 45911a60c3 website: fix double include of menubar 2008-03-21 20:06:42 +00:00
Denis Vlasenko 31567c1c70 webpage: fix English 2008-03-21 18:52:18 +00:00
Denis Vlasenko 68d09697c9 website: announce stable point releases 2008-03-21 18:41:21 +00:00
Denis Vlasenko 4824ccae8e *: fix build problems found with randomconfig 2008-03-21 18:29:01 +00:00
Denis Vlasenko 0dc490bda2 scripts/bb_release: release script (I nearly lost it last time)
website: update links to latest releases
2008-03-21 09:56:19 +00:00
Denis Vlasenko f90ab183d6 *: use fopen_or_warn in few more places 2008-03-20 21:19:35 +00:00
Paul Fox 275b929e01 let top build without TERMIOS enabled 2008-03-20 16:05:02 +00:00
Paul Fox 9e1f92d0bb termios can be used by either top or more. 2008-03-20 16:04:36 +00:00
Denis Vlasenko 9230582315 inetd: use change_identity().
libbb: shrink our internal initgroups().
httpd: remove stray 'else' and 'index_page = "index.html"'

function                                             old     new   delta
httpd_main                                           750     743      -7
inetd_main                                          2033    2011     -22
bb_internal_initgroups                               251     228     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-52)             Total: -52 bytes
2008-03-20 15:12:58 +00:00
Denis Vlasenko c52248e41c small NOMMU fixes 2008-03-20 14:04:30 +00:00
Denis Vlasenko 3c96d0258c hdparm: do not lie about supporting -q (quiet)
hdparm: interpret_standby() shrink
hdparm: make HDIO_GET/SET_QDMA #ifdef more complete
 (by Joe Krahn <krahn AT niehs.nih.gov>)

function                                             old     new   delta
packed_usage                                       23798   23776     -22
process_dev                                         5342    5315     -27
2008-03-20 13:44:50 +00:00
Denis Vlasenko 0f3a580c4f gcc compat fix and warning suppression
by Joe Krahn <krahn AT niehs.nih.gov>
2008-03-20 13:13:09 +00:00
Denis Vlasenko 027271e5a9 udhcp: fix wrong order of args here: index_in_strings(opt, dhcp_option_strings);
code shrink while at it:

function                                             old     new   delta
read_config                                          406     323     -83
2008-03-20 12:47:01 +00:00
Denis Vlasenko 0a0180cdc5 tftpd: small trivial shrink
tftpd_main                                           502     488     -14
2008-03-19 23:37:32 +00:00
Denis Vlasenko 104d544fd7 die_if_bad_username: shrink: 88 -> 77 bytes 2008-03-19 23:25:00 +00:00
Denis Vlasenko dd5702d696 ...and actually adding new file now... 2008-03-19 23:15:55 +00:00
Denis Vlasenko a7d6c8bab9 adduser/addgroup: check username for invalid chars
(by Tito <farmatito AT tiscali.it>). +129 bytes when enabled.
2008-03-19 23:15:26 +00:00
Denis Vlasenko cf7cf62204 *: s/BB_SIGS_FATAL/BB_FATAL_SIGS/ (latter proved easier to remember)
top: fix "top </dev/null" case (by Cristian Ionescu-Idbohrn)
2008-03-19 19:38:46 +00:00
Denis Vlasenko 0764a7f72d ifupdown: make it NOMMU-capable 2008-03-19 16:24:17 +00:00
Denis Vlasenko 7a60133c6c tftpd: fix download: we must change user AFTER bind
tftp_protocol                                       1466    1468      +2
2008-03-19 13:24:13 +00:00
Denis Vlasenko 403a5a298e tftpd: options -c (allow _new_ files to be uploaded) and -u USER
function                                             old     new   delta
tftp_protocol                                       1316    1466    +150
packed_usage                                       23774   23798     +24
tftpd_main                                           509     502      -7
tftp_main                                            311     252     -59
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 174/-66)           Total: 108 bytes
   text    data     bss     dec     hex filename
 797700     641    7380  805721   c4b59 busybox_old
 797833     641    7380  805854   c4bde busybox_unstripped
2008-03-19 13:07:00 +00:00
Denis Vlasenko 71c9f015e9 tftp(d): a bit more verbose error reporting 2008-03-19 09:43:50 +00:00
Denis Vlasenko dd9228b861 tftpd: make it emit error packets
telnetd: use login always, not "sometimes login, sometimes shell"

   text    data     bss     dec     hex filename
 797612     641    7380  805633   c4b01 busybox_old
 797695     641    7380  805716   c4b54 busybox_unstripped
2008-03-19 05:00:05 +00:00
Denis Vlasenko c0183e6e0d unlzma: shrink by Pascal Bellard <pascal.bellard AT ads-lu.com> 2008-03-18 03:13:25 +00:00
Denis Vlasenko 6aa7696e28 mount: #ifdef out MOUNT_LABEL code parts if it is not selected 2008-03-18 01:44:52 +00:00
Denis Vlasenko 2a7a451391 patch: don't trash permissions of patched file 2008-03-18 01:38:04 +00:00
Denis Vlasenko d7e6af2dda tftpd: make open() check r/w permissions instead of doing it ourself.
Add -r "prohibit upload" opt for those lazy people who run tftpd as root.
-40 bytes.
2008-03-18 01:13:11 +00:00
Denis Vlasenko 78c5656530 tftpd: fix bugs spotted by Vladimir 2008-03-18 00:11:46 +00:00
Denis Vlasenko e421b5ebf6 init: do not close all descriptors > 2. We were doing it - sometimes.
Good choices are "do it, always" or "don't do it". Second is smaller.
2008-03-17 22:01:42 +00:00
Paul Fox 2724fa9d8a remove alarm() calls which were functioning as a primitive
watchdog function, presumably to catch infinite loop bugs. 
(control-C can do the same thing, and the alarms were too short in
any case.)  also, switch to sigsetjmp/siglongjmp in order to allow
repeated use of control-C -- otherwise it works once, then not again.
2008-03-17 15:28:07 +00:00
Denis Vlasenko fb274df079 init: do not use bb_sanitize_stdio(), "/dev/null" may be missing (yet) 2008-03-17 13:26:51 +00:00
Denis Vlasenko 9c8c038981 httpd: small fixlet for POST upload - skip
whitespace between "Content-length:" and number
2008-03-17 12:58:19 +00:00
Denis Vlasenko d1277c6052 remove extra spaces in help text; delete duplicate #define 2008-03-17 09:37:24 +00:00
Denis Vlasenko d0a071a528 brctl: eliminate stray data object
brctl: use constant fd to reduce parameter passing
runsvdir: do not use data/bss
od: reuse bb_argv_dash
last: do not go into endless loop on read error
mount: make it not fail scripts/find_bad_common_bufsiz check
dc: add INIT_G() (no-op for dc, but we want uniform usage of "G trick")

function                                             old     new   delta
runsvdir_main                                       1646    1672     +26
set_pgrp                                               1       -      -1
exitsoon                                               1       -      -1
check                                                679     678      -1
svnum                                                  4       -      -4
svdir                                                  4       -      -4
sv                                                     4       -      -4
stamplog                                               4       -      -4
rploglen                                               4       -      -4
rplog                                                  4       -      -4
mount_main                                           995     988      -7
static.default_file_list                               8       -      -8
pfd                                                    8       -      -8
logpipe                                                8       -      -8
static.info                                           20       -     -20
brctl_main                                           767     739     -28
------------------------------------------------------------------------------
(add/remove: 0/12 grow/shrink: 1/3 up/down: 26/-106)          Total: -80 bytes
   text    data     bss     dec     hex filename
 793327     662    7412  801401   c3a79 busybox_old
 793329     641    7372  801342   c3a3e busybox_unstripped
2008-03-17 09:33:45 +00:00
Denis Vlasenko b44c790e41 *: fix various kinds of damage to letter 'c' in Arkadiusz Mickiewicz' surname.
chrt,taskset,dc,eject: shrink
crontab: call "vi" with just name, no path
watchdog: intercept all fatal signals

function                                             old     new   delta
xstrtoull_range                                        -      35     +35
static.sg_commands                                     -      18     +18
packed_usage                                       23698   23712     +14
watchdog_main                                        148     151      +3
crontab_main                                         637     638      +1
base                                                   1       -      -1
static.ps                                              4       -      -4
pointer                                                4       -      -4
stack_machine                                         99      92      -7
run_command                                          273     260     -13
eject_main                                           360     343     -17
static.C                                              30      12     -18
ptok                                                  61      38     -23
xstrtol_range                                         27       -     -27
get_token                                             35       -     -35
taskset_main                                         586     550     -36
chrt_main                                            411     372     -39
dc_main                                              158     117     -41
time_main                                           1127    1037     -90
------------------------------------------------------------------------------
(add/remove: 2/5 grow/shrink: 3/9 up/down: 71/-355)          Total: -284 bytes
   text    data     bss     dec     hex filename
 793680     662    7420  801762   c3be2 busybox_old
 793327     662    7412  801401   c3a79 busybox_unstripped
2008-03-17 09:29:43 +00:00
Denis Vlasenko d25c33f186 volume_id: disable detection routines which are not setting label and uuid anyway
function                                             old     new   delta
static.warn                                            1       -      -1
static.drive_name_string                              14      12      -2
static.offsets                                         8       -      -8
static.sectors                                        10       -     -10
fs2                                                   60      48     -12
raid2                                                 16       -     -16
uuidcache_init                                       704     677     -27
raid1                                                 32       -     -32
volume_id_probe_all                                  198     158     -40
volume_id_probe_lvm1                                  58       -     -58
volume_id_probe_highpoint_37x_raid                    63       -     -63
volume_id_probe_hpfs                                  67       -     -67
volume_id_probe_minix                                 74       -     -74
volume_id_probe_lvm2                                  78       -     -78
volume_id_probe_silicon_medley_raid                   97       -     -97
volume_id_probe_via_raid                             101       -    -101
volume_id_probe_highpoint_45x_raid                   104       -    -104
volume_id_probe_nvidia_raid                          108       -    -108
volume_id_probe_lsi_mega_raid                        108       -    -108
volume_id_probe_intel_software_raid                  108       -    -108
volume_id_probe_ufs                                  126       -    -126
volume_id_probe_promise_fasttrack_raid               144       -    -144
------------------------------------------------------------------------------
(add/remove: 0/18 grow/shrink: 0/4 up/down: 0/-1384)        Total: -1384 bytes
   text    data     bss     dec     hex filename
 794244     662    7420  802326   c3e16 busybox_old
 792698     662    7420  800780   c380c busybox_unstripped
2008-03-17 09:25:05 +00:00
Denis Vlasenko c5b737231d volude_id: remove unused fields and functions which were setting them
function                                             old     new   delta
uuidcache_init                                       567     704    +137
findfs_main                                            -     125    +125
packed_usage                                       23662   23694     +32
static.drive_name_string                               -      14     +14
applet_names                                        1815    1822      +7
applet_main                                         1104    1108      +4
volume_id_open_node                                   35      38      +3
applet_nameofs                                       552     554      +2
get_devname_from_label                                78      79      +1
applet_install_loc                                   138     139      +1
volume_id_set_label_unicode16                         31      27      -4
volume_id_set_label_string                            74      70      -4
get_devname_from_uuid                                 63      59      -4
fs1                                                   12       8      -4
volume_id_set_unicode16                              209     202      -7
volume_id_free_buffer                                 71      56     -15
free_volume_id                                        52      37     -15
volume_id_probe_luks                                  97      79     -18
volume_id_set_usage_part                              21       -     -21
volume_id_probe_ufs                                  148     126     -22
volume_id_probe_lsi_mega_raid                        131     108     -23
volume_id_probe_highpoint_45x_raid                   127     104     -23
volume_id_probe_highpoint_37x_raid                    87      63     -24
volume_id_set_usage                                   28       -     -28
volume_id_probe_romfs                                121      93     -28
volume_id_set_label_raw                               30       -     -30
volume_id_probe_promise_fasttrack_raid               174     144     -30
volume_id_set_uuid                                   373     342     -31
volume_id_probe_xfs                                  122      91     -31
volume_id_probe_jfs                                  138     107     -31
volume_id_probe_ocfs2                                139     107     -32
volume_id_probe_lvm1                                  90      58     -32
volume_id_probe_cramfs                               106      63     -43
volume_id_probe_via_raid                             145     101     -44
volume_id_probe_intel_software_raid                  153     108     -45
volume_id_probe_minix                                121      74     -47
volume_id_probe_udf                                  682     632     -50
volume_id_probe_nvidia_raid                          158     108     -50
volume_id_probe_lvm2                                 128      78     -50
volume_id_probe_hpfs                                 117      67     -50
volume_id_probe_ext                                  143      93     -50
volume_id_probe_linux_raid                           191     139     -52
volume_id_probe_sysv                                 244     187     -57
volume_id_probe_silicon_medley_raid                  158      97     -61
usage_to_string                                       64       -     -64
volume_id_probe_linux_swap                           263     198     -65
volume_id_get_buffer                                 372     307     -65
volume_id_probe_iso9660                              412     332     -80
volume_id_probe_hfs_hfsplus                          888     806     -82
volume_id_probe_ntfs                                 396     294    -102
volume_id_probe_vfat                                 980     872    -108
volume_id_probe_reiserfs                             417     268    -149
dev_get_major_minor                                  175       -    -175
uuidcache_check_device                               692     499    -193
volume_id_probe_mac_partition_map                    697       -    -697
------------------------------------------------------------------------------
(add/remove: 2/6 grow/shrink: 8/39 up/down: 326/-2836)      Total: -2510 bytes
   text    data     bss     dec     hex filename
 797220     662    7420  805302   c49b6 busybox_old
 794244     662    7420  802326   c3e16 busybox_unstripped
2008-03-17 09:21:26 +00:00
Denis Vlasenko 592d4fe772 selinux/*: -Wunused-parameter fixes
runsv: make it NOMMU-capable

function                                             old     new   delta
startservice                                         291     313     +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 22/0)               Total: 22 bytes
2008-03-17 09:19:26 +00:00
Denis Vlasenko 4866e905d7 svn add/svn rm to actually move tcp/udpsvd... 2008-03-17 09:17:27 +00:00
Denis Vlasenko 4ee7cd4f6f *: mode tcp/udpsvd to networking, delete ipsvd/*
*/Config.in: fixes to text
svlogd: make it NOMMU capable

function                                             old     new   delta
processorstart                                       378     420     +42
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 42/0)               Total: 42 bytes
   text    data     bss     dec     hex filename
 797153     662    7420  805235   c4973 busybox_old
 797196     662    7420  805278   c499e busybox_unstripped
2008-03-17 09:13:22 +00:00
Denis Vlasenko aa9b1828b9 tftpd: new applet (mostly using existing code for tftp)
function                                             old     new   delta
tftp_protocol                                          -    1173   +1173
tftpd_main                                             -     500    +500
tftp_option_get                                        -     102    +102
packed_usage                                       23650   23662     +12
applet_names                                        1809    1815      +6
applet_main                                         1100    1104      +4
applet_nameofs                                       550     552      +2
tftp_main                                            302     301      -1
get_nport                                             32       -     -32
tftp                                                1172       -   -1172
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 4/1 up/down: 1799/-1205)        Total: 594 bytes
   text    data     bss     dec     hex filename
 796479     662    7420  804561   c46d1 busybox_old
 797153     662    7420  805235   c4973 busybox_unstripped
2008-03-17 09:10:39 +00:00
Denis Vlasenko 1d42665b6b *: shrink: use Vladimir's "o+" specifier instead of xatou(opt_param)
function                                             old     new   delta
getopt32                                            1370    1385     +15
sulogin_main                                         490     494      +4
realpath_main                                         84      86      +2
sleep_main                                            76      77      +1
mt_main                                              256     257      +1
printenv_main                                         75      74      -1
fdformat_main                                        546     545      -1
usleep_main                                           44      42      -2
setlogcons_main                                       77      75      -2
ed_main                                             2654    2649      -5
deallocvt_main                                        69      64      -5
addgroup_main                                        373     368      -5
mkfs_minix_main                                     2989    2982      -7
tail_main                                           1221    1213      -8
sv_main                                             1254    1241     -13
du_main                                              348     328     -20
tftp_main                                            325     302     -23
split_main                                           581     558     -23
nc_main                                             1000     977     -23
diff_main                                            891     868     -23
arping_main                                         1797    1770     -27
ls_main                                              893     847     -46
od_main                                             2797    2750     -47
readprofile_main                                    1944    1895     -49
tcpudpsvd_main                                      1973    1922     -51
udhcpc_main                                         2590    2513     -77
grep_main                                            824     722    -102
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/22 up/down: 23/-560)         Total: -537 bytes
   text    data     bss     dec     hex filename
 796973     658    7428  805059   c48c3 busybox_old
 796479     662    7420  804561   c46d1 busybox_unstripped
2008-03-17 09:09:09 +00:00
Denis Vlasenko 62a90cdd74 *: shrink by using [f]open_or_warn_stdin where appropriate
function                                             old     new   delta
lsattr_main                                           62     143     +81
open_or_warn_stdin                                     -      36     +36
fclose_if_not_stdin                                   20      47     +27
xfopen_stdin                                           -      20     +20
tac_main                                             336     356     +20
cksum_main                                           249     259     +10
bb_argv_dash                                           -       8      +8
su_main                                              448     455      +7
cmp_main                                             630     633      +3
passwd_main                                         1072    1074      +2
uudecode_main                                        317     315      -2
text_yank                                            110     108      -2
handle_incoming_and_exit                            2653    2651      -2
flags                                                  5       1      -4
write_leases                                         235     230      -5
fopen_or_warn_stdin                                   48      42      -6
fold_main                                            648     642      -6
static.argv_dash                                       8       -      -8
sum_main                                             142     128     -14
tail_main                                           1237    1221     -16
sed_main                                             711     695     -16
cmp_xfopen_input                                      17       -     -17
bb_cat                                               113      96     -17
catv_main                                            328     306     -22
strings_main                                         457     434     -23
hash_file                                            298     274     -24
sum_file                                             353     325     -28
sort_main                                            904     859     -45
expand_main                                          736     686     -50
cut_main                                            1116    1065     -51
md5_sha1_sum_main                                    549     493     -56
lsattr_args                                           90       -     -90
read_stduu                                           408     255    -153
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 7/20 up/down: 214/-657)        Total: -443 bytes
   text    data     bss     dec     hex filename
 797417     658    7428  805503   c4a7f busybox_old
 796973     658    7428  805059   c48c3 busybox_unstripped
2008-03-17 09:07:36 +00:00
Denis Vlasenko d02db89244 clean up TODO file. No real code changes. 2008-03-17 09:05:21 +00:00
Denis Vlasenko 85c247161b *: fix fallout from -Wunused-parameter
function                                             old     new   delta
bbunpack                                             358     366      +8
passwd_main                                         1070    1072      +2
handle_incoming_and_exit                            2651    2653      +2
getpty                                                88      86      -2
script_main                                          975     972      -3
inetd_main                                          2036    2033      -3
dname_enc                                            377     373      -4
make_new_session                                     474     462     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/5 up/down: 12/-24)            Total: -12 bytes
   text    data     bss     dec     hex filename
 797429     658    7428  805515   c4a8b busybox_old
 797417     658    7428  805503   c4a7f busybox_unstripped
2008-03-17 09:04:04 +00:00
Denis Vlasenko 081eb71ebd dnsd: properly set _src_ IP:port on outgoing UDP packets
function                                             old     new   delta
send_to_from                                           -     258    +258
dnsd_main                                           1500    1568     +68
interrupt                                             17      19      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 328/0)             Total: 328 bytes
   text    data     bss     dec     hex filename
 797101     658    7428  805187   c4943 busybox_old
 797429     658    7428  805515   c4a8b busybox_unstripped
2008-03-17 09:02:21 +00:00
Denis Vlasenko 68404f13d4 *: add -Wunused-parameter; fix resulting breakage
function                                             old     new   delta
procps_scan                                         1265    1298     +33
aliascmd                                             278     283      +5
parse_file_cmd                                       116     120      +4
dname_enc                                            373     377      +4
setcmd                                                90      93      +3
execcmd                                               57      60      +3
count_lines                                           72      74      +2
process_command_subs                                 340     339      -1
test_main                                            409     407      -2
mknod_main                                           179     177      -2
handle_incoming_and_exit                            2653    2651      -2
argstr                                              1312    1310      -2
shiftcmd                                             131     128      -3
exitcmd                                               46      43      -3
dotcmd                                               297     294      -3
breakcmd                                              86      83      -3
evalpipe                                             353     349      -4
evalcommand                                         1180    1176      -4
evalcmd                                              109     105      -4
send_tree                                            374     369      -5
mkfifo_main                                           82      77      -5
evalsubshell                                         152     147      -5
typecmd                                               75      69      -6
letcmd                                                61      55      -6
add_cmd                                             1190    1183      -7
main                                                 891     883      -8
ash_main                                            1415    1407      -8
parse_stream                                        1377    1367     -10
alloc_procps_scan                                     55       -     -55
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/21 up/down: 54/-148)          Total: -94 bytes
   text    data     bss     dec     hex filename
 797195     658    7428  805281   c49a1 busybox_old
 797101     658    7428  805187   c4943 busybox_unstripped
2008-03-17 09:00:54 +00:00
Denis Vlasenko a55bd05f3c fsck: shrink (we were passing around some params which were unused)
function                                             old     new   delta
fsck_main                                           1807    2256    +449
fsck_device                                          196     189      -7
create_fs_device                                     131     124      -7
wait_one                                             325     309     -16
wait_many                                             52      33     -19
free_instance                                         38       -     -38
packed_usage                                       23698   23650     -48
execute                                             2508    2402    -106
check_all                                            609       -    -609
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/6 up/down: 449/-850)         Total: -401 bytes
   text    data     bss     dec     hex filename
 797604     658    7428  805690   c4b3a busybox_old
 797195     658    7428  805281   c49a1 busybox_unstripped
2008-03-17 08:59:19 +00:00
Denis Vlasenko 397de617f3 help text: regularize format, and shrink
getty: shrink, and improve comments
mount: OPT_ALL is superfluous, we already have OPT_a

function                                             old     new   delta
bcode                                                 47      25     -22
getty_main                                          2503    2349    -154
packed_usage                                       23928   23698    -230
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-406)           Total: -406 bytes
   text    data     bss     dec     hex filename
 798031     658    7428  806117   c4ce5 busybox_old
 797604     658    7428  805690   c4b3a busybox_unstripped
2008-03-17 08:55:44 +00:00
Denis Vlasenko a4522c5a66 mount: plug a hole where FEATURE_MOUNT_HELPERS could allow execution
of arbitrary command.

function                                             old     new   delta
mount_it_now                                         266     309     +43
2008-03-17 08:46:43 +00:00
Denis Vlasenko afc4113ed7 fuser: bugfixes and shrink. It was assuming that xmalloc zeroes returned area!
function                                             old     new   delta
scan_dir_links                                         -     106    +106
add_inode                                              -      89     +89
scan_link                                              -      78     +78
file_to_dev_inode                                      -      64     +64
search_dev_inode                                       -      63     +63
add_pid                                                -      39     +39
packed_usage                                       23948   23928     -20
fuser_add_pid                                         49       -     -49
fuser_file_to_dev_inode                               64       -     -64
fuser_search_dev_inode                                77       -     -77
fuser_scan_link                                       91       -     -91
fuser_scan_dir_links                                 108       -    -108
fuser_add_inode                                      124       -    -124
fuser_main                                          1450    1243    -207
------------------------------------------------------------------------------
(add/remove: 6/6 grow/shrink: 0/2 up/down: 439/-740)         Total: -301 bytes
   text    data     bss     dec     hex filename
 798327     658    7428  806413   c4e0d busybox_old
 797988     658    7428  806074   c4cba busybox_unstripped
2008-03-17 08:44:58 +00:00
Denis Vlasenko cdf62770af dos2unix: tiny shrink
login,su: fix setup_environment() so that it works as intended
          (parameter names were a bit misleading)
fdisk: shrink
help text: shrink

function                                             old     new   delta
login_main                                          1658    1701     +43
setup_environment                                    206     203      -3
dos_compatible_flag                                    4       1      -3
dos2unix_main                                        383     375      -8
get_boot                                            1724    1702     -22
fdisk_main                                          2949    2889     -60
packed_usage                                       24250   23948    -302
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 43/-398)          Total: -355 bytes
   text    data     bss     dec     hex filename
 798768     661    7428  806857   c4fc9 busybox_old
 798327     658    7428  806413   c4e0d busybox_unstripped
2008-03-17 08:42:43 +00:00
Denis Vlasenko 107fe7c081 less: improve search when data is not supplied fast enough by stdin -
now will try reading for 1-2 seconds before declaring that there is no match.
This fixes a very common annoyance with long manpages.

function                                             old     new   delta
read_lines                                           653     719     +66
buffer_down                                           28      83     +55
goto_match                                           140     141      +1
cap_cur_fline                                         72       -     -72
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/0 up/down: 122/-72)            Total: 50 bytes
   text    data     bss     dec     hex filename
 798734     661    7428  806823   c4fa7 busybox_old
 798768     661    7428  806857   c4fc9 busybox_unstripped
2008-03-17 08:38:45 +00:00
Denis Vlasenko aefed941c2 tcpsvd,udpsvd: make them NOMMU-capable
inetd: make udp nowait work

function                                             old     new   delta
inetd_main                                          1797    2036    +239
tcpudpsvd_main                                      1839    1973    +134
xsetenv_plain                                          -      39     +39
xsetenv_proto                                         23      40     +17
bump_nofile                                          169     170      +1
sig_term_handler                                      72      69      -3
sig_child_handler                                    239     233      -6
connection_status                                     37      31      -6
parse_one_line                                      1102    1092     -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/4 up/down: 430/-25)           Total: 405 bytes
   text    data     bss     dec     hex filename
 798437     661    7428  806526   c4e7e busybox_old
 798734     661    7428  806823   c4fa7 busybox_unstripped
2008-03-17 08:35:44 +00:00
Denis Vlasenko 9f153f610f fsck_minix: getopt32-ification; code shrink; reduce stack usage;
fix bug in map_block2: s/(blknr >= 256 * 256)/(blknr < 256 * 256)/

function                                             old     new   delta
get_inode_common                                       -     291    +291
add_zone_common                                        -     205    +205
ask                                                  229     215     -14
write_super_block                                    109      90     -19
write_block                                          653     629     -24
bad_zone                                              95      64     -31
read_block                                           241     198     -43
fsck_minix_main                                     3285    3195     -90
add_zone2                                            217      34    -183
add_zone                                             216      33    -183
recursive_check                                     1097     866    -231
recursive_check2                                    1340     956    -384
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/10 up/down: 496/-1202)       Total: -706 bytes
   text    data     bss     dec     hex filename
 799349     661    7428  807438   c520e busybox_old
 798437     661    7428  806526   c4e7e busybox_unstripped
2008-03-17 08:32:26 +00:00
Denis Vlasenko 3f165fa5b3 libbb: introduce and use sigprocmask_allsigs and sigaction_set.
libbb: rename sig_pause to wait_for_any_sig.
2008-03-17 08:29:08 +00:00
Denis Vlasenko 8e2cfec1cd libbb: introduse and use signal_[no_]SA_RESTART_empty_mask and sigaction_set
signal_SA_RESTART_empty_mask                           -      65     +65
signal_no_SA_RESTART_empty_mask                        -      54     +54
dd_main                                             1325    1369     +44
sigaction_set                                          -      19     +19
dname_enc                                            373     377      +4
UNSPEC_print                                          64      66      +2
setsignal                                            296     294      -2
bb_signals_recursive                                  95      92      -3
bb_askpass                                           367     361      -6
inetd_main                                          1810    1797     -13
rx_main                                              912     883     -29
sigdelset                                             32       -     -32
__sigdelset                                           32       -     -32
__GI_sigdelset                                        32       -     -32
sighup_handler                                        84      37     -47
arping_main                                         1844    1797     -47
fsck_main                                           1869    1807     -62
run_list                                            1917    1844     -73
vlock_main                                           492     409     -83
progressmeter                                        883     798     -85
handle_incoming_and_exit                            2737    2651     -86
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 3/12 up/down: 188/-632)        Total: -444 bytes
2008-03-12 23:19:35 +00:00
Denis Vlasenko 4cf1d08fc2 nc: remove a bit of bloat
inetd: more NOMMU fixes
rx: shrink
devfsd: minor shrink
vlock: shrink
tcpudp: narrow down window where we have no wildcard socket

parse_one_line                                      1015    1102     +87
init_ring                                              -      53     +53
xzalloc_lsa                                            -      48     +48
read_byte                                             51      50      -1
rearm_alarm                                           28      25      -3
nc_main                                             1028    1000     -28
initring                                              53       -     -53
vlock_main                                           583     496     -87
reread_config_file                                  1089     991     -98
rx_main                                             1046     912    -134
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/6 up/down: 188/-404)         Total: -216 bytes
   text    data     bss     dec     hex filename
 800120     661    7428  808209   c5511 busybox_old
 799796     661    7428  807885   c53cd busybox_unstripped
2008-03-12 23:13:50 +00:00
Denis Vlasenko 4e6d5117b8 inetd: make it NOMMU-capable and IPv6-friendly. Lots of renames
of variable/function names

Total: -2474 bytes
   text    data     bss     dec     hex filename
 802215     661    7452  810328   c5d58 busybox_old
 800120     661    7428  808209   c5511 busybox_unstripped
2008-03-12 22:14:34 +00:00
Denis Vlasenko 4e6c8120a5 crond: make it NOMMU-capable
function                                             old     new   delta
safe_setenv4                                           -      62     +62
ForkJob                                              472     511     +39
change_identity                                       21      57     +36
ParseField                                           564     571      +7
SynchronizeDir                                       178     176      -2
LogLevel                                               4       -      -4
LogFile                                                4       -      -4
FileBase                                               4       -      -4
DebugOpt                                               4       -      -4
CDir                                                   4       -      -4
DeleteFile                                           141     132      -9
packed_usage                                       24248   24228     -20
crondlog                                             157     113     -44
change_identity_e2str                                 54       -     -54
SynchronizeFile                                      729     671     -58
crond_main                                          1555    1404    -151
------------------------------------------------------------------------------
(add/remove: 1/6 grow/shrink: 3/6 up/down: 144/-358)         Total: -214 bytes
2008-03-12 22:10:25 +00:00
Paul Fox 35e9c5d83a fixups to vi usage, and move the initial redraw() past the
execution of commands supplied by -c or EXINIT, so their
effect is displayed correctly.
2008-03-06 16:26:12 +00:00
Paul Fox c51fc7bed6 fixed the "dot" (i.e. '.') command, to properly re-init its
buffer between commands, not recalculate its length all the time,
and to not reallocate its fixed-length buffer frequently.

fixed the 'c', 'd', and 'y' commands to properly handle both motions
that are just part of a line, and those that are multiline.  for
instance, now "c%" and "2cw" work correctly, whether the motions span
lines or not.

added some permissble motions for 'c', 'd', and 'y':  namely 'h',
'l', SPACE, BS, and DEL
2008-03-06 01:34:23 +00:00
Paul Fox b4a5087ee0 define DEBUG as 0, for when ENABLE_FEATURE_DEVPTS is not on. 2008-03-05 22:01:45 +00:00
Paul Fox 4917c11432 fix vi's '?' and '/' commands to correctly set a new direction
when reusing a previous search pattern.  previously only 'n' and 'N'
reversed directions properly.
2008-03-05 16:44:02 +00:00
Denis Vlasenko a43dba76ea msh: create testsuite (based on hush one)
hush: add TODO (doesn't know ":" command)
2008-03-02 19:57:53 +00:00
Denis Vlasenko 444639cc21 unlzma: save a few more bytes, and maybe even a bit faster now 2008-03-02 18:56:23 +00:00
Denis Vlasenko c3fff877e1 unlzma: if !LZMA_FAST, save ~200 more bytes (Pascal Bellard <pascal.bellard AT ads-lu.com>) 2008-03-02 18:55:49 +00:00
Denis Vlasenko 4aafd5f4e3 msh: a few fields renamed; short->int conversion for a field
holding file descriptors; short->smalling for flag field

synio                                                263     264      +1
readc                                                247     242      -5
forkexec                                            1339    1307     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-37)             Total: -36 bytes
2008-03-02 14:33:26 +00:00
Denis Vlasenko d18f52bd18 actually add bb_qsort.c
*: s/Denis/Denys/
2008-03-02 12:53:15 +00:00
Denis Vlasenko fb29038b59 libbb: inntroduce and use bb_pstrcmp() and qsort_string_vector()
msh: glob0/glob1/glob2/glob3 are just a sorting routine! remove them.

bb_pstrcmp                                             -      25     +25
qsort_string_vector                                    -      24     +24
expand                                              2209    2227     +18
getopt32                                            1359    1370     +11
passwd_main                                         1072    1074      +2
handle_incoming_and_exit                            2737    2735      -2
UNSPEC_print                                          66      64      -2
forkexec                                            1343    1339      -4
input_tab                                           3338    3330      -8
get_dir                                              185     177      -8
expmeta                                              481     473      -8
cmdputs                                              405     397      -8
xstrcmp                                               12       -     -12
find_pair                                            187     167     -20
match_compare                                         25       -     -25
dir_strcmp                                            25       -     -25
glob2                                                 27       -     -27
glob3                                                 34       -     -34
glob1                                                256       -    -256
------------------------------------------------------------------------------
(add/remove: 2/6 grow/shrink: 3/8 up/down: 80/-439)          Total: -359 bytes
2008-03-02 12:51:26 +00:00
Denis Vlasenko 509697f00d msh: renames: ->words => ->op_words, space() => get_space()
msh: simplify glob0/glob1/glob2/glob3

get_space                                              -      26     +26
glob3                                                 35      34      -1
glob2                                                 28      27      -1
strsave                                               55      53      -2
globv                                                  4       -      -4
func                                                   4       -      -4
xstrcmp                                               25      12     -13
dodot                                                178     164     -14
rexecve                                              272     257     -15
space                                                 26       -     -26
glob1                                                292     256     -36
expand                                              2246    2209     -37
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 0/8 up/down: 26/-153)          Total: -127 bytes
2008-03-02 12:49:39 +00:00
Denis Vlasenko da8ae75340 doc: add info about sed s/.../.../I modifier 2008-03-01 19:29:56 +00:00
Denis Vlasenko fe2188378c msh: fix for bug 846 ("break" didn't work second time)
msh: don't use floating point in "times" builtin
+4 bytes difference
2008-03-01 09:35:39 +00:00
Denis Vlasenko 8a2e421f26 nmeter: fix bug where %[mf] behaves as %[mt] 2008-02-29 07:46:19 +00:00
Denis Vlasenko 19fb67eee4 run-parts: add --reverse 2008-02-28 21:30:22 +00:00
Denis Vlasenko b29028e351 zcip: chdiring to root when daemonizing is not useful,
only makes strip writer's life more miserable. Who want
to have zcip run in root dir, can trivially do that.
2008-02-28 18:02:23 +00:00
Denis Vlasenko f39c7c0c86 sed: n cmd must reset "we had successful subst" flag. closes bug 1214. 2008-02-28 17:59:01 +00:00
Denis Vlasenko cd174d1f31 microcom: shrink 2008-02-28 13:14:42 +00:00
Denis Vlasenko 32fd76c1d5 script: correctly handle buffered "tail" of output. +35 bytes. 2008-02-28 10:10:10 +00:00
Bernhard Reutner-Fischer 93e1a215af - Don't point to obsolete patches but the current fixes for the stable releases 2008-02-27 21:42:13 +00:00
Bernhard Reutner-Fischer 3444bd4fc2 - update docs to point to the current stable branch 2008-02-27 21:28:02 +00:00
Bernhard Reutner-Fischer 51f421a55c - fix compilation failure due to implicit decl of resolve_mount_spec().
DCE DTRT so remove the wrong guard.
2008-02-27 21:14:52 +00:00
Denis Vlasenko 1acb4ef87e httpd: fix breakage introduced by "support for I:index.xml" 2008-02-27 20:59:54 +00:00
Denis Vlasenko 574f2f4394 *: add optimization barrier to all "G trick" locations 2008-02-27 18:41:59 +00:00
Denis Vlasenko fe66a0eca1 lpr: removed stdio; added "job received" message in verbose mode. 2008-02-27 14:35:21 +00:00
Denis Vlasenko c8f2f74ddd libbb: add forgotten part of "script" applet change 2008-02-27 14:33:28 +00:00
Denis Vlasenko 5014dada3f script: new applet by Pascal Bellard <pascal.bellard AT ads-lu.com> 2008-02-27 11:54:59 +00:00
Denis Vlasenko 8195d20e36 sendmail: yet another maintainer's update 2008-02-27 09:39:04 +00:00
Denis Vlasenko 17db1a9ac1 sendmail: update from maintainer 2008-02-26 21:13:17 +00:00
Denis Vlasenko 7be1030dcc lpr: fflush stdout fix 2008-02-26 20:23:02 +00:00
Denis Vlasenko be048f21e6 syslogd: optional support for dropping dups. closes bug 436. 2008-02-26 20:13:52 +00:00
Denis Vlasenko 06aed4316e ifenslave: new applet. closes bug 115. 2008-02-26 18:25:24 +00:00
Denis Vlasenko 04bb2d2d06 start_stop_daemon: stop using data/bss
function                                             old     new   delta
start_stop_daemon_main                               749     770     +21
do_procinit                                          184     185      +1
quiet                                                  1       -      -1
userspec                                               4       -      -4
user_id                                                4       -      -4
signal_nr                                              4       -      -4
pidfile                                                4       -      -4
found                                                  4       -      -4
execname                                               4       -      -4
cmdname                                                4       -      -4
------------------------------------------------------------------------------
(add/remove: 0/8 grow/shrink: 2/0 up/down: 22/-29)             Total: -7 bytes
2008-02-26 16:08:02 +00:00
Denis Vlasenko d4f0b9476a reset: call "stty sane". Closes bug 1414.
reset_main                                            26      59     +33
static.args                                            -      12     +12
2008-02-26 15:33:10 +00:00
Denis Vlasenko d686482d05 actually add libbb/safe_gethostname.c 2008-02-25 23:24:32 +00:00
Denis Vlasenko 6f1713f216 *: intrduce and use safe_gethostname. By Tito <farmatito AT tiscali.it>
safe_gethostname                                       -      48     +48
glob3                                                 35      37      +2
timestamp_and_log                                    314     315      +1
udhcp_send_kernel_packet                             234     231      -3
scan_tree                                            275     271      -4
passwd_main                                         1074    1070      -4
print_login_prompt                                    68      58     -10
obscure                                              392     377     -15
syslogd_main                                         882     866     -16
print_login_issue                                    516     478     -38
hostname_main                                        278     223     -55
parse_and_put_prompt                                 825     756     -69
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/9 up/down: 51/-214)          Total: -163 bytes
   text    data     bss     dec     hex filename
 798791     728    7484  807003   c505b busybox_old
 798631     728    7484  806843   c4fbb busybox_unstripped
2008-02-25 23:23:58 +00:00
Denis Vlasenko 394eebed66 lpd: spool mode added by Vladimir
lpr: more robust error reporting
*: introduce and use xchroot
libbb: full_read/write now will report partial data counts prior to error
isdirectory.c: style fixes

lpd_main                                             249     486    +237
xchroot                                                -      29     +29
get_response_or_say_and_die                          110     139     +29
full_write                                            52      60      +8
full_read                                             55      63      +8
static.newline                                         1       -      -1
switch_root_main                                     404     400      -4
chpst_main                                          1089    1079     -10
getopt32                                            1370    1359     -11
chroot_main                                          115     101     -14
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 4/4 up/down: 311/-40)           Total: 271 bytes
   text    data     bss     dec     hex filename
 798472     728    7484  806684   c4f1c busybox_old
 798775     728    7484  806987   c504b busybox_unstripped
2008-02-25 20:30:24 +00:00
Denis Vlasenko 38b8831b32 lpd: now with "svn add"... 2008-02-25 14:48:15 +00:00
Denis Vlasenko f99afb5dff lpd: new applet by Vladimir Dronnikov <dronnikov AT gmail.com> 2008-02-24 23:32:36 +00:00
Denis Vlasenko a2f47358eb forgotten bit of rmdir long options support 2008-02-24 22:45:04 +00:00
Denis Vlasenko 6d8112cc24 fix typo in comment, no code changes 2008-02-24 22:08:57 +00:00
Denis Vlasenko 8f8a420f12 lpr: fixing vda's thinko 2008-02-24 19:22:25 +00:00
Denis Vlasenko b78d1c045f less: shrink 2008-02-24 19:18:18 +00:00
Denis Vlasenko 4f82bdb050 lpr,lpq: rework by dronnikov AT gmail.com 2008-02-24 18:44:20 +00:00
Denis Vlasenko 52feee9b1f rmdir: optional long options support for Debian users. +68 bytes.
By Roberto Gordo Saez <roberto.gordo AT gmail.com>
2008-02-24 14:56:10 +00:00
Denis Vlasenko 28b29916cb watch: shrink (by walter harms <WHarms AT bfs.de>)
watch_main                                           327     263     -64
2008-02-24 14:33:17 +00:00
Denis Vlasenko 400d8bb45e less,klogd,syslogd,nc,tcpudp: exit on signal by killing itself, not exit(1)
*: minor shrink
2008-02-24 13:36:01 +00:00
Denis Vlasenko d553faf5a5 less: small shrink 2008-02-23 12:22:17 +00:00
Denis Vlasenko a7259b64e8 syslogd: small shrink 2008-02-23 12:08:36 +00:00
Denis Vlasenko d2172c04e6 less: make it a bit more resistant against statusline corruption.
less: "examine" command will not bomb out on bad file name now

less_main                                           1663    1694     +31
examine_file                                          87     114     +27
less_getch                                           138     160     +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 80/0)               Total: 80 bytes
   text    data     bss     dec     hex filename
 798368     740    7484  806592   c4ec0 busybox_old
 798470     740    7484  806694   c4f26 busybox_unstripped
2008-02-23 11:54:37 +00:00
Denis Vlasenko 33196372be less: update line input so that it doesn't interfere with
screen update. Makes "man bash", [enter], [/],
<enter search pattern>, [enter] more usable - manpage
draws as you enter the pattern! Yay!!
less: fix bug where backspace wasn't actually deleting chars
less: "examine file with empty name" doesn't abort anymore.
libbb: add "all fatal signals" mask.

getch_nowait                                           -     207    +207
status_print                                           -     105    +105
examine_file                                          64      87     +23
move_cursor                                            -      16     +16
m_status_print                                       185     195     +10
less_main                                           1656    1663      +7
decode_format_string                                 790     795      +5
test_main                                            403     405      +2
process0_stdin                                       247     249      +2
passwd_main                                         1070    1072      +2
less_gets                                            196     178     -18
buffer_print                                         169      71     -98
less_getch                                           362     138    -224
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 7/3 up/down: 379/-340)           Total: 39 bytes
   text    data     bss     dec     hex filename
 798329     740    7484  806553   c4e99 busybox_old
 798368     740    7484  806592   c4ec0 busybox_unstripped
2008-02-23 01:25:38 +00:00
Denis Vlasenko 86620756d2 lpr: document options better 2008-02-22 23:21:31 +00:00
Denis Vlasenko 32b2a9fd6a small code readability and typo fixes 2008-02-22 22:43:22 +00:00
Denis Vlasenko 68444b9f0c lpr and lpq applets by Walter Harms.
text    data     bss     dec     hex filename
    392       0       0     392     188 lpq.o
   1378       0       0    1378     562 lpr.o
    142       0       0     142      8e parse_prt.o
2008-02-22 22:24:48 +00:00
Denis Vlasenko 6aa74fcf5b ash: s/ckzmalloc/ckzalloc/ 2008-02-21 04:35:14 +00:00
Denis Vlasenko 838ffd5be2 ash: sprinkle a bit more of zeroed allocations. 2008-02-21 04:32:08 +00:00
Denis Vlasenko 2f518b078b httpd: "HEAD" support. Closes bug 1530.
send_file_and_exit                                   629     645     +16
static.request_HEAD                                    -       5      +5
handle_incoming_and_exit                            2732    2737      +5
send_headers                                         594     597      +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 29/0)               Total: 29 bytes
   text    data     bss     dec     hex filename
 796283     740    7484  804507   c469b busybox_old
 796312     740    7484  804536   c46b8 busybox_unstripped
2008-02-21 00:12:07 +00:00
Denis Vlasenko 081efd1232 corrected English in comment 2008-02-20 22:57:24 +00:00
Denis Vlasenko a523e2efad udhcp: we were forgetting to set right op byte in tha packet
for DHCPDECLINE. Fixing, and making code smaller.
2008-02-20 22:33:38 +00:00
Denis Vlasenko 84da0bf475 udhcp: make paths configurable
syslogd: trivial build fix
2008-02-20 22:29:52 +00:00
Denis Vlasenko e376d454bb libbb: introduce and use nonblock_safe_read(). Yay!
Our shells are immune from this nasty O_NONBLOCK now!

function                                             old     new   delta
nonblock_safe_read                                     -      78     +78
file_get                                             276     295     +19
generateMTFValues                                    428     435      +7
read_line_input                                     1776    1772      -4
preadbuffer                                          543     450     -93
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 104/-97)             Total: 7 bytes
   text    data     bss     dec     hex filename
 615190     715   23924  639829   9c355 busybox_old
 615168     715   23924  639807   9c33f busybox_unstripped
2008-02-20 22:23:24 +00:00
Mike Frysinger ae86a338b8 [#1334] exec script for devices even if they dont have device nodes 2008-02-20 18:31:36 +00:00
Denis Vlasenko 597906c436 ash: introduce and use stzalloc and ckzalloc.
function                                             old     new   delta
stzalloc                                               -      29     +29
ckzalloc                                               -      29     +29
recordregion                                         108     102      -6
cmdlookup                                            158     152      -6
pipeline                                             188     181      -7
parseheredoc                                         135     128      -7
makename                                              42      35      -7
list                                                 355     348      -7
setvareq                                             221     212      -9
aliascmd                                             324     311     -13
pushfile                                              83      69     -14
readtoken1                                          2872    2849     -23
parse_command                                       1430    1391     -39
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/11 up/down: 58/-138)          Total: -80 bytes
   text    data     bss     dec     hex filename
 577227     706   23740  601673   92e49 busybox_old
 577147     706   23740  601593   92df9 busybox_unstripped
2008-02-20 16:38:54 +00:00
Denis Vlasenko e7b43cf59f trivial fixes to config system 2008-02-19 23:42:22 +00:00
Denis Vlasenko c12d51e94e ash: fix fallout from "A=1 B=$A; echo $B" code. 2008-02-19 23:31:05 +00:00
Denis Vlasenko 624188aec0 microcom: tiny shrink, adding comments 2008-02-19 18:26:40 +00:00
Denis Vlasenko 671ca33aa1 init: make it NOMMU-capable
httpd: trivial compile fix
2008-02-19 14:13:20 +00:00
Denis Vlasenko a58a637bed init: fix comments 2008-02-19 12:10:18 +00:00
Denis Vlasenko 99a61842df init: HUP should not be temporarily set to "restart",
we use it for config reload, and we have QUIT for "restart".
2008-02-19 12:08:38 +00:00
Denis Vlasenko 8617454027 fix chat CONFIG_xxx dependencies 2008-02-19 11:36:22 +00:00
Denis Vlasenko e93550866b chat: now with "svn add" 2008-02-19 11:35:08 +00:00
Denis Vlasenko 53ce7f0d71 findfs,mount: trivial build fix and whitespace fiexs 2008-02-19 11:29:46 +00:00
Denis Vlasenko 431a7c9c53 tar: optional autodetection of gz/bz2 compressed tarballs.
+130 bytes. Closes bug 992.
2008-02-19 11:26:28 +00:00
Denis Vlasenko a37e7134f7 init: fix bug 1111: restart actions were not splitting words:
::restart:/sbin/rc restart
resulted in:
exec of '/sbin/rc restart' failed: No such file or directory
2008-02-19 02:57:07 +00:00
Denis Vlasenko 92657d484f syslogd: tighten up hostname handling. 2008-02-19 01:10:20 +00:00
Denis Vlasenko e8419c90f1 tail: fix "tail -c 20 /dev/huge_disk" (was taking ages)
tail: a few variables renamed
wc: tiny optimization.
2008-02-19 00:38:10 +00:00
Denis Vlasenko 5233cd3800 chat: new applet by dronnikov AT gmail.com. With all options on:
function                                             old     new   delta
chat_main                                              -    1230   +1230
unescape                                               -     135    +135
packed_usage                                       23802   23922    +120
signal_handler                                       123     131      +8
input_backward                                       123     128      +5
applet_names                                        1775    1780      +5
applet_main                                         1076    1080      +4
applet_nameofs                                       538     540      +2
exitcode                                               -       1      +1
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 6/0 up/down: 1510/0)           Total: 1510 bytes
2008-02-18 23:24:46 +00:00
Denis Vlasenko 6f04391cec lineedit: tiny shrink 2008-02-18 22:28:03 +00:00
Denis Vlasenko de7684a309 support for mount by label (not yet tested)
Also adds findfs applet. Closes bug 1143.
2008-02-18 21:08:49 +00:00
Bernhard Reutner-Fischer 27dd495b98 - fix open(creat) without a mode 2008-02-18 18:35:53 +00:00
Denis Vlasenko b4133683a4 mount: with -vv -f, say what mount() calls we were going to make
782357     728    7476  790561   c1021 busybox_old
 782429     728    7476  790633   c1069 busybox_unstripped
2008-02-18 13:05:38 +00:00
Denis Vlasenko f732e96757 mount: optional support for -vv verbosity
mount: do "struct globals" trick

With -vv on:

function                                             old     new   delta
verbose_mount                                          -      83     +83
mount_main                                           970     988     +18
mount_it_now                                         219     229     +10
singlemount                                         4564    4570      +6
mount_option_str                                     227     233      +6
nfs_mount_version                                      1       -      -1
fslist                                                 4       -      -4
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 4/0 up/down: 123/-5)            Total: 118 bytes
2008-02-18 12:07:49 +00:00
Denis Vlasenko c9ca0a3274 mount: recognize "dirsync" (closes bug 835)
mount: sanitize environ if called by non-root
*: adjust for slightly different sanitize routine
2008-02-18 11:08:33 +00:00
Denis Vlasenko 56244736ec whitespace fixes 2008-02-17 15:14:04 +00:00
Denis Vlasenko 542963685c dos2unix: shrink
bloatcheck for last four commits:
function                                             old     new   delta
xrename                                                -      38     +38
md5_hash_block                                       437     458     +21
sv_main                                             1237    1254     +17
update_status                                        569     580     +11
decode_format_string                                 795     805     +10
doset                                                317     326      +9
passwd_main                                         1070    1074      +4
sha1_compile                                         447     446      -1
rename_or_warn                                        49      47      -2
fill_bounds                                          174     172      -2
buffer_fill_and_print                                 76      73      -3
bb_perror_nomsg                                        9       -      -9
get_next_block                                      1810    1795     -15
patch_main                                          1107    1085     -22
write_status_file                                   1123    1077     -46
remove                                                52       -     -52
__GI_remove                                           52       -     -52
open_as_user                                         171     111     -60
microcom_main                                        811     747     -64
dos2unix_main                                        452     383     -69
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 6/10 up/down: 110/-397)        Total: -287 bytes
2008-02-17 14:31:50 +00:00
Denis Vlasenko 03b4c14bd4 crontab: stop using remove() - use unlink() instead 2008-02-17 14:30:03 +00:00
Denis Vlasenko b3b0753593 dpkg: fix bug where existence check was reversed 2008-02-17 14:29:25 +00:00
Denis Vlasenko cb448fe01b libbb: introduce and use xrename and rename_or_warn. 2008-02-17 14:28:53 +00:00
Denis Vlasenko ffae845cfd microcom: maintainer update 2008-02-16 23:40:47 +00:00
Denis Vlasenko b1d8e7db0f mount: make -f work even without mtab support
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>)
2008-02-16 23:28:42 +00:00
Denis Vlasenko 25591c322c libbb: introduce bb_signals and bb_signals_recursive,
which sets same handler for many signals. sig_catch is nuked
(bb_signals_recursive is more descriptive name).
*: use them as appropriate. 

function                                             old     new   delta
bb_signals_recursive                                   -      95     +95
bb_signals                                             -      52     +52
run_command                                          258     273     +15
svlogd_main                                         1368    1377      +9
runsv_main                                          1746    1752      +6
runsvdir_main                                       1643    1646      +3
UNSPEC_print                                          64      66      +2
time_main                                           1128    1127      -1
...
resize_main                                          246     210     -36
sig_catch                                             63       -     -63
set_fatal_sighandler                                  85      14     -71
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 5/24 up/down: 182/-548)        Total: -366 bytes
2008-02-16 22:58:56 +00:00
Denis Vlasenko 7fc294cdfe crontab: clear env if run by non-root, so that we can use PATH now
crontab: make "-c /tmp/ -e" work
2008-02-16 13:47:57 +00:00
Denis Vlasenko 3718832a15 *: more readable handling of pipe fds. No code changes. 2008-02-16 13:20:56 +00:00
Denis Vlasenko 1e18f1bab3 ifupdowm: shrink
ifupdown_main                                       2170    2459    +289
find_iface_state                                      57      56      -1
next_word                                             63      58      -5
popen2                                               350       -    -350
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 289/-356)          Total: -67 bytes
2008-02-16 13:19:19 +00:00
Denis Vlasenko 284d0faed6 random s/short/int/
add_cmd                                             1189    1190      +1
xconnect_ftpdata                                     118     117      -1
data_align                                            86      84      -2
process_files                                       2101    2096      -5
forkexec                                            1345    1334     -11
2008-02-16 13:18:17 +00:00
Denis Vlasenko 069e347863 crontab: almost complete rewrite
crontab: make options consistent with other implementations

   text    data     bss     dec     hex filename
   2042       4       0    2046     7fe busybox.t1/miscutils/crontab.o
   1331       0       0    1331     533 busybox.t2/miscutils/crontab.o

function                                             old     new   delta
edit_file                                            733     956    +223
open_as_user                                           -     171    +171
packed_usage                                       23652   23650      -2
CDir                                                   8       4      -4
ChangeUser                                           139       -    -139
crontab_main                                        1522     616    -906
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/3 up/down: 394/-1051)        Total: -657 bytes
2008-02-16 13:17:13 +00:00
Denis Vlasenko cd5c61cd3b ifupdown: code shrink
function                                             old     new   delta
next_word                                             78      63     -15
ifupdown_main                                       2381    2170    -211
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-226)           Total: -226 bytes
2008-02-15 16:20:26 +00:00
Denis Vlasenko 753f42ab8d adduser: optional support for long options. +110 bytes.
closes bug 2134.
2008-02-15 15:17:23 +00:00
Denis Vlasenko 0e6f661e23 ash: handle "A=1 A=2 B=$A; echo $B". closes bug 947. 2008-02-15 15:02:15 +00:00
Mike Frysinger 977bc6a137 we need to pass back the rtc device name that was actually used so that we can turn around and check its sysfs status 2008-02-15 07:19:03 +00:00
Mike Frysinger ea915363e7 fix build failure when long opts are enabled 2008-02-15 02:33:22 +00:00
Mike Frysinger 6b160e490d split some rtc funcs out of hwclock and into an rtc header/lib so that the new rtcwake applet as well as hwclock can utilize the same code 2008-02-15 02:27:19 +00:00
Mike Frysinger be7d2a8ded sendmail is lexically after selinux, so fix the order 2008-02-15 01:43:22 +00:00
Mike Frysinger 25cd7fd702 add a test case for usage strings to catch people forgetting to add trailing escape in middle of usage 2008-02-15 01:42:28 +00:00
Mike Frysinger 1e47c429bf fix microcom usage 2008-02-15 01:34:14 +00:00
Denis Vlasenko e00e5025ec tar: real support for -p. +200 if selected.
By Natanael Copa <natanael.copa at gmail.com>
2008-02-14 20:37:54 +00:00
Denis Vlasenko 39487e2d6a libbb: filename completion should match dangling symlinks too 2008-02-14 19:55:58 +00:00
Denis Vlasenko 94e87bc83d ash: explain why "set -o BOGUS" doesn't abort 2008-02-14 16:51:58 +00:00
Denis Vlasenko 28bf671d6d ash: make ash -c 'if set -o barfoo 2>/dev/null; then echo foo; else echo bar; fi' work
(fixes bug 1142)

function                                             old     new   delta
options                                              551     565     +14
ash_main                                            1397    1411     +14
setcmd                                                77      90     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0)               Total: 41 bytes
2008-02-14 15:01:47 +00:00
Denis Vlasenko f1d93ec420 build system: pass CFLAGS to link stage too (closes bug 1376) 2008-02-14 12:24:14 +00:00
Denis Vlasenko b2e578a1f2 umount: instead of non-standard -D, use -d with opposite meaning
(closes bug 1604)
umount: do not try to free loop device or erase mtab if remounted ro
umount: do not complain several times about the same mountpoint

function                                             old     new   delta
umount_main                                          646     638      -8
packed_usage                                       23662   23652     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18)             Total: -18 bytes
2008-02-14 12:00:21 +00:00
Denis Vlasenko 773f6710c1 typo fix 2008-02-14 10:31:18 +00:00
Denis Vlasenko 12c0622231 tar: do "short EOF" compat only if CONFIG_DESKTOP.
ash: add a comment about new minor bug
2008-02-14 08:52:30 +00:00
Paul Fox b5ee8db9b5 add ',' and 'gg' commands (patch from Leo Jay) 2008-02-14 01:17:01 +00:00
Denis Vlasenko 65eb550024 reinstate redir.tests with correct perms 2008-02-13 18:10:46 +00:00
Denis Vlasenko 81887e2342 ash: add a testcase for recently fixed signal bug 2008-02-13 18:09:56 +00:00
Denis Vlasenko 23ffb6a4a2 tar: compat: handle tarballs with only one zero block at the end 2008-02-13 17:52:42 +00:00
Denis Vlasenko 6dd03f04ea switch_root: stop at first non-option. Closes bug 1425. 2008-02-13 17:25:31 +00:00
Denis Vlasenko 87cf2ee8ab tar: move FNM_LEADING_DIR #define to tar.c - no other users.
Closes bug 1332.
2008-02-13 17:06:53 +00:00
Denis Vlasenko d5fe880a57 cp: add ENABLE_FEATURE_VERBOSE_CP_MESSAGE. Closes bug 1470 2008-02-13 16:52:00 +00:00
Denis Vlasenko 9d96af2e83 mkswap: fix help text to not lie about supported options.
mkswap: use uint32, not int, to match kernel.
mkswap: optimization: use pre-zeroed buffer
2008-02-13 15:35:52 +00:00
Denis Vlasenko 3b92eaac53 sort: -z outputs NUL terminated lines. Closes bug 1591. 2008-02-13 14:30:33 +00:00
Denis Vlasenko 75cddd8eb5 syslogd: send '\n'-terminated messages over the network.
fully closes bug 1574. +8 bytes.
2008-02-13 09:19:14 +00:00
Denis Vlasenko 0a4624aece build system: don't use -o /dev/null, old gcc can delete /dev/null! 2008-02-13 07:47:37 +00:00
Denis Vlasenko 59bb4a4f50 website: add direct links to every last stable release tarball 2008-02-12 19:01:34 +00:00
Denis Vlasenko 7c5258b1c4 website: fix English 2008-02-12 18:53:16 +00:00
Denis Vlasenko 3d3d698594 Announce 1.9.1 2008-02-12 17:53:59 +00:00
Denis Vlasenko fee2d0c256 msh: stop trying to parse variables in "msh SCRIPT VAR=val param".
They should be passed as ordinary parameters.
2008-02-12 10:12:18 +00:00
Denis Vlasenko 7e497527ea msh: instead of fixing "ls | cd", "cd | ls" etc just disallow
builtins in pipes. They make no sense there anyway.
msh: shrink umask builtin.

function                                             old     new   delta
execute                                             2508    2509      +1
doset                                                326     317      -9
forkexec                                            1370    1345     -25
doumask                                              165     101     -64
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 1/-98)             Total: -97 bytes
2008-02-12 09:51:03 +00:00
Denis Vlasenko e26b2783a5 ash: fix warning about _GNU_SOURCE being redefined, fix typo in comment. 2008-02-12 07:40:29 +00:00
Denis Vlasenko 648b44fd78 msh: shrink, mainly by using smallints
function                                             old     new   delta
synio                                                251     263     +12
filechar                                             310     315      +5
subgetc                                              781     785      +4
brkcontin                                            106     109      +3
...
yylex                                                981     976      -5
execute                                             2513    2508      -5
waitfor                                              321     315      -6
onintr                                               103      97      -6
doset                                                332     326      -6
doexec                                               186     180      -6
yyparse                                               65      57      -8
thenpart                                             135     126      -9
forkexec                                            1379    1370      -9
onecommand                                           457     433     -24
newtp                                                 52      28     -24
command                                             1086    1061     -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/23 up/down: 27/-163)         Total: -136 bytes
2008-02-12 06:04:06 +00:00
Denis Vlasenko a5f2cd30c9 msh: do not run pipes where last command is a builtin
msh: code shrink and some renames for better readability
2008-02-11 18:10:06 +00:00
Denis Vlasenko fc21305892 httpd: fix bug where we did chdir("") if CGI path had only one "/".
httpd: fix bug 2004: wrong argv when interpreter is invoked

+8 bytes growth
2008-02-11 16:26:22 +00:00
Bernhard Reutner-Fischer f536b99d26 - shrink a tiny bit (-30Bytes) 2008-02-11 13:26:54 +00:00
Bernhard Reutner-Fischer a985d306a1 - spelling fixes 2008-02-11 11:44:38 +00:00
Denis Vlasenko 83177991c8 hush: die_sllep needs restoring only if job control is on 2008-02-11 08:44:36 +00:00
Denis Vlasenko 08126f665d hush: close-on-exec interactive_fd 2008-02-11 08:39:11 +00:00
Denis Vlasenko 459a5ad410 hush: set CLOEXEC on script file being executed 2008-02-11 08:35:03 +00:00
Denis Vlasenko 4ecfcdcced hush: fix the comment 2008-02-11 08:32:31 +00:00
Denis Vlasenko c04163a289 hush: reset die_sleep to 0 in child after fork 2008-02-11 08:30:53 +00:00
Denis Vlasenko 04e11c9209 getpot: add support for "a+" specifier for nonnegative int parameters.
By Vladimir Dronnikov <dronnikov at gmail.com>.
fdisk and top are converted as an example.

function                                             old     new   delta
getopt32                                            1340    1370     +30
top_main                                            1137    1120     -17
fdisk_main                                          3033    2949     -84
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 30/-101)           Total: -71 bytes
2008-02-10 19:44:20 +00:00
Denis Vlasenko 9304d6ea92 microcom: read more than 1 byte from device, if possible 2008-02-10 19:05:56 +00:00
Denis Vlasenko 991a1da148 ash: fix "orwell bug" 1984. Testcase:
trap_handler() {
        echo trap
    }
    trap trap_handler USR1
    sleep 3600 &
    while true; do wait; done
2008-02-10 19:02:53 +00:00
Denis Vlasenko 0ef240d979 hush: small fixes to docs/testsuite 2008-02-10 16:00:30 +00:00
Denis Vlasenko 05743d7949 hush: reinstate cmd handling for NOMMU (with fat big warning).
hush: fix a case where none of pipe members could be started
  because of fork failure
hush: rename functions: xxx_real -> xxx
hush: try to add a bit more of vfork-friendliness
hush: add rudimentary design docs
hush: add TODO (newly discovered bug with globbing)
2008-02-10 12:10:08 +00:00
Denis Vlasenko 68e8e96d7f microcom: compile fixes 2008-02-09 11:39:00 +00:00
Denis Vlasenko d56e3ccf96 microcom: split -d (delay) option away from -t 2008-02-09 11:37:21 +00:00
Denis Vlasenko 937b10f35d build system: make it do without od -t 2008-02-09 09:26:43 +00:00
Denis Vlasenko 761e1d1462 mktemp: don't advertise -q option 2008-02-09 06:29:32 +00:00
Denis Vlasenko 65581f3ed1 mktemp: support -p DIR (Timo Teras <timo.teras at iki.fi>)
packed_usage                                       23595   23660     +65
mktemp_main                                          139     157     +18
2008-02-09 06:26:53 +00:00
Denis Vlasenko 1e2a7e4ed1 test: fix mishandling of 'test ! arg1 op arg2 more args'; add testsuite 2008-02-09 05:48:42 +00:00
Denis Vlasenko 6d52c1ee24 sendmail: update from maintainer 2008-02-08 18:24:54 +00:00
Denis Vlasenko dc1c45795b microcom: update from maintainer 2008-02-08 17:30:39 +00:00
Denis Vlasenko 97bd0e05cc README: doccument the need of CONFIG_DESKTOP
od: fix help text to include -t
od: handle /proc files (which have filesize 0) correctly
od: fix comments to not lie about return value
od: "%u" is 1 byte less than "%zu"
cat: fix English
2008-02-08 15:41:01 +00:00
Denis Vlasenko 7dbf1b4d9e httpd: add a bit of error logging; a few code simplifications. +29 bytes. 2008-02-08 15:21:55 +00:00
Bernhard Reutner-Fischer afdad653ac - add eject -s for SCSI- and USB-devices (Nico Erfurth) 2008-02-08 15:04:00 +00:00
Mike Frysinger 534b8d0483 force disable setlocalversion usage in busybox 2008-02-07 22:44:27 +00:00
Mike Frysinger 9412ec7555 some more fixes for cross-compiling on an OS X host: apple provides core types so dont redefine them, sys/statfs.h is not available, and only use some newer AF_* defines if they are actually available 2008-02-07 22:41:33 +00:00
Mike Frysinger 22876c797c only include mntent.h according to HAVE_MNTENT_H and dont define this on OS X 2008-02-07 22:10:07 +00:00
Denis Vlasenko b386c1c614 udhcp: ifdef out unused members 2008-02-04 13:23:53 +00:00
Denis Vlasenko d55fe3e595 udhcp: optional support for non-standard DHCP ports (+300 bytes when selected) 2008-02-04 13:12:16 +00:00
Denis Vlasenko e8ef7ec7de unzip: do not try to read entire compressed stream at once (it can be huge)
unzip: handle short reads correctly
2008-02-04 12:12:48 +00:00
Denis Vlasenko f3f33ebb0b zcip: open ARP socket before openlog
(else we can thrash syslog socket)
2008-02-04 09:42:05 +00:00
Denis Vlasenko f8157cafcb nohup: compat patch by Christoph Gysin <mailinglist.cache at gmail.com> 2008-02-04 00:30:06 +00:00
Denis Vlasenko 32d49bc70f mkswap: do not do extra seek
mount: add another mount helper call method
2008-02-03 23:52:41 +00:00
Denis Vlasenko c85bfcad52 ps: fixlet to disabled compat code 2008-02-03 22:04:19 +00:00
Denis Vlasenko 5c3d2b334a ash: readability enhancement, no code changes 2008-02-03 22:01:08 +00:00
Denis Vlasenko 95dc672326 getty: don't try to detect parity on local lines
(Joakim Tjernlund <Joakim.Tjernlund at transmode.se>)
2008-02-02 19:05:36 +00:00
Denis Vlasenko 30eb319103 fsck: don't kill pid -1! (Roy Marples <roy at marples.name>) 2008-02-02 18:54:58 +00:00
Denis Vlasenko 6e602c4931 msh: also handle EOF/read errors correctly 2008-02-02 18:50:50 +00:00
Denis Vlasenko 80667e30fb msh: fix Ctrl-C handling with line editing 2008-02-02 18:35:55 +00:00
Denis Vlasenko a2980c6249 sendmail: fixes by Vladimir Dronnikov <dronnikov at gmail.com> 2008-02-02 17:54:35 +00:00
Denis Vlasenko 5de754a395 ps: add (disabled) compat code 2008-02-02 16:43:51 +00:00
Denis Vlasenko 7cff01ec2d nc: fix fallout from C99 standard compliance change 2008-02-02 16:23:43 +00:00
Paul Fox 0b2b5842a1 Fix compilation error when FEATURE_FANCY_PING enabled. Also
reorder networking/Config.in moving FEATURE_FANCY_PING next to
PING6.  (Cristian Ionescu-Idbohrn)
2008-02-01 23:25:32 +00:00
Mike Frysinger f0044c480c add support for renaming/relocating device nodes 2008-02-01 06:53:50 +00:00
Mike Frysinger c348e0bc7b add a mini-faq about std{in,out,err} 2008-02-01 01:41:57 +00:00
Bernhard Reutner-Fischer 8c69afd992 - be C99 friendly. Anonymous unions are a GNU extension. This change is
size-neutral WRT -std=gnu99 and fixes several compilation errors for strict
  C99 mode.
2008-01-29 10:33:34 +00:00
Denis Vlasenko c882f341ce init: allow last line to be not terminated by '\n' 2008-01-29 09:56:21 +00:00
Denis Vlasenko 8c638cbf09 mount: allow and ignore _netdev option 2008-01-29 09:31:09 +00:00
Bernhard Reutner-Fischer c96d37050f - update defconfig 2008-01-29 09:28:02 +00:00
Denis Vlasenko 36fc3cd8bc ash: code readability enhancements, no real code changes 2008-01-29 09:23:49 +00:00
Denis Vlasenko ddd42cb064 sendmail: really svn add it 2008-01-29 00:59:15 +00:00
Denis Vlasenko 9772816570 *: move getopt reset code to better place(s) 2008-01-28 22:57:10 +00:00
Denis Vlasenko 73032ca04b sendmail: new applet by dronnikov at gmail.com 2008-01-28 22:47:03 +00:00
Denis Vlasenko 847fa779af *: tidy up usage of char **environ 2008-01-28 22:45:43 +00:00
Denis Vlasenko 0effc2410b microcom: undo #define trick, gcc fails to take advantage of it 2008-01-28 09:39:30 +00:00
Denis Vlasenko b5c60fc787 mkswap, readahead: stop using fdlength, it is reported to be unreliable 2008-01-27 23:41:34 +00:00
Denis Vlasenko da42bd5bbe stty: fix mishandling of 'control' keywords (Ralf Friedl <Ralf.Friedl@online.de>) 2008-01-27 23:24:31 +00:00
Denis Vlasenko ef67c5758a microcom: update from the author 2008-01-27 22:40:39 +00:00
Denis Vlasenko c4e4be9414 tentatively fix getopt state corruption for NOFORK applets 2008-01-27 22:39:55 +00:00
Bernhard Reutner-Fischer f470196a41 - fix conflicting decls of syslog related facilitynames and prioritynames tables 2008-01-27 12:50:12 +00:00
Mike Frysinger 61160dd0a1 do not respect CONFIG_MODULES as it breaks building if it is defined in the build env 2008-01-27 09:41:24 +00:00
Denis Vlasenko b76b9a4328 udhcpc: filter unwanted packets in kernel
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
2008-01-25 22:46:34 +00:00
Denis Vlasenko 893988182a fdisk: comment out unused function 2008-01-25 20:18:46 +00:00
Denis Vlasenko ca9635b19d udhcpc: fix wrong options in decline and release packets
(Jonas Danielsson <jonas.danielsson at axis.com>)
2008-01-25 19:27:08 +00:00
Denis Vlasenko a5549c9617 fdisk: fix a case where break was reached only for DOS labels 2008-01-24 22:49:15 +00:00
Denis Vlasenko 680b86afbb halt: write wtmp entry if wtmp support is enabled 2008-01-24 02:28:00 +00:00
Denis Vlasenko 1d290d1e24 halt: update help text 2008-01-24 02:27:30 +00:00
Denis Vlasenko 9e58921e7e comment fix 2008-01-24 01:33:42 +00:00
Denis Vlasenko 314820e595 crond: small code shrink and readability enhancements 2008-01-24 01:33:12 +00:00
Denis Vlasenko 8e8200a772 grep: fix wrong filename in error message 2008-01-24 01:30:36 +00:00
Mike Frysinger 46ef46aefb as reported by George Boudreau, make sure we properly skip blank lines 2008-01-23 18:48:26 +00:00
Bernhard Reutner-Fischer 46904bfbcc - Fix hdparm's ioctl parameter passing (John Brandwood) 2008-01-19 11:27:11 +00:00
Paul Fox 518d8dd979 eliminated CONFIG_FEATURE_EDITING_FANCY_KEYS. the size savings
was small, compared to the total size of the command-line editing
features, and it removed key bindings that most wouldn't consider
"fancy", like ^U, and 'l' and 'h' in vi mode, ^F and ^B in emacs
mode.
2008-01-18 20:41:24 +00:00
Bernhard Reutner-Fischer 52432f2b06 - correct helptext of stat (Cristian Ionescu-Idbohrn) 2008-01-17 11:05:09 +00:00
Bernhard Reutner-Fischer 2b11fb483e - implement brctl setpathcost, setportprio, setbridgeprio, stp
text    data     bss     dec     hex filename
    907      20       0     927     39f networking/brctl.o
2008-01-14 16:10:11 +00:00
Bernhard Reutner-Fischer c2f0de5eef - mention strtod code-duplication as TODO for cleanup 2008-01-14 14:32:56 +00:00
Bernhard Reutner-Fischer 1aac3ab49f - shrink a bit and implement time related fancy features. Improve help texts.
text	   data	    bss	    dec	    hex	filename
    253	     20	      0	    273	    111	networking/brctl.o.bare
    613	     20	      0	    633	    279	networking/brctl.o.fancy-time
2008-01-13 18:43:50 +00:00
Bernhard Reutner-Fischer 78e1d58d3a - fix commentary typo 2008-01-13 17:52:53 +00:00
Bernhard Reutner-Fischer c44c21060e - save four bytes by manually hoisting the br assignment 2008-01-13 15:43:28 +00:00
Bernhard Reutner-Fischer ce34cccf28 - update defconfig 2008-01-13 15:33:13 +00:00
Bernhard Reutner-Fischer d27d925a6d - new applet brctl
text	   data	    bss	    dec	    hex	filename
    289	     20	      0	    309	    135	networking/brctl.o
    335	     23	      0	    358	    166	networking/brctl-verbose-ops.o
2008-01-13 15:23:27 +00:00
Bernhard Reutner-Fischer 481ce92bdf - add ipsvd 2008-01-11 20:52:45 +00:00
Paul Fox 84bbac5a09 enable use of ^V prefix to allow forced insertion of any character. in
particular, without this it's impossible to enter a TAB on the commandline
(whether tab completion is enabled or not).
2008-01-11 16:50:08 +00:00
Paul Fox ee8e3ee919 allow 8-bit characters 2008-01-11 16:12:57 +00:00
Denis Vlasenko de24bd960f tac: handle NULs properly. +145 bytes 2008-01-09 23:00:00 +00:00
Denis Vlasenko d2c450ce81 hush: report [v]fork failures
hush: more correct handling of piping
config: add CONFIG_NOMMU
2008-01-08 20:32:12 +00:00
Denis Vlasenko 474d1c57c8 whitespace fixes 2008-01-07 19:06:47 +00:00
Denis Vlasenko 9b4c072a04 ps: fix yet another buglet from recent ulltoa conversion :( 2008-01-07 16:51:25 +00:00
Denis Vlasenko 766f65919b ps: fix COMMAND column adjustment 2008-01-07 16:41:41 +00:00
Denis Vlasenko 482f2b31e7 tac: *really* add tac.c now 2008-01-07 16:14:14 +00:00
Denis Vlasenko 6b404431aa ps: fix build breakage from vda's recent commit
*: whitespace fixes
2008-01-07 16:13:14 +00:00
Denis Vlasenko 4e9ca75281 syslogd: fix shmat error check 2008-01-07 15:58:02 +00:00
Denis Vlasenko bcd5fc12ec tac: new applet. ~240 bytes.
Copyright (C) 2003  Yang Xiaopeng  <yxp at hanwang.com.cn>
Copyright (C) 2007  Natanael Copa  <natanael.copa@gmail.com>
Copyright (C) 2007  Tito Ragusa    <farmatito@tiscali.it>
2008-01-06 06:27:17 +00:00
Denis Vlasenko 56ea65ca5f ps: fix overflow in USER and VSZ columns
function                                             old     new   delta
smart_ulltoa4                                          -     280    +280
smart_ulltoa5                                        283     408    +125
ulltoa6_and_space                                      -      25     +25
scale                                                 28      38     +10
bbunpack                                             358     366      +8
ps_main                                              259     261      +2
glob3                                                 35      37      +2
fill_bounds                                          172     174      +2
process_stdin                                        456     446     -10
smart_ulltoa6                                        406       -    -406
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 6/1 up/down: 454/-416)           Total: 38 bytes
2008-01-06 03:26:53 +00:00
Denis Vlasenko 5fee2e1a79 ps: add conditional support for -o [e]time 2008-01-05 03:26:41 +00:00
Denis Vlasenko 9cd30d30a0 Makefile.help: removing allbareconfig target from help
applet_tables: fix allnoconfig
2008-01-04 20:10:51 +00:00
Denis Vlasenko 83c44229d2 ip route: "ip route" was misbehaving (extra argv+1 ate 1st env var) 2008-01-04 15:28:28 +00:00
Denis Vlasenko 21e20cb4ad init: wait for orphaned children too while waiting
for sysinit-like processes (Harald Küthe <harald-tuxbox@arcor.de>)
2008-01-04 15:10:47 +00:00
Denis Vlasenko 4dada747e5 syslogd: avoid excessive tine() system calls
function                                             old     new   delta
timestamp_and_log_internal                             -      24     +24
log_locally                                          741     744      +3
timestamp_and_log                                    313     314      +1
syslogd_main                                         904     897      -7
quit_signal                                          101      94      -7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 28/-14)             Total: 14 bytes
2008-01-03 12:13:42 +00:00
Denis Vlasenko 4f2e8bc765 syslogd: don't die if remote host's IP cannot be resolved.
retry resolutions every two minutes instead.

function                                             old     new   delta
syslogd_main                                         865     904     +39
timestamp_and_log                                    324     313     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 39/-11)             Total: 28 bytes
2008-01-03 12:12:27 +00:00
Denis Vlasenko fb0eba706c libbb: introduce and use safe_waitpid (loops in EINTR)
*: use more approproate (shorter) versions of wait()

function                                             old     new   delta
safe_waitpid                                           -      48     +48
wait_any_nohang                                        -      17     +17
send_tree                                            365     369      +4
processorstop                                        432     435      +3
text_yank                                            110     108      -2
make_human_readable_str                              202     200      -2
crond_main                                          1368    1366      -2
handle_sigchld                                        49      43      -6
reapchild                                            166     159      -7
custom                                               260     250     -10
checkscript                                          191     177     -14
wait_nohang                                           17       -     -17
wait_pid                                              43       -     -43
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/7 up/down: 72/-103)           Total: -31 bytes
2008-01-02 19:55:04 +00:00
Denis Vlasenko 27963980db adding libbb/printable.c 2007-12-30 20:13:39 +00:00
Denis Vlasenko d3c042fc60 libbb: introduce fputc_printable (from ed)
netstat: print control chars as ^C etc
vi: style fixlet

function                                             old     new   delta
fputc_printable                                        -     100    +100
unix_do_one                                          451     487     +36
printLines                                           258     190     -68
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 136/-68)            Total: 68 bytes
2007-12-30 01:59:53 +00:00
Denis Vlasenko fcd878efcd httpd: support for "I:index.xml" syntax (Peter Korsgaard <jacmet@uclibc.org>)
function                                             old     new   delta
parse_conf                                          1481    1507     +26
handle_incoming_and_exit                            2650    2663     +13
httpd_main                                           749     759     +10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 49/0)               Total: 49 bytes
2007-12-29 02:16:23 +00:00
Denis Vlasenko 3f9c848576 trylink: instead of build error, disable --gc-sections if GLIBC && STATIC
nameif: glibc build fixlet
2007-12-28 17:04:42 +00:00
Denis Vlasenko ddc865fb0d netstat: in error message, report filename and line number
where we see problematic data

   text    data     bss     dec     hex filename
 778456     832    7344  786632   c00c8 busybox_old
 778394     832    7344  786570   c008a busybox_unstripped
2007-12-26 21:49:33 +00:00
Denis Vlasenko c03e872112 save a bit of code with *strchrnul = '\0' trick
function                                             old     new   delta
nextline                                              59      55      -4
include_conf                                         902     898      -4
read_config                                          414     406      -8
fsck_main                                           1880    1869     -11
2007-12-26 20:56:55 +00:00
Denis Vlasenko abee3d0e0d Fix xmalloc_fgets_str so that it really does NOT strip terminator.
Add xmalloc_fgetline_str which does strip terminator,
and use it in dpkg instead of xmalloc_fgets_str.
netstat: use xmalloc_fgets_str - allows to eat strings with NULs
(this fixes bug with some weird /proc/net/unix input)

function                                             old     new   delta
xmalloc_fgets_internal                                 -     191    +191
xmalloc_fgetline_str                                   -      18     +18
do_info                                              116     120      +4
unix_do_one                                          451     447      -4
tcp_do_one                                           423     419      -4
send_tree                                            369     365      -4
xmalloc_fgets_str                                    178      15    -163
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/4 up/down: 213/-175)           Total: 38 bytes
   text    data     bss     dec     hex filename
 778445     832    7344  786621   c00bd busybox_old
 778483     832    7344  786659   c00e3 busybox_unstripped
2007-12-26 20:44:45 +00:00
Denis Vlasenko d55268d0d4 init: don't spawn tons of waiting children, one is enough
init: shrink signal disabling code
init: rename some functions
   text    data     bss     dec     hex filename
 778657     832    7344  786833   c0191 busybox_old
 778445     832    7344  786621   c00bd busybox_unstripped
2007-12-26 18:32:58 +00:00
Denis Vlasenko 5adfa44101 init: sometimes, #ifdefs are cleaner. 2007-12-25 16:08:53 +00:00
Denis Vlasenko 1d61416b5a sync examples to what actual actual code expects 2007-12-25 15:32:56 +00:00
Mike Frysinger 08137c28c4 add expected output 2007-12-25 04:35:05 +00:00
Mike Frysinger bb50fdfe07 convert #if to if -- let gcc optimize away dead code for us 2007-12-25 04:30:14 +00:00
Denis Vlasenko ec5631b6d6 init: add FEATURE_KILL_REMOVED (Eugene Bordenkircher <eugebo@gmail.com>)
init: slight size optimization
2007-12-25 01:08:58 +00:00
Denis Vlasenko 7b55c7f97d fix typo in web page 2007-12-24 17:33:56 +00:00
Denis Vlasenko 8e5b6f58a2 Makefile: change version to 1.10.0.svn
udhcpc: make UDP packet sending the same as raw sending in regards
  to error messages. Minor code size shrink. Total size grows due
  to added messages:

   text    data     bss     dec     hex filename
 770312     683    7244  778239   bdfff busybox_old
 770327     683    7244  778254   be00e busybox_unstripped
2007-12-24 17:32:22 +00:00
Denis Vlasenko 299c5c379e Announce 1.9.0 2007-12-24 14:43:25 +00:00
Denis Vlasenko 3b4921674e hush: fixlet for NOMMU
update TODO_config_nommu
2007-12-24 14:26:57 +00:00
Denis Vlasenko f7be20e70c nameif: extended matching (Nico Erfurth <masta@perlgolf.de>)
*: whitespace fixes

function                                             old     new   delta
prepend_new_eth_table                                  -     304    +304
nameif_main                                          620     684     +64
cc_macaddr                                            51       -     -51
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 368/-51)           Total: 317 bytes
2007-12-24 14:09:19 +00:00
Denis Vlasenko fcfb5c04bb defconfig: update
appletli.c: add vda's (C)
top: fixlet for incorrect display of "0"
Makefile: reduce stack size from 20k to 16k
2007-12-24 12:16:24 +00:00
Denis Vlasenko e4bc603f0b od: reduce data/bss usage (code size went down too) 2007-12-24 12:14:24 +00:00
Denis Vlasenko ef36c04ccf umount: fix fallout from stack reduction change 2007-12-24 12:11:57 +00:00
Denis Vlasenko f882f08627 vi: speed up some string ops 2007-12-23 02:36:51 +00:00
Denis Vlasenko 528a8b9769 cttyhack: trivial build fixlet 2007-12-22 19:57:28 +00:00
Denis Vlasenko 4baed3a080 vi: reduce amount of memset'ing on each screen refresh 2007-12-22 17:31:29 +00:00
Denis Vlasenko e3cbfb91d2 vi: introduce FEATURE_VI_8BIT (as vi currently is not Unicode capable,
people may want to disable display of high-bit chars)
ip: build fixlet
2007-12-22 17:00:11 +00:00
Denis Vlasenko 94e3365b8f perror_nomsg: don't print extra colon
losetup: print name of loop device in error messages
2007-12-22 15:44:23 +00:00
Denis Vlasenko 88adfcd178 vi: change MAX_LINELEN meaning: now it is the biggest supported
screen wigth. Introduce MAX_TABSTOP and MAX_INPUT_LEN. Fix redraw
of very long lines and cursor movement past NULs.
2007-12-22 15:40:13 +00:00
Denis Vlasenko ee87ebf381 fix buglets found by randomconfig 2007-12-21 22:18:16 +00:00
Denis Vlasenko 26b6fba9d3 vi: fix a problem with displaying overlong lines 2007-12-21 21:34:37 +00:00
Denis Vlasenko 619879246d udhcp: decided to not send "short" dhcp packets,
but lets add comments how to do it if needed.
2007-12-21 16:32:30 +00:00
Denis Vlasenko fff145dba3 udhcp: fix oversized packet sending (introduced by "slack for bad dhcp servers" options);
slight optimizations and function renaming

udhcp_send_raw_packet                                  -     391    +391
udhcp_send_kernel_packet                               -     197    +197
udhcp_recv_packet                                      -     134    +134
get_raw_packet                                       353     326     -27
udhcp_get_packet                                     134       -    -134
udhcp_kernel_packet                                  197       -    -197
udhcp_raw_packet                                     391       -    -391
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 0/1 up/down: 722/-749)          Total: -27 bytes
2007-12-20 21:11:38 +00:00
Denis Vlasenko f77f369ce8 fdisk: reduce global data/bss usage. 8k data+bss build is achievable soon ;)
(add/remove: 0/13 grow/shrink: 6/19 up/down: 74/-492)        Total: -418 bytes
   text    data     bss     dec     hex filename
 778330     860    7408  786598   c00a6 busybox_old
 777970     840    7376  786186   bff0a busybox_unstripped
2007-12-16 17:22:33 +00:00
Denis Vlasenko c794c51a1a msh: reduce global data/bss usage
(add/remove: 1/5 grow/shrink: 28/6 up/down: 464/-394)          Total: 70 bytes
   text    data     bss     dec     hex filename
 778077     908    7568  786553   c0079 busybox_old
 778330     860    7408  786598   c00a6 busybox_unstripped
2007-12-16 17:21:29 +00:00
Denis Vlasenko 0163111325 ash: reduce global data/bss usage
(add/remove: 4/29 grow/shrink: 76/21 up/down: 1007/-1713)    Total: -706 bytes
   text    data     bss     dec     hex filename
 777206    1084    8976  787266   c0342 busybox_old
 778077     908    7568  786553   c0079 busybox_unstripped
2007-12-16 17:20:38 +00:00
Denis Vlasenko 9ad2cb3f1a traceroute: stop using global data/bss
(add/remove: 0/15 grow/shrink: 0/1 up/down: 0/-95)            Total: -95 bytes
   text    data     bss     dec     hex filename
 777245    1094    9008  787347   c0393 busybox_old
 777206    1084    8976  787266   c0342 busybox_unstripped
2007-12-16 17:19:40 +00:00
Denis Vlasenko 4ca2965b99 add a link to vda's pet projects 2007-12-13 00:15:50 +00:00
Denis Vlasenko 2cd4a747e5 num conversions: allow for leading '+' (renice needs that) 2007-12-11 13:15:11 +00:00
Denis Vlasenko d7e2e127a9 cttyhack: add missing ';'
init: remove pointless access() check
2007-12-10 08:40:29 +00:00
Denis Vlasenko 2afabe8b83 init: remove superfluous forks and messing up with argv[0]
cttyhack: add stealing of ctty
2007-12-10 07:06:04 +00:00
Denis Vlasenko 191836845e udhcpc: support for -O <option>.
Two important notes:
* nissrv and nisdomain are not requested by default anymore!
* inconsistency between "XXXsvr" and "XXsrv" in option names resolved,
  all are "XXXsrv" now.

function                                             old     new   delta
udhcpc_main                                         2494    2600    +106
packed_usage                                       23023   23067     +44
add_requests                                          91     119     +28
static.udhcpc_longopts                               209     226     +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 195/0)             Total: 195 bytes
2007-12-10 07:03:38 +00:00
Denis Vlasenko 75aa615bef find: add -iname support (Alexander Griesser <alexander.griesser@lkh-vil.or.at>) 2007-12-09 10:07:39 +00:00
Denis Vlasenko 9cb220be9d lineedit: don't violate API if we do simple fgets
ash: cosmetic style fixes, no code changes
2007-12-09 10:03:28 +00:00
Denis Vlasenko a96425fe82 vi: don't use common_bufsiz as read buffer, it can be too small
(found by Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
2007-12-09 04:13:43 +00:00
Denis Vlasenko b851c42a14 signal names hack was wrong, it broke "get signal name" function.
Reverting :(
2007-12-04 21:44:52 +00:00
Denis Vlasenko f3fca91e9f getty: a small code shrink
touch                                                  -      40     +40
fakehost                                               4       -      -4
getty_main                                          2546    2493     -53
2007-12-04 18:46:01 +00:00
Denis Vlasenko c689fcfdb0 Make signal table a bit smaller
get_signum                                           136     151     +15
signals                                              224     192     -32
2007-12-04 10:20:48 +00:00
Denis Vlasenko 5f934b0785 guard against SIGxxx >= 32 (no code changes on i386) 2007-12-04 10:05:28 +00:00
Denis Vlasenko d0bbbdcd6e getty: don't accept ancient '#' and '@' as backspace/kill line,
it only confuses people.
(Alexander Griesser <alexander.griesser@lkh-vil.or.at> (LKH Villach))
various other cleanups.

function                                             old     new   delta
getty_main                                          2526    2546     +20
static.baud_index                                      4       -      -4
parse_speeds                                          91       -     -91
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/0 up/down: 20/-95)            Total: -75 bytes
   text    data     bss     dec     hex filename
 773152    1086    9008  783246   bf38e busybox_old
 773081    1086    9008  783175   bf347 busybox_unstripped
2007-12-04 09:48:40 +00:00
Denis Vlasenko 7221c8c22d lineedit: reduce stack usage
netstat: reduce stack usage; fix handling of NULs in unix socket filenames

static.has_inode                                       1       -      -1
do_info                                              119     116      -3
deinit_S                                              60      51      -9
unix_do_one                                          578     451    -127
parse_and_put_prompt                                 966     825    -141
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/4 up/down: 0/-281)           Total: -281 bytes
2007-12-03 10:45:14 +00:00
Denis Vlasenko 2bec513996 fix whitespace damage 2007-12-02 08:56:53 +00:00
Denis Vlasenko 7ab3699b58 mkfs.minix: add testsuite; disable code which makes images variable 2007-12-02 08:55:34 +00:00
Denis Vlasenko ab801874f8 attack the biggest stack users:
-mkfs_minix_main [busybox_unstripped]:                  4288
-mkfs_minix_main [busybox_unstripped]:                  4276
-grave [busybox_unstripped]:                            4260
(bzip2 users too - not listed)

price we pay in code size increase:
mainSort                                            2458    2515     +57
grave                                               1005    1058     +53
sendMTFValues                                       2177    2195     +18
BZ2_blockSort                                        122     125      +3
mkfs_minix_main                                     3070    3022     -48
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 131/-48)            Total: 83 bytes
2007-12-02 08:35:37 +00:00
Denis Vlasenko 8003e266ed explain why we use mmap instead of malloc 2007-12-02 07:18:29 +00:00
Denis Vlasenko 8723a94c25 libnetlink: comment out unused code; don't use 8k stack buffers
function                                             old     new   delta
ipaddr_modify                                       1305    1297      -8
do_iprule                                            963     955      -8
do_iproute                                          2193    2169     -24
xrtnl_dump_filter                                    418     391     -27
rtnl_talk                                            671     536    -135
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-202)           Total: -202 bytes
2007-12-02 06:30:57 +00:00
Denis Vlasenko 5cb40bbbd3 Fix minor discrepancy in "make help" 2007-12-02 05:36:37 +00:00
Denis Vlasenko 4c13922961 Introduce FEATURE_COPYBUF_KB.
People who want smaller stack at any cost may use it
to reduce cp's stack usage (FEATURE_COPYBUF_KB=1).
Desktop people may get faster copy of big files
(FEATURE_COPYBUF_KB=32 is ~30% faster than 4kb)
2007-12-02 03:27:42 +00:00
Denis Vlasenko e2532ab5f2 dd: fix a bug where we don't report write errors
testsuite: small cleanup

full_write_or_warn                                    38      40      +2
write_and_stats                                       66      67      +1
dd_main                                             1358    1335     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 3/-23)             Total: -20 bytes
2007-12-02 01:44:42 +00:00
Denis Vlasenko 1796e2c495 dd: add testsuite entry for write errors 2007-12-02 01:43:18 +00:00
Denis Vlasenko 6672c8e480 test: stop using lots of bss.
function                                             old     new   delta
test_main                                            425     456     +31
t_lex                                                 69      73      +4
syntax                                               100     104      +4
ptr_to_statics                                         8      12      +4
t_wp_op                                                4       -      -4
t_wp                                                   4       -      -4
ngroups                                                4       -      -4
group_array                                            4       -      -4
binop                                                590     585      -5
oexpr                                                104      97      -7
aexpr                                                101      94      -7
nexpr                                                831     820     -11
leaving                                              156       -    -156
------------------------------------------------------------------------------
(add/remove: 0/5 grow/shrink: 4/4 up/down: 43/-202)          Total: -159 bytes
   text    data     bss     dec     hex filename
 775098     929    9084  785111   bfad7 busybox_old
 775107     933    8908  784948   bfa34 busybox_unstripped
2007-11-30 07:29:05 +00:00
Denis Vlasenko b539c8452f dhcp: heed TODO item - divorced options from their string descriptions
code shrink while at it.

function                                             old     new   delta
dhcp_option_strings                                    -     258    +258
udhcp_run_script                                    1135    1174     +39
dhcp_option_lengths                                    -      11     +11
udhcp_add_simple_option                               93      92      -1
packet_num                                             4       -      -4
read_opt                                             746     739      -7
udhcp_option_lengths                                  11       -     -11
udhcpc_main                                         2590    2494     -96
dhcp_options                                         490      70    -420
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/4 up/down: 308/-539)         Total: -231 bytes
   text    data     bss     dec     hex filename
 775309     929    9100  785338   bfbba busybox_old
 775098     929    9084  785111   bfad7 busybox_unstripped
2007-11-29 08:17:45 +00:00
Denis Vlasenko 64309f8669 sysctl: add -e: supress warnings about invalid key (Jeremy Kerr <jk@ozlabs.org>)
code shrink:

   text    data     bss     dec     hex filename
 775565     929    9100  785594   bfcba busybox_old
 775296     929    9100  785325   bfbad busybox_unstripped
2007-11-29 06:40:28 +00:00
Denis Vlasenko 745cd17926 Further optimize applet tables; prettify build output
text    data     bss     dec     hex filename
 775923     929    9100  785952   bfe20 busybox_old
 775565     929    9100  785594   bfcba busybox_unstripped
2007-11-29 03:31:20 +00:00
Denis Vlasenko c253778de9 touch: accept and ignore -f 2007-11-28 19:25:32 +00:00
Denis Vlasenko 35ff74676b dhcpc: let server know we don't like oversized packets.
add TODO comment
2007-11-28 19:23:12 +00:00
Denis Vlasenko 41f5add965 forgotten part of previous commit 2007-11-28 06:49:42 +00:00
Denis Vlasenko 1aa7e477b1 reorganize applet table. Eliminates pointers to names.
Should be a big win for libbusybox. busybox wins too:

   text    data     bss     dec     hex filename
 776524     929    9100  786553   c0079 busybox_old
 775903     929    9100  785932   bfe0c busybox_unstripped
2007-11-28 06:49:03 +00:00
Denis Vlasenko 79c6904faf ip route: add comment, no code changes 2007-11-27 09:42:33 +00:00
Denis Vlasenko 186c2b3d0e iproute: fix a bug where "ip r flush table main" was rejected,
add "ip r flush cache" (however I'm unsure it is really valid syntax)
Add a few comments and stop mixing params and params' keywords.
2007-11-26 18:29:52 +00:00
Denis Vlasenko 30297a5b83 fix vda's testsuite bogons, part 2 2007-11-26 07:23:27 +00:00
Denis Vlasenko bd9a48bc9c fix vda's testsuite bogons, part 1 2007-11-26 07:23:09 +00:00
Denis Vlasenko 4e1e720523 testsuite: add tests for cut and grep;
slight improvements to infrastructure
2007-11-26 05:38:20 +00:00
Denis Vlasenko ed270a5f32 ash: make code simpler, and do not do close(-1) - it's rude 2007-11-26 05:37:07 +00:00
Denis Vlasenko b1bac0dab2 zcip: simplify code a bit 2007-11-25 12:53:25 +00:00
Denis Vlasenko a09300a88c zcip: use low-order 4 bytes of MAC as random seed, not 4 high-order
arping: fix wrong roundtrip calculation
arping,zcip: cleanups and code shrink

run                                                  389     402     +13
arp                                                  195     188      -7
zcip_main                                           1524    1495     -29
arping_main                                         1874    1823     -51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 13/-87)            Total: -74 bytes
   text    data     bss     dec     hex filename
 776587     929    9100  786616   c00b8 busybox_old
 776499     929    9100  786528   c0060 busybox_unstripped
2007-11-25 12:40:56 +00:00
Denis Vlasenko 7c9d533a85 cttyhack should be in /bin, not /usr/bin 2007-11-25 07:58:42 +00:00
Denis Vlasenko 6446c2d4ab which: fix testsuite failure
pidof: do not output empty line if nothing found
testsuite: disable false positive
2007-11-25 04:54:13 +00:00
Denis Vlasenko 72e76044cf dhcpc: cope with buggy DHCP servers which send oversized packets
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
2007-11-25 03:15:24 +00:00
Denis Vlasenko a8875efa85 Announce 1.8.2 and 1.7.4 2007-11-24 04:49:07 +00:00
Denis Vlasenko dd8bbfd084 stty: reorganize data tables - save 0.5k
function                                             old     new   delta
mode_name                                              -     496    +496
control_name                                           -      91     +91
stty_main                                           1235    1255     +20
find_mode                                             45      63     +18
find_control                                          45      63     +18
do_display                                           482     493     +11
wrapf                                                165     166      +1
set_mode                                             761     759      -2
max_col                                                4       -      -4
device_name                                            4       -      -4
control_info                                         153      34    -119
mode_info                                           1700     680   -1020
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 5/3 up/down: 655/-1149)        Total: -494 bytes
   text    data     bss     dec     hex filename
 777037     937    9100  787074   c0282 busybox_old
 776551     929    9100  786580   c0094 busybox_unstripped
2007-11-24 04:32:49 +00:00
Denis Vlasenko fe5e23bf75 remove echo_main -> bb_echo indirection 2007-11-24 02:23:51 +00:00
Denis Vlasenko c3c6659f12 hush: fix segfault in "echo $@" when we have no arguments 2007-11-24 00:22:42 +00:00
Denis Vlasenko d2023283ac fix buglets found by randomconfig 2007-11-23 23:39:01 +00:00
Denis Vlasenko 1da0ad13fb update defconfig 2007-11-23 23:37:19 +00:00
Denis Vlasenko 96702ca945 kill lash. "lash" builtin still exists, but it runs hush. 2007-11-23 23:28:55 +00:00
Denis Vlasenko 8ec6ee47f1 Add an RFC for future ipv6 ftp work 2007-11-23 21:43:40 +00:00
Denis Vlasenko 5bc593ccb8 hush: implement echo builtin
builtin_echo                                           -      36     +36
bltins                                               384     396     +12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 48/0)               Total: 48 bytes
2007-11-23 21:20:21 +00:00
Denis Vlasenko cccdc4e01a hush: fix $ expansion in redirections, add testcase for that 2007-11-23 21:08:38 +00:00
Denis Vlasenko 835068637e hush: implement test builtin 2007-11-23 13:11:42 +00:00
Denis Vlasenko f962a0354e hush: plug memory leak 2007-11-23 12:50:54 +00:00
Denis Vlasenko f23c3f95e8 arping: fix help text (-i -> -I), and shorten it a bit 2007-11-23 09:27:05 +00:00
Denis Vlasenko fff9b699f1 arping: fix a bug where there is implicit count of 4G;
eliminate data/bss usage; code shrink

function                                             old     new   delta
timeout_us                                             4       -      -4
static.start                                           4       -      -4
src                                                    4       -      -4
sock                                                   4       -      -4
sent                                                   4       -      -4
req_recv                                               4       -      -4
received                                               4       -      -4
last                                                   4       -      -4
dst                                                    4       -      -4
count                                                  4       -      -4
brd_sent                                               4       -      -4
brd_recv                                               4       -      -4
catcher                                              375     365     -10
me                                                    20       -     -20
he                                                    20       -     -20
arping_main                                         1941    1874     -67
------------------------------------------------------------------------------
(add/remove: 0/14 grow/shrink: 0/2 up/down: 0/-165)          Total: -165 bytes
   text    data     bss     dec     hex filename
 783035     941    9244  793220   c1a84 busybox_old
 782907     937    9156  793000   c19a8 busybox_unstripped
2007-11-23 09:15:26 +00:00
Denis Vlasenko 3831c91c95 cut: add proper stdout error handling, fix "-" handling;
modest code shrink
2007-11-23 07:26:15 +00:00
Denis Vlasenko e85dbae389 logread: add forgotten INIT_G(); 2007-11-23 03:41:20 +00:00
Denis Vlasenko ff2b6d2185 logread: eliminate usage of data/bss
ifup: don't remove virtual iface prefixes (eth0:0)

function                                             old     new   delta
shbuf                                                  4       -      -4
SMrup                                                  6       -      -6
SMrdn                                                 12       -     -12
static.label_buf                                      20       4     -16
get_var                                              158     140     -18
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 0/2 up/down: 0/-56)             Total: -56 bytes
   text    data     bss     dec     hex filename
 783501     962    9260  793723   c1c7b busybox_old
 783483     942    9244  793669   c1c45 busybox_unstripped
2007-11-23 03:39:45 +00:00
Denis Vlasenko 6884f665bd dhcp: stop using magic constants; use (htonl(CONST) != a) - it's smaller
function                                             old     new   delta
udhcp_get_packet                                     146     134     -12
get_raw_packet                                       368     353     -15
2007-11-23 00:08:54 +00:00
Denis Vlasenko 68af8e7a08 udhcpc: remove -W option, -A can be reused for that
help texts: trimmed a bit

static.udhcpc_longopts                               227     209     -18
udhcpc_main                                         2633    2590     -43
packed_usage                                       22927   22871     -56
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-117)           Total: -117 bytes
2007-11-22 21:41:14 +00:00
Denis Vlasenko b559105cfb fix a thinko in build system 2007-11-22 20:09:41 +00:00
Denis Vlasenko 7d75a96b15 ash: fix bug where redirection of closed fd was leaving it open afterwards.
redirect                                             983    1024     +41
bb_echo                                              276     301     +25
popredir                                             118     132     +14
evalcommand                                         1163    1176     +13
bbunpack                                             358     366      +8
echocmd                                               13       5      -8
echo_main                                             13       5      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/2 up/down: 101/-16)            Total: 85 bytes
   text    data     bss     dec     hex filename
 774999     962    9236  785197   bfb2d busybox_old
 775084     962    9236  785282   bfb82 busybox_unstripped
2007-11-22 08:16:57 +00:00
Denis Vlasenko 705eaf8b40 sestatus: new SELinux applet (KaiGai Kohei <kaigai@ak.jp.nec.com>) 2007-11-22 01:10:41 +00:00
Denis Vlasenko 9cdfd14223 dhcpc: cleanup and comments; fix buggy timeout handling in corner cases.
-25 bytes.
2007-11-22 01:00:00 +00:00
Denis Vlasenko 223bc97f61 udhcpc: an option to perform ARP check (Jonas Danielsson <jonas.danielsson@axis.com>)
configurable, ~+300 bytes when on.
2007-11-22 00:58:49 +00:00
Mike Frysinger c881c733bb cleanup comments and coding style and rewrite the mdev.conf parser to use common busybox functions and call strdup() less often ... saves a ~few hundred bytes 2007-11-19 09:04:22 +00:00
Denis Vlasenko ed6a49c657 ip: stop propagating argc; optimize ip_parse_common_args
function                                             old     new   delta
find_pair                                            167     187     +20
static.families                                        -      17     +17
die_must_be_on_off                                     -      11     +11
...
on_off                                                33      22     -11
do_ipaddr                                            103      90     -13
do_iptunnel                                         1001     986     -15
iproute_list_or_flush                               1237    1217     -20
static.ip_common_commands                             43      22     -21
do_iproute                                          2217    2193     -24
parse_args                                          1444    1414     -30
ip_do                                                 47      16     -31
do_iprule                                            994     963     -31
ip_main                                              153     113     -40
ipaddr_modify                                       1357    1305     -52
ipaddr_list_or_flush                                2543    2490     -53
ip_parse_common_args                                 294     159    -135
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 4/24 up/down: 85/-563)         Total: -478 bytes
   text    data     bss     dec     hex filename
 775561     966    9236  785763   bfd63 busybox_old
 775073     962    9236  785271   bfb77 busybox_unstripped
2007-11-18 22:56:25 +00:00
Denis Vlasenko 2a587df80a stty: mark variable as static 2007-11-18 11:47:25 +00:00
Mike Frysinger 49d15890e0 make output a little more friendly 2007-11-18 06:42:56 +00:00
Mike Frysinger e13bd362e3 merge from upstream for systems that dont integrate libintl into their C library:
commit aa1e5ef5c1d95e7ebf0821d9ba27debe43a87a22
Author: Sam Ravnborg <sam@ravnborg.org>
Date:   Sun Aug 12 23:15:44 2007 +0200

    kbuild: check if we can link gettext not just compile

    cygwin provides the header file but the lib file needs
    to be added manually. A generic fix is to check if
    we can compile and link a program that uses gettext()
    and if it fails fall back to NO_NLS.

    International users of cygwin may have to specify
    HOST_LOADLIBES := "-lintl" on the make command line.

    Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2007-11-18 06:17:52 +00:00
Mike Frysinger dbd18f639c exported symbols may be weak, so allow symbols marked as W 2007-11-18 06:13:58 +00:00
Denis Vlasenko 70ab28f907 syslogd: use DEV_CONSOLE consistently
init: remove obsolete comment
2007-11-18 05:43:05 +00:00
Denis Vlasenko fbe5f39f0f hexdump: add hd alias, add -R option 2007-11-18 05:36:50 +00:00
Paul Fox 16aec39ebe add comment clarifying busybox's use of non-standard tar header 2007-11-17 19:11:05 +00:00
Denis Vlasenko 8512862163 tar: fix a case where glibc detects bogus buffer overrun
which is not really there!
2007-11-16 20:35:30 +00:00
Denis Vlasenko 7e3a5f58bc dmesg,klogd: make code more readable
libbb: explain why we declare klogctl
libbb: move defs around so that order makes more sense
2007-11-16 20:18:54 +00:00
Bernhard Reutner-Fischer 7c2db5c198 - use standard-imposed constants some more 2007-11-16 12:39:16 +00:00
Bernhard Reutner-Fischer a702457eac - remove most of the forward declarations. No obj-code changes. 2007-11-16 12:20:30 +00:00
Bernhard Reutner-Fischer e8979889b4 - add note about SUSv3 missing options. 2007-11-16 11:52:42 +00:00
Denis Vlasenko 01cd9570c7 who: add -a (by Tito) 2007-11-16 05:24:43 +00:00
Denis Vlasenko a6899c3587 lash: fix compile-time warning 2007-11-15 17:47:45 +00:00
Denis Vlasenko 6d38dc3af4 df: add -a
df: don't special case rootfs and /dev/root

function                                             old     new   delta
df_main                                              746     684     -62
find_block_device                                    111       -    -111
find_block_device_in_dir                             243       -    -243
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-416)           Total: -416 bytes
2007-11-15 09:02:12 +00:00
Denis Vlasenko f430cdbf2e df: add -i (conditional on CONFIG)
uasge: trim a bit
2007-11-15 07:02:55 +00:00
Denis Vlasenko 1fe4e9e573 cosmetic change in message text 2007-11-15 00:57:40 +00:00
Paul Fox ae6bf96659 bad syntax error should go to stderr 2007-11-14 23:48:35 +00:00
Denis Vlasenko 9d6c46955f Introduce FEATURE_PREFER_IPV4_ADDRESS. If selected, we have:
function                                             old     new   delta
str2sockaddr                                         328     344     +16
2007-11-14 10:18:33 +00:00
Denis Vlasenko 8d0a734d91 tr: more of code shrink (getopt32-ification)
runtest: cleanup. Method of getting $applets was truly bizarre

function                                             old     new   delta
tr_main                                              655     527    -128
2007-11-13 22:23:57 +00:00
Denis Vlasenko 3d461676a9 tr: better comments, small code shrink
function                                             old     new   delta
expand                                              2232    2230      -2
tr_main                                              677     655     -22
2007-11-13 22:22:29 +00:00
Denis Vlasenko a89d50fb9a tr: properly detect read errors (Fernando Silveira <fsilveira@gmail.com>)
readprofile: use xwrite

function                                             old     new   delta
tr_main                                              679     677      -2
readprofile_main                                    1964    1944     -20
2007-11-13 17:51:40 +00:00
Denis Vlasenko 130f559f4d trylink: accomodate older versions of ld 2007-11-13 17:36:12 +00:00
Denis Vlasenko 05c8c4f745 who: code shrink by Tito <farmatito@tiscali.it>
function                                             old     new   delta
who_main                                             271     259     -12
2007-11-13 17:26:21 +00:00
Denis Vlasenko 72cc9641f8 add sed mini-doc 2007-11-13 17:13:31 +00:00
Denis Vlasenko 40276648ab sed: support GNU-like '\t' escape in substitutions 2007-11-13 16:48:10 +00:00
Denis Vlasenko 6df9e3c9a3 inetd: revert bogus fix for bug 1562; shrink inetd a bit
function                                             old     new   delta
dupconfig                                            159     146     -13
getconfigent                                        1123    1073     -50
2007-11-12 21:21:35 +00:00
Denis Vlasenko 059c91711f open_transformer: do not duplicate "<program> -cf -"
text    data     bss     dec     hex filename
 677858     738    7236  685832   a7708 busybox_old
 677804     738    7236  685778   a76d2 busybox_unstripped
2007-11-12 02:13:12 +00:00
Denis Vlasenko 4bfb84db4e gzip: fix a case where tar xzf fails (we use uninitialized fd) 2007-11-12 01:44:49 +00:00
Denis Vlasenko e5569cb52e who: fix wrong date/time field size 2007-11-11 06:35:41 +00:00
Denis Vlasenko 40702dac93 Announce 1.8.1 2007-11-10 03:24:21 +00:00
Denis Vlasenko f6ccc62c70 init: fix bug 1584: improper check for fork error 2007-11-10 01:57:35 +00:00
Denis Vlasenko 5cc6459c46 umount: stop using excessive aounts of stack. Surprisingly,
code shrank a lot too

function                                             old     new   delta
umount_main                                          751     640    -111
2007-11-10 01:45:03 +00:00
Denis Vlasenko 73cb1fdfea lineedit: stop using both data/bss and tons of stack.
stack usage was ~10 kb!
unfortunately, noticeable code size growth:
   text    data     bss     dec     hex filename
   9252      12     181    9445    24e5 busybox.t7/libbb/lineedit.o
   9714       4       0    9718    25f6 busybox.t8/libbb/lineedit.o
2007-11-10 01:35:47 +00:00
Denis Vlasenko e7fca5125a *: remove superfluous "?" in option parsing 2007-11-10 01:32:18 +00:00
Denis Vlasenko b4f608d8e0 readlink: realpath requires PATH_MAX, bb_common_bufsiz1 can be too small
umount: don't actually need char[2 * PATH_MAX] for realpath
2007-11-10 01:31:19 +00:00
Denis Vlasenko d031b203c7 syslogd: support "symlink to symlink" for /dev/log; reduce stack usage
function                                             old     new   delta
create_socket                                          -     134    +134
syslogd_main                                        1132     865    -267
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 134/-267)         Total: -133 bytes
   text    data     bss     dec     hex filename
 775603     974    9420  785997   bfe4d busybox_old
 775445     974    9420  785839   bfdaf busybox_unstripped
2007-11-10 01:28:19 +00:00
Bernhard Reutner-Fischer 9bd8d0c23e - commentary fixes
- use common exit sequence for failure path:
   text	   data	    bss	    dec	    hex	filename
    308	      0	      0	    308	    134	libbb/xreadlink.o.pgf
    296	      0	      0	    296	    128	libbb/xreadlink.o
2007-11-08 21:11:43 +00:00
Paul Fox 599bbfbd9b xmalloc_follow_symlinks() -- fix ELOOP issue with absolute paths,
return full path in cases where path doesn't resolve to a link. 
change name to better differentiate from xmalloc_readlink().
2007-11-08 20:00:36 +00:00
Denis Vlasenko abbd363261 xreadlink: code shrink
udhcp: add missing tryagain member to client_config

function                                             old     new   delta
xmalloc_readlink_follow                              169     154     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-15)             Total: -15 bytes
2007-11-08 17:40:23 +00:00
Paul Fox 53bd4015aa follow symlinks to find the true passwd file before updating. 2007-11-08 01:12:38 +00:00
Paul Fox 459a2ba1ef new xmalloc_readlink_follow() routine to fully expand trailing symlinks
to get to a "real" file (or directory).
2007-11-08 01:11:41 +00:00
Paul Fox 49cce2b838 add "-A N" / "--tryagain=N" option to client, to allow altering the
default 60 second wait after failure to get a lease.
2007-11-07 16:01:28 +00:00
Paul Fox 6e1b62b18c flush typeahead before prompt 2007-11-07 15:51:35 +00:00
Denis Vlasenko a29a5e40ae login: fix PAM login (was unable to complete Kerberos login) 2007-11-07 00:23:47 +00:00
Denis Vlasenko cb12cb2407 modprobe: fix a bug where we were entering endless loop
syslogd: strip trailing '\n' too, not only NULs
2007-11-06 11:34:03 +00:00
Denis Vlasenko 5281630229 login: clear dangerous environment variables if started by non-root 2007-11-06 05:26:51 +00:00
Denis Vlasenko 6bef3d1d22 fbset: fix buglet where we were using wrong pointer
readahead: stop using stdio.h
*: style fixes
2007-11-06 03:05:54 +00:00
Denis Vlasenko 1bec1b980e telnet: use poll, it's shorter
*: style fixes
2007-11-06 02:23:39 +00:00
Denis Vlasenko cd0fbb5e77 unzip: hmm... gcc doesn't like ATTRIBUTE_PACKED?? Document that... 2007-11-06 02:16:01 +00:00
Denis Vlasenko ef66d75704 insmod: make error reporting less verbose 2007-11-06 02:02:45 +00:00
Denis Vlasenko 018b155ad9 telnetd: fix problem with zombies (by Paul Fox <pgf@brightstareng.com>)
syslogd: strip trailing NULs
2007-11-06 01:38:46 +00:00
Paul Fox cb981638f5 change safety check on zip header to allow for extra length, and
revert the header read to use the correct constant rather than
sizeof.  at least one version of gcc (armv4-linux-gcc-3.4.1) pads
the struct to 28 bytes in spite of the packing.
2007-11-05 23:09:03 +00:00
Denis Vlasenko f8b21d0933 swaponoff: prevent arithmetic overflow (spotted by Paul Fox <pgf@brightstareng.com>) 2007-11-05 19:33:38 +00:00
Denis Vlasenko 15c3885688 fix incorrect text of link-time error message. No code changes 2007-11-05 19:31:01 +00:00
Denis Vlasenko 9fcd799b98 webpage: fix typo, remove inconsistent trailing dots
Makefile: version is 1.9.0.svn now
2007-11-05 16:26:34 +00:00
Denis Vlasenko 3a3e50e3db update screenshot 2007-11-04 15:57:35 +00:00
Denis Vlasenko 6cee58e9cf Announce 1.8.0 2007-11-04 15:43:26 +00:00
Denis Vlasenko 360362dc57 docs: fix new-applet-HOWTO.txt, delete ipv4_ipv6.txt (it's obsolete) 2007-11-04 04:46:46 +00:00
Denis Vlasenko 06200348be Announce 1.7.3 on website 2007-11-04 04:30:20 +00:00
Denis Vlasenko bfc3d82256 ifconfig: code shrink
adjtimex: code shrink
libbb: move nth_string function into libbb
hdparm: nth_string was here

   text    data     bss     dec     hex filename
 730013   10334   12032  752379   b7afb busybox_old
 730093   10134   12032  752259   b7a83 busybox_unstripped
2007-11-04 04:10:17 +00:00
Denis Vlasenko 681023650e grep: fix -Fo 2007-11-04 00:46:03 +00:00
Denis Vlasenko b68979aefa insmod: code shrink, stop exporting insmod_ng_main.
function                                             old     new   delta
add_ksymoops_symbols                                   -     421    +421
static.section_names                                  20      40     +20
lsmod_main                                           425     424      -1
set_tainted                                          153     150      -3
main_opts                                              4       -      -4
obj_symbol_patch                                      47      42      -5
obj_string_patch                                     144     139      -5
already_loaded                                       144     138      -6
check_dep                                            348     341      -7
append_option                                         75      68      -7
obj_allocate_commons                                 515     501     -14
new_process_module_arguments                        1039    1018     -21
arch_new_symbol                                       31       9     -22
check_module_name_match                               85      61     -24
obj_create_alloced_section                           164     136     -28
include_conf                                         930     902     -28
modprobe_main                                       1643    1535    -108
obj_load                                             924     777    -147
insmod_ng_main                                       245       -    -245
insmod_main                                         4122    3794    -328
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/16 up/down: 441/-1003)       Total: -562 bytes
   text    data     bss     dec     hex filename
 776020     974    9420  786414   bffee busybox_old
 775384     974    9420  785778   bfd72 busybox_unstripped
2007-11-02 23:31:10 +00:00
Denis Vlasenko 9d1afdb571 inetd: fix bug 1562 "inetd does not set argv[0] properly" (fix by IlyaPanfilov)
inetd: code shrink while at it

function                                             old     new   delta
static.SOCK_xxx                                        -       6      +6
getconfigent                                        1222    1123     -99
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 6/-99)             Total: -93 bytes
   text    data     bss     dec     hex filename
 776099     974    9420  786493   c003d busybox_old
 776020     974    9420  786414   bffee busybox_unstripped
2007-10-30 19:54:39 +00:00
Denis Vlasenko 9130340adf hdparm: code shrink
text    data     bss     dec     hex filename
 776494     974    9420  786888   c01c8 busybox_old
 776099     974    9420  786493   c003d busybox_unstripped
2007-10-30 19:36:54 +00:00
Denis Vlasenko d059ddc1bb e2fsprogs: code shrink
text    data     bss     dec     hex filename
 776594     974    9420  786988   c022c busybox_old
 776494     974    9420  786888   c01c8 busybox_unstripped
2007-10-30 19:36:07 +00:00
Bernhard Reutner-Fischer 1641d614fa - fix typo in helptext 2007-10-29 21:21:27 +00:00
Denis Vlasenko 968dbf9685 minor fix in comment, no code changes 2007-10-29 19:52:21 +00:00
Denis Vlasenko dfc0740b04 ll_types.c: optimize link type table, make it conditional
on FEATURE_IP_RARE_PROTOCOLS

function                                             old     new   delta
static.arphrd_name                                     -     373    +373
static.arphrd_type                                     -     124    +124
ll_type_n2a                                           58      78     +20
static.arphrd_names                                  496       -    -496
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/0 up/down: 517/-496)           Total: 21 bytes
   text    data     bss     dec     hex filename
 776880     974    9420  787274   c034a busybox_old
 776594     974    9420  786988   c022c busybox_unstripped
2007-10-29 19:33:26 +00:00
Denis Vlasenko 15ca51e3e2 appletlib.c: make it actally follow _BB_SUID_ALWAYS rules
adduser: implement -S and code shrink / fix uid selection
*: sanitize getspnam_r use

   text    data     bss     dec     hex filename
 777042     974    9676  787692   c04ec busybox_old
 776883     974    9676  787533   c044d busybox_unstripped
2007-10-29 19:25:45 +00:00
Denis Vlasenko 5a28a25b9d syscall: code shrink
text    data     bss     dec     hex filename
 777209     974    9676  787859   c0593 busybox_old
 777042     974    9676  787692   c04ec busybox_unstripped
2007-10-29 19:22:13 +00:00
Denis Vlasenko 63430ae35a mount: size-optimize mount_options[] and nfs_errtbl[]
777253     974    9676  787903   c05bf busybox_old
 777209     974    9676  787859   c0593 busybox_unstripped
2007-10-29 19:18:39 +00:00
Denis Vlasenko a59f435b5f ash: if tcgetattr(stdin) fails, don't mess with tcsetattr
ash: size-optimize ulimit's table of limits

   text    data     bss     dec     hex filename
 777345     974    9676  787995   c061b busybox_old
 777253     974    9676  787903   c05bf busybox_unstripped
2007-10-29 19:17:29 +00:00
Denis Vlasenko 7ab5e3dfcd svlogd: fix compat problem: svlogd -tt should timestanp stderr too 2007-10-22 15:53:34 +00:00
Denis Vlasenko 78ee7c853a httpd: fix trivial bug (spotted by Alex Landau) 2007-10-21 23:24:42 +00:00
Denis Vlasenko 6fa3ab3cf1 bzip2: make -d actually work 2007-10-21 18:59:58 +00:00
Denis Vlasenko e5387a0574 bb_askpass: handle Ctrl-C, restore termoios on Ctrl-C.
sulogin: remove alarm handling, as it is redundant there.
code shrink. After all differences cancel out:

   text    data     bss     dec     hex filename
 777543    1000    9532  788075   c066b busybox_old
 777543    1000    9532  788075   c066b busybox_unstripped
2007-10-20 19:20:22 +00:00
Denis Vlasenko 037576d77b read_line_input: fix it to not do any fancy editing if echoing is disabled.
ash: make read handling both more correct and smaller

read_line_input                                     4037    4101     +64
input_backward                                       140     139      -1
readcmd                                             1079    1070      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 65/-10)             Total: 54 bytes
   text    data     bss     dec     hex filename
 777575    1000    9532  788107   c068b busybox_old
 777629    1000    9532  788161   c06c1 busybox_unstripped
2007-10-20 18:30:38 +00:00
Denis Vlasenko 99014e8965 more fixes for help text wrt long options 2007-10-20 14:54:58 +00:00
Denis Vlasenko a03945aa84 website: add link to "No ifup" document 2007-10-20 04:44:08 +00:00
Denis Vlasenko 2edbc2ab85 ping: fix breakage from -I fix
passwd: SELinux support by KaiGai Kohei <kaigai@ak.jp.nec.com>
2007-10-20 02:00:49 +00:00
Denis Vlasenko aa7a888e42 kbd_mode: new applet by Loïc Grenié <loic.grenie@gmail.com>
kbd_mode_main                                          -     189    +189
packed_usage                                       22745   22833     +88
applets                                             3132    3144     +12
static.opts                                            7      12      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 294/0)             Total: 294 bytes
   text    data     bss     dec     hex filename
 777210    1000    9532  787742   c051e busybox_old
 777575    1000    9532  788107   c068b busybox_unstripped
2007-10-20 00:17:34 +00:00
Denis Vlasenko 85ff862753 mkswap: selinux support by KaiGai Kohei <kaigai@ak.jp.nec.com> 2007-10-19 21:49:48 +00:00
Denis Vlasenko 1a7afb48da paing: make -I ethN work too (-I addr already worked) 2007-10-19 21:39:25 +00:00
Denis Vlasenko fcc569637b unzip: add a comment explaining why we don't die 2007-10-19 21:03:09 +00:00
Denis Vlasenko bc7c5d082e unzip: fix endianness bugs 2007-10-18 23:27:46 +00:00
Denis Vlasenko 34cd7afc49 httpd: free big buffer after use; improve grep-ability of 'headers' variable 2007-10-18 13:01:22 +00:00
Denis Vlasenko f74194e942 xatonum.h: add comment
lineedit: fix typo in comment
httpd: support for proxying connection to other http server
(by Alex Landau <landau_alex@yahoo.com>)
2007-10-18 12:54:39 +00:00
Denis Vlasenko 0363078437 more of usage text fixes wrt long options 2007-10-18 11:11:12 +00:00
Denis Vlasenko 73e5ed2206 exclude --longopts from usage texts if those are disabled 2007-10-18 10:52:36 +00:00
Denis Vlasenko 740eae0585 snv add setsebool 2007-10-18 10:46:42 +00:00
Denis Vlasenko e87b8689d2 telnetd: make sure telnetd -K exits if child dies 2007-10-17 14:33:31 +00:00
Denis Vlasenko 9e23767ef5 telnetd: trivial optimization 2007-10-17 11:18:49 +00:00
Denis Vlasenko 0de37e10ed ash: use fdprintf, not dprintf.
*: trailing whitespace removed
2007-10-17 11:08:53 +00:00
Denis Vlasenko 31acd1ba0a bzip2: more of code shrink
compressStream                                       503     473     -30
BZ2_bzCompress                                        78       -     -78
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-108)           Total: -108 bytes
   text    data     bss     dec     hex filename
 676300    2538   12104  690942   a8afe busybox_old
 676192    2538   12104  690834   a8a92 busybox_unstripped
2007-10-17 10:14:11 +00:00
Denis Vlasenko 16e74b7464 another fix for build failure found by randomconfig 2007-10-17 09:59:01 +00:00
Denis Vlasenko aff3a306b8 even more fixes from randomconfig runs 2007-10-16 23:00:50 +00:00
Denis Vlasenko 5576136563 fixes revealed by randomconfig run 2007-10-16 22:53:05 +00:00
Denis Vlasenko 23c8128916 telnetd: fix comment 2007-10-16 22:01:23 +00:00
Denis Vlasenko f472b237a1 telnetd: code shrink suggested by Ralf Friedl <Ralf.Friedl@online.de> 2007-10-16 21:35:17 +00:00
Denis Vlasenko 686b0ef7d8 bzip2: move state pointer to the offset 0 (smaller code)
ifdef out DecompressEnd if FEATURE_CLEAN_UP is not seleted

fallbackSort                                        1655    1672     +17
mainSort                                            2447    2458     +11
bzip2_main                                           109     119     +10
.rodata                                           123466  123469      +3
generateMTFValues                                    433     435      +2
handle_compress                                      355     356      +1
BZ2_bzCompress                                        79      78      -1
prepare_new_block                                     55      48      -7
compressStream                                       547     503     -44
sendMTFValues                                       2225    2140     -85
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/4 up/down: 44/-137)           Total: -93 bytes
   text    data     bss     dec     hex filename
 676421    2538   12104  691063   a8b77 busybox_old
 676328    2538   12104  690970   a8b1a busybox_unstripped
2007-10-16 14:07:41 +00:00
Denis Vlasenko 008eda2c54 bzip2: make -s equivalent to -2 (compatible with standard bzip2)
telnetd: typo fix in comment
2007-10-16 10:47:27 +00:00
Denis Vlasenko 2450c450ab telnetd: at Alexander Kriegisch <Alexander@kriegisch.name> insistence
add an option to close sessions as soon as child exits.
Maybe it should be a CONFIG option. OTOH, maybe it should be always on,
as it mimics, say, getty's behaviour.

function                                             old     new   delta
handle_sigchld                                         -      49     +49
telnetd_main                                        1312    1355     +43
.rodata                                           123429  123466     +37
packed_usage                                       22770   22806     +36
make_new_session                                     525     532      +7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 172/0)             Total: 172 bytes
   text    data     bss     dec     hex filename
 676285    2538   12104  690927   a8aef busybox_old
 676421    2538   12104  691063   a8b77 busybox_unstripped
2007-10-15 22:09:15 +00:00
Denis Vlasenko 10916c5c6b telnetd: document bug in remove_iacs. reinstate band-aid
which was making it near-impossible to trigger.
remove memmove call which was happening at each network read,
and in 99%+ cases was not needed. Unfortunately, +50 bytes.
2007-10-15 17:28:00 +00:00
Denis Vlasenko 59d7c43dbe telnetd: some simplifications and better error hadling.
telnetd: don't SIGKILL child when closing the session.
kernel will seng SIGHUP for us.

static.iacs_to_send                                    -      15     +15
.rodata                                           123418  123429     +11
make_new_session                                     549     525     -24
send_iac                                              26       -     -26
free_session                                         144     118     -26
telnetd_main                                        1303    1261     -42
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/3 up/down: 26/-118)           Total: -92 bytes
   text    data     bss     dec     hex filename
 676341    2538   12104  690983   a8b27 busybox_old
 676234    2538   12104  690876   a8abc busybox_unstripped
2007-10-15 15:19:36 +00:00
Denis Vlasenko d898b8600c bzip2: update help text 2007-10-14 07:57:26 +00:00
Denis Vlasenko b6ccd32e3f bzip2: implement -1..-9 command line flags 2007-10-14 07:51:19 +00:00
Denis Vlasenko 6a9154b6f6 bzip2: eliminate some divisions 2007-10-14 07:49:48 +00:00
Denis Vlasenko 3f5fdc7572 remove trailing whitespace 2007-10-14 04:55:59 +00:00
Denis Vlasenko be039374f3 setsebool: new applet (Yuichi Nakamura <ynakam@hitachisoft.jp>) 2007-10-14 04:48:44 +00:00
Denis Vlasenko 4a4575686e httpd: fix bug where we were trying to read more POSTDATA than content-length 2007-10-14 02:34:20 +00:00
Denis Vlasenko 9435993b01 bzip2: code size shrink 2007-10-14 01:37:53 +00:00
Denis Vlasenko be5a7b9655 bzip2: remove files which are not used anymore 2007-10-14 00:44:10 +00:00
Denis Vlasenko ef3aabe906 bzip2: size reduction, to just below 9k. 2007-10-14 00:43:01 +00:00
Denis Vlasenko 77f1ec1b9b bzip2: port bzip2 1.0.4 to busybox. note: bzip2 code resides
in separate directory (archival/bz/*)
and is covered by BSD-style license.
code size: 13k
2007-10-13 03:36:03 +00:00
Denis Vlasenko 11c23d7b99 whitespace/style fix 2007-10-11 19:53:10 +00:00
Denis Vlasenko 8add068573 mt: eliminate vector of structures with pointers (bad for libbusybox).
It's a win for static build too:

function                                             old     new   delta
opcode_name                                            -     213    +213
opcode_value                                           -      68     +68
mt_main                                              281     256     -25
opcodes                                              280       -    -280
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/1 up/down: 281/-305)          Total: -24 bytes
   text    data     bss     dec     hex filename
 767403     974    9420  777797   bde45 busybox_old
 767224     974    9420  777618   bdd92 busybox_unstripped
2007-10-11 19:38:59 +00:00
Denis Vlasenko 2ea8c40e8f stty: incorporate strings into struct instead of keeping pointers there.
static:
   text    data     bss     dec     hex filename
 767535     974    9420  777929   bdec9 busybox_old
 767403     974    9420  777797   bde45 busybox_unstripped

dynamic -fpic:
   text    data     bss     dec     hex filename
 718954   14030   12032  745016   b5e38 busybox_old
 720278   12534   12032  744844   b5d8c busybox_unstripped
2007-10-11 16:02:36 +00:00
Denis Vlasenko 4f95e5aab8 vi: don't wait 50 ms before reading ESC sequences
inetd,syslogd: use safe_read instead of open-coded EINTR handling
syslogd: bail out if you see null read from Unix socket
(should never happen, but if it does, spinning forever
and eating 100% CPU is not a good idea)
2007-10-11 10:10:15 +00:00
Denis Vlasenko f9566d8c29 trim too verbose help texts 2007-10-11 10:07:24 +00:00
Denis Vlasenko 15cb4a4272 fix a problem with two different applet_name's 2007-10-11 10:06:26 +00:00
Denis Vlasenko 9b49a5ed85 add -fvisibility=hidden to CC flags, mark XXX_main functions
EXTERNALLY_VISIBLE. 5% size reduction of libbusybox.so
2007-10-11 10:05:36 +00:00
Denis Vlasenko 8d82cf72c9 add -fpic to CC flags when we build libbusybox (14% smaller .so) 2007-10-11 10:02:52 +00:00
Denis Vlasenko 52a4388d95 bunzip: small code shrink and consmetics
read_bunzip                                          276     283      +7
get_bits                                             184     162     -22
get_next_block                                      1833    1810     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 7/-45)             Total: -38 bytes
2007-10-10 20:53:41 +00:00
Denis Vlasenko db60bcf1b7 ip tunnel parameter parsing fix by Jean Wolter <jw5@os.inf.tu-dresden.de> 2007-10-10 14:43:03 +00:00
Denis Vlasenko 724d196c75 Move applets/applet.c into libbb, allows to get rid of --whole-archive
(smaller code). Tested in static and shared mode.
2007-10-10 14:41:07 +00:00
Denis Vlasenko 82d38dab91 get rid of global "struct bb_applet *current_applet" 2007-10-10 14:38:47 +00:00
Denis Vlasenko 141750e388 trylink: s/strip/$STRIP/g 2007-10-10 10:05:35 +00:00
Denis Vlasenko 88ce2748e4 typo fix in help text 2007-10-09 18:08:04 +00:00
Denis Vlasenko 42e418292d trylink: trivial cleanup 2007-10-09 18:01:13 +00:00
Denis Vlasenko 01f3b2c91a trylink: reformat link flags for readability
trylink: add --sort-section alignment:
    text           data     bss     dec     hex filename
-   6557            428    3260   10245    2805 busybox
+   6555            428    3260   10243    2803 busybox
- 909621           1076   12108  922805   e14b5 libbusybox.so.1.8.0.svn
+ 908868           1050   12016  921934   e114e libbusybox.so.1.8.0.svn
2007-10-09 13:49:26 +00:00
Denis Vlasenko d19b87ece4 trylink: remove useless redirects, add missing error checks 2007-10-09 13:08:02 +00:00
Denis Vlasenko 8d755adc1a trylink: trivial fixes 2007-10-09 10:15:41 +00:00
Denis Vlasenko e9fd69c8e8 make "individual applets" build less noisy.
add *.tmp to list of files deleted by make mrproper.
2007-10-08 22:16:14 +00:00
Denis Vlasenko d419a9f830 whitespace fix 2007-10-08 20:45:42 +00:00
Denis Vlasenko ac7d0e375e add libbb/appletlib.c 2007-10-08 19:32:12 +00:00
Denis Vlasenko 642a52d65e make --help work for "individual applets" too. 2007-10-07 21:00:41 +00:00
Denis Vlasenko d62fd84d4b libbusybox: move (possibly compressed) help stuff into libbusybox.
Makes individual binaries much smaller.
2007-10-07 20:46:34 +00:00
Denis Vlasenko 7930bcf736 trim too verbose help messages 2007-10-07 19:13:55 +00:00
Denis Vlasenko 5037b21478 website: "BusyBox Weekly News" didn't really work, remove link 2007-10-07 18:10:44 +00:00
Denis Vlasenko 41770226bb ash: revert "cat | jobs" fix, it causes more problems than good 2007-10-07 18:02:52 +00:00
Denis Vlasenko f545be083d reviving libbusybox, adding CONFIG_INDIVIDUAL part 4 2007-10-07 17:06:26 +00:00
Denis Vlasenko def8898596 reviving libbusybox, adding CONFIG_INDIVIDUAL part 3 2007-10-07 17:06:01 +00:00
Denis Vlasenko 76a6b236a9 reviving libbusybox, adding CONFIG_INDIVIDUAL part 2 2007-10-07 17:05:42 +00:00
Denis Vlasenko 3240474c23 reviving libbusybox, adding CONFIG_INDIVIDUAL part 1 2007-10-07 17:05:22 +00:00
Bernhard Reutner-Fischer e747f62ed6 - mark TODO: use index_in_str_array() 2007-10-06 20:47:53 +00:00
Denis Vlasenko 339936be00 chpst: fix whitespace damage
svlogd: fix bug (two different "line" variables); stop using data/bss

function                                             old     new   delta
processorstop                                        419     432     +13
rotate                                               514     525     +11
buffer_pwrite                                        493     499      +6
sig_term_handler                                      68      70      +2
sig_hangup_handler                                    34      36      +2
sig_alarm_handler                                     34      36      +2
rmoldest                                             305     307      +2
processorstart                                       401     403      +2
logdir_close                                         188     190      +2
tmaxflag                                               1       -      -1
rotateasap                                             1       -      -1
repl                                                   1       -      -1
reopenasap                                             1       -      -1
linecomplete                                           1       -      -1
exitasap                                               1       -      -1
wstat                                                  4       -      -4
verbose                                                9       5      -4
replace                                                4       -      -4
nearest_rotate                                         4       -      -4
linemax                                                4       -      -4
linelen                                                4       -      -4
line                                                   4       -      -4
fndir                                                  4       -      -4
fl_flag_0                                              4       -      -4
fdwdir                                                 4       -      -4
dirn                                                   4       -      -4
dir                                                    4       -      -4
blocked_sigset                                         4       -      -4
sig_child_handler                                    248     239      -9
logdirs_reopen                                      1263    1240     -23
buffer_pread                                         532     473     -59
svlogd_main                                         1466    1367     -99
------------------------------------------------------------------------------
(add/remove: 0/18 grow/shrink: 9/5 up/down: 42/-248)         Total: -206 bytes
   text    data     bss     dec     hex filename
 770916     989    9496  781401   bec59 busybox_old
 770768     980    9448  781196   beb8c busybox_unstripped
2007-10-05 22:11:06 +00:00
Denis Vlasenko 23e3e25df6 chpst: stop using data/bss
function                                             old     new   delta
chpst_main                                          1066    1089     +23
set_user                                               4       -      -4
root                                                   4       -      -4
nicelvl                                                4       -      -4
limitt                                                 4       -      -4
limits                                               196     192      -4
limitr                                                 4       -      -4
limitp                                                 4       -      -4
limito                                                 4       -      -4
limitl                                                 4       -      -4
limitf                                                 4       -      -4
limitd                                                 4       -      -4
limitc                                                 4       -      -4
limita                                                 4       -      -4
env_user                                               4       -      -4
env_dir                                                4       -      -4
------------------------------------------------------------------------------
(add/remove: 0/14 grow/shrink: 1/1 up/down: 23/-60)           Total: -37 bytes
   text    data     bss     dec     hex filename
 770892    1029    9520  781441   bec81 busybox_old
 770916     989    9496  781401   bec59 busybox_unstripped
2007-10-05 21:23:49 +00:00
Denis Vlasenko 91e5203205 stat: code shrink; stop using bss; stop using strncat incorrectly
function                                             old     new   delta
printfs                                                -      28     +28
strcatc                                                -      26     +26
human_time                                            41      44      +3
print_it                                             229     219     -10
buf                                                   30       -     -30
print_statfs                                         420     358     -62
print_stat                                          1089     921    -168
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/3 up/down: 57/-270)          Total: -213 bytes
   text    data     bss     dec     hex filename
 771105    1029    9552  781686   bed76 busybox_old
 770892    1029    9520  781441   bec81 busybox_unstripped
2007-10-05 20:31:23 +00:00
Denis Vlasenko 91e80c2be7 delete now unused check_header_gzip.c
sum: do not use uintmax needlessly
2007-10-05 20:29:31 +00:00
Denis Vlasenko 226002ea74 tail: sizeof(buf) is sizeof(char*)! must be BUFSIZ 2007-10-05 19:17:16 +00:00
Denis Vlasenko d21f596ddb add tests for gunzip 2007-10-05 15:27:03 +00:00
Denis Vlasenko 5dd8a03665 gunzip: support concatenated gz files.
text    data     bss     dec     hex filename
 770988    1029    9552  781569   bed01 busybox.t0/busybox
 771105    1029    9552  781686   bed76 busybox.t3/busybox
2007-10-05 15:26:08 +00:00
Denis Vlasenko 368a12efc2 tail: work correctly on /proc files (Kazuo TAKADA <kztakada@sm.sony.co.jp>) 2007-10-02 10:17:56 +00:00
Denis Vlasenko ebeaea04dc logger: fix a problem of losing all argv except first 2007-10-02 09:57:41 +00:00
Bernhard Reutner-Fischer d24d5c84c2 - ditch 2 bytes 2007-10-01 18:04:42 +00:00
Denis Vlasenko feb7ae7f01 printf("%s\n") -> puts() 2007-10-01 12:05:12 +00:00
Denis Vlasenko 0c97c9d437 'simple' error message functions by Loic Grenie <loic.grenie@gmail.com>.
263 bytes saved.
2007-10-01 11:58:38 +00:00
Denis Vlasenko d65ea39ffc hush: fix glob() abuse. Code was making unfounded assumptions how
glob() works, and it broke horribly on specific uclibc config.
2007-10-01 10:02:25 +00:00
Denis Vlasenko ff0976248a hush: int->smallint for flag vars; make some names more "greppable" 2007-10-01 10:00:45 +00:00
Denis Vlasenko 8412d7959a hush: feeble attempt at making it more NOMMU-friendly 2007-10-01 09:59:47 +00:00
Denis Vlasenko a0898170d8 hush: stop doing manual acounting of open fd's, kernel can do it for us 2007-10-01 09:59:01 +00:00
Denis Vlasenko 96e1b38586 introduce and use close_on_exec_on(fd). -50 bytes. 2007-09-30 23:50:48 +00:00
Denis Vlasenko deabacdf91 move udhcp_{client/server}_config to common_bufsiz1
udhcp_run_script                                    1108    1151     +43
init_packet                                          209     210      +1
udhcpc_main                                         2395    2393      -2
udhcp_client_config                                   56       -     -56
udhcp_server_config                                   88       -     -88
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/1 up/down: 44/-146)          Total: -102 bytes
   text    data     bss     dec     hex filename
 771326    1029    9696  782051   beee3 busybox_old
 771383    1029    9552  781964   bee8c busybox_unstripped
2007-09-30 17:55:43 +00:00
Denis Vlasenko d7b3350eb3 dhcpreplay: code shrink, -40 bytes 2007-09-30 17:54:10 +00:00
Denis Vlasenko 5fb09656ca fixlet to pgrep/pkill 2007-09-30 16:36:02 +00:00
Denis Vlasenko a4f4de9b7e print_signames_and_exit -> print_signames (because of "ash calls kill_main") 2007-09-30 16:32:01 +00:00
Denis Vlasenko 605b20e277 replace printf with fputs where appropriate 2007-09-30 16:22:36 +00:00
Denis Vlasenko 1eecaf26b0 libiproute: add missing break's 2007-09-30 16:04:21 +00:00
Denis Vlasenko e03c77fe15 announce 1.7.2 on the website 2007-09-30 00:06:42 +00:00
Denis Vlasenko f60d62638b small code shrink 2007-09-29 23:26:52 +00:00
Denis Vlasenko 64e619c0c8 build system: pass EXTRA_LDFLAGS to final link stage 2007-09-29 22:52:25 +00:00
Denis Vlasenko 304a97a1ec trivial typo fix 2007-09-29 22:49:26 +00:00
Denis Vlasenko 72e1c89d97 pgrep,pkill: new applets by Loic Grenie <loic.grenie@gmail.com> 2007-09-29 22:26:01 +00:00
Denis Vlasenko 2450e4ba44 xrealloc_getcwd_or_warn: smaller cod and less wasted RAM at run time 2007-09-29 19:19:55 +00:00
Denis Vlasenko 1ebd0a6d91 remove if() which is always true 2007-09-29 18:27:14 +00:00
Denis Vlasenko 66bbfbd581 bunzip2: trim verbose messages
text    data     bss     dec     hex filename
 770752    1029    9696  781477   beca5 busybox_old
 770691    1029    9696  781416   bec68 busybox_unstripped
2007-09-28 23:45:56 +00:00
Denis Vlasenko 3d2a9217a7 httpd: trivial simplification 2007-09-28 22:35:29 +00:00
Denis Vlasenko ab8c9378c9 more "if (p) free(p)" fixes; fix a typo in comment 2007-09-28 22:13:55 +00:00
Denis Vlasenko 6081868ee3 fix "if (p) free(p)" constructs 2007-09-28 22:07:23 +00:00
Denis Vlasenko e918e155ed remove stray semicolon 2007-09-28 21:56:36 +00:00
Denis Vlasenko 0afdfdf649 hdparm: paranoia-induced fix against theoretical div-by-0 case 2007-09-28 13:41:41 +00:00
Denis Vlasenko 920c52a5c8 hdparm: more robust (re overflows) code. +38 bytes. 2007-09-28 13:38:08 +00:00
Denis Vlasenko a0ad43b80b trivial fix in setfiles. spotted by Yuichi Nakamura <ynakam@hitachisoft.jp> 2007-09-28 11:37:38 +00:00
Denis Vlasenko a7bc9ac8f8 hdparm: reduce possibility of numeric overflow in -T.
do_time                                              386     410     +24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 24/0)               Total: 24 bytes
2007-09-28 11:21:47 +00:00
Denis Vlasenko b925605441 assorted static vars removal
function                                             old     new   delta
tcpudpsvd_main                                      1829    1839     +10
update_status                                        567     569      +2
sigterm                                                1       -      -1
.........
dhcprelay_signal_handler                               8       -      -8
nfs_strerror                                          60      49     -11
singlemount                                         4579    4564     -15
static.p                                              16       -     -16
svstatus                                              20       -     -20
dhcprelay_xid_list                                    32       -     -32
runsv_main                                          1785    1746     -39
static.buf                                            74      28     -46
svd                                                   56       -     -56
dhcprelay_main                                      1141    1080     -61
------------------------------------------------------------------------------
(add/remove: 0/20 grow/shrink: 2/10 up/down: 12/-386)        Total: -374 bytes
2007-09-28 10:29:17 +00:00
Denis Vlasenko c3122bca53 hdparm: simplify timing measurement (it wa the last last user
of setitimer in the tree).

static.thousand                                       16       -     -16
read_big_block                                        81      46     -35
getitimer                                             41       -     -41
setitimer                                             47       -     -47
__GI_setitimer                                        47       -     -47
do_time                                              480     386     -94
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 0/2 up/down: 0/-280)           Total: -280 bytes

M    miscutils/hdparm.c
2007-09-28 10:28:03 +00:00
Denis Vlasenko 0d3c6afc93 hdparm: get rid of static variables
process_dev                                         5309    5311      +2
unregister_hwif                                        1       -      -1
...........
Xreadahead                                             4       -      -4
seek_to_zero                                          25      17      -8
hdparm_main                                         1242    1227     -15
do_time                                              547     480     -67
------------------------------------------------------------------------------
(add/remove: 0/83 grow/shrink: 1/3 up/down: 2/-248)          Total: -246 bytes
2007-09-28 10:25:32 +00:00
Denis Vlasenko 8607677529 libbb: make const_int_0 reside in rodata 2007-09-27 20:49:57 +00:00
Denis Vlasenko 1d31f0f380 libbb: align bb_common_bufsiz1 to "long long" 2007-09-27 20:46:08 +00:00
Denis Vlasenko 78e2d4e361 less: make 'f' page forward 2007-09-27 17:11:48 +00:00
Denis Vlasenko a36535b067 wget: -O FILE is allowed to overwrite existing file (compat) 2007-09-27 15:07:23 +00:00
Denis Vlasenko 6124c37135 zcip: fix unaligned trap on ARM 2007-09-27 11:15:42 +00:00
Denis Vlasenko 7c654ae9df remove stray '/*' within comment 2007-09-27 10:26:59 +00:00
Denis Vlasenko 892536f019 hdparm: use fixed fd #3 for device being interrogated
(surprisingly, on i386 almost no code size change)
2007-09-27 10:23:34 +00:00
Denis Vlasenko 4daad9004d introduce bb_putchar(). saves ~1800 on uclibc (less on glibc). 2007-09-27 10:20:47 +00:00
Denis Vlasenko 1acdc89e99 style and message text fixes 2007-09-27 10:17:53 +00:00
Denis Vlasenko 86b29ea9e8 lineedit: plug memory leak 2007-09-27 10:17:16 +00:00
Denis Vlasenko 33b900f984 vlock: get rid of statics 2007-09-27 10:12:02 +00:00
Denis Vlasenko 5d61e71c3a introduce safe_poll (fixes a problem in top)
function                                             old     new   delta
safe_poll                                              -      77     +77
svlogd_main                                         1470    1466      -4
zcip_main                                           1530    1524      -6
forkexec                                            1345    1338      -7
decode_format_string                                 795     788      -7
collect_blk                                          474     467      -7
buffer_pread                                         540     532      -8
tftp                                                1182    1172     -10
microcom_main                                        763     749     -14
arpping                                              441     424     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/9 up/down: 77/-80)             Total: -3 bytes
   text    data     bss     dec     hex filename
 770162    1034   10404  781600   bed20 busybox_old
 770158    1034   10404  781596   bed1c busybox_unstripped
2007-09-27 10:09:59 +00:00
Denis Vlasenko c9dc2ac578 make variables static 2007-09-27 10:08:02 +00:00
Denis Vlasenko a619b85ef5 check-lxdialog.sh: no point in giving up, maybe -lcurses will work? 2007-09-26 18:18:59 +00:00
Denis Vlasenko b042bd9514 load_policy: update (Yuichi Nakamura <ynakam@hitachisoft.jp>) 2007-09-26 18:01:32 +00:00
Denis Vlasenko dd5e11bb05 chcon: trivial fix 2007-09-26 17:55:55 +00:00
Denis Vlasenko 7ae209c019 losetup: support -f (Loic Grenie <loic.grenie@gmail.com>)
function                                             old     new   delta
losetup_main                                         238     278     +40
packed_usage                                       23021   23027      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 46/0)               Total: 46 bytes
2007-09-26 17:54:18 +00:00
Denis Vlasenko 137fbe495d runsvdir: fix "linear wait time" bug 2007-09-26 12:18:07 +00:00
Denis Vlasenko 3982407ba4 inetd: move struct fields around -> save .25 k of code
function                                             old     new   delta
freeconfig                                            75      76      +1
register_rpc                                         200     196      -4
dupconfig                                            165     159      -6
reapchild                                            173     166      -7
retry                                                 93      82     -11
goaway                                               112     101     -11
getconfigent                                        1241    1222     -19
setup                                                645     592     -53
inetd_main                                          2160    2107     -53
config                                              1602    1518     -84
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 1/-248)           Total: -247 bytes
   text    data     bss     dec     hex filename
 773951    1038   10332  785321   bfba9 busybox_old
 773703    1038   10332  785073   bfab1 busybox_unstripped
2007-09-26 10:46:18 +00:00
Denis Vlasenko 4dd4e6d6b9 install: fix bug in "install -c file dir" (tries to copy dir into dir too)
install: 'support' (ignore) -v and -b
2007-09-26 10:34:54 +00:00
Denis Vlasenko 6a5377ac14 documentation bits in comments, no code changes 2007-09-25 18:35:28 +00:00
Denis Vlasenko ea7645bab6 cp: -r and -R imply -d (coreutils compat) 2007-09-25 18:06:36 +00:00
Denis Vlasenko 35465a3f00 httpd: small auth and IPv6 fixes (Kim B. Heino <Kim.Heino@bluegiga.com>) 2007-09-25 11:58:33 +00:00
Denis Vlasenko d9391b15f1 ed: large cleanup
function                                             old     new   delta
bad_nums                                               -      43     +43
skip_blank                                             -      24     +24
getNum                                               557     578     +21
insertLine                                           159     163      +4
setCurNum                                             31      33      +2
lastNum                                                4       -      -4
fileName                                               4       -      -4
dirty                                                  4       -      -4
curNum                                                 4       -      -4
curLine                                                4       -      -4
bufUsed                                                4       -      -4
bufSize                                                4       -      -4
bufPtr                                                 4       -      -4
bufBase                                                4       -      -4
printLines                                           357     345     -12
findLine                                             165     152     -13
lines                                                 16       -     -16
deleteLines                                          203     144     -59
readLines                                            538     473     -65
addLines                                             163      87     -76
marks                                                104       -    -104
termEdit                                             140       -    -140
ed_main                                             3125    2654    -471
------------------------------------------------------------------------------
(add/remove: 2/12 grow/shrink: 3/6 up/down: 94/-992)         Total: -898 bytes
   text    data     bss     dec     hex filename
 771142    1034   10564  782740   bf194 busybox_old
 770265    1034   10404  781703   bed87 busybox_unstripped

# size */ed.o
   text    data     bss     dec     hex filename
   6370       0     156    6526    197e editors.org/ed.o
   5505       0       0    5505    1581 editors/ed.o
2007-09-25 11:55:57 +00:00
Denis Vlasenko a545726d2b insmod: fix help text to not show options if only 2.6 was selected 2007-09-24 20:14:32 +00:00
Denis Vlasenko d9c6a001e3 insmod: shorten message text; style fixes 2007-09-24 19:54:36 +00:00
Denis Vlasenko e9b3321b9f tar: add a comment about previous subtle fix 2007-09-24 19:32:53 +00:00
Denis Vlasenko 86e0a22ec6 tar: strip leading '/' BEFORE memorizing hardlink's name
function                                             old     new   delta
writeFileToTarball                                  1362    1352     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10)             Total: -10 bytes
2007-09-24 19:07:57 +00:00
Denis Vlasenko 46a530626d ash: fix prompt expansion (Natanael Copa <natanael.copa@gmail.com>) 2007-09-24 18:30:02 +00:00
Denis Vlasenko 818322b9b1 *: kill bb_get_last_path_component, replace with two functions
(one which strips trailing slash and one which does not)
wget: straighten out as a result of above change
   text    data     bss     dec     hex filename
   5056       1       0    5057    13c1 busybox.t4/networking/wget.o
   5022       0       0    5022    139e busybox.t5/networking/wget.o
2007-09-24 18:27:04 +00:00
Denis Vlasenko a7ce207bd8 wget: get rid of setitimer
text    data     bss     dec     hex filename
   5110       1       0    5111    13f7 busybox.t3/networking/wget.o
   5056       1       0    5057    13c1 busybox.t4/networking/wget.o
2007-09-24 18:25:08 +00:00
Denis Vlasenko 47ddd01b3c wget: reorder functions, no code changes 2007-09-24 18:24:17 +00:00
Denis Vlasenko 7710563858 wget: code shrink, move data out of bss 2007-09-24 15:04:00 +00:00
Denis Vlasenko 06783a5140 wget: allow dots in header field names.
wget: code shrink

function                                             old     new   delta
gethdr                                               211     190     -21
wget_main                                           2609    2557     -52
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-73)             Total: -73 bytes
2007-09-24 13:51:54 +00:00
Denis Vlasenko 512a545f0d inetd: make some fields smaller, move data out of data/bss sections
function                                             old     new   delta
inetd_main                                          2125    2160     +35
setup                                                640     645      +5
initring                                              48      53      +5
reapchild                                            169     173      +4
retry                                                 92      93      +1
goaway                                               113     112      -1
inetd_setproctitle                                   175     173      -2
chargen_dg                                           229     227      -2
uid                                                    4       -      -4
.......................
Argv                                                   4       -      -4
rlim_ofile_cur                                         8       -      -8
config                                              1610    1602      -8
rlim_ofile                                            16       -     -16
getconfigent                                        1271    1241     -30
builtins                                             176     132     -44
ring                                                 128       -    -128
allsock                                              128       -    -128
------------------------------------------------------------------------------
(add/remove: 0/18 grow/shrink: 5/6 up/down: 50/-423)         Total: -373 bytes
   text    data     bss     dec     hex filename
 774144    1051   10708  785903   bfdef busybox_old
 774108    1039   10380  785527   bfc77 busybox_unstripped
$ size inetd.o inetd_orig.o
   text    data     bss     dec     hex filename
   9027       0       0    9027    2343 inetd.o
   9064      12     324    9400    24b8 inetd_orig.o
2007-09-24 10:41:30 +00:00
Denis Vlasenko 2a1d024333 run_parts: make it sort executables by name (required by API) 2007-09-23 18:34:49 +00:00
Denis Vlasenko 06b3cc2811 make fdisk compile on libc without llseek64 2007-09-23 14:05:54 +00:00
Denis Vlasenko 32a471e4db httpd: simplify CGI i/o loop. -200 bytes. 2007-09-23 13:56:57 +00:00
Denis Vlasenko 9a4e08eaa8 include libbb.h, not busybox.h 2007-09-22 21:37:27 +00:00
Bernhard Reutner-Fischer 73f56bb76d - actually mv microcom.c to miscutils 2007-09-22 21:18:46 +00:00
Bernhard Reutner-Fischer 3a252b8c12 - add microcom to defconfig 2007-09-22 21:13:17 +00:00
Denis Vlasenko 23856ab8e6 move microcom to miscutils 2007-09-22 20:51:41 +00:00
Bernhard Reutner-Fischer f588f70b91 - remove some trailing whitespace 2007-09-22 20:35:32 +00:00
Denis Vlasenko f34e821572 microcom: add copyright/license info 2007-09-22 20:23:57 +00:00
Denis Vlasenko 7b70d78de8 ash: remove erroneously applied patch 2007-09-21 22:48:02 +00:00
Denis Vlasenko f431017535 httpd: optional support for partial downloads 2007-09-21 22:35:18 +00:00
Denis Vlasenko bcceb0c5a4 ash: s/int/smallint/. -60 bytes. 2007-09-21 18:06:20 +00:00
Denis Vlasenko fc5d15912c test: correct confusing placement of "const" 2007-09-21 17:58:43 +00:00
Denis Vlasenko 707669501f microcom: add new applet, this time for real 2007-09-21 17:42:40 +00:00
Denis Vlasenko efd3f38f8c microcom: new applet by Vladimir Dronnikov <dronnikov@gmail.ru> 2007-09-21 13:43:28 +00:00
Denis Vlasenko 0beaff8c19 update Glenn McGrath's email address 2007-09-21 13:16:32 +00:00
Denis Vlasenko 9b0a439f02 remove stray 8-bit chars from copyright banner 2007-09-20 19:44:10 +00:00
Denis Vlasenko 27bd8d7146 announce 1.7.1 on website 2007-09-16 19:41:40 +00:00
Denis Vlasenko 2535f12cf2 httpd: do not clear environment
mount: mount helpers support (by Vladimir Dronnikov <dronnikov@gmail.ru>)
2007-09-15 13:28:30 +00:00
Denis Vlasenko 32eb1f6cb9 webpage: add a link to vda's "init must die" page 2007-09-13 20:20:44 +00:00
Denis Vlasenko a9335eafcf cp: make it a bit closer to POSIX, but still refuse to open and
write to dest which is a symlink.
2007-09-11 16:28:14 +00:00
Denis Vlasenko fa05074eee cp: make "cp file /dev/node" special case; explained in comments
function                                             old     new   delta
copy_file                                           1487    1538     +51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 51/0)               Total: 51 bytes
   text    data     bss     dec     hex filename
 772502    1051   10724  784277   bf795 busybox_old
 772554    1051   10724  784329   bf7c9 busybox_unstripped
2007-09-11 10:39:13 +00:00
Denis Vlasenko 976690afe0 run_shell: code shrink for selinux 2007-09-10 17:17:01 +00:00
Denis Vlasenko a2f61012b6 setup_environment: code shrink
run_shell: mark as NORETURN
setup_environment, run_shell: add usage comments
login: add FIXME :(

function                                             old     new   delta
UNSPEC_print                                          64      66      +2
sulogin_main                                         509     506      -3
mkfs_minix_main                                     3070    3067      -3
login_main                                          1615    1612      -3
su_main                                              461     448     -13
setup_environment                                    261     206     -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/5 up/down: 2/-77)             Total: -75 bytes
   text    data     bss     dec     hex filename
 772578    1051   10724  784353   bf7e1 busybox_old
 772502    1051   10724  784277   bf795 busybox_unstripped
2007-09-10 13:15:28 +00:00
Denis Vlasenko ac074b3f87 grep: delete obsolete comment 2007-09-10 12:23:27 +00:00
Denis Vlasenko 04ea11b033 grep: fix grep -F -e str1 -e str2 (was matching str2 only)
by replacing "=" by "|=" here:
  found |= strstr(line, gl->pattern) != NULL;
grep: optimization: stop on first -e match
grep: stop using bss. -40 bytes
2007-09-10 12:18:32 +00:00
Denis Vlasenko 476b070036 style fix, no code changes 2007-09-09 14:11:11 +00:00
Denis Vlasenko bf8fcaceb7 open_transformer: fix vda's goofup 2007-09-09 11:20:55 +00:00
Denis Vlasenko 4d7605af86 top: small fix for command line wrapping 2007-09-08 17:42:00 +00:00
Denis Vlasenko 4c1d88daff top: get rid of on-stack variable buffers, use permanent one.
code shrank with and without TOPMEM:

top_main                                             828     844     +16
display_process_list                                1525    1473     -52
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-52)            Total: -36 bytes

top_main                                            1150    1171     +21
display_topmem_process_list                         1150    1167     +17
display_process_list                                1525    1473     -52
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 38/-52)            Total: -14 bytes
2007-09-08 17:34:05 +00:00
Denis Vlasenko e7c1ad1540 top: add sizeof(G) check; fix style 2007-09-08 17:21:01 +00:00
Denis Vlasenko ff6e8e2974 top: TOPMEM feature - 's(how sizes)' command. +2.5k when enabled,
+80 bytes when disabled (mainly because of text wrapping fixes
in display_process_list).
2007-09-08 16:51:19 +00:00
Paul Fox 9382b3809b overload the existing '-q' flag so that if '-l' and '-q' are used
together, a "short form" listing (just pathnames) is generated.
change a few flag variables to "smallint" as well.
2007-09-07 20:28:25 +00:00
Denis Vlasenko c8d4d2f11d messages: by popular request allow PATH to be customized at build time
mount: smallish code shrink
2007-09-07 19:33:56 +00:00
Denis Vlasenko d7ecd863c8 syslogd: do not need to poll(), we can just block in read().
function                                             old     new   delta
syslogd_main                                        1206    1106    -100
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-100)           Total: -100 bytes
   text    data     bss     dec     hex filename
 769820    1051   10764  781635   bed43 busybox_old
 769702    1051   10764  781517   beccd busybox_unstripped
2007-09-07 13:53:32 +00:00
Denis Vlasenko 87f3b26b3a *: replace select-for-one descriptor with poll, it's smaller.
$ ./.cmk bloatcheck
function                                             old     new   delta
readit                                               406     364     -42
syslogd_main                                        1249    1206     -43
traceroute_main                                     4115    4060     -55
mysleep                                              112      45     -67
arpping                                              579     441    -138
tftp                                                1575    1182    -393
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-738)           Total: -738 bytes
   text    data     bss     dec     hex filename
 770580    1051   10764  782395   bf03b busybox_old
 769820    1051   10764  781635   bed43 busybox_unstripped
2007-09-07 13:43:28 +00:00
Paul Fox 40f0bcf9d3 fix infinite retry bug. also, reduce per-packet receive timeout
to something more reasonable than 5 seconds, and add simple
exponential backoff to compensate.  improves performance on
marginal networks.
2007-09-06 17:52:22 +00:00
Paul Fox dcf9bba3b7 fix -xdev behavior in the presence of two or more nested mount points
on the command line, e.g. "find / /boot -xdev".
2007-09-06 17:45:16 +00:00
Denis Vlasenko fdf9060aa3 umount: support (by ignoring) -i; style fixes 2007-09-06 16:57:05 +00:00
Denis Vlasenko cef23e0d8b usage: trim a bit
function                                             old     new   delta
packed_usage                                       23113   23011    -102
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-102)           Total: -102 bytes
   text    data     bss     dec     hex filename
 770610    1051   10764  782425   bf059 busybox_old
 770508    1051   10764  782323   beff3 busybox_unstripped
2007-09-05 15:45:51 +00:00
Denis Vlasenko 3638cc4462 watchdog: allow millisecond spec (-t 250ms)
function                                             old     new   delta
packed_usage                                       23069   23113     +44
static.suffixes                                        -      24     +24
watchdog_main                                        147     160     +13
static.V                                               -       1      +1
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 82/0)               Total: 82 bytes
2007-09-05 12:13:51 +00:00
Denis Vlasenko 211f7f88ae tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau <landau_alex@yahoo.com>) 2007-09-05 11:48:32 +00:00
Denis Vlasenko beffd43d8e busybox --install -s: prevent puzzling "/bin/busybox: Invalid argument" message
libbb: comment out realpath, add readlink which doesn't warn
2007-09-05 11:30:34 +00:00
Denis Vlasenko 7e0fbf9c26 tar: conditionally don't wait for vforked child to exec, as it always
works right on Linux, and anyway mayresult only on less-than-clear error
message only, it will not cause tar to misbehave.

function                                             old     new   delta
open_transformer                                      98      80     -18
writeTarFile                                         714     547    -167
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-185)           Total: -185 bytes
   text    data     bss     dec     hex filename
 770651    1051   10764  782466   bf082 busybox_old
 770463    1051   10764  782278   befc6 busybox_unstripped
2007-09-04 19:33:22 +00:00
Denis Vlasenko f0000653e9 mount: ignore NFS bg option on NOMMU machines 2007-09-04 18:30:26 +00:00
Denis Vlasenko 21b83cfb27 du: remove statics (by Bernhard Fischer <rep.dot.nop@gmail.com>)
$ ./.cmk bloatcheck
function                                             old     new   delta
du_main                                              340     348      +8
print                                                 39      40      +1
status                                               129     125      -4
slink_depth                                            4       -      -4
print_files                                            4       -      -4
one_file_system                                        4       -      -4
max_print_depth                                        4       -      -4
du_depth                                               4       -      -4
disp_hr                                                4       -      -4
count_hardlinks                                        4       -      -4
du                                                   407     401      -6
dir_dev                                                8       -      -8
------------------------------------------------------------------------------
(add/remove: 0/8 grow/shrink: 2/2 up/down: 9/-46)             Total: -37 bytes
   text    data     bss     dec     hex filename
    864      12      28     904     388 busybox.t3/coreutils/du.o
    867       0       0     867     363 busybox.t4/coreutils/du.o
 770647    1063   10788  782498   bf0a2 busybox.t3/busybox_unstripped
 770651    1051   10764  782466   bf082 busybox.t4/busybox_unstripped
2007-09-03 20:05:58 +00:00
Denis Vlasenko 82f3b16713 login: do reject wrong passwords with PAM auth 2007-09-03 11:56:27 +00:00
Denis Vlasenko 9862e6b056 trylink: reinstate accidentally deleted --verbose
trylink: remove commented-out parts
2007-09-03 11:28:14 +00:00
Bernhard Reutner-Fischer fc202427d5 - IFUPDOWN_IFSTATE_PATH depends on IFUPDOWN 2007-09-02 22:12:07 +00:00
Bernhard Reutner-Fischer d2bb2d3918 - Generally strip off -l that does not pull in a lib.
If l_list is non-empty then add the group flags.
2007-09-02 15:28:30 +00:00
Bernhard Reutner-Fischer 8d91c13df5 - fix bug where we linked again -lm even though it is not needed.
For BBOX_LIB_LIST="crypt m" trylink ... with just applet true, we pulled in
  libm because in this case we tried to use invalid flags (plain "-l" without
  a lib) which of course failed, thus the script thought that -lm was needed.

  The fix is not to pass "-l" without a lib if we are about to check if any
  or the last remaining lib is really needed.
2007-09-02 14:51:54 +00:00
Denis Vlasenko 7bc5360bba isrv: use monotonic_sec
runsv: do not use clock_gettime if !MONOTONIC_CLOCK
2007-08-31 21:45:52 +00:00
Denis Vlasenko 05241802a7 top: another readability fix 2007-08-29 18:34:26 +00:00
Denis Vlasenko fc1e9951c6 vsz and rss are unsigned longs (ulong ~= width of void* =>
suitable for expressing total RAM in system). We account
for "32 bit in 64 bit" systems by storing kbytes, not bytes
there. Should allow for up to ~2000 Gb RAM on 32 bits.
2007-08-29 18:23:36 +00:00
Denis Vlasenko 8bdba4d011 top: don't wait before final bailout (try top -b -n1).
top: make code a bit more readable.
2007-08-29 18:18:08 +00:00
Denis Vlasenko fb48f6c982 mount: allow (and ignore) -i 2007-08-29 11:49:41 +00:00
Denis Vlasenko 76c476f817 smart_ulltoa5: emit small letters k,m,g... - makes top
more readable
2007-08-28 20:04:15 +00:00
Denis Vlasenko b308d81e92 top: use poll instead of select for waiting on one descriptor
smart_ulltoa5: make it more cryptic. -50 bytes.

function                                             old     new   delta
passwd_main                                         1095    1103      +8
getNum                                               557     565      +8
buffer_fill_and_print                                 73      76      +3
udhcpc_main                                         2393    2395      +2
mkfs_minix_main                                     3071    3070      -1
dname_enc                                            377     373      -4
expmeta                                              480     472      -8
smart_ulltoa5                                        334     283     -51
top_main                                             911     815     -96
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/5 up/down: 21/-160)          Total: -139 bytes
   text    data     bss     dec     hex filename
 770872    1063   10788  782723   bf183 busybox_old
 770732    1063   10788  782583   bf0f7 busybox_unstripped
2007-08-28 19:35:34 +00:00
Denis Vlasenko 7d8de4d55d mount: don't close fd twice in NFS code 2007-08-28 11:23:23 +00:00
Denis Vlasenko 0f214ecef0 cp: fix recursion check to not waste bytes remembering names of dirs 2007-08-27 17:02:19 +00:00
Denis Vlasenko 8a5fab6333 cp: detect and prevent infinite recursion 2007-08-27 16:51:30 +00:00
Denis Vlasenko 512499c8ca ps: fix RSS parsing (rss field in /proc/PID/stat is in pages, not bytes) 2007-08-26 18:23:13 +00:00
Denis Vlasenko ec9781d5e4 add links to vda's pet projects 2007-08-26 16:39:47 +00:00
Denis Vlasenko 614aca61e5 install: shrink a bit, fix two buglets 2007-08-26 14:21:55 +00:00
Denis Vlasenko 6dd333dfe6 Start a small document "why ifupdown is bad" 2007-08-25 22:16:04 +00:00
Denis Vlasenko 30bab71f7b make copy_file() a bit easier to understand, and smaller
function                                             old     new   delta
copy_file                                           1565    1447    -118
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-118)           Total: -118 bytes
   text    data     bss     dec     hex filename
 770938    1063   10788  782789   bf1c5 busybox_old
 770814    1063   10788  782665   bf149 busybox_unstripped
2007-08-25 21:14:55 +00:00
Denis Vlasenko 737d131e5e support "#!/bin/busybox"-style wrappers. Needed for SELinux.
Patch by Yuichi Nakamura <ynakam@hitachisoft.jp>
2007-08-25 18:25:24 +00:00
Bernhard Reutner-Fischer 5222677176 - add Yann's email-addr 2007-08-25 11:16:18 +00:00
Denis Vlasenko 6666ac42a5 cp,mv: simpler arg[cv] handling -> smallish code savings 2007-08-24 21:46:24 +00:00
Bernhard Reutner-Fischer 2062fc4155 - cosmetic html cleanup 2007-08-24 14:32:23 +00:00
Bernhard Reutner-Fischer 6a7b7ce23e - obfuscate addrs a little bit 2007-08-24 14:30:59 +00:00
Denis Vlasenko 3d829627fb cp: make POSIX-me-harder mode complain with a bit less insane message 2007-08-24 14:23:57 +00:00
Denis Vlasenko cab774d6e5 spelling fixes to website 2007-08-24 12:52:04 +00:00
Denis Vlasenko 46fc23b532 Cosmetic fixes to webpage 2007-08-24 11:49:55 +00:00
Denis Vlasenko 30f00a4286 add missed attribution to httpd sendfile support 2007-08-24 11:18:21 +00:00
Denis Vlasenko 66dc9068eb Start 1.8.x cycle 2007-08-24 11:05:49 +00:00
902 changed files with 62008 additions and 30166 deletions

No files matched your search

+1 -1
View File
@@ -95,7 +95,7 @@ Stephan Linz <linz@li-pro.net>
John Lombardo <john@deltanet.com>
tr
Glenn McGrath <bug1@iinet.net.au>
Glenn McGrath <glenn.l.mcgrath@gmail.com>
Common unarchiving code and unarchiving applets, ifupdown, ftpgetput,
nameif, sed, patch, fold, install, uudecode.
Various bugfixes, review and apply numerous patches.
+198 -109
View File
@@ -13,22 +13,6 @@ menu "Busybox Settings"
menu "General Configuration"
config NITPICK
bool "See lots more (probably unnecessary) configuration options."
default n
help
Some BusyBox applets have more configuration options than anyone
will ever care about. To avoid drowining people in complexity, most
of the applet features that can be set to a sane default value are
hidden, unless you hit the above switch.
This is better than to telling people to edit the busybox source
code, but not by much.
See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet
You have been warned.
config DESKTOP
bool "Enable options for full-blown desktop systems"
default n
@@ -37,15 +21,35 @@ config DESKTOP
Select this only if you plan to use busybox on full-blown
desktop machine with common Linux distro, not on an embedded box.
config EXTRA_COMPAT
bool "Provide compatible behavior for rare corner cases (bigger code)"
default n
help
This option makes grep, sed etc handle rare corner cases
(embedded NUL bytes and such). This makes code bigger and uses
some GNU extensions in libc. You probably only need this option
if you plan to run busybox on desktop.
config FEATURE_ASSUME_UNICODE
bool "Assume that 1:1 char/glyph correspondence is not true"
default n
help
This makes various applets aware that one byte is not
one character on screen.
Busybox aims to eventually work correctly with Unicode displays.
Any older encodings are not guaranteed to work.
Probably by the time when busybox will be fully Unicode-clean,
other encodings will be mainly of historic interest.
choice
prompt "Buffer allocation policy"
default FEATURE_BUFFERS_USE_MALLOC
depends on NITPICK
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
- Put them on stack. For some very small machines with limited stack
space, this can be deadly. For most folks, this works just fine.
space, this can be deadly. For most folks, this works just fine.
- Put them in BSS. This works beautifully for computers with a real
MMU (and OS support), but wastes runtime RAM for uCLinux. This
behavior was the only one available for BusyBox versions 0.48 and
@@ -77,8 +81,8 @@ config FEATURE_VERBOSE_USAGE
select SHOW_USAGE
help
All BusyBox applets will show more verbose help messages when
busybox is invoked with --help. This will add a lot of text to the
busybox binary. In the default configuration, this will add about
busybox is invoked with --help. This will add a lot of text to the
busybox binary. In the default configuration, this will add about
13k, but it can add much more depending on your configuration.
config FEATURE_COMPRESS_USAGE
@@ -91,15 +95,15 @@ config FEATURE_COMPRESS_USAGE
If you have a really tiny busybox with few applets enabled (and
bunzip2 isn't one of them), the overhead of the decompressor might
be noticeable. Also, if you run executables directly from ROM
and have very little memory, this might not be a win. Otherwise,
be noticeable. Also, if you run executables directly from ROM
and have very little memory, this might not be a win. Otherwise,
you probably want this.
config FEATURE_INSTALLER
bool "Support --install [-s] to install applet links at runtime"
default n
help
Enable 'busybox --install [-s]' support. This will allow you to use
Enable 'busybox --install [-s]' support. This will allow you to use
busybox at runtime to create hard links or symlinks for all the
applets that are compiled into busybox.
@@ -111,7 +115,7 @@ config LOCALE_SUPPORT
busybox to support locale settings.
config GETOPT_LONG
bool "Enable support for --long-options"
bool "Support for --long-options"
default y
help
Enable this if you want busybox applets to use the gnu --long-option
@@ -123,17 +127,16 @@ config FEATURE_DEVPTS
help
Enable if you want BusyBox to use Unix98 PTY support. If enabled,
busybox will use /dev/ptmx for the master side of the pseudoterminal
and /dev/pts/<number> for the slave side. Otherwise, BSD style
and /dev/pts/<number> for the slave side. Otherwise, BSD style
/dev/ttyp<number> will be used. To use this option, you should have
devpts mounted.
config FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
depends on NITPICK
help
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
freeing dynamically allocated memory or closing files. This saves
space since the OS will clean up for us, but it can confuse debuggers
like valgrind, which report tons of memory and resource leaks.
@@ -158,7 +161,7 @@ config FEATURE_SUID
If you're really paranoid and don't want to do this, build two
busybox binaries with different applets in them (and the appropriate
symlinks pointing to each binary), and only set the suid bit on the
one that needs it. The applets currently marked to need the suid bit
one that needs it. The applets currently marked to need the suid bit
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
and vlock.
@@ -168,7 +171,7 @@ config FEATURE_SUID_CONFIG
depends on FEATURE_SUID
help
Allow the SUID / SGID state of an applet to be determined at runtime
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
The format of this file is as follows:
<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)
@@ -176,20 +179,21 @@ config FEATURE_SUID_CONFIG
An example might help:
[SUID]
su = ssx root.0 # applet su can be run by anyone and runs with euid=0/egid=0
su = ssx root.0 # applet su can be run by anyone and runs with
# euid=0/egid=0
su = ssx # exactly the same
mount = sx- root.disk # applet mount can be run by root and members of group disk
# and runs with euid=0
mount = sx- root.disk # applet mount can be run by root and members
# of group disk and runs with euid=0
cp = --- # disable applet cp for everyone
The file has to be owned by user root, group root and has to be
writeable only by root:
(chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
(chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
The busybox executable has to be owned by user root, group
root and has to be setuid root for this to work:
(chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
(chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
Robert 'sandman' Griebl has more information here:
<url: http://www.softforge.de/bb/suid.html >.
@@ -199,14 +203,15 @@ config FEATURE_SUID_CONFIG_QUIET
default y
depends on FEATURE_SUID_CONFIG
help
/etc/busybox.conf should be readable by the user needing the SUID, check
this option to avoid users to be notified about missing permissions.
/etc/busybox.conf should be readable by the user needing the SUID,
check this option to avoid users to be notified about missing
permissions.
config SELINUX
bool "Support NSA Security Enhanced Linux"
default n
help
Enable support for SELinux in applets ls, ps, and id. Also provide
Enable support for SELinux in applets ls, ps, and id. Also provide
the option of compiling in SELinux applets.
If you do not have a complete SELinux userland installed, this stuff
@@ -241,9 +246,9 @@ config BUSYBOX_EXEC_PATH
default "/proc/self/exe"
help
When Busybox applets need to run other busybox applets, BusyBox
sometimes needs to exec() itself. When the /proc filesystem is
sometimes needs to exec() itself. When the /proc filesystem is
mounted, /proc/self/exe always points to the currently running
executable. If you haven't got /proc, set this to wherever you
executable. If you haven't got /proc, set this to wherever you
want to run BusyBox from.
# These are auto-selected by other options
@@ -280,44 +285,104 @@ config STATIC
Most people will leave this set to 'N'.
config PIE
bool "Build BusyBox as a position independent executable"
default n
depends on !STATIC
help
(TODO: what is it and why/when is it useful?)
Most people will leave this set to 'N'.
config NOMMU
bool "Force NOMMU build"
default n
help
Busybox tries to detect whether architecture it is being
built against supports MMU or not. If this detection fails,
or if you want to build NOMMU version of busybox for testing,
you may force NOMMU build here.
Most people will leave this set to 'N'.
# PIE can be made to work with BUILD_LIBBUSYBOX, but currently
# build system does not support that
config BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
depends on !FEATURE_PREFER_APPLETS && !PIE && !STATIC
help
Build a shared library libbusybox.so which contains all
libraries used inside busybox.
Build a shared library libbusybox.so.N.N.N which contains all
busybox code.
This is an experimental feature intended to support the upcoming
"make standalone" mode. Enabling it against the one big busybox
binary serves no purpose (and increases the size). You should
almost certainly say "no" to this right now.
This feature allows every applet to be built as a tiny
separate executable. Enabling it for "one big busybox binary"
approach serves no purpose and increases code size.
You should almost certainly say "no" to this.
config FEATURE_FULL_LIBBUSYBOX
bool "Feature-complete libbusybox"
default n if !FEATURE_SHARED_BUSYBOX
### config FEATURE_FULL_LIBBUSYBOX
### bool "Feature-complete libbusybox"
### default n if !FEATURE_SHARED_BUSYBOX
### depends on BUILD_LIBBUSYBOX
### help
### Build a libbusybox with the complete feature-set, disregarding
### the actually selected config.
###
### Normally, libbusybox will only contain the features which are
### used by busybox itself. If you plan to write a separate
### standalone application which uses libbusybox say 'Y'.
###
### Note: libbusybox is GPL, not LGPL, and exports no stable API that
### might act as a copyright barrier. We can and will modify the
### exported function set between releases (even minor version number
### changes), and happily break out-of-tree features.
###
### Say 'N' if in doubt.
config FEATURE_INDIVIDUAL
bool "Produce a binary for each applet, linked against libbusybox"
default y
depends on BUILD_LIBBUSYBOX
help
Build a libbusybox with the complete feature-set, disregarding
the actually selected config.
If your CPU architecture doesn't allow for sharing text/rodata
sections of running binaries, but allows for runtime dynamic
libraries, this option will allow you to reduce memory footprint
when you have many different applets running at once.
Normally, libbusybox will only contain the features which are
used by busybox itself. If you plan to write a separate
standalone application which uses libbusybox say 'Y'.
If your CPU architecture allows for sharing text/rodata,
having single binary is more optimal.
Note: libbusybox is GPL, not LGPL, and exports no stable API that
might act as a copyright barrier. We can and will modify the
exported function set between releases (even minor version number
changes), and happily break out-of-tree features.
Each applet will be a tiny program, dynamically linked
against libbusybox.so.N.N.N.
Say 'N' if in doubt.
You need to have a working dynamic linker.
config FEATURE_SHARED_BUSYBOX
bool "Use shared libbusybox for busybox"
default y if BUILD_LIBBUSYBOX
depends on !STATIC && BUILD_LIBBUSYBOX
bool "Produce additional busybox binary linked against libbusybox"
default y
depends on BUILD_LIBBUSYBOX
help
Use libbusybox.so also for busybox itself.
You need to have a working dynamic linker to use this variant.
Build busybox, dynamically linked against libbusybox.so.N.N.N.
You need to have a working dynamic linker.
### config BUILD_AT_ONCE
### bool "Compile all sources at once"
### default n
### help
### Normally each source-file is compiled with one invocation of
### the compiler.
### If you set this option, all sources are compiled at once.
### This gives the compiler more opportunities to optimize which can
### result in smaller and/or faster binaries.
###
### Setting this option will consume alot of memory, e.g. if you
### enable all applets with all features, gcc uses more than 300MB
### RAM during compilation of busybox.
###
### This option is most likely only beneficial for newer compilers
### such as gcc-4.1 and above.
###
### Say 'N' unless you know what you are doing.
config LFS
bool "Build with Large File Support (for accessing files > 2 GB)"
@@ -325,30 +390,21 @@ config LFS
select FDISK_SUPPORT_LARGE_DISKS
help
If you want to build BusyBox with large file support, then enable
this option. This will have no effect if your kernel or your C
library lacks large file support for large files. Some of the
this option. This will have no effect if your kernel or your C
library lacks large file support for large files. Some of the
programs that can benefit from large file support include dd, gzip,
cp, mount, tar, and many others. If you want to access files larger
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
cp, mount, tar, and many others. If you want to access files larger
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
config BUILD_AT_ONCE
bool "Compile all sources at once"
default n
config CROSS_COMPILER_PREFIX
string "Cross Compiler prefix"
default ""
help
Normally each source-file is compiled with one invocation of
the compiler.
If you set this option, all sources are compiled at once.
This gives the compiler more opportunities to optimize which can
result in smaller and/or faster binaries.
Setting this option will consume alot of memory, e.g. if you
enable all applets with all features, gcc uses more than 300MB
RAM during compilation of busybox.
This option is most likely only beneficial for newer compilers
such as gcc-4.1 and above.
Say 'N' unless you know what you are doing.
If you want to build BusyBox with a cross compiler, then you
will need to set this to the cross-compiler prefix, for example,
"i386-uclibc-". Note that CROSS_COMPILE environment variable
or "make CROSS_COMPILE=xxx ..." will override this selection.
For native build leave it empty.
endmenu
@@ -359,12 +415,23 @@ config DEBUG
default n
help
Say Y here if you wish to examine BusyBox internals while applets are
running. This increases the size of the binary considerably, and
should only be used when doing development. If you are doing
running. This increases the size of the binary considerably, and
should only be used when doing development. If you are doing
development and want to debug BusyBox, answer Y.
Most people should answer N.
config DEBUG_PESSIMIZE
bool "Disable compiler optimizations"
default n
depends on DEBUG
help
The compiler's optimization of source code can eliminate and reorder
code, resulting in an executable that's hard to understand when
stepping through it with a debugger. This switches it off, resulting
in a much bigger executable that more closely matches the source
code.
config WERROR
bool "Abort compilation on any warning"
default n
@@ -373,44 +440,33 @@ config WERROR
Most people should answer N.
# Seems to be unused
#config DEBUG_PESSIMIZE
# bool "Disable compiler optimizations."
# default n
# depends on DEBUG
# help
# The compiler's optimization of source code can eliminate and reorder
# code, resulting in an executable that's hard to understand when
# stepping through it with a debugger. This switches it off, resulting
# in a much bigger executable that more closely matches the source
# code.
choice
prompt "Additional debugging library"
default NO_DEBUG_LIB
help
Using an additional debugging library will make BusyBox become
considerable larger and will cause it to run more slowly. You
considerable larger and will cause it to run more slowly. You
should always leave this option disabled for production use.
dmalloc support:
----------------
This enables compiling with dmalloc ( http://dmalloc.com/ )
which is an excellent public domain mem leak and malloc problem
detector. To enable dmalloc, before running busybox you will
detector. To enable dmalloc, before running busybox you will
want to properly set your environment, for example:
export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
The 'debug=' value is generated using the following command
dmalloc -p log-stats -p log-non-free -p log-bad-space -p log-elapsed-time \
-p check-fence -p check-heap -p check-lists -p check-blank \
-p check-funcs -p realloc-copy -p allow-free-null
dmalloc -p log-stats -p log-non-free -p log-bad-space \
-p log-elapsed-time -p check-fence -p check-heap \
-p check-lists -p check-blank -p check-funcs -p realloc-copy \
-p allow-free-null
Electric-fence support:
-----------------------
This enables compiling with Electric-fence support. Electric
This enables compiling with Electric-fence support. Electric
fence is another very useful malloc debugging library which uses
your computer's virtual memory hardware to detect illegal memory
accesses. This support will make BusyBox be considerable larger
accesses. This support will make BusyBox be considerable larger
and run slower, so you should leave this option disabled unless
you are hunting a hard to find memory problem.
@@ -432,9 +488,12 @@ config INCLUDE_SUSv2
help
This option will enable backwards compatibility with SuSv2,
specifically, old-style numeric options ('command -1 <file>')
will be supported in head, tail, and fold. (Note: should
will be supported in head, tail, and fold. (Note: should
affect renice too.)
config PARSE
bool "Uniform config file parser debugging applet: parse"
endmenu
menu 'Installation Options'
@@ -462,8 +521,13 @@ config INSTALL_APPLET_SYMLINKS
config INSTALL_APPLET_HARDLINKS
bool "as hard-links"
help
Install applets as hard-links to the busybox binary. This might count
on a filesystem with few inodes.
Install applets as hard-links to the busybox binary. This might
count on a filesystem with few inodes.
config INSTALL_APPLET_SCRIPT_WRAPPERS
bool "as script wrappers"
help
Install applets as script wrappers that call the busybox binary.
config INSTALL_APPLET_DONT
bool "not installed"
@@ -474,6 +538,31 @@ config INSTALL_APPLET_DONT
endchoice
choice
prompt "/bin/sh applet link"
default INSTALL_SH_APPLET_SYMLINK
depends on INSTALL_APPLET_SCRIPT_WRAPPERS
help
Choose how you install /bin/sh applet link.
config INSTALL_SH_APPLET_SYMLINK
bool "as soft-link"
help
Install /bin/sh applet as soft-link to the busybox binary.
config INSTALL_SH_APPLET_HARDLINK
bool "as hard-link"
help
Install /bin/sh applet as hard-link to the busybox binary.
config INSTALL_SH_APPLET_SCRIPT_WRAPPER
bool "as script wrapper"
help
Install /bin/sh applet as script wrapper that call the busybox
binary.
endchoice
config PREFIX
string "BusyBox installation prefix"
default "./_install"
@@ -506,4 +595,4 @@ source shell/Config.in
source sysklogd/Config.in
source runit/Config.in
source selinux/Config.in
source ipsvd/Config.in
source printutils/Config.in
+57 -37
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 7
SUBLEVEL = 5
PATCHLEVEL = 12
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
@@ -142,17 +142,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH TOPDIR
# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
# line overrides the setting of ARCH below. If a native build is happening,
# then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
@@ -172,8 +161,32 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
CROSS_COMPILE ?=
# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
# and it has not been included yet... thus using an awkward syntax.
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null)
CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE))
CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE))
endif
# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
# line overrides the setting of ARCH below. If a native build is happening,
# then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.
ifneq ($(CROSS_COMPILE),)
SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
else
SUBARCH := $(shell uname -m)
endif
SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
ARCH ?= $(SUBARCH)
# Architecture as present in compile.h
UTS_MACHINE := $(ARCH)
@@ -302,6 +315,8 @@ AFLAGS_KERNEL =
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
CFLAGS := $(CFLAGS)
# Added only to final link stage of busybox binary
CFLAGS_busybox := $(CFLAGS_busybox)
CPPFLAGS := $(CPPFLAGS)
AFLAGS := $(AFLAGS)
LDFLAGS := $(LDFLAGS)
@@ -361,7 +376,8 @@ endif
# of make so .config is not included in this case either (for *config).
no-dot-config-targets := clean mrproper distclean \
cscope TAGS tags help %docs check%
cscope TAGS tags help %docs
#bbox# check% is removed from above
config-targets := 0
mixed-targets := 0
@@ -437,7 +453,6 @@ libs-y := \
editors/ \
findutils/ \
init/ \
ipsvd/ \
libbb/ \
libpwdgrp/ \
loginutils/ \
@@ -446,12 +461,14 @@ libs-y := \
networking/ \
networking/libiproute/ \
networking/udhcp/ \
printutils/ \
procps/ \
runit/ \
selinux/ \
shell/ \
sysklogd/ \
util-linux/ \
util-linux/volume_id/ \
endif # KBUILD_EXTMOD
@@ -496,12 +513,6 @@ all: busybox
#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# disable pointer signedness warnings in gcc 4.0
CFLAGS += $(call cc-option,-Wno-pointer-sign,)
# Default kernel image to build when no specific target is given.
# KBUILD_IMAGE may be overruled on the commandline or
# set in the environment
@@ -568,11 +579,14 @@ busybox-all := $(core-y) $(libs-y)
# Rule to link busybox - also used during CONFIG_KALLSYMS
# May be overridden by arch/$(ARCH)/Makefile
quiet_cmd_busybox__ ?= LINK $@
cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \
-o $@ -Wl,-Map -Wl,$@.map \
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
-Wl,--start-group $(busybox-all) -Wl,--end-group \
$(LDLIBS)
cmd_busybox__ ?= $(srctree)/scripts/trylink \
"$@" \
"$(CC)" \
"$(CFLAGS) $(CFLAGS_busybox)" \
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
"$(core-y)" \
"$(libs-y)" \
"$(LDLIBS)"
# Generate System.map
quiet_cmd_sysmap = SYSMAP
@@ -684,6 +698,8 @@ ifeq ($(SKIP_STRIP),y)
else
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
busybox_unstripped -o $@
# strip is confused by PIE executable and does not set exec bits
$(Q)chmod a+x $@
endif
# The actual objects are generated when descending,
@@ -727,7 +743,7 @@ localver = $(subst $(space),, \
# Currently, only git is supported.
# Other SCMs can edit scripts/setlocalversion and add the appropriate
# checks as needed.
ifdef CONFIG_LOCALVERSION_AUTO
ifdef _BB_DISABLED_CONFIG_LOCALVERSION_AUTO
_localver-auto = $(shell $(CONFIG_SHELL) \
$(srctree)/scripts/setlocalversion $(srctree))
localver-auto = $(LOCALVERSION)$(_localver-auto)
@@ -840,7 +856,7 @@ depend dep:
# ---------------------------------------------------------------------------
# Modules
ifdef CONFIG_MODULES
ifdef _BB_DISABLED_CONFIG_MODULES
# By default, build modules as well
@@ -916,8 +932,9 @@ endif # CONFIG_MODULES
# make distclean Remove editor backup files, patch leftover files and the like
# Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += busybox* System.map .kernelrelease \
CLEAN_DIRS += $(MODVERDIR) _install 0_lib
CLEAN_FILES += busybox busybox_unstripped* busybox.links \
System.map .kernelrelease \
.tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
# Directories & files removed with 'make mrproper'
@@ -926,7 +943,10 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \
include/autoconf.h \
include/bbconfigopts.h \
include/usage_compressed.h \
.kernelrelease Module.symvers tags TAGS cscope*
include/applet_tables.h \
applets/usage \
.kernelrelease Module.symvers tags TAGS cscope* \
busybox_old
# clean - Delete most, but leave enough to build external modules
#
@@ -942,7 +962,7 @@ clean: archclean $(clean-dirs)
$(call cmd,rmdirs)
$(call cmd,rmfiles)
@find . $(RCS_FIND_IGNORE) \
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
-type f -print | xargs rm -f
@@ -966,9 +986,9 @@ PHONY += distclean
distclean: mrproper
@find $(srctree) $(RCS_FIND_IGNORE) \
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
-o -name '.*.rej' -o -size 0 \
-o -name '.*.rej' -o -name '*.tmp' -o -size 0 \
-o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
-type f -print | xargs rm -f
@@ -1072,7 +1092,7 @@ clean: rm-dirs := $(MODVERDIR)
clean: $(clean-dirs)
$(call cmd,rmdirs)
@find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
-type f -print | xargs rm -f
+21 -5
View File
@@ -12,6 +12,17 @@ endif
ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
INSTALL_OPTS:= --hardlinks
endif
ifeq ($(CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS),y)
ifeq ($(CONFIG_INSTALL_SH_APPLET_SYMLINK),y)
INSTALL_OPTS:= --sw-sh-sym
endif
ifeq ($(CONFIG_INSTALL_SH_APPLET_HARDLINK),y)
INSTALL_OPTS:= --sw-sh-hard
endif
ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
INSTALL_OPTS:= --scriptwrapper
endif
endif
install: $(srctree)/applets/install.sh busybox busybox.links
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
@@ -35,15 +46,20 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n)
done
endif
# Not very elegant: copies testsuite to objdir...
# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
.PHONY: check
.PHONY: test
check test: busybox busybox.links
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
bindir=$(objtree) srcdir=$(srctree)/testsuite \
$(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
.PHONY: release
release: distclean
cd ..; \
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
-name .svn \
-print \
@@ -79,11 +95,11 @@ objsizes: busybox_unstripped
.PHONY: stksizes
stksizes: busybox_unstripped
$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH)
$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq
.PHONY: bigdata
bigdata: busybox_unstripped
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
# Documentation Targets
.PHONY: doc
+59 -36
View File
@@ -3,6 +3,7 @@
# ==========================================================================
BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
export BB_VER
SKIP_STRIP = n
# -std=gnu99 needed for [U]LLONG_MAX on some systems
@@ -10,37 +11,31 @@ CPPFLAGS += $(call cc-option,-std=gnu99,)
CPPFLAGS += \
-Iinclude -Ilibbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include -I$(srctree)/libbb) \
-include include/autoconf.h \
-D_GNU_SOURCE -DNDEBUG \
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
# flag checks are grouped together to speed the checks up a bit..
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action().
# Looks more like gcc bug: gcc will warn on it with or without prototype.
# But still, warning-free compile is a must, or else we will drown
# in warnings pretty soon.
CFLAGS += $(call cc-option,-Wall,)
CFLAGS += $(call cc-option,-Wshadow,)
CFLAGS += $(call cc-option,-Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef,)
CFLAGS += $(call cc-option,-Wstrict-prototypes,)
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# If you want to add more -Wsomething above, make sure that it is
# still possible to build bbox without warnings.
ifeq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Werror,)
else
# for development, warn a little bit about unused results..
CPPFLAGS += -D_FORTIFY_SOURCE=2
endif
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
ifneq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
endif
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
# -fno-guess-branch-probability: prohibit pseudo-random guessing
# of branch probabilities (hopefully makes bloatcheck more stable):
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
@@ -49,45 +44,73 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
# FIXME: These warnings are at least partially to be concerned about and should
# be fixed..
#CFLAGS+=$(call cc-option,-Wconversion,)
#CFLAGS += $(call cc-option,-Wconversion,)
ifeq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-g)
ifneq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-Os,)
else
CFLAGS += $(call cc-option,-g,)
#CFLAGS += "-D_FORTIFY_SOURCE=2"
ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
CFLAGS += $(call cc-option,-O0,)
else
CFLAGS += $(call cc-option,-Os,)
endif
endif
# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
ARCH_FPIC ?= -fpic
ARCH_FPIE ?= -fpie
ARCH_PIE ?= -pie
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
# on i386: 14% smaller libbusybox.so
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
CFLAGS += $(ARCH_FPIC)
# and another 4% reduction of libbusybox.so:
# (external entry points must be marked EXTERNALLY_VISIBLE)
CFLAGS += $(call cc-option,-fvisibility=hidden)
endif
ifeq ($(CONFIG_STATIC),y)
LDFLAGS += -static
CFLAGS_busybox += -static
endif
BBOX_LIB_LIST = m crypt
ifeq ($(CONFIG_PIE),y)
CFLAGS_busybox += $(ARCH_PIE)
CFLAGS += $(ARCH_FPIE)
endif
LDLIBS += m crypt
ifeq ($(CONFIG_PAM),y)
BBOX_LIB_LIST += pam pam_misc
LDLIBS += pam pam_misc
endif
ifeq ($(CONFIG_SELINUX),y)
BBOX_LIB_LIST += selinux sepol
LDLIBS += selinux sepol
endif
ifeq ($(CONFIG_EFENCE),y)
BBOX_LIB_LIST += efence
LDLIBS += efence
endif
ifeq ($(CONFIG_DMALLOC),y)
BBOX_LIB_LIST += dmalloc
LDLIBS += dmalloc
endif
# For scripts/trylink
export BBOX_LIB_LIST
#LDFLAGS += -nostdlib
LDFLAGS_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
# env var should be set for make invocation.
# Here we check whether CFLAGS_busybox indeed contains that flag.
# (For historical reasons, we also check LDFLAGS, which doesn't
# seem to be entirely correct variable to put "-Wl,-elf2flt" into).
W_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
SKIP_STRIP = y
endif
# Busybox is a stack-fatty so make sure we increase default size
# TODO: use "make stksizes" to find & fix big stack users
# (we stole scripts/checkstack.pl from the kernel... thanks guys!)
FLTFLAGS += -s 20000
# Reduced from 20k to 16k in 1.9.0.
FLTFLAGS += -s 16000
+2 -3
View File
@@ -16,7 +16,6 @@ help:
@echo 'Configuration:'
@echo ' allnoconfig - disable all symbols in .config'
@echo ' allyesconfig - enable all symbols in .config (see defconfig)'
@echo ' allbareconfig - enable all applets without any sub-features'
@echo ' config - text based configurator (of last resort)'
@echo ' defconfig - set .config to largest generic configuration'
@echo ' menuconfig - interactive curses-based configurator'
@@ -24,10 +23,10 @@ help:
@echo ' hosttools - build sed for the host.'
@echo ' You can use these commands if the commands on the host'
@echo ' is unusable. Afterwards use it like:'
@echo ' make SED="$(objtree)/sed"'
@echo ' make SED="$(objtree)/sed"'
@echo
@echo 'Installation:'
@echo ' install - install busybox into $(CONFIG_PREFIX)'
@echo ' install - install busybox into CONFIG_PREFIX'
@echo ' uninstall'
@echo
@echo 'Development:'
+7 -6
View File
@@ -82,6 +82,9 @@ Downloading the current source code:
is generally a faster way of getting it fixed, and the complete archive of
what happened is the subversion changelog.
Note: if you want to compile busybox in a busybox environment you must
select ENABLE_DESKTOP.
----------------
getting help:
@@ -119,7 +122,7 @@ bugs:
illegal instruction
i am using debian unstable, kernel version 2.4.25-vrs2 on a netwinder,
and the latest uclibc from cvs. thanks for the wonderful program!
and the latest uclibc from cvs.
-diligent
@@ -170,10 +173,8 @@ Portability:
you're into that sort of thing, start small (selecting just a few applets)
and work your way up.
Shaun Jackman has recently (2005) ported busybox to a combination of newlib
and libgloss, and some of his patches have been integrated. This platform
may join glibc/uclibc and Linux as a supported combination with the 1.1
release, but is not supported in 1.0.
In 2005 Shaun Jackman has ported busybox to a combination of newlib
and libgloss, and some of his patches have been integrated.
Supported hardware:
@@ -194,5 +195,5 @@ Supported hardware:
Please feed suggestions, bug reports, insults, and bribes back to the busybox
maintainer:
Denis Vlasenko
Denys Vlasenko
<vda.linux@googlemail.com>
+11 -33
View File
@@ -6,37 +6,24 @@ do one of these bounce an email off the person it's listed under to see if they
have any suggestions how they plan to go about it, and to minimize conflicts
between your work and theirs. But otherwise, all of these are fair game.
Rob Landley <rob@landley.net>:
Add BB_NOMMU to platform.h and migrate __uClinux__ tests to that.
#if defined __UCLIBC__ && !defined __ARCH_USE_MMU__
Rob Landley suggested these:
Add a libbb/platform.c
Implement fdprintf() for platforms that haven't got one.
Implement bb_realpath() that can handle NULL on non-glibc.
Cleanup bb_asprintf()
Migrate calloc() and bb_calloc() occurrences to bb_xzalloc().
Remove obsolete _() wrapper crud for internationalization we don't do.
Figure out where we need utf8 support, and add it.
sh
The command shell situation is a big mess. We have three or four different
The command shell situation is a big mess. We have three different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. I'm writing a new shell (bbsh) to unify the various
shells and configurably add the minimal set of bash features people
actually use. The hardest part is it has to configure down as small as
lash while providing lash's features. The rest is easy in comparison.
bzip2
Compression-side support.
being reentrant.
lash is phased out. hush can be configured down to be nearly as small,
but less buggy :)
init
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
depmod
busybox lacks a way to update module deps when running from firmware without the
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
modutils. The orig depmod is rather pointless to have to add to a firmware image
in when we already have a insmod/rmmod and friends.
Unify base64 handling.
[done]
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
@@ -128,9 +115,6 @@ Bernhard Fischer <busybox@busybox.net> suggests to look at these:
As yet unclaimed:
----
find
doesn't understand (), lots of susv3 stuff.
----
diff
Make sure we handle empty files properly:
@@ -148,10 +132,6 @@ patch
And while we're at it, a new patch filename quoting format is apparently
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
---
ps / top
Add support for both RSS and VSIZE rather than just one or the other.
Or make it a build option.
---
man
It would be nice to have a man command. Not one that handles troff or
anything, just one that can handle preformatted ascii man pages, possibly
@@ -161,7 +141,7 @@ man
(How doclifter might work into this is anybody's guess.)
---
ar
Write support?
Write support!
---
stty / catv
stty's visible() function and catv's guts are identical. Merge them into
@@ -297,24 +277,22 @@ Minor stuff:
---
use bb_perror_msg where appropriate: See
egrep "[^_]perror"
---
Remove superfluous fmt occurances: e.g.
fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
---
possible code duplication ingroup() and is_a_group_member()
---
Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c
---
See grep -r strtod
Alot of duplication that wants cleanup.
---
in_ether duplicated in network/{interface,ifconfig}.c
---
Code cleanup:
Replace deprecated functions.
bzero() -> memset()
---
sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
---
vdprintf() -> similar sized functionality
---
+282 -139
View File
@@ -1,11 +1,7 @@
# This .config compiles for NOMMU.
# TODO:
# Pick disabled applet, enable & try to make it compile & work on NOMMU
#
# Automatically generated make config: don't edit
# Busybox version: 1.6.0.svn
# Wed Apr 11 01:29:04 2007
# Busybox version: 1.12.0.svn
# Wed Aug 20 00:24:07 2008
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -16,9 +12,10 @@ CONFIG_HAVE_DOT_CONFIG=y
#
# General Configuration
#
# CONFIG_NITPICK is not set
# CONFIG_DESKTOP is not set
# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
CONFIG_DESKTOP=y
# CONFIG_EXTRA_COMPAT is not set
CONFIG_FEATURE_ASSUME_UNICODE=y
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
CONFIG_SHOW_USAGE=y
@@ -31,33 +28,37 @@ CONFIG_FEATURE_DEVPTS=y
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_PIDFILE=y
CONFIG_FEATURE_SUID=y
CONFIG_FEATURE_SYSLOG=y
# CONFIG_FEATURE_SUID_CONFIG is not set
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
# CONFIG_FEATURE_HAVE_RPC is not set
# CONFIG_SELINUX is not set
CONFIG_FEATURE_SUID_CONFIG=y
CONFIG_FEATURE_SUID_CONFIG_QUIET=y
CONFIG_SELINUX=y
CONFIG_FEATURE_PREFER_APPLETS=y
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
CONFIG_FEATURE_SYSLOG=y
CONFIG_FEATURE_HAVE_RPC=y
#
# Build Options
#
# CONFIG_STATIC is not set
# CONFIG_PIE is not set
CONFIG_NOMMU=y
# CONFIG_BUILD_LIBBUSYBOX is not set
# CONFIG_FEATURE_FULL_LIBBUSYBOX is not set
# CONFIG_FEATURE_INDIVIDUAL is not set
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
CONFIG_LFS=y
# CONFIG_BUILD_AT_ONCE is not set
CONFIG_CROSS_COMPILER_PREFIX=""
#
# Debugging Options
#
# CONFIG_DEBUG is not set
CONFIG_WERROR=y
# CONFIG_DEBUG_PESSIMIZE is not set
# CONFIG_WERROR is not set
CONFIG_NO_DEBUG_LIB=y
# CONFIG_DMALLOC is not set
# CONFIG_EFENCE is not set
CONFIG_INCLUDE_SUSv2=y
# CONFIG_PARSE is not set
#
# Installation Options
@@ -65,7 +66,11 @@ CONFIG_INCLUDE_SUSv2=y
# CONFIG_INSTALL_NO_USR is not set
CONFIG_INSTALL_APPLET_SYMLINKS=y
# CONFIG_INSTALL_APPLET_HARDLINKS is not set
# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
# CONFIG_INSTALL_APPLET_DONT is not set
# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set
# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set
# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set
CONFIG_PREFIX="./_install"
#
@@ -73,14 +78,21 @@ CONFIG_PREFIX="./_install"
#
CONFIG_PASSWORD_MINLEN=6
CONFIG_MD5_SIZE_VS_SPEED=2
CONFIG_FEATURE_FAST_TOP=y
CONFIG_FEATURE_ETC_NETWORKS=y
CONFIG_FEATURE_EDITING=y
# CONFIG_FEATURE_EDITING_FANCY_KEYS is not set
# CONFIG_FEATURE_EDITING_VI is not set
CONFIG_FEATURE_EDITING_MAX_LEN=1024
CONFIG_FEATURE_EDITING_VI=y
CONFIG_FEATURE_EDITING_HISTORY=15
# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
# CONFIG_FEATURE_TAB_COMPLETION is not set
# CONFIG_FEATURE_USERNAME_COMPLETION is not set
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
CONFIG_FEATURE_TAB_COMPLETION=y
CONFIG_FEATURE_USERNAME_COMPLETION=y
CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
CONFIG_FEATURE_COPYBUF_KB=4
CONFIG_MONOTONIC_SYSCALL=y
CONFIG_IOCTL_HEX2STR_ERROR=y
CONFIG_FEATURE_HWIB=y
#
# Applets
@@ -89,41 +101,37 @@ CONFIG_FEATURE_EDITING_HISTORY=15
#
# Archival Utilities
#
CONFIG_FEATURE_SEAMLESS_LZMA=y
CONFIG_FEATURE_SEAMLESS_BZ2=y
CONFIG_FEATURE_SEAMLESS_GZ=y
CONFIG_FEATURE_SEAMLESS_Z=y
CONFIG_AR=y
CONFIG_FEATURE_AR_LONG_FILENAMES=y
CONFIG_BUNZIP2=y
CONFIG_BZIP2=y
CONFIG_CPIO=y
# CONFIG_DPKG is not set
# CONFIG_DPKG_DEB is not set
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
CONFIG_FEATURE_CPIO_O=y
CONFIG_DPKG=y
CONFIG_DPKG_DEB=y
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
CONFIG_GUNZIP=y
CONFIG_FEATURE_GUNZIP_UNCOMPRESS=y
CONFIG_GZIP=y
CONFIG_RPM2CPIO=y
# CONFIG_RPM is not set
CONFIG_RPM=y
CONFIG_TAR=y
CONFIG_FEATURE_TAR_CREATE=y
# CONFIG_FEATURE_TAR_BZIP2 is not set
# CONFIG_FEATURE_TAR_LZMA is not set
CONFIG_FEATURE_TAR_AUTODETECT=y
CONFIG_FEATURE_TAR_FROM=y
# CONFIG_FEATURE_TAR_GZIP is not set
# CONFIG_FEATURE_TAR_COMPRESS is not set
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
CONFIG_FEATURE_TAR_UNAME_GNAME=y
CONFIG_UNCOMPRESS=y
CONFIG_UNLZMA=y
CONFIG_FEATURE_LZMA_FAST=y
CONFIG_UNZIP=y
#
# Common options for cpio and tar
#
CONFIG_FEATURE_UNARCHIVE_TAPE=y
# CONFIG_FEATURE_DEB_TAR_GZ is not set
# CONFIG_FEATURE_DEB_TAR_BZ2 is not set
# CONFIG_FEATURE_DEB_TAR_LZMA is not set
#
# Coreutils
#
@@ -136,7 +144,6 @@ CONFIG_CHMOD=y
CONFIG_CHOWN=y
CONFIG_CHROOT=y
CONFIG_CKSUM=y
CONFIG_CMP=y
CONFIG_COMM=y
CONFIG_CP=y
CONFIG_CUT=y
@@ -146,10 +153,7 @@ CONFIG_DD=y
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
CONFIG_FEATURE_DD_IBS_OBS=y
CONFIG_DF=y
CONFIG_DIFF=y
CONFIG_FEATURE_DIFF_BINARY=y
CONFIG_FEATURE_DIFF_DIR=y
CONFIG_FEATURE_DIFF_MINIMAL=y
CONFIG_FEATURE_DF_INODE=y
CONFIG_DIRNAME=y
CONFIG_DOS2UNIX=y
CONFIG_UNIX2DOS=y
@@ -159,6 +163,8 @@ CONFIG_ECHO=y
CONFIG_FEATURE_FANCY_ECHO=y
CONFIG_ENV=y
CONFIG_FEATURE_ENV_LONG_OPTIONS=y
CONFIG_EXPAND=y
CONFIG_FEATURE_EXPAND_LONG_OPTIONS=y
CONFIG_EXPR=y
CONFIG_EXPR_MATH_SUPPORT_64=y
CONFIG_FALSE=y
@@ -194,13 +200,17 @@ CONFIG_OD=y
CONFIG_PRINTENV=y
CONFIG_PRINTF=y
CONFIG_PWD=y
CONFIG_READLINK=y
CONFIG_FEATURE_READLINK_FOLLOW=y
CONFIG_REALPATH=y
CONFIG_RM=y
CONFIG_RMDIR=y
CONFIG_FEATURE_RMDIR_LONG_OPTIONS=y
CONFIG_SEQ=y
CONFIG_SHA1SUM=y
CONFIG_SLEEP=y
CONFIG_FEATURE_FANCY_SLEEP=y
CONFIG_FEATURE_FLOAT_SLEEP=y
CONFIG_SORT=y
CONFIG_FEATURE_SORT_BIG=y
CONFIG_SPLIT=y
@@ -210,6 +220,7 @@ CONFIG_FEATURE_STAT_FORMAT=y
CONFIG_STTY=y
CONFIG_SUM=y
CONFIG_SYNC=y
CONFIG_TAC=y
CONFIG_TAIL=y
CONFIG_FEATURE_FANCY_TAIL=y
CONFIG_TEE=y
@@ -223,11 +234,12 @@ CONFIG_FEATURE_TR_EQUIV=y
CONFIG_TRUE=y
CONFIG_TTY=y
CONFIG_UNAME=y
CONFIG_UNEXPAND=y
CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS=y
CONFIG_UNIQ=y
CONFIG_USLEEP=y
CONFIG_UUDECODE=y
CONFIG_UUENCODE=y
CONFIG_WATCH=y
CONFIG_WC=y
CONFIG_FEATURE_WC_LARGE=y
CONFIG_WHO=y
@@ -261,6 +273,7 @@ CONFIG_CHVT=y
CONFIG_CLEAR=y
CONFIG_DEALLOCVT=y
CONFIG_DUMPKMAP=y
CONFIG_KBD_MODE=y
CONFIG_LOADFONT=y
CONFIG_LOADKMAP=y
CONFIG_OPENVT=y
@@ -269,22 +282,22 @@ CONFIG_RESIZE=y
CONFIG_FEATURE_RESIZE_PRINT=y
CONFIG_SETCONSOLE=y
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
CONFIG_SETFONT=y
CONFIG_SETKEYCODES=y
CONFIG_SETLOGCONS=y
CONFIG_SHOWKEY=y
#
# Debian Utilities
#
CONFIG_MKTEMP=y
CONFIG_PIPE_PROGRESS=y
CONFIG_READLINK=y
CONFIG_FEATURE_READLINK_FOLLOW=y
CONFIG_RUN_PARTS=y
CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
CONFIG_FEATURE_RUN_PARTS_FANCY=y
# CONFIG_START_STOP_DAEMON is not set
# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
CONFIG_START_STOP_DAEMON=y
CONFIG_FEATURE_START_STOP_DAEMON_FANCY=y
CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y
CONFIG_WHICH=y
#
@@ -292,10 +305,17 @@ CONFIG_WHICH=y
#
CONFIG_AWK=y
CONFIG_FEATURE_AWK_MATH=y
CONFIG_CMP=y
CONFIG_DIFF=y
CONFIG_FEATURE_DIFF_BINARY=y
CONFIG_FEATURE_DIFF_DIR=y
CONFIG_FEATURE_DIFF_MINIMAL=y
CONFIG_ED=y
CONFIG_PATCH=y
CONFIG_SED=y
CONFIG_VI=y
CONFIG_FEATURE_VI_MAX_LEN=4096
CONFIG_FEATURE_VI_8BIT=y
CONFIG_FEATURE_VI_COLON=y
CONFIG_FEATURE_VI_YANKMARK=y
CONFIG_FEATURE_VI_SEARCH=y
@@ -318,6 +338,7 @@ CONFIG_FEATURE_FIND_MMIN=y
CONFIG_FEATURE_FIND_PERM=y
CONFIG_FEATURE_FIND_TYPE=y
CONFIG_FEATURE_FIND_XDEV=y
CONFIG_FEATURE_FIND_MAXDEPTH=y
CONFIG_FEATURE_FIND_NEWER=y
CONFIG_FEATURE_FIND_INUM=y
CONFIG_FEATURE_FIND_EXEC=y
@@ -328,6 +349,10 @@ CONFIG_FEATURE_FIND_DEPTH=y
CONFIG_FEATURE_FIND_PAREN=y
CONFIG_FEATURE_FIND_SIZE=y
CONFIG_FEATURE_FIND_PRUNE=y
CONFIG_FEATURE_FIND_DELETE=y
CONFIG_FEATURE_FIND_PATH=y
CONFIG_FEATURE_FIND_REGEX=y
CONFIG_FEATURE_FIND_CONTEXT=y
CONFIG_GREP=y
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
@@ -341,14 +366,16 @@ CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
#
# Init Utilities
#
# CONFIG_INIT is not set
CONFIG_INIT=y
# CONFIG_DEBUG_INIT is not set
# CONFIG_FEATURE_USE_INITTAB is not set
# CONFIG_FEATURE_INIT_SCTTY is not set
# CONFIG_FEATURE_INIT_SYSLOG is not set
# CONFIG_FEATURE_EXTRA_QUIET is not set
# CONFIG_FEATURE_INIT_COREDUMPS is not set
# CONFIG_FEATURE_INITRD is not set
CONFIG_FEATURE_USE_INITTAB=y
CONFIG_FEATURE_KILL_REMOVED=y
CONFIG_FEATURE_KILL_DELAY=1
CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=y
CONFIG_FEATURE_EXTRA_QUIET=y
CONFIG_FEATURE_INIT_COREDUMPS=y
CONFIG_FEATURE_INITRD=y
CONFIG_HALT=y
CONFIG_MESG=y
@@ -356,21 +383,29 @@ CONFIG_MESG=y
# Login/Password Management Utilities
#
CONFIG_FEATURE_SHADOWPASSWDS=y
CONFIG_USE_BB_SHADOW=y
CONFIG_USE_BB_PWD_GRP=y
CONFIG_USE_BB_SHADOW=y
CONFIG_USE_BB_CRYPT=y
CONFIG_ADDGROUP=y
CONFIG_FEATURE_ADDUSER_TO_GROUP=y
CONFIG_DELGROUP=y
CONFIG_FEATURE_DEL_USER_FROM_GROUP=y
CONFIG_FEATURE_CHECK_NAMES=y
CONFIG_ADDUSER=y
CONFIG_FEATURE_ADDUSER_LONG_OPTIONS=y
CONFIG_DELUSER=y
CONFIG_GETTY=y
CONFIG_FEATURE_UTMP=y
CONFIG_FEATURE_WTMP=y
CONFIG_LOGIN=y
# CONFIG_PAM is not set
CONFIG_LOGIN_SCRIPTS=y
CONFIG_FEATURE_NOLOGIN=y
CONFIG_FEATURE_SECURETTY=y
CONFIG_PASSWD=y
CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
CONFIG_CRYPTPW=y
CONFIG_CHPASSWD=y
CONFIG_SU=y
CONFIG_FEATURE_SU_SYSLOG=y
CONFIG_FEATURE_SU_CHECKS_SHELLS=y
@@ -387,25 +422,30 @@ CONFIG_LSATTR=y
#
# Linux Module Utilities
#
CONFIG_INSMOD=y
CONFIG_FEATURE_INSMOD_VERSION_CHECKING=y
CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS=y
CONFIG_FEATURE_INSMOD_LOADINKMEM=y
CONFIG_FEATURE_INSMOD_LOAD_MAP=y
CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL=y
CONFIG_RMMOD=y
CONFIG_LSMOD=y
CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
CONFIG_MODPROBE=y
CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS=y
CONFIG_FEATURE_MODPROBE_FANCY_ALIAS=y
#
# Options common to multiple modutils
#
CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
CONFIG_FEATURE_2_4_MODULES=y
CONFIG_FEATURE_2_6_MODULES=y
CONFIG_MODPROBE_SMALL=y
CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
# CONFIG_DEPMOD is not set
# CONFIG_FEATURE_DEPMOD_PRUNE_FANCY is not set
# CONFIG_FEATURE_DEPMOD_ALIAS is not set
# CONFIG_INSMOD is not set
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
# CONFIG_RMMOD is not set
# CONFIG_LSMOD is not set
# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
# CONFIG_MODPROBE is not set
# CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS is not set
# CONFIG_FEATURE_MODPROBE_FANCY_ALIAS is not set
# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
# CONFIG_FEATURE_2_4_MODULES is not set
# CONFIG_FEATURE_2_6_MODULES is not set
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
#
@@ -426,6 +466,7 @@ CONFIG_FEATURE_SGI_LABEL=y
CONFIG_FEATURE_SUN_LABEL=y
CONFIG_FEATURE_OSF_LABEL=y
CONFIG_FEATURE_FDISK_ADVANCED=y
CONFIG_FINDFS=y
CONFIG_FREERAMDISK=y
CONFIG_FSCK_MINIX=y
CONFIG_MKFS_MINIX=y
@@ -436,6 +477,8 @@ CONFIG_MKFS_MINIX=y
CONFIG_FEATURE_MINIX2=y
CONFIG_GETOPT=y
CONFIG_HEXDUMP=y
CONFIG_FEATURE_HEXDUMP_REVERSE=y
CONFIG_HD=y
CONFIG_HWCLOCK=y
CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
@@ -444,21 +487,49 @@ CONFIG_IPCS=y
CONFIG_LOSETUP=y
CONFIG_MDEV=y
CONFIG_FEATURE_MDEV_CONF=y
CONFIG_FEATURE_MDEV_RENAME=y
CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
CONFIG_FEATURE_MDEV_EXEC=y
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
CONFIG_MKSWAP=y
CONFIG_FEATURE_MKSWAP_V0=y
CONFIG_MORE=y
CONFIG_FEATURE_USE_TERMIOS=y
CONFIG_VOLUMEID=y
CONFIG_FEATURE_VOLUMEID_EXT=y
CONFIG_FEATURE_VOLUMEID_REISERFS=y
CONFIG_FEATURE_VOLUMEID_FAT=y
CONFIG_FEATURE_VOLUMEID_HFS=y
CONFIG_FEATURE_VOLUMEID_JFS=y
CONFIG_FEATURE_VOLUMEID_XFS=y
CONFIG_FEATURE_VOLUMEID_NTFS=y
CONFIG_FEATURE_VOLUMEID_ISO9660=y
CONFIG_FEATURE_VOLUMEID_UDF=y
CONFIG_FEATURE_VOLUMEID_LUKS=y
CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
CONFIG_FEATURE_VOLUMEID_CRAMFS=y
CONFIG_FEATURE_VOLUMEID_ROMFS=y
CONFIG_FEATURE_VOLUMEID_SYSV=y
CONFIG_FEATURE_VOLUMEID_OCFS2=y
CONFIG_FEATURE_VOLUMEID_LINUXRAID=y
CONFIG_MOUNT=y
# CONFIG_FEATURE_MOUNT_NFS is not set
CONFIG_FEATURE_MOUNT_FAKE=y
CONFIG_FEATURE_MOUNT_VERBOSE=y
CONFIG_FEATURE_MOUNT_HELPERS=y
CONFIG_FEATURE_MOUNT_LABEL=y
CONFIG_FEATURE_MOUNT_NFS=y
CONFIG_FEATURE_MOUNT_CIFS=y
CONFIG_FEATURE_MOUNT_FLAGS=y
CONFIG_FEATURE_MOUNT_FSTAB=y
CONFIG_PIVOT_ROOT=y
CONFIG_RDATE=y
CONFIG_RDEV=y
CONFIG_READPROFILE=y
CONFIG_RTCWAKE=y
CONFIG_SCRIPT=y
CONFIG_SETARCH=y
CONFIG_SWAPONOFF=y
CONFIG_FEATURE_SWAPON_PRI=y
CONFIG_SWITCH_ROOT=y
CONFIG_UMOUNT=y
CONFIG_FEATURE_UMOUNT_ALL=y
@@ -473,12 +544,20 @@ CONFIG_FEATURE_MOUNT_LOOP=y
# Miscellaneous Utilities
#
CONFIG_ADJTIMEX=y
# CONFIG_BBCONFIG is not set
CONFIG_BBCONFIG=y
CONFIG_CHAT=y
CONFIG_FEATURE_CHAT_NOFAIL=y
CONFIG_FEATURE_CHAT_TTY_HIFI=y
CONFIG_FEATURE_CHAT_IMPLICIT_CR=y
CONFIG_FEATURE_CHAT_SWALLOW_OPTS=y
CONFIG_FEATURE_CHAT_SEND_ESCAPES=y
CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
CONFIG_FEATURE_CHAT_CLR_ABORT=y
CONFIG_CHRT=y
# CONFIG_CROND is not set
# CONFIG_DEBUG_CROND_OPTION is not set
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
# CONFIG_CRONTAB is not set
CONFIG_CROND=y
CONFIG_DEBUG_CROND_OPTION=y
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
CONFIG_CRONTAB=y
CONFIG_DC=y
# CONFIG_DEVFSD is not set
# CONFIG_DEVFSD_MODLOAD is not set
@@ -486,7 +565,12 @@ CONFIG_DC=y
# CONFIG_DEVFSD_VERBOSE is not set
# CONFIG_FEATURE_DEVFS is not set
CONFIG_EJECT=y
CONFIG_FEATURE_EJECT_SCSI=y
CONFIG_FBSPLASH=y
CONFIG_INOTIFYD=y
CONFIG_LAST=y
CONFIG_FEATURE_LAST_SMALL=y
# CONFIG_FEATURE_LAST_FANCY is not set
CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
CONFIG_FEATURE_LESS_BRACKETS=y
@@ -504,27 +588,33 @@ CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
CONFIG_MAKEDEVS=y
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
CONFIG_FEATURE_MAKEDEVS_TABLE=y
CONFIG_MAN=y
CONFIG_MICROCOM=y
CONFIG_MOUNTPOINT=y
CONFIG_MT=y
CONFIG_NMETER=y
CONFIG_RAIDAUTORUN=y
CONFIG_READAHEAD=y
CONFIG_RUNLEVEL=y
CONFIG_RX=y
CONFIG_STRINGS=y
CONFIG_SETSID=y
# CONFIG_TASKSET is not set
# CONFIG_FEATURE_TASKSET_FANCY is not set
CONFIG_STRINGS=y
CONFIG_TASKSET=y
CONFIG_FEATURE_TASKSET_FANCY=y
CONFIG_TIME=y
CONFIG_TTYSIZE=y
CONFIG_WATCHDOG=y
#
# Networking Utilities
#
CONFIG_FEATURE_IPV6=y
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
CONFIG_VERBOSE_RESOLUTION_ERRORS=y
CONFIG_ARP=y
CONFIG_ARPING=y
CONFIG_BRCTL=y
CONFIG_FEATURE_BRCTL_FANCY=y
CONFIG_FEATURE_BRCTL_SHOW=y
CONFIG_DNSD=y
CONFIG_ETHER_WAKE=y
CONFIG_FAKEIDENTD=y
@@ -532,37 +622,43 @@ CONFIG_FTPGET=y
CONFIG_FTPPUT=y
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
CONFIG_HOSTNAME=y
# CONFIG_HTTPD is not set
# CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP is not set
# CONFIG_FEATURE_HTTPD_SETUID is not set
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES is not set
# CONFIG_FEATURE_HTTPD_CGI is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
CONFIG_HTTPD=y
CONFIG_FEATURE_HTTPD_RANGES=y
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP=y
CONFIG_FEATURE_HTTPD_SETUID=y
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES=y
CONFIG_FEATURE_HTTPD_CGI=y
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y
CONFIG_FEATURE_HTTPD_ERROR_PAGES=y
CONFIG_FEATURE_HTTPD_PROXY=y
CONFIG_IFCONFIG=y
CONFIG_FEATURE_IFCONFIG_STATUS=y
CONFIG_FEATURE_IFCONFIG_SLIP=y
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
CONFIG_FEATURE_IFCONFIG_HW=y
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
# CONFIG_IFUPDOWN is not set
# CONFIG_FEATURE_IFUPDOWN_IP is not set
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
CONFIG_IFENSLAVE=y
CONFIG_IFUPDOWN=y
CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
CONFIG_FEATURE_IFUPDOWN_IP=y
CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN=y
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
# CONFIG_FEATURE_IFUPDOWN_IPX is not set
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
# CONFIG_INETD is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
# CONFIG_FEATURE_INETD_RPC is not set
CONFIG_FEATURE_IFUPDOWN_IPV4=y
CONFIG_FEATURE_IFUPDOWN_IPV6=y
CONFIG_FEATURE_IFUPDOWN_MAPPING=y
CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP=y
CONFIG_INETD=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN=y
CONFIG_FEATURE_INETD_RPC=y
CONFIG_IP=y
CONFIG_FEATURE_IP_ADDRESS=y
CONFIG_FEATURE_IP_LINK=y
@@ -570,6 +666,7 @@ CONFIG_FEATURE_IP_ROUTE=y
CONFIG_FEATURE_IP_TUNNEL=y
CONFIG_FEATURE_IP_RULE=y
CONFIG_FEATURE_IP_SHORT_FORMS=y
CONFIG_FEATURE_IP_RARE_PROTOCOLS=y
CONFIG_IPADDR=y
CONFIG_IPLINK=y
CONFIG_IPROUTE=y
@@ -579,41 +676,57 @@ CONFIG_IPCALC=y
CONFIG_FEATURE_IPCALC_FANCY=y
CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y
CONFIG_NAMEIF=y
CONFIG_FEATURE_NAMEIF_EXTENDED=y
CONFIG_NC=y
CONFIG_NC_SERVER=y
CONFIG_NC_EXTRA=y
CONFIG_NETSTAT=y
CONFIG_FEATURE_NETSTAT_WIDE=y
CONFIG_FEATURE_NETSTAT_PRG=y
CONFIG_NSLOOKUP=y
CONFIG_PING=y
CONFIG_PING6=y
CONFIG_FEATURE_FANCY_PING=y
CONFIG_PSCAN=y
CONFIG_ROUTE=y
CONFIG_SENDMAIL=y
CONFIG_FETCHMAIL=y
CONFIG_SLATTACH=y
CONFIG_TELNET=y
CONFIG_FEATURE_TELNET_TTYPE=y
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
# CONFIG_TELNETD is not set
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
CONFIG_TELNETD=y
CONFIG_FEATURE_TELNETD_STANDALONE=y
CONFIG_TFTP=y
CONFIG_TFTPD=y
CONFIG_FEATURE_TFTP_GET=y
CONFIG_FEATURE_TFTP_PUT=y
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
# CONFIG_DEBUG_TFTP is not set
CONFIG_DEBUG_TFTP=y
CONFIG_TRACEROUTE=y
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE=y
CONFIG_FEATURE_TRACEROUTE_USE_ICMP=y
CONFIG_APP_UDHCPD=y
CONFIG_APP_DHCPRELAY=y
CONFIG_APP_DUMPLEASES=y
# CONFIG_APP_UDHCPC is not set
# CONFIG_FEATURE_UDHCP_DEBUG is not set
CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY=y
CONFIG_DHCPD_LEASES_FILE="/var/lib/misc/udhcpd.leases"
CONFIG_APP_UDHCPC=y
CONFIG_FEATURE_UDHCPC_ARPING=y
CONFIG_FEATURE_UDHCP_PORT=y
CONFIG_FEATURE_UDHCP_DEBUG=y
CONFIG_FEATURE_RFC3397=y
CONFIG_DHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
CONFIG_VCONFIG=y
CONFIG_WGET=y
CONFIG_FEATURE_WGET_STATUSBAR=y
CONFIG_FEATURE_WGET_AUTHENTICATION=y
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
CONFIG_ZCIP=y
CONFIG_TCPSVD=y
CONFIG_UDPSVD=y
#
# Process Utilities
@@ -623,26 +736,35 @@ CONFIG_FUSER=y
CONFIG_KILL=y
CONFIG_KILLALL=y
CONFIG_KILLALL5=y
CONFIG_NMETER=y
CONFIG_PGREP=y
CONFIG_PIDOF=y
CONFIG_FEATURE_PIDOF_SINGLE=y
CONFIG_FEATURE_PIDOF_OMIT=y
CONFIG_PKILL=y
CONFIG_PS=y
CONFIG_FEATURE_PS_WIDE=y
CONFIG_FEATURE_PS_TIME=y
CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS=y
CONFIG_RENICE=y
CONFIG_BB_SYSCTL=y
CONFIG_TOP=y
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
CONFIG_FEATURE_TOP_DECIMALS=y
CONFIG_FEATURE_TOPMEM=y
CONFIG_UPTIME=y
CONFIG_WATCH=y
#
# Shells
#
# CONFIG_FEATURE_SH_IS_ASH is not set
# CONFIG_FEATURE_SH_IS_HUSH is not set
# CONFIG_FEATURE_SH_IS_LASH is not set
# CONFIG_FEATURE_SH_IS_MSH is not set
CONFIG_FEATURE_SH_IS_NONE=y
# CONFIG_ASH is not set
# CONFIG_ASH_BASH_COMPAT is not set
# CONFIG_ASH_JOB_CONTROL is not set
# CONFIG_ASH_READ_NCHARS is not set
# CONFIG_ASH_READ_TIMEOUT is not set
@@ -651,14 +773,22 @@ CONFIG_FEATURE_SH_IS_NONE=y
# CONFIG_ASH_MATH_SUPPORT_64 is not set
# CONFIG_ASH_GETOPTS is not set
# CONFIG_ASH_BUILTIN_ECHO is not set
# CONFIG_ASH_BUILTIN_PRINTF is not set
# CONFIG_ASH_BUILTIN_TEST is not set
# CONFIG_ASH_CMDCMD is not set
# CONFIG_ASH_MAIL is not set
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
# CONFIG_ASH_RANDOM_SUPPORT is not set
# CONFIG_ASH_EXPAND_PRMT is not set
# CONFIG_HUSH is not set
# CONFIG_LASH is not set
CONFIG_HUSH=y
CONFIG_HUSH_HELP=y
CONFIG_HUSH_INTERACTIVE=y
CONFIG_HUSH_JOB=y
CONFIG_HUSH_TICK=y
CONFIG_HUSH_IF=y
CONFIG_HUSH_LOOPS=y
CONFIG_HUSH_CASE=y
CONFIG_LASH=y
CONFIG_MSH=y
#
@@ -666,6 +796,8 @@ CONFIG_MSH=y
#
CONFIG_FEATURE_SH_EXTRA_QUIET=y
CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_FEATURE_SH_NOFORK=y
CONFIG_CTTYHACK=y
#
# System Logging Utilities
@@ -673,6 +805,7 @@ CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_SYSLOGD=y
CONFIG_FEATURE_ROTATE_LOGFILE=y
CONFIG_FEATURE_REMOTE_LOG=y
CONFIG_FEATURE_SYSLOGD_DUP=y
CONFIG_FEATURE_IPC_SYSLOG=y
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
CONFIG_LOGREAD=y
@@ -683,28 +816,38 @@ CONFIG_LOGGER=y
#
# Runit Utilities
#
# CONFIG_RUNSV is not set
# CONFIG_RUNSVDIR is not set
CONFIG_RUNSV=y
CONFIG_RUNSVDIR=y
CONFIG_SV=y
# CONFIG_SVLOGD is not set
CONFIG_SVLOGD=y
CONFIG_CHPST=y
CONFIG_SETUIDGID=y
CONFIG_ENVUIDGID=y
CONFIG_ENVDIR=y
CONFIG_SOFTLIMIT=y
# CONFIG_CHCON is not set
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
# CONFIG_GETENFORCE is not set
# CONFIG_GETSEBOOL is not set
# CONFIG_LOAD_POLICY is not set
# CONFIG_MATCHPATHCON is not set
# CONFIG_RUNCON is not set
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
# CONFIG_SELINUXENABLED is not set
# CONFIG_SETENFORCE is not set
#
# ipsvd utilities
# Selinux Utilities
#
# CONFIG_TCPSVD is not set
# CONFIG_UDPSVD is not set
CONFIG_CHCON=y
CONFIG_FEATURE_CHCON_LONG_OPTIONS=y
CONFIG_GETENFORCE=y
CONFIG_GETSEBOOL=y
CONFIG_LOAD_POLICY=y
CONFIG_MATCHPATHCON=y
CONFIG_RESTORECON=y
CONFIG_RUNCON=y
CONFIG_FEATURE_RUNCON_LONG_OPTIONS=y
CONFIG_SELINUXENABLED=y
CONFIG_SETENFORCE=y
CONFIG_SETFILES=y
CONFIG_FEATURE_SETFILES_CHECK_OPTION=y
CONFIG_SETSEBOOL=y
CONFIG_SESTATUS=y
#
# Print Utilities
#
CONFIG_LPD=y
CONFIG_LPR=y
CONFIG_LPQ=y
+17 -8
View File
@@ -4,22 +4,31 @@
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
obj-y:=
obj-y += applets.o
obj-y :=
obj-y += applets.o
hostprogs-y:=
hostprogs-y += usage
hostprogs-y += usage applet_tables
always:= $(hostprogs-y)
always:= $(hostprogs-y)
# Generated files need additional love
HOSTCFLAGS_usage.o = -I$(srctree)/include
applets/applets.o: include/usage_compressed.h include/applet_tables.h
applets/usage: .config $(srctree)/applets/usage_compressed
applets/applet_tables: .config
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets
HOSTCFLAGS_usage.o = -I$(srctree)/include
applets/applets.o: include/usage_compressed.h
applets/usage: .config $(srctree)/applets/usage_compressed
include/usage_compressed.h: applets/usage $(srctree)/applets/usage_compressed
$(call cmd,gen_usage_compressed)
quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h
include/applet_tables.h: applets/applet_tables
$(call cmd,gen_applet_tables)
+126
View File
@@ -0,0 +1,126 @@
/* vi: set sw=4 ts=4: */
/*
* Applet table generator.
* Runs on host and produces include/applet_tables.h
*
* Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
*
* Licensed under GPLv2, see file License in this tarball for details.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "../include/autoconf.h"
#include "../include/busybox.h"
struct bb_applet {
const char *name;
const char *main;
enum bb_install_loc_t install_loc;
enum bb_suid_t need_suid;
/* true if instead of fork(); exec("applet"); waitpid();
* one can do fork(); exit(applet_main(argc,argv)); waitpid(); */
unsigned char noexec;
/* Even nicer */
/* true if instead of fork(); exec("applet"); waitpid();
* one can simply call applet_main(argc,argv); */
unsigned char nofork;
};
/* Define struct bb_applet applets[] */
#include "../include/applets.h"
enum { NUM_APPLETS = ARRAY_SIZE(applets) };
static int offset[NUM_APPLETS];
static int cmp_name(const void *a, const void *b)
{
const struct bb_applet *aa = a;
const struct bb_applet *bb = b;
return strcmp(aa->name, bb->name);
}
int main(int argc, char **argv)
{
int i;
int ofs;
unsigned MAX_APPLET_NAME_LEN = 1;
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
ofs = 0;
for (i = 0; i < NUM_APPLETS; i++) {
offset[i] = ofs;
ofs += strlen(applets[i].name) + 1;
}
/* We reuse 4 high-order bits of offset array for other purposes,
* so if they are indeed needed, refuse to proceed */
if (ofs > 0xfff)
return 1;
if (!argv[1])
return 1;
i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (i < 0)
return 1;
dup2(i, 1);
/* Keep in sync with include/busybox.h! */
puts("/* This is a generated file, don't edit */\n");
printf("#define NUM_APPLETS %u\n", NUM_APPLETS);
if (NUM_APPLETS == 1) {
printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].name);
}
puts("\nconst char applet_names[] ALIGN1 = \"\"");
for (i = 0; i < NUM_APPLETS; i++) {
printf("\"%s\" \"\\0\"\n", applets[i].name);
if (MAX_APPLET_NAME_LEN < strlen(applets[i].name))
MAX_APPLET_NAME_LEN = strlen(applets[i].name);
}
puts(";");
puts("\nint (*const applet_main[])(int argc, char **argv) = {");
for (i = 0; i < NUM_APPLETS; i++) {
printf("%s_main,\n", applets[i].main);
}
puts("};");
puts("const uint16_t applet_nameofs[] ALIGN2 = {");
for (i = 0; i < NUM_APPLETS; i++) {
printf("0x%04x,\n",
offset[i]
#if ENABLE_FEATURE_PREFER_APPLETS
+ (applets[i].nofork << 12)
+ (applets[i].noexec << 13)
#endif
#if ENABLE_FEATURE_SUID
+ (applets[i].need_suid << 14) /* 2 bits */
#endif
);
}
puts("};");
#if ENABLE_FEATURE_INSTALLER
puts("const uint8_t applet_install_loc[] ALIGN1 = {");
i = 0;
while (i < NUM_APPLETS) {
int v = applets[i].install_loc; /* 3 bits */
if (++i < NUM_APPLETS)
v |= applets[i].install_loc << 4; /* 3 bits */
printf("0x%02x,\n", v);
i++;
}
puts("};\n");
#endif
printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
return 0;
}
+8 -658
View File
@@ -1,668 +1,18 @@
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
* Stub for linking busybox binary against libbusybox.
*
* Copyright (C) tons of folks. Tracking down who wrote what
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
* Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
* Licensed under GPLv2 or later, see file License in this tarball for details.
* Licensed under GPLv2, see file License in this tarball for details.
*/
#include <assert.h>
#include "busybox.h"
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
#warning Static linking against glibc produces buggy executables
#warning (glibc does not cope well with ld --gc-sections).
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
#warning Note that glibc is unsuitable for static linking anyway.
#warning If you still want to do it, remove -Wl,--gc-sections
#warning from top-level Makefile and remove this warning.
#error Aborting compilation.
#if ENABLE_BUILD_LIBBUSYBOX
int main(int argc UNUSED_PARAM, char **argv)
{
return lbb_main(argv);
}
#endif
/* Declare <applet>_main() */
#define PROTOTYPES
#include "applets.h"
#undef PROTOTYPES
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
/* Define usage_messages[] */
static const char usage_messages[] ALIGN1 = ""
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
;
#undef MAKE_USAGE
#else
#define usage_messages 0
#endif /* SHOW_USAGE */
/* Define struct bb_applet applets[] */
#include "applets.h"
/* The -1 arises because of the {0,NULL,0,-1} entry. */
#if ENABLE_FEATURE_SH_STANDALONE
const unsigned short NUM_APPLETS = ARRAY_SIZE(applets);
#endif
const struct bb_applet *current_applet;
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
#if !BB_MMU
bool re_execed;
#endif
USE_FEATURE_SUID(static uid_t ruid;) /* real uid */
#if ENABLE_FEATURE_SUID_CONFIG
/* applets[] is const, so we have to define this "override" structure */
static struct BB_suid_config {
const struct bb_applet *m_applet;
uid_t m_uid;
gid_t m_gid;
mode_t m_mode;
struct BB_suid_config *m_next;
} *suid_config;
static bool suid_cfg_readable;
/* check if u is member of group g */
static int ingroup(uid_t u, gid_t g)
{
struct group *grp = getgrgid(g);
if (grp) {
char **mem;
for (mem = grp->gr_mem; *mem; mem++) {
struct passwd *pwd = getpwnam(*mem);
if (pwd && (pwd->pw_uid == u))
return 1;
}
}
return 0;
}
/* This should probably be a libbb routine. In that case,
* I'd probably rename it to something like bb_trimmed_slice.
*/
static char *get_trimmed_slice(char *s, char *e)
{
/* First, consider the value at e to be nul and back up until we
* reach a non-space char. Set the char after that (possibly at
* the original e) to nul. */
while (e-- > s) {
if (!isspace(*e)) {
break;
}
}
e[1] = '\0';
/* Next, advance past all leading space and return a ptr to the
* first non-space char; possibly the terminating nul. */
return skip_whitespace(s);
}
/* Don't depend on the tools to combine strings. */
static const char config_file[] ALIGN1 = "/etc/busybox.conf";
/* We don't supply a value for the nul, so an index adjustment is
* necessary below. Also, we use unsigned short here to save some
* space even though these are really mode_t values. */
static const unsigned short mode_mask[] ALIGN2 = {
/* SST sst xxx --- */
S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */
S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */
0, S_IXOTH, S_IXOTH, 0 /* other */
};
#define parse_error(x) do { errmsg = x; goto pe_label; } while (0)
static void parse_config_file(void)
{
struct BB_suid_config *sct_head;
struct BB_suid_config *sct;
const struct bb_applet *applet;
FILE *f;
const char *errmsg;
char *s;
char *e;
int i;
unsigned lc;
smallint section;
char buffer[256];
struct stat st;
assert(!suid_config); /* Should be set to NULL by bss init. */
ruid = getuid();
if (ruid == 0) /* run by root - don't need to even read config file */
return;
if ((stat(config_file, &st) != 0) /* No config file? */
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|| (st.st_uid != 0) /* Not owned by root? */
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|| !(f = fopen(config_file, "r")) /* Cannot open? */
) {
return;
}
suid_cfg_readable = 1;
sct_head = NULL;
section = lc = 0;
while (1) {
s = buffer;
if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */
if (ferror(f)) { /* Make sure it wasn't a read error. */
parse_error("reading");
}
fclose(f);
suid_config = sct_head; /* Success, so set the pointer. */
return;
}
lc++; /* Got a (partial) line. */
/* If a line is too long for our buffer, we consider it an error.
* The following test does mistreat one corner case though.
* If the final line of the file does not end with a newline and
* yet exactly fills the buffer, it will be treated as too long
* even though there isn't really a problem. But it isn't really
* worth adding code to deal with such an unlikely situation, and
* we do err on the side of caution. Besides, the line would be
* too long if it did end with a newline. */
if (!strchr(s, '\n') && !feof(f)) {
parse_error("line too long");
}
/* Trim leading and trailing whitespace, ignoring comments, and
* check if the resulting string is empty. */
s = get_trimmed_slice(s, strchrnul(s, '#'));
if (!*s) {
continue;
}
/* Check for a section header. */
if (*s == '[') {
/* Unlike the old code, we ignore leading and trailing
* whitespace for the section name. We also require that
* there are no stray characters after the closing bracket. */
e = strchr(s, ']');
if (!e /* Missing right bracket? */
|| e[1] /* Trailing characters? */
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
) {
parse_error("section header");
}
/* Right now we only have one section so just check it.
* If more sections are added in the future, please don't
* resort to cascading ifs with multiple strcasecmp calls.
* That kind of bloated code is all too common. A loop
* and a string table would be a better choice unless the
* number of sections is very small. */
if (strcasecmp(s, "SUID") == 0) {
section = 1;
continue;
}
section = -1; /* Unknown section so set to skip. */
continue;
}
/* Process sections. */
if (section == 1) { /* SUID */
/* Since we trimmed leading and trailing space above, we're
* now looking for strings of the form
* <key>[::space::]*=[::space::]*<value>
* where both key and value could contain inner whitespace. */
/* First get the key (an applet name in our case). */
e = strchr(s, '=');
if (e) {
s = get_trimmed_slice(s, e);
}
if (!e || !*s) { /* Missing '=' or empty key. */
parse_error("keyword");
}
/* Ok, we have an applet name. Process the rhs if this
* applet is currently built in and ignore it otherwise.
* Note: this can hide config file bugs which only pop
* up when the busybox configuration is changed. */
applet = find_applet_by_name(s);
if (applet) {
/* Note: We currently don't check for duplicates!
* The last config line for each applet will be the
* one used since we insert at the head of the list.
* I suppose this could be considered a feature. */
sct = xmalloc(sizeof(struct BB_suid_config));
sct->m_applet = applet;
sct->m_mode = 0;
sct->m_next = sct_head;
sct_head = sct;
/* Get the specified mode. */
e = skip_whitespace(e+1);
for (i = 0; i < 3; i++) {
/* There are 4 chars + 1 nul for each of user/group/other. */
static const char mode_chars[] ALIGN1 = "Ssx-\0" "Ssx-\0" "Ttx-";
const char *q;
q = strchrnul(mode_chars + 5*i, *e++);
if (!*q) {
parse_error("mode");
}
/* Adjust by -i to account for nul. */
sct->m_mode |= mode_mask[(q - mode_chars) - i];
}
/* Now get the the user/group info. */
s = skip_whitespace(e);
/* Note: we require whitespace between the mode and the
* user/group info. */
if ((s == e) || !(e = strchr(s, '.'))) {
parse_error("<uid>.<gid>");
}
*e++ = '\0';
/* We can't use get_ug_id here since it would exit()
* if a uid or gid was not found. Oh well... */
sct->m_uid = bb_strtoul(s, NULL, 10);
if (errno) {
struct passwd *pwd = getpwnam(s);
if (!pwd) {
parse_error("user");
}
sct->m_uid = pwd->pw_uid;
}
sct->m_gid = bb_strtoul(e, NULL, 10);
if (errno) {
struct group *grp;
grp = getgrnam(e);
if (!grp) {
parse_error("group");
}
sct->m_gid = grp->gr_gid;
}
}
continue;
}
/* Unknown sections are ignored. */
/* Encountering configuration lines prior to seeing a
* section header is treated as an error. This is how
* the old code worked, but it may not be desirable.
* We may want to simply ignore such lines in case they
* are used in some future version of busybox. */
if (!section) {
parse_error("keyword outside section");
}
} /* while (1) */
pe_label:
fprintf(stderr, "Parse error in %s, line %d: %s\n",
config_file, lc, errmsg);
fclose(f);
/* Release any allocated memory before returning. */
while (sct_head) {
sct = sct_head->m_next;
free(sct_head);
sct_head = sct;
}
}
#else
static inline void parse_config_file(void)
{
USE_FEATURE_SUID(ruid = getuid();)
}
#endif /* FEATURE_SUID_CONFIG */
#if ENABLE_FEATURE_SUID
static void check_suid(const struct bb_applet *applet)
{
gid_t rgid; /* real gid */
if (ruid == 0) /* set by parse_config_file() */
return; /* run by root - no need to check more */
rgid = getgid();
#if ENABLE_FEATURE_SUID_CONFIG
if (suid_cfg_readable) {
uid_t uid;
struct BB_suid_config *sct;
mode_t m;
for (sct = suid_config; sct; sct = sct->m_next) {
if (sct->m_applet == applet)
goto found;
}
/* default: drop all privileges */
xsetgid(rgid);
xsetuid(ruid);
return;
found:
m = sct->m_mode;
if (sct->m_uid == ruid)
/* same uid */
m >>= 6;
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
/* same group / in group */
m >>= 3;
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die("you have no permission to run this applet!");
/* _both_ sgid and group_exec have to be set for setegid */
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
rgid = sct->m_gid;
/* else (no setegid) we will set egid = rgid */
/* We set effective AND saved ids. If saved-id is not set
* like we do below, seteiud(0) can still later succeed! */
if (setresgid(-1, rgid, rgid))
bb_perror_msg_and_die("setresgid");
/* do we have to set effective uid? */
uid = ruid;
if (sct->m_mode & S_ISUID)
uid = sct->m_uid;
/* else (no seteuid) we will set euid = ruid */
if (setresuid(-1, uid, uid))
bb_perror_msg_and_die("setresuid");
return;
}
#if !ENABLE_FEATURE_SUID_CONFIG_QUIET
{
static bool onetime = 0;
if (!onetime) {
onetime = 1;
fprintf(stderr, "Using fallback suid method\n");
}
}
#endif
#endif
if (applet->need_suid == _BB_SUID_ALWAYS) {
/* Real uid is not 0. If euid isn't 0 too, suid bit
* is most probably not set on our executable */
if (geteuid())
bb_error_msg_and_die("applet requires root privileges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
xsetgid(rgid); /* drop all privileges */
xsetuid(ruid);
}
}
#else
#define check_suid(x) ((void)0)
#endif /* FEATURE_SUID */
#if ENABLE_FEATURE_COMPRESS_USAGE
#include "usage_compressed.h"
#include "unarchive.h"
static const char *unpack_usage_messages(void)
{
char *outbuf = NULL;
bunzip_data *bd;
int i;
i = start_bunzip(&bd,
/* src_fd: */ -1,
/* inbuf: */ packed_usage,
/* len: */ sizeof(packed_usage));
/* read_bunzip can longjmp to start_bunzip, and ultimately
* end up here with i != 0 on read data errors! Not trivial */
if (!i) {
/* Cannot use xmalloc: will leak bd in NOFORK case! */
outbuf = malloc_or_warn(SIZEOF_usage_messages);
if (outbuf)
read_bunzip(bd, outbuf, SIZEOF_usage_messages);
}
dealloc_bunzip(bd);
return outbuf;
}
#define dealloc_usage_messages(s) free(s)
#else
#define unpack_usage_messages() usage_messages
#define dealloc_usage_messages(s) ((void)(s))
#endif /* FEATURE_COMPRESS_USAGE */
void bb_show_usage(void)
{
if (ENABLE_SHOW_USAGE) {
const char *format_string;
const char *p;
const char *usage_string = p = unpack_usage_messages();
int i;
i = current_applet - applets;
while (i) {
while (*p++) continue;
i--;
}
fprintf(stderr, "%s multi-call binary\n", bb_banner);
format_string = "\nUsage: %s %s\n\n";
if (*p == '\b')
format_string = "\nNo help available.\n\n";
fprintf(stderr, format_string, applet_name, p);
dealloc_usage_messages((char*)usage_string);
}
xfunc_die();
}
static int applet_name_compare(const void *name, const void *vapplet)
{
const struct bb_applet *applet = vapplet;
return strcmp(name, applet->name);
}
const struct bb_applet *find_applet_by_name(const char *name)
{
/* Do a binary search to find the applet entry given the name. */
return bsearch(name, applets, ARRAY_SIZE(applets)-1, sizeof(applets[0]),
applet_name_compare);
}
#if ENABLE_FEATURE_INSTALLER
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
/* directory table
* this should be consistent w/ the enum,
* busybox.h::bb_install_loc_t, or else... */
static const char usr_bin [] ALIGN1 = "/usr/bin";
static const char usr_sbin[] ALIGN1 = "/usr/sbin";
static const char *const install_dir[] = {
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
&usr_bin [4], /* "/bin" */
&usr_sbin[4], /* "/sbin" */
usr_bin,
usr_sbin
};
int (*lf)(const char *, const char *) = link;
char *fpc;
int i;
int rc;
if (use_symbolic_links)
lf = symlink;
for (i = 0; applets[i].name != NULL; i++) {
fpc = concat_path_file(
install_dir[applets[i].install_loc],
applets[i].name);
rc = lf(busybox, fpc);
if (rc != 0 && errno != EEXIST) {
bb_perror_msg("%s", fpc);
}
free(fpc);
}
}
#else
#define install_links(x,y) ((void)0)
#endif /* FEATURE_INSTALLER */
/* If we were called as "busybox..." */
static int busybox_main(char **argv)
{
if (!argv[1]) {
/* Called without arguments */
const struct bb_applet *a;
int col, output_width;
help:
output_width = 80;
if (ENABLE_FEATURE_AUTOWIDTH) {
/* Obtain the terminal width */
get_terminal_width_height(0, &output_width, NULL);
}
/* leading tab and room to wrap */
output_width -= sizeof("start-stop-daemon, ") + 8;
printf("%s multi-call binary\n", bb_banner); /* reuse const string... */
printf("Copyright (C) 1998-2006  Erik Andersen, Rob Landley, and others.\n"
"Licensed under GPLv2.  See source distribution for full notice.\n"
"\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n"
"\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use and BusyBox\n"
"\twill act like whatever it was invoked as!\n"
"\nCurrently defined functions:\n");
col = 0;
a = applets;
while (a->name) {
if (col > output_width) {
puts(",");
col = 0;
}
col += printf("%s%s", (col ? ", " : "\t"), a->name);
a++;
}
puts("\n");
return 0;
}
if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
const char *busybox;
busybox = xmalloc_readlink(bb_busybox_exec_path);
if (!busybox)
busybox = bb_busybox_exec_path;
/* -s makes symlinks */
install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0);
return 0;
}
if (strcmp(argv[1], "--help") == 0) {
/* "busybox --help [<applet>]" */
if (!argv[2])
goto help;
/* convert to "<applet> --help" */
argv[0] = argv[2];
argv[2] = NULL;
} else {
/* "busybox <applet> arg1 arg2 ..." */
argv++;
}
/* we want "<argv[0]>: applet not found", not "busybox: ..." */
applet_name = argv[0];
run_applet_and_exit(argv[0], argv);
bb_error_msg_and_die("applet not found");
}
void run_current_applet_and_exit(char **argv)
{
int argc = 1;
while (argv[argc])
argc++;
/* Reinit some shared global data */
optind = 1;
xfunc_error_retval = EXIT_FAILURE;
applet_name = current_applet->name;
if (argc == 2 && !strcmp(argv[1], "--help"))
bb_show_usage();
if (ENABLE_FEATURE_SUID)
check_suid(current_applet);
exit(current_applet->main(argc, argv));
}
void run_applet_and_exit(const char *name, char **argv)
{
current_applet = find_applet_by_name(name);
if (current_applet)
run_current_applet_and_exit(argv);
if (!strncmp(name, "busybox", 7))
exit(busybox_main(argv));
}
#ifdef __GLIBC__
/* Make it reside in R/W memory: */
int *const bb_errno __attribute__ ((section (".data")));
#endif
int main(int argc, char **argv)
{
#ifdef __GLIBC__
(*(int **)&bb_errno) = __errno_location();
#endif
#if !BB_MMU
/* NOMMU re-exec trick sets high-order bit in first byte of name */
if (argv[0][0] & 0x80) {
re_execed = 1;
argv[0][0] &= 0x7f;
}
#endif
applet_name = argv[0];
if (applet_name[0] == '-')
applet_name++;
applet_name = bb_basename(applet_name);
parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */
/* Set locale for everybody except 'init' */
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
setlocale(LC_ALL, "");
run_applet_and_exit(applet_name, argv);
bb_error_msg_and_die("applet not found");
}
+2 -4
View File
@@ -14,13 +14,11 @@ const char *applet_name;
int main(int argc, char **argv)
{
applet_name = argv[0];
return APPLET_main(argc,argv);
}
void bb_show_usage(void)
{
printf(APPLET_full_usage "\n");
exit(1);
fputs(APPLET_full_usage "\n", stdout);
exit(EXIT_FAILURE);
}
+50 -34
View File
@@ -5,19 +5,23 @@ export LC_CTYPE=POSIX
prefix=${1}
if [ -z "$prefix" ]; then
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]"
exit 1;
fi
h=`sort busybox.links | uniq`
scriptwrapper="n"
cleanup="0"
noclobber="0"
case "$2" in
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
--cleanup) cleanup="1";;
--noclobber) noclobber="1";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
--scriptwrapper) scriptwrapper="y";swrapall="y";;
--sw-sh-hard) scriptwrapper="y";linkopts="-f";;
--sw-sh-sym) scriptwrapper="y";linkopts="-fs";;
--cleanup) cleanup="1";;
--noclobber) noclobber="1";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
esac
if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
@@ -33,7 +37,7 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
for i in $DO_INSTALL_LIBS; do
rm -f $prefix/$libdir/$i || exit 1
if [ -f $i ]; then
cp -a $i $prefix/$libdir/ || exit 1
cp -pPR $i $prefix/$libdir/ || exit 1
chmod 0644 $prefix/$libdir/$i || exit 1
fi
done
@@ -52,6 +56,7 @@ if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
cd "$pd"
done
`
exit 0
fi
rm -f $prefix/bin/busybox || exit 1
@@ -61,33 +66,44 @@ install -m 755 busybox $prefix/bin/busybox || exit 1
for i in $h; do
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
if [ "$scriptwrapper" = "y" ]; then
if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
ln $linkopts busybox $prefix$i || exit 1
else
rm -f $prefix$i
echo "#!/bin/busybox" > $prefix$i
chmod +x $prefix/$i
fi
echo " $prefix$i"
else
case "$appdir" in
/)
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
fi
if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
else
echo " $prefix$i already exists"
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
else
case "$appdir" in
/)
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
fi
if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
else
echo " $prefix$i already exists"
fi
fi
done
+12 -1
View File
@@ -5,6 +5,17 @@
* object directory */
#include "../include/autoconf.h"
/* Since we can't use platform.h, have to do this again by hand: */
#if ENABLE_NOMMU
#define BB_MMU 0
#define USE_FOR_NOMMU(...) __VA_ARGS__
#define USE_FOR_MMU(...)
#else
#define BB_MMU 1
#define USE_FOR_NOMMU(...)
#define USE_FOR_MMU(...) __VA_ARGS__
#endif
static const char usage_messages[] = ""
#define MAKE_USAGE
#include "usage.h"
@@ -13,6 +24,6 @@ static const char usage_messages[] = ""
int main(void)
{
write(1, usage_messages, sizeof(usage_messages));
write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
return 0;
}
+18 -3
View File
@@ -12,8 +12,23 @@ sz=`"$loc/usage" | wc -c` || exit 1
exec >"$target"
echo 'static const char packed_usage[] ALIGN1 = '
echo 'static const char packed_usage[] ALIGN1 = {'
## Breaks on big-endian systems!
## # Extra effort to avoid using "od -t x1": -t is not available
## # in non-CONFIG_DESKTOPed busybox od
##
## "$loc/usage" | bzip2 -1 | od -v -x \
## | $SED -e 's/^[^ ]*//' \
## | $SED -e 's/ //g' \
## | grep -v '^$' \
## | $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
"$loc/usage" | bzip2 -1 | od -v -t x1 \
| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
echo ';'
| $SED -e 's/^[^ ]*//' \
| $SED -e 's/ //g' \
| grep -v '^$' \
| $SED -e 's/\(..\)/0x\1,/g'
echo '};'
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
+93 -118
View File
@@ -5,12 +5,36 @@
menu "Archival Utilities"
config FEATURE_SEAMLESS_LZMA
bool "Make tar, rpm, modprobe etc understand .lzma data"
default n
help
Make tar, rpm, modprobe etc understand .lzma data.
config FEATURE_SEAMLESS_BZ2
bool "Make tar, rpm, modprobe etc understand .bz2 data"
default n
help
Make tar, rpm, modprobe etc understand .bz2 data.
config FEATURE_SEAMLESS_GZ
bool "Make tar, rpm, modprobe etc understand .gz data"
default n
help
Make tar, rpm, modprobe etc understand .gz data.
config FEATURE_SEAMLESS_Z
bool "Make tar and gunzip understand .Z data"
default n
help
Make tar and gunzip understand .Z data.
config AR
bool "ar"
default n
help
ar is an archival utility program used to create, modify, and
extract contents from archives. An archive is a single file holding
extract contents from archives. An archive is a single file holding
a collection of other files in a structure that makes it possible to
retrieve the original individual files (called archive members).
The original files' contents, mode (permissions), timestamp, owner,
@@ -29,12 +53,12 @@ config AR
probably say N here.
config FEATURE_AR_LONG_FILENAMES
bool "Enable support for long filenames (not need for debs)"
bool "Support for long filenames (not need for debs)"
default n
depends on AR
help
By default the ar format can only store the first 15 characters of the
filename, this option removes that limitation.
By default the ar format can only store the first 15 characters of
the filename, this option removes that limitation.
It supports the GNU ar long filename method which moves multiple long
filenames into a the data section of a new ar entry.
@@ -43,59 +67,80 @@ config BUNZIP2
default n
help
bunzip2 is a compression utility using the Burrows-Wheeler block
sorting text compression algorithm, and Huffman coding. Compression
sorting text compression algorithm, and Huffman coding. Compression
is generally considerably better than that achieved by more
conventional LZ77/LZ78-based compressors, and approaches the
performance of the PPM family of statistical compressors.
The BusyBox bunzip2 applet is limited to de-compression only.
On an x86 system, this applet adds about 11K.
Unless you have a specific application which requires bunzip2, you
should probably say N here.
config BZIP2
bool "bzip2"
default n
help
bzip2 is a compression utility using the Burrows-Wheeler block
sorting text compression algorithm, and Huffman coding. Compression
is generally considerably better than that achieved by more
conventional LZ77/LZ78-based compressors, and approaches the
performance of the PPM family of statistical compressors.
Unless you have a specific application which requires bzip2, you
should probably say N here.
config CPIO
bool "cpio"
default n
help
cpio is an archival utility program used to create, modify, and extract
contents from archives.
cpio is an archival utility program used to create, modify, and
extract contents from archives.
cpio has 110 bytes of overheads for every stored file.
This implementation of cpio can extract cpio archives created in the
"newc" or "crc" format, it cannot create or modify them.
Unless you have a specific application which requires cpio, you should
probably say N here.
Unless you have a specific application which requires cpio, you
should probably say N here.
config FEATURE_CPIO_O
bool "Support for archive creation"
default n
depends on CPIO
help
This implementation of cpio can create cpio archives in the "newc"
format only.
config DPKG
bool "dpkg"
default n
help
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
dpkg is a medium-level tool to install, build, remove and manage
Debian packages.
This implementation of dpkg has a number of limitations, you should use the
official dpkg if possible.
This implementation of dpkg has a number of limitations,
you should use the official dpkg if possible.
config DPKG_DEB
bool "dpkg_deb"
default n
help
dpkg-deb packs, unpacks and provides information about Debian archives.
dpkg-deb packs, unpacks and provides information about Debian
archives.
This implementation of dpkg-deb cannot pack archives.
Unless you have a specific application which requires dpkg-deb, you should
probably say N here.
Unless you have a specific application which requires dpkg-deb,
say N here.
config FEATURE_DPKG_DEB_EXTRACT_ONLY
bool "extract only (-x)"
bool "Extract only (-x)"
default n
depends on DPKG_DEB
help
This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
However it saves space as none of the extra dpkg-deb, ar or tar options are
needed, they are linked to internally.
This reduces dpkg-deb to the equivalent of
"ar -p <deb> data.tar.gz | tar -zx". However it saves space as none
of the extra dpkg-deb, ar or tar options are needed, they are linked
to internally.
config GUNZIP
bool "gunzip"
@@ -105,15 +150,6 @@ config GUNZIP
You can use the `-t' option to test the integrity of
an archive, without decompressing it.
config FEATURE_GUNZIP_UNCOMPRESS
bool "Uncompress support"
default n
depends on GUNZIP
help
Enable if you want gunzip to have the ability to decompress
archives created by the program compress (not much
used anymore).
config GZIP
bool "gzip"
default n
@@ -133,13 +169,6 @@ config RPM
help
Mini RPM applet - queries and extracts RPM packages.
config FEATURE_RPM_BZ2
bool "Enable handling of rpms with bzip2-compressed data inside"
default n
depends on RPM
help
Enable handling of rpms with bzip2-compressed data inside.
config TAR
bool "tar"
default n
@@ -148,6 +177,8 @@ config TAR
create compressed archives. It's probably the most widely used
UNIX archive program.
if TAR
config FEATURE_TAR_CREATE
bool "Enable archive creation"
default y
@@ -156,21 +187,13 @@ config FEATURE_TAR_CREATE
If you enable this option you'll be able to create
tar archives using the `-c' option.
config FEATURE_TAR_BZIP2
bool "Enable -j option to handle .tar.bz2 files"
config FEATURE_TAR_AUTODETECT
bool "Autodetect gz/bz2 compressed tarballs"
default n
depends on TAR
depends on FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA
help
If you enable this option you'll be able to extract
archives compressed with bzip2.
config FEATURE_TAR_LZMA
bool "Enable -a option to handle .tar.lzma files"
default n
depends on TAR
help
If you enable this option you'll be able to extract
archives compressed with lzma.
With this option tar can automatically detect gzip/bzip2 compressed
tarballs. Currently it works only on files (not pipes etc).
config FEATURE_TAR_FROM
bool "Enable -X (exclude from) and -T (include from) options)"
@@ -180,24 +203,8 @@ config FEATURE_TAR_FROM
If you enable this option you'll be able to specify
a list of files to include or exclude from an archive.
config FEATURE_TAR_GZIP
bool "Enable -z option"
default y
depends on TAR
help
If you enable this option tar will be able to call gzip,
when creating or extracting tar gziped archives.
config FEATURE_TAR_COMPRESS
bool "Enable -Z option"
default n
depends on TAR
help
If you enable this option tar will be able to call uncompress,
when extracting .tar.Z archives.
config FEATURE_TAR_OLDGNU_COMPATIBILITY
bool "Enable support for old tar header format"
bool "Support for old tar header format"
default N
depends on TAR
help
@@ -211,11 +218,12 @@ config FEATURE_TAR_OLDSUN_COMPATIBILITY
depends on TAR
help
This option is required to unpack archives created by some old
version of Sun's tar (it was calculating checksum using signed arithmetic).
It is said to be fixed in newer Sun tar, but "old" tarballs still exist.
version of Sun's tar (it was calculating checksum using signed
arithmetic). It is said to be fixed in newer Sun tar, but "old"
tarballs still exist.
config FEATURE_TAR_GNU_EXTENSIONS
bool "Enable support for some GNU tar extensions"
bool "Support for GNU tar extensions (long filenames)"
default y
depends on TAR
help
@@ -227,7 +235,18 @@ config FEATURE_TAR_LONG_OPTIONS
default n
depends on TAR && GETOPT_LONG
help
Enable use of long options, increases size by about 400 Bytes
Enable use of long options, increases size by about 400 Bytes
config FEATURE_TAR_UNAME_GNAME
bool "Enable use of user and group names"
default n
depends on TAR
help
Enables use of user and group names in tar. This affects contents
listings (-t) and preserving permissions when unpacking (-p).
+200 bytes.
endif #tar
config UNCOMPRESS
bool "uncompress"
@@ -241,7 +260,7 @@ config UNLZMA
default n
help
unlzma is a compression utility using the Lempel-Ziv-Markov chain
compression algorithm, and range coding. Compression
compression algorithm, and range coding. Compression
is generally considerably better than that achieved by the bzip2
compressors.
@@ -252,7 +271,7 @@ config UNLZMA
should probably say N here.
config FEATURE_LZMA_FAST
bool "Optimze unlzma for speed"
bool "Optimize unlzma for speed"
default n
depends on UNLZMA
help
@@ -269,48 +288,4 @@ config UNZIP
current directory. Use the `-d' option to extract to a
directory of your choice.
comment "Common options for cpio and tar"
depends on CPIO || TAR
config FEATURE_UNARCHIVE_TAPE
bool "Enable tape drive support"
default n
depends on CPIO || TAR
help
I don't think this is needed anymore.
comment "Common options for dpkg and dpkg_deb"
depends on DPKG || DPKG_DEB
config FEATURE_DEB_TAR_GZ
bool "gzip debian packages (normal)"
default y if DPKG || DPKG_DEB
depends on DPKG || DPKG_DEB
help
This is the default compression method inside the debian ar file.
If you want compatibility with standard .deb's you should say yes here.
config FEATURE_DEB_TAR_BZ2
bool "bzip2 debian packages"
default n
depends on DPKG || DPKG_DEB
help
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
with bzip2 instead of gzip.
You only want this if you are creating your own custom debian packages that
use an internal control.tar.bz2 or data.tar.bz2.
config FEATURE_DEB_TAR_LZMA
bool "lzma debian packages"
default n
depends on DPKG || DPKG_DEB
help
This allows dpkg and dpkg-deb to extract deb's that are compressed
internally with lzma instead of gzip.
You only want this if you are creating your own custom debian
packages that use an internal control.tar.lzma or data.tar.lzma.
endmenu
+1
View File
@@ -9,6 +9,7 @@ libs-y += libunarchive/
lib-y:=
lib-$(CONFIG_AR) += ar.o
lib-$(CONFIG_BUNZIP2) += bbunzip.o
lib-$(CONFIG_BZIP2) += bzip2.o bbunzip.o
lib-$(CONFIG_UNLZMA) += bbunzip.o
lib-$(CONFIG_CPIO) += cpio.o
lib-$(CONFIG_DPKG) += dpkg.o
+4 -13
View File
@@ -3,7 +3,6 @@
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@iinet.net.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
@@ -17,7 +16,7 @@
#include "libbb.h"
#include "unarchive.h"
static void header_verbose_list_ar(const file_header_t *file_header)
static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
{
const char *mode = bb_mode_string(file_header->mode);
char *mtime;
@@ -38,7 +37,7 @@ static void header_verbose_list_ar(const file_header_t *file_header)
#define AR_OPT_CREATE 0x20
#define AR_OPT_INSERT 0x40
int ar_main(int argc, char **argv);
int ar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ar_main(int argc, char **argv)
{
static const char msg_unsupported_err[] ALIGN1 =
@@ -46,7 +45,6 @@ int ar_main(int argc, char **argv)
archive_handle_t *archive_handle;
unsigned opt;
char magic[8];
archive_handle = init_handle();
@@ -64,7 +62,7 @@ int ar_main(int argc, char **argv)
archive_handle->action_data = data_extract_all;
}
if (opt & AR_OPT_PRESERVE_DATE) {
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
archive_handle->ah_flags |= ARCHIVE_PRESERVE_DATE;
}
if (opt & AR_OPT_VERBOSE) {
archive_handle->action_header = header_verbose_list_ar;
@@ -83,14 +81,7 @@ int ar_main(int argc, char **argv)
llist_add_to(&(archive_handle->accept), argv[optind++]);
}
xread(archive_handle->src_fd, magic, 7);
if (strncmp(magic, "!<arch>", 7) != 0) {
bb_error_msg_and_die("invalid ar magic");
}
archive_handle->offset += 7;
while (get_header_ar(archive_handle) == EXIT_SUCCESS)
continue;
unpack_ar_archive(archive_handle);
return EXIT_SUCCESS;
}
+42 -23
View File
@@ -11,7 +11,7 @@
enum {
OPT_STDOUT = 0x1,
OPT_FORCE = 0x2,
/* gunzip only: */
/* gunzip and bunzip2 only: */
OPT_VERBOSE = 0x4,
OPT_DECOMPRESS = 0x8,
OPT_TEST = 0x10,
@@ -28,7 +28,7 @@ int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
return 0;
}
int bbunpack(char **argv,
int FAST_FUNC bbunpack(char **argv,
char* (*make_new_name)(char *filename),
USE_DESKTOP(long long) int (*unpacker)(void)
)
@@ -49,7 +49,7 @@ int bbunpack(char **argv,
/* Open src */
if (filename) {
if (stat(filename, &stat_buf) != 0) {
bb_perror_msg("%s", filename);
bb_simple_perror_msg(filename);
err:
exitcode = 1;
goto free_name;
@@ -73,8 +73,14 @@ int bbunpack(char **argv,
bb_error_msg("%s: unknown suffix - ignored", filename);
goto err;
}
/* -f: overwrite existing output files */
if (option_mask32 & OPT_FORCE) {
unlink(new_name);
}
/* O_EXCL: "real" bunzip2 doesn't overwrite files */
/* GNU gunzip goes not bail out, but goes to next file */
/* GNU gunzip does not bail out, but goes to next file */
if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL,
stat_buf.st_mode))
goto err;
@@ -138,7 +144,7 @@ char* make_new_name_generic(char *filename, const char *expected_ext)
/*
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
* Modified for busybox by Glenn McGrath
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
@@ -155,13 +161,13 @@ char* make_new_name_bunzip2(char *filename)
static
USE_DESKTOP(long long) int unpack_bunzip2(void)
{
return unpack_bz2_stream(STDIN_FILENO, STDOUT_FILENO);
return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
}
int bunzip2_main(int argc, char **argv);
int bunzip2_main(int argc, char **argv)
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
{
getopt32(argv, "cf");
getopt32(argv, "cfvdt");
argv += optind;
if (applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT;
@@ -185,7 +191,7 @@ int bunzip2_main(int argc, char **argv)
* handling.
*
* General cleanup to better adhere to the style guide and make use of standard
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
* busybox functions by Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
@@ -212,8 +218,8 @@ char* make_new_name_gunzip(char *filename)
extension++;
if (strcmp(extension, "tgz" + 1) == 0
#if ENABLE_FEATURE_GUNZIP_UNCOMPRESS
|| strcmp(extension, "Z") == 0
#if ENABLE_FEATURE_SEAMLESS_Z
|| (extension[0] == 'Z' && extension[1] == '\0')
#endif
) {
extension[-1] = '\0';
@@ -238,10 +244,9 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
unsigned char magic2;
magic2 = xread_char(STDIN_FILENO);
if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) {
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) {
status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
} else if (magic2 == 0x8b) {
check_header_gzip_or_die(STDIN_FILENO);
status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO);
} else {
goto bad_magic;
@@ -257,10 +262,24 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
return status;
}
int gunzip_main(int argc, char **argv);
int gunzip_main(int argc, char **argv)
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
* -n --no-name
* gzip: do not save the original file name and time stamp.
* (The original name is always saved if the name had to be truncated.)
* gunzip: do not restore the original file name/time even if present
* (remove only the gzip suffix from the compressed file name).
* This option is the default when decompressing.
* -N --name
* gzip: always save the original file name and time stamp (this is the default)
* gunzip: restore the original file name and time stamp if present.
*/
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int gunzip_main(int argc UNUSED_PARAM, char **argv)
{
getopt32(argv, "cfvdt");
getopt32(argv, "cfvdtn");
argv += optind;
/* if called as zcat */
if (applet_name[1] == 'c')
@@ -295,8 +314,8 @@ USE_DESKTOP(long long) int unpack_unlzma(void)
return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
}
int unlzma_main(int argc, char **argv);
int unlzma_main(int argc, char **argv)
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unlzma_main(int argc UNUSED_PARAM, char **argv)
{
getopt32(argv, "cf");
argv += optind;
@@ -332,13 +351,13 @@ USE_DESKTOP(long long) int unpack_uncompress(void)
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
bb_error_msg("invalid magic");
} else {
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
}
return status;
}
int uncompress_main(int argc, char **argv);
int uncompress_main(int argc, char **argv)
int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uncompress_main(int argc UNUSED_PARAM, char **argv)
{
getopt32(argv, "cf");
argv += optind;
+61
View File
@@ -0,0 +1,61 @@
#!/bin/sh
# Test that concatenated gz files are unpacking correctly.
# It also tests that unpacking in general is working right.
# Since zip code has many corner cases, run it for a few hours
# to get a decent coverage (200000 tests or more).
gzip="gzip"
gunzip="../busybox gunzip"
# Or the other way around:
#gzip="../busybox gzip"
#gunzip="gunzip"
c=0
i=$PID
while true; do
c=$((c+1))
# RANDOM is not very random on some shells. Spice it up.
# 100003 is prime
len1=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
i=$((i * 1664525 + 1013904223))
len2=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
# Just using urandom will make gzip use method 0 (store) -
# not good for test coverage!
cat /dev/urandom | while true; do read junk; echo "junk $c $i $junk"; done \
| dd bs=$len1 count=1 >z1 2>/dev/null
cat /dev/urandom | while true; do read junk; echo "junk $c $i $junk"; done \
| dd bs=$len2 count=1 >z2 2>/dev/null
$gzip <z1 >zz.gz
$gzip <z2 >>zz.gz
$gunzip -c zz.gz >z9 || {
echo "Exitcode $?"
exit
}
sum=`cat z1 z2 | md5sum`
sum9=`md5sum <z9`
test "$sum" == "$sum9" || {
echo "md5sums don't match"
exit
}
echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum"
sum=`cat z1 z2 z1 z2 | md5sum`
rm z1.gz z2.gz 2>/dev/null
$gzip z1
$gzip z2
cat z1.gz z2.gz z1.gz z2.gz >zz.gz
$gunzip -c zz.gz >z9 || {
echo "Exitcode $? (2)"
exit
}
sum9=`md5sum <z9`
test "$sum" == "$sum9" || {
echo "md5sums don't match (1)"
exit
}
echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum (2)"
done
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# Leak test for gunzip. Watch top for growing process size.
# Just using urandom will make gzip use method 0 (store) -
# not good for test coverage!
cat /dev/urandom \
| while true; do read junk; echo "junk $RANDOM $junk"; done \
| ../busybox gzip \
| ../busybox gunzip -c >/dev/null
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
# Leak test for gunzip. Watch top for growing process size.
# In this case we look for leaks in "concatenated .gz" code -
# we feed gunzip with a stream of .gz files.
i=$PID
c=0
while true; do
c=$((c + 1))
echo "Block# $c" >&2
# RANDOM is not very random on some shells. Spice it up.
i=$((i * 1664525 + 1013904223))
# 100003 is prime
len=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
# Just using urandom will make gzip use method 0 (store) -
# not good for test coverage!
cat /dev/urandom \
| while true; do read junk; echo "junk $c $i $junk"; done \
| dd bs=$len count=1 2>/dev/null \
| gzip >xxx.gz
cat xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz
done | ../busybox gunzip -c >/dev/null
+44
View File
@@ -0,0 +1,44 @@
bzip2 applet in busybox is based on lightly-modified source
of bzip2 version 1.0.4. bzip2 source is distributed
under the following conditions (copied verbatim from LICENSE file)
===========================================================
This program, "bzip2", the associated library "libbzip2", and all
documentation, are copyright (C) 1996-2006 Julian R Seward. All
rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0.4 of 20 December 2006
+90
View File
@@ -0,0 +1,90 @@
This file is an abridged version of README from bzip2 1.0.4
Build instructions (which are not relevant to busyboxed bzip2)
are removed.
===========================================================
This is the README for bzip2/libzip2.
This version is fully compatible with the previous public releases.
------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------
Please read and be aware of the following:
WARNING:
This program and library (attempts to) compress data by
performing several non-trivial transformations on it.
Unless you are 100% familiar with *all* the algorithms
contained herein, and with the consequences of modifying them,
you should NOT meddle with the compression or decompression
machinery. Incorrect changes can and very likely *will*
lead to disastrous loss of data.
DISCLAIMER:
I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED.
Every compression of a file implies an assumption that the
compressed file can be decompressed to reproduce the original.
Great efforts in design, coding and testing have been made to
ensure that this program works correctly. However, the complexity
of the algorithms, and, in particular, the presence of various
special cases in the code which occur with very low but non-zero
probability make it impossible to rule out the possibility of bugs
remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS
PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER
SMALL, THAT THE DATA WILL NOT BE RECOVERABLE.
That is not to say this program is inherently unreliable.
Indeed, I very much hope the opposite is true. bzip2/libbzip2
has been carefully constructed and extensively tested.
PATENTS:
To the best of my knowledge, bzip2/libbzip2 does not use any
patented algorithms. However, I do not have the resources
to carry out a patent search. Therefore I cannot give any
guarantee of the above statement.
I hope you find bzip2 useful. Feel free to contact me at
jseward@bzip.org
if you have any suggestions or queries. Many people mailed me with
comments, suggestions and patches after the releases of bzip-0.15,
bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this
feedback. I thank you for your comments.
bzip2's "home" is http://www.bzip.org/
Julian Seward
jseward@bzip.org
Cambridge, UK.
18 July 1996 (version 0.15)
25 August 1996 (version 0.21)
7 August 1997 (bzip2, version 0.1)
29 August 1997 (bzip2, version 0.1pl2)
23 August 1998 (bzip2, version 0.9.0)
8 June 1999 (bzip2, version 0.9.5)
4 Sept 1999 (bzip2, version 0.9.5d)
5 May 2000 (bzip2, version 1.0pre8)
30 December 2001 (bzip2, version 1.0.2pre1)
15 February 2005 (bzip2, version 1.0.3)
20 December 2006 (bzip2, version 1.0.4)
File diff suppressed because it is too large. Load diff
+429
View File
@@ -0,0 +1,429 @@
/*
* bzip2 is written by Julian Seward <jseward@bzip.org>.
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
* See README and LICENSE files in this directory for more information.
*/
/*-------------------------------------------------------------*/
/*--- Library top-level functions. ---*/
/*--- bzlib.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
/* CHANGES
* 0.9.0 -- original version.
* 0.9.0a/b -- no changes in this file.
* 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress().
* fixed bzWrite/bzRead to ignore zero-length requests.
* fixed bzread to correctly handle read requests after EOF.
* wrong parameter order in call to bzDecompressInit in
* bzBuffToBuffDecompress. Fixed.
*/
/* #include "bzlib_private.h" */
/*---------------------------------------------------*/
/*--- Compression stuff ---*/
/*---------------------------------------------------*/
/*---------------------------------------------------*/
#if BZ_LIGHT_DEBUG
static
void bz_assert_fail(int errcode)
{
/* if (errcode == 1007) bb_error_msg_and_die("probably bad RAM"); */
bb_error_msg_and_die("internal error %d", errcode);
}
#endif
/*---------------------------------------------------*/
static
void prepare_new_block(EState* s)
{
int i;
s->nblock = 0;
s->numZ = 0;
s->state_out_pos = 0;
BZ_INITIALISE_CRC(s->blockCRC);
/* inlined memset would be nice to have here */
for (i = 0; i < 256; i++)
s->inUse[i] = 0;
s->blockNo++;
}
/*---------------------------------------------------*/
static
ALWAYS_INLINE
void init_RL(EState* s)
{
s->state_in_ch = 256;
s->state_in_len = 0;
}
static
int isempty_RL(EState* s)
{
return (s->state_in_ch >= 256 || s->state_in_len <= 0);
}
/*---------------------------------------------------*/
static
void BZ2_bzCompressInit(bz_stream *strm, int blockSize100k)
{
int32_t n;
EState* s;
s = xzalloc(sizeof(EState));
s->strm = strm;
n = 100000 * blockSize100k;
s->arr1 = xmalloc(n * sizeof(uint32_t));
s->mtfv = (uint16_t*)s->arr1;
s->ptr = (uint32_t*)s->arr1;
s->arr2 = xmalloc((n + BZ_N_OVERSHOOT) * sizeof(uint32_t));
s->block = (uint8_t*)s->arr2;
s->ftab = xmalloc(65537 * sizeof(uint32_t));
s->crc32table = crc32_filltable(NULL, 1);
s->state = BZ_S_INPUT;
s->mode = BZ_M_RUNNING;
s->blockSize100k = blockSize100k;
s->nblockMAX = n - 19;
strm->state = s;
/*strm->total_in = 0;*/
strm->total_out = 0;
init_RL(s);
prepare_new_block(s);
}
/*---------------------------------------------------*/
static
void add_pair_to_block(EState* s)
{
int32_t i;
uint8_t ch = (uint8_t)(s->state_in_ch);
for (i = 0; i < s->state_in_len; i++) {
BZ_UPDATE_CRC(s, s->blockCRC, ch);
}
s->inUse[s->state_in_ch] = 1;
switch (s->state_in_len) {
case 3:
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
/* fall through */
case 2:
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
/* fall through */
case 1:
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
break;
default:
s->inUse[s->state_in_len - 4] = 1;
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
s->block[s->nblock] = (uint8_t)(s->state_in_len - 4);
s->nblock++;
break;
}
}
/*---------------------------------------------------*/
static
void flush_RL(EState* s)
{
if (s->state_in_ch < 256) add_pair_to_block(s);
init_RL(s);
}
/*---------------------------------------------------*/
#define ADD_CHAR_TO_BLOCK(zs, zchh0) \
{ \
uint32_t zchh = (uint32_t)(zchh0); \
/*-- fast track the common case --*/ \
if (zchh != zs->state_in_ch && zs->state_in_len == 1) { \
uint8_t ch = (uint8_t)(zs->state_in_ch); \
BZ_UPDATE_CRC(zs, zs->blockCRC, ch); \
zs->inUse[zs->state_in_ch] = 1; \
zs->block[zs->nblock] = (uint8_t)ch; \
zs->nblock++; \
zs->state_in_ch = zchh; \
} \
else \
/*-- general, uncommon cases --*/ \
if (zchh != zs->state_in_ch || zs->state_in_len == 255) { \
if (zs->state_in_ch < 256) \
add_pair_to_block(zs); \
zs->state_in_ch = zchh; \
zs->state_in_len = 1; \
} else { \
zs->state_in_len++; \
} \
}
/*---------------------------------------------------*/
static
void /*Bool*/ copy_input_until_stop(EState* s)
{
/*Bool progress_in = False;*/
#ifdef SAME_CODE_AS_BELOW
if (s->mode == BZ_M_RUNNING) {
/*-- fast track the common case --*/
while (1) {
/*-- no input? --*/
if (s->strm->avail_in == 0) break;
/*-- block full? --*/
if (s->nblock >= s->nblockMAX) break;
/*progress_in = True;*/
ADD_CHAR_TO_BLOCK(s, (uint32_t)(*(uint8_t*)(s->strm->next_in)));
s->strm->next_in++;
s->strm->avail_in--;
/*s->strm->total_in++;*/
}
} else
#endif
{
/*-- general, uncommon case --*/
while (1) {
/*-- no input? --*/
if (s->strm->avail_in == 0) break;
/*-- block full? --*/
if (s->nblock >= s->nblockMAX) break;
//# /*-- flush/finish end? --*/
//# if (s->avail_in_expect == 0) break;
/*progress_in = True;*/
ADD_CHAR_TO_BLOCK(s, *(uint8_t*)(s->strm->next_in));
s->strm->next_in++;
s->strm->avail_in--;
/*s->strm->total_in++;*/
//# s->avail_in_expect--;
}
}
/*return progress_in;*/
}
/*---------------------------------------------------*/
static
void /*Bool*/ copy_output_until_stop(EState* s)
{
/*Bool progress_out = False;*/
while (1) {
/*-- no output space? --*/
if (s->strm->avail_out == 0) break;
/*-- block done? --*/
if (s->state_out_pos >= s->numZ) break;
/*progress_out = True;*/
*(s->strm->next_out) = s->zbits[s->state_out_pos];
s->state_out_pos++;
s->strm->avail_out--;
s->strm->next_out++;
s->strm->total_out++;
}
/*return progress_out;*/
}
/*---------------------------------------------------*/
static
void /*Bool*/ handle_compress(bz_stream *strm)
{
/*Bool progress_in = False;*/
/*Bool progress_out = False;*/
EState* s = strm->state;
while (1) {
if (s->state == BZ_S_OUTPUT) {
/*progress_out |=*/ copy_output_until_stop(s);
if (s->state_out_pos < s->numZ) break;
if (s->mode == BZ_M_FINISHING
//# && s->avail_in_expect == 0
&& s->strm->avail_in == 0
&& isempty_RL(s))
break;
prepare_new_block(s);
s->state = BZ_S_INPUT;
#ifdef FLUSH_IS_UNUSED
if (s->mode == BZ_M_FLUSHING
&& s->avail_in_expect == 0
&& isempty_RL(s))
break;
#endif
}
if (s->state == BZ_S_INPUT) {
/*progress_in |=*/ copy_input_until_stop(s);
//#if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
if (s->mode != BZ_M_RUNNING && s->strm->avail_in == 0) {
flush_RL(s);
BZ2_compressBlock(s, (s->mode == BZ_M_FINISHING));
s->state = BZ_S_OUTPUT;
} else
if (s->nblock >= s->nblockMAX) {
BZ2_compressBlock(s, 0);
s->state = BZ_S_OUTPUT;
} else
if (s->strm->avail_in == 0) {
break;
}
}
}
/*return progress_in || progress_out;*/
}
/*---------------------------------------------------*/
static
int BZ2_bzCompress(bz_stream *strm, int action)
{
/*Bool progress;*/
EState* s;
s = strm->state;
switch (s->mode) {
case BZ_M_RUNNING:
if (action == BZ_RUN) {
/*progress =*/ handle_compress(strm);
/*return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;*/
return BZ_RUN_OK;
}
#ifdef FLUSH_IS_UNUSED
else
if (action == BZ_FLUSH) {
//#s->avail_in_expect = strm->avail_in;
s->mode = BZ_M_FLUSHING;
goto case_BZ_M_FLUSHING;
}
#endif
else
/*if (action == BZ_FINISH)*/ {
//#s->avail_in_expect = strm->avail_in;
s->mode = BZ_M_FINISHING;
goto case_BZ_M_FINISHING;
}
#ifdef FLUSH_IS_UNUSED
case_BZ_M_FLUSHING:
case BZ_M_FLUSHING:
/*if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR;*/
/*progress =*/ handle_compress(strm);
if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ)
return BZ_FLUSH_OK;
s->mode = BZ_M_RUNNING;
return BZ_RUN_OK;
#endif
case_BZ_M_FINISHING:
/*case BZ_M_FINISHING:*/
default:
/*if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR;*/
/*progress =*/ handle_compress(strm);
/*if (!progress) return BZ_SEQUENCE_ERROR;*/
//#if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ)
//# return BZ_FINISH_OK;
if (s->strm->avail_in > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ)
return BZ_FINISH_OK;
/*s->mode = BZ_M_IDLE;*/
return BZ_STREAM_END;
}
/* return BZ_OK; --not reached--*/
}
/*---------------------------------------------------*/
#if ENABLE_FEATURE_CLEAN_UP
static
void BZ2_bzCompressEnd(bz_stream *strm)
{
EState* s;
s = strm->state;
free(s->arr1);
free(s->arr2);
free(s->ftab);
free(s->crc32table);
free(strm->state);
}
#endif
/*---------------------------------------------------*/
/*--- Misc convenience stuff ---*/
/*---------------------------------------------------*/
/*---------------------------------------------------*/
#ifdef EXAMPLE_CODE_FOR_MEM_TO_MEM_COMPRESSION
static
int BZ2_bzBuffToBuffCompress(char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int blockSize100k)
{
bz_stream strm;
int ret;
if (dest == NULL || destLen == NULL ||
source == NULL ||
blockSize100k < 1 || blockSize100k > 9)
return BZ_PARAM_ERROR;
BZ2_bzCompressInit(&strm, blockSize100k);
strm.next_in = source;
strm.next_out = dest;
strm.avail_in = sourceLen;
strm.avail_out = *destLen;
ret = BZ2_bzCompress(&strm, BZ_FINISH);
if (ret == BZ_FINISH_OK) goto output_overflow;
if (ret != BZ_STREAM_END) goto errhandler;
/* normal termination */
*destLen -= strm.avail_out;
BZ2_bzCompressEnd(&strm);
return BZ_OK;
output_overflow:
BZ2_bzCompressEnd(&strm);
return BZ_OUTBUFF_FULL;
errhandler:
BZ2_bzCompressEnd(&strm);
return ret;
}
#endif
/*-------------------------------------------------------------*/
/*--- end bzlib.c ---*/
/*-------------------------------------------------------------*/
+65
View File
@@ -0,0 +1,65 @@
/*
* bzip2 is written by Julian Seward <jseward@bzip.org>.
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
* See README and LICENSE files in this directory for more information.
*/
/*-------------------------------------------------------------*/
/*--- Public header file for the library. ---*/
/*--- bzlib.h ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
#define BZ_OK 0
#define BZ_RUN_OK 1
#define BZ_FLUSH_OK 2
#define BZ_FINISH_OK 3
#define BZ_STREAM_END 4
#define BZ_SEQUENCE_ERROR (-1)
#define BZ_PARAM_ERROR (-2)
#define BZ_MEM_ERROR (-3)
#define BZ_DATA_ERROR (-4)
#define BZ_DATA_ERROR_MAGIC (-5)
#define BZ_IO_ERROR (-6)
#define BZ_UNEXPECTED_EOF (-7)
#define BZ_OUTBUFF_FULL (-8)
#define BZ_CONFIG_ERROR (-9)
typedef struct bz_stream {
void *state;
char *next_in;
char *next_out;
unsigned avail_in;
unsigned avail_out;
/*unsigned long long total_in;*/
unsigned long long total_out;
} bz_stream;
/*-- Core (low-level) library functions --*/
static void BZ2_bzCompressInit(bz_stream *strm, int blockSize100k);
static int BZ2_bzCompress(bz_stream *strm, int action);
#if ENABLE_FEATURE_CLEAN_UP
static void BZ2_bzCompressEnd(bz_stream *strm);
#endif
/*-------------------------------------------------------------*/
/*--- end bzlib.h ---*/
/*-------------------------------------------------------------*/
+219
View File
@@ -0,0 +1,219 @@
/*
* bzip2 is written by Julian Seward <jseward@bzip.org>.
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
* See README and LICENSE files in this directory for more information.
*/
/*-------------------------------------------------------------*/
/*--- Private header file for the library. ---*/
/*--- bzlib_private.h ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
/* #include "bzlib.h" */
/*-- General stuff. --*/
typedef unsigned char Bool;
#define True ((Bool)1)
#define False ((Bool)0)
#if BZ_LIGHT_DEBUG
static void bz_assert_fail(int errcode) NORETURN;
#define AssertH(cond, errcode) \
do { \
if (!(cond)) \
bz_assert_fail(errcode); \
} while (0)
#else
#define AssertH(cond, msg) do { } while (0)
#endif
#if BZ_DEBUG
#define AssertD(cond, msg) \
do { \
if (!(cond)) \
bb_error_msg_and_die("(debug build): internal error %s", msg); \
} while (0)
#else
#define AssertD(cond, msg) do { } while (0)
#endif
/*-- Header bytes. --*/
#define BZ_HDR_B 0x42 /* 'B' */
#define BZ_HDR_Z 0x5a /* 'Z' */
#define BZ_HDR_h 0x68 /* 'h' */
#define BZ_HDR_0 0x30 /* '0' */
#define BZ_HDR_BZh0 0x425a6830
/*-- Constants for the back end. --*/
#define BZ_MAX_ALPHA_SIZE 258
#define BZ_MAX_CODE_LEN 23
#define BZ_RUNA 0
#define BZ_RUNB 1
#define BZ_N_GROUPS 6
#define BZ_G_SIZE 50
#define BZ_N_ITERS 4
#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
/*-- Stuff for doing CRCs. --*/
#define BZ_INITIALISE_CRC(crcVar) \
{ \
crcVar = 0xffffffffL; \
}
#define BZ_FINALISE_CRC(crcVar) \
{ \
crcVar = ~(crcVar); \
}
#define BZ_UPDATE_CRC(s, crcVar, cha) \
{ \
crcVar = (crcVar << 8) ^ s->crc32table[(crcVar >> 24) ^ ((uint8_t)cha)]; \
}
/*-- States and modes for compression. --*/
#define BZ_M_IDLE 1
#define BZ_M_RUNNING 2
#define BZ_M_FLUSHING 3
#define BZ_M_FINISHING 4
#define BZ_S_OUTPUT 1
#define BZ_S_INPUT 2
#define BZ_N_RADIX 2
#define BZ_N_QSORT 12
#define BZ_N_SHELL 18
#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
/*-- Structure holding all the compression-side stuff. --*/
typedef struct EState {
/* pointer back to the struct bz_stream */
bz_stream *strm;
/* mode this stream is in, and whether inputting */
/* or outputting data */
int32_t mode;
int32_t state;
/* remembers avail_in when flush/finish requested */
/* bbox: not needed, strm->avail_in always has the same value */
/* commented out with '//#' throughout the code */
/* uint32_t avail_in_expect; */
/* for doing the block sorting */
int32_t origPtr;
uint32_t *arr1;
uint32_t *arr2;
uint32_t *ftab;
/* aliases for arr1 and arr2 */
uint32_t *ptr;
uint8_t *block;
uint16_t *mtfv;
uint8_t *zbits;
/* guess what */
uint32_t *crc32table;
/* run-length-encoding of the input */
uint32_t state_in_ch;
int32_t state_in_len;
/* input and output limits and current posns */
int32_t nblock;
int32_t nblockMAX;
int32_t numZ;
int32_t state_out_pos;
/* the buffer for bit stream creation */
uint32_t bsBuff;
int32_t bsLive;
/* block and combined CRCs */
uint32_t blockCRC;
uint32_t combinedCRC;
/* misc administratium */
int32_t blockNo;
int32_t blockSize100k;
/* stuff for coding the MTF values */
int32_t nMTF;
/* map of bytes used in block */
int32_t nInUse;
Bool inUse[256] ALIGNED(sizeof(long));
uint8_t unseqToSeq[256];
/* stuff for coding the MTF values */
int32_t mtfFreq [BZ_MAX_ALPHA_SIZE];
uint8_t selector [BZ_MAX_SELECTORS];
uint8_t selectorMtf[BZ_MAX_SELECTORS];
uint8_t len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
/* stack-saving measures: these can be local, but they are too big */
int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
/* second dimension: only 3 needed; 4 makes index calculations faster */
uint32_t sendMTFValues__len_pack[BZ_MAX_ALPHA_SIZE][4];
#endif
int32_t BZ2_hbMakeCodeLengths__heap [BZ_MAX_ALPHA_SIZE + 2];
int32_t BZ2_hbMakeCodeLengths__weight[BZ_MAX_ALPHA_SIZE * 2];
int32_t BZ2_hbMakeCodeLengths__parent[BZ_MAX_ALPHA_SIZE * 2];
int32_t mainSort__runningOrder[256];
int32_t mainSort__copyStart[256];
int32_t mainSort__copyEnd[256];
} EState;
/*-- compression. --*/
static void
BZ2_blockSort(EState*);
static void
BZ2_compressBlock(EState*, int);
static void
BZ2_bsInitWrite(EState*);
static void
BZ2_hbAssignCodes(int32_t*, uint8_t*, int32_t, int32_t, int32_t);
static void
BZ2_hbMakeCodeLengths(EState*, uint8_t*, int32_t*, int32_t, int32_t);
/*-------------------------------------------------------------*/
/*--- end bzlib_private.h ---*/
/*-------------------------------------------------------------*/
+687
View File
@@ -0,0 +1,687 @@
/*
* bzip2 is written by Julian Seward <jseward@bzip.org>.
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
* See README and LICENSE files in this directory for more information.
*/
/*-------------------------------------------------------------*/
/*--- Compression machinery (not incl block sorting) ---*/
/*--- compress.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
/* CHANGES
* 0.9.0 -- original version.
* 0.9.0a/b -- no changes in this file.
* 0.9.0c -- changed setting of nGroups in sendMTFValues()
* so as to do a bit better on small files
*/
/* #include "bzlib_private.h" */
/*---------------------------------------------------*/
/*--- Bit stream I/O ---*/
/*---------------------------------------------------*/
/*---------------------------------------------------*/
static
void BZ2_bsInitWrite(EState* s)
{
s->bsLive = 0;
s->bsBuff = 0;
}
/*---------------------------------------------------*/
static NOINLINE
void bsFinishWrite(EState* s)
{
while (s->bsLive > 0) {
s->zbits[s->numZ] = (uint8_t)(s->bsBuff >> 24);
s->numZ++;
s->bsBuff <<= 8;
s->bsLive -= 8;
}
}
/*---------------------------------------------------*/
static
/* Helps only on level 5, on other levels hurts. ? */
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
ALWAYS_INLINE
#endif
void bsW(EState* s, int32_t n, uint32_t v)
{
while (s->bsLive >= 8) {
s->zbits[s->numZ] = (uint8_t)(s->bsBuff >> 24);
s->numZ++;
s->bsBuff <<= 8;
s->bsLive -= 8;
}
s->bsBuff |= (v << (32 - s->bsLive - n));
s->bsLive += n;
}
/*---------------------------------------------------*/
static
void bsPutU32(EState* s, unsigned u)
{
bsW(s, 8, (u >> 24) & 0xff);
bsW(s, 8, (u >> 16) & 0xff);
bsW(s, 8, (u >> 8) & 0xff);
bsW(s, 8, u & 0xff);
}
/*---------------------------------------------------*/
static
void bsPutU16(EState* s, unsigned u)
{
bsW(s, 8, (u >> 8) & 0xff);
bsW(s, 8, u & 0xff);
}
/*---------------------------------------------------*/
/*--- The back end proper ---*/
/*---------------------------------------------------*/
/*---------------------------------------------------*/
static
void makeMaps_e(EState* s)
{
int i;
s->nInUse = 0;
for (i = 0; i < 256; i++) {
if (s->inUse[i]) {
s->unseqToSeq[i] = s->nInUse;
s->nInUse++;
}
}
}
/*---------------------------------------------------*/
static NOINLINE
void generateMTFValues(EState* s)
{
uint8_t yy[256];
int32_t i, j;
int32_t zPend;
int32_t wr;
int32_t EOB;
/*
* After sorting (eg, here),
* s->arr1[0 .. s->nblock-1] holds sorted order,
* and
* ((uint8_t*)s->arr2)[0 .. s->nblock-1]
* holds the original block data.
*
* The first thing to do is generate the MTF values,
* and put them in
* ((uint16_t*)s->arr1)[0 .. s->nblock-1].
* Because there are strictly fewer or equal MTF values
* than block values, ptr values in this area are overwritten
* with MTF values only when they are no longer needed.
*
* The final compressed bitstream is generated into the
* area starting at
* &((uint8_t*)s->arr2)[s->nblock]
*
* These storage aliases are set up in bzCompressInit(),
* except for the last one, which is arranged in
* compressBlock().
*/
uint32_t* ptr = s->ptr;
uint8_t* block = s->block;
uint16_t* mtfv = s->mtfv;
makeMaps_e(s);
EOB = s->nInUse+1;
for (i = 0; i <= EOB; i++)
s->mtfFreq[i] = 0;
wr = 0;
zPend = 0;
for (i = 0; i < s->nInUse; i++)
yy[i] = (uint8_t) i;
for (i = 0; i < s->nblock; i++) {
uint8_t ll_i;
AssertD(wr <= i, "generateMTFValues(1)");
j = ptr[i] - 1;
if (j < 0)
j += s->nblock;
ll_i = s->unseqToSeq[block[j]];
AssertD(ll_i < s->nInUse, "generateMTFValues(2a)");
if (yy[0] == ll_i) {
zPend++;
} else {
if (zPend > 0) {
zPend--;
while (1) {
if (zPend & 1) {
mtfv[wr] = BZ_RUNB; wr++;
s->mtfFreq[BZ_RUNB]++;
} else {
mtfv[wr] = BZ_RUNA; wr++;
s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2) break;
zPend = (uint32_t)(zPend - 2) / 2;
/* bbox: unsigned div is easier */
};
zPend = 0;
}
{
register uint8_t rtmp;
register uint8_t* ryy_j;
register uint8_t rll_i;
rtmp = yy[1];
yy[1] = yy[0];
ryy_j = &(yy[1]);
rll_i = ll_i;
while (rll_i != rtmp) {
register uint8_t rtmp2;
ryy_j++;
rtmp2 = rtmp;
rtmp = *ryy_j;
*ryy_j = rtmp2;
};
yy[0] = rtmp;
j = ryy_j - &(yy[0]);
mtfv[wr] = j+1;
wr++;
s->mtfFreq[j+1]++;
}
}
}
if (zPend > 0) {
zPend--;
while (1) {
if (zPend & 1) {
mtfv[wr] = BZ_RUNB;
wr++;
s->mtfFreq[BZ_RUNB]++;
} else {
mtfv[wr] = BZ_RUNA;
wr++;
s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2)
break;
zPend = (uint32_t)(zPend - 2) / 2;
/* bbox: unsigned div is easier */
};
zPend = 0;
}
mtfv[wr] = EOB;
wr++;
s->mtfFreq[EOB]++;
s->nMTF = wr;
}
/*---------------------------------------------------*/
#define BZ_LESSER_ICOST 0
#define BZ_GREATER_ICOST 15
static NOINLINE
void sendMTFValues(EState* s)
{
int32_t v, t, i, j, gs, ge, totc, bt, bc, iter;
int32_t nSelectors, alphaSize, minLen, maxLen, selCtr;
int32_t nGroups, nBytes;
/*
* uint8_t len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
* is a global since the decoder also needs it.
*
* int32_t code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
* int32_t rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
* are also globals only used in this proc.
* Made global to keep stack frame size small.
*/
#define code sendMTFValues__code
#define rfreq sendMTFValues__rfreq
#define len_pack sendMTFValues__len_pack
uint16_t cost[BZ_N_GROUPS];
int32_t fave[BZ_N_GROUPS];
uint16_t* mtfv = s->mtfv;
alphaSize = s->nInUse + 2;
for (t = 0; t < BZ_N_GROUPS; t++)
for (v = 0; v < alphaSize; v++)
s->len[t][v] = BZ_GREATER_ICOST;
/*--- Decide how many coding tables to use ---*/
AssertH(s->nMTF > 0, 3001);
if (s->nMTF < 200) nGroups = 2; else
if (s->nMTF < 600) nGroups = 3; else
if (s->nMTF < 1200) nGroups = 4; else
if (s->nMTF < 2400) nGroups = 5; else
nGroups = 6;
/*--- Generate an initial set of coding tables ---*/
{
int32_t nPart, remF, tFreq, aFreq;
nPart = nGroups;
remF = s->nMTF;
gs = 0;
while (nPart > 0) {
tFreq = remF / nPart;
ge = gs - 1;
aFreq = 0;
while (aFreq < tFreq && ge < alphaSize-1) {
ge++;
aFreq += s->mtfFreq[ge];
}
if (ge > gs
&& nPart != nGroups && nPart != 1
&& ((nGroups - nPart) % 2 == 1) /* bbox: can this be replaced by x & 1? */
) {
aFreq -= s->mtfFreq[ge];
ge--;
}
for (v = 0; v < alphaSize; v++)
if (v >= gs && v <= ge)
s->len[nPart-1][v] = BZ_LESSER_ICOST;
else
s->len[nPart-1][v] = BZ_GREATER_ICOST;
nPart--;
gs = ge + 1;
remF -= aFreq;
}
}
/*
* Iterate up to BZ_N_ITERS times to improve the tables.
*/
for (iter = 0; iter < BZ_N_ITERS; iter++) {
for (t = 0; t < nGroups; t++)
fave[t] = 0;
for (t = 0; t < nGroups; t++)
for (v = 0; v < alphaSize; v++)
s->rfreq[t][v] = 0;
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
/*
* Set up an auxiliary length table which is used to fast-track
* the common case (nGroups == 6).
*/
if (nGroups == 6) {
for (v = 0; v < alphaSize; v++) {
s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
}
}
#endif
nSelectors = 0;
totc = 0;
gs = 0;
while (1) {
/*--- Set group start & end marks. --*/
if (gs >= s->nMTF)
break;
ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF)
ge = s->nMTF-1;
/*
* Calculate the cost of this group as coded
* by each of the coding tables.
*/
for (t = 0; t < nGroups; t++)
cost[t] = 0;
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
register uint32_t cost01, cost23, cost45;
register uint16_t icv;
cost01 = cost23 = cost45 = 0;
#define BZ_ITER(nn) \
icv = mtfv[gs+(nn)]; \
cost01 += s->len_pack[icv][0]; \
cost23 += s->len_pack[icv][1]; \
cost45 += s->len_pack[icv][2];
BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4);
BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9);
BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14);
BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19);
BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24);
BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29);
BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34);
BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39);
BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44);
BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49);
#undef BZ_ITER
cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
} else
#endif
{
/*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) {
uint16_t icv = mtfv[i];
for (t = 0; t < nGroups; t++)
cost[t] += s->len[t][icv];
}
}
/*
* Find the coding table which is best for this group,
* and record its identity in the selector table.
*/
/*bc = 999999999;*/
/*bt = -1;*/
bc = cost[0];
bt = 0;
for (t = 1 /*0*/; t < nGroups; t++) {
if (cost[t] < bc) {
bc = cost[t];
bt = t;
}
}
totc += bc;
fave[bt]++;
s->selector[nSelectors] = bt;
nSelectors++;
/*
* Increment the symbol frequencies for the selected table.
*/
/* 1% faster compress. +800 bytes */
#if CONFIG_BZIP2_FEATURE_SPEED >= 4
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
#define BZ_ITUR(nn) s->rfreq[bt][mtfv[gs + (nn)]]++
BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4);
BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9);
BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14);
BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19);
BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24);
BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29);
BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34);
BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39);
BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44);
BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49);
#undef BZ_ITUR
gs = ge + 1;
} else
#endif
{
/*--- slow version which correctly handles all situations ---*/
while (gs <= ge) {
s->rfreq[bt][mtfv[gs]]++;
gs++;
}
/* already is: gs = ge + 1; */
}
}
/*
* Recompute the tables based on the accumulated frequencies.
*/
/* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
* comment in huffman.c for details. */
for (t = 0; t < nGroups; t++)
BZ2_hbMakeCodeLengths(s, &(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 17 /*20*/);
}
AssertH(nGroups < 8, 3002);
AssertH(nSelectors < 32768 && nSelectors <= (2 + (900000 / BZ_G_SIZE)), 3003);
/*--- Compute MTF values for the selectors. ---*/
{
uint8_t pos[BZ_N_GROUPS], ll_i, tmp2, tmp;
for (i = 0; i < nGroups; i++)
pos[i] = i;
for (i = 0; i < nSelectors; i++) {
ll_i = s->selector[i];
j = 0;
tmp = pos[j];
while (ll_i != tmp) {
j++;
tmp2 = tmp;
tmp = pos[j];
pos[j] = tmp2;
};
pos[0] = tmp;
s->selectorMtf[i] = j;
}
};
/*--- Assign actual codes for the tables. --*/
for (t = 0; t < nGroups; t++) {
minLen = 32;
maxLen = 0;
for (i = 0; i < alphaSize; i++) {
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
if (s->len[t][i] < minLen) minLen = s->len[t][i];
}
AssertH(!(maxLen > 17 /*20*/), 3004);
AssertH(!(minLen < 1), 3005);
BZ2_hbAssignCodes(&(s->code[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize);
}
/*--- Transmit the mapping table. ---*/
{
/* bbox: optimized a bit more than in bzip2 */
int inUse16 = 0;
for (i = 0; i < 16; i++) {
if (sizeof(long) <= 4) {
inUse16 = inUse16*2 +
((*(uint32_t*)&(s->inUse[i * 16 + 0])
| *(uint32_t*)&(s->inUse[i * 16 + 4])
| *(uint32_t*)&(s->inUse[i * 16 + 8])
| *(uint32_t*)&(s->inUse[i * 16 + 12])) != 0);
} else { /* Our CPU can do better */
inUse16 = inUse16*2 +
((*(uint64_t*)&(s->inUse[i * 16 + 0])
| *(uint64_t*)&(s->inUse[i * 16 + 8])) != 0);
}
}
nBytes = s->numZ;
bsW(s, 16, inUse16);
inUse16 <<= (sizeof(int)*8 - 16); /* move 15th bit into sign bit */
for (i = 0; i < 16; i++) {
if (inUse16 < 0) {
unsigned v16 = 0;
for (j = 0; j < 16; j++)
v16 = v16*2 + s->inUse[i * 16 + j];
bsW(s, 16, v16);
}
inUse16 <<= 1;
}
}
/*--- Now the selectors. ---*/
nBytes = s->numZ;
bsW(s, 3, nGroups);
bsW(s, 15, nSelectors);
for (i = 0; i < nSelectors; i++) {
for (j = 0; j < s->selectorMtf[i]; j++)
bsW(s, 1, 1);
bsW(s, 1, 0);
}
/*--- Now the coding tables. ---*/
nBytes = s->numZ;
for (t = 0; t < nGroups; t++) {
int32_t curr = s->len[t][0];
bsW(s, 5, curr);
for (i = 0; i < alphaSize; i++) {
while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ };
while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ };
bsW(s, 1, 0);
}
}
/*--- And finally, the block data proper ---*/
nBytes = s->numZ;
selCtr = 0;
gs = 0;
while (1) {
if (gs >= s->nMTF)
break;
ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF)
ge = s->nMTF-1;
AssertH(s->selector[selCtr] < nGroups, 3006);
/* Costs 1300 bytes and is _slower_ (on Intel Core 2) */
#if 0
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
uint16_t mtfv_i;
uint8_t* s_len_sel_selCtr = &(s->len[s->selector[selCtr]][0]);
int32_t* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]);
#define BZ_ITAH(nn) \
mtfv_i = mtfv[gs+(nn)]; \
bsW(s, s_len_sel_selCtr[mtfv_i], s_code_sel_selCtr[mtfv_i])
BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4);
BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9);
BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14);
BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19);
BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24);
BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29);
BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34);
BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39);
BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44);
BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49);
#undef BZ_ITAH
gs = ge+1;
} else
#endif
{
/*--- slow version which correctly handles all situations ---*/
/* code is bit bigger, but moves multiply out of the loop */
uint8_t* s_len_sel_selCtr = &(s->len [s->selector[selCtr]][0]);
int32_t* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]);
while (gs <= ge) {
bsW(s,
s_len_sel_selCtr[mtfv[gs]],
s_code_sel_selCtr[mtfv[gs]]
);
gs++;
}
/* already is: gs = ge+1; */
}
selCtr++;
}
AssertH(selCtr == nSelectors, 3007);
#undef code
#undef rfreq
#undef len_pack
}
/*---------------------------------------------------*/
static
void BZ2_compressBlock(EState* s, int is_last_block)
{
if (s->nblock > 0) {
BZ_FINALISE_CRC(s->blockCRC);
s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
s->combinedCRC ^= s->blockCRC;
if (s->blockNo > 1)
s->numZ = 0;
BZ2_blockSort(s);
}
s->zbits = &((uint8_t*)s->arr2)[s->nblock];
/*-- If this is the first block, create the stream header. --*/
if (s->blockNo == 1) {
BZ2_bsInitWrite(s);
/*bsPutU8(s, BZ_HDR_B);*/
/*bsPutU8(s, BZ_HDR_Z);*/
/*bsPutU8(s, BZ_HDR_h);*/
/*bsPutU8(s, BZ_HDR_0 + s->blockSize100k);*/
bsPutU32(s, BZ_HDR_BZh0 + s->blockSize100k);
}
if (s->nblock > 0) {
/*bsPutU8(s, 0x31);*/
/*bsPutU8(s, 0x41);*/
/*bsPutU8(s, 0x59);*/
/*bsPutU8(s, 0x26);*/
bsPutU32(s, 0x31415926);
/*bsPutU8(s, 0x53);*/
/*bsPutU8(s, 0x59);*/
bsPutU16(s, 0x5359);
/*-- Now the block's CRC, so it is in a known place. --*/
bsPutU32(s, s->blockCRC);
/*
* Now a single bit indicating (non-)randomisation.
* As of version 0.9.5, we use a better sorting algorithm
* which makes randomisation unnecessary. So always set
* the randomised bit to 'no'. Of course, the decoder
* still needs to be able to handle randomised blocks
* so as to maintain backwards compatibility with
* older versions of bzip2.
*/
bsW(s, 1, 0);
bsW(s, 24, s->origPtr);
generateMTFValues(s);
sendMTFValues(s);
}
/*-- If this is the last block, add the stream trailer. --*/
if (is_last_block) {
/*bsPutU8(s, 0x17);*/
/*bsPutU8(s, 0x72);*/
/*bsPutU8(s, 0x45);*/
/*bsPutU8(s, 0x38);*/
bsPutU32(s, 0x17724538);
/*bsPutU8(s, 0x50);*/
/*bsPutU8(s, 0x90);*/
bsPutU16(s, 0x5090);
bsPutU32(s, s->combinedCRC);
bsFinishWrite(s);
}
}
/*-------------------------------------------------------------*/
/*--- end compress.c ---*/
/*-------------------------------------------------------------*/
+229
View File
@@ -0,0 +1,229 @@
/*
* bzip2 is written by Julian Seward <jseward@bzip.org>.
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
* See README and LICENSE files in this directory for more information.
*/
/*-------------------------------------------------------------*/
/*--- Huffman coding low-level stuff ---*/
/*--- huffman.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
/* #include "bzlib_private.h" */
/*---------------------------------------------------*/
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
#define ADDWEIGHTS(zw1,zw2) \
(WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \
(1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
#define UPHEAP(z) \
{ \
int32_t zz, tmp; \
zz = z; \
tmp = heap[zz]; \
while (weight[tmp] < weight[heap[zz >> 1]]) { \
heap[zz] = heap[zz >> 1]; \
zz >>= 1; \
} \
heap[zz] = tmp; \
}
/* 90 bytes, 0.3% of overall compress speed */
#if CONFIG_BZIP2_FEATURE_SPEED >= 1
/* macro works better than inline (gcc 4.2.1) */
#define DOWNHEAP1(heap, weight, Heap) \
{ \
int32_t zz, yy, tmp; \
zz = 1; \
tmp = heap[zz]; \
while (1) { \
yy = zz << 1; \
if (yy > nHeap) \
break; \
if (yy < nHeap \
&& weight[heap[yy+1]] < weight[heap[yy]]) \
yy++; \
if (weight[tmp] < weight[heap[yy]]) \
break; \
heap[zz] = heap[yy]; \
zz = yy; \
} \
heap[zz] = tmp; \
}
#else
static
void DOWNHEAP1(int32_t *heap, int32_t *weight, int32_t nHeap)
{
int32_t zz, yy, tmp;
zz = 1;
tmp = heap[zz];
while (1) {
yy = zz << 1;
if (yy > nHeap)
break;
if (yy < nHeap
&& weight[heap[yy + 1]] < weight[heap[yy]])
yy++;
if (weight[tmp] < weight[heap[yy]])
break;
heap[zz] = heap[yy];
zz = yy;
}
heap[zz] = tmp;
}
#endif
/*---------------------------------------------------*/
static
void BZ2_hbMakeCodeLengths(EState *s,
uint8_t *len,
int32_t *freq,
int32_t alphaSize,
int32_t maxLen)
{
/*
* Nodes and heap entries run from 1. Entry 0
* for both the heap and nodes is a sentinel.
*/
int32_t nNodes, nHeap, n1, n2, i, j, k;
Bool tooLong;
/* bbox: moved to EState to save stack
int32_t heap [BZ_MAX_ALPHA_SIZE + 2];
int32_t weight[BZ_MAX_ALPHA_SIZE * 2];
int32_t parent[BZ_MAX_ALPHA_SIZE * 2];
*/
#define heap (s->BZ2_hbMakeCodeLengths__heap)
#define weight (s->BZ2_hbMakeCodeLengths__weight)
#define parent (s->BZ2_hbMakeCodeLengths__parent)
for (i = 0; i < alphaSize; i++)
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
while (1) {
nNodes = alphaSize;
nHeap = 0;
heap[0] = 0;
weight[0] = 0;
parent[0] = -2;
for (i = 1; i <= alphaSize; i++) {
parent[i] = -1;
nHeap++;
heap[nHeap] = i;
UPHEAP(nHeap);
}
AssertH(nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001);
while (nHeap > 1) {
n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP1(heap, weight, nHeap);
n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP1(heap, weight, nHeap);
nNodes++;
parent[n1] = parent[n2] = nNodes;
weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
parent[nNodes] = -1;
nHeap++;
heap[nHeap] = nNodes;
UPHEAP(nHeap);
}
AssertH(nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002);
tooLong = False;
for (i = 1; i <= alphaSize; i++) {
j = 0;
k = i;
while (parent[k] >= 0) {
k = parent[k];
j++;
}
len[i-1] = j;
if (j > maxLen)
tooLong = True;
}
if (!tooLong)
break;
/* 17 Oct 04: keep-going condition for the following loop used
to be 'i < alphaSize', which missed the last element,
theoretically leading to the possibility of the compressor
looping. However, this count-scaling step is only needed if
one of the generated Huffman code words is longer than
maxLen, which up to and including version 1.0.2 was 20 bits,
which is extremely unlikely. In version 1.0.3 maxLen was
changed to 17 bits, which has minimal effect on compression
ratio, but does mean this scaling step is used from time to
time, enough to verify that it works.
This means that bzip2-1.0.3 and later will only produce
Huffman codes with a maximum length of 17 bits. However, in
order to preserve backwards compatibility with bitstreams
produced by versions pre-1.0.3, the decompressor must still
handle lengths of up to 20. */
for (i = 1; i <= alphaSize; i++) {
j = weight[i] >> 8;
/* bbox: yes, it is a signed division.
* don't replace with shift! */
j = 1 + (j / 2);
weight[i] = j << 8;
}
}
#undef heap
#undef weight
#undef parent
}
/*---------------------------------------------------*/
static
void BZ2_hbAssignCodes(int32_t *code,
uint8_t *length,
int32_t minLen,
int32_t maxLen,
int32_t alphaSize)
{
int32_t n, vec, i;
vec = 0;
for (n = minLen; n <= maxLen; n++) {
for (i = 0; i < alphaSize; i++) {
if (length[i] == n) {
code[i] = vec;
vec++;
};
}
vec <<= 1;
}
}
/*-------------------------------------------------------------*/
/*--- end huffman.c ---*/
/*-------------------------------------------------------------*/
+184
View File
@@ -0,0 +1,184 @@
/*
* Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
*
* This file uses bzip2 library code which is written
* by Julian Seward <jseward@bzip.org>.
* See README and LICENSE files in bz/ directory for more information
* about bzip2 library code.
*/
#include "libbb.h"
#define CONFIG_BZIP2_FEATURE_SPEED 1
/* Speed test:
* Compiled with gcc 4.2.1, run on Athlon 64 1800 MHz (512K L2 cache).
* Stock bzip2 is 26.4% slower than bbox bzip2 at SPEED 1
* (time to compress gcc-4.2.1.tar is 126.4% compared to bbox).
* At SPEED 5 difference is 32.7%.
*
* Test run of all CONFIG_BZIP2_FEATURE_SPEED values on a 11Mb text file:
* Size Time (3 runs)
* 0: 10828 4.145 4.146 4.148
* 1: 11097 3.845 3.860 3.861
* 2: 11392 3.763 3.767 3.768
* 3: 11892 3.722 3.724 3.727
* 4: 12740 3.637 3.640 3.644
* 5: 17273 3.497 3.509 3.509
*/
#define BZ_DEBUG 0
/* Takes ~300 bytes, detects corruption caused by bad RAM etc */
#define BZ_LIGHT_DEBUG 0
#include "bz/bzlib.h"
#include "bz/bzlib_private.h"
#include "bz/blocksort.c"
#include "bz/bzlib.c"
#include "bz/compress.c"
#include "bz/huffman.c"
/* No point in being shy and having very small buffer here.
* bzip2 internal buffers are much bigger anyway, hundreds of kbytes.
* If iobuf is several pages long, malloc() may use mmap,
* making iobuf is page aligned and thus (maybe) have one memcpy less
* if kernel is clever enough.
*/
enum {
IOBUF_SIZE = 8 * 1024
};
static uint8_t level;
/* NB: compressStream() has to return -1 on errors, not die.
* bbunpack() will correctly clean up in this case
* (delete incomplete .bz2 file)
*/
/* Returns:
* -1 on errors
* total written bytes so far otherwise
*/
static
USE_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, void *wbuf)
{
int n, n2, ret;
strm->avail_in = rlen;
strm->next_in = rbuf;
while (1) {
strm->avail_out = IOBUF_SIZE;
strm->next_out = wbuf;
ret = BZ2_bzCompress(strm, rlen ? BZ_RUN : BZ_FINISH);
if (ret != BZ_RUN_OK /* BZ_RUNning */
&& ret != BZ_FINISH_OK /* BZ_FINISHing, but not done yet */
&& ret != BZ_STREAM_END /* BZ_FINISHed */
) {
bb_error_msg_and_die("internal error %d", ret);
}
n = IOBUF_SIZE - strm->avail_out;
if (n) {
n2 = full_write(STDOUT_FILENO, wbuf, n);
if (n2 != n) {
if (n2 >= 0)
errno = 0; /* prevent bogus error message */
bb_perror_msg(n2 >= 0 ? "short write" : "write error");
return -1;
}
}
if (ret == BZ_STREAM_END)
break;
if (rlen && strm->avail_in == 0)
break;
}
return 0 USE_DESKTOP( + strm->total_out );
}
static
USE_DESKTOP(long long) int compressStream(void)
{
USE_DESKTOP(long long) int total;
ssize_t count;
bz_stream bzs; /* it's small */
#define strm (&bzs)
char *iobuf;
#define rbuf iobuf
#define wbuf (iobuf + IOBUF_SIZE)
iobuf = xmalloc(2 * IOBUF_SIZE);
BZ2_bzCompressInit(strm, level);
while (1) {
count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE);
if (count < 0) {
bb_perror_msg("read error");
total = -1;
break;
}
/* if count == 0, bz_write finalizes compression */
total = bz_write(strm, rbuf, count, wbuf);
if (count == 0 || total < 0)
break;
}
#if ENABLE_FEATURE_CLEAN_UP
BZ2_bzCompressEnd(strm);
free(iobuf);
#endif
return total;
}
static
char* make_new_name_bzip2(char *filename)
{
return xasprintf("%s.bz2", filename);
}
int bzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bzip2_main(int argc UNUSED_PARAM, char **argv)
{
unsigned opt;
/* standard bzip2 flags
* -d --decompress force decompression
* -z --compress force compression
* -k --keep keep (don't delete) input files
* -f --force overwrite existing output files
* -t --test test compressed file integrity
* -c --stdout output to standard out
* -q --quiet suppress noncritical error messages
* -v --verbose be verbose (a 2nd -v gives more)
* -s --small use less memory (at most 2500k)
* -1 .. -9 set block size to 100k .. 900k
* --fast alias for -1
* --best alias for -9
*/
opt_complementary = "s2"; /* -s means -2 (compatibility) */
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argv, "cfv" USE_BUNZIP2("dt") "123456789qzs");
#if ENABLE_BUNZIP2 /* bunzip2_main may not be visible... */
if (opt & 0x18) // -d and/or -t
return bunzip2_main(argc, argv);
opt >>= 5;
#else
opt >>= 3;
#endif
opt = (uint8_t)opt; /* isolate bits for -1..-8 */
opt |= 0x100; /* if nothing else, assume -9 */
level = 1;
while (!(opt & 1)) {
level++;
opt >>= 1;
}
argv += optind;
option_mask32 &= 0x7; /* ignore all except -cfv */
return bbunpack(argv, make_new_name_bzip2, compressStream);
}
+287 -22
View File
@@ -7,35 +7,296 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Limitations:
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
*
*/
#include "libbb.h"
#include "unarchive.h"
#define CPIO_OPT_EXTRACT 0x01
#define CPIO_OPT_TEST 0x02
#define CPIO_OPT_UNCONDITIONAL 0x04
#define CPIO_OPT_VERBOSE 0x08
#define CPIO_OPT_FILE 0x10
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
#define CPIO_OPT_PRESERVE_MTIME 0x40
#if ENABLE_FEATURE_CPIO_O
static off_t cpio_pad4(off_t size)
{
int i;
int cpio_main(int argc, char **argv);
int cpio_main(int argc, char **argv)
i = (- size) & 3;
size += i;
while (--i >= 0)
bb_putchar('\0');
return size;
}
/* Return value will become exit code.
* It's ok to exit instead of return. */
static int cpio_o(void)
{
struct name_s {
struct name_s *next;
char name[1];
};
struct inodes_s {
struct inodes_s *next;
struct name_s *names;
struct stat st;
};
struct inodes_s *links = NULL;
off_t bytes = 0; /* output bytes count */
while (1) {
const char *name;
char *line;
struct stat st;
line = xmalloc_fgetline(stdin);
if (line) {
/* Strip leading "./[./]..." from the filename */
name = line;
while (name[0] == '.' && name[1] == '/') {
while (*++name == '/')
continue;
}
if (!*name) { /* line is empty */
free(line);
continue;
}
if (lstat(name, &st)) {
abort_cpio_o:
bb_simple_perror_msg_and_die(name);
}
if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)))
st.st_size = 0; /* paranoia */
/* Store hardlinks for later processing, dont output them */
if (!S_ISDIR(st.st_mode) && st.st_nlink > 1) {
struct name_s *n;
struct inodes_s *l;
/* Do we have this hardlink remembered? */
l = links;
while (1) {
if (l == NULL) {
/* Not found: add new item to "links" list */
l = xzalloc(sizeof(*l));
l->st = st;
l->next = links;
links = l;
break;
}
if (l->st.st_ino == st.st_ino) {
/* found */
break;
}
l = l->next;
}
/* Add new name to "l->names" list */
n = xmalloc(sizeof(*n) + strlen(name));
strcpy(n->name, name);
n->next = l->names;
l->names = n;
free(line);
continue;
}
} else { /* line == NULL: EOF */
next_link:
if (links) {
/* Output hardlink's data */
st = links->st;
name = links->names->name;
links->names = links->names->next;
/* GNU cpio is reported to emit file data
* only for the last instance. Mimic that. */
if (links->names == NULL)
links = links->next;
else
st.st_size = 0;
/* NB: we leak links->names and/or links,
* this is intended (we exit soon anyway) */
} else {
/* If no (more) hardlinks to output,
* output "trailer" entry */
name = "TRAILER!!!";
/* st.st_size == 0 is a must, but for uniformity
* in the output, we zero out everything */
memset(&st, 0, sizeof(st));
/* st.st_nlink = 1; - GNU cpio does this */
}
}
bytes += printf("070701"
"%08X%08X%08X%08X%08X%08X%08X"
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
/* strlen+1: */ "%08X"
/* chksum: */ "00000000" /* (only for "070702" files) */
/* name,NUL: */ "%s%c",
(unsigned)(uint32_t) st.st_ino,
(unsigned)(uint32_t) st.st_mode,
(unsigned)(uint32_t) st.st_uid,
(unsigned)(uint32_t) st.st_gid,
(unsigned)(uint32_t) st.st_nlink,
(unsigned)(uint32_t) st.st_mtime,
(unsigned)(uint32_t) st.st_size,
(unsigned)(uint32_t) major(st.st_dev),
(unsigned)(uint32_t) minor(st.st_dev),
(unsigned)(uint32_t) major(st.st_rdev),
(unsigned)(uint32_t) minor(st.st_rdev),
(unsigned)(strlen(name) + 1),
name, '\0');
bytes = cpio_pad4(bytes);
if (st.st_size) {
if (S_ISLNK(st.st_mode)) {
char *lpath = xmalloc_readlink_or_warn(name);
if (!lpath)
goto abort_cpio_o;
bytes += printf("%s", lpath);
free(lpath);
} else { /* S_ISREG */
int fd = xopen(name, O_RDONLY);
fflush(stdout);
/* We must abort if file got shorter too! */
bb_copyfd_exact_size(fd, STDOUT_FILENO, st.st_size);
bytes += st.st_size;
close(fd);
}
bytes = cpio_pad4(bytes);
}
if (!line) {
if (links)
goto next_link;
/* TODO: GNU cpio pads trailer to 512 bytes, do we want that? */
return EXIT_SUCCESS;
}
free(line);
} /* end of "while (1)" */
}
#endif
/* GNU cpio 2.9 --help (abridged):
Modes:
-i, --extract Extract files from an archive
-o, --create Create the archive
-p, --pass-through Copy-pass mode [was ist das?!]
-t, --list List the archive
Options valid in any mode:
--block-size=SIZE I/O block size = SIZE * 512 bytes
-B I/O block size = 5120 bytes
-c Use the old portable (ASCII) archive format
-C, --io-size=NUMBER I/O block size in bytes
-f, --nonmatching Only copy files that do not match given pattern
-F, --file=FILE Use FILE instead of standard input or output
-H, --format=FORMAT Use given archive FORMAT
-M, --message=STRING Print STRING when the end of a volume of the
backup media is reached
-n, --numeric-uid-gid If -v, show numeric UID and GID
--quiet Do not print the number of blocks copied
--rsh-command=COMMAND Use remote COMMAND instead of rsh
-v, --verbose Verbosely list the files processed
-V, --dot Print a "." for each file processed
-W, --warning=FLAG Control warning display: 'none','truncate','all';
multiple options accumulate
Options valid only in --extract mode:
-b, --swap Swap both halfwords of words and bytes of
halfwords in the data (equivalent to -sS)
-r, --rename Interactively rename files
-s, --swap-bytes Swap the bytes of each halfword in the files
-S, --swap-halfwords Swap the halfwords of each word (4 bytes)
--to-stdout Extract files to standard output
-E, --pattern-file=FILE Read additional patterns specifying filenames to
extract or list from FILE
--only-verify-crc Verify CRC's, don't actually extract the files
Options valid only in --create mode:
-A, --append Append to an existing archive
-O FILE File to use instead of standard output
Options valid only in --pass-through mode:
-l, --link Link files instead of copying them, when possible
Options valid in --extract and --create modes:
--absolute-filenames Do not strip file system prefix components from
the file names
--no-absolute-filenames Create all files relative to the current dir
Options valid in --create and --pass-through modes:
-0, --null A list of filenames is terminated by a NUL
-a, --reset-access-time Reset the access times of files after reading them
-I FILE File to use instead of standard input
-L, --dereference Dereference symbolic links (copy the files
that they point to instead of copying the links)
-R, --owner=[USER][:.][GROUP] Set owner of created files
Options valid in --extract and --pass-through modes:
-d, --make-directories Create leading directories where needed
-m, --preserve-modification-time Retain mtime when creating files
--no-preserve-owner Do not change the ownership of the files
--sparse Write files with blocks of zeros as sparse files
-u, --unconditional Replace all files unconditionally
*/
int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cpio_main(int argc UNUSED_PARAM, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename = NULL;
char *cpio_filename;
USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
unsigned opt;
enum {
CPIO_OPT_EXTRACT = (1 << 0),
CPIO_OPT_TEST = (1 << 1),
CPIO_OPT_UNCONDITIONAL = (1 << 2),
CPIO_OPT_VERBOSE = (1 << 3),
CPIO_OPT_FILE = (1 << 4),
CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
CPIO_OPT_PRESERVE_MTIME = (1 << 6),
CPIO_OPT_CREATE = (1 << 7),
CPIO_OPT_FORMAT = (1 << 8),
};
/* Initialise */
#if ENABLE_GETOPT_LONG
applet_long_options =
"extract\0" No_argument "i"
"list\0" No_argument "t"
#if ENABLE_FEATURE_CPIO_O
"create\0" No_argument "o"
"format\0" Required_argument "H"
#endif
;
#endif
/* Initialize */
archive_handle = init_handle();
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
#if ENABLE_FEATURE_CPIO_O
opt = getopt32(argv, "ituvF:dmoH:", &cpio_filename, &cpio_fmt);
if (opt & CPIO_OPT_CREATE) {
if (*cpio_fmt != 'n')
bb_show_usage();
if (opt & CPIO_OPT_FILE) {
fclose(stdout);
stdout = fopen_for_write(cpio_filename);
/* Paranoia: I don't trust libc that much */
xdup2(fileno(stdout), STDOUT_FILENO);
}
return cpio_o();
}
#else
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
#endif
argv += optind;
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
@@ -53,8 +314,8 @@ int cpio_main(int argc, char **argv)
archive_handle->action_data = data_extract_all;
}
if (opt & CPIO_OPT_UNCONDITIONAL) {
archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
archive_handle->flags &= ~ARCHIVE_EXTRACT_NEWER;
archive_handle->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
archive_handle->ah_flags &= ~ARCHIVE_EXTRACT_NEWER;
}
if (opt & CPIO_OPT_VERBOSE) {
if (archive_handle->action_header == header_list) {
@@ -63,21 +324,25 @@ int cpio_main(int argc, char **argv)
archive_handle->action_header = header_list;
}
}
if (cpio_filename) { /* CPIO_OPT_FILE */
if (opt & CPIO_OPT_FILE) { /* -F */
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
archive_handle->seek = seek_by_jump;
}
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
archive_handle->ah_flags |= ARCHIVE_CREATE_LEADING_DIRS;
}
if (opt & CPIO_OPT_PRESERVE_MTIME) {
archive_handle->ah_flags |= ARCHIVE_PRESERVE_DATE;
}
while (optind < argc) {
while (*argv) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), argv[optind]);
optind++;
llist_add_to(&(archive_handle->accept), *argv);
argv++;
}
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
continue;
return EXIT_SUCCESS;
}
+133 -112
View File
@@ -75,10 +75,21 @@ typedef struct status_node_s {
unsigned status:16; /* was:14 */ /* has to fit STATUS_HASH_PRIME */
} status_node_t;
/* Were statically declared here, but such a big bss is nommu-unfriendly */
static char **name_hashtable; /* [NAME_HASH_PRIME + 1] */
static common_node_t **package_hashtable; /* [PACKAGE_HASH_PRIME + 1] */
static status_node_t **status_hashtable; /* [STATUS_HASH_PRIME + 1] */
/* Globals */
struct globals {
char *name_hashtable[NAME_HASH_PRIME + 1];
common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
};
#define G (*ptr_to_globals)
#define name_hashtable (G.name_hashtable )
#define package_hashtable (G.package_hashtable)
#define status_hashtable (G.status_hashtable )
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0)
/* Even numbers are for 'extras', like ored dependencies or null */
enum edge_type_e {
@@ -124,7 +135,7 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
* shift amount is mod 24 because long int is 32 bit and data
* to be shifted is 8, don't want to shift data to where it has
* no effect*/
hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24));
hash_num += (key[i] + key[i-1]) << ((key[i] * i) % 24);
}
*start = (unsigned) hash_num % hash_prime;
*decrement = (unsigned) 1 + (hash_num % (hash_prime - 1));
@@ -133,8 +144,8 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
/* this adds the key to the hash table */
static int search_name_hashtable(const char *key)
{
unsigned probe_address = 0;
unsigned probe_decrement = 0;
unsigned probe_address;
unsigned probe_decrement;
make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME);
while (name_hashtable[probe_address] != NULL) {
@@ -155,8 +166,8 @@ static int search_name_hashtable(const char *key)
*/
static unsigned search_status_hashtable(const char *key)
{
unsigned probe_address = 0;
unsigned probe_decrement = 0;
unsigned probe_address;
unsigned probe_decrement;
make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME);
while (status_hashtable[probe_address] != NULL) {
@@ -312,11 +323,10 @@ static int test_version(const unsigned version1, const unsigned version2, const
return FALSE;
}
static int search_package_hashtable(const unsigned name, const unsigned version, const unsigned operator)
{
unsigned probe_address = 0;
unsigned probe_decrement = 0;
unsigned probe_address;
unsigned probe_decrement;
make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME);
while (package_hashtable[probe_address] != NULL) {
@@ -372,9 +382,8 @@ static int search_for_provides(int needle, int start_at)
*/
static void add_edge_to_node(common_node_t *node, edge_t *edge)
{
node->num_of_edges++;
node->edge = xrealloc(node->edge, sizeof(edge_t) * (node->num_of_edges + 1));
node->edge[node->num_of_edges - 1] = edge;
node->edge = xrealloc_vector(node->edge, 2, node->num_of_edges);
node->edge[node->num_of_edges++] = edge;
}
/*
@@ -410,10 +419,10 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS)
&& (strcmp(field, field2) != 0)
) {
or_edge = xmalloc(sizeof(edge_t));
or_edge = xzalloc(sizeof(edge_t));
or_edge->type = edge_type + 1;
or_edge->name = search_name_hashtable(field);
or_edge->version = 0; // tracks the number of alternatives
//or_edge->version = 0; // tracks the number of alternatives
add_edge_to_node(parent_node, or_edge);
}
@@ -439,17 +448,13 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
if (offset_ch > 0) {
if (strncmp(version, "=", offset_ch) == 0) {
edge->operator = VER_EQUAL;
}
else if (strncmp(version, "<<", offset_ch) == 0) {
} else if (strncmp(version, "<<", offset_ch) == 0) {
edge->operator = VER_LESS;
}
else if (strncmp(version, "<=", offset_ch) == 0) {
} else if (strncmp(version, "<=", offset_ch) == 0) {
edge->operator = VER_LESS_EQUAL;
}
else if (strncmp(version, ">>", offset_ch) == 0) {
} else if (strncmp(version, ">>", offset_ch) == 0) {
edge->operator = VER_MORE;
}
else if (strncmp(version, ">=", offset_ch) == 0) {
} else if (strncmp(version, ">=", offset_ch) == 0) {
edge->operator = VER_MORE_EQUAL;
} else {
bb_error_msg_and_die("illegal operator");
@@ -602,7 +607,7 @@ static unsigned fill_package_struct(char *control_buffer)
&field_name, &field_value);
if (field_name == NULL) {
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement! */
goto fill_package_struct_cleanup;
}
field_num = index_in_strings(field_names, field_name);
@@ -735,7 +740,6 @@ static const char *describe_status(int status_num)
return "is not installed or flagged to be installed";
}
static void index_status_file(const char *filename)
{
FILE *status_file;
@@ -744,8 +748,8 @@ static void index_status_file(const char *filename)
status_node_t *status_node = NULL;
unsigned status_num;
status_file = xfopen(filename, "r");
while ((control_buffer = xmalloc_fgets_str(status_file, "\n\n")) != NULL) {
status_file = xfopen_for_read(filename);
while ((control_buffer = xmalloc_fgetline_str(status_file, "\n\n")) != NULL) {
const unsigned package_num = fill_package_struct(control_buffer);
if (package_num != -1) {
status_node = xmalloc(sizeof(status_node_t));
@@ -786,8 +790,8 @@ static void write_buffer_no_status(FILE *new_status_file, const char *control_bu
/* This could do with a cleanup */
static void write_status_file(deb_file_t **deb_file)
{
FILE *old_status_file = xfopen("/var/lib/dpkg/status", "r");
FILE *new_status_file = xfopen("/var/lib/dpkg/status.udeb", "w");
FILE *old_status_file = xfopen_for_read("/var/lib/dpkg/status");
FILE *new_status_file = xfopen_for_write("/var/lib/dpkg/status.udeb");
char *package_name;
char *status_from_file;
char *control_buffer = NULL;
@@ -798,7 +802,7 @@ static void write_status_file(deb_file_t **deb_file)
int i = 0;
/* Update previously known packages */
while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) {
while ((control_buffer = xmalloc_fgetline_str(old_status_file, "\n\n")) != NULL) {
tmp_string = strstr(control_buffer, "Package:");
if (tmp_string == NULL) {
continue;
@@ -913,20 +917,16 @@ static void write_status_file(deb_file_t **deb_file)
fclose(old_status_file);
fclose(new_status_file);
/* Create a separate backfile to dpkg */
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
struct stat stat_buf;
xstat("/var/lib/dpkg/status", &stat_buf);
if (errno != ENOENT)
bb_error_msg_and_die("cannot create backup status file");
/* Its ok if renaming the status file fails because status
* file doesnt exist, maybe we are starting from scratch */
bb_error_msg("no status file found, creating new one");
}
if (rename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status") == -1) {
bb_error_msg_and_die("DANGER: cannot create status file, "
"you need to manually repair your status file");
}
xrename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status");
}
/* This function returns TRUE if the given package can satisfy a
@@ -953,7 +953,7 @@ static int package_satisfies_dependency(int package, int depend_type)
return 0;
}
static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count - ?? */)
{
int *conflicts = NULL;
int conflicts_num = 0;
@@ -971,7 +971,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
* installed package for conflicts*/
while (deb_file[i] != NULL) {
const unsigned package_num = deb_file[i]->package;
conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1));
conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
conflicts[conflicts_num] = package_num;
conflicts_num++;
/* add provides to conflicts list */
@@ -988,7 +988,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
new_node->version = package_hashtable[package_num]->edge[j]->version;
package_hashtable[conflicts_package_num] = new_node;
}
conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1));
conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
conflicts[conflicts_num] = conflicts_package_num;
conflicts_num++;
}
@@ -1156,27 +1156,25 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
static char **create_list(const char *filename)
{
FILE *list_stream;
char **file_list = NULL;
char *line = NULL;
int count = 0;
char **file_list;
char *line;
int count;
/* don't use [xw]fopen here, handle error ourself */
list_stream = fopen(filename, "r");
list_stream = fopen_for_read(filename);
if (list_stream == NULL) {
return NULL;
}
while ((line = xmalloc_getline(list_stream)) != NULL) {
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
file_list[count] = line;
count++;
file_list = NULL;
count = 0;
while ((line = xmalloc_fgetline(list_stream)) != NULL) {
file_list = xrealloc_vector(file_list, 2, count);
file_list[count++] = line;
/*file_list[count] = NULL; - xrealloc_vector did it */
}
fclose(list_stream);
if (count == 0) {
return NULL;
}
file_list[count] = NULL;
return file_list;
}
@@ -1213,24 +1211,54 @@ static int remove_file_array(char **remove_names, char **exclude_names)
return (remove_flag == 0);
}
static int run_package_script(const char *package_name, const char *script_type)
static void run_package_script_or_die(const char *package_name, const char *script_type)
{
struct stat path_stat;
char *script_path;
int result;
script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
/* If the file doesnt exist is isnt a fatal */
result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
/* If the file doesnt exist is isnt fatal */
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
free(script_path);
return result;
if (result)
bb_error_msg_and_die("%s failed, exit code %d", script_type, result);
}
/*
The policy manual defines what scripts get called when and with
what arguments. I realize that busybox does not support all of
these scenarios, but it does support some of them; it does not,
however, run them with any parameters in run_package_script_or_die().
Here are the scripts:
preinst install
preinst install <old_version>
preinst upgrade <old_version>
preinst abort_upgrade <new_version>
postinst configure <most_recent_version>
postinst abort-upgade <new_version>
postinst abort-remove
postinst abort-remove in-favour <package> <version>
postinst abort-deconfigure in-favor <failed_install_package> removing <conflicting_package> <version>
prerm remove
prerm upgrade <new_version>
prerm failed-upgrade <old_version>
prerm remove in-favor <package> <new_version>
prerm deconfigure in-favour <package> <version> removing <package> <version>
postrm remove
postrm purge
postrm upgrade <new_version>
postrm failed-upgrade <old_version>
postrm abort-install
postrm abort-install <old_version>
postrm abort-upgrade <old_version>
postrm disappear <overwriter> <version>
*/
static const char *const all_control_files[] = {
"preinst", "postinst", "prerm", "postrm",
"list", "md5sums", "shlibs", "conffiles",
"config", "templates", NULL
"config", "templates"
};
static char **all_control_list(const char *package_name)
@@ -1239,9 +1267,10 @@ static char **all_control_list(const char *package_name)
char **remove_files;
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = xzalloc(sizeof(all_control_files));
while (all_control_files[i]) {
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
remove_files = xzalloc(sizeof(all_control_files) + sizeof(char*));
while (i < ARRAY_SIZE(all_control_files)) {
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s",
package_name, all_control_files[i]);
i++;
}
@@ -1314,27 +1343,26 @@ static void remove_package(const unsigned package_num, int noisy)
if (noisy)
printf("Removing %s (%s)...\n", package_name, package_version);
/* run prerm script */
if (run_package_script(package_name, "prerm") != 0) {
bb_error_msg_and_die("script failed, prerm failure");
}
/* Run prerm script */
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove, and a separate list of those to keep */
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
sprintf(conffile_name, "/var/lib/dpkg/info/%s.conffiles", package_name);
sprintf(conffile_name, "/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
exclude_files = create_list(conffile_name);
/* Some directories can't be removed straight away, so do multiple passes */
while (remove_file_array(remove_files, exclude_files)) /*repeat */;
while (remove_file_array(remove_files, exclude_files))
continue;
free_array(exclude_files);
free_array(remove_files);
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
exclude_files = xzalloc(sizeof(char*) * 3);
exclude_files[0] = xstrdup(conffile_name);
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.postrm", package_name);
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
@@ -1343,7 +1371,9 @@ static void remove_package(const unsigned package_num, int noisy)
free_array(remove_files);
free_array(exclude_files);
/* rename <package>.conffile to <package>.list */
/* rename <package>.conffiles to <package>.list
* The conffiles control file isn't required in Debian packages, so don't
* error out if it's missing. */
rename(conffile_name, list_name);
/* Change package status */
@@ -1361,13 +1391,11 @@ static void purge_package(const unsigned package_num)
printf("Purging %s (%s)...\n", package_name, package_version);
/* run prerm script */
if (run_package_script(package_name, "prerm") != 0) {
bb_error_msg_and_die("script failed, prerm failure");
}
/* Run prerm script */
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove */
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
exclude_files = xzalloc(sizeof(char*));
@@ -1382,10 +1410,8 @@ static void purge_package(const unsigned package_num)
free_array(remove_files);
free(exclude_files);
/* run postrm script */
if (run_package_script(package_name, "postrm") != 0) {
bb_error_msg_and_die("postrm failure.. set status to what?");
}
/* Run postrm script */
run_package_script_or_die(package_name, "postrm");
/* Change package status */
set_status(status_num, "not-installed", 3);
@@ -1412,10 +1438,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
tar_handle->src_fd = ar_handle->src_fd;
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
#if ENABLE_FEATURE_DEB_TAR_GZ
#if ENABLE_FEATURE_SEAMLESS_GZ
llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz");
#endif
#if ENABLE_FEATURE_DEB_TAR_BZ2
#if ENABLE_FEATURE_SEAMLESS_BZ2
llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2");
#endif
@@ -1432,10 +1458,10 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
tar_handle->src_fd = ar_handle->src_fd;
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
#if ENABLE_FEATURE_DEB_TAR_GZ
#if ENABLE_FEATURE_SEAMLESS_GZ
llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz");
#endif
#if ENABLE_FEATURE_DEB_TAR_BZ2
#if ENABLE_FEATURE_SEAMLESS_BZ2
llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2");
#endif
@@ -1455,7 +1481,7 @@ static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, lli
return ar_handle->sub_archive->buffer;
}
static void data_extract_all_prefix(archive_handle_t *archive_handle)
static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
{
char *name_ptr = archive_handle->file_header->name;
@@ -1475,8 +1501,8 @@ static void unpack_package(deb_file_t *deb_file)
char *list_filename;
archive_handle_t *archive_handle;
FILE *out_stream;
llist_t *accept_list = NULL;
int i = 0;
llist_t *accept_list;
int i;
/* If existing version, remove it first */
if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
@@ -1490,11 +1516,13 @@ static void unpack_package(deb_file_t *deb_file)
}
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
info_prefix = xasprintf("/var/lib/dpkg/info/%s.", package_name);
info_prefix = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "");
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_control(archive_handle);
while (all_control_files[i]) {
accept_list = NULL;
i = 0;
while (i < ARRAY_SIZE(all_control_files)) {
char *c = xasprintf("./%s", all_control_files[i]);
llist_add_to(&accept_list, c);
i++;
@@ -1503,26 +1531,23 @@ static void unpack_package(deb_file_t *deb_file)
archive_handle->sub_archive->filter = filter_accept_list;
archive_handle->sub_archive->action_data = data_extract_all_prefix;
archive_handle->sub_archive->buffer = info_prefix;
archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
unpack_ar_archive(archive_handle);
/* Run the preinst prior to extracting */
if (run_package_script(package_name, "preinst") != 0) {
/* when preinst returns exit code != 0 then quit installation process */
bb_error_msg_and_die("subprocess pre-installation script returned error");
}
run_package_script_or_die(package_name, "preinst");
/* Extract data.tar.gz to the root directory */
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_data(archive_handle);
archive_handle->sub_archive->action_data = data_extract_all_prefix;
archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */
archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
unpack_ar_archive(archive_handle);
/* Create the list file */
list_filename = xasprintf("/var/lib/dpkg/info/%s.list", package_name);
out_stream = xfopen(list_filename, "w");
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
out_stream = xfopen_for_write(list_filename);
while (archive_handle->sub_archive->passed) {
/* the leading . has been stripped by data_extract_all_prefix already */
fputs(archive_handle->sub_archive->passed->data, out_stream);
@@ -1548,17 +1573,16 @@ static void configure_package(deb_file_t *deb_file)
printf("Setting up %s (%s)...\n", package_name, package_version);
/* Run the postinst script */
if (run_package_script(package_name, "postinst") != 0) {
/* TODO: handle failure gracefully */
bb_error_msg_and_die("postinst failure.. set status to what?");
}
/* TODO: handle failure gracefully */
run_package_script_or_die(package_name, "postinst");
/* Change status to reflect success */
set_status(status_num, "install", 1);
set_status(status_num, "installed", 3);
}
int dpkg_main(int argc, char **argv);
int dpkg_main(int argc, char **argv)
int dpkg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dpkg_main(int argc UNUSED_PARAM, char **argv)
{
deb_file_t **deb_file = NULL;
status_node_t *status_node;
@@ -1579,6 +1603,8 @@ int dpkg_main(int argc, char **argv)
OPT_unpack = 0x40,
};
INIT_G();
opt = getopt32(argv, "CF:ilPru", &str_f);
//if (opt & OPT_configure) ... // -C
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
@@ -1590,16 +1616,11 @@ int dpkg_main(int argc, char **argv)
//if (opt & OPT_purge) ... // -P
//if (opt & OPT_remove) ... // -r
//if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
argc -= optind;
argv += optind;
/* check for non-option argument if expected */
if (!opt || (!argc && !(opt && OPT_list_installed)))
if (!opt || (!argv[0] && !(opt && OPT_list_installed)))
bb_show_usage();
name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1));
package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1));
status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1));
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
index_status_file("/var/lib/dpkg/status");
@@ -1612,7 +1633,7 @@ int dpkg_main(int argc, char **argv)
/* Read arguments and store relevant info in structs */
while (*argv) {
/* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
deb_file = xrealloc(deb_file, sizeof(deb_file[0]) * (deb_count + 2));
deb_file = xrealloc_vector(deb_file, 2, deb_count);
deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0]));
if (opt & (OPT_install | OPT_unpack)) {
/* -i/-u: require filename */
@@ -1693,7 +1714,7 @@ int dpkg_main(int argc, char **argv)
/* Check that the deb file arguments are installable */
if (!(opt & OPT_force_ignore_depends)) {
if (!check_deps(deb_file, 0, deb_count)) {
if (!check_deps(deb_file, 0 /*, deb_count*/)) {
bb_error_msg_and_die("dependency check failed");
}
}
+22 -15
View File
@@ -13,15 +13,15 @@
#define DPKG_DEB_OPT_EXTRACT 8
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
int dpkg_deb_main(int argc, char **argv);
int dpkg_deb_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dpkg_deb_main(int argc, char **argv)
{
archive_handle_t *ar_archive;
archive_handle_t *tar_archive;
llist_t *control_tar_llist = NULL;
unsigned opt;
const char *extract_dir = NULL;
short argcount = 1;
const char *extract_dir;
int need_args;
/* Setup the tar archive handle */
tar_archive = init_handle();
@@ -31,29 +31,33 @@ int dpkg_deb_main(int argc, char **argv)
ar_archive->sub_archive = tar_archive;
ar_archive->filter = filter_accept_list_reassign;
#if ENABLE_FEATURE_DEB_TAR_GZ
#if ENABLE_FEATURE_SEAMLESS_GZ
llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
#endif
#if ENABLE_FEATURE_DEB_TAR_BZ2
#if ENABLE_FEATURE_SEAMLESS_BZ2
llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
#endif
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt_complementary = "c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = getopt32(argv, "cefXx");
argv += optind;
argc -= optind;
if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
}
extract_dir = NULL;
need_args = 1;
if (opt & DPKG_DEB_OPT_CONTROL) {
ar_archive->accept = control_tar_llist;
tar_archive->action_data = data_extract_all;
if (optind + 1 == argc) {
if (1 == argc) {
extract_dir = "./DEBIAN";
} else {
argcount++;
need_args++;
}
}
if (opt & DPKG_DEB_OPT_FIELD) {
@@ -70,28 +74,31 @@ int dpkg_deb_main(int argc, char **argv)
}
if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) {
tar_archive->action_data = data_extract_all;
argcount = 2;
need_args = 2;
}
if ((optind + argcount) != argc) {
if (need_args != argc) {
bb_show_usage();
}
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY);
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[0], O_RDONLY);
/* Workout where to extract the files */
/* Work out where to extract the files */
/* 2nd argument is a dir name */
if (argv[optind]) {
extract_dir = argv[optind];
if (argv[1]) {
extract_dir = argv[1];
}
if (extract_dir) {
mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */
xchdir(extract_dir);
}
/* Do it */
unpack_ar_archive(ar_archive);
/* Cleanup */
close(ar_archive->src_fd);
if (ENABLE_FEATURE_CLEAN_UP)
close(ar_archive->src_fd);
return EXIT_SUCCESS;
}
+29 -11
View File
@@ -686,7 +686,7 @@ static void check_match(IPos start, IPos match, int length)
if (verbose > 1) {
bb_error_msg("\\[%d,%d]", start - match, length);
do {
putc(G1.window[start++], stderr);
fputc(G1.window[start++], stderr);
} while (--length != 0);
}
}
@@ -2025,26 +2025,44 @@ USE_DESKTOP(long long) int pack_gzip(void)
return 0;
}
int gzip_main(int argc, char **argv);
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
* -n --no-name
* gzip: do not save the original file name and time stamp.
* (The original name is always saved if the name had to be truncated.)
* gunzip: do not restore the original file name/time even if present
* (remove only the gzip suffix from the compressed file name).
* This option is the default when decompressing.
* -N --name
* gzip: always save the original file name and time stamp (this is the default)
* gunzip: restore the original file name and time stamp if present.
*/
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
#if ENABLE_GUNZIP
int gzip_main(int argc, char **argv)
#else
int gzip_main(int argc UNUSED_PARAM, char **argv)
#endif
{
unsigned opt;
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
option_mask32 &= 0x7; /* Clear -d, ignore -q, -0..9 */
opt = getopt32(argv, "cfv" USE_GUNZIP("dt") "q123456789n");
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
if (opt & 0x18) // -d and/or -t
return gunzip_main(argc, argv);
#endif
option_mask32 &= 0x7; /* ignore -q, -0..9 */
//if (opt & 0x1) // -c
//if (opt & 0x2) // -f
//if (opt & 0x4) // -v
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
if (opt & 0x8) { // -d
return gunzip_main(argc, argv);
}
#endif
argv += optind;
PTR_TO_GLOBALS = xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+ sizeof(struct globals);
SET_PTR_TO_GLOBALS(xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+ sizeof(struct globals));
barrier();
G2.l_desc.dyn_tree = G2.dyn_ltree;
G2.l_desc.static_tree = G2.static_ltree;
G2.l_desc.extra_bits = extra_lbits;
+8 -25
View File
@@ -18,8 +18,6 @@ lib-y:= \
header_skip.o \
header_list.o \
header_verbose_list.o \
\
archive_xread_all_eof.o \
\
seek_by_read.o \
seek_by_jump.o \
@@ -28,41 +26,26 @@ lib-y:= \
find_list_entry.o \
init_handle.o
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
DPKG_FILES:= \
get_header_ar.o \
unpack_ar_archive.o \
get_header_tar.o \
filter_accept_list_reassign.o
lib-$(CONFIG_RPM) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
lib-$(CONFIG_CPIO) += get_header_cpio.o
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
lib-$(CONFIG_GUNZIP) += decompress_unzip.o
lib-$(CONFIG_RPM2CPIO) += decompress_unzip.o get_header_cpio.o
lib-$(CONFIG_RPM) += open_transformer.o decompress_unzip.o get_header_cpio.o
lib-$(CONFIG_TAR) += get_header_tar.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_UNZIP) += decompress_unzip.o
lib-$(CONFIG_FEATURE_SEAMLESS_Z) += open_transformer.o decompress_uncompress.o
lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_unzip.o get_header_tar_gz.o
lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
@@ -1,20 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
unsigned char *buf, size_t count)
{
ssize_t size;
size = full_read(archive_handle->src_fd, buf, count);
if (size != 0 && size != count) {
bb_error_msg_and_die("short read: %u of %u",
(unsigned)size, (unsigned)count);
}
return size;
}
-59
View File
@@ -1,59 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h" /* for external decl of check_header_gzip_or_die */
void check_header_gzip_or_die(int src_fd)
{
union {
unsigned char raw[8];
struct {
unsigned char method;
unsigned char flags;
unsigned int mtime;
unsigned char xtra_flags;
unsigned char os_flags;
} formatted;
} header;
xread(src_fd, header.raw, 8);
/* Check the compression method */
if (header.formatted.method != 8) {
bb_error_msg_and_die("unknown compression method %d",
header.formatted.method);
}
if (header.formatted.flags & 0x04) {
/* bit 2 set: extra field present */
unsigned extra_short;
extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
while (extra_short > 0) {
/* Ignore extra field */
xread_char(src_fd);
extra_short--;
}
}
/* Discard original name if any */
if (header.formatted.flags & 0x08) {
/* bit 3 set: original file name present */
while (xread_char(src_fd) != 0);
}
/* Discard file comment if any */
if (header.formatted.flags & 0x10) {
/* bit 4 set: file comment present */
while (xread_char(src_fd) != 0);
}
/* Read the header checksum */
if (header.formatted.flags & 0x02) {
xread_char(src_fd);
xread_char(src_fd);
}
}
+2 -4
View File
@@ -3,14 +3,12 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
//#include <sys/types.h>
#include "libbb.h"
#include "unarchive.h"
void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
void FAST_FUNC data_align(archive_handle_t *archive_handle, unsigned boundary)
{
const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
unsigned skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
archive_handle->seek(archive_handle, skip_amount);
archive_handle->offset += skip_amount;
+28 -13
View File
@@ -6,21 +6,21 @@
#include "libbb.h"
#include "unarchive.h"
void data_extract_all(archive_handle_t *archive_handle)
void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
{
file_header_t *file_header = archive_handle->file_header;
int dst_fd;
int res;
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
if (archive_handle->ah_flags & ARCHIVE_CREATE_LEADING_DIRS) {
char *name = xstrdup(file_header->name);
bb_make_directory(dirname(name), -1, FILEUTILS_RECUR);
free(name);
}
/* Check if the file already exists */
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the existing entry if it exists */
if (archive_handle->ah_flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the entry if it exists */
if (((file_header->mode & S_IFMT) != S_IFDIR)
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
@@ -29,7 +29,7 @@ void data_extract_all(archive_handle_t *archive_handle)
file_header->name);
}
}
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
else if (archive_handle->ah_flags & ARCHIVE_EXTRACT_NEWER) {
/* Remove the existing entry if its older than the extracted entry */
struct stat statbuf;
if (lstat(file_header->name, &statbuf) == -1) {
@@ -38,7 +38,7 @@ void data_extract_all(archive_handle_t *archive_handle)
}
}
else if (statbuf.st_mtime <= file_header->mtime) {
if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
if (!(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) {
bb_error_msg("%s not created: newer or "
"same age file exists", file_header->name);
}
@@ -58,7 +58,7 @@ void data_extract_all(archive_handle_t *archive_handle)
) {
/* hard link */
res = link(file_header->link_target, file_header->name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
if ((res == -1) && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("cannot create %slink "
"from %s to %s", "hard",
file_header->name,
@@ -78,7 +78,7 @@ void data_extract_all(archive_handle_t *archive_handle)
case S_IFDIR:
res = mkdir(file_header->name, file_header->mode);
if ((res == -1) && (errno != EISDIR)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot make dir %s", file_header->name);
}
@@ -87,7 +87,7 @@ void data_extract_all(archive_handle_t *archive_handle)
/* Symlink */
res = symlink(file_header->link_target, file_header->name);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create %slink "
"from %s to %s", "sym",
@@ -101,7 +101,7 @@ void data_extract_all(archive_handle_t *archive_handle)
case S_IFIFO:
res = mknod(file_header->name, file_header->mode, file_header->device);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create node %s", file_header->name);
}
@@ -111,18 +111,33 @@ void data_extract_all(archive_handle_t *archive_handle)
}
}
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_OWN)) {
#if ENABLE_FEATURE_TAR_UNAME_GNAME
uid_t uid = file_header->uid;
gid_t gid = file_header->gid;
if (file_header->uname) {
struct passwd *pwd = getpwnam(file_header->uname);
if (pwd) uid = pwd->pw_uid;
}
if (file_header->gname) {
struct group *grp = getgrnam(file_header->gname);
if (grp) gid = grp->gr_gid;
}
lchown(file_header->name, uid, gid);
#else
lchown(file_header->name, file_header->uid, file_header->gid);
#endif
}
if ((file_header->mode & S_IFMT) != S_IFLNK) {
/* uclibc has no lchmod, glibc is even stranger -
* it has lchmod which seems to do nothing!
* so we use chmod... */
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM)) {
if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_PERM)) {
chmod(file_header->name, file_header->mode);
}
/* same for utime */
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
if (archive_handle->ah_flags & ARCHIVE_PRESERVE_DATE) {
struct utimbuf t;
t.actime = t.modtime = file_header->mtime;
utime(file_header->name, &t);
@@ -8,7 +8,7 @@
#include "libbb.h"
#include "unarchive.h"
void data_extract_to_buffer(archive_handle_t *archive_handle)
void FAST_FUNC data_extract_to_buffer(archive_handle_t *archive_handle)
{
unsigned int size = archive_handle->file_header->size;
@@ -6,7 +6,7 @@
#include "libbb.h"
#include "unarchive.h"
void data_extract_to_stdout(archive_handle_t *archive_handle)
void FAST_FUNC data_extract_to_stdout(archive_handle_t *archive_handle)
{
bb_copyfd_exact_size(archive_handle->src_fd,
STDOUT_FILENO,
+1 -1
View File
@@ -6,7 +6,7 @@
#include "libbb.h"
#include "unarchive.h"
void data_skip(archive_handle_t *archive_handle)
void FAST_FUNC data_skip(archive_handle_t *archive_handle)
{
archive_handle->seek(archive_handle, archive_handle->file_header->size);
}
+74 -113
View File
@@ -44,7 +44,7 @@
#define RETVAL_LAST_BLOCK (-1)
#define RETVAL_NOT_BZIP_DATA (-2)
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
#define RETVAL_SHORT_WRITE (-4)
#define RETVAL_DATA_ERROR (-5)
#define RETVAL_OUT_OF_MEMORY (-6)
#define RETVAL_OBSOLETE_INPUT (-7)
@@ -54,22 +54,26 @@
/* This is what we know about each Huffman coding group */
struct group_data {
/* We have an extra slot at the end of limit[] for a sentinal value. */
/* We have an extra slot at the end of limit[] for a sentinel value. */
int limit[MAX_HUFCODE_BITS+1], base[MAX_HUFCODE_BITS], permute[MAX_SYMBOLS];
int minLen, maxLen;
};
/* Structure holding all the housekeeping data, including IO buffers and
memory that persists between calls to bunzip */
* memory that persists between calls to bunzip
* Found the most used member:
* cat this_file.c | sed -e 's/"/ /g' -e "s/'/ /g" | xargs -n1 \
* | grep 'bd->' | sed 's/^.*bd->/bd->/' | sort | $PAGER
* and moved it (inbufBitCount) to offset 0.
*/
struct bunzip_data {
/* State for interrupting output loop */
int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;
/* I/O tracking data (file handles, buffers, positions, etc.) */
unsigned inbufBitCount, inbufBits;
int in_fd, out_fd, inbufCount, inbufPos /*, outbufPos*/;
unsigned char *inbuf /*,*outbuf*/;
unsigned inbufBitCount, inbufBits;
/* State for interrupting output loop */
int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;
/* The CRC values stored in the block header and calculated from the data */
uint32_t headerCRC, totalCRC, writeCRC;
@@ -80,7 +84,7 @@ struct bunzip_data {
/* For I/O error handling */
jmp_buf jmpbuf;
/* Big things go last (register-relative addressing can be larger for big offsets */
/* Big things go last (register-relative addressing can be larger for big offsets) */
uint32_t crc32Table[256];
unsigned char selectors[32768]; /* nSelectors=15 bits */
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
@@ -91,17 +95,15 @@ struct bunzip_data {
/* Return the next nnn bits of input. All reads from the compressed input
are done through this function. All reads are big endian */
static unsigned get_bits(bunzip_data *bd, char bits_wanted)
static unsigned get_bits(bunzip_data *bd, int bits_wanted)
{
unsigned bits = 0;
/* If we need to get more data from the byte buffer, do so. (Loop getting
one byte at a time to enforce endianness and avoid unaligned access.) */
while (bd->inbufBitCount < bits_wanted) {
while ((int)(bd->inbufBitCount) < bits_wanted) {
/* If we need to read more data from file into byte buffer, do so */
if (bd->inbufPos == bd->inbufCount) {
/* if "no input fd" case: in_fd == -1, read fails, we jump */
bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE);
@@ -111,7 +113,6 @@ static unsigned get_bits(bunzip_data *bd, char bits_wanted)
}
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
if (bd->inbufBitCount >= 24) {
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
bits_wanted -= bd->inbufBitCount;
@@ -120,13 +121,11 @@ static unsigned get_bits(bunzip_data *bd, char bits_wanted)
}
/* Grab next 8 bits of input from buffer. */
bd->inbufBits = (bd->inbufBits<<8) | bd->inbuf[bd->inbufPos++];
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
bd->inbufBitCount += 8;
}
/* Calculate result */
bd->inbufBitCount -= bits_wanted;
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
@@ -134,7 +133,6 @@ static unsigned get_bits(bunzip_data *bd, char bits_wanted)
}
/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */
static int get_next_block(bunzip_data *bd)
{
struct group_data *hufGroup;
@@ -148,13 +146,11 @@ static int get_next_block(bunzip_data *bd)
selectors = bd->selectors;
/* Reset longjmp I/O error handling */
i = setjmp(bd->jmpbuf);
if (i) return i;
/* Read in header signature and CRC, then validate signature.
(last block signature means CRC is for whole file, return now) */
i = get_bits(bd, 24);
j = get_bits(bd, 24);
bd->headerCRC = get_bits(bd, 32);
@@ -164,17 +160,15 @@ static int get_next_block(bunzip_data *bd)
/* We can add support for blockRandomised if anybody complains. There was
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
it didn't actually work. */
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
origPtr = get_bits(bd, 24);
if (origPtr > dbufSize) return RETVAL_DATA_ERROR;
if ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR;
/* mapping table: if some byte values are never used (encoding things
like ascii text), the compression code removes the gaps to have fewer
symbols to deal with, and writes a sparse bitfield indicating which
values were present. We make a translation table to convert the symbols
back to the corresponding bytes. */
t = get_bits(bd, 16);
symTotal = 0;
for (i = 0; i < 16; i++) {
@@ -187,7 +181,6 @@ static int get_next_block(bunzip_data *bd)
}
/* How many different Huffman coding groups does this block use? */
groupCount = get_bits(bd, 3);
if (groupCount < 2 || groupCount > MAX_GROUPS)
return RETVAL_DATA_ERROR;
@@ -196,19 +189,16 @@ static int get_next_block(bunzip_data *bd)
group. Read in the group selector list, which is stored as MTF encoded
bit runs. (MTF=Move To Front, as each value is used it's moved to the
start of the list.) */
nSelectors = get_bits(bd, 15);
if (!nSelectors) return RETVAL_DATA_ERROR;
for (i = 0; i < groupCount; i++) mtfSymbol[i] = i;
for (i = 0; i < nSelectors; i++) {
/* Get next value */
for (j = 0; get_bits(bd, 1); j++)
if (j>=groupCount) return RETVAL_DATA_ERROR;
if (j >= groupCount) return RETVAL_DATA_ERROR;
/* Decode MTF to get the next selector */
uc = mtfSymbol[j];
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
mtfSymbol[0] = selectors[i] = uc;
@@ -216,10 +206,11 @@ static int get_next_block(bunzip_data *bd)
/* Read the Huffman coding tables for each group, which code for symTotal
literal symbols, plus two run symbols (RUNA, RUNB) */
symCount = symTotal + 2;
for (j = 0; j < groupCount; j++) {
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
unsigned char length[MAX_SYMBOLS];
/* 8 bits is ALMOST enough for temp[], see below */
unsigned temp[MAX_HUFCODE_BITS+1];
int minLen, maxLen, pp;
/* Read Huffman code lengths for each symbol. They're stored in
@@ -228,7 +219,6 @@ static int get_next_block(bunzip_data *bd)
(Subtracting 1 before the loop and then adding it back at the end is
an optimization that makes the test inside the loop simpler: symbol
length 0 becomes negative, so an unsigned inequality catches it.) */
t = get_bits(bd, 5) - 1;
for (i = 0; i < symCount; i++) {
for (;;) {
@@ -238,7 +228,6 @@ static int get_next_block(bunzip_data *bd)
/* If first bit is 0, stop. Else second bit indicates whether
to increment or decrement the value. Optimization: grab 2
bits and unget the second if the first was 0. */
k = get_bits(bd, 2);
if (k < 2) {
bd->inbufBitCount++;
@@ -246,17 +235,14 @@ static int get_next_block(bunzip_data *bd)
}
/* Add one if second bit 1, else subtract 1. Avoids if/else */
t += (((k+1) & 2) - 1);
}
/* Correct for the initial -1, to get the final symbol length */
length[i] = t + 1;
}
/* Find largest and smallest lengths in this group */
minLen = maxLen = length[0];
for (i = 1; i < symCount; i++) {
if (length[i] > maxLen) maxLen = length[i];
@@ -273,7 +259,6 @@ static int get_next_block(bunzip_data *bd)
* number of bits can have. This is how the Huffman codes can vary in
* length: each code with a value>limit[length] needs another bit.
*/
hufGroup = bd->groups + j;
hufGroup->minLen = minLen;
hufGroup->maxLen = maxLen;
@@ -281,12 +266,10 @@ static int get_next_block(bunzip_data *bd)
/* Note that minLen can't be smaller than 1, so we adjust the base
and limit array pointers so we're not always wasting the first
entry. We do this again when using them (during symbol decoding).*/
base = hufGroup->base - 1;
limit = hufGroup->limit - 1;
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
pp = 0;
for (i = minLen; i <= maxLen; i++) {
temp[i] = limit[i] = 0;
@@ -296,14 +279,14 @@ static int get_next_block(bunzip_data *bd)
}
/* Count symbols coded for at each bit length */
/* NB: in pathological cases, temp[8] can end ip being 256.
* That's why uint8_t is too small for temp[]. */
for (i = 0; i < symCount; i++) temp[length[i]]++;
/* Calculate limit[] (the largest symbol-coding value at each bit
* length, which is (previous limit<<1)+symbols at this level), and
* base[] (number of symbols to ignore at each bit length, which is
* limit minus the cumulative count of symbols coded for already). */
pp = t = 0;
for (i = minLen; i < maxLen; i++) {
pp += temp[i];
@@ -314,25 +297,24 @@ static int get_next_block(bunzip_data *bd)
each level we're really only interested in the first few bits,
so here we set all the trailing to-be-ignored bits to 1 so they
don't affect the value>limit[length] comparison. */
limit[i] = (pp << (maxLen - i)) - 1;
pp <<= 1;
t += temp[i];
base[i+1] = pp - t;
}
limit[maxLen+1] = INT_MAX; /* Sentinal value for reading next sym. */
limit[maxLen+1] = INT_MAX; /* Sentinel value for reading next sym. */
limit[maxLen] = pp + temp[maxLen] - 1;
base[minLen] = 0;
}
/* We've finished reading and digesting the block header. Now read this
block's Huffman coded symbols from the file and undo the Huffman coding
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
and run length encoding, saving the result into dbuf[dbufCount++] = uc */
/* Initialize symbol occurrence counters and symbol Move To Front table */
memset(byteCount, 0, sizeof(byteCount)); /* smaller, maybe slower? */
for (i = 0; i < 256; i++) {
byteCount[i] = 0;
//byteCount[i] = 0;
mtfSymbol[i] = (unsigned char)i;
}
@@ -341,8 +323,7 @@ static int get_next_block(bunzip_data *bd)
runPos = dbufCount = selector = 0;
for (;;) {
/* fetch next Huffman coding group from list. */
/* Fetch next Huffman coding group from list. */
symCount = GROUP_SIZE - 1;
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
hufGroup = bd->groups + selectors[selector++];
@@ -361,8 +342,7 @@ static int get_next_block(bunzip_data *bd)
dry). The following (up to got_huff_bits:) is equivalent to
j = get_bits(bd, hufGroup->maxLen);
*/
while (bd->inbufBitCount < hufGroup->maxLen) {
while ((int)(bd->inbufBitCount) < hufGroup->maxLen) {
if (bd->inbufPos == bd->inbufCount) {
j = get_bits(bd, hufGroup->maxLen);
goto got_huff_bits;
@@ -376,13 +356,11 @@ static int get_next_block(bunzip_data *bd)
got_huff_bits:
/* Figure how how many bits are in next symbol and unget extras */
i = hufGroup->minLen;
while (j > limit[i]) ++i;
bd->inbufBitCount += (hufGroup->maxLen - i);
/* Huffman decode value to get nextSym (with bounds checking) */
if (i > hufGroup->maxLen)
return RETVAL_DATA_ERROR;
j = (j >> (hufGroup->maxLen - i)) - base[i];
@@ -394,11 +372,9 @@ static int get_next_block(bunzip_data *bd)
byte, or a repeated run of the most recent literal byte. First,
check if nextSym indicates a repeated run, and if so loop collecting
how many times to repeat the last literal. */
if ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
/* If this is the start of a new run, zero out counter */
if (!runPos) {
runPos = 1;
t = 0;
@@ -411,7 +387,6 @@ static int get_next_block(bunzip_data *bd)
the basic or 0/1 method (except all bits 0, which would use no
symbols, but a run of length 0 doesn't mean anything in this
context). Thus space is saved. */
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
if (runPos < dbufSize) runPos <<= 1;
goto end_of_huffman_loop;
@@ -421,7 +396,6 @@ static int get_next_block(bunzip_data *bd)
how many times to repeat the last literal, so append that many
copies to our buffer of decoded symbols (dbuf) now. (The last
literal used is the one at the head of the mtfSymbol array.) */
if (runPos) {
runPos = 0;
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
@@ -432,7 +406,6 @@ static int get_next_block(bunzip_data *bd)
}
/* Is this the terminating symbol? */
if (nextSym > symTotal) break;
/* At this point, nextSym indicates a new literal character. Subtract
@@ -442,7 +415,6 @@ static int get_next_block(bunzip_data *bd)
first symbol in the mtf array, position 0, would have been handled
as part of a run above. Therefore 1 unused mtf position minus
2 non-literal nextSym values equals -1.) */
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
i = nextSym - 1;
uc = mtfSymbol[i];
@@ -451,7 +423,6 @@ static int get_next_block(bunzip_data *bd)
* small number of symbols, and are bound by 256 in any case, using
* memmove here would typically be bigger and slower due to function
* call overhead and other assorted setup costs. */
do {
mtfSymbol[i] = mtfSymbol[i-1];
} while (--i);
@@ -459,13 +430,11 @@ static int get_next_block(bunzip_data *bd)
uc = symToByte[uc];
/* We have our literal byte. Save it into dbuf. */
byteCount[uc]++;
dbuf[dbufCount++] = (unsigned)uc;
/* Skip group initialization if we're not done with this group. Done
* this way to avoid compiler warning. */
end_of_huffman_loop:
if (symCount--) goto continue_this_group;
}
@@ -478,7 +447,6 @@ static int get_next_block(bunzip_data *bd)
*/
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
j = 0;
for (i = 0; i < 256; i++) {
k = j + byteCount[i];
@@ -487,7 +455,6 @@ static int get_next_block(bunzip_data *bd)
}
/* Figure out what order dbuf would be in if we sorted it. */
for (i = 0; i < dbufCount; i++) {
uc = (unsigned char)(dbuf[i] & 0xff);
dbuf[byteCount[uc]] |= (i << 8);
@@ -497,11 +464,10 @@ static int get_next_block(bunzip_data *bd)
/* Decode first byte by hand to initialize "previous" byte. Note that it
doesn't get output, and if the first three characters are identical
it doesn't qualify as a run (hence writeRunCountdown=5). */
if (dbufCount) {
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
if ((int)origPtr >= dbufCount) return RETVAL_DATA_ERROR;
bd->writePos = dbuf[origPtr];
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
bd->writePos >>= 8;
bd->writeRunCountdown = 5;
}
@@ -516,8 +482,7 @@ static int get_next_block(bunzip_data *bd)
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
are ignored, data is written to out_fd and return is RETVAL_OK or error.
*/
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
int FAST_FUNC read_bunzip(bunzip_data *bd, char *outbuf, int len)
{
const unsigned *dbuf;
int pos, current, previous, gotcount;
@@ -533,34 +498,28 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* We will always have pending decoded data to write into the output
buffer unless this is the very first call (in which case we haven't
Huffman-decoded a block into the intermediate buffer yet). */
if (bd->writeCopies) {
/* Inside the loop, writeCopies means extra copies (beyond 1) */
--bd->writeCopies;
/* Loop outputting bytes */
for (;;) {
/* If the output buffer is full, snapshot state and return */
if (gotcount >= len) {
bd->writePos =pos;
bd->writePos = pos;
bd->writeCurrent = current;
bd->writeCopies++;
return len;
}
/* Write next byte into output buffer, updating CRC */
outbuf[gotcount++] = current;
bd->writeCRC = (bd->writeCRC << 8)
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
/* Loop now if we're outputting multiple copies of this byte */
if (bd->writeCopies) {
--bd->writeCopies;
continue;
@@ -573,47 +532,40 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
current = pos & 0xff;
pos >>= 8;
/* After 3 consecutive copies of the same byte, the 4th is a repeat
count. We count down from 4 instead
/* After 3 consecutive copies of the same byte, the 4th
* is a repeat count. We count down from 4 instead
* of counting up because testing for non-zero is faster */
if (--bd->writeRunCountdown) {
if (current != previous)
bd->writeRunCountdown = 4;
} else {
/* We have a repeated run, this byte indicates the count */
bd->writeCopies = current;
current = previous;
bd->writeRunCountdown = 5;
/* Sometimes there are just 3 bytes (run length 0) */
if (!bd->writeCopies) goto decode_next_byte;
/* Subtract the 1 copy we'd output anyway to get extras */
--bd->writeCopies;
}
}
/* Decompression of this block completed successfully */
bd->writeCRC = ~bd->writeCRC;
bd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->writeCRC;
/* If this block had a CRC error, force file level CRC error. */
if (bd->writeCRC != bd->headerCRC) {
bd->totalCRC = bd->headerCRC+1;
bd->totalCRC = bd->headerCRC + 1;
return RETVAL_LAST_BLOCK;
}
}
/* Refill the intermediate buffer by Huffman-decoding next block of input */
/* (previous is just a convenient unused temp variable here) */
previous = get_next_block(bd);
if (previous) {
bd->writeCount = previous;
@@ -625,7 +577,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
goto decode_next_byte;
}
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
ignored, and data is read from file handle into temporary buffer. */
@@ -633,27 +584,24 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
should work for NOFORK applets too, we must be extremely careful to not leak
any allocations! */
int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
int FAST_FUNC start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
int len)
{
bunzip_data *bd;
unsigned i;
enum {
BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0'
BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0',
h0 = ('h' << 8) + '0',
};
/* Figure out how much data to allocate */
i = sizeof(bunzip_data);
if (in_fd != -1) i += IOBUF_SIZE;
/* Allocate bunzip_data. Most fields initialize to zero. */
bd = *bdp = xzalloc(i);
/* Setup input buffer */
bd->in_fd = in_fd;
if (-1 == in_fd) {
/* in this case, bd->inbuf is read-only */
@@ -663,23 +611,25 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
bd->inbuf = (unsigned char *)(bd + 1);
/* Init the CRC32 table (big endian) */
crc32_filltable(bd->crc32Table, 1);
/* Setup for I/O error handling via longjmp */
i = setjmp(bd->jmpbuf);
if (i) return i;
/* Ensure that file starts with "BZh['1'-'9']." */
/* Update: now caller verifies 1st two bytes, makes .gz/.bz2
* integration easier */
/* was: */
/* i = get_bits(bd, 32); */
/* if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA; */
i = get_bits(bd, 16);
if ((unsigned)(i - h0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
i = get_bits(bd, 32);
if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
/* Fourth byte (ascii '1'-'9') indicates block size in units of 100k of
uncompressed data. Allocate intermediate buffer for block. */
bd->dbufSize = 100000 * (i - BZh0);
/* bd->dbufSize = 100000 * (i - BZh0); */
bd->dbufSize = 100000 * (i - h0);
/* Cannot use xmalloc - may leak bd in NOFORK case! */
bd->dbuf = malloc_or_warn(bd->dbufSize * sizeof(int));
@@ -690,7 +640,7 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
return RETVAL_OK;
}
void dealloc_bunzip(bunzip_data *bd)
void FAST_FUNC dealloc_bunzip(bunzip_data *bd)
{
free(bd->dbuf);
free(bd);
@@ -698,8 +648,7 @@ void dealloc_bunzip(bunzip_data *bd)
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
USE_DESKTOP(long long) int
USE_DESKTOP(long long) int FAST_FUNC
unpack_bz2_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
@@ -713,8 +662,8 @@ unpack_bz2_stream(int src_fd, int dst_fd)
for (;;) {
i = read_bunzip(bd, outbuf, IOBUF_SIZE);
if (i <= 0) break;
if (i != safe_write(dst_fd, outbuf, i)) {
i = RETVAL_UNEXPECTED_OUTPUT_EOF;
if (i != full_write(dst_fd, outbuf, i)) {
i = RETVAL_SHORT_WRITE;
break;
}
USE_DESKTOP(total_written += i;)
@@ -725,14 +674,14 @@ unpack_bz2_stream(int src_fd, int dst_fd)
if (i == RETVAL_LAST_BLOCK) {
if (bd->headerCRC != bd->totalCRC) {
bb_error_msg("data integrity error when decompressing");
bb_error_msg("CRC error");
} else {
i = RETVAL_OK;
}
} else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {
bb_error_msg("compressed file ends unexpectedly");
} else if (i == RETVAL_SHORT_WRITE) {
bb_error_msg("short write");
} else {
bb_error_msg("decompression failed");
bb_error_msg("bunzip error %d", i);
}
dealloc_bunzip(bd);
free(outbuf);
@@ -740,6 +689,17 @@ unpack_bz2_stream(int src_fd, int dst_fd)
return i ? i : USE_DESKTOP(total_written) + 0;
}
USE_DESKTOP(long long) int FAST_FUNC
unpack_bz2_stream_prime(int src_fd, int dst_fd)
{
unsigned char magic[2];
xread(src_fd, magic, 2);
if (magic[0] != 'B' || magic[1] != 'Z') {
bb_error_msg_and_die("invalid magic");
}
return unpack_bz2_stream(src_fd, dst_fd);
}
#ifdef TESTING
static char *const bunzip_errors[] = {
@@ -751,13 +711,14 @@ static char *const bunzip_errors[] = {
/* Dumb little test thing, decompress stdin to stdout */
int main(int argc, char **argv)
{
int i = unpack_bz2_stream(0, 1);
int i;
char c;
int i = unpack_bz2_stream_prime(0, 1);
if (i < 0)
fprintf(stderr,"%s\n", bunzip_errors[-i]);
else if (read(0, &c, 1))
fprintf(stderr,"Trailing garbage ignored\n");
fprintf(stderr, "%s\n", bunzip_errors[-i]);
else if (read(STDIN_FILENO, &c, 1))
fprintf(stderr, "Trailing garbage ignored\n");
return -i;
}
#endif
@@ -1,6 +1,4 @@
/* vi: set sw=4 ts=4: */
#include "libbb.h"
/* uncompress for busybox -- (c) 2002 Robert Griebl
*
* based on the original compress42.c source
@@ -26,6 +24,10 @@
*
*/
#include "libbb.h"
#include "unarchive.h"
/* Default input buffer size */
#define IBUFSIZ 2048
@@ -70,8 +72,8 @@
* be stored in the compressed file.
*/
USE_DESKTOP(long long) int
uncompress(int fd_in, int fd_out)
USE_DESKTOP(long long) int FAST_FUNC
unpack_Z_stream(int fd_in, int fd_out)
{
USE_DESKTOP(long long total_written = 0;)
USE_DESKTOP(long long) int retval = -1;
+67 -63
View File
@@ -45,7 +45,7 @@ typedef struct {
/* Called twice: once at startup and once in rc_normalize() */
static void rc_read(rc_t * rc)
static void rc_read(rc_t *rc)
{
int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE);
if (buffer_size <= 0)
@@ -58,9 +58,9 @@ static void rc_read(rc_t * rc)
static rc_t* rc_init(int fd) /*, int buffer_size) */
{
int i;
rc_t* rc;
rc_t *rc;
rc = xmalloc(sizeof(rc_t) + RC_BUFFER_SIZE);
rc = xmalloc(sizeof(*rc) + RC_BUFFER_SIZE);
rc->fd = fd;
/* rc->buffer_size = buffer_size; */
@@ -78,21 +78,20 @@ static rc_t* rc_init(int fd) /*, int buffer_size) */
}
/* Called once */
static ALWAYS_INLINE void rc_free(rc_t * rc)
static ALWAYS_INLINE void rc_free(rc_t *rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc);
free(rc);
}
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
static void rc_do_normalize(rc_t * rc)
static void rc_do_normalize(rc_t *rc)
{
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static ALWAYS_INLINE void rc_normalize(rc_t * rc)
static ALWAYS_INLINE void rc_normalize(rc_t *rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
@@ -105,25 +104,25 @@ static ALWAYS_INLINE void rc_normalize(rc_t * rc)
* Thus rc_is_bit_0 is always inlined, and rc_is_bit_0_helper is inlined
* only if we compile for speed.
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
static speed_inline uint32_t rc_is_bit_0_helper(rc_t *rc, uint16_t *p)
{
rc_normalize(rc);
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
static ALWAYS_INLINE int rc_is_bit_0(rc_t *rc, uint16_t *p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
}
/* Called ~10 times, but very small, thus inlined */
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
static speed_inline void rc_update_bit_0(rc_t *rc, uint16_t *p)
{
rc->range = rc->bound;
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
}
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
static speed_inline void rc_update_bit_1(rc_t *rc, uint16_t *p)
{
rc->range -= rc->bound;
rc->code -= rc->bound;
@@ -131,7 +130,7 @@ static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
}
/* Called 4 times in unlzma loop */
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
static int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)
{
if (rc_is_bit_0(rc, p)) {
rc_update_bit_0(rc, p);
@@ -145,7 +144,7 @@ static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
}
/* Called once */
static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
static ALWAYS_INLINE int rc_direct_bit(rc_t *rc)
{
rc_normalize(rc);
rc->range >>= 1;
@@ -158,7 +157,7 @@ static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
/* Called twice */
static speed_inline void
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
rc_bit_tree_decode(rc_t *rc, uint16_t *p, int num_levels, int *symbol)
{
int i = num_levels;
@@ -229,7 +228,7 @@ enum {
};
USE_DESKTOP(long long) int
USE_DESKTOP(long long) int FAST_FUNC
unpack_lzma_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
@@ -282,14 +281,16 @@ unpack_lzma_stream(int src_fd, int dst_fd)
while (global_pos + buffer_pos < header.dst_size) {
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
prob =
p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
prob = p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
if (rc_is_bit_0(rc, prob)) {
mi = 1;
rc_update_bit_0(rc, prob);
prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
* ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
+ (previous_byte >> (8 - lc)))));
prob = (p + LZMA_LITERAL
+ (LZMA_LIT_SIZE * ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
+ (previous_byte >> (8 - lc))
)
)
);
if (state >= LZMA_NUM_LIT_STATES) {
int match_byte;
@@ -304,35 +305,37 @@ unpack_lzma_stream(int src_fd, int dst_fd)
match_byte <<= 1;
bit = match_byte & 0x100;
prob_lit = prob + 0x100 + bit + mi;
if (rc_get_bit(rc, prob_lit, &mi)) {
if (!bit)
break;
} else {
if (bit)
break;
}
bit ^= (rc_get_bit(rc, prob_lit, &mi) << 8); /* 0x100 or 0 */
if (bit)
break;
} while (mi < 0x100);
}
while (mi < 0x100) {
prob_lit = prob + mi;
rc_get_bit(rc, prob_lit, &mi);
}
previous_byte = (uint8_t) mi;
state -= 3;
if (state < 4-3)
state = 0;
if (state >= 10-3)
state -= 6-3;
previous_byte = (uint8_t) mi;
#if ENABLE_FEATURE_LZMA_FAST
one_byte1:
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
if (state < 4)
state = 0;
else if (state < 10)
state -= 3;
else
state -= 6;
#else
len = 1;
goto one_byte2;
#endif
} else {
int offset;
uint16_t *prob_len;
@@ -352,24 +355,23 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
prob = (p + LZMA_IS_REP_0_LONG
+ (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
+ (state << LZMA_NUM_POS_BITS_MAX)
+ pos_state
);
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
#if ENABLE_FEATURE_LZMA_FAST
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
continue;
goto one_byte1;
#else
len = 1;
goto string;
#endif
} else {
rc_update_bit_1(rc, prob);
}
@@ -405,7 +407,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (rc_is_bit_0(rc, prob_len)) {
rc_update_bit_0(rc, prob_len);
prob_len = (prob + LZMA_LEN_LOW
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
offset = 0;
num_bits = LZMA_LEN_NUM_LOW_BITS;
} else {
@@ -414,14 +416,14 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (rc_is_bit_0(rc, prob_len)) {
rc_update_bit_0(rc, prob_len);
prob_len = (prob + LZMA_LEN_MID
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
offset = 1 << LZMA_LEN_NUM_LOW_BITS;
num_bits = LZMA_LEN_NUM_MID_BITS;
} else {
rc_update_bit_1(rc, prob_len);
prob_len = prob + LZMA_LEN_HIGH;
offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
+ (1 << LZMA_LEN_NUM_MID_BITS));
+ (1 << LZMA_LEN_NUM_MID_BITS));
num_bits = LZMA_LEN_NUM_HIGH_BITS;
}
}
@@ -432,12 +434,10 @@ unpack_lzma_stream(int src_fd, int dst_fd)
int pos_slot;
state += LZMA_NUM_LIT_STATES;
prob =
p + LZMA_POS_SLOT +
((len <
LZMA_NUM_LEN_TO_POS_STATES ? len :
LZMA_NUM_LEN_TO_POS_STATES - 1)
<< LZMA_NUM_POS_SLOT_BITS);
prob = p + LZMA_POS_SLOT +
((len < LZMA_NUM_LEN_TO_POS_STATES ? len :
LZMA_NUM_LEN_TO_POS_STATES - 1)
<< LZMA_NUM_POS_SLOT_BITS);
rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS,
&pos_slot);
if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
@@ -468,17 +468,18 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
len += LZMA_MATCH_MIN_LEN;
SKIP_FEATURE_LZMA_FAST(string:)
do {
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
SKIP_FEATURE_LZMA_FAST(one_byte2:)
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
@@ -487,13 +488,16 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
}
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
{
SKIP_DESKTOP(int total_written = 0; /* success */)
USE_DESKTOP(total_written += buffer_pos;)
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
bad:
total_written = -1; /* failure */
}
rc_free(rc);
return -1;
free(p);
free(buffer);
return total_written;
}
rc_free(rc);
USE_DESKTOP(total_written += buffer_pos;)
return USE_DESKTOP(total_written) + 0;
}
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -9,7 +9,7 @@
#include "unarchive.h"
/* Accept any non-null name, its not really a filter at all */
char filter_accept_all(archive_handle_t *archive_handle)
char FAST_FUNC filter_accept_all(archive_handle_t *archive_handle)
{
if (archive_handle->file_header->name)
return EXIT_SUCCESS;
+1 -1
View File
@@ -11,7 +11,7 @@
/*
* Accept names that are in the accept list, ignoring reject list.
*/
char filter_accept_list(archive_handle_t *archive_handle)
char FAST_FUNC filter_accept_list(archive_handle_t *archive_handle)
{
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name))
return EXIT_SUCCESS;
@@ -8,34 +8,41 @@
#include "libbb.h"
#include "unarchive.h"
/* Built and used only if ENABLE_DPKG || ENABLE_DPKG_DEB */
/*
* Reassign the subarchive metadata parser based on the filename extension
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
*/
char filter_accept_list_reassign(archive_handle_t *archive_handle)
char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
{
/* Check the file entry is in the accept list */
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
const char *name_ptr;
/* Extract the last 2 extensions */
/* Find extension */
name_ptr = strrchr(archive_handle->file_header->name, '.');
if (!name_ptr)
return EXIT_FAILURE;
name_ptr++;
/* Modify the subarchive handler based on the extension */
#if ENABLE_FEATURE_DEB_TAR_GZ
if (strcmp(name_ptr, ".gz") == 0) {
if (ENABLE_FEATURE_SEAMLESS_GZ
&& strcmp(name_ptr, "gz") == 0
) {
archive_handle->action_data_subarchive = get_header_tar_gz;
return EXIT_SUCCESS;
}
#endif
#if ENABLE_FEATURE_DEB_TAR_BZ2
if (strcmp(name_ptr, ".bz2") == 0) {
if (ENABLE_FEATURE_SEAMLESS_BZ2
&& strcmp(name_ptr, "bz2") == 0
) {
archive_handle->action_data_subarchive = get_header_tar_bz2;
return EXIT_SUCCESS;
}
#endif
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) {
if (ENABLE_FEATURE_SEAMLESS_LZMA
&& strcmp(name_ptr, "lzma") == 0
) {
archive_handle->action_data_subarchive = get_header_tar_lzma;
return EXIT_SUCCESS;
}
@@ -11,13 +11,16 @@
/*
* Accept names that are in the accept list and not in the reject list
*/
char filter_accept_reject_list(archive_handle_t *archive_handle)
char FAST_FUNC filter_accept_reject_list(archive_handle_t *archive_handle)
{
const char *key = archive_handle->file_header->name;
const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key);
const char *key;
const llist_t *reject_entry;
const llist_t *accept_entry;
key = archive_handle->file_header->name;
/* If the key is in a reject list fail */
reject_entry = find_list_entry2(archive_handle->reject, key);
if (reject_entry) {
return EXIT_FAILURE;
}
+3 -3
View File
@@ -10,7 +10,7 @@
#include "unarchive.h"
/* Find a string in a shell pattern list */
const llist_t *find_list_entry(const llist_t *list, const char *filename)
const llist_t* FAST_FUNC find_list_entry(const llist_t *list, const char *filename)
{
while (list) {
if (fnmatch(list->data, filename, 0) == 0) {
@@ -24,7 +24,7 @@ const llist_t *find_list_entry(const llist_t *list, const char *filename)
/* Same, but compares only path components present in pattern
* (extra trailing path components in filename are assumed to match)
*/
const llist_t *find_list_entry2(const llist_t *list, const char *filename)
const llist_t* FAST_FUNC find_list_entry2(const llist_t *list, const char *filename)
{
char buf[PATH_MAX];
int pattern_slash_cnt;
@@ -38,7 +38,7 @@ const llist_t *find_list_entry2(const llist_t *list, const char *filename)
if (*c++ == '/') pattern_slash_cnt++;
c = filename;
d = buf;
/* paranoia is better that buffer overflows */
/* paranoia is better than buffer overflows */
while (*c && d != buf + sizeof(buf)-1) {
if (*c == '/' && --pattern_slash_cnt < 0)
break;
+5 -4
View File
@@ -7,7 +7,7 @@
#include "libbb.h"
#include "unarchive.h"
char get_header_ar(archive_handle_t *archive_handle)
char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
{
int err;
file_header_t *typed = archive_handle->file_header;
@@ -108,12 +108,13 @@ char get_header_ar(archive_handle_t *archive_handle)
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(typed);
#if ENABLE_DPKG || ENABLE_DPKG_DEB
if (archive_handle->sub_archive) {
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS)
/* repeat */;
} else {
continue;
} else
#endif
archive_handle->action_data(archive_handle);
}
} else {
data_skip(archive_handle);
}
+117 -97
View File
@@ -7,71 +7,41 @@
#include "libbb.h"
#include "unarchive.h"
typedef struct hardlinks_s {
char *name;
int inode;
struct hardlinks_s *next;
typedef struct hardlinks_t {
struct hardlinks_t *next;
int inode; /* TODO: must match maj/min too! */
int mode ;
int mtime; /* These three are useful only in corner case */
int uid ; /* of hardlinks with zero size body */
int gid ;
char name[1];
} hardlinks_t;
char get_header_cpio(archive_handle_t *archive_handle)
char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
{
static hardlinks_t *saved_hardlinks = NULL;
static unsigned pending_hardlinks = 0;
static int inode;
file_header_t *file_header = archive_handle->file_header;
char cpio_header[110];
int namesize;
char dummy[16];
int major, minor, nlink;
int major, minor, nlink, mode, inode;
unsigned size, uid, gid, mtime;
if (pending_hardlinks) { /* Deal with any pending hardlinks */
hardlinks_t *tmp, *oldtmp;
tmp = saved_hardlinks;
oldtmp = NULL;
file_header->link_target = file_header->name;
file_header->size = 0;
while (tmp) {
if (tmp->inode != inode) {
tmp = tmp->next;
continue;
}
file_header->name = tmp->name;
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
}
pending_hardlinks--;
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
if (oldtmp == saved_hardlinks)
saved_hardlinks = tmp;
}
file_header->name = file_header->link_target;
if (pending_hardlinks > 1) {
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
}
/* No more pending hardlinks, read next file entry */
pending_hardlinks = 0;
}
#define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0]))
#define created_hardlinks (*(hardlinks_t **)(&archive_handle->ah_priv[1]))
// if (!archive_handle->ah_priv_inited) {
// archive_handle->ah_priv_inited = 1;
// hardlinks_to_create = NULL;
// created_hardlinks = NULL;
// }
/* There can be padding before archive header */
data_align(archive_handle, 4);
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
return EXIT_FAILURE;
size = full_read(archive_handle->src_fd, cpio_header, 110);
if (size == 0) {
goto create_hardlinks;
}
if (size != 110) {
bb_error_msg_and_die("short read");
}
archive_handle->offset += 110;
@@ -81,17 +51,21 @@ char get_header_cpio(archive_handle_t *archive_handle)
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
}
{
unsigned long tmpsize;
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, (unsigned int*)&file_header->mode,
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
&nlink, &file_header->mtime, &tmpsize,
dummy, &major, &minor, &namesize, dummy);
file_header->size = tmpsize;
}
if (sscanf(cpio_header + 6,
"%8x" "%8x" "%8x" "%8x"
"%8x" "%8x" "%8x" /*maj,min:*/ "%*16c"
/*rmaj,rmin:*/"%8x" "%8x" "%8x" /*chksum: "%*8c"*/,
&inode, &mode, &uid, &gid,
&nlink, &mtime, &size,
&major, &minor, &namesize) != 10)
bb_error_msg_and_die("damaged cpio file");
file_header->mode = mode;
file_header->uid = uid;
file_header->gid = gid;
file_header->mtime = mtime;
file_header->size = size;
free(file_header->name);
namesize &= 0x1fff; /* paranoia: limit names to 8k chars */
file_header->name = xzalloc(namesize + 1);
/* Read in filename */
xread(archive_handle->src_fd, file_header->name, namesize);
@@ -101,54 +75,46 @@ char get_header_cpio(archive_handle_t *archive_handle)
data_align(archive_handle, 4);
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
/* Always round up */
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
archive_handle->offset / 512 + 1 :
archive_handle->offset / 512
));
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
hardlinks_t *tmp = saved_hardlinks;
hardlinks_t *oldtmp = NULL;
while (tmp) {
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
}
saved_hardlinks = NULL;
pending_hardlinks = 0;
}
return EXIT_FAILURE;
/* Always round up. ">> 9" divides by 512 */
printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
goto create_hardlinks;
}
file_header->link_target = NULL;
if (S_ISLNK(file_header->mode)) {
file_header->size &= 0x1fff; /* paranoia: limit names to 8k chars */
file_header->link_target = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, file_header->link_target, file_header->size);
archive_handle->offset += file_header->size;
file_header->size = 0; /* Stop possible seeks in future */
} else {
file_header->link_target = NULL;
}
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
if (file_header->size == 0) { /* Put file on a linked list for later */
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
new->next = saved_hardlinks;
new->inode = inode;
/* name current allocated, freed later */
new->name = file_header->name;
file_header->name = NULL;
saved_hardlinks = new;
// TODO: data_extract_all can't deal with hardlinks to non-files...
// when fixed, change S_ISREG to !S_ISDIR here
if (nlink > 1 && S_ISREG(file_header->mode)) {
hardlinks_t *new = xmalloc(sizeof(*new) + namesize);
new->inode = inode;
new->mode = mode ;
new->mtime = mtime;
new->uid = uid ;
new->gid = gid ;
strcpy(new->name, file_header->name);
/* Put file on a linked list for later */
if (size == 0) {
new->next = hardlinks_to_create;
hardlinks_to_create = new;
return EXIT_SUCCESS; /* Skip this one */
/* TODO: this breaks cpio -t (it does not show hardlinks) */
}
/* Found the file with data in */
pending_hardlinks = nlink;
new->next = created_hardlinks;
created_hardlinks = new;
}
file_header->device = makedev(major, minor);
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
archive_handle->action_header(file_header);
} else {
data_skip(archive_handle);
}
@@ -156,6 +122,60 @@ char get_header_cpio(archive_handle_t *archive_handle)
archive_handle->offset += file_header->size;
free(file_header->link_target);
free(file_header->name);
file_header->link_target = NULL;
file_header->name = NULL;
return EXIT_SUCCESS;
create_hardlinks:
free(file_header->link_target);
free(file_header->name);
while (hardlinks_to_create) {
hardlinks_t *cur;
hardlinks_t *make_me = hardlinks_to_create;
hardlinks_to_create = make_me->next;
memset(file_header, 0, sizeof(*file_header));
file_header->mtime = make_me->mtime;
file_header->name = make_me->name;
file_header->mode = make_me->mode;
file_header->uid = make_me->uid;
file_header->gid = make_me->gid;
/*file_header->size = 0;*/
/*file_header->link_target = NULL;*/
/* Try to find a file we are hardlinked to */
cur = created_hardlinks;
while (cur) {
/* TODO: must match maj/min too! */
if (cur->inode == make_me->inode) {
file_header->link_target = cur->name;
/* link_target != NULL, size = 0: "I am a hardlink" */
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
archive_handle->action_data(archive_handle);
free(make_me);
goto next_link;
}
cur = cur->next;
}
/* Oops... no file with such inode was created... do it now
* (happens when hardlinked files are empty (zero length)) */
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
archive_handle->action_data(archive_handle);
/* Move to the list of created hardlinked files */
make_me->next = created_hardlinks;
created_hardlinks = make_me;
next_link: ;
}
while (created_hardlinks) {
hardlinks_t *p = created_hardlinks;
created_hardlinks = p->next;
free(p);
}
return EXIT_FAILURE; /* "No more files to process" */
}
+141 -66
View File
@@ -14,26 +14,13 @@
#include "libbb.h"
#include "unarchive.h"
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
static char *longname;
static char *linkname;
#else
enum {
longname = 0,
linkname = 0,
};
#endif
/* NB: _DESTROYS_ str[len] character! */
static unsigned long long getOctal(char *str, int len)
{
unsigned long long v;
/* Actually, tar header allows leading spaces also.
* Oh well, we will be liberal and skip this...
* The only downside probably is that we allow "-123" too :)
if (*str < '0' || *str > '7')
bb_error_msg_and_die("corrupted octal value in tar header");
*/
/* NB: leading spaces are allowed. Using strtoull to handle that.
* The downside is that we accept e.g. "-123" too :)
*/
str[len] = '\0';
v = strtoull(str, &str, 8);
if (*str && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY || *str != ' '))
@@ -43,10 +30,8 @@ static unsigned long long getOctal(char *str, int len)
#define GET_OCTAL(a) getOctal((a), sizeof(a))
void BUG_tar_header_size(void);
char get_header_tar(archive_handle_t *archive_handle)
char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
{
static smallint end;
file_header_t *file_header = archive_handle->file_header;
struct {
/* ustar header, Posix 1003.1 */
@@ -59,8 +44,12 @@ char get_header_tar(archive_handle_t *archive_handle)
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
/* POSIX: "ustar" NUL "00" */
/* GNU tar: "ustar " NUL */
/* Normally it's defined as magic[6] followed by
* version[2], but we put them together to simplify code
*/
char magic[8]; /* 257-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
@@ -75,6 +64,22 @@ char get_header_tar(archive_handle_t *archive_handle)
#endif
int parse_names;
/* Our "private data" */
#define p_end (*(smallint *)(&archive_handle->ah_priv[0]))
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
#define p_longname (*(char* *)(&archive_handle->ah_priv[1]))
#define p_linkname (*(char* *)(&archive_handle->ah_priv[2]))
#else
#define p_longname 0
#define p_linkname 0
#endif
// if (!archive_handle->ah_priv_inited) {
// archive_handle->ah_priv_inited = 1;
// p_end = 0;
// USE_FEATURE_TAR_GNU_EXTENSIONS(p_longname = NULL;)
// USE_FEATURE_TAR_GNU_EXTENSIONS(p_linkname = NULL;)
// }
if (sizeof(tar) != 512)
BUG_tar_header_size();
@@ -86,32 +91,87 @@ char get_header_tar(archive_handle_t *archive_handle)
again_after_align:
xread(archive_handle->src_fd, &tar, 512);
archive_handle->offset += 512;
#if ENABLE_DESKTOP
/* to prevent misdetection of bz2 sig */
*(uint32_t*)(&tar) = 0;
i = full_read(archive_handle->src_fd, &tar, 512);
/* If GNU tar sees EOF in above read, it says:
* "tar: A lone zero block at N", where N = kilobyte
* where EOF was met (not EOF block, actual EOF!),
* and exits with EXIT_SUCCESS.
* We will mimic exit(EXIT_SUCCESS), although we will not mimic
* the message and we don't check whether we indeed
* saw zero block directly before this. */
if (i == 0) {
xfunc_error_retval = 0;
short_read:
bb_error_msg_and_die("short read");
}
if (i != 512) {
USE_FEATURE_TAR_AUTODETECT(goto autodetect;)
goto short_read;
}
#else
i = 512;
xread(archive_handle->src_fd, &tar, i);
#endif
archive_handle->offset += i;
/* If there is no filename its an empty header */
if (tar.name[0] == 0) {
if (end) {
/* This is the second consecutive empty header! End of archive!
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
if (p_end) {
/* Second consecutive empty header - end of archive.
* Read until the end to empty the pipe from gz or bz2
*/
while (full_read(archive_handle->src_fd, &tar, 512) == 512)
/* repeat */;
continue;
return EXIT_FAILURE;
}
end = 1;
p_end = 1;
return EXIT_SUCCESS;
}
end = 0;
p_end = 0;
/* Check header has valid magic, "ustar" is for the proper tar
* 0's are for the old tar format
*/
if (strncmp(tar.magic, "ustar", 5) != 0) {
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (memcmp(tar.magic, "\0\0\0\0", 5) != 0)
/* Check header has valid magic, "ustar" is for the proper tar,
* five NULs are for the old tar format */
if (strncmp(tar.magic, "ustar", 5) != 0
&& (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|| memcmp(tar.magic, "\0\0\0\0", 5) != 0)
) {
#if ENABLE_FEATURE_TAR_AUTODETECT
char FAST_FUNC (*get_header_ptr)(archive_handle_t *);
USE_DESKTOP(autodetect:)
/* tar gz/bz autodetect: check for gz/bz2 magic.
* If we see the magic, and it is the very first block,
* we can switch to get_header_tar_gz/bz2/lzma().
* Needs seekable fd. I wish recv(MSG_PEEK) works
* on any fd... */
#if ENABLE_FEATURE_SEAMLESS_GZ
if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
get_header_ptr = get_header_tar_gz;
} else
#endif
bb_error_msg_and_die("invalid tar magic");
#if ENABLE_FEATURE_SEAMLESS_BZ2
if (tar.name[0] == 'B' && tar.name[1] == 'Z'
&& tar.name[2] == 'h' && isdigit(tar.name[3])
) { /* bzip2 */
get_header_ptr = get_header_tar_bz2;
} else
#endif
goto err;
/* Two different causes for lseek() != 0:
* unseekable fd (would like to support that too, but...),
* or not first block (false positive, it's not .gz/.bz2!) */
if (lseek(archive_handle->src_fd, -i, SEEK_CUR) != 0)
goto err;
while (get_header_ptr(archive_handle) == EXIT_SUCCESS)
continue;
return EXIT_FAILURE;
err:
#endif /* FEATURE_TAR_AUTODETECT */
bb_error_msg_and_die("invalid tar magic");
}
/* Do checksum on headers.
@@ -156,18 +216,23 @@ char get_header_tar(archive_handle_t *archive_handle)
/* getOctal trashes subsequent field, therefore we call it
* on fields in reverse order */
if (tar.devmajor[0]) {
char t = tar.prefix[0];
/* we trash prefix[0] here, but we DO need it later! */
unsigned minor = GET_OCTAL(tar.devminor);
unsigned major = GET_OCTAL(tar.devmajor);
file_header->device = makedev(major, minor);
tar.prefix[0] = t;
}
file_header->link_target = NULL;
if (!linkname && parse_names && tar.linkname[0]) {
/* we trash magic[0] here, it's ok */
tar.linkname[sizeof(tar.linkname)] = '\0';
file_header->link_target = xstrdup(tar.linkname);
if (!p_linkname && parse_names && tar.linkname[0]) {
file_header->link_target = xstrndup(tar.linkname, sizeof(tar.linkname));
/* FIXME: what if we have non-link object with link_target? */
/* Will link_target be free()ed? */
}
#if ENABLE_FEATURE_TAR_UNAME_GNAME
file_header->uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
file_header->gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
#endif
file_header->mtime = GET_OCTAL(tar.mtime);
file_header->size = GET_OCTAL(tar.size);
file_header->gid = GET_OCTAL(tar.gid);
@@ -176,12 +241,14 @@ char get_header_tar(archive_handle_t *archive_handle)
file_header->mode = 07777 & GET_OCTAL(tar.mode);
file_header->name = NULL;
if (!longname && parse_names) {
if (!p_longname && parse_names) {
/* we trash mode[0] here, it's ok */
tar.name[sizeof(tar.name)] = '\0';
//tar.name[sizeof(tar.name)] = '\0'; - gcc 4.3.0 would complain
tar.mode[0] = '\0';
if (tar.prefix[0]) {
/* and padding[0] */
tar.prefix[sizeof(tar.prefix)] = '\0';
//tar.prefix[sizeof(tar.prefix)] = '\0'; - gcc 4.3.0 would complain
tar.padding[0] = '\0';
file_header->name = concat_path_file(tar.prefix, tar.name);
} else
file_header->name = xstrdup(tar.name);
@@ -199,43 +266,48 @@ char get_header_tar(archive_handle_t *archive_handle)
case '0':
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (last_char_is(file_header->name, '/')) {
file_header->mode |= S_IFDIR;
} else
goto set_dir;
}
#endif
file_header->mode |= S_IFREG;
break;
case '2':
file_header->mode |= S_IFLNK;
/* have seen tarballs with size field containing
* the size of the link target's name */
size0:
file_header->size = 0;
break;
case '3':
file_header->mode |= S_IFCHR;
break;
goto size0; /* paranoia */
case '4':
file_header->mode |= S_IFBLK;
break;
goto size0;
case '5':
USE_FEATURE_TAR_OLDGNU_COMPATIBILITY(set_dir:)
file_header->mode |= S_IFDIR;
break;
goto size0;
case '6':
file_header->mode |= S_IFIFO;
break;
goto size0;
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
case 'L':
/* free: paranoia: tar with several consecutive longnames */
free(longname);
free(p_longname);
/* For paranoia reasons we allocate extra NUL char */
longname = xzalloc(file_header->size + 1);
p_longname = xzalloc(file_header->size + 1);
/* We read ASCIZ string, including NUL */
xread(archive_handle->src_fd, longname, file_header->size);
xread(archive_handle->src_fd, p_longname, file_header->size);
archive_handle->offset += file_header->size;
/* return get_header_tar(archive_handle); */
/* gcc 4.1.1 didn't optimize it into jump */
/* so we will do it ourself, this also saves stack */
goto again;
case 'K':
free(linkname);
linkname = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, linkname, file_header->size);
free(p_linkname);
p_linkname = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, p_linkname, file_header->size);
archive_handle->offset += file_header->size;
/* return get_header_tar(archive_handle); */
goto again;
@@ -262,16 +334,16 @@ char get_header_tar(archive_handle_t *archive_handle)
}
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
if (longname) {
file_header->name = longname;
longname = NULL;
if (p_longname) {
file_header->name = p_longname;
p_longname = NULL;
}
if (linkname) {
file_header->link_target = linkname;
linkname = NULL;
if (p_linkname) {
file_header->link_target = p_linkname;
p_linkname = NULL;
}
#endif
if (!strncmp(file_header->name, "/../"+1, 3)
if (strncmp(file_header->name, "/../"+1, 3) == 0
|| strstr(file_header->name, "/../")
) {
bb_error_msg_and_die("name with '..' encountered: '%s'",
@@ -283,11 +355,11 @@ char get_header_tar(archive_handle_t *archive_handle)
cp = last_char_is(file_header->name, '/');
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(archive_handle->file_header);
archive_handle->action_header(/*archive_handle->*/ file_header);
/* Note that we kill the '/' only after action_header() */
/* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */
if (cp) *cp = '\0';
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
archive_handle->ah_flags |= ARCHIVE_EXTRACT_QUIET;
archive_handle->action_data(archive_handle);
llist_add_to(&(archive_handle->passed), file_header->name);
} else {
@@ -297,7 +369,10 @@ char get_header_tar(archive_handle_t *archive_handle)
archive_handle->offset += file_header->size;
free(file_header->link_target);
/* Do not free(file_header->name)! */
/* Do not free(file_header->name)! (why?) */
#if ENABLE_FEATURE_TAR_UNAME_GNAME
free(file_header->uname);
free(file_header->gname);
#endif
return EXIT_SUCCESS;
}
+4 -3
View File
@@ -6,14 +6,15 @@
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_bz2(archive_handle_t *archive_handle)
char FAST_FUNC get_header_tar_bz2(archive_handle_t *archive_handle)
{
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
open_transformer(archive_handle->src_fd, unpack_bz2_stream_prime, "bunzip2");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
continue;
/* Can only do one file at a time */
return EXIT_FAILURE;
+5 -5
View File
@@ -6,7 +6,7 @@
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_gz(archive_handle_t *archive_handle)
char FAST_FUNC get_header_tar_gz(archive_handle_t *archive_handle)
{
#if BB_MMU
unsigned char magic[2];
@@ -20,16 +20,16 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
* need the header. */
#if BB_MMU
xread(archive_handle->src_fd, &magic, 2);
/* Can skip this check, but error message will be less clear */
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip_or_die(archive_handle->src_fd);
#endif
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL);
open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
continue;
/* Can only do one file at a time */
return EXIT_FAILURE;
+4 -3
View File
@@ -9,14 +9,15 @@
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_lzma(archive_handle_t * archive_handle)
char FAST_FUNC get_header_tar_lzma(archive_handle_t *archive_handle)
{
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
continue;
/* Can only do one file at a time */
return EXIT_FAILURE;
+1 -1
View File
@@ -5,7 +5,7 @@
#include "libbb.h"
#include "unarchive.h"
void header_list(const file_header_t *file_header)
void FAST_FUNC header_list(const file_header_t *file_header)
{
puts(file_header->name);
}
+1 -1
View File
@@ -5,6 +5,6 @@
#include "libbb.h"
#include "unarchive.h"
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
void FAST_FUNC header_skip(const file_header_t *file_header UNUSED_PARAM)
{
}
+30 -3
View File
@@ -6,10 +6,37 @@
#include "libbb.h"
#include "unarchive.h"
void header_verbose_list(const file_header_t *file_header)
void FAST_FUNC header_verbose_list(const file_header_t *file_header)
{
struct tm *mtime = localtime(&(file_header->mtime));
#if ENABLE_FEATURE_TAR_UNAME_GNAME
char uid[8];
char gid[8];
char *user = file_header->uname;
char *group = file_header->gname;
if (user == NULL) {
snprintf(uid, sizeof(uid), "%u", (unsigned)file_header->uid);
user = uid;
}
if (group == NULL) {
snprintf(gid, sizeof(gid), "%u", (unsigned)file_header->gid);
group = gid;
}
printf("%s %s/%s %9u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
user,
group,
(unsigned int) file_header->size,
1900 + mtime->tm_year,
1 + mtime->tm_mon,
mtime->tm_mday,
mtime->tm_hour,
mtime->tm_min,
mtime->tm_sec,
file_header->name);
#else /* !FEATURE_TAR_UNAME_GNAME */
printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
file_header->uid,
@@ -22,10 +49,10 @@ void header_verbose_list(const file_header_t *file_header)
mtime->tm_min,
mtime->tm_sec,
file_header->name);
#endif /* FEATURE_TAR_UNAME_GNAME */
if (file_header->link_target) {
printf(" -> %s", file_header->link_target);
}
/* putchar isnt used anywhere else i dont think */
puts("");
bb_putchar('\n');
}
+1 -1
View File
@@ -6,7 +6,7 @@
#include "libbb.h"
#include "unarchive.h"
archive_handle_t *init_handle(void)
archive_handle_t* FAST_FUNC init_handle(void)
{
archive_handle_t *archive_handle;
+30 -25
View File
@@ -8,52 +8,57 @@
/* transformer(), more than meets the eye */
/*
* On MMU machine, the transform_prog and ... are stripped
* by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
* On MMU machine, the transform_prog is removed by macro magic
* in include/unarchive.h. On NOMMU, transformer is removed.
*/
int open_transformer(int src_fd,
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
const char *transform_prog, ...)
void FAST_FUNC open_transformer(int fd,
USE_DESKTOP(long long) int FAST_FUNC (*transformer)(int src_fd, int dst_fd),
const char *transform_prog)
{
int fd_pipe[2];
struct fd_pair fd_pipe;
int pid;
xpipe(fd_pipe);
xpiped_pair(fd_pipe);
#if BB_MMU
pid = fork();
if (pid == -1)
bb_perror_msg_and_die("vfork" + 1);
#else
pid = vfork();
#endif
if (pid == -1)
bb_perror_msg_and_die("fork failed");
bb_perror_msg_and_die("vfork");
#endif
if (pid == 0) {
#if !BB_MMU
va_list ap;
#endif
/* child process */
close(fd_pipe[0]); /* We don't wan't to read from the parent */
close(fd_pipe.rd); /* we don't want to read from the parent */
// FIXME: error check?
#if BB_MMU
transformer(src_fd, fd_pipe[1]);
transformer(fd, fd_pipe.wr);
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd_pipe[1]); /* Send EOF */
close(src_fd);
close(fd_pipe.wr); /* send EOF */
close(fd);
}
exit(0);
/* must be _exit! bug was actually seen here */
_exit(EXIT_SUCCESS);
#else
xmove_fd(src_fd, 0);
xmove_fd(fd_pipe[1], 1);
va_start(ap, transform_prog);
BB_EXECVP(transform_prog, ap);
bb_perror_and_die("exec failed");
{
char *argv[4];
xmove_fd(fd, 0);
xmove_fd(fd_pipe.wr, 1);
argv[0] = (char*)transform_prog;
argv[1] = (char*)"-cf";
argv[2] = (char*)"-";
argv[3] = NULL;
BB_EXECVP(transform_prog, argv);
bb_perror_msg_and_die("can't exec %s", transform_prog);
}
#endif
/* notreached */
}
/* parent process */
close(fd_pipe[1]); /* Don't want to write to the child */
return fd_pipe[0];
close(fd_pipe.wr); /* don't want to write to the child */
xmove_fd(fd_pipe.rd, fd);
}
+6 -6
View File
@@ -6,14 +6,14 @@
#include "libbb.h"
#include "unarchive.h"
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
void FAST_FUNC seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#if ENABLE_FEATURE_UNARCHIVE_TAPE
if (errno == ESPIPE) {
if (amount
&& lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1
) {
if (errno == ESPIPE)
seek_by_read(archive_handle, amount);
} else
#endif
else
bb_perror_msg_and_die("seek failure");
}
}
+2 -2
View File
@@ -6,10 +6,10 @@
#include "libbb.h"
#include "unarchive.h"
/* If we are reading through a pipe(), or from stdin then we can't lseek,
/* If we are reading through a pipe, or from stdin then we can't lseek,
* we must read and discard the data to skip over it.
*/
void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size)
void FAST_FUNC seek_by_read(const archive_handle_t *archive_handle, unsigned jump_size)
{
if (jump_size)
bb_copyfd_exact_size(archive_handle->src_fd, -1, jump_size);
+3 -2
View File
@@ -6,7 +6,7 @@
#include "libbb.h"
#include "unarchive.h"
void unpack_ar_archive(archive_handle_t *ar_archive)
void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
{
char magic[7];
@@ -16,5 +16,6 @@ void unpack_ar_archive(archive_handle_t *ar_archive)
}
ar_archive->offset += 7;
while (get_header_ar(ar_archive) == EXIT_SUCCESS);
while (get_header_ar(ar_archive) == EXIT_SUCCESS)
continue;
}
+20 -22
View File
@@ -80,7 +80,7 @@ static void fileaction_dobackup(char *filename, int fileref);
static void fileaction_setowngrp(char *filename, int fileref);
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
int rpm_main(int argc, char **argv);
int rpm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rpm_main(int argc, char **argv)
{
int opt = 0, func = 0, rpm_fd, offset;
@@ -190,7 +190,7 @@ static void extract_cpio_gz(int fd)
archive_handle_t *archive_handle;
unsigned char magic[2];
#if BB_MMU
USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
USE_DESKTOP(long long) int FAST_FUNC (*xformer)(int src_fd, int dst_fd);
enum { xformer_prog = 0 };
#else
enum { xformer = 0 };
@@ -202,10 +202,11 @@ static void extract_cpio_gz(int fd)
archive_handle->seek = seek_by_read;
//archive_handle->action_header = header_list;
archive_handle->action_data = data_extract_all;
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
archive_handle->ah_flags = ARCHIVE_PRESERVE_DATE | ARCHIVE_CREATE_LEADING_DIRS;
archive_handle->src_fd = fd;
archive_handle->offset = 0;
/*archive_handle->offset = 0; - init_handle() did it */
// TODO: open_zipped does the same
xread(archive_handle->src_fd, &magic, 2);
#if BB_MMU
@@ -213,23 +214,20 @@ static void extract_cpio_gz(int fd)
#else
xformer_prog = "gunzip";
#endif
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
if (ENABLE_FEATURE_RPM_BZ2
&& (magic[0] == 0x42) && (magic[1] == 0x5a)) {
#if BB_MMU
xformer = unpack_bz2_stream;
#else
xformer_prog = "bunzip2";
#endif
/* We can do better, need modifying unpack_bz2_stream to not require
* first 2 bytes. Not very hard to do... I mean, TODO :) */
xlseek(archive_handle->src_fd, -2, SEEK_CUR);
} else
if (magic[0] != 0x1f || magic[1] != 0x8b) {
if (!ENABLE_FEATURE_SEAMLESS_BZ2
|| magic[0] != 'B' || magic[1] != 'Z'
) {
bb_error_msg_and_die("no gzip"
USE_FEATURE_RPM_BZ2("/bzip")
USE_FEATURE_SEAMLESS_BZ2("/bzip2")
" magic");
}
#if BB_MMU
xformer = unpack_bz2_stream;
#else
xformer_prog = "bunzip2";
#endif
} else {
check_header_gzip_or_die(archive_handle->src_fd);
#if !BB_MMU
/* NOMMU version of open_transformer execs an external unzipper that should
* have the file position at the start of the file */
@@ -238,7 +236,7 @@ static void extract_cpio_gz(int fd)
}
xchdir("/"); /* Install RPM's to root */
archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL);
open_transformer(archive_handle->src_fd, xformer, xformer_prog);
archive_handle->offset = 0;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
continue;
@@ -281,12 +279,12 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
tmpindex->type = ntohl(tmpindex->type);
tmpindex->count = ntohl(tmpindex->count);
tmpindex->offset = storepos + ntohl(tmpindex->offset);
if (pass==0)
if (pass == 0)
tmpindex->tag -= 743;
}
xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
/* Skip padding to 8 byte boundary after reading signature headers */
if (pass==0)
if (pass == 0)
xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR);
}
tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
+9 -10
View File
@@ -13,14 +13,14 @@
#define RPM_HEADER_MAGIC "\216\255\350"
struct rpm_lead {
unsigned char magic[4];
uint8_t major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
unsigned char magic[4];
uint8_t major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
};
struct rpm_header {
@@ -49,7 +49,7 @@ static void skip_header(int rpm_fd)
}
/* No getopt required */
int rpm2cpio_main(int argc, char **argv);
int rpm2cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rpm2cpio_main(int argc, char **argv)
{
struct rpm_lead lead;
@@ -79,7 +79,6 @@ int rpm2cpio_main(int argc, char **argv)
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip_or_die(rpm_fd);
if (unpack_gz_stream(rpm_fd, STDOUT_FILENO) < 0) {
bb_error_msg("error inflating");
}
+226 -179
View File
@@ -3,7 +3,7 @@
* Mini tar implementation for busybox
*
* Modified to use common extraction code used by ar, cpio, dpkg-deb, dpkg
* Glenn McGrath <bug1@iinet.net.au>
* by Glenn McGrath
*
* Note, that as of BusyBox-0.43, tar has been completely rewritten from the
* ground up. It still has remnants of the old code lying about, but it is
@@ -24,12 +24,25 @@
*/
#include <fnmatch.h>
#include <getopt.h>
#include "libbb.h"
#include "unarchive.h"
/* FIXME: Stop using this non-standard feature */
#ifndef FNM_LEADING_DIR
#define FNM_LEADING_DIR 0
#endif
#define block_buf bb_common_bufsiz1
#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
/* Do not pass gzip flag to writeTarFile() */
#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
#endif
#if ENABLE_FEATURE_TAR_CREATE
/* Tar file constants */
@@ -50,14 +63,18 @@ struct TarHeader { /* byte offset */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[NAME_SIZE]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
/* POSIX: "ustar" NUL "00" */
/* GNU tar: "ustar " NUL */
/* Normally it's defined as magic[6] followed by
* version[2], but we put them together to save code.
*/
char magic[8]; /* 257-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */
char padding[12]; /* 500-512 (pad to exactly TAR_BLOCK_SIZE) */
};
/*
@@ -67,26 +84,26 @@ struct TarHeader { /* byte offset */
*/
typedef struct HardLinkInfo HardLinkInfo;
struct HardLinkInfo {
HardLinkInfo *next; /* Next entry in list */
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
short linkCount; /* (Hard) Link Count */
char name[1]; /* Start of filename (must be last) */
HardLinkInfo *next; /* Next entry in list */
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
short linkCount; /* (Hard) Link Count */
char name[1]; /* Start of filename (must be last) */
};
/* Some info to be carried along when creating a new tarball */
typedef struct TarBallInfo TarBallInfo;
struct TarBallInfo {
int tarFd; /* Open-for-write file descriptor
for the tarball */
struct stat statBuf; /* Stat info for the tarball, letting
us know the inode and device that the
tarball lives, so we can avoid trying
to include the tarball into itself */
int verboseFlag; /* Whether to print extra stuff or not */
const llist_t *excludeList; /* List of files to not include */
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
int tarFd; /* Open-for-write file descriptor
* for the tarball */
struct stat statBuf; /* Stat info for the tarball, letting
* us know the inode and device that the
* tarball lives, so we can avoid trying
* to include the tarball into itself */
int verboseFlag; /* Whether to print extra stuff or not */
const llist_t *excludeList; /* List of files to not include */
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
};
/* A nice enum with all the possible tar file content types */
@@ -106,7 +123,7 @@ enum TarFileType {
typedef enum TarFileType TarFileType;
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
static void addHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr,
static void addHardLinkInfo(HardLinkInfo **hlInfoHeadPtr,
struct stat *statbuf,
const char *fileName)
{
@@ -122,7 +139,7 @@ static void addHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr,
strcpy(hlInfo->name, fileName);
}
static void freeHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr)
static void freeHardLinkInfo(HardLinkInfo **hlInfoHeadPtr)
{
HardLinkInfo *hlInfo;
HardLinkInfo *hlInfoNext;
@@ -139,7 +156,7 @@ static void freeHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr)
}
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
static HardLinkInfo *findHardLinkInfo(HardLinkInfo * hlInfo, struct stat *statbuf)
static HardLinkInfo *findHardLinkInfo(HardLinkInfo *hlInfo, struct stat *statbuf)
{
while (hlInfo) {
if ((statbuf->st_ino == hlInfo->ino) && (statbuf->st_dev == hlInfo->dev))
@@ -379,13 +396,34 @@ static int exclude_file(const llist_t *excluded_files, const char *file)
#define exclude_file(excluded_files, file) 0
#endif
static int writeFileToTarball(const char *fileName, struct stat *statbuf,
void *userData, int depth ATTRIBUTE_UNUSED)
static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statbuf,
void *userData, int depth UNUSED_PARAM)
{
struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData;
const char *header_name;
int inputFileFd = -1;
/* Strip leading '/' (must be before memorizing hardlink's name) */
header_name = fileName;
while (header_name[0] == '/') {
static smallint warned;
if (!warned) {
bb_error_msg("removing leading '/' from member names");
warned = 1;
}
header_name++;
}
if (header_name[0] == '\0')
return TRUE;
/* It is against the rules to archive a socket */
if (S_ISSOCK(statbuf->st_mode)) {
bb_error_msg("%s: socket ignored", fileName);
return TRUE;
}
/*
* Check to see if we are dealing with a hard link.
* If so -
@@ -397,48 +435,29 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
if (statbuf->st_nlink > 1) {
tbInfo->hlInfo = findHardLinkInfo(tbInfo->hlInfoHead, statbuf);
if (tbInfo->hlInfo == NULL)
addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, fileName);
}
/* It is against the rules to archive a socket */
if (S_ISSOCK(statbuf->st_mode)) {
bb_error_msg("%s: socket ignored", fileName);
return TRUE;
addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, header_name);
}
/* It is a bad idea to store the archive we are in the process of creating,
* so check the device and inode to be sure that this particular file isn't
* the new tarball */
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
tbInfo->statBuf.st_ino == statbuf->st_ino) {
if (tbInfo->statBuf.st_dev == statbuf->st_dev
&& tbInfo->statBuf.st_ino == statbuf->st_ino
) {
bb_error_msg("%s: file is the archive; skipping", fileName);
return TRUE;
}
header_name = fileName;
while (header_name[0] == '/') {
static smallint warned;
if (!warned) {
bb_error_msg("removing leading '/' from member names");
warned = 1;
}
header_name++;
}
if (exclude_file(tbInfo->excludeList, header_name))
return SKIP;
#if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS
if (strlen(fileName) >= NAME_SIZE) {
if (strlen(header_name) >= NAME_SIZE) {
bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
return TRUE;
}
#endif
if (header_name[0] == '\0')
return TRUE;
if (exclude_file(tbInfo->excludeList, header_name))
return SKIP;
/* Is this a regular file? */
if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) {
/* open the file we want to archive, and make sure all is well */
@@ -484,11 +503,90 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
return TRUE;
}
static int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip)
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
#if !(ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2)
#define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd)
#endif
/* Don't inline: vfork scares gcc and pessimizes code */
static void NOINLINE vfork_compressor(int tar_fd, int gzip)
{
pid_t gzipPid;
#if ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
#elif ENABLE_FEATURE_SEAMLESS_GZ
const char *zip_exec = "gzip";
#else /* only ENABLE_FEATURE_SEAMLESS_BZ2 */
const char *zip_exec = "bzip2";
#endif
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
#define WAIT_FOR_CHILD 0
volatile int vfork_exec_errno = 0;
struct fd_pair gzipDataPipe;
#if WAIT_FOR_CHILD
struct fd_pair gzipStatusPipe;
xpiped_pair(gzipStatusPipe);
#endif
xpiped_pair(gzipDataPipe);
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
#if defined(__GNUC__) && __GNUC__
/* Avoid vfork clobbering */
(void) &zip_exec;
#endif
gzipPid = vfork();
if (gzipPid < 0)
bb_perror_msg_and_die("vfork");
if (gzipPid == 0) {
/* child */
/* NB: close _first_, then move fds! */
close(gzipDataPipe.wr);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.rd);
/* gzipStatusPipe.wr will close only on exec -
* parent waits for this close to happen */
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
#endif
xmove_fd(gzipDataPipe.rd, 0);
xmove_fd(tar_fd, 1);
/* exec gzip/bzip2 program/applet */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
_exit(EXIT_FAILURE);
}
/* parent */
xmove_fd(gzipDataPipe.wr, tar_fd);
close(gzipDataPipe.rd);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.wr);
while (1) {
char buf;
int n;
/* Wait until child execs (or fails to) */
n = full_read(gzipStatusPipe.rd, &buf, 1);
if (n < 0 /* && errno == EAGAIN */)
continue; /* try it again */
}
close(gzipStatusPipe.rd);
#endif
if (vfork_exec_errno) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("cannot exec %s", zip_exec);
}
}
#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 */
/* gcc 4.2.1 inlines it, making code bigger */
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
const llist_t *exclude, int gzip)
{
pid_t gzipPid = 0;
int errorFlag = FALSE;
struct TarBallInfo tbInfo;
@@ -503,62 +601,11 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
bb_perror_msg_and_die("cannot stat tar file");
if ((ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2) && gzip) {
int gzipDataPipe[2] = { -1, -1 };
int gzipStatusPipe[2] = { -1, -1 };
volatile int vfork_exec_errno = 0;
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
xpipe(gzipDataPipe);
xpipe(gzipStatusPipe);
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
#if defined(__GNUC__) && __GNUC__
/* Avoid vfork clobbering */
(void) &include;
(void) &errorFlag;
(void) &zip_exec;
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
if (gzip)
vfork_compressor(tbInfo.tarFd, gzip);
#endif
gzipPid = vfork();
if (gzipPid == 0) {
dup2(gzipDataPipe[0], 0);
close(gzipDataPipe[1]);
dup2(tbInfo.tarFd, 1);
close(gzipStatusPipe[0]);
fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows success */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
close(gzipStatusPipe[1]);
exit(-1);
} else if (gzipPid > 0) {
close(gzipDataPipe[0]);
close(gzipStatusPipe[1]);
while (1) {
char buf;
int n = full_read(gzipStatusPipe[0], &buf, 1);
if (n == 0 && vfork_exec_errno != 0) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("cannot exec %s", zip_exec);
} else if ((n < 0) && (errno == EAGAIN || errno == EINTR))
continue; /* try it again */
break;
}
close(gzipStatusPipe[0]);
tbInfo.tarFd = gzipDataPipe[1];
} else bb_perror_msg_and_die("vfork gzip");
}
tbInfo.excludeList = exclude;
/* Read the directory/files and iterate over them one at a time */
@@ -590,37 +637,34 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
if (errorFlag)
bb_error_msg("error exit delayed from previous errors");
if (gzipPid) {
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
if (gzip) {
int status;
if (waitpid(gzipPid, &status, 0) == -1)
if (safe_waitpid(-1, &status, 0) == -1)
bb_perror_msg("waitpid");
else if (!WIFEXITED(status) || WEXITSTATUS(status))
/* gzip was killed or has exited with nonzero! */
errorFlag = TRUE;
}
#endif
return errorFlag;
}
#else
int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip);
int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
const llist_t *exclude, int gzip);
#endif /* FEATURE_TAR_CREATE */
#if ENABLE_FEATURE_TAR_FROM
static llist_t *append_file_list_to_list(llist_t *list)
{
FILE *src_stream;
llist_t *cur = list;
llist_t *tmp;
char *line;
llist_t *newlist = NULL;
while (cur) {
src_stream = xfopen(cur->data, "r");
tmp = cur;
cur = cur->link;
free(tmp);
while ((line = xmalloc_getline(src_stream)) != NULL) {
while (list) {
src_stream = xfopen_for_read(llist_pop(&list));
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(line, '/');
if (cp > line)
@@ -635,8 +679,8 @@ static llist_t *append_file_list_to_list(llist_t *list)
#define append_file_list_to_list(x) 0
#endif
#if ENABLE_FEATURE_TAR_COMPRESS
static char get_header_tar_Z(archive_handle_t *archive_handle)
#if ENABLE_FEATURE_SEAMLESS_Z
static char FAST_FUNC get_header_tar_Z(archive_handle_t *archive_handle)
{
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
@@ -648,10 +692,10 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
bb_error_msg_and_die("invalid magic");
}
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL);
open_transformer(archive_handle->src_fd, unpack_Z_stream, "uncompress");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
/* nothing */;
continue;
/* Can only do one file at a time */
return EXIT_FAILURE;
@@ -670,7 +714,7 @@ static void handle_SIGCHLD(int status)
/* Actually, 'status' is a signo. We reuse it for other needs */
/* Wait for any child without blocking */
if (waitpid(-1, &status, WNOHANG) < 0)
if (wait_any_nohang(&status) < 0)
/* wait failed?! I'm confused... */
return;
@@ -685,14 +729,14 @@ static void handle_SIGCHLD(int status)
enum {
OPTBIT_KEEP_OLD = 7,
USE_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
USE_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,)
USE_FEATURE_TAR_BZIP2( OPTBIT_BZIP2 ,)
USE_FEATURE_TAR_LZMA( OPTBIT_LZMA ,)
USE_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
USE_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
USE_FEATURE_TAR_GZIP( OPTBIT_GZIP ,)
USE_FEATURE_TAR_COMPRESS(OPTBIT_COMPRESS ,)
USE_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
USE_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,)
USE_FEATURE_SEAMLESS_BZ2( OPTBIT_BZIP2 ,)
USE_FEATURE_SEAMLESS_LZMA(OPTBIT_LZMA ,)
USE_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
USE_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
USE_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
USE_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
OPTBIT_NOPRESERVE_OWN,
OPTBIT_NOPRESERVE_PERM,
OPT_TEST = 1 << 0, // t
@@ -703,14 +747,14 @@ enum {
OPT_P = 1 << 5, // p
OPT_VERBOSE = 1 << 6, // v
OPT_KEEP_OLD = 1 << 7, // k
OPT_CREATE = USE_FEATURE_TAR_CREATE( (1<<OPTBIT_CREATE )) + 0, // c
OPT_DEREFERENCE = USE_FEATURE_TAR_CREATE( (1<<OPTBIT_DEREFERENCE )) + 0, // h
OPT_BZIP2 = USE_FEATURE_TAR_BZIP2( (1<<OPTBIT_BZIP2 )) + 0, // j
OPT_LZMA = USE_FEATURE_TAR_LZMA( (1<<OPTBIT_LZMA )) + 0, // a
OPT_INCLUDE_FROM = USE_FEATURE_TAR_FROM( (1<<OPTBIT_INCLUDE_FROM)) + 0, // T
OPT_EXCLUDE_FROM = USE_FEATURE_TAR_FROM( (1<<OPTBIT_EXCLUDE_FROM)) + 0, // X
OPT_GZIP = USE_FEATURE_TAR_GZIP( (1<<OPTBIT_GZIP )) + 0, // z
OPT_COMPRESS = USE_FEATURE_TAR_COMPRESS((1<<OPTBIT_COMPRESS )) + 0, // Z
OPT_CREATE = USE_FEATURE_TAR_CREATE( (1 << OPTBIT_CREATE )) + 0, // c
OPT_DEREFERENCE = USE_FEATURE_TAR_CREATE( (1 << OPTBIT_DEREFERENCE )) + 0, // h
OPT_BZIP2 = USE_FEATURE_SEAMLESS_BZ2( (1 << OPTBIT_BZIP2 )) + 0, // j
OPT_LZMA = USE_FEATURE_SEAMLESS_LZMA((1 << OPTBIT_LZMA )) + 0, // a
OPT_INCLUDE_FROM = USE_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
OPT_EXCLUDE_FROM = USE_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
OPT_GZIP = USE_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
OPT_COMPRESS = USE_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
OPT_NOPRESERVE_OWN = 1 << OPTBIT_NOPRESERVE_OWN , // no-same-owner
OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions
};
@@ -728,20 +772,20 @@ static const char tar_longopts[] ALIGN1 =
"create\0" No_argument "c"
"dereference\0" No_argument "h"
# endif
# if ENABLE_FEATURE_TAR_BZIP2
# if ENABLE_FEATURE_SEAMLESS_BZ2
"bzip2\0" No_argument "j"
# endif
# if ENABLE_FEATURE_TAR_LZMA
# if ENABLE_FEATURE_SEAMLESS_LZMA
"lzma\0" No_argument "a"
# endif
# if ENABLE_FEATURE_TAR_FROM
"files-from\0" Required_argument "T"
"exclude-from\0" Required_argument "X"
# endif
# if ENABLE_FEATURE_TAR_GZIP
# if ENABLE_FEATURE_SEAMLESS_GZ
"gzip\0" No_argument "z"
# endif
# if ENABLE_FEATURE_TAR_COMPRESS
# if ENABLE_FEATURE_SEAMLESS_Z
"compress\0" No_argument "Z"
# endif
"no-same-owner\0" No_argument "\xfd"
@@ -755,10 +799,10 @@ static const char tar_longopts[] ALIGN1 =
;
#endif
int tar_main(int argc, char **argv);
int tar_main(int argc, char **argv)
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tar_main(int argc UNUSED_PARAM, char **argv)
{
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
char FAST_FUNC (*get_header_ptr)(archive_handle_t *) = get_header_tar;
archive_handle_t *tar_handle;
char *base_dir = NULL;
const char *tar_filename = "-";
@@ -770,9 +814,9 @@ int tar_main(int argc, char **argv)
/* Initialise default values */
tar_handle = init_handle();
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS
| ARCHIVE_PRESERVE_DATE
| ARCHIVE_EXTRACT_UNCONDITIONAL;
tar_handle->ah_flags = ARCHIVE_CREATE_LEADING_DIRS
| ARCHIVE_PRESERVE_DATE
| ARCHIVE_EXTRACT_UNCONDITIONAL;
/* Prepend '-' to the first argument if required */
opt_complementary = "--:" // first arg is options
@@ -790,12 +834,12 @@ int tar_main(int argc, char **argv)
#endif
opt = getopt32(argv,
"txC:f:Opvk"
USE_FEATURE_TAR_CREATE( "ch" )
USE_FEATURE_TAR_BZIP2( "j" )
USE_FEATURE_TAR_LZMA( "a" )
USE_FEATURE_TAR_FROM( "T:X:")
USE_FEATURE_TAR_GZIP( "z" )
USE_FEATURE_TAR_COMPRESS("Z" )
USE_FEATURE_TAR_CREATE( "ch" )
USE_FEATURE_SEAMLESS_BZ2( "j" )
USE_FEATURE_SEAMLESS_LZMA("a" )
USE_FEATURE_TAR_FROM( "T:X:")
USE_FEATURE_SEAMLESS_GZ( "z" )
USE_FEATURE_SEAMLESS_Z( "Z" )
, &base_dir // -C dir
, &tar_filename // -f filename
USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
@@ -806,6 +850,7 @@ int tar_main(int argc, char **argv)
, &verboseFlag // combined count for -t and -v
, &verboseFlag // combined count for -t and -v
);
argv += optind;
if (verboseFlag) tar_handle->action_header = header_verbose_list;
if (verboseFlag == 1) tar_handle->action_header = header_list;
@@ -817,13 +862,13 @@ int tar_main(int argc, char **argv)
tar_handle->action_data = data_extract_to_stdout;
if (opt & OPT_KEEP_OLD)
tar_handle->flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL;
tar_handle->ah_flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL;
if (opt & OPT_NOPRESERVE_OWN)
tar_handle->flags |= ARCHIVE_NOPRESERVE_OWN;
tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_OWN;
if (opt & OPT_NOPRESERVE_PERM)
tar_handle->flags |= ARCHIVE_NOPRESERVE_PERM;
tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM;
if (opt & OPT_GZIP)
get_header_ptr = get_header_tar_gz;
@@ -851,21 +896,15 @@ int tar_main(int argc, char **argv)
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
#endif
/* Check if we are reading from stdin */
if (argv[optind] && *argv[optind] == '-') {
/* Default is to read from stdin, so just skip to next arg */
optind++;
}
/* Setup an array of filenames to work with */
/* TODO: This is the same as in ar, separate function ? */
while (optind < argc) {
while (*argv) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(argv[optind], '/');
if (cp > argv[optind])
char *cp = last_char_is(*argv, '/');
if (cp > *argv)
*cp = '\0';
llist_add_to_end(&tar_handle->accept, argv[optind]);
optind++;
llist_add_to_end(&tar_handle->accept, *argv);
argv++;
}
if (tar_handle->accept || tar_handle->reject)
@@ -883,8 +922,7 @@ int tar_main(int argc, char **argv)
tar_stream = stdout;
/* Mimicking GNU tar 1.15.1: */
flags = O_WRONLY|O_CREAT|O_TRUNC;
/* was doing unlink; open(O_WRONLY|O_CREAT|O_EXCL); why? */
flags = O_WRONLY | O_CREAT | O_TRUNC;
} else {
tar_stream = stdin;
flags = O_RDONLY;
@@ -894,7 +932,14 @@ int tar_main(int argc, char **argv)
tar_handle->src_fd = fileno(tar_stream);
tar_handle->seek = seek_by_read;
} else {
tar_handle->src_fd = xopen(tar_filename, flags);
if (ENABLE_FEATURE_TAR_AUTODETECT && flags == O_RDONLY) {
get_header_ptr = get_header_tar;
tar_handle->src_fd = open_zipped(tar_filename);
if (tar_handle->src_fd < 0)
bb_perror_msg_and_die("can't open '%s'", tar_filename);
} else {
tar_handle->src_fd = xopen(tar_filename, flags);
}
}
}
@@ -908,11 +953,13 @@ int tar_main(int argc, char **argv)
/* create an archive */
if (opt & OPT_CREATE) {
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
int zipMode = 0;
if (ENABLE_FEATURE_TAR_GZIP && get_header_ptr == get_header_tar_gz)
if (ENABLE_FEATURE_SEAMLESS_GZ && (opt & OPT_GZIP))
zipMode = 1;
if (ENABLE_FEATURE_TAR_BZIP2 && get_header_ptr == get_header_tar_bz2)
if (ENABLE_FEATURE_SEAMLESS_BZ2 && (opt & OPT_BZIP2))
zipMode = 2;
#endif
/* NB: writeTarFile() closes tar_handle->src_fd */
return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE,
tar_handle->accept,
@@ -920,7 +967,7 @@ int tar_main(int argc, char **argv)
}
while (get_header_ptr(tar_handle) == EXIT_SUCCESS)
/* nothing */;
continue;
/* Check that every file that should have been extracted was */
while (tar_handle->accept) {
+162 -123
View File
@@ -27,37 +27,67 @@
#include "libbb.h"
#include "unarchive.h"
#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
#define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50)
#define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50)
#define ZIP_DD_MAGIC SWAP_LE32(0x08074b50)
enum {
#if BB_BIG_ENDIAN
ZIP_FILEHEADER_MAGIC = 0x504b0304,
ZIP_CDS_MAGIC = 0x504b0102,
ZIP_CDS_END_MAGIC = 0x504b0506,
ZIP_DD_MAGIC = 0x504b0708,
#else
ZIP_FILEHEADER_MAGIC = 0x04034b50,
ZIP_CDS_MAGIC = 0x02014b50,
ZIP_CDS_END_MAGIC = 0x06054b50,
ZIP_DD_MAGIC = 0x08074b50,
#endif
};
#define ZIP_HEADER_LEN 26
typedef union {
unsigned char raw[26];
uint8_t raw[ZIP_HEADER_LEN];
struct {
unsigned short version; /* 0-1 */
unsigned short flags; /* 2-3 */
unsigned short method; /* 4-5 */
unsigned short modtime; /* 6-7 */
unsigned short moddate; /* 8-9 */
unsigned int crc32 ATTRIBUTE_PACKED; /* 10-13 */
unsigned int cmpsize ATTRIBUTE_PACKED; /* 14-17 */
unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
unsigned short filename_len; /* 22-23 */
unsigned short extra_len; /* 24-25 */
} formatted ATTRIBUTE_PACKED;
} zip_header_t;
uint16_t version; /* 0-1 */
uint16_t flags; /* 2-3 */
uint16_t method; /* 4-5 */
uint16_t modtime; /* 6-7 */
uint16_t moddate; /* 8-9 */
uint32_t crc32 PACKED; /* 10-13 */
uint32_t cmpsize PACKED; /* 14-17 */
uint32_t ucmpsize PACKED; /* 18-21 */
uint16_t filename_len; /* 22-23 */
uint16_t extra_len; /* 24-25 */
} formatted PACKED;
} zip_header_t; /* PACKED - gcc 4.2.1 doesn't like it (spews warning) */
/* Check the offset of the last element, not the length. This leniency
* allows for poor packing, whereby the overall struct may be too long,
* even though the elements are all in the right place.
*/
struct BUG_zip_header_must_be_26_bytes {
char BUG_zip_header_must_be_26_bytes[
offsetof(zip_header_t, formatted.extra_len) + 2 ==
ZIP_HEADER_LEN ? 1 : -1];
};
#define FIX_ENDIANNESS(zip_header) do { \
(zip_header).formatted.version = SWAP_LE16((zip_header).formatted.version ); \
(zip_header).formatted.flags = SWAP_LE16((zip_header).formatted.flags ); \
(zip_header).formatted.method = SWAP_LE16((zip_header).formatted.method ); \
(zip_header).formatted.modtime = SWAP_LE16((zip_header).formatted.modtime ); \
(zip_header).formatted.moddate = SWAP_LE16((zip_header).formatted.moddate ); \
(zip_header).formatted.crc32 = SWAP_LE32((zip_header).formatted.crc32 ); \
(zip_header).formatted.cmpsize = SWAP_LE32((zip_header).formatted.cmpsize ); \
(zip_header).formatted.ucmpsize = SWAP_LE32((zip_header).formatted.ucmpsize ); \
(zip_header).formatted.filename_len = SWAP_LE16((zip_header).formatted.filename_len); \
(zip_header).formatted.extra_len = SWAP_LE16((zip_header).formatted.extra_len ); \
} while (0)
static void unzip_skip(int fd, off_t skip)
{
if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
if (errno != ESPIPE)
bb_error_msg_and_die("seek failure");
bb_copyfd_exact_size(fd, -1, skip);
}
bb_copyfd_exact_size(fd, -1, skip);
}
static void unzip_create_leading_dirs(char *fn)
static void unzip_create_leading_dirs(const char *fn)
{
/* Create all leading directories */
char *name = xstrdup(fn);
@@ -67,7 +97,7 @@ static void unzip_create_leading_dirs(char *fn)
free(name);
}
static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
static void unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
{
if (zip_header->formatted.method == 0) {
/* Method 0 - stored (not compressed) */
@@ -77,64 +107,71 @@ static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
} else {
/* Method 8 - inflate */
inflate_unzip_result res;
/* err = */ inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd);
// we should check for -1 error return
if (inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd) < 0)
bb_error_msg_and_die("inflate error");
/* Validate decompression - crc */
if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) {
bb_error_msg("invalid compressed data--%s error", "crc");
return 1;
bb_error_msg_and_die("crc error");
}
/* Validate decompression - size */
if (zip_header->formatted.ucmpsize != res.bytes_out) {
bb_error_msg("invalid compressed data--%s error", "length");
return 1;
/* Don't die. Who knows, maybe len calculation
* was botched somewhere. After all, crc matched! */
bb_error_msg("bad length");
}
}
return 0;
}
int unzip_main(int argc, char **argv);
int unzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unzip_main(int argc, char **argv)
{
enum { O_PROMPT, O_NEVER, O_ALWAYS };
zip_header_t zip_header;
enum {v_silent, v_normal, v_list} verbosity = v_normal;
enum {o_prompt, o_never, o_always} overwrite = o_prompt;
unsigned int total_size = 0;
unsigned int total_entries = 0;
int src_fd = -1, dst_fd = -1;
char *src_fn = NULL, *dst_fn = NULL;
smallint verbose = 1;
smallint listing = 0;
smallint overwrite = O_PROMPT;
unsigned total_size;
unsigned total_entries;
int src_fd = -1;
int dst_fd = -1;
char *src_fn = NULL;
char *dst_fn = NULL;
llist_t *zaccept = NULL;
llist_t *zreject = NULL;
char *base_dir = NULL;
int failed, i, opt, opt_range = 0, list_header_done = 0;
char key_buf[512];
int i, opt;
int opt_range = 0;
char key_buf[80];
struct stat stat_buf;
/* '-' makes getopt return 1 for non-options */
while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
switch (opt_range) {
case 0: /* Options */
switch (opt) {
case 'l': /* List */
verbosity = v_list;
listing = 1;
break;
case 'n': /* Never overwrite existing files */
overwrite = o_never;
overwrite = O_NEVER;
break;
case 'o': /* Always overwrite existing files */
overwrite = o_always;
overwrite = O_ALWAYS;
break;
case 'p': /* Extract files to stdout and fall through to set verbosity */
dst_fd = STDOUT_FILENO;
case 'q': /* Be quiet */
verbosity = (verbosity == v_normal) ? v_silent : verbosity;
verbose = 0;
break;
case 1 : /* The zip file */
src_fn = xmalloc(strlen(optarg)+4);
case 1: /* The zip file */
/* +5: space for ".zip" and NUL */
src_fn = xmalloc(strlen(optarg) + 5);
strcpy(src_fn, optarg);
opt_range++;
break;
@@ -148,31 +185,30 @@ int unzip_main(int argc, char **argv)
case 1: /* Include files */
if (opt == 1) {
llist_add_to(&zaccept, optarg);
} else if (opt == 'd') {
break;
}
if (opt == 'd') {
base_dir = optarg;
opt_range += 2;
} else if (opt == 'x') {
opt_range++;
} else {
bb_show_usage();
break;
}
break;
if (opt == 'x') {
opt_range++;
break;
}
bb_show_usage();
case 2 : /* Exclude files */
if (opt == 1) {
llist_add_to(&zreject, optarg);
} else if (opt == 'd') { /* Extract to base directory */
break;
}
if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
opt_range++;
} else {
bb_show_usage();
break;
}
break;
/* fall through */
default:
bb_show_usage();
@@ -187,17 +223,19 @@ int unzip_main(int argc, char **argv)
if (LONE_DASH(src_fn)) {
src_fd = STDIN_FILENO;
/* Cannot use prompt mode since zip data is arriving on STDIN */
overwrite = (overwrite == o_prompt) ? o_never : overwrite;
if (overwrite == O_PROMPT)
overwrite = O_NEVER;
} else {
static const char *const extn[] = {"", ".zip", ".ZIP"};
static const char extn[][5] = {"", ".zip", ".ZIP"};
int orig_src_fn_len = strlen(src_fn);
for (i = 0; (i < 3) && (src_fd == -1); i++) {
strcpy(src_fn + orig_src_fn_len, extn[i]);
src_fd = open(src_fn, O_RDONLY);
}
if (src_fd == -1) {
src_fn[orig_src_fn_len] = '\0';
bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
}
}
@@ -205,36 +243,38 @@ int unzip_main(int argc, char **argv)
if (base_dir)
xchdir(base_dir);
if (verbosity != v_silent)
if (verbose) {
printf("Archive: %s\n", src_fn);
if (listing){
puts(" Length Date Time Name\n"
" -------- ---- ---- ----");
}
}
failed = 0;
total_size = 0;
total_entries = 0;
while (1) {
unsigned int magic;
uint32_t magic;
/* Check magic number */
xread(src_fd, &magic, 4);
if (magic == ZIP_CDS_MAGIC) {
/* Central directory? It's at the end, so exit */
if (magic == ZIP_CDS_MAGIC)
break;
} else if (magic != ZIP_FILEHEADER_MAGIC) {
bb_error_msg_and_die("invalid zip magic %08X", magic);
}
if (magic != ZIP_FILEHEADER_MAGIC)
bb_error_msg_and_die("invalid zip magic %08X", (int)magic);
/* Read the file header */
xread(src_fd, zip_header.raw, 26);
zip_header.formatted.version = SWAP_LE32(zip_header.formatted.version);
zip_header.formatted.flags = SWAP_LE32(zip_header.formatted.flags);
zip_header.formatted.method = SWAP_LE32(zip_header.formatted.method);
zip_header.formatted.modtime = SWAP_LE32(zip_header.formatted.modtime);
zip_header.formatted.moddate = SWAP_LE32(zip_header.formatted.moddate);
zip_header.formatted.crc32 = SWAP_LE32(zip_header.formatted.crc32);
zip_header.formatted.cmpsize = SWAP_LE32(zip_header.formatted.cmpsize);
zip_header.formatted.ucmpsize = SWAP_LE32(zip_header.formatted.ucmpsize);
zip_header.formatted.filename_len = SWAP_LE32(zip_header.formatted.filename_len);
zip_header.formatted.extra_len = SWAP_LE32(zip_header.formatted.extra_len);
xread(src_fd, zip_header.raw, ZIP_HEADER_LEN);
FIX_ENDIANNESS(zip_header);
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method);
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
}
if (zip_header.formatted.flags & (0x0008|0x0001)) {
/* 0x0001 - encrypted */
/* 0x0008 - streaming. [u]cmpsize can be reliably gotten
* only from Central Directory. See unzip_doc.txt */
bb_error_msg_and_die("zip flags 8 and 1 are not supported");
}
/* Read filename */
@@ -245,23 +285,17 @@ int unzip_main(int argc, char **argv)
/* Skip extra header bytes */
unzip_skip(src_fd, zip_header.formatted.extra_len);
if ((verbosity == v_list) && !list_header_done){
puts(" Length Date Time Name\n"
" -------- ---- ---- ----");
list_header_done = 1;
}
/* Filter zip entries */
if (find_list_entry(zreject, dst_fn) ||
(zaccept && !find_list_entry(zaccept, dst_fn))) { /* Skip entry */
if (find_list_entry(zreject, dst_fn)
|| (zaccept && !find_list_entry(zaccept, dst_fn))
) { /* Skip entry */
i = 'n';
} else { /* Extract entry */
total_size += zip_header.formatted.ucmpsize;
if (verbosity == v_list) { /* List entry */
unsigned int dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
if (listing) { /* List entry */
if (verbose) {
unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
zip_header.formatted.ucmpsize,
(dostime & 0x01e00000) >> 21,
(dostime & 0x001f0000) >> 16,
@@ -269,16 +303,21 @@ int unzip_main(int argc, char **argv)
(dostime & 0x0000f800) >> 11,
(dostime & 0x000007e0) >> 5,
dst_fn);
total_entries++;
total_size += zip_header.formatted.ucmpsize;
total_entries++;
} else {
/* short listing -- filenames only */
puts(dst_fn);
}
i = 'n';
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
i = -1;
} else if (last_char_is(dst_fn, '/')) { /* Extract directory */
if (stat(dst_fn, &stat_buf) == -1) {
if (errno != ENOENT) {
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
bb_perror_msg_and_die("cannot stat '%s'", dst_fn);
}
if (verbosity == v_normal) {
if (verbose) {
printf(" creating: %s\n", dst_fn);
}
unzip_create_leading_dirs(dst_fn);
@@ -293,27 +332,27 @@ int unzip_main(int argc, char **argv)
i = 'n';
} else { /* Extract file */
_check_file:
check_file:
if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
if (errno != ENOENT) {
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
bb_perror_msg_and_die("cannot stat '%s'", dst_fn);
}
i = 'y';
} else { /* File already exists */
if (overwrite == o_never) {
if (overwrite == O_NEVER) {
i = 'n';
} else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
if (overwrite == o_always) {
if (overwrite == O_ALWAYS) {
i = 'y';
} else {
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
if (!fgets(key_buf, 512, stdin)) {
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
bb_perror_msg_and_die("cannot read input");
}
i = key_buf[0];
}
} else { /* File is not regular file */
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
bb_error_msg_and_die("'%s' exists but is not regular file", dst_fn);
}
}
}
@@ -321,17 +360,15 @@ int unzip_main(int argc, char **argv)
switch (i) {
case 'A':
overwrite = o_always;
overwrite = O_ALWAYS;
case 'y': /* Open file and fall into unzip */
unzip_create_leading_dirs(dst_fn);
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
case -1: /* Unzip */
if (verbosity == v_normal) {
if (verbose) {
printf(" inflating: %s\n", dst_fn);
}
if (unzip_extract(&zip_header, src_fd, dst_fd)) {
failed = 1;
}
unzip_extract(&zip_header, src_fd, dst_fd);
if (dst_fd != STDOUT_FILENO) {
/* closing STDOUT is potentially bad for future business */
close(dst_fd);
@@ -339,7 +376,7 @@ int unzip_main(int argc, char **argv)
break;
case 'N':
overwrite = o_never;
overwrite = O_NEVER;
case 'n':
/* Skip entry data */
unzip_skip(src_fd, zip_header.formatted.cmpsize);
@@ -348,30 +385,32 @@ int unzip_main(int argc, char **argv)
case 'r':
/* Prompt for new name */
printf("new name: ");
if (!fgets(key_buf, 512, stdin)) {
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
bb_perror_msg_and_die("cannot read input");
}
free(dst_fn);
dst_fn = xstrdup(key_buf);
chomp(dst_fn);
goto _check_file;
goto check_file;
default:
printf("error: invalid response [%c]\n",(char)i);
goto _check_file;
goto check_file;
}
/* Data descriptor section */
if (zip_header.formatted.flags & 4) {
/* skip over duplicate crc, compressed size and uncompressed size */
unzip_skip(src_fd, 12);
}
// Looks like bug (data descriptor cannot be identified this way)
// /* Data descriptor section */
// if (zip_header.formatted.flags & 4) {
// /* skip over duplicate crc, compressed size and uncompressed size */
// unzip_skip(src_fd, 12);
// }
}
if (verbosity == v_list) {
if (listing && verbose) {
printf(" -------- -------\n"
"%9d %d files\n", total_size, total_entries);
"%9d %d files\n",
total_size, total_entries);
}
return failed;
return 0;
}
Binary file not shown.
Binary file not shown.
+19 -1
View File
@@ -31,6 +31,12 @@ config DUMPKMAP
This program dumps the kernel's keyboard translation table to
stdout, in binary format. You can then use loadkmap to load it.
config KBD_MODE
bool "kbd_mode"
default n
help
This program reports and sets keyboard mode.
config LOADFONT
bool "loadfont"
default n
@@ -66,7 +72,7 @@ config RESIZE
terminal.
config FEATURE_RESIZE_PRINT
bool "print environment variables"
bool "Print environment variables"
default n
depends on RESIZE
help
@@ -89,6 +95,12 @@ config FEATURE_SETCONSOLE_LONG_OPTIONS
help
Support long options for the setconsole applet.
config SETFONT
bool "setfont"
default n
help
Allows to load console screen map. Useful for i18n.
config SETKEYCODES
bool "setkeycodes"
default n
@@ -102,4 +114,10 @@ config SETLOGCONS
help
This program redirects the output console of kernel messages.
config SHOWKEY
bool "showkey"
default n
help
Shows keys pressed.
endmenu
+3
View File
@@ -10,10 +10,13 @@ lib-$(CONFIG_CLEAR) += clear.o
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
lib-$(CONFIG_SETCONSOLE) += setconsole.o
lib-$(CONFIG_KBD_MODE) += kbd_mode.o
lib-$(CONFIG_LOADFONT) += loadfont.o
lib-$(CONFIG_LOADKMAP) += loadkmap.o
lib-$(CONFIG_OPENVT) += openvt.o
lib-$(CONFIG_RESET) += reset.o
lib-$(CONFIG_RESIZE) += resize.o
lib-$(CONFIG_SETFONT) += loadfont.o
lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
lib-$(CONFIG_SETLOGCONS) += setlogcons.o
lib-$(CONFIG_SHOWKEY) += showkey.o
+3 -12
View File
@@ -9,25 +9,16 @@
#include "libbb.h"
/* From <linux/vt.h> */
enum {
VT_ACTIVATE = 0x5606, /* make vt active */
VT_WAITACTIVE = 0x5607 /* wait for vt active */
};
int chvt_main(int argc, char **argv);
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chvt_main(int argc, char **argv)
{
int fd, num;
int num;
if (argc != 2) {
bb_show_usage();
}
fd = get_console_fd();
num = xatou_range(argv[1], 1, 63);
/* double cast suppresses "cast to ptr from int of different size */
xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num);
xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num);
console_make_active(get_console_fd_or_die(), num);
return EXIT_SUCCESS;
}
+2 -2
View File
@@ -12,8 +12,8 @@
#include "libbb.h"
int clear_main(int argc, char **argv);
int clear_main(int argc, char **argv)
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
return printf("\033[H\033[J") != 6;
}
+7 -11
View File
@@ -15,23 +15,19 @@
/* From <linux/vt.h> */
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
int deallocvt_main(int argc, char **argv);
int deallocvt_main(int argc, char **argv)
int deallocvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int deallocvt_main(int argc UNUSED_PARAM, char **argv)
{
/* num = 0 deallocate all unused consoles */
int num = 0;
switch (argc) {
case 2:
if (argv[1]) {
if (argv[2])
bb_show_usage();
num = xatou_range(argv[1], 1, 63);
/* Fallthrough */
case 1:
break;
default:
bb_show_usage();
}
/* double cast suppresses "cast to ptr from int of different size */
xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
/* double cast suppresses "cast to ptr from int of different size" */
xioctl(get_console_fd_or_die(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
return EXIT_SUCCESS;
}
+13 -10
View File
@@ -7,6 +7,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
/* no options, no getopt */
#include "libbb.h"
@@ -22,19 +23,18 @@ struct kbentry {
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv);
int dumpkmap_main(int argc, char **argv)
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
struct kbentry ke;
int i, j, fd;
char flags[MAX_NR_KEYMAPS];
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
if (argc >= 2 && argv[1][0] == '-')
bb_show_usage();
/* bb_warn_ignoring_args(argc>=2);*/
fd = xopen(CURRENT_VC, O_RDWR);
fd = get_console_fd_or_die();
write(1, "bkeymap", 7);
write(STDOUT_FILENO, "bkeymap", 7);
/* Here we want to set everything to 0 except for indexes:
* [0-2] [4-6] [8-10] [12] */
@@ -43,7 +43,7 @@ int dumpkmap_main(int argc, char **argv)
flags[3] = flags[7] = flags[11] = 0;
/* dump flags */
write(1, flags, MAX_NR_KEYMAPS);
write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
@@ -56,11 +56,14 @@ int dumpkmap_main(int argc, char **argv)
(char *)&ke.kb_table,
&ke.kb_value)
) {
write(1, (void*)&ke.kb_value, 2);
write(STDOUT_FILENO, (void*)&ke.kb_value, 2);
}
}
}
}
close(fd);
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd);
RELEASE_CONFIG_BUFFER(flags);
}
return EXIT_SUCCESS;
}
+54
View File
@@ -0,0 +1,54 @@
/* vi: set sw=4 ts=4: */
/*
* Mini kbd_mode implementation for busybox
*
* Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
* written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
* console-utils v0.2.3, licensed under GNU GPLv2
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
#include "libbb.h"
#include <linux/kd.h>
int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
{
int fd;
unsigned opt;
enum {
SCANCODE = (1 << 0),
ASCII = (1 << 1),
MEDIUMRAW = (1 << 2),
UNICODE = (1 << 3)
};
static const char KD_xxx[] ALIGN1 = "saku";
opt = getopt32(argv, KD_xxx);
fd = get_console_fd_or_die();
if (!opt) { /* print current setting */
const char *mode = "unknown";
int m;
ioctl(fd, KDGKBMODE, &m);
if (m == K_RAW)
mode = "raw (scancode)";
else if (m == K_XLATE)
mode = "default (ASCII)";
else if (m == K_MEDIUMRAW)
mode = "mediumraw (keycode)";
else if (m == K_UNICODE)
mode = "Unicode (UTF-8)";
printf("The keyboard is in %s mode\n", mode);
} else {
opt = opt & UNICODE ? 3 : opt >> 1;
/* double cast prevents warnings about widening conversion */
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
}
if (ENABLE_FEATURE_CLEAN_UP)
close(fd);
return EXIT_SUCCESS;
}
+92 -76
View File
@@ -26,7 +26,7 @@ struct psf_header {
unsigned char charsize; /* Character size */
};
#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
#define PSF_MAGIC_OK(x) ((x)->magic1 == PSF_MAGIC1 && (x)->magic2 == PSF_MAGIC2)
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
{
@@ -37,7 +37,6 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
bb_error_msg_and_die("bad character size %d", unit);
buf = xzalloc(16 * 1024);
/*memset(buf, 0, 16 * 1024);*/
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
@@ -58,8 +57,7 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
free(buf);
}
static void
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
{
struct unimapinit advice;
struct unimapdesc ud;
@@ -68,7 +66,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
int glyph;
uint16_t unicode;
maxct = tailsz; /* more than enough */
maxct = tailsz; /* more than enough */
up = xmalloc(maxct * sizeof(struct unipair));
for (glyph = 0; glyph < fontsize; glyph++) {
@@ -96,86 +94,104 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
xioctl(fd, PIO_UNIMAP, &ud);
}
static void loadnewfont(int fd)
static void do_load(int fd, struct psf_header *psfhdr, size_t len)
{
enum { INBUF_SIZE = 32*1024 + 1 };
int unit;
unsigned inputlth, offset;
/* Was on stack, but 32k is a bit too much: */
unsigned char *inbuf = xmalloc(INBUF_SIZE);
int fontsize;
int hastable;
unsigned head0, head = head;
/* test for psf first */
if (len >= sizeof(struct psf_header) && PSF_MAGIC_OK(psfhdr)) {
if (psfhdr->mode > PSF_MAXMODE)
bb_error_msg_and_die("unsupported psf file mode");
fontsize = ((psfhdr->mode & PSF_MODE512) ? 512 : 256);
#if !defined(PIO_FONTX) || defined(__sparc__)
if (fontsize != 256)
bb_error_msg_and_die("only fontsize 256 supported");
#endif
hastable = (psfhdr->mode & PSF_MODEHASTAB);
unit = psfhdr->charsize;
head0 = sizeof(struct psf_header);
head = head0 + fontsize * unit;
if (head > len || (!hastable && head != len))
bb_error_msg_and_die("input file: bad length");
} else {
/* file with three code pages? */
if (len == 9780) {
head0 = 40;
unit = 16;
} else {
/* bare font */
if (len & 0377)
bb_error_msg_and_die("input file: bad length");
head0 = 0;
unit = len / 256;
}
fontsize = 256;
hastable = 0;
}
do_loadfont(fd, (unsigned char *)psfhdr + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, (unsigned char *)psfhdr + head, len - head, fontsize);
}
#if ENABLE_LOADFONT
int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int loadfont_main(int argc UNUSED_PARAM, char **argv)
{
size_t len;
struct psf_header *psfhdr;
// no arguments allowed!
opt_complementary = "=0";
getopt32(argv, "");
/*
* We used to look at the length of the input file
* with stat(); now that we accept compressed files,
* just read the entire file.
*/
inputlth = full_read(STDIN_FILENO, inbuf, INBUF_SIZE);
if (inputlth < 0)
len = 32*1024; // can't be larger
psfhdr = (struct psf_header *) xmalloc_read(STDIN_FILENO, &len);
// xmalloc_open_zipped_read_close(filename, &len);
if (!psfhdr)
bb_perror_msg_and_die("error reading input font");
if (inputlth >= INBUF_SIZE)
bb_error_msg_and_die("font too large");
/* test for psf first */
{
struct psf_header psfhdr;
int fontsize;
int hastable;
unsigned head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
psfhdr = *(struct psf_header *) &inbuf[0];
if (!PSF_MAGIC_OK(psfhdr))
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE)
bb_error_msg_and_die("unsupported psf file mode");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined(PIO_FONTX) || defined(__sparc__)
if (fontsize != 256)
bb_error_msg_and_die("only fontsize 256 supported");
#endif
hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize;
head0 = sizeof(struct psf_header);
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth))
bb_error_msg_and_die("input file: bad length");
do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
return;
}
no_psf:
/* file with three code pages? */
if (inputlth == 9780) {
offset = 40;
unit = 16;
} else {
/* bare font */
if (inputlth & 0377)
bb_error_msg_and_die("bad input file size");
offset = 0;
unit = inputlth / 256;
}
do_loadfont(fd, inbuf + offset, unit, 256);
}
int loadfont_main(int argc, char **argv);
int loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
loadnewfont(fd);
do_load(get_console_fd_or_die(), psfhdr, len);
return EXIT_SUCCESS;
}
#endif
#if ENABLE_SETFONT
int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setfont_main(int argc UNUSED_PARAM, char **argv)
{
size_t len;
struct psf_header *psfhdr;
char *mapfilename;
int fd;
opt_complementary = "=1";
getopt32(argv, "m:", &mapfilename);
argv += optind;
// load font
len = 32*1024; // can't be larger
psfhdr = (struct psf_header *) xmalloc_open_zipped_read_close(*argv, &len);
fd = get_console_fd_or_die();
do_load(fd, psfhdr, len);
// load the screen map, if any
if (option_mask32 & 1) { // -m
void *map = xmalloc_open_zipped_read_close(mapfilename, &len);
if (len == E_TABSZ || len == 2*E_TABSZ) {
xioctl(fd, (len == 2*E_TABSZ) ? PIO_UNISCRNMAP : PIO_SCRNMAP, map);
}
}
return EXIT_SUCCESS;
}
#endif
+15 -14
View File
@@ -25,29 +25,27 @@ struct kbentry {
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv);
int loadkmap_main(int argc, char **argv)
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
struct kbentry ke;
int i, j, fd;
uint16_t ibuff[NR_KEYS];
char flags[MAX_NR_KEYMAPS];
char buff[7];
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
if (argc != 1)
bb_show_usage();
/* bb_warn_ignoring_args(argc>=2);*/
fd = xopen(CURRENT_VC, O_RDWR);
fd = get_console_fd_or_die();
xread(0, buff, 7);
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("this is not a valid binary keymap");
xread(STDIN_FILENO, flags, 7);
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("not a valid binary keymap");
xread(0, flags, MAX_NR_KEYMAPS);
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
@@ -57,6 +55,9 @@ int loadkmap_main(int argc, char **argv)
}
}
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
return 0;
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd);
RELEASE_CONFIG_BUFFER(flags);
}
return EXIT_SUCCESS;
}
+162 -16
View File
@@ -8,28 +8,174 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* getopt not needed */
#include <linux/vt.h>
#include "libbb.h"
int openvt_main(int argc, char **argv);
int openvt_main(int argc, char **argv)
/* "Standard" openvt's man page (we do not support all of this):
openvt [-c NUM] [-fsulv] [--] [command [args]]
Find the first available VT, and run command on it. Stdio is directed
to that VT. If no command is specified then $SHELL is used.
-c NUM
Use the given VT number, not the first free one.
-f
Force opening a VT: don't try to check if VT is already in use.
-s
Switch to the new VT when starting the command.
The VT of the new command will be made the new current VT.
-u
Figure out the owner of the current VT, and run login as that user.
Suitable to be called by init. Shouldn't be used with -c or -l.
-l
Make the command a login shell: a "-" is prepended to the argv[0]
when command is executed.
-v
Verbose.
-w
Wait for command to complete. If -w and -s are used together,
switch back to the controlling terminal when the command completes.
bbox:
-u: not implemented
-f: always in effect
-l: not implemented, ignored
-v: ignored
-ws: does NOT switch back
*/
/* Helper: does this fd understand VT_xxx? */
static int not_vt_fd(int fd)
{
char vtname[sizeof(VC_FORMAT) + 2];
struct vt_stat vtstat;
return ioctl(fd, VT_GETSTATE, &vtstat); /* !0: error, it's not VT fd */
}
if (argc < 3)
bb_show_usage();
/* Helper: get a fd suitable for VT_xxx */
static int get_vt_fd(void)
{
int fd;
/* check for illegal vt number: < 1 or > 63 */
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
/* Do we, by chance, already have it? */
for (fd = 0; fd < 3; fd++)
if (!not_vt_fd(fd))
return fd;
/* _only_ O_NONBLOCK: ask for neither read nor write perms */
/*FIXME: use? device_open(DEV_CONSOLE,0); */
fd = open(DEV_CONSOLE, O_NONBLOCK);
if (fd >= 0 && !not_vt_fd(fd))
return fd;
bb_error_msg_and_die("can't find open VT");
}
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
/* grab new one */
close(0);
static int find_free_vtno(void)
{
int vtno;
int fd = get_vt_fd();
errno = 0;
/*xfunc_error_retval = 3; - do we need compat? */
if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0)
bb_perror_msg_and_die("can't find open VT");
// Not really needed, grep for DAEMON_ONLY_SANITIZE
// if (fd > 2)
// close(fd);
return vtno;
}
/* vfork scares gcc, it generates bigger code.
* Keep it away from main program.
* TODO: move to libbb; or adapt existing libbb's spawn().
*/
static NOINLINE void vfork_child(char **argv)
{
if (vfork() == 0) {
/* CHILD */
/* Try to make this VT our controlling tty */
setsid(); /* lose old ctty */
ioctl(STDIN_FILENO, TIOCSCTTY, 0 /* 0: don't forcibly steal */);
//bb_error_msg("our sid %d", getsid(0));
//bb_error_msg("our pgrp %d", getpgrp());
//bb_error_msg("VT's sid %d", tcgetsid(0));
//bb_error_msg("VT's pgrp %d", tcgetpgrp(0));
BB_EXECVP(argv[0], argv);
bb_perror_msg_and_die("exec %s", argv[0]);
}
}
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int openvt_main(int argc UNUSED_PARAM, char **argv)
{
char vtname[sizeof(VC_FORMAT) + sizeof(int)*3];
struct vt_stat vtstat;
char *str_c;
int vtno;
int flags;
enum {
OPT_c = (1 << 0),
OPT_w = (1 << 1),
OPT_s = (1 << 2),
OPT_l = (1 << 3),
OPT_f = (1 << 4),
OPT_v = (1 << 5),
};
/* "+" - stop on first non-option */
flags = getopt32(argv, "+c:wslfv", &str_c);
argv += optind;
if (flags & OPT_c) {
/* Check for illegal vt number: < 1 or > 63 */
vtno = xatou_range(str_c, 1, 63);
} else {
vtno = find_free_vtno();
}
/* Grab new VT */
sprintf(vtname, VC_FORMAT, vtno);
/* (Try to) clean up stray open fds above fd 2 */
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL);
close(STDIN_FILENO);
/*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */
xopen(vtname, O_RDWR);
dup2(0, STDOUT_FILENO);
dup2(0, STDERR_FILENO);
xioctl(STDIN_FILENO, VT_GETSTATE, &vtstat);
if (flags & OPT_s) {
console_make_active(STDIN_FILENO, vtno);
}
if (!argv[0]) {
argv--;
argv[0] = getenv("SHELL");
if (!argv[0])
argv[0] = (char *) DEFAULT_SHELL;
/*argv[1] = NULL; - already is */
}
xdup2(STDIN_FILENO, STDOUT_FILENO);
xdup2(STDIN_FILENO, STDERR_FILENO);
#ifdef BLOAT
{
/* Handle -l (login shell) option */
const char *prog = argv[0];
if (flags & OPT_l)
argv[0] = xasprintf("-%s", argv[0]);
}
#endif
BB_EXECVP(argv[2], &argv[2]);
_exit(1);
vfork_child(argv);
if (flags & OPT_w) {
/* We have only one child, wait for it */
safe_waitpid(-1, NULL, 0); /* loops on EINTR */
if (flags & OPT_s) {
console_make_active(STDIN_FILENO, vtstat.v_active);
// Compat: even with -c N (try to) disallocate:
// # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5
// openvt: could not deallocate console 9
xioctl(STDIN_FILENO, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno);
}
}
return EXIT_SUCCESS;
}
+23 -6
View File
@@ -8,14 +8,25 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#include "libbb.h"
int reset_main(int argc, char **argv);
int reset_main(int argc, char **argv)
/* BTW, which "standard" package has this utility? It doesn't seem
* to be ncurses, coreutils, console-tools... then what? */
#if ENABLE_STTY
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
#endif
int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
if (isatty(1)) {
static const char *const args[] = {
"stty", "sane", NULL
};
/* no options, no getopt */
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
/* See 'man 4 console_codes' for details:
* "ESC c" -- Reset
* "ESC ( K" -- Select user mapping
@@ -24,7 +35,13 @@ int reset_main(int argc, char **argv)
* "ESC [ ? 25 h" -- Make cursor visible.
*/
printf("\033c\033(K\033[J\033[0m\033[?25h");
/* http://bugs.busybox.net/view.php?id=1414:
* people want it to reset echo etc: */
#if ENABLE_STTY
return stty_main(2, (char**)args);
#else
execvp("stty", (char**)args);
#endif
}
return EXIT_SUCCESS;
}
+11 -9
View File
@@ -14,17 +14,17 @@
#define old_termios (*(struct termios*)&bb_common_bufsiz1)
static void
onintr(int sig ATTRIBUTE_UNUSED)
onintr(int sig UNUSED_PARAM)
{
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
exit(1);
exit(EXIT_FAILURE);
}
int resize_main(int argc, char **argv);
int resize_main(int argc, char **argv)
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
struct termios new;
struct winsize w = { 0,0,0,0 };
struct winsize w = { 0, 0, 0, 0 };
int ret;
/* We use _stderr_ in order to make resize usable
@@ -37,10 +37,12 @@ int resize_main(int argc, char **argv)
new = old_termios;
new.c_cflag |= (CLOCAL | CREAD);
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
signal(SIGINT, onintr);
signal(SIGQUIT, onintr);
signal(SIGTERM, onintr);
signal(SIGALRM, onintr);
bb_signals(0
+ (1 << SIGINT)
+ (1 << SIGQUIT)
+ (1 << SIGTERM)
+ (1 << SIGALRM)
, onintr);
tcsetattr(STDERR_FILENO, TCSANOW, &new);
/* save_cursor_pos 7
+14 -21
View File
@@ -3,41 +3,34 @@
* setconsole.c - redirect system console output
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
* Copyright (C) 2008 Bernhard Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <getopt.h>
#include "libbb.h"
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
#endif
#define OPT_SETCONS_RESET 1
int setconsole_main(int argc, char **argv);
int setconsole_main(int argc, char **argv)
int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setconsole_main(int argc UNUSED_PARAM, char **argv)
{
unsigned long flags;
const char *device = CURRENT_TTY;
bool reset;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
applet_long_options = setconsole_longopts;
#endif
flags = getopt32(argv, "r");
/* at most one non-option argument */
opt_complementary = "?1";
reset = getopt32(argv, "r");
if (argc - optind > 1)
bb_show_usage();
if (argc - optind == 1) {
if (flags & OPT_SETCONS_RESET)
bb_show_usage();
device = argv[optind];
argv += 1 + reset;
if (*argv) {
device = *argv;
} else {
if (flags & OPT_SETCONS_RESET)
if (reset)
device = DEV_CONSOLE;
}
+7 -7
View File
@@ -14,33 +14,33 @@
/* From <linux/kd.h> */
struct kbkeycode {
unsigned int scancode, keycode;
unsigned scancode, keycode;
};
enum {
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
};
int setkeycodes_main(int argc, char** argv);
int setkeycodes_main(int argc, char** argv)
int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setkeycodes_main(int argc, char **argv)
{
int fd, sc;
struct kbkeycode a;
if (argc % 2 != 1 || argc < 2) {
if (!(argc & 1) /* if even */ || argc < 2) {
bb_show_usage();
}
fd = get_console_fd();
fd = get_console_fd_or_die();
while (argc > 2) {
a.keycode = xatoul_range(argv[2], 0, 127);
a.keycode = xatou_range(argv[2], 0, 127);
a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
"failed to set SCANCODE %x to KEYCODE %d",
"can't set SCANCODE %x to KEYCODE %d",
sc, a.keycode);
argc -= 2;
argv += 2;
+8 -9
View File
@@ -11,21 +11,20 @@
#include "libbb.h"
int setlogcons_main(int argc, char **argv);
int setlogcons_main(int argc, char **argv)
int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setlogcons_main(int argc UNUSED_PARAM, char **argv)
{
struct {
char fn;
char subarg;
} arg;
} arg = { 11, /* redirect kernel messages */
0 /* to specified console (current as default) */
};
arg.fn = 11; /* redirect kernel messages */
arg.subarg = 0; /* to specified console (current as default) */
if (argc == 2)
arg.subarg = xatoul_range(argv[1], 0, 63);
if (argv[1])
arg.subarg = xatou_range(argv[1], 0, 63);
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
return 0;
return EXIT_SUCCESS;
}
+138
View File
@@ -0,0 +1,138 @@
/* vi: set sw=4 ts=4: */
/*
* shows keys pressed. inspired by kbd package
*
* Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include <linux/kd.h>
// set raw tty mode
// also used by microcom
// libbb candidates?
static void xget1(int fd, struct termios *t, struct termios *oldt)
{
tcgetattr(fd, oldt);
*t = *oldt;
cfmakeraw(t);
}
static int xset1(int fd, struct termios *tio, const char *device)
{
int ret = tcsetattr(fd, TCSAFLUSH, tio);
if (ret) {
bb_perror_msg("can't tcsetattr for %s", device);
}
return ret;
}
/*
* GLOBALS
*/
struct globals {
int kbmode;
struct termios tio, tio0;
};
#define G (*ptr_to_globals)
#define kbmode (G.kbmode)
#define tio (G.tio)
#define tio0 (G.tio0)
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0)
static void signal_handler(int signo)
{
// restore keyboard and console settings
xset1(STDIN_FILENO, &tio0, "stdin");
xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode);
// alarmed? -> exit 0
exit(SIGALRM == signo);
}
int showkey_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int showkey_main(int argc UNUSED_PARAM, char **argv)
{
enum {
OPT_a = (1<<0), // display the decimal/octal/hex values of the keys
OPT_k = (1<<1), // display only the interpreted keycodes (default)
OPT_s = (1<<2), // display only the raw scan-codes
};
// FIXME: aks are all mutually exclusive
getopt32(argv, "aks");
INIT_G();
// get keyboard settings
xioctl(STDIN_FILENO, KDGKBMODE, &kbmode);
printf("kb mode was %s\n\nPress any keys. Program terminates %s\n\n",
kbmode == K_RAW ? "RAW" :
(kbmode == K_XLATE ? "XLATE" :
(kbmode == K_MEDIUMRAW ? "MEDIUMRAW" :
(kbmode == K_UNICODE ? "UNICODE" : "?UNKNOWN?")))
, (option_mask32 & OPT_a) ? "when CTRL+D pressed" : "10s after last keypress"
);
// prepare for raw mode
xget1(STDIN_FILENO, &tio, &tio0);
// put stdin in raw mode
xset1(STDIN_FILENO, &tio, "stdin");
if (option_mask32 & OPT_a) {
char c;
// just read stdin char by char
while (1 == safe_read(STDIN_FILENO, &c, 1)) {
printf("%3d 0%03o 0x%02x\r\n", c, c, c);
if (04 /*CTRL-D*/ == c)
break;
}
} else {
// we should exit on any signal
bb_signals(BB_FATAL_SIGS, signal_handler);
// set raw keyboard mode
xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)((option_mask32 & OPT_k) ? K_MEDIUMRAW : K_RAW));
// read and show scancodes
while (1) {
char buf[18];
int i, n;
// setup 10s watchdog
alarm(10);
// read scancodes
n = read(STDIN_FILENO, buf, sizeof(buf));
i = 0;
while (i < n) {
char c = buf[i];
// show raw scancodes ordered? ->
if (option_mask32 & OPT_s) {
printf("0x%02x ", buf[i++]);
// show interpreted scancodes (default) ? ->
} else {
int kc;
if (i+2 < n && (c & 0x7f) == 0
&& (buf[i+1] & 0x80) != 0
&& (buf[i+2] & 0x80) != 0) {
kc = ((buf[i+1] & 0x7f) << 7) | (buf[i+2] & 0x7f);
i += 3;
} else {
kc = (c & 0x7f);
i++;
}
printf("keycode %3d %s", kc, (c & 0x80) ? "release" : "press");
}
}
puts("\r");
}
}
// cleanup
signal_handler(SIGALRM);
// should never be here!
return EXIT_SUCCESS;
}
+53 -16
View File
@@ -10,7 +10,7 @@ config BASENAME
default n
help
basename is used to strip the directory and suffix from filenames,
leaving just the filename itself. Enable this option if you wish
leaving just the filename itself. Enable this option if you wish
to enable the 'basename' utility.
config CAL
@@ -24,7 +24,7 @@ config CAT
default n
help
cat is used to concatenate files and print them to the standard
output. Enable this option if you wish to enable the 'cat' utility.
output. Enable this option if you wish to enable the 'cat' utility.
config CATV
bool "catv"
@@ -117,7 +117,8 @@ config FEATURE_DD_SIGNAL_HANDLING
print to standard error the number of records read and written
so far, then to resume copying.
$ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
$ dd if=/dev/zero of=/dev/null&
$ pid=$! kill -USR1 $pid; sleep 1; kill $pid
10899206+0 records in 10899206+0 records out
config FEATURE_DD_IBS_OBS
@@ -135,6 +136,13 @@ config DF
df reports the amount of disk space used and available
on filesystems.
config FEATURE_DF_INODE
bool "Enable -i (inode information)"
default n
depends on DF
help
This option enables support for df -i.
config DIRNAME
bool "dirname"
default n
@@ -225,7 +233,7 @@ config EXPR_MATH_SUPPORT_64
default n
depends on EXPR
help
Enable 64-bit math support in the expr applet. This will make
Enable 64-bit math support in the expr applet. This will make
the applet slightly larger, but will allow computation with very
large numbers.
@@ -481,6 +489,14 @@ config RMDIR
help
rmdir is used to remove empty directories.
config FEATURE_RMDIR_LONG_OPTIONS
bool "Enable long options"
default n
depends on RMDIR && GETOPT_LONG
help
Support long options for the rmdir applet, including
--ignore-fail-on-non-empty for compatibility with GNU rmdir.
config SEQ
bool "seq"
default n
@@ -494,18 +510,33 @@ config SHA1SUM
Compute and check SHA1 message digest
config SLEEP
bool "sleep (single integer arg with no suffix)"
bool "sleep"
default n
help
sleep is used to pause for a specified number of seconds,
sleep is used to pause for a specified number of seconds.
It comes in 3 versions:
- small: takes one integer parameter
- fancy: takes multiple integer arguments with suffixes:
sleep 1d 2h 3m 15s
- fancy with fractional numbers:
sleep 2.3s 4.5h sleeps for 16202.3 seconds
Last one is "the most compatible" with coreutils sleep,
but it adds around 1k of code.
config FEATURE_FANCY_SLEEP
bool "Enable multiple integer args and optional time suffixes"
bool "Enable multiple arguments and s/m/h/d suffixes"
default n
depends on SLEEP
help
Allow sleep to pause for specified minutes, hours, and days.
config FEATURE_FLOAT_SLEEP
bool "Enable fractional arguments"
default n
depends on FEATURE_FANCY_SLEEP
help
Allow for fractional numeric parameters.
config SORT
bool "sort"
default n
@@ -513,13 +544,13 @@ config SORT
sort is used to sort lines of text in specified files.
config FEATURE_SORT_BIG
bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
bool "Full SuSv3 compliant sort (support -ktcsbdfiozgM)"
default y
depends on SORT
help
Without this, sort only supports -r, -u, and an integer version
of -n. Selecting this adds sort keys, floating point support, and
more. This adds a little over 3k to a nonstatic build on x86.
Without this, sort only supports -r, -u, and an integer version
of -n. Selecting this adds sort keys, floating point support, and
more. This adds a little over 3k to a nonstatic build on x86.
The SuSv3 sort standard is available at:
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
@@ -531,7 +562,7 @@ config SPLIT
split a file into pieces.
config FEATURE_SPLIT_FANCY
bool "fancy extensions"
bool "Fancy extensions"
default n
depends on SPLIT
help
@@ -551,7 +582,7 @@ config FEATURE_STAT_FORMAT
depends on STAT
help
Without this, stat will not support the '-c format' option where
users can pass a custom format string for output. This adds about
users can pass a custom format string for output. This adds about
7k to a nonstatic build on amd64.
config STTY
@@ -572,6 +603,12 @@ config SYNC
help
sync is used to flush filesystem buffers.
config TAC
bool "tac"
default n
help
tac is used to concatenate and print files in reverse.
config TAIL
bool "tail"
default n
@@ -595,7 +632,7 @@ config TEE
to standard output and files.
config FEATURE_TEE_USE_BLOCK_IO
bool "Enable block i/o (larger/faster) instead of byte i/o."
bool "Enable block I/O (larger/faster) instead of byte I/O"
default n
depends on TEE
help
@@ -606,7 +643,7 @@ config TEST
default n
help
test is used to check file types and compare values,
returning an appropriate exit code. The bash shell
returning an appropriate exit code. The bash shell
has test built in, ash can build it in optionally.
config FEATURE_TEST_64
@@ -717,7 +754,7 @@ config FEATURE_WC_LARGE
default n
depends on WC
help
Use "unsigned long long" in wc for count variables
Use "unsigned long long" in wc for count variables.
config WHO
bool "who"
+8 -2
View File
@@ -12,6 +12,7 @@ lib-$(CONFIG_CAL) += cal.o
lib-$(CONFIG_CAT) += cat.o
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
lib-$(CONFIG_LESS) += cat.o # less too
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
lib-$(CONFIG_CATV) += catv.o
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
lib-$(CONFIG_CHMOD) += chmod.o
@@ -29,6 +30,7 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_HUSH) += echo.o # used by hush
lib-$(CONFIG_ENV) += env.o
lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_EXPAND) += expand.o
@@ -52,6 +54,7 @@ lib-$(CONFIG_NOHUP) += nohup.o
lib-$(CONFIG_OD) += od.o
lib-$(CONFIG_PRINTENV) += printenv.o
lib-$(CONFIG_PRINTF) += printf.o
lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o
lib-$(CONFIG_PWD) += pwd.o
lib-$(CONFIG_READLINK) += readlink.o
lib-$(CONFIG_REALPATH) += realpath.o
@@ -66,10 +69,13 @@ lib-$(CONFIG_STAT) += stat.o
lib-$(CONFIG_STTY) += stty.o
lib-$(CONFIG_SUM) += sum.o
lib-$(CONFIG_SYNC) += sync.o
lib-$(CONFIG_TAC) += tac.o
lib-$(CONFIG_TAIL) += tail.o
lib-$(CONFIG_TEE) += tee.o
lib-$(CONFIG_TEST) += test.o
lib-$(CONFIG_ASH) += test.o # used by ash
lib-$(CONFIG_TEST) += test.o test_ptr_hack.o
lib-$(CONFIG_ASH) += test.o test_ptr_hack.o # used by ash
lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o # used by hush
lib-$(CONFIG_MSH) += test.o test_ptr_hack.o # used by msh
lib-$(CONFIG_TOUCH) += touch.o
lib-$(CONFIG_TR) += tr.o
lib-$(CONFIG_TRUE) += true.o
+9 -7
View File
@@ -24,7 +24,7 @@
/* This is a NOFORK applet. Be very careful! */
int basename_main(int argc, char **argv);
int basename_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int basename_main(int argc, char **argv)
{
size_t m, n;
@@ -34,17 +34,19 @@ int basename_main(int argc, char **argv)
bb_show_usage();
}
s = bb_get_last_path_component(*++argv);
/* It should strip slash: /abc/def/ -> def */
s = bb_get_last_path_component_strip(*++argv);
m = strlen(s);
if (*++argv) {
n = strlen(*argv);
m = strlen(s);
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
s[m-n] = '\0';
m -= n;
/*s[m] = '\0'; - redundant */
}
}
puts(s);
return fflush(stdout);
/* puts(s) will do, but we can do without stdio this way: */
s[m++] = '\n';
return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
}
+8 -6
View File
@@ -40,7 +40,8 @@ static const unsigned char sep1752[] ALIGN1 = {
24, 25, 26, 27, 28, 29, 30
};
static unsigned julian;
/* Set to 0 or 1 in main */
#define julian ((unsigned)option_mask32)
/* leap year -- account for Gregorian reformation in 1752 */
static int leap_year(unsigned yr)
@@ -75,7 +76,7 @@ static char *build_row(char *p, unsigned *dp);
#define J_WEEK_LEN (WEEK_LEN + 7)
#define HEAD_SEP 2 /* spaces between day headings */
int cal_main(int argc, char **argv);
int cal_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cal_main(int argc, char **argv)
{
struct tm *local_time;
@@ -87,7 +88,8 @@ int cal_main(int argc, char **argv)
char buf[40];
flags = getopt32(argv, "jy");
julian = flags & 1;
/* This sets julian = flags & 1: */
option_mask32 &= 1;
month = 0;
argv += optind;
argc -= optind;
@@ -100,7 +102,7 @@ int cal_main(int argc, char **argv)
time(&now);
local_time = localtime(&now);
year = local_time->tm_year + 1900;
if (!(flags & 2)) {
if (!(flags & 2)) { /* no -y */
month = local_time->tm_mon + 1;
}
} else {
@@ -167,7 +169,7 @@ int cal_main(int argc, char **argv)
if (!julian) {
printf("%*s%s", HEAD_SEP, "", day_headings);
}
putchar('\n');
bb_putchar('\n');
for (row = 0; row < (6*7); row += 7) {
for (which_cal = 0; which_cal < 3-julian; which_cal++) {
dp = days[month + which_cal] + row;
@@ -179,7 +181,7 @@ int cal_main(int argc, char **argv)
}
}
fflush_stdout_and_exit(0);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*
+5 -9
View File
@@ -17,20 +17,16 @@
int bb_cat(char **argv)
{
static const char *const argv_dash[] = { "-", NULL };
int fd;
int retval = EXIT_SUCCESS;
if (!*argv)
argv = (char**) &argv_dash;
argv = (char**) &bb_argv_dash;
do {
fd = STDIN_FILENO;
if (!LONE_DASH(*argv))
fd = open_or_warn(*argv, O_RDONLY);
fd = open_or_warn_stdin(*argv);
if (fd >= 0) {
/* This is not an xfunc - never exits */
/* This is not a xfunc - never exits */
off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
if (fd != STDIN_FILENO)
close(fd);
@@ -43,8 +39,8 @@ int bb_cat(char **argv)
return retval;
}
int cat_main(int argc, char **argv);
int cat_main(int argc, char **argv)
int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cat_main(int argc UNUSED_PARAM, char **argv)
{
getopt32(argv, "u");
argv += optind;
+7 -11
View File
@@ -12,8 +12,8 @@
#include "libbb.h"
int catv_main(int argc, char **argv);
int catv_main(int argc, char **argv)
int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int catv_main(int argc UNUSED_PARAM, char **argv)
{
int retval = EXIT_SUCCESS;
int fd;
@@ -27,18 +27,14 @@ int catv_main(int argc, char **argv)
argv += optind;
/* Read from stdin if there's nothing else to do. */
fd = 0;
if (!argv[0]) {
argv--;
goto jump_in;
}
if (!argv[0])
*--argv = (char*)"-";
do {
fd = open_or_warn(*argv, O_RDONLY);
fd = open_or_warn_stdin(*argv);
if (fd < 0) {
retval = EXIT_FAILURE;
continue;
}
jump_in:
for (;;) {
int i, res;
@@ -62,13 +58,13 @@ int catv_main(int argc, char **argv)
if (c < 32) {
if (c == 10) {
if (flags & CATV_OPT_e)
putchar('$');
bb_putchar('$');
} else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
printf("^%c", c+'@');
continue;
}
}
putchar(c);
bb_putchar(c);
}
}
if (ENABLE_FEATURE_CLEAN_UP && fd)
+1 -1
View File
@@ -16,7 +16,7 @@
/* This is a NOEXEC applet. Be very careful! */
int chgrp_main(int argc, char **argv);
int chgrp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chgrp_main(int argc, char **argv)
{
/* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */
+4 -4
View File
@@ -34,7 +34,7 @@
* symbolic links encountered during recursive directory traversals.
*/
static int fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
{
mode_t newmode;
@@ -63,12 +63,12 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* param, i
}
err:
if (!OPT_QUIET)
bb_perror_msg("%s", fileName);
bb_simple_perror_msg(fileName);
return FALSE;
}
int chmod_main(int argc, char **argv);
int chmod_main(int argc, char **argv)
int chmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chmod_main(int argc UNUSED_PARAM, char **argv)
{
int retval = EXIT_SUCCESS;
char *arg, **argp;
+33 -24
View File
@@ -18,11 +18,11 @@
#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP"))
#define BIT_RECURSE 1
#define OPT_RECURSE (option_mask32 & 1)
#define OPT_NODEREF (option_mask32 & 2)
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 0x04) SKIP_DESKTOP(0))
#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 0x08) SKIP_DESKTOP(0))
#define OPT_QUIET (USE_DESKTOP(option_mask32 & 0x10) SKIP_DESKTOP(0))
#define OPT_RECURSE (opt & 1)
#define OPT_NODEREF (opt & 2)
#define OPT_VERBOSE (USE_DESKTOP(opt & 0x04) SKIP_DESKTOP(0))
#define OPT_CHANGED (USE_DESKTOP(opt & 0x08) SKIP_DESKTOP(0))
#define OPT_QUIET (USE_DESKTOP(opt & 0x10) SKIP_DESKTOP(0))
/* POSIX options
* -L traverse every symbolic link to a directory encountered
* -H if a command line argument is a symbolic link to a directory, traverse it
@@ -32,22 +32,27 @@
* The last option specified shall determine the behavior of the utility." */
/* -L */
#define BIT_TRAVERSE 0x20
#define OPT_TRAVERSE (USE_DESKTOP(option_mask32 & BIT_TRAVERSE) SKIP_DESKTOP(0))
#define OPT_TRAVERSE (USE_DESKTOP(opt & BIT_TRAVERSE) SKIP_DESKTOP(0))
/* -H or -L */
#define BIT_TRAVERSE_TOP (0x20|0x40)
#define OPT_TRAVERSE_TOP (USE_DESKTOP(option_mask32 & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0))
#define OPT_TRAVERSE_TOP (USE_DESKTOP(opt & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0))
typedef int (*chown_fptr)(const char *, uid_t, gid_t);
static struct bb_uidgid_t ugid = { -1, -1 };
struct param_t {
struct bb_uidgid_t ugid;
chown_fptr chown_func;
};
static int fileAction(const char *fileName, struct stat *statbuf,
void *cf, int depth)
static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf,
void *vparam, int depth UNUSED_PARAM)
{
uid_t u = (ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid;
gid_t g = (ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid;
#define param (*(struct param_t*)vparam)
#define opt option_mask32
uid_t u = (param.ugid.uid == (uid_t)-1) ? statbuf->st_uid : param.ugid.uid;
gid_t g = (param.ugid.gid == (gid_t)-1) ? statbuf->st_gid : param.ugid.gid;
if (!((chown_fptr)cf)(fileName, u, g)) {
if (param.chown_func(fileName, u, g) == 0) {
if (OPT_VERBOSE
|| (OPT_CHANGED && (statbuf->st_uid != u || statbuf->st_gid != g))
) {
@@ -57,28 +62,32 @@ static int fileAction(const char *fileName, struct stat *statbuf,
return TRUE;
}
if (!OPT_QUIET)
bb_perror_msg("%s", fileName); /* A filename can have % in it... */
bb_simple_perror_msg(fileName); /* A filename can have % in it... */
return FALSE;
#undef opt
#undef param
}
int chown_main(int argc, char **argv);
int chown_main(int argc, char **argv)
int chown_main(int argc UNUSED_PARAM, char **argv)
{
int retval = EXIT_SUCCESS;
int flags;
chown_fptr chown_func;
int opt, flags;
struct param_t param;
param.ugid.uid = -1;
param.ugid.gid = -1;
param.chown_func = chown;
opt_complementary = "-2";
getopt32(argv, OPT_STR);
opt = getopt32(argv, OPT_STR);
argv += optind;
/* This matches coreutils behavior (almost - see below) */
chown_func = chown;
if (OPT_NODEREF
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
USE_DESKTOP( || (option_mask32 & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
USE_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
) {
chown_func = lchown;
param.chown_func = lchown;
}
flags = ACTION_DEPTHFIRST; /* match coreutils order */
@@ -89,7 +98,7 @@ int chown_main(int argc, char **argv)
if (OPT_TRAVERSE)
flags |= ACTION_FOLLOWLINKS; /* follow links if -L */
parse_chown_usergroup_or_die(&ugid, argv[0]);
parse_chown_usergroup_or_die(&param.ugid, argv[0]);
/* Ok, ready to do the deed now */
argv++;
@@ -98,7 +107,7 @@ int chown_main(int argc, char **argv)
flags, /* flags */
fileAction, /* file action */
fileAction, /* dir action */
chown_func, /* user data */
&param, /* user data */
0) /* depth */
) {
retval = EXIT_FAILURE;
+2 -4
View File
@@ -11,7 +11,7 @@
#include "libbb.h"
int chroot_main(int argc, char **argv);
int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chroot_main(int argc, char **argv)
{
if (argc < 2) {
@@ -19,9 +19,7 @@ int chroot_main(int argc, char **argv)
}
++argv;
if (chroot(*argv)) {
bb_perror_msg_and_die("cannot change root directory to %s", *argv);
}
xchroot(*argv);
xchdir("/");
++argv;
+22 -20
View File
@@ -8,47 +8,49 @@
#include "libbb.h"
int cksum_main(int argc, char **argv);
int cksum_main(int argc, char **argv)
int cksum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cksum_main(int argc UNUSED_PARAM, char **argv)
{
uint32_t *crc32_table = crc32_filltable(NULL, 1);
FILE *fp;
uint32_t crc;
long length, filesize;
int bytes_read;
char *cp;
uint8_t *cp;
int inp_stdin = (argc == optind) ? 1 : 0;
#if ENABLE_DESKTOP
getopt32(argv, ""); /* coreutils 6.9 compat */
argv += optind;
#else
argv++;
#endif
do {
fp = fopen_or_warn_stdin((inp_stdin) ? bb_msg_standard_input : *++argv);
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
if (fd < 0)
continue;
crc = 0;
length = 0;
#define read_buf bb_common_bufsiz1
while ((bytes_read = fread(read_buf, 1, BUFSIZ, fp)) > 0) {
cp = read_buf;
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
cp = (uint8_t *) read_buf;
length += bytes_read;
while (bytes_read--)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
do {
crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *cp++];
} while (--bytes_read);
}
close(fd);
filesize = length;
for (; length; length >>= 8)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xffL];
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xff];
crc ^= 0xffffffffL;
if (inp_stdin) {
printf("%" PRIu32 " %li\n", crc, filesize);
break;
}
printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
fclose(fp);
} while (*(argv + 1));
printf((*argv ? "%" PRIu32 " %li %s\n" : "%" PRIu32 " %li\n"),
crc, filesize, *argv);
} while (*argv && *++argv);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
Loaded 100 of 902 files, more files were not shown because too many files have changed in this diff. Show more